From 8cd46c16e0d72211fc8cb4cbc456e980736b49b9 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 7 Mar 2017 05:41:43 +1000 Subject: [PATCH] Sneak in another feature (simple option to enable ammo in the grappling hook mutator) --- defaultXonotic.cfg | 1 + qcsrc/common/mutators/mutator/hook/sv_hook.qc | 18 ++++++++++++++++-- .../mutators/mutator/instagib/sv_instagib.qc | 2 +- qcsrc/common/weapons/weapon/hook.qc | 3 ++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index f27c5dd670..e39c7887df 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -478,6 +478,7 @@ set g_playerclip_collisions 1 "0 = disable collision testing against playerclips set g_botclip_collisions 1 "0 = disable collision testing against botclips, might be useful on some defrag maps" set g_grappling_hook 0 "let players spawn with the grappling hook which allows them to pull themselves up" +set g_grappling_hook_useammo 0 "use ammunition with the off-hand grappling hook" set g_spawn_alloweffects 1 "allow clients to enable spawn point and event effects such as particles and sounds, see cl_spawn_ cvars for more info" set g_spawn_furthest 0.5 "this amount of the spawns shall be far away from any players" diff --git a/qcsrc/common/mutators/mutator/hook/sv_hook.qc b/qcsrc/common/mutators/mutator/hook/sv_hook.qc index badb2a6a14..5dfdf43866 100644 --- a/qcsrc/common/mutators/mutator/hook/sv_hook.qc +++ b/qcsrc/common/mutators/mutator/hook/sv_hook.qc @@ -3,14 +3,18 @@ // 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, cvar("g_grappling_hook")) { MUTATOR_ONADD { g_grappling_hook = true; - WEP_HOOK.ammo_factor = 0; + if(!autocvar_g_grappling_hook_useammo) + WEP_HOOK.ammo_factor = 0; } MUTATOR_ONROLLBACK_OR_REMOVE { g_grappling_hook = false; - WEP_HOOK.ammo_factor = 1; + if(!autocvar_g_grappling_hook_useammo) + WEP_HOOK.ammo_factor = 1; // we don't need to change it } return false; @@ -31,6 +35,16 @@ MUTATOR_HOOKFUNCTION(hook, BuildGameplayTipsString) M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3grappling hook^8 is enabled, press 'e' to use it\n"); } +MUTATOR_HOOKFUNCTION(hook, SetStartItems) +{ + if(autocvar_g_grappling_hook_useammo) + { + start_items |= ITEM_JetpackRegen.m_itemid; + start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable")); + warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable")); + } +} + MUTATOR_HOOKFUNCTION(hook, PlayerSpawn) { entity player = M_ARGV(0, entity); diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index eab41c5865..578294a725 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -353,7 +353,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, SetStartItems) start_ammo_cells = warmup_start_ammo_cells = cvar("g_instagib_ammo_start"); start_ammo_plasma = warmup_start_ammo_plasma = 0; start_ammo_rockets = warmup_start_ammo_rockets = 0; - start_ammo_fuel = warmup_start_ammo_fuel = 0; + //start_ammo_fuel = warmup_start_ammo_fuel = 0; start_weapons = warmup_start_weapons = WEPSET(VAPORIZER); start_items |= IT_UNLIMITED_SUPERWEAPONS; diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 1eea1dfd58..26c04ad4fa 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -252,7 +252,8 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { actor.ammo_fuel = 0; actor.(weaponentity).hook_state |= HOOK_REMOVING; - W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); + if(actor.(weaponentity).m_weapon != WEP_Null) // offhand + W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); } } } -- 2.39.2