summaryrefslogtreecommitdiffstats
path: root/src/esp.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/esp.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/esp.cpp b/src/esp.cpp
index 2c033ea..e6981f7 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -516,6 +516,59 @@ bool aimbot_apply(CUserCmd *cmd) {
516 return true; 516 return true;
517} 517}
518 518
519bool triggerbot_apply(CUserCmd *cmd) {
520 if (!g_iface.enginetrace || !g_iface.entitylist)
521 return false;
522 int local = engine_get_local_player();
523 if (local <= 0)
524 return false;
525 void *local_ent = entitylist_get(local);
526 if (!local_ent)
527 return false;
528 if (g_net.health >= 0 &&
529 *(int *)((uintptr_t)local_ent + g_net.health) <= 0)
530 return false;
531
532 QAngle view{cmd->viewangles[0], cmd->viewangles[1], 0.0f};
533 Vector fwd = angle_forward_vector(view);
534 Vector start = g_cam_eye;
535 Vector end{start.x + fwd.x * 8192.0f, start.y + fwd.y * 8192.0f,
536 start.z + fwd.z * 8192.0f};
537 void *hit = trace_entity(start, end, local_ent);
538 if (!hit)
539 return false;
540
541 using Fn = int (*)(void *);
542 int hi = vfunc<Fn>(g_iface.entitylist, 6)(g_iface.entitylist);
543 if (hi < 0 || hi > 4096)
544 hi = 4096;
545 for (int idx = 1; idx <= hi; idx++) {
546 if (entitylist_get(idx) != hit)
547 continue;
548 void *net = entity_networkable(idx);
549 const char *cls = net ? entity_class_name(net, nullptr) : nullptr;
550 if (!cls || !is_npc_class(cls))
551 return false;
552 uintptr_t e = (uintptr_t)hit;
553 int life = g_net.lifestate >= 0
554 ? (int)*(unsigned char *)(e + g_net.lifestate)
555 : -1;
556 if (life != LIFE_ALIVE)
557 return false;
558 const char *model = entity_model_name(hit);
559 if (model_is_friendly(model) || model_is_neutral(model))
560 return false;
561 cmd->buttons |= IN_ATTACK;
562 static int logs = 0;
563 if (logs < 5) {
564 logs++;
565 logf("triggerbot: fire idx=%d model=%s", idx, model ? model : "?");
566 }
567 return true;
568 }
569 return false;
570}
571
519void esp_draw() { 572void esp_draw() {
520 if (!g_surface || !g_iface.entitylist || !g_net.esp_ok()) return; 573 if (!g_surface || !g_iface.entitylist || !g_net.esp_ok()) return;
521 if (!g_scr_w) { 574 if (!g_scr_w) {