Skip to content

Commit

Permalink
Add the missing global shield keys for ConditionYellow/Red
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Feb 28, 2024
1 parent 0d3fe57 commit 4f6eac9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ LaserTrail.Types=SOMETRAIL ; list of LaserTrailTypes
In `rulesmd.ini`:
```ini
[AudioVisual]
Shield.ConditionYellow= ; floating point value, percents or absolute
Shield.ConditionRed= ; floating point value, percents or absolute
Pips.Shield=-1,-1,-1 ; integer, frames of pips.shp (zero-based) for Green, Yellow, Red
Pips.Shield.Building=-1,-1,-1 ; integer, frames of pips.shp (zero-based) for Green, Yellow, Red
Pips.Shield.Background=PIPBRD.SHP ; filename - including the .shp/.pcx extension
Expand Down Expand Up @@ -188,7 +190,7 @@ Shield.InheritStateOnReplace=false ; boolean
- 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.
- `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]` -> `ConditionYellow` & `ConditionRed` respectively.
- `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.
- This also works with Ares' `Convert.*`.
- `Powered` controls whether or not the shield is active when a unit is running low on power or it is affected by EMP.
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->PlacementPreview.Read(exINI, GameStrings::AudioVisual, "PlacementPreview");
this->PlacementPreview_Translucency.Read(exINI, GameStrings::AudioVisual, "PlacementPreview.Translucency");

this->Shield_ConditionYellow.Read(exINI, GameStrings::AudioVisual, "Shield.ConditionYellow");
this->Shield_ConditionRed.Read(exINI, GameStrings::AudioVisual, "Shield.ConditionRed");
this->Pips_Shield.Read(exINI, GameStrings::AudioVisual, "Pips.Shield");
this->Pips_Shield_Background.Read(exINI, GameStrings::AudioVisual, "Pips.Shield.Background");
this->Pips_Shield_Building.Read(exINI, GameStrings::AudioVisual, "Pips.Shield.Building");
Expand Down Expand Up @@ -228,6 +230,8 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->PlacementGrid_TranslucencyWithPreview)
.Process(this->PlacementPreview)
.Process(this->PlacementPreview_Translucency)
.Process(this->Shield_ConditionYellow)
.Process(this->Shield_ConditionRed)
.Process(this->Pips_Shield)
.Process(this->Pips_Shield_Background)
.Process(this->Pips_Shield_Building)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class RulesExt
Valueable<bool> PlacementPreview;
TranslucencyLevel PlacementPreview_Translucency;

Nullable<double> Shield_ConditionYellow;
Nullable<double> Shield_ConditionRed;
Valueable<Vector3D<int>> Pips_Shield;
Nullable<SHPStruct*> Pips_Shield_Background;
Valueable<Vector3D<int>> Pips_Shield_Building;
Expand Down Expand Up @@ -130,6 +132,8 @@ class RulesExt
, PlacementPreview { false }
, PlacementPreview_Translucency { 75 }

, Shield_ConditionYellow { }
, Shield_ConditionRed { }
, Pips_Shield_Background { }
, Pips_Shield_Building { { -1,-1,-1 } }
, Pips_Shield_Building_Empty { }
Expand Down
4 changes: 2 additions & 2 deletions src/New/Type/ShieldTypeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ AnimTypeClass* ShieldTypeClass::GetIdleAnimType(bool isDamaged, double healthRat

double ShieldTypeClass::GetConditionYellow()
{
return this->ConditionYellow.Get(RulesClass::Instance->ConditionYellow);
return this->ConditionYellow.Get(RulesExt::Global()->Shield_ConditionYellow.Get(RulesClass::Instance->ConditionYellow));
}

double ShieldTypeClass::GetConditionRed()
{
return this->ConditionRed.Get(RulesClass::Instance->ConditionRed);
return this->ConditionRed.Get(RulesExt::Global()->Shield_ConditionRed.Get(RulesClass::Instance->ConditionRed));
}

void ShieldTypeClass::LoadFromINI(CCINIClass* pINI)
Expand Down

0 comments on commit 4f6eac9

Please sign in to comment.