diff --git a/Content.Server/Nyanotrasen/Psionics/Glimmer/GlimmerReactiveSystem.cs b/Content.Server/Nyanotrasen/Psionics/Glimmer/GlimmerReactiveSystem.cs index ddd5ac11585..da3b07d6dab 100644 --- a/Content.Server/Nyanotrasen/Psionics/Glimmer/GlimmerReactiveSystem.cs +++ b/Content.Server/Nyanotrasen/Psionics/Glimmer/GlimmerReactiveSystem.cs @@ -16,6 +16,9 @@ using Content.Shared.Damage; using Content.Shared.Destructible; using Content.Shared.Construction.Components; +using Content.Shared.Mind; +using Content.Shared.Mind.Components; +using Content.Shared.Weapons.Melee.Components; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Map; @@ -62,6 +65,7 @@ public override void Initialize() SubscribeLocalEvent(OnDamageChanged); SubscribeLocalEvent(OnDestroyed); SubscribeLocalEvent(OnUnanchorAttempt); + SubscribeLocalEvent(OnMeleeThrowOnHitAttempt); } /// @@ -314,6 +318,25 @@ private void AnchorOrExplode(EntityUid uid) _destructibleSystem.DestroyEntity(uid); } + private void OnMeleeThrowOnHitAttempt(Entity ent, ref AttemptMeleeThrowOnHitEvent args) + { + var (uid, _) = ent; + + if (_glimmerSystem.GetGlimmerTier() < GlimmerTier.Dangerous) + return; + + args.Cancelled = true; + args.Handled = true; + + _lightning.ShootRandomLightnings(uid, 10, 2, "SuperchargedLightning", 2, false); + + // Check if the parent of the user is alive, which will be the case if the user is an item and is being held. + var zapTarget = _transformSystem.GetParentUid(args.User); + if (TryComp(zapTarget, out _)) + _electrocutionSystem.TryDoElectrocution(zapTarget, uid, 5, TimeSpan.FromSeconds(3), true, + ignoreInsulation: true); + } + private void Reset(RoundRestartCleanupEvent args) { Accumulator = 0; diff --git a/Content.Shared/Weapons/Melee/Components/MeleeThrowOnHitComponent.cs b/Content.Shared/Weapons/Melee/Components/MeleeThrowOnHitComponent.cs index 82ffc5e51fc..559d58298ba 100644 --- a/Content.Shared/Weapons/Melee/Components/MeleeThrowOnHitComponent.cs +++ b/Content.Shared/Weapons/Melee/Components/MeleeThrowOnHitComponent.cs @@ -101,9 +101,10 @@ public sealed partial class MeleeThrownComponent : Component /// /// Event raised before an entity is thrown by to see if a throw is allowed. /// If not handled, the enabled field on the component will be used instead. +/// Delta-V modification: Added User field, since it is now also raised on the entity being hit /// [ByRefEvent] -public record struct AttemptMeleeThrowOnHitEvent(EntityUid Hit, bool Cancelled = false, bool Handled = false); +public record struct AttemptMeleeThrowOnHitEvent(EntityUid Hit, Entity User, bool Cancelled = false, bool Handled = false); [ByRefEvent] public record struct MeleeThrowOnHitStartEvent(EntityUid User, EntityUid Used); diff --git a/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs b/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs index fc364286549..e840bd1ddd5 100644 --- a/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs +++ b/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs @@ -104,9 +104,14 @@ public bool CanThrowOnHit(Entity ent, EntityUid target { var (uid, comp) = ent; - var ev = new AttemptMeleeThrowOnHitEvent(target); - RaiseLocalEvent(uid, ref ev); + var ev = new AttemptMeleeThrowOnHitEvent(target, ent); + // Delta-V modification: Also raise on the entity being hit, in case it wants to object + RaiseLocalEvent(target, ref ev); + if (ev.Handled) + return !ev.Cancelled; + + RaiseLocalEvent(uid, ref ev); if (ev.Handled) return !ev.Cancelled;