Skip to content

Commit

Permalink
Light effect customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed May 11, 2024
1 parent 8027c03 commit 7656be6
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 0 deletions.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ This page lists all the individual contributions to the project by their author.
- Projectile return weapon
- Aircraft landing / docking direction
- `DeploysInto` cursor desync fix
- Light effect customizations
- **Morton (MortonPL)**:
- `XDrawOffset` for animations
- Shield passthrough & absorption
Expand Down
1 change: 1 addition & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<ClCompile Include="src\Misc\Hooks.AssignHouses.cpp" />
<ClCompile Include="src\Misc\Hooks.Gamespeed.cpp" />
<ClCompile Include="src\Misc\Hooks.Ares.cpp" />
<ClCompile Include="src\Misc\Hooks.LightEffects.cpp" />
<ClCompile Include="src\Misc\Hooks.VeinholeMonster.cpp" />
<ClCompile Include="src\Misc\PhobosToolTip.cpp" />
<ClCompile Include="src\Misc\TextInput.cpp" />
Expand Down
15 changes: 15 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,21 @@ In `rulesmd.ini`:
DecloakDamagedTargets=true ; boolean
```

### Combat light customizations

- You can now set minimum detail level at which combat light effects are shown by setting `[AudioVisual]` -> `CombatLightDetailLevel` or `CombatLightDetailLevel` on Warhead, latter defaults to former.
- You can now set a percentage chance a combat light effect is shown on Warhead impact by setting `CombatLightChance`.

In `rulesmd.ini`:
```ini
[AudioVisual]
CombatLightDetailLevel=0 ; integer

[SOMEWARHEAD] ; WarheadType
CombatLightDetailLevel= ; integer
CombatLightChance=1.0 ; floating point value, percents or absolute (0.0-1.0)
```

### Restricting screen shaking to current view

- You can now specify whether or not the warhead can only shake screen (`ShakeX/Ylo/hi`) if it is detonated while visible on current screen view.
Expand Down
23 changes: 23 additions & 0 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,29 @@ In `rulesmd.ini`:
HealthBar.Hide=false ; boolean
```

### Light flash effect toggling

- It is possible to toggle certain light flash effects off. These light flash effects include:
- Combat light effects (`Bright=true`) and everything that uses same functionality e.g Iron Curtain / Force Field impact flashes.
- Alpha images attached to ParticleSystems or Particles that are generated through a Warhead's `Particle` if `[AudioVisual]` -> `WarheadParticleAlphaImageIsLightFlash` or on Warhead `Particle.AlphaImageIsLightFlash` is set to true, latter defaults to former.
- Additionally these alpha images are not created if `[AudioVisual]`->`LightFlashAlphaImageDetailLevel` is higher than current detail level, regardless of the `HideLightFlashEffects` setting.

In `rulesmd.ini`:
```ini
[AudioVisual]
WarheadParticleAlphaImageIsLightFlash=false ; boolean
LightFlashAlphaImageDetailLevel=0 ; integer

[SOMEWARHEAD] ; WarheadType
Particle.AlphaImageIsLightFlash= ; boolean
```

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

### Low priority for box selection

![smartvesters](_static/images/lowpriority-01.gif)
Expand Down
2 changes: 2 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ ShowWeedsCounter=true ; boolean
ToolTipDescriptions=true ; boolean
ToolTipBlur=false ; boolean
SaveGameOnScenarioStart=true ; boolean
HideLightFlashEffects=false ; boolean
```

### For Map Editor (Final Alert 2)
Expand Down Expand Up @@ -394,6 +395,7 @@ New:
- Toggleable height-based shadow scaling for voxel air units (by Trsdy & Starkku)
- User setting toggles for harvester counter & power delta indicator (by Starkku)
- Shrapnel weapon target filtering toggle (by Starkku)
- Light effect customizations (by Starkku)
Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
7 changes: 7 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->Vehicles_DefaultDigitalDisplayTypes.Read(exINI, GameStrings::AudioVisual, "Vehicles.DefaultDigitalDisplayTypes");
this->Aircraft_DefaultDigitalDisplayTypes.Read(exINI, GameStrings::AudioVisual, "Aircraft.DefaultDigitalDisplayTypes");

this->WarheadParticleAlphaImageIsLightFlash.Read(exINI, GameStrings::AudioVisual, "WarheadParticleAlphaImageIsLightFlash");
this->CombatLightDetailLevel.Read(exINI, GameStrings::AudioVisual, "CombatLightDetailLevel");
this->LightFlashAlphaImageDetailLevel.Read(exINI, GameStrings::AudioVisual, "LightFlashAlphaImageDetailLevel");

// Section AITargetTypes
int itemsCount = pINI->GetKeyCount(sectionAITargetTypes);
for (int i = 0; i < itemsCount; ++i)
Expand Down Expand Up @@ -300,6 +304,9 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->ShowDesignatorRange)
.Process(this->DropPodTrailer)
.Process(this->PodImage)
.Process(this->WarheadParticleAlphaImageIsLightFlash)
.Process(this->CombatLightDetailLevel)
.Process(this->LightFlashAlphaImageDetailLevel)
;
}

Expand Down
7 changes: 7 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ class RulesExt
AnimTypeClass* DropPodTrailer;
SHPStruct* PodImage;

Valueable<bool> WarheadParticleAlphaImageIsLightFlash;
Valueable<int> CombatLightDetailLevel;
Valueable<int> LightFlashAlphaImageDetailLevel;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, InfantryGainSelfHealCap {}
Expand Down Expand Up @@ -198,6 +202,9 @@ class RulesExt
, ShowDesignatorRange { true }
, DropPodTrailer { }
, PodImage { }
, WarheadParticleAlphaImageIsLightFlash { false }
, CombatLightDetailLevel { 0 }
, LightFlashAlphaImageDetailLevel { 0 }
{ }

virtual ~ExtData() = default;
Expand Down
8 changes: 8 additions & 0 deletions src/Ext/WarheadType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->DetonateOnAllMapObjects_AffectTypes.Read(exINI, pSection, "DetonateOnAllMapObjects.AffectTypes");
this->DetonateOnAllMapObjects_IgnoreTypes.Read(exINI, pSection, "DetonateOnAllMapObjects.IgnoreTypes");

this->CombatLightDetailLevel.Read(exINI, pSection, "CombatLightDetailLevel");
this->CombatLightChance.Read(exINI, pSection, "CombatLightChance");
this->Particle_AlphaImageIsLightFlash.Read(exINI, pSection, "Particle.AlphaImageIsLightFlash");

// Convert.From & Convert.To
TypeConvertGroup::Parse(this->Convert_Pairs, exINI, pSection, AffectedHouse::All);

Expand Down Expand Up @@ -341,6 +345,10 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
.Process(this->InflictLocomotor)
.Process(this->RemoveInflictedLocomotor)

.Process(this->CombatLightDetailLevel)
.Process(this->CombatLightChance)
.Process(this->Particle_AlphaImageIsLightFlash)

// Ares tags
.Process(this->AffectsEnemies)
.Process(this->AffectsOwner)
Expand Down
7 changes: 7 additions & 0 deletions src/Ext/WarheadType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class WarheadTypeExt
Valueable<bool> InflictLocomotor;
Valueable<bool> RemoveInflictedLocomotor;

Nullable<int> CombatLightDetailLevel;
Valueable<double> CombatLightChance;
Nullable<bool> Particle_AlphaImageIsLightFlash;

// Ares tags
// http://ares-developers.github.io/Ares-docs/new/warheads/general.html
Expand Down Expand Up @@ -229,6 +232,10 @@ class WarheadTypeExt
, InflictLocomotor { false }
, RemoveInflictedLocomotor { false }

, CombatLightDetailLevel {}
, CombatLightChance { 1.0 }
, Particle_AlphaImageIsLightFlash {}

, AffectsEnemies { true }
, AffectsOwner {}

Expand Down
75 changes: 75 additions & 0 deletions src/Misc/Hooks.LightEffects.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <GameOptionsClass.h>

#include <Ext/WarheadType/Body.h>
#include <Helpers/Macro.h>

namespace LightEffectsTemp
{
bool AlphaIsLightFlash = false;
}

DEFINE_HOOK(0x48A444, AreaDamage_Particle_LightFlashSet, 0x5)
{
GET(WarheadTypeClass*, pWH, EDI);

auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWH);

if (pWHExt->Particle_AlphaImageIsLightFlash.Get(RulesExt::Global()->WarheadParticleAlphaImageIsLightFlash))
LightEffectsTemp::AlphaIsLightFlash = true;

return 0;
}

DEFINE_HOOK(0x48A47E, AreaDamage_Particle_LightFlashUnset, 0x6)
{
LightEffectsTemp::AlphaIsLightFlash = false;

return 0;
}

DEFINE_HOOK(0x5F5053, ObjectClass_Unlimbo_AlphaImage, 0x6)
{
enum { SkipAlphaImage = 0x5F514B };

int detailLevel = 0;

if (LightEffectsTemp::AlphaIsLightFlash)
{
if (Phobos::Config::HideLightFlashEffects)
return SkipAlphaImage;

detailLevel = RulesExt::Global()->LightFlashAlphaImageDetailLevel;
}

if (detailLevel > GameOptionsClass::Instance->DetailLevel)
return SkipAlphaImage;

return 0;
}

DEFINE_HOOK(0x48A62E, DoFlash_CombatLightOptions, 0x6)
{
enum { Continue = 0x48A64A, SkipFlash = 0x48A6FA };

if (Phobos::Config::HideLightFlashEffects)
return SkipFlash;

GET(int, currentDetailLevel, EAX);
GET(WarheadTypeClass*, pWH, EDI);

int detailLevel = RulesExt::Global()->CombatLightDetailLevel;

if (pWH)
{
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWH);
detailLevel = pWHExt->CombatLightDetailLevel.Get(detailLevel);

if (pWHExt->CombatLightChance < Randomizer::Global->RandomDouble())
return SkipFlash;
}

if (detailLevel <= currentDetailLevel)
return Continue;

return SkipFlash;
}
2 changes: 2 additions & 0 deletions src/Phobos.INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ bool Phobos::Config::ShowBriefing = true;
bool Phobos::Config::ShowHarvesterCounter = false;
bool Phobos::Config::ShowPowerDelta = true;
bool Phobos::Config::ShowWeedsCounter = false;
bool Phobos::Config::HideLightFlashEffects = true;

bool Phobos::Misc::CustomGS = false;
int Phobos::Misc::CustomGS_ChangeInterval[7] = { -1, -1, -1, -1, -1, -1, -1 };
Expand All @@ -68,6 +69,7 @@ DEFINE_HOOK(0x5FACDF, OptionsClass_LoadSettings_LoadPhobosSettings, 0x5)
Phobos::Config::ShowPowerDelta = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ShowPowerDelta", true);
Phobos::Config::ShowHarvesterCounter = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ShowHarvesterCounter", true);
Phobos::Config::ShowWeedsCounter = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ShowWeedsCounter", true);
Phobos::Config::HideLightFlashEffects = CCINIClass::INI_RA2MD->ReadBool("Phobos", "HideLightFlashEffects", false);

CCINIClass* pINI_UIMD = CCINIClass::LoadINIFile(GameStrings::UIMD_INI);

Expand Down
1 change: 1 addition & 0 deletions src/Phobos.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Phobos
static bool ShowPowerDelta;
static bool ShowHarvesterCounter;
static bool ShowWeedsCounter;
static bool HideLightFlashEffects;
};

class Misc
Expand Down

0 comments on commit 7656be6

Please sign in to comment.