From 7d0add19804225fdfae3c9861081504c14c225d7 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 11 Aug 2024 15:04:17 +0200 Subject: [PATCH] Fix weapons with blaster secondary attack improperly using damage and force settings of the blaster itself --- .../common/mutators/mutator/overkill/okhmg.qc | 4 ++-- .../mutators/mutator/overkill/okmachinegun.qc | 4 ++-- .../common/mutators/mutator/overkill/oknex.qc | 4 ++-- .../common/mutators/mutator/overkill/okrpc.qc | 4 ++-- .../mutators/mutator/overkill/okshotgun.qc | 4 ++-- qcsrc/common/weapons/all.qh | 7 +++++++ qcsrc/common/weapons/weapon/blaster.qc | 18 ++++++++++-------- qcsrc/common/weapons/weapon/vaporizer.qc | 2 +- 8 files changed, 28 insertions(+), 19 deletions(-) diff --git a/qcsrc/common/mutators/mutator/overkill/okhmg.qc b/qcsrc/common/mutators/mutator/overkill/okhmg.qc index 391d9acbb..7348f2efe 100644 --- a/qcsrc/common/mutators/mutator/overkill/okhmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/okhmg.qc @@ -65,7 +65,7 @@ METHOD(OverkillHeavyMachineGun, 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(okhmg, refire) * W_WeaponRateFactor(actor); makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -103,7 +103,7 @@ METHOD(OverkillHeavyMachineGun, wr_think, void(entity thiswep, entity actor, .en return; } makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okhmg, animtime), w_ready); } } diff --git a/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc b/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc index e73e63fa1..9eec4f2ff 100644 --- a/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc +++ b/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc @@ -69,7 +69,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); makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -107,7 +107,7 @@ METHOD(OverkillMachineGun, wr_think, void(entity thiswep, entity actor, .entity return; } makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); 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 311e7a738..a6a6d633b 100644 --- a/qcsrc/common/mutators/mutator/overkill/oknex.qc +++ b/qcsrc/common/mutators/mutator/overkill/oknex.qc @@ -142,7 +142,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); makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -182,7 +182,7 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone return; } makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(oknex, animtime), w_ready); return; } diff --git a/qcsrc/common/mutators/mutator/overkill/okrpc.qc b/qcsrc/common/mutators/mutator/overkill/okrpc.qc index a1f9d5db6..3437883ad 100644 --- a/qcsrc/common/mutators/mutator/overkill/okrpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/okrpc.qc @@ -140,7 +140,7 @@ METHOD(OverkillRocketPropelledChainsaw, wr_think, void(entity thiswep, entity ac // Secondary uses it's own refire timer if refire_type is 1. actor.jump_interval = time + WEP_CVAR_SEC(okrpc, refire) * W_WeaponRateFactor(actor); makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -178,7 +178,7 @@ METHOD(OverkillRocketPropelledChainsaw, wr_think, void(entity thiswep, entity ac return; } makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okrpc, animtime), w_ready); } } diff --git a/qcsrc/common/mutators/mutator/overkill/okshotgun.qc b/qcsrc/common/mutators/mutator/overkill/okshotgun.qc index 301ed4d9e..3524430b6 100644 --- a/qcsrc/common/mutators/mutator/overkill/okshotgun.qc +++ b/qcsrc/common/mutators/mutator/overkill/okshotgun.qc @@ -20,7 +20,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); makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); if ((actor.(weaponentity).wframe == WFRAME_IDLE) || (actor.(weaponentity).wframe == WFRAME_FIRE2)) { @@ -71,7 +71,7 @@ METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity wea return; } makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready); } } diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 50c6e3cb5..729cd831f 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -38,6 +38,8 @@ STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPicku #define WepSet_FromWeapon(it) ((it).m_wepset) WepSet _WepSet_FromWeapon(int i); +.entity real_weapon; + #define DEFAULT_FILENAME "weapons_dump.cfg" // NOTE: dumpeffectinfo, dumpnotifs, dumpturrets and dumpweapons use similar code GENERIC_COMMAND(dumpweapons, "Dump all turrets into " DEFAULT_FILENAME, false) // WEAPONTODO: make this work with other progs than just server @@ -301,6 +303,11 @@ const .float reloading_time = reload_time; #define WEP_CVAR_SEC(wepname, name) WEP_CVAR(wepname, secondary_##name) #define WEP_CVAR_BOTH(wepname, isprimary, name) ((isprimary) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name)) +#define WEP_CVAR_E(wep, name) (wep.wepvar_##name) +#define WEP_CVAR_PRI_E(wep, name) WEP_CVAR_E(wep, primary_##name) +#define WEP_CVAR_SEC_E(wep, name) WEP_CVAR_E(wep, secondary_##name) +#define WEP_CVAR_BOTH_E(wep, isprimary, name) ((isprimary) ? WEP_CVAR_PRI_E(wep, name) : WEP_CVAR_SEC_E(wep, name)) + const int WEP_FIRST = 1; #define WEP_LAST (REGISTRY_COUNT(Weapons) - 1) WepSet WEPSET_ALL; diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 6ac1415df..426a68ec3 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -14,14 +14,14 @@ void W_Blaster_Touch(entity this, entity toucher) (this.origin + (this.mins + this.maxs) * 0.5), this.velocity, this.realowner, - WEP_CVAR_BOTH(blaster, isprimary, damage), - WEP_CVAR_BOTH(blaster, isprimary, edgedamage), - WEP_CVAR_BOTH(blaster, isprimary, radius), + WEP_CVAR_BOTH_E(this.real_weapon, isprimary, damage), + WEP_CVAR_BOTH_E(this.real_weapon, isprimary, edgedamage), + WEP_CVAR_BOTH_E(this.real_weapon, isprimary, radius), NULL, NULL, false, - WEP_CVAR_BOTH(blaster, isprimary, force), - WEP_CVAR_BOTH(blaster, isprimary, force_zscale), + WEP_CVAR_BOTH_E(this.real_weapon, isprimary, force), + WEP_CVAR_BOTH_E(this.real_weapon, isprimary, force_zscale), this.projectiledeathtype, this.weaponentity_fld, toucher @@ -41,6 +41,7 @@ void W_Blaster_Think(entity this) void W_Blaster_Attack( entity actor, + entity real_wpn, .entity weaponentity, float atk_deathtype) { @@ -53,6 +54,7 @@ void W_Blaster_Attack( W_MuzzleFlash(WEP_BLASTER, actor, weaponentity, w_shotorg, w_shotdir); entity missile = new(blasterbolt); + missile.real_weapon = real_wpn; missile.owner = missile.realowner = actor; missile.bot_dodge = true; missile.bot_dodgerating = atk_damage; @@ -107,7 +109,7 @@ METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponenti { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(blaster, refire))) { - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready); } } @@ -126,7 +128,7 @@ METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponenti { if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(blaster, refire))) { - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(blaster, animtime), w_ready); } @@ -165,7 +167,7 @@ METHOD(OffhandBlaster, offhand_think, void(OffhandBlaster this, entity actor, bo actor.jump_interval = time + WEP_CVAR_SEC(blaster, refire) * W_WeaponRateFactor(actor); .entity weaponentity = weaponentities[1]; makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, this, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); } #endif diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 00be9c218..d5ee4cf61 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -305,7 +305,7 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo), weaponentity); makevectors(actor.v_angle); - W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); + W_Blaster_Attack(actor, thiswep, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY); // now do normal refire weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready); -- 2.39.2