Skip to content

Commit

Permalink
Fixed low damage for Shield with AbsorbOverDamage
Browse files Browse the repository at this point in the history
  • Loading branch information
Belonit committed Dec 7, 2022
1 parent 6722562 commit f3cb079
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/Ext/Techno/Hooks.Shield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <Ext/WarheadType/Body.h>
#include <Ext/TEvent/Body.h>

bool bSkipLowDamageCheck = false;

// #issue 88 : shield logic
DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
{
Expand All @@ -31,26 +33,29 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
if (auto pTag = pThis->AttachedTag)
pTag->RaiseEvent((TriggerEvent)PhobosTriggerEvent::ShieldBroken, pThis, CellStruct::Empty);
}

if (nDamageLeft == 0)
bSkipLowDamageCheck = true;
}
}
return 0;
}

DEFINE_HOOK(0x7019D8, TechnoClass_ReceiveDamage_SkipLowDamageCheck, 0x5)
{
GET(TechnoClass*, pThis, ESI);
GET(int*, Damage, EBX);

const auto pExt = TechnoExt::ExtMap.Find(pThis);

if (const auto pShieldData = pExt->Shield.get())
if (bSkipLowDamageCheck)
{
bSkipLowDamageCheck = false;
}
else
{
if (pShieldData->IsActive())
return 0x7019E3;
// Restore overridden instructions
GET(int*, nDamage, EBX);
if (*nDamage < 1)
*nDamage = 1;
}

// Restore overridden instructions
return *Damage >= 1 ? 0x7019E3 : 0x7019DD;
return 0x7019E3;
}

DEFINE_HOOK_AGAIN(0x70CF39, TechnoClass_ReplaceArmorWithShields, 0x6) //TechnoClass_EvalThreatRating_Shield
Expand Down

0 comments on commit f3cb079

Please sign in to comment.