]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/selection.qc
Merge branch 'master' into Mario/overkill
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / selection.qc
index c232795919afc01e45aeb2c39903740f6127d417..12ffbb9b49bd17d2f5f664bd824dc99f97352767 100644 (file)
@@ -1,11 +1,10 @@
 // switch between weapons
-void Send_WeaponComplain(entity e, float wpn, string wpnname, float type)
+void Send_WeaponComplain(entity e, float wpn, float type)
 {
        msg_entity = e;
        WriteByte(MSG_ONE, SVC_TEMPENTITY);
        WriteByte(MSG_ONE, TE_CSQC_WEAPONCOMPLAIN);
        WriteByte(MSG_ONE, wpn);
-       WriteString(MSG_ONE, wpnname);
        WriteByte(MSG_ONE, type);
 }
 
@@ -58,7 +57,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                if(IS_REAL_CLIENT(cl))
                                {
                                        play2(cl, "weapons/unavailable.wav");
-                                       Send_WeaponComplain (cl, wpn, W_Name(wpn), 0);
+                                       Send_WeaponComplain (cl, wpn, 0);
                                }
                                return FALSE;
                        }
@@ -71,26 +70,22 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                // Report Proper Weapon Status / Modified Weapon Ownership Message
                if (weaponsInMap & WepSet_FromWeapon(wpn))
                {
-                       Send_WeaponComplain(cl, wpn, W_Name(wpn), 1);
+                       Send_WeaponComplain(cl, wpn, 1);
 
                        if(autocvar_g_showweaponspawns)
                        {
                                entity e;
-                               string s;
-
-                               e = get_weaponinfo(wpn);
-                               s = e.model2;
 
                                for(e = world; (e = findfloat(e, weapon, wpn)); )
                                {
-                                       if(e.classname == "droppedweapon")
+                                       if(e.classname == "droppedweapon" && autocvar_g_showweaponspawns < 2)
                                                continue;
-                                       if not(e.flags & FL_ITEM)
+                                       if(!(e.flags & FL_ITEM))
                                                continue;
                                        WaypointSprite_Spawn(
-                                               s,
+                                               (get_weaponinfo(wpn)).wpmodel,
                                                1, 0,
-                                               world, e.origin,
+                                               world, e.origin + ('0 0 1' * e.maxs_z) * 1.2,
                                                self, 0,
                                                world, enemy,
                                                0,
@@ -101,7 +96,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                }
                else
                {
-                       Send_WeaponComplain (cl, wpn, W_Name(wpn), 2);
+                       Send_WeaponComplain (cl, wpn, 2);
                }
 
                play2(cl, "weapons/unavailable.wav");
@@ -115,9 +110,11 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        // function. Thus we must use car/cdr.
        float weaponwant, first_valid, prev_valid, switchtonext, switchtolast, c;
        string rest;
+       WepSet wepset = '0 0 0';
        switchtonext = switchtolast = 0;
        first_valid = prev_valid = 0;
        float weaponcur;
+       entity wep;
 
        if(skipmissing || pl.selectweapon == 0)
                weaponcur = pl.switchweapon;
@@ -133,9 +130,26 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        while(rest != "")
        {
                weaponwant = stof(car(rest)); rest = cdr(rest);
+               wep = get_weaponinfo(weaponwant);
+               wepset = WepSet_FromWeapon(weaponwant);
                if(imp >= 0)
-                       if((get_weaponinfo(weaponwant)).impulse != imp)
-                               continue;
+               if(wep.impulse != imp)
+                       continue;
+
+               float i, have_other = FALSE;
+               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+               {
+                       if(i != weaponwant)
+                       if((get_weaponinfo(i)).impulse == imp || imp < 0)
+                       if((pl.weapons & WepSet_FromWeapon(i)) || (weaponsInMap & WepSet_FromWeapon(i)))
+                               have_other = TRUE;
+               }
+
+               // skip weapons we don't own that aren't normal and aren't in the map
+               if(!(pl.weapons & wepset))
+               if(!(weaponsInMap & wepset))
+               if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other)
+                       continue;
 
                ++c;
 
@@ -173,10 +187,27 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                while(rest != "")
                {
                        weaponwant = stof(car(rest)); rest = cdr(rest);
+                       wep = get_weaponinfo(weaponwant);
+                       wepset = WepSet_FromWeapon(weaponwant);
                        if(imp >= 0)
-                               if((get_weaponinfo(weaponwant)).impulse != imp)
+                               if(wep.impulse != imp)
                                        continue;
 
+                       float i, have_other = FALSE;
+                       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+                       {
+                               if(i != weaponwant)
+                               if((get_weaponinfo(i)).impulse == imp || imp < 0)
+                               if((pl.weapons & WepSet_FromWeapon(i)) || (weaponsInMap & WepSet_FromWeapon(i)))
+                                       have_other = TRUE;
+                       }
+
+                       // skip weapons we don't own that aren't normal and aren't in the map
+                       if(!(pl.weapons & wepset))
+                       if(!(weaponsInMap & wepset))
+                       if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other)
+                               continue;
+
                        --c;
                        if(c == 0)
                        {
@@ -222,7 +253,7 @@ void W_SwitchWeapon(float imp)
                else
                        self.selectweapon = imp; // update selectweapon ANYWAY
        }
-       else { WEP_ACTION(self.weapon, WR_RELOAD); }
+       else if(!forbidWeaponUse()) { WEP_ACTION(self.weapon, WR_RELOAD); }
 }
 
 void W_CycleWeapon(string weaponorder, float dir)