Skip to content

Commit

Permalink
Prevent probers from being unachored by gorilla gauntlets (#824)
Browse files Browse the repository at this point in the history
* Fix being able to punt probers to unachor them

* Fix my wacky comment
  • Loading branch information
DebugOk authored Feb 13, 2024
1 parent ac1af5b commit 7c62f5e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
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

0 comments on commit 7c62f5e

Please sign in to comment.