Skip to content

Commit 771e444

Browse files
OtamaaCoroniachaserliStarkku
authored
Mastermind Overload characteristic deharcoded (#549)
```ini [MASTERMIND] Overload.Count= ; list of integer, default to [CombatDamage]->OverloadCount Overload.Damage= ; list of integer, default to [CombatDamage]->OverloadDamage Overload.Frames= ; list of integer, default to [CombatDamage]->OverloadFrames Overload.DeathSound= ; Sound entry, default to [AudioVisual]->MasterMindOverloadDeathSound Overload.ParticleSys= ; ParticleSystemType, default to [CombatDamage]->DefaultSparkSystem Overload.ParticleSysCount=5 ; integer MindControlLink.VisibleToHouse=all ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all) ``` --------- Co-authored-by: Coronia <[email protected]> Co-authored-by: Trsdy <[email protected]> Co-authored-by: Starkku <[email protected]>
1 parent ed85cea commit 771e444

File tree

6 files changed

+170
-1
lines changed

6 files changed

+170
-1
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ This page lists all the individual contributions to the project by their author.
117117
- Ares detection and integration
118118
- Help with custom locomotors
119119
- Extension class optimization
120+
- Overload characteristic dehardcoded
120121
- **FS-21**:
121122
- Dump Object Info enhancements
122123
- `Powered.KillSpawns`

docs/New-or-Enhanced-Logics.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,12 +1518,14 @@ AutoDeath.TechnosExist.Houses=owner ; Affected House Enumeration (non
15181518
*Multiple Mind Control unit auto-releases the first victim in [Fantasy ADVENTURE](https://www.moddb.com/mods/fantasy-adventure)*
15191519

15201520
- Mind controllers now can have the upper limit of the control distance. Tag values greater than 0 will activate this feature.
1521+
- Mind controllers now can decide which house can see the link drawn between itself and the controlled units.
15211522
- Mind controllers with multiple controlling slots can now release the first controlled unit when they have reached the control limit and are ordered to control a new target.
15221523

15231524
In `rulesmd.ini`:
15241525
```ini
15251526
[SOMETECHNO] ; TechnoType
15261527
MindControlRangeLimit=-1.0 ; floating point value
1528+
MindControlLink.VisibleToHouse=all ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
15271529
MultiMindControl.ReleaseVictim=false ; boolean
15281530
```
15291531

@@ -1561,6 +1563,22 @@ NoReload.UnderEMP= ; boolean
15611563
NoReload.Temporal= ; boolean
15621564
```
15631565

1566+
### Overload characteristic dehardcoded
1567+
1568+
- It is now possible to customize `Overload` behaviors for a TechnoType with `InfiniteMindControl=yes` weapon.
1569+
1570+
In `rulesmd.ini`:
1571+
```ini
1572+
1573+
[SOMETECHNO] ; TechnoType
1574+
Overload.Count= ; list of integer, default to [CombatDamage] -> OverloadCount
1575+
Overload.Damage= ; list of integer, default to [CombatDamage] -> OverloadDamage
1576+
Overload.Frames= ; list of integer, default to [CombatDamage] -> OverloadFrames
1577+
Overload.DeathSound= ; Sound entry, default to [AudioVisual] -> MasterMindOverloadDeathSound
1578+
Overload.ParticleSys= ; ParticleSystemType, default to [CombatDamage] -> DefaultSparkSystem
1579+
Overload.ParticleSysCount=5 ; integer
1580+
```
1581+
15641582
### Promoted Spawns
15651583

15661584
![image](_static/images/promotedspawns-01.gif)

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ New:
360360
- [Removed dependency on `blowfish.dll`](Miscellanous.md#blowfish-dependency) (by ZivDero)
361361
- [Warhead that can not kill](New-or-Enhanced-Logics.md#warhead-that-cannot-kill) (by FS-21)
362362
- [Customize parasite culling targets](Fixed-or-Improved-Logics.md#customizing-parasite-culling-targets) (by NetsuNegi)
363+
- [Overload characteristic dehardcoded](New-or-Enhanced-Logics.md#overload-characteristic-dehardcoded) (by Otamaa)
363364
364365
Vanilla fixes:
365366
- Prevent the units with locomotors that cause problems from entering the tank bunker (by TaranDahl)

src/Ext/CaptureManager/Hooks.cpp

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "Body.h"
22

3+
#include <ParticleSystemClass.h>
4+
#include <Utilities/Macro.h>
5+
#include <Utilities/EnumFunctions.h>
6+
37
DEFINE_HOOK(0x471D40, CaptureManagerClass_CaptureUnit, 0x7)
48
{
59
GET(CaptureManagerClass*, pThis, ECX);
@@ -49,3 +53,117 @@ DEFINE_HOOK(0x519F71, InfantryClass_UpdatePosition_BeforeBuildingChangeHouse, 0x
4953

5054
return 0;
5155
}
56+
57+
static void __stdcall DrawALinkTo(CoordStruct nFrom, CoordStruct nTo, ColorStruct color)
58+
{
59+
JMP_STD(0x704E40);
60+
}
61+
62+
DEFINE_HOOK(0x4721E6, CaptureManagerClass_DrawLinkToVictim, 0x6)
63+
{
64+
GET(CaptureManagerClass*, pThis, EDI);
65+
GET(TechnoClass*, pVictim, ECX);
66+
GET_STACK(int, nNodeCount, STACK_OFFSET(0x30, -0x1C));
67+
68+
auto const pAttacker = pThis->Owner;
69+
const auto pExt = TechnoTypeExt::ExtMap.Find(pAttacker->GetTechnoType());
70+
71+
if (EnumFunctions::CanTargetHouse(pExt->MindControlLink_VisibleToHouse, pAttacker->Owner, HouseClass::CurrentPlayer))
72+
{
73+
auto nVictimCoord = pVictim->Location;
74+
nVictimCoord.Z += pVictim->GetTechnoType()->LeptonMindControlOffset;
75+
auto nFLH = pAttacker->GetFLH(-1 - nNodeCount % 5, CoordStruct::Empty);
76+
DrawALinkTo(nFLH, nVictimCoord, pAttacker->Owner->Color);
77+
}
78+
79+
R->EBP(nNodeCount);
80+
return 0x472287;
81+
}
82+
83+
void __fastcall CaptureManagerClass_Overload_AI(CaptureManagerClass* pThis, void* _)
84+
{
85+
auto const pOwner = pThis->Owner;
86+
auto const pOwnerTypeExt = TechnoTypeExt::ExtMap.Find(pOwner->GetTechnoType());
87+
88+
if (!pOwnerTypeExt) // we cant find type Ext for this , just return to original function !
89+
{
90+
pThis->HandleOverload();
91+
return;
92+
}
93+
94+
if (pThis->InfiniteMindControl)
95+
{
96+
auto const pRules = RulesClass::Instance;
97+
98+
if (pThis->OverloadPipState > 0)
99+
--pThis->OverloadPipState;
100+
101+
if (pThis->OverloadDamageDelay <= 0)
102+
{
103+
auto const& OverloadCount = pOwnerTypeExt->Overload_Count.GetElements(pRules->OverloadCount);
104+
105+
if (OverloadCount.empty())
106+
return;
107+
108+
int nCurIdx = 0;
109+
int const nNodeCount = pThis->ControlNodes.Count;
110+
111+
for (int i = 0; i < (int)(OverloadCount.size()); ++i)
112+
{
113+
if (nNodeCount > OverloadCount[i])
114+
nCurIdx = i + 1; // select the index !
115+
}
116+
117+
// prevent nCurIdx selecting out of bound index !
118+
constexpr auto FixIdx = [](const Iterator<int>& iter, int nInput) {
119+
return iter.empty() ? 0 : iter[nInput >= (int)iter.size() ? (int)iter.size() - 1 : nInput];
120+
};
121+
122+
auto const& nOverloadfr = pOwnerTypeExt->Overload_Frames.GetElements(pRules->OverloadFrames);
123+
pThis->OverloadDamageDelay = FixIdx(nOverloadfr, nCurIdx);
124+
125+
auto const& nOverloadDmg = pOwnerTypeExt->Overload_Damage.GetElements(pRules->OverloadDamage);
126+
auto nDamage = FixIdx(nOverloadDmg, nCurIdx);
127+
128+
if (nDamage <= 0)
129+
{
130+
pThis->OverloadDeathSoundPlayed = false;
131+
}
132+
else
133+
{
134+
pThis->OverloadPipState = 10;
135+
pOwner->ReceiveDamage(&nDamage, 0, pRules->C4Warhead, 0, 0, 0, 0);
136+
137+
if (!pThis->OverloadDeathSoundPlayed)
138+
{
139+
VocClass::PlayAt(pOwnerTypeExt->Overload_DeathSound.Get(pRules->MasterMindOverloadDeathSound), pOwner->Location, 0);
140+
pThis->OverloadDeathSoundPlayed = true;
141+
}
142+
143+
if (auto const pParticle = pOwnerTypeExt->Overload_ParticleSys.Get(pRules->DefaultSparkSystem))
144+
{
145+
for (int i = pOwnerTypeExt->Overload_ParticleSysCount; i > 0; --i)
146+
{
147+
auto const nRandomY = ScenarioClass::Instance->Random.RandomRanged(-200, 200);
148+
auto const nRamdomX = ScenarioClass::Instance->Random.RandomRanged(-200, 200);
149+
CoordStruct nParticleCoord{ pOwner->Location.X + nRamdomX, nRandomY + pOwner->Location.Y, pOwner->Location.Z + 100 };
150+
GameCreate<ParticleSystemClass>(pParticle, nParticleCoord, nullptr, nullptr, CoordStruct::Empty, nullptr);
151+
}
152+
}
153+
154+
if (nCurIdx > 0 && pOwner->IsAlive && pOwner->Health > 0 && !pOwner->InLimbo)
155+
{
156+
double const nBase = (nCurIdx != 1) ? 0.015 : 0.03;
157+
double const nCopied_base = (ScenarioClass::Instance->Random.RandomRanged(0, 100) < 50) ? -nBase : nBase;
158+
pOwner->RockingSidewaysPerFrame = (float)nCopied_base;
159+
}
160+
}
161+
}
162+
else
163+
{
164+
--pThis->OverloadDamageDelay;
165+
}
166+
}
167+
}
168+
169+
DEFINE_FUNCTION_JUMP(CALL, 0x6FA730, CaptureManagerClass_Overload_AI);

src/Ext/TechnoType/Body.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
275275
this->UIDescription.Read(exINI, pSection, "UIDescription");
276276
this->LowSelectionPriority.Read(exINI, pSection, "LowSelectionPriority");
277277
this->MindControlRangeLimit.Read(exINI, pSection, "MindControlRangeLimit");
278+
this->MindControlLink_VisibleToHouse.Read(exINI, pSection, "MindControlLink.VisibleToHouse");
278279
this->FactoryPlant_Multiplier.Read(exINI, pSection, "FactoryPlant.Multiplier");
279280

280281
this->Spawner_LimitRange.Read(exINI, pSection, "Spawner.LimitRange");
@@ -527,6 +528,13 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
527528
this->Promote_VeteranAnimation.Read(exINI, pSection, "Promote.VeteranAnimation");
528529
this->Promote_EliteAnimation.Read(exINI, pSection, "Promote.EliteAnimation");
529530

531+
this->Overload_Count.Read(exINI, pSection, "Overload.Count");
532+
this->Overload_Damage.Read(exINI, pSection, "Overload.Damage");
533+
this->Overload_Frames.Read(exINI, pSection, "Overload.Frames");
534+
this->Overload_DeathSound.Read(exINI, pSection, "Overload.DeathSound");
535+
this->Overload_ParticleSys.Read(exINI, pSection, "Overload.ParticleSys");
536+
this->Overload_ParticleSysCount.Read(exINI, pSection, "Overload.ParticleSysCount");
537+
530538
// Ares 0.2
531539
this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius");
532540

@@ -699,6 +707,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
699707
.Process(this->UIDescription)
700708
.Process(this->LowSelectionPriority)
701709
.Process(this->MindControlRangeLimit)
710+
.Process(this->MindControlLink_VisibleToHouse)
702711
.Process(this->FactoryPlant_Multiplier)
703712

704713
.Process(this->InterceptorType)
@@ -972,6 +981,13 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
972981

973982
.Process(this->Promote_VeteranAnimation)
974983
.Process(this->Promote_EliteAnimation)
984+
985+
.Process(this->Overload_Count)
986+
.Process(this->Overload_Damage)
987+
.Process(this->Overload_Frames)
988+
.Process(this->Overload_DeathSound)
989+
.Process(this->Overload_ParticleSys)
990+
.Process(this->Overload_ParticleSysCount)
975991
;
976992
}
977993
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)

src/Ext/TechnoType/Body.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <New/Type/Affiliated/DroppodTypeClass.h>
1515

1616
class Matrix3D;
17-
17+
class ParticleSystemTypeClass;
1818
class TechnoTypeExt
1919
{
2020
public:
@@ -35,6 +35,7 @@ class TechnoTypeExt
3535
Nullable<int> DesignatorRange;
3636
Valueable<float> FactoryPlant_Multiplier;
3737
Valueable<Leptons> MindControlRangeLimit;
38+
Valueable<AffectedHouse> MindControlLink_VisibleToHouse;
3839

3940
std::unique_ptr<InterceptorTypeClass> InterceptorType;
4041

@@ -321,6 +322,12 @@ class TechnoTypeExt
321322
Valueable<bool> SuppressKillWeapons;
322323
ValueableVector<WeaponTypeClass*> SuppressKillWeapons_Types;
323324

325+
NullableVector<int> Overload_Count;
326+
NullableVector<int> Overload_Damage;
327+
NullableVector<int> Overload_Frames;
328+
NullableIdx<VocClass> Overload_DeathSound;
329+
Nullable<ParticleSystemTypeClass*> Overload_ParticleSys;
330+
Valueable<int> Overload_ParticleSysCount;
324331

325332
ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
326333
, HealthBar_Hide { false }
@@ -332,6 +339,7 @@ class TechnoTypeExt
332339
, DesignatorRange { }
333340
, FactoryPlant_Multiplier { 1.0 }
334341
, MindControlRangeLimit {}
342+
, MindControlLink_VisibleToHouse{ AffectedHouse::All }
335343

336344
, InterceptorType { nullptr }
337345

@@ -597,6 +605,13 @@ class TechnoTypeExt
597605

598606
, Promote_VeteranAnimation { }
599607
, Promote_EliteAnimation { }
608+
609+
, Overload_Count {}
610+
, Overload_Damage {}
611+
, Overload_Frames {}
612+
, Overload_DeathSound {}
613+
, Overload_ParticleSys {}
614+
, Overload_ParticleSysCount { 5 }
600615
{ }
601616

602617
virtual ~ExtData() = default;

0 commit comments

Comments
 (0)