From b89b8f076af573e6ff270495094bf0e5e312d4e6 Mon Sep 17 00:00:00 2001 From: pheenty Date: Wed, 20 Nov 2024 14:25:06 +0700 Subject: [PATCH] change a bit 4 --- .../Stories/Garrote/GarroteComponent.cs | 26 ++----- .../Stories/Garrote/GarroteSystem.cs | 69 +++++-------------- .../Stories/Garrote/GarroteEvents.cs | 2 +- .../_stories/garrote/garrote-component.ftl | 6 -- 4 files changed, 24 insertions(+), 79 deletions(-) diff --git a/Content.Server/Stories/Garrote/GarroteComponent.cs b/Content.Server/Stories/Garrote/GarroteComponent.cs index df680d04b9..f76f2c1249 100644 --- a/Content.Server/Stories/Garrote/GarroteComponent.cs +++ b/Content.Server/Stories/Garrote/GarroteComponent.cs @@ -3,33 +3,15 @@ namespace Content.Server.Stories.Garrote; [RegisterComponent] public sealed partial class GarroteComponent : Component { - /// - /// For how long a DoAfter lasts - /// [DataField("doAfterTime")] - public TimeSpan DoAfterTime = TimeSpan.FromSeconds(5f); + public TimeSpan DoAfterTime = TimeSpan.FromSeconds(0.5f); + + [DataField("damage")] + public float Damage = 5f; /// /// The mininum angle in degrees from face to back to use /// [DataField("minAngleFromFace")] public float MinAngleFromFace = 90; - - /// - /// Whether the garrote is being used at the moment - /// - [DataField] - public bool Busy = false; - - /// - /// Whether the stun should be removed on DoAfter cancel, so we don't unstun stunned entities - /// - [DataField] - public bool RemoveStun = false; - - /// - /// Whether the mute should be removed on DoAfter cancel, so we don't unmute mimes and alike - /// - [DataField] - public bool RemoveMute = false; } diff --git a/Content.Server/Stories/Garrote/GarroteSystem.cs b/Content.Server/Stories/Garrote/GarroteSystem.cs index e85c772efe..57839fbeef 100644 --- a/Content.Server/Stories/Garrote/GarroteSystem.cs +++ b/Content.Server/Stories/Garrote/GarroteSystem.cs @@ -11,9 +11,9 @@ using Content.Shared.Interaction; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; -using Content.Shared.Mobs.Systems; using Content.Shared.Popups; using Content.Shared.Speech.Muting; +using Content.Shared.StatusEffect; using Content.Shared.Stunnable; using Content.Shared.Wieldable.Components; using Robust.Shared.Player; @@ -28,23 +28,23 @@ public sealed class GarroteSystem : EntitySystem [Dependency] private readonly DamageableSystem _damageable = default!; [Dependency] private readonly ChatSystem _chatSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; - [Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!; [Dependency] private readonly RespiratorSystem _respirator = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly StatusEffectsSystem _statusEffect = default!; + [Dependency] private readonly SharedStunSystem _stun = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnGarroteAttempt); - SubscribeLocalEvent(OnGarroteDone); + SubscribeLocalEvent(OnGarroteDoAfter); } private void OnGarroteAttempt(EntityUid uid, GarroteComponent comp, ref AfterInteractEvent args) { - if (comp.Busy - || args.User == args.Target + if (args.User == args.Target || !args.CanReach || !HasComp(args.Target) || !HasComp(args.Target) @@ -60,14 +60,14 @@ private void OnGarroteAttempt(EntityUid uid, GarroteComponent comp, ref AfterInt if (!(mobstate.CurrentState == MobState.Alive && HasComp(args.Target))) { var message = Loc.GetString("garrote-component-doesnt-breath", ("target", args.Target)); - _popupSystem.PopupEntity(message, uid, args.User); + _popupSystem.PopupEntity(message, args.Target.Value, args.User); return; } if (!IsBehind(args.User, args.Target.Value, comp.MinAngleFromFace) && _actionBlocker.CanInteract(args.Target.Value, null)) { var message = Loc.GetString("garrote-component-must-be-behind", ("target", args.Target)); - _popupSystem.PopupEntity(message, uid, args.User); + _popupSystem.PopupEntity(message, args.Target.Value, args.User); return; } @@ -77,11 +77,12 @@ private void OnGarroteAttempt(EntityUid uid, GarroteComponent comp, ref AfterInt var messageothers = Loc.GetString("garrote-component-started-others", ("user", args.User), ("target", args.Target)); _popupSystem.PopupEntity(messageothers, args.User, Filter.PvsExcept(args.Target.Value), true, PopupType.MediumCaution); - var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, comp.DoAfterTime, new GarroteDoneEvent(), uid, target: args.Target) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, comp.DoAfterTime, new GarroteDoAfterEvent(), uid, target: args.Target) { BreakOnMove = true, BreakOnDamage = true, - NeedHand = true + NeedHand = true, + DuplicateCondition = DuplicateConditions.SameTool }; if (!_doAfter.TryStartDoAfter(doAfterEventArgs)) return; @@ -89,62 +90,30 @@ private void OnGarroteAttempt(EntityUid uid, GarroteComponent comp, ref AfterInt ProtoId emote = "Cough"; _chatSystem.TryEmoteWithChat(args.Target.Value, emote, ChatTransmitRange.HideChat, ignoreActionBlocker: true); - if (!HasComp(args.Target)) - { - comp.RemoveStun = true; - AddComp(args.Target.Value); - } - - if (!HasComp(args.Target)) - { - comp.RemoveMute = true; - AddComp(args.Target.Value); - } - - comp.Busy = true; + _stun.TryStun(args.Target.Value, 2*comp.DoAfterTime, true); // multiplying time by 2 to prevent mispredictons + _statusEffect.TryAddStatusEffect(args.Target.Value, "Muted", 2*comp.DoAfterTime, true); } - private void OnGarroteDone(EntityUid uid, GarroteComponent comp, GarroteDoneEvent args) + private void OnGarroteDoAfter(EntityUid uid, GarroteComponent comp, GarroteDoAfterEvent args) { if (args.Target == null || !TryComp(args.Target, out var damageable) - || !TryComp(args.Target, out var thresholds) || !TryComp(args.Target, out var respirator) || !TryComp(args.Target, out var mobstate)) - { - comp.RemoveStun = false; - comp.RemoveMute = false; - comp.Busy = false; return; - } - - if (comp.RemoveStun) - { - RemComp(args.Target.Value); - comp.RemoveStun = false; - } - - if (comp.RemoveMute) - { - RemComp(args.Target.Value); - comp.RemoveMute = false; - } - - comp.Busy = false; if (args.Cancelled || mobstate.CurrentState != MobState.Alive) return; - var critthreshold = _mobThresholdSystem.GetThresholdForState(args.Target.Value, MobState.Critical, thresholds); - var deadthreshold = _mobThresholdSystem.GetThresholdForState(args.Target.Value, MobState.Dead, thresholds); - var damage = critthreshold + 0.1 * (deadthreshold - critthreshold) - damageable.TotalDamage; - DamageSpecifier damageDealt = new(_prototypeManager.Index("Asphyxiation"), damage); - _damageable.TryChangeDamage(args.Target, damageDealt, false, origin: args.User); + DamageSpecifier damage = new(_prototypeManager.Index("Asphyxiation"), comp.Damage); // TODO: unhardcode asphyxiation? + _damageable.TryChangeDamage(args.Target, damage, false, origin: args.User); var saturationDelta = respirator.MinSaturation - respirator.Saturation; _respirator.UpdateSaturation(args.Target.Value, saturationDelta, respirator); - var message = Loc.GetString("garrote-component-complete", ("user", args.User), ("target", args.Target)); - _popupSystem.PopupEntity(message, args.User, PopupType.LargeCaution); + _stun.TryStun(args.Target.Value, 2*comp.DoAfterTime, true); + _statusEffect.TryAddStatusEffect(args.Target.Value, "Muted", 2*comp.DoAfterTime, true); + + args.Repeat = true; } private bool IsBehind(EntityUid user, EntityUid target, float minAngleFromFace) diff --git a/Content.Shared/Stories/Garrote/GarroteEvents.cs b/Content.Shared/Stories/Garrote/GarroteEvents.cs index 4b1dd81852..bb8534d16a 100644 --- a/Content.Shared/Stories/Garrote/GarroteEvents.cs +++ b/Content.Shared/Stories/Garrote/GarroteEvents.cs @@ -5,6 +5,6 @@ namespace Content.Shared.Stories.Garrote; [Serializable, NetSerializable] -public sealed partial class GarroteDoneEvent : SimpleDoAfterEvent +public sealed partial class GarroteDoAfterEvent : SimpleDoAfterEvent { } diff --git a/Resources/Locale/ru-RU/_stories/garrote/garrote-component.ftl b/Resources/Locale/ru-RU/_stories/garrote/garrote-component.ftl index 6aec97959e..857d296042 100644 --- a/Resources/Locale/ru-RU/_stories/garrote/garrote-component.ftl +++ b/Resources/Locale/ru-RU/_stories/garrote/garrote-component.ftl @@ -2,9 +2,3 @@ garrote-component-doesnt-breath = { $target } уже не дышит! garrote-component-must-be-behind = Вы должны быть сзади { $target }. garrote-component-started-target = { $user } начинает удушать вас! garrote-component-started-others = { $user } начинает удушать { $target }! -garrote-component-complete = { $user } { GENDER($user) -> - [male] задушил - [female] задушила - [epicene] задушили - *[neuter] задушило - } { $target }!