Skip to content

Commit

Permalink
Light effect customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Aug 28, 2024
1 parent 0c83f16 commit 5012a40
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 0 deletions.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ This page lists all the individual contributions to the project by their author.
- Allowed and disallowed types for `FactoryPlant`
- Forbidding parallel AI queues for specific TechnoTypes
- Nonprovocative Warheads
- 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 @@ -67,6 +67,7 @@
<ClCompile Include="src\Misc\Hooks.Gamespeed.cpp" />
<ClCompile Include="src\Misc\Hooks.Ares.cpp" />
<ClCompile Include="src\Misc\Hooks.Crates.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
16 changes: 16 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,21 @@ In `rulesmd.ini`:
AllowDamageOnSelf=false ; 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)
```

### Customizing decloak on damaging targets

- You can now specify whether or not the warhead decloaks objects that are damaged by the warhead.
Expand All @@ -1262,6 +1277,7 @@ In `rulesmd.ini`:
Nonprovocative=false ; boolean
```


### 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 @@ -131,6 +131,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 @@ -88,6 +88,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 @@ -449,6 +450,7 @@ New:
- Custom object palettes for TerrainTypes (by Starkku)
- Forbidding parallel AI queues for specific TechnoTypes (by Starkku)
- Nonprovocative Warheads (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 @@ -190,6 +190,10 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)

this->UseFixedVoxelLighting.Read(exINI, GameStrings::AudioVisual, "UseFixedVoxelLighting");

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("AITargetTypes");
for (int i = 0; i < itemsCount; ++i)
Expand Down Expand Up @@ -360,6 +364,9 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->VoxelLightSource)
// .Process(this->VoxelShadowLightSource)
.Process(this->UseFixedVoxelLighting)
.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 @@ -149,6 +149,10 @@ class RulesExt
// Nullable<Vector3D<float>> VoxelShadowLightSource;
Valueable<bool> UseFixedVoxelLighting;

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

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, InfantryGainSelfHealCap {}
Expand Down Expand Up @@ -254,6 +258,9 @@ class RulesExt
, VoxelLightSource { }
// , VoxelShadowLightSource { }
, UseFixedVoxelLighting { false }
, 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 @@ -252,6 +252,10 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

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

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

this->AttachEffect_AttachTypes.Read(exINI, pSection, "AttachEffect.AttachTypes");
this->AttachEffect_RemoveTypes.Read(exINI, pSection, "AttachEffect.RemoveTypes");
exINI.ParseStringList(this->AttachEffect_RemoveGroups, pSection, "AttachEffect.RemoveGroups");
Expand Down Expand Up @@ -481,6 +485,10 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)

.Process(this->Nonprovocative)

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

// Ares tags
.Process(this->AffectsEnemies)
.Process(this->AffectsOwner)
Expand Down
8 changes: 8 additions & 0 deletions src/Ext/WarheadType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ class WarheadTypeExt

Valueable<bool> Nonprovocative;

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

ValueableVector<AttachEffectTypeClass*> AttachEffect_AttachTypes;
ValueableVector<AttachEffectTypeClass*> AttachEffect_RemoveTypes;
std::vector<std::string> AttachEffect_RemoveGroups;
Expand Down Expand Up @@ -284,6 +288,10 @@ class WarheadTypeExt

, Nonprovocative { false }

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

, AttachEffect_AttachTypes {}
, AttachEffect_RemoveTypes {}
, AttachEffect_RemoveGroups {}
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 @@ -52,6 +52,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 @@ -72,6 +73,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);

// Custom game speeds, 6 - i so that GS6 is index 0, just like in the engine
Phobos::Config::CampaignDefaultGameSpeed = 6 - CCINIClass::INI_RA2MD->ReadInteger("Phobos", "CampaignDefaultGameSpeed", 4);
Expand Down
1 change: 1 addition & 0 deletions src/Phobos.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Phobos
static bool ShowPowerDelta;
static bool ShowHarvesterCounter;
static bool ShowWeedsCounter;
static bool HideLightFlashEffects;
};

class Misc
Expand Down

0 comments on commit 5012a40

Please sign in to comment.