int ps_primary, ps_secondary;
int ts_primary, ts_secondary;
-int last_switchweapon;
-int last_activeweapon;
+Weapon last_switchweapon;
+Weapon last_activeweapon;
float weapontime;
float weaponprevtime;
ammo_size.y = newSize;
}
+ Weapon wep = switchweapon;
int i;
bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
row = column = 0;
DrawAmmoItem(
pos,
ammo_size,
- (get_weaponinfo(switchweapon)).ammo_field,
+ wep.ammo_field,
true,
infinite_ammo
);
pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
ammo_size,
ammotype,
- ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
+ (wep.ammo_field == ammotype),
infinite_ammo
);
{
attacker = sprintf(_("Player %d"), count + 1);
victim = sprintf(_("Player %d"), count + 2);
- icon = get_weaponinfo(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
+ icon = Weapons_from(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
alpha = bound(0, 1.2 - count / entry_count, 1);
}
else
weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
weapon_cnt = 0;
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- {
- setself(get_weaponinfo(i));
- if(self.impulse >= 0)
- {
- weaponorder[weapon_cnt] = self;
- ++weapon_cnt;
- }
- }
+ FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, LAMBDA(weaponorder[weapon_cnt++] = it));
for(i = weapon_cnt; i < Weapons_MAX; ++i)
- weaponorder[i] = world;
- heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
+ weaponorder[i] = NULL;
+ heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, NULL);
weaponorder_cmp_str = string_null;
}
{
if(!weapons_stat)
for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
- weapons_stat |= WepSet_FromWeapon(i);
+ weapons_stat |= WepSet_FromWeapon(Weapons_from(i));
#if 0
/// debug code
weapons_stat = '0 0 0';
float countw = 1 + floor((floor(time * cvar("wep_add"))) % (Weapons_COUNT - 1));
for(i = WEP_FIRST; i <= countw; ++i)
- weapons_stat |= WepSet_FromWeapon(i);
+ weapons_stat |= WepSet_FromWeapon(Weapons_from(i));
}
#endif
}
// do we own this weapon?
weapon_count = 0;
for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
- if((weapons_stat & WepSet_FromWeapon(weaponorder[i].weapon)) || (weaponorder[i].weapon == complain_weapon))
+ if((weapons_stat & WepSet_FromWeapon(Weapons_from(weaponorder[i].weapon))) || (weaponorder[i].weapon == complain_weapon))
++weapon_count;
// get the all-weapons layout
int nHidden = 0;
WepSet weapons_stat = WepSet_GetFromStat();
- for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
- Weapon w = get_weaponinfo(i);
- if (weapons_stat & w.m_wepset) continue;
- if (w.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
- }
+ FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ if (weapons_stat & it.m_wepset) continue;
+ if (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
+ ));
vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, padded_panel_size, aspect);
columns = table_size.x;
rows = table_size.y;
// retrieve information about the current weapon to be drawn
setself(weaponorder[i]);
weapon_id = self.impulse;
- isCurrent = (self.weapon == switchweapon);
+ isCurrent = (self.weapon == switchweapon.m_id);
// skip if this weapon doesn't exist
if(!self || weapon_id < 0) { continue; }
// skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
if(autocvar_hud_panel_weapons_onlyowned)
- if (!((weapons_stat & WepSet_FromWeapon(self.weapon)) || (self.weapon == complain_weapon)))
+ if (!((weapons_stat & WepSet_FromWeapon(Weapons_from(self.weapon))) || (self.weapon == complain_weapon)))
continue;
// figure out the drawing position of weapon
}
// drawing all the weapon items
- if(weapons_stat & WepSet_FromWeapon(self.weapon))
+ if(weapons_stat & WepSet_FromWeapon(Weapons_from(self.weapon)))
{
// draw the weapon image
if(isCurrent)
#define CLIENT_MAIN_H
#include "../common/constants.qh"
+#include "../common/weapons/all.qh"
// --------------------------------------------------------------------------
// MENU Functionality
bool spectatorbutton_zoom;
bool button_attack2;
-int activeweapon;
-int switchingweapon;
-#define switchweapon STAT(SWITCHWEAPON)
+Weapon activeweapon;
+Weapon switchingweapon;
+Weapon switchweapon;
float current_viewzoom;
float zoomin_effect;
float warmup_stage;
WepSet weapons_inmap = WepSet_GetFromStat_InMap();
float initial_posx = pos.x;
int disownedcnt = 0;
- for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
- Weapon e = get_weaponinfo(i);
- setself(e);
- if (!self.weapon) continue;
+ FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ if (!it.weapon) continue;
int weapon_stats = weapon_accuracy[i - WEP_FIRST];
- WepSet set = e.m_wepset;
+ WepSet set = it.m_wepset;
if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
++disownedcnt;
- }
+ ));
int weapon_cnt = (Weapons_COUNT - 1) - disownedcnt;
if (weapon_cnt <= 0) return pos;
vector tmpos = pos;
int column = 0;
- for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
- Weapon e = get_weaponinfo(i);
- setself(e);
- if (!self.weapon) continue;
+ FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ if (!it.weapon) continue;
int weapon_stats = weapon_accuracy[i - WEP_FIRST];
- WepSet set = e.m_wepset;
+ WepSet set = it.m_wepset;
if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
continue;
weapon_alpha = 0.2 * scoreboard_alpha_fg;
// weapon icon
- drawpic_aspect_skin(tmpos, self.model2, '1 0 0' * weapon_width + '0 1 0' * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
+ drawpic_aspect_skin(tmpos, it.model2, '1 0 0' * weapon_width + '0 1 0' * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
// the accuracy
if (weapon_stats >= 0) {
weapons_with_stats += 1;
pos.y += height;
}
++column;
- }
+ ));
if (weapons_with_stats)
average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
float a = this.alpha;
int c = stof(getplayerkeyvalue(current_player, "colors"));
vector g;
- Weapon wep = Weapons_from(activeweapon);
+ Weapon wep = activeweapon;
if (!(g = wep.wr_glow(wep))) g = colormapPaletteColor(c & 0x0F, true) * 2;
entity me = CSQCModel_server2csqc(player_localentnum - 1);
int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
}
{
static string name_last;
- string name = Weapons_from(activeweapon).mdl;
+ string name = wep.mdl;
if (name != name_last)
{
name_last = name;
vector p, dir, ang, q, nextdir;
float portal_number, portal1_idx;
- if(activeweapon != WEP_PORTO.m_id || spectatee_status || gametype == MAPINFO_TYPE_NEXBALL)
+ if(activeweapon != WEP_PORTO || spectatee_status || gametype == MAPINFO_TYPE_NEXBALL)
return;
if(g_balance_porto_secondary)
return;
zoomdir = button_zoom;
if(hud == HUD_NORMAL)
if(switchweapon == activeweapon)
- if((activeweapon == WEP_VORTEX.m_id && vortex_scope) || (activeweapon == WEP_RIFLE.m_id && rifle_scope)) // do NOT use switchweapon here
+ if((activeweapon == WEP_VORTEX && vortex_scope) || (activeweapon == WEP_RIFLE && rifle_scope)) // do NOT use switchweapon here
zoomdir += button_attack2;
if(spectatee_status > 0 || isdemo())
{
switch(activeweapon) // WEAPONTODO
{
- case WEP_TUBA.m_id: // no aim
- case WEP_PORTO.m_id: // shoots from eye
- case WEP_NEXBALL.m_id: // shoots from eye
- case WEP_HOOK.m_id: // no trueaim
- case WEP_MORTAR.m_id: // toss curve
+ case WEP_TUBA: // no aim
+ case WEP_PORTO: // shoots from eye
+ case WEP_NEXBALL: // shoots from eye
+ case WEP_HOOK: // no trueaim
+ case WEP_MORTAR: // toss curve
return SHOTTYPE_HITWORLD;
- case WEP_VORTEX.m_id:
- case WEP_VAPORIZER.m_id:
+ case WEP_VORTEX:
+ case WEP_VAPORIZER:
mv = MOVE_NORMAL;
break;
- case WEP_RIFLE.m_id:
+ case WEP_RIFLE:
ta = trueaim_rifle;
mv = MOVE_NORMAL;
if(zoomscript_caught)
return EnemyHitCheck();
}
break;
- case WEP_DEVASTATOR.m_id: // projectile has a size!
+ case WEP_DEVASTATOR: // projectile has a size!
mi = '-3 -3 -3';
ma = '3 3 3';
break;
- case WEP_FIREBALL.m_id: // projectile has a size!
+ case WEP_FIREBALL: // projectile has a size!
mi = '-16 -16 -16';
ma = '16 16 16';
break;
- case WEP_SEEKER.m_id: // projectile has a size!
+ case WEP_SEEKER: // projectile has a size!
mi = '-2 -2 -2';
ma = '2 2 2';
break;
- case WEP_ELECTRO.m_id: // projectile has a size!
+ case WEP_ELECTRO: // projectile has a size!
mi = '0 0 -3';
ma = '0 0 -3';
break;
static float hitsound_time_prev = 0;
// HACK: the only way to get the arc to sound consistent with pitch shift is to ignore cl_hitsound_antispam_time
- float arc_hack = activeweapon == WEP_ARC.m_id && autocvar_cl_hitsound >= 2;
+ float arc_hack = activeweapon == WEP_ARC && autocvar_cl_hitsound >= 2;
if (arc_hack || COMPARE_INCREASING(time, hitsound_time_prev) > autocvar_cl_hitsound_antispam_time)
{
if (autocvar_cl_hitsound && unaccounted_damage)
if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
{
- e = get_weaponinfo(switchingweapon);
+ e = switchingweapon;
if(e)
{
if(autocvar_crosshair_per_weapon)
// handle the values
- if (autocvar_crosshair_ring && activeweapon == WEP_VORTEX.m_id && vortex_charge && autocvar_crosshair_ring_vortex) // ring around crosshair representing velocity-dependent damage for the vortex
+ if (autocvar_crosshair_ring && activeweapon == WEP_VORTEX && vortex_charge && autocvar_crosshair_ring_vortex) // ring around crosshair representing velocity-dependent damage for the vortex
{
if (vortex_chargepool || use_vortex_chargepool) {
use_vortex_chargepool = 1;
ring_rgb = wcross_color;
ring_image = "gfx/crosshair_ring_nexgun.tga";
}
- else if (autocvar_crosshair_ring && activeweapon == WEP_MINE_LAYER.m_id && minelayer_maxmines && autocvar_crosshair_ring_minelayer)
+ else if (autocvar_crosshair_ring && activeweapon == WEP_MINE_LAYER && minelayer_maxmines && autocvar_crosshair_ring_minelayer)
{
ring_value = bound(0, STAT(LAYED_MINES) / minelayer_maxmines, 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to.
ring_alpha = autocvar_crosshair_ring_minelayer_alpha;
ring_rgb = wcross_color;
ring_image = "gfx/crosshair_ring.tga";
}
- else if (activeweapon == WEP_HAGAR.m_id && STAT(HAGAR_LOAD) && autocvar_crosshair_ring_hagar)
+ else if (activeweapon == WEP_HAGAR && STAT(HAGAR_LOAD) && autocvar_crosshair_ring_hagar)
{
ring_value = bound(0, STAT(HAGAR_LOAD) / hagar_maxrockets, 1);
ring_alpha = autocvar_crosshair_ring_hagar_alpha;
// Note: This is to stop Taoki from complaining that the image doesn't match all potential balances.
// if a new image for another weapon is added, add the code (and its respective file/value) here
- if ((activeweapon == WEP_RIFLE.m_id) && (weapon_clipsize == 80))
+ if ((activeweapon == WEP_RIFLE) && (weapon_clipsize == 80))
ring_image = "gfx/crosshair_ring_rifle.tga";
else
ring_image = "gfx/crosshair_ring.tga";
}
- else if ( autocvar_crosshair_ring && autocvar_crosshair_ring_arc && arc_heat && activeweapon == WEP_ARC.m_id )
+ else if ( autocvar_crosshair_ring && autocvar_crosshair_ring_arc && arc_heat && activeweapon == WEP_ARC )
{
ring_value = arc_heat;
ring_alpha = (1-arc_heat)*autocvar_crosshair_ring_arc_cold_alpha +
ColorTranslateMode = autocvar_cl_stripcolorcodes;
// currently switching-to weapon (for crosshair)
- switchingweapon = STAT(SWITCHINGWEAPON);
+ switchingweapon = Weapons_from(STAT(SWITCHINGWEAPON));
// actually active weapon (for zoom)
- activeweapon = getstati(STAT_ACTIVEWEAPON);
+ activeweapon = Weapons_from(getstati(STAT_ACTIVEWEAPON));
+
+ switchweapon = Weapons_from(STAT(SWITCHWEAPON));
f = (serverflags & SERVERFLAG_TEAMPLAY);
if(f != teamplay)
{
last_activeweapon = activeweapon;
- e = get_weaponinfo(activeweapon);
+ e = activeweapon;
if(e.netname != "")
localcmd(strcat("\ncl_hook_activeweapon ", e.netname), "\n");
else
if(autocvar_cl_reticle)
{
- Weapon wep = get_weaponinfo(activeweapon);
+ Weapon wep = activeweapon;
// Draw the aiming reticle for weapons that use it
// reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use
// It must be a persisted float for fading out to work properly (you let go of the zoom button for
#define DEATH_ISVEHICLE(t) (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "vehicle")
#define DEATH_ISTURRET(t) (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "turret")
#define DEATH_ISMONSTER(t) (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "monster")
-#define DEATH_WEAPONOF(t) (DEATH_ISSPECIAL(t) ? WEP_Null : get_weaponinfo((t) & DEATH_WEAPONMASK))
+#define DEATH_WEAPONOF(t) (DEATH_ISSPECIAL(t) ? WEP_Null : Weapons_from((t) & DEATH_WEAPONMASK))
#define DEATH_ISWEAPON(t, w) (DEATH_WEAPONOF(t) == (w))
string Deathtype_Name(int deathtype);
for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
{
// Find weapon
- if(self.weapons & WepSet_FromWeapon(i))
+ if(self.weapons & WepSet_FromWeapon(Weapons_from(i)))
if(++c>=4)
break;
}
// mark the guns as ok to use by e.g. impulse 99
for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
if(nt_IsNewToy(i))
- get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+ Weapons_from(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
}
MUTATOR_ONROLLBACK_OR_REMOVE
{
for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
if(nt_IsNewToy(i))
- get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+ Weapons_from(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
}
MUTATOR_ONREMOVE
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- entity e = get_weaponinfo(i);
+ entity e = Weapons_from(i);
if(!e.weapon)
continue;
for (j = 0; j < n; ++j)
for (k = WEP_FIRST; k <= WEP_LAST; ++k)
{
- Weapon w = get_weaponinfo(k);
+ Weapon w = Weapons_from(k);
if (w.netname == argv(j))
{
WepSet seti = e.m_wepset;
for (int i = WEP_FIRST; i <= WEP_LAST; ++i)
if (NIX_CanChooseWeapon(i)) {
- Weapon w = get_weaponinfo(i);
+ Weapon w = Weapons_from(i);
w.wr_init(w);
}
}
bool NIX_CanChooseWeapon(int wpn)
{
- entity e = get_weaponinfo(wpn);
+ entity e = Weapons_from(wpn);
if(!e.weapon) // skip dummies
return false;
if(g_weaponarena)
nix_nextchange = time; // start the first round now!
else
nix_nextchange = time + autocvar_g_balance_nix_roundtime;
- // Weapon w = get_weaponinfo(nix_weapon);
+ // Weapon w = Weapons_from(nix_weapon);
// w.wr_init(w); // forget it, too slow
}
// get weapon info
- entity e = get_weaponinfo(nix_weapon);
+ entity e = Weapons_from(nix_weapon);
if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round!
{
return;
}
- Weapon w = get_weaponinfo(actor.weapon);
- if(!w.wr_checkammo1(w))
+ if(!thiswep.wr_checkammo1(thiswep))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(WEP_CVAR(hmg, reload_ammo) && actor.clip_load < WEP_CVAR(hmg, ammo)) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else
{
if (fire & 1)
{
if(!ent.ok_use_ammocharge) return;
- entity wepent = get_weaponinfo(wep);
+ entity wepent = Weapons_from(wep);
if(wepent.weapon == 0)
return; // dummy
void ok_IncreaseCharge(entity ent, int wep)
{
- entity wepent = get_weaponinfo(wep);
+ entity wepent = Weapons_from(wep);
if(wepent.weapon == 0)
return; // dummy
{
if(!ent.ok_use_ammocharge) return true;
- entity wepent = get_weaponinfo(wep);
+ entity wepent = Weapons_from(wep);
if(wepent.weapon == 0)
return 0; // dummy
self.ok_notice_time = time + 2;
play2(self, SND(DRYFIRE));
}
- Weapon wpn = get_weaponinfo(self.weapon);
+ Weapon wpn = Weapons_from(self.weapon);
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
if(self.(weaponentity).state != WS_CLEAR)
w_ready(wpn, self, weaponentity, (self.BUTTON_ATCK ? 1 : 0) | (self.BUTTON_ATCK2 ? 2 : 0));
METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(WEP_CVAR(rpc, reload_ammo) && actor.clip_load < WEP_CVAR(rpc, ammo)) {
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else
{
if (fire & 1)
MUTATOR_HOOKFUNCTION(pinata, PlayerDies)
{SELFPARAM();
for(int j = WEP_FIRST; j <= WEP_LAST; ++j)
- if(self.weapons & WepSet_FromWeapon(j))
+ if(self.weapons & WepSet_FromWeapon(Weapons_from(j)))
if(self.switchweapon != j)
if(W_IsWeaponThrowable(j))
W_ThrowNewWeapon(self, j, false, self.origin + (self.mins + self.maxs) * 0.5, randomvec() * 175 + '0 0 325');
float spritelookupblinkvalue(string s)
{SELFPARAM();
if (s == WP_Weapon.netname) {
- if (get_weaponinfo(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
+ if (Weapons_from(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
return 2;
}
if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypointblink;
vector spritelookupcolor(entity this, string s, vector def)
{
- if (s == WP_Weapon.netname || s == RADARICON_Weapon.netname) return get_weaponinfo(this.wp_extra).wpcolor;
+ if (s == WP_Weapon.netname || s == RADARICON_Weapon.netname) return Weapons_from(this.wp_extra).wpcolor;
if (s == WP_Item.netname || s == RADARICON_Item.netname) return Items_from(this.wp_extra).m_color;
if (MUTATOR_CALLHOOK(WP_Format, this, s))
{
string spritelookuptext(string s)
{SELFPARAM();
if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
- if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).m_name;
+ if (s == WP_Weapon.netname) return Weapons_from(self.wp_extra).m_name;
if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypoint;
if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;
if (MUTATOR_CALLHOOK(WP_Format, this, s))
void PlayerStats_GameReport_Accuracy(entity p)
{
- int i;
-
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- {
- entity w = get_weaponinfo(i);
-
- #define ACCMAC(suffix,field) \
- PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", w.netname, suffix), p.accuracy.(field[i-1]));
-
+ #define ACCMAC(suffix, field) \
+ PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", it.netname, suffix), p.accuracy.(field[i-1]));
+ FOREACH(Weapons, it != WEP_Null, LAMBDA(
ACCMAC("hit", accuracy_hit)
ACCMAC("fired", accuracy_fired)
ACCMAC("cnt-hit", accuracy_cnt_hit)
ACCMAC("cnt-fired", accuracy_cnt_fired)
ACCMAC("frags", accuracy_frags)
-
- #undef ACCMAC
- }
+ ));
+ #undef ACCMAC
}
void PlayerStats_GameReport_FinalizePlayer(entity p)
PlayerStats_GameReport_AddEvent(PLAYERSTATS_RANK);
// accuracy stats
- entity w;
- float i;
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- {
- w = get_weaponinfo(i);
- PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-hit"));
- PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-fired"));
- PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-cnt-hit"));
- PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-cnt-fired"));
- PlayerStats_GameReport_AddEvent(strcat("acc-", w.netname, "-frags"));
- }
+ FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-hit"));
+ PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-fired"));
+ PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-cnt-hit"));
+ PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-cnt-fired"));
+ PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-frags"));
+ ));
PlayerStats_GameReport_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_3);
PlayerStats_GameReport_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_5);
}
string W_NameWeaponOrder_MapFunc(string s)
{
- entity wi;
- if (s == "0" || stof(s))
+ int i = stof(s);
+ if (s == "0" || i)
{
- wi = get_weaponinfo(stof(s));
+ entity wi = Weapons_from(i);
if (wi != WEP_Null) return wi.netname;
}
return s;
}
string W_NumberWeaponOrder_MapFunc(string s)
{
- int i;
if (s == "0" || stof(s)) return s;
s = W_UndeprecateName(s);
- for (i = WEP_FIRST; i <= WEP_LAST; ++i)
- if (s == get_weaponinfo(i).netname) return ftos(i);
+ FOREACH(Weapons, it != WEP_Null && it.netname == s, LAMBDA(return ftos(i)));
return s;
}
string W_NumberWeaponOrder(string order)
}
float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
{
- entity e1, e2;
- float d;
- e1 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[i]);
- e2 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[j]);
- d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
+ int si = W_FixWeaponOrder_BuildImpulseList_buf[i];
+ Weapon e1 = Weapons_from(si);
+ int sj = W_FixWeaponOrder_BuildImpulseList_buf[j];
+ Weapon e2 = Weapons_from(sj);
+ int d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
if (d != 0) return -d; // high impulse first!
return strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "),
- sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
+ sprintf(" %d ", si), 0)
-
strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "),
- sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
+ sprintf(" %d ", sj), 0)
; // low char index first!
}
string W_FixWeaponOrder_BuildImpulseList(string o)
{
RandomSelection_Init();
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
- if (remaining & WepSet_FromWeapon(j)) RandomSelection_Add(world, j, string_null, 1, 1);
- result |= WepSet_FromWeapon(RandomSelection_chosen_float);
- remaining &= ~WepSet_FromWeapon(RandomSelection_chosen_float);
+ if (remaining & WepSet_FromWeapon(Weapons_from(j))) RandomSelection_Add(NULL, j, string_null, 1, 1);
+ Weapon w = Weapons_from(RandomSelection_chosen_float);
+ result |= WepSet_FromWeapon(w);
+ remaining &= ~WepSet_FromWeapon(w);
}
e.weapons = result;
}
REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
#define Weapons_from(i) _Weapons_from(i, WEP_Null)
-#define get_weaponinfo(i) Weapons_from(i)
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)
+#define WepSet_FromWeapon(it) ((it).m_wepset)
WepSet _WepSet_FromWeapon(int i);
STATIC_INIT(WepSets)
{
for (int i = Weapons_MAX - 1; i >= 1; --i)
if (Weapons_from(i))
weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
- weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
+ weaponorder_byid = strzone(substring(weaponorder_byid, 1, -1));
}
#ifndef MENUQC
void Dump_Weapon_Settings()
{
- int i, x, totalsettings = 0;
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- {
+ int totalweapons = 0, totalsettings = 0;
+ FOREACH(Weapons, it != WEP_Null, LAMBDA(
// step 1: clear the queue
WEP_CONFIG_COUNT = 0;
- for(x = 0; x <= MAX_WEP_CONFIG; ++x)
+ for (int x = 0; x <= MAX_WEP_CONFIG; ++x)
{ wep_config_queue[x] = string_null; }
// step 2: build new queue
- Weapon w = get_weaponinfo(i);
- w.wr_config(w);
+ it.wr_config(it);
// step 3: sort queue
heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, world);
WEP_CONFIG_WRITETOFILE(sprintf(
"// {{{ #%d: %s%s\n",
i,
- WEP_NAME(i),
- (((get_weaponinfo(i)).spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
+ it.m_name,
+ ((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
));
- for(x = 0; x <= WEP_CONFIG_COUNT; ++x) { WEP_CONFIG_WRITETOFILE(wep_config_queue[x]); }
+ for (int x = 0; x <= WEP_CONFIG_COUNT; ++x) { WEP_CONFIG_WRITETOFILE(wep_config_queue[x]); }
WEP_CONFIG_WRITETOFILE("// }}}\n");
// step 5: debug info
- LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, WEP_NAME(i), WEP_CONFIG_COUNT));
+ LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.m_name, WEP_CONFIG_COUNT));
+ totalweapons += 1;
totalsettings += WEP_CONFIG_COUNT;
- }
+ ));
// clear queue now that we're finished
WEP_CONFIG_COUNT = 0;
- for(x = 0; x <= MAX_WEP_CONFIG; ++x)
+ for(int x = 0; x <= MAX_WEP_CONFIG; ++x)
{ wep_config_queue[x] = string_null; }
// extra information
- LOG_INFO(sprintf("Totals: %d weapons, %d settings\n", (i - 1), totalsettings));
+ LOG_INFO(sprintf("Totals: %d weapons, %d settings\n", totalweapons, totalsettings));
}
// other useful macros
#define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
-#define WEP_NAME(wpn) ((get_weaponinfo(wpn)).m_name)
+#define WEP_NAME(wpn) ((Weapons_from(wpn)).m_name)
#endif
METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(autocvar_g_balance_crylink_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
}
if(fire & 1)
METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else {
if(fire & 1)
{
if(!ammo_amount)
{
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
return;
}
}
self.hagar_warning = false;
// we aren't checking ammo during an attack, so we must do it here
- Weapon w = get_weaponinfo(self.weapon);
- if(!(w.wr_checkammo1(w) + w.wr_checkammo2(w)))
+ if(!(thiswep.wr_checkammo1(thiswep) + thiswep.wr_checkammo2(thiswep)))
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
// note: this doesn't force the switch
if(loadable_secondary)
W_Hagar_Attack2_Load(thiswep, weaponentity); // must always run each frame
if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else if((fire & 1) && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hagar, refire)))
if(actor.BUTTON_ATCK)
{
- Weapon w = get_weaponinfo(actor.weapon);
- if(!w.wr_checkammo1(w))
+ if(!thiswep.wr_checkammo1(thiswep))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(autocvar_g_balance_hlac_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else if(fire & 1)
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
}
if(actor.BUTTON_ATCK)
{
- Weapon w = get_weaponinfo(actor.weapon);
- if(!w.wr_checkammo2(w))
+ if(!thiswep.wr_checkammo2(thiswep))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
return;
}
- Weapon w = get_weaponinfo(actor.weapon);
- if(!w.wr_checkammo1(w))
+ if(!thiswep.wr_checkammo1(thiswep))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(WEP_CVAR(machinegun, reload_ammo) && actor.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else
if(WEP_CVAR(machinegun, mode) == 1)
{
if(fire & 2)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
{
- Weapon w = get_weaponinfo(actor.weapon);
- if(!w.wr_checkammo2(w))
+ if(!thiswep.wr_checkammo2(thiswep))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
{
// not if we're holding the minelayer without enough ammo, but can detonate existing mines
if(!(W_MineLayer_PlacedMines(false) && actor.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo))) {
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
}
}
else if(fire & 1)
METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(autocvar_g_balance_mortar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else if(fire & 1)
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire)))
METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(autocvar_g_balance_rifle_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else
{
actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time);
if(WEP_CVAR(rifle, secondary))
{
if(WEP_CVAR_SEC(rifle, reload)) {
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else
{
if(weapon_prepareattack_check(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(rifle, refire)))
METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
if(autocvar_g_balance_seeker_reload_ammo && actor.clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else if(fire & 1)
{
if(WEP_CVAR(seeker, type) == 1)
// alternate secondary weapon frames
void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- Weapon w = get_weaponinfo(actor.weapon);
- if (!w.wr_checkammo2(w))
+ if (!thiswep.wr_checkammo2(thiswep))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
}
void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- Weapon w = get_weaponinfo(actor.weapon);
- if (!w.wr_checkammo2(w))
+ if (!thiswep.wr_checkammo2(thiswep))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
{
// don't force reload an empty shotgun if its melee attack is active
if(WEP_CVAR(shotgun, secondary) < 2) {
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
}
}
else
float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
// if the laser uses load, we also consider its ammo for reloading
if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else if(WEP_CVAR(vaporizer, reload_ammo) && actor.clip_load < vaporizer_ammo) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
}
if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
{
}
if(autocvar_g_balance_vortex_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
+ thiswep.wr_reload(thiswep);
} else
{
if(fire & 1)
--- /dev/null
+# CSQC
+
+```
+
+// input:
+// self
+.void() predraw;
+
+// input:
+// time
+// self
+.void() think;
+
+// 0 = keydown, key, character (EXT_CSQC)
+// 1 = keyup, key, character (EXT_CSQC)
+// 2 = mousemove relative, x, y (EXT_CSQC)
+// 3 = mousemove absolute, x, y (DP_CSQC)
+bool CSQC_InputEvent(int eventtype, int x, int y);
+
+void CSQC_UpdateView(int width, int height);
+bool CSQC_ConsoleCommand(string cmd);
+bool CSQC_Parse_TempEntity();
+bool CSQC_Parse_StuffCmd(string msg);
+bool CSQC_Parse_Print(string msg);
+bool CSQC_Parse_CenterPrint(string msg);
+bool CSQC_Event_Sound(int ent, int channel, string sample, float volume, float attenuation, vector pos, float speed, int flags);
+
+entity CSQC_Ent_Spawn(int entnum);
+void CSQC_Ent_Update(bool isnew);
+void CSQC_Ent_Remove();
+
+void CSQC_Init();
+void CSQC_Shutdown();
+
+// input:
+// time
+// self
+// v_forward: forward
+// v_right: right
+// v_up: up
+// output:
+// origin
+// v_forward: forward
+// v_right: right
+// v_up: up
+// trace_endpos: visorigin
+.vector camera_transform(vector pos, vector ang);
+
+```
+
+# SVQC
+
+```
+
+.entity clientcamera;
+
+// input:
+// time
+// self
+void ClientDisconnect();
+
+// input:
+// time
+void SV_Shutdown();
+
+// input:
+// time
+void SV_PausedTic(float elapsed);
+
+// input:
+// time
+// self
+void SV_ChangeTeam(int color);
+
+// input:
+// time
+// self
+void ClientKill();
+
+// input:
+// time
+// self
+void RestoreGame();
+
+// input:
+// time
+// self
+// parm1..n
+void ClientConnect();
+
+// input:
+// time
+// self
+// parm1..n
+void PutClientInServer();
+
+// return false to remove
+.bool SendEntity(entity to, int sf);
+
+// input:
+// time
+// self
+void SV_OnEntityPreSpawnFunction();
+
+// input:
+// time
+// self
+void SV_OnEntityNoSpawnFunction();
+
+// input:
+// time
+// self
+void SV_OnEntityPostSpawnFunction();
+
+// input:
+// time
+// output:
+// parm1..n
+void SetNewParms();
+
+// input:
+//
+.bool customizeentityforclient();
+
+// input:
+// time
+// self
+// output:
+// parm1..n
+void SetChangeParms();
+
+// input:
+// time
+// self
+// other
+// trace_allsolid
+// trace_startsolid
+// trace_fraction
+// trace_inwater
+// trace_inopen
+// trace_endpos: self.origin
+// trace_plane_normal
+// trace_plane_dist
+// trace_ent: other
+// trace_dpstartcontents
+// trace_dphitcontents
+// trace_dphitq3surfaceflags
+// trace_dphittexturename
+.void touch();
+
+// when .watertype changes:
+.void contentstransition(int prev, int current);
+
+// input:
+// time
+// self
+// other
+.void blocked();
+
+// input:
+// time
+// self
+.void movetypesteplandevent(vector vel);
+
+// input:
+// time
+// self
+void PlayerPreThink();
+
+// input:
+// time
+// self
+void PlayerPostThink();
+
+// input:
+// time
+// frametime
+void StartFrame();
+
+// input:
+// time
+void EndFrame();
+
+// input:
+// time
+// self
+void SV_PlayerPhysics();
+
+// input:
+// time
+// self
+void SV_ParseClientCommand(string cmd);
+
+```
+
+# MENUQC
+
+```
+
+void m_keydown(int key, int ascii);
+
+void m_keyup(int key, int ascii);
+
+void m_draw(int width, int height);
+
+void m_toggle(int mode);
+
+int m_gethostcachecategory(int entry);
+
+void m_shutdown();
+
+void m_init();
+
+```
+
+# All
+
+```
+
+void URI_Get_Callback(int id, int status, string data);
+
+void GameCommand(string cmd);
+
+```
{
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if(argv(i) == e.netname)
s = strcat(s, " & ", e.m_name);
}
e.cvarOffValue = "0";
for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
{
- w = get_weaponinfo(i);
+ w = Weapons_from(i);
if(w.spawnflags & WEP_FLAG_HIDDEN)
continue;
if((j & 1) == 0)
int i;
- #define ADD_TO_W_LIST(pred) do { \
- for(i = WEP_FIRST; i <= WEP_LAST; ++i) \
- { \
- wep = get_weaponinfo(i); \
- if(wep.impulse == imp && (pred)) \
- w_list = strcat(w_list, WEP_NAME(i), " / "); \
- } \
- } while(0)
-
- int imp;
- entity wep;
- string w_list = "";
- for(imp = 1; imp <= 9; ++imp)
+ #define ADD_TO_W_LIST(pred) \
+ FOREACH(Weapons, it != WEP_Null, LAMBDA( \
+ if (it.impulse != imp) continue; \
+ if (!(pred)) continue; \
+ w_list = strcat(w_list, it.m_name, " / "); \
+ ))
+
+ for(int imp = 1; imp <= 9; ++imp)
{
- ADD_TO_W_LIST(!(wep.flags & WEP_FLAG_MUTATORBLOCKED) && !(wep.flags & WEP_FLAG_SUPERWEAPON));
- ADD_TO_W_LIST(wep.flags & WEP_FLAG_SUPERWEAPON);
- ADD_TO_W_LIST(wep.flags & WEP_FLAG_MUTATORBLOCKED);
+ string w_list = "";
+ ADD_TO_W_LIST(!(it.flags & WEP_FLAG_MUTATORBLOCKED) && !(it.flags & WEP_FLAG_SUPERWEAPON));
+ ADD_TO_W_LIST(it.flags & WEP_FLAG_SUPERWEAPON);
+ ADD_TO_W_LIST(it.flags & WEP_FLAG_MUTATORBLOCKED);
if(w_list)
KEYBIND_DEF(strcat("weapon_group_", itos(imp)), substring(w_list, 0, -4));
- w_list = "";
if(imp == 0)
break;
if(imp == 9)
s = "";
for(i = 0; i < n; ++i)
{
- e = get_weaponinfo(stof(argv(i)));
+ e = Weapons_from(stof(argv(i)));
s = strcat(s, e.m_name, ", ");
}
return substring(s, 0, strlen(s) - 2);
me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
}
- e = get_weaponinfo(stof(argv(i)));
+ e = Weapons_from(stof(argv(i)));
string msg = e.m_name;
if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
msg = strcat(msg, "*");
if(self.weapons)
{
- Weapon w = get_weaponinfo(self.weapon);
+ Weapon w = Weapons_from(self.weapon);
w.wr_aim(w);
if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(self))
{
{
for (int i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- entity e = get_weaponinfo(i);
+ entity e = Weapons_from(i);
if ((self.weapons & (e.m_wepset)) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < e.reloading_ammo))
self.switchweapon = i;
}
float i, other_weapon_available = false;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- Weapon w = get_weaponinfo(i);
+ Weapon w = Weapons_from(i);
// if we are out of ammo for all other weapons, it's an emergency to switch to anything else
if (w.wr_checkammo1(w) + w.wr_checkammo2(w))
other_weapon_available = true;
break;
case 20:
if(!forbidWeaponUse(self)) {
- Weapon w = get_weaponinfo(self.weapon);
+ Weapon w = Weapons_from(self.weapon);
w.wr_reload(w);
}
break;
if(DIFF_TEAM(self, attacker))
{
if(DEATH_ISSPECIAL(deathtype))
- awep = get_weaponinfo(attacker.weapon);
+ awep = Weapons_from(attacker.weapon);
else
awep = DEATH_WEAPONOF(deathtype);
valid_damage_for_weaponstats = 1;
MUTATOR_CALLHOOK(PlayerDies, inflictor, attacker, self, deathtype);
excess = frag_damage;
- Weapon wep = get_weaponinfo(self.weapon);
+ Weapon wep = Weapons_from(self.weapon);
wep.wr_playerdeath(wep);
RemoveGrapplingHook(self);
// reset fields the weapons may use just in case
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- Weapon w = get_weaponinfo(j);
+ Weapon w = Weapons_from(j);
w.wr_resetplayer(w);
for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
{
// 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 & (culprit.m_wepset))) culprit = get_weaponinfo(attacker.weapon);
+ if(!culprit) culprit = Weapons_from(attacker.weapon);
+ else if(!(attacker.weapons & (culprit.m_wepset))) culprit = Weapons_from(attacker.weapon);
if(g_weaponarena_random_with_blaster && culprit == WEP_BLASTER) // WEAPONTODO: Shouldn't this be in a mutator?
{
}
// after a frag, choose another random weapon set
- if (!(attacker.weapons & WepSet_FromWeapon(attacker.weapon)))
+ if (!(attacker.weapons & WepSet_FromWeapon(Weapons_from(attacker.weapon))))
W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker));
}
g_weaponarena_list = "All Weapons";
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if (!(e.spawnflags & WEP_FLAG_MUTATORBLOCKED))
g_weaponarena_weapons |= (e.m_wepset);
}
g_weaponarena_list = "Most Weapons";
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if (!(e.spawnflags & WEP_FLAG_MUTATORBLOCKED))
if (e.spawnflags & WEP_FLAG_NORMAL)
g_weaponarena_weapons |= (e.m_wepset);
s = argv(i);
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if (e.netname == s)
{
g_weaponarena_weapons |= (e.m_wepset);
{
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- e = get_weaponinfo(i);
+ e = Weapons_from(i);
int w = want_weapon(e, false);
WepSet s = e.m_wepset;
if(w & 1)
warmup_start_weapons_defaultmask = '0 0 0';
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- e = get_weaponinfo(i);
+ e = Weapons_from(i);
int w = want_weapon(e, g_warmup_allguns);
WepSet s = (e.m_wepset);
if(w & 1)
precache_weapons |= warmup_start_weapons;
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- e = get_weaponinfo(i);
+ e = Weapons_from(i);
if(precache_weapons & (e.m_wepset)) {
e.wr_init(e);
}
game_starttime = time + cvar("g_start_delay");
for(int i = WEP_FIRST; i <= WEP_LAST; ++i) {
- Weapon w = get_weaponinfo(i);
+ Weapon w = Weapons_from(i);
w.wr_init(w);
}
MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0');
do {
{
- entity wi = get_weaponinfo(self.weapon);
+ entity wi = Weapons_from(self.weapon);
if (wi.m_id) {
entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Weapon);
wp.wp_extra = wi.m_id;
if (player.switchweapon == w_getbestweapon(player))
_switchweapon = true;
- if (!(player.weapons & WepSet_FromWeapon(player.switchweapon)))
+ if (!(player.weapons & WepSet_FromWeapon(Weapons_from(player.switchweapon))))
_switchweapon = true;
pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
{
pickedup = true;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- if(it & WepSet_FromWeapon(i))
+ if(it & WepSet_FromWeapon(Weapons_from(i)))
{
W_DropEvent(wr_pickup, player, i, item);
W_GiveWeapon(player, i);
// Detect needed ammo
for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
{
- wi = get_weaponinfo(i);
+ wi = Weapons_from(i);
if (!(player.weapons & (wi.m_wepset)))
continue;
}
if(weaponid)
- this.weapons = WepSet_FromWeapon(weaponid);
+ this.weapons = WepSet_FromWeapon(Weapons_from(weaponid));
this.flags = FL_ITEM | itemflags;
this.is_item = true;
}
- weaponsInMap |= WepSet_FromWeapon(weaponid);
+ weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
precache_model(this.model);
precache_sound(this.item_pickupsound);
{
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
s = W_UndeprecateName(argv(i));
if(s == e.netname)
{
self.weapons |= (e.m_wepset);
if(self.spawnflags == 0 || self.spawnflags == 2) {
- Weapon w = get_weaponinfo(e.weapon);
+ Weapon w = Weapons_from(e.weapon);
w.wr_init(w);
}
break;
if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "armor");
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if(e.weapon)
self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (e.m_wepset)), e.netname);
}
{
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if(argv(i) == e.netname)
{
- Weapon w = get_weaponinfo(e.weapon);
+ Weapon w = Weapons_from(e.weapon);
w.wr_init(w);
break;
}
float GiveWeapon(entity e, float wpn, float op, float val)
{
WepSet v0, v1;
- WepSet s = WepSet_FromWeapon(wpn);
+ WepSet s = WepSet_FromWeapon(Weapons_from(wpn));
v0 = (e.weapons & s);
switch(op)
{
case "allweapons":
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- wi = get_weaponinfo(j);
+ wi = Weapons_from(j);
if(wi.weapon)
if (!(wi.spawnflags & WEP_FLAG_MUTATORBLOCKED))
got += GiveWeapon(e, j, op, val);
default:
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- wi = get_weaponinfo(j);
+ wi = Weapons_from(j);
if(cmd == wi.netname)
{
got += GiveWeapon(e, j, op, val);
POSTGIVE_BIT(e, items, ITEM_Jetpack.m_itemid, SND(ITEMPICKUP), string_null);
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- wi = get_weaponinfo(j);
+ wi = Weapons_from(j);
if(wi.weapon)
{
- POSTGIVE_WEAPON(e, j, SND(WEAPONPICKUP), string_null);
+ POSTGIVE_WEAPON(e, Weapons_from(j), SND(WEAPONPICKUP), string_null);
if (!(save_weapons & (wi.m_wepset)))
if(e.weapons & (wi.m_wepset)) {
- Weapon w = get_weaponinfo(wi.weapon);
+ Weapon w = Weapons_from(wi.weapon);
w.wr_init(w);
}
}
else
e.superweapons_finished += time;
- if (!(e.weapons & WepSet_FromWeapon(e.switchweapon)))
+ if (!(e.weapons & WepSet_FromWeapon(Weapons_from(e.switchweapon))))
_switchweapon = true;
if(_switchweapon)
W_SwitchWeapon_Force(e, w_getbestweapon(e));
if (!wep)
return;
- e.weapons |= WepSet_FromWeapon(wep);
+ e.weapons |= WepSet_FromWeapon(Weapons_from(wep));
setself(e);
// ignore hook button when using other offhand equipment
if (cl.offhand != OFFHAND_HOOK)
- if (wpn == WEP_HOOK.m_id && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
+ if (wpn == WEP_HOOK.m_id && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(Weapons_from(wpn))))
complain = 0;
if(complain)
sprint(self, "Invalid weapon\n");
return false;
}
- if (cl.weapons & WepSet_FromWeapon(wpn))
+ if (cl.weapons & WepSet_FromWeapon(Weapons_from(wpn)))
{
if (andammo)
{
else
{
setself(cl);
- Weapon w = get_weaponinfo(wpn);
+ Weapon w = Weapons_from(wpn);
f = w.wr_checkammo1(w) + w.wr_checkammo2(w);
// always allow selecting the Mine Layer if we placed mines, so that we can detonate them
{
// DRESK - 3/16/07
// Report Proper Weapon Status / Modified Weapon Ownership Message
- if (weaponsInMap & WepSet_FromWeapon(wpn))
+ if (weaponsInMap & WepSet_FromWeapon(Weapons_from(wpn)))
{
Send_WeaponComplain(cl, wpn, 1);
while(rest != "")
{
weaponwant = stof(car(rest)); rest = cdr(rest);
- wep = get_weaponinfo(weaponwant);
+ wep = Weapons_from(weaponwant);
wepset = wep.m_wepset;
if(imp >= 0)
if(wep.impulse != imp)
float i, have_other = false;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- Weapon e = get_weaponinfo(i);
+ Weapon e = Weapons_from(i);
if(i != weaponwant)
if(e.impulse == imp || imp < 0)
if((pl.weapons & (e.m_wepset)) || (weaponsInMap & (e.m_wepset)))
while(rest != "")
{
weaponwant = stof(car(rest)); rest = cdr(rest);
- wep = get_weaponinfo(weaponwant);
+ wep = Weapons_from(weaponwant);
wepset = wep.m_wepset;
if(imp >= 0)
if(wep.impulse != imp)
float i, have_other = false;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- Weapon w = get_weaponinfo(i);
+ Weapon w = Weapons_from(i);
if(i != weaponwant)
if(w.impulse == imp || imp < 0)
if((pl.weapons & (w.m_wepset)) || (weaponsInMap & (w.m_wepset)))
{
// hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
int ww;
- WepSet set = WepSet_FromWeapon(pl.weapon);
+ WepSet set = WepSet_FromWeapon(Weapons_from(pl.weapon));
if(pl.weapons & set)
{
pl.weapons &= ~set;
self.selectweapon = imp; // update selectweapon ANYWAY
}
else if(!forbidWeaponUse(self)) {
- Weapon w = get_weaponinfo(self.weapon);
+ Weapon w = Weapons_from(self.weapon);
w.wr_reload(w);
}
}
for(j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if(e.netname == s)
{
replacement = e.weaponreplace;
int j;
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if (e.netname == s)
{
entity replacement = spawn();
int j;
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
{
- e = get_weaponinfo(j);
+ e = Weapons_from(j);
if (e.netname == s)
{
wpn = j;
}
}
- e = get_weaponinfo(wpn);
+ e = Weapons_from(wpn);
if (!this.respawntime)
{
{SELFPARAM();
float thisammo, i;
string s;
- Weapon info = get_weaponinfo(wpn);
+ Weapon info = Weapons_from(wpn);
var .int ammotype = info.ammo_field;
entity wep = new(droppedweapon);
W_DropEvent(wr_drop,own,wpn,wep);
- if(WepSet_FromWeapon(wpn) & WEPSET_SUPERWEAPONS)
+ if(WepSet_FromWeapon(Weapons_from(wpn)) & WEPSET_SUPERWEAPONS)
{
if(own.items & IT_UNLIMITED_SUPERWEAPONS)
{
float superweapons = 1;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- WepSet set = WepSet_FromWeapon(i);
+ WepSet set = WepSet_FromWeapon(Weapons_from(i));
if ((set & WEPSET_SUPERWEAPONS) && (own.weapons & set)) ++superweapons;
}
if(superweapons <= 1)
return false;
#if 0
- if(start_weapons & WepSet_FromWeapon(w))
+ if(start_weapons & WepSet_FromWeapon(Weapons_from(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)
return false;
- if((get_weaponinfo(w)).ammo_field == ammo_none)
+ if((Weapons_from(w)).ammo_field == ammo_none)
return false;
}
return true;
#else
- return (get_weaponinfo(w)).weaponthrowable;
+ return (Weapons_from(w)).weaponthrowable;
#endif
}
if(!W_IsWeaponThrowable(w))
return;
- WepSet set = WepSet_FromWeapon(w);
+ WepSet set = WepSet_FromWeapon(Weapons_from(w));
if(!(self.weapons & set)) return;
self.weapons &= ~set;
void SpawnThrownWeapon(vector org, float w)
{SELFPARAM();
- if(self.weapons & WepSet_FromWeapon(self.weapon))
+ if(self.weapons & WepSet_FromWeapon(Weapons_from(self.weapon)))
if(W_IsWeaponThrowable(self.weapon))
W_ThrowNewWeapon(self, self.weapon, false, org, randomvec() * 125 + '0 0 200');
}
// server framerate is very low and the weapon fire rate very high
for (int c = 0; c < W_TICSPERFRAME; ++c)
{
- if (w && !(actor.weapons & WepSet_FromWeapon(w)))
+ if (w && !(actor.weapons & WepSet_FromWeapon(Weapons_from(w))))
{
if (actor.weapon == actor.switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
w = 0;