Files
wwdpublic/Content.Server/_EE/Shadowling/Systems/LightDetectionDamageModifierSystem.cs
Lumminal 16ea61f52f Shadowling Antagonist (SS13 Port and Remake) (#2207)
<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Ports Shadowlings from SS13 to SS14 with a remake to make them fun to
play.

Minimal Design Doc (not up-to-date, read comments in this repo for
updates):

https://github.com/Lumminal/SS14-Design-Docs-Lumminal/blob/main/Shadowling.md

---

- Abilities
  - [X] Hatch
  - [x] Glare
  - [X] Enthrall
  - [x] Veil
  - [x] Shadow Walk
  - [x] Icy Veins
  - [x] Collective Mind
  - [x] Rapid Re-Hatch
  - [x] Destroy Engines
  - [x] Sonic Screech
  - [x] Blindness Smoke
  - [x] Null Charge
  - [x] Black Recuperation
  - [x] Empowered Enthrall
  - [x] Nox Imperii
  - [x] Ascension
  - [x] Annihilate
  - [x] Hypnosis
  - [x] Plane-Shift
  - [x] Lighting Storm
  - [x] Ascendant Broadcast
- Antags
  - [X] Thrall
      - [x] Guise
      - [x] Thrall Darksight
  - [x] Lesser Shadowling
- Passive
  - [x] Light Resistance Scaling
  - [x] Shadowmind
  - [x] Damage on Light
- Other
  - [x] Sounds
  - [x] Sprites
  - [x] Psionic Interactions
  - [x] Handle Edge Cases
---

<details><summary><h1>Media</h1></summary>
<p>

https://www.youtube.com/watch?v=H-Ee5wuRINc

</p>
</details>

---

🆑
- add: The shadows have awakened, and their ascendance is soon to
follow. Do not enter maints.

---------

Signed-off-by: Lumminal <81829924+Lumminal@users.noreply.github.com>
2025-07-20 12:05:11 +10:00

112 lines
3.8 KiB
C#

using Content.Shared._EE.Shadowling.Components;
using Content.Shared.Alert;
using Content.Shared.Damage;
using Content.Shared.Mobs.Systems;
using Robust.Server.Audio;
using Robust.Shared.Audio;
using Robust.Shared.Timing;
namespace Content.Server._EE.Shadowling;
/// <summary>
/// This handles healing or dealing damage to an entity that is standing on a lighted area.
/// </summary>
public sealed class LightDetectionDamageModifierSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly AudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LightDetectionDamageModifierComponent, ComponentStartup>(OnComponentStartup);
}
/// <inheritdoc/>
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<LightDetectionDamageModifierComponent>();
while (query.MoveNext(out var uid, out var comp))
{
if (!TryComp<LightDetectionComponent>(uid, out var lightDet))
continue;
if (comp.ShowAlert)
{
Dirty(uid, comp);
_alerts.ShowAlert(uid, comp.AlertProto);
}
if (_timing.CurTime < comp.NextUpdate)
continue;
if (lightDet.IsOnLight)
{
comp.DetectionValue -= comp.DetectionValueFactor;
if (comp.DetectionValue <= 0)
comp.DetectionValue = 0;
}
else
{
comp.DetectionValue += comp.DetectionValueFactor;
if (comp.DetectionValue >= comp.DetectionValueMax)
comp.DetectionValue = comp.DetectionValueMax;
}
if (comp.DetectionValue <= 0 && comp.TakeDamageOnLight)
{
// Take Damage
if (_timing.CurTime >= comp.NextUpdateDamage)
{
// Prevents from ashing when critical
if (!_mobState.IsCritical(uid))
{
_damageable.TryChangeDamage(uid, comp.DamageToDeal * comp.ResistanceModifier);
_audio.PlayPvs(
new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/energy_meat1.ogg"),
uid,
AudioParams.Default.WithVolume(-2f));
comp.NextUpdateDamage = _timing.CurTime + comp.DamageInterval;
}
}
}
else if (comp.DetectionValue >= comp.DetectionValueMax && comp.HealOnShadows)
{
// Heal Damage
if (_timing.CurTime >= comp.NextUpdateHeal)
{
_damageable.TryChangeDamage(uid, comp.DamageToHeal);
comp.NextUpdateHeal = _timing.CurTime + comp.HealInterval;
}
}
comp.NextUpdate = _timing.CurTime + comp.UpdateInterval;
}
}
private void OnComponentStartup(
EntityUid uid,
LightDetectionDamageModifierComponent component,
ComponentStartup args
)
{
component.NextUpdate = _timing.CurTime;
component.NextUpdateDamage = _timing.CurTime;
component.NextUpdateHeal = _timing.CurTime;
component.DetectionValue = component.DetectionValueMax;
}
public void AddResistance(float amount, EntityUid uid, LightDetectionDamageModifierComponent component)
{
component.ResistanceModifier += amount;
}
}