diff --git a/CREDITS.md b/CREDITS.md index a37947eb32..44d70b704a 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -749,4 +749,7 @@ This page lists all the individual contributions to the project by their author. - **Dmitry Volkov** - extensive and thorough testing - **Rise of the East community** - extensive playtesting of in-dev features - **11EJDE11** - Prevent mpdebug number from being drawn when visibility toggled off -- **CnCRazer** - Wall overlay unit sell exploit fix +- **RAZER**: + - Wall overlay unit sell exploit fix + - Revert Ares patch to allow OpenTopped transport customization. + diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 647b54db92..dbaa9e7ef4 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -343,6 +343,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - Fixed the bug that vehicle survivor can spawn on wrong position when transport has been destroyed. - Fixed the bug that building with `Explodes=yes` use Ares's rubble logic will cause it's owner cannot defeat normally. - Fixed an issue that retaliation will make the unit keep switching among multiple targets with the same amount of threat. +- Fixed ares hook which stopped OpenTopped transports from firing if cloaked. This can now be customized. ## Newly added global settings diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 83f2fafb5d..595dfdc02f 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1556,8 +1556,12 @@ DrainMoneyDisplay.OnTarget.UseDisplayIncome= ; boolean - `OpenTopped.AllowFiringIfDeactivated` can be used to customize whether or not passengers can fire out when the transport is deactivated (EMP, powered unit etc). - `OpenTopped.ShareTransportTarget` controls whether or not the current target of the transport itself is passed to the passengers as well. - 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`. +- `OpenTopped.DecloakToFire` can customize if a transport has to uncloak to have passengers fireout if transport is also OpenTopped. ```ini +[General] +OpenTopped.DecloakToFire=true ; boolean + [SOMETECHNO] ; TechnoType, transport with OpenTopped=yes OpenTopped.RangeBonus= ; integer, default to [CombatDamage] -> OpenToppedRangeBonus OpenTopped.DamageMultiplier= ; floating point value, default to [CombatDamage] -> OpenToppedDamageMultiplier @@ -1565,6 +1569,7 @@ OpenTopped.WarpDistance= ; integer, default to [CombatDamage] - OpenTopped.IgnoreRangefinding=false ; boolean OpenTopped.AllowFiringIfDeactivated=true ; boolean OpenTopped.ShareTransportTarget=true ; boolean +OpenTopped.DecloakToFire= ; boolean, defaults to [General] -> OpenTopped.DecloakToFire [SOMETECHNO] ; TechnoType, passenger OpenTransport.RangeBonus=0 ; integer diff --git a/docs/Whats-New.md b/docs/Whats-New.md index a4eaebd6b4..c5860aa138 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -643,6 +643,8 @@ Fixes / interactions with other extensions: - Fixed the issue that technos cannot spawn survivors due to non-probabilistic reasons when the tech type was destroyed (by NetsuNegi) - Fixed the bug that vehicle survivor can spawn on wrong position when transport has been destroyed (by NetsuNegi) - Fixed the bug that building with `Explodes=yes` use Ares's rubble logic will cause it's owner cannot defeat normally (by NetsuNegi) +- Fixed ares hook which stopped OpenTopped transports from firing if cloaked. This can now be customized (by RAZER) + ``` ### 0.4.0.3 diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 228b0415ca..b2737ed77c 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -343,6 +343,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->FallingDownTargetingFix.Read(exINI, GameStrings::General, "FallingDownTargetingFix"); this->AIAirTargetingFix.Read(exINI, GameStrings::General, "AIAirTargetingFix"); + this->OpenTopped_DecloakToFire.Read(exINI, GameStrings::General, "OpenTopped.DecloakToFire"); this->SortCameoByName.Read(exINI, GameStrings::General, "SortCameoByName"); @@ -656,6 +657,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->IvanBombAttachToCenter) .Process(this->FallingDownTargetingFix) .Process(this->AIAirTargetingFix) + .Process(this->OpenTopped_DecloakToFire) .Process(this->SortCameoByName) .Process(this->MergeBuildingDamage) .Process(this->BuildingRadioLink_SyncOwner) diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index ca624cd9ae..078044691d 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -293,6 +293,7 @@ class RulesExt Valueable FallingDownTargetingFix; Valueable AIAirTargetingFix; + Valueable OpenTopped_DecloakToFire; Valueable SortCameoByName; @@ -555,6 +556,7 @@ class RulesExt , FallingDownTargetingFix { false } , AIAirTargetingFix { false } + , OpenTopped_DecloakToFire { false } , SortCameoByName { false } diff --git a/src/Ext/Techno/Hooks.Cloak.cpp b/src/Ext/Techno/Hooks.Cloak.cpp index 85e268dfaf..9cf0a71c51 100644 --- a/src/Ext/Techno/Hooks.Cloak.cpp +++ b/src/Ext/Techno/Hooks.Cloak.cpp @@ -1,4 +1,5 @@ #include "Body.h" +#include namespace CloakTemp { @@ -174,3 +175,41 @@ DEFINE_HOOK(0x4579A5, BuildingClass_ShouldNotCloak_Sensors, 0x6) return Continue; } + +// NOTE: Overrides incorrect Ares hook at the same address. +DEFINE_HOOK(0x6FCA26, TechnoClass_CanFire_RevertAresOpenTopCloakFix, 0x6) +{ + enum { Skip = 0x6FCA4F, Continue = 0x6FCA36, NotApplicable = 0x6FCA5E }; + + GET(WeaponTypeClass*, pWeapon, EBX); + + if (!pWeapon->DecloakToFire) + return NotApplicable; + + GET(TechnoClass*, pThis, ESI); + + if (pThis->InOpenToppedTransport && pThis->Transporter) + { + auto const pTransporterTypeExt = TechnoTypeExt::ExtMap.Find(pThis->Transporter->GetTechnoType()); + if (pTransporterTypeExt->OpenTopped_DecloakToFire.Get(RulesExt::Global()->OpenTopped_DecloakToFire)) + return NotApplicable; + } + + R->EAX(pThis->CloakState); + return Continue; +} + +DEFINE_HOOK(0x6FCD1D, TechnoClass_CanFire_OpenTopCloakFix, 0x5) +{ + GET(TechnoClass*, pThis, ESI); + GET_STACK(bool, checkIfTargetInRange, STACK_OFFSET(0x20, 0xC)); + + if (checkIfTargetInRange && pThis->InOpenToppedTransport && pThis->Transporter) + { + auto const pTransporterTypeExt = TechnoTypeExt::ExtMap.Find(pThis->Transporter->GetTechnoType()); + if (pTransporterTypeExt->OpenTopped_DecloakToFire.Get(RulesExt::Global()->OpenTopped_DecloakToFire)) + pThis->Transporter->Uncloak(true); + } + + return 0; +} diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 8cc82868c4..2135f2b37a 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -858,6 +858,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->OpenTopped_ShareTransportTarget.Read(exINI, pSection, "OpenTopped.ShareTransportTarget"); this->OpenTopped_UseTransportRangeModifiers.Read(exINI, pSection, "OpenTopped.UseTransportRangeModifiers"); this->OpenTopped_CheckTransportDisableWeapons.Read(exINI, pSection, "OpenTopped.CheckTransportDisableWeapons"); + this->OpenTopped_DecloakToFire.Read(exINI, pSection, "OpenTopped.DecloakToFire"); this->OpenTransport_RangeBonus.Read(exINI, pSection, "OpenTransport.RangeBonus"); this->OpenTransport_DamageMultiplier.Read(exINI, pSection, "OpenTransport.DamageMultiplier"); @@ -1564,6 +1565,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->OpenTopped_ShareTransportTarget) .Process(this->OpenTopped_UseTransportRangeModifiers) .Process(this->OpenTopped_CheckTransportDisableWeapons) + .Process(this->OpenTopped_DecloakToFire) .Process(this->OpenTransport_RangeBonus) .Process(this->OpenTransport_DamageMultiplier) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index c11729ec83..b05c3ad1fa 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -166,6 +166,7 @@ class TechnoTypeExt Valueable OpenTopped_ShareTransportTarget; Valueable OpenTopped_UseTransportRangeModifiers; Valueable OpenTopped_CheckTransportDisableWeapons; + Nullable OpenTopped_DecloakToFire; Valueable OpenTransport_RangeBonus; Valueable OpenTransport_DamageMultiplier; @@ -580,6 +581,7 @@ class TechnoTypeExt , OpenTopped_ShareTransportTarget { true } , OpenTopped_UseTransportRangeModifiers { false } , OpenTopped_CheckTransportDisableWeapons { false } + , OpenTopped_DecloakToFire {} , OpenTransport_RangeBonus { 0 } , OpenTransport_DamageMultiplier { 1.0 }