diff --git a/CREDITS.md b/CREDITS.md index 5a62ee5ac4..ce467a5e43 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -563,6 +563,7 @@ This page lists all the individual contributions to the project by their author. - Customize crash spin multiplier - Customize reveal radius of `RevealToAll` - Fix the bug that technos do not reset their link with the linked building when deactivated + - Customize whether warhead can prevent crew escape from techno - **Apollo** - Translucent SHP drawing patches - **ststl**: - Customizable `ShowTimer` priority of superweapons diff --git a/YRpp b/YRpp index 0448458fa0..8531d82713 160000 --- a/YRpp +++ b/YRpp @@ -1 +1 @@ -Subproject commit 0448458fa093c1a4d6e2e078583cb24475fd2b8c +Subproject commit 8531d82713dab0b2d3f1bd9bf24209474b49a69a diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 6b9671da80..b6fb539452 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -3291,6 +3291,16 @@ UnlimboDetonate.KeepSelected=true ; boolean `UnlimboDetonate` cannot be used in conjunction with `Parasite`. ``` +### Customize whether warhead can prevent crew escape from techno + +In `rulesmd.ini`: +```ini +[SOMEWARHEAD] ; WarheadType +PreventCrew=false ; boolean +PreventPassengerEscape=false ; boolean +PreventOccupantEscape=false ; boolean +``` + ## Weapons ### Allow Laser drawing position update diff --git a/docs/Whats-New.md b/docs/Whats-New.md index cea113e83f..5159dc69b0 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -663,6 +663,7 @@ HideShakeEffects=false ; boolean - SkipMapSelect Enhancement (by FlyStar) - [Allow the unit to stop immediately if the target enters the range during ApproachTarget](Fixed-or-Improved-Logics.md#stop-immediately-if-the-target-enters-the-range-during-approachtarget) (by TaranDahl) - [Allow the unit to keep pursuing the target during ApproachTarget](Fixed-or-Improved-Logics.md#keep-pursuing-the-target-during-approachtarget) (by TaranDahl) +- [Customize whether warhead can prevent crew escape from techno](New-or-Enhanced-Logics.md#customize-whether-warhead-can-prevent-crew-escape-from-techno) (by NetsuNegi) #### 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/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po b/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po index 751fddc91b..a2e88d1a86 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po +++ b/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po @@ -1848,6 +1848,10 @@ msgid "" " when deactivated" msgstr "修复了单位失灵时不会重置其与相链接建筑链接状态的 Bug" +msgid "" +"Customize whether warhead can prevent crew escape from techno" +msgstr "自定义弹头是否阻止生还者逃出" + msgid "**Apollo** - Translucent SHP drawing patches" msgstr "**Apollo** - 半透明 SHP 绘制补丁" diff --git a/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po b/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po index 74688f0890..9878b5d8fa 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po +++ b/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po @@ -6515,6 +6515,10 @@ msgstr "`UnlimboDetonate.KeepSelected` 允许单位进出 Limbo 状态前保留 msgid "`UnlimboDetonate` cannot be used in conjunction with `Parasite`." msgstr "`UnlimboDetonate` 不能与 `Parasite` 共用。" +msgid "" +"Customize whether warhead can prevent crew escape from techno" +msgstr "自定义弹头是否阻止生还者逃出" + msgid "Weapons" msgstr "武器" diff --git a/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po b/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po index bd05bf539d..a680f6ab04 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po +++ b/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po @@ -2388,6 +2388,11 @@ msgstr "" "[`600` 配置掉落箱子行为](AI-Scripting-and-Mapping.md#configure-drop-crate)(by " "FS-21)" +msgid "" +"[Customize whether warhead can prevent crew escape from techno](New-or-Enhanced-Logics.md#customize-whether-warhead-can-prevent-crew-escape-from-techno) (by NetsuNegi)" +msgstr "" +"[自定义弹头是否阻止生还者逃出](New-or-Enhanced-Logics.md#customize-whether-warhead-can-prevent-crew-escape-from-techno)(by NetsuNegi)" + msgid "Vanilla fixes:" msgstr "原版问题修复:" diff --git a/src/Ext/Techno/Body.cpp b/src/Ext/Techno/Body.cpp index 31327f0126..b1c61de632 100644 --- a/src/Ext/Techno/Body.cpp +++ b/src/Ext/Techno/Body.cpp @@ -1200,6 +1200,7 @@ void TechnoExt::Serialize(T& Stm) .Process(this->LastTargetCrd) .Process(this->LastTargetCrdClearTimer) .Process(this->ShouldBeDead) + .Process(this->PreventCrew) ; } diff --git a/src/Ext/Techno/Hooks.ReceiveDamage.cpp b/src/Ext/Techno/Hooks.ReceiveDamage.cpp index 1d2be6a02c..99e11f71c8 100644 --- a/src/Ext/Techno/Hooks.ReceiveDamage.cpp +++ b/src/Ext/Techno/Hooks.ReceiveDamage.cpp @@ -248,14 +248,39 @@ DEFINE_HOOK(0x702603, TechnoClass_ReceiveDamage_Explodes, 0x6) DEFINE_HOOK(0x702672, TechnoClass_ReceiveDamage_RevengeWeapon, 0x5) { GET(TechnoClass*, pThis, ESI); - GET_STACK(TechnoClass*, pSource, STACK_OFFSET(0xC4, 0x10)); GET_STACK(WarheadTypeClass*, pWarhead, STACK_OFFSET(0xC4, 0xC)); + GET_STACK(TechnoClass*, pSource, STACK_OFFSET(0xC4, 0x10)); TechnoExt::ApplyKillWeapon(pThis, pSource, pWarhead); if (pSource) TechnoExt::ApplyRevengeWeapon(pThis, pSource, pWarhead); + const auto pWHExt = WarheadTypeExt::Fetch(pWarhead); + + if (pWHExt->PreventCrew) + TechnoExt::Fetch(pThis)->PreventCrew = true; + + if (pWHExt->PreventPassengerEscape) + pThis->KillPassengers(pSource); + + return 0; +} + +DEFINE_HOOK(0x442635, BuildingClass_ReceiveDamage_PreventOccupantEscape, 0x6) +{ + enum { SkipClearOccupants = 0x442640 }; + + GET_STACK(WarheadTypeClass*, pWarhead, STACK_OFFSET(0x9C, 0xC)); + + if (WarheadTypeExt::Fetch(pWarhead)->PreventOccupantEscape) + { + GET(BuildingClass*, pThis, ESI); + GET_STACK(TechnoClass*, pSource, STACK_OFFSET(0x9C, 0x10)); + pThis->KillOccupants(pSource); + return SkipClearOccupants; + } + return 0; } diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index 52bdc3737c..2301cdde75 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -2382,3 +2382,35 @@ void DeactivateTemp::TechnoClassFake::_Deactivate() } } DEFINE_FUNCTION_JUMP(LJMP, 0x70FC90, DeactivateTemp::TechnoClassFake::_Deactivate) + +#pragma region Crew + +namespace CrewTemp +{ + class TechnoClassFake final : public TechnoClass + { + int _GetCrewCount() const + { + const auto pThis = static_cast(this); + const auto pExt = TechnoExt::Fetch(pThis); + return pExt->PreventCrew ? 0 : pThis->TechnoClass::GetCrewCount(); + } + }; + + class BuildingClassFake final : public BuildingClass + { + int _GetCrewCount() const + { + const auto pThis = static_cast(this); + const auto pExt = TechnoExt::Fetch(pThis); + return pExt->PreventCrew ? 0 : pThis->BuildingClass::GetCrewCount(); + } + }; +} + +DEFINE_FUNCTION_JUMP(VTABLE, 0x7E2574, CrewTemp::TechnoClassFake::_GetCrewCount) // AircraftClass +DEFINE_FUNCTION_JUMP(VTABLE, 0x7EB328, CrewTemp::TechnoClassFake::_GetCrewCount) // InfantryClass +DEFINE_FUNCTION_JUMP(VTABLE, 0x7F5F40, CrewTemp::TechnoClassFake::_GetCrewCount) // UnitClass +DEFINE_FUNCTION_JUMP(VTABLE, 0x7E418C, CrewTemp::BuildingClassFake::_GetCrewCount) // BuildingClass + +#pragma endregion diff --git a/src/Ext/WarheadType/Body.cpp b/src/Ext/WarheadType/Body.cpp index 9226fc2fb7..4f4c72a668 100644 --- a/src/Ext/WarheadType/Body.cpp +++ b/src/Ext/WarheadType/Body.cpp @@ -445,6 +445,10 @@ void WarheadTypeExt::LoadFromINIFile(CCINIClass* const pINI) this->Psychedelic_StackingMode.Read(exINI, pSection, "Psychedelic.StackingMode"); + this->PreventCrew.Read(exINI, pSection, "PreventCrew"); + this->PreventPassengerEscape.Read(exINI, pSection, "PreventPassengerEscape"); + this->PreventOccupantEscape.Read(exINI, pSection, "PreventOccupantEscape"); + // Convert.From & Convert.To TypeConvertGroup::Parse(this->Convert_Pairs, exINI, pSection, AffectedHouse::All); @@ -793,6 +797,10 @@ void WarheadTypeExt::Serialize(T& Stm) .Process(this->Psychedelic_StackingMode) + .Process(this->PreventCrew) + .Process(this->PreventPassengerEscape) + .Process(this->PreventOccupantEscape) + // Ares tags .Process(this->AffectsEnemies) .Process(this->AffectsOwner) diff --git a/src/Ext/WarheadType/Body.h b/src/Ext/WarheadType/Body.h index 569a772fb6..b9ceb2c112 100644 --- a/src/Ext/WarheadType/Body.h +++ b/src/Ext/WarheadType/Body.h @@ -266,6 +266,10 @@ class WarheadTypeExt final : public AbstractTypeExt Nullable Psychedelic_StackingMode; + Valueable PreventCrew; + Valueable PreventPassengerEscape; + Valueable PreventOccupantEscape; + // Ares tags // http://ares-developers.github.io/Ares-docs/new/warheads/general.html Valueable AffectsEnemies; @@ -556,6 +560,10 @@ class WarheadTypeExt final : public AbstractTypeExt , Taunt { false } , Psychedelic_StackingMode {} + + , PreventCrew { false } + , PreventPassengerEscape { false } + , PreventOccupantEscape { false } { } void ApplyConvert(HouseClass* pHouse, TechnoClass* pTarget);