From 32859bfcbed07ee7a99ced8d1ccbb8f83ef82462 Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Sat, 22 Jan 2011 04:03:52 +0200 Subject: [PATCH] Reload if we don't have ammo for a certain attack. Prevents situations in which you still hold the weapon (if you have ammo for the other firing type), and the firing key you have no ammo for does nothing. We make it reload instead. --- qcsrc/server/w_crylink.qc | 14 ++++++++++++++ qcsrc/server/w_electro.qc | 14 ++++++++++++++ qcsrc/server/w_fireball.qc | 14 ++++++++++++++ qcsrc/server/w_grenadelauncher.qc | 14 ++++++++++++++ qcsrc/server/w_hlac.qc | 14 ++++++++++++++ qcsrc/server/w_minelayer.qc | 7 +++++++ qcsrc/server/w_shotgun.qc | 7 +++++++ qcsrc/server/w_sniperrifle.qc | 7 +++++++ qcsrc/server/w_uzi.qc | 14 ++++++++++++++ 9 files changed, 105 insertions(+) diff --git a/qcsrc/server/w_crylink.qc b/qcsrc/server/w_crylink.qc index 604efbe1c..4a9ab41d3 100644 --- a/qcsrc/server/w_crylink.qc +++ b/qcsrc/server/w_crylink.qc @@ -373,6 +373,13 @@ void W_Crylink_Attack (void) vector forward, right, up; float maxdmg; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_crylink_reload_ammo && self.clip_load < autocvar_g_balance_crylink_primary_ammo) + { + W_Crylink_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { @@ -485,6 +492,13 @@ void W_Crylink_Attack2 (void) local entity proj, prevproj, firstproj; float maxdmg; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_crylink_reload_ammo && self.clip_load < autocvar_g_balance_crylink_secondary_ammo) + { + W_Crylink_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { diff --git a/qcsrc/server/w_electro.qc b/qcsrc/server/w_electro.qc index c4cd72689..bbcdc06df 100644 --- a/qcsrc/server/w_electro.qc +++ b/qcsrc/server/w_electro.qc @@ -164,6 +164,13 @@ void W_Electro_Attack() { local entity proj; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_electro_reload_ammo && self.clip_load < autocvar_g_balance_electro_primary_ammo) + { + W_Electro_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { @@ -211,6 +218,13 @@ void W_Electro_Attack2() { local entity proj; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_electro_reload_ammo && self.clip_load < autocvar_g_balance_electro_secondary_ammo) + { + W_Electro_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { diff --git a/qcsrc/server/w_fireball.qc b/qcsrc/server/w_fireball.qc index e0f0748f4..4465aae9c 100644 --- a/qcsrc/server/w_fireball.qc +++ b/qcsrc/server/w_fireball.qc @@ -252,6 +252,13 @@ void W_Fireball_Attack1_Frame1() void W_Fireball_Attack1_Frame0() { + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_fireball_reload_ammo && self.clip_load < autocvar_g_balance_fireball_primary_ammo) + { + W_Fireball_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { @@ -313,6 +320,13 @@ void W_Fireball_Attack2() vector f_diff; float c; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_fireball_reload_ammo && self.clip_load < autocvar_g_balance_fireball_secondary_ammo) + { + W_Fireball_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { diff --git a/qcsrc/server/w_grenadelauncher.qc b/qcsrc/server/w_grenadelauncher.qc index ddd5eacf4..23312b914 100644 --- a/qcsrc/server/w_grenadelauncher.qc +++ b/qcsrc/server/w_grenadelauncher.qc @@ -215,6 +215,13 @@ void W_Grenade_Attack (void) { local entity gren; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_grenadelauncher_reload_ammo && self.clip_load < autocvar_g_balance_grenadelauncher_primary_ammo) + { + W_GrenadeLauncher_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { @@ -272,6 +279,13 @@ void W_Grenade_Attack2 (void) { local entity gren; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_grenadelauncher_reload_ammo && self.clip_load < autocvar_g_balance_grenadelauncher_secondary_ammo) + { + W_GrenadeLauncher_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { diff --git a/qcsrc/server/w_hlac.qc b/qcsrc/server/w_hlac.qc index 3a5ff0717..b07570b95 100644 --- a/qcsrc/server/w_hlac.qc +++ b/qcsrc/server/w_hlac.qc @@ -76,6 +76,13 @@ void W_HLAC_Attack (void) local entity missile; float spread; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < autocvar_g_balance_hlac_primary_ammo) + { + W_HLAC_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { @@ -177,6 +184,13 @@ void W_HLAC_Attack2 (void) { float i; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < autocvar_g_balance_hlac_secondary_ammo) + { + W_HLAC_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { diff --git a/qcsrc/server/w_minelayer.qc b/qcsrc/server/w_minelayer.qc index d46342ccc..8efb7566c 100644 --- a/qcsrc/server/w_minelayer.qc +++ b/qcsrc/server/w_minelayer.qc @@ -268,6 +268,13 @@ void W_Mine_Attack (void) } } + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_minelayer_reload_ammo && self.clip_load < autocvar_g_balance_minelayer_ammo) + { + W_MineLayer_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index acf65a1f9..f38076deb 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -69,6 +69,13 @@ void W_Shotgun_Attack (void) float bulletconstant; local entity flash; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_shotgun_reload_ammo && self.clip_load < autocvar_g_balance_shotgun_primary_ammo) + { + W_Shotgun_Reload(); + return; + } + ammoamount = autocvar_g_balance_shotgun_primary_ammo; bullets = autocvar_g_balance_shotgun_primary_bullets; d = autocvar_g_balance_shotgun_primary_damage; diff --git a/qcsrc/server/w_sniperrifle.qc b/qcsrc/server/w_sniperrifle.qc index 826aa8d8d..454e1db7a 100644 --- a/qcsrc/server/w_sniperrifle.qc +++ b/qcsrc/server/w_sniperrifle.qc @@ -63,6 +63,13 @@ void W_SniperRifle_Reload() void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant) { + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_sniperrifle_reload_ammo && self.clip_load < autocvar_g_balance_sniperrifle_primary_ammo) + { + W_SniperRifle_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { diff --git a/qcsrc/server/w_uzi.qc b/qcsrc/server/w_uzi.qc index a02175884..10390188d 100644 --- a/qcsrc/server/w_uzi.qc +++ b/qcsrc/server/w_uzi.qc @@ -150,6 +150,13 @@ void uzi_mode1_fire_auto() { float uzi_spread; + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_uzi_reload_ammo && self.clip_load < max(autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_first_ammo)) + { + W_UZI_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { @@ -268,6 +275,13 @@ float w_uzi(float req) return FALSE; } + // if there's not enough ammo for this attack (but we still have the weapon), reload + if(autocvar_g_balance_uzi_reload_ammo && self.clip_load < autocvar_g_balance_uzi_burst_ammo) + { + W_UZI_Reload(); + return; + } + // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { -- 2.39.2