From 3b652dc3e171f43e10e4ee0238d8baa8c015a737 Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Sun, 28 Jun 2026 23:38:46 +0800 Subject: [PATCH 01/11] AutoDeath based on player power status --- docs/New-or-Enhanced-Logics.md | 4 ++++ docs/Whats-New.md | 1 + src/Ext/Techno/Body.Update.cpp | 12 ++++++++++++ src/Ext/TechnoType/Body.cpp | 2 ++ src/Ext/TechnoType/Body.h | 2 ++ src/Utilities/Enum.h | 7 +++++++ src/Utilities/TemplateDef.h | 27 +++++++++++++++++++++++++++ 7 files changed, 55 insertions(+) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index dcb3358057..2f03a6a22b 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1926,6 +1926,9 @@ Both `InitialStrength` and `InitialStrength.Cloning` never surpass the type's `S - `Technos(Dont)Exist.Any` controls whether or not a single listed TechnoType is enough to satisfy the requirement or if all are required. - `Technos(Dont)Exist.AllowLimboed` controls whether or not limboed TechnoTypes (f.ex those in transports) are counted. - `Technos(Dont)Exist.Houses` controls which houses are checked. + - `PlayerPower`: The object will die if its owner's power status matches the configured state. + - `low / consumer`: Trigger when the owner is in low power. + - `normal`: Trigger when the owner is not in low power. - The auto-death behavior can be chosen from the following: - `kill`: The object will be destroyed normally. @@ -1952,6 +1955,7 @@ AutoDeath.TechnosExist= ; List of TechnoTypes AutoDeath.TechnosExist.Any=true ; boolean AutoDeath.TechnosExist.AllowLimboed=false ; boolean AutoDeath.TechnosExist.Houses=owner ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all) +AutoDeath.PlayerPower=none ; Player Power Enumeration (none|low/consumer|normal) ``` ```{note} diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 0b297249f0..ed9a30117b 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -592,6 +592,7 @@ HideShakeEffects=false ; boolean - [Animation transparency customization settings](New-or-Enhanced-Logics.md#customizable-animation-transparency-settings) (by Starkku) - [Customize `Tiled` drawing interval and centering](Fixed-or-Improved-Logics.md#customize-the-drawing-interval-for-tiled) (by Noble_Fish) - [Customize whether technos with `Locomotor=Fly` wobble](Fixed-or-Improved-Logics.md#customize-whether-technos-with-locomotor-fly-wobble) (by Noble_Fish) +- [AutoDeath based on player power status](New-or-Enhanced-Logics.md#kill-object-automatically) (by Flactine) #### 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/Techno/Body.Update.cpp b/src/Ext/Techno/Body.Update.cpp index 8b8ed569bd..166df7f0dc 100644 --- a/src/Ext/Techno/Body.Update.cpp +++ b/src/Ext/Techno/Body.Update.cpp @@ -331,6 +331,18 @@ bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo) : std::all_of(vTypes.begin(), vTypes.end(), existSingleType); }; + // death if player power status is not as specified + if (pTypeExt->AutoDeath_PlayerPowerStatus != PlayerPowerStatus::None) + { + const bool isLowPower = pOwner->PowerDrain > pOwner->PowerOutput; + + if ((pTypeExt->AutoDeath_PlayerPowerStatus == PlayerPowerStatus::Normal && !isLowPower) || (pTypeExt->AutoDeath_PlayerPowerStatus == PlayerPowerStatus::Consumer && isLowPower)) + { + TechnoExt::KillSelf(pThis, howToDie, pTypeExt->AutoDeath_VanishAnimation, isInLimbo); + return true; + } + } + // death if listed technos don't exist if (!pTypeExt->AutoDeath_TechnosDontExist.empty()) { diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 55a153f919..9671675ad3 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -798,6 +798,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->AutoDeath_TechnosExist_Any.Read(exINI, pSection, "AutoDeath.TechnosExist.Any"); this->AutoDeath_TechnosExist_AllowLimboed.Read(exINI, pSection, "AutoDeath.TechnosExist.AllowLimboed"); this->AutoDeath_TechnosExist_Houses.Read(exINI, pSection, "AutoDeath.TechnosExist.Houses"); + this->AutoDeath_PlayerPowerStatus.Read(exINI, pSection, "AutoDeath.PlayerPowerStatus"); this->Slaved_OwnerWhenMasterKilled.Read(exINI, pSection, "Slaved.OwnerWhenMasterKilled"); this->SlavesFreeSound.Read(exINI, pSection, "SlavesFreeSound"); @@ -1548,6 +1549,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->AutoDeath_TechnosExist_Any) .Process(this->AutoDeath_TechnosExist_AllowLimboed) .Process(this->AutoDeath_TechnosExist_Houses) + .Process(this->AutoDeath_PlayerPowerStatus) .Process(this->Slaved_OwnerWhenMasterKilled) .Process(this->SlavesFreeSound) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 0571b99caf..f5135577fd 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -105,6 +105,7 @@ class TechnoTypeExt Valueable AutoDeath_TechnosExist_Any; Valueable AutoDeath_TechnosExist_AllowLimboed; Valueable AutoDeath_TechnosExist_Houses; + Valueable AutoDeath_PlayerPowerStatus; Valueable Slaved_OwnerWhenMasterKilled; NullableIdx SlavesFreeSound; @@ -653,6 +654,7 @@ class TechnoTypeExt , AutoDeath_TechnosExist_Any { true } , AutoDeath_TechnosExist_AllowLimboed { true } , AutoDeath_TechnosExist_Houses { AffectedHouse::Owner } + , AutoDeath_PlayerPowerStatus { PlayerPowerStatus::None } , Slaved_OwnerWhenMasterKilled { SlaveChangeOwnerType::Killer } , SlavesFreeSound {} diff --git a/src/Utilities/Enum.h b/src/Utilities/Enum.h index 2e9d9645f4..f9c7cb0795 100644 --- a/src/Utilities/Enum.h +++ b/src/Utilities/Enum.h @@ -188,6 +188,13 @@ enum class AutoDeathBehavior Sell = 2, // buildings only }; +enum class PlayerPowerStatus +{ + None = 0, + Normal = 1, // not low power + Consumer = 2, // low power +}; + enum class SelfHealGainType { NoHeal = 0, diff --git a/src/Utilities/TemplateDef.h b/src/Utilities/TemplateDef.h index dcac3f3534..624b26bd78 100644 --- a/src/Utilities/TemplateDef.h +++ b/src/Utilities/TemplateDef.h @@ -1625,6 +1625,33 @@ if(_strcmpi(parser.value(), #name) == 0){ value = __uuidof(name ## LocomotionCla Debug::INIParseFailed(pSection, pKey, pCur); } } + + template <> + inline bool read(PlayerPowerStatus& value, INI_EX& parser, const char* pSection, const char* pKey) + { + if (parser.ReadString(pSection, pKey)) + { + static const std::pair Names[] = + { + {"none", PlayerPowerStatus::None}, + {"consumer", PlayerPowerStatus::Consumer}, + {"low", PlayerPowerStatus::Consumer}, + {"normal", PlayerPowerStatus::Normal}, + }; + + for (auto const& [name, val] : Names) + { + if (_strcmpi(parser.value(), name) == 0) + { + value = val; + return true; + } + } + + Debug::INIParseFailed(pSection, pKey, parser.value(), "Expected a valid PlayerPowerStatus (none, normal, low|consumer"); + } + return false; + } } // Valueable From 097b425c30e38b55ae4d556ab522d0e9856166ca Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Sun, 28 Jun 2026 23:45:43 +0800 Subject: [PATCH 02/11] Update New-or-Enhanced-Logics.md --- docs/New-or-Enhanced-Logics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 2f03a6a22b..4415a825a1 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1955,7 +1955,7 @@ AutoDeath.TechnosExist= ; List of TechnoTypes AutoDeath.TechnosExist.Any=true ; boolean AutoDeath.TechnosExist.AllowLimboed=false ; boolean AutoDeath.TechnosExist.Houses=owner ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all) -AutoDeath.PlayerPower=none ; Player Power Enumeration (none|low/consumer|normal) +AutoDeath.PlayerPowerStatus=none ; Player Power Enumeration (none|low/consumer|normal) ``` ```{note} From aa6fdebd57e15684fc96365d3ba70eba98df6474 Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Sun, 28 Jun 2026 23:58:24 +0800 Subject: [PATCH 03/11] Update CREDITS.md --- CREDITS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.md b/CREDITS.md index d64e4ff175..6db1cc5883 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -820,6 +820,7 @@ This page lists all the individual contributions to the project by their author. - **Flactine** - Add target filtering options to attacheffect system - Add veterancy-based target filtering for weapons and warheads + - Add a new AutoDeath condition based on the owner's power status - **tyuah8**: - Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix - Destroyed unit leaves sensors bugfix From 5411afa5e89da6584bc2684a2b0115a6698c67e8 Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Mon, 29 Jun 2026 00:49:24 +0800 Subject: [PATCH 04/11] update docs --- docs/New-or-Enhanced-Logics.md | 4 ++-- docs/Whats-New.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 5529187716..650ff06ff1 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1925,8 +1925,8 @@ Both `InitialStrength` and `InitialStrength.Cloning` never surpass the type's `S - `Technos(Dont)Exist.AllowLimboed` controls whether or not limboed TechnoTypes (f.ex those in transports) are counted. - `Technos(Dont)Exist.Houses` controls which houses are checked. - `PlayerPower`: The object will die if its owner's power status matches the configured state. - - `low / consumer`: Trigger when the owner is in low power. - - `normal`: Trigger when the owner is not in low power. + - `low` / `consumer`: Trigger when the owner is in low power. + - `normal`: Trigger when the owner is not in low power. - The auto-death behavior can be chosen from the following: - `kill`: The object will be destroyed normally. diff --git a/docs/Whats-New.md b/docs/Whats-New.md index b79665e3f9..1b0af85a50 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -592,12 +592,12 @@ HideShakeEffects=false ; boolean - [Animation transparency customization settings](Fixed-or-Improved-Logics.md#customizable-animation-transparency-settings) (by Starkku) - [Customize `Tiled` drawing interval and centering](Fixed-or-Improved-Logics.md#customize-tiled-drawing-interval-and-centering) (by Noble_Fish) - [Customize whether technos with `Locomotor=Fly` wobble](Fixed-or-Improved-Logics.md#customize-whether-technos-with-locomotor-fly-wobble) (by Noble_Fish) -- [AutoDeath based on player power status](New-or-Enhanced-Logics.md#kill-object-automatically) (by Flactine) - [Customize the landing animation of technos that have `Locomotor=Fly`](Fixed-or-Improved-Logics.md#customize-the-landing-animation-of-technos-that-have-locomotor-fly) (by Noble_Fish) - [Allow infantry to perform type conversion when deploying and undeploying](New-or-Enhanced-Logics.md#allow-infantry-to-perform-type-conversion-when-deploying-and-undeploying) (by Noble_Fish) - Add `ClampToScreen` tag for `BannerType` (defaults to `true`) to control whether banner position is clamped to the visible area (by Chang_zhi) - [Customizable Berzerk mission](Fixed-or-Improved-Logics.md#enhanced-berzerk-behavior) (by TaranDahl) - [Tank Bunker foundation and state update delay improvements](Fixed-or-Improved-Logics.md#tank-bunker-improvements) (by Starkku) +- [AutoDeath based on player power status](New-or-Enhanced-Logics.md#kill-object-automatically) (by Flactine) #### Vanilla fixes: - Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya) From 3ed5552c184febc160ae64a20d24fededd70d330 Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Wed, 1 Jul 2026 21:37:00 +0800 Subject: [PATCH 05/11] Player Credits --- docs/New-or-Enhanced-Logics.md | 8 +++++ docs/Whats-New.md | 2 +- .../LC_MESSAGES/New-or-Enhanced-Logics.po | 27 ++++++++++++++ src/Ext/Techno/Body.Update.cpp | 36 +++++++++++++++++-- src/Ext/TechnoType/Body.cpp | 4 +++ src/Ext/TechnoType/Body.h | 4 +++ src/Utilities/Enum.h | 2 +- src/Utilities/TemplateDef.h | 4 +-- 8 files changed, 80 insertions(+), 7 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 650ff06ff1..27079332b3 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1927,6 +1927,12 @@ Both `InitialStrength` and `InitialStrength.Cloning` never surpass the type's `S - `PlayerPower`: The object will die if its owner's power status matches the configured state. - `low` / `consumer`: Trigger when the owner is in low power. - `normal`: Trigger when the owner is not in low power. + - `PlayerMoneyLessThan` / `PlayerMoneyMoreThan`: The object will die based on the owner's available credits. + - If only `PlayerMoneyLessThan` is set, triggers when money is below this value. + - If only `PlayerMoneyMoreThan` is set, triggers when money is above this value. + - If both are set, they define a range condition: + - If `PlayerMoneyLessThan < PlayerMoneyMoreThan`: triggers when money is **inside the range**. + - If `PlayerMoneyLessThan >= PlayerMoneyMoreThan`: triggers when money is **outside the range**. - The auto-death behavior can be chosen from the following: - `kill`: The object will be destroyed normally. @@ -1954,6 +1960,8 @@ AutoDeath.TechnosExist.Any=true ; boolean AutoDeath.TechnosExist.AllowLimboed=false ; boolean AutoDeath.TechnosExist.Houses=owner ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all) AutoDeath.PlayerPowerStatus=none ; Player Power Enumeration (none|low/consumer|normal) +AutoDeath.PlayerMoneyLessThan=-1 ; integer +AutoDeath.PlayerMoneyMoreThan=-1 ; integer ``` ```{note} diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 1b0af85a50..c3ae519da6 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -597,7 +597,7 @@ HideShakeEffects=false ; boolean - Add `ClampToScreen` tag for `BannerType` (defaults to `true`) to control whether banner position is clamped to the visible area (by Chang_zhi) - [Customizable Berzerk mission](Fixed-or-Improved-Logics.md#enhanced-berzerk-behavior) (by TaranDahl) - [Tank Bunker foundation and state update delay improvements](Fixed-or-Improved-Logics.md#tank-bunker-improvements) (by Starkku) -- [AutoDeath based on player power status](New-or-Enhanced-Logics.md#kill-object-automatically) (by Flactine) +- [AutoDeath based on player power status and player credits](New-or-Enhanced-Logics.md#kill-object-automatically) (by Flactine) #### 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/New-or-Enhanced-Logics.po b/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po index 4ce74a3ea9..8962aedbcc 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 @@ -4425,6 +4425,33 @@ msgstr "`Technos(Dont)Exist.AllowLimboed` 控制是否计入虚拟的科技类 msgid "`Technos(Dont)Exist.Houses` controls which houses are checked." msgstr "`Technos(Dont)Exist.Houses` 控制检查哪些所属方。" +msgid "`PlayerPower`: The object will die if its owner's power status matches the configured state." +msgstr "`PlayerPower`:当对象所属方的电力状态符合设定条件时,则对象死亡。" + +msgid "`low` / `consumer`: Trigger when the owner is in low power." +msgstr "`low` / `consumer`:当对象所属方处于电力不足状态时触发。" + +msgid "`normal`: Trigger when the owner is not in low power." +msgstr "`normal`:当对象所属方未处于电力不足状态时触发。" + +msgid "`PlayerMoneyLessThan` / `PlayerMoneyMoreThan`: The object will die based on the owner's available credits." +msgstr "`PlayerMoneyLessThan` / `PlayerMoneyMoreThan`:根据对象所属方的资金决定对象是否死亡。" + +msgid "If only `PlayerMoneyLessThan` is set, triggers when money is below this value." +msgstr "仅设置 `PlayerMoneyLessThan` 时,当资金低于该值时触发。" + +msgid "If only `PlayerMoneyMoreThan` is set, triggers when money is above this value." +msgstr "仅设置 `PlayerMoneyMoreThan` 时,当资金高于该值时触发。" + +msgid "If both are set, they define a range condition:" +msgstr "同时设置时为区间条件:" + +msgid "If `PlayerMoneyLessThan < PlayerMoneyMoreThan`: triggers when money is **outside the range**." +msgstr "当 `PlayerMoneyLessThan < PlayerMoneyMoreThan` 时:资金处于**区间内**时触发。" + +msgid "If `PlayerMoneyLessThan >= PlayerMoneyMoreThan`: triggers when money is **inside the range**." +msgstr "当 `PlayerMoneyLessThan >= PlayerMoneyMoreThan` 时:资金处于**区间外**时触发。" + msgid "The auto-death behavior can be chosen from the following:" msgstr "自毁行为有以下选择:" diff --git a/src/Ext/Techno/Body.Update.cpp b/src/Ext/Techno/Body.Update.cpp index 566da383c7..5fcb0a291c 100644 --- a/src/Ext/Techno/Body.Update.cpp +++ b/src/Ext/Techno/Body.Update.cpp @@ -332,12 +332,42 @@ bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo) : std::all_of(vTypes.begin(), vTypes.end(), existSingleType); }; - // death if player power status is not as specified if (pTypeExt->AutoDeath_PlayerPowerStatus != PlayerPowerStatus::None) { - const bool isLowPower = pOwner->PowerDrain > pOwner->PowerOutput; + const bool isLowPower = pOwner->HasLowPower(); + const auto status = pTypeExt->AutoDeath_PlayerPowerStatus; - if ((pTypeExt->AutoDeath_PlayerPowerStatus == PlayerPowerStatus::Normal && !isLowPower) || (pTypeExt->AutoDeath_PlayerPowerStatus == PlayerPowerStatus::Consumer && isLowPower)) + if ((status == PlayerPowerStatus::Normal && !isLowPower) || (status == PlayerPowerStatus::Low && isLowPower)) + { + TechnoExt::KillSelf(pThis, howToDie, pTypeExt->AutoDeath_VanishAnimation, isInLimbo); + return true; + } + } + + if (pTypeExt->AutoDeath_PlayerMoneyLessThan != -1 || pTypeExt->AutoDeath_PlayerMoneyMoreThan != -1) + { + const int lessThan = pTypeExt->AutoDeath_PlayerMoneyLessThan; + const int moreThan = pTypeExt->AutoDeath_PlayerMoneyMoreThan; + const int money = pOwner->Available_Money(); + bool shouldDie = false; + + if (lessThan != -1 && moreThan != -1) + { + if (lessThan < moreThan) + shouldDie = (money < lessThan && money > moreThan); + else + shouldDie = (money < lessThan || money > moreThan); + } + else if (lessThan != -1) + { + shouldDie = (money < lessThan); + } + else + { + shouldDie = (money > moreThan); + } + + if (shouldDie) { TechnoExt::KillSelf(pThis, howToDie, pTypeExt->AutoDeath_VanishAnimation, isInLimbo); return true; diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 2774aebdc1..9f72737d52 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -799,6 +799,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->AutoDeath_TechnosExist_AllowLimboed.Read(exINI, pSection, "AutoDeath.TechnosExist.AllowLimboed"); this->AutoDeath_TechnosExist_Houses.Read(exINI, pSection, "AutoDeath.TechnosExist.Houses"); this->AutoDeath_PlayerPowerStatus.Read(exINI, pSection, "AutoDeath.PlayerPowerStatus"); + this->AutoDeath_PlayerMoneyLessThan.Read(exINI, pSection, "AutoDeath.PlayerMoneyLessThan"); + this->AutoDeath_PlayerMoneyMoreThan.Read(exINI, pSection, "AutoDeath.PlayerMoneyMoreThan"); this->Slaved_OwnerWhenMasterKilled.Read(exINI, pSection, "Slaved.OwnerWhenMasterKilled"); this->SlavesFreeSound.Read(exINI, pSection, "SlavesFreeSound"); @@ -1553,6 +1555,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->AutoDeath_TechnosExist_AllowLimboed) .Process(this->AutoDeath_TechnosExist_Houses) .Process(this->AutoDeath_PlayerPowerStatus) + .Process(this->AutoDeath_PlayerMoneyLessThan) + .Process(this->AutoDeath_PlayerMoneyMoreThan) .Process(this->Slaved_OwnerWhenMasterKilled) .Process(this->SlavesFreeSound) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 80157e9a3a..0a49b11999 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -106,6 +106,8 @@ class TechnoTypeExt Valueable AutoDeath_TechnosExist_AllowLimboed; Valueable AutoDeath_TechnosExist_Houses; Valueable AutoDeath_PlayerPowerStatus; + Valueable AutoDeath_PlayerMoneyLessThan; + Valueable AutoDeath_PlayerMoneyMoreThan; Valueable Slaved_OwnerWhenMasterKilled; NullableIdx SlavesFreeSound; @@ -658,6 +660,8 @@ class TechnoTypeExt , AutoDeath_TechnosExist_AllowLimboed { true } , AutoDeath_TechnosExist_Houses { AffectedHouse::Owner } , AutoDeath_PlayerPowerStatus { PlayerPowerStatus::None } + , AutoDeath_PlayerMoneyLessThan { -1 } + , AutoDeath_PlayerMoneyMoreThan { -1 } , Slaved_OwnerWhenMasterKilled { SlaveChangeOwnerType::Killer } , SlavesFreeSound {} diff --git a/src/Utilities/Enum.h b/src/Utilities/Enum.h index f9c7cb0795..2e51ee48d1 100644 --- a/src/Utilities/Enum.h +++ b/src/Utilities/Enum.h @@ -192,7 +192,7 @@ enum class PlayerPowerStatus { None = 0, Normal = 1, // not low power - Consumer = 2, // low power + Low = 2, // low power }; enum class SelfHealGainType diff --git a/src/Utilities/TemplateDef.h b/src/Utilities/TemplateDef.h index 624b26bd78..b45eb21ce0 100644 --- a/src/Utilities/TemplateDef.h +++ b/src/Utilities/TemplateDef.h @@ -1634,8 +1634,8 @@ if(_strcmpi(parser.value(), #name) == 0){ value = __uuidof(name ## LocomotionCla static const std::pair Names[] = { {"none", PlayerPowerStatus::None}, - {"consumer", PlayerPowerStatus::Consumer}, - {"low", PlayerPowerStatus::Consumer}, + {"consumer", PlayerPowerStatus::Low}, + {"low", PlayerPowerStatus::Low}, {"normal", PlayerPowerStatus::Normal}, }; From 25fa1f5bf8b17ac11d7b494cbd1bf65dcef44f98 Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Wed, 1 Jul 2026 21:38:30 +0800 Subject: [PATCH 06/11] Update New-or-Enhanced-Logics.md --- docs/New-or-Enhanced-Logics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 27079332b3..724021b992 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1924,7 +1924,7 @@ Both `InitialStrength` and `InitialStrength.Cloning` never surpass the type's `S - `Technos(Dont)Exist.Any` controls whether or not a single listed TechnoType is enough to satisfy the requirement or if all are required. - `Technos(Dont)Exist.AllowLimboed` controls whether or not limboed TechnoTypes (f.ex those in transports) are counted. - `Technos(Dont)Exist.Houses` controls which houses are checked. - - `PlayerPower`: The object will die if its owner's power status matches the configured state. + - `PlayerPowerStatus`: The object will die if its owner's power status matches the configured state. - `low` / `consumer`: Trigger when the owner is in low power. - `normal`: Trigger when the owner is not in low power. - `PlayerMoneyLessThan` / `PlayerMoneyMoreThan`: The object will die based on the owner's available credits. From 901d5f36e886db49fe0f72ddae28f2c3c61363c9 Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Wed, 1 Jul 2026 21:39:23 +0800 Subject: [PATCH 07/11] Update New-or-Enhanced-Logics.po --- docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 8962aedbcc..acbf40ac42 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 @@ -4425,8 +4425,8 @@ msgstr "`Technos(Dont)Exist.AllowLimboed` 控制是否计入虚拟的科技类 msgid "`Technos(Dont)Exist.Houses` controls which houses are checked." msgstr "`Technos(Dont)Exist.Houses` 控制检查哪些所属方。" -msgid "`PlayerPower`: The object will die if its owner's power status matches the configured state." -msgstr "`PlayerPower`:当对象所属方的电力状态符合设定条件时,则对象死亡。" +msgid "`PlayerPowerStatus`: The object will die if its owner's power status matches the configured state." +msgstr "`PlayerPowerStatus`:当对象所属方的电力状态符合设定条件时,则对象死亡。" msgid "`low` / `consumer`: Trigger when the owner is in low power." msgstr "`low` / `consumer`:当对象所属方处于电力不足状态时触发。" From 62edf617cd2d702fb12e58cb7b3f5fd083d2cf73 Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Wed, 1 Jul 2026 23:03:49 +0800 Subject: [PATCH 08/11] Fix lessThan & moreThan --- docs/New-or-Enhanced-Logics.md | 4 ++-- docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po | 8 ++++---- src/Ext/Techno/Body.Update.cpp | 6 +----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 724021b992..b68898da90 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1931,8 +1931,8 @@ Both `InitialStrength` and `InitialStrength.Cloning` never surpass the type's `S - If only `PlayerMoneyLessThan` is set, triggers when money is below this value. - If only `PlayerMoneyMoreThan` is set, triggers when money is above this value. - If both are set, they define a range condition: - - If `PlayerMoneyLessThan < PlayerMoneyMoreThan`: triggers when money is **inside the range**. - - If `PlayerMoneyLessThan >= PlayerMoneyMoreThan`: triggers when money is **outside the range**. + - If `PlayerMoneyLessThan > PlayerMoneyMoreThan`: triggers when money is **inside the range**. + - If `PlayerMoneyLessThan <= PlayerMoneyMoreThan`: triggers when money is **outside the range**. - The auto-death behavior can be chosen from the following: - `kill`: The object will be destroyed normally. 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 acbf40ac42..451560619d 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 @@ -4446,11 +4446,11 @@ msgstr "仅设置 `PlayerMoneyMoreThan` 时,当资金高于该值时触发。" msgid "If both are set, they define a range condition:" msgstr "同时设置时为区间条件:" -msgid "If `PlayerMoneyLessThan < PlayerMoneyMoreThan`: triggers when money is **outside the range**." -msgstr "当 `PlayerMoneyLessThan < PlayerMoneyMoreThan` 时:资金处于**区间内**时触发。" +msgid "If `PlayerMoneyLessThan > PlayerMoneyMoreThan`: triggers when money is **outside the range**." +msgstr "当 `PlayerMoneyLessThan > PlayerMoneyMoreThan` 时:资金处于**区间内**时触发。" -msgid "If `PlayerMoneyLessThan >= PlayerMoneyMoreThan`: triggers when money is **inside the range**." -msgstr "当 `PlayerMoneyLessThan >= PlayerMoneyMoreThan` 时:资金处于**区间外**时触发。" +msgid "If `PlayerMoneyLessThan <= PlayerMoneyMoreThan`: triggers when money is **inside the range**." +msgstr "当 `PlayerMoneyLessThan <= PlayerMoneyMoreThan` 时:资金处于**区间外**时触发。" msgid "The auto-death behavior can be chosen from the following:" msgstr "自毁行为有以下选择:" diff --git a/src/Ext/Techno/Body.Update.cpp b/src/Ext/Techno/Body.Update.cpp index 5fcb0a291c..3a1bfcc811 100644 --- a/src/Ext/Techno/Body.Update.cpp +++ b/src/Ext/Techno/Body.Update.cpp @@ -353,19 +353,15 @@ bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo) if (lessThan != -1 && moreThan != -1) { - if (lessThan < moreThan) + if (lessThan > moreThan) shouldDie = (money < lessThan && money > moreThan); else shouldDie = (money < lessThan || money > moreThan); } else if (lessThan != -1) - { shouldDie = (money < lessThan); - } else - { shouldDie = (money > moreThan); - } if (shouldDie) { From 583f0f554c40dce012a66be8629adc8fd1c073e0 Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Thu, 2 Jul 2026 12:30:33 +0800 Subject: [PATCH 09/11] Max Min --- docs/New-or-Enhanced-Logics.md | 10 ++++---- .../LC_MESSAGES/New-or-Enhanced-Logics.po | 22 +++++++----------- src/Ext/Techno/Body.Update.cpp | 23 ++++--------------- src/Ext/TechnoType/Body.cpp | 13 +++++++---- src/Ext/TechnoType/Body.h | 8 +++---- 5 files changed, 30 insertions(+), 46 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index b68898da90..9a4aad2d7c 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1927,12 +1927,10 @@ Both `InitialStrength` and `InitialStrength.Cloning` never surpass the type's `S - `PlayerPowerStatus`: The object will die if its owner's power status matches the configured state. - `low` / `consumer`: Trigger when the owner is in low power. - `normal`: Trigger when the owner is not in low power. - - `PlayerMoneyLessThan` / `PlayerMoneyMoreThan`: The object will die based on the owner's available credits. - - If only `PlayerMoneyLessThan` is set, triggers when money is below this value. - - If only `PlayerMoneyMoreThan` is set, triggers when money is above this value. - - If both are set, they define a range condition: - - If `PlayerMoneyLessThan > PlayerMoneyMoreThan`: triggers when money is **inside the range**. - - If `PlayerMoneyLessThan <= PlayerMoneyMoreThan`: triggers when money is **outside the range**. + - `PlayerMoney.Max` / `PlayerMoney.Min`: The object will die based on the owner's available credits. + - If only `PlayerMoney.Max` is set, triggers when money is not above this value. + - If only `PlayerMoney.Min` is set, triggers when money is not below this value. + - If both are set, triggers when money is **inside the range**. - The auto-death behavior can be chosen from the following: - `kill`: The object will be destroyed normally. 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 451560619d..31c599d368 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 @@ -4434,23 +4434,17 @@ msgstr "`low` / `consumer`:当对象所属方处于电力不足状态时触发 msgid "`normal`: Trigger when the owner is not in low power." msgstr "`normal`:当对象所属方未处于电力不足状态时触发。" -msgid "`PlayerMoneyLessThan` / `PlayerMoneyMoreThan`: The object will die based on the owner's available credits." -msgstr "`PlayerMoneyLessThan` / `PlayerMoneyMoreThan`:根据对象所属方的资金决定对象是否死亡。" +msgid "`PlayerMoney.Max` / `PlayerMoney.Min`: The object will die based on the owner's available credits." +msgstr "`PlayerMoney.Max` / `PlayerMoney.Min`:根据对象所属方的资金决定对象是否死亡。" -msgid "If only `PlayerMoneyLessThan` is set, triggers when money is below this value." -msgstr "仅设置 `PlayerMoneyLessThan` 时,当资金低于该值时触发。" +msgid "If only `PlayerMoney.Max` is set, triggers when money is not above this value." +msgstr "仅设置 `PlayerMoney.Max` 时,当资金不高于该值时触发。" -msgid "If only `PlayerMoneyMoreThan` is set, triggers when money is above this value." -msgstr "仅设置 `PlayerMoneyMoreThan` 时,当资金高于该值时触发。" +msgid "If only `PlayerMoney.Min` is set, triggers when money is not below this value." +msgstr "仅设置 `PlayerMoney.Min` 时,当资金不低于该值时触发。" -msgid "If both are set, they define a range condition:" -msgstr "同时设置时为区间条件:" - -msgid "If `PlayerMoneyLessThan > PlayerMoneyMoreThan`: triggers when money is **outside the range**." -msgstr "当 `PlayerMoneyLessThan > PlayerMoneyMoreThan` 时:资金处于**区间内**时触发。" - -msgid "If `PlayerMoneyLessThan <= PlayerMoneyMoreThan`: triggers when money is **inside the range**." -msgstr "当 `PlayerMoneyLessThan <= PlayerMoneyMoreThan` 时:资金处于**区间外**时触发。" +msgid "If both are set, triggers when money is **inside the range**." +msgstr "同时设置时,资金处于**区间内**时触发。" msgid "The auto-death behavior can be chosen from the following:" msgstr "自毁行为有以下选择:" diff --git a/src/Ext/Techno/Body.Update.cpp b/src/Ext/Techno/Body.Update.cpp index 3a1bfcc811..0de2f396eb 100644 --- a/src/Ext/Techno/Body.Update.cpp +++ b/src/Ext/Techno/Body.Update.cpp @@ -344,26 +344,13 @@ bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo) } } - if (pTypeExt->AutoDeath_PlayerMoneyLessThan != -1 || pTypeExt->AutoDeath_PlayerMoneyMoreThan != -1) + if (pTypeExt->AutoDeath_PlayerMoney_Max != -1 || pTypeExt->AutoDeath_PlayerMoney_Min != -1) { - const int lessThan = pTypeExt->AutoDeath_PlayerMoneyLessThan; - const int moreThan = pTypeExt->AutoDeath_PlayerMoneyMoreThan; - const int money = pOwner->Available_Money(); - bool shouldDie = false; + const int maxMoney = pTypeExt->AutoDeath_PlayerMoney_Max; + const int minMoney = pTypeExt->AutoDeath_PlayerMoney_Min; + const int currentMoney = pOwner->Available_Money(); - if (lessThan != -1 && moreThan != -1) - { - if (lessThan > moreThan) - shouldDie = (money < lessThan && money > moreThan); - else - shouldDie = (money < lessThan || money > moreThan); - } - else if (lessThan != -1) - shouldDie = (money < lessThan); - else - shouldDie = (money > moreThan); - - if (shouldDie) + if ((maxMoney == -1 || currentMoney <= maxMoney) && (minMoney == -1 || currentMoney >= minMoney)) { TechnoExt::KillSelf(pThis, howToDie, pTypeExt->AutoDeath_VanishAnimation, isInLimbo); return true; diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 9f72737d52..a881573950 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -799,8 +799,13 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->AutoDeath_TechnosExist_AllowLimboed.Read(exINI, pSection, "AutoDeath.TechnosExist.AllowLimboed"); this->AutoDeath_TechnosExist_Houses.Read(exINI, pSection, "AutoDeath.TechnosExist.Houses"); this->AutoDeath_PlayerPowerStatus.Read(exINI, pSection, "AutoDeath.PlayerPowerStatus"); - this->AutoDeath_PlayerMoneyLessThan.Read(exINI, pSection, "AutoDeath.PlayerMoneyLessThan"); - this->AutoDeath_PlayerMoneyMoreThan.Read(exINI, pSection, "AutoDeath.PlayerMoneyMoreThan"); + this->AutoDeath_PlayerMoney_Max.Read(exINI, pSection, "AutoDeath.PlayerMoney.Max"); + this->AutoDeath_PlayerMoney_Min.Read(exINI, pSection, "AutoDeath.PlayerMoney.Min"); + + if ((this->AutoDeath_PlayerMoney_Max != -1) + && (this->AutoDeath_PlayerMoney_Min != -1) + && (this->AutoDeath_PlayerMoney_Max < this->AutoDeath_PlayerMoney_Min)) + Debug::Log("[Developer warning][%s] AutoDeath.PlayerMoney.Max is not bigger than AutoDeath.PlayerMoney.Min, AutoDeath will never activate!\n", pSection); this->Slaved_OwnerWhenMasterKilled.Read(exINI, pSection, "Slaved.OwnerWhenMasterKilled"); this->SlavesFreeSound.Read(exINI, pSection, "SlavesFreeSound"); @@ -1555,8 +1560,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->AutoDeath_TechnosExist_AllowLimboed) .Process(this->AutoDeath_TechnosExist_Houses) .Process(this->AutoDeath_PlayerPowerStatus) - .Process(this->AutoDeath_PlayerMoneyLessThan) - .Process(this->AutoDeath_PlayerMoneyMoreThan) + .Process(this->AutoDeath_PlayerMoney_Max) + .Process(this->AutoDeath_PlayerMoney_Min) .Process(this->Slaved_OwnerWhenMasterKilled) .Process(this->SlavesFreeSound) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 0a49b11999..54f685fe8f 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -106,8 +106,8 @@ class TechnoTypeExt Valueable AutoDeath_TechnosExist_AllowLimboed; Valueable AutoDeath_TechnosExist_Houses; Valueable AutoDeath_PlayerPowerStatus; - Valueable AutoDeath_PlayerMoneyLessThan; - Valueable AutoDeath_PlayerMoneyMoreThan; + Valueable AutoDeath_PlayerMoney_Max; + Valueable AutoDeath_PlayerMoney_Min; Valueable Slaved_OwnerWhenMasterKilled; NullableIdx SlavesFreeSound; @@ -660,8 +660,8 @@ class TechnoTypeExt , AutoDeath_TechnosExist_AllowLimboed { true } , AutoDeath_TechnosExist_Houses { AffectedHouse::Owner } , AutoDeath_PlayerPowerStatus { PlayerPowerStatus::None } - , AutoDeath_PlayerMoneyLessThan { -1 } - , AutoDeath_PlayerMoneyMoreThan { -1 } + , AutoDeath_PlayerMoney_Max { -1 } + , AutoDeath_PlayerMoney_Min { -1 } , Slaved_OwnerWhenMasterKilled { SlaveChangeOwnerType::Killer } , SlavesFreeSound {} From b37f13a6ee57abffd1003d59e1b95641dce39e1e Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Thu, 2 Jul 2026 12:31:51 +0800 Subject: [PATCH 10/11] Update Body.cpp --- src/Ext/TechnoType/Body.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index a881573950..96f76e0a0a 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -805,7 +805,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) if ((this->AutoDeath_PlayerMoney_Max != -1) && (this->AutoDeath_PlayerMoney_Min != -1) && (this->AutoDeath_PlayerMoney_Max < this->AutoDeath_PlayerMoney_Min)) - Debug::Log("[Developer warning][%s] AutoDeath.PlayerMoney.Max is not bigger than AutoDeath.PlayerMoney.Min, AutoDeath will never activate!\n", pSection); + Debug::Log("[Developer warning][%s] AutoDeath.PlayerMoney.Min is bigger than AutoDeath.PlayerMoney.Max, AutoDeath will never activate!\n", pSection); this->Slaved_OwnerWhenMasterKilled.Read(exINI, pSection, "Slaved.OwnerWhenMasterKilled"); this->SlavesFreeSound.Read(exINI, pSection, "SlavesFreeSound"); From 936eb56a6f4d1c9729dc6ed5f2e02103cb55a567 Mon Sep 17 00:00:00 2001 From: Flactine <1716455702@qq.com> Date: Sat, 4 Jul 2026 12:44:07 +0800 Subject: [PATCH 11/11] Update Body.Update.cpp --- src/Ext/Techno/Body.Update.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Ext/Techno/Body.Update.cpp b/src/Ext/Techno/Body.Update.cpp index 0de2f396eb..027df5014f 100644 --- a/src/Ext/Techno/Body.Update.cpp +++ b/src/Ext/Techno/Body.Update.cpp @@ -336,8 +336,9 @@ bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo) { const bool isLowPower = pOwner->HasLowPower(); const auto status = pTypeExt->AutoDeath_PlayerPowerStatus; + const auto isFirstFrame = (Unsorted::CurrentFrame == 0); - if ((status == PlayerPowerStatus::Normal && !isLowPower) || (status == PlayerPowerStatus::Low && isLowPower)) + if ((status == PlayerPowerStatus::Normal && !isLowPower) || (status == PlayerPowerStatus::Low && isLowPower) && !isFirstFrame) { TechnoExt::KillSelf(pThis, howToDie, pTypeExt->AutoDeath_VanishAnimation, isInLimbo); return true;