From 101c811a51a08305d18ca504af57b5dab1bb16a4 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Sat, 17 Feb 2018 09:55:02 +0300 Subject: [PATCH] OK weapons: Better secondary attack code. --- qcsrc/common/mutators/mutator/overkill/hmg.qc | 37 +------------------ .../mutators/mutator/overkill/okmachinegun.qc | 34 +---------------- .../common/mutators/mutator/overkill/oknex.qc | 34 +---------------- .../mutators/mutator/overkill/okshotgun.qc | 34 +---------------- qcsrc/common/mutators/mutator/overkill/rpc.qc | 37 +------------------ 5 files changed, 10 insertions(+), 166 deletions(-) diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index 28bc8c8b5..347e76d4b 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -70,25 +70,7 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea { // Secondary uses it's own refire timer if refire_type is 1. actor.jump_interval = time + WEP_CVAR_SEC(hmg, refire) * W_WeaponRateFactor(actor); - // Ugly hack to reuse the fire mode of the blaster. - makevectors(actor.v_angle); - Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack - actor.(weaponentity).m_weapon = WEP_BLASTER; - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(hmg, shotangle), - WEP_CVAR_SEC(hmg, damage), - WEP_CVAR_SEC(hmg, edgedamage), - WEP_CVAR_SEC(hmg, radius), - WEP_CVAR_SEC(hmg, force), - WEP_CVAR_SEC(hmg, speed), - WEP_CVAR_SEC(hmg, spread), - WEP_CVAR_SEC(hmg, delay), - WEP_CVAR_SEC(hmg, lifetime) - ); - actor.(weaponentity).m_weapon = oldwep; + BLASTER_SECONDARY_ATTACK(hmg, actor, weaponentity); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -128,22 +110,7 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea { return; } - // ugly instagib hack to reuse the fire mode of the laser - makevectors(actor.v_angle); - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(hmg, shotangle), - WEP_CVAR_SEC(hmg, damage), - WEP_CVAR_SEC(hmg, edgedamage), - WEP_CVAR_SEC(hmg, radius), - WEP_CVAR_SEC(hmg, force), - WEP_CVAR_SEC(hmg, speed), - WEP_CVAR_SEC(hmg, spread), - WEP_CVAR_SEC(hmg, delay), - WEP_CVAR_SEC(hmg, lifetime) - ); + BLASTER_SECONDARY_ATTACK(hmg, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hmg, animtime), w_ready); } } diff --git a/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc b/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc index 48c6634dd..63c1e245b 100644 --- a/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc +++ b/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc @@ -64,22 +64,7 @@ METHOD(OverkillMachineGun, wr_think, void(entity thiswep, entity actor, .entity { // Secondary uses it's own refire timer if refire_type is 1. actor.jump_interval = time + WEP_CVAR_SEC(okmachinegun, refire) * W_WeaponRateFactor(actor); - // Ugly hack to reuse the fire mode of the blaster. - makevectors(actor.v_angle); - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(okmachinegun, shotangle), - WEP_CVAR_SEC(okmachinegun, damage), - WEP_CVAR_SEC(okmachinegun, edgedamage), - WEP_CVAR_SEC(okmachinegun, radius), - WEP_CVAR_SEC(okmachinegun, force), - WEP_CVAR_SEC(okmachinegun, speed), - WEP_CVAR_SEC(okmachinegun, spread), - WEP_CVAR_SEC(okmachinegun, delay), - WEP_CVAR_SEC(okmachinegun, lifetime) - ); + BLASTER_SECONDARY_ATTACK(okmachinegun, actor, weaponentity); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -119,22 +104,7 @@ METHOD(OverkillMachineGun, wr_think, void(entity thiswep, entity actor, .entity { return; } - // Ugly hack to reuse the fire mode of the blaster. - makevectors(actor.v_angle); - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(okmachinegun, shotangle), - WEP_CVAR_SEC(okmachinegun, damage), - WEP_CVAR_SEC(okmachinegun, edgedamage), - WEP_CVAR_SEC(okmachinegun, radius), - WEP_CVAR_SEC(okmachinegun, force), - WEP_CVAR_SEC(okmachinegun, speed), - WEP_CVAR_SEC(okmachinegun, spread), - WEP_CVAR_SEC(okmachinegun, delay), - WEP_CVAR_SEC(okmachinegun, lifetime) - ); + BLASTER_SECONDARY_ATTACK(okmachinegun, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okmachinegun, animtime), w_ready); } } diff --git a/qcsrc/common/mutators/mutator/overkill/oknex.qc b/qcsrc/common/mutators/mutator/overkill/oknex.qc index cbfa1216d..0f67ddba2 100644 --- a/qcsrc/common/mutators/mutator/overkill/oknex.qc +++ b/qcsrc/common/mutators/mutator/overkill/oknex.qc @@ -140,22 +140,7 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone { // Secondary uses it's own refire timer if refire_type is 1. actor.jump_interval = time + WEP_CVAR_SEC(oknex, refire) * W_WeaponRateFactor(actor); - // Ugly hack to reuse the fire mode of the blaster. - makevectors(actor.v_angle); - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(oknex, shotangle), - WEP_CVAR_SEC(oknex, damage), - WEP_CVAR_SEC(oknex, edgedamage), - WEP_CVAR_SEC(oknex, radius), - WEP_CVAR_SEC(oknex, force), - WEP_CVAR_SEC(oknex, speed), - WEP_CVAR_SEC(oknex, spread), - WEP_CVAR_SEC(oknex, delay), - WEP_CVAR_SEC(oknex, lifetime) - ); + BLASTER_SECONDARY_ATTACK(oknex, actor, weaponentity); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -197,22 +182,7 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone { return; } - // ugly instagib hack to reuse the fire mode of the laser - makevectors(actor.v_angle); - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(oknex, shotangle), - WEP_CVAR_SEC(oknex, damage), - WEP_CVAR_SEC(oknex, edgedamage), - WEP_CVAR_SEC(oknex, radius), - WEP_CVAR_SEC(oknex, force), - WEP_CVAR_SEC(oknex, speed), - WEP_CVAR_SEC(oknex, spread), - WEP_CVAR_SEC(oknex, delay), - WEP_CVAR_SEC(oknex, lifetime) - ); + BLASTER_SECONDARY_ATTACK(oknex, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(oknex, animtime), w_ready); return; } diff --git a/qcsrc/common/mutators/mutator/overkill/okshotgun.qc b/qcsrc/common/mutators/mutator/overkill/okshotgun.qc index a0c80f25e..2f1651776 100644 --- a/qcsrc/common/mutators/mutator/overkill/okshotgun.qc +++ b/qcsrc/common/mutators/mutator/overkill/okshotgun.qc @@ -19,22 +19,7 @@ METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity wea { // Secondary uses it's own refire timer if refire_type is 1. actor.jump_interval = time + WEP_CVAR_SEC(okshotgun, refire) * W_WeaponRateFactor(actor); - // Ugly hack to reuse the fire mode of the blaster. - makevectors(actor.v_angle); - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(okshotgun, shotangle), - WEP_CVAR_SEC(okshotgun, damage), - WEP_CVAR_SEC(okshotgun, edgedamage), - WEP_CVAR_SEC(okshotgun, radius), - WEP_CVAR_SEC(okshotgun, force), - WEP_CVAR_SEC(okshotgun, speed), - WEP_CVAR_SEC(okshotgun, spread), - WEP_CVAR_SEC(okshotgun, delay), - WEP_CVAR_SEC(okshotgun, lifetime) - ); + BLASTER_SECONDARY_ATTACK(okshotgun, actor, weaponentity); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -80,22 +65,7 @@ METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity wea { return; } - // Ugly hack to reuse the fire mode of the blaster. - makevectors(actor.v_angle); - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(okshotgun, shotangle), - WEP_CVAR_SEC(okshotgun, damage), - WEP_CVAR_SEC(okshotgun, edgedamage), - WEP_CVAR_SEC(okshotgun, radius), - WEP_CVAR_SEC(okshotgun, force), - WEP_CVAR_SEC(okshotgun, speed), - WEP_CVAR_SEC(okshotgun, spread), - WEP_CVAR_SEC(okshotgun, delay), - WEP_CVAR_SEC(okshotgun, lifetime) - ); + BLASTER_SECONDARY_ATTACK(okshotgun, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready); } } diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index f42a55f65..ceb4563b8 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -121,25 +121,7 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en { // Secondary uses it's own refire timer if refire_type is 1. actor.jump_interval = time + WEP_CVAR_SEC(rpc, refire) * W_WeaponRateFactor(actor); - // Ugly hack to reuse the fire mode of the blaster. - makevectors(actor.v_angle); - Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack - actor.(weaponentity).m_weapon = WEP_BLASTER; - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(rpc, shotangle), - WEP_CVAR_SEC(rpc, damage), - WEP_CVAR_SEC(rpc, edgedamage), - WEP_CVAR_SEC(rpc, radius), - WEP_CVAR_SEC(rpc, force), - WEP_CVAR_SEC(rpc, speed), - WEP_CVAR_SEC(rpc, spread), - WEP_CVAR_SEC(rpc, delay), - WEP_CVAR_SEC(rpc, lifetime) - ); - actor.(weaponentity).m_weapon = oldwep; + BLASTER_SECONDARY_ATTACK(rpc, actor, weaponentity); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -179,22 +161,7 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en { return; } - // ugly instagib hack to reuse the fire mode of the laser - makevectors(actor.v_angle); - W_Blaster_Attack( - actor, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(rpc, shotangle), - WEP_CVAR_SEC(rpc, damage), - WEP_CVAR_SEC(rpc, edgedamage), - WEP_CVAR_SEC(rpc, radius), - WEP_CVAR_SEC(rpc, force), - WEP_CVAR_SEC(rpc, speed), - WEP_CVAR_SEC(rpc, spread), - WEP_CVAR_SEC(rpc, delay), - WEP_CVAR_SEC(rpc, lifetime) - ); + BLASTER_SECONDARY_ATTACK(rpc, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(rpc, animtime), w_ready); } } -- 2.39.2