Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadowkin Rework #1200

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Content.Server/Abilities/Psionics/Abilities/DarkSwapSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ private void OnPowerUsed(DarkSwapActionEvent args)
return;
}

if (_psionics.OnAttemptPowerUse(args.Performer, "DarkSwap", args.ManaCost / 2, args.CheckInsulation))
if (_psionics.OnAttemptPowerUse(args.Performer, "DarkSwap"))
{
SpawnAtPosition("ShadowkinShadow", Transform(args.Performer).Coordinates);
SpawnAtPosition("EffectFlashShadowkinDarkSwapOff", Transform(args.Performer).Coordinates);
RemComp(args.Performer, ethereal);
args.Handled = true;
}
}
else if (_psionics.OnAttemptPowerUse(args.Performer, "DarkSwap", args.ManaCost, args.CheckInsulation))
else if (_psionics.OnAttemptPowerUse(args.Performer, "DarkSwap", args.ManaCost))
{
var newethereal = EnsureComp<EtherealComponent>(args.Performer);
newethereal.Darken = true;
Expand All @@ -50,7 +52,7 @@ private void OnPowerUsed(DarkSwapActionEvent args)
}

if (args.Handled)
_psionics.LogPowerUsed(args.Performer, "DarkSwap", 0, 0);
_psionics.LogPowerUsed(args.Performer, "DarkSwap");
}
}
}
Expand Down
38 changes: 38 additions & 0 deletions Content.Server/Alert/Click/CheckMana.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Server.Chat.Managers;
using Content.Shared.Abilities.Psionics;
using Content.Shared.Alert;
using Content.Shared.Chat;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Player;

namespace Content.Server.Alert.Click;

[UsedImplicitly]
[DataDefinition]
public sealed partial class CheckMana : IAlertClick
{
public void AlertClicked(EntityUid player)
{
var chatManager = IoCManager.Resolve<IChatManager>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var playerManager = IoCManager.Resolve<IPlayerManager>();

if (!entityManager.TryGetComponent(player, out PsionicComponent? magic) ||
!playerManager.TryGetSessionByEntity(player, out var session))
return;

var baseMsg = Loc.GetString("mana-alert", ("mana", magic.Mana), ("manaMax", magic.MaxMana));
SendMessage(chatManager, baseMsg, session);
}

private static void SendMessage(IChatManager chatManager, string msg, ICommonSession session)
{
chatManager.ChatMessageToOne(ChatChannel.Emotes,
msg,
msg,
EntityUid.Invalid,
false,
session.Channel);
}
}
20 changes: 20 additions & 0 deletions Content.Server/Psionics/PsionicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
using Content.Shared.Mobs;
using Content.Shared.Damage;
using Content.Shared.Interaction.Events;
using Content.Shared.Alert;
using Content.Shared.Rounding;
using Content.Shared.Psionics;

namespace Content.Server.Psionics;

Expand All @@ -39,6 +42,7 @@ public sealed class PsionicsSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly PsionicFamiliarSystem _psionicFamiliar = default!;
[Dependency] private readonly NPCRetaliationSystem _retaliationSystem = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;

private const string BaselineAmplification = "Baseline Amplification";
private const string BaselineDampening = "Baseline Dampening";
Expand Down Expand Up @@ -71,6 +75,7 @@ public override void Initialize()
SubscribeLocalEvent<PsionicComponent, MobStateChangedEvent>(OnMobstateChanged);
SubscribeLocalEvent<PsionicComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<PsionicComponent, AttackAttemptEvent>(OnAttackAttempt);
SubscribeLocalEvent<PsionicComponent, OnManaUpdateEvent>(OnManaUpdate);

SubscribeLocalEvent<PsionicComponent, ComponentStartup>(OnInit);
SubscribeLocalEvent<PsionicComponent, ComponentRemove>(OnRemove);
Expand Down Expand Up @@ -135,6 +140,8 @@ private void CheckAntiPsionic(EntityUid entity, AntiPsionicWeaponComponent compo

private void OnInit(EntityUid uid, PsionicComponent component, ComponentStartup args)
{
UpdateManaAlert(uid, component);

component.AmplificationSources.Add(BaselineAmplification, _random.NextFloat(component.BaselineAmplification.Item1, component.BaselineAmplification.Item2));
component.DampeningSources.Add(BaselineDampening, _random.NextFloat(component.BaselineDampening.Item1, component.BaselineDampening.Item2));

Expand All @@ -148,12 +155,25 @@ private void OnInit(EntityUid uid, PsionicComponent component, ComponentStartup

private void OnRemove(EntityUid uid, PsionicComponent component, ComponentRemove args)
{
_alerts.ClearAlert(uid, AlertType.Mana);

if (!HasComp<NpcFactionMemberComponent>(uid))
return;

_npcFactonSystem.RemoveFaction(uid, "PsionicInterloper");
}

public void UpdateManaAlert(EntityUid uid, PsionicComponent component)
{
var severity = (short) ContentHelpers.RoundToLevels(component.Mana, component.MaxMana, 8);
_alerts.ShowAlert(uid, AlertType.Mana, severity);
}

private void OnManaUpdate(EntityUid uid, PsionicComponent component, ref OnManaUpdateEvent args)
{
UpdateManaAlert(uid, component);
}

private void OnStamHit(EntityUid uid, AntiPsionicWeaponComponent component, TakeStaminaDamageEvent args)
{
if (!HasComp<PsionicComponent>(args.Target))
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Shadowkin/EtherealStunItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private void OnUseInHand(EntityUid uid, EtherealStunItemComponent component, Use
{
foreach (var ent in _lookup.GetEntitiesInRange(uid, component.Radius))
{
if (!TryComp<EtherealComponent>(ent, out var ethereal))
if (!TryComp<EtherealComponent>(ent, out var ethereal)
|| !ethereal.CanBeStunned)
continue;

RemComp(ent, ethereal);
Expand Down
7 changes: 2 additions & 5 deletions Content.Server/Shadowkin/EtherealSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public override void OnShutdown(EntityUid uid, EtherealComponent component, Comp
RemComp<RespiratorImmuneComponent>(uid);
RemComp<MovementIgnoreGravityComponent>(uid);

SpawnAtPosition("ShadowkinShadow", Transform(uid).Coordinates);
SpawnAtPosition("EffectFlashShadowkinDarkSwapOff", Transform(uid).Coordinates);

foreach (var light in component.DarkenedLights.ToArray())
{
if (!TryComp<PointLightComponent>(light, out var pointLight)
Expand Down Expand Up @@ -181,7 +178,7 @@ public override void Update(float frameTime)

if (etherealLight.AttachedEntity == uid
&& _random.Prob(0.03f))
etherealLight.AttachedEntity = EntityUid.Invalid;
etherealLight.AttachedEntity = EntityUid.Invalid;

if (!etherealLight.OldRadiusEdited)
{
Expand Down Expand Up @@ -213,4 +210,4 @@ public override void Update(float frameTime)
}
}
}
}
}
29 changes: 0 additions & 29 deletions Content.Server/Shadowkin/ShadowkinCuffSystem.cs

This file was deleted.

59 changes: 4 additions & 55 deletions Content.Server/Shadowkin/ShadowkinSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,19 @@ public override void Initialize()
SubscribeLocalEvent<ShadowkinComponent, ComponentStartup>(OnInit);
SubscribeLocalEvent<ShadowkinComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<ShadowkinComponent, OnMindbreakEvent>(OnMindbreak);
SubscribeLocalEvent<ShadowkinComponent, OnAttemptPowerUseEvent>(OnAttemptPowerUse);
SubscribeLocalEvent<ShadowkinComponent, OnManaUpdateEvent>(OnManaUpdate);
SubscribeLocalEvent<ShadowkinComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<ShadowkinComponent, EyeColorInitEvent>(OnEyeColorChange);
}

private void OnInit(EntityUid uid, ShadowkinComponent component, ComponentStartup args)
{
if (component.BlackeyeSpawn)
ApplyBlackEye(uid);

_actionsSystem.AddAction(uid, ref component.ShadowkinSleepAction, ShadowkinSleepActionId, uid);

UpdateShadowkinAlert(uid, component);
}

private void OnEyeColorChange(EntityUid uid, ShadowkinComponent component, EyeColorInitEvent args)
{
if (!TryComp<HumanoidAppearanceComponent>(uid, out var humanoid)
|| !component.BlackeyeSpawn
|| humanoid.EyeColor == component.OldEyeColor)
return;

Expand Down Expand Up @@ -81,26 +74,6 @@ private void OnExamined(EntityUid uid, ShadowkinComponent component, ExaminedEve
));
}

/// <summary>
/// Update the Shadowkin Alert, if Blackeye will remove the Alert, if not will update to its current power status.
/// </summary>
public void UpdateShadowkinAlert(EntityUid uid, ShadowkinComponent component)
{
if (TryComp<PsionicComponent>(uid, out var magic))
{
var severity = (short) ContentHelpers.RoundToLevels(magic.Mana, magic.MaxMana, 8);
_alerts.ShowAlert(uid, AlertType.ShadowkinPower, severity);
}
else
_alerts.ClearAlert(uid, AlertType.ShadowkinPower);
}

private void OnAttemptPowerUse(EntityUid uid, ShadowkinComponent component, OnAttemptPowerUseEvent args)
{
if (HasComp<ShadowkinCuffComponent>(uid))
args.Cancel();
}

private void OnManaUpdate(EntityUid uid, ShadowkinComponent component, ref OnManaUpdateEvent args)
{
if (!TryComp<PsionicComponent>(uid, out var magic))
Expand All @@ -112,24 +85,7 @@ private void OnManaUpdate(EntityUid uid, ShadowkinComponent component, ref OnMan
else
magic.ManaGainMultiplier = 1;

if (magic.Mana <= component.BlackEyeMana)
ApplyBlackEye(uid);

Dirty(magic); // Update Shadowkin Overlay.
UpdateShadowkinAlert(uid, component);
}

/// <summary>
/// Blackeye the Shadowkin, its just a function to mindbreak the shadowkin but making sure "Removable" is checked true during it.
/// </summary>
/// <param name="uid"></param>
public void ApplyBlackEye(EntityUid uid)
{
if (!TryComp<PsionicComponent>(uid, out var magic))
return;

magic.Removable = true;
_psionicAbilitiesSystem.MindBreak(uid);
}

private void OnMindbreak(EntityUid uid, ShadowkinComponent component, ref OnMindbreakEvent args)
Expand All @@ -144,17 +100,13 @@ private void OnMindbreak(EntityUid uid, ShadowkinComponent component, ref OnMind
Dirty(humanoid);
}

if (component.BlackeyeSpawn)
return;

if (TryComp<StaminaComponent>(uid, out var stamina))
_stamina.TakeStaminaDamage(uid, stamina.CritThreshold, stamina, uid);
}

private void OnRejuvenate(EntityUid uid, ShadowkinComponent component, RejuvenateEvent args)
{
if (component.BlackeyeSpawn
|| !HasComp<MindbrokenComponent>(uid))
if (!HasComp<MindbrokenComponent>(uid))
return;

RemComp<MindbrokenComponent>(uid);
Expand All @@ -166,16 +118,13 @@ private void OnRejuvenate(EntityUid uid, ShadowkinComponent component, Rejuvenat
}

EnsureComp<PsionicComponent>(uid, out var magic);
magic.Mana = 250;
magic.MaxMana = 250;
magic.Mana = 200;
magic.MaxMana = 200;
magic.ManaGain = 0.25f;
magic.BypassManaCheck = true;
magic.Removable = false;
magic.MindbreakingFeedback = "shadowkin-blackeye";
magic.NoMana = "shadowkin-tired";

if (_prototypeManager.TryIndex<PsionicPowerPrototype>("ShadowkinPowers", out var shadowkinPowers))
_psionicAbilitiesSystem.InitializePsionicPower(uid, shadowkinPowers);

UpdateShadowkinAlert(uid, component);
}
}
2 changes: 1 addition & 1 deletion Content.Shared/Alert/AlertType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public enum AlertType : byte
BorgCrit,
BorgDead,
Offer,
ShadowkinPower,
Mana,
Deflecting,
}

Expand Down
3 changes: 2 additions & 1 deletion Content.Shared/Psionics/PsionicComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed partial class PsionicComponent : Component
/// Current Mana.
/// </summary>
[DataField, AutoNetworkedField]
public float Mana;
public float Mana = 50;

/// <summary>
/// Max Mana Possible.
Expand Down Expand Up @@ -212,6 +212,7 @@ private set
public string AlreadyCasting = "already-casting";

/// Popup to play if there no Mana left for a power to execute.
[DataField]
public string NoMana = "no-mana";

/// <summary>
Expand Down
6 changes: 5 additions & 1 deletion Content.Shared/Psionics/SharedPsionicAbilitiesSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ public override void Update(float frameTime)
var query = EntityQueryEnumerator<PsionicComponent>();
while (query.MoveNext(out var uid, out var component))
{
if (_mobState.IsDead(uid))
if (_mobState.IsDead(uid)
|| HasComp<PsionicInsulationComponent>(uid))
continue;

component.ManaAccumulator += frameTime;
Expand All @@ -160,6 +161,9 @@ public override void Update(float frameTime)
if (component.Mana > component.MaxMana)
component.Mana = component.MaxMana;

if (component.Mana < 0)
component.Mana = 0;

if (component.Mana < component.MaxMana)
{
var gainedmana = component.ManaGain * component.ManaGainMultiplier;
Expand Down
16 changes: 15 additions & 1 deletion Content.Shared/Shadowkin/EtherealComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,22 @@ public sealed partial class EtherealComponent : Component
[DataField]
public float DarkenRate = 0.084f;

/// <summary>
/// Can be stunned by ethereal stun objects?
/// </summary>
[DataField]
public bool CanBeStunned = true;

/// <summary>
/// Drain Mana is ent is psionic?
/// </summary>
[DataField]
public bool DrainMana = true;

public List<EntityUid> DarkenedLights = new();

public float OldManaGain;

public float DarkenAccumulator;

public int OldMobMask;
Expand All @@ -33,4 +47,4 @@ public sealed partial class EtherealComponent : Component

public List<string> SuppressedFactions = new();
public bool HasDoorBumpTag;
}
}
Loading
Loading