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

Prevent probers from being unachored by gorilla gauntlets #824

Merged
merged 2 commits into from
Feb 13, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,6 +65,7 @@ public override void Initialize()
SubscribeLocalEvent<SharedGlimmerReactiveComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, DestructionEventArgs>(OnDestroyed);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
SubscribeLocalEvent<SharedGlimmerReactiveComponent, AttemptMeleeThrowOnHitEvent>(OnMeleeThrowOnHitAttempt);
}

/// <summary>
Expand Down Expand Up @@ -314,6 +318,25 @@ private void AnchorOrExplode(EntityUid uid)
_destructibleSystem.DestroyEntity(uid);
}

private void OnMeleeThrowOnHitAttempt(Entity<SharedGlimmerReactiveComponent> 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<MindContainerComponent>(zapTarget, out _))
_electrocutionSystem.TryDoElectrocution(zapTarget, uid, 5, TimeSpan.FromSeconds(3), true,
ignoreInsulation: true);
}

private void Reset(RoundRestartCleanupEvent args)
{
Accumulator = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ public sealed partial class MeleeThrownComponent : Component
/// <summary>
/// Event raised before an entity is thrown by <see cref="MeleeThrowOnHitComponent"/> 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
/// </summary>
[ByRefEvent]
public record struct AttemptMeleeThrowOnHitEvent(EntityUid Hit, bool Cancelled = false, bool Handled = false);
public record struct AttemptMeleeThrowOnHitEvent(EntityUid Hit, Entity<MeleeThrowOnHitComponent> User, bool Cancelled = false, bool Handled = false);

[ByRefEvent]
public record struct MeleeThrowOnHitStartEvent(EntityUid User, EntityUid Used);
Expand Down
9 changes: 7 additions & 2 deletions Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ public bool CanThrowOnHit(Entity<MeleeThrowOnHitComponent> 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;

Expand Down
Loading