diff --git a/CREDITS.md b/CREDITS.md index 521e2dde1e..48ac94bb01 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -317,6 +317,7 @@ This page lists all the individual contributions to the project by their author. - Iron Curtain effects customization on infantries and organic units - Use `CustomPalette` for animations with `Tiled=yes` - Unlimited `AlternateFLH` entries + - Customizing whether passengers are kicked out when an aircraft fires - **TwinkleStar** - Custom slaves free sound - Jumpjet crash rotation control diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 3a3db84c8b..17acc4182a 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -1116,6 +1116,16 @@ ROF.RandomDelay=0,2 ; integer - single or comma-sep. range (game frames) ROF.RandomDelay= ; integer - single or comma-sep. range (game frames) ``` +### Customizing whether passengers are kicked out when an aircraft fires + +- You can now customize whether aircraft will forcefully eject passengers (vanilla behavior) or fire its weapon when attempting to fire. + +In `rulesmd.ini` +```ini +[SOMEWEAPON] +KickOutPassengers=true ; boolean +``` + ### Single-color lasers ![image](_static/images/issinglecolor.gif) diff --git a/docs/Whats-New.md b/docs/Whats-New.md index ce4ce13649..38d283e92b 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -413,6 +413,7 @@ New: - Allow customizing Aircraft weapon strafing regardless of `ROT` and `Strafing.Shots` values beyond 5 (by Trsdy) - Allow strafing weapons to deduct ammo per shot instead of per strafing run (by Starkku) - Allow `CloakVisible=true` laser trails optinally be seen only if unit is detected (by Starkku) +- Customizing whether passengers are kicked out when an aircraft fires (by ststl) Vanilla fixes: - Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy) diff --git a/src/Ext/Aircraft/Hooks.cpp b/src/Ext/Aircraft/Hooks.cpp index f1a9c6e556..89db20dc18 100644 --- a/src/Ext/Aircraft/Hooks.cpp +++ b/src/Ext/Aircraft/Hooks.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -308,3 +309,23 @@ DEFINE_HOOK(0x4CF68D, FlyLocomotionClass_DrawMatrix_OnAirport, 0x5) return 0; } + +DEFINE_HOOK(0x415EEE, AircraftClass_Fire_KickOutPassengers, 0x6) +{ + enum { SkipKickOutPassengers = 0x415F08 }; + + GET(AircraftClass*, pThis, EDI); + GET_BASE(int, weaponIdx, 0xC); + + auto const pWeapon = pThis->GetWeapon(weaponIdx)->WeaponType; + + if (!pWeapon) + return 0; + + auto const pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon); + + if (pWeaponExt->KickOutPassengers) + return 0; + + return SkipKickOutPassengers; +} diff --git a/src/Ext/Techno/Body.cpp b/src/Ext/Techno/Body.cpp index 7ecb9706ea..badbd1780f 100644 --- a/src/Ext/Techno/Body.cpp +++ b/src/Ext/Techno/Body.cpp @@ -37,14 +37,14 @@ TechnoExt::ExtData::~ExtData() bool TechnoExt::IsActive(TechnoClass* pThis) { - return - pThis && - !pThis->TemporalTargetingMe && - !pThis->BeingWarpedOut && - !pThis->IsUnderEMP() && - pThis->IsAlive && - pThis->Health > 0 && - !pThis->InLimbo; + return pThis + && pThis->IsAlive + && pThis->Health > 0 + && !pThis->InLimbo + && !pThis->TemporalTargetingMe + && !pThis->BeingWarpedOut + && !pThis->IsUnderEMP() + ; } bool TechnoExt::IsHarvesting(TechnoClass* pThis) diff --git a/src/Ext/WeaponType/Body.cpp b/src/Ext/WeaponType/Body.cpp index 8e7f6ff9e3..b7ea2d917f 100644 --- a/src/Ext/WeaponType/Body.cpp +++ b/src/Ext/WeaponType/Body.cpp @@ -102,6 +102,7 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->AttachEffect_DisallowedMinCounts.Read(exINI, pSection, "AttachEffect.DisallowedMinCounts"); this->AttachEffect_DisallowedMaxCounts.Read(exINI, pSection, "AttachEffect.DisallowedMaxCounts"); this->AttachEffect_IgnoreFromSameSource.Read(exINI, pSection, "AttachEffect.IgnoreFromSameSource"); + this->KickOutPassengers.Read(exINI, pSection, "KickOutPassengers"); } template @@ -141,6 +142,7 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm) .Process(this->AttachEffect_DisallowedMinCounts) .Process(this->AttachEffect_DisallowedMaxCounts) .Process(this->AttachEffect_IgnoreFromSameSource) + .Process(this->KickOutPassengers) ; }; diff --git a/src/Ext/WeaponType/Body.h b/src/Ext/WeaponType/Body.h index 2f83b150e5..4f42a724f4 100644 --- a/src/Ext/WeaponType/Body.h +++ b/src/Ext/WeaponType/Body.h @@ -54,6 +54,7 @@ class WeaponTypeExt ValueableVector AttachEffect_DisallowedMinCounts; ValueableVector AttachEffect_DisallowedMaxCounts; Valueable AttachEffect_IgnoreFromSameSource; + Valueable KickOutPassengers; ExtData(WeaponTypeClass* OwnerObject) : Extension(OwnerObject) , DiskLaser_Radius { DiskLaserClass::Radius } @@ -89,6 +90,7 @@ class WeaponTypeExt , AttachEffect_DisallowedMinCounts {} , AttachEffect_DisallowedMaxCounts {} , AttachEffect_IgnoreFromSameSource { false } + , KickOutPassengers { true } { } int GetBurstDelay(int burstIndex) const;