Skip to content

Commit b81a1dd

Browse files
[Retry] Allow infantry to perform type conversion when deploying and undeploying (#2250)
Reimplement #2239. - Used a more performant method - The execution timing of convert was changed from the start of Sequence to after its end <img width="348" height="167" alt="Retry Convert (Un)deploy" src="https://github.com/user-attachments/assets/35ed047d-abf8-4ab3-b1d3-4f313f740929" /> *E1↔GGI, YURI↔YURIPR, E2↔BORIS*
1 parent 9a47f00 commit b81a1dd

8 files changed

Lines changed: 75 additions & 0 deletions

File tree

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ This page lists all the individual contributions to the project by their author.
686686
- Customize `Tiled` drawing interval and centering
687687
- Customize whether technos with `Locomotor=Fly` wobble
688688
- Customize the landing animation of technos that have `Locomotor=Fly`
689+
- Allow infantry to use `Convert.Deploy` without requiring `IsSimpleDeployer=true`
689690
- **Ollerus**:
690691
- Build limit group enhancement
691692
- Customizable rocker amplitude

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
376376
- `EVA.Tag` already supports being set for specific countries, and `EVAIndex` is no longer reset after load game.
377377
- `DisableWeapons.Duration` now makes `Gattling=yes` rate tick down and stops the sounds from playing, no longer interferes with target acquisition and works together with Phobos' `OpenTopped.CheckTransportDisableWeapons`.
378378
- Allowed Ares' `SW.AuxBuildings` and `SW.NegBuildings` to count building upgrades.
379+
- Allowed infantry to use `Convert.Deploy` without requiring `IsSimpleDeployer=true`.
379380

380381
## Newly added global settings
381382

docs/New-or-Enhanced-Logics.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,17 @@ SpyEffect.InfiltratorSuperWeapon= ; SuperWeaponType
701701

702702
## Infantry
703703

704+
### Allow infantry to perform type conversion when deploying and undeploying
705+
706+
- Now infantry can perform type conversion immediately after the `Deploy` or `Undeploy` sequence action has been executed.
707+
708+
In `rulesmd.ini`:
709+
```ini
710+
[SOMEINFANTRY] ; InfantryType
711+
Convert.Deploy= ; InfantryType
712+
Convert.Undeploy= ; InfantryType
713+
```
714+
704715
### Customizable FLH when infantry is prone or deployed
705716

706717
- Now infantry can override `PrimaryFireFLH` and `SecondaryFireFLH` if is prone (crawling) or deployed. Also works in conjunction with [burst-index specific firing offsets](#firing-offsets-for-specific-burst-shots).

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ HideShakeEffects=false ; boolean
593593
- [Customize `Tiled` drawing interval and centering](Fixed-or-Improved-Logics.md#customize-tiled-drawing-interval-and-centering) (by Noble_Fish)
594594
- [Customize whether technos with `Locomotor=Fly` wobble](Fixed-or-Improved-Logics.md#customize-whether-technos-with-locomotor-fly-wobble) (by Noble_Fish)
595595
- [Customize the landing animation of technos that have `Locomotor=Fly`](Fixed-or-Improved-Logics.md#customize-the-landing-animation-of-technos-that-have-locomotor-fly) (by Noble_Fish)
596+
- [Allow infantry to perform type conversion when deploying and undeploying](New-or-Enhanced-Logics.md#allow-infantry-to-perform-type-conversion-when-deploying-and-undeploying) (by Noble_Fish)
596597
597598
#### Vanilla fixes:
598599
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
@@ -755,6 +756,7 @@ HideShakeEffects=false ; boolean
755756
- [Export interface for external call](index.md#interoperability) (by TaranDahl)
756757
- Allowed `MindControl.Permanent` warhead to mute `MindClearedSound` (by NetsuNegi & Noble_Fish)
757758
- [Export interface for accessing scenario local/global variables](Interoperability.md#scenarioext) (by Chang_zhi)
759+
- Allowed infantry to use `Convert.Deploy` without requiring `IsSimpleDeployer=true` (by Noble_Fish)
758760
759761
```
760762

src/Ext/Infantry/Hooks.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <Ext/BuildingType/Body.h>
22
#include <Ext/TechnoType/Body.h>
3+
#include <Ext/Techno/Body.h>
34

45
#include <InputManagerClass.h>
56

@@ -11,6 +12,56 @@ DEFINE_HOOK(0x51B2BD, InfantryClass_UpdateTarget_IsControlledByHuman, 0x6)
1112
return (!pTarget || pThis->Owner->IsControlledByHuman()) ? 0x51B33F : 0;
1213
}
1314

15+
// Deploy case: DoAction(Deployed)
16+
DEFINE_HOOK(0x520B3E, InfantryClass_DoingAI_DeployConvert_Deploy, 0x6)
17+
{
18+
GET(InfantryClass*, pThis, ESI);
19+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->Type);
20+
auto const pExt = TechnoExt::ExtMap.Find(pThis);
21+
22+
if (pTypeExt->Convert_Deploy && !pExt->HasDeployConverted)
23+
{
24+
pExt->HasDeployConverted = true;
25+
pExt->HasUndeployConverted = false;
26+
TechnoExt::ConvertToType(pThis, pTypeExt->Convert_Deploy);
27+
}
28+
29+
return 0x520B44;
30+
}
31+
32+
// Undeploy case: DoAction(Ready)
33+
DEFINE_HOOK(0x520B99, InfantryClass_DoingAI_DeployConvert_Undeploy, 0x6)
34+
{
35+
GET(InfantryClass*, pThis, ESI);
36+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->Type);
37+
auto const pExt = TechnoExt::ExtMap.Find(pThis);
38+
39+
if (pTypeExt->Convert_Undeploy && !pExt->HasUndeployConverted)
40+
{
41+
pExt->HasUndeployConverted = true;
42+
pExt->HasDeployConverted = false;
43+
TechnoExt::ConvertToType(pThis, pTypeExt->Convert_Undeploy);
44+
}
45+
46+
return 0x520B9F;
47+
}
48+
49+
// Reset mark when Deploy/Undeploy
50+
DEFINE_HOOK(0x520E75, InfantryClass_DoingAI_DeployConvert_ResetFlags, 0x6)
51+
{
52+
GET(InfantryClass*, pThis, ESI);
53+
const auto curSeq = pThis->SequenceAnim;
54+
55+
if (curSeq != Sequence::Deploy && curSeq != Sequence::Undeploy)
56+
{
57+
auto const pExt = TechnoExt::ExtMap.Find(pThis);
58+
pExt->HasDeployConverted = false;
59+
pExt->HasUndeployConverted = false;
60+
}
61+
62+
return 0;
63+
}
64+
1465
#pragma region WhatActionObjectFix
1566

1667
namespace WhatActionObjectTemp

src/Ext/Techno/Body.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class TechnoExt
106106
CoordStruct LastTargetCrd;
107107
CDTimerClass LastTargetCrdClearTimer;
108108

109+
bool HasDeployConverted;
110+
bool HasUndeployConverted;
111+
109112
ExtData(TechnoClass* OwnerObject) : Extension<TechnoClass>(OwnerObject)
110113
, TypeExtData { nullptr }
111114
, Shield {}
@@ -177,6 +180,8 @@ class TechnoExt
177180
, HoverShutdown { false }
178181
, LastTargetCrd { CoordStruct::Empty }
179182
, LastTargetCrdClearTimer {}
183+
, HasDeployConverted { false }
184+
, HasUndeployConverted { false }
180185
{ }
181186

182187
void OnEarlyUpdate();

src/Ext/TechnoType/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
10101010
this->CurleyShuffle.Read(exINI, pSection, "CurleyShuffle");
10111011

10121012
this->Convert_Deploy.Read(exINI, pSection, "Convert.Deploy");
1013+
this->Convert_Undeploy.Read(exINI, pSection, "Convert.Undeploy");
10131014
this->Convert_HumanToComputer.Read(exINI, pSection, "Convert.HumanToComputer");
10141015
this->Convert_ComputerToHuman.Read(exINI, pSection, "Convert.ComputerToHuman");
10151016
this->Convert_ResetMindControl.Read(exINI, pSection, "Convert.ResetMindControl");
@@ -1742,6 +1743,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
17421743
.Process(this->TiberiumEaterType)
17431744

17441745
.Process(this->Convert_Deploy)
1746+
.Process(this->Convert_Undeploy)
17451747
.Process(this->Convert_HumanToComputer)
17461748
.Process(this->Convert_ComputerToHuman)
17471749
.Process(this->Convert_ResetMindControl)

src/Ext/TechnoType/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ class TechnoTypeExt
289289
Nullable<bool> CurleyShuffle;
290290

291291
Valueable<TechnoTypeClass*> Convert_Deploy; // Ares
292+
Valueable<TechnoTypeClass*> Convert_Undeploy;
292293
Valueable<TechnoTypeClass*> Convert_HumanToComputer;
293294
Valueable<TechnoTypeClass*> Convert_ComputerToHuman;
294295
Valueable<bool> Convert_ResetMindControl;
@@ -777,6 +778,7 @@ class TechnoTypeExt
777778
, CurleyShuffle {}
778779

779780
, Convert_Deploy { }
781+
, Convert_Undeploy { }
780782
, Convert_HumanToComputer { }
781783
, Convert_ComputerToHuman { }
782784
, Convert_ResetMindControl { false }

0 commit comments

Comments
 (0)