From cf4d6f8344e0d9eb868c2ca88ca7b779b16affec Mon Sep 17 00:00:00 2001 From: CaYpeN1 Date: Thu, 21 Mar 2024 14:01:32 +0500 Subject: [PATCH] tweak: timers, effects --- .../_White/Chemistry/NarcoticEffect.cs | 27 ++++++++++++------- .../Chemistry/NarcoticEffectComponent.cs | 8 +++++- Resources/Prototypes/Reagents/narcotics.yml | 4 +-- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Content.Server/_White/Chemistry/NarcoticEffect.cs b/Content.Server/_White/Chemistry/NarcoticEffect.cs index 4ce8bdd8a9..c87390ebfa 100644 --- a/Content.Server/_White/Chemistry/NarcoticEffect.cs +++ b/Content.Server/_White/Chemistry/NarcoticEffect.cs @@ -1,8 +1,10 @@ using System.Threading; +using Content.Server.Speech.EntitySystems; using Content.Server.Stunnable; using Content.Shared._White.Mood; -using Content.Shared.Alert; using Content.Shared.Damage.Systems; +using Content.Shared.Drunk; +using Content.Shared.StatusEffect; using Robust.Shared.Random; using Timer = Robust.Shared.Timing.Timer; @@ -15,8 +17,8 @@ public sealed class NarcoticEffect : EntitySystem { [Dependency] private readonly StunSystem _stun = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!; [Dependency] private readonly StaminaSystem _stamina = default!; - [Dependency] private readonly AlertsSystem _alertsSystem = default!; /// public override void Initialize() @@ -37,35 +39,40 @@ public sealed class NarcoticEffect : EntitySystem private void OnRemove(EntityUid uid, NarcoticEffectComponent component, ComponentRemove args) { component.cancelTokenSource.Cancel(); - _alertsSystem.ClearAlert(uid, AlertType.Bleeding); } private void Effects(EntityUid uid, NarcoticEffectComponent component, int index) { RaiseLocalEvent(uid, new MoodEffectEvent("Stimulator")); CancellationToken token = component.cancelTokenSource.Token; + + TryComp(uid, out var statusEffectsComp); + + int timer = component.TimerInterval[_robustRandom.Next(0, component.TimerInterval.Count)]; + int slur = component.SlurTime[_robustRandom.Next(0, component.SlurTime.Count)]; + switch (component.Effects[index]) { case "Stun": - Timer.SpawnRepeating(10000, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token); + Timer.SpawnRepeating(timer, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token); break; case "TremorAndShake": - Timer.SpawnRepeating(6000, () => _stamina.TakeStaminaDamage(uid, 20F), token); - _alertsSystem.ShowAlert(uid, AlertType.Bleeding); + Timer.SpawnRepeating(timer, () => _stamina.TakeStaminaDamage(uid, 20F), token); + _statusEffectsSystem.TryAddStatusEffect(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp); break; case "Tremor": - Timer.SpawnRepeating(6000, () => _stamina.TakeStaminaDamage(uid, 20F), token); + Timer.SpawnRepeating(timer, () => _stamina.TakeStaminaDamage(uid, 20F), token); break; case "Shake": - _alertsSystem.ShowAlert(uid, AlertType.Bleeding); + _statusEffectsSystem.TryAddStatusEffect(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp); break; case "StunAndShake": - Timer.SpawnRepeating(10000, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token); - _alertsSystem.ShowAlert(uid, AlertType.Bleeding); + Timer.SpawnRepeating(timer, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token); + _statusEffectsSystem.TryAddStatusEffect(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp); break; } } diff --git a/Content.Server/_White/Chemistry/NarcoticEffectComponent.cs b/Content.Server/_White/Chemistry/NarcoticEffectComponent.cs index 0c8cce1ae0..de5f2dc39f 100644 --- a/Content.Server/_White/Chemistry/NarcoticEffectComponent.cs +++ b/Content.Server/_White/Chemistry/NarcoticEffectComponent.cs @@ -9,11 +9,17 @@ namespace Content.Server._White.Chemistry; public sealed partial class NarcoticEffectComponent : Component { [ViewVariables(VVAccess.ReadWrite), DataField] - public float StunTime = 3f; + public float StunTime = 2.5f; [ViewVariables(VVAccess.ReadWrite), DataField] public CancellationTokenSource cancelTokenSource = new(); [ViewVariables(VVAccess.ReadOnly), DataField] public List Effects = new() { "Stun", "TremorAndShake", "Tremor", "Shake", "StunAndShake" }; + + [ViewVariables(VVAccess.ReadOnly), DataField] + public List TimerInterval = new() { 3000, 6000, 3800, 7000, 5000 }; + + [ViewVariables(VVAccess.ReadOnly), DataField] + public List SlurTime = new() { 35, 60, 80, 90, 45 }; } diff --git a/Resources/Prototypes/Reagents/narcotics.yml b/Resources/Prototypes/Reagents/narcotics.yml index afccc62e00..24a072adf9 100644 --- a/Resources/Prototypes/Reagents/narcotics.yml +++ b/Resources/Prototypes/Reagents/narcotics.yml @@ -32,8 +32,8 @@ key: Stutter component: StutteringAccent - !type:GenericStatusEffect - key: BlurryVision - component: BlurryVision + key: NarcoticEffect + component: NarcoticEffect - !type:Jitter - !type:GenericStatusEffect key: Stun