From d907e4ef577e6df595a77c7c87e5f864ee38ad0c Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sat, 15 Jun 2024 00:01:22 -0400 Subject: [PATCH] make pulled uncuffing slower & reduce uncuff spam cooldown (#29008) * prevent people being pulled from uncuffing themselves * block -> modify duration --- .../Cuffs/Components/HandcuffComponent.cs | 6 ++++++ Content.Shared/Cuffs/SharedCuffableSystem.cs | 5 ++++- .../Movement/Pulling/Systems/PullingSystem.cs | 16 ++++++++++++++++ .../Entities/Objects/Misc/handcuffs.yml | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Cuffs/Components/HandcuffComponent.cs b/Content.Shared/Cuffs/Components/HandcuffComponent.cs index 30577da064..289f587239 100644 --- a/Content.Shared/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Shared/Cuffs/Components/HandcuffComponent.cs @@ -105,3 +105,9 @@ public record struct UncuffAttemptEvent(EntityUid User, EntityUid Target) public readonly EntityUid Target = Target; public bool Cancelled = false; } + +/// +/// Event raised on an entity being uncuffed to determine any modifiers to the amount of time it takes to uncuff them. +/// +[ByRefEvent] +public record struct ModifyUncuffDurationEvent(EntityUid User, EntityUid Target, float Duration); diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index 1ced3c8d6c..0e506f938e 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -561,7 +561,10 @@ namespace Content.Shared.Cuffs return; } - var uncuffTime = isOwner ? cuff.BreakoutTime : cuff.UncuffTime; + + var ev = new ModifyUncuffDurationEvent(user, target, isOwner ? cuff.BreakoutTime : cuff.UncuffTime); + RaiseLocalEvent(user, ref ev); + var uncuffTime = ev.Duration; if (isOwner) { diff --git a/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs b/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs index 225810daed..161868370e 100644 --- a/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs +++ b/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Administration.Logs; using Content.Shared.Alert; using Content.Shared.Buckle.Components; +using Content.Shared.Cuffs.Components; using Content.Shared.Database; using Content.Shared.Hands; using Content.Shared.Hands.EntitySystems; @@ -12,6 +13,7 @@ using Content.Shared.Movement.Events; using Content.Shared.Movement.Pulling.Components; using Content.Shared.Movement.Pulling.Events; using Content.Shared.Movement.Systems; +using Content.Shared.Popups; using Content.Shared.Pulling.Events; using Content.Shared.Standing; using Content.Shared.Throwing; @@ -43,6 +45,7 @@ public sealed class PullingSystem : EntitySystem [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly SharedInteractionSystem _interaction = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; public override void Initialize() { @@ -56,6 +59,7 @@ public sealed class PullingSystem : EntitySystem SubscribeLocalEvent(OnJointRemoved); SubscribeLocalEvent>(AddPullVerbs); SubscribeLocalEvent(OnPullableContainerInsert); + SubscribeLocalEvent(OnModifyUncuffDuration); SubscribeLocalEvent(OnPullerContainerInsert); SubscribeLocalEvent(OnPullerUnpaused); @@ -94,6 +98,18 @@ public sealed class PullingSystem : EntitySystem TryStopPull(ent.Owner, ent.Comp); } + private void OnModifyUncuffDuration(Entity ent, ref ModifyUncuffDurationEvent args) + { + if (!ent.Comp.BeingPulled) + return; + + // We don't care if the person is being uncuffed by someone else + if (args.User != args.Target) + return; + + args.Duration *= 2; + } + public override void Shutdown() { base.Shutdown(); diff --git a/Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml b/Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml index f703886127..a502c71404 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml @@ -27,7 +27,7 @@ guides: - Security - type: UseDelay - delay: 30 + delay: 3 - type: entity name: makeshift handcuffs