# 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_CONTAINS_ANY_EE(e,o) ((e).weapons & (o).weapons)
-# define WEPSET_CONTAINS_ALL_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 = (_WS_##a))
# define WEPSET_EQ_EA(e,a) ((e).weapons == (_WS_##a))
# define WEPSET_OR_EA(e,a) ((e).weapons |= (_WS_##a))
# define WEPSET_AND_EA(e,a) ((e).weapons &= (_WS_##a))
# define WEPSET_ANDNOT_EA(e,a) ((e).weapons &~= (_WS_##a))
-# define WEPSET_CONTAINS_ANY_EA(e,a) ((e).weapons & (_WS_##a))
-# define WEPSET_CONTAINS_ALL_EA(e,a) (((e).weapons & (_WS_##a)) == (_WS_##a))
+# define WEPSET_CONTAINS_ANY_EA(e,a) !!((e).weapons & (_WS_##a))
+# define WEPSET_CONTAINS_ALL_EA(e,a) !!(((e).weapons & (_WS_##a)) == (_WS_##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))
-# define WEPSET_CONTAINS_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) ((_WS_##a) = (e).weapons)
# define WEPSET_EQ_AE(a,e) ((_WS_##a) == (e).weapons)
# define WEPSET_OR_AE(a,e) ((_WS_##a) |= (e).weapons)
# define WEPSET_AND_AE(a,e) ((_WS_##a) &= (e).weapons)
# define WEPSET_ANDNOT_AE(a,e) ((_WS_##a) &~= (e).weapons)
-# define WEPSET_CONTAINS_ANY_AE(a,e) ((_WS_##a) & (e).weapons)
-# define WEPSET_CONTAINS_ALL_AE(a,e) (((_WS_##a) & (e).weapons) == (e))
+# define WEPSET_CONTAINS_ANY_AE(a,e) !!((_WS_##a) & (e).weapons)
+# define WEPSET_CONTAINS_ALL_AE(a,e) !!(((_WS_##a) & (e).weapons) == (e))
# define WEPSET_COPY_AA(a,b) ((_WS_##a) = (_WS_##b))
# define WEPSET_EQ_AA(a,b) ((_WS_##a) == (_WS_##b))
# define WEPSET_OR_AA(a,b) ((_WS_##a) |= (_WS_##b))
# define WEPSET_AND_AA(a,b) ((_WS_##a) &= (_WS_##b))
# define WEPSET_ANDNOT_AA(a,b) ((_WS_##a) &~= (_WS_##b))
-# define WEPSET_CONTAINS_ANY_AA(a,b) ((_WS_##a) & (_WS_##b))
-# define WEPSET_CONTAINS_ALL_AA(a,b) (((_WS_##a) & (_WS_##b)) == (_WS_##b))
+# define WEPSET_CONTAINS_ANY_AA(a,b) !!((_WS_##a) & (_WS_##b))
+# define WEPSET_CONTAINS_ALL_AA(a,b) !!(((_WS_##a) & (_WS_##b)) == (_WS_##b))
# define WEPSET_COPY_AW(a,w) ((_WS_##a) = power2of((w) - WEP_FIRST))
# define WEPSET_EQ_AW(a,w) ((_WS_##a) == power2of((w) - WEP_FIRST))
# define WEPSET_OR_AW(a,w) ((_WS_##a) |= power2of((w) - WEP_FIRST))
# define WEPSET_AND_AW(a,w) ((_WS_##a) &= power2of((w) - WEP_FIRST))
# define WEPSET_ANDNOT_AW(a,w) ((_WS_##a) &~= power2of((w) - WEP_FIRST))
-# define WEPSET_CONTAINS_AW(a,w) ((_WS_##a) & power2of((w) - WEP_FIRST))
+# define WEPSET_CONTAINS_AW(a,w) !((_WS_##a) & power2of((w) - WEP_FIRST))
# ifdef CSQC
# define WEPSET_COPY_AS(a) ((_WS_##a) = getstatf(STAT_WEAPONS))
{
if(self.spawnshieldtime)
return TRUE;
- if(self.weapons != (self.weapons & other.weapons))
+ if(!WEPSET_CONTAINS_ALL_EE(other, self))
{
self.colormod = '0 0 0';
self.glowmod = self.colormod;
float weapon_pickupevalfunc(entity player, entity item)
{
- float c, i, j, position;
+ float c, j, position;
// See if I have it already
- if(player.weapons & item.weapons == item.weapons)
+ if(!WEPSET_CONTAINS_ALL_EE(player, item))
{
// If I can pick it up
if(!item.spawnshieldtime)
// If custom weapon priorities for bots is enabled rate most wanted weapons higher
if( bot_custom_weapon && c )
{
- for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
- {
- // Find weapon
- if( (get_weaponinfo(i)).weapons & item.weapons != item.weapons )
- continue;
-
- // Find the highest position on any range
- position = -1;
- for(j = 0; j < WEP_LAST ; ++j){
- if(
- bot_weapons_far[j] == i ||
- bot_weapons_mid[j] == i ||
- bot_weapons_close[j] == i
- )
- {
- position = j;
- break;
- }
- }
-
- // Rate it
- if (position >= 0 )
+ // Find the highest position on any range
+ position = -1;
+ for(j = 0; j < WEP_LAST ; ++j){
+ if(
+ bot_weapons_far[j] == item.weapon ||
+ bot_weapons_mid[j] == item.weapon ||
+ bot_weapons_close[j] == item.weapon
+ )
{
- position = WEP_LAST - position;
- // item.bot_pickupbasevalue is overwritten here
- return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c;
+ position = j;
+ break;
}
}
+
+ // Rate it
+ if (position >= 0 )
+ {
+ position = WEP_LAST - position;
+ // item.bot_pickupbasevalue is overwritten here
+ return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c;
+ }
}
return item.bot_pickupbasevalue * c;
{
wi = get_weaponinfo(i);
- if not(wi.weapons & player.weapons)
+ if not(WEPSET_CONTAINS_EW(player, i))
continue;
if(wi.items & IT_SHELLS)
startitem_failed = FALSE;
self.items = itemid;
- self.weapons = weaponid;
+ self.weapon = weaponid;
+ if(weaponid)
+ WEPSET_COPY_EW(self, weaponid);
self.flags = FL_ITEM | itemflags;
// is it a dropped weapon?
if(self.strength_finished || self.invincible_finished || self.superweapons_finished)
/*
if(self.items == 0)
- if(self.weapons == (self.weapons & WEPBIT_SUPERWEAPONS)) // only superweapons
+ if(WEPSET_CONTAINS_ALL_AE(WEPBIT_SUPERWEAPONS, self)) // only superweapons
if(self.ammo_nails == 0)
if(self.ammo_cells == 0)
if(self.ammo_rockets == 0)
self.bot_pickupbasevalue = pickupbasevalue;
self.mdl = itemmodel;
self.item_pickupsound = pickupsound;
- if(self.weapons)
- self.weapon = WEP_FIRST + log2of(lowestbit(self.weapons));
- else
- self.weapon = 0;
// let mappers override respawntime
if(!self.respawntime) // both set
{
if(self.team)
f |= FL_NO_WEAPON_STAY;
- StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapons, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
+ StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
if (self.modelindex) // don't precache if self was removed
weapon_action(e.weapon, WR_PRECACHE);
}
e = get_weaponinfo(j);
if(argv(i) == e.netname)
{
- self.weapons |= e.weapons;
+ WEPSET_OR_EW(self, j);
if(self.spawnflags == 0 || self.spawnflags == 2)
weapon_action(e.weapon, WR_PRECACHE);
break;
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
e = get_weaponinfo(j);
- if(e.weapons)
- self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & e.weapons), e.netname);
+ if(e.weapon)
+ self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, WEPSET_CONTAINS_EW(self, j), e.netname);
}
}
self.netname = strzone(self.netname);
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
wi = get_weaponinfo(j);
- if(wi.weapons)
- got += GiveBit(e, weapons, wi.weapons, op, val);
+ if(wi.weapon)
+ got += GiveBit(e, weapons, wi.weapons, op, val); // FIXME
}
case "allammo":
got += GiveValue(e, ammo_cells, op, val);
wi = get_weaponinfo(j);
if(cmd == wi.netname)
{
- got += GiveBit(e, weapons, wi.weapons, op, val);
+ got += GiveBit(e, weapons, wi.weapons, op, val); // FIXME
break;
}
}
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
wi = get_weaponinfo(j);
- if(wi.weapons)
+ if(wi.weapon)
{
- POSTGIVE_BIT(e, weapons, wi.weapons, "weapons/weaponpickup.wav", string_null);
- if not(save_weapons & wi.weapons)
- if(e.weapons & wi.weapons)
+ POSTGIVE_BIT(e, weapons, wi.weapons, "weapons/weaponpickup.wav", string_null); // FIXME
+#define _WS_save_weapons save_weapons
+ if not(WEPSET_CONTAINS_AW(save_weapons, j)) // FIXME
+ if(WEPSET_CONTAINS_EW(e, j))
weapon_action(wi.weapon, WR_PRECACHE);
}
}