int nHidden = 0;
WepSet weapons_stat = WepSet_GetFromStat();
for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
- WepSet weapons_wep = WepSet_FromWeapon(i);
- if (weapons_stat & weapons_wep) continue;
Weapon w = get_weaponinfo(i);
+ if (weapons_stat & w.m_wepset) continue;
if (w.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
}
vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, padded_panel_size, aspect);
float initial_posx = pos.x;
int disownedcnt = 0;
for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
- setself(get_weaponinfo(i));
+ Weapon e = get_weaponinfo(i);
+ setself(e);
if (!self.weapon) continue;
int weapon_stats = weapon_accuracy[i - WEP_FIRST];
- if (weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
+ WepSet set = e.m_wepset;
+ if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
++disownedcnt;
}
int column = 0;
for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
- setself(get_weaponinfo(i));
+ Weapon e = get_weaponinfo(i);
+ setself(e);
if (!self.weapon) continue;
int weapon_stats = weapon_accuracy[i - WEP_FIRST];
- if (weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
+ WepSet set = e.m_wepset;
+ if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
continue;
float weapon_alpha;
return true;
if(MUTATOR_CALLHOOK(WantEventchase, self))
return true;
- if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WepSet_FromWeapon(WEP_NEXBALL.m_id)))
+ if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
return true;
if(autocvar_cl_eventchase_death && (getstati(STAT_HEALTH) <= 0))
{
n = tokenize_console(nt_GetReplacement(e.netname, autocvar_g_new_toys_autoreplace));
- for(j = 0; j < n; ++j)
- for(k = WEP_FIRST; k <= WEP_LAST; ++k)
- if(get_weaponinfo(k).netname == argv(j))
+ for (j = 0; j < n; ++j)
+ for (k = WEP_FIRST; k <= WEP_LAST; ++k)
+ {
+ Weapon w = get_weaponinfo(k);
+ if (w.netname == argv(j))
{
- if(start_weapons & WepSet_FromWeapon(i))
- newdefault |= WepSet_FromWeapon(k);
- if(warmup_start_weapons & WepSet_FromWeapon(i))
- warmup_newdefault |= WepSet_FromWeapon(k);
+ WepSet seti = e.m_wepset;
+ WepSet setk = w.m_wepset;
+ if (start_weapons & seti) newdefault |= setk;
+ if (warmup_start_weapons & seti) warmup_newdefault |= setk;
}
+ }
}
newdefault &= start_weapons_defaultmask;
return false;
if(g_weaponarena)
{
- if(!(g_weaponarena_weapons & WepSet_FromWeapon(wpn)))
+ if(!(g_weaponarena_weapons & e.m_wepset))
return false;
}
else
else
Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon);
- Weapon w = get_weaponinfo(nix_weapon);
- w.wr_resetplayer(w);
+ e.wr_resetplayer(e);
// all weapons must be fully loaded when we spawn
if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
self.weapons = '0 0 0';
if(g_nix_with_blaster)
self.weapons |= WEPSET(BLASTER);
- self.weapons |= WepSet_FromWeapon(nix_weapon);
+ self.weapons |= e.m_wepset;
if(self.switchweapon != nix_weapon)
if(!client_hasweapon(self, self.switchweapon, true, false))
// WEAPON PLUGIN SYSTEM
-WepSet WepSet_FromWeapon(int a) {
+WepSet _WepSet_FromWeapon(int a) {
a -= WEP_FIRST;
if (Weapons_MAX > 24)
if (a >= 24) {
// weapon sets
typedef vector WepSet;
-#define WEPSET(id) WepSet_FromWeapon(WEP_##id.m_id)
-WepSet WepSet_FromWeapon(int a);
#ifdef SVQC
void WepSet_AddStat();
void WepSet_AddStat_InMap();
REGISTER_REGISTRY(Weapons)
STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); }
+.WepSet m_wepset;
+#define WEPSET(id) (WEP_##id.m_wepset)
+#define WepSet_FromWeapon(i) (Weapons_from(i).m_wepset)
+WepSet _WepSet_FromWeapon(int i);
+STATIC_INIT(WepSets)
+{
+ FOREACH(Weapons, true, LAMBDA(it.m_wepset = _WepSet_FromWeapon(it.m_id)));
+}
GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPONTODO: make this work with other progs than just server
{
{
FOREACH(Weapons, true, LAMBDA(
it.m_id = i;
- WepSet set = WepSet_FromWeapon(it.m_id);
+ WepSet set = it.m_wepset;
WEPSET_ALL |= set;
if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
it.weapon = it.m_id;
for (int i = WEP_FIRST; i <= WEP_LAST; ++i)
{
entity e = get_weaponinfo(i);
- if ((self.weapons & WepSet_FromWeapon(i)) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < e.reloading_ammo))
+ if ((self.weapons & (e.m_wepset)) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < e.reloading_ammo))
self.switchweapon = i;
}
}
{
// after a frag, exchange the current weapon (or the culprit, if detectable) by a new random weapon
Weapon culprit = DEATH_WEAPONOF(deathtype);
- if(!culprit)
- culprit = get_weaponinfo(attacker.weapon);
- else if(!(attacker.weapons & WepSet_FromWeapon(culprit.m_id)))
- culprit = get_weaponinfo(attacker.weapon);
+ if(!culprit) culprit = get_weaponinfo(attacker.weapon);
+ else if(!(attacker.weapons & (culprit.m_wepset))) culprit = get_weaponinfo(attacker.weapon);
if(g_weaponarena_random_with_blaster && culprit == WEP_BLASTER) // WEAPONTODO: Shouldn't this be in a mutator?
{
// all others (including the culprit): remove
GiveFrags_randomweapons.weapons &= ~attacker.weapons;
- GiveFrags_randomweapons.weapons &= ~WepSet_FromWeapon(culprit.m_id);
+ GiveFrags_randomweapons.weapons &= ~(culprit.m_wepset);
// among the remaining ones, choose one by random
W_RandomWeapons(GiveFrags_randomweapons, 1);
if(GiveFrags_randomweapons.weapons)
{
attacker.weapons |= GiveFrags_randomweapons.weapons;
- attacker.weapons &= ~WepSet_FromWeapon(culprit.m_id);
+ attacker.weapons &= ~(culprit.m_wepset);
}
}
{
e = get_weaponinfo(j);
if (!(e.spawnflags & WEP_FLAG_MUTATORBLOCKED))
- g_weaponarena_weapons |= WepSet_FromWeapon(j);
+ g_weaponarena_weapons |= (e.m_wepset);
}
}
else if (s == "most")
e = get_weaponinfo(j);
if (!(e.spawnflags & WEP_FLAG_MUTATORBLOCKED))
if (e.spawnflags & WEP_FLAG_NORMAL)
- g_weaponarena_weapons |= WepSet_FromWeapon(j);
+ g_weaponarena_weapons |= (e.m_wepset);
}
}
else if (s == "none")
e = get_weaponinfo(j);
if (e.netname == s)
{
- g_weaponarena_weapons |= WepSet_FromWeapon(j);
+ g_weaponarena_weapons |= (e.m_wepset);
g_weaponarena_list = strcat(g_weaponarena_list, e.m_name, " & ");
break;
}
{
e = get_weaponinfo(i);
int w = want_weapon(e, false);
+ WepSet s = e.m_wepset;
if(w & 1)
- start_weapons |= WepSet_FromWeapon(i);
+ start_weapons |= s;
if(w & 2)
- start_weapons_default |= WepSet_FromWeapon(i);
+ start_weapons_default |= s;
if(w & 4)
- start_weapons_defaultmask |= WepSet_FromWeapon(i);
+ start_weapons_defaultmask |= s;
}
}
{
e = get_weaponinfo(i);
int w = want_weapon(e, g_warmup_allguns);
+ WepSet s = (e.m_wepset);
if(w & 1)
- warmup_start_weapons |= WepSet_FromWeapon(i);
+ warmup_start_weapons |= s;
if(w & 2)
- warmup_start_weapons_default |= WepSet_FromWeapon(i);
+ warmup_start_weapons_default |= s;
if(w & 4)
- warmup_start_weapons_defaultmask |= WepSet_FromWeapon(i);
+ warmup_start_weapons_defaultmask |= s;
}
}
}
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
e = get_weaponinfo(i);
- if(precache_weapons & WepSet_FromWeapon(i)) {
- Weapon w = get_weaponinfo(i);
- w.wr_init(w);
+ if(precache_weapons & (e.m_wepset)) {
+ e.wr_init(e);
}
}
{
wi = get_weaponinfo(i);
- if (!(player.weapons & WepSet_FromWeapon(i)))
+ if (!(player.weapons & (wi.m_wepset)))
continue;
if(wi.items & ITEM_Shells.m_itemid)
s = W_UndeprecateName(argv(i));
if(s == e.netname)
{
- self.weapons |= WepSet_FromWeapon(j);
+ self.weapons |= (e.m_wepset);
if(self.spawnflags == 0 || self.spawnflags == 2) {
Weapon w = get_weaponinfo(e.weapon);
w.wr_init(w);
{
e = get_weaponinfo(j);
if(e.weapon)
- self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & WepSet_FromWeapon(j)), e.netname);
+ self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (e.m_wepset)), e.netname);
}
}
self.netname = strzone(self.netname);
float GiveWeapon(entity e, float wpn, float op, float val)
{
WepSet v0, v1;
- v0 = (e.weapons & WepSet_FromWeapon(wpn));
+ WepSet s = WepSet_FromWeapon(wpn);
+ v0 = (e.weapons & s);
switch(op)
{
case OP_SET:
if(val > 0)
- e.weapons |= WepSet_FromWeapon(wpn);
+ e.weapons |= s;
else
- e.weapons &= ~WepSet_FromWeapon(wpn);
+ e.weapons &= ~s;
break;
case OP_MIN:
case OP_PLUS:
if(val > 0)
- e.weapons |= WepSet_FromWeapon(wpn);
+ e.weapons |= s;
break;
case OP_MAX:
if(val <= 0)
- e.weapons &= ~WepSet_FromWeapon(wpn);
+ e.weapons &= ~s;
break;
case OP_MINUS:
if(val > 0)
- e.weapons &= ~WepSet_FromWeapon(wpn);
+ e.weapons &= ~s;
break;
}
- v1 = (e.weapons & WepSet_FromWeapon(wpn));
+ v1 = (e.weapons & s);
return (v0 != v1);
}
if(wi.weapon)
{
POSTGIVE_WEAPON(e, j, SND(WEAPONPICKUP), string_null);
- if (!(save_weapons & WepSet_FromWeapon(j)))
- if(e.weapons & WepSet_FromWeapon(j)) {
+ if (!(save_weapons & (wi.m_wepset)))
+ if(e.weapons & (wi.m_wepset)) {
Weapon w = get_weaponinfo(wi.weapon);
w.wr_init(w);
}
{
weaponwant = stof(car(rest)); rest = cdr(rest);
wep = get_weaponinfo(weaponwant);
- wepset = WepSet_FromWeapon(weaponwant);
+ wepset = wep.m_wepset;
if(imp >= 0)
if(wep.impulse != imp)
continue;
float i, have_other = false;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
+ Weapon e = get_weaponinfo(i);
if(i != weaponwant)
- if((get_weaponinfo(i)).impulse == imp || imp < 0)
- if((pl.weapons & WepSet_FromWeapon(i)) || (weaponsInMap & WepSet_FromWeapon(i)))
+ if(e.impulse == imp || imp < 0)
+ if((pl.weapons & (e.m_wepset)) || (weaponsInMap & (e.m_wepset)))
have_other = true;
}
{
weaponwant = stof(car(rest)); rest = cdr(rest);
wep = get_weaponinfo(weaponwant);
- wepset = WepSet_FromWeapon(weaponwant);
+ wepset = wep.m_wepset;
if(imp >= 0)
if(wep.impulse != imp)
continue;
float i, have_other = false;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
+ Weapon w = get_weaponinfo(i);
if(i != weaponwant)
- if((get_weaponinfo(i)).impulse == imp || imp < 0)
- if((pl.weapons & WepSet_FromWeapon(i)) || (weaponsInMap & WepSet_FromWeapon(i)))
+ if(w.impulse == imp || imp < 0)
+ if((pl.weapons & (w.m_wepset)) || (weaponsInMap & (w.m_wepset)))
have_other = true;
}
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(pl.weapons & WepSet_FromWeapon(w))
+ int ww;
+ WepSet set = WepSet_FromWeapon(pl.weapon);
+ if(pl.weapons & set)
{
- pl.weapons &= ~WepSet_FromWeapon(w);
+ pl.weapons &= ~set;
ww = w_getbestweapon(pl);
- pl.weapons |= WepSet_FromWeapon(w);
+ pl.weapons |= set;
}
else
ww = w_getbestweapon(pl);
{
float superweapons = 1;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- if(WepSet_FromWeapon(i) & WEPSET_SUPERWEAPONS)
- if(own.weapons & WepSet_FromWeapon(i))
- ++superweapons;
+ {
+ WepSet set = WepSet_FromWeapon(i);
+ if ((set & WEPSET_SUPERWEAPONS) && (own.weapons & set)) ++superweapons;
+ }
if(superweapons <= 1)
{
wep.superweapons_finished = own.superweapons_finished;
if(!W_IsWeaponThrowable(w))
return;
- if(!(self.weapons & WepSet_FromWeapon(w)))
- return;
- self.weapons &= ~WepSet_FromWeapon(w);
+ WepSet set = WepSet_FromWeapon(w);
+ if(!(self.weapons & set)) return;
+ self.weapons &= ~set;
W_SwitchWeapon_Force(self, w_getbestweapon(self));
string a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo);