diff --git a/CREDITS.md b/CREDITS.md index 37bdf49887..278e3e5d60 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -637,6 +637,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 7346ebfc94..e8caee5456 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -274,6 +274,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - 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. - Allow Reveal Crate to take effect when picking up by another player controlled house in campaign. +- 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 bcb528780e..c4831eee2f 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -494,6 +494,7 @@ Vanilla fixes: - 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) - Allow Reveal Crate to take effect when picking up by another player controlled house in campaign (by Trsdy) +- 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) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 3da69a8f32..b2a105fbca 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -330,6 +330,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->IvanBombAttachToCenter.Read(exINI, GameStrings::CombatDamage, "IvanBombAttachToCenter"); this->FallingDownTargetingFix.Read(exINI, GameStrings::General, "FallingDownTargetingFix"); + this->AIAirTargetingFix.Read(exINI, GameStrings::General, "AIAirTargetingFix"); // Section AITargetTypes int itemsCount = pINI->GetKeyCount("AITargetTypes"); @@ -603,6 +604,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->WarheadAnimZAdjust) .Process(this->IvanBombAttachToCenter) .Process(this->FallingDownTargetingFix) + .Process(this->AIAirTargetingFix) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 37bfd91c13..6ddc6ed06c 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -279,6 +279,7 @@ class RulesExt Valueable IvanBombAttachToCenter; Valueable FallingDownTargetingFix; + Valueable AIAirTargetingFix; ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } @@ -498,6 +499,7 @@ class RulesExt , IvanBombAttachToCenter { false } , FallingDownTargetingFix { false } + , AIAirTargetingFix { false } { } virtual ~ExtData() = default; diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index c084b80e70..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); @@ -2859,3 +2859,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(const 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