]> 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 247437bc06853735ca1f14bef431d984420e0d95..154e7275c625b1cf1403727fa26bdc1804e07183 100644 (file)
@@ -5,6 +5,9 @@ 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()
 {
        // set clip_load to the weapon we have switched to, if the gun uses reloading
@@ -437,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;
@@ -549,45 +553,36 @@ 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)
        {
                W_Shotgun_Reload();
        }
-       else if (req == WR_SWITCHABLE)
-       {
-               // checks if this weapon can be switched to, when reloading is enabled
-               // returns true if there's either enough load in the weapon to use it,
-               // or we have enough ammo to reload the weapon to a usable point
-               float ammo_amount;
-               ammo_amount = min(autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_secondary_ammo);
-               return (autocvar_g_balance_electro_reload_ammo && self.electro_load >= ammo_amount) || self.ammo_cells >= ammo_amount;
-       }
        return TRUE;
 };
 #endif
@@ -629,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;