]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Part 2 of per-weapon load persistence. Much closer to what it should be like
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 21 Jan 2011 02:03:50 +0000 (04:03 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 21 Jan 2011 02:03:50 +0000 (04:03 +0200)
balanceXonotic.cfg
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/w_shotgun.qc
qcsrc/server/w_sniperrifle.qc

index 414222b286d664a6687262010c9be19b40fda71d..24bdbe08bd8a0724f4bfdb44a80ca1fa3e4d6483 100644 (file)
@@ -263,7 +263,7 @@ set g_balance_shotgun_secondary_damage 110
 set g_balance_shotgun_secondary_force 150
 set g_balance_shotgun_secondary_refire 1.1
 set g_balance_shotgun_secondary_animtime 1
-set g_balance_shotgun_reload_ammo 4
+set g_balance_shotgun_reload_ammo 5
 // }}}
 // {{{ uzi
 set g_balance_uzi_mode 1                               // Activates varible spread for sustained & burst mode secondary
index 31f3da102e35848990a359a2b179adcbac83e7a8..914abef3580ff399fe87232620b2db82df0ec975 100644 (file)
@@ -1616,27 +1616,16 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread)
 // weapon reload code
 // ----------------------------------------------------------------
 
-void W_ReloadedAndReady()
+float W_ReloadCheck(float ammo_amount)
 {
-       float t;
-       self.ammo_counter = autocvar_g_balance_sniperrifle_magazinecapacity;
-       t = ATTACK_FINISHED(self) - autocvar_g_balance_sniperrifle_reloadtime - 1;
-       ATTACK_FINISHED(self) = t;
-       w_ready();
-}
-
-float W_Reload(float ammo_value)
-{
-       float t;
-
-       if(ammo_value < min(autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo)) // when we get here, bulletcounter must be 0 or -1
+       if(ammo_amount < min(autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo)) // when we get here, ammo_counter must be 0 or -1
        {
-               print("cannot reload... not enough bullets\n");
+               print("cannot reload... not enough ammo\n");
                self.ammo_counter = -1; // reload later
                W_SwitchToOtherWeapon(self);
                return 0;
        }
-       
+
        if (self.ammo_counter >= autocvar_g_balance_shotgun_reload_ammo)
                return 0;
 
@@ -1649,15 +1638,6 @@ float W_Reload(float ammo_value)
                self.weaponentity.state = WS_READY;
        }
 
-       sound (self, CHAN_WEAPON2, "weapons/campingrifle_reload.wav", VOL_BASE, ATTN_NORM);
-
-       t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_sniperrifle_reloadtime + 1;
-       ATTACK_FINISHED(self) = t;
-
-       weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_sniperrifle_reloadtime, W_ReloadedAndReady);
-
-       self.ammo_counter = -1;
-
        return 1;
 }
 
index 4af29229d58f01bb58800389ec129e07725431dd..13f2cfe67e4292621205b64c210f9e510e3032ae 100644 (file)
@@ -7,31 +7,50 @@ REGISTER_WEAPON(SHOTGUN, w_shotgun, IT_SHELLS, 2, WEP_FLAG_NORMAL | WEP_TYPE_HIT
 
 void W_Shotgun_SetAmmoCounter()
 {
-       // set our ammo counter to the weapon we have switched to
+       // set ammo counter to the weapon we have switched to
        if(!autocvar_g_balance_shotgun_reload_ammo)
                self.ammo_counter = 0; // also keeps the crosshair ammo from displaying
        else
                self.ammo_counter = self.shotgun_load;
 }
 
+void W_Shotgun_ReloadedAndReady()
+{
+       float t;
+
+       // now do the ammo maths
+       self.ammo_counter = 0; // when we get here it's -1
+       while(self.ammo_counter < autocvar_g_balance_shotgun_reload_ammo)
+       {
+               self.ammo_counter += 1;
+               self.ammo_shells -= 1;
+       }
+       self.shotgun_load = self.ammo_counter;
+
+       t = ATTACK_FINISHED(self) - autocvar_g_balance_sniperrifle_reloadtime - 1;
+       ATTACK_FINISHED(self) = t;
+       w_ready();
+}
+
 void W_Shotgun_Reload()
 {
        // reloading is disabled for this weapon
        if(!autocvar_g_balance_shotgun_reload_ammo)
                return;
 
-       w_ready();
-       if(W_Reload(self.ammo_shells))
-       {
-               // now do the actual ammo transfer
-               for(self.shotgun_load; self.shotgun_load < autocvar_g_balance_shotgun_reload_ammo && self.ammo_shells; )
-               {
-                       self.ammo_counter += 1;
-                       self.shotgun_load = self.ammo_counter;
-                       self.ammo_shells -= 1;
-               }
+       float t;
+
+       if(!W_ReloadCheck(self.ammo_shells))
                return;
-       }
+
+       sound (self, CHAN_WEAPON2, "weapons/campingrifle_reload.wav", VOL_BASE, ATTN_NORM);
+
+       t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_sniperrifle_reloadtime + 1;
+       ATTACK_FINISHED(self) = t;
+
+       weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_sniperrifle_reloadtime, W_Shotgun_ReloadedAndReady);
+
+       self.ammo_counter = -1;
 }
 
 void W_Shotgun_Attack (void)
@@ -182,7 +201,7 @@ float w_shotgun(float req)
                 if(self.weaponentity.state == WS_READY)
                 {
                     self.wish_reload = 0;
-                    W_Reload(self.ammo_shells);
+                    W_Shotgun_Reload();
                 }
             }
         }
index 378e0622aa6f28e7d297799d92908d48008e9cf0..10d77affa11faa331d71fd43210f10adc76d4083 100644 (file)
@@ -24,13 +24,13 @@ void W_SniperRifle_Reload()
                return;
 
        w_ready();
-       if(W_Reload(self.ammo_nails))
+       /*if(W_Reload(self.ammo_nails))
        {
                // now do the actual ammo transfer
                for(self.sniperrifle_load; self.sniperrifle_load < autocvar_g_balance_shotgun_reload_ammo && self.ammo_nails; ++self.sniperrifle_load)
                        self.ammo_nails -= 1;
                return;
-       }
+       }*/
 }
 
 float W_SniperRifle_CheckMaxBullets(float checkammo)
@@ -110,8 +110,8 @@ void spawnfunc_weapon_campingrifle (void)
 void W_SniperRifle_BulletHail_Continue()
 {
        float r, sw, af;
-       if(self.ammo_counter <= 0)
-               W_SniperRifle_Reload();
+       //if(self.ammo_counter <= 0)
+               //W_SniperRifle_Reload();
        if(self.ammo_counter < 0)
                return; // reloading, so we are done
        sw = self.switchweapon; // make it not detect weapon changes as reason to abort firing
@@ -224,7 +224,7 @@ float w_sniperrifle(float req)
                 if(self.weaponentity.state == WS_READY)
                 {
                     self.wish_reload = 0;
-                    W_Reload(self.ammo_nails);
+                    //W_Reload(self.ammo_nails);
                 }
             }
         }