Skip to content

Commit a4a3eb1

Browse files
TaranDahlCoronia
andauthored
Auto deploy for GI-like infantry (#1802)
### Auto deploy for GI-like infantry - In RA2, the GI-like infantry controlled by the AI will automatically deploy to use their more powerful secondary weapons when engaging the enemy. This feature was broken in Yuri’s Revenge. Now you can use the following flags to re-enable this feature. In `rulesmd.ini`: ```ini [General] InfantryAutoDeploy=false ; boolean [SOMEINFANTRY] ; InfantryType InfantryAutoDeploy= ; boolean, default to [General] -> InfantryAutoDeploy ``` --------- Co-authored-by: Coronia <[email protected]>
1 parent c528a1a commit a4a3eb1

File tree

8 files changed

+39
-0
lines changed

8 files changed

+39
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ This page lists all the individual contributions to the project by their author.
588588
- Skip target scanning function calling for unarmed technos (code)
589589
- Force techno targeting in distributed frames to improve performance
590590
- Use `SkipCrushSlowdown=true` to avoid the bug related to `Accelerates=true` and `MovementZone=CrushAll`
591+
- Auto deploy for GI-like infantry
591592
- **solar-III (凤九歌)**
592593
- Target scanning delay customization (documentation)
593594
- Skip target scanning function calling for unarmed technos (documentation)

docs/Fixed-or-Improved-Logics.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,19 @@ BuildingWaypoints=false ; boolean
691691

692692
## Infantry
693693

694+
### Auto deploy for GI-like infantry
695+
696+
- In RA2, the GI-like infantry controlled by the AI will automatically deploy to use their more powerful secondary weapons when engaging the enemy. This feature was broken in Yuri’s Revenge. Now you can use the following flags to re-enable this feature.
697+
698+
In `rulesmd.ini`:
699+
```ini
700+
[General]
701+
InfantryAutoDeploy=false ; boolean
702+
703+
[SOMEINFANTRY] ; InfantryType
704+
InfantryAutoDeploy= ; boolean, default to [General] -> InfantryAutoDeploy
705+
```
706+
694707
### Prone speed customization
695708

696709
- In vanilla, infantry has hardcoded prone speed. Now you can customize it.

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ New:
427427
- Use `SkipCrushSlowdown=true` to avoid the bug related to `Accelerates=true` and `MovementZone=CrushAll` (by TaranDahl)
428428
- Units can customize the attack voice that plays when using more weapons (by FlyStar)
429429
- Customize squid grapple animation (by NetsuNegi)
430+
- Auto deploy for GI-like infantry (by TaranDahl)
430431
431432
Vanilla fixes:
432433
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Infantry/Hooks.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <InputManagerClass.h>
66
#include <WarheadTypeClass.h>
77

8+
#include <Ext/TechnoType/Body.h>
9+
810
DEFINE_HOOK(0x51B2BD, InfantryClass_UpdateTarget_IsControlledByHuman, 0x6)
911
{
1012
GET(InfantryClass*, pThis, ESI);
@@ -128,3 +130,11 @@ DEFINE_HOOK(0x7093F8, TechnoClass_709290_DeployWeapon, 0x5)
128130

129131
return ReturnTrue;
130132
}
133+
134+
// Skip incorrect retn to restore the auto deploy behavior of infantry
135+
DEFINE_HOOK(0x522373, InfantryClass_ApproachTarget_InfantryAutoDeploy, 0x5)
136+
{
137+
enum { Deploy = 0x522378 };
138+
GET(InfantryClass*, pThis, ESI);
139+
return TechnoTypeExt::ExtMap.Find(pThis->Type)->InfantryAutoDeploy.Get(RulesExt::Global()->InfantryAutoDeploy) ? Deploy : 0;
140+
}

src/Ext/Rules/Body.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
299299
this->DistributeTargetingFrame.Read(exINI, GameStrings::General, "DistributeTargetingFrame");
300300
this->DistributeTargetingFrame_AIOnly.Read(exINI, GameStrings::General, "DistributeTargetingFrame.AIOnly");
301301

302+
this->InfantryAutoDeploy.Read(exINI, GameStrings::General, "InfantryAutoDeploy");
303+
302304
// Section AITargetTypes
303305
int itemsCount = pINI->GetKeyCount("AITargetTypes");
304306
for (int i = 0; i < itemsCount; ++i)
@@ -551,6 +553,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
551553
.Process(this->AttackMove_IgnoreWeaponCheck)
552554
.Process(this->AttackMove_StopWhenTargetAcquired)
553555
.Process(this->Parasite_GrappleAnim)
556+
.Process(this->InfantryAutoDeploy)
554557
;
555558
}
556559

src/Ext/Rules/Body.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ class RulesExt
252252
int TintColorForceShield;
253253
int TintColorBerserk;
254254

255+
Valueable<bool> InfantryAutoDeploy;
256+
255257
ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
256258
, Storage_TiberiumIndex { -1 }
257259
, HarvesterDumpAmount { 0.0f }
@@ -447,6 +449,7 @@ class RulesExt
447449
, AttackMove_StopWhenTargetAcquired { }
448450

449451
, Parasite_GrappleAnim {}
452+
, InfantryAutoDeploy { false }
450453
{ }
451454

452455
virtual ~ExtData() = default;

src/Ext/TechnoType/Body.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
955955
this->AttackMove_StopWhenTargetAcquired.Read(exINI, pSection, "AttackMove.StopWhenTargetAcquired");
956956
this->AttackMove_PursuitTarget.Read(exINI, pSection, "AttackMove.PursuitTarget");
957957

958+
this->InfantryAutoDeploy.Read(exINI, pSection, "InfantryAutoDeploy");
959+
958960
// Ares 0.2
959961
this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius");
960962

@@ -1587,6 +1589,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
15871589
.Process(this->VoiceIFVRepair)
15881590
.Process(this->VoiceWeaponAttacks)
15891591
.Process(this->VoiceEliteWeaponAttacks)
1592+
1593+
.Process(this->InfantryAutoDeploy)
15901594
;
15911595
}
15921596
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)

src/Ext/TechnoType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ class TechnoTypeExt
416416
ValueableVector<int> VoiceWeaponAttacks;
417417
ValueableVector<int> VoiceEliteWeaponAttacks;
418418

419+
Nullable<bool> InfantryAutoDeploy;
420+
419421
ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
420422
, HealthBar_Hide { false }
421423
, UIDescription {}
@@ -781,6 +783,8 @@ class TechnoTypeExt
781783
, VoiceIFVRepair { -1 }
782784
, VoiceWeaponAttacks {}
783785
, VoiceEliteWeaponAttacks {}
786+
787+
, InfantryAutoDeploy {}
784788
{ }
785789

786790
virtual ~ExtData() = default;

0 commit comments

Comments
 (0)