Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -603,6 +604,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->WarheadAnimZAdjust)
.Process(this->IvanBombAttachToCenter)
.Process(this->FallingDownTargetingFix)
.Process(this->AIAirTargetingFix)
;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class RulesExt
Valueable<bool> IvanBombAttachToCenter;

Valueable<bool> FallingDownTargetingFix;
Valueable<bool> AIAirTargetingFix;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
Expand Down Expand Up @@ -498,6 +499,7 @@ class RulesExt
, IvanBombAttachToCenter { false }

, FallingDownTargetingFix { false }
, AIAirTargetingFix { false }
{ }

virtual ~ExtData() = default;
Expand Down
39 changes: 34 additions & 5 deletions src/Misc/Hooks.BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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