From be6cf731eacd4fd2d2259e5f93efa20e03c681a6 Mon Sep 17 00:00:00 2001 From: Fly-Star <100747645+a851903106@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:40:08 +0800 Subject: [PATCH 1/3] Update Hooks.BugFixes.cpp --- src/Misc/Hooks.BugFixes.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 35c0bd6f6e..deaedb5565 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -2698,4 +2698,19 @@ DEFINE_HOOK(0x5218C2, InfantryClass_UnmarkAllOccupationBits_ResetOwnerIdx, 0x6) return (newFlag & 0x1C) == 0 || pExt->InfantryCount == 0 ? Reset : NoReset; } -#pragma endregion \ No newline at end of file +#pragma endregion + +#pragma region CanAutoTargetFix + +DEFINE_JUMP(LJMP, 0x6F7D88, 0x6F7DA9) // They should be placed at the front. + +DEFINE_HOOK(0x6F7CB7, TechnoClass_CanAutoTargetObject_IsAlive, 0x7) +{ + enum { ReturnFalse = 0x6F894F }; + + GET(TechnoClass*, pTarget, ESI); + + return (!pTarget || !pTarget->IsAlive || pTarget->Health <= 0 || pTarget->InLimbo) ? ReturnFalse : 0; +} + +#pragma endregion From 754e444f92f68984b8afe5d793646db8d789cf4f Mon Sep 17 00:00:00 2001 From: Fly-Star <100747645+a851903106@users.noreply.github.com> Date: Sun, 12 Oct 2025 15:00:24 +0800 Subject: [PATCH 2/3] update doc --- CREDITS.md | 1 + docs/Fixed-or-Improved-Logics.md | 1 + docs/Whats-New.md | 1 + 3 files changed, 3 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index a89619a151..cf190a99d6 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -394,6 +394,7 @@ This page lists all the individual contributions to the project by their author. - Health bar permanently displayed - Unlimbo Detonate warhead - Fast access structure + - The target of death is excluded from automatic target selection - **NetsuNegi**: - Forbidding parallel AI queues by type - Jumpjet crash speed fix when crashing onto building diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 07396800dd..57c364bc5a 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -265,6 +265,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - Fixed an issue that the currently hovered planning node not update up-to-date, such as using hotkeys to select technos. - Fixed an issue that infantry walking through a cell containing a tree would cause it to be impassable to other houses. - Fixed the bug that techno unit will draw with ironcurtain and airstrike color and intensity who disguised as terrain or overlay. +- The target of death is excluded from automatic target selection. ## Fixes / interactions with other extensions diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 104bb1ede6..a45de87416 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -478,6 +478,7 @@ Vanilla fixes: - Fixed an issue that the jumpjet vehicles cannot stop correctly after going berserk (by TaranDahl) - Fixed an issue that infantry walking through a cell containing a tree would cause it to be impassable to other houses (by TaranDahl) - Fixed the bug that techno unit will draw with ironcurtain and airstrike color and intensity who disguised as terrain or overlay (by NetsuNegi) +- The target of death is excluded from automatic target selection (by FlyStar) Phobos fixes: - Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi) From a68268b605d12eb723650f582ef6528425898291 Mon Sep 17 00:00:00 2001 From: Fly-Star <100747645+a851903106@users.noreply.github.com> Date: Mon, 13 Oct 2025 15:41:39 +0800 Subject: [PATCH 3/3] Update Hooks.BugFixes.cpp --- src/Misc/Hooks.BugFixes.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index a3056c5f9c..00bb31526f 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2749,13 +2749,31 @@ DEFINE_HOOK(0x44242A, BuildingClass_ReceiveDamage_SetLATime, 0x8) DEFINE_JUMP(LJMP, 0x6F7D88, 0x6F7DA9) // They should be placed at the front. -DEFINE_HOOK(0x6F7CB7, TechnoClass_CanAutoTargetObject_IsAlive, 0x7) +DEFINE_HOOK_AGAIN(0x6F8B56, TechnoClass_CheckAutoTargetObject_OnMap, 0x5) // TechnoClass::TryAutoTargetObject +DEFINE_HOOK_AGAIN(0x6F9C89, TechnoClass_CheckAutoTargetObject_OnMap, 0x8) // TechnoClass::SelectAutoTargetObject_TechnoClass.Array +DEFINE_HOOK_AGAIN(0x6F9B9C, TechnoClass_CheckAutoTargetObject_OnMap, 0x8) // TechnoClass::SelectAutoTargetObject_AircraftClass.Array +DEFINE_HOOK(0x6F91F2, TechnoClass_CheckAutoTargetObject_OnMap, 0x9) // TechnoClass::SelectAutoTargetObject_AircraftTrackerClass { - enum { ReturnFalse = 0x6F894F }; + const DWORD address = R->Origin(); + TechnoClass* const pTarget = (address == 0x6F91F2 || address == 0x6F8B56) ? + R->EBP() : R->EDI(); - GET(TechnoClass*, pTarget, ESI); + if (!pTarget->IsAlive || pTarget->Health <= 0 || pTarget->InLimbo) + { + switch (address) + { + case 0x6F91F2: + return 0x6F9377; + case 0x6F9B9C: + return 0x6F9C48; + case 0x6F8B56: + return 0x6F8C07; + default: + return 0x6F9D93; + } + } - return (!pTarget || !pTarget->IsAlive || pTarget->Health <= 0 || pTarget->InLimbo) ? ReturnFalse : 0; + return 0; } #pragma endregion