Files
wwdpublic/Content.Server/GameTicking/Rules/ShadowlingRuleSystem.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

134 lines
4.6 KiB
C#

using Content.Server.Antag;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Mind;
using Content.Server.Roles;
using Content.Server.Zombies;
using Content.Shared._EE.Shadowling;
using Content.Shared.GameTicking.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.NPC.Prototypes;
using Content.Shared.NPC.Systems;
using Content.Shared.Roles;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
namespace Content.Server.GameTicking.Rules;
public sealed class ShadowlingRuleSystem : GameRuleSystem<ShadowlingRuleComponent>
{
[Dependency] private readonly SharedRoleSystem _role = default!;
[Dependency] private readonly AntagSelectionSystem _antag = default!;
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly MobStateSystem _mob = default!;
[Dependency] private readonly NpcFactionSystem _npc = default!;
public readonly SoundSpecifier BriefingSound = new SoundPathSpecifier("/Audio/_EE/Shadowling/shadowling.ogg");
[ValidatePrototypeId<EntityPrototype>] EntProtoId _mindRole = "MindRoleShadowling";
public readonly ProtoId<NpcFactionPrototype> ShadowlingFactionId = "Shadowling";
public readonly ProtoId<NpcFactionPrototype> NanotrasenFactionId = "NanoTrasen";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ShadowlingRuleComponent, AfterAntagEntitySelectedEvent>(OnSelectAntag);
SubscribeLocalEvent<ShadowlingRoleComponent, GetBriefingEvent>(OnGetBriefing);
SubscribeLocalEvent<ShadowlingAscendEvent>(OnAscend);
SubscribeLocalEvent<ShadowlingDeathEvent>(OnDeath);
}
private void OnDeath(ShadowlingDeathEvent args)
{
var rulesQuery = QueryActiveRules();
while (rulesQuery.MoveNext(out _, out var shadowling, out _))
{
var shadowlingCount = 0;
var shadowlingDead = 0;
var query = EntityQueryEnumerator<ShadowlingComponent>();
while (query.MoveNext(out var uid, out _))
{
shadowlingCount++;
if (_mob.IsDead(uid) || _mob.IsInvalidState(uid))
shadowlingDead++;
}
if (shadowlingCount == shadowlingDead)
shadowling.WinCondition = ShadowlingWinCondition.Failure;
}
}
private void OnAscend(ShadowlingAscendEvent args)
{
var rulesQuery = QueryActiveRules();
while (rulesQuery.MoveNext(out _, out var shadowling, out _))
{
shadowling.WinCondition = ShadowlingWinCondition.Win;
return;
}
}
private void OnGetBriefing(EntityUid uid, ShadowlingRoleComponent component, ref GetBriefingEvent args)
{
var ent = args.Mind.Comp.OwnedEntity;
var sling = HasComp<ShadowlingComponent>(ent);
args.Briefing = Loc.GetString(sling ? "shadowling-briefing" : "thrall-briefing");
}
private void OnSelectAntag(EntityUid uid, ShadowlingRuleComponent comp, ref AfterAntagEntitySelectedEvent args)
{
MakeShadowling(args.EntityUid, comp);
}
public bool MakeShadowling(EntityUid target, ShadowlingRuleComponent rule)
{
EnsureComp<ZombieImmuneComponent>(target);
if (!_mind.TryGetMind(target, out var mindId, out var mind))
return false;
_role.MindAddRole(mindId, _mindRole.Id, mind, true);
_npc.RemoveFaction(target, NanotrasenFactionId, false);
_npc.AddFaction(target, ShadowlingFactionId);
TryComp<MetaDataComponent>(target, out var metaData);
if (metaData == null)
return false;
var briefing = Loc.GetString("shadowling-role-greeting");
_antag.SendBriefing(target, briefing, Color.MediumPurple, BriefingSound);
EnsureComp<ShadowlingComponent>(target);
rule.ShadowlingMinds.Add(mindId);
return true;
}
protected override void AppendRoundEndText(
EntityUid uid,
ShadowlingRuleComponent component,
GameRuleComponent gamerule,
ref RoundEndTextAppendEvent args
)
{
base.AppendRoundEndText(uid, component, gamerule, ref args);
var winText = Loc.GetString($"shadowling-condition-{component.WinCondition.ToString().ToLower()}");
args.AddLine(winText);
args.AddLine(Loc.GetString("shadowling-list-start"));
var sessionData = _antag.GetAntagIdentifiers(uid);
foreach (var (_, data, name) in sessionData)
{
var listing = Loc.GetString("shadowling-list-name", ("name", name), ("user", data.UserName));
args.AddLine(listing);
}
}
}