it.weapons = start_weapons;
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false))
- it.(weaponentity).m_switchweapon = w_getbestweapon(it);
+ it.(weaponentity).m_switchweapon = w_getbestweapon(it, weaponentity);
});
}
if((!thiswep.wr_checkammo1(thiswep, actor, weaponentity) && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (!(actor.items & IT_SUPERWEAPON) && !(actor.items & IT_UNLIMITED_SUPERWEAPONS)))
{
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
// if the player is using their best weapon before items are given, they
// probably want to switch to an even better weapon after items are given
if (player.autoswitch)
- if (player.(weaponentity).m_switchweapon == w_getbestweapon(player))
+ if (player.(weaponentity).m_switchweapon == w_getbestweapon(player, weaponentity))
_switchweapon = true;
if (!(player.weapons & WepSet_FromWeapon(player.(weaponentity).m_switchweapon)))
}
if (_switchweapon)
- if (player.(weaponentity).m_switchweapon != w_getbestweapon(player))
- W_SwitchWeapon_Force(player, w_getbestweapon(player), weaponentity);
+ if (player.(weaponentity).m_switchweapon != w_getbestweapon(player, weaponentity))
+ W_SwitchWeapon_Force(player, w_getbestweapon(player, weaponentity), weaponentity);
return 1;
}
_switchweapon = false;
if (e.autoswitch)
- if (e.(weaponentity).m_switchweapon == w_getbestweapon(e))
+ if (e.(weaponentity).m_switchweapon == w_getbestweapon(e, weaponentity))
_switchweapon = true;
e.strength_finished = max(0, e.strength_finished - time);
if (!(e.weapons & WepSet_FromWeapon(e.(weaponentity).m_switchweapon)))
_switchweapon = true;
if(_switchweapon)
- W_SwitchWeapon_Force(e, w_getbestweapon(e), weaponentity);
+ W_SwitchWeapon_Force(e, w_getbestweapon(e, weaponentity), weaponentity);
return got;
}
{
// ran out of ammo!
actor.cnt = WEP_CRYLINK.m_id;
- actor.(weaponentity).m_switchweapon = w_getbestweapon(actor);
+ actor.(weaponentity).m_switchweapon = w_getbestweapon(actor, weaponentity);
}
}
}
this.realowner.cnt = WEP_DEVASTATOR.m_id;
int slot = weaponslot(weaponentity);
ATTACK_FINISHED(this.realowner, slot) = time;
- this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner);
+ this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
}
}
delete(this);
this.realowner.cnt = WEP_DEVASTATOR.m_id;
int slot = weaponslot(weaponentity);
ATTACK_FINISHED(this.realowner, slot) = time;
- this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner);
+ this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
}
}
delete(this);
if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
{
actor.ammo_fuel = 0;
actor.(weaponentity).hook_state |= HOOK_REMOVING;
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
}
}
}
if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
own.cnt = WEP_MINE_LAYER.m_id;
int slot = weaponslot(weaponentity);
ATTACK_FINISHED(own, slot) = time;
- own.(weaponentity).m_switchweapon = w_getbestweapon(own);
+ own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
}
}
this.realowner.minelayer_mines -= 1;
own.cnt = WEP_MINE_LAYER.m_id;
int slot = weaponslot(weaponentity);
ATTACK_FINISHED(own, slot) = time;
- own.(weaponentity).m_switchweapon = w_getbestweapon(own);
+ own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
}
}
this.realowner.minelayer_mines -= 1;
if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
{
.entity weaponentity = weaponentities[slot];
if(slot == 0)
- this.(weaponentity).m_switchweapon = w_getbestweapon(this);
+ this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
else
this.(weaponentity).m_switchweapon = WEP_Null;
this.(weaponentity).weaponname = "";
// after a frag, choose another random weapon set
if (!(attacker.weapons & WepSet_FromWeapon(attacker.(weaponentity).m_weapon)))
- W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker), weaponentity);
+ W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker, weaponentity), weaponentity);
}
// FIXME fix the mess this is (we have REAL points now!)
{
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
if (s == "cl_weaponpriority")
- if (this.(weaponentity)) this.(weaponentity).m_switchweapon = w_getbestweapon(this);
+ if (this.(weaponentity)) this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
if (s == "cl_allow_uidtracking")
PlayerStats_GameReport_AddPlayer(this);
}
return ret;
}
-void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright, vector screenup)
+void W_HitPlotAnalysis(entity player, .entity weaponentity, vector screenforward, vector screenright, vector screenup)
{
vector hitplot;
vector org;
antilag_takeback(trace_ent, store, time - lag);
hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos);
antilag_restore(trace_ent, store);
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
fputs(player.hitplotfh, strcat(ftos(hitplot.x), " ", ftos(hitplot.y), " ", ftos(hitplot.z), " ", ftos(player.(weaponentity).m_switchweapon.m_id), "\n"));
//print(strcat(ftos(hitplot_x), " ", ftos(hitplot_y), " ", ftos(hitplot_z), "\n"));
}
.float hitplotfh;
-void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright, vector screenup);
+void W_HitPlotAnalysis(entity player, .entity weaponentity, vector screenforward, vector screenright, vector screenup);
void W_HitPlotOpen(entity player);
void W_HitPlotClose(entity player);
if (this.weapons & set)
{
this.weapons &= ~set;
- ww = w_getbestweapon(this);
+ ww = w_getbestweapon(this, weaponentity);
this.weapons |= set;
}
else
{
- ww = w_getbestweapon(this);
+ ww = w_getbestweapon(this, weaponentity);
}
if (ww == WEP_Null) return;
W_SwitchWeapon_Force(this, ww, weaponentity);
.int weaponcomplainindex;
float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing, .entity weaponentity);
-// TODO: unhardcode
-#define w_getbestweapon(ent) Weapons_from(W_GetCycleWeapon(ent, ent.cvar_cl_weaponpriority, 0, -1, false, true, weaponentities[0]))
+#define w_getbestweapon(ent,wepent) Weapons_from(W_GetCycleWeapon(ent, ent.cvar_cl_weaponpriority, 0, -1, false, true, wepent))
void W_SwitchWeapon_Force(Player this, Weapon w, .entity weaponentity);
if(!(this.weapons & set)) return;
this.weapons &= ~set;
- W_SwitchWeapon_Force(this, w_getbestweapon(this), weaponentity);
+ W_SwitchWeapon_Force(this, w_getbestweapon(this, weaponentity), weaponentity);
string a = W_ThrowNewWeapon(this, w.m_id, doreduce, this.origin + delta, velo, weaponentity);
if(!a) return;
accuracy_add(ent, ent.(weaponentity).m_weapon.m_id, maxdamage, 0);
if(IS_PLAYER(ent))
- W_HitPlotAnalysis(ent, v_forward, v_right, v_up);
+ W_HitPlotAnalysis(ent, weaponentity, v_forward, v_right, v_up);
vector md = ent.(weaponentity).movedir;
if(md.x > 0)
wepent_link(view);
- if (weaponentity == weaponentities[0])
+ if (weaponentity == weaponentities[0]) // only one exterior model, thank you very much
{
entity exterior = actor.exteriorweaponentity = new(exteriorweaponentity);
exterior.solid = SOLID_NOT;
{
if (w != WEP_Null && !(actor.weapons & WepSet_FromWeapon(w)))
{
- if (this.m_weapon == this.m_switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+ if (this.m_weapon == this.m_switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
w = WEP_Null;
}