ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
}
- plyr.(weaponentity).weapons = STAT(WEAPONS, plyr);
+ STAT(WEAPONS, plyr.(weaponentity)) = STAT(WEAPONS, plyr);
plyr.m_switchweapon = plyr.(weaponentity).m_weapon;
STAT(WEAPONS, plyr) = WEPSET(NEXBALL);
Weapon w = WEP_NEXBALL;
{
.entity weaponentity = weaponentities[slot];
- if(player.(weaponentity).weapons)
+ if(STAT(WEAPONS, player.(weaponentity)))
{
- STAT(WEAPONS, player) = player.(weaponentity).weapons;
+ STAT(WEAPONS, player) = STAT(WEAPONS, player.(weaponentity));
Weapon w = WEP_NEXBALL;
w.wr_resetplayer(w, player);
player.(weaponentity).m_switchweapon = player.m_switchweapon;
W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
- player.(weaponentity).weapons = '0 0 0';
+ STAT(WEAPONS, player.(weaponentity)) = '0 0 0';
}
}
}
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
.entity weaponentity = weaponentities[slot];
- player.(weaponentity).weapons = '0 0 0';
+ STAT(WEAPONS, player.(weaponentity)) = '0 0 0';
}
if (nexball_mode & NBM_BASKETBALL)
{
// gather health and armor only
if (it.solid)
- if ( ((it.health || it.armorvalue) && needarmor) || (it.weapons && needweapons ) )
+ if ( ((it.health || it.armorvalue) && needarmor) || (STAT(WEAPONS, it) && needweapons ) )
if (vdist(it.origin - org, <, sradius))
{
int t = it.bot_pickupevalfunc(this, it);
{
if (!item.instanceOfWeaponPickup)
it_times[item.m_id] = t;
- else if (e.weapons & WEPSET_SUPERWEAPONS)
+ else if (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS)
it_times[Items_MAX] = t;
}
}
bool isavailable = (t == 0);
IL_EACH(g_items, it != e,
{
- if(!(it.itemdef == e.itemdef || ((e.weapons & WEPSET_SUPERWEAPONS) && (it.weapons & WEPSET_SUPERWEAPONS))))
+ if(!(it.itemdef == e.itemdef || ((STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS) && (STAT(WEAPONS, it) & WEPSET_SUPERWEAPONS))))
continue;
if (it.scheduledrespawntime <= time)
isavailable = true;
entity player = M_ARGV(0, entity);
if (g_weaponarena_random_with_blaster) STAT(WEAPONS, player) &= ~WEPSET(BLASTER);
- W_RandomWeapons(player, g_weaponarena_random);
+ STAT(WEAPONS, player) = W_RandomWeapons(player, STAT(WEAPONS, player), g_weaponarena_random);
if (g_weaponarena_random_with_blaster) STAT(WEAPONS, player) |= WEPSET(BLASTER);
}
if(autocvar_g_pickup_items == 0)
return false;
if(g_weaponarena)
- if(this.weapons || this.itemdef.instanceOfAmmo) // no item or ammo pickups in weaponarena
+ if(STAT(WEAPONS, this) || this.itemdef.instanceOfAmmo) // no item or ammo pickups in weaponarena
return false;
}
return true;
}
else
{
- bool nostay = def.instanceOfWeaponPickup ? !!(def.m_weapon.weapons & WEPSET_SUPERWEAPONS) : false // no weapon-stay on superweapons
+ bool nostay = def.instanceOfWeaponPickup ? !!(def.m_weapon.m_wepset & WEPSET_SUPERWEAPONS) : false // no weapon-stay on superweapons
|| e.team // weapon stay isn't supported for teamed weapons
;
if(def.instanceOfWeaponPickup && !nostay && g_weapon_stay)
sound(this, CH_TRIGGER, this.itemdef.m_respawnsound, VOL_BASE, ATTEN_NORM); // play respawn sound
setorigin(this, this.origin);
- if (Item_ItemsTime_Allow(this.itemdef) || (this.weapons & WEPSET_SUPERWEAPONS))
+ if (Item_ItemsTime_Allow(this.itemdef) || (STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS))
{
float t = Item_ItemsTime_UpdateTime(this, 0);
Item_ItemsTime_SetTime(this, t);
void Item_ScheduleRespawnIn(entity e, float t)
{
// if the respawn time is longer than 10 seconds, show a waypoint, otherwise, just respawn normally
- if ((Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS) || MUTATOR_CALLHOOK(Item_ScheduleRespawn, e, t)) && (t - ITEM_RESPAWN_TICKS) > 0)
+ if ((Item_ItemsTime_Allow(e.itemdef) || (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS) || MUTATOR_CALLHOOK(Item_ScheduleRespawn, e, t)) && (t - ITEM_RESPAWN_TICKS) > 0)
{
setthink(e, Item_RespawnCountdown);
e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
e.item_respawncounter = 0;
- if(Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS))
+ if(Item_ItemsTime_Allow(e.itemdef) || (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS))
{
t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
Item_ItemsTime_SetTime(e, t);
e.scheduledrespawntime = time + t;
e.wait = time + t;
- if(Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS))
+ if(Item_ItemsTime_Allow(e.itemdef) || (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS))
{
t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
Item_ItemsTime_SetTime(e, t);
if (item.itemdef.instanceOfWeaponPickup)
{
WepSet w;
- w = item.weapons;
+ w = STAT(WEAPONS, item);
w &= ~STAT(WEAPONS, player);
if (w || (item.spawnshieldtime && item.pickup_anyway > 0))
{
WaypointSprite_Kill(this.waypointsprite_attached);
}
- if (this.itemdef.instanceOfPowerup || (this.weapons & WEPSET_SUPERWEAPONS)) // do not spawn powerups initially!
+ if (this.itemdef.instanceOfPowerup || (STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS)) // do not spawn powerups initially!
{
Item_ScheduleInitialRespawn(this);
}
float weapon_pickupevalfunc(entity player, entity item)
{
// See if I have it already
- if(STAT(WEAPONS, player) & item.weapons)
+ if(STAT(WEAPONS, player) & STAT(WEAPONS, item))
{
// If I can pick it up
if(!item.spawnshieldtime)
}
if(weaponid)
- this.weapons = WepSet_FromWeapon(Weapons_from(weaponid));
+ STAT(WEAPONS, this) = WepSet_FromWeapon(Weapons_from(weaponid));
this.flags = FL_ITEM | itemflags;
IL_PUSH(g_items, this);
s = W_UndeprecateName(argv(j));
if(s == it.netname)
{
- this.weapons |= (it.m_wepset);
+ STAT(WEAPONS, this) |= (it.m_wepset);
if(this.spawnflags == 0 || this.spawnflags == 2)
it.wr_init(it);
break;
if(this.health != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, this.health), "health");
if(this.armorvalue != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, this.armorvalue), "armor");
FOREACH(Buffs, it != BUFF_Null, this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, !!(STAT(BUFFS, this) & (it.m_itemid)), it.m_name));
- FOREACH(Weapons, it != WEP_Null, this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, !!(this.weapons & (it.m_wepset)), it.netname));
+ FOREACH(Weapons, it != WEP_Null, this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, !!(STAT(WEAPONS, this) & (it.m_wepset)), it.netname));
}
this.netname = strzone(this.netname);
//print(this.netname, "\n");
return W_FixWeaponOrder(order, 1);
}
-void W_RandomWeapons(entity e, int n)
+WepSet W_RandomWeapons(entity e, WepSet remaining, int n)
{
-#ifdef SVQC
- WepSet remaining = STAT(WEAPONS, e);
-#else
- WepSet remaining = e.weapons;
-#endif
WepSet result = '0 0 0';
for (int j = 0; j < n; ++j)
{
result |= WepSet_FromWeapon(w);
remaining &= ~WepSet_FromWeapon(w);
}
-#ifdef SVQC
- STAT(WEAPONS, e) = result;
-#else
- e.weapons = result;
-#endif
+ return result;
}
string GetAmmoPicture(int ammotype)
WepSet set = it.m_wepset = _WepSet_FromWeapon(it.m_id = i);
WEPSET_ALL |= set;
if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
- it.weapons = set;
if (it == WEP_Null) continue;
int imp = WEP_IMPULSE_BEGIN + it.m_id - 1;
if (imp <= WEP_IMPULSE_END)
ATTRIB(Weapon, m_canonical_spawnfunc, string);
/** control what happens when this weapon is spawned */
METHOD(Weapon, m_spawnfunc_hookreplace, Weapon(Weapon this, entity e)) { return this; }
- /** A: WEPSET_id : WEPSET_... */
- ATTRIB(Weapon, weapons, WepSet, '0 0 0');
/** M: ammotype : main ammo type */
ATTRIB(Weapon, ammo_type, int, RESOURCE_NONE);
/** M: impulse : weapon impulse */
string W_FixWeaponOrder_BuildImpulseList(string o);
string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
string W_FixWeaponOrder_ForceComplete(string order);
-void W_RandomWeapons(entity e, int n);
+WepSet W_RandomWeapons(entity e, WepSet remaining, int n);
string GetAmmoPicture(int ammotype);
{
if (item.health && player.health <= this.health) {return true;}
if (item.armorvalue && player.armorvalue <= this.armorvalue) {return true;}
- if (item.weapons && !(STAT(WEAPONS, player) & item.weapons)) {return true;}
+ if (STAT(WEAPONS, item) && !(STAT(WEAPONS, player) & STAT(WEAPONS, item))) {return true;}
if (item.ammo_shells && player.ammo_shells <= this.ammo_shells) {return true;}
if (item.ammo_nails && player.ammo_nails <= this.ammo_nails) {return true;}
if (item.ammo_rockets && player.ammo_rockets <= this.ammo_rockets) {return true;}
this.personal.ammo_fuel = this.ammo_fuel;
this.personal.health = max(1, this.health);
this.personal.armorvalue = this.armorvalue;
- this.personal.weapons = STAT(WEAPONS, this);
+ STAT(WEAPONS, this.personal) = STAT(WEAPONS, this);
this.personal.items = this.items;
this.personal.pauserotarmor_finished = this.pauserotarmor_finished;
this.personal.pauserothealth_finished = this.pauserothealth_finished;
this.ammo_fuel = this.personal.ammo_fuel;
this.health = this.personal.health;
this.armorvalue = this.personal.armorvalue;
- STAT(WEAPONS, this) = this.personal.weapons;
+ STAT(WEAPONS, this) = STAT(WEAPONS, this.personal);
this.items = this.personal.items;
this.pauserotarmor_finished = time + this.personal.pauserotarmor_finished - this.personal.teleport_time;
this.pauserothealth_finished = time + this.personal.pauserothealth_finished - this.personal.teleport_time;
// WEAPONTODO: remove this
//WepSet weaponsInMap;
-//#define weapons _STAT(WEAPONS)
-.WepSet weapons; // WEAPONTODO: remove this too, items can safely use the stat, weapon code shouldn't need it!
-
.float respawn_countdown; // next number to count
float bot_waypoints_for_items;
}
if(warmup_stage)
- GiveFrags_randomweapons.weapons = WARMUP_START_WEAPONS;
+ STAT(WEAPONS, GiveFrags_randomweapons) = WARMUP_START_WEAPONS;
else
- GiveFrags_randomweapons.weapons = start_weapons;
+ STAT(WEAPONS, GiveFrags_randomweapons) = start_weapons;
// all others (including the culprit): remove
- GiveFrags_randomweapons.weapons &= ~STAT(WEAPONS, attacker);
- GiveFrags_randomweapons.weapons &= ~(culprit.m_wepset);
+ STAT(WEAPONS, GiveFrags_randomweapons) &= ~STAT(WEAPONS, attacker);
+ STAT(WEAPONS, GiveFrags_randomweapons) &= ~(culprit.m_wepset);
// among the remaining ones, choose one by random
- W_RandomWeapons(GiveFrags_randomweapons, 1);
+ STAT(WEAPONS, GiveFrags_randomweapons) = W_RandomWeapons(GiveFrags_randomweapons, STAT(WEAPONS, GiveFrags_randomweapons), 1);
- if(GiveFrags_randomweapons.weapons)
+ if(STAT(WEAPONS, GiveFrags_randomweapons))
{
- STAT(WEAPONS, attacker) |= GiveFrags_randomweapons.weapons;
+ STAT(WEAPONS, attacker) |= STAT(WEAPONS, GiveFrags_randomweapons);
STAT(WEAPONS, attacker) &= ~(culprit.m_wepset);
}
}
MUTATOR_HOOKABLE(FilterItemDefinition, EV_FilterItemDefinition);
/**
- * checks if the current item may be spawned (.items and .weapons may be read and written to, as well as the ammo_ fields)
+ * checks if the current item may be spawned (.items may be read and written to, as well as the ammo_ fields)
* return error to request removal
*/
#define EV_FilterItem(i, o) \