]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Share the final reload code that comes to mind. The reload code is for the most part...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 30 Jan 2011 20:35:52 +0000 (22:35 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 30 Jan 2011 20:35:52 +0000 (22:35 +0200)
16 files changed:
qcsrc/server/cl_weapons.qc
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_laser.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
qcsrc/server/w_uzi.qc

index 4f2c9c3402ba2ebf360fa4d680fb728ac8ab55ee..d57883a292e372e916b7088b82818d7208bac3e1 100644 (file)
@@ -340,6 +340,18 @@ void W_WeaponFrame()
                        setanim(self, self.anim_draw, FALSE, TRUE, TRUE);
                        self.weaponentity.state = WS_RAISE;
                        weapon_action(self.switchweapon, WR_SETUP);
+
+                       // set our clip load to the load of the weapon we switched to, if it's reloadable
+                       entity e;
+                       e = get_weaponinfo(self.switchweapon);
+                       if(e.spawnflags & WEP_FLAG_RELOADABLE && cvar(strcat("g_balance_", e.netname, "_reload_ammo")))
+                       {
+                               self.clip_load = self.weapon_load[self.switchweapon];
+                               self.clip_size = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
+                       }
+                       else
+                               self.clip_load = self.clip_size = 0;
+
                        // VorteX: add player model weapon select frame here
                        // setcustomframe(PlayerWeaponRaise);
                        weapon_thinkf(WFRAME_IDLE, autocvar_g_balance_weaponswitchdelay, w_ready);
index 2d6319797666af33d12f3658a255e57cf450318e..e901a459ec7b9a5e952971259443d0608b6f603a 100644 (file)
@@ -9,18 +9,6 @@ REGISTER_WEAPON(CRYLINK, w_crylink, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_FLAG_RELO
 .entity queuenext;
 .entity queueprev;
 
-void W_Crylink_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_crylink_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_CRYLINK];
-               self.clip_size = autocvar_g_balance_crylink_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Crylink_Reload()
 {
        self.reload_ammo_player = ammo_cells;
@@ -644,7 +632,6 @@ float w_crylink(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_CRYLINK);
-               W_Crylink_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index 55ebcf50dceed3d9f83c5137e463b38cd406e86c..160d2df7f0e6a9c59b116c66f62c792232b8d08f 100644 (file)
@@ -5,18 +5,6 @@ REGISTER_WEAPON(ELECTRO, w_electro, IT_CELLS, 5, WEP_FLAG_NORMAL | WEP_FLAG_RELO
 .float electro_count;
 .float electro_secondarytime;
 
-void W_Electro_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_electro_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_ELECTRO];
-               self.clip_size = autocvar_g_balance_electro_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Electro_Reload()
 {
        self.reload_ammo_player = ammo_cells;
@@ -537,7 +525,6 @@ float w_electro(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_ELECTRO);
-               W_Electro_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index 3d1956de7862a61ecf964b9d74401b909cd1fa02..29fdab1819713b4c775e628ab3c305091b93fa0c 100644 (file)
@@ -6,18 +6,6 @@ REGISTER_WEAPON(FIREBALL, w_fireball, IT_FUEL, 9, WEP_FLAG_RELOADABLE | WEP_TYPE
 .vector fireball_impactvec;
 .float fireball_primarytime;
 
-void W_Fireball_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_fireball_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_FIREBALL];
-               self.clip_size = autocvar_g_balance_fireball_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Fireball_Reload()
 {
        // fuel can be a non-whole number, which brakes stuff here when between 0 and 1
@@ -407,7 +395,6 @@ float w_fireball(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_FIREBALL);
-               W_Fireball_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index 9f6efb64aa1d2c1343ed3864e306a25d65f4aa7f..5ebe530cb34423bbdb8b5f4e24a33bc8834f786c 100644 (file)
@@ -5,18 +5,6 @@ REGISTER_WEAPON(GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS, 4, WEP_FLAG_NORMAL |
 .float gl_detonate_later;
 .float gl_bouncecnt;
 
-void W_GrenadeLauncher_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_grenadelauncher_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_GRENADE_LAUNCHER];
-               self.clip_size = autocvar_g_balance_grenadelauncher_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_GrenadeLauncher_Reload()
 {
        self.reload_ammo_player = ammo_rockets;
@@ -379,7 +367,6 @@ float w_glauncher(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_GRENADE_LAUNCHER);
-               W_GrenadeLauncher_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index 274e1b61463397f3569ef093dc055d14097d51ec..3f57c141e6b9fd8060d771c2bef54c3a26e1c691 100644 (file)
@@ -4,18 +4,6 @@ REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELOAD
 #ifdef SVQC
 // NO bounce protection, as bounces are limited!
 
-void W_Hagar_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_hagar_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_HAGAR];
-               self.clip_size = autocvar_g_balance_hagar_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Hagar_Reload()
 {
        self.reload_ammo_player = ammo_rockets;
@@ -203,7 +191,6 @@ float w_hagar(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_HAGAR);
-               W_Hagar_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index 83f2bc6f55788565bd938646bafd85583824c87f..212def8af2ae555bc6f1908170bdda84a76e97bb 100644 (file)
@@ -3,18 +3,6 @@ REGISTER_WEAPON(HLAC, w_hlac, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE
 #else
 #ifdef SVQC
 
-void W_HLAC_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_hlac_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_HLAC];
-               self.clip_size = autocvar_g_balance_hlac_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_HLAC_Reload()
 {
        self.reload_ammo_player = ammo_cells;
@@ -242,7 +230,6 @@ float w_hlac(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_HLAC);
-               W_HLAC_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index c5858ad2f67c1eb59dbe42f8d81f6ca585e4d08c..3f902ac948b3aa1a9a33cd38ba28d50c82bf5c78 100644 (file)
@@ -4,18 +4,6 @@ REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WE
 #ifdef SVQC
 void(float imp) W_SwitchWeapon;
 
-void W_Laser_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_laser_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_LASER];
-               self.clip_size = autocvar_g_balance_laser_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Laser_Reload()
 {
        self.(self.reload_ammo_player) = 1;
@@ -308,7 +296,6 @@ float w_laser(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_LASER);
-               W_Laser_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index 14c67ce2c0146ccbacc89431dd4e550082332c62..20f04fed6817daa87097edea5ffa3de392dae094 100644 (file)
@@ -6,18 +6,6 @@ void W_Mine_Think (void);
 .float minelayer_detonate, minelayer_mines;
 .float mine_time;
 
-void W_MineLayer_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_minelayer_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_MINE_LAYER];
-               self.clip_size = autocvar_g_balance_minelayer_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_MineLayer_Reload()
 {
        self.reload_ammo_player = ammo_rockets;
@@ -443,7 +431,6 @@ float w_minelayer(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_MINE_LAYER);
-               W_MineLayer_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index e2c08cb99ed951a502c422523fc883eb5cc43529..267bc2547fd4c955b9be022e904e0a24eadec280 100644 (file)
@@ -4,18 +4,6 @@ REGISTER_WEAPON(MINSTANEX, w_minstanex, IT_CELLS, 7, WEP_FLAG_HIDDEN | WEP_FLAG_
 #ifdef SVQC
 .float minstanex_lasthit;
 
-void W_Minstanex_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_minstanex_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_MINSTANEX];
-               self.clip_size = autocvar_g_balance_minstanex_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Minstanex_Reload()
 {
        self.reload_ammo_player = ammo_cells;
@@ -280,7 +268,6 @@ float w_minstanex(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_MINSTANEX);
-               W_Minstanex_SetAmmoCounter();
                self.minstanex_lasthit = 0;
        }
        else if (req == WR_CHECKAMMO1)
index 33fd922a97bde137d3a9e693820e59294edd4db8..ad73ec9e425489394216e428e2cf7f03b1246129 100644 (file)
@@ -3,18 +3,6 @@ REGISTER_WEAPON(NEX, w_nex, IT_CELLS, 7, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE |
 #else
 #ifdef SVQC
 
-void W_Nex_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_nex_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_NEX];
-               self.clip_size = autocvar_g_balance_nex_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Nex_Reload()
 {
        self.reload_ammo_player = ammo_cells;
@@ -253,7 +241,6 @@ float w_nex(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_NEX);
-               W_Nex_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index e55995c43b0b82f183880e2a1a583fd5ac63b8aa..6abe83b930fd2e8da63dc8b7a506e93d1f5d1773 100644 (file)
@@ -5,18 +5,6 @@ REGISTER_WEAPON(ROCKET_LAUNCHER, w_rlauncher, IT_ROCKETS, 9, WEP_FLAG_NORMAL | W
 .float rl_release;
 .float rl_detonate_later;
 
-void W_RocketLauncher_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_rocketlauncher_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_ROCKET_LAUNCHER];
-               self.clip_size = autocvar_g_balance_rocketlauncher_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_RocketLauncher_Reload()
 {
        self.reload_ammo_player = ammo_rockets;
@@ -483,7 +471,6 @@ float w_rlauncher(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_ROCKET_LAUNCHER);
-               W_RocketLauncher_SetAmmoCounter();
                self.rl_release = 1;
        }
        else if (req == WR_CHECKAMMO1)
index d53a567c7c54b7d768b5960d08e6233f39ff3cbb..45bfd240d0100dd41f35f12c16405c4dcf218ed0 100644 (file)
@@ -5,18 +5,6 @@ REGISTER_WEAPON(SEEKER, w_seeker, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELO
 //.float proxytime; = autoswitch
 //.float tl; = wait
 
-void W_Seeker_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_seeker_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_SEEKER];
-               self.clip_size = autocvar_g_balance_seeker_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Seeker_Reload()
 {
        self.reload_ammo_player = ammo_rockets;
@@ -504,7 +492,6 @@ float w_seeker(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_SEEKER);
-               W_Seeker_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index b1e62d7c9e5855059e6b0087c2e98069879ba441..ff07f82b2f1e2c28eb6dfd068d466a1c87731af8 100644 (file)
@@ -3,18 +3,6 @@ REGISTER_WEAPON(SHOTGUN, w_shotgun, IT_SHELLS, 2, WEP_FLAG_NORMAL | WEP_FLAG_REL
 #else
 #ifdef SVQC
 
-void W_Shotgun_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_shotgun_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_SHOTGUN];
-               self.clip_size = autocvar_g_balance_shotgun_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_Shotgun_Reload()
 {
        self.reload_ammo_player = ammo_shells;
@@ -185,7 +173,6 @@ float w_shotgun(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_SHOTGUN);
-               W_Shotgun_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index 23d04d73b3ccb27d970e3de49f3de9c3dd61145f..198171f1fc2f800827c5a696e260dc685e931ce5 100644 (file)
@@ -8,18 +8,6 @@ REGISTER_WEAPON(SNIPERRIFLE, w_sniperrifle, IT_NAILS, 7, WEP_FLAG_NORMAL | WEP_F
 
 .float sniperrifle_accumulator;
 
-void W_SniperRifle_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_sniperrifle_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_SNIPERRIFLE];
-               self.clip_size = autocvar_g_balance_sniperrifle_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_SniperRifle_Reload()
 {
        self.reload_ammo_player = ammo_nails;
@@ -213,7 +201,6 @@ float w_sniperrifle(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_SNIPERRIFLE);
-               W_SniperRifle_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
index a1d286bd5ba1c01bce2b4cf4041288d56a058993..b30cf2dd19559c91c3bf4c5f611b8e4e64be5e7c 100644 (file)
@@ -3,18 +3,6 @@ REGISTER_WEAPON(UZI, w_uzi, IT_NAILS, 3, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE |
 #else
 #ifdef SVQC
 
-void W_UZI_SetAmmoCounter()
-{
-       // set clip_load to the weapon we have switched to, if the gun uses reloading
-       if(!autocvar_g_balance_uzi_reload_ammo)
-               self.clip_load = 0; // also keeps crosshair ammo from displaying
-       else
-       {
-               self.clip_load = self.weapon_load[WEP_UZI];
-               self.clip_size = autocvar_g_balance_uzi_reload_ammo; // for the crosshair ammo display
-       }
-}
-
 void W_UZI_Reload()
 {
        self.reload_ammo_player = ammo_nails;
@@ -306,7 +294,6 @@ float w_uzi(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_UZI);
-               W_UZI_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {