From 3cb169cae871f9d978620513040184293e2878bf Mon Sep 17 00:00:00 2001 From: Shegare <147345753+Shegare@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:11:06 +0300 Subject: [PATCH] back crawling and chatting in crit --- Content.Server/Chat/Systems/ChatSystem.cs | 5 ++ .../Systems/MobStateSystem.Subscribers.cs | 49 ++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 27db5cae60..bbabfd27c4 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -562,6 +562,11 @@ private void SendEntityWhisper( _replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, message, wrappedMessage, GetNetEntity(source), null, MessageRangeHideChatForReplay(range))); + // Stories-Crit-Speech-Start + if (_mobStateSystem.IsCritical(source) && _prototype.TryIndex("Asphyxiation", out var asphyxiation)) + _damageable.TryChangeDamage(source, new(asphyxiation, 100), true, false); + // Stories-Crit-Speech-End + var ev = new EntitySpokeEvent(source, message, originalMessage, channel, obfuscatedMessage); // Stories-TTS: Spec symbol sanitize RaiseLocalEvent(source, ev, true); if (!hideLog) diff --git a/Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs b/Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs index f99bd43feb..801adc6367 100644 --- a/Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs +++ b/Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs @@ -18,6 +18,11 @@ using Content.Shared.Throwing; using Robust.Shared.Physics.Components; +using Content.Shared.Damage; +using Content.Shared.Humanoid; +using Content.Shared.Movement.Components; +using Content.Shared.Movement.Systems; + namespace Content.Shared.Mobs.Systems; public partial class MobStateSystem @@ -46,6 +51,8 @@ private void SubscribeEvents() SubscribeLocalEvent(OnAttemptPacifiedAttack); SubscribeLocalEvent(OnUnbuckleAttempt); + + SubscribeLocalEvent(OnRefreshMovementSpeedModifiers); // Stories-Crawling } private void OnUnbuckleAttempt(Entity ent, ref UnbuckleAttemptEvent args) @@ -73,6 +80,11 @@ private void OnStateExitSubscribers(EntityUid target, MobStateComponent componen { case MobState.Alive: //unused + + // Stories-Crawling-Start + if (!_standing.CanCrawl(target)) + _standing.Stand(target); + // Stories-Crawling-End break; case MobState.Critical: _standing.Stand(target); @@ -144,6 +156,10 @@ private void OnSpeakAttempt(EntityUid uid, MobStateComponent component, SpeakAtt RemCompDeferred(uid); return; } + // Stories-Crit-Speech-Start + if (component.CurrentState == MobState.Critical) + return; + // Stories-Crit-Speech-End CheckAct(uid, component, args); } @@ -153,9 +169,13 @@ private void CheckAct(EntityUid target, MobStateComponent component, Cancellable switch (component.CurrentState) { case MobState.Dead: - case MobState.Critical: args.Cancel(); break; + case MobState.Critical: + if (args is not UpdateCanMoveEvent || !HasComp(target)) + args.Cancel(); + + break; } } @@ -186,5 +206,32 @@ private void OnAttemptPacifiedAttack(Entity ent, ref AttemptP args.Cancelled = true; } + private void OnRefreshMovementSpeedModifiers(EntityUid uid, MobStateComponent component, ref RefreshMovementSpeedModifiersEvent ev) + { + if (!HasComp(uid)) + return; + + switch (component.CurrentState) + { + case MobState.Critical: + if (!TryComp(uid, out var damageable)) + return; + + // Stories-Crawling-Start + if (!TryComp(uid, out var speed)) + return; + + if (!_mobThreshold.TryGetPercentageForState(uid, MobState.Dead, damageable.TotalDamage, out var percentage)) + return; + + var sprintSpeedModifier = (1 - (float) percentage) * 2 * 0.15f * speed.BaseSprintSpeed; + var walkSpeedModifier = (1 - (float) percentage) * 2 * 0.15f * speed.BaseWalkSpeed; + + ev.ModifySpeed(sprintSpeedModifier, walkSpeedModifier); + // Stories-Crawling-End + break; + } + } + #endregion }