]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Ammo panel: always show fuel only if hook and jetpack actually consume fuel terencehill/fuel_on_ammo_panel 1345/head
authorterencehill <piuntn@gmail.com>
Wed, 4 Sep 2024 16:15:29 +0000 (18:15 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 4 Sep 2024 16:15:29 +0000 (18:15 +0200)
qcsrc/client/hud/panel/ammo.qc
qcsrc/common/mutators/mutator/hook/sv_hook.qc
qcsrc/common/stats.qh

index 37e3dc45b1dca72da86f0df38a349e4b9f11b019..a7830a5604bf10a7f9b85e50ab7dd23679151c8f 100644 (file)
@@ -165,11 +165,29 @@ void HUD_Ammo()
                total_ammo_count = AMMO_COUNT;
 
        bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_AMMO);
-       bool have_hook = (WepSet_GetFromStat() & WEPSET(HOOK)) != '0 0 0';
+
+       bool show_fuel = false;
+       int have_hook;
+       if (mut_is_active(MUT_GRAPPLING_HOOK))
+       {
+               have_hook = 2; // off-hand hook
+               if (STAT(HOOK_FUEL))
+                       show_fuel = true;
+       }
+       else
+       {
+               have_hook = ((WepSet_GetFromStat() & WEPSET(HOOK)) != '0 0 0') ? 1 : 0;
+               if (have_hook && WEP_CVAR_PRI(WEP_HOOK, ammo))
+                       show_fuel = true;
+       }
+
        bool have_jetpack = boolean(STAT(ITEMS) & IT_JETPACK);
+       if (have_jetpack && STAT(JETPACK_FUEL))
+               show_fuel = true;
+
+       if (!show_fuel)
+               show_fuel = (STAT(FUEL) || infinite_ammo);
 
-       // always show fuel if we have jetpack or off-hand hook
-       bool show_fuel = (STAT(FUEL) || infinite_ammo || have_jetpack || have_hook);
        if (show_fuel)
                ++total_ammo_count;
 
@@ -247,7 +265,7 @@ void HUD_Ammo()
                                if (!show_fuel)
                                        continue;
                                if (!isCurrent)
-                                       isCurrent = have_jetpack; // jetpack can be used anytime
+                                       isCurrent = (have_jetpack || have_hook == 2); // these tools can be used anytime
                        }
 
                        DrawAmmoItem(
index 94379cbb2828410315ee8312c1f42844a32dcdb1..05388908c6ff28044467ec4c59c791c6fcb9cb43 100644 (file)
@@ -3,8 +3,6 @@
 // can't use the autocvar as it doesn't work in the campaign
 //AUTOCVAR(g_grappling_hook, bool, false, "let players spawn with the grappling hook which allows them to pull themselves up");
 #ifdef SVQC
-AUTOCVAR(g_grappling_hook_useammo, bool, false, "Use ammunition with the off-hand grappling hook");
-
 REGISTER_MUTATOR(hook, expr_evaluate(cvar_string("g_grappling_hook"))) {
     MUTATOR_ONADD {
         g_grappling_hook = true;
index 9b4394e45a62f1d0a2851555945521740c7c8e71..3352ed85d394b34dda7c5cc03d6b70060b17e7ae 100644 (file)
@@ -304,6 +304,11 @@ REGISTER_STAT(JETPACK_MAXSPEED_SIDE, float, autocvar_g_jetpack_maxspeed_side)
 REGISTER_STAT(JETPACK_MAXSPEED_UP, float, autocvar_g_jetpack_maxspeed_up)
 REGISTER_STAT(JETPACK_REVERSE_THRUST, float, autocvar_g_jetpack_reverse_thrust)
 
+#ifdef SVQC
+float autocvar_g_grappling_hook_useammo;
+#endif
+REGISTER_STAT(HOOK_FUEL, bool, autocvar_g_grappling_hook_useammo)
+
 REGISTER_STAT(MOVEVARS_HIGHSPEED, float)
 
 #ifdef SVQC