]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/selection.qc
Merge remote-tracking branch 'origin/master' into samual/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / selection.qc
index 95a145e692dae94a7e4991d422c7abe0abcb89bf..c232795919afc01e45aeb2c39903740f6127d417 100644 (file)
@@ -9,7 +9,6 @@ void Send_WeaponComplain(entity e, float wpn, string wpnname, float type)
        WriteByte(MSG_ONE, type);
 }
 
-.float hasweapon_complain_spam;
 float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 {
        float f;
@@ -17,6 +16,10 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 
        if(time < self.hasweapon_complain_spam)
                complain = 0;
+
+       if(wpn == WEP_HOOK && !g_grappling_hook && autocvar_g_nades && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
+               complain = 0;
+               
        if(complain)
                self.hasweapon_complain_spam = time + 0.2;
 
@@ -26,7 +29,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        sprint(self, "Invalid weapon\n");
                return FALSE;
        }
-       if (WEPSET_CONTAINS_EW(cl, wpn))
+       if (cl.weapons & WepSet_FromWeapon(wpn))
        {
                if (andammo)
                {
@@ -66,7 +69,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
        {
                // DRESK - 3/16/07
                // Report Proper Weapon Status / Modified Weapon Ownership Message
-               if (WEPSET_CONTAINS_AW(weaponsInMap, wpn))
+               if (weaponsInMap & WepSet_FromWeapon(wpn))
                {
                        Send_WeaponComplain(cl, wpn, W_Name(wpn), 1);
 
@@ -106,7 +109,6 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
        return FALSE;
 }
 
-.float weaponcomplainindex;
 float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing)
 {
        // We cannot tokenize in this function, as GiveItems calls this
@@ -186,7 +188,12 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        return 0;
 }
 
-#define w_getbestweapon(ent) W_GetCycleWeapon(ent, ent.cvar_cl_weaponpriority, 0, -1, FALSE, TRUE)
+void W_SwitchWeapon_Force(entity e, float w)
+{
+       e.cnt = e.switchweapon;
+       e.switchweapon = w;
+       e.selectweapon = w;
+}
 
 // perform weapon to attack (weaponstate and attack_finished check is here)
 void W_SwitchToOtherWeapon(entity pl)
@@ -194,11 +201,11 @@ void W_SwitchToOtherWeapon(entity pl)
        // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
        float w, ww;
        w = pl.weapon;
-       if(WEPSET_CONTAINS_EW(pl, w))
+       if(pl.weapons & WepSet_FromWeapon(w))
        {
-               WEPSET_ANDNOT_EW(pl, w);
+               pl.weapons &= ~WepSet_FromWeapon(w);
                ww = w_getbestweapon(pl);
-               WEPSET_OR_EW(pl, w);
+               pl.weapons |= WepSet_FromWeapon(w);
        }
        else
                ww = w_getbestweapon(pl);