]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_crylink.qc
Doh, it CAN be done differently than my ugly list. Use WR checks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_crylink.qc
index 604efbe1c1cd5ac3b0b83e5ae08b6ffa3786c6b8..74b6e92736dd426792fe2a827dbe2bda973e7c3a 100644 (file)
@@ -9,8 +9,6 @@ REGISTER_WEAPON(CRYLINK, w_crylink, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_TYPE_SPLA
 .entity queuenext;
 .entity queueprev;
 
-.float crylink_load;
-
 void W_Crylink_SetAmmoCounter()
 {
        // set clip_load to the weapon we have switched to, if the gun uses reloading
@@ -672,6 +670,7 @@ float w_crylink(float req)
                precache_sound ("weapons/crylink_fire.wav");
                precache_sound ("weapons/crylink_fire2.wav");
                precache_sound ("weapons/crylink_linkjoin.wav");
+               precache_sound ("weapons/reload.wav");
        }
        else if (req == WR_SETUP)
        {
@@ -700,6 +699,19 @@ float w_crylink(float req)
                else
                        return self.ammo_cells >= autocvar_g_balance_crylink_secondary_ammo;
        }
+       else if (req == WR_RELOAD)
+       {
+               W_Crylink_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_crylink_primary_ammo, autocvar_g_balance_crylink_secondary_ammo);
+               return self.crylink_load >= ammo_amount || self.ammo_cells >= ammo_amount;
+       }
        return TRUE;
 };
 #endif
@@ -741,10 +753,6 @@ float w_crylink(float req)
                else
                        w_deathtypestring = "%s took a close look at %s's Crylink"; // unchecked: SECONDARY
        }
-       else if (req == WR_RELOAD)
-       {
-               W_Crylink_Reload();
-       }
        return TRUE;
 }
 #endif