]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Properly do the ammo checks, and tweak the sniper rifle code (still not fixed though)
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 21 Jan 2011 15:18:29 +0000 (17:18 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 21 Jan 2011 15:18:29 +0000 (17:18 +0200)
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/w_shotgun.qc
qcsrc/server/w_sniperrifle.qc

index 94613feb89946eeddcff5f60022b2f6b75fbabb2..a92c642c705472cf74a2b05b5fbf8ab6545d212a 100644 (file)
@@ -1623,9 +1623,9 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread)
 // weapon reload code
 // ----------------------------------------------------------------
 
-float W_ReloadCheck(float ammo_amount, float ammo_use_primary, float ammo_use_secondary)
+float W_ReloadCheck(float ammo_amount)
 {
-       if(ammo_amount < min(ammo_use_primary, ammo_use_secondary)) // when we get here, ammo_counter must be 0 or -1
+       if(!ammo_amount) // when we get here, ammo_counter must be 0 or -1
        {
                print("cannot reload... not enough ammo\n");
                self.ammo_counter = -1; // reload later
index 83087c323491a9b3a77fff862692a7147100a4da..643c3158a3b261bebd2f2808765720538374d17d 100644 (file)
@@ -40,7 +40,7 @@ void W_Shotgun_Reload()
 
        float t;
 
-       if(!W_ReloadCheck(self.shotgun_load, autocvar_g_balance_shotgun_primary_ammo, 0))
+       if(!W_ReloadCheck(self.ammo_shells))
                return;
 
        sound (self, CHAN_WEAPON2, "weapons/campingrifle_reload.wav", VOL_BASE, ATTN_NORM);
index 56018ac2a9910cd4cc21686cd936ccd8ec61e4ae..5bd5d5fc6c9a00108184cbe5b5360fa734a0cae7 100644 (file)
@@ -44,7 +44,7 @@ void W_SniperRifle_Reload()
 
        float t;
 
-       if(!W_ReloadCheck(self.sniperrifle_load, autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo))
+       if(!W_ReloadCheck(self.ammo_nails))
                return;
 
        sound (self, CHAN_WEAPON2, "weapons/campingrifle_reload.wav", VOL_BASE, ATTN_NORM);
@@ -58,20 +58,6 @@ void W_SniperRifle_Reload()
        self.ammo_counter = -1;
 }
 
-float W_SniperRifle_CheckMaxBullets(float checkammo)
-{
-       float maxbulls;
-       maxbulls = autocvar_g_balance_sniperrifle_reload_ammo;
-       if(!maxbulls)
-               maxbulls = 8; // match HUD
-       if(checkammo)
-               if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-                       maxbulls = min(maxbulls, floor(self.ammo_nails / min(autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo)));
-       if(self.ammo_counter > maxbulls)
-               self.ammo_counter = maxbulls;
-       return (self.ammo_counter == maxbulls);
-}
-
 void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant)
 {
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
@@ -183,7 +169,6 @@ void W_SniperRifle_BulletHail(float mode, void(void) AttackFunc, float fr, float
 .float bot_secondary_sniperriflemooth;
 float w_sniperrifle(float req)
 {
-       float full;
        if (req == WR_AIM)
        {
                self.BUTTON_ATCK=FALSE;
@@ -209,7 +194,6 @@ float w_sniperrifle(float req)
        }
        else if (req == WR_THINK)
        {
-               W_SniperRifle_SetAmmoCounter();
                if(autocvar_g_balance_sniperrifle_reload_ammo && self.ammo_counter <= 0) // forced reload
             W_SniperRifle_Reload();
                else
@@ -266,11 +250,7 @@ float w_sniperrifle(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_SNIPERRIFLE);
-
-               full = W_SniperRifle_CheckMaxBullets(TRUE);
-               if(autocvar_g_balance_sniperrifle_auto_reload_on_switch)
-                       if(!full)
-                               self.ammo_counter = -1;
+               W_SniperRifle_SetAmmoCounter();
        }
        else if (req == WR_CHECKAMMO1)
        {
@@ -294,7 +274,6 @@ float w_sniperrifle(float req)
        {
                self.sniperrifle_accumulator = time - autocvar_g_balance_sniperrifle_bursttime;
                self.ammo_counter = autocvar_g_balance_sniperrifle_reload_ammo;
-               W_SniperRifle_CheckMaxBullets(FALSE);
        }
        return TRUE;
 };