From 223ada6accb3798fe61a8a7168213582f02a3415 Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Fri, 11 Feb 2011 18:37:31 +0200 Subject: [PATCH] Phase 2. A global ammo decreasing function. Still not fully ready --- qcsrc/server/cl_weaponsystem.qc | 27 ++++++++++++++++++----- qcsrc/server/defs.qh | 2 ++ qcsrc/server/w_crylink.qc | 24 ++------------------- qcsrc/server/w_electro.qc | 24 ++------------------- qcsrc/server/w_fireball.qc | 24 ++------------------- qcsrc/server/w_grenadelauncher.qc | 24 ++------------------- qcsrc/server/w_hagar.qc | 24 ++------------------- qcsrc/server/w_hlac.qc | 24 ++------------------- qcsrc/server/w_minelayer.qc | 12 +---------- qcsrc/server/w_minstanex.qc | 30 +++++--------------------- qcsrc/server/w_nex.qc | 12 +---------- qcsrc/server/w_rocketlauncher.qc | 12 +---------- qcsrc/server/w_seeker.qc | 36 +++---------------------------- qcsrc/server/w_shotgun.qc | 12 +---------- qcsrc/server/w_sniperrifle.qc | 12 +---------- 15 files changed, 49 insertions(+), 250 deletions(-) diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 4465c190b..222c0f9fd 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -1612,9 +1612,26 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread) #define W_SETUPPROJECTILEVELOCITY_UP(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), cvar(#s "_speed_up"), cvar(#s "_speed_z"), cvar(#s "_spread"), FALSE) #define W_SETUPPROJECTILEVELOCITY(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), 0, 0, cvar(#s "_spread"), FALSE) +void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload) +{ + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo + if not(self.items & IT_UNLIMITED_WEAPON_AMMO) + { + if(ammo_reload) + { + self.clip_load -= ammo_use; + self.weapon_load[self.weapon] = self.clip_load; + } + else + { + self.current_ammo = ammo_type; + self.(self.current_ammo) -= ammo_use; + } + } +} + // weapon reloading code -..float reload_ammo_player; .float reload_ammo_amount, reload_ammo_min, reload_time; .float reload_complain; .string reload_sound; @@ -1668,10 +1685,10 @@ void W_ReloadEnd() self.clip_load = self.reload_ammo_amount; else { - while(self.clip_load < self.reload_ammo_amount && self.(self.reload_ammo_player)) // make sure we don't add more ammo than we have + while(self.clip_load < self.reload_ammo_amount && self.(self.current_ammo)) // make sure we don't add more ammo than we have { self.clip_load += 1; - self.(self.reload_ammo_player) -= 1; + self.(self.current_ammo) -= 1; } } self.weapon_load[self.weapon] = self.clip_load; @@ -1687,7 +1704,7 @@ void W_ReloadStart() if(!self.reload_ammo_amount) return; - if(!W_ReloadCheck(self.(self.reload_ammo_player), self.reload_ammo_min)) + if(!W_ReloadCheck(self.(self.current_ammo), self.reload_ammo_min)) return; float t; @@ -1705,7 +1722,7 @@ void W_ReloadStart() void W_Reload(.float sent_ammo_player, float sent_ammo_min, float sent_ammo_amount, float sent_time, string sent_sound) { - self.reload_ammo_player = sent_ammo_player; + self.current_ammo = sent_ammo_player; self.reload_ammo_min = sent_ammo_min; self.reload_ammo_amount = sent_ammo_amount; self.reload_time = sent_time; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index d7242de93..3c7617b35 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -614,6 +614,8 @@ float client_cefc_accumulator; float client_cefc_accumulatortime; #endif +..float current_ammo; + .float weapon_load[WEP_MAXCOUNT]; FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(weapon_load); .float zero_ammo; // used by the reloading system, must always be 0 .float clip_load; diff --git a/qcsrc/server/w_crylink.qc b/qcsrc/server/w_crylink.qc index 97b1b0218..a663df0f8 100644 --- a/qcsrc/server/w_crylink.qc +++ b/qcsrc/server/w_crylink.qc @@ -326,17 +326,7 @@ void W_Crylink_Attack (void) vector forward, right, up; float maxdmg; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_crylink_reload_ammo) - { - self.clip_load -= autocvar_g_balance_crylink_primary_ammo; - self.weapon_load[WEP_CRYLINK] = self.clip_load; - } - else - self.ammo_cells -= autocvar_g_balance_crylink_primary_ammo; - } + W_DecreaseAmmo(ammo_cells, autocvar_g_balance_crylink_primary_ammo, autocvar_g_balance_crylink_reload_ammo); maxdmg = autocvar_g_balance_crylink_primary_damage*autocvar_g_balance_crylink_primary_shots; maxdmg *= 1 + autocvar_g_balance_crylink_primary_bouncedamagefactor * autocvar_g_balance_crylink_primary_bounces; @@ -439,17 +429,7 @@ void W_Crylink_Attack2 (void) local entity proj, prevproj, firstproj; float maxdmg; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_crylink_reload_ammo) - { - self.clip_load -= autocvar_g_balance_crylink_secondary_ammo; - self.weapon_load[WEP_CRYLINK] = self.clip_load; - } - else - self.ammo_cells -= autocvar_g_balance_crylink_secondary_ammo; - } + W_DecreaseAmmo(ammo_cells, autocvar_g_balance_crylink_secondary_ammo, autocvar_g_balance_crylink_reload_ammo); maxdmg = autocvar_g_balance_crylink_secondary_damage*autocvar_g_balance_crylink_secondary_shots; maxdmg *= 1 + autocvar_g_balance_crylink_secondary_bouncedamagefactor * autocvar_g_balance_crylink_secondary_bounces; diff --git a/qcsrc/server/w_electro.qc b/qcsrc/server/w_electro.qc index c4be2d04e..6fb410019 100644 --- a/qcsrc/server/w_electro.qc +++ b/qcsrc/server/w_electro.qc @@ -110,17 +110,7 @@ void W_Electro_Attack() { local entity proj; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_electro_reload_ammo) - { - self.clip_load -= autocvar_g_balance_electro_primary_ammo; - self.weapon_load[WEP_ELECTRO] = self.clip_load; - } - else - self.ammo_cells -= autocvar_g_balance_electro_primary_ammo; - } + W_DecreaseAmmo(ammo_cells, autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_reload_ammo); W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CHAN_WEAPON, autocvar_g_balance_electro_primary_damage); @@ -157,17 +147,7 @@ void W_Electro_Attack2() { local entity proj; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_electro_reload_ammo) - { - self.clip_load -= autocvar_g_balance_electro_secondary_ammo; - self.weapon_load[WEP_ELECTRO] = self.clip_load; - } - else - self.ammo_cells -= autocvar_g_balance_electro_secondary_ammo; - } + W_DecreaseAmmo(ammo_cells, autocvar_g_balance_electro_secondary_ammo, autocvar_g_balance_electro_reload_ammo); W_SetupShot_ProjectileSize (self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CHAN_WEAPON, autocvar_g_balance_electro_secondary_damage); diff --git a/qcsrc/server/w_fireball.qc b/qcsrc/server/w_fireball.qc index 89da692f4..a269c6556 100644 --- a/qcsrc/server/w_fireball.qc +++ b/qcsrc/server/w_fireball.qc @@ -194,17 +194,7 @@ void W_Fireball_Attack1_Frame1() void W_Fireball_Attack1_Frame0() { - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_fireball_reload_ammo) - { - self.clip_load -= autocvar_g_balance_fireball_primary_ammo; - self.weapon_load[WEP_FIREBALL] = self.clip_load; - } - else - self.ammo_fuel -= autocvar_g_balance_fireball_primary_ammo; - } + W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_reload_ammo); W_Fireball_AttackEffect(0, '-1.25 -3.75 0'); sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM); @@ -255,17 +245,7 @@ void W_Fireball_Attack2() vector f_diff; float c; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_fireball_reload_ammo) - { - self.clip_load -= autocvar_g_balance_fireball_secondary_ammo; - self.weapon_load[WEP_FIREBALL] = self.clip_load; - } - else - self.ammo_fuel -= autocvar_g_balance_fireball_secondary_ammo; - } + W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_fireball_secondary_ammo, autocvar_g_balance_fireball_reload_ammo); c = mod(self.bulletcounter, 4); switch(c) diff --git a/qcsrc/server/w_grenadelauncher.qc b/qcsrc/server/w_grenadelauncher.qc index 3571d50be..5ea482a4c 100644 --- a/qcsrc/server/w_grenadelauncher.qc +++ b/qcsrc/server/w_grenadelauncher.qc @@ -161,17 +161,7 @@ void W_Grenade_Attack (void) { local entity gren; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_grenadelauncher_reload_ammo) - { - self.clip_load -= autocvar_g_balance_grenadelauncher_primary_ammo; - self.weapon_load[WEP_GRENADE_LAUNCHER] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_grenadelauncher_primary_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_grenadelauncher_primary_ammo, autocvar_g_balance_grenadelauncher_reload_ammo); W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CHAN_WEAPON, autocvar_g_balance_grenadelauncher_primary_damage); w_shotdir = v_forward; // no TrueAim for grenades please @@ -218,17 +208,7 @@ void W_Grenade_Attack2 (void) { local entity gren; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_grenadelauncher_reload_ammo) - { - self.clip_load -= autocvar_g_balance_grenadelauncher_secondary_ammo; - self.weapon_load[WEP_GRENADE_LAUNCHER] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_grenadelauncher_secondary_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_grenadelauncher_secondary_ammo, autocvar_g_balance_grenadelauncher_reload_ammo); W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CHAN_WEAPON, autocvar_g_balance_grenadelauncher_secondary_damage); w_shotdir = v_forward; // no TrueAim for grenades please diff --git a/qcsrc/server/w_hagar.qc b/qcsrc/server/w_hagar.qc index 078e36d26..cb6fad003 100644 --- a/qcsrc/server/w_hagar.qc +++ b/qcsrc/server/w_hagar.qc @@ -45,17 +45,7 @@ void W_Hagar_Attack (void) { local entity missile; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_hagar_reload_ammo) - { - self.clip_load -= autocvar_g_balance_hagar_primary_ammo; - self.weapon_load[WEP_HAGAR] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_hagar_primary_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo); W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage); @@ -90,17 +80,7 @@ void W_Hagar_Attack2 (void) { local entity missile; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_hagar_reload_ammo) - { - self.clip_load -= autocvar_g_balance_hagar_secondary_ammo; - self.weapon_load[WEP_HAGAR] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_hagar_secondary_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo); W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage); diff --git a/qcsrc/server/w_hlac.qc b/qcsrc/server/w_hlac.qc index bbab9cdbc..c1de434ed 100644 --- a/qcsrc/server/w_hlac.qc +++ b/qcsrc/server/w_hlac.qc @@ -22,17 +22,7 @@ void W_HLAC_Attack (void) local entity missile; float spread; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_hlac_reload_ammo) - { - self.clip_load -= autocvar_g_balance_hlac_primary_ammo; - self.weapon_load[WEP_HLAC] = self.clip_load; - } - else - self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo; - } + W_DecreaseAmmo(ammo_cells, autocvar_g_balance_hlac_primary_ammo, autocvar_g_balance_hlac_reload_ammo); spread = autocvar_g_balance_hlac_primary_spread_min + (autocvar_g_balance_hlac_primary_spread_add * self.misc_bulletcounter); spread = min(spread,autocvar_g_balance_hlac_primary_spread_max); @@ -123,17 +113,7 @@ void W_HLAC_Attack2 (void) { float i; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_hlac_reload_ammo) - { - self.clip_load -= autocvar_g_balance_hlac_secondary_ammo; - self.weapon_load[WEP_HLAC] = self.clip_load; - } - else - self.ammo_cells -= autocvar_g_balance_hlac_secondary_ammo; - } + W_DecreaseAmmo(ammo_cells, autocvar_g_balance_hlac_secondary_ammo, autocvar_g_balance_hlac_reload_ammo); for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i) W_HLAC_Attack2f(); diff --git a/qcsrc/server/w_minelayer.qc b/qcsrc/server/w_minelayer.qc index 5fb00698a..3c9aac6cc 100644 --- a/qcsrc/server/w_minelayer.qc +++ b/qcsrc/server/w_minelayer.qc @@ -220,17 +220,7 @@ void W_Mine_Attack (void) } } - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_minelayer_reload_ammo) - { - self.clip_load -= autocvar_g_balance_minelayer_ammo; - self.weapon_load[WEP_MINE_LAYER] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_minelayer_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_minelayer_ammo, autocvar_g_balance_minelayer_reload_ammo); W_SetupShot_ProjectileSize (self, '-4 -4 -4', '4 4 4', FALSE, 5, "weapons/mine_fire.wav", CHAN_WEAPON, autocvar_g_balance_minelayer_damage); pointparticles(particleeffectnum("rocketlauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); diff --git a/qcsrc/server/w_minstanex.qc b/qcsrc/server/w_minstanex.qc index 066585548..a15a6b258 100644 --- a/qcsrc/server/w_minstanex.qc +++ b/qcsrc/server/w_minstanex.qc @@ -80,25 +80,10 @@ void W_MinstaNex_Attack (void) if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)) Damage_DamageInfo(trace_endpos, 10000, 0, 0, 800 * w_shotdir, WEP_MINSTANEX, self); - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_minstanex_reload_ammo) - { - if (g_minstagib) - self.clip_load -= - 1; - else - self.clip_load -= autocvar_g_balance_minstanex_ammo; - self.weapon_load[WEP_MINSTANEX] = self.clip_load; - } - else - { - if (g_minstagib) - self.ammo_cells -= - 1; - else - self.ammo_cells -= autocvar_g_balance_minstanex_ammo; - } - } + if (g_minstagib) + W_DecreaseAmmo(ammo_cells, 1, autocvar_g_balance_minstanex_reload_ammo); + else + W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_ammo, autocvar_g_balance_minstanex_reload_ammo); } @@ -222,12 +207,7 @@ float w_minstanex(float req) // decrease ammo for the laser? if(autocvar_g_balance_minstanex_laser_ammo) - { - if(autocvar_g_balance_minstanex_reload_ammo) - self.clip_load -= autocvar_g_balance_minstanex_laser_ammo; - else - self.ammo_cells -= autocvar_g_balance_minstanex_laser_ammo; - } + W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_laser_ammo, autocvar_g_balance_minstanex_reload_ammo); // ugly minstagib hack to reuse the fire mode of the laser float w; diff --git a/qcsrc/server/w_nex.qc b/qcsrc/server/w_nex.qc index dbe8394c3..e3f4659c9 100644 --- a/qcsrc/server/w_nex.qc +++ b/qcsrc/server/w_nex.qc @@ -75,17 +75,7 @@ void W_Nex_Attack (float issecondary) if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)) Damage_DamageInfo(trace_endpos, mydmg, 0, 0, myforce * w_shotdir, WEP_NEX, self); - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_nex_reload_ammo) - { - self.clip_load -= myammo; - self.weapon_load[WEP_NEX] = self.clip_load; - } - else - self.ammo_cells -= myammo; - } + W_DecreaseAmmo(ammo_cells, myammo, autocvar_g_balance_nex_reload_ammo); } void spawnfunc_weapon_nex (void); // defined in t_items.qc diff --git a/qcsrc/server/w_rocketlauncher.qc b/qcsrc/server/w_rocketlauncher.qc index adb62874e..c33e0e764 100644 --- a/qcsrc/server/w_rocketlauncher.qc +++ b/qcsrc/server/w_rocketlauncher.qc @@ -248,17 +248,7 @@ void W_Rocket_Attack (void) local entity missile; local entity flash; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_rocketlauncher_reload_ammo) - { - self.clip_load -= autocvar_g_balance_rocketlauncher_ammo; - self.weapon_load[WEP_ROCKET_LAUNCHER] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_rocketlauncher_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_rocketlauncher_ammo, autocvar_g_balance_rocketlauncher_reload_ammo); W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 5, "weapons/rocket_fire.wav", CHAN_WEAPON, autocvar_g_balance_rocketlauncher_damage); pointparticles(particleeffectnum("rocketlauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); diff --git a/qcsrc/server/w_seeker.qc b/qcsrc/server/w_seeker.qc index 64f25a2c7..3659a2ec4 100644 --- a/qcsrc/server/w_seeker.qc +++ b/qcsrc/server/w_seeker.qc @@ -158,17 +158,7 @@ void Seeker_Fire_Missile(vector f_diff) { local entity missile; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_seeker_reload_ammo) - { - self.clip_load -= autocvar_g_balance_seeker_missile_ammo; - self.weapon_load[WEP_SEEKER] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_reload_ammo); makevectors(self.v_angle); W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0); @@ -303,17 +293,7 @@ void Seeker_Tag_Touch() void Seeker_Fire_Tag() { local entity missile; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_seeker_reload_ammo) - { - self.clip_load -= autocvar_g_balance_seeker_tag_ammo; - self.weapon_load[WEP_SEEKER] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_tag_ammo, autocvar_g_balance_seeker_reload_ammo); W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_missile_damage * autocvar_g_balance_seeker_missile_count); @@ -371,17 +351,7 @@ void Seeker_Fire_Flac() vector f_diff; float c; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_seeker_reload_ammo) - { - self.clip_load -= autocvar_g_balance_seeker_flac_ammo; - self.weapon_load[WEP_SEEKER] = self.clip_load; - } - else - self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo; - } + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_flac_ammo, autocvar_g_balance_seeker_reload_ammo); c = mod(self.bulletcounter, 4); switch(c) diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index f522d19a1..f92a3d356 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -23,17 +23,7 @@ void W_Shotgun_Attack (void) bulletspeed = autocvar_g_balance_shotgun_primary_speed; bulletconstant = autocvar_g_balance_shotgun_primary_bulletconstant; - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_shotgun_reload_ammo) - { - self.clip_load -= ammoamount; - self.weapon_load[WEP_SHOTGUN] = self.clip_load; - } - else - self.ammo_shells -= ammoamount; - } + W_DecreaseAmmo(ammo_shells, ammoamount, autocvar_g_balance_shotgun_reload_ammo); W_SetupShot (self, autocvar_g_antilag_bullets && bulletspeed >= autocvar_g_antilag_bullets, 5, "weapons/shotgun_fire.wav", CHAN_WEAPON, d * bullets); for (sc = 0;sc < bullets;sc = sc + 1) diff --git a/qcsrc/server/w_sniperrifle.qc b/qcsrc/server/w_sniperrifle.qc index 6c2621f9f..ec5743d0b 100644 --- a/qcsrc/server/w_sniperrifle.qc +++ b/qcsrc/server/w_sniperrifle.qc @@ -10,17 +10,7 @@ REGISTER_WEAPON(SNIPERRIFLE, w_sniperrifle, IT_NAILS, 7, WEP_FLAG_NORMAL | WEP_F void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant) { - // if this weapon is reloadable, decrease its load. Else decrease the player's ammo - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_sniperrifle_reload_ammo) - { - self.clip_load -= pAmmo; - self.weapon_load[WEP_SNIPERRIFLE] = self.clip_load; - } - else - self.ammo_nails -= pAmmo; - } + W_DecreaseAmmo(ammo_nails, pAmmo, autocvar_g_balance_sniperrifle_reload_ammo); if(deathtype & HITTYPE_SECONDARY) W_SetupShot (self, autocvar_g_antilag_bullets && pSpeed >= autocvar_g_antilag_bullets, 2, "weapons/campingrifle_fire2.wav", CHAN_WEAPON, autocvar_g_balance_sniperrifle_secondary_damage + autocvar_g_balance_sniperrifle_secondary_headshotaddeddamage); -- 2.39.2