Skip to content

Commit c50e77f

Browse files
[Vanilla Enhancement] Customize which parasite can remove by warhead (#2135)
In `rulesmd.ini`: ```ini [SOMEWARHEAD] ; WarheadType RemoveParasite.Allow= ; List of TechnoTypes RemoveParasite.Disallow= ; List of TechnoTypes ``` --------- Co-authored-by: Noble_Fish <1065703286@qq.com>
1 parent 46ba134 commit c50e77f

9 files changed

Lines changed: 42 additions & 3 deletions

File tree

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ This page lists all the individual contributions to the project by their author.
510510
- Fix the issue that `PassengerDeletion` dont consider passenger's passenger, parasite and hijacker
511511
- Fix the issue that power output of building on tooltip won't consider power enhancer
512512
- 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
513+
- Customize which parasite can remove by warhead
513514
- **Apollo** - Translucent SHP drawing patches
514515
- **ststl**:
515516
- Customizable `ShowTimer` priority of superweapons

docs/New-or-Enhanced-Logics.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,11 +2644,15 @@ Due to the nature of some superweapon types, not all superweapons are suitable f
26442644
### Parasite removal
26452645

26462646
- 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.
2647+
- `RemoveParasite.Allow` can be used to define which parasites can be removed.
2648+
- `RemoveParasite.Disallow` can be used to define which parasites cannot be removed.
26472649

26482650
In `rulesmd.ini`:
26492651
```ini
2650-
[SOMEWARHEAD] ; WarheadType
2651-
RemoveParasite= ; boolean
2652+
[SOMEWARHEAD] ; WarheadType
2653+
RemoveParasite= ; boolean
2654+
RemoveParasite.Allow= ; List of TechnoTypes
2655+
RemoveParasite.Disallow= ; List of TechnoTypes
26522656
```
26532657

26542658
### Penetrates damage on transporter

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ New:
551551
- [Custom hover vehicles shutdown drowning death](New-or-Enhanced-Logics.md#custom-hover-vehicles-shutdown-drowning-death) (by FlyStar)
552552
- [SHP turret vehicles support the use of `*tur.shp` files](New-or-Enhanced-Logics.md#independent-shp-vehicle-turret-files) (by FlyStar)
553553
- [Implement `CurleyShuffle` for AircraftTypes](Fixed-or-Improved-Logics.md#implement-curleyshuffle-for-aircrafttypes) (ported from Vinifera by Noble_Fish)
554+
- Customize which parasite can remove by warhead (by NetsuNegi)
554555
555556
Vanilla fixes:
556557
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

docs/locale/zh_CN/LC_MESSAGES/CREDITS.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,9 @@ msgid ""
16591659
"itself"
16601660
msgstr "修复了加载物建筑的电厂增幅效果仅取决于其基底建筑而非加载物建筑自身的 Bug"
16611661

1662+
msgid "Customize which parasite can remove by warhead"
1663+
msgstr "自定义哪些寄生者可被弹头移除"
1664+
16621665
msgid "**Apollo** - Translucent SHP drawing patches"
16631666
msgstr "**Apollo** - 半透明 SHP 绘制补丁"
16641667

docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5600,6 +5600,18 @@ msgstr ""
56005600
"默认情况下如果单位从弹头收到负伤害(在 `Verses` "
56015601
"前计算)任何寄生单位都会被移除和删除。现在可以自定义此行为以禁用负伤害的移除效果或为任意弹头启用它。"
56025602

5603+
msgid ""
5604+
"`RemoveParasite.Allow` can be used to define which parasites can be "
5605+
"removed."
5606+
msgstr ""
5607+
"`RemoveParasite.Allow` 定义哪些寄生者可以被移除。"
5608+
5609+
msgid ""
5610+
"`RemoveParasite.Disallow` can be used to define which parasites cannot be"
5611+
" removed."
5612+
msgstr ""
5613+
"`RemoveParasite.Disallow` 定义哪些寄生者不能被移除。"
5614+
56035615
msgid "Penetrates damage on transporter"
56045616
msgstr "对运输工具的穿透伤害"
56055617

docs/locale/zh_CN/LC_MESSAGES/Whats-New.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,9 @@ msgstr ""
17501750
"[实现战机微观 `CurleyShuffle` 设置](Fixed-or-Improved-Logics.md#implement-"
17511751
"curleyshuffle-for-aircrafttypes)(由 Noble_Fish 移植自 Vinifera)"
17521752

1753+
msgid "Customize which parasite can remove by warhead (by NetsuNegi)"
1754+
msgstr "自定义哪些寄生者可被弹头移除(by NetsuNegi)"
1755+
17531756
msgid "Vanilla fixes:"
17541757
msgstr "原版问题修复:"
17551758

src/Ext/WarheadType/Body.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
147147
this->RemoveDisguise.Read(exINI, pSection, "RemoveDisguise");
148148
this->RemoveMindControl.Read(exINI, pSection, "RemoveMindControl");
149149
this->RemoveParasite.Read(exINI, pSection, "RemoveParasite");
150+
this->RemoveParasite_Allow.Read(exINI, pSection, "RemoveParasite.Allow");
151+
this->RemoveParasite_Disallow.Read(exINI, pSection, "RemoveParasite.Disallow");
150152
this->DecloakDamagedTargets.Read(exINI, pSection, "DecloakDamagedTargets");
151153
this->ShakeIsLocal.Read(exINI, pSection, "ShakeIsLocal");
152154
this->ApplyModifiersOnNegativeDamage.Read(exINI, pSection, "ApplyModifiersOnNegativeDamage");
@@ -518,6 +520,8 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
518520
.Process(this->RemoveDisguise)
519521
.Process(this->RemoveMindControl)
520522
.Process(this->RemoveParasite)
523+
.Process(this->RemoveParasite_Allow)
524+
.Process(this->RemoveParasite_Disallow)
521525
.Process(this->DecloakDamagedTargets)
522526
.Process(this->ShakeIsLocal)
523527
.Process(this->ApplyModifiersOnNegativeDamage)

src/Ext/WarheadType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class WarheadTypeExt
4141
Valueable<bool> RemoveDisguise;
4242
Valueable<bool> RemoveMindControl;
4343
Nullable<bool> RemoveParasite;
44+
ValueableVector<TechnoTypeClass*> RemoveParasite_Allow;
45+
ValueableVector<TechnoTypeClass*> RemoveParasite_Disallow;
4446
Valueable<bool> DecloakDamagedTargets;
4547
Valueable<bool> ShakeIsLocal;
4648
Valueable<bool> ApplyModifiersOnNegativeDamage;
@@ -285,6 +287,8 @@ class WarheadTypeExt
285287
, RemoveDisguise { false }
286288
, RemoveMindControl { false }
287289
, RemoveParasite {}
290+
, RemoveParasite_Allow {}
291+
, RemoveParasite_Disallow {}
288292
, DecloakDamagedTargets { true }
289293
, ShakeIsLocal { false }
290294
, ApplyModifiersOnNegativeDamage { false }

src/Ext/WarheadType/Hooks.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,18 @@ DEFINE_HOOK(0x4D73DE, FootClass_ReceiveDamage_RemoveParasite, 0x5)
567567
GET(WarheadTypeClass*, pWarhead, EBP);
568568
GET(const int*, damage, EDI);
569569

570-
auto const pTypeExt = WarheadTypeExt::ExtMap.Find(pWarhead);
570+
const auto pTypeExt = WarheadTypeExt::ExtMap.Find(pWarhead);
571571

572572
if (!pTypeExt->RemoveParasite.Get(*damage < 0))
573573
return Skip;
574574

575+
GET(FootClass*, pParasite, EDX);
576+
const auto pParasiteType = pParasite->GetTechnoType();
577+
578+
if (pTypeExt->RemoveParasite_Disallow.Contains(pParasiteType)
579+
|| (!pTypeExt->RemoveParasite_Allow.empty() && !pTypeExt->RemoveParasite_Allow.Contains(pParasiteType)))
580+
return Skip;
581+
575582
return Continue;
576583
}
577584

0 commit comments

Comments
 (0)