]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/selection.qc
Merge branch 'master' into TimePath/effectinfo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / selection.qc
index 868d6b041b0dc9207fa5fbe6920ad6286d04699e..ce464c18e49252562f12f5b2b17e8dcd0716a9dc 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "weaponsystem.qh"
 #include "../t_items.qh"
-#include "../waypointsprites.qh"
 #include "../../common/constants.qh"
 #include "../../common/util.qh"
 #include "../../common/weapons/all.qh"
@@ -19,9 +18,8 @@ void Send_WeaponComplain(entity e, float wpn, float type)
 }
 
 float client_hasweapon(entity cl, float wpn, float andammo, float complain)
-{
+{SELFPARAM();
        float f;
-       entity oldself;
 
        if(time < self.hasweapon_complain_spam)
                complain = 0;
@@ -48,8 +46,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        }
                        else
                        {
-                               oldself = self;
-                               self = cl;
+                               setself(cl);
                                f = WEP_ACTION(wpn, WR_CHECKAMMO1);
                                f = f + WEP_ACTION(wpn, WR_CHECKAMMO2);
 
@@ -59,14 +56,14 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
                                        f = 1;
 
-                               self = oldself;
+                               setself(this);
                        }
                        if (!f)
                        {
                                if (complain)
                                if(IS_REAL_CLIENT(cl))
                                {
-                                       play2(cl, "weapons/unavailable.wav");
+                                       play2(cl, SND(UNAVAILABLE));
                                        Send_WeaponComplain (cl, wpn, 0);
                                }
                                return false;
@@ -92,15 +89,16 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                                continue;
                                        if(!(e.flags & FL_ITEM))
                                                continue;
-                                       WaypointSprite_Spawn(
-                                               (get_weaponinfo(wpn)).wpmodel,
+                                       entity wp = WaypointSprite_Spawn(
+                                               WP_Weapon,
                                                1, 0,
                                                world, e.origin + ('0 0 1' * e.maxs.z) * 1.2,
                                                self, 0,
                                                world, enemy,
                                                0,
-                                               RADARICON_NONE, '0 0 0'
+                                               RADARICON_NONE
                                        );
+                                       wp.wp_extra = wpn;
                                }
                        }
                }
@@ -109,13 +107,13 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        Send_WeaponComplain (cl, wpn, 2);
                }
 
-               play2(cl, "weapons/unavailable.wav");
+               play2(cl, SND(UNAVAILABLE));
        }
        return false;
 }
 
 float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing)
-{
+{SELFPARAM();
        // We cannot tokenize in this function, as GiveItems calls this
        // function. Thus we must use car/cdr.
        float weaponwant, first_valid, prev_valid, switchtonext, switchtolast;
@@ -254,7 +252,7 @@ void W_SwitchToOtherWeapon(entity pl)
 }
 
 void W_SwitchWeapon(float imp)
-{
+{SELFPARAM();
        if (self.switchweapon != imp)
        {
                if (client_hasweapon(self, imp, true, true))
@@ -266,7 +264,7 @@ void W_SwitchWeapon(float imp)
 }
 
 void W_CycleWeapon(string weaponorder, float dir)
-{
+{SELFPARAM();
        float w;
        w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1, true);
        if(w > 0)
@@ -274,7 +272,7 @@ void W_CycleWeapon(string weaponorder, float dir)
 }
 
 void W_NextWeaponOnImpulse(float imp)
-{
+{SELFPARAM();
        float w;
        w = W_GetCycleWeapon(self, self.cvar_cl_weaponpriority, +1, imp, 1, (self.cvar_cl_weaponimpulsemode == 0));
        if(w > 0)
@@ -283,7 +281,7 @@ void W_NextWeaponOnImpulse(float imp)
 
 // next weapon
 void W_NextWeapon(float list)
-{
+{SELFPARAM();
        if(list == 0)
                W_CycleWeapon(weaponorder_byid, -1);
        else if(list == 1)
@@ -294,7 +292,7 @@ void W_NextWeapon(float list)
 
 // prev weapon
 void W_PreviousWeapon(float list)
-{
+{SELFPARAM();
        if(list == 0)
                W_CycleWeapon(weaponorder_byid, +1);
        else if(list == 1)
@@ -305,7 +303,7 @@ void W_PreviousWeapon(float list)
 
 // previously used if exists and has ammo, (second) best otherwise
 void W_LastWeapon(void)
-{
+{SELFPARAM();
        if(client_hasweapon(self, self.cnt, true, false))
                W_SwitchWeapon(self.cnt);
        else