]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Adapt the laser and its no-ammo usage too
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 30 Jan 2011 17:57:59 +0000 (19:57 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 30 Jan 2011 17:57:59 +0000 (19:57 +0200)
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/w_laser.qc

index 78135fcc98bf76b62c43a5e03a8d2846f1897bf0..90c581f3830e66522f41c96fe00932dfde2138d7 100644 (file)
@@ -1617,15 +1617,12 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread)
 .float reload_complain;
 float W_ReloadCheck(float ammo_amount, float ammo_shot)
 {
-       entity e;
-       e = get_weaponinfo(self.weapon);
-
        // our weapon is fully loaded, no need to reload
        if (self.clip_load >= self.reload_ammo_amount)
-               return 0;
+               return FALSE;
 
        // no ammo, so nothing to load
-       if(!ammo_amount)
+       if(!ammo_amount && ammo_shot)
        {
                if(clienttype(self) == CLIENTTYPE_REAL && self.reload_complain < time)
                {
@@ -1639,19 +1636,19 @@ float W_ReloadCheck(float ammo_amount, float ammo_shot)
                        self.clip_load = -1; // reload later
                        W_SwitchToOtherWeapon(self);
                }
-               return 0;
+               return FALSE;
        }
 
        if (self.weaponentity)
        {
                if (self.weaponentity.wframe == WFRAME_RELOAD)
-                       return 0;
+                       return FALSE;
 
                // allow switching away while reloading, but this will cause a new reload!
                self.weaponentity.state = WS_READY;
        }
 
-       return 1;
+       return TRUE;
 }
 
 void W_ReloadedAndReady()
@@ -1659,11 +1656,19 @@ void W_ReloadedAndReady()
        float t;
 
        // now do the ammo transfer
+
        self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
-       while(self.clip_load < self.reload_ammo_amount && self.(self.reload_ammo_player)) // make sure we don't add more ammo than we have
+
+       // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load
+       if(!self.reload_ammo_min)
+               self.clip_load = self.reload_ammo_amount;
+       else
        {
-               self.clip_load += 1;
-               self.(self.reload_ammo_player) -= 1;
+               while(self.clip_load < self.reload_ammo_amount && self.(self.reload_ammo_player)) // make sure we don't add more ammo than we have
+               {
+                       self.clip_load += 1;
+                       self.(self.reload_ammo_player) -= 1;
+               }
        }
        self.weapon_load[self.weapon] = self.clip_load;
 
index 6164f543d863fe2a1e5b64c6082ad8eab9141a5d..0f27f4d7889f99670d0595cee80673fb3585f848 100644 (file)
@@ -4,9 +4,6 @@ REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_
 #ifdef SVQC
 void(float imp) W_SwitchWeapon;
 
-// weapon load persistence, for weapons that support reloading
-.float laser_load;
-
 void W_Laser_SetAmmoCounter()
 {
        // set clip_load to the weapon we have switched to, if the gun uses reloading
@@ -14,42 +11,20 @@ void W_Laser_SetAmmoCounter()
                self.clip_load = 0; // also keeps crosshair ammo from displaying
        else
        {
-               self.clip_load = self.laser_load;
+               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_ReloadedAndReady()
-{
-       float t;
-
-       self.clip_load = autocvar_g_balance_laser_reload_ammo; // maximum load since this weapon uses no ammo
-       self.laser_load = self.clip_load;
-
-       t = ATTACK_FINISHED(self) - autocvar_g_balance_laser_reload_time - 1;
-       ATTACK_FINISHED(self) = t;
-       w_ready();
-}
-
 void W_Laser_Reload()
 {
-       // return if reloading is disabled for this weapon
-       if(!autocvar_g_balance_laser_reload_ammo)
-               return;
-
-       if(!W_ReloadCheck(1, 0))
-               return;
-
-       float t;
-
-       sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
-
-       t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_laser_reload_time + 1;
-       ATTACK_FINISHED(self) = t;
-
-       weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_laser_reload_time, W_Laser_ReloadedAndReady);
+       self.(self.reload_ammo_player) = 0;
+       self.reload_ammo_min = 0;
+       self.reload_ammo_amount = autocvar_g_balance_laser_reload_ammo;
+       self.reload_time = autocvar_g_balance_laser_reload_time;
+       self.reload_sound = "weapons/reload.wav";
 
-       self.clip_load = -1;
+       W_Reload();
 }
 
 void W_Laser_Touch (void)
@@ -286,7 +261,7 @@ float w_laser(float req)
                                        if(autocvar_g_balance_laser_reload_ammo)
                                        {
                                                self.clip_load -= 1;
-                                               self.laser_load = self.clip_load;
+                                               self.weapon_load[WEP_LASER] = self.clip_load;
                                        }
                                }
 
@@ -304,7 +279,7 @@ float w_laser(float req)
                                        if(autocvar_g_balance_laser_reload_ammo)
                                        {
                                                self.clip_load -= 1;
-                                               self.laser_load = self.clip_load;
+                                               self.weapon_load[WEP_LASER] = self.clip_load;
                                        }
                                }
 
@@ -346,7 +321,7 @@ float w_laser(float req)
        else if (req == WR_RESETPLAYER)
        {
                // all weapons must be fully loaded when we spawn
-               self.laser_load = autocvar_g_balance_laser_reload_ammo;
+               self.weapon_load[WEP_LASER] = autocvar_g_balance_laser_reload_ammo;
        }
        else if (req == WR_RELOAD)
        {