# define WEPSET_OR_EE(e,o) ((e).weapons |= (o).weapons)
# define WEPSET_AND_EE(e,o) ((e).weapons &= (o).weapons)
# define WEPSET_ANDNOT_EE(e,o) ((e).weapons &~= (o).weapons)
-# define WEPSET_TEST_EE(e,o) ((e).weapons & (o).weapons)
-# define WEPSET_CONTAINS_EE(e,o) (((e).weapons & (o).weapons) == (e).weapons)
+# define WEPSET_CONTAINS_ANY_EE(e,o) ((e).weapons & (o).weapons)
+# define WEPSET_CONTAINS_ALL_EE(e,o) (((e).weapons & (o).weapons) == (e).weapons)
# define WEPSET_COPY_EA(e,a) ((e).weapons = (a))
# define WEPSET_EQ_EA(e,a) ((e).weapons == (a))
# define WEPSET_OR_EA(e,a) ((e).weapons |= (a))
# define WEPSET_AND_EA(e,a) ((e).weapons &= (a))
# define WEPSET_ANDNOT_EA(e,a) ((e).weapons &~= (a))
-# define WEPSET_TEST_EA(e,a) ((e).weapons & (a))
-# define WEPSET_CONTAINS_EA(e,a) (((e).weapons & (a)) == (a))
+# define WEPSET_CONTAINS_ANY_EA(e,a) ((e).weapons & (a))
+# define WEPSET_CONTAINS_ALL_EA(e,a) (((e).weapons & (a)) == (a))
# define WEPSET_COPY_EW(e,w) ((e).weapons = power2of((w) - WEP_FIRST))
# define WEPSET_EQ_EW(e,w) ((e).weapons == power2of((w) - WEP_FIRST))
# define WEPSET_OR_EW(e,w) ((e).weapons |= power2of((w) - WEP_FIRST))
# define WEPSET_AND_EW(e,w) ((e).weapons &= power2of((w) - WEP_FIRST))
# define WEPSET_ANDNOT_EW(e,w) ((e).weapons &~= power2of((w) - WEP_FIRST))
-// no TEST necessary here, CONTAINS does the same
-# define WEPSET_TEST_EW(e,w) ((e).weapons & power2of((w) - WEP_FIRST))
+# define WEPSET_CONTAINS_EW(e,w) ((e).weapons & power2of((w) - WEP_FIRST))
# define WEPSET_COPY_AE(a,e) ((a) = (e).weapons)
# define WEPSET_EQ_AE(a,e) ((a) == (e).weapons)
# define WEPSET_OR_AE(a,e) ((a) |= (e).weapons)
# define WEPSET_AND_AE(a,e) ((a) &= (e).weapons)
# define WEPSET_ANDNOT_AE(a,e) ((a) &~= (e).weapons)
-# define WEPSET_TEST_AE(a,e) ((a) & (e).weapons)
-# define WEPSET_CONTAINS_AE(a,e) (((a) & (e).weapons) == (e))
+# define WEPSET_CONTAINS_ANY_AE(a,e) ((a) & (e).weapons)
+# define WEPSET_CONTAINS_ALL_AE(a,e) (((a) & (e).weapons) == (e))
# define WEPSET_COPY_AA(a,b) ((a) = (b))
# define WEPSET_EQ_AA(a,b) ((a) == (b))
# define WEPSET_OR_AA(a,b) ((a) |= (b))
# define WEPSET_AND_AA(a,b) ((a) &= (b))
# define WEPSET_ANDNOT_AA(a,b) ((a) &~= (b))
-# define WEPSET_TEST_AA(a,b) ((a) & (b))
-# define WEPSET_CONTAINS_AA(a,b) (((a) & (b)) == (b))
+# define WEPSET_CONTAINS_ANY_AA(a,b) ((a) & (b))
+# define WEPSET_CONTAINS_ALL_AA(a,b) (((a) & (b)) == (b))
# define WEPSET_COPY_AW(a,w) ((a) = power2of((w) - WEP_FIRST))
# define WEPSET_EQ_AW(a,w) ((a) == power2of((w) - WEP_FIRST))
# define WEPSET_OR_AW(a,w) ((a) |= power2of((w) - WEP_FIRST))
# define WEPSET_AND_AW(a,w) ((a) &= power2of((w) - WEP_FIRST))
# define WEPSET_ANDNOT_AW(a,w) ((a) &~= power2of((w) - WEP_FIRST))
-// no TEST necessary here, CONTAINS does the same
# define WEPSET_CONTAINS_AW(a,w) ((a) & power2of((w) - WEP_FIRST))
# ifdef CSQC
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
e = get_weaponinfo(i);
- if (WEPSET_TEST_EE(self, e) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < cvar(strcat("g_balance_", e.netname, "_reload_ammo"))))
+ if (WEPSET_CONTAINS_EW(self, i) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < cvar(strcat("g_balance_", e.netname, "_reload_ammo"))))
self.switchweapon = i;
}
}
for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
{
// Find weapon
- if(WEPSET_TEST_EW(self, i))
+ if(WEPSET_CONTAINS_EW(self, i))
if(++c>=4)
break;
}
continue;
if( !WEPSET_EMPTY_E(head) )
- if( !WEPSET_CONTAINS_EE(player, head) )
+ if( !WEPSET_CONTAINS_ALL_EE(player, head) )
continue;
if (head.ammo_shells && player.ammo_shells > self.ammo_shells)
WEPSET_COPY_EA(self, start_weapons);
}
- if(WEPSET_TEST_EA(self, WEPBIT_SUPERWEAPONS)) // exception for minstagib, as minstanex is a superweapon
+ if(WEPSET_CONTAINS_ANY_EA(self, WEPBIT_SUPERWEAPONS)) // exception for minstagib, as minstanex is a superweapon
self.superweapons_finished = time + autocvar_g_balance_superweapons_time;
else
self.superweapons_finished = 0;
}
if (self.items & IT_SUPERWEAPON)
{
- if (!WEPSET_TEST_EA(self, WEPBIT_SUPERWEAPONS))
+ if (!WEPSET_CONTAINS_ANY_EA(self, WEPBIT_SUPERWEAPONS))
{
self.superweapons_finished = 0;
self.items = self.items - (self.items & IT_SUPERWEAPON);
}
}
}
- else if(WEPSET_TEST_EA(self, WEPBIT_SUPERWEAPONS))
+ else if(WEPSET_CONTAINS_ANY_EA(self, WEPBIT_SUPERWEAPONS))
{
if (time < self.superweapons_finished || (self.items & IT_UNLIMITED_SUPERWEAPONS))
{
float j;
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- if(self.weapons & W_WeaponBit(j))
+ if(WEPSET_CONTAINS_EW(self, j))
if(W_IsWeaponThrowable(j))
W_ThrowNewWeapon(self, j, FALSE, org, randomvec() * 175 + '0 0 325');
}
return (get_weaponinfo(weaponid)).message;
}
-float W_WeaponBit(float wpn)
-{
- return (get_weaponinfo(wpn)).weapons;
-}
-
float W_AmmoItemCode(float wpn)
{
return (get_weaponinfo(wpn)).items & IT_AMMO;
wep.flags |= FL_TOSSED;
wep.colormap = own.colormap;
- if(W_WeaponBit(wpn) & WEPBIT_SUPERWEAPONS)
+ if(WEPSET_CONTAINS_AW(WEPBIT_SUPERWEAPONS, wpn))
{
if(own.items & IT_UNLIMITED_SUPERWEAPONS)
{
{
float superweapons = 1;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- if(own.weapons & WEPBIT_SUPERWEAPONS & W_WeaponBit(i))
- ++superweapons;
+ if(WEPSET_CONTAINS_AW(WEPBIT_SUPERWEAPONS, i))
+ if(WEPSET_CONTAINS_EW(own, i))
+ ++superweapons;
if(superweapons <= 1)
{
wep.superweapons_finished = own.superweapons_finished;
float W_IsWeaponThrowable(float w)
{
- float wb, wa;
+ float wa;
if (!autocvar_g_pickup_items)
return 0;
if (g_nexball && w == WEP_GRENADE_LAUNCHER)
return 0;
- wb = W_WeaponBit(w);
- if(!wb)
- return 0;
wa = W_AmmoItemCode(w);
- if(start_weapons & wb)
+ if(WEPSET_CONTAINS_AW(start_weapons, w))
{
// start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
if(start_items & IT_UNLIMITED_WEAPON_AMMO)
// toss current weapon
void W_ThrowWeapon(vector velo, vector delta, float doreduce)
{
- float w, wb;
+ float w;
string a;
w = self.weapon;
if(!W_IsWeaponThrowable(w))
return;
- wb = W_WeaponBit(w);
- if(self.weapons & wb != wb)
+ if(!WEPSET_CONTAINS_EW(self, w))
return;
+ WEPSET_ANDNOT_EW(self, w);
- self.weapons &~= wb;
W_SwitchWeapon_Force(self, w_getbestweapon(self));
a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo);
if not(a)
//if (self.button0)
// print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(self)), " >= ", ftos(self.weapon_nextthink), "\n");
- float wb;
- wb = W_WeaponBit(self.weapon);
+ float w;
+ w = self.weapon;
// call the think code which may fire the weapon
// and do so multiple times to resolve framerate dependency issues if the
while (c < W_TICSPERFRAME)
{
c = c + 1;
- if(wb && ((self.weapons & wb) == 0))
+ if(w && !WEPSET_CONTAINS_EW(self, w))
{
if(self.weapon == self.switchweapon)
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- wb = 0;
+ w = 0;
}
v_forward = fo;
v_right = ri;
v_up = up;
- if(wb)
+ if(w)
weapon_action(self.weapon, WR_THINK);
else
weapon_action(self.weapon, WR_GONETHINK);
float client_hasweapon(entity cl, float wpn, float andammo, float complain)
{
- float weaponbit, f;
+ float f;
entity oldself;
if(time < self.hasweapon_complain_spam)
sprint(self, "Invalid weapon\n");
return FALSE;
}
- weaponbit = W_WeaponBit(wpn);
- if (cl.weapons & weaponbit)
+ if (WEPSET_CONTAINS_EW(cl, wpn))
{
if (andammo)
{
{
// DRESK - 3/16/07
// Report Proper Weapon Status / Modified Weapon Ownership Message
- if(weaponsInMap & weaponbit)
+ if (WEPSET_CONTAINS_AW(weaponsInMap, wpn))
{
sprint(cl, strcat("You do not have the ^2", W_Name(wpn), "\n") );
Send_WeaponComplain (cl, wpn, W_Name(wpn), 1);
e = get_weaponinfo(wpn);
s = e.model2;
- for(e = world; (e = findfloat(e, weapons, weaponbit)); )
+ for(e = world; (e = findfloat(e, weapon, wpn)); )
{
if(e.classname == "droppedweapon")
continue;
{
// 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 = W_WeaponBit(pl.weapon);
- pl.weapons &~= w;
- ww = w_getbestweapon(pl);
- pl.weapons |= w;
+ w = pl.weapon;
+ if(WEPSET_CONTAINS_EW(pl, w))
+ {
+ WEPSET_ANDNOT_EW(pl, w);
+ ww = w_getbestweapon(pl);
+ WEPSET_OR_EW(pl, w);
+ }
+ else
+ ww = w_getbestweapon(pl);
if(ww)
W_SwitchWeapon_Force(pl, ww);
}
floatfield Item_CounterField(float it);
float W_AmmoItemCode(float wpn);
-float W_WeaponBit(float wpn);
string W_Name(float weaponid);
void FixIntermissionClient(entity e);
// after a frag, exchange the current weapon (or the culprit, if detectable) by a new random weapon
float culprit;
culprit = DEATH_WEAPONOF(deathtype);
- if(!culprit || !(attacker.weapons & W_WeaponBit(culprit)))
+ if(!culprit || !WEPSET_CONTAINS_EW(attacker, culprit))
culprit = attacker.weapon;
if(g_weaponarena_random_with_laser && culprit == WEPBIT_LASER)
if(w)
{
attacker.weapons |= w;
- attacker.weapons &~= W_WeaponBit(culprit);
+ attacker.weapons &~= get_weaponinfo(culprit).weapons;
}
}
// after a frag, choose another random weapon set
- if not(attacker.weapons & W_WeaponBit(attacker.weapon))
+ if not(WEPSET_CONTAINS_EW(attacker, attacker.weapon))
W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker));
}
self = plyr;
self.weaponentity.weapons = self.weapons;
self.weaponentity.switchweapon = self.weapon;
- self.weapons = W_WeaponBit(WEP_PORTO);
+ WEPSET_COPY_EW(self, WEP_PORTO);
weapon_action(WEP_PORTO, WR_RESETPLAYER);
self.switchweapon = WEP_PORTO;
W_SwitchWeapon(WEP_PORTO);
self.weaponentity.weapons = 0;
if(nexball_mode & NBM_BASKETBALL)
- self.weapons |= W_WeaponBit(WEP_PORTO);
+ WEPSET_OR_EW(self, WEP_PORTO);
else
- self.weapons = 0; // W_WeaponBit(WEP_PORTO);
+ WEPSET_CLEAR_E(self);
return FALSE;
}
self.weapons = 0;
if(g_nix_with_laser)
self.weapons = self.weapons | WEPBIT_LASER;
- self.weapons = self.weapons | W_WeaponBit(nix_weapon);
+ WEPSET_OR_EW(self, nix_weapon);
if(self.switchweapon != nix_weapon)
if(!client_hasweapon(self, self.switchweapon, TRUE, FALSE))
if (player.switchweapon == w_getbestweapon(player))
_switchweapon = TRUE;
- if not(player.weapons & W_WeaponBit(player.switchweapon))
+ if not(WEPSET_CONTAINS_EW(player, player.switchweapon))
_switchweapon = TRUE;
pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
else
e.superweapons_finished += time;
- if not(e.weapons & W_WeaponBit(e.switchweapon))
+ if not(WEPSET_CONTAINS_EW(e, e.switchweapon))
_switchweapon = TRUE;
if(_switchweapon)
W_SwitchWeapon_Force(e, w_getbestweapon(e));
if (!wep)
return;
- e.weapons = e.weapons | W_WeaponBit(wep);
+ WEPSET_OR_EW(e, wep);
oldself = self;
self = e;