Skip to content

Commit d45a975

Browse files
CnCRAZERMetadoriusDeathFishAtEaseCoronia
authored
Ares Optional Fix -- Ability To Revert Ares Transport Cloak Behavior (#2110)
This pull request introduces a fix and new customization for the decloaking behavior of open-topped transports, specifically when passengers fire weapons with `DecloakToFire=yes`. The changes allow modders to control whether passenger actions can decloak their transporter, and revert a previous patch that forced decloaking under certain conditions. **Open-topped transport decloak behavior improvements:** * Added the `OpenTopped.DecloakToFire` option to both `RulesExt` and `TechnoTypeExt`, allowing global or per-unit control over whether passengers firing with `DecloakToFire=yes` decloak their open-topped transporter. --------- Co-authored-by: Kerbiter <[email protected]> Co-authored-by: Noble Fish <[email protected]> Co-authored-by: Coronia <[email protected]>
1 parent 30b1002 commit d45a975

File tree

9 files changed

+56
-0
lines changed

9 files changed

+56
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,3 +770,4 @@ This page lists all the individual contributions to the project by their author.
770770
- **RAZER**:
771771
- Wall overlay unit sell exploit fix
772772
- Multiplayer gamespeed fix for RealTimeTimers
773+
- Revert Ares patch to allow OpenTopped transport customization

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
352352
- Fixed the bug that vehicle survivor can spawn on wrong position when transport has been destroyed.
353353
- Fixed the bug that building with `Explodes=yes` use Ares's rubble logic will cause it's owner cannot defeat normally.
354354
- Fixed an issue that retaliation will make the unit keep switching among multiple targets with the same amount of threat.
355+
- Fixed ares hook which stopped OpenTopped transports from firing if cloaked. This can now be customized.
355356

356357
## Newly added global settings
357358

docs/New-or-Enhanced-Logics.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,16 +1560,21 @@ DrainMoneyDisplay.OnTarget.UseDisplayIncome= ; boolean
15601560
- `OpenTopped.AllowFiringIfDeactivated` can be used to customize whether or not passengers can fire out when the transport is deactivated (EMP, powered unit etc).
15611561
- `OpenTopped.ShareTransportTarget` controls whether or not the current target of the transport itself is passed to the passengers as well.
15621562
- You can also customize range bonus and damage multiplier for passenger inside the transport with `OpenTransport.RangeBonus/DamageMultiplier`, which works independently from transport's `OpenTopped.RangeBonus/DamageMultiplier`.
1563+
- `OpenTopped.DecloakToFire` can customize if a transport has to uncloak to have passengers fireout if transport is also OpenTopped.
15631564

15641565
In `rulesmd.ini`:
15651566
```ini
1567+
[General]
1568+
OpenTopped.DecloakToFire=true ; boolean
1569+
15661570
[SOMETECHNO] ; TechnoType, transport with OpenTopped=yes
15671571
OpenTopped.RangeBonus= ; integer, default to [CombatDamage] -> OpenToppedRangeBonus
15681572
OpenTopped.DamageMultiplier= ; floating point value, default to [CombatDamage] -> OpenToppedDamageMultiplier
15691573
OpenTopped.WarpDistance= ; integer, default to [CombatDamage] -> OpenToppedWarpDistance
15701574
OpenTopped.IgnoreRangefinding=false ; boolean
15711575
OpenTopped.AllowFiringIfDeactivated=true ; boolean
15721576
OpenTopped.ShareTransportTarget=true ; boolean
1577+
OpenTopped.DecloakToFire= ; boolean, defaults to [General] -> OpenTopped.DecloakToFire
15731578

15741579
[SOMETECHNO] ; TechnoType, passenger
15751580
OpenTransport.RangeBonus=0 ; integer

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ Fixes / interactions with other extensions:
667667
- Fixed the issue that technos cannot spawn survivors due to non-probabilistic reasons when the tech type was destroyed (by NetsuNegi)
668668
- Fixed the bug that vehicle survivor can spawn on wrong position when transport has been destroyed (by NetsuNegi)
669669
- Fixed the bug that building with `Explodes=yes` use Ares's rubble logic will cause it's owner cannot defeat normally (by NetsuNegi)
670+
- Fixed ares hook which stopped OpenTopped transports from firing if cloaked. This can now be customized (by RAZER & Morton)
671+
670672
```
671673

672674
### 0.4.0.3

src/Ext/Rules/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
344344

345345
this->FallingDownTargetingFix.Read(exINI, GameStrings::General, "FallingDownTargetingFix");
346346
this->AIAirTargetingFix.Read(exINI, GameStrings::General, "AIAirTargetingFix");
347+
this->OpenTopped_DecloakToFire.Read(exINI, GameStrings::General, "OpenTopped.DecloakToFire");
347348

348349
this->SortCameoByName.Read(exINI, GameStrings::General, "SortCameoByName");
349350

@@ -658,6 +659,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
658659
.Process(this->IvanBombAttachToCenter)
659660
.Process(this->FallingDownTargetingFix)
660661
.Process(this->AIAirTargetingFix)
662+
.Process(this->OpenTopped_DecloakToFire)
661663
.Process(this->SortCameoByName)
662664
.Process(this->MergeBuildingDamage)
663665
.Process(this->BuildingRadioLink_SyncOwner)

src/Ext/Rules/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class RulesExt
294294

295295
Valueable<bool> FallingDownTargetingFix;
296296
Valueable<bool> AIAirTargetingFix;
297+
Valueable<bool> OpenTopped_DecloakToFire;
297298

298299
Valueable<bool> SortCameoByName;
299300

@@ -557,6 +558,7 @@ class RulesExt
557558

558559
, FallingDownTargetingFix { false }
559560
, AIAirTargetingFix { false }
561+
, OpenTopped_DecloakToFire { false }
560562

561563
, SortCameoByName { false }
562564

src/Ext/Techno/Hooks.Cloak.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Body.h"
2+
#include <Ext/Rules/Body.h>
23

34
namespace CloakTemp
45
{
@@ -174,3 +175,41 @@ DEFINE_HOOK(0x4579A5, BuildingClass_ShouldNotCloak_Sensors, 0x6)
174175

175176
return Continue;
176177
}
178+
179+
// NOTE: Overrides incorrect Ares hook at the same address.
180+
DEFINE_HOOK(0x6FCA26, TechnoClass_CanFire_RevertAresOpenTopCloakFix, 0x6)
181+
{
182+
enum { Skip = 0x6FCA4F, Continue = 0x6FCA36, NotApplicable = 0x6FCA5E };
183+
184+
GET(WeaponTypeClass*, pWeapon, EBX);
185+
186+
if (!pWeapon->DecloakToFire)
187+
return NotApplicable;
188+
189+
GET(TechnoClass*, pThis, ESI);
190+
191+
if (pThis->InOpenToppedTransport && pThis->Transporter)
192+
{
193+
auto const pTransporterTypeExt = TechnoExt::ExtMap.Find(pThis->Transporter)->TypeExtData;
194+
if (pTransporterTypeExt->OpenTopped_DecloakToFire.Get(RulesExt::Global()->OpenTopped_DecloakToFire))
195+
return NotApplicable;
196+
}
197+
198+
R->EAX(pThis->CloakState);
199+
return Continue;
200+
}
201+
202+
DEFINE_HOOK(0x6FCD1D, TechnoClass_CanFire_OpenTopCloakFix, 0x5)
203+
{
204+
GET(TechnoClass*, pThis, ESI);
205+
GET_STACK(const bool, checkIfTargetInRange, STACK_OFFSET(0x20, 0xC));
206+
207+
if (checkIfTargetInRange && pThis->InOpenToppedTransport && pThis->Transporter)
208+
{
209+
auto const pTransporterTypeExt = TechnoExt::ExtMap.Find(pThis->Transporter)->TypeExtData;
210+
if (pTransporterTypeExt->OpenTopped_DecloakToFire.Get(RulesExt::Global()->OpenTopped_DecloakToFire))
211+
pThis->Transporter->Uncloak(true);
212+
}
213+
214+
return 0;
215+
}

src/Ext/TechnoType/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
855855
this->OpenTopped_ShareTransportTarget.Read(exINI, pSection, "OpenTopped.ShareTransportTarget");
856856
this->OpenTopped_UseTransportRangeModifiers.Read(exINI, pSection, "OpenTopped.UseTransportRangeModifiers");
857857
this->OpenTopped_CheckTransportDisableWeapons.Read(exINI, pSection, "OpenTopped.CheckTransportDisableWeapons");
858+
this->OpenTopped_DecloakToFire.Read(exINI, pSection, "OpenTopped.DecloakToFire");
858859
this->OpenTransport_RangeBonus.Read(exINI, pSection, "OpenTransport.RangeBonus");
859860
this->OpenTransport_DamageMultiplier.Read(exINI, pSection, "OpenTransport.DamageMultiplier");
860861

@@ -1580,6 +1581,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
15801581
.Process(this->OpenTopped_ShareTransportTarget)
15811582
.Process(this->OpenTopped_UseTransportRangeModifiers)
15821583
.Process(this->OpenTopped_CheckTransportDisableWeapons)
1584+
.Process(this->OpenTopped_DecloakToFire)
15831585
.Process(this->OpenTransport_RangeBonus)
15841586
.Process(this->OpenTransport_DamageMultiplier)
15851587

src/Ext/TechnoType/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class TechnoTypeExt
166166
Valueable<bool> OpenTopped_ShareTransportTarget;
167167
Valueable<bool> OpenTopped_UseTransportRangeModifiers;
168168
Valueable<bool> OpenTopped_CheckTransportDisableWeapons;
169+
Nullable<bool> OpenTopped_DecloakToFire;
169170
Valueable<int> OpenTransport_RangeBonus;
170171
Valueable<float> OpenTransport_DamageMultiplier;
171172

@@ -587,6 +588,7 @@ class TechnoTypeExt
587588
, OpenTopped_ShareTransportTarget { true }
588589
, OpenTopped_UseTransportRangeModifiers { false }
589590
, OpenTopped_CheckTransportDisableWeapons { false }
591+
, OpenTopped_DecloakToFire {}
590592
, OpenTransport_RangeBonus { 0 }
591593
, OpenTransport_DamageMultiplier { 1.0f }
592594

0 commit comments

Comments
 (0)