From: terencehill Date: Wed, 4 Sep 2024 16:15:29 +0000 (+0200) Subject: Ammo panel: always show fuel only if hook and jetpack actually consume fuel X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fmerge-requests%2F1345%2Fhead;p=xonotic%2Fxonotic-data.pk3dir.git Ammo panel: always show fuel only if hook and jetpack actually consume fuel --- diff --git a/qcsrc/client/hud/panel/ammo.qc b/qcsrc/client/hud/panel/ammo.qc index 37e3dc45b..a7830a560 100644 --- a/qcsrc/client/hud/panel/ammo.qc +++ b/qcsrc/client/hud/panel/ammo.qc @@ -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( diff --git a/qcsrc/common/mutators/mutator/hook/sv_hook.qc b/qcsrc/common/mutators/mutator/hook/sv_hook.qc index 94379cbb2..05388908c 100644 --- a/qcsrc/common/mutators/mutator/hook/sv_hook.qc +++ b/qcsrc/common/mutators/mutator/hook/sv_hook.qc @@ -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; diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 9b4394e45..3352ed85d 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -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