summaryrefslogtreecommitdiffstats
path: root/src/esp.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-04 23:32:00 +0100
committersalmonik <salmonik@tuta.io>2026-11-04 23:32:00 +0100
commit80a287910f3f77519c8243ba5f53d9c877fbddcb (patch)
tree761c4b0ca3ab857cd57a886dd6e9c4048bca950d /src/esp.cpp
parentAdd grenade trajectory, RPG armour priority, empty chargers, mega gravity gun (diff)
downloadhl2h-80a287910f3f77519c8243ba5f53d9c877fbddcb.tar.gz
hl2h-80a287910f3f77519c8243ba5f53d9c877fbddcb.zip
Charger juice: resolve per-class offsets
CWallHealth derives CBaseToggle and CNewRecharge derives CBaseAnimating, so m_iJuice is at different offsets (0x3c8 and 0x47c here). Collect every m_iJuice datamap match, derive the suit offset from m_iMaxJuice-20, and pick by the server class name. Also detect health brushes via wallhealth/recharge rather than the ESP label. Verified the offsets resolve distinctly on :99.
Diffstat (limited to '')
-rw-r--r--src/esp.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/esp.cpp b/src/esp.cpp
index 594a8fa..dbe0051 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -2655,6 +2655,16 @@ static bool item_kind_enabled(int kind) {
2655 } 2655 }
2656} 2656}
2657 2657
2658// Health chargers are brushes (func_healthcharger/CWallHealth) and suit
2659// chargers are item_suitcharger/CNewRecharge. Both expose m_iJuice.
2660static bool item_is_charger(const char *model, const char *cls) {
2661 return item_icontains(model, "charger") ||
2662 item_icontains(model, "suit_charger") ||
2663 item_icontains(cls, "charger") ||
2664 item_icontains(cls, "wallhealth") ||
2665 item_icontains(cls, "recharge");
2666}
2667
2658static void items_collect(int local_idx) { 2668static void items_collect(int local_idx) {
2659 static double last_scan = 0.0; 2669 static double last_scan = 0.0;
2660 double now = esp_now(); 2670 double now = esp_now();
@@ -2784,7 +2794,7 @@ static void items_collect(int local_idx) {
2784 // Health/suit chargers are dispensers that stay useful after a refill, but 2794 // Health/suit chargers are dispensers that stay useful after a refill, but
2785 // an empty one cannot give anything. m_iJuice is 0 when depleted (until it 2795 // an empty one cannot give anything. m_iJuice is 0 when depleted (until it
2786 // recharges); only hide the tag once the server value is readable. 2796 // recharges); only hide the tag once the server value is readable.
2787 if (strcasestr(label, "charger") && server_item_juice(idx) == 0) 2797 if (item_is_charger(model, cls) && server_item_juice(idx) == 0)
2788 continue; 2798 continue;
2789 2799
2790 Vector origin{*(float *)((uintptr_t)ent + g_net.origin), 2800 Vector origin{*(float *)((uintptr_t)ent + g_net.origin),