Skip to content

Commit 31aba26

Browse files
committed
Fix handling of Area Guard mission for Speed=0 vehicles
- Separate the handling from Hunt, do not reassign to Guard and reimplement only the target acquisition from original Area Guard handling
1 parent d3863ea commit 31aba26

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

YRpp

Submodule YRpp updated 1 file

src/Ext/Unit/Hooks.DisallowMoving.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ DEFINE_HOOK(0x73891D, UnitClass_Active_Click_With_DisallowMoving, 0x6)
8282
return TechnoExt::CannotMove(pThis) ? 0x738927 : 0;
8383
}
8484

85-
DEFINE_HOOK_AGAIN(0x744103, UnitClass_Mission_DisallowMoving, 0x6) // UnitClass::Mission_AreaGuard
86-
DEFINE_HOOK(0x73EFC4, UnitClass_Mission_DisallowMoving, 0x6) // UnitClass::Mission_Hunt
85+
DEFINE_HOOK(0x73EFC4, UnitClass_Mission_Hunt_DisallowMoving, 0x6)
8786
{
8887
GET(UnitClass*, pThis, ESI);
8988

@@ -93,7 +92,34 @@ DEFINE_HOOK(0x73EFC4, UnitClass_Mission_DisallowMoving, 0x6) // UnitClass::Miss
9392
pThis->NextMission();
9493

9594
R->EAX(pThis->Mission_Guard());
96-
return R->Origin() == 0x744103 ? 0x744173 : 0x73F091;
95+
return 0x73F091;
96+
}
97+
98+
return 0;
99+
}
100+
101+
// 3 Sep, 2025 - Starkku: Separated from above, do not change to guard mission
102+
// and only handle the target acquisition part of area guard for immobile units.
103+
DEFINE_HOOK(0x744103, UnitClass_Mission_AreaGuard_DisallowMoving, 0x6)
104+
{
105+
GET(UnitClass*, pThis, ESI);
106+
107+
if (TechnoExt::CannotMove(pThis))
108+
{
109+
if (pThis->CanPassiveAcquireTargets() && pThis->TargetingTimer.Completed())
110+
pThis->TargetAndEstimateDamage(pThis->Location, ThreatType::Area);
111+
112+
int delay = 1;
113+
114+
if (!pThis->Target)
115+
{
116+
pThis->UpdateIdleAction();
117+
auto const control = &MissionControlClass::Array[(int)Mission::Area_Guard];
118+
delay = static_cast<int>(control->Rate * 900) + ScenarioClass::Instance->Random(1, 5);
119+
}
120+
121+
R->EAX(delay);
122+
return 0x744173;
97123
}
98124

99125
return 0;

0 commit comments

Comments
 (0)