Skip to content
Open
4 changes: 3 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,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
11 changes: 11 additions & 0 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ 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#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.
- Whether the feature is enabled by default is determined by `DisplayDamageNumbers` setting in `RA2MD.INI`.

In `RA2MD.INI`:
```ini
[Phobos]
DisplayDamageNumbers=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
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ New:
- [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)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
MakeCommand<ToggleDesignatorRangeCommandClass>();
MakeCommand<ToggleMessageListCommandClass>();
MakeCommand<ToggleSWSidebar>();
MakeCommand<DamageDisplayCommandClass>();

if (Phobos::Config::SuperWeaponSidebarCommands)
{
Expand All @@ -46,7 +47,6 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)

if (Phobos::Config::DevelopmentCommands)
{
MakeCommand<DamageDisplayCommandClass>();
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;
}
2 changes: 1 addition & 1 deletion src/Ext/Bullet/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ 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)
if (Phobos::Config::DisplayDamageNumbers && damage != 0)
GeneralUtils::DisplayDamageNumberString(damage, DamageDisplayType::Intercept, pThis->GetRenderCoords(), this->DamageNumberOffset);

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

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

GET(TechnoClass* const, pThis, ESI);
Expand Down
2 changes: 1 addition & 1 deletion src/New/Entity/ShieldClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ 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)
if (Phobos::Config::DisplayDamageNumbers && shieldDamage != 0)
GeneralUtils::DisplayDamageNumberString(shieldDamage, DamageDisplayType::Shield, pTechno->GetRenderCoords(), TechnoExt::ExtMap.Find(pTechno)->DamageNumberOffset);

if (shieldDamage > 0)
Expand Down
2 changes: 2 additions & 0 deletions src/Phobos.INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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 +109,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
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
2 changes: 1 addition & 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 @@ -111,6 +110,7 @@ class Phobos
static bool ShowFlashOnSelecting;
static bool UnitPowerDrain;
static int SuperWeaponSidebar_RequiredSignificance;
static bool DisplayDamageNumbers;
};

class Misc
Expand Down
18 changes: 16 additions & 2 deletions src/Utilities/GeneralUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,28 @@ 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);

if (offset >= maxOffset || offset == INT32_MIN)
offset = -maxOffset;

FlyingStrings::Add(damageStr, coords, color, Point2D { offset - (width / 2), 0 });
Point2D basePos { offset - (width / 2), 0 };

FlyingStrings::Add(
damageStr,
coords,
color,
basePos
);

FlyingStrings::Add(
damageStr,
coords,
ColorStruct { 84, 84, 84 },
Point2D { basePos.X + 1, basePos.Y + 1 }
);

offset = offset + width;
}
Expand Down