From 4d2feb16697b3f2e829421dfb217696015259341 Mon Sep 17 00:00:00 2001 From: Coronia <2217891145@qq.com> Date: Thu, 10 Oct 2024 13:50:30 +0800 Subject: [PATCH] Shield armor inheritance customization --- CREDITS.md | 1 + docs/New-or-Enhanced-Logics.md | 4 ++++ docs/Whats-New.md | 1 + src/New/Entity/ShieldClass.cpp | 14 +++++++++++--- src/New/Type/ShieldTypeClass.cpp | 4 ++++ src/New/Type/ShieldTypeClass.h | 4 ++++ 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index df74398907..b6d9327367 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -371,6 +371,7 @@ This page lists all the individual contributions to the project by their author. - **Ollerus** - Build limit group enhancement - Customizable rocker amplitude + - Shield armor inheritance customization - **handama** - AI script action to jump back to previous script - **TaranDahl (航味麻酱)** - Skirmish AI "sell all buildings and set all technos to hunt" behavior dehardcode diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index be80bc7f44..54090f2170 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -276,6 +276,8 @@ ConditionYellow= ; floating point value, percents or ConditionRed= ; floating point value, percents or absolute Armor=none ; ArmorType InheritArmorFromTechno=false ; boolean +InheritArmor.Allowed= ; list of TechnoTypes +InheritArmor.Disallowed= ; list of TechnoTypes Powered=false ; boolean AbsorbOverDamage=false ; boolean SelfHealing=0.0 ; floating point value, percents or absolute @@ -363,6 +365,8 @@ Shield.InheritStateOnReplace=false ; boolean - Negative damage weapons will consider targets with active, but not at full health shields in need of healing / repairing unless the Warhead has `Shield.Penetrate=true`, in which case only object health is considered. - When a TechnoType has an unbroken shield, `[ShieldType]->Armor` will replace `[TechnoType]->Armor` for targeting and damage calculation purposes. - `InheritArmorFromTechno` can be set to true to override this so that `[TechnoType]->Armor` is used even if shield is active and `[ShieldType]->Armor` is ignored. + - `InheritArmor.Allowed` lists TechnoTypes whose armor can be overridden. If empty, any TechnoType not listed in `InheritArmor.Disallowed` is okay. + - `InheritArmor.Disallowed` lists TechnoTypes whose armor can't be overridden. If empty, any TechnoTypes are okay as long as `InheritArmor.Allowed` is empty or they are listed on it. - `InitialStrength` can be used to set a different initial strength value from maximum. - `ConditionYellow` and `ConditionRed` can be used to set the thresholds for shield damage states, defaulting to `[AudioVisual]` -> `Shield.ConditionYellow` & `Shield.ConditionRed` respectively which in turn default to just `ConditionYellow` & `ConditionRed`. - When executing `DeploysInto` or `UndeploysInto`, if both of the TechnoTypes have shields, the transformed unit/building would keep relative shield health (in percents), same as with `Strength`. If one of the TechnoTypes doesn't have shields, it's shield's state on conversion will be preserved until converted back. diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 2c11230bd1..eeb0fc3d60 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -463,6 +463,7 @@ New: - Toggle to disallow buildings from providing build area during buildup (by Starkku) - Allow customizing which building types provide build area for a building (by Starkku) - `Scorch` / `Flamer` fire animation customization (by Starkku) +- Shield armor inheritance customization (by Ollerus) 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/New/Entity/ShieldClass.cpp b/src/New/Entity/ShieldClass.cpp index 7635f36095..9f04c6abc3 100644 --- a/src/New/Entity/ShieldClass.cpp +++ b/src/New/Entity/ShieldClass.cpp @@ -978,10 +978,18 @@ ShieldTypeClass* ShieldClass::GetType() const ArmorType ShieldClass::GetArmorType() const { - if (this->Techno && this->Type->InheritArmorFromTechno) - return this->Techno->GetTechnoType()->Armor; + const auto pShieldType = this->Type; - return this->Type->Armor.Get(); + if (this->Techno && pShieldType->InheritArmorFromTechno) + { + const auto pTechnoType = this->Techno->GetTechnoType(); + + if (pShieldType->InheritArmor_Allowed.empty() || pShieldType->InheritArmor_Allowed.Contains(pTechnoType) + && (pShieldType->InheritArmor_Disallowed.empty() || !pShieldType->InheritArmor_Disallowed.Contains(pTechnoType))) + return pTechnoType->Armor; + } + + return pShieldType->Armor.Get(); } int ShieldClass::GetFramesSinceLastBroken() const diff --git a/src/New/Type/ShieldTypeClass.cpp b/src/New/Type/ShieldTypeClass.cpp index f913e64476..f29f8e6e1c 100644 --- a/src/New/Type/ShieldTypeClass.cpp +++ b/src/New/Type/ShieldTypeClass.cpp @@ -40,6 +40,8 @@ void ShieldTypeClass::LoadFromINI(CCINIClass* pINI) this->ConditionRed.Read(exINI, pSection, "ConditionRed"); this->Armor.Read(exINI, pSection, "Armor"); this->InheritArmorFromTechno.Read(exINI, pSection, "InheritArmorFromTechno"); + this->InheritArmor_Allowed.Read(exINI, pSection, "InheritArmor.Allowed"); + this->InheritArmor_Disallowed.Read(exINI, pSection, "InheritArmor.Disallowed"); this->Powered.Read(exINI, pSection, "Powered"); this->Respawn.Read(exINI, pSection, "Respawn"); @@ -106,6 +108,8 @@ void ShieldTypeClass::Serialize(T& Stm) .Process(this->ConditionRed) .Process(this->Armor) .Process(this->InheritArmorFromTechno) + .Process(this->InheritArmor_Allowed) + .Process(this->InheritArmor_Disallowed) .Process(this->Powered) .Process(this->Respawn) .Process(this->Respawn_Rate) diff --git a/src/New/Type/ShieldTypeClass.h b/src/New/Type/ShieldTypeClass.h index 2735966525..bf4b210862 100644 --- a/src/New/Type/ShieldTypeClass.h +++ b/src/New/Type/ShieldTypeClass.h @@ -15,6 +15,8 @@ class ShieldTypeClass final : public Enumerable Nullable ConditionRed; Valueable Armor; Valueable InheritArmorFromTechno; + ValueableVector InheritArmor_Allowed; + ValueableVector InheritArmor_Disallowed; Valueable Powered; Valueable Respawn; Valueable Respawn_Rate; @@ -64,6 +66,8 @@ class ShieldTypeClass final : public Enumerable , ConditionRed { } , Armor { Armor::None } , InheritArmorFromTechno { false } + , InheritArmor_Allowed { } + , InheritArmor_Disallowed { } , Powered { false } , Respawn { 0.0 } , Respawn_Rate { 0 }