]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_electro.qc
Merge branch 'master' into mirceakitsune/universal_reload_system
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_electro.qc
index c4cd72689843646e50a916b660850d4fc7215131..154e7275c625b1cf1403727fa26bdc1804e07183 100644 (file)
@@ -5,6 +5,7 @@ REGISTER_WEAPON(ELECTRO, w_electro, IT_CELLS, 5, WEP_FLAG_NORMAL | WEP_TYPE_SPLA
 .float electro_count;
 .float electro_secondarytime;
 
+// weapon load persistence, for weapons that support reloading
 .float electro_load;
 
 void W_Electro_SetAmmoCounter()
@@ -439,6 +440,7 @@ void w_electro_checkattack()
 .float BUTTON_ATCK_prev;
 float w_electro(float req)
 {
+       float ammo_amount;
        if (req == WR_AIM)
        {
                self.BUTTON_ATCK=FALSE;
@@ -527,18 +529,6 @@ float w_electro(float req)
                                }
                        }
                }
-
-        if(self.wish_reload)
-        {
-            if(self.switchweapon == self.weapon)
-            {
-                if(self.weaponentity.state == WS_READY)
-                {
-                    self.wish_reload = 0;
-                    W_Electro_Reload();
-                }
-            }
-        }
        }
        else if (req == WR_PRECACHE)
        {
@@ -550,6 +540,7 @@ float w_electro(float req)
                precache_sound ("weapons/electro_fire2.wav");
                precache_sound ("weapons/electro_impact.wav");
                precache_sound ("weapons/electro_impact_combo.wav");
+               precache_sound ("weapons/reload.wav");
                if(autocvar_g_balance_electro_lightning)
                {
                        precache_sound ("weapons/lgbeam_fire.wav");
@@ -562,31 +553,31 @@ float w_electro(float req)
        }
        else if (req == WR_CHECKAMMO1)
        {
-               if(autocvar_g_balance_electro_reload_ammo)
-               {
-                       if(autocvar_g_balance_electro_lightning)
-                               return !autocvar_g_balance_electro_primary_ammo || (self.electro_load > 0);
-                       else
-                               return self.electro_load >= autocvar_g_balance_electro_primary_ammo;
-               }
+               if(autocvar_g_balance_electro_lightning)
+                       ammo_amount = !autocvar_g_balance_electro_primary_ammo || (self.ammo_cells > 0);
                else
+                       ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_primary_ammo;
+               if(autocvar_g_balance_electro_reload_ammo)
                {
                        if(autocvar_g_balance_electro_lightning)
-                               return !autocvar_g_balance_electro_primary_ammo || (self.ammo_cells > 0);
+                               ammo_amount += !autocvar_g_balance_electro_primary_ammo || (self.electro_load > 0);
                        else
-                               return self.ammo_cells >= autocvar_g_balance_electro_primary_ammo;
+                               ammo_amount += self.electro_load >= autocvar_g_balance_electro_primary_ammo;
                }
+               return ammo_amount;
        }
        else if (req == WR_CHECKAMMO2)
        {
-               if(autocvar_g_balance_electro_reload_ammo)
-                       return self.electro_load >= autocvar_g_balance_electro_secondary_ammo;
-               else
-                       return self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
+               ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
+               ammo_amount += (autocvar_g_balance_electro_reload_ammo && self.electro_load >= autocvar_g_balance_electro_secondary_ammo);
+               return ammo_amount;
        }
        else if (req == WR_RESETPLAYER)
        {
                self.electro_secondarytime = time;
+
+               // all weapons must be fully loaded when we spawn
+               self.electro_load = autocvar_g_balance_electro_reload_ammo;
        }
        else if (req == WR_RELOAD)
        {
@@ -633,27 +624,27 @@ float w_electro(float req)
        else if (req == WR_SUICIDEMESSAGE)
        {
                if(w_deathtype & HITTYPE_SECONDARY)
-                       w_deathtypestring = "%s could not remember where they put plasma";
+                       w_deathtypestring = _("%s could not remember where they put plasma");
                else
-                       w_deathtypestring = "%s played with plasma";
+                       w_deathtypestring = _("%s played with plasma");
        }
        else if (req == WR_KILLMESSAGE)
        {
                if(w_deathtype & HITTYPE_SECONDARY)
                {
                        if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
-                               w_deathtypestring = "%s just noticed %s's blue ball";
+                               w_deathtypestring = _("%s just noticed %s's blue ball");
                        else // unchecked: BOUNCE
-                               w_deathtypestring = "%s got in touch with %s's blue ball";
+                               w_deathtypestring = _("%s got in touch with %s's blue ball");
                }
                else
                {
                        if(w_deathtype & HITTYPE_BOUNCE) // combo
-                               w_deathtypestring = "%s felt the electrifying air of %s's combo";
+                               w_deathtypestring = _("%s felt the electrifying air of %s's combo");
                        else if(w_deathtype & HITTYPE_SPLASH)
-                               w_deathtypestring = "%s got too close to %s's blue beam";
+                               w_deathtypestring = _("%s got too close to %s's blue beam");
                        else
-                               w_deathtypestring = "%s was blasted by %s's blue beam";
+                               w_deathtypestring = _("%s was blasted by %s's blue beam");
                }
        }
        return TRUE;