diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-26 15:33:02 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-26 15:33:02 +0100 |
| commit | d7edcc9d9e3d90e1c53885870461e046389dee96 (patch) | |
| tree | d4e80c026f65cbff9804c80184293d0c1b63afa8 /src/hl2h.h | |
| parent | Default map d1_town_01 (intro-less, enemies spawned) (diff) | |
| download | hl2h-d7edcc9d9e3d90e1c53885870461e046389dee96.tar.gz hl2h-d7edcc9d9e3d90e1c53885870461e046389dee96.zip | |
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
Diffstat (limited to 'src/hl2h.h')
| -rw-r--r-- | src/hl2h.h | 15 |
1 files changed, 13 insertions, 2 deletions
| @@ -36,7 +36,7 @@ struct Module { | |||
| 36 | return false; | 36 | return false; |
| 37 | } | 37 | } |
| 38 | }; | 38 | }; |
| 39 | extern Module g_client, g_engine; | 39 | extern Module g_client, g_engine, g_server; |
| 40 | 40 | ||
| 41 | // --------------------------------------------------------------------------- | 41 | // --------------------------------------------------------------------------- |
| 42 | // game interfaces | 42 | // game interfaces |
| @@ -48,6 +48,9 @@ struct GameInterfaces { | |||
| 48 | void *client = nullptr; | 48 | void *client = nullptr; |
| 49 | void *entitylist = nullptr; | 49 | void *entitylist = nullptr; |
| 50 | void *engine = nullptr; | 50 | void *engine = nullptr; |
| 51 | void *modelinfo = nullptr; // IVModelInfoClient006 (model index -> model name) | ||
| 52 | void *engineserver = nullptr; // IVEngineServer021 (edict access, incl. server entities) | ||
| 53 | void *debugoverlay = nullptr; // IVDebugOverlay003 (engine-accurate world->screen) | ||
| 51 | }; | 54 | }; |
| 52 | extern GameInterfaces g_iface; | 55 | extern GameInterfaces g_iface; |
| 53 | 56 | ||
| @@ -70,9 +73,13 @@ struct NetVars { | |||
| 70 | int viewoffset = -1; | 73 | int viewoffset = -1; |
| 71 | int mins = -1; | 74 | int mins = -1; |
| 72 | int maxs = -1; | 75 | int maxs = -1; |
| 76 | int lifestate = -1; | ||
| 77 | int modelindex = -1; | ||
| 73 | // ponytail: mins/maxs may be absent from some HL2 netvar tables; esp.cpp falls back to h=72 | 78 | // ponytail: mins/maxs may be absent from some HL2 netvar tables; esp.cpp falls back to h=72 |
| 74 | bool ok() const { return flags >= 0 && velocity >= 0 && movetype >= 0; } | 79 | bool ok() const { return flags >= 0 && velocity >= 0 && movetype >= 0; } |
| 75 | bool esp_ok() const { return ok() && health >= 0 && maxhealth >= 0 && teamnum >= 0 && origin >= 0 && viewoffset >= 0; } | 80 | // ponytail: m_iMaxHealth isn't a netvar in HL2 SP; esp.cpp falls back to 100. |
| 81 | // m_iHealth only ever updates for players — NPCs are detected via m_lifeState. | ||
| 82 | bool esp_ok() const { return ok() && health >= 0 && teamnum >= 0 && origin >= 0 && viewoffset >= 0; } | ||
| 76 | }; | 83 | }; |
| 77 | extern NetVars g_net; | 84 | extern NetVars g_net; |
| 78 | 85 | ||
| @@ -139,6 +146,10 @@ void fix_verified_crc(int seq, uint32_t crc); | |||
| 139 | uint32_t usercmd_checksum(const CUserCmd *c); | 146 | uint32_t usercmd_checksum(const CUserCmd *c); |
| 140 | bool find_input_global(); | 147 | bool find_input_global(); |
| 141 | void resolve_netvars(); | 148 | void resolve_netvars(); |
| 149 | int class_health_off(const char *name); | ||
| 150 | bool resolve_server_netvars(); | ||
| 151 | int server_entity_health(int idx, int *maxhealth, int *lifestate, void **base_out); | ||
| 152 | int server_model_index(void *base); | ||
| 142 | void find_modules(); | 153 | void find_modules(); |
| 143 | void init_conmsg(); | 154 | void init_conmsg(); |
| 144 | bool feature_active(int feature); | 155 | bool feature_active(int feature); |
