Skip to content

Commit

Permalink
Fix a bug that caused DamageArea to not apply Phobos Warhead effects …
Browse files Browse the repository at this point in the history
…unless the hit was nullified by invulnerability
  • Loading branch information
Starkku committed Aug 28, 2024
1 parent 119b6de commit 05aafd6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 42 deletions.
2 changes: 2 additions & 0 deletions src/Ext/Bullet/Hooks.DetonateLogics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,7 @@ DEFINE_HOOK(0x46A290, BulletClass_Logics_Extras, 0x5)
}
}

WarheadTypeExt::ExtMap.Find(pThis->WH)->InDamageArea = true;

return 0;
}
2 changes: 2 additions & 0 deletions src/Ext/WarheadType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class WarheadTypeExt
double Crit_RandomBuffer;
double Crit_CurrentChance;
bool Crit_Active;
bool InDamageArea;
bool WasDetonatedOnAllMapObjects;
bool Splashed;
bool Reflected;
Expand Down Expand Up @@ -299,6 +300,7 @@ class WarheadTypeExt
, Crit_RandomBuffer { 0.0 }
, Crit_CurrentChance { 0.0 }
, Crit_Active { false }
, InDamageArea { true }
, WasDetonatedOnAllMapObjects { false }
, Splashed { false }
, Reflected { false }
Expand Down
61 changes: 19 additions & 42 deletions src/Ext/WarheadType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,37 @@
#include <Ext/WeaponType/Body.h>
#include <Utilities/EnumFunctions.h>

#pragma region DETONATION

namespace Detonation
{
bool InDamageArea = true;
}
#pragma region Detonation

DEFINE_HOOK(0x46920B, BulletClass_Detonate, 0x6)
{
GET(BulletClass* const, pBullet, ESI);
GET_BASE(const CoordStruct*, pCoords, 0x8);

auto const pWH = pBullet ? pBullet->WH : nullptr;

if (auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWH))
{
GET_BASE(const CoordStruct*, pCoords, 0x8);
auto const pBulletExt = BulletExt::ExtMap.Find(pBullet);
auto const pOwner = pBullet->Owner;
auto const pHouse = pOwner ? pOwner->Owner : nullptr;
auto const pDecidedHouse = pHouse ? pHouse : pBulletExt->FirerHouse;

pWHExt->Detonate(pOwner, pDecidedHouse, pBulletExt, *pCoords);
}

Detonation::InDamageArea = false;

return 0;
}
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pBullet->WH);
auto const pBulletExt = BulletExt::ExtMap.Find(pBullet);
auto const pOwner = pBullet->Owner;
auto const pHouse = pOwner ? pOwner->Owner : nullptr;
auto const pDecidedHouse = pHouse ? pHouse : pBulletExt->FirerHouse;
pWHExt->Detonate(pOwner, pDecidedHouse, pBulletExt, *pCoords);
pWHExt->InDamageArea = false;

DEFINE_HOOK(0x46A290, BulletClass_Detonate_Return, 0x5)
{
Detonation::InDamageArea = true;
return 0;
}

DEFINE_HOOK(0x489286, MapClass_DamageArea, 0x6)
{
if (Detonation::InDamageArea)
{
// GET(const int, Damage, EDX);
// GET_BASE(const bool, AffectsTiberium, 0x10);

GET_BASE(const WarheadTypeClass*, pWH, 0x0C);

if (auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWH))
{
GET(const CoordStruct*, pCoords, ECX);
GET_BASE(TechnoClass*, pOwner, 0x08);
GET_BASE(HouseClass*, pHouse, 0x14);
GET_BASE(const WarheadTypeClass*, pWH, 0x0C);
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWH);

auto const pDecidedHouse = !pHouse && pOwner ? pOwner->Owner : pHouse;
if (pWHExt->InDamageArea)
{
GET(const CoordStruct*, pCoords, ECX);
GET_BASE(TechnoClass*, pOwner, 0x08);
GET_BASE(HouseClass*, pHouse, 0x14);

pWHExt->Detonate(pOwner, pDecidedHouse, nullptr, *pCoords);
}
auto const pDecidedHouse = !pHouse && pOwner ? pOwner->Owner : pHouse;
pWHExt->Detonate(pOwner, pDecidedHouse, nullptr, *pCoords);
}

return 0;
Expand Down Expand Up @@ -268,4 +245,4 @@ DEFINE_HOOK(0x489B49, MapClass_DamageArea_Rocker, 0xA)
_asm fld rocker

return 0x489B53;
}
}

0 comments on commit 05aafd6

Please sign in to comment.