Skip to content

Commit 7679315

Browse files
authored
[Minor] Speed=0 extension 2 (#1818)
Team attack scripts no longer affect vehicles that cannot move and are beyond weapon range. - 作战小队攻击脚本不再对无法移动且超出武器射程的载具生效。
1 parent 6a9fb6b commit 7679315

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/Ext/Script/Mission.Attack.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, int calcThreatMode, bool repeat
233233

234234
const auto whatAmI = pFoot->WhatAmI();
235235

236+
// If the vehicle cannot be moved, perhaps it is better this way.
237+
if (whatAmI == AbstractType::Unit
238+
&& TechnoExt::CannotMove(static_cast<UnitClass*>(pFoot))
239+
&& !pFoot->IsCloseEnough(pSelectedTarget, pFoot->SelectWeapon(pSelectedTarget)))
240+
{
241+
continue;
242+
}
243+
236244
// Aircraft hack. I hate how this game auto-manages the aircraft missions.
237245
if (whatAmI == AbstractType::Aircraft
238246
&& pFoot->Ammo > 0

src/Ext/Unit/Hooks.DisallowMoving.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,40 @@ DEFINE_HOOK(0x7415A9, UnitClass_ApproachTarget_SetWeaponIndex, 0x6)
152152

153153
return 0;
154154
}
155+
156+
DEFINE_HOOK(0x6F7CE2, TechnoClass_CanAutoTargetObject_DisallowMoving, 0x6)
157+
{
158+
GET(TechnoClass* const, pThis, EDI);
159+
GET(AbstractClass* const, pTarget, ESI);
160+
GET(const int, weaponIndex, EBX);
161+
162+
if (const auto pUnit = abstract_cast<UnitClass*, true>(pThis))
163+
{
164+
if (TechnoExt::CannotMove(pUnit))
165+
{
166+
R->EAX(pUnit->GetFireError(pTarget, weaponIndex, true));
167+
return 0x6F7CEE;
168+
}
169+
}
170+
171+
return 0;
172+
}
173+
174+
DEFINE_HOOK(0x7088E3, TechnoClass_ShouldRetaliate_DisallowMoving, 0x6)
175+
{
176+
GET(TechnoClass* const, pThis, EDI);
177+
GET(AbstractClass* const, pTarget, EBP);
178+
GET(const int, weaponIndex, EBX);
179+
180+
if (const auto pUnit = abstract_cast<UnitClass*, true>(pThis))
181+
{
182+
if (TechnoExt::CannotMove(pUnit))
183+
{
184+
R->Stack(STACK_OFFSET(0x18, 0x4), weaponIndex);
185+
R->EAX(pUnit->GetFireError(pTarget, weaponIndex, true));
186+
return 0x7088F3;
187+
}
188+
}
189+
190+
return 0;
191+
}

0 commit comments

Comments
 (0)