Skip to content

Commit

Permalink
Fix powered anims during capture
Browse files Browse the repository at this point in the history
  • Loading branch information
chaserli committed Dec 24, 2023
1 parent db8ef2c commit aa899e2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Setting `ReloadInTransport` to true on units with `Ammo` will allow the ammo to be reloaded according to `Reload` or `EmptyReload` timers even while the unit is inside a transport.
- It is now possible to enable `Verses` and `PercentAtMax` to be applied on negative damage by setting `ApplyModifiersOnNegativeDamage` to true on the Warhead.
- Attached animations on flying units now have their layer updated immediately after the parent unit, if on same layer they always draw above the parent.

- Fixed the issue where the powered anims of `Powered`/`PoweredSpecial` buildings cease to update when being captured by enemies.
## Fixes / interactions with other extensions

- All forms of type conversion (including Ares') now correctly update `OpenTopped` state of passengers in transport that is converted.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ Vanilla fixes:
- `EMPulseCannon=yes` building weapons now respect `Floater` and Phobos-added `Gravity` setting (by Starkku)
- Fixed position and layer of info tip and reveal production cameo on selected building (by Belonit)
- Fixed `TurretOffset` to be supported for SHP vehicles (by TwinkleStar)
- `Powered`/`PoweredSpecial` buildings' powered anims will update as usual when being captured by enemies (by Trsdy)
Phobos fixes:
- Fixed a few errors of calling for superweapon launch by `LaunchSW` or building infiltration (by Trsdy)
Expand Down
10 changes: 0 additions & 10 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ DEFINE_HOOK(0x4DBF13, FootClass_SetOwningHouse, 0x6)
return 0;
}

DEFINE_HOOK(0x4483C0, BuildingClass_SetOwningHouse_MuteSound, 0x6)
{
GET(BuildingClass* const, pThis, ESI);
REF_STACK(bool, announce, STACK_OFFSET(0x60, 0x8));

announce = announce && !pThis->Type->IsVehicle();

return 0;
}

DEFINE_HOOK_AGAIN(0x7355C0, TechnoClass_Init_InitialStrength, 0x6) // UnitClass_Init
DEFINE_HOOK_AGAIN(0x517D69, TechnoClass_Init_InitialStrength, 0x6) // InfantryClass_Init
DEFINE_HOOK_AGAIN(0x442C7B, TechnoClass_Init_InitialStrength, 0x6) // BuildingClass_Init
Expand Down
31 changes: 31 additions & 0 deletions src/Misc/Hooks.BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,34 @@ DEFINE_HOOK(0x6D9781, Tactical_RenderLayers_DrawInfoTipAndSpiedSelection, 0x5)
return 0;
}
#pragma endregion DrawInfoTipAndSpiedSelection


bool __fastcall BuildingClass_SetOwningHouse_Wrapper(BuildingClass* pThis, void*, HouseClass* pHouse, bool announce)
{
// Fix : Suppress capture EVA event if ConsideredVehicle=no
announce = announce && !pThis->Type->IsVehicle();

using this_func_sig = bool(__thiscall*)(BuildingClass*, HouseClass*, bool);
bool res = reinterpret_cast<this_func_sig>(0x448260)(pThis, pHouse, announce);

// Fix : update powered anims
if (res && (pThis->Type->Powered || pThis->Type->PoweredSpecial))
reinterpret_cast<void(__thiscall*)(BuildingClass*)>(0x4549B0)(pThis);
return res;
}

DEFINE_JUMP(VTABLE, 0x7E4290, GET_OFFSET(BuildingClass_SetOwningHouse_Wrapper));

DEFINE_HOOK(0x6E0BB4, TActionClass_36_Rewrite, 0x6)
{
GET(HouseClass*, pDecided, EBP);
GET_STACK(HouseClass*, pHouse, STACK_OFFSET(0x10, 0x4));
bool res = false;
for (auto* pTechno : *TechnoClass::Array)
{
if (pTechno->Owner == pHouse)
res = res || pTechno->SetOwningHouse(pDecided, false);
}
R->BL(res);
return 0x6E0C8B;
}

0 comments on commit aa899e2

Please sign in to comment.