]> 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 e73600eaeeb1ed16b9d7c0d852c6ca512157e6a1..d45edbbed7bc58bc2962eb0cb9af48b186569936 100644 (file)
@@ -9,6 +9,7 @@ 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()
@@ -47,7 +48,7 @@ void W_Crylink_Reload()
        if(!autocvar_g_balance_crylink_reload_ammo)
                return;
 
-       if(!W_ReloadCheck(self.ammo_cells))
+       if(!W_ReloadCheck(self.ammo_cells, min(autocvar_g_balance_crylink_primary_ammo, autocvar_g_balance_crylink_secondary_ammo)))
                return;
 
        float t;
@@ -373,6 +374,18 @@ void W_Crylink_Attack (void)
        vector forward, right, up;
        float maxdmg;
 
+       // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
+       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+       {
+               if(autocvar_g_balance_crylink_reload_ammo)
+               {
+                       self.clip_load -= autocvar_g_balance_crylink_primary_ammo;
+                       self.crylink_load = self.clip_load;
+               }
+               else
+                       self.ammo_cells -= autocvar_g_balance_crylink_primary_ammo;
+       }
+
        maxdmg = autocvar_g_balance_crylink_primary_damage*autocvar_g_balance_crylink_primary_shots;
        maxdmg *= 1 + autocvar_g_balance_crylink_primary_bouncedamagefactor * autocvar_g_balance_crylink_primary_bounces;
        if(autocvar_g_balance_crylink_primary_joinexplode)
@@ -465,25 +478,25 @@ void W_Crylink_Attack (void)
                counter = counter + 1;
        }
        self.crylink_lastgroup = proj;
+}
+
+void W_Crylink_Attack2 (void)
+{
+       local float counter, shots;
+       local entity proj, prevproj, firstproj;
+       float maxdmg;
 
        // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
        {
                if(autocvar_g_balance_crylink_reload_ammo)
                {
-                       self.clip_load -= autocvar_g_balance_crylink_primary_ammo;
+                       self.clip_load -= autocvar_g_balance_crylink_secondary_ammo;
                        self.crylink_load = self.clip_load;
                }
                else
-                       self.ammo_cells -= autocvar_g_balance_crylink_primary_ammo;
+                       self.ammo_cells -= autocvar_g_balance_crylink_secondary_ammo;
        }
-}
-
-void W_Crylink_Attack2 (void)
-{
-       local float counter, shots;
-       local entity proj, prevproj, firstproj;
-       float maxdmg;
 
        maxdmg = autocvar_g_balance_crylink_secondary_damage*autocvar_g_balance_crylink_secondary_shots;
        maxdmg *= 1 + autocvar_g_balance_crylink_secondary_bouncedamagefactor * autocvar_g_balance_crylink_secondary_bounces;
@@ -562,18 +575,6 @@ void W_Crylink_Attack2 (void)
                counter = counter + 1;
        }
        self.crylink_lastgroup = proj;
-
-       // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-       {
-               if(autocvar_g_balance_crylink_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_crylink_secondary_ammo;
-                       self.crylink_load = self.clip_load;
-               }
-               else
-                       self.ammo_cells -= autocvar_g_balance_crylink_secondary_ammo;
-       }
 }
 
 void spawnfunc_weapon_crylink (void)
@@ -583,6 +584,7 @@ void spawnfunc_weapon_crylink (void)
 
 float w_crylink(float req)
 {
+       float ammo_amount;
        if (req == WR_AIM)
        {
                if (random() < 0.10)
@@ -652,17 +654,6 @@ float w_crylink(float req)
                                }
                        }
                }
-        if(self.wish_reload)
-        {
-            if(self.switchweapon == self.weapon)
-            {
-                if(self.weaponentity.state == WS_READY)
-                {
-                    self.wish_reload = 0;
-                    W_Crylink_Reload();
-                }
-            }
-        }
        }
        else if (req == WR_PRECACHE)
        {
@@ -672,6 +663,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)
        {
@@ -684,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)
        {
@@ -695,10 +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_RESETPLAYER)
+       {
+               // all weapons must be fully loaded when we spawn
+               self.crylink_load = autocvar_g_balance_crylink_reload_ammo;
+       }
+       else if (req == WR_RELOAD)
+       {
+               W_Crylink_Reload();
        }
        return TRUE;
 };
@@ -730,20 +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
-       }
-       else if (req == WR_RELOAD)
-       {
-               W_Crylink_Reload();
+                       w_deathtypestring = _("%s took a close look at %s's Crylink"); // unchecked: SECONDARY
        }
        return TRUE;
 }