Skip to content
Open
4 changes: 3 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,9 @@ This page lists all the individual contributions to the project by their author.
- **solar-III (凤九歌)**
- Target scanning delay customization (documentation)
- Skip target scanning function calling for unarmed technos (documentation)
- **Flactine** - add target filtering options to attacheffect system
- **Flactine**
- Add target filtering options to attacheffect system
- Improve Damage Number Display Configuration and Readability
- **tyuah8**:
- Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
- Destroyed unit leaves sensors bugfix
Expand Down
4 changes: 0 additions & 4 deletions docs/Miscellanous.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ This page describes every change in Phobos that wasn't categorized into a proper

- Phobos writes additional information to the `SYNC#.txt` log files when a desynchronization occurs such as calls to random number generator functions, facing / target / destination changes etc.

### Display Damage Numbers

- There's a [new hotkey](User-Interface.md#display-damage-numbers) to show exact numbers of damage dealt on units & buildings. The numbers are shown in red (blue against shields) for damage, and for healing damage in green (cyan against shields). They are shown on the affected units and will move upwards after appearing. Available only if `DebugKeysEnabled` under `[GlobalControls]` is set to true in `rulesmd.ini`.

### Dump Object Info

![image](_static/images/objectinfo-01.png)
Expand Down
27 changes: 25 additions & 2 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ The arrangement of static images on the plane is entirely up to you to draw free
Of course, this is just the implementation method. To balance freedom with efficiency—that is, how to efficiently draw the patterns you need—you still need to independently explore a workflow that suits you.
````

### Display Damage Numbers

- There's a [new hotkey](User-Interface.md#toggle-damage-numbers-display) to show exact numbers of damage dealt on units & buildings. The numbers are shown in red (blue against shields) for damage, and for healing damage in green (cyan against shields). They are shown on the affected units and will move upwards after appearing.
- The feature is **available only when** `DamageNumbersEnabled` under `[GlobalControls]` in `rulesmd.ini` is set to `true`. If this setting is `false`, the feature is completely disabled and cannot be used.
- If `DamageNumbersEnabled` is not specified, its value defaults to the value of `DebugKeysEnabled`.
- The initial state of the feature (enabled or disabled when entering a game) is controlled by the `DisplayDamageNumbers` setting in `RA2MD.INI`.
- If set to `yes`, the feature starts enabled.
- If set to `no`, the feature starts disabled, but the player can still toggle it manually using the hotkey.
- Regardless of the default state, the hotkey always allows enabling or disabling the feature during gameplay.
- Individual warheads can suppress damage number display by setting `HiddenDamageNumbers`.

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

In `rulesmd.ini`:
```ini
[SOMEWARHEAD]
HiddenDamageNumbers=false ; boolean
```

### Flashing Technos on selecting

- Selecting technos, controlled by player, now may show a flash effect by setting `SelectionFlashDuration` parameter higher than 0.
Expand Down Expand Up @@ -455,9 +478,9 @@ DisplayIncome.Offset=0,0 ; X,Y, pixels relative to default

## Hotkey Commands

### `[ ]` Display Damage Numbers
### `[ ]` Toggle Damage Numbers Display

- Switches on/off floating numbers when dealing damage. See [this](Miscellanous.md#display-damage-numbers) for details.
- Switches on/off floating numbers when dealing damage. See [this](User-Interface.md#display-damage-numbers) for details.
- For localization add `TXT_DISPLAY_DAMAGE` and `TXT_DISPLAY_DAMAGE_DESC` into your `.csf` file.

### `[ ]` Dump Object Info
Expand Down
3 changes: 3 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ New:
- [Customize if cloning need power](Fixed-or-Improved-Logics.md#customize-if-cloning-need-power) (by NetsuNegi)
- [Added Target Filtering Options to AttachEffect System](New-or-Enhanced-Logics.md#attached-effects) (by Flactine)
- [Customize type selection for IFV](Fixed-or-Improved-Logics.md#customize-type-selection-for-ifv) (by NetsuNegi)
- CellSpread in cylinder shape (by TaranDahl)
- CellSpread damage check if victim is in air or on floor (by TaranDahl)
- Improve Damage Number Display Configuration and Readability (by Flactine)
- [CellSpread in cylinder shape](New-or-Enhanced-Logics.md#cellspread-enhancement) (by TaranDahl)
- [CellSpread damage check if victim is in air or on floor](New-or-Enhanced-Logics.md#cellspread-enhancement) (by TaranDahl)
- OpenTopped range bonus and damage multiplier customization for passengers (by Ollerus)
Expand Down
6 changes: 5 additions & 1 deletion src/Commands/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
SWSidebarClass::Commands[9] = MakeCommand<FireTacticalSWCommandClass<9>>();
}

if (Phobos::Config::DevelopmentCommands)
if (Phobos::Config::DamageNumbersCommands)
{
MakeCommand<DamageDisplayCommandClass>();
}

if (Phobos::Config::DevelopmentCommands)
{
MakeCommand<SaveVariablesToFileCommandClass>();
MakeCommand<ObjectInfoCommandClass>();
MakeCommand<FrameByFrameCommandClass>();
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/DamageDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ const wchar_t* DamageDisplayCommandClass::GetUIDescription() const

void DamageDisplayCommandClass::Execute(WWKey eInput) const
{
Phobos::DisplayDamageNumbers = !Phobos::DisplayDamageNumbers;
Phobos::Config::DisplayDamageNumbers = !Phobos::Config::DisplayDamageNumbers;
}
4 changes: 3 additions & 1 deletion src/Ext/Bullet/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ void BulletExt::ExtData::InterceptBullet(TechnoClass* pSource, BulletClass* pInt
const int damage = static_cast<int>(pInterceptor->Health * versus);
this->CurrentStrength -= damage;

if (Phobos::DisplayDamageNumbers && damage != 0)
const bool HiddenNumbers = WarheadTypeExt::ExtMap.Find(pThis->WH)->HiddenDamageNumbers;

if (Phobos::Config::DamageNumbersCommands && Phobos::Config::DisplayDamageNumbers && !HiddenNumbers && damage != 0)
GeneralUtils::DisplayDamageNumberString(damage, DamageDisplayType::Intercept, pThis->GetRenderCoords(), this->DamageNumberOffset);

if (this->CurrentStrength <= 0)
Expand Down
6 changes: 5 additions & 1 deletion src/Ext/Techno/Hooks.ReceiveDamage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ DEFINE_HOOK(0x702819, TechnoClass_ReceiveDamage_Decloak, 0xA)

DEFINE_HOOK(0x701DFF, TechnoClass_ReceiveDamage_FlyingStrings, 0x7)
{
if (!Phobos::DisplayDamageNumbers)
if (!Phobos::Config::DamageNumbersCommands || !Phobos::Config::DisplayDamageNumbers)
return 0;

GET(TechnoClass* const, pThis, ESI);
GET(int* const, pDamage, EBX);
GET_STACK(WarheadTypeClass*, pWarhead, STACK_OFFSET(0xC4, 0xC));

if (WarheadTypeExt::ExtMap.Find(pWarhead)->HiddenDamageNumbers)
return 0;

if (*pDamage)
GeneralUtils::DisplayDamageNumberString(*pDamage, DamageDisplayType::Regular, pThis->GetRenderCoords(), TechnoExt::ExtMap.Find(pThis)->DamageNumberOffset);
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/WarheadType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->CombatAlert_Suppress.Read(exINI, pSection, "CombatAlert.Suppress");

this->CanKill.Read(exINI, pSection, "CanKill");
this->HiddenDamageNumbers.Read(exINI, pSection, "HiddenDamageNumbers");

this->KillWeapon.Read(exINI, pSection, "KillWeapon");
this->KillWeapon_OnFirer.Read(exINI, pSection, "KillWeapon.OnFirer");
Expand Down Expand Up @@ -586,6 +587,8 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)

.Process(this->CanKill)

.Process(this->HiddenDamageNumbers)

.Process(this->ReverseEngineer)

.Process(this->UnlimboDetonate)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/WarheadType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ class WarheadTypeExt

Valueable<bool> CanKill;

Valueable<bool> HiddenDamageNumbers;

Valueable<bool> UnlimboDetonate;
Valueable<bool> UnlimboDetonate_ForceLocation;
Valueable<bool> UnlimboDetonate_KeepTarget;
Expand Down Expand Up @@ -427,6 +429,8 @@ class WarheadTypeExt

, CanKill { true }

, HiddenDamageNumbers { false }

, KillWeapon {}
, KillWeapon_OnFirer {}
, KillWeapon_AffectsHouses { AffectedHouse::All }
Expand Down
9 changes: 2 additions & 7 deletions src/Misc/FlyingStrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,9 @@ void FlyingStrings::UpdateAll()
bound.Height -= 32;

if (Unsorted::CurrentFrame > dataItem.CreationFrame + Duration - 70)
{
point.Y -= (Unsorted::CurrentFrame - dataItem.CreationFrame);
DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow);
}
else
{
DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow);
}

DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow);

if (Unsorted::CurrentFrame > dataItem.CreationFrame + Duration || Unsorted::CurrentFrame < dataItem.CreationFrame)
Data.erase(Data.begin() + i);
Expand Down
4 changes: 3 additions & 1 deletion src/New/Entity/ShieldClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ int ShieldClass::ReceiveDamage(args_ReceiveDamage* args)
const int maxDmg = GeneralUtils::SafeMultiply(max, pWHExt->Shield_ReceivedDamage_MaxMultiplier);
shieldDamage = Math::clamp(shieldDamage, minDmg, maxDmg);

if (Phobos::DisplayDamageNumbers && shieldDamage != 0)
const bool HiddenNumbers = pWHExt->HiddenDamageNumbers;

if (Phobos::Config::DamageNumbersCommands && Phobos::Config::DisplayDamageNumbers && !HiddenNumbers && shieldDamage != 0)
GeneralUtils::DisplayDamageNumberString(shieldDamage, DamageDisplayType::Shield, pTechno->GetRenderCoords(), TechnoExt::ExtMap.Find(pTechno)->DamageNumberOffset);

if (shieldDamage > 0)
Expand Down
4 changes: 4 additions & 0 deletions src/Phobos.INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ bool Phobos::Config::ToolTipDescriptions = true;
bool Phobos::Config::ToolTipBlur = false;
bool Phobos::Config::PrioritySelectionFiltering = true;
bool Phobos::Config::DevelopmentCommands = true;
bool Phobos::Config::DamageNumbersCommands = false;
bool Phobos::Config::SuperWeaponSidebarCommands = false;
bool Phobos::Config::ShowPlanningPath = false;
bool Phobos::Config::ArtImageSwap = false;
Expand Down Expand Up @@ -75,6 +76,7 @@ bool Phobos::Config::HideShakeEffects = true;
bool Phobos::Config::ShowFlashOnSelecting = false;
bool Phobos::Config::UnitPowerDrain = false;
int Phobos::Config::SuperWeaponSidebar_RequiredSignificance = 0;
bool Phobos::Config::DisplayDamageNumbers = false;

bool Phobos::Misc::CustomGS = false;
int Phobos::Misc::CustomGS_ChangeInterval[7] = { -1, -1, -1, -1, -1, -1, -1 };
Expand Down Expand Up @@ -108,6 +110,7 @@ DEFINE_HOOK(0x5FACDF, OptionsClass_LoadSettings_LoadPhobosSettings, 0x5)
Phobos::Config::HideShakeEffects = CCINIClass::INI_RA2MD.ReadBool(phobosSection, "HideShakeEffects", false);
Phobos::Config::ShowFlashOnSelecting = CCINIClass::INI_RA2MD.ReadBool(phobosSection, "ShowFlashOnSelecting", false);
Phobos::Config::SuperWeaponSidebar_RequiredSignificance = CCINIClass::INI_RA2MD.ReadInteger(phobosSection, "SuperWeaponSidebar.RequiredSignificance", 0);
Phobos::Config::DisplayDamageNumbers = CCINIClass::INI_RA2MD.ReadBool(phobosSection, "DisplayDamageNumbers", false);

// Custom game speeds, 6 - i so that GS6 is index 0, just like in the engine
Phobos::Config::CampaignDefaultGameSpeed = 6 - CCINIClass::INI_RA2MD.ReadInteger(phobosSection, "CampaignDefaultGameSpeed", 4);
Expand Down Expand Up @@ -281,6 +284,7 @@ DEFINE_HOOK(0x52D21F, InitRules_ThingsThatShouldntBeSerailized, 0x6)
Phobos::Config::SaveVariablesOnScenarioEnd = pINI_RULESMD->ReadBool(GameStrings::General, "SaveVariablesOnScenarioEnd", false);
#ifndef DEBUG
Phobos::Config::DevelopmentCommands = pINI_RULESMD->ReadBool("GlobalControls", "DebugKeysEnabled", Phobos::Config::DevelopmentCommands);
Phobos::Config::DamageNumbersCommands = pINI_RULESMD->ReadBool("GlobalControls", "DamageNumbersEnabled", Phobos::Config::DevelopmentCommands);
#endif
Phobos::Config::SuperWeaponSidebarCommands = pINI_RULESMD->ReadBool("GlobalControls", "SuperWeaponSidebarKeysEnabled", Phobos::Config::SuperWeaponSidebarCommands);
Phobos::Config::ShowPlanningPath = pINI_RULESMD->ReadBool("GlobalControls", "DebugPlanningPaths", Phobos::Config::ShowPlanningPath);
Expand Down
1 change: 0 additions & 1 deletion src/Phobos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ wchar_t Phobos::wideBuffer[Phobos::readLength];

const char* Phobos::AppIconPath = nullptr;

bool Phobos::DisplayDamageNumbers = false;
bool Phobos::IsLoadingSaveGame = false;

bool Phobos::Optimizations::Applied = false;
Expand Down
3 changes: 2 additions & 1 deletion src/Phobos.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Phobos

static const char* AppIconPath;
static const wchar_t* VersionDescription;
static bool DisplayDamageNumbers;
static bool IsLoadingSaveGame;
static bool ShouldSave;
static std::wstring CustomGameSaveDescription;
Expand Down Expand Up @@ -82,6 +81,7 @@ class Phobos
static bool ToolTipBlur;
static bool PrioritySelectionFiltering;
static bool DevelopmentCommands;
static bool DamageNumbersCommands;
static bool SuperWeaponSidebarCommands;
static bool ArtImageSwap;
static bool ShowPlacementPreview;
Expand Down Expand Up @@ -111,6 +111,7 @@ class Phobos
static bool ShowFlashOnSelecting;
static bool UnitPowerDrain;
static int SuperWeaponSidebar_RequiredSignificance;
static bool DisplayDamageNumbers;
};

class Misc
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/GeneralUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void GeneralUtils::DisplayDamageNumberString(int damage, DamageDisplayType type,
const int maxOffset = Unsorted::CellWidthInPixels / 2;
int width = 0, height = 0;
wchar_t damageStr[0x20];
swprintf_s(damageStr, L"%d", damage);
swprintf_s(damageStr, L"%c%d", damage > 0 ? L'-' : L'+', abs(damage));

BitFont::Instance->GetTextDimension(damageStr, &width, &height, 120);

Expand Down