]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Phase 2. A global ammo decreasing function. Still not fully ready
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 11 Feb 2011 16:37:31 +0000 (18:37 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 11 Feb 2011 16:37:31 +0000 (18:37 +0200)
15 files changed:
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/defs.qh
qcsrc/server/w_crylink.qc
qcsrc/server/w_electro.qc
qcsrc/server/w_fireball.qc
qcsrc/server/w_grenadelauncher.qc
qcsrc/server/w_hagar.qc
qcsrc/server/w_hlac.qc
qcsrc/server/w_minelayer.qc
qcsrc/server/w_minstanex.qc
qcsrc/server/w_nex.qc
qcsrc/server/w_rocketlauncher.qc
qcsrc/server/w_seeker.qc
qcsrc/server/w_shotgun.qc
qcsrc/server/w_sniperrifle.qc

index 4465c190b7d8d7e6f4675ab1eb5d09fe59a99c50..222c0f9fdbe8bf9aaf42975045a4140e359b335f 100644 (file)
@@ -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;
index d7242de9304e7f1985ce1dda7739bd09691561ef..3c7617b3509b062bff3052eac3f3224aa3089b6e 100644 (file)
@@ -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;
index 97b1b02188728f2c2416214b0a8b0ccc6db80d88..a663df0f8e3572ec5049fe19bf83c93c78051e5d 100644 (file)
@@ -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;
index c4be2d04ecf3bcf7ff30544917726964de6d1ef6..6fb410019ebaae7e8977e9602ddc6abb95b2aac4 100644 (file)
@@ -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);
 
index 89da692f477e5ba5b1149f59f45d9d59f76187fd..a269c6556301b663a99a89cbfccec2f78206b178 100644 (file)
@@ -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)
index 3571d50beb1a3d36b0130626ee286697cb01501d..5ea482a4c55c8560c1d18683347202da1595f529 100644 (file)
@@ -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
index 078e36d26dd5b9941533d3a89ac5b2946b5cbaee..cb6fad0039e3f76859371a43d8e2011256a6d78c 100644 (file)
@@ -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);
 
index bbab9cdbc3a42bab25976506c0f77acbee0450b3..c1de434ed4a9b4808410c57a8964081a1aaa8fd2 100644 (file)
@@ -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();
index 5fb00698a5744ca51309ab2691bf62ba126f65bb..3c9aac6cc22090bbad023cb39c930d0f1940b4f4 100644 (file)
@@ -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);
index 06658554822c65717b4f2a59fc73a9659da5d719..a15a6b2587f7f948659a6ad0617083d8751df5c8 100644 (file)
@@ -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;
index dbe8394c3c0a80cbe5024d10acfd6a4af2f4db74..e3f4659c903ad94058f08e2b54e75e0840269f0f 100644 (file)
@@ -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
index adb62874ef97776f53f867e9ae21390b6173b387..c33e0e76488d1c8ae7fa4ea166db5a4723e30cea 100644 (file)
@@ -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);
index 64f25a2c7aadb0b7d51d12d1fc5723a6568a1ced..3659a2ec48e7e4bde37a7856440e1d1bc45b4750 100644 (file)
@@ -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)
index f522d19a17710ee1839d1ddcb23b44de0a295510..f92a3d356ee7c50dad661c8b5fbd46166d2049a9 100644 (file)
@@ -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)
index 6c2621f9f4c14025151984e8e0475918c75e5553..ec5743d0b1b558d2133d4ae0e9cfcda39ae96711 100644 (file)
@@ -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);