Skip to content

Commit 3d66793

Browse files
authored
[Customized] Aggressive attack move mission (#1473)
- `AttackMove.Aggressive` allows your technos to attack the enemy's unarmed buildings more aggressively when in attack move mission (Ctrl+Shift). Default to `[General]->AttackMove.Aggressive`. - `AttackMove.UpdateTarget` allows your technos to automatically change and select a higher threat target when in attack move mission (Ctrl+Shift). Also default to `[General]->AttackMove.UpdateTarget`. In `rulesmd.ini`: ```ini [General] AttackMove.Aggressive=false ; boolean AttackMove.UpdateTarget=false ; boolean [SOMETECHNO] AttackMove.Aggressive= ; boolean AttackMove.UpdateTarget= ; boolean ```
1 parent 6688c42 commit 3d66793

File tree

9 files changed

+114
-5
lines changed

9 files changed

+114
-5
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ This page lists all the individual contributions to the project by their author.
453453
- Jumpjet Tilts While Moving
454454
- Fix an issue that game crashes (EIP:7FB178) when infantry are about to enter an occupiable building that has been removed and is not real dead
455455
- Fix an issue that game crashes when spawnee has been removed and is not real dead
456+
- Aggressive attack move mission
456457
- **Ollerus**:
457458
- Build limit group enhancement
458459
- Customizable rocker amplitude

YRpp

docs/New-or-Enhanced-Logics.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ WarpOutWeapon= ; WeaponType
17241724

17251725
### Fast access vehicle
17261726

1727-
- Now you can let infantry or vehicle passengers quickly enter or leave the transport vehicles without queuing. Defaults to `[General] -> NoQueueUpToEnter` or `[General] -> NoQueueUpToUnload`.
1727+
- Now you can let infantry or vehicle passengers quickly enter or leave the transport vehicles without queuing.
17281728

17291729
In `rulesmd.ini`:
17301730
```ini
@@ -1733,8 +1733,24 @@ NoQueueUpToEnter=false ; boolean
17331733
NoQueueUpToUnload=false ; boolean
17341734

17351735
[SOMEVEHICLE] ; VehicleType
1736-
NoQueueUpToEnter= ; boolean
1737-
NoQueueUpToUnload= ; boolean
1736+
NoQueueUpToEnter= ; boolean, default to [General] -> NoQueueUpToEnter
1737+
NoQueueUpToUnload= ; boolean, default to [General] -> NoQueueUpToUnload
1738+
```
1739+
1740+
### Aggressive attack move mission
1741+
1742+
- `AttackMove.Aggressive` allows your technos to attack the enemy's unarmed buildings more aggressively when in attack move mission (Ctrl+Shift).
1743+
- `AttackMove.UpdateTarget` allows your technos to automatically change and select a higher threat target when in attack move mission (Ctrl+Shift).
1744+
1745+
In `rulesmd.ini`:
1746+
```ini
1747+
[General]
1748+
AttackMove.Aggressive=false ; boolean
1749+
AttackMove.UpdateTarget=false ; boolean
1750+
1751+
[SOMETECHNO]
1752+
AttackMove.Aggressive= ; boolean, default to [General] -> AttackMove.Aggressive
1753+
AttackMove.UpdateTarget= ; boolean, default to [General] -> AttackMove.UpdateTarget
17381754
```
17391755

17401756
## Terrain

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ New:
365365
- [Customize harvester dump amount](Fixed-or-Improved-Logics.md#customize-harvester-dump-amount) (by NetsuNegi)
366366
- Select box logic (by NetsuNegi)
367367
- Customize airstrike targets (by NetsuNegi)
368+
- Aggressive attack move mission (by CrimRecya)
368369
369370
Vanilla fixes:
370371
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Rules/Body.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
231231

232232
this->UseFixedVoxelLighting.Read(exINI, GameStrings::AudioVisual, "UseFixedVoxelLighting");
233233

234+
this->AttackMove_Aggressive.Read(exINI, GameStrings::General, "AttackMove.Aggressive");
235+
this->AttackMove_UpdateTarget.Read(exINI, GameStrings::General, "AttackMove.UpdateTarget");
236+
234237
this->MindControl_ThreatDelay.Read(exINI, GameStrings::General, "MindControl.ThreatDelay");
235238

236239
this->RecountBurst.Read(exINI, GameStrings::General, "RecountBurst");
@@ -454,6 +457,8 @@ void RulesExt::ExtData::Serialize(T& Stm)
454457
.Process(this->CombatAlert_UseAttackVoice)
455458
.Process(this->CombatAlert_UseEVA)
456459
.Process(this->UseFixedVoxelLighting)
460+
.Process(this->AttackMove_Aggressive)
461+
.Process(this->AttackMove_UpdateTarget)
457462
.Process(this->MindControl_ThreatDelay)
458463
.Process(this->RecountBurst)
459464
.Process(this->NoRearm_UnderEMP)

src/Ext/Rules/Body.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ class RulesExt
185185
// Nullable<Vector3D<float>> VoxelShadowLightSource;
186186
Valueable<bool> UseFixedVoxelLighting;
187187

188+
Valueable<bool> AttackMove_Aggressive;
189+
Valueable<bool> AttackMove_UpdateTarget;
190+
188191
Valueable<int> MindControl_ThreatDelay;
189192

190193
Valueable<bool> RecountBurst;
@@ -349,6 +352,8 @@ class RulesExt
349352
, CombatAlert_UseAttackVoice { true }
350353
, CombatAlert_UseEVA { true }
351354
, UseFixedVoxelLighting { false }
355+
, AttackMove_Aggressive { false }
356+
, AttackMove_UpdateTarget { false }
352357
, MindControl_ThreatDelay { 0 }
353358
, RecountBurst { false }
354359
, NoRearm_UnderEMP { false }

src/Ext/Techno/Hooks.TargetEvaluation.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,75 @@ DEFINE_FUNCTION_JUMP(CALL6, 0x6F8DD2, TechnoClass_EvaluateCellGetWeaponRangeWrap
147147

148148
#pragma endregion
149149

150+
#pragma region AggressiveAttackMove
151+
152+
static inline bool CheckAttackMoveCanResetTarget(FootClass* pThis)
153+
{
154+
const auto pTarget = pThis->Target;
155+
156+
if (!pTarget || pTarget == pThis->MegaTarget)
157+
return false;
158+
159+
const auto pTargetTechno = abstract_cast<TechnoClass*, true>(pTarget);
160+
161+
if (!pTargetTechno || pTargetTechno->IsArmed())
162+
return false;
163+
164+
if (pThis->TargetingTimer.InProgress())
165+
return false;
166+
167+
const auto pPrimaryWeapon = pThis->GetWeapon(0)->WeaponType;
168+
169+
if (!pPrimaryWeapon)
170+
return false;
171+
172+
const auto pNewTarget = abstract_cast<TechnoClass*>(pThis->GreatestThreat(ThreatType::Range, &pThis->Location, false));
173+
174+
if (!pNewTarget || pNewTarget->GetTechnoType() == pTargetTechno->GetTechnoType())
175+
return false;
176+
177+
const auto pSecondaryWeapon = pThis->GetWeapon(1)->WeaponType;
178+
179+
if (!pSecondaryWeapon || !pSecondaryWeapon->NeverUse) // Melee unit's virtual scanner
180+
return true;
181+
182+
return pSecondaryWeapon->Range <= pPrimaryWeapon->Range;
183+
}
184+
185+
DEFINE_HOOK(0x4DF3A0, FootClass_UpdateAttackMove_SelectNewTarget, 0x6)
186+
{
187+
GET(FootClass* const, pThis, ECX);
188+
189+
const auto pExt = TechnoExt::ExtMap.Find(pThis);
190+
191+
if (pExt->TypeExtData->AttackMove_UpdateTarget.Get(RulesExt::Global()->AttackMove_UpdateTarget) && CheckAttackMoveCanResetTarget(pThis))
192+
{
193+
pThis->Target = nullptr;
194+
pThis->HaveAttackMoveTarget = false;
195+
}
196+
197+
return 0;
198+
}
199+
200+
DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTargetObject_AggressiveAttackMove, 0x6)
201+
{
202+
enum { ContinueCheck = 0x6F85BA, CanTarget = 0x6F8604 };
203+
204+
GET(TechnoClass* const, pThis, EDI);
205+
206+
if (!pThis->Owner->IsControlledByHuman())
207+
return CanTarget;
208+
209+
if (!pThis->MegaMissionIsAttackMove())
210+
return ContinueCheck;
211+
212+
const auto pExt = TechnoExt::ExtMap.Find(pThis);
213+
214+
return pExt->TypeExtData->AttackMove_Aggressive.Get(RulesExt::Global()->AttackMove_Aggressive) ? CanTarget : ContinueCheck;
215+
}
216+
217+
#pragma endregion
218+
150219
#pragma region HealingWeapons
151220

152221
#pragma region TechnoClass_EvaluateObject

src/Ext/TechnoType/Body.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,9 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
501501
this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking");
502502
this->BunkerableAnyway.Read(exINI, pSection, "BunkerableAnyway");
503503

504+
this->AttackMove_Aggressive.Read(exINI, pSection, "AttackMove.Aggressive");
505+
this->AttackMove_UpdateTarget.Read(exINI, pSection, "AttackMove.UpdateTarget");
506+
504507
this->KeepTargetOnMove.Read(exINI, pSection, "KeepTargetOnMove");
505508
this->KeepTargetOnMove_NoMorePursuit.Read(exINI, pSection, "KeepTargetOnMove.NoMorePursuit");
506509
this->KeepTargetOnMove_ExtraDistance.Read(exINI, pSection, "KeepTargetOnMove.ExtraDistance");
@@ -963,6 +966,9 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
963966
.Process(this->Wake_Grapple)
964967
.Process(this->Wake_Sinking)
965968

969+
.Process(this->AttackMove_Aggressive)
970+
.Process(this->AttackMove_UpdateTarget)
971+
966972
.Process(this->BunkerableAnyway)
967973
.Process(this->KeepTargetOnMove)
968974
.Process(this->KeepTargetOnMove_NoMorePursuit)

src/Ext/TechnoType/Body.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ class TechnoTypeExt
276276
Nullable<AnimTypeClass*> Wake_Grapple;
277277
Nullable<AnimTypeClass*> Wake_Sinking;
278278

279+
Nullable<bool> AttackMove_Aggressive;
280+
Nullable<bool> AttackMove_UpdateTarget;
281+
279282
Valueable<bool> BunkerableAnyway;
280283
Valueable<bool> KeepTargetOnMove;
281284
Valueable<bool> KeepTargetOnMove_NoMorePursuit;
@@ -588,6 +591,9 @@ class TechnoTypeExt
588591
, Wake_Grapple { }
589592
, Wake_Sinking { }
590593

594+
, AttackMove_Aggressive {}
595+
, AttackMove_UpdateTarget {}
596+
591597
, BunkerableAnyway { false }
592598
, KeepTargetOnMove { false }
593599
, KeepTargetOnMove_NoMorePursuit { true }
@@ -597,7 +603,7 @@ class TechnoTypeExt
597603

598604
, AllowAirstrike { }
599605

600-
, Image_ConditionYellow { }
606+
, Image_ConditionYellow { }
601607
, Image_ConditionRed { }
602608
, WaterImage_ConditionYellow { }
603609
, WaterImage_ConditionRed { }

0 commit comments

Comments
 (0)