Skip to content

Faking Digital Display of Health #1418

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

Merged
merged 7 commits into from
Jun 13, 2025
Merged
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
5 changes: 3 additions & 2 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ This page lists all the individual contributions to the project by their author.
- **Ollerus**:
- Build limit group enhancement
- Customizable rocker amplitude
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades
- Allow `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades
- Type select for buildings (doc)
- Enhanced Bombard trajectory
- Shield armor inheritance customization
Expand All @@ -500,8 +500,9 @@ This page lists all the individual contributions to the project by their author.
- Forcing specific weapon by range
- Passenger-based insignias
- Use `InsigniaType` to set the properties of insignia in a batch
- Allowed player's self-healing effects to be benefited by allied or `PlayerControl=true` houses
- Allow player's self-healing effects to be benefited by allied or `PlayerControl=true` houses
- Power plant damage factor
- Allow faking digital display for `InfoType=Health` at disguise
- **NaotoYuuki** - Vertical & meteor trajectory projectile prototypes
- **handama** - AI script action to `16005 Jump Back To Previous Script`
- **TaranDahl (航味麻酱)**:
Expand Down
67 changes: 35 additions & 32 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,54 +57,57 @@ IngameScore.LoseTheme= ; Soundtrack theme ID
- Default `Shape.Spacing` for buildings is `4,-2`, `4,0` for others.
- `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).

- `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
[DigitalDisplayTypes]
0=SOMEDIGITALDISPLAYTYPE

[AudioVisual]
Buildings.DefaultDigitalDisplayTypes= ; List of DigitalDisplayTypes
Infantry.DefaultDigitalDisplayTypes= ; List of DigitalDisplayTypes
Vehicles.DefaultDigitalDisplayTypes= ; List of DigitalDisplayTypes
Aircraft.DefaultDigitalDisplayTypes= ; List of DigitalDisplayTypes
Buildings.DefaultDigitalDisplayTypes= ; list of DigitalDisplayTypes
Infantry.DefaultDigitalDisplayTypes= ; list of DigitalDisplayTypes
Vehicles.DefaultDigitalDisplayTypes= ; list of DigitalDisplayTypes
Aircraft.DefaultDigitalDisplayTypes= ; list of DigitalDisplayTypes

[SOMEDIGITALDISPLAYTYPE] ; DigitalDisplayType
[SOMEDIGITALDISPLAYTYPE] ; DigitalDisplayType
; Generic
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)
InfoIndex= ; integer
Offset=0,0 ; integers - horizontal, vertical
Offset.ShieldDelta= ; integers - horizontal, vertical
Align=right ; Text alignment enumeration (left|right|center/centre)
Anchor.Horizontal=right ; Horizontal position enumeration (left|center/centre|right)
Anchor.Vertical=top ; Vertical position enumeration (top|center/centre|bottom)
Anchor.Building=top ; Hexagon vertex enumeration (top|lefttop|leftbottom|bottom|rightbottom|righttop)
Percentage=false ; boolean
HideMaxValue=false ; boolean
VisibleToHouses=owner ; Affected house enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
VisibleToHouses.Observer=true ; boolean
VisibleInSpecialState=true ; boolean
ValueScaleDivisor= ; integer
ValueAsTimer=false ; boolean
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)
InfoIndex= ; integer
Offset=0,0 ; integers - horizontal, vertical
Offset.ShieldDelta= ; integers - horizontal, vertical
Align=right ; Text alignment enumeration (left|right|center/centre)
Anchor.Horizontal=right ; Horizontal position enumeration (left|center/centre|right)
Anchor.Vertical=top ; Vertical position enumeration (top|center/centre|bottom)
Anchor.Building=top ; Hexagon vertex enumeration (top|lefttop|leftbottom|bottom|rightbottom|righttop)
Percentage=false ; boolean
HideMaxValue=false ; boolean
VisibleToHouses=owner ; Affected house enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
VisibleToHouses.Observer=true ; boolean
VisibleInSpecialState=true ; boolean
ValueScaleDivisor= ; integer
ValueAsTimer=false ; boolean
; Text
Text.Color=0,255,0 ; integers - Red, Green, Blue
Text.Color.ConditionYellow=255,255,0 ; integers - Red, Green, Blue
Text.Color.ConditionRed=255,0,0 ; integers - Red, Green, Blue
Text.Background=false ; boolean
Text.Color=0,255,0 ; integers - Red, Green, Blue
Text.Color.ConditionYellow=255,255,0 ; integers - Red, Green, Blue
Text.Color.ConditionRed=255,0,0 ; integers - Red, Green, Blue
Text.Background=false ; boolean
; Shape
Shape= ; filename with .shp extension, if not present, game-drawn text will be used instead
Palette=palette.pal ; filename with .pal extension
Shape.Spacing= ; integers - horizontal, vertical spacing between digits
Shape.PercentageFrame=false ; boolean
Shape= ; filename with .shp extension, if not present, game-drawn text will be used instead
Palette=palette.pal ; filename with .pal extension
Shape.Spacing= ; integers - horizontal, vertical spacing between digits
Shape.PercentageFrame=false ; boolean

[SOMETECHNO] ; TechnoType
DigitalDisplay.Disable=false ; boolean
DigitalDisplayTypes= ; List of DigitalDisplayTypes
[SOMETECHNOTYPE]
DigitalDisplay.Disable=false ; boolean
DigitalDisplayTypes= ; list of DigitalDisplayTypes
DigitalDisplay.Health.FakeAtDisguise=true ; boolean
```

In `RA2MD.INI`:
```ini
[Phobos]
DigitalDisplay.Enable=false ; boolean
DigitalDisplay.Enable=false ; boolean
```

```{note}
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ New:
- Infantry support `IsGattling=yes` (by FlyStar)
- [Several new Infotypes, no display in specific status and a new single frame display method](User-Interface.md#digital-display) (by CrimRecya)
- Targeting limitation for berzerk technos (by TaranDahl)
- Allowed faking digital display for `InfoType=Health` at disguise (by Ollerus)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
22 changes: 22 additions & 0 deletions src/Ext/Techno/Body.Visuals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ void TechnoExt::GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType
{
value = pThis->Health;
maxValue = pType->Strength;

if (pThis->Disguised && !pThis->Owner->IsAlliedWith(HouseClass::CurrentPlayer))
GetDigitalDisplayFakeHealth(pThis, value, maxValue);

break;
}
case DisplayInfoType::Shield:
Expand Down Expand Up @@ -829,7 +833,25 @@ void TechnoExt::GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType
{
value = pThis->Health;
maxValue = pType->Strength;

if (pThis->Disguised && !pThis->Owner->IsAlliedWith(HouseClass::CurrentPlayer))
GetDigitalDisplayFakeHealth(pThis, value, maxValue);

break;
}
}
}

void TechnoExt::GetDigitalDisplayFakeHealth(TechnoClass* pThis, int& value, int& maxValue)
{
if (TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->DigitalDisplay_Health_FakeAtDisguise)
{
if (const auto pType = TechnoTypeExt::GetTechnoType(pThis->Disguise))
{
const int newMaxValue = pType->Strength;
const double ratio = static_cast<double>(value) / maxValue;
value = static_cast<int>(ratio * newMaxValue);
maxValue = newMaxValue;
}
}
}
1 change: 1 addition & 0 deletions src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class TechnoExt
static void DrawSelectBox(TechnoClass* pThis, const Point2D* pLocation, const RectangleStruct* pBounds, bool drawBefore = false);
static void ProcessDigitalDisplays(TechnoClass* pThis);
static void GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType, int& value, int& maxValue, int infoIndex);
static void GetDigitalDisplayFakeHealth(TechnoClass* pThis, int& value, int& maxValue);

// WeaponHelpers.cpp
static int PickWeaponIndex(TechnoClass* pThis, TechnoClass* pTargetTechno, AbstractClass* pTarget, int weaponIndexOne, int weaponIndexTwo, bool allowFallback = true, bool allowAAFallback = true);
Expand Down
6 changes: 5 additions & 1 deletion src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking");
this->BunkerableAnyway.Read(exINI, pSection, "BunkerableAnyway");

this->DigitalDisplay_Health_FakeAtDisguise.Read(exINI, pSection, "DigitalDisplay.Health.FakeAtDisguise");

this->AttackMove_Aggressive.Read(exINI, pSection, "AttackMove.Aggressive");
this->AttackMove_UpdateTarget.Read(exINI, pSection, "AttackMove.UpdateTarget");

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

.Process(this->DigitalDisplay_Health_FakeAtDisguise)

.Process(this->AttackMove_Aggressive)
.Process(this->AttackMove_UpdateTarget)

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

.Process(this->FiringForceScatter)

.Process(this->FireUp)
.Process(this->FireUp_ResetInRetarget)
//.Process(this->SecondaryFire)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ class TechnoTypeExt
Valueable<bool> SuppressKillWeapons;
ValueableVector<WeaponTypeClass*> SuppressKillWeapons_Types;

Valueable<bool> DigitalDisplay_Health_FakeAtDisguise;

NullableVector<int> Overload_Count;
NullableVector<int> Overload_Damage;
NullableVector<int> Overload_Frames;
Expand Down Expand Up @@ -636,6 +638,8 @@ class TechnoTypeExt
, Wake_Grapple { }
, Wake_Sinking { }

, DigitalDisplay_Health_FakeAtDisguise { true }

, AttackMove_Aggressive {}
, AttackMove_UpdateTarget {}

Expand Down