From b212e8e13835cfdc4849a61c1b57146bd0312a29 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 28 Oct 2026 13:02:26 +0100 Subject: Melee: surface weapon state across maps; reset stale caches - Map transitions often leave a non-crowbar weapon active, so the killbot silently does nothing. Log every active-weapon change as a normal `melee: active ... crowbar=0/1` line and toast once suggesting the crowbar. - Recover the crowbar model from the server entity when the client weapon model index is missing/0 after a map change. - Clear the bone cache and aim/silent locks when the local player entity changes (map load/respawn) so stale entity/model data cannot poison melee target selection. --- src/esp.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/esp.cpp') diff --git a/src/esp.cpp b/src/esp.cpp index 06bafaf..a0d84dd 100644 --- a/src/esp.cpp +++ b/src/esp.cpp @@ -873,6 +873,8 @@ bool melee_weapon_active(void *local_ent) { if (!local_ent) return false; int local = engine_get_local_player(); + if (g_iface.engineserver) + resolve_server_netvars(); auto check = [&](int idx, const char **cls_out, const char **model_out) -> bool { @@ -882,6 +884,14 @@ bool melee_weapon_active(void *local_ent) { void *net = entity_networkable(idx); const char *cls = net ? entity_class_name(net, nullptr) : nullptr; const char *model = wep ? entity_model_name(wep) : nullptr; + // Client weapon models can be missing/0 after a map change; recover the + // server model index so the crowbar is still recognized. + if ((!model || !*model) && g_iface.engineserver) { + void *sbase = nullptr; + server_entity_health(idx, nullptr, nullptr, &sbase); + if (sbase) + model = model_name_from_index(server_model_index(sbase)); + } *cls_out = cls; *model_out = model; return (cls && strstr(cls, "Crowbar")) || @@ -916,8 +926,15 @@ bool melee_weapon_active(void *local_ent) { if (idx != last_idx || crowbar != last_crowbar) { last_idx = idx; last_crowbar = crowbar; - logd("melee: active idx=%d cls=%s model=%s crowbar=%d", idx, + logf("melee: active idx=%d cls=%s model=%s crowbar=%d", idx, cls ? cls : "?", model ? model : "?", (int)crowbar); + if (!crowbar) { + static bool warned = false; + if (!warned) { + warned = true; + toastf(TOAST_WARN, "Melee killbot: equip the crowbar"); + } + } } return crowbar; } -- cgit v1.2.3