Skip to content

Commit fc4a19a

Browse files
committed
Fix some issues with aircraft attacks
- Disable a check that forces aircraft to be removed from team if in air with no ammo, intended usage seems to be to fix problems caused by faulty scripting - Fix edge case issues with custom Units.RepairRate on docks - Fix edge case problem where aircraft can get stuck on sleep mission on dock if assigned a target f.ex via AI script
1 parent 1229205 commit fc4a19a

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/Ext/Aircraft/Hooks.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ DEFINE_HOOK(0x418CD1, AircraftClass_Mission_Attack_ContinueFlyToDestination, 0x6
692692
return Return;
693693
}
694694

695+
// 10.6.2025 - Starkku: This is a bandaid fix to AI scripting problem that causes more issues than it solves so I have disabled it.
696+
/*
695697
// Idle: clear the target if no ammo
696698
DEFINE_HOOK(0x414D4D, AircraftClass_Update_ClearTargetIfNoAmmo, 0x6)
697699
{
@@ -711,7 +713,7 @@ DEFINE_HOOK(0x414D4D, AircraftClass_Update_ClearTargetIfNoAmmo, 0x6)
711713
}
712714
713715
return 0;
714-
}
716+
}*/
715717

716718
// Stop: clear the mega mission and return to airbase immediately
717719
// (StopEventFix's DEFINE_HOOK(0x4C75DA, EventClass_RespondToEvent_Stop, 0x6) in Hooks.BugFixes.cpp)

src/Ext/Building/Hooks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ DEFINE_HOOK(0x44C836, BuildingClass_Mission_Repair_UnitReload, 0x6)
484484
{
485485
if (auto const pLink = pThis->GetNthLink(i))
486486
{
487-
if (!pLink->IsInAir() && pThis->SendCommand(RadioCommand::QueryMoving, pLink) == RadioCommand::AnswerPositive)
487+
if (!pLink->IsInAir() && pLink->Health < pLink->GetTechnoType()->Strength && pThis->SendCommand(RadioCommand::QueryMoving, pLink) == RadioCommand::AnswerPositive)
488488
pThis->SendCommand(RadioCommand::RequestRepair, pLink);
489489
}
490490
}
@@ -525,7 +525,7 @@ DEFINE_HOOK(0x44BD38, BuildingClass_Mission_Repair_UnitRepair, 0x6)
525525

526526
DEFINE_HOOK(0x6F4D1A, TechnoClass_ReceiveCommand_Repair, 0x5)
527527
{
528-
enum { AnswerNegative = 0x6F4CB4 };
528+
enum { SkipEffects = 0x6F4DE5 };
529529

530530
GET_STACK(TechnoClass*, pFrom, STACK_OFFSET(0x18, 0x4));
531531

@@ -536,7 +536,7 @@ DEFINE_HOOK(0x6F4D1A, TechnoClass_ReceiveCommand_Repair, 0x5)
536536
auto const pTypeExt = BuildingTypeExt::ExtMap.Find(pBuilding->Type);
537537

538538
if (pBuilding->Type->UnitReload && pTypeExt->Units_RepairRate.isset() && !UnitRepairTemp::SeparateRepair)
539-
return AnswerNegative;
539+
return SkipEffects;
540540

541541
repairStep = pTypeExt->Units_RepairStep.Get(repairStep);
542542
double repairPercent = pTypeExt->Units_RepairPercent.Get(RulesClass::Instance->RepairPercent);

src/Misc/Hooks.BugFixes.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,19 @@ DEFINE_HOOK(0x44985B, BuildingClass_Mission_Guard_UnitReload, 0x6)
10111011
return 0;
10121012
}
10131013

1014+
// Fix a potential edge case where aircraft gets stuck in 'sleep' (reload/repair) on dock if it gets assigned target from team mission etc.
1015+
DEFINE_HOOK(0x41915D, AircraftClass_ReceiveCommand_QueryPreparedness, 0x8)
1016+
{
1017+
enum { CheckAmmo = 0x419169 };
1018+
1019+
GET(AircraftClass*, pThis, ESI);
1020+
1021+
if (pThis->Team && pThis->Team->Focus == pThis->Target && pThis->CurrentMission == Mission::Sleep)
1022+
return CheckAmmo;
1023+
1024+
return 0;
1025+
}
1026+
10141027
// Fix tileset parsing to not reset certain tileset indices for Lunar theater if the fix is enabled.
10151028
DEFINE_HOOK(0x546C95, IsometricTileTypeClass_ReadINI_LunarFixes, 0x6)
10161029
{

0 commit comments

Comments
 (0)