From 90e39049eaeafbbd25267d1dfcf08023734cf6b8 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 8 Aug 2016 19:52:47 +1000 Subject: [PATCH] Purge most of the weaponentities[0] cases --- qcsrc/common/effects/qc/casings.qc | 5 +- .../gamemodes/gamemode/nexball/nexball.qc | 16 +++--- qcsrc/common/monsters/monster/mage.qc | 2 +- qcsrc/common/monsters/monster/spider.qc | 2 +- qcsrc/common/monsters/monster/wyvern.qc | 2 +- qcsrc/common/mutators/mutator/nades/nades.qc | 3 +- qcsrc/common/mutators/mutator/overkill/hmg.qc | 10 ++-- .../mutators/mutator/overkill/overkill.qc | 3 +- qcsrc/common/mutators/mutator/overkill/rpc.qc | 10 ++-- qcsrc/common/turrets/turret/ewheel_weapon.qc | 2 +- qcsrc/common/turrets/turret/flac_weapon.qc | 2 +- qcsrc/common/turrets/turret/hellion_weapon.qc | 2 +- qcsrc/common/turrets/turret/hk_weapon.qc | 2 +- .../turrets/turret/machinegun_weapon.qc | 8 +-- qcsrc/common/turrets/turret/mlrs_weapon.qc | 2 +- qcsrc/common/turrets/turret/phaser_weapon.qc | 2 +- qcsrc/common/turrets/turret/plasma_weapon.qc | 2 +- qcsrc/common/turrets/turret/tesla_weapon.qc | 2 +- qcsrc/common/turrets/turret/walker_weapon.qc | 2 +- qcsrc/common/vehicles/vehicle/racer_weapon.qc | 4 +- .../common/vehicles/vehicle/raptor_weapons.qc | 2 +- qcsrc/common/weapons/weapon/arc.qc | 13 ++--- qcsrc/common/weapons/weapon/blaster.qc | 5 +- qcsrc/common/weapons/weapon/crylink.qc | 14 ++--- qcsrc/common/weapons/weapon/devastator.qc | 10 ++-- qcsrc/common/weapons/weapon/electro.qc | 14 ++--- qcsrc/common/weapons/weapon/fireball.qc | 38 ++++++------- qcsrc/common/weapons/weapon/hagar.qc | 16 +++--- qcsrc/common/weapons/weapon/hlac.qc | 20 +++---- qcsrc/common/weapons/weapon/hook.qc | 6 +-- qcsrc/common/weapons/weapon/machinegun.qc | 54 ++++++++++--------- qcsrc/common/weapons/weapon/minelayer.qc | 10 ++-- qcsrc/common/weapons/weapon/mortar.qc | 18 +++---- qcsrc/common/weapons/weapon/porto.qc | 10 ++-- qcsrc/common/weapons/weapon/rifle.qc | 24 ++++----- qcsrc/common/weapons/weapon/seeker.qc | 41 +++++++------- qcsrc/common/weapons/weapon/shockwave.qc | 8 +-- qcsrc/common/weapons/weapon/shotgun.qc | 32 +++++------ qcsrc/common/weapons/weapon/tuba.qc | 10 ++-- qcsrc/common/weapons/weapon/vaporizer.qc | 21 ++++---- qcsrc/common/weapons/weapon/vortex.qc | 10 ++-- qcsrc/server/cheats.qc | 4 +- qcsrc/server/cl_client.qc | 5 +- qcsrc/server/cl_impulse.qc | 2 +- qcsrc/server/weapons/throwing.qc | 3 +- qcsrc/server/weapons/throwing.qh | 2 +- qcsrc/server/weapons/tracing.qc | 3 +- qcsrc/server/weapons/tracing.qh | 12 ++--- qcsrc/server/weapons/weaponsystem.qc | 9 ++-- qcsrc/server/weapons/weaponsystem.qh | 6 +-- 50 files changed, 255 insertions(+), 250 deletions(-) diff --git a/qcsrc/common/effects/qc/casings.qc b/qcsrc/common/effects/qc/casings.qc index 46d1a8c614..f92df7cd0e 100644 --- a/qcsrc/common/effects/qc/casings.qc +++ b/qcsrc/common/effects/qc/casings.qc @@ -1,5 +1,5 @@ #ifdef SVQC -void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner); +void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner, .entity weaponentity); #endif #ifdef IMPLEMENTATION @@ -14,9 +14,8 @@ void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float ran REGISTER_NET_TEMP(casings) #ifdef SVQC -void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner) +void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner, .entity weaponentity) { - .entity weaponentity = weaponentities[0]; // TODO: parameter entity wep = casingowner.(weaponentity); vector org = casingowner.origin + casingowner.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up; diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index b50013ff7b..a3d68a2eb0 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -762,14 +762,14 @@ void W_Nexball_Touch(entity this, entity toucher) delete(this); } -void W_Nexball_Attack(entity actor, float t) +void W_Nexball_Attack(entity actor, .entity weaponentity, float t) { entity ball; float mul, mi, ma; if(!(ball = actor.ballcarried)) return; - W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0); + W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0); tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, NULL); if(trace_startsolid) { @@ -800,12 +800,12 @@ void W_Nexball_Attack(entity actor, float t) vector trigger_push_calculatevelocity(vector org, entity tgt, float ht); -void W_Nexball_Attack2(entity actor) +void W_Nexball_Attack2(entity actor, .entity weaponentity) { if(actor.ballcarried.enemy) { entity _ball = actor.ballcarried; - W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0); + W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0); DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32)); setthink(_ball, W_Nexball_Think); _ball.nextthink = time; @@ -815,7 +815,7 @@ void W_Nexball_Attack2(entity actor) if(!autocvar_g_nexball_tackling) return; - W_SetupShot(actor, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0); + W_SetupShot(actor, weaponentity, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0); entity missile = new(ballstealer); missile.owner = actor; @@ -881,19 +881,19 @@ METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity we } else { - W_Nexball_Attack(actor, -1); + W_Nexball_Attack(actor, weaponentity, -1); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } if(fire & 2) if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire)) { - W_Nexball_Attack2(actor); + W_Nexball_Attack2(actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready); } if(!(fire & 1) && actor.metertime && actor.ballcarried) { - W_Nexball_Attack(actor, time - actor.metertime); + W_Nexball_Attack(actor, weaponentity, time - actor.metertime); // DropBall or stealing will set metertime back to 0 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 02a01eff9e..509fa0aca1 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -49,7 +49,7 @@ METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weapon if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) { if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range; actor.enemy = Monster_FindTarget(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_MageSpike_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_MageSpike_FIRE, CH_WEAPON_B, 0); if (!IS_PLAYER(actor)) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); M_Mage_Attack_Spike(actor, w_shotdir); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready); diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index 0270119cff..9fa73508c1 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -106,7 +106,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity actor.anim_finished = time + 1; } if (isPlayer) actor.enemy = Monster_FindTarget(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0); if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); M_Spider_Attack_Web(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready); diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index 5d2103b6ae..33a3c44599 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -54,7 +54,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity TC(WyvernAttack, thiswep); if (fire & 1) if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, weaponentity, false, 1.2)) { - if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, v_forward, false, 0, SND_WyvernAttack_FIRE, CH_WEAPON_B, 0); + if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_WyvernAttack_FIRE, CH_WEAPON_B, 0); if (IS_MONSTER(actor)) { actor.attack_finished_single[0] = time + 1.2; actor.anim_finished = time + 1.2; diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index fdde998566..fc1eb3b6b8 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -890,7 +890,8 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) makevectors(e.v_angle); - W_SetupShot(e, false, false, SND_Null, CH_WEAPON_A, 0); + // NOTE: always throw from first weapon entity? + W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0); Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES); diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index 2000ffd5dd..6fbc485b15 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -71,7 +71,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone W_DecreaseAmmo(WEP_HMG, actor, WEP_CVAR(hmg, ammo)); - W_SetupShot (actor, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(hmg, damage)); + W_SetupShot (actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(hmg, damage)); if(!autocvar_g_norecoil) { @@ -86,13 +86,13 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - W_MachineGun_MuzzleFlash(actor); - W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0'); + W_MachineGun_MuzzleFlash(actor, weaponentity); + W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0'); if (autocvar_g_casings >= 2) // casing code { makevectors(actor.v_angle); // for some reason, this is lost - SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); + SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); } int slot = weaponslot(weaponentity); @@ -145,7 +145,7 @@ METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor)) METHOD(HeavyMachineGun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, WEP_CVAR(hmg, ammo), SND_RELOAD); + W_Reload(actor, weaponentity, WEP_CVAR(hmg, ammo), SND_RELOAD); } METHOD(HeavyMachineGun, wr_suicidemessage, Notification(entity thiswep)) diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc index 2aeab7be48..12f5087583 100644 --- a/qcsrc/common/mutators/mutator/overkill/overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -53,7 +53,7 @@ MUTATOR_HOOKFUNCTION(ok, W_Reload) return actor.ok_use_ammocharge; } -void W_Blaster_Attack(entity, float, float, float, float, float, float, float, float, float, float); +void W_Blaster_Attack(entity, .entity, float, float, float, float, float, float, float, float, float, float); spawnfunc(weapon_hmg); spawnfunc(weapon_rpc); @@ -227,6 +227,7 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink) PS(player).m_weapon = WEP_BLASTER; W_Blaster_Attack( player, + weaponentities[0], WEP_BLASTER.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(vaporizer, shotangle), WEP_CVAR_SEC(vaporizer, damage), diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index d9e68f20f2..62e997b639 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -110,13 +110,13 @@ void W_RocketPropelledChainsaw_Think(entity this) this.nextthink = time; } -void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor) +void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor, .entity weaponentity) { entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(actor); entity flash = spawn (); W_DecreaseAmmo(thiswep, actor, WEP_CVAR(rpc, ammo)); - W_SetupShot_ProjectileSize (actor, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(rpc, damage)); + W_SetupShot_ProjectileSize (actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(rpc, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); PROJECTILE_MAKETRIGGER(missile); @@ -150,7 +150,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor) setmodel(flash, MDL_RPC_MUZZLEFLASH); // precision set below SUB_SetFade (flash, time, 0.1); flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(actor, flash, '5 0 0'); + W_AttachToShotorg(actor, weaponentity, flash, '5 0 0'); missile.pos1 = missile.velocity; MUTATOR_CALLHOOK(EditProjectile, actor, missile); @@ -171,7 +171,7 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(rpc, refire))) { - W_RocketPropelledChainsaw_Attack(thiswep, actor); + W_RocketPropelledChainsaw_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready); } } @@ -197,7 +197,7 @@ METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor METHOD(RocketPropelledChainsaw, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, WEP_CVAR(rpc, ammo), SND_RELOAD); + W_Reload(actor, weaponentity, WEP_CVAR(rpc, ammo), SND_RELOAD); } METHOD(RocketPropelledChainsaw, wr_suicidemessage, Notification(entity thiswep)) diff --git a/qcsrc/common/turrets/turret/ewheel_weapon.qc b/qcsrc/common/turrets/turret/ewheel_weapon.qc index 17df7dac04..e77b534022 100644 --- a/qcsrc/common/turrets/turret/ewheel_weapon.qc +++ b/qcsrc/common/turrets/turret/ewheel_weapon.qc @@ -12,7 +12,7 @@ METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, .entity weapon if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_EWheelAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_EWheelAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/turrets/turret/flac_weapon.qc b/qcsrc/common/turrets/turret/flac_weapon.qc index 2462433374..357bba975d 100644 --- a/qcsrc/common/turrets/turret/flac_weapon.qc +++ b/qcsrc/common/turrets/turret/flac_weapon.qc @@ -12,7 +12,7 @@ METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponen if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_FlacAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_FlacAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/turrets/turret/hellion_weapon.qc b/qcsrc/common/turrets/turret/hellion_weapon.qc index bc8e581e08..ea392ec4ed 100644 --- a/qcsrc/common/turrets/turret/hellion_weapon.qc +++ b/qcsrc/common/turrets/turret/hellion_weapon.qc @@ -15,7 +15,7 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weapo if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_HellionAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_HellionAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/turrets/turret/hk_weapon.qc b/qcsrc/common/turrets/turret/hk_weapon.qc index c2e9d6a146..ddad35d025 100644 --- a/qcsrc/common/turrets/turret/hk_weapon.qc +++ b/qcsrc/common/turrets/turret/hk_weapon.qc @@ -20,7 +20,7 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_HunterKillerAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_HunterKillerAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/turrets/turret/machinegun_weapon.qc b/qcsrc/common/turrets/turret/machinegun_weapon.qc index 34cd32d742..44c8d64599 100644 --- a/qcsrc/common/turrets/turret/machinegun_weapon.qc +++ b/qcsrc/common/turrets/turret/machinegun_weapon.qc @@ -4,7 +4,7 @@ #ifdef SVQC -void W_MachineGun_MuzzleFlash(entity actor); +void W_MachineGun_MuzzleFlash(entity actor, .entity weaponentity); SOUND(MachineGunTurretAttack_FIRE, W_Sound("electro_fire")); METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { @@ -13,15 +13,15 @@ METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .ent if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(machinegun, sustained_refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_MachineGunTurretAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_MachineGunTurretAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready); } fireBullet (actor, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_MACHINEGUN.m_id, 0); - W_MachineGun_MuzzleFlash(actor); - setattachment(actor.muzzle_flash, actor.tur_head, "tag_fire"); + W_MachineGun_MuzzleFlash(actor, weaponentity); + setattachment(actor.(weaponentity).muzzle_flash, actor.tur_head, "tag_fire"); } } diff --git a/qcsrc/common/turrets/turret/mlrs_weapon.qc b/qcsrc/common/turrets/turret/mlrs_weapon.qc index 305392cd5a..cfd51c7320 100644 --- a/qcsrc/common/turrets/turret/mlrs_weapon.qc +++ b/qcsrc/common/turrets/turret/mlrs_weapon.qc @@ -11,7 +11,7 @@ METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, .entity we if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(machinegun, sustained_refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_MLRSTurretAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_MLRSTurretAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/turrets/turret/phaser_weapon.qc b/qcsrc/common/turrets/turret/phaser_weapon.qc index 0ddfd153d0..2e08f5eb3d 100644 --- a/qcsrc/common/turrets/turret/phaser_weapon.qc +++ b/qcsrc/common/turrets/turret/phaser_weapon.qc @@ -14,7 +14,7 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_PhaserTurretAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_PhaserTurretAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/turrets/turret/plasma_weapon.qc b/qcsrc/common/turrets/turret/plasma_weapon.qc index 535e8b4754..f6f717f85f 100644 --- a/qcsrc/common/turrets/turret/plasma_weapon.qc +++ b/qcsrc/common/turrets/turret/plasma_weapon.qc @@ -10,7 +10,7 @@ METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, .entity weapon if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_PlasmaAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_PlasmaAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/turrets/turret/tesla_weapon.qc b/qcsrc/common/turrets/turret/tesla_weapon.qc index 4fe5109d7d..a173d8b675 100644 --- a/qcsrc/common/turrets/turret/tesla_weapon.qc +++ b/qcsrc/common/turrets/turret/tesla_weapon.qc @@ -12,7 +12,7 @@ METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .enti if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_TeslaCoilTurretAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_TeslaCoilTurretAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/turrets/turret/walker_weapon.qc b/qcsrc/common/turrets/turret/walker_weapon.qc index 91e4345a95..88b18b9198 100644 --- a/qcsrc/common/turrets/turret/walker_weapon.qc +++ b/qcsrc/common/turrets/turret/walker_weapon.qc @@ -11,7 +11,7 @@ METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, .entity if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND_WalkerTurretAttack_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_WalkerTurretAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qc b/qcsrc/common/vehicles/vehicle/racer_weapon.qc index 1af09990bc..d20210c611 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qc +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qc @@ -16,7 +16,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone veh.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost; veh.wait = time; } - if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0); + if (isPlayer) W_SetupShot_Dir(player, weaponentity, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0); vector org = w_shotorg; vector dir = w_shotdir; entity bolt = vehicles_projectile(veh, EFFECT_RACER_MUZZLEFLASH.eent_eff_name, SND_LASERGUN_FIRE, @@ -28,7 +28,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone } if (fire & 2) if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) { - if (isPlayer) W_SetupShot_Dir(actor, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0); + if (isPlayer) W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0); racer_fire_rocket(player, w_shotorg, w_shotdir, NULL); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready); } diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index 24db99841b..502ef80e2c 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -12,7 +12,7 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weapon float t = autocvar_g_vehicle_raptor_cannon_refire * (1 + veh.misc_bulletcounter == 4); if (fire & 1) if (weapon_prepareattack(thiswep, player, weaponentity, false, t)) { - if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0); + if (isPlayer) W_SetupShot_Dir(player, weaponentity, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0); vector org = w_shotorg; vector dir = w_shotdir; if (veh) { diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 65b625b9a2..0a59951005 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -265,13 +265,13 @@ void W_Arc_Bolt_Touch(entity this, entity toucher) this.use(this, NULL, toucher); } -void W_Arc_Attack_Bolt(Weapon thiswep, entity actor) +void W_Arc_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; W_DecreaseAmmo(thiswep, actor, WEP_CVAR(arc, bolt_ammo)); - W_SetupShot(actor, false, 2, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR(arc, bolt_damage)); + W_SetupShot(actor, weaponentity, false, 2, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR(arc, bolt_damage)); Send_Effect(EFFECT_ARC_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -405,6 +405,7 @@ void W_Arc_Beam_Think(entity this) W_SetupShot_Range( this.owner, + weaponentities[0], // TODO true, 0, SND_Null, @@ -691,10 +692,10 @@ void W_Arc_Beam(float burst, entity actor) getthink(beam)(beam); } -void Arc_Smoke(entity actor) +void Arc_Smoke(entity actor, .entity weaponentity) { makevectors(actor.v_angle); - W_SetupShot_Range(actor,true,0,SND_Null,0,0,0); + W_SetupShot_Range(actor,weaponentity,true,0,SND_Null,0,0,0); vector smoke_origin = w_shotorg + actor.velocity*frametime; if ( actor.arc_overheat > time ) @@ -753,7 +754,7 @@ METHOD(Arc, wr_aim, void(entity thiswep, entity actor)) METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { Arc_Player_SetHeat(actor); - Arc_Smoke(actor); + Arc_Smoke(actor, weaponentity); bool beam_fire2 = ((fire & 2) && !WEP_CVAR(arc, bolt)); @@ -791,7 +792,7 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(arc, bolt_refire))) { - W_Arc_Attack_Bolt(thiswep, actor); + W_Arc_Attack_Bolt(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, bolt_refire), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 0c3765a139..d5387f4bd1 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -88,6 +88,7 @@ void W_Blaster_Think(entity this) void W_Blaster_Attack( entity actor, + .entity weaponentity, float atk_deathtype, float atk_shotangle, float atk_damage, @@ -101,7 +102,7 @@ void W_Blaster_Attack( { vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD); - W_SetupShot_Dir(actor, s_forward, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, atk_damage); + W_SetupShot_Dir(actor, weaponentity, s_forward, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, atk_damage); Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); entity missile = new(blasterbolt); @@ -172,6 +173,7 @@ METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponenti { W_Blaster_Attack( actor, + weaponentity, WEP_BLASTER.m_id, WEP_CVAR_PRI(blaster, shotangle), WEP_CVAR_PRI(blaster, damage), @@ -203,6 +205,7 @@ METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponenti { W_Blaster_Attack( actor, + weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(blaster, shotangle), WEP_CVAR_SEC(blaster, damage), diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 643aca2069..1b192881e1 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -345,7 +345,7 @@ void W_Crylink_Fadethink(entity this) delete(this); } -void W_Crylink_Attack(Weapon thiswep, entity actor) +void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity) { float counter, shots; entity proj, prevproj, firstproj; @@ -360,7 +360,7 @@ void W_Crylink_Attack(Weapon thiswep, entity actor) if(WEP_CVAR_PRI(crylink, joinexplode)) maxdmg += WEP_CVAR_PRI(crylink, joinexplode_damage); - W_SetupShot(actor, false, 2, SND_CRYLINK_FIRE, CH_WEAPON_A, maxdmg); + W_SetupShot(actor, weaponentity, false, 2, SND_CRYLINK_FIRE, CH_WEAPON_A, maxdmg); forward = v_forward; right = v_right; up = v_up; @@ -454,7 +454,7 @@ void W_Crylink_Attack(Weapon thiswep, entity actor) } } -void W_Crylink_Attack2(Weapon thiswep, entity actor) +void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { float counter, shots; entity proj, prevproj, firstproj; @@ -469,7 +469,7 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor) if(WEP_CVAR_SEC(crylink, joinexplode)) maxdmg += WEP_CVAR_SEC(crylink, joinexplode_damage); - W_SetupShot(actor, false, 2, SND_CRYLINK_FIRE2, CH_WEAPON_A, maxdmg); + W_SetupShot(actor, weaponentity, false, 2, SND_CRYLINK_FIRE2, CH_WEAPON_A, maxdmg); forward = v_forward; right = v_right; up = v_up; @@ -588,7 +588,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit if(actor.crylink_waitrelease != 1) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(crylink, refire))) { - W_Crylink_Attack(thiswep, actor); + W_Crylink_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready); } } @@ -598,7 +598,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit if(actor.crylink_waitrelease != 2) if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(crylink, refire))) { - W_Crylink_Attack2(thiswep, actor); + W_Crylink_Attack2(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready); } } @@ -655,7 +655,7 @@ METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor)) } METHOD(Crylink, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND_RELOAD); } METHOD(Crylink, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 870ced3d9c..5f8a8a1b78 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -351,11 +351,11 @@ void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float d W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode_think); } -void W_Devastator_Attack(Weapon thiswep, entity actor) +void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) { W_DecreaseAmmo(thiswep, actor, WEP_CVAR(devastator, ammo)); - W_SetupShot_ProjectileSize(actor, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); entity missile = WarpZone_RefSys_SpawnSameRefSys(actor); @@ -400,7 +400,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor) setmodel(flash, MDL_DEVASTATOR_MUZZLEFLASH); // precision set below SUB_SetFade(flash, time, 0.1); flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(actor, flash, '5 0 0'); + W_AttachToShotorg(actor, weaponentity, flash, '5 0 0'); // common properties MUTATOR_CALLHOOK(EditProjectile, actor, missile); @@ -528,7 +528,7 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen if(actor.rl_release || WEP_CVAR(devastator, guidestop)) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire))) { - W_Devastator_Attack(thiswep, actor); + W_Devastator_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready); actor.rl_release = 0; } @@ -605,7 +605,7 @@ METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor)) } METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, WEP_CVAR(devastator, ammo), SND_RELOAD); + W_Reload(actor, weaponentity, WEP_CVAR(devastator, ammo), SND_RELOAD); } METHOD(Devastator, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 5f8208a7ff..c5da549533 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -260,7 +260,7 @@ void W_Electro_Bolt_Think(entity this) // this.nextthink = time; } -void W_Electro_Attack_Bolt(Weapon thiswep, entity actor) +void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity) { entity proj; @@ -268,6 +268,7 @@ void W_Electro_Attack_Bolt(Weapon thiswep, entity actor) W_SetupShot_ProjectileSize( actor, + weaponentity, '0 0 -3', '0 0 -3', false, @@ -403,12 +404,13 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float } } -void W_Electro_Attack_Orb(Weapon thiswep, entity actor) +void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) { W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(electro, ammo)); W_SetupShot_ProjectileSize( actor, + weaponentity, '-4 -4 -4', '4 4 4', false, @@ -470,7 +472,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i if(PHYS_INPUT_BUTTON_ATCK2(actor)) if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1)) { - W_Electro_Attack_Orb(WEP_ELECTRO, actor); + W_Electro_Attack_Orb(WEP_ELECTRO, actor, weaponentity); actor.electro_count -= 1; weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); return; @@ -530,7 +532,7 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { - W_Electro_Attack_Bolt(thiswep, actor); + W_Electro_Attack_Bolt(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } } @@ -539,7 +541,7 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit if(time >= actor.electro_secondarytime) if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire))) { - W_Electro_Attack_Orb(thiswep, actor); + W_Electro_Attack_Orb(thiswep, actor, weaponentity); actor.electro_count = WEP_CVAR_SEC(electro, count); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor); @@ -573,7 +575,7 @@ METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor)) } METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD); } METHOD(Electro, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index a523354a02..8c67144434 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -55,7 +55,7 @@ REGISTER_WEAPON(FIREBALL, fireball, NEW(Fireball)); #ifdef SVQC .float bot_primary_fireballmooth; // whatever a mooth is .vector fireball_impactvec; -.float fireball_primarytime; +.float fireball_primarytime[MAX_WEAPONSLOTS]; #endif #endif #ifdef IMPLEMENTATION @@ -193,15 +193,13 @@ void W_Fireball_Damage(entity this, entity inflictor, entity attacker, float dam } } -void W_Fireball_Attack1(entity actor) +void W_Fireball_Attack1(entity actor, .entity weaponentity) { - entity proj; - - W_SetupShot_ProjectileSize(actor, '-16 -16 -16', '16 16 16', false, 2, SND_FIREBALL_FIRE2, CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-16 -16 -16', '16 16 16', false, 2, SND_FIREBALL_FIRE2, CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage)); Send_Effect(EFFECT_FIREBALL_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - proj = new(plasma_prim); + entity proj = new(plasma_prim); proj.owner = proj.realowner = actor; proj.bot_dodge = true; proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage); @@ -232,40 +230,40 @@ void W_Fireball_Attack1(entity actor) MUTATOR_CALLHOOK(EditProjectile, actor, proj); } -void W_Fireball_AttackEffect(entity actor, float i, vector f_diff) +void W_Fireball_AttackEffect(entity actor, .entity weaponentity, float i, vector f_diff) { - W_SetupShot_ProjectileSize(actor, '-16 -16 -16', '16 16 16', false, 0, SND_Null, 0, 0); + W_SetupShot_ProjectileSize(actor, weaponentity, '-16 -16 -16', '16 16 16', false, 0, SND_Null, 0, 0); w_shotorg += f_diff.x * v_up + f_diff.y * v_right; Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); } void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - W_Fireball_Attack1(actor); + W_Fireball_Attack1(actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready); } void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - W_Fireball_AttackEffect(actor, 0, '+1.25 +3.75 0'); + W_Fireball_AttackEffect(actor, weaponentity, 0, '+1.25 +3.75 0'); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4); } void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - W_Fireball_AttackEffect(actor, 0, '-1.25 +3.75 0'); + W_Fireball_AttackEffect(actor, weaponentity, 0, '-1.25 +3.75 0'); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3); } void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - W_Fireball_AttackEffect(actor, 1, '+1.25 -3.75 0'); + W_Fireball_AttackEffect(actor, weaponentity, 1, '+1.25 -3.75 0'); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2); } void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - W_Fireball_AttackEffect(actor, 0, '-1.25 -3.75 0'); + W_Fireball_AttackEffect(actor, weaponentity, 0, '-1.25 -3.75 0'); sound(actor, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1); } @@ -308,7 +306,7 @@ void W_Fireball_Firemine_Touch(entity this, entity toucher) this.projectiledeathtype |= HITTYPE_BOUNCE; } -void W_Fireball_Attack2(entity actor) +void W_Fireball_Attack2(entity actor, .entity weaponentity) { entity proj; vector f_diff; @@ -331,7 +329,7 @@ void W_Fireball_Attack2(entity actor) f_diff = '+1.25 +3.75 0'; break; } - W_SetupShot_ProjectileSize(actor, '-4 -4 -4', '4 4 4', false, 2, SND_FIREBALL_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-4 -4 -4', '4 4 4', false, 2, SND_FIREBALL_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage)); traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, actor); w_shotorg = trace_endpos; @@ -388,18 +386,19 @@ METHOD(Fireball, wr_think, void(entity thiswep, entity actor, .entity weaponenti { if(fire & 1) { - if(time >= actor.fireball_primarytime) + int slot = weaponslot(weaponentity); + if(time >= actor.fireball_primarytime[slot]) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(fireball, refire))) { W_Fireball_Attack1_Frame0(thiswep, actor, weaponentity, fire); - actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(actor); + actor.fireball_primarytime[slot] = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(actor); } } else if(fire & 2) { if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(fireball, refire))) { - W_Fireball_Attack2(actor); + W_Fireball_Attack2(actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready); } } @@ -418,7 +417,8 @@ METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor)) } METHOD(Fireball, wr_resetplayer, void(entity thiswep, entity actor)) { - actor.fireball_primarytime = time; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + actor.fireball_primarytime[slot] = time; } METHOD(Fireball, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 7d45dc8b82..a51bbc8b3b 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -134,13 +134,13 @@ void W_Hagar_Touch2(entity this, entity toucher) } } -void W_Hagar_Attack(Weapon thiswep, entity actor) +void W_Hagar_Attack(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hagar, ammo)); - W_SetupShot(actor, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage)); + W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage)); Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -177,13 +177,13 @@ void W_Hagar_Attack(Weapon thiswep, entity actor) MUTATOR_CALLHOOK(EditProjectile, actor, missile); } -void W_Hagar_Attack2(Weapon thiswep, entity actor) +void W_Hagar_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo)); - W_SetupShot(actor, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); + W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -236,7 +236,7 @@ void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity) weapon_prepareattack_do(actor, weaponentity, true, WEP_CVAR_SEC(hagar, refire)); - W_SetupShot(actor, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); + W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); forward = v_forward; @@ -426,7 +426,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int return; } - W_Hagar_Attack(thiswep, actor); + W_Hagar_Attack(thiswep, actor, weaponentity); int slot = weaponslot(weaponentity); ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor(actor); @@ -466,7 +466,7 @@ METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hagar, refire))) { - W_Hagar_Attack2(thiswep, actor); + W_Hagar_Attack2(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready); } } @@ -517,7 +517,7 @@ METHOD(Hagar, wr_playerdeath, void(entity thiswep, entity actor)) METHOD(Hagar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { if(!actor.hagar_load) // require releasing loaded rockets first - W_Reload(actor, min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND_RELOAD); } METHOD(Hagar, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 64c87c8a06..5d3463df93 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -69,7 +69,7 @@ void W_HLAC_Touch(entity this, entity toucher) delete(this); } -void W_HLAC_Attack(Weapon thiswep, entity actor) +void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; float spread; @@ -81,7 +81,7 @@ void W_HLAC_Attack(Weapon thiswep, entity actor) if(actor.crouch) spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod); - W_SetupShot(actor, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage)); + W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage)); Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); if(!autocvar_g_norecoil) { @@ -118,7 +118,7 @@ void W_HLAC_Attack(Weapon thiswep, entity actor) MUTATOR_CALLHOOK(EditProjectile, actor, missile); } -void W_HLAC_Attack2(entity actor) +void W_HLAC_Attack2(entity actor, .entity weaponentity) { entity missile; float spread; @@ -129,7 +129,7 @@ void W_HLAC_Attack2(entity actor) if(actor.crouch) spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod); - W_SetupShot(actor, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage)); + W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage)); Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); missile = new(hlacbolt); @@ -183,7 +183,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int int slot = weaponslot(weaponentity); ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor); - W_HLAC_Attack(WEP_HLAC, actor); + W_HLAC_Attack(WEP_HLAC, actor, weaponentity); actor.misc_bulletcounter = actor.misc_bulletcounter + 1; weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); } @@ -193,14 +193,14 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int } } -void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor) +void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity) { float i; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hlac, ammo)); for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i) - W_HLAC_Attack2(actor); + W_HLAC_Attack2(actor, weaponentity); if(!autocvar_g_norecoil) { @@ -222,7 +222,7 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire))) { actor.misc_bulletcounter = 0; - W_HLAC_Attack(thiswep, actor); + W_HLAC_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); } } @@ -231,7 +231,7 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hlac, refire))) { - W_HLAC_Attack2_Frame(thiswep, actor); + W_HLAC_Attack2_Frame(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready); } } @@ -250,7 +250,7 @@ METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor)) } METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD); } METHOD(HLAC, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index e9200e7626..b2b38e04c0 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -143,10 +143,10 @@ void W_Hook_Touch2(entity this, entity toucher) this.use(this, NULL, NULL); } -void W_Hook_Attack2(Weapon thiswep, entity actor) +void W_Hook_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { //W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb) - W_SetupShot(actor, false, 4, SND_HOOKBOMB_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hook, damage)); + W_SetupShot(actor, weaponentity, false, 4, SND_HOOKBOMB_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hook, damage)); entity gren = new(hookbomb); gren.owner = gren.realowner = actor; @@ -208,7 +208,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hook, refire))) { - W_Hook_Attack2(thiswep, actor); + W_Hook_Attack2(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 59dfc10e20..bb74e7f7bf 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -88,27 +88,29 @@ void W_MachineGun_MuzzleFlash_Think(entity this) } -void W_MachineGun_MuzzleFlash(entity actor) +void W_MachineGun_MuzzleFlash(entity actor, .entity weaponentity) { - if(actor.muzzle_flash == NULL) - actor.muzzle_flash = spawn(); + entity wepent = actor.(weaponentity); + + if(wepent.muzzle_flash == NULL) + wepent.muzzle_flash = spawn(); // muzzle flash for 1st person view - setmodel(actor.muzzle_flash, MDL_MACHINEGUN_MUZZLEFLASH); // precision set below - - actor.muzzle_flash.scale = 0.75; - setthink(actor.muzzle_flash, W_MachineGun_MuzzleFlash_Think); - actor.muzzle_flash.nextthink = time + 0.02; - actor.muzzle_flash.frame = 2; - actor.muzzle_flash.alpha = 0.75; - actor.muzzle_flash.angles_z = random() * 180; - actor.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - actor.muzzle_flash.owner = actor.muzzle_flash.realowner = actor; + setmodel(wepent.muzzle_flash, MDL_MACHINEGUN_MUZZLEFLASH); // precision set below + + wepent.muzzle_flash.scale = 0.75; + setthink(wepent.muzzle_flash, W_MachineGun_MuzzleFlash_Think); + wepent.muzzle_flash.nextthink = time + 0.02; + wepent.muzzle_flash.frame = 2; + wepent.muzzle_flash.alpha = 0.75; + wepent.muzzle_flash.angles_z = random() * 180; + wepent.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; + wepent.muzzle_flash.owner = wepent.muzzle_flash.realowner = wepent; } void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity weaponentity) { - W_SetupShot(actor, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((actor.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage))); + W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((actor.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage))); if(!autocvar_g_norecoil) { actor.punchangle_x = random() - 0.5; @@ -125,14 +127,14 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity we Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - W_MachineGun_MuzzleFlash(actor); - W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0'); + W_MachineGun_MuzzleFlash(actor, weaponentity); + W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0'); // casing code if(autocvar_g_casings >= 2) { makevectors(actor.v_angle); // for some reason, this is lost - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); } if(actor.misc_bulletcounter == 1) @@ -187,7 +189,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity W_DecreaseAmmo(WEP_MACHINEGUN, actor, WEP_CVAR(machinegun, sustained_ammo)); - W_SetupShot(actor, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); + W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); if(!autocvar_g_norecoil) { actor.punchangle_x = random() - 0.5; @@ -201,13 +203,13 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - W_MachineGun_MuzzleFlash(actor); - W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0'); + W_MachineGun_MuzzleFlash(actor, weaponentity); + W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0'); if(autocvar_g_casings >= 2) // casing code { makevectors(actor.v_angle); // for some reason, this is lost - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); } int slot = weaponslot(weaponentity); @@ -217,7 +219,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - W_SetupShot(actor, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); + W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); if(!autocvar_g_norecoil) { actor.punchangle_x = random() - 0.5; @@ -228,13 +230,13 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - W_MachineGun_MuzzleFlash(actor); - W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0'); + W_MachineGun_MuzzleFlash(actor, weaponentity); + W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0'); if(autocvar_g_casings >= 2) // casing code { makevectors(actor.v_angle); // for some reason, this is lost - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); } actor.misc_bulletcounter = actor.misc_bulletcounter + 1; @@ -345,7 +347,7 @@ METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor)) } METHOD(MachineGun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND_RELOAD); } METHOD(MachineGun, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index e5ba64f246..2b59e7841b 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -315,7 +315,7 @@ void W_MineLayer_Damage(entity this, entity inflictor, entity attacker, float da W_PrepareExplosionByDamage(this, attacker, W_MineLayer_Explode_think); } -void W_MineLayer_Attack(Weapon thiswep, entity actor) +void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity) { entity mine; entity flash; @@ -334,7 +334,7 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor) W_DecreaseAmmo(thiswep, actor, WEP_CVAR(minelayer, ammo)); - W_SetupShot_ProjectileSize(actor, '-4 -4 -4', '4 4 4', false, 5, SND_MINE_FIRE, CH_WEAPON_A, WEP_CVAR(minelayer, damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-4 -4 -4', '4 4 4', false, 5, SND_MINE_FIRE, CH_WEAPON_A, WEP_CVAR(minelayer, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); mine = WarpZone_RefSys_SpawnSameRefSys(actor); @@ -380,7 +380,7 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor) setmodel(flash, MDL_MINELAYER_MUZZLEFLASH); // precision set below SUB_SetFade(flash, time, 0.1); flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(actor, flash, '5 0 0'); + W_AttachToShotorg(actor, weaponentity, flash, '5 0 0'); // common properties @@ -506,7 +506,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(minelayer, refire))) { - W_MineLayer_Attack(thiswep, actor); + W_MineLayer_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready); } } @@ -542,7 +542,7 @@ METHOD(MineLayer, wr_resetplayer, void(entity thiswep, entity actor)) } METHOD(MineLayer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, WEP_CVAR(minelayer, ammo), SND_RELOAD); + W_Reload(actor, weaponentity, WEP_CVAR(minelayer, ammo), SND_RELOAD); } METHOD(MineLayer, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index c2e0cfc70d..61fa98b4b5 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -209,18 +209,16 @@ void W_Mortar_Grenade_Touch2(entity this, entity toucher) } } -void W_Mortar_Attack(Weapon thiswep, entity actor) +void W_Mortar_Attack(Weapon thiswep, entity actor, .entity weaponentity) { - entity gren; - W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(mortar, ammo)); - W_SetupShot_ProjectileSize(actor, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage)); w_shotdir = v_forward; // no TrueAim for grenades please Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - gren = new(grenade); + entity gren = new(grenade); gren.owner = gren.realowner = actor; gren.bot_dodge = true; gren.bot_dodgerating = WEP_CVAR_PRI(mortar, damage); @@ -258,13 +256,13 @@ void W_Mortar_Attack(Weapon thiswep, entity actor) MUTATOR_CALLHOOK(EditProjectile, actor, gren); } -void W_Mortar_Attack2(Weapon thiswep, entity actor) +void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { entity gren; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(mortar, ammo)); - W_SetupShot_ProjectileSize(actor, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage)); w_shotdir = v_forward; // no TrueAim for grenades please Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -353,7 +351,7 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire))) { - W_Mortar_Attack(thiswep, actor); + W_Mortar_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready); } } @@ -376,7 +374,7 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity } else if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(mortar, refire))) { - W_Mortar_Attack2(thiswep, actor); + W_Mortar_Attack2(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready); } } @@ -395,7 +393,7 @@ METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor)) } METHOD(Mortar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND_RELOAD); // WEAPONTODO + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND_RELOAD); // WEAPONTODO } METHOD(Mortar, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index b950a8f037..9bbc669e38 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -240,11 +240,11 @@ void W_Porto_Touch(entity this, entity toucher) } } -void W_Porto_Attack(entity actor, float type) +void W_Porto_Attack(entity actor, .entity weaponentity, float type) { entity gren; - W_SetupShot(actor, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0); + W_SetupShot(actor, weaponentity, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0); // always shoot from the eye w_shotdir = v_forward; w_shotorg = actor.origin + actor.view_ofs + ((w_shotorg - actor.origin - actor.view_ofs) * v_forward) * v_forward; @@ -310,7 +310,7 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire))) { - W_Porto_Attack(actor, 0); + W_Porto_Attack(actor, weaponentity, 0); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } @@ -319,7 +319,7 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(porto, refire))) { - W_Porto_Attack(actor, 1); + W_Porto_Attack(actor, weaponentity, 1); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready); } } @@ -352,7 +352,7 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire))) { - W_Porto_Attack(actor, -1); + W_Porto_Attack(actor, weaponentity, -1); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index c46b8f2b2c..e8c89cb757 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -56,13 +56,13 @@ spawnfunc(weapon_rifle) { weapon_defaultspawnfunc(this, WEP_RIFLE); } spawnfunc(weapon_campingrifle) { spawnfunc_weapon_rifle(this); } spawnfunc(weapon_sniperrifle) { spawnfunc_weapon_rifle(this); } -void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, Sound pSound, entity actor) +void W_Rifle_FireBullet(Weapon thiswep, .entity weaponentity, float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, Sound pSound, entity actor) { float i; W_DecreaseAmmo(thiswep, actor, pAmmo); - W_SetupShot(actor, true, 2, pSound, CH_WEAPON_A, pDamage * pShots); + W_SetupShot(actor, weaponentity, true, 2, pSound, CH_WEAPON_A, pDamage * pShots); Send_Effect(EFFECT_RIFLE_MUZZLEFLASH, w_shotorg, w_shotdir * 2000, 1); @@ -78,21 +78,21 @@ void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pFor if(autocvar_g_casings >= 2) { makevectors(actor.v_angle); // for some reason, this is lost - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); } } -void W_Rifle_Attack(entity actor) +void W_Rifle_Attack(entity actor, .entity weaponentity) { - W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND_CAMPINGRIFLE_FIRE, actor); + W_Rifle_FireBullet(WEP_RIFLE, weaponentity, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND_CAMPINGRIFLE_FIRE, actor); } -void W_Rifle_Attack2(entity actor) +void W_Rifle_Attack2(entity actor, .entity weaponentity) { - W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND_CAMPINGRIFLE_FIRE2, actor); + W_Rifle_FireBullet(WEP_RIFLE, weaponentity, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND_CAMPINGRIFLE_FIRE2, actor); } -.void(entity actor) rifle_bullethail_attackfunc; +.void(entity actor, .entity weaponentity) rifle_bullethail_attackfunc; .WFRAME rifle_bullethail_frame; .float rifle_bullethail_animtime; .float rifle_bullethail_refire; @@ -110,7 +110,7 @@ void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, .entity weaponent PS(actor).m_switchweapon = sw; if(r) { - actor.rifle_bullethail_attackfunc(actor); + actor.rifle_bullethail_attackfunc(actor, weaponentity); weapon_thinkf(actor, weaponentity, actor.rifle_bullethail_frame, actor.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue); } else @@ -119,10 +119,10 @@ void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, .entity weaponent } } -void W_Rifle_BulletHail(entity actor, .entity weaponentity, float mode, void(entity actor) AttackFunc, WFRAME fr, float animtime, float refire) +void W_Rifle_BulletHail(entity actor, .entity weaponentity, float mode, void(entity actor, .entity weaponentity) AttackFunc, WFRAME fr, float animtime, float refire) { // if we get here, we have at least one bullet to fire - AttackFunc(actor); + AttackFunc(actor, weaponentity); if(mode) { // continue hail @@ -217,7 +217,7 @@ METHOD(Rifle, wr_resetplayer, void(entity thiswep, entity actor)) } METHOD(Rifle, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND_RELOAD); } METHOD(Rifle, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 42487b5a3c..02987232f8 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -253,20 +253,18 @@ void W_Seeker_Missile_Animate(entity this) } */ -void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, vector f_diff, entity m_target) +void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, .entity weaponentity, vector f_diff, entity m_target) { - entity missile; - W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, missile_ammo)); makevectors(actor.v_angle); - W_SetupShot_ProjectileSize(actor, '-2 -2 -2', '2 2 2', false, 2, SND_SEEKER_FIRE, CH_WEAPON_A, 0); + W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_SEEKER_FIRE, CH_WEAPON_A, 0); w_shotorg += f_diff; Send_Effect(EFFECT_SEEKER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); //actor.detornator = false; - missile = new(seeker_missile); + entity missile = new(seeker_missile); missile.owner = missile.realowner = actor; missile.bot_dodge = true; missile.bot_dodgerating = WEP_CVAR(seeker, missile_damage); @@ -329,7 +327,7 @@ void W_Seeker_Flac_Explode_use(entity this, entity actor, entity trigger) W_Seeker_Flac_Explode(this, trigger); } -void W_Seeker_Fire_Flac(Weapon thiswep, entity actor) +void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; vector f_diff; @@ -354,7 +352,7 @@ void W_Seeker_Fire_Flac(Weapon thiswep, entity actor) f_diff = '+1.25 +3.75 0'; break; } - W_SetupShot_ProjectileSize(actor, '-2 -2 -2', '2 2 2', false, 2, SND_FLAC_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, flac_damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_FLAC_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, flac_damage)); w_shotorg += f_diff; Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -401,7 +399,7 @@ entity W_Seeker_Tagged_Info(entity isowner, entity istarget) return NULL; } -void W_Seeker_Attack(entity actor) +void W_Seeker_Attack(entity actor, .entity weaponentity) { entity tracker, closest_target; @@ -421,7 +419,7 @@ void W_Seeker_Attack(entity actor) if((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target))) closest_target = NULL; - W_Seeker_Fire_Missile(WEP_SEEKER, actor, '0 0 0', closest_target); + W_Seeker_Fire_Missile(WEP_SEEKER, actor, weaponentity, '0 0 0', closest_target); } void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seeker_Attack @@ -448,17 +446,17 @@ void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seek switch(c) { case 0: - W_Seeker_Fire_Missile(WEP_SEEKER, own, '-1.25 -3.75 0', own.enemy); + W_Seeker_Fire_Missile(WEP_SEEKER, own, weaponentities[0], '-1.25 -3.75 0', own.enemy); // TODO break; case 1: - W_Seeker_Fire_Missile(WEP_SEEKER, own, '+1.25 -3.75 0', own.enemy); + W_Seeker_Fire_Missile(WEP_SEEKER, own, weaponentities[0], '+1.25 -3.75 0', own.enemy); // TODO break; case 2: - W_Seeker_Fire_Missile(WEP_SEEKER, own, '-1.25 +3.75 0', own.enemy); + W_Seeker_Fire_Missile(WEP_SEEKER, own, weaponentities[0], '-1.25 +3.75 0', own.enemy); // TODO break; case 3: default: - W_Seeker_Fire_Missile(WEP_SEEKER, own, '+1.25 +3.75 0', own.enemy); + W_Seeker_Fire_Missile(WEP_SEEKER, own, weaponentities[0], '+1.25 +3.75 0', own.enemy); // TODO break; } @@ -566,14 +564,13 @@ void W_Seeker_Tag_Touch(entity this, entity toucher) return; } -void W_Seeker_Fire_Tag(Weapon thiswep, entity actor) +void W_Seeker_Fire_Tag(Weapon thiswep, entity actor, .entity weaponentity) { - entity missile; W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, tag_ammo)); - W_SetupShot_ProjectileSize(actor, '-2 -2 -2', '2 2 2', false, 2, SND_TAG_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, missile_damage) * WEP_CVAR(seeker, missile_count)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_TAG_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, missile_damage) * WEP_CVAR(seeker, missile_count)); - missile = new(seeker_tag); + entity missile = new(seeker_tag); missile.owner = missile.realowner = actor; missile.bot_dodge = true; missile.bot_dodgerating = 50; @@ -628,7 +625,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, missile_refire))) { - W_Seeker_Attack(actor); + W_Seeker_Attack(actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready); } } @@ -636,7 +633,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire))) { - W_Seeker_Fire_Tag(thiswep, actor); + W_Seeker_Fire_Tag(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready); } } @@ -648,7 +645,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire))) { - W_Seeker_Fire_Tag(thiswep, actor); + W_Seeker_Fire_Tag(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready); } } @@ -656,7 +653,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, flac_refire))) { - W_Seeker_Fire_Flac(thiswep, actor); + W_Seeker_Fire_Flac(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready); } } @@ -694,7 +691,7 @@ METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor)) } METHOD(Seeker, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND_RELOAD); } METHOD(Seeker, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index f143bd1cc2..ef5432c9b0 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -243,7 +243,7 @@ void W_Shockwave_Melee(Weapon thiswep, entity actor, .entity weaponentity, int f meleetemp.owner = meleetemp.realowner = actor; setthink(meleetemp, W_Shockwave_Melee_Think); meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor(actor); - W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range)); + W_SetupShot_Range(actor, weaponentity, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range)); } // SHOCKWAVE ATTACK MODE @@ -355,7 +355,7 @@ void W_Shockwave_Send(entity actor) WriteByte(MSG_BROADCAST, etof(actor)); } -void W_Shockwave_Attack(entity actor) +void W_Shockwave_Attack(entity actor, .entity weaponentity) { // declarations float multiplier, multiplier_from_accuracy, multiplier_from_distance; @@ -366,7 +366,7 @@ void W_Shockwave_Attack(entity actor) float i, queue = 0; // set up the shot direction - W_SetupShot(actor, true, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage)); + W_SetupShot(actor, weaponentity, true, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage)); vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance))); WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, actor); vector attack_hitpos = trace_endpos; @@ -709,7 +709,7 @@ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponent { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(shockwave, blast_animtime))) { - W_Shockwave_Attack(actor); + W_Shockwave_Attack(actor, weaponentity); actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready); } diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index b03c6fb4da..ee1b0138ed 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -58,11 +58,11 @@ REGISTER_WEAPON(SHOTGUN, shotgun, NEW(Shotgun)); #ifdef SVQC spawnfunc(weapon_shotgun) { weapon_defaultspawnfunc(this, WEP_SHOTGUN); } -void W_Shotgun_Attack(Weapon thiswep, entity actor, float isprimary) +void W_Shotgun_Attack(Weapon thiswep, entity actor, .entity weaponentity, float isprimary) { W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(shotgun, ammo)); - W_SetupShot(actor, true, 5, SND_SHOTGUN_FIRE, ((isprimary) ? CH_WEAPON_A : CH_WEAPON_SINGLE), WEP_CVAR_PRI(shotgun, damage) * WEP_CVAR_PRI(shotgun, bullets)); + W_SetupShot(actor, weaponentity, true, 5, SND_SHOTGUN_FIRE, ((isprimary) ? CH_WEAPON_A : CH_WEAPON_SINGLE), WEP_CVAR_PRI(shotgun, damage) * WEP_CVAR_PRI(shotgun, bullets)); for(int sc = 0;sc < WEP_CVAR_PRI(shotgun, bullets);sc = sc + 1) fireBullet(actor, w_shotorg, w_shotdir, WEP_CVAR_PRI(shotgun, spread), WEP_CVAR_PRI(shotgun, solidpenetration), WEP_CVAR_PRI(shotgun, damage), WEP_CVAR_PRI(shotgun, force), WEP_SHOTGUN.m_id, 0); @@ -73,7 +73,7 @@ void W_Shotgun_Attack(Weapon thiswep, entity actor, float isprimary) { makevectors(actor.v_angle); // for some reason, this is lost //for(int sc = 0;sc < WEP_CVAR_PRI(shotgun, ammo);sc = sc + 1) - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1, actor); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1, actor, weaponentity); } // muzzle flash for 1st person view @@ -82,7 +82,7 @@ void W_Shotgun_Attack(Weapon thiswep, entity actor, float isprimary) setthink(flash, SUB_Remove); flash.nextthink = time + 0.06; flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(actor, flash, '5 0 0'); + W_AttachToShotorg(actor, weaponentity, flash, '5 0 0'); } .float swing_prev; @@ -192,7 +192,7 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f meleetemp.realowner = actor; setthink(meleetemp, W_Shotgun_Melee_Think); meleetemp.nextthink = time + WEP_CVAR_SEC(shotgun, melee_delay) * W_WeaponRateFactor(actor); - W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range)); + W_SetupShot_Range(actor, weaponentity, true, 0, SND_Null, 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range)); } // alternate secondary weapon frames @@ -207,7 +207,7 @@ void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity } sound(actor, CH_WEAPON_SINGLE, SND_Null, VOL_BASE, ATTN_NORM); // kill previous sound - W_Shotgun_Attack(WEP_SHOTGUN, actor, true); // actually is secondary, but we trick the last shot into playing full reload sound + W_Shotgun_Attack(WEP_SHOTGUN, actor, weaponentity, true); // actually is secondary, but we trick the last shot into playing full reload sound weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready); } void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire) @@ -220,11 +220,11 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity return; } - W_Shotgun_Attack(WEP_SHOTGUN, actor, false); + W_Shotgun_Attack(WEP_SHOTGUN, actor, weaponentity, false); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2); } -.float shotgun_primarytime; +.float shotgun_primarytime[MAX_WEAPONSLOTS]; METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor)) { @@ -246,24 +246,26 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit { if(fire & 1) { - if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary + int slot = weaponslot(weaponentity); + if(time >= actor.shotgun_primarytime[slot]) // handle refire separately so the secondary can be fired straight after a primary { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(shotgun, animtime))) { - W_Shotgun_Attack(thiswep, actor, true); - actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(actor); + W_Shotgun_Attack(thiswep, actor, weaponentity, true); + actor.shotgun_primarytime[slot] = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready); } } } else if((fire & 2) && WEP_CVAR(shotgun, secondary) == 2) { - if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary + int slot = weaponslot(weaponentity); + if(time >= actor.shotgun_primarytime[slot]) // handle refire separately so the secondary can be fired straight after a primary { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(shotgun, alt_animtime))) { - W_Shotgun_Attack(thiswep, actor, false); - actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(actor); + W_Shotgun_Attack(thiswep, actor, weaponentity, false); + actor.shotgun_primarytime[slot] = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1); } } @@ -308,7 +310,7 @@ METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor)) } METHOD(Shotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, WEP_CVAR_PRI(shotgun, ammo), SND_RELOAD); // WEAPONTODO + W_Reload(actor, weaponentity, WEP_CVAR_PRI(shotgun, ammo), SND_RELOAD); // WEAPONTODO } METHOD(Shotgun, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 1fba375eb7..036181ca41 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -309,12 +309,12 @@ void W_Tuba_NoteThink(entity this) }); } -void W_Tuba_NoteOn(entity actor, float hittype) +void W_Tuba_NoteOn(entity actor, .entity weaponentity, float hittype) { vector o; float n; - W_SetupShot(actor, false, 2, SND_Null, 0, WEP_CVAR(tuba, damage)); + W_SetupShot(actor, weaponentity, false, 2, SND_Null, 0, WEP_CVAR(tuba, damage)); n = W_Tuba_GetNote(actor, hittype); @@ -377,13 +377,13 @@ METHOD(Tuba, wr_think, void(Tuba this, entity actor, .entity weaponentity, int f if (fire & 1) if (weapon_prepareattack(this, actor, weaponentity, false, WEP_CVAR(tuba, refire))) { - W_Tuba_NoteOn(actor, 0); + W_Tuba_NoteOn(actor, weaponentity, 0); weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready); } if (fire & 2) if (weapon_prepareattack(this, actor, weaponentity, true, WEP_CVAR(tuba, refire))) { - W_Tuba_NoteOn(actor, HITTYPE_SECONDARY); + W_Tuba_NoteOn(actor, weaponentity, HITTYPE_SECONDARY); weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready); } if (actor.tuba_note) @@ -448,7 +448,7 @@ METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity)) break; } tuba_instrument_send(actor, actor.tuba_instrument); - W_SetupShot(actor, false, 0, SND_Null, 0, 0); + W_SetupShot(actor, weaponentity, false, 0, SND_Null, 0, 0); Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1); actor.(weaponentity).state = WS_INUSE; weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, 0.5, w_ready); diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 488b5af278..df95007ae0 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -180,12 +180,12 @@ void W_RocketMinsta_Explosion(entity actor, vector loc) delete(dmgent); } -void W_Vaporizer_Attack(Weapon thiswep, entity actor) +void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity) { bool flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000); - W_SetupShot(actor, true, 0, SND_Null, CH_WEAPON_A, vaporizer_damage); + W_SetupShot(actor, weaponentity, true, 0, SND_Null, CH_WEAPON_A, vaporizer_damage); // handle sound separately so we can change the volume // added bonus: no longer plays the strength sound (strength gives no bonus to instakill anyway) sound (actor, CH_WEAPON_A, SND_MINSTANEXFIRE, VOL_BASE * 0.8, ATTEN_NORM); @@ -242,7 +242,7 @@ void W_RocketMinsta_Laser_Touch(entity this, entity toucher) delete(this); } -void W_RocketMinsta_Attack2(entity actor) +void W_RocketMinsta_Attack2(entity actor, .entity weaponentity) { makevectors(actor.v_angle); @@ -254,7 +254,7 @@ void W_RocketMinsta_Attack2(entity actor) Weapon w = PS(actor).m_weapon; PS(actor).m_weapon = WEP_ELECTRO; - W_SetupShot_ProjectileSize (actor, '0 0 -3', '0 0 -3', false, 2, SND_CRYLINK_FIRE, CH_WEAPON_A, autocvar_g_rm_laser_damage); + W_SetupShot_ProjectileSize (actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, SND_CRYLINK_FIRE, CH_WEAPON_A, autocvar_g_rm_laser_damage); PS(actor).m_weapon = w; Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -297,7 +297,7 @@ void W_RocketMinsta_Attack2(entity actor) } } -void W_RocketMinsta_Attack3 (entity actor) +void W_RocketMinsta_Attack3 (entity actor, .entity weaponentity) { makevectors(actor.v_angle); @@ -307,7 +307,7 @@ void W_RocketMinsta_Attack3 (entity actor) Weapon w = PS(actor).m_weapon; PS(actor).m_weapon = WEP_ELECTRO; - W_SetupShot_ProjectileSize (actor, '0 0 -3', '0 0 -3', false, 2, SND_ELECTRO_FIRE2, CH_WEAPON_A, autocvar_g_rm_laser_damage); + W_SetupShot_ProjectileSize (actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, SND_ELECTRO_FIRE2, CH_WEAPON_A, autocvar_g_rm_laser_damage); PS(actor).m_weapon = w; Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -368,7 +368,7 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire))) { - W_Vaporizer_Attack(thiswep, actor); + W_Vaporizer_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready); } } @@ -384,13 +384,13 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent actor.jump_interval = time + autocvar_g_rm_laser_refire; actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay; damage_goodhits = 0; - W_RocketMinsta_Attack2(actor); + W_RocketMinsta_Attack2(actor, weaponentity); } else if(rapid && actor.jump_interval2 <= time && actor.held_down) { actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire; damage_goodhits = 0; - W_RocketMinsta_Attack3(actor); + W_RocketMinsta_Attack3(actor, weaponentity); //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready); } } @@ -409,6 +409,7 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent PS(actor).m_weapon = WEP_BLASTER; W_Blaster_Attack( actor, + weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(vaporizer, shotangle), WEP_CVAR_SEC(vaporizer, damage), @@ -462,7 +463,7 @@ METHOD(Vaporizer, wr_reload, void(entity thiswep, entity actor, .entity weaponen else used_ammo = vaporizer_ammo; - W_Reload(actor, used_ammo, SND_RELOAD); + W_Reload(actor, weaponentity, used_ammo, SND_RELOAD); } METHOD(Vaporizer, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 640cd2c402..0c6b1f3c8a 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -157,7 +157,7 @@ MUTATOR_HOOKFUNCTION(vortex_charge, GetPressedKeys) } } -void W_Vortex_Attack(Weapon thiswep, entity actor, float issecondary) +void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float issecondary) { float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge; @@ -184,7 +184,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, float issecondary) mydmg *= charge; myforce *= charge; - W_SetupShot(actor, true, 5, SND_NEXFIRE, CH_WEAPON_A, mydmg); + W_SetupShot(actor, weaponentity, true, 5, SND_NEXFIRE, CH_WEAPON_A, mydmg); if(charge > WEP_CVAR(vortex, charge_animlimit) && WEP_CVAR(vortex, charge_animlimit)) // if the Vortex is overcharged, we play an extra sound { sound(actor, CH_WEAPON_B, SND_NEXCHARGE, VOL_BASE * (charge - 0.5 * WEP_CVAR(vortex, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(vortex, charge_animlimit)), ATTN_NORM); @@ -243,7 +243,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vortex, refire))) { - W_Vortex_Attack(thiswep, actor, 0); + W_Vortex_Attack(thiswep, actor, weaponentity, 0); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready); } } @@ -315,7 +315,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(vortex, refire))) { - W_Vortex_Attack(thiswep, actor, 1); + W_Vortex_Attack(thiswep, actor, weaponentity, 1); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready); } } @@ -358,7 +358,7 @@ METHOD(Vortex, wr_resetplayer, void(entity thiswep, entity actor)) } METHOD(Vortex, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND_RELOAD); } METHOD(Vortex, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 40ca3da275..f31b3e5c2f 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -323,7 +323,7 @@ float CheatCommand(entity this, int argc) // arguments: // effectname effectnum = _particleeffectnum(argv(1)); - W_SetupShot(this, false, false, SND_Null, CH_WEAPON_A, 0); + W_SetupShot(this, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0); traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, this); __trailparticles(this, effectnum, w_shotorg, trace_endpos); DID_CHEAT(); @@ -338,7 +338,7 @@ float CheatCommand(entity this, int argc) // arguments: // modelname mode f = stof(argv(2)); - W_SetupShot(this, false, false, SND_Null, CH_WEAPON_A, 0); + W_SetupShot(this, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0); traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, this); if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1) { diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index b9ada9722f..a8bd4e7356 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2367,7 +2367,10 @@ void PlayerPreThink (entity this) { this.items &= ~this.items_added; - W_WeaponFrame(this); + //for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + //W_WeaponFrame(this, weaponentities[slot]); + .entity weaponentity = weaponentities[0]; // TODO + W_WeaponFrame(this, weaponentity); this.items_added = 0; if (this.items & ITEM_Jetpack.m_itemid && (this.items & ITEM_JetpackRegen.m_itemid || this.ammo_fuel >= 0.01)) diff --git a/qcsrc/server/cl_impulse.qc b/qcsrc/server/cl_impulse.qc index 51cb60a727..bcd612c565 100644 --- a/qcsrc/server/cl_impulse.qc +++ b/qcsrc/server/cl_impulse.qc @@ -247,7 +247,7 @@ IMPULSE(weapon_drop) { if (this.vehicle) return; if (IS_DEAD(this)) return; - W_ThrowWeapon(this, W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), '0 0 0', true); + W_ThrowWeapon(this, weaponentities[0], W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), '0 0 0', true); } IMPULSE(weapon_reload) diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index c69b8e9a9c..b120c302f2 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -165,7 +165,7 @@ bool W_IsWeaponThrowable(entity this, int w) } // toss current weapon -void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce) +void W_ThrowWeapon(entity this, .entity weaponentity, vector velo, vector delta, float doreduce) { Weapon w = PS(this).m_weapon; if (w == WEP_Null) @@ -174,7 +174,6 @@ void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce) return; if(!autocvar_g_weapon_throwable) return; - .entity weaponentity = weaponentities[0]; // TODO: unhardcode if(this.(weaponentity).state != WS_READY) return; if(!W_IsWeaponThrowable(this, w.m_id)) diff --git a/qcsrc/server/weapons/throwing.qh b/qcsrc/server/weapons/throwing.qh index 5a27025bc8..a03968083e 100644 --- a/qcsrc/server/weapons/throwing.qh +++ b/qcsrc/server/weapons/throwing.qh @@ -9,6 +9,6 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto bool W_IsWeaponThrowable(entity this, int w); // toss current weapon -void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce); +void W_ThrowWeapon(entity this, .entity weaponentity, vector velo, vector delta, float doreduce); void SpawnThrownWeapon(entity this, vector org, float w); diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index e9148e6e27..85551aa2b3 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -20,7 +20,7 @@ // this function calculates w_shotorg and w_shotdir based on the weapon model // offset, trueaim and antilag, and won't put w_shotorg inside a wall. // make sure you call makevectors first (FIXME?) -void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range) +void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range) { TC(Sound, snd); float nudge = 1; // added to traceline target and subtracted from result TOOD(divVerent): do we still need this? Doesn't the engine do this now for us? @@ -58,7 +58,6 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m if(IS_PLAYER(ent)) W_HitPlotAnalysis(ent, v_forward, v_right, v_up); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode vector md = ent.(weaponentity).movedir; if(md.x > 0) vecs = md; diff --git a/qcsrc/server/weapons/tracing.qh b/qcsrc/server/weapons/tracing.qh index 52e5bd840e..21f12c1e4c 100644 --- a/qcsrc/server/weapons/tracing.qh +++ b/qcsrc/server/weapons/tracing.qh @@ -7,13 +7,13 @@ vector w_shotend; // this function calculates w_shotorg and w_shotdir based on the weapon model // offset, trueaim and antilag, and won't put w_shotorg inside a wall. // make sure you call makevectors first (FIXME?) -void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range); +void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range); -#define W_SetupShot_Dir_ProjectileSize(ent,s_forward,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, MAX_SHOT_DISTANCE) -#define W_SetupShot_ProjectileSize(ent,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, v_forward, mi, ma, antilag, recoil, snd, chan, maxdamage) -#define W_SetupShot_Dir(ent,s_forward,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage) -#define W_SetupShot(ent,antilag,recoil,snd,chan,maxdamage) W_SetupShot_ProjectileSize(ent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage) -#define W_SetupShot_Range(ent,antilag,recoil,snd,chan,maxdamage,range) W_SetupShot_Dir_ProjectileSize_Range(ent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, range) +#define W_SetupShot_Dir_ProjectileSize(ent,wepent,s_forward,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, MAX_SHOT_DISTANCE) +#define W_SetupShot_ProjectileSize(ent,wepent,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, wepent, v_forward, mi, ma, antilag, recoil, snd, chan, maxdamage) +#define W_SetupShot_Dir(ent,wepent,s_forward,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage) +#define W_SetupShot(ent,wepent,antilag,recoil,snd,chan,maxdamage) W_SetupShot_ProjectileSize(ent, wepent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage) +#define W_SetupShot_Range(ent,wepent,antilag,recoil,snd,chan,maxdamage,range) W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, range) vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute); diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 22fd70a2ec..6cc1324cf4 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -417,11 +417,10 @@ bool forbidWeaponUse(entity player) .bool hook_switchweapon; -void W_WeaponFrame(Player actor) +void W_WeaponFrame(Player actor, .entity weaponentity) { TC(Player, actor); TC(PlayerState, PS(actor)); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode entity this = actor.(weaponentity); if (frametime) actor.weapon_frametime = frametime; @@ -593,9 +592,8 @@ void W_WeaponFrame(Player actor) } } -void W_AttachToShotorg(entity actor, entity flash, vector offset) +void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector offset) { - .entity weaponentity = weaponentities[0]; flash.owner = actor; flash.angles_z = random() * 360; @@ -690,10 +688,9 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1)); } -void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound) +void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound) { TC(Sound, sent_sound); - .entity weaponentity = weaponentities[0]; // set global values to work with Weapon e = PS(actor).m_weapon; diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index 2aeca53811..d0ba634121 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -10,15 +10,15 @@ vector CL_Weapon_GetShotOrg(float wpn); float forbidWeaponUse(entity player); -void W_AttachToShotorg(entity actor, entity flash, vector offset); +void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector offset); void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use); void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item); -void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound); +void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound); -void W_WeaponFrame(Player actor); +void W_WeaponFrame(Player actor, .entity weaponentity); float W_WeaponRateFactor(entity this); -- 2.39.2