]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/hook/sv_hook.qc
Sneak in another feature (simple option to enable ammo in the grappling hook mutator)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / hook / sv_hook.qc
index badb2a6a14165c3c1b9a3ce9cf52f54bf29f097c..5dfdf4386642933e5d98404e5be6914d785c2f0c 100644 (file)
@@ -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);