From: TimePath Date: Tue, 6 Oct 2015 01:28:32 +0000 (+1100) Subject: Hook: infinite ammo in mutator X-Git-Tag: xonotic-v0.8.2~1874^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=65f750b860e32f02cdc60a12e6d90d8782ba2bc9;p=xonotic%2Fxonotic-data.pk3dir.git Hook: infinite ammo in mutator --- diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index e279b798a..bc79a88a3 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -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 diff --git a/qcsrc/server/mutators/mutator_hook.qc b/qcsrc/server/mutators/mutator_hook.qc index bfbe02ea6..e43848b30 100644 --- a/qcsrc/server/mutators/mutator_hook.qc +++ b/qcsrc/server/mutators/mutator_hook.qc @@ -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