diff --git a/Content.Server/_White/Chemistry/NarcoticEffect.cs b/Content.Server/_White/Chemistry/NarcoticEffect.cs new file mode 100644 index 0000000000..4ce8bdd8a9 --- /dev/null +++ b/Content.Server/_White/Chemistry/NarcoticEffect.cs @@ -0,0 +1,72 @@ +using System.Threading; +using Content.Server.Stunnable; +using Content.Shared._White.Mood; +using Content.Shared.Alert; +using Content.Shared.Damage.Systems; +using Robust.Shared.Random; +using Timer = Robust.Shared.Timing.Timer; + +namespace Content.Server._White.Chemistry; + +/// +/// This handles system? +/// +public sealed class NarcoticEffect : EntitySystem +{ + [Dependency] private readonly StunSystem _stun = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly StaminaSystem _stamina = default!; + [Dependency] private readonly AlertsSystem _alertsSystem = default!; + + /// + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnRemove); + } + + private void OnInit(EntityUid uid, NarcoticEffectComponent component, ComponentInit args) + { + int index = _robustRandom.Next(0, component.Effects.Count); + + Effects(uid, component, index); + } + + 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; + switch (component.Effects[index]) + { + case "Stun": + Timer.SpawnRepeating(10000, () => _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); + break; + + case "Tremor": + Timer.SpawnRepeating(6000, () => _stamina.TakeStaminaDamage(uid, 20F), token); + break; + + case "Shake": + _alertsSystem.ShowAlert(uid, AlertType.Bleeding); + break; + + case "StunAndShake": + Timer.SpawnRepeating(10000, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token); + _alertsSystem.ShowAlert(uid, AlertType.Bleeding); + break; + } + } +} diff --git a/Content.Server/_White/Chemistry/NarcoticEffectComponent.cs b/Content.Server/_White/Chemistry/NarcoticEffectComponent.cs new file mode 100644 index 0000000000..0c8cce1ae0 --- /dev/null +++ b/Content.Server/_White/Chemistry/NarcoticEffectComponent.cs @@ -0,0 +1,19 @@ +using System.Threading; + +namespace Content.Server._White.Chemistry; + +/// +/// This is used for... +/// +[RegisterComponent] +public sealed partial class NarcoticEffectComponent : Component +{ + [ViewVariables(VVAccess.ReadWrite), DataField] + public float StunTime = 3f; + + [ViewVariables(VVAccess.ReadWrite), DataField] + public CancellationTokenSource cancelTokenSource = new(); + + [ViewVariables(VVAccess.ReadOnly), DataField] + public List Effects = new() { "Stun", "TremorAndShake", "Tremor", "Shake", "StunAndShake" }; +} diff --git a/Resources/Prototypes/Reagents/narcotics.yml b/Resources/Prototypes/Reagents/narcotics.yml index ba86e86406..afccc62e00 100644 --- a/Resources/Prototypes/Reagents/narcotics.yml +++ b/Resources/Prototypes/Reagents/narcotics.yml @@ -76,8 +76,8 @@ Asphyxiation: 2 - !type:Jitter - !type:GenericStatusEffect - key: BlurryVision - component: BlurryVision + key: NarcoticEffect + component: NarcoticEffect - !type:GenericStatusEffect key: Stun time: 1 diff --git a/Resources/Prototypes/White/Mood/generic_positveEffects.yml b/Resources/Prototypes/White/Mood/generic_positveEffects.yml index 71fd30dc0b..5c34773fc2 100644 --- a/Resources/Prototypes/White/Mood/generic_positveEffects.yml +++ b/Resources/Prototypes/White/Mood/generic_positveEffects.yml @@ -50,3 +50,10 @@ desc: "Знаю правду, славим великого!" moodChange: enum.MoodChangeLevel.Big positiveEffect: true + +- type: moodEffect + id: Stimulator + desc: "Я ЧУВСТВУЮ ЭТО, В МОЕЙ КРОВИ НЕЧТО УСКОРЯЮЩЕЕ!!" + moodChange: enum.MoodChangeLevel.Medium + positiveEffect: true + timeout: 4 \ No newline at end of file diff --git a/Resources/Prototypes/status_effects.yml b/Resources/Prototypes/status_effects.yml index 1c2bd7fbf8..a9ea56db57 100644 --- a/Resources/Prototypes/status_effects.yml +++ b/Resources/Prototypes/status_effects.yml @@ -64,6 +64,10 @@ id: BlurryVision alwaysAllowed: true +- type: statusEffect + id: NarcoticEffect + alwaysAllowed: true + #WD EDIT - type: statusEffect id: Incorporeal