From d7edcc9d9e3d90e1c53885870461e046389dee96 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 26 Oct 2026 15:33:02 +0100 Subject: ESP working: NPC detection + authoritative server-side health - entitylist slot 6 (GetHighestEntityIndex); class name via GetClientNetworkable -> GetClientClass (replaces the unsafe slot-2 call) - HL2 SP NPCs: class CAI_BaseNPC + m_lifeState, since NPC m_iHealth is not networked; model names from VModelInfoClient006 for labels/friend-foe - real HP/HP-max from the listen-server entity (IVEngineServer021 -> PEntityOfEntIndex -> edict->m_pUnk -> GetBaseEntity) using offsets scanned from server.so's datamap; validated against the client model index - world_to_screen via IVDebugOverlay003::ScreenPosition (fixes box drift) - maxs sanity clamp, NPC-only debug logging, neutral colour for wildlife - build.sh: restore -o libhl2hake.so and add server.cpp --- src/hl2h.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/hl2h.h') diff --git a/src/hl2h.h b/src/hl2h.h index d6a005e..b693617 100644 --- a/src/hl2h.h +++ b/src/hl2h.h @@ -36,7 +36,7 @@ struct Module { return false; } }; -extern Module g_client, g_engine; +extern Module g_client, g_engine, g_server; // --------------------------------------------------------------------------- // game interfaces @@ -48,6 +48,9 @@ struct GameInterfaces { void *client = nullptr; void *entitylist = nullptr; void *engine = nullptr; + void *modelinfo = nullptr; // IVModelInfoClient006 (model index -> model name) + void *engineserver = nullptr; // IVEngineServer021 (edict access, incl. server entities) + void *debugoverlay = nullptr; // IVDebugOverlay003 (engine-accurate world->screen) }; extern GameInterfaces g_iface; @@ -70,9 +73,13 @@ struct NetVars { int viewoffset = -1; int mins = -1; int maxs = -1; + int lifestate = -1; + int modelindex = -1; // ponytail: mins/maxs may be absent from some HL2 netvar tables; esp.cpp falls back to h=72 bool ok() const { return flags >= 0 && velocity >= 0 && movetype >= 0; } - bool esp_ok() const { return ok() && health >= 0 && maxhealth >= 0 && teamnum >= 0 && origin >= 0 && viewoffset >= 0; } + // ponytail: m_iMaxHealth isn't a netvar in HL2 SP; esp.cpp falls back to 100. + // m_iHealth only ever updates for players — NPCs are detected via m_lifeState. + bool esp_ok() const { return ok() && health >= 0 && teamnum >= 0 && origin >= 0 && viewoffset >= 0; } }; extern NetVars g_net; @@ -139,6 +146,10 @@ void fix_verified_crc(int seq, uint32_t crc); uint32_t usercmd_checksum(const CUserCmd *c); bool find_input_global(); void resolve_netvars(); +int class_health_off(const char *name); +bool resolve_server_netvars(); +int server_entity_health(int idx, int *maxhealth, int *lifestate, void **base_out); +int server_model_index(void *base); void find_modules(); void init_conmsg(); bool feature_active(int feature); -- cgit v1.2.3