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???

(cherry picked from commit 5a2c744998)
This commit is contained in:
Callmore
2024-03-24 00:29:42 +01:00
committed by NullWanderer
parent f1b0fb62e2
commit a31fc4df45
3 changed files with 47 additions and 31 deletions
@@ -142,33 +142,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; }
}
}
+3 -14
View File
@@ -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!;
@@ -116,7 +114,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)
@@ -125,17 +123,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;
}