From 7779bdd488de14ec800782f2904d49a7f5aa33f8 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 29 Sep 2016 23:47:18 +1000 Subject: [PATCH] Add weaponentity parameter to ammo checking --- .../gamemodes/gamemode/nexball/nexball.qc | 4 +- qcsrc/common/monsters/monster/wyvern.qc | 2 +- qcsrc/common/mutators/mutator/nix/sv_nix.qc | 6 +- qcsrc/common/mutators/mutator/overkill/hmg.qc | 6 +- qcsrc/common/mutators/mutator/overkill/rpc.qc | 4 +- qcsrc/common/t_items.qc | 2 +- qcsrc/common/vehicles/vehicle/racer.qc | 4 +- qcsrc/common/vehicles/vehicle/racer_weapon.qc | 2 +- qcsrc/common/vehicles/vehicle/raptor.qc | 4 +- .../common/vehicles/vehicle/raptor_weapons.qc | 2 +- qcsrc/common/weapons/weapon.qh | 8 +-- qcsrc/common/weapons/weapon/arc.qc | 12 ++-- qcsrc/common/weapons/weapon/blaster.qc | 4 +- qcsrc/common/weapons/weapon/crylink.qc | 55 +++++++++++-------- qcsrc/common/weapons/weapon/devastator.qc | 4 +- qcsrc/common/weapons/weapon/electro.qc | 4 +- qcsrc/common/weapons/weapon/fireball.qc | 4 +- qcsrc/common/weapons/weapon/hagar.qc | 8 +-- qcsrc/common/weapons/weapon/hlac.qc | 6 +- qcsrc/common/weapons/weapon/hook.qc | 13 ++--- qcsrc/common/weapons/weapon/machinegun.qc | 10 ++-- qcsrc/common/weapons/weapon/minelayer.qc | 8 +-- qcsrc/common/weapons/weapon/mortar.qc | 4 +- qcsrc/common/weapons/weapon/porto.qc | 4 +- qcsrc/common/weapons/weapon/rifle.qc | 4 +- qcsrc/common/weapons/weapon/seeker.qc | 4 +- qcsrc/common/weapons/weapon/shockwave.qc | 4 +- qcsrc/common/weapons/weapon/shotgun.qc | 8 +-- qcsrc/common/weapons/weapon/tuba.qc | 4 +- qcsrc/common/weapons/weapon/vaporizer.qc | 4 +- qcsrc/common/weapons/weapon/vortex.qc | 4 +- qcsrc/server/bot/default/havocbot/havocbot.qc | 16 +++--- qcsrc/server/bot/default/scripting.qc | 2 +- qcsrc/server/defs.qh | 2 +- qcsrc/server/weapons/selection.qc | 12 ++-- qcsrc/server/weapons/selection.qh | 2 +- qcsrc/server/weapons/throwing.qc | 2 +- qcsrc/server/weapons/weaponsystem.qc | 14 ++--- qcsrc/server/weapons/weaponsystem.qh | 2 +- 39 files changed, 135 insertions(+), 129 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 15f1d265e..baa9cd8a3 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -905,13 +905,13 @@ METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor)) //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; diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index 6f2b50e31..823242299 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -46,7 +46,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity } } -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; } diff --git a/qcsrc/common/mutators/mutator/nix/sv_nix.qc b/qcsrc/common/mutators/mutator/nix/sv_nix.qc index 01b8a50c5..0a2bc8181 100644 --- a/qcsrc/common/mutators/mutator/nix/sv_nix.qc +++ b/qcsrc/common/mutators/mutator/nix/sv_nix.qc @@ -64,7 +64,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill" 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); }); } @@ -212,9 +212,9 @@ void NIX_GiveCurrentWeapon(entity this) .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); } } diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index 732f4f43f..c04607e99 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -20,7 +20,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone 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); @@ -81,7 +81,7 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea } } -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); @@ -91,7 +91,7 @@ METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor)) 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); diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index 32d51f924..b9d61ee93 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -137,14 +137,14 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en } } -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; } diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 694903577..1753f9d1f 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -711,7 +711,7 @@ float Item_GiveTo(entity item, entity player) 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); } }); diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 41a31743f..e6364a6cd 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -289,9 +289,10 @@ bool racer_frame(entity this, float dt) #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") @@ -302,7 +303,6 @@ bool racer_frame(entity this, float dt) // 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); } diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qc b/qcsrc/common/vehicles/vehicle/racer_weapon.qc index d20210c61..838f0cf42 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qc +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qc @@ -34,7 +34,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone } } -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; diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 1068e7430..8ede8f2c5 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -356,11 +356,11 @@ bool raptor_frame(entity this, float dt) */ 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); } diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index 4e16efbcc..5cb0f271c 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -30,7 +30,7 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weapon 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; diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index fc1167218..a83629f96 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -89,9 +89,9 @@ CLASS(Weapon, Object) /** (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 */ @@ -120,9 +120,9 @@ CLASS(Weapon, Object) /** (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)) { diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 6cee61981..c45387012 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -378,7 +378,7 @@ void W_Arc_Beam_Think(entity this) 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 @@ -835,11 +835,11 @@ METHOD(Arc, wr_init, void(entity thiswep)) 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)) { @@ -858,7 +858,7 @@ METHOD(Arc, wr_killmessage, Notification(entity thiswep)) 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; @@ -867,9 +867,9 @@ METHOD(Arc, wr_drop, void(entity thiswep, entity actor)) 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; diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index b669db758..c1be1fe76 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -233,12 +233,12 @@ METHOD(Blaster, wr_setup, void(entity thiswep, entity actor)) 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 } diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index a6df25064..570e14fbb 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -98,8 +98,9 @@ void W_Crylink_CheckLinks(entity e) 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"; @@ -128,8 +129,9 @@ void W_Crylink_LinkExplode(entity e, entity e2, entity directhitentity) 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); @@ -235,7 +237,8 @@ void W_Crylink_LinkJoinEffect_Think(entity this) // 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) { @@ -317,8 +320,9 @@ void W_Crylink_Touch(entity this, entity toucher) 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); @@ -374,6 +378,7 @@ void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity) 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) { @@ -450,9 +455,9 @@ void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity) } 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; } } @@ -482,6 +487,7 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity) 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; @@ -567,9 +573,9 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity) } 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; } } @@ -588,7 +594,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit 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); @@ -598,7 +604,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit 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); @@ -606,27 +612,28 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit } } - 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! @@ -636,20 +643,20 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit } } } -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); diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 160971b14..6ca5fa101 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -537,7 +537,7 @@ METHOD(Devastator, wr_setup, void(entity thiswep, entity actor)) 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 @@ -573,7 +573,7 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor)) 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; } diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 79f6cadf3..33299f653 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -553,13 +553,13 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit } } } -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. diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index 7ba71aaa7..703162fd8 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -410,11 +410,11 @@ METHOD(Fireball, wr_setup, void(entity thiswep, entity actor)) { 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 } diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index d819a479c..f74de39b0 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -409,7 +409,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) 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 @@ -427,7 +427,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int 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); @@ -505,13 +505,13 @@ METHOD(Hagar, wr_setup, void(entity thiswep, entity actor)) } } } -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); diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index e77944076..3fe8e8c04 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -176,7 +176,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int 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); @@ -239,13 +239,13 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity 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); diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 716aa247c..2c4edd13d 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -288,19 +288,16 @@ METHOD(Hook, wr_setup, void(entity thiswep, entity actor)) 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 diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 4b2941648..c2b566730 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -154,7 +154,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit } 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); @@ -180,7 +180,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity 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); @@ -278,7 +278,7 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen 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); @@ -312,7 +312,7 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen } } } -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) @@ -329,7 +329,7 @@ METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor)) } 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) diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 35507c341..89141b17f 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -131,7 +131,7 @@ void W_MineLayer_Explode(entity this, entity directhitentity) { 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); @@ -163,7 +163,7 @@ void W_MineLayer_DoRemoteExplode(entity this) { 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); @@ -524,7 +524,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent 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 @@ -536,7 +536,7 @@ METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor)) //} //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; diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index fa089083d..dcb8a7121 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -381,13 +381,13 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity } } } -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); diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index e47d5dd32..f55d31f6d 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -361,12 +361,12 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone } } } -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; diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index b290728e5..6dbcd31c2 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -200,13 +200,13 @@ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, } } } -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); diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index ca5ecf4dd..2104c6edb 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -667,7 +667,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity } } } -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) @@ -682,7 +682,7 @@ METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor)) } 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) diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index 28cbe69bb..ea756dfc7 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -726,11 +726,11 @@ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponent } } } -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; diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 13de3fb25..80d485e4b 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -199,7 +199,7 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f // 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); @@ -213,7 +213,7 @@ void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity 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); @@ -285,13 +285,13 @@ METHOD(Shotgun, wr_setup, void(entity thiswep, entity actor)) { 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))) diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 8fa9e7fe5..b3cae67a6 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -465,8 +465,8 @@ METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity)) #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)) { diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 01c884785..25464b243 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -438,14 +438,14 @@ METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor)) 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; diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 351f8fc27..331885b32 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -334,13 +334,13 @@ METHOD(Vortex, wr_setup, void(entity thiswep, entity actor)) { 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)) { diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index b3bc26bbf..c721c0639 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -585,8 +585,10 @@ void havocbot_movetogoal(entity this) } 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; @@ -600,7 +602,6 @@ void havocbot_movetogoal(entity this) return; } - .entity weaponentity = weaponentities[0]; // TODO: unhardcode this.(weaponentity).m_switchweapon = WEP_DEVASTATOR; this.v_angle_x = 90; PHYS_INPUT_BUTTON_ATCK(this) = true; @@ -997,8 +998,9 @@ float havocbot_chooseweapon_checkreload(entity this, int new_weapon) 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) @@ -1027,7 +1029,7 @@ void havocbot_chooseweapon(entity this) // 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; @@ -1073,7 +1075,7 @@ void havocbot_chooseweapon(entity this) 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; @@ -1087,7 +1089,7 @@ void havocbot_chooseweapon(entity this) 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; @@ -1100,7 +1102,7 @@ void havocbot_chooseweapon(entity this) // 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; diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index 19baa587d..68b7da46a 100644 --- a/qcsrc/server/bot/default/scripting.qc +++ b/qcsrc/server/bot/default/scripting.qc @@ -570,7 +570,7 @@ float bot_cmd_select_weapon(entity this) .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; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index ce9d17403..e60743c51 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -116,7 +116,7 @@ const float MAX_DAMAGEEXTRARADIUS = 16; // 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) diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 809becc33..f8ce9e750 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -38,7 +38,7 @@ void Weapon_whereis(Weapon this, entity cl) }); } -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; @@ -69,7 +69,7 @@ bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain) } 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) @@ -166,7 +166,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl ++c; - if(!skipmissing || client_hasweapon(this, wep, true, false)) + if(!skipmissing || client_hasweapon(this, wep, weaponentity, true, false)) { if(switchtonext) return weaponwant; @@ -223,7 +223,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl --c; if(c == 0) { - client_hasweapon(this, wep, true, true); + client_hasweapon(this, wep, weaponentity, true, true); break; } } @@ -263,7 +263,7 @@ void W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) { 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 @@ -317,7 +317,7 @@ void W_PreviousWeapon(entity this, float list, .entity weaponentity) 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); diff --git a/qcsrc/server/weapons/selection.qh b/qcsrc/server/weapons/selection.qh index 336dc1304..68c15139e 100644 --- a/qcsrc/server/weapons/selection.qh +++ b/qcsrc/server/weapons/selection.qh @@ -4,7 +4,7 @@ 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); diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index f3a72412b..f36a0eebf 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -47,7 +47,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto 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) { diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index f5330d08e..a37462eae 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -220,8 +220,8 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary { 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) @@ -243,8 +243,8 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary // 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) @@ -742,7 +742,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen } // 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); @@ -778,9 +778,9 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen 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); } diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index 389a52bcc..2fb0f9956 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -16,7 +16,7 @@ void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector 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); -- 2.39.2