]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Hook: infinite ammo in mutator
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 6 Oct 2015 01:28:32 +0000 (12:28 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 6 Oct 2015 01:28:32 +0000 (12:28 +1100)
qcsrc/common/weapons/weapon/hook.qc
qcsrc/server/mutators/mutator_hook.qc

index e279b798a98489bd47a8b0de58364f849fef9fd8..bc79a88a313db91961d254bbb1765966ce384f31 100644 (file)
@@ -14,6 +14,7 @@ CLASS(Hook, Weapon)
 /* wepimg    */ ATTRIB(Hook, model2, string, "weaponhook");
 /* refname   */ ATTRIB(Hook, netname, string, "hook");
 /* wepname   */ ATTRIB(Hook, message, string, _("Grappling Hook"));
+       ATTRIB(Hook, ammo_factor, float, 1)
 ENDCLASS(Hook)
 REGISTER_WEAPON(HOOK, NEW(Hook));
 
@@ -181,7 +182,7 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
                                if(time > actor.hook_refire)
                                if(weapon_prepareattack(thiswep, actor, false, -1))
                                {
-                                       W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hook, ammo));
+                                       W_DecreaseAmmo(thiswep, actor, thiswep.ammo_factor * WEP_CVAR_PRI(hook, ammo));
                                        actor.hook_state |= HOOK_FIRING;
                                        actor.hook_state |= HOOK_WAITING_FOR_RELEASE;
                                        weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready);
@@ -219,7 +220,7 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
                                                actor.hook_state |= HOOK_REMOVING;
                                }
 
-                               float hooked_fuel = WEP_CVAR_PRI(hook, hooked_ammo);
+                               float hooked_fuel = thiswep.ammo_factor * WEP_CVAR_PRI(hook, hooked_ammo);
                                if(hooked_fuel > 0)
                                {
                                        if( time > actor.hook_time_fueldecrease )
@@ -273,14 +274,15 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
                {
                        self.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
                }
-               METHOD(Hook, wr_checkammo1, bool(entity thiswep))
+               METHOD(Hook, wr_checkammo1, bool(Hook thiswep))
                {
+                       if (!thiswep.ammo_factor) return true;
                        if(self.hook)
                                return self.ammo_fuel > 0;
                        else
                                return self.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
                }
-               METHOD(Hook, wr_checkammo2, bool(entity thiswep))
+               METHOD(Hook, wr_checkammo2, bool(Hook thiswep))
                {
                        // infinite ammo for now
                        return true; // self.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
index bfbe02ea699af95787a68e8a1b5de67e75fdb9ae..e43848b30840dee280aa100385e1ba7d95ec130d 100644 (file)
@@ -3,9 +3,11 @@ AUTOCVAR(g_grappling_hook, bool, false, _("let players spawn with the grappling
 REGISTER_MUTATOR(hook, autocvar_g_grappling_hook) {
     MUTATOR_ONADD {
         g_grappling_hook = true;
+        WEP_HOOK.ammo_factor = 0;
     }
     MUTATOR_ONROLLBACK_OR_REMOVE {
         g_grappling_hook = false;
+        WEP_HOOK.ammo_factor = 1;
     }
 }
 
@@ -35,10 +37,4 @@ MUTATOR_HOOKFUNCTION(hook, FilterItem)
     return self.weapon == WEP_HOOK.m_id;
 }
 
-MUTATOR_HOOKFUNCTION(hook, SetStartItems)
-{
-    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"));
-}
 #endif