Tiny shove fix. (#25353)
* Remove second shove check. * Change when popups and sounds are created. Reduces phantom shoves that feel bad. * why didn't i think of this i saw it earlier... * Replaced Is fields with prefix * remove some dependencies to fix tests???
This commit is contained in:
@@ -6,15 +6,20 @@ using Content.Server.Stunnable;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Explosion;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
using Content.Shared.Physics.Pull;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Stacks;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Map;
|
||||
@@ -38,7 +43,7 @@ namespace Content.Server.Hands.Systems
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] {typeof(StunSystem)});
|
||||
SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] {typeof(StunSystem), typeof(StaminaSystem)});
|
||||
|
||||
SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
|
||||
SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
|
||||
@@ -95,6 +100,8 @@ namespace Content.Server.Hands.Systems
|
||||
if (!_handsSystem.TryDrop(uid, component.ActiveHand!, null, checkActionBlocker: false))
|
||||
return;
|
||||
|
||||
args.PopupPrefix = "disarm-action-";
|
||||
|
||||
args.Handled = true; // no shove/stun.
|
||||
}
|
||||
|
||||
|
||||
@@ -144,33 +144,49 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
|
||||
if (_random.Prob(chance))
|
||||
{
|
||||
// Yknow something tells me this comment is hilariously out of date...
|
||||
// Don't play a sound as the swing is already predicted.
|
||||
// Also don't play popups because most disarms will miss.
|
||||
return false;
|
||||
}
|
||||
|
||||
var filterOther = Filter.PvsExcept(user, entityManager: EntityManager);
|
||||
var msgPrefix = "disarm-action-";
|
||||
|
||||
if (inTargetHand == null)
|
||||
msgPrefix = "disarm-action-shove-";
|
||||
|
||||
var msgOther = Loc.GetString(
|
||||
msgPrefix + "popup-message-other-clients",
|
||||
("performerName", Identity.Entity(user, EntityManager)),
|
||||
("targetName", Identity.Entity(target, EntityManager)));
|
||||
|
||||
var msgUser = Loc.GetString(msgPrefix + "popup-message-cursor", ("targetName", Identity.Entity(target, EntityManager)));
|
||||
|
||||
PopupSystem.PopupEntity(msgOther, user, filterOther, true);
|
||||
PopupSystem.PopupEntity(msgUser, target, user);
|
||||
|
||||
Audio.PlayPvs(combatMode.DisarmSuccessSound, user, AudioParams.Default.WithVariation(0.025f).WithVolume(5f));
|
||||
AdminLogger.Add(LogType.DisarmedAction, $"{ToPrettyString(user):user} used disarm on {ToPrettyString(target):target}");
|
||||
|
||||
var eventArgs = new DisarmedEvent { Target = target, Source = user, PushProbability = 1 - chance };
|
||||
RaiseLocalEvent(target, eventArgs);
|
||||
|
||||
if (!eventArgs.Handled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Audio.PlayPvs(combatMode.DisarmSuccessSound, user, AudioParams.Default.WithVariation(0.025f).WithVolume(5f));
|
||||
|
||||
var targetEnt = Identity.Entity(target, EntityManager);
|
||||
var userEnt = Identity.Entity(user, EntityManager);
|
||||
|
||||
var msgOther = Loc.GetString(
|
||||
eventArgs.PopupPrefix + "popup-message-other-clients",
|
||||
("performerName", userEnt),
|
||||
("targetName", targetEnt));
|
||||
|
||||
var msgUser = Loc.GetString(eventArgs.PopupPrefix + "popup-message-cursor", ("targetName", targetEnt));
|
||||
|
||||
var filterOther = Filter.PvsExcept(user, entityManager: EntityManager);
|
||||
|
||||
PopupSystem.PopupEntity(msgOther, user, filterOther, true);
|
||||
PopupSystem.PopupEntity(msgUser, target, user);
|
||||
|
||||
|
||||
if (eventArgs.IsStunned)
|
||||
{
|
||||
|
||||
PopupSystem.PopupEntity(Loc.GetString("stunned-component-disarm-success-others", ("source", userEnt), ("target", targetEnt)), targetEnt, Filter.PvsExcept(user), true, PopupType.LargeCaution);
|
||||
PopupSystem.PopupCursor(Loc.GetString("stunned-component-disarm-success", ("target", targetEnt)), user, PopupType.Large);
|
||||
|
||||
AdminLogger.Add(LogType.DisarmedKnockdown, LogImpact.Medium, $"{ToPrettyString(user):user} knocked down {ToPrettyString(target):target}");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,5 +16,16 @@ namespace Content.Shared.CombatMode
|
||||
/// Probability for push/knockdown.
|
||||
/// </summary>
|
||||
public float PushProbability { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Prefix for the popup message that will be displayed on a successful push.
|
||||
/// Should be set before returning.
|
||||
/// </summary>
|
||||
public string PopupPrefix { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Whether the entity was successfully stunned from a shove.
|
||||
/// </summary>
|
||||
public bool IsStunned { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,10 @@ public sealed partial class StaminaSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly INetManager _net = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metadata = default!;
|
||||
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
|
||||
@@ -122,7 +120,7 @@ public sealed partial class StaminaSystem : EntitySystem
|
||||
|
||||
private void OnDisarmed(EntityUid uid, StaminaComponent component, DisarmedEvent args)
|
||||
{
|
||||
if (args.Handled || !_random.Prob(args.PushProbability))
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (component.Critical)
|
||||
@@ -131,17 +129,8 @@ public sealed partial class StaminaSystem : EntitySystem
|
||||
var damage = args.PushProbability * component.CritThreshold;
|
||||
TakeStaminaDamage(uid, damage, component, source: args.Source);
|
||||
|
||||
// We need a better method of getting if the entity is going to resist stam damage, both this and the lines in the foreach at the end of OnHit() are awful
|
||||
if (!component.Critical)
|
||||
return;
|
||||
|
||||
var targetEnt = Identity.Entity(args.Target, EntityManager);
|
||||
var sourceEnt = Identity.Entity(args.Source, EntityManager);
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("stunned-component-disarm-success-others", ("source", sourceEnt), ("target", targetEnt)), targetEnt, Filter.PvsExcept(args.Source), true, PopupType.LargeCaution);
|
||||
_popup.PopupCursor(Loc.GetString("stunned-component-disarm-success", ("target", targetEnt)), args.Source, PopupType.Large);
|
||||
|
||||
_adminLogger.Add(LogType.DisarmedKnockdown, LogImpact.Medium, $"{ToPrettyString(args.Source):user} knocked down {ToPrettyString(args.Target):target}");
|
||||
args.PopupPrefix = "disarm-action-shove-";
|
||||
args.IsStunned = component.Critical;
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user