Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Minor] Shield armor inheritance customization #1403

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions src/New/Entity/ShieldClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/New/Type/ShieldTypeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/New/Type/ShieldTypeClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class ShieldTypeClass final : public Enumerable<ShieldTypeClass>
Nullable<double> ConditionRed;
Valueable<ArmorType> Armor;
Valueable<bool> InheritArmorFromTechno;
ValueableVector<TechnoTypeClass*> InheritArmor_Allowed;
ValueableVector<TechnoTypeClass*> InheritArmor_Disallowed;
Valueable<bool> Powered;
Valueable<double> Respawn;
Valueable<int> Respawn_Rate;
Expand Down Expand Up @@ -64,6 +66,8 @@ class ShieldTypeClass final : public Enumerable<ShieldTypeClass>
, ConditionRed { }
, Armor { Armor::None }
, InheritArmorFromTechno { false }
, InheritArmor_Allowed { }
, InheritArmor_Disallowed { }
, Powered { false }
, Respawn { 0.0 }
, Respawn_Rate { 0 }
Expand Down
Loading