Skip to content

Commit

Permalink
Fixed big mistake
Browse files Browse the repository at this point in the history
- I used a wrong function for cheking the damage value xD
- Small changes so now it doesn't skip code in ReceiveDamage hook.
  • Loading branch information
FS-21 committed Feb 6, 2025
1 parent b87371e commit 4f73031
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Ext/RadSite/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ bool RadSiteExt::ExtData::ApplyRadiationDamage(TechnoClass* pTarget, int& damage
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWarhead);

// Check if the WH should affect the techno target or skip it
double versus = MapClass::GetTotalDamage(damage, pWarhead, pTarget->GetTechnoType()->Armor, 0);
int nDamageTotal = static_cast<int>(damage * versus);
int nDamageTotal = MapClass::GetTotalDamage(damage, pWarhead, pTarget->GetTechnoType()->Armor, 0);

if (pTarget->Health > 0 && !pWHExt->CanKill && nDamageTotal >= pTarget->Health)
{
damage = 0;
pTarget->Health = 1;
pTarget->EstimatedHealth = 1;

Expand Down
11 changes: 4 additions & 7 deletions src/Ext/Techno/Hooks.ReceiveDamage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
const auto pExt = TechnoExt::ExtMap.Find(pThis);

int nDamageLeft = *args->Damage;
double versus = MapClass::GetTotalDamage(nDamageLeft, args->WH, pThis->GetTechnoType()->Armor, 0);
int nDamageTotal = static_cast<int>(nDamageLeft * versus);
int nDamageTotal = MapClass::GetTotalDamage(nDamageLeft, args->WH, pThis->GetTechnoType()->Armor, 0);
auto const pWHExt = WarheadTypeExt::ExtMap.Find(args->WH);

if (!args->IgnoreDefenses)
Expand All @@ -36,8 +35,7 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
*args->Damage = 0;
pThis->Health = 1;
pThis->EstimatedHealth = 1;

return SkipGameCode;
ReceiveDamageTemp::SkipLowDamageCheck = true;
}

return 0;
Expand All @@ -59,15 +57,14 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
}

// Update remaining damage and check if the target will die and should be avoided
nDamageTotal = static_cast<int>(nDamageLeft * versus);
nDamageTotal = MapClass::GetTotalDamage(nDamageLeft, args->WH, pThis->GetTechnoType()->Armor, 0);

if (pThis->Health > 0 && !pWHExt->CanKill && nDamageTotal >= pThis->Health)
{
*args->Damage = 0;
pThis->Health = 1;
pThis->EstimatedHealth = 1;

return SkipGameCode;
ReceiveDamageTemp::SkipLowDamageCheck = true;
}

return 0;
Expand Down

0 comments on commit 4f73031

Please sign in to comment.