From d27eaf5f2810e21d4a14398febe16a7b0c8faa34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Wed, 12 Nov 2025 14:38:24 +0800 Subject: [PATCH 1/4] code --- src/Ext/Rules/Body.cpp | 3 +++ src/Ext/Rules/Body.h | 4 ++++ src/Misc/Hooks.BugFixes.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index e1673b2efe..438ee2d0b1 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -329,6 +329,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->IvanBombAttachToCenter.Read(exINI, GameStrings::CombatDamage, "IvanBombAttachToCenter"); + this->AIAirTargetingFix.Read(exINI, GameStrings::General, "AIAirTargetingFix"); + // Section AITargetTypes int itemsCount = pINI->GetKeyCount("AITargetTypes"); for (int i = 0; i < itemsCount; ++i) @@ -600,6 +602,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->AdjacentWallDamage) .Process(this->WarheadAnimZAdjust) .Process(this->IvanBombAttachToCenter) + .Process(this->AIAirTargetingFix) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 07fe5f2036..6bb312e1db 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -277,6 +277,8 @@ class RulesExt Valueable WarheadAnimZAdjust; Valueable IvanBombAttachToCenter; + + Valueable AIAirTargetingFix; ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } @@ -494,6 +496,8 @@ class RulesExt , WarheadAnimZAdjust { -15 } , IvanBombAttachToCenter { false } + + , AIAirTargetingFix { false } { } virtual ~ExtData() = default; diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 453172be8c..08691af5e2 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2861,3 +2861,32 @@ DEFINE_HOOK(0x70D4FD, AbstractClass_ClearTargetToMe_ClearLastTarget, 0x6) } #pragma endregion + +#pragma region AIAirTargetingFix + +DEFINE_HOOK(0x6F9B7E, TechnoClass_SelectAutoTarget_AIAirTargetingFix1, 0x5) +{ + return RulesExt::Global()->AIAirTargetingFix ? 0x6F9C56 : 0; +} + +DEFINE_HOOK(0x6F9D13, TechnoClass_SelectAutoTarget_AIAirTargetingFix2, 0x7) +{ + enum { Ok = 0x6F9D1C, NotOK = 0x6F9D93 }; + + if (!RulesExt::Global()->AIAirTargetingFix) + return 0; + + GET_STACK(int, canTargetRtti, STACK_OFFSET(0x6C, -0x58)); + GET(TechnoClass*, pTarget, EDI); + + bool canTarget = false; + + if ((canTargetRtti & 4) != 0) + canTarget = pTarget->LastLayer != Layer::Underground; + else + canTarget = pTarget->LastLayer == Layer::Ground; + + return canTarget ? Ok : NotOK; +} + +#pragma endregion From 9740c51c429c9be2aa8bed111fef0904398edac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Wed, 12 Nov 2025 14:53:10 +0800 Subject: [PATCH 2/4] docs --- 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 461045a7ad..ab27138204 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -636,6 +636,7 @@ This page lists all the individual contributions to the project by their author. - Fix an issue that the techno with weapon with `AA=yes` and `AG=no` would not auto targeting units that are falling, such as paratroopers - Dehardcode the `ZAdjust` of warhead anim - Fix an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner + - Fix an issue where the vanilla script ignores jumpjets. - **solar-III (凤九歌)** - Target scanning delay customization (documentation) - Skip target scanning function calling for unarmed technos (documentation) diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 8a68d1c1b9..95cda40b1b 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -273,6 +273,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - Fixed buildings that have their owner changed during buildup skipping buildup and sometimes not correctly clearing the state. - Fixed `MovementZone=Subterannean` harvesters being unable to find docks if in area enclosed by water, cliffs etc. - Fixed an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner. +- Fixed an issue where the vanilla script ignores jumpjets. Enable it through `[General] -> AIAirTargetingFix=true`. ## Fixes / interactions with other extensions diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 79505991d9..13b8384602 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -492,6 +492,7 @@ Vanilla fixes: - Fixed buildings that have their owner changed during buildup skipping buildup and sometimes not correctly clearing the state (by Starkku) - Fixed `MovementZone=Subterannean` harvesters being unable to find docks if in area enclosed by water, cliffs etc. (by Starkku) - Fixed an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner (by TaranDahl) +- Fixed an issue where the vanilla script ignores jumpjets. (by TaranDahl) Phobos fixes: - Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi) From 52d97b2a3770b4533cf1208dfc943eaaa648aa7b Mon Sep 17 00:00:00 2001 From: Coronia <2217891145@qq.com> Date: Fri, 14 Nov 2025 10:24:30 +0800 Subject: [PATCH 3/4] fix merging error --- src/Ext/Rules/Body.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index aac86da355..b2a105fbca 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -604,7 +604,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->WarheadAnimZAdjust) .Process(this->IvanBombAttachToCenter) .Process(this->FallingDownTargetingFix) - .Process(this->FallingDownTargetingFix) + .Process(this->AIAirTargetingFix) ; } From b7814ba4d001930e23dd6e01b1d2f26e42a73f2d Mon Sep 17 00:00:00 2001 From: Coronia <2217891145@qq.com> Date: Fri, 14 Nov 2025 10:27:32 +0800 Subject: [PATCH 4/4] codestyle --- src/Misc/Hooks.BugFixes.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index cb9a69a83b..2bdb8d21c3 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2494,18 +2494,18 @@ DEFINE_HOOK(0x700536, TechnoClass_WhatAction_Object_AllowAttack, 0x6) { enum { CanAttack = 0x70055D, Continue = 0x700548 }; - GET_STACK(bool, canEnter, STACK_OFFSET(0x1C, 0x4)); - GET_STACK(bool, ignoreForce, STACK_OFFSET(0x1C, 0x8)); + GET_STACK(const bool, canEnter, STACK_OFFSET(0x1C, 0x4)); + GET_STACK(const bool, ignoreForce, STACK_OFFSET(0x1C, 0x8)); if (canEnter || ignoreForce) return CanAttack; GET(TechnoClass*, pThis, ESI); GET(ObjectClass*, pObject, EDI); - GET_STACK(int, WeaponIndex, STACK_OFFSET(0x1C, -0x8)); + GET_STACK(const int, weaponIndex, STACK_OFFSET(0x1C, -0x8)); WhatActionObjectTemp::Skip = true; - R->EAX(pThis->GetFireError(pObject, WeaponIndex, true)); + R->EAX(pThis->GetFireError(pObject, weaponIndex, true)); WhatActionObjectTemp::Skip = false; return Continue; @@ -2693,7 +2693,7 @@ DEFINE_HOOK(0x5218C2, InfantryClass_UnmarkAllOccupationBits_ResetOwnerIdx, 0x6) enum { Reset = 0x5218CC, NoReset = 0x5218D3 }; GET(CellClass*, pCell, ESI); - GET(DWORD, newFlag, ECX); + GET(const DWORD, newFlag, ECX); pCell->OccupationFlags = newFlag; auto pExt = CellExt::ExtMap.Find(pCell); @@ -2874,7 +2874,7 @@ DEFINE_HOOK(0x6F9D13, TechnoClass_SelectAutoTarget_AIAirTargetingFix2, 0x7) if (!RulesExt::Global()->AIAirTargetingFix) return 0; - GET_STACK(int, canTargetRtti, STACK_OFFSET(0x6C, -0x58)); + GET_STACK(const int, canTargetRtti, STACK_OFFSET(0x6C, -0x58)); GET(TechnoClass*, pTarget, EDI); bool canTarget = false;