Skip to content

Commit d693dcc

Browse files
committed
Fix ThreatPosed taking effect for uncaptured NeedsEngineer=true buildings
- Additionally separate the ThreatPosed getter logic from single TechnoClass function to Foot/Building ones taking advantage of it being a virtual
1 parent bb7d1dd commit d693dcc

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
341341
- Fixed the bug that vehicle survivor can spawn on wrong position when transport has been destroyed.
342342
- Fixed the bug that building with `Explodes=yes` use Ares's rubble logic will cause it's owner cannot defeat normally.
343343
- Fixed an issue that retaliation will make the unit keep switching among multiple targets with the same amount of threat.
344+
- Buildings with `NeedsEngineer=true` are now considered to have threat value of 0 under ownership of `MultiplayPassive=true` houses regardless of their `ThreatPosed` value.
344345

345346
## Newly added global settings
346347

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ Vanilla fixes:
600600
- Fixed the bug that cause technos teleport to cell 0,0 by ChronoSphere superweapon (by NetsuNegi)
601601
- Fixed the bug that techno in attack move will move to target if it cannot attack it (by NetsuNegi)
602602
- Fixed the bug in AI scripts 56 and 57 that forced the launch of superweapons with index numbers 3 and 4 (by FlyStar)
603+
- Buildings with `NeedsEngineer=true` are now considered to have threat value of 0 under ownership of `MultiplayPassive=true` houses regardless of their `ThreatPosed` value (by Starkku)
603604
604605
Phobos fixes:
605606
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)

src/Ext/Techno/Hooks.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,3 +1806,38 @@ DEFINE_HOOK(0x6F90DE, TechnoClass_GreatestThreat_MultiWeapon, 0x6)
18061806
}
18071807

18081808
#pragma endregion
1809+
1810+
#pragma region ThreatPosed
1811+
1812+
static int __fastcall FootClass_GetThreatValue_Wrapper(FootClass* pThis)
1813+
{
1814+
return pThis->GetTechnoType()->ThreatPosed;
1815+
}
1816+
1817+
static int __fastcall Building_GetThreatValue_Wrapper(BuildingClass* pThis)
1818+
{
1819+
int occupantCount = pThis->Occupants.Count;
1820+
1821+
if (occupantCount > 0)
1822+
return RulesClass::Instance->ThreatPerOccupant * occupantCount;
1823+
1824+
if (auto const pLinked = pThis->BunkerLinkedItem)
1825+
return pLinked->GetThreatValue();
1826+
1827+
auto const pType = pThis->Type;
1828+
1829+
// Set threat value of uncaptured tech buildings to 0.
1830+
if (pType->NeedsEngineer && pThis->Owner->Type->MultiplayPassive)
1831+
return 0;
1832+
1833+
return pType->ThreatPosed;
1834+
}
1835+
1836+
DEFINE_FUNCTION_JUMP(VTABLE, 0x7E2564, FootClass_GetThreatValue_Wrapper); // AircraftClass
1837+
DEFINE_FUNCTION_JUMP(VTABLE, 0x7E8F54, FootClass_GetThreatValue_Wrapper); // FootClass
1838+
DEFINE_FUNCTION_JUMP(VTABLE, 0x7EB318, FootClass_GetThreatValue_Wrapper); // InfantryClass
1839+
DEFINE_FUNCTION_JUMP(VTABLE, 0x7F4C20, FootClass_GetThreatValue_Wrapper); // TechnoClass
1840+
DEFINE_FUNCTION_JUMP(VTABLE, 0x7F5F30, FootClass_GetThreatValue_Wrapper); // UnitClass
1841+
DEFINE_FUNCTION_JUMP(VTABLE, 0x7E417C, Building_GetThreatValue_Wrapper); // BuildingClass
1842+
1843+
#pragma endregion

0 commit comments

Comments
 (0)