From 5243923a2c8695f2b68900887ea67f94af491f8a Mon Sep 17 00:00:00 2001 From: Trsdy <914137150@qq.com> Date: Fri, 12 Jan 2024 22:25:58 +0800 Subject: [PATCH] Skip turret rotation and jumpjet wobbling under EMP --- CREDITS.md | 3 ++- docs/Fixed-or-Improved-Logics.md | 2 ++ docs/Whats-New.md | 1 + src/Ext/Unit/Hooks.Jumpjet.cpp | 24 +++++++++++++++++++++++- src/Misc/Hooks.BugFixes.cpp | 2 +- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index 7c08404c9c..9912883945 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -281,7 +281,8 @@ This page lists all the individual contributions to the project by their author. - Permanent healthbar display on units targeted by temporal weapons fix - Powered anims on buildings cease playing upon capture by different house fix - TechnoType conversion placeholder - - EIP 00529A14 crash fix on Linux + - EIP 00529A14 crash fix on Linux + - Skip units' turret rotation and jumpjets' wobbling under EMP - Misc code refactor & maintenance, CN doc fixes, bugfixes - **FlyStar** - Campaign load screen PCX support diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 204a43d092..88a0aef080 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -141,6 +141,8 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - Fixed the issue where the powered anims of `Powered`/`PoweredSpecial` buildings cease to update when being captured by enemies. - Fix a glitch related to incorrect target setting for missiles. - Fix [EIP 00529A14](https://modenc.renegadeprojects.com/Internal_Error/YR#eip_00529A14) when attempting to read `[Header]` section of campaign maps. +- Units will no longer rotate its turret under EMP. +- Jumpjets will no longer wobble under EMP. ## Fixes / interactions with other extensions diff --git a/docs/Whats-New.md b/docs/Whats-New.md index b330559e64..8f24cb4bdc 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -398,6 +398,7 @@ Vanilla fixes: - `Powered`/`PoweredSpecial` buildings' powered anims will update as usual when being captured by enemies (by Trsdy) - Fixed a glitch related to incorrect target setting for missiles (by Belonit) - Skipped parsing `[Header]` section of compaign maps which led to occasional crashes on Linux (by Trsdy) +- Fixed units' turret rotation and jumpjet wobble under EMP (by Trsdy) Phobos fixes: - Fixed a few errors of calling for superweapon launch by `LaunchSW` or building infiltration (by Trsdy) diff --git a/src/Ext/Unit/Hooks.Jumpjet.cpp b/src/Ext/Unit/Hooks.Jumpjet.cpp index 17c0f2d962..5cba39018a 100644 --- a/src/Ext/Unit/Hooks.Jumpjet.cpp +++ b/src/Ext/Unit/Hooks.Jumpjet.cpp @@ -78,8 +78,30 @@ DEFINE_HOOK(0x736EE9, UnitClass_UpdateFiring_FireErrorIsOK, 0x6) return 0; } +DEFINE_HOOK(0x54D208, JumpjetLocomotionClass_ProcessMove_EMPWobble, 0x5) +{ + GET(JumpjetLocomotionClass* const, pThis, ESI); + enum { ZeroWobble = 0x54D22C }; + + if (pThis->LinkedTo->IsUnderEMP()) + return ZeroWobble; + + return 0; +} + +DEFINE_HOOK(0x736990, UnitClass_UpdateRotation_TurretFacing_EMP, 0x6) +{ + GET(UnitClass* const, pThis, ECX); + enum { SkipAll = 0x736C0E }; + + if (pThis->Deactivated || pThis->IsUnderEMP()) + return SkipAll; + + return 0; +} + // Bugfix: Align jumpjet turret's facing with body's -DEFINE_HOOK(0x736BA3, UnitClass_UpdateRotation_TurretFacing_TemporaryFix, 0x6) +DEFINE_HOOK(0x736BA3, UnitClass_UpdateRotation_TurretFacing_Jumpjet, 0x6) { GET(UnitClass* const, pThis, ESI); enum { SkipCheckDestination = 0x736BCA, GetDirectionTowardsDestination = 0x736BBB }; diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 6be74f1a29..56297c7eb3 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -783,7 +783,7 @@ DEFINE_HOOK(0x6D9781, Tactical_RenderLayers_DrawInfoTipAndSpiedSelection, 0x5) bool __fastcall BuildingClass_SetOwningHouse_Wrapper(BuildingClass* pThis, void*, HouseClass* pHouse, bool announce) { - // Fix : Suppress capture EVA event if ConsideredVehicle=no + // Fix : Suppress capture EVA event if ConsideredVehicle=yes announce = announce && !pThis->Type->IsVehicle(); using this_func_sig = bool(__thiscall*)(BuildingClass*, HouseClass*, bool);