You can no longer disarm wielded weapons (#7983)
Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -6,10 +6,13 @@ namespace Content.Server.Actions.Events
|
|||||||
{
|
{
|
||||||
public readonly EntityUid TargetUid;
|
public readonly EntityUid TargetUid;
|
||||||
public readonly EntityUid DisarmerUid;
|
public readonly EntityUid DisarmerUid;
|
||||||
public DisarmAttemptEvent(EntityUid targetUid, EntityUid disarmerUid)
|
public readonly EntityUid? TargetItemInHandUid;
|
||||||
|
|
||||||
|
public DisarmAttemptEvent(EntityUid targetUid, EntityUid disarmerUid, EntityUid? targetItemInHandUid = null)
|
||||||
{
|
{
|
||||||
TargetUid = targetUid;
|
TargetUid = targetUid;
|
||||||
DisarmerUid = disarmerUid;
|
DisarmerUid = disarmerUid;
|
||||||
|
TargetItemInHandUid = targetItemInHandUid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
using Content.Server.Act;
|
using Content.Server.Act;
|
||||||
using Content.Server.Actions.Events;
|
using Content.Server.Actions.Events;
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
|
using Content.Server.Hands.Components;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Weapon.Melee;
|
using Content.Server.Weapon.Melee;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
@@ -9,6 +11,10 @@ using Content.Shared.CombatMode;
|
|||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
@@ -38,7 +44,21 @@ namespace Content.Server.CombatMode
|
|||||||
if (!_actionBlockerSystem.CanAttack(args.Performer))
|
if (!_actionBlockerSystem.CanAttack(args.Performer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var attemptEvent = new DisarmAttemptEvent(args.Target, args.Performer);
|
EntityUid? inTargetHand = null;
|
||||||
|
|
||||||
|
if (EntityManager.TryGetComponent<HandsComponent>(args.Target, out HandsComponent targetHandsComponent)
|
||||||
|
&& targetHandsComponent.ActiveHand != null
|
||||||
|
&& !targetHandsComponent.ActiveHand.IsEmpty)
|
||||||
|
{
|
||||||
|
inTargetHand = targetHandsComponent.ActiveHand.HeldEntity!.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var attemptEvent = new DisarmAttemptEvent(args.Target, args.Performer,inTargetHand);
|
||||||
|
|
||||||
|
if (inTargetHand != null)
|
||||||
|
{
|
||||||
|
RaiseLocalEvent(inTargetHand.Value, attemptEvent);
|
||||||
|
}
|
||||||
RaiseLocalEvent(args.Target, attemptEvent);
|
RaiseLocalEvent(args.Target, attemptEvent);
|
||||||
if (attemptEvent.Cancelled)
|
if (attemptEvent.Cancelled)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ using Content.Shared.Popups;
|
|||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using System.Linq;
|
using Content.Server.Actions.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace Content.Server.Wieldable
|
namespace Content.Server.Wieldable
|
||||||
{
|
{
|
||||||
@@ -32,10 +33,17 @@ namespace Content.Server.Wieldable
|
|||||||
SubscribeLocalEvent<WieldableComponent, GotUnequippedHandEvent>(OnItemLeaveHand);
|
SubscribeLocalEvent<WieldableComponent, GotUnequippedHandEvent>(OnItemLeaveHand);
|
||||||
SubscribeLocalEvent<WieldableComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
|
SubscribeLocalEvent<WieldableComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
|
||||||
SubscribeLocalEvent<WieldableComponent, GetVerbsEvent<InteractionVerb>>(AddToggleWieldVerb);
|
SubscribeLocalEvent<WieldableComponent, GetVerbsEvent<InteractionVerb>>(AddToggleWieldVerb);
|
||||||
|
SubscribeLocalEvent<WieldableComponent, DisarmAttemptEvent>(OnDisarmAttemptEvent);
|
||||||
|
|
||||||
SubscribeLocalEvent<IncreaseDamageOnWieldComponent, MeleeHitEvent>(OnMeleeHit);
|
SubscribeLocalEvent<IncreaseDamageOnWieldComponent, MeleeHitEvent>(OnMeleeHit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDisarmAttemptEvent(EntityUid uid, WieldableComponent component, DisarmAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (component.Wielded)
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
private void AddToggleWieldVerb(EntityUid uid, WieldableComponent component, GetVerbsEvent<InteractionVerb> args)
|
private void AddToggleWieldVerb(EntityUid uid, WieldableComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||||
{
|
{
|
||||||
if (args.Hands == null || !args.CanAccess || !args.CanInteract)
|
if (args.Hands == null || !args.CanAccess || !args.CanInteract)
|
||||||
|
|||||||
Reference in New Issue
Block a user