Skip to content

Commit

Permalink
Fix ApplyModifiersOnNegativeDamage not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Mar 17, 2024
1 parent 50562f3 commit 98f3d74
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/Ext/WarheadType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,50 @@ DEFINE_HOOK(0x48A4F3, SelectDamageAnimation_NegativeZeroDamage, 0x6)
return SkipGameCode;
}

DEFINE_HOOK(0x4891AF, GetTotalDamage_NegativeDamageModifiers, 0x6)
#pragma region NegativeDamageModifiers

namespace NegativeDamageTemp
{
bool ApplyNegativeDamageModifiers = false;
}

DEFINE_HOOK(0x4891AF, GetTotalDamage_NegativeDamageModifiers1, 0x6)
{
enum { ApplyModifiers = 0x4891C6 };

GET(WarheadTypeClass* const, pWarhead, EDI);
GET(int, damage, ESI);

auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWarhead);

if (pWHExt->ApplyModifiersOnNegativeDamage)
if (damage < 0 && pWHExt->ApplyModifiersOnNegativeDamage)
{
NegativeDamageTemp::ApplyNegativeDamageModifiers = true;
return ApplyModifiers;
}

return 0;
}

DEFINE_HOOK(0x48922D, GetTotalDamage_NegativeDamageModifiers2, 0x5)
{
enum { SkipGameCode = 0x489235 };

GET(int, damage, ESI);

if (NegativeDamageTemp::ApplyNegativeDamageModifiers)
{
NegativeDamageTemp::ApplyNegativeDamageModifiers = false;
R->ECX(damage);

}
else
{
R->ECX(damage < 0 ? 0 : damage);
}


return SkipGameCode;
}

#pragma endregion

0 comments on commit 98f3d74

Please sign in to comment.