Skip to content

Commit 6f61cbf

Browse files
committed
Fix faulty math in fix for type conversion health ratio problem
1 parent 5438ff3 commit 6f61cbf

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Ext/Techno/Body.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,9 @@ bool TechnoExt::ConvertToType(FootClass* pThis, TechnoTypeClass* pToType)
308308

309309
if (AresFunctions::ConvertTypeTo(pThis, pToType))
310310
{
311-
if (pType->Strength == pToType->Strength)
312-
{
313-
// Fixed an issue where morphing could result in -1 health.
314-
pThis->Health = Math::max(1, oldHealth * pToType->Strength / pType->Strength);
315-
}
311+
// Fixed an issue where morphing could result in -1 health.
312+
double ratio = static_cast<double>(pToType->Strength) / pType->Strength;
313+
pThis->Health = static_cast<int>(oldHealth * ratio + 0.5);
316314

317315
auto const pTypeExt = TechnoExt::ExtMap.Find(static_cast<TechnoClass*>(pThis));
318316
pTypeExt->UpdateTypeData(pToType);

0 commit comments

Comments
 (0)