diff --git a/CREDITS.md b/CREDITS.md index 3c73c31416..f82f19cd0a 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -510,6 +510,7 @@ This page lists all the individual contributions to the project by their author. - Fix the issue that `PassengerDeletion` dont consider passenger's passenger, parasite and hijacker - Fix the issue that power output of building on tooltip won't consider power enhancer - Fix the bug that the upgrade building's power-enhancing effect depends only on its parent building and is not related to the upgrade building itself + - Customize which parasite can remove by warhead - **Apollo** - Translucent SHP drawing patches - **ststl**: - Customizable `ShowTimer` priority of superweapons diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index bb96aa7b64..9152efbd09 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -2644,11 +2644,15 @@ Due to the nature of some superweapon types, not all superweapons are suitable f ### Parasite removal - By default if unit takes negative damage from a Warhead (before `Verses` are calculated), any parasites infecting it are removed and deleted. This behaviour can now be customized to disable the removal for negative damage, or enable it for any arbitrary warhead. +- `RemoveParasite.Allow` can be used to define which parasites can be removed. +- `RemoveParasite.Disallow` can be used to define which parasites cannot be removed. In `rulesmd.ini`: ```ini -[SOMEWARHEAD] ; WarheadType -RemoveParasite= ; boolean +[SOMEWARHEAD] ; WarheadType +RemoveParasite= ; boolean +RemoveParasite.Allow= ; List of TechnoTypes +RemoveParasite.Disallow= ; List of TechnoTypes ``` ### Penetrates damage on transporter diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 5ec9a2e433..0e7ba1fefc 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -551,6 +551,7 @@ New: - [Custom hover vehicles shutdown drowning death](New-or-Enhanced-Logics.md#custom-hover-vehicles-shutdown-drowning-death) (by FlyStar) - [SHP turret vehicles support the use of `*tur.shp` files](New-or-Enhanced-Logics.md#independent-shp-vehicle-turret-files) (by FlyStar) - [Implement `CurleyShuffle` for AircraftTypes](Fixed-or-Improved-Logics.md#implement-curleyshuffle-for-aircrafttypes) (ported from Vinifera by Noble_Fish) +- Customize which parasite can remove by warhead (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 2e515c958b..45bc208987 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po +++ b/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po @@ -1659,6 +1659,9 @@ msgid "" "itself" msgstr "修复了加载物建筑的电厂增幅效果仅取决于其基底建筑而非加载物建筑自身的 Bug" +msgid "Customize which parasite can remove by warhead" +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 722093a8fb..260f635c3a 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 @@ -5600,6 +5600,18 @@ msgstr "" "默认情况下如果单位从弹头收到负伤害(在 `Verses` " "前计算)任何寄生单位都会被移除和删除。现在可以自定义此行为以禁用负伤害的移除效果或为任意弹头启用它。" +msgid "" +"`RemoveParasite.Allow` can be used to define which parasites can be " +"removed." +msgstr "" +"`RemoveParasite.Allow` 定义哪些寄生者可以被移除。" + +msgid "" +"`RemoveParasite.Disallow` can be used to define which parasites cannot be" +" removed." +msgstr "" +"`RemoveParasite.Disallow` 定义哪些寄生者不能被移除。" + msgid "Penetrates damage on transporter" msgstr "对运输工具的穿透伤害" diff --git a/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po b/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po index 35fd3c1b42..0117fad822 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po +++ b/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po @@ -1750,6 +1750,9 @@ msgstr "" "[实现战机微观 `CurleyShuffle` 设置](Fixed-or-Improved-Logics.md#implement-" "curleyshuffle-for-aircrafttypes)(由 Noble_Fish 移植自 Vinifera)" +msgid "Customize which parasite can remove by warhead (by NetsuNegi)" +msgstr "自定义哪些寄生者可被弹头移除(by NetsuNegi)" + msgid "Vanilla fixes:" msgstr "原版问题修复:" diff --git a/src/Ext/WarheadType/Body.cpp b/src/Ext/WarheadType/Body.cpp index 9c741ef1e0..a61f004a51 100644 --- a/src/Ext/WarheadType/Body.cpp +++ b/src/Ext/WarheadType/Body.cpp @@ -150,6 +150,8 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->RemoveDisguise.Read(exINI, pSection, "RemoveDisguise"); this->RemoveMindControl.Read(exINI, pSection, "RemoveMindControl"); this->RemoveParasite.Read(exINI, pSection, "RemoveParasite"); + this->RemoveParasite_Allow.Read(exINI, pSection, "RemoveParasite.Allow"); + this->RemoveParasite_Disallow.Read(exINI, pSection, "RemoveParasite.Disallow"); this->DecloakDamagedTargets.Read(exINI, pSection, "DecloakDamagedTargets"); this->ShakeIsLocal.Read(exINI, pSection, "ShakeIsLocal"); this->ApplyModifiersOnNegativeDamage.Read(exINI, pSection, "ApplyModifiersOnNegativeDamage"); @@ -521,6 +523,8 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm) .Process(this->RemoveDisguise) .Process(this->RemoveMindControl) .Process(this->RemoveParasite) + .Process(this->RemoveParasite_Allow) + .Process(this->RemoveParasite_Disallow) .Process(this->DecloakDamagedTargets) .Process(this->ShakeIsLocal) .Process(this->ApplyModifiersOnNegativeDamage) diff --git a/src/Ext/WarheadType/Body.h b/src/Ext/WarheadType/Body.h index bad037f0ea..71aaee6351 100644 --- a/src/Ext/WarheadType/Body.h +++ b/src/Ext/WarheadType/Body.h @@ -41,6 +41,8 @@ class WarheadTypeExt Valueable RemoveDisguise; Valueable RemoveMindControl; Nullable RemoveParasite; + ValueableVector RemoveParasite_Allow; + ValueableVector RemoveParasite_Disallow; Valueable DecloakDamagedTargets; Valueable ShakeIsLocal; Valueable ApplyModifiersOnNegativeDamage; @@ -286,6 +288,8 @@ class WarheadTypeExt , RemoveDisguise { false } , RemoveMindControl { false } , RemoveParasite {} + , RemoveParasite_Allow {} + , RemoveParasite_Disallow {} , DecloakDamagedTargets { true } , ShakeIsLocal { false } , ApplyModifiersOnNegativeDamage { false } diff --git a/src/Ext/WarheadType/Hooks.cpp b/src/Ext/WarheadType/Hooks.cpp index 32c7507380..a706148224 100644 --- a/src/Ext/WarheadType/Hooks.cpp +++ b/src/Ext/WarheadType/Hooks.cpp @@ -567,11 +567,18 @@ DEFINE_HOOK(0x4D73DE, FootClass_ReceiveDamage_RemoveParasite, 0x5) GET(WarheadTypeClass*, pWarhead, EBP); GET(const int*, damage, EDI); - auto const pTypeExt = WarheadTypeExt::ExtMap.Find(pWarhead); + const auto pTypeExt = WarheadTypeExt::ExtMap.Find(pWarhead); if (!pTypeExt->RemoveParasite.Get(*damage < 0)) return Skip; + GET(FootClass*, pParasite, EDX); + const auto pParasiteType = pParasite->GetTechnoType(); + + if (pTypeExt->RemoveParasite_Disallow.Contains(pParasiteType) + || (!pTypeExt->RemoveParasite_Allow.empty() && !pTypeExt->RemoveParasite_Allow.Contains(pParasiteType))) + return Skip; + return Continue; }