//weapon_setup(WEP_PORTO.m_id);
}
-METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor))
+METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor, .entity weaponentity))
{
TC(BallStealer, this);
return true;
}
-METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor))
+METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor, .entity weaponentity))
{
TC(BallStealer, this);
return true;
}
}
-METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor)) {
+METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor, .entity weaponentity)) {
TC(WyvernAttack, this);
return true;
}
it.ammo_fuel = start_ammo_fuel;
it.weapons = start_weapons;
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
- if(!client_hasweapon(it, it.(weaponentity).m_weapon, true, false))
+ if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false))
it.(weaponentity).m_switchweapon = w_getbestweapon(it);
});
}
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
Weapon w = Weapons_from(nix_weapon);
if(this.(weaponentity).m_switchweapon != w)
- if(!client_hasweapon(this, this.(weaponentity).m_switchweapon, true, false))
+ if(!client_hasweapon(this, this.(weaponentity).m_switchweapon, weaponentity, true, false))
{
- if(client_hasweapon(this, w, true, false))
+ if(client_hasweapon(this, w, weaponentity, true, false))
W_SwitchWeapon(this, w, weaponentity);
}
}
return;
}
- if((!thiswep.wr_checkammo1(thiswep, actor) && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (!(actor.items & IT_SUPERWEAPON) && !(actor.items & IT_UNLIMITED_SUPERWEAPONS)))
+ 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_ready(thiswep, actor, weaponentity, fire);
}
}
-METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
return ammo_amount;
}
-METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
}
}
-METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
ammo_amount += actor.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
return ammo_amount;
}
-METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
return false;
}
FOREACH(Weapons, it != WEP_Null, {
if(w & (it.m_wepset))
{
- W_DropEvent(wr_pickup, player, it.m_id, item);
+ W_DropEvent(wr_pickup, player, it.m_id, item, weaponentity);
W_GiveWeapon(player, it.m_id);
}
});
#ifdef SVQC
Weapon wep1 = WEP_RACER;
+ .entity weaponentity = weaponentities[0]; // TODO: unhardcode
if (!forbidWeaponUse(this))
if (PHYS_INPUT_BUTTON_ATCK(this))
- if (wep1.wr_checkammo1(wep1, vehic))
+ if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
{
string tagname = (vehic.cnt)
? (vehic.cnt = 0, "tag_fire1")
// Fix z-aim (for chase mode)
crosshair_trace(this);
w_shotdir.z = normalize(trace_endpos - org).z * 0.5;
- .entity weaponentity = weaponentities[0];
wep1.wr_think(wep1, vehic, weaponentity, 1);
}
}
}
-METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep, entity actor))
+METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep, entity actor, .entity weaponentity))
{
bool isPlayer = IS_PLAYER(actor);
entity player = isPlayer ? actor : actor.owner;
*/
Weapon wep1 = WEP_RAPTOR;
+ .entity weaponentity = weaponentities[0];
if(!forbidWeaponUse(this))
if(PHYS_INPUT_BUTTON_ATCK(this))
- if (wep1.wr_checkammo1(wep1, vehic))
+ if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
{
- .entity weaponentity = weaponentities[0];
wep1.wr_think(wep1, vehic, weaponentity, 1);
}
weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready);
}
}
-METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor)) {
+METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor, .entity weaponentity)) {
bool isPlayer = IS_PLAYER(actor);
entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
/** (SERVER) logic to run every frame */
METHOD(Weapon, wr_think, void(Weapon this, entity actor, .entity weaponentity, int fire)) {}
/** (SERVER) checks ammo for weapon primary */
- METHOD(Weapon, wr_checkammo1, bool(Weapon this, entity actor)) {return false;}
+ METHOD(Weapon, wr_checkammo1, bool(Weapon this, entity actor, .entity weaponentity)) {return false;}
/** (SERVER) checks ammo for weapon second */
- METHOD(Weapon, wr_checkammo2, bool(Weapon this, entity actor)) {return false;}
+ METHOD(Weapon, wr_checkammo2, bool(Weapon this, entity actor, .entity weaponentity)) {return false;}
/** (SERVER) runs bot aiming code for this weapon */
METHOD(Weapon, wr_aim, void(Weapon this, entity actor)) {}
/** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
/** (CLIENT) weapon specific glow */
METHOD(Weapon, wr_glow, vector(Weapon this, entity actor, entity wepent)) { return '0 0 0'; }
/** (SERVER) the weapon is dropped */
- METHOD(Weapon, wr_drop, void(Weapon this, entity actor)) {}
+ METHOD(Weapon, wr_drop, void(Weapon this, entity actor, .entity weaponentity)) {}
/** (SERVER) a weapon is picked up */
- METHOD(Weapon, wr_pickup, void(Weapon this, entity actor)) {}
+ METHOD(Weapon, wr_pickup, void(Weapon this, entity actor, .entity weaponentity)) {}
/** (SERVER) update cvar based properties */
METHOD(Weapon, wr_update, void(Weapon this)) {}
METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
if(this == this.owner.(weaponentity).arc_beam) { this.owner.(weaponentity).arc_beam = NULL; }
entity own = this.owner;
Weapon w = WEP_ARC;
- if(!w.wr_checkammo1(w, own) && !w.wr_checkammo2(w, own))
+ if(!w.wr_checkammo1(w, own, weaponentity) && !w.wr_checkammo2(w, own, weaponentity))
if(!(own.items & IT_UNLIMITED_WEAPON_AMMO))
{
// note: this doesn't force the switch
arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 4);
}
}
-METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
return ((!WEP_CVAR(arc, beam_ammo)) || (actor.(thiswep.ammo_field) > 0));
}
-METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
if(WEP_CVAR(arc, bolt))
{
else
return WEAPON_ARC_MURDER;
}
-METHOD(Arc, wr_drop, void(entity thiswep, entity actor))
+METHOD(Arc, wr_drop, void(entity thiswep, entity actor, .entity weaponentity))
{
weapon_dropevent_item.arc_overheat = actor.arc_overheat;
weapon_dropevent_item.arc_cooldown = actor.arc_cooldown;
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
actor.arc_BUTTON_ATCK_prev[slot] = false;
}
-METHOD(Arc, wr_pickup, void(entity thiswep, entity actor))
+METHOD(Arc, wr_pickup, void(entity thiswep, entity actor, .entity weaponentity))
{
- if ( !client_hasweapon(actor, thiswep, false, false) &&
+ if ( !client_hasweapon(actor, thiswep, weaponentity, false, false) &&
weapon_dropevent_item.arc_overheat > time )
{
actor.arc_overheat = weapon_dropevent_item.arc_overheat;
actor.ammo_field = ammo_none;
}
-METHOD(Blaster, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Blaster, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
return true; // infinite ammo
}
-METHOD(Blaster, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Blaster, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
return true; // blaster has infinite ammo
}
void W_Crylink_Dequeue_Raw(entity own, entity prev, entity me, entity next)
{
W_Crylink_CheckLinks(next);
- if(me == own.crylink_lastgroup)
- own.crylink_lastgroup = ((me == next) ? NULL : next);
+ .entity weaponentity = me.weaponentity_fld;
+ if(me == own.(weaponentity).crylink_lastgroup)
+ own.(weaponentity).crylink_lastgroup = ((me == next) ? NULL : next);
prev.queuenext = next;
next.queueprev = prev;
me.classname = "spike_oktoremove";
a = bound(0, 1 - (time - e.fade_time) * e.fade_rate, 1);
- if(e == e.realowner.crylink_lastgroup)
- e.realowner.crylink_lastgroup = NULL;
+ .entity weaponentity = e.weaponentity_fld;
+ if(e == e.realowner.(weaponentity).crylink_lastgroup)
+ e.realowner.(weaponentity).crylink_lastgroup = NULL;
float isprimary = !(e.projectiledeathtype & HITTYPE_SECONDARY);
// is there at least 2 projectiles very close?
entity e, p;
float n;
- e = this.owner.crylink_lastgroup;
+ .entity weaponentity = this.weaponentity_fld;
+ e = this.owner.(weaponentity).crylink_lastgroup;
n = 0;
if(e)
{
if(totaldamage && ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 2) || ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 1) && !W_Crylink_Touch_WouldHitFriendly(this, WEP_CVAR_BOTH(crylink, isprimary, radius)))))
{
- if(this == this.realowner.crylink_lastgroup)
- this.realowner.crylink_lastgroup = NULL;
+ .entity weaponentity = this.weaponentity_fld;
+ if(this == this.realowner.(weaponentity).crylink_lastgroup)
+ this.realowner.(weaponentity).crylink_lastgroup = NULL;
W_Crylink_LinkExplode(this.queuenext, this, toucher);
this.classname = "spike_oktoremove";
delete(this);
proj = new(spike);
proj.reset = W_Crylink_Reset;
proj.realowner = proj.owner = actor;
+ proj.weaponentity_fld = weaponentity;
proj.bot_dodge = true;
proj.bot_dodgerating = WEP_CVAR_PRI(crylink, damage);
if(shots == 1) {
}
if(WEP_CVAR_PRI(crylink, joinspread) != 0)
{
- actor.crylink_lastgroup = proj;
+ actor.(weaponentity).crylink_lastgroup = proj;
W_Crylink_CheckLinks(proj);
- actor.crylink_waitrelease = 1;
+ actor.(weaponentity).crylink_waitrelease = 1;
}
}
for(counter = 0; counter < shots; ++counter)
{
proj = new(spike);
+ proj.weaponentity_fld = weaponentity;
proj.reset = W_Crylink_Reset;
proj.realowner = proj.owner = actor;
proj.bot_dodge = true;
}
if(WEP_CVAR_SEC(crylink, joinspread) != 0)
{
- actor.crylink_lastgroup = proj;
+ actor.(weaponentity).crylink_lastgroup = proj;
W_Crylink_CheckLinks(proj);
- actor.crylink_waitrelease = 2;
+ actor.(weaponentity).crylink_waitrelease = 2;
}
}
if(fire & 1)
{
- if(actor.crylink_waitrelease != 1)
+ if(actor.(weaponentity).crylink_waitrelease != 1)
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(crylink, refire)))
{
W_Crylink_Attack(thiswep, actor, weaponentity);
if((fire & 2) && autocvar_g_balance_crylink_secondary)
{
- if(actor.crylink_waitrelease != 2)
+ if(actor.(weaponentity).crylink_waitrelease != 2)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(crylink, refire)))
{
W_Crylink_Attack2(thiswep, actor, weaponentity);
}
}
- if((actor.crylink_waitrelease == 1 && !(fire & 1)) || (actor.crylink_waitrelease == 2 && !(fire & 2)))
+ if((actor.(weaponentity).crylink_waitrelease == 1 && !(fire & 1)) || (actor.(weaponentity).crylink_waitrelease == 2 && !(fire & 2)))
{
- if(!actor.crylink_lastgroup || time > actor.crylink_lastgroup.teleport_time)
+ if(!actor.(weaponentity).crylink_lastgroup || time > actor.(weaponentity).crylink_lastgroup.teleport_time)
{
// fired and released now!
- if(actor.crylink_lastgroup)
+ if(actor.(weaponentity).crylink_lastgroup)
{
vector pos;
entity linkjoineffect;
- float isprimary = (actor.crylink_waitrelease == 1);
+ float isprimary = (actor.(weaponentity).crylink_waitrelease == 1);
- pos = W_Crylink_LinkJoin(actor.crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed));
+ pos = W_Crylink_LinkJoin(actor.(weaponentity).crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed));
linkjoineffect = new(linkjoineffect);
+ linkjoineffect.weaponentity_fld = weaponentity;
setthink(linkjoineffect, W_Crylink_LinkJoinEffect_Think);
linkjoineffect.nextthink = time + w_crylink_linkjoin_time;
linkjoineffect.owner = actor;
setorigin(linkjoineffect, pos);
}
- actor.crylink_waitrelease = 0;
- if(!thiswep.wr_checkammo1(thiswep, actor) && !thiswep.wr_checkammo2(thiswep, actor))
+ actor.(weaponentity).crylink_waitrelease = 0;
+ if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity) && !thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
// ran out of ammo!
}
}
}
-METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
// don't "run out of ammo" and switch weapons while waiting for release
- if(actor.crylink_lastgroup && actor.crylink_waitrelease)
+ if(actor.(weaponentity).crylink_lastgroup && actor.(weaponentity).crylink_waitrelease)
return true;
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
return ammo_amount;
}
-METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
// don't "run out of ammo" and switch weapons while waiting for release
- if(actor.crylink_lastgroup && actor.crylink_waitrelease)
+ if(actor.(weaponentity).crylink_lastgroup && actor.(weaponentity).crylink_waitrelease)
return true;
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
actor.rl_release[slot] = 1;
}
-METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
#if 0
// don't switch while guiding a missile
return ammo_amount;
#endif
}
-METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
return false;
}
}
}
}
-METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
return ammo_amount;
}
-METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount;
if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
{
actor.ammo_field = ammo_none;
}
-METHOD(Fireball, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Fireball, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
return true; // infinite ammo
}
-METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
return true; // fireball has infinite ammo
}
actor.(weaponentity).hagar_warning = false;
// we aren't checking ammo during an attack, so we must do it here
- if(!(thiswep.wr_checkammo1(thiswep, actor) + thiswep.wr_checkammo2(thiswep, actor)))
+ if(!(thiswep.wr_checkammo1(thiswep, actor, weaponentity) + thiswep.wr_checkammo2(thiswep, actor, weaponentity)))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
// note: this doesn't force the switch
return;
}
- if(!thiswep.wr_checkammo1(thiswep, actor))
+ if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
}
}
}
-METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
return ammo_amount;
}
-METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
if(PHYS_INPUT_BUTTON_ATCK(actor))
{
- if(!thiswep.wr_checkammo1(thiswep, actor))
+ if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
}
}
}
-METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
return ammo_amount;
}
-METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
actor.(weaponentity).hook_state &= ~HOOK_WAITING_FOR_RELEASE;
}
}
-METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor))
+METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor, .entity weaponentity))
{
if (!thiswep.ammo_factor) return true;
- for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
- {
- .entity weaponentity = weaponentities[slot];
- if(actor.(weaponentity).hook)
- return actor.ammo_fuel > 0;
- }
+
+ if(actor.(weaponentity).hook)
+ return actor.ammo_fuel > 0;
return actor.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
}
-METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor))
+METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor, .entity weaponentity))
{
// infinite ammo for now
return true; // actor.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
}
if(PHYS_INPUT_BUTTON_ATCK(actor))
{
- if(!thiswep.wr_checkammo2(thiswep, actor))
+ if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
return;
}
- if(!thiswep.wr_checkammo1(thiswep, actor))
+ if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
if(fire & 2)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
{
- if(!thiswep.wr_checkammo2(thiswep, actor))
+ if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
}
}
}
-METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount;
if(WEP_CVAR(machinegun, mode) == 1)
}
return ammo_amount;
}
-METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount;
if(WEP_CVAR(machinegun, mode) == 1)
{
entity own = this.realowner;
Weapon w = WEP_MINE_LAYER;
- if(!w.wr_checkammo1(w, own))
+ if(!w.wr_checkammo1(w, own, weaponentity))
{
own.cnt = WEP_MINE_LAYER.m_id;
int slot = weaponslot(weaponentity);
{
entity own = this.realowner;
Weapon w = WEP_MINE_LAYER;
- if(!w.wr_checkammo1(w, own))
+ if(!w.wr_checkammo1(w, own, weaponentity))
{
own.cnt = WEP_MINE_LAYER.m_id;
int slot = weaponslot(weaponentity);
sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
}
}
-METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
//int slot = 0; // TODO: unhardcode
// actually do // don't switch while placing a mine
//}
//return true;
}
-METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
if(W_MineLayer_PlacedMines(actor, false))
return true;
}
}
}
-METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
return ammo_amount;
}
-METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
}
}
}
-METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this))
+METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this, .entity weaponentity))
{
// always allow infinite ammo
return true;
}
-METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this))
+METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this, .entity weaponentity))
{
// always allow infinite ammo
return true;
}
}
}
-METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
return ammo_amount;
}
-METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
}
}
}
-METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount;
if(WEP_CVAR(seeker, type) == 1)
}
return ammo_amount;
}
-METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount;
if(WEP_CVAR(seeker, type) == 1)
}
}
}
-METHOD(Shockwave, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Shockwave, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
return true; // infinite ammo
}
-METHOD(Shockwave, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Shockwave, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
// shockwave has infinite ammo
return true;
// alternate secondary weapon frames
void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- if (!thiswep.wr_checkammo2(thiswep, actor))
+ if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
}
void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- if (!thiswep.wr_checkammo2(thiswep, actor))
+ if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
{
actor.ammo_field = ammo_none;
}
-METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
return ammo_amount;
}
-METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
if(IS_BOT_CLIENT(actor))
if(vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
#ifdef SVQC
// infinite ammo
-METHOD(Tuba, wr_checkammo1, bool(Tuba this, entity actor)) { return true; }
-METHOD(Tuba, wr_checkammo2, bool(Tuba this, entity actor)) { return true; }
+METHOD(Tuba, wr_checkammo1, bool(Tuba this, entity actor, .entity weaponentity)) { return true; }
+METHOD(Tuba, wr_checkammo2, bool(Tuba this, entity actor, .entity weaponentity)) { return true; }
METHOD(Tuba, wr_suicidemessage, Notification(Tuba this))
{
actor.ammo_field = (thiswep.ammo_field);
actor.vaporizer_lasthit = 0;
}
-METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo;
ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
return ammo_amount;
}
-METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
if(!WEP_CVAR_SEC(vaporizer, ammo))
return true;
{
actor.vortex_lasthit = 0;
}
-METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor))
+METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
return ammo_amount;
}
-METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
if(WEP_CVAR(vortex, secondary))
{
}
else if(this.health>WEP_CVAR(devastator, damage)*0.5)
{
+ .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+
if(this.velocity.z < 0)
- if(client_hasweapon(this, WEP_DEVASTATOR, true, false))
+ if(client_hasweapon(this, WEP_DEVASTATOR, weaponentity, true, false))
{
this.movement_x = maxspeed;
return;
}
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
this.(weaponentity).m_switchweapon = WEP_DEVASTATOR;
this.v_angle_x = 90;
PHYS_INPUT_BUTTON_ATCK(this) = true;
if (this.weapon_load[new_weapon] < 0)
{
bool other_weapon_available = false;
+ .entity weaponentity = weaponentities[0]; // TODO: unhardcode
FOREACH(Weapons, it != WEP_Null, LAMBDA(
- if(it.wr_checkammo1(it, this) + it.wr_checkammo2(it, this))
+ if(it.wr_checkammo1(it, this, weaponentity) + it.wr_checkammo2(it, this, weaponentity))
other_weapon_available = true;
));
if(other_weapon_available)
// If no weapon was chosen get the first available weapon
if(this.(weaponentity).m_weapon==WEP_Null)
FOREACH(Weapons, it != WEP_Null, LAMBDA(
- if(client_hasweapon(this, it, true, false))
+ if(client_hasweapon(this, it, weaponentity, true, false))
{
this.(weaponentity).m_switchweapon = it;
return;
if ( distance > bot_distance_far ) {
for(i=0; i < Weapons_COUNT && bot_weapons_far[i] != -1 ; ++i){
w = bot_weapons_far[i];
- if ( client_hasweapon(this, Weapons_from(w), true, false) )
+ if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
{
if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
continue;
if ( distance > bot_distance_close) {
for(i=0; i < Weapons_COUNT && bot_weapons_mid[i] != -1 ; ++i){
w = bot_weapons_mid[i];
- if ( client_hasweapon(this, Weapons_from(w), true, false) )
+ if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
{
if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
continue;
// Choose weapons for close distance
for(i=0; i < Weapons_COUNT && bot_weapons_close[i] != -1 ; ++i){
w = bot_weapons_close[i];
- if ( client_hasweapon(this, Weapons_from(w), true, false) )
+ if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
{
if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, w))
continue;
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
- if(client_hasweapon(this, Weapons_from(id), true, false))
+ if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
this.(weaponentity).m_switchweapon = Weapons_from(id);
else
return CMD_STATUS_ERROR;
// WEAPONTODO
.float autoswitch;
-bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain);
+bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andammo, bool complain);
void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire);
void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire);
// VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
});
}
-bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain)
+bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andammo, bool complain)
{
float f = 0;
}
else
{
- f = wpn.wr_checkammo1(wpn, this) + wpn.wr_checkammo2(wpn, this);
+ f = wpn.wr_checkammo1(wpn, this, weaponentity) + wpn.wr_checkammo2(wpn, this, weaponentity);
// always allow selecting the Mine Layer if we placed mines, so that we can detonate them
if(wpn == WEP_MINE_LAYER)
++c;
- if(!skipmissing || client_hasweapon(this, wep, true, false))
+ if(!skipmissing || client_hasweapon(this, wep, weaponentity, true, false))
{
if(switchtonext)
return weaponwant;
--c;
if(c == 0)
{
- client_hasweapon(this, wep, true, true);
+ client_hasweapon(this, wep, weaponentity, true, true);
break;
}
}
{
if(this.(weaponentity).m_switchweapon != w)
{
- if(client_hasweapon(this, w, true, true))
+ if(client_hasweapon(this, w, weaponentity, true, true))
W_SwitchWeapon_Force(this, w, weaponentity);
else
this.(weaponentity).selectweapon = w.m_id; // update selectweapon anyway
void W_LastWeapon(entity this, .entity weaponentity)
{
Weapon wep = Weapons_from(this.(weaponentity).cnt);
- if (client_hasweapon(this, wep, true, false))
+ if (client_hasweapon(this, wep, weaponentity, true, false))
W_SwitchWeapon(this, wep, weaponentity);
else
W_SwitchToOtherWeapon(this, weaponentity);
void Send_WeaponComplain(entity e, float wpn, float type);
.float hasweapon_complain_spam;
-bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain);
+bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andammo, bool complain);
.int weaponcomplainindex;
float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing, .entity weaponentity);
wep.colormap = own.colormap;
wep.glowmod = weaponentity_glowmod(info, own, own.clientcolors, own.(weaponentity));
- W_DropEvent(wr_drop,own,wpn,wep);
+ W_DropEvent(wr_drop,own,wpn,wep,weaponentity);
if(WepSet_FromWeapon(Weapons_from(wpn)) & WEPSET_SUPERWEAPONS)
{
{
if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
bool ammo = false;
- if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor);
- else ammo = thiswep.wr_checkammo1(thiswep, actor);
+ if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
+ else ammo = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
if (ammo) return true;
// always keep the Mine Layer if we placed mines, so that we can detonate them
if (thiswep == WEP_MINE_LAYER)
// check if the other firing mode has enough ammo
bool ammo_other = false;
- if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor);
- else ammo_other = thiswep.wr_checkammo2(thiswep, actor);
+ if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
+ else ammo_other = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
if (ammo_other)
{
if (time - actor.prevwarntime > 1)
}
// switch away if the amount of ammo is not enough to keep using this weapon
Weapon w = actor.(weaponentity).m_weapon;
- if (!(w.wr_checkammo1(w, actor) + w.wr_checkammo2(w, actor)))
+ if (!(w.wr_checkammo1(w, actor, weaponentity) + w.wr_checkammo2(w, actor, weaponentity)))
{
actor.clip_load = -1; // reload later
W_SwitchToOtherWeapon(actor, weaponentity);
actor.clip_load = actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = -1;
}
-void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item)
+void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity)
{
Weapon w = Weapons_from(weapon_type);
weapon_dropevent_item = weapon_item;
- w.event(w, player);
+ w.event(w, player, weaponentity);
}
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity);
-void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item);
+void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity);
void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound);