Skip to content

Commit 6a8df9e

Browse files
committed
Fix veterancy firepower modifier not being factored in multiple places together with crate/AE ones
1 parent b0e23bc commit 6a8df9e

File tree

7 files changed

+14
-10
lines changed

7 files changed

+14
-10
lines changed

src/Ext/Anim/Hooks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ DEFINE_HOOK(0x42453E, AnimClass_AI_Damage, 0x6)
119119
pOwner = pInvoker->Owner;
120120

121121
if (pTypeExt->Damage_ApplyFirepowerMult)
122-
appliedDamage = static_cast<int>(appliedDamage * pInvoker->FirepowerMultiplier * TechnoExt::ExtMap.Find(pInvoker)->AE.FirepowerMultiplier);
122+
appliedDamage = static_cast<int>(appliedDamage * TechnoExt::GetCurrentFirepowerMultiplier(pInvoker));
123123
}
124124
}
125125

src/Ext/Bullet/Hooks.DetonateLogics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ DEFINE_HOOK(0x469AA4, BulletClass_Logics_Extras, 0x5)
414414
int damage = pWeapon->Damage;
415415

416416
if (pTypeExt->ReturnWeapon_ApplyFirepowerMult)
417-
damage = static_cast<int>(damage * pTechno->FirepowerMultiplier * TechnoExt::ExtMap.Find(pTechno)->AE.FirepowerMultiplier);
417+
damage = static_cast<int>(damage * TechnoExt::GetCurrentFirepowerMultiplier(pTechno));
418418

419419
if (BulletClass* pBullet = pWeapon->Projectile->CreateBullet(pTechno, pTechno,
420420
damage, pWeapon->Warhead, pWeapon->Speed, pWeapon->Bright))
@@ -611,7 +611,7 @@ DEFINE_HOOK(0x469EC0, BulletClass_Logics_AirburstWeapon, 0x6)
611611
int damage = pWeapon->Damage;
612612

613613
if (pTypeExt->AirburstWeapon_ApplyFirepowerMult && pSource)
614-
damage = static_cast<int>(damage * pSource->FirepowerMultiplier * TechnoExt::ExtMap.Find(pSource)->AE.FirepowerMultiplier);
614+
damage = static_cast<int>(damage * TechnoExt::GetCurrentFirepowerMultiplier(pSource));
615615

616616
// Cache all pointer variables before the loop
617617
auto const pWH = pWeapon->Warhead;

src/Ext/Bullet/Trajectories/StraightTrajectory.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,7 @@ void StraightTrajectory::OnUnlimbo(BulletClass* pBullet, CoordStruct* pCoord, Bu
168168
if (pFirer)
169169
{
170170
this->CurrentBurst = pFirer->CurrentBurstIndex;
171-
this->FirepowerMult = pFirer->FirepowerMultiplier;
172-
173-
if (const auto pExt = TechnoExt::ExtMap.TryFind(pFirer))
174-
this->FirepowerMult *= pExt->AE.FirepowerMultiplier;
171+
this->FirepowerMult = TechnoExt::GetCurrentFirepowerMultiplier(pFirer);
175172

176173
if (pType->MirrorCoord && pFirer->CurrentBurstIndex % 2 == 1)
177174
this->OffsetCoord.Y = -(this->OffsetCoord.Y);

src/Ext/Techno/Body.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ double TechnoExt::GetCurrentSpeedMultiplier(FootClass* pThis)
186186
(pThis->HasAbility(Ability::Faster) ? RulesClass::Instance->VeteranSpeed : 1.0);
187187
}
188188

189+
double TechnoExt::GetCurrentFirepowerMultiplier(TechnoClass* pThis)
190+
{
191+
return pThis->FirepowerMultiplier * TechnoExt::ExtMap.Find(pThis)->AE.FirepowerMultiplier *
192+
(pThis->HasAbility(Ability::Firepower) ? RulesClass::Instance->VeteranCombat : 1.0);
193+
}
194+
189195
CoordStruct TechnoExt::PassengerKickOutLocation(TechnoClass* pThis, FootClass* pPassenger, int maxAttempts = 1)
190196
{
191197
if (!pThis || !pPassenger)

src/Ext/Techno/Body.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class TechnoExt
238238
static void ObjectKilledBy(TechnoClass* pThis, TechnoClass* pKiller);
239239
static void UpdateSharedAmmo(TechnoClass* pThis);
240240
static double GetCurrentSpeedMultiplier(FootClass* pThis);
241+
static double GetCurrentFirepowerMultiplier(TechnoClass* pThis);
241242
static void DrawSelfHealPips(TechnoClass* pThis, Point2D* pLocation, RectangleStruct* pBounds);
242243
static void DrawInsignia(TechnoClass* pThis, Point2D* pLocation, RectangleStruct* pBounds);
243244
static void ApplyGainedSelfHeal(TechnoClass* pThis);

src/Ext/WarheadType/Detonate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ void WarheadTypeExt::ExtData::ApplyCrit(HouseClass* pHouse, TechnoClass* pTarget
497497
int damage = this->Crit_ExtraDamage.Get();
498498

499499
if (this->Crit_ExtraDamage_ApplyFirepowerMult && pOwner)
500-
damage = static_cast<int>(damage * pOwner->FirepowerMultiplier * TechnoExt::ExtMap.Find(pOwner)->AE.FirepowerMultiplier);
500+
damage = static_cast<int>(damage * TechnoExt::GetCurrentFirepowerMultiplier(pOwner));
501501

502502
if (this->Crit_Warhead)
503503
{

src/New/Entity/AttachEffectClass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ AttachEffectClass::AttachEffectClass(AttachEffectTypeClass* pType, TechnoClass*
6161
duration = this->DurationOverride != 0 ? this->DurationOverride : pType->Duration;
6262

6363
if (pType->Duration_ApplyFirepowerMult && duration > 0 && pInvoker)
64-
duration = Math::max(static_cast<int>(duration * pInvoker->FirepowerMultiplier * TechnoExt::ExtMap.Find(pInvoker)->AE.FirepowerMultiplier), 0);
64+
duration = Math::max(static_cast<int>(duration * TechnoExt::GetCurrentFirepowerMultiplier(pInvoker)), 0);
6565

6666
const auto pTechnoExt = TechnoExt::ExtMap.Find(pTechno);
6767

@@ -493,7 +493,7 @@ void AttachEffectClass::RefreshDuration(int durationOverride)
493493
duration = this->DurationOverride ? this->DurationOverride : pType->Duration;
494494

495495
if (pType->Duration_ApplyFirepowerMult && duration > 0 && this->Invoker)
496-
duration = Math::max(static_cast<int>(duration * this->Invoker->FirepowerMultiplier * TechnoExt::ExtMap.Find(this->Invoker)->AE.FirepowerMultiplier), 0);
496+
duration = Math::max(static_cast<int>(duration * TechnoExt::GetCurrentFirepowerMultiplier(this->Invoker)), 0);
497497

498498
if (pType->Duration_ApplyArmorMultOnTarget && duration > 0) // no need to count its own effect again
499499
duration = Math::max(static_cast<int>(duration / this->Techno->ArmorMultiplier / TechnoExt::ExtMap.Find(this->Techno)->AE.ArmorMultiplier), 0);

0 commit comments

Comments
 (0)