From 6a639f6000af2086c578c64cf1caffc06778350b Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 29 Sep 2015 12:03:08 +1000 Subject: [PATCH] Offhand: fix ammo consumption --- qcsrc/common/weapons/weapon/crylink.qc | 12 +++++----- qcsrc/common/weapons/weapon/devastator.qc | 6 ++--- qcsrc/common/weapons/weapon/electro.qc | 14 ++++++------ qcsrc/common/weapons/weapon/hagar.qc | 22 +++++++++--------- qcsrc/common/weapons/weapon/hlac.qc | 14 ++++++------ qcsrc/common/weapons/weapon/hmg.qc | 2 +- qcsrc/common/weapons/weapon/hook.qc | 10 ++++---- qcsrc/common/weapons/weapon/machinegun.qc | 16 ++++++------- qcsrc/common/weapons/weapon/minelayer.qc | 6 ++--- qcsrc/common/weapons/weapon/mortar.qc | 12 +++++----- qcsrc/common/weapons/weapon/rifle.qc | 8 +++---- qcsrc/common/weapons/weapon/rpc.qc | 6 ++--- qcsrc/common/weapons/weapon/seeker.qc | 28 +++++++++++------------ qcsrc/common/weapons/weapon/shotgun.qc | 12 +++++----- qcsrc/common/weapons/weapon/vaporizer.qc | 8 +++---- qcsrc/common/weapons/weapon/vortex.qc | 8 +++---- qcsrc/server/weapons/selection.qc | 4 ++-- qcsrc/server/weapons/weaponsystem.qc | 3 +-- qcsrc/server/weapons/weaponsystem.qh | 2 +- 19 files changed, 96 insertions(+), 97 deletions(-) diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 902bcab49..b4955ef60 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -341,7 +341,7 @@ void W_Crylink_Fadethink(void) remove(self); } -void W_Crylink_Attack(void) +void W_Crylink_Attack(Weapon thiswep) {SELFPARAM(); float counter, shots; entity proj, prevproj, firstproj; @@ -349,7 +349,7 @@ void W_Crylink_Attack(void) vector forward, right, up; float maxdmg; - W_DecreaseAmmo(WEP_CVAR_PRI(crylink, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(crylink, ammo)); maxdmg = WEP_CVAR_PRI(crylink, damage) * WEP_CVAR_PRI(crylink, shots); maxdmg *= 1 + WEP_CVAR_PRI(crylink, bouncedamagefactor) * WEP_CVAR_PRI(crylink, bounces); @@ -450,7 +450,7 @@ void W_Crylink_Attack(void) } } -void W_Crylink_Attack2(void) +void W_Crylink_Attack2(Weapon thiswep) {SELFPARAM(); float counter, shots; entity proj, prevproj, firstproj; @@ -458,7 +458,7 @@ void W_Crylink_Attack2(void) vector forward, right, up; float maxdmg; - W_DecreaseAmmo(WEP_CVAR_SEC(crylink, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(crylink, ammo)); maxdmg = WEP_CVAR_SEC(crylink, damage) * WEP_CVAR_SEC(crylink, shots); maxdmg *= 1 + WEP_CVAR_SEC(crylink, bouncedamagefactor) * WEP_CVAR_SEC(crylink, bounces); @@ -587,7 +587,7 @@ void W_Crylink_Attack2(void) if(self.crylink_waitrelease != 1) if(weapon_prepareattack(0, WEP_CVAR_PRI(crylink, refire))) { - W_Crylink_Attack(); + W_Crylink_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready); } } @@ -597,7 +597,7 @@ void W_Crylink_Attack2(void) if(self.crylink_waitrelease != 2) if(weapon_prepareattack(1, WEP_CVAR_SEC(crylink, refire))) { - W_Crylink_Attack2(); + W_Crylink_Attack2(thiswep); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index c52693a65..cfa94a2db 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -337,12 +337,12 @@ void W_Devastator_Damage(entity inflictor, entity attacker, float damage, int de W_PrepareExplosionByDamage(attacker, W_Devastator_Explode); } -void W_Devastator_Attack(void) +void W_Devastator_Attack(Weapon thiswep) {SELFPARAM(); entity missile; entity flash; - W_DecreaseAmmo(WEP_CVAR(devastator, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(devastator, ammo)); W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 5, SND(ROCKET_FIRE), CH_WEAPON_A, WEP_CVAR(devastator, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -533,7 +533,7 @@ void W_Devastator_Attack(void) if(self.rl_release || WEP_CVAR(devastator, guidestop)) if(weapon_prepareattack(0, WEP_CVAR(devastator, refire))) { - W_Devastator_Attack(); + W_Devastator_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready); self.rl_release = 0; } diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 5a23f8849..dbcbb76b9 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -245,11 +245,11 @@ void W_Electro_Bolt_Think(void) else { self.nextthink = self.ltime; } } -void W_Electro_Attack_Bolt(void) +void W_Electro_Attack_Bolt(Weapon thiswep) {SELFPARAM(); entity proj; - W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(electro, ammo)); W_SetupShot_ProjectileSize( self, @@ -345,9 +345,9 @@ void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int d } } -void W_Electro_Attack_Orb(void) +void W_Electro_Attack_Orb(Weapon thiswep) {SELFPARAM(); - W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(electro, ammo)); W_SetupShot_ProjectileSize( self, @@ -412,7 +412,7 @@ void W_Electro_CheckAttack(void) if(self.BUTTON_ATCK2) if(weapon_prepareattack(1, -1)) { - W_Electro_Attack_Orb(); + W_Electro_Attack_Orb(WEP_ELECTRO); self.electro_count -= 1; weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); return; @@ -476,7 +476,7 @@ void W_Electro_CheckAttack(void) { if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire))) { - W_Electro_Attack_Bolt(); + W_Electro_Attack_Bolt(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } } @@ -485,7 +485,7 @@ void W_Electro_CheckAttack(void) if(time >= self.electro_secondarytime) if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire))) { - W_Electro_Attack_Orb(); + W_Electro_Attack_Orb(thiswep); self.electro_count = WEP_CVAR_SEC(electro, count); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(); diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 9ca028450..54e2496cf 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -123,11 +123,11 @@ void W_Hagar_Touch2(void) } } -void W_Hagar_Attack(void) +void W_Hagar_Attack(Weapon thiswep) {SELFPARAM(); entity missile; - W_DecreaseAmmo(WEP_CVAR_PRI(hagar, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(hagar, ammo)); W_SetupShot(self, false, 2, SND(HAGAR_FIRE), CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage)); @@ -166,11 +166,11 @@ void W_Hagar_Attack(void) MUTATOR_CALLHOOK(EditProjectile, self, missile); } -void W_Hagar_Attack2(void) +void W_Hagar_Attack2(Weapon thiswep) {SELFPARAM(); entity missile; - W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hagar, ammo)); W_SetupShot(self, false, 2, SND(HAGAR_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); @@ -291,7 +291,7 @@ void W_Hagar_Attack2_Load_Release(void) self.hagar_load = 0; } -void W_Hagar_Attack2_Load(void) +void W_Hagar_Attack2_Load(Weapon thiswep) {SELFPARAM(); // loadable hagar secondary attack, must always run each frame @@ -319,7 +319,7 @@ void W_Hagar_Attack2_Load(void) { // if we pressed primary fire while loading, unload all rockets and abort self.weaponentity.state = WS_READY; - W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo self.hagar_load = 0; sound(self, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM); @@ -337,7 +337,7 @@ void W_Hagar_Attack2_Load(void) { if(!self.hagar_loadblock && self.hagar_loadstep < time) { - W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hagar, ammo)); self.weaponentity.state = WS_INUSE; self.hagar_load += 1; sound(self, CH_WEAPON_B, SND_HAGAR_LOAD, VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most @@ -414,14 +414,14 @@ void W_Hagar_Attack2_Load(void) loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary)); if(loadable_secondary) - W_Hagar_Attack2_Load(); // must always run each frame + W_Hagar_Attack2_Load(thiswep); // must always run each frame if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) // forced reload _WEP_ACTION(self.weapon, WR_RELOAD); else if(fire1 && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset { if(weapon_prepareattack(0, WEP_CVAR_PRI(hagar, refire))) { - W_Hagar_Attack(); + W_Hagar_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready); } } @@ -429,7 +429,7 @@ void W_Hagar_Attack2_Load(void) { if(weapon_prepareattack(1, WEP_CVAR_SEC(hagar, refire))) { - W_Hagar_Attack2(); + W_Hagar_Attack2(thiswep); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready); } } @@ -457,7 +457,7 @@ void W_Hagar_Attack2_Load(void) if(self.hagar_load) { - W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo if necessary + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo if necessary self.hagar_load = 0; } diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 1c4b3a018..ad21fd9ca 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -67,12 +67,12 @@ void W_HLAC_Touch(void) remove(self); } -void W_HLAC_Attack(void) +void W_HLAC_Attack(Weapon thiswep) {SELFPARAM(); entity missile; float spread; - W_DecreaseAmmo(WEP_CVAR_PRI(hlac, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(hlac, ammo)); spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * self.misc_bulletcounter); spread = min(spread,WEP_CVAR_PRI(hlac, spread_max)); @@ -180,7 +180,7 @@ void W_HLAC_Attack_Frame(void) } ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(); - W_HLAC_Attack(); + W_HLAC_Attack(WEP_HLAC); self.misc_bulletcounter = self.misc_bulletcounter + 1; weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); } @@ -190,11 +190,11 @@ void W_HLAC_Attack_Frame(void) } } -void W_HLAC_Attack2_Frame(void) +void W_HLAC_Attack2_Frame(Weapon thiswep) {SELFPARAM(); float i; - W_DecreaseAmmo(WEP_CVAR_SEC(hlac, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hlac, ammo)); for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i) W_HLAC_Attack2(); @@ -220,7 +220,7 @@ void W_HLAC_Attack2_Frame(void) if(weapon_prepareattack(0, WEP_CVAR_PRI(hlac, refire))) { self.misc_bulletcounter = 0; - W_HLAC_Attack(); + W_HLAC_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); } } @@ -229,7 +229,7 @@ void W_HLAC_Attack2_Frame(void) { if(weapon_prepareattack(1, WEP_CVAR_SEC(hlac, refire))) { - W_HLAC_Attack2_Frame(); + W_HLAC_Attack2_Frame(thiswep); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/hmg.qc b/qcsrc/common/weapons/weapon/hmg.qc index bba7f127f..bb35d6783 100644 --- a/qcsrc/common/weapons/weapon/hmg.qc +++ b/qcsrc/common/weapons/weapon/hmg.qc @@ -61,7 +61,7 @@ void W_HeavyMachineGun_Attack_Auto() return; } - W_DecreaseAmmo(WEP_CVAR(hmg, ammo)); + W_DecreaseAmmo(WEP_HMG, WEP_CVAR(hmg, ammo)); W_SetupShot (self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(hmg, damage)); diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 8e7afd53d..68907915b 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -131,11 +131,11 @@ void W_Hook_Touch2(void) self.use(); } -void W_Hook_Attack2(void) +void W_Hook_Attack2(Weapon thiswep) {SELFPARAM(); entity gren; - //W_DecreaseAmmo(WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb) + //W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb) W_SetupShot(self, false, 4, SND(HOOKBOMB_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hook, damage)); gren = spawn(); @@ -191,7 +191,7 @@ void W_Hook_Attack2(void) if(time > self.hook_refire) if(weapon_prepareattack(0, -1)) { - W_DecreaseAmmo(WEP_CVAR_PRI(hook, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(hook, ammo)); self.hook_state |= HOOK_FIRING; weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready); } @@ -201,7 +201,7 @@ void W_Hook_Attack2(void) { if(weapon_prepareattack(1, WEP_CVAR_SEC(hook, refire))) { - W_Hook_Attack2(); + W_Hook_Attack2(thiswep); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready); } } @@ -234,7 +234,7 @@ void W_Hook_Attack2(void) { if( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel ) { - W_DecreaseAmmo((time - self.hook_time_fueldecrease) * hooked_fuel); + W_DecreaseAmmo(thiswep, (time - self.hook_time_fueldecrease) * hooked_fuel); self.hook_time_fueldecrease = time; // decrease next frame again } diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 784b9a435..a8437586f 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -104,7 +104,7 @@ void W_MachineGun_MuzzleFlash(void) self.muzzle_flash.owner = self.muzzle_flash.realowner = self; } -void W_MachineGun_Attack(int deathtype) +void W_MachineGun_Attack(Weapon thiswep, int deathtype) {SELFPARAM(); W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage))); if(!autocvar_g_norecoil) @@ -131,9 +131,9 @@ void W_MachineGun_Attack(int deathtype) SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self); if(self.misc_bulletcounter == 1) - W_DecreaseAmmo(WEP_CVAR(machinegun, first_ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, first_ammo)); else - W_DecreaseAmmo(WEP_CVAR(machinegun, sustained_ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, sustained_ammo)); } // weapon frames @@ -154,7 +154,7 @@ void W_MachineGun_Attack_Frame(void) return; } self.misc_bulletcounter = self.misc_bulletcounter + 1; - W_MachineGun_Attack(WEP_MACHINEGUN.m_id); + W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); } else @@ -180,7 +180,7 @@ void W_MachineGun_Attack_Auto(void) return; } - W_DecreaseAmmo(WEP_CVAR(machinegun, sustained_ammo)); + W_DecreaseAmmo(WEP_MACHINEGUN, WEP_CVAR(machinegun, sustained_ammo)); W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); if(!autocvar_g_norecoil) @@ -271,7 +271,7 @@ void W_MachineGun_Attack_Burst(void) return false; } - W_DecreaseAmmo(WEP_CVAR(machinegun, burst_ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, burst_ammo)); self.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1; W_MachineGun_Attack_Burst(); @@ -284,7 +284,7 @@ void W_MachineGun_Attack_Burst(void) if(weapon_prepareattack(0, 0)) { self.misc_bulletcounter = 1; - W_MachineGun_Attack(WEP_MACHINEGUN.m_id); // sets attack_finished + W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id); // sets attack_finished weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); } @@ -292,7 +292,7 @@ void W_MachineGun_Attack_Burst(void) if(weapon_prepareattack(1, 0)) { self.misc_bulletcounter = 1; - W_MachineGun_Attack(WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY); // sets attack_finished + W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY); // sets attack_finished weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index b6aa26343..fb2cdc850 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -306,7 +306,7 @@ void W_MineLayer_Damage(entity inflictor, entity attacker, float damage, int dea W_PrepareExplosionByDamage(attacker, W_MineLayer_Explode); } -void W_MineLayer_Attack(void) +void W_MineLayer_Attack(Weapon thiswep) {SELFPARAM(); entity mine; entity flash; @@ -323,7 +323,7 @@ void W_MineLayer_Attack(void) } } - W_DecreaseAmmo(WEP_CVAR(minelayer, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(minelayer, ammo)); W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', false, 5, SND(MINE_FIRE), CH_WEAPON_A, WEP_CVAR(minelayer, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -511,7 +511,7 @@ float W_MineLayer_PlacedMines(float detonate) { if(weapon_prepareattack(0, WEP_CVAR(minelayer, refire))) { - W_MineLayer_Attack(); + W_MineLayer_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 559c50310..893b0ae17 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -198,11 +198,11 @@ void W_Mortar_Grenade_Touch2(void) } } -void W_Mortar_Attack(void) +void W_Mortar_Attack(Weapon thiswep) {SELFPARAM(); entity gren; - W_DecreaseAmmo(WEP_CVAR_PRI(mortar, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(mortar, ammo)); W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, SND(GRENADE_FIRE), CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage)); w_shotdir = v_forward; // no TrueAim for grenades please @@ -247,11 +247,11 @@ void W_Mortar_Attack(void) MUTATOR_CALLHOOK(EditProjectile, self, gren); } -void W_Mortar_Attack2(void) +void W_Mortar_Attack2(Weapon thiswep) {SELFPARAM(); entity gren; - W_DecreaseAmmo(WEP_CVAR_SEC(mortar, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(mortar, ammo)); W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, SND(GRENADE_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage)); w_shotdir = v_forward; // no TrueAim for grenades please @@ -344,7 +344,7 @@ void W_Mortar_Attack2(void) { if(weapon_prepareattack(0, WEP_CVAR_PRI(mortar, refire))) { - W_Mortar_Attack(); + W_Mortar_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready); } } @@ -367,7 +367,7 @@ void W_Mortar_Attack2(void) } else if(weapon_prepareattack(1, WEP_CVAR_SEC(mortar, refire))) { - W_Mortar_Attack2(); + W_Mortar_Attack2(thiswep); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 3d69e2d8f..8aad95ef6 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -53,11 +53,11 @@ void spawnfunc_weapon_rifle(void) { weapon_defaultspawnfunc(WEP_RIFLE.m_id); } void spawnfunc_weapon_campingrifle(void) { spawnfunc_weapon_rifle(); } void spawnfunc_weapon_sniperrifle(void) { spawnfunc_weapon_rifle(); } -void W_Rifle_FireBullet(float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, string pSound) +void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, string pSound) {SELFPARAM(); float i; - W_DecreaseAmmo(pAmmo); + W_DecreaseAmmo(thiswep, pAmmo); W_SetupShot(self, true, 2, pSound, CH_WEAPON_A, pDamage * pShots); @@ -78,12 +78,12 @@ void W_Rifle_FireBullet(float pSpread, float pDamage, float pForce, float pSolid void W_Rifle_Attack(void) { - W_Rifle_FireBullet(WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND(CAMPINGRIFLE_FIRE)); + W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND(CAMPINGRIFLE_FIRE)); } void W_Rifle_Attack2(void) { - W_Rifle_FireBullet(WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND(CAMPINGRIFLE_FIRE2)); + W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND(CAMPINGRIFLE_FIRE2)); } .void(void) rifle_bullethail_attackfunc; diff --git a/qcsrc/common/weapons/weapon/rpc.qc b/qcsrc/common/weapons/weapon/rpc.qc index 836b4be33..d8e35351b 100644 --- a/qcsrc/common/weapons/weapon/rpc.qc +++ b/qcsrc/common/weapons/weapon/rpc.qc @@ -104,12 +104,12 @@ void W_RocketPropelledChainsaw_Think() self.nextthink = time; } -void W_RocketPropelledChainsaw_Attack (void) +void W_RocketPropelledChainsaw_Attack (Weapon thiswep) {SELFPARAM(); entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(self); entity flash = spawn (); - W_DecreaseAmmo(WEP_CVAR(rpc, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(rpc, ammo)); W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', false, 5, SND(ROCKET_FIRE), CH_WEAPON_A, WEP_CVAR(rpc, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); PROJECTILE_MAKETRIGGER(missile); @@ -164,7 +164,7 @@ void W_RocketPropelledChainsaw_Attack (void) { if(weapon_prepareattack(0, WEP_CVAR(rpc, refire))) { - W_RocketPropelledChainsaw_Attack(); + W_RocketPropelledChainsaw_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 74be279bc..811231cca 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -245,11 +245,11 @@ void W_Seeker_Missile_Animate(void) } */ -void W_Seeker_Fire_Missile(vector f_diff, entity m_target) +void W_Seeker_Fire_Missile(Weapon thiswep, vector f_diff, entity m_target) {SELFPARAM(); entity missile; - W_DecreaseAmmo(WEP_CVAR(seeker, missile_ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(seeker, missile_ammo)); makevectors(self.v_angle); W_SetupShot_ProjectileSize(self, '-2 -2 -2', '2 2 2', false, 2, SND(SEEKER_FIRE), CH_WEAPON_A, 0); @@ -318,13 +318,13 @@ void W_Seeker_Flac_Touch(void) W_Seeker_Flac_Explode(); } -void W_Seeker_Fire_Flac(void) +void W_Seeker_Fire_Flac(Weapon thiswep) {SELFPARAM(); entity missile; vector f_diff; float c; - W_DecreaseAmmo(WEP_CVAR(seeker, flac_ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(seeker, flac_ammo)); c = self.bulletcounter % 4; switch(c) @@ -410,7 +410,7 @@ void W_Seeker_Attack(void) if((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target))) closest_target = world; - W_Seeker_Fire_Missile('0 0 0', closest_target); + W_Seeker_Fire_Missile(WEP_SEEKER, '0 0 0', closest_target); } void W_Seeker_Vollycontroller_Think(void) // TODO: Merge this with W_Seeker_Attack @@ -436,17 +436,17 @@ void W_Seeker_Vollycontroller_Think(void) // TODO: Merge this with W_Seeker_Atta switch(c) { case 0: - W_Seeker_Fire_Missile('-1.25 -3.75 0', self.enemy); + W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 -3.75 0', self.enemy); break; case 1: - W_Seeker_Fire_Missile('+1.25 -3.75 0', self.enemy); + W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 -3.75 0', self.enemy); break; case 2: - W_Seeker_Fire_Missile('-1.25 +3.75 0', self.enemy); + W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 +3.75 0', self.enemy); break; case 3: default: - W_Seeker_Fire_Missile('+1.25 +3.75 0', self.enemy); + W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 +3.75 0', self.enemy); break; } @@ -556,10 +556,10 @@ void W_Seeker_Tag_Touch(void) return; } -void W_Seeker_Fire_Tag(void) +void W_Seeker_Fire_Tag(Weapon thiswep) {SELFPARAM(); entity missile; - W_DecreaseAmmo(WEP_CVAR(seeker, tag_ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR(seeker, tag_ammo)); W_SetupShot_ProjectileSize(self, '-2 -2 -2', '2 2 2', false, 2, SND(TAG_FIRE), CH_WEAPON_A, WEP_CVAR(seeker, missile_damage) * WEP_CVAR(seeker, missile_count)); @@ -628,7 +628,7 @@ void W_Seeker_Fire_Tag(void) { if(weapon_prepareattack(0, WEP_CVAR(seeker, tag_refire))) { - W_Seeker_Fire_Tag(); + W_Seeker_Fire_Tag(thiswep); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready); } } @@ -640,7 +640,7 @@ void W_Seeker_Fire_Tag(void) { if(weapon_prepareattack(0, WEP_CVAR(seeker, tag_refire))) { - W_Seeker_Fire_Tag(); + W_Seeker_Fire_Tag(thiswep); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready); } } @@ -648,7 +648,7 @@ void W_Seeker_Fire_Tag(void) { if(weapon_prepareattack(0, WEP_CVAR(seeker, flac_refire))) { - W_Seeker_Fire_Flac(); + W_Seeker_Fire_Flac(thiswep); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 578e9284c..809542a48 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -56,12 +56,12 @@ SHOTGUN_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) #ifdef SVQC void spawnfunc_weapon_shotgun(void) { weapon_defaultspawnfunc(WEP_SHOTGUN.m_id); } -void W_Shotgun_Attack(float isprimary) +void W_Shotgun_Attack(Weapon thiswep, float isprimary) {SELFPARAM(); float sc; entity flash; - W_DecreaseAmmo(WEP_CVAR_PRI(shotgun, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(shotgun, ammo)); W_SetupShot(self, true, 5, SND(SHOTGUN_FIRE), ((isprimary) ? CH_WEAPON_A : CH_WEAPON_SINGLE), WEP_CVAR_PRI(shotgun, damage) * WEP_CVAR_PRI(shotgun, bullets)); for(sc = 0;sc < WEP_CVAR_PRI(shotgun, bullets);sc = sc + 1) @@ -206,7 +206,7 @@ void W_Shotgun_Attack3_Frame2() } sound(self, CH_WEAPON_SINGLE, SND_Null, VOL_BASE, ATTN_NORM); // kill previous sound - W_Shotgun_Attack(true); // actually is secondary, but we trick the last shot into playing full reload sound + W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready); } void W_Shotgun_Attack3_Frame1() @@ -219,7 +219,7 @@ void W_Shotgun_Attack3_Frame1() return; } - W_Shotgun_Attack(false); + W_Shotgun_Attack(WEP_SHOTGUN, false); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2); } @@ -250,7 +250,7 @@ void W_Shotgun_Attack3_Frame1() { if(weapon_prepareattack(0, WEP_CVAR_PRI(shotgun, animtime))) { - W_Shotgun_Attack(true); + W_Shotgun_Attack(thiswep, true); self.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready); } @@ -262,7 +262,7 @@ void W_Shotgun_Attack3_Frame1() { if(weapon_prepareattack(0, WEP_CVAR_SEC(shotgun, alt_animtime))) { - W_Shotgun_Attack(false); + W_Shotgun_Attack(thiswep, false); self.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1); } diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 3cfbf3b38..957e721f1 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -71,7 +71,7 @@ void W_RocketMinsta_Explosion(vector loc) remove(dmgent); } -void W_Vaporizer_Attack(void) +void W_Vaporizer_Attack(Weapon thiswep) {SELFPARAM(); bool flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000); @@ -105,7 +105,7 @@ void W_Vaporizer_Attack(void) if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT))) W_RocketMinsta_Explosion(trace_endpos); - W_DecreaseAmmo(((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo))); + W_DecreaseAmmo(thiswep, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo))); } void W_RocketMinsta_Laser_Explode (void) @@ -258,7 +258,7 @@ void W_RocketMinsta_Attack3 (void) { if(weapon_prepareattack(0, WEP_CVAR_PRI(vaporizer, refire))) { - W_Vaporizer_Attack(); + W_Vaporizer_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready); } } @@ -291,7 +291,7 @@ void W_RocketMinsta_Attack3 (void) // decrease ammo for the laser? if(WEP_CVAR_SEC(vaporizer, ammo)) - W_DecreaseAmmo(WEP_CVAR_SEC(vaporizer, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(vaporizer, ammo)); // ugly instagib hack to reuse the fire mode of the laser makevectors(self.v_angle); diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index a4e0fb5e0..2d09c17e8 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -78,7 +78,7 @@ void SendCSQCVortexBeamParticle(float charge) { WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255)); } -void W_Vortex_Attack(float issecondary) +void W_Vortex_Attack(Weapon thiswep, float issecondary) {SELFPARAM(); float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge; @@ -128,7 +128,7 @@ void W_Vortex_Attack(float issecondary) //beam and muzzle flash done on client SendCSQCVortexBeamParticle(charge); - W_DecreaseAmmo(myammo); + W_DecreaseAmmo(thiswep, myammo); } .float vortex_chargepool_pauseregen_finished; @@ -165,7 +165,7 @@ void W_Vortex_Attack(float issecondary) { if(weapon_prepareattack(0, WEP_CVAR_PRI(vortex, refire))) { - W_Vortex_Attack(0); + W_Vortex_Attack(thiswep, 0); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready); } } @@ -237,7 +237,7 @@ void W_Vortex_Attack(float issecondary) { if(weapon_prepareattack(0, WEP_CVAR_SEC(vortex, refire))) { - W_Vortex_Attack(1); + W_Vortex_Attack(thiswep, 1); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready); } } diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 7b5eb25ef..afc445cb2 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -24,8 +24,8 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) if(time < self.hasweapon_complain_spam) complain = 0; - // ignore hook button when using nades without hook - if (autocvar_g_nades && cl.offhand != OFFHAND_HOOK) + // ignore hook button when using other offhand equipment + if (cl.offhand != OFFHAND_HOOK) if (wpn == WEP_HOOK.m_id && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn))) complain = 0; diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 56a92bb77..b682ab8fe 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -827,9 +827,8 @@ void W_AttachToShotorg(entity flash, vector offset) } } -void W_DecreaseAmmo(float ammo_use) +void W_DecreaseAmmo(Weapon wep, float ammo_use) {SELFPARAM(); - entity wep = get_weaponinfo(self.weapon); if(cvar("g_overkill")) if(self.ok_use_ammocharge) diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index 41b382d97..8ee65bb26 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -22,7 +22,7 @@ float forbidWeaponUse(entity player); void W_AttachToShotorg(entity flash, vector offset); -void W_DecreaseAmmo(float ammo_use); +void W_DecreaseAmmo(Weapon wep, float ammo_use); void W_DropEvent(float event, entity player, float weapon_type, entity weapon_item); -- 2.39.2