]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_crylink.qc
Merge branch 'master' into mirceakitsune/universal_reload_system
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_crylink.qc
index 4f3d5ae2392bd627f3773d92ce532c38914f2a05..d45edbbed7bc58bc2962eb0cb9af48b186569936 100644 (file)
@@ -9,6 +9,9 @@ REGISTER_WEAPON(CRYLINK, w_crylink, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_TYPE_SPLA
 .entity queuenext;
 .entity queueprev;
 
+// weapon load persistence, for weapons that support reloading
+.float crylink_load;
+
 void W_Crylink_SetAmmoCounter()
 {
        // set clip_load to the weapon we have switched to, if the gun uses reloading
@@ -581,6 +584,7 @@ void spawnfunc_weapon_crylink (void)
 
 float w_crylink(float req)
 {
+       float ammo_amount;
        if (req == WR_AIM)
        {
                if (random() < 0.10)
@@ -672,10 +676,9 @@ float w_crylink(float req)
                if(self.crylink_lastgroup && self.crylink_waitrelease)
                        return TRUE;
 
-               if(autocvar_g_balance_crylink_reload_ammo)
-                       return self.crylink_load >= autocvar_g_balance_crylink_primary_ammo;
-               else
-                       return self.ammo_cells >= autocvar_g_balance_crylink_primary_ammo;
+               ammo_amount = self.ammo_cells >= autocvar_g_balance_crylink_primary_ammo;
+               ammo_amount += (autocvar_g_balance_crylink_reload_ammo && self.crylink_load >= autocvar_g_balance_crylink_primary_ammo);
+               return ammo_amount;
        }
        else if (req == WR_CHECKAMMO2)
        {
@@ -683,23 +686,18 @@ float w_crylink(float req)
                if(self.crylink_lastgroup && self.crylink_waitrelease)
                        return TRUE;
 
-               if(autocvar_g_balance_crylink_reload_ammo)
-                       return self.crylink_load >= autocvar_g_balance_crylink_secondary_ammo;
-               else
-                       return self.ammo_cells >= autocvar_g_balance_crylink_secondary_ammo;
+               ammo_amount = self.ammo_cells >= autocvar_g_balance_crylink_secondary_ammo;
+               ammo_amount += (autocvar_g_balance_crylink_reload_ammo && self.crylink_load >= autocvar_g_balance_crylink_secondary_ammo);
+               return ammo_amount;
        }
-       else if (req == WR_RELOAD)
+       else if (req == WR_RESETPLAYER)
        {
-               W_Crylink_Reload();
+               // all weapons must be fully loaded when we spawn
+               self.crylink_load = autocvar_g_balance_crylink_reload_ammo;
        }
-       else if (req == WR_SWITCHABLE)
+       else if (req == WR_RELOAD)
        {
-               // 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_crylink_primary_ammo, autocvar_g_balance_crylink_secondary_ammo);
-               return (autocvar_g_balance_crylink_reload_ammo && self.crylink_load >= ammo_amount) || self.ammo_cells >= ammo_amount;
+               W_Crylink_Reload();
        }
        return TRUE;
 };
@@ -731,16 +729,16 @@ float w_crylink(float req)
        }
        else if (req == WR_SUICIDEMESSAGE)
        {
-               w_deathtypestring = "%s succeeded at self-destructing themself with the Crylink";
+               w_deathtypestring = _("%s succeeded at self-destructing themself with the Crylink");
        }
        else if (req == WR_KILLMESSAGE)
        {
                if(w_deathtype & HITTYPE_BOUNCE)
-                       w_deathtypestring = "%s could not hide from %s's Crylink"; // unchecked: SPLASH (SECONDARY can't be)
+                       w_deathtypestring = _("%s could not hide from %s's Crylink"); // unchecked: SPLASH (SECONDARY can't be)
                else if(w_deathtype & HITTYPE_SPLASH)
-                       w_deathtypestring = "%s was too close to %s's Crylink"; // unchecked: SECONDARY
+                       w_deathtypestring = _("%s was too close to %s's Crylink"); // unchecked: SECONDARY
                else
-                       w_deathtypestring = "%s took a close look at %s's Crylink"; // unchecked: SECONDARY
+                       w_deathtypestring = _("%s took a close look at %s's Crylink"); // unchecked: SECONDARY
        }
        return TRUE;
 }