]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_laser.qc
Merge remote-tracking branch 'origin/master' into samual/balance
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_laser.qc
index 05542ee6aba0328fdc4067ece1a32984f6e65201..a7e5c4df7d272f785e3dd2fc7d4e576eed97806e 100644 (file)
@@ -1,56 +1,9 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "laser", "laser", _("Laser"))
+REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "laser", "laser", _("Laser"))
 #else
 #ifdef SVQC
 void(float imp) W_SwitchWeapon;
 
-.float laser_load;
-
-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.laser_load;
-               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.clip_load = -1;
-}
-
 void W_Laser_Touch (void)
 {
        PROJECTILE_TOUCH;
@@ -274,20 +227,12 @@ float w_laser(float req)
        else if (req == WR_THINK)
        {
                if(autocvar_g_balance_laser_reload_ammo && self.clip_load < 1) // forced reload
-                       W_Laser_Reload();
+                       weapon_action(self.weapon, WR_RELOAD);
                else if (self.BUTTON_ATCK)
                {
                        if (weapon_prepareattack(0, autocvar_g_balance_laser_primary_refire))
                        {
-                               // if this weapon is reloadable, decrease its load
-                               if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-                               {
-                                       if(autocvar_g_balance_laser_reload_ammo)
-                                       {
-                                               self.clip_load -= 1;
-                                               self.laser_load = self.clip_load;
-                                       }
-                               }
+                               W_DecreaseAmmo(ammo_none, 1, TRUE);
 
                                W_Laser_Attack(0);
                                weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_laser_primary_animtime, w_ready);
@@ -297,15 +242,7 @@ float w_laser(float req)
                {
                        if(autocvar_g_balance_laser_secondary)
                        {
-                               // if this weapon is reloadable, decrease its load
-                               if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-                               {
-                                       if(autocvar_g_balance_laser_reload_ammo)
-                                       {
-                                               self.clip_load -= 1;
-                                               self.laser_load = self.clip_load;
-                                       }
-                               }
+                               W_DecreaseAmmo(ammo_none, 1, TRUE);
 
                                if (weapon_prepareattack(0, 0))
                                {
@@ -319,17 +256,6 @@ float w_laser(float req)
                                        W_SwitchWeapon (self.cnt);
                        }
                }
-        if(self.wish_reload)
-        {
-            if(self.switchweapon == self.weapon)
-            {
-                if(self.weaponentity.state == WS_READY)
-                {
-                    self.wish_reload = 0;
-                    W_Laser_Reload();
-                }
-            }
-        }
        }
        else if (req == WR_PRECACHE)
        {
@@ -338,18 +264,25 @@ float w_laser(float req)
                precache_model ("models/weapons/h_laser.iqm");
                precache_sound ("weapons/lasergun_fire.wav");
                precache_sound ("weapons/gauntlet_fire.wav");
+               //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
        }
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_LASER);
-               W_Laser_SetAmmoCounter();
+               self.current_ammo = ammo_none;
        }
        else if (req == WR_CHECKAMMO1)
+       {
                return TRUE;
+       }
        else if (req == WR_CHECKAMMO2)
+       {
                return TRUE;
+       }
        else if (req == WR_RELOAD)
-               W_Laser_Reload();
+       {
+               W_Reload(0, autocvar_g_balance_laser_reload_ammo, autocvar_g_balance_laser_reload_time, "weapons/reload.wav");
+       }
        return TRUE;
 };
 #endif
@@ -369,13 +302,13 @@ float w_laser(float req)
                precache_sound("weapons/laserimpact.wav");
        }
        else if (req == WR_SUICIDEMESSAGE)
-               w_deathtypestring = "%s lasered themself to hell";
+               w_deathtypestring = _("%s lasered themself to hell");
        else if (req == WR_KILLMESSAGE)
        {
                if(w_deathtype & HITTYPE_SECONDARY)
-                       w_deathtypestring = "%s was cut in half by %s's gauntlet"; // unchecked: SPLASH
+                       w_deathtypestring = _("%s was cut in half by %s's gauntlet"); // unchecked: SPLASH
                else
-                       w_deathtypestring = "%s was lasered to death by %s"; // unchecked: SPLASH
+                       w_deathtypestring = _("%s was lasered to death by %s"); // unchecked: SPLASH
        }
        return TRUE;
 }