mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-21 23:48:15 +03:00
# Description The bug with the traits menu related to psionics is a significantly more complicated issue, so I'm fixing that separately, it notably involves touching a different system entirely than anything in this PR. The biggest ones this fixes are Psi-Invis and Anoigo. Others are a variety of other powers that were supposed to be checking "Is the target insulated?" but weren't. To make it easier to check, I added an overload for the OnAttemptPowerUse function that accepts a Target EntityUid, which extends the insulation check to a second entity, which all of the pre-existing targetted powers now use. Which simplifies the need to constantly write the checks over and over again. The biggest fixes this patch from to Psi Invisibility, and to an underlying secondary problem that I discovered as a result of more closely examining the cause of the Invis bugs. So now the client gets networked their casting stats. Both Psi-invis and Anoigo have had their audio fixed (it was a typo in both cases). Anoigo now also checks if the target has insulation. This last point is relevant because certain "High Security" doors have had their components psifoil insulated to protect from people with a rare and obnoxious power from forcing their way in. <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/ba53df07-5ed9-4b08-b787-a6f6b347c8a3 </p> </details> # Changelog 🆑 - add: NT has had its station's "High Security" doors such as Command, Security, and Vault doors shielded with psifoil around their components. They can no longer be forced open by the Anoigo power. - tweak: Anoigo, Dispel, Mindswap, Healing Word, Breath Of Life, Pyrokinesis, and Noospheric Zap now all don't work if the target has psionic insulation. - fix: Psionic Invisibility now actually works as advertised. - fix: Psionic Invisibility and Anoigo now actually produce a sound, as well as properly enforce their cooldowns. - tweak: Anoigo reclassified as a "Dangerous" power, it now also costs 10 points for Elementalists. - remove: Prisoners can no longer be Psionic. - fix: Mantis can no longer summon his black blade if his hands are full. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit a4b8cf17f0a6cb62a499cb004fd2f5512c31ef18)
124 lines
5.2 KiB
C#
124 lines
5.2 KiB
C#
using Content.Shared.Actions;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Stunnable;
|
|
using Content.Shared.Stealth;
|
|
using Content.Shared.Stealth.Components;
|
|
using Content.Shared.Psionics;
|
|
using Content.Shared.Actions.Events;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Network;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
using Content.Shared.Throwing;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.Abilities.Psionics;
|
|
|
|
public sealed class PsionicInvisibilityPowerSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
|
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
|
[Dependency] private readonly SharedPsionicAbilitiesSystem _psionics = default!;
|
|
[Dependency] private readonly SharedStealthSystem _stealth = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly INetManager _net = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<PsionicComponent, PsionicInvisibilityPowerActionEvent>(OnPowerUsed);
|
|
SubscribeLocalEvent<RemovePsionicInvisibilityOffPowerActionEvent>(OnPowerOff);
|
|
SubscribeLocalEvent<PsionicInvisibilityUsedComponent, ComponentInit>(OnStart);
|
|
SubscribeLocalEvent<PsionicInvisibilityUsedComponent, ComponentShutdown>(OnEnd);
|
|
SubscribeLocalEvent<PsionicInvisibilityUsedComponent, DamageChangedEvent>(OnDamageChanged);
|
|
SubscribeLocalEvent<PsionicInvisibilityUsedComponent, AttackAttemptEvent>(OnAttackAttempt);
|
|
SubscribeLocalEvent<PsionicInvisibilityUsedComponent, ShotAttemptedEvent>(OnShootAttempt);
|
|
SubscribeLocalEvent<PsionicInvisibilityUsedComponent, ThrowAttemptEvent>(OnThrowAttempt);
|
|
}
|
|
|
|
// This entire system is disgusting and doesn't comply with newer psi power standards.
|
|
// But all I'm here for is to fix a bug, so bite me - TCJ.
|
|
private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicInvisibilityPowerActionEvent args)
|
|
{
|
|
if (!_psionics.OnAttemptPowerUse(args.Performer, "psionic invisibility", true)
|
|
|| HasComp<PsionicInvisibilityUsedComponent>(uid))
|
|
return;
|
|
|
|
ToggleInvisibility(args.Performer);
|
|
_actions.TryGetActionData(args.Action, out var actionData);
|
|
if (actionData is { UseDelay: not null })
|
|
_actions.SetCooldown(args.Action, actionData.UseDelay.Value / component.CurrentDampening);
|
|
|
|
Timer.Spawn(TimeSpan.FromSeconds(args.PowerTimer * component.CurrentAmplification), () => RemComp<PsionicInvisibilityUsedComponent>(uid));
|
|
_psionics.LogPowerUsed(uid, "psionic invisibility",
|
|
args.MinGlimmer * component.CurrentAmplification / component.CurrentDampening,
|
|
args.MaxGlimmer * component.CurrentAmplification / component.CurrentDampening);
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void OnPowerOff(RemovePsionicInvisibilityOffPowerActionEvent args)
|
|
{
|
|
if (!HasComp<PsionicInvisibilityUsedComponent>(args.Performer))
|
|
return;
|
|
|
|
ToggleInvisibility(args.Performer);
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void OnStart(EntityUid uid, PsionicInvisibilityUsedComponent component, ComponentInit args)
|
|
{
|
|
EnsureComp<PsionicallyInvisibleComponent>(uid);
|
|
var stealth = EnsureComp<StealthComponent>(uid);
|
|
_stealth.SetVisibility(uid, 0.66f, stealth);
|
|
|
|
if (_net.IsServer)
|
|
_audio.PlayPvs(component.StartSound, uid);
|
|
|
|
}
|
|
|
|
private void OnEnd(EntityUid uid, PsionicInvisibilityUsedComponent component, ComponentShutdown args)
|
|
{
|
|
if (Terminating(uid))
|
|
return;
|
|
|
|
RemComp<PsionicallyInvisibleComponent>(uid);
|
|
RemComp<StealthComponent>(uid);
|
|
|
|
if (_net.IsServer)
|
|
_audio.PlayPvs(component.EndSound, uid);
|
|
|
|
DirtyEntity(uid);
|
|
}
|
|
|
|
private void OnAttackAttempt(EntityUid uid, PsionicInvisibilityUsedComponent component, AttackAttemptEvent args) =>
|
|
RemComp<PsionicInvisibilityUsedComponent>(uid);
|
|
|
|
private void OnShootAttempt(EntityUid uid, PsionicInvisibilityUsedComponent component, ShotAttemptedEvent args) =>
|
|
RemComp<PsionicInvisibilityUsedComponent>(uid);
|
|
|
|
private void OnThrowAttempt(EntityUid uid, PsionicInvisibilityUsedComponent component, ThrowAttemptEvent args) =>
|
|
RemComp<PsionicInvisibilityUsedComponent>(uid);
|
|
|
|
private void OnDamageChanged(EntityUid uid, PsionicInvisibilityUsedComponent component, DamageChangedEvent args)
|
|
{
|
|
if (!TryComp<PsionicComponent>(uid, out var psionic)
|
|
|| !args.DamageIncreased || args.DamageDelta is not null && args.DamageDelta.GetTotal() < component.DamageToStun)
|
|
return;
|
|
|
|
ToggleInvisibility(uid);
|
|
_stunSystem.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime * psionic.CurrentAmplification / psionic.CurrentDampening), false);
|
|
}
|
|
|
|
public void ToggleInvisibility(EntityUid uid)
|
|
{
|
|
if (!HasComp<PsionicInvisibilityUsedComponent>(uid))
|
|
{
|
|
EnsureComp<PsionicInvisibilityUsedComponent>(uid);
|
|
}
|
|
else
|
|
{
|
|
RemComp<PsionicInvisibilityUsedComponent>(uid);
|
|
}
|
|
}
|
|
}
|