diff options
Diffstat (limited to 'src/esp.cpp')
| -rw-r--r-- | src/esp.cpp | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/src/esp.cpp b/src/esp.cpp index 7c3f1bc..0966ff5 100644 --- a/src/esp.cpp +++ b/src/esp.cpp | |||
| @@ -148,6 +148,34 @@ static bool model_is_neutral(const char *m) { | |||
| 148 | return false; | 148 | return false; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | static bool npc_is_friendly(int idx, const char *model, int local_idx, | ||
| 152 | bool &neutral) { | ||
| 153 | int rel = server_npc_relation(idx, local_idx); | ||
| 154 | if (rel == 3) { // D_LI | ||
| 155 | neutral = false; | ||
| 156 | return true; | ||
| 157 | } | ||
| 158 | if (rel == 4) { // D_NU | ||
| 159 | neutral = true; | ||
| 160 | return false; | ||
| 161 | } | ||
| 162 | if (rel == 1 || rel == 2) { // D_HT / D_FR | ||
| 163 | neutral = false; | ||
| 164 | return false; | ||
| 165 | } | ||
| 166 | // Bugbait-controlled antlions follow a target even when their default | ||
| 167 | // relationship was never rewritten. | ||
| 168 | if (model && strstr(model, "antlion") && | ||
| 169 | server_npc_has_follow_target(idx)) { | ||
| 170 | neutral = false; | ||
| 171 | return true; | ||
| 172 | } | ||
| 173 | bool friendly = model_is_friendly(model); | ||
| 174 | neutral = model_is_neutral(model); | ||
| 175 | return friendly; | ||
| 176 | } | ||
| 177 | |||
| 178 | |||
| 151 | static void short_name(const char *model, char *out, size_t outn) { | 179 | static void short_name(const char *model, char *out, size_t outn) { |
| 152 | if (!model) { snprintf(out, outn, "NPC"); return; } | 180 | if (!model) { snprintf(out, outn, "NPC"); return; } |
| 153 | const char *base = strrchr(model, '/'); | 181 | const char *base = strrchr(model, '/'); |
| @@ -259,8 +287,9 @@ static void esp_collect(int local_idx) { | |||
| 259 | t.health = hp > 0 ? (float)hp : 0.0f; | 287 | t.health = hp > 0 ? (float)hp : 0.0f; |
| 260 | t.maxhealth = maxhp > 0 ? (float)maxhp : 100.0f; | 288 | t.maxhealth = maxhp > 0 ? (float)maxhp : 100.0f; |
| 261 | t.show_health = hp > 0; | 289 | t.show_health = hp > 0; |
| 262 | t.friendly = model_is_friendly(model); | 290 | bool neutral = false; |
| 263 | t.neutral = model_is_neutral(model); | 291 | t.friendly = npc_is_friendly(idx, model, local_idx, neutral); |
| 292 | t.neutral = neutral; | ||
| 264 | short_name(model, t.name, sizeof(t.name)); | 293 | short_name(model, t.name, sizeof(t.name)); |
| 265 | if (npc && !model) snprintf(t.name, sizeof(t.name), "NPC"); | 294 | if (npc && !model) snprintf(t.name, sizeof(t.name), "NPC"); |
| 266 | } | 295 | } |
| @@ -527,7 +556,8 @@ static bool select_aim_target(const QAngle &view, unsigned bone_mask, | |||
| 527 | if (life != LIFE_ALIVE) | 556 | if (life != LIFE_ALIVE) |
| 528 | return false; | 557 | return false; |
| 529 | const char *model = entity_model_name(ent); | 558 | const char *model = entity_model_name(ent); |
| 530 | if (model_is_friendly(model) || model_is_neutral(model)) | 559 | bool neutral = false; |
| 560 | if (npc_is_friendly(idx, model, local, neutral) || neutral) | ||
| 531 | return false; | 561 | return false; |
| 532 | if (!bones_update(idx, ent)) | 562 | if (!bones_update(idx, ent)) |
| 533 | return false; | 563 | return false; |
| @@ -605,7 +635,8 @@ static bool select_aim_target(const QAngle &view, unsigned bone_mask, | |||
| 605 | if (life != LIFE_ALIVE) | 635 | if (life != LIFE_ALIVE) |
| 606 | continue; | 636 | continue; |
| 607 | const char *model = entity_model_name(ent); | 637 | const char *model = entity_model_name(ent); |
| 608 | if (model_is_friendly(model) || model_is_neutral(model)) | 638 | bool neutral = false; |
| 639 | if (npc_is_friendly(idx, model, local, neutral) || neutral) | ||
| 609 | continue; | 640 | continue; |
| 610 | 641 | ||
| 611 | float maxz = g_net.maxs >= 0 ? *(float *)(e + g_net.maxs + 8) : 72.0f; | 642 | float maxz = g_net.maxs >= 0 ? *(float *)(e + g_net.maxs + 8) : 72.0f; |
| @@ -990,7 +1021,8 @@ bool melee_aimbot_apply(CUserCmd *cmd) { | |||
| 990 | if (life != LIFE_ALIVE) | 1021 | if (life != LIFE_ALIVE) |
| 991 | continue; | 1022 | continue; |
| 992 | const char *model = entity_model_name(ent); | 1023 | const char *model = entity_model_name(ent); |
| 993 | if (model_is_friendly(model) || model_is_neutral(model)) | 1024 | bool neutral = false; |
| 1025 | if (npc_is_friendly(idx, model, local, neutral) || neutral) | ||
| 994 | continue; | 1026 | continue; |
| 995 | 1027 | ||
| 996 | Vector origin{*(float *)(e + g_net.origin), | 1028 | Vector origin{*(float *)(e + g_net.origin), |
| @@ -1320,7 +1352,8 @@ bool triggerbot_apply(CUserCmd *cmd) { | |||
| 1320 | if (life != LIFE_ALIVE) | 1352 | if (life != LIFE_ALIVE) |
| 1321 | return false; | 1353 | return false; |
| 1322 | const char *model = entity_model_name(hit); | 1354 | const char *model = entity_model_name(hit); |
| 1323 | if (model_is_friendly(model) || model_is_neutral(model)) | 1355 | bool neutral = false; |
| 1356 | if (npc_is_friendly(idx, model, local, neutral) || neutral) | ||
| 1324 | return false; | 1357 | return false; |
| 1325 | cmd->buttons |= IN_ATTACK; | 1358 | cmd->buttons |= IN_ATTACK; |
| 1326 | static int logs = 0; | 1359 | static int logs = 0; |
