Skip to content

Commit fea4401

Browse files
authored
Faking Digital Display of Health (#1418)
- `DigitalDisplay.Health.FakeAtDisguise`, if set to true on an InfantryType with Disguise, will use the disguised TechnoType's `Strength` value as the maximum value of health display. The current value will be displayed as the percentage of its current health multiplies the new maximum value. In `rulesmd.ini`: ```ini [SOMETECHNOTYPE] DigitalDisplay.Health.FakeAtDisguise=true ; boolean ```
1 parent f7d7591 commit fea4401

File tree

7 files changed

+71
-35
lines changed

7 files changed

+71
-35
lines changed

CREDITS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ This page lists all the individual contributions to the project by their author.
490490
- **Ollerus**:
491491
- Build limit group enhancement
492492
- Customizable rocker amplitude
493-
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades
493+
- Allow `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades
494494
- Type select for buildings (doc)
495495
- Enhanced Bombard trajectory
496496
- Shield armor inheritance customization
@@ -500,8 +500,9 @@ This page lists all the individual contributions to the project by their author.
500500
- Forcing specific weapon by range
501501
- Passenger-based insignias
502502
- Use `InsigniaType` to set the properties of insignia in a batch
503-
- Allowed player's self-healing effects to be benefited by allied or `PlayerControl=true` houses
503+
- Allow player's self-healing effects to be benefited by allied or `PlayerControl=true` houses
504504
- Power plant damage factor
505+
- Allow faking digital display for `InfoType=Health` at disguise
505506
- **NaotoYuuki** - Vertical & meteor trajectory projectile prototypes
506507
- **handama** - AI script action to `16005 Jump Back To Previous Script`
507508
- **TaranDahl (航味麻酱)**:

docs/User-Interface.md

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,54 +57,57 @@ IngameScore.LoseTheme= ; Soundtrack theme ID
5757
- Default `Shape.Spacing` for buildings is `4,-2`, `4,0` for others.
5858
- `ValueScaleDivisor` can be used to adjust scale of displayed values. Both the current & maximum value will be divided by the integer number given, if higher than 1. Default to 1 (or 15 when set `ValueAsTimer` to true).
5959

60+
- `DigitalDisplay.Health.FakeAtDisguise`, if set to true on an InfantryType with Disguise, will use the disguised TechnoType's `Strength` value as the maximum value of health display. The current value will be displayed as the percentage of its current health multiplies the new maximum value.
61+
6062
In `rulesmd.ini`:
6163
```ini
6264
[DigitalDisplayTypes]
6365
0=SOMEDIGITALDISPLAYTYPE
6466

6567
[AudioVisual]
66-
Buildings.DefaultDigitalDisplayTypes= ; List of DigitalDisplayTypes
67-
Infantry.DefaultDigitalDisplayTypes= ; List of DigitalDisplayTypes
68-
Vehicles.DefaultDigitalDisplayTypes= ; List of DigitalDisplayTypes
69-
Aircraft.DefaultDigitalDisplayTypes= ; List of DigitalDisplayTypes
68+
Buildings.DefaultDigitalDisplayTypes= ; list of DigitalDisplayTypes
69+
Infantry.DefaultDigitalDisplayTypes= ; list of DigitalDisplayTypes
70+
Vehicles.DefaultDigitalDisplayTypes= ; list of DigitalDisplayTypes
71+
Aircraft.DefaultDigitalDisplayTypes= ; list of DigitalDisplayTypes
7072

71-
[SOMEDIGITALDISPLAYTYPE] ; DigitalDisplayType
73+
[SOMEDIGITALDISPLAYTYPE] ; DigitalDisplayType
7274
; Generic
73-
InfoType=Health ; Displayed value enumeration (Health|Shield|Ammo|Mindcontrol|Spawns|Passengers|Tiberium|Experience|Occupants|GattlingStage|ROF|Reload|SpawnTimer|GattlingTimer|ProduceCash|PassengerKill|AutoDeath|SuperWeapon|IronCurtain|TemporalLife|FactoryProcess)
74-
InfoIndex= ; integer
75-
Offset=0,0 ; integers - horizontal, vertical
76-
Offset.ShieldDelta= ; integers - horizontal, vertical
77-
Align=right ; Text alignment enumeration (left|right|center/centre)
78-
Anchor.Horizontal=right ; Horizontal position enumeration (left|center/centre|right)
79-
Anchor.Vertical=top ; Vertical position enumeration (top|center/centre|bottom)
80-
Anchor.Building=top ; Hexagon vertex enumeration (top|lefttop|leftbottom|bottom|rightbottom|righttop)
81-
Percentage=false ; boolean
82-
HideMaxValue=false ; boolean
83-
VisibleToHouses=owner ; Affected house enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
84-
VisibleToHouses.Observer=true ; boolean
85-
VisibleInSpecialState=true ; boolean
86-
ValueScaleDivisor= ; integer
87-
ValueAsTimer=false ; boolean
75+
InfoType=Health ; Displayed value enumeration (Health|Shield|Ammo|Mindcontrol|Spawns|Passengers|Tiberium|Experience|Occupants|GattlingStage|ROF|Reload|SpawnTimer|GattlingTimer|ProduceCash|PassengerKill|AutoDeath|SuperWeapon|IronCurtain|TemporalLife|FactoryProcess)
76+
InfoIndex= ; integer
77+
Offset=0,0 ; integers - horizontal, vertical
78+
Offset.ShieldDelta= ; integers - horizontal, vertical
79+
Align=right ; Text alignment enumeration (left|right|center/centre)
80+
Anchor.Horizontal=right ; Horizontal position enumeration (left|center/centre|right)
81+
Anchor.Vertical=top ; Vertical position enumeration (top|center/centre|bottom)
82+
Anchor.Building=top ; Hexagon vertex enumeration (top|lefttop|leftbottom|bottom|rightbottom|righttop)
83+
Percentage=false ; boolean
84+
HideMaxValue=false ; boolean
85+
VisibleToHouses=owner ; Affected house enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
86+
VisibleToHouses.Observer=true ; boolean
87+
VisibleInSpecialState=true ; boolean
88+
ValueScaleDivisor= ; integer
89+
ValueAsTimer=false ; boolean
8890
; Text
89-
Text.Color=0,255,0 ; integers - Red, Green, Blue
90-
Text.Color.ConditionYellow=255,255,0 ; integers - Red, Green, Blue
91-
Text.Color.ConditionRed=255,0,0 ; integers - Red, Green, Blue
92-
Text.Background=false ; boolean
91+
Text.Color=0,255,0 ; integers - Red, Green, Blue
92+
Text.Color.ConditionYellow=255,255,0 ; integers - Red, Green, Blue
93+
Text.Color.ConditionRed=255,0,0 ; integers - Red, Green, Blue
94+
Text.Background=false ; boolean
9395
; Shape
94-
Shape= ; filename with .shp extension, if not present, game-drawn text will be used instead
95-
Palette=palette.pal ; filename with .pal extension
96-
Shape.Spacing= ; integers - horizontal, vertical spacing between digits
97-
Shape.PercentageFrame=false ; boolean
96+
Shape= ; filename with .shp extension, if not present, game-drawn text will be used instead
97+
Palette=palette.pal ; filename with .pal extension
98+
Shape.Spacing= ; integers - horizontal, vertical spacing between digits
99+
Shape.PercentageFrame=false ; boolean
98100

99-
[SOMETECHNO] ; TechnoType
100-
DigitalDisplay.Disable=false ; boolean
101-
DigitalDisplayTypes= ; List of DigitalDisplayTypes
101+
[SOMETECHNOTYPE]
102+
DigitalDisplay.Disable=false ; boolean
103+
DigitalDisplayTypes= ; list of DigitalDisplayTypes
104+
DigitalDisplay.Health.FakeAtDisguise=true ; boolean
102105
```
103106

104107
In `RA2MD.INI`:
105108
```ini
106109
[Phobos]
107-
DigitalDisplay.Enable=false ; boolean
110+
DigitalDisplay.Enable=false ; boolean
108111
```
109112

110113
```{note}

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ New:
392392
- Infantry support `IsGattling=yes` (by FlyStar)
393393
- [Several new Infotypes, no display in specific status and a new single frame display method](User-Interface.md#digital-display) (by CrimRecya)
394394
- Targeting limitation for berzerk technos (by TaranDahl)
395+
- Allowed faking digital display for `InfoType=Health` at disguise (by Ollerus)
395396
396397
Vanilla fixes:
397398
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Techno/Body.Visuals.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ void TechnoExt::GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType
502502
{
503503
value = pThis->Health;
504504
maxValue = pType->Strength;
505+
506+
if (pThis->Disguised && !pThis->Owner->IsAlliedWith(HouseClass::CurrentPlayer))
507+
GetDigitalDisplayFakeHealth(pThis, value, maxValue);
508+
505509
break;
506510
}
507511
case DisplayInfoType::Shield:
@@ -829,7 +833,25 @@ void TechnoExt::GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType
829833
{
830834
value = pThis->Health;
831835
maxValue = pType->Strength;
836+
837+
if (pThis->Disguised && !pThis->Owner->IsAlliedWith(HouseClass::CurrentPlayer))
838+
GetDigitalDisplayFakeHealth(pThis, value, maxValue);
839+
832840
break;
833841
}
834842
}
835843
}
844+
845+
void TechnoExt::GetDigitalDisplayFakeHealth(TechnoClass* pThis, int& value, int& maxValue)
846+
{
847+
if (TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->DigitalDisplay_Health_FakeAtDisguise)
848+
{
849+
if (const auto pType = TechnoTypeExt::GetTechnoType(pThis->Disguise))
850+
{
851+
const int newMaxValue = pType->Strength;
852+
const double ratio = static_cast<double>(value) / maxValue;
853+
value = static_cast<int>(ratio * newMaxValue);
854+
maxValue = newMaxValue;
855+
}
856+
}
857+
}

src/Ext/Techno/Body.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ class TechnoExt
230230
static void DrawSelectBox(TechnoClass* pThis, const Point2D* pLocation, const RectangleStruct* pBounds, bool drawBefore = false);
231231
static void ProcessDigitalDisplays(TechnoClass* pThis);
232232
static void GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType, int& value, int& maxValue, int infoIndex);
233+
static void GetDigitalDisplayFakeHealth(TechnoClass* pThis, int& value, int& maxValue);
233234

234235
// WeaponHelpers.cpp
235236
static int PickWeaponIndex(TechnoClass* pThis, TechnoClass* pTargetTechno, AbstractClass* pTarget, int weaponIndexOne, int weaponIndexTwo, bool allowFallback = true, bool allowAAFallback = true);

src/Ext/TechnoType/Body.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
633633
this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking");
634634
this->BunkerableAnyway.Read(exINI, pSection, "BunkerableAnyway");
635635

636+
this->DigitalDisplay_Health_FakeAtDisguise.Read(exINI, pSection, "DigitalDisplay.Health.FakeAtDisguise");
637+
636638
this->AttackMove_Aggressive.Read(exINI, pSection, "AttackMove.Aggressive");
637639
this->AttackMove_UpdateTarget.Read(exINI, pSection, "AttackMove.UpdateTarget");
638640

@@ -1216,6 +1218,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
12161218
.Process(this->Wake_Grapple)
12171219
.Process(this->Wake_Sinking)
12181220

1221+
.Process(this->DigitalDisplay_Health_FakeAtDisguise)
1222+
12191223
.Process(this->AttackMove_Aggressive)
12201224
.Process(this->AttackMove_UpdateTarget)
12211225

@@ -1274,7 +1278,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
12741278
.Process(this->FallingDownDamage_Water)
12751279

12761280
.Process(this->FiringForceScatter)
1277-
1281+
12781282
.Process(this->FireUp)
12791283
.Process(this->FireUp_ResetInRetarget)
12801284
//.Process(this->SecondaryFire)

src/Ext/TechnoType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ class TechnoTypeExt
351351
Valueable<bool> SuppressKillWeapons;
352352
ValueableVector<WeaponTypeClass*> SuppressKillWeapons_Types;
353353

354+
Valueable<bool> DigitalDisplay_Health_FakeAtDisguise;
355+
354356
NullableVector<int> Overload_Count;
355357
NullableVector<int> Overload_Damage;
356358
NullableVector<int> Overload_Frames;
@@ -636,6 +638,8 @@ class TechnoTypeExt
636638
, Wake_Grapple { }
637639
, Wake_Sinking { }
638640

641+
, DigitalDisplay_Health_FakeAtDisguise { true }
642+
639643
, AttackMove_Aggressive {}
640644
, AttackMove_UpdateTarget {}
641645

0 commit comments

Comments
 (0)