Skip to content

Commit

Permalink
Rewritten and fixed a hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Metadorius committed Nov 8, 2021
1 parent 5d14698 commit fa97a03
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/Ext/Techno/Hooks.Shield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,6 @@ DEFINE_HOOK(0x6F9E50, TechnoClass_AI_Shield, 0x5)
return 0;
}

// Ares-hook jmp to this offset
DEFINE_HOOK(0x71A88D, TemporalClass_AI_Shield, 0x0)
{
GET(TemporalClass*, pThis, ESI);
if (auto const pTarget = pThis->Target)
{
const auto pExt = TechnoExt::ExtMap.Find(pTarget);
if (const auto pShieldData = pExt->Shield.get())
{
if (pShieldData->IsAvailable())
pShieldData->AI_Temporal();
}
}

// Recovering vanilla instructions that were broken by a hook call
return R->EAX<int>() <= 0 ? 0x71A895 : 0x71AB08;
}

DEFINE_HOOK(0x6F6AC4, TechnoClass_Remove_Shield, 0x5)
{
GET(TechnoClass*, pThis, ECX);
Expand Down
23 changes: 23 additions & 0 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,27 @@ DEFINE_HOOK(0x518505, InfantryClass_TakeDamage_NotHuman, 0x4)
pThis->PlayAnim(static_cast<Sequence>(resultSequence), true);

return 0x518515;
}

// Ares-hook jmp to this offset
DEFINE_HOOK(0x71A88D, TemporalClass_AI_Shield, 0x0)
{
GET(TemporalClass*, pThis, ESI);

// Shield logic
if (auto const pTarget = pThis->Target)
{
const auto pExt = TechnoExt::ExtMap.Find(pTarget);
if (const auto pShieldData = pExt->Shield.get())
{
if (pShieldData->IsAvailable())
pShieldData->AI_Temporal();
}
}

// Techno attachment logic
TechnoExt::AttachmentAI(pThis->Target);

// Recovering vanilla instructions that were broken by a hook call
return R->EAX<int>() <= 0 ? 0x71A895 : 0x71AB08;
}

0 comments on commit fa97a03

Please sign in to comment.