diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 17:34:35 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 17:34:35 +0100 |
| commit | 38c40b7536f6142253a26ba29bedb7a2b2039c12 (patch) | |
| tree | fd4262c59edc8f154c4374ef55b0e38dadefd166 | |
| parent | Items: read ammo and inventory from the server arrays (diff) | |
| download | hl2h-38c40b7536f6142253a26ba29bedb7a2b2039c12.tar.gz hl2h-38c40b7536f6142253a26ba29bedb7a2b2039c12.zip | |
Items/projectiles: ammo diagnostics, dispensers, launched RPG
- Exempt chargers and ammo/supply crates from the fullness filter; reusable
dispensers stay visible at max ammo/health.
- Log the local ammo current/max table once and the first 24 ammo filter
decisions, so the RPG/grenade/weapon cases can be diagnosed.
- Classify the launched w_missile as an RPG projectile (class not item/
weapon) and exclude the w_missile_closed ammo pickup from projectile ESP.
| -rw-r--r-- | src/esp.cpp | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/src/esp.cpp b/src/esp.cpp index b4d3eee..a12cf9c 100644 --- a/src/esp.cpp +++ b/src/esp.cpp | |||
| @@ -2796,11 +2796,32 @@ void esp_draw_items() { | |||
| 2796 | if (g_item_usable) | 2796 | if (g_item_usable) |
| 2797 | local_vitals(vit_hp, vit_max, vit_armor); | 2797 | local_vitals(vit_hp, vit_max, vit_armor); |
| 2798 | 2798 | ||
| 2799 | static bool ammo_logged = false; | ||
| 2800 | if (!ammo_logged) { | ||
| 2801 | ammo_logged = true; | ||
| 2802 | void *le = entitylist_get(local); | ||
| 2803 | char buf[512] = {}; | ||
| 2804 | int used = 0; | ||
| 2805 | for (int t = 0; t < 12 && used < (int)sizeof(buf) - 24; t++) { | ||
| 2806 | int w = snprintf(buf + used, sizeof(buf) - (size_t)used, "%d=%d/%d ", t, | ||
| 2807 | local_ammo(le, t), ammo_max(t)); | ||
| 2808 | if (w < 0) | ||
| 2809 | break; | ||
| 2810 | used += w; | ||
| 2811 | } | ||
| 2812 | logf("items: ammo current/max %s(usable=%d my_weapons=%d ammo=%d)", buf, | ||
| 2813 | (int)g_item_usable, g_net.my_weapons, g_net.ammo); | ||
| 2814 | } | ||
| 2815 | |||
| 2799 | for (int i = 0; i < g_nitems; i++) { | 2816 | for (int i = 0; i < g_nitems; i++) { |
| 2800 | const ItemTarget &t = g_item_targets[i]; | 2817 | const ItemTarget &t = g_item_targets[i]; |
| 2801 | if (!item_kind_enabled(t.kind)) | 2818 | if (!item_kind_enabled(t.kind)) |
| 2802 | continue; | 2819 | continue; |
| 2803 | if (g_item_usable) { | 2820 | // Dispensers (chargers, ammo crates, supply crates) stay useful after a |
| 2821 | // refill, so the fullness filter does not apply to them. | ||
| 2822 | bool dispenser = strcasestr(t.label, "crate") || | ||
| 2823 | strcasestr(t.label, "charger"); | ||
| 2824 | if (g_item_usable && !dispenser) { | ||
| 2804 | if (t.kind == IK_HEALTH && vit_hp >= 0 && vit_max > 0 && | 2825 | if (t.kind == IK_HEALTH && vit_hp >= 0 && vit_max > 0 && |
| 2805 | vit_hp >= vit_max) | 2826 | vit_hp >= vit_max) |
| 2806 | continue; | 2827 | continue; |
| @@ -2809,6 +2830,12 @@ void esp_draw_items() { | |||
| 2809 | if (t.kind == IK_AMMO && t.ammo_type >= 0) { | 2830 | if (t.kind == IK_AMMO && t.ammo_type >= 0) { |
| 2810 | int maxa = ammo_max(t.ammo_type); | 2831 | int maxa = ammo_max(t.ammo_type); |
| 2811 | int cura = local_ammo(entitylist_get(local), t.ammo_type); | 2832 | int cura = local_ammo(entitylist_get(local), t.ammo_type); |
| 2833 | static int flt_logs = 0; | ||
| 2834 | if (flt_logs < 24) { | ||
| 2835 | flt_logs++; | ||
| 2836 | logf("items: ammo %s type=%d cur=%d max=%d", t.label, t.ammo_type, | ||
| 2837 | cura, maxa); | ||
| 2838 | } | ||
| 2812 | if (maxa > 0 && cura >= 0 && cura >= maxa) | 2839 | if (maxa > 0 && cura >= 0 && cura >= maxa) |
| 2813 | continue; | 2840 | continue; |
| 2814 | } | 2841 | } |
| @@ -2946,16 +2973,17 @@ static void projs_collect(int local_idx) { | |||
| 2946 | bool owned = item_weapon_is_owned(ent); | 2973 | bool owned = item_weapon_is_owned(ent); |
| 2947 | bool frag_cls = cls && strcasestr(cls, "grenade") && | 2974 | bool frag_cls = cls && strcasestr(cls, "grenade") && |
| 2948 | !strcasestr(cls, "weapon"); | 2975 | !strcasestr(cls, "weapon"); |
| 2949 | bool missile_cls = cls && strcasestr(cls, "missile") && | 2976 | bool item_cls = cls && (strcasestr(cls, "item") || |
| 2950 | !strcasestr(cls, "weapon"); | 2977 | strcasestr(cls, "weapon")); |
| 2978 | bool missile_model = strcasestr(model, "w_missile") && | ||
| 2979 | !strcasestr(model, "missile_closed"); | ||
| 2951 | int kind; | 2980 | int kind; |
| 2952 | if (strcasestr(model, "w_grenade") && | 2981 | if (strcasestr(model, "w_grenade") && |
| 2953 | (frag_cls || (!cls && owned))) { | 2982 | (frag_cls || (!cls && owned))) { |
| 2954 | kind = PK_FRAG; | 2983 | kind = PK_FRAG; |
| 2955 | } else if ((strcasestr(model, "w_missile") || | 2984 | } else if ((missile_model || strcasestr(model, "missile_launch")) && |
| 2956 | strcasestr(model, "missile_launch") || | 2985 | !item_cls) { |
| 2957 | strcasestr(model, "missile_closed")) && | 2986 | // Launched RPG rocket; ammo pickups/weapons use the same model family. |
| 2958 | (missile_cls || (!cls && owned))) { | ||
| 2959 | kind = PK_RPG; | 2987 | kind = PK_RPG; |
| 2960 | } else if (strcasestr(model, "helicopter_bomb")) { | 2988 | } else if (strcasestr(model, "helicopter_bomb")) { |
| 2961 | kind = PK_BOMB; | 2989 | kind = PK_BOMB; |
