Skip to content

Commit

Permalink
fix psi (#1069)
Browse files Browse the repository at this point in the history
* fix psi

* Update events.yml
  • Loading branch information
Rxup authored Feb 22, 2025
1 parent b234264 commit dadc19e
Show file tree
Hide file tree
Showing 16 changed files with 245 additions and 74 deletions.
8 changes: 8 additions & 0 deletions Content.Client/Backmen/Chapel/SacrificialAltarSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Backmen.Chapel;

namespace Content.Client.Backmen.Chapel;

public sealed class SacrificialAltarSystem : SharedSacrificialAltarSystem
{

}
50 changes: 5 additions & 45 deletions Content.Server/Backmen/Chapel/SacrificialAltarSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
using Content.Server.Body.Systems;
using Content.Shared.Backmen.Abilities.Psionics;
using Content.Shared.Backmen.Chapel;
using Content.Shared.Backmen.Chapel.Components;
using Content.Shared.Backmen.Psionics.Glimmer;
using Content.Shared.Backmen.Soul;
using Content.Shared.Hands.Components;
using Content.Shared.Players;
using Robust.Server.Audio;
using Robust.Shared.Prototypes;
Expand All @@ -28,7 +30,7 @@

namespace Content.Server.Backmen.Chapel;

public sealed class SacrificialAltarSystem : EntitySystem
public sealed class SacrificialAltarSystem : SharedSacrificialAltarSystem
{
[Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
Expand All @@ -46,51 +48,9 @@ public sealed class SacrificialAltarSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SacrificialAltarComponent, GetVerbsEvent<AlternativeVerb>>(AddSacrificeVerb);
SubscribeLocalEvent<SacrificialAltarComponent, StrapAttemptEvent>(OnStrappedEvent);
SubscribeLocalEvent<SacrificialAltarComponent, UnstrapAttemptEvent>(OnUnstrappedEvent);
SubscribeLocalEvent<SacrificialAltarComponent, SacrificeDoAfterEvent>(OnDoAfter);

}

private void AddSacrificeVerb(EntityUid uid, SacrificialAltarComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract || component.DoAfter != null)
return;

if (!TryComp<StrapComponent>(uid, out var strap))
return;

EntityUid? sacrificee = null;

foreach (var entity in strap.BuckledEntities) // mm yes I love hashsets which can't be accessed via index
{
sacrificee = entity;
}

if (sacrificee == null)
return;

AlternativeVerb verb = new()
{
Act = () =>
{
AttemptSacrifice(args.User, sacrificee.Value, uid, component);
},
Text = Loc.GetString("altar-sacrifice-verb"),
Priority = 2
};
args.Verbs.Add(verb);
}

private void OnUnstrappedEvent(EntityUid uid, SacrificialAltarComponent component, ref UnstrapAttemptEvent args)
{
args.Cancelled = true;
}
SubscribeLocalEvent<SacrificialAltarComponent, SacrificeDoAfterEvent>(OnDoAfter);

private void OnStrappedEvent(EntityUid uid, SacrificialAltarComponent component, ref StrapAttemptEvent args)
{
args.Cancelled = true;
}

private void OnDoAfter(EntityUid uid, SacrificialAltarComponent component, SacrificeDoAfterEvent args)
Expand Down Expand Up @@ -151,7 +111,7 @@ private void OnDoAfter(EntityUid uid, SacrificialAltarComponent component, Sacri
}
}

public void AttemptSacrifice(EntityUid agent, EntityUid patient, EntityUid altar, SacrificialAltarComponent? component = null)
protected override void AttemptSacrifice(EntityUid agent, EntityUid patient, EntityUid altar, SacrificialAltarComponent? component = null)
{
if (!Resolve(altar, ref component))
return;
Expand Down
40 changes: 20 additions & 20 deletions Content.Server/Backmen/Psionics/Glimmer/GlimmerReactiveSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public override void Initialize()

SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);

SubscribeLocalEvent<SharedGlimmerReactiveComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, GlimmerTierChangedEvent>(OnTierChanged);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, GetVerbsEvent<AlternativeVerb>>(AddShockVerb);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, DestructionEventArgs>(OnDestroyed);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
SubscribeLocalEvent<GlimmerReactiveComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<GlimmerReactiveComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<GlimmerReactiveComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<GlimmerReactiveComponent, GlimmerTierChangedEvent>(OnTierChanged);
SubscribeLocalEvent<GlimmerReactiveComponent, GetVerbsEvent<AlternativeVerb>>(AddShockVerb);
SubscribeLocalEvent<GlimmerReactiveComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<GlimmerReactiveComponent, DestructionEventArgs>(OnDestroyed);
SubscribeLocalEvent<GlimmerReactiveComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
}

/// <summary>
Expand All @@ -82,7 +82,7 @@ public override void Initialize()
/// difference since last update. This can be zero for the sake of
/// toggling the enabled states.</param>
private void UpdateEntityState(EntityUid uid,
SharedGlimmerReactiveComponent component,
GlimmerReactiveComponent component,
GlimmerTier currentGlimmerTier,
int glimmerTierDelta)
{
Expand Down Expand Up @@ -132,7 +132,7 @@ private void UpdateEntityState(EntityUid uid,
/// current status of the glimmer tier, if it wasn't around when an
/// update went out.
/// </summary>
private void OnMapInit(EntityUid uid, SharedGlimmerReactiveComponent component, MapInitEvent args)
private void OnMapInit(EntityUid uid, GlimmerReactiveComponent component, MapInitEvent args)
{
if (component.RequiresApcPower && !HasComp<ApcPowerReceiverComponent>(uid))
{
Expand All @@ -150,7 +150,7 @@ private void OnMapInit(EntityUid uid, SharedGlimmerReactiveComponent component,
/// just in case some objects can temporarily become reactive to the
/// glimmer.
/// </summary>
private void OnComponentRemove(EntityUid uid, SharedGlimmerReactiveComponent component, ComponentRemove args)
private void OnComponentRemove(EntityUid uid, GlimmerReactiveComponent component, ComponentRemove args)
{
UpdateEntityState(uid, component, GlimmerTier.Minimal, -1 * (int) LastGlimmerTier);
}
Expand All @@ -159,7 +159,7 @@ private void OnComponentRemove(EntityUid uid, SharedGlimmerReactiveComponent com
/// If the Entity has RequiresApcPower set to true, this will force an
/// update to the entity's state.
/// </summary>
private void OnPowerChanged(EntityUid uid, SharedGlimmerReactiveComponent component, ref PowerChangedEvent args)
private void OnPowerChanged(EntityUid uid, GlimmerReactiveComponent component, ref PowerChangedEvent args)
{
if (component.RequiresApcPower)
UpdateEntityState(uid, component, LastGlimmerTier, 0);
Expand All @@ -169,7 +169,7 @@ private void OnPowerChanged(EntityUid uid, SharedGlimmerReactiveComponent compon
/// Enable / disable special effects from higher tiers.
/// </summary>
private void OnTierChanged(EntityUid uid,
SharedGlimmerReactiveComponent component,
GlimmerReactiveComponent component,
GlimmerTierChangedEvent args)
{
if (!TryComp<ApcPowerReceiverComponent>(uid, out var receiver))
Expand All @@ -190,7 +190,7 @@ private void OnTierChanged(EntityUid uid,
}

private void AddShockVerb(EntityUid uid,
SharedGlimmerReactiveComponent component,
GlimmerReactiveComponent component,
GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract)
Expand Down Expand Up @@ -218,7 +218,7 @@ private void AddShockVerb(EntityUid uid,
args.Verbs.Add(verb);
}

private void OnDamageChanged(EntityUid uid, SharedGlimmerReactiveComponent component, DamageChangedEvent args)
private void OnDamageChanged(EntityUid uid, GlimmerReactiveComponent component, DamageChangedEvent args)
{
if (args.Origin == null)
return;
Expand All @@ -233,7 +233,7 @@ private void OnDamageChanged(EntityUid uid, SharedGlimmerReactiveComponent compo
}

[ValidatePrototypeId<EntityPrototype>] private const string MaterialBluespace = "MaterialBluespace1";
private void OnDestroyed(EntityUid uid, SharedGlimmerReactiveComponent component, DestructionEventArgs args)
private void OnDestroyed(EntityUid uid, GlimmerReactiveComponent component, DestructionEventArgs args)
{
Spawn(MaterialBluespace, Transform(uid).Coordinates);

Expand All @@ -251,7 +251,7 @@ private void OnDestroyed(EntityUid uid, SharedGlimmerReactiveComponent component
_explosionSystem.QueueExplosion(uid, "Default", totalIntensity, slope, maxIntensity);
}

private void OnUnanchorAttempt(EntityUid uid, SharedGlimmerReactiveComponent component,
private void OnUnanchorAttempt(EntityUid uid, GlimmerReactiveComponent component,
UnanchorAttemptEvent args)
{
if (_glimmerSystem.GetGlimmerTier() >= GlimmerTier.Dangerous)
Expand All @@ -273,7 +273,7 @@ public void BeamRandomNearProber(EntityUid prober, int targets, float range = 10
var pos = Transform(prober).Coordinates.ToMap(EntityManager,_transformSystem);
_entitySet.Clear();
_entityLookupSystem.GetEntitiesInRange(typeof(StatusEffectsComponent),pos.MapId,pos.Position, range, _entitySet);
_entityLookupSystem.GetEntitiesInRange(typeof(SharedGlimmerReactiveComponent),pos.MapId,pos.Position, range, _entitySet);
_entityLookupSystem.GetEntitiesInRange(typeof(GlimmerReactiveComponent),pos.MapId,pos.Position, range, _entitySet);
_entities.Clear();

foreach (var target in _entitySet)
Expand Down Expand Up @@ -389,7 +389,7 @@ public override void Update(float frameTime)
var glimmerTierDelta = (int) currentGlimmerTier - (int) LastGlimmerTier;
var ev = new GlimmerTierChangedEvent(LastGlimmerTier, currentGlimmerTier, glimmerTierDelta);

var reactiv = EntityQueryEnumerator<SharedGlimmerReactiveComponent>();
var reactiv = EntityQueryEnumerator<GlimmerReactiveComponent>();
while (reactiv.MoveNext(out var owner, out var reactive))
{
UpdateEntityState(owner, reactive, currentGlimmerTier, glimmerTierDelta);
Expand Down Expand Up @@ -429,7 +429,7 @@ public override void Update(float frameTime)
}
}

var reactives = EntityQueryEnumerator<SharedGlimmerReactiveComponent,TransformComponent>();
var reactives = EntityQueryEnumerator<GlimmerReactiveComponent,TransformComponent>();
while (reactives.MoveNext(out var owner, out _, out var transformComponent))
{
if (currentGlimmerTier == GlimmerTier.Critical)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ public sealed partial class GlimmerSourceComponent : Component
/// </summary>
[DataField("addToGlimmer")]
public bool AddToGlimmer = true;

[DataField("range")]
public float Range = 4f;

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
using Content.Server.Anomaly.Components;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Stunnable;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Shared.Anomaly.Components;
using Content.Shared.Backmen.Abilities.Psionics;
using Content.Shared.Backmen.Psionics.Components;
using Content.Shared.Backmen.Psionics.Glimmer;
using Content.Shared.Mobs.Systems;
using Content.Shared.Power;
using Content.Shared.StatusEffect;
using Robust.Shared.Random;

namespace Content.Server.Backmen.Psionics.Glimmer;

Expand All @@ -14,6 +22,14 @@ public sealed class GlimmerStructuresSystem : EntitySystem
{
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly PsionicsSystem _psionicsSystem = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;

private EntityQuery<ApcPowerReceiverComponent> _apcPower;

public override void Initialize()
Expand All @@ -24,10 +40,64 @@ public override void Initialize()

SubscribeLocalEvent<GlimmerSourceComponent, AnomalyPulseEvent>(OnAnomalyPulse);
SubscribeLocalEvent<GlimmerSourceComponent, AnomalySupercriticalEvent>(OnAnomalySupercritical);
SubscribeLocalEvent<GlimmerSourceComponent, ArtifactActivatedEvent>(OnArtifactActivated);

_apcPower = GetEntityQuery<ApcPowerReceiverComponent>();
}

private void OnArtifactActivated(Entity<GlimmerSourceComponent> ent, ref ArtifactActivatedEvent args)
{
if (ent.Comp.AddToGlimmer)
{
_glimmerSystem.Glimmer += 10;
}
else
{
_glimmerSystem.Glimmer -= 10;
}

if (args.Activator != null &&
!HasComp<PsionicInsulationComponent>(args.Activator) &&
TryComp<PotentialPsionicComponent>(args.Activator, out var potentialPsionicComponent))
{
ZapTarget((args.Activator.Value, potentialPsionicComponent));
return;
}

foreach (var target in _lookup.GetEntitiesInRange<PotentialPsionicComponent>(Transform(ent).Coordinates, ent.Comp.Range))
{
ZapTarget(target);
}
}

private void ZapTarget(Entity<PotentialPsionicComponent> target)
{
if(HasComp<PsionicInsulationComponent>(target))
return;

_stunSystem.TryParalyze(target, TimeSpan.FromSeconds(5), false);
_statusEffectsSystem.TryAddStatusEffect(target, "Stutter", TimeSpan.FromSeconds(10), false, "StutteringAccent");

if (HasComp<PsionicComponent>(target))
{
_popupSystem.PopupEntity(Loc.GetString("noospheric-zap-seize"), target, target, Shared.Popups.PopupType.LargeCaution);
_glimmerSystem.Glimmer += 50;
}
else
{
if (target.Comp.Rerolled)
{
target.Comp.Rerolled = false;
_popupSystem.PopupEntity(Loc.GetString("noospheric-zap-seize-potential-regained"), target, target, Shared.Popups.PopupType.LargeCaution);
}
else
{
_psionicsSystem.RollPsionics(target, multiplier: 0.25f);
_popupSystem.PopupEntity(Loc.GetString("noospheric-zap-seize"), target, target, Shared.Popups.PopupType.LargeCaution);
}
}
}

private void OnAnomalyVesselPowerChanged(EntityUid uid, AnomalyVesselComponent component, ref PowerChangedEvent args)
{
if (TryComp<GlimmerSourceComponent>(component.Anomaly, out var glimmerSource))
Expand All @@ -54,7 +124,7 @@ private void OnAnomalyPulse(EntityUid uid, GlimmerSourceComponent component, ref

private void OnAnomalySupercritical(EntityUid uid, GlimmerSourceComponent component, ref AnomalySupercriticalEvent args)
{
_glimmerSystem.Glimmer += 100;
_glimmerSystem.Glimmer += 400;
}

public override void Update(float frameTime)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Backmen/Soul/GolemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void OnGetLaws(EntityUid uid, GolemComponent component, ref GetSiliconLa
// Add the first emag law
args.Laws.Laws.Add(new SiliconLaw
{
LawString = Loc.GetString("law-golem-1", ("name", component.Master ?? "----")),
LawString = Loc.GetString("golem-law", ("master", component.Master ?? "----")),
Order = 1
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected override void Started(EntityUid uid, NoosphericFryRuleComponent compon
}

// for probers:
var queryReactive = EntityQueryEnumerator<SharedGlimmerReactiveComponent, TransformComponent, PhysicsComponent>();
var queryReactive = EntityQueryEnumerator<GlimmerReactiveComponent, TransformComponent, PhysicsComponent>();
while (queryReactive.MoveNext(out var reactive, out _, out var xform, out var physics))
{
// shoot out three bolts of lighting...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Content.Shared.DoAfter;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Components;
using Robust.Shared.GameStates;

namespace Content.Server.Backmen.Chapel;
namespace Content.Shared.Backmen.Chapel.Components;

[RegisterComponent]
[RegisterComponent, NetworkedComponent]
public sealed partial class SacrificialAltarComponent : Component
{
[DataField("doAfter")]
Expand Down
Loading

0 comments on commit dadc19e

Please sign in to comment.