void register_weapons_done();
#if 1
+.float weapons;
+# define WEPSET_DECLARE_A(a) float _WS_##a
+
# define WEPSET_CLEAR_E(e) ((e).weapons = 0)
-# define WEPSET_CLEAR_A(a) ((a) = 0)
+# define WEPSET_CLEAR_A(a) ((_WS_##a) = 0)
# define WEPSET_EMPTY_E(e) ((e).weapons == 0)
-# define WEPSET_EMPTY_A(a) ((a) == 0)
+# define WEPSET_EMPTY_A(a) ((_WS_##a) == 0)
# define WEPSET_COPY_EE(e,o) ((e).weapons = (o).weapons)
# define WEPSET_EQ_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_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_CONTAINS_ANY_EA(e,a) ((e).weapons & (a))
-# define WEPSET_CONTAINS_ALL_EA(e,a) (((e).weapons & (a)) == (a))
+# 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_COPY_EW(e,w) ((e).weapons = power2of((w) - WEP_FIRST))
# define WEPSET_EQ_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_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_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_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))
-# define WEPSET_CONTAINS_AW(a,w) ((a) & 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_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_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))
# ifdef CSQC
-# define WEPSET_COPY_AS(a) ((a) = getstatf(STAT_WEAPONS))
+# define WEPSET_COPY_AS(a) ((_WS_##a) = getstatf(STAT_WEAPONS))
# endif
#endif
float WEP_FIRST = 1;
float WEP_LAST;
#define WEP_MAXCOUNT 24
-float WEPBIT_ALL;
-float WEPBIT_SUPERWEAPONS;
+WEPSET_DECLARE_A(WEPBIT_ALL);
+WEPSET_DECLARE_A(WEPBIT_SUPERWEAPONS);
// note: the fabs call is just there to hide "if result is constant" warning
#define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
float id; \
float i;
// ;)
- if(WEPSET_EQ_AW(g_weaponarena, WEP_TUBA))
+ if(WEPSET_EQ_AW(g_weaponarena_weapons, WEP_TUBA))
{
self.switchweapon = WEP_TUBA;
return;
if(clienttype(self) == CLIENTTYPE_REAL)
{
- if(autocvar_g_bugrigs || WEPSET_EQ_AW(g_weaponarena, WEP_TUBA))
+ if(autocvar_g_bugrigs || WEPSET_EQ_AW(g_weaponarena_weapons, WEP_TUBA))
stuffcmd(self, "cl_cmd settemp chase_active 1\n");
}
void FixIntermissionClient(entity e);
void FixClientCvars(entity e);
-float weaponsInMap;
+WEPSET_DECLARE_A(weaponsInMap);
.float respawn_countdown; // next number to count
void W_SwitchWeapon_Force(entity e, float w);
void GiveFrags (entity attacker, entity targ, float f, float deathtype)
{
- float w;
+ WEPSET_DECLARE_A(w);
// TODO route through PlayerScores instead
if(gameover) return;
WEPSET_ANDNOT_AW(w, culprit);
// among the remaining ones, choose one by random
- w = randombits(w, 1, FALSE);
- if(w)
+ _WS_w = randombits(_WS_w, 1, FALSE); // FIXME
+ if(!WEPSET_EMPTY_A(w))
{
WEPSET_OR_EA(attacker, w);
WEPSET_ANDNOT_EW(attacker, culprit);
float g_pickup_ammo_anyway;
float g_pickup_weapons_anyway;
float g_weaponarena;
+WEPSET_DECLARE_A(g_weaponarena_weapons);
float g_weaponarena_random;
float g_weaponarena_random_with_laser;
string g_weaponarena_list;
float g_weaponforcefactor;
float g_weaponspreadfactor;
-float start_weapons;
+WEPSET_DECLARE_A(start_weapons);
float start_items;
float start_ammo_shells;
float start_ammo_nails;
float start_ammo_fuel;
float start_health;
float start_armorvalue;
-float warmup_start_weapons;
+WEPSET_DECLARE_A(warmup_start_weapons);
float warmup_start_ammo_shells;
float warmup_start_ammo_nails;
float warmup_start_ammo_rockets;
string s;
// initialize starting values for players
- start_weapons = 0;
+ WEPSET_CLEAR_A(start_weapons);
start_items = 0;
start_ammo_shells = 0;
start_ammo_nails = 0;
start_armorvalue = cvar("g_balance_armor_start");
g_weaponarena = 0;
+ WEPSET_CLEAR_A(g_weaponarena_weapons);
+
s = cvar_string("g_weaponarena");
if (s == "0" || s == "")
{
}
else if (s == "all")
{
+ g_weaponarena = 1;
g_weaponarena_list = "All Weapons";
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
- {
- e = get_weaponinfo(j);
- g_weaponarena |= e.weapons;
- weapon_action(e.weapon, WR_PRECACHE);
- }
+ WEPSET_OR_AW(g_weaponarena_weapons, j);
}
else if (s == "most")
{
+ g_weaponarena = 1;
g_weaponarena_list = "Most Weapons";
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
{
e = get_weaponinfo(j);
if (e.spawnflags & WEP_FLAG_NORMAL)
- {
- g_weaponarena |= e.weapons;
- weapon_action(e.weapon, WR_PRECACHE);
- }
+ WEPSET_OR_AW(g_weaponarena_weapons, j);
}
}
else if (s == "none")
{
+ g_weaponarena = 1;
g_weaponarena_list = "No Weapons";
- g_weaponarena = WEPBIT_ALL + 1; // this supports no single weapon bit!
}
else
{
+ g_weaponarena = 1;
t = tokenize_console(s);
g_weaponarena_list = "";
for (i = 0; i < t; ++i)
e = get_weaponinfo(j);
if (e.netname == s)
{
- g_weaponarena |= e.weapons;
- weapon_action(e.weapon, WR_PRECACHE);
+ WEPSET_OR_AW(g_weaponarena_weapons, j);
g_weaponarena_list = strcat(g_weaponarena_list, e.message, " & ");
break;
}
g_minstagib = 0; // incompatible
g_pinata = 0; // incompatible
g_weapon_stay = 0; // incompatible
- start_weapons = g_weaponarena;
+ WEPSET_COPY_AA(start_weapons, g_weaponarena_weapons);
if(!(g_lms || g_ca))
start_items |= IT_UNLIMITED_AMMO;
}
g_bloodloss = 0; // incompatible
start_health = 100;
start_armorvalue = 0;
- start_weapons = WEPBIT_MINSTANEX;
- weapon_action(WEP_MINSTANEX, WR_PRECACHE);
+ WEPSET_COPY_AW(start_weapons, WEP_MINSTANEX);
g_minstagib_invis_alpha = cvar("g_minstagib_invis_alpha");
start_items |= IT_UNLIMITED_SUPERWEAPONS;
{
e = get_weaponinfo(i);
if(want_weapon("g_start_weapon_", e, FALSE))
- start_weapons |= e.weapons;
+ WEPSET_OR_AW(start_weapons, e.weapons);
}
}
warmup_start_ammo_fuel = start_ammo_fuel;
warmup_start_health = start_health;
warmup_start_armorvalue = start_armorvalue;
- warmup_start_weapons = start_weapons;
+ WEPSET_COPY_AA(warmup_start_weapons, start_weapons);
if (!g_weaponarena && !g_minstagib && !g_ca)
{
warmup_start_ammo_fuel = cvar("g_warmup_start_ammo_fuel");
warmup_start_health = cvar("g_warmup_start_health");
warmup_start_armorvalue = cvar("g_warmup_start_armor");
- warmup_start_weapons = 0;
+ WEPSET_CLEAR_A(warmup_start_weapons);
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
e = get_weaponinfo(i);
if(want_weapon("g_start_weapon_", e, cvar("g_warmup_allguns")))
- warmup_start_weapons |= e.weapons;
+ WEPSET_OR_AW(warmup_start_weapons, j);
}
}
}
- if (g_jetpack || (g_grappling_hook && (start_weapons & WEPBIT_HOOK)))
+ if (g_jetpack || (g_grappling_hook && WEPSET_CONTAINS_AW(start_weapons, WEPBIT_HOOK)))
{
g_grappling_hook = 0; // these two can't coexist, as they use the same button
start_items |= IT_FUEL_REGEN;
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
e = get_weaponinfo(i);
- if(e.weapons & (start_weapons | warmup_start_weapons))
+ if(WEPSET_CONTAINS_AW(start_weapons, j) || WEPSET_CONTAINS_AW(warmup_start_weapons, j))
weapon_action(e.weapon, WR_PRECACHE);
}
.float nix_lastinfotime;
.float nix_nextincr;
-.float nix_save_cells;
-.float nix_save_shells;
-.float nix_save_nails;
-.float nix_save_rockets;
-.float nix_save_fuel;
-.float nix_save_weapons;
-
float NIX_CanChooseWeapon(float wpn)
{
entity e;
nix_nextweapon = 0;
NIX_precache();
-
- FOR_EACH_PLAYER(e)
- {
- if(e.deadflag == DEAD_NO)
- {
- e.nix_save_cells = e.ammo_cells;
- e.nix_save_shells = e.ammo_shells;
- e.nix_save_nails = e.ammo_nails;
- e.nix_save_rockets = e.ammo_rockets;
- e.nix_save_fuel = e.ammo_fuel;
- e.nix_save_weapons = e.weapons;
- }
- else
- {
- e.nix_save_cells = 0;
- e.nix_save_shells = 0;
- e.nix_save_nails = 0;
- e.nix_save_rockets = 0;
- e.nix_save_fuel = 0;
- e.nix_save_weapons = 0;
- }
- }
}
MUTATOR_ONREMOVE
FOR_EACH_PLAYER(e) if(e.deadflag == DEAD_NO)
{
- e.ammo_cells = max(start_ammo_cells, e.nix_save_cells);
- e.ammo_shells = max(start_ammo_shells, e.nix_save_shells);
- e.ammo_nails = max(start_ammo_nails, e.nix_save_nails);
- e.ammo_rockets = max(start_ammo_rockets, e.nix_save_rockets);
- e.ammo_fuel = max(start_ammo_fuel, e.nix_save_fuel);
- e.weapons = (start_weapons | e.nix_save_weapons);
+ e.ammo_cells = start_ammo_cells;
+ e.ammo_shells = start_ammo_shells;
+ e.ammo_nails = start_ammo_nails;
+ e.ammo_rockets = start_ammo_rockets;
+ e.ammo_fuel = start_ammo_fuel;
+ WEPSET_COPY_EA(e, start_weapons);
if(!client_hasweapon(e, e.weapon, TRUE, FALSE))
e.switchweapon = w_getbestweapon(self);
}
if(g_ca)
return FALSE;
if(g_weaponarena)
- if((self.weapons & WEPBIT_ALL) || (self.items & IT_AMMO))
+ if(!WEPSET_EMPTY_E(self) || (self.items & IT_AMMO))
return FALSE;
}
return TRUE;
void Item_ScheduleRespawnIn(entity e, float t)
{
- if((e.flags & FL_POWERUP) || (e.weapons & WEPBIT_SUPERWEAPONS))
+ if((e.flags & FL_POWERUP) || WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
{
e.think = Item_RespawnCountdown;
e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
if(self.waypointsprite_attached)
WaypointSprite_Kill(self.waypointsprite_attached);
- if((self.flags & FL_POWERUP) | (self.weapons & WEPBIT_SUPERWEAPONS)) // do not spawn powerups initially!
+ if((self.flags & FL_POWERUP) | WEPSET_CONTAINS_ANY_EA(self, WEPBIT_SUPERWEAPONS)) // do not spawn powerups initially!
Item_ScheduleInitialRespawn(self);
}
}
self.is_item = TRUE;
}
- weaponsInMap |= weaponid;
+ WEPSET_OR_AW(weaponsInMap, weaponid);
precache_model (itemmodel);
precache_sound (pickupsound);
if(!self.respawntime)
{
- if(e.weapons & WEPBIT_SUPERWEAPONS)
+ if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
{
self.respawntime = g_pickup_respawntime_superweapon;
self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
}
}
- if(e.weapons & WEPBIT_SUPERWEAPONS)
+ if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
if(!self.superweapons_finished)
self.superweapons_finished = autocvar_g_balance_superweapons_time;
f = FL_WEAPON;
// no weapon-stay on superweapons
- if(e.weapons & WEPBIT_SUPERWEAPONS)
+ if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
f |= FL_NO_WEAPON_STAY;
// weapon stay isn't supported for teamed weapons
POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, "misc/megahealth.wav", string_null);
if(e.superweapons_finished <= 0)
- if(self.weapons & WEPBIT_SUPERWEAPONS)
+ if(WEPSET_CONTAINS_ANY_EA(self, WEPBIT_SUPERWEAPONS))
e.superweapons_finished = autocvar_g_balance_superweapons_time;
if (g_minstagib)
self.realowner.porto_current = world;
- if(self.cnt < 0 && !failhard && self.realowner.playerid == self.playerid && self.realowner.deadflag == DEAD_NO && !WEPSET_CONTAINS_EW(self.realowner, WEPBIT_PORTO))
+ if(self.cnt < 0 && !failhard && self.realowner.playerid == self.playerid && self.realowner.deadflag == DEAD_NO && !WEPSET_CONTAINS_EW(self.realowner, WEP_PORTO))
{
setsize (self, '-16 -16 0', '16 16 32');
setorigin(self, self.origin + trace_plane_normal);