diff --git a/CREDITS.md b/CREDITS.md index 2adb1c7ce4..7e84491e31 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -724,6 +724,7 @@ This page lists all the individual contributions to the project by their author. - `ElectricAssault` weapons can now auto acquire allies' overpowerable defenses - Allow `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades - Dynamic team delays + - Customize whether or not passenger can fire out when the transport is moving - **NaotoYuuki** - Vertical & meteor trajectory projectile prototypes - **handama**: - AI script action to `16005 Jump Back To Previous Script` diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 51f8468f6c..f9f1fa40f7 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -325,6 +325,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - Fixed voxel projectile and animation lighting issues. - Fixed the bug that techno will get stuck if change owner in tunnel. - Restored the original Tiberian Sun behavior of playing the `[AudioVisual] -> DeploySound=` sound effect when clicking the sidebar to execute `Deploy`. +- Whether or not a passenger's weapon can fire out from an `OpenTopped=yes` transport will now respect the weapon's `FireWhileMoving` setting. ## Fixes / interactions with other extensions diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index ec9ae2bdcc..73e0d49f68 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1648,12 +1648,15 @@ DrainMoneyDisplay.OnTarget.UseDisplayIncome= ; boolean - `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. +- `OpenTopped/OpenTransport.FireWhileMoving` can be used to customize whether or not passengers can fire out when the transport is moving, for transport and passenger respectively. Both of them and the weapon's `FireWhileMoving` toggle need to be set to true to allow firing out when moving. In `rulesmd.ini`: ```ini [General] OpenTopped.AllowFiringIfAttackedByLocomotor=true ; boolean OpenTopped.DecloakToFire=true ; boolean +OpenTopped.FireWhileMoving=true ; boolean +OpenTransport.FireWhileMoving=true ; boolean [SOMETECHNO] ; TechnoType, transport with OpenTopped=yes OpenTopped.RangeBonus= ; integer, default to [CombatDamage] -> OpenToppedRangeBonus @@ -1664,10 +1667,12 @@ OpenTopped.AllowFiringIfDeactivated=true ; boolean OpenTopped.AllowFiringIfAttackedByLocomotor= ; boolean, defaults to [General] -> OpenTopped.AllowFiringIfAttackedByLocomotor OpenTopped.ShareTransportTarget=true ; boolean OpenTopped.DecloakToFire= ; boolean, defaults to [General] -> OpenTopped.DecloakToFire +OpenTopped.FireWhileMoving= ; boolean, defaults to [General] -> OpenTopped.FireWhileMoving [SOMETECHNO] ; TechnoType, passenger OpenTransport.RangeBonus=0 ; integer OpenTransport.DamageMultiplier=1.0 ; floating point value +OpenTransport.FireWhileMoving= ; boolean, defaults to [General] -> OpenTransport.FireWhileMoving ``` ```{note} diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 2c98a36155..de55b9cebe 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -606,6 +606,7 @@ HideShakeEffects=false ; boolean - [Customize the step limit of the credits indicator](User-Interface.md#customize-the-step-limit-of-the-credits-indicator) (by Noble_Fish) - [Disable the credits indicator smooth transition](User-Interface.md#disable-the-credits-indicator-smooth-transition) (by Noble_Fish) - Add `selling`, `undeploying` and `harvesting` conditions to `DiscardOn` (by Noble_Fish) +- Customize whether or not passenger can fire out when the transport is moving (by Ollerus) #### Vanilla fixes: - Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 9166c2ef1e..6194d63d4d 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -361,7 +361,9 @@ 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->OpenTopped_FireWhileMoving.Read(exINI, GameStrings::General, "OpenTopped.FireWhileMoving"); this->OpenTopped_AllowFiringIfAttackedByLocomotor.Read(exINI, GameStrings::General, "OpenTopped.AllowFiringIfAttackedByLocomotor"); + this->OpenTransport_FireWhileMoving.Read(exINI, GameStrings::General, "OpenTransport.FireWhileMoving"); this->SortCameoByName.Read(exINI, GameStrings::General, "SortCameoByName"); @@ -748,7 +750,9 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->FallingDownTargetingFix) .Process(this->AIAirTargetingFix) .Process(this->OpenTopped_DecloakToFire) + .Process(this->OpenTopped_FireWhileMoving) .Process(this->OpenTopped_AllowFiringIfAttackedByLocomotor) + .Process(this->OpenTransport_FireWhileMoving) .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 285bcc07b4..54be93d277 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -305,7 +305,9 @@ class RulesExt Valueable FallingDownTargetingFix; Valueable AIAirTargetingFix; Valueable OpenTopped_DecloakToFire; + Valueable OpenTopped_FireWhileMoving; Valueable OpenTopped_AllowFiringIfAttackedByLocomotor; + Valueable OpenTransport_FireWhileMoving; Valueable SortCameoByName; @@ -629,7 +631,9 @@ class RulesExt , FallingDownTargetingFix { false } , AIAirTargetingFix { false } , OpenTopped_DecloakToFire { false } + , OpenTopped_FireWhileMoving { true } , OpenTopped_AllowFiringIfAttackedByLocomotor { true } + , OpenTransport_FireWhileMoving { true } , SortCameoByName { false } diff --git a/src/Ext/Techno/Hooks.Firing.cpp b/src/Ext/Techno/Hooks.Firing.cpp index c018009d11..3ac8c633f7 100644 --- a/src/Ext/Techno/Hooks.Firing.cpp +++ b/src/Ext/Techno/Hooks.Firing.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #pragma region TechnoClass_SelectWeapon @@ -436,17 +437,28 @@ DEFINE_HOOK(0x6FC5C7, TechnoClass_CanFire_OpenTopped, 0x6) if (pTransport->Deactivated && !pTypeExt->OpenTopped_AllowFiringIfDeactivated) return Illegal; + if (pTransport->Transporter) + return Illegal; + + auto const pWeapon = pThis->GetWeapon(weaponIndex)->WeaponType; + + if (pTypeExt->OpenTopped_CheckTransportDisableWeapons && TechnoExt::HasWeaponsDisabled(pTransport) && pWeapon) + return OutOfRange; + if (const auto pTransportFoot = abstract_cast(pTransport)) { if (pTransportFoot->IsAttackedByLocomotor && !pTypeExt->OpenTopped_AllowFiringIfAttackedByLocomotor.Get(RulesExt::Global()->OpenTopped_AllowFiringIfAttackedByLocomotor)) return Illegal; - } - if (pTransport->Transporter) - return Illegal; - - if (pTypeExt->OpenTopped_CheckTransportDisableWeapons && TechnoExt::HasWeaponsDisabled(pTransport) && pThis->GetWeapon(weaponIndex)->WeaponType) - return OutOfRange; + if (!pTypeExt->OpenTopped_FireWhileMoving.Get(RulesExt::Global()->OpenTopped_FireWhileMoving) + || !TechnoExt::ExtMap.Find(pThis)->TypeExtData->OpenTransport_FireWhileMoving.Get(RulesExt::Global()->OpenTransport_FireWhileMoving) + || (pWeapon && !pWeapon->FireWhileMoving)) + { + const auto pLoco = pTransportFoot->Locomotor; + if (locomotion_cast(pLoco) ? pLoco->Is_Moving_Now() : pLoco->Is_Really_Moving_Now()) + return Illegal; + } + } return Continue; } diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index d77b610154..4392240610 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -866,8 +866,10 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) 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->OpenTopped_FireWhileMoving.Read(exINI, pSection, "OpenTopped.FireWhileMoving"); this->OpenTransport_RangeBonus.Read(exINI, pSection, "OpenTransport.RangeBonus"); this->OpenTransport_DamageMultiplier.Read(exINI, pSection, "OpenTransport.DamageMultiplier"); + this->OpenTransport_FireWhileMoving.Read(exINI, pSection, "OpenTransport.FireWhileMoving"); if (exINI.ReadString(pSection, "AutoFire") > 0) { @@ -1627,8 +1629,10 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->OpenTopped_UseTransportRangeModifiers) .Process(this->OpenTopped_CheckTransportDisableWeapons) .Process(this->OpenTopped_DecloakToFire) + .Process(this->OpenTopped_FireWhileMoving) .Process(this->OpenTransport_RangeBonus) .Process(this->OpenTransport_DamageMultiplier) + .Process(this->OpenTransport_FireWhileMoving) .Process(this->AutoTargetOwnPosition) .Process(this->AutoTargetOwnPosition_Self) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 3237832272..7cd9cd2a73 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -169,8 +169,10 @@ class TechnoTypeExt Valueable OpenTopped_UseTransportRangeModifiers; Valueable OpenTopped_CheckTransportDisableWeapons; Nullable OpenTopped_DecloakToFire; + Nullable OpenTopped_FireWhileMoving; Valueable OpenTransport_RangeBonus; Valueable OpenTransport_DamageMultiplier; + Nullable OpenTransport_FireWhileMoving; Valueable AutoTargetOwnPosition; Valueable AutoTargetOwnPosition_Self; @@ -617,8 +619,10 @@ class TechnoTypeExt , OpenTopped_UseTransportRangeModifiers { false } , OpenTopped_CheckTransportDisableWeapons { false } , OpenTopped_DecloakToFire {} + , OpenTopped_FireWhileMoving {} , OpenTransport_RangeBonus { 0 } , OpenTransport_DamageMultiplier { 1.0f } + , OpenTransport_FireWhileMoving {} , AutoTargetOwnPosition { false } , AutoTargetOwnPosition_Self { false }