diff --git a/Content.Server/Holosign/HolosignSystem.cs b/Content.Server/Holosign/HolosignSystem.cs index 33a08c0975..7f0952987f 100644 --- a/Content.Server/Holosign/HolosignSystem.cs +++ b/Content.Server/Holosign/HolosignSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.Coordinates.Helpers; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Popups; +using Content.Shared.Storage; namespace Content.Server.Holosign; @@ -59,7 +60,7 @@ public sealed class HolosignSystem : EntitySystem return; } - if (args.Handled || !args.CanReach) + if (args.Handled || !args.CanReach || HasComp(args.Target)) return; if (component.Signs.Count >= component.Uses) // wd edit diff --git a/Content.Shared/_White/Chemistry/NarcoticEffect.cs b/Content.Shared/_White/Chemistry/NarcoticEffect.cs new file mode 100644 index 0000000000..bb98352db7 --- /dev/null +++ b/Content.Shared/_White/Chemistry/NarcoticEffect.cs @@ -0,0 +1,99 @@ +using System.Threading; +using Content.Shared._White.Mood; +using Content.Shared.Chemistry.Components; +using Content.Shared.Damage.Systems; +using Content.Shared.Drunk; +using Content.Shared.Standing; +using Content.Shared.StatusEffect; +using Robust.Shared.Random; +using Timer = Robust.Shared.Timing.Timer; + +namespace Content.Shared._White.Chemistry; + +public sealed class NarcoticEffect : EntitySystem +{ + [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!; + [Dependency] private readonly StaminaSystem _stamina = default!; + [Dependency] private readonly StandingStateSystem _standingStateSystem = 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, Enum.GetNames(typeof(NarcoticEffects)).Length); + + Effects(uid, component, index); + } + + private void OnRemove(EntityUid uid, NarcoticEffectComponent component, ComponentRemove args) + { + if (TryComp(uid, out var movespeedModifierComponent)) + { + if (movespeedModifierComponent.ModifierTimer != TimeSpan.Zero) + Timer.Spawn(movespeedModifierComponent.ModifierTimer, () => component.CancelTokenSource.Cancel()); + return; + } + component.CancelTokenSource.Cancel(); + } + + private void Effects(EntityUid uid, NarcoticEffectComponent component, int index) + { + if(!TryComp(uid, out var standingComp)) + return; + + 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 (Enum.GetValues(typeof(NarcoticEffects)).GetValue(index)) + { + case NarcoticEffects.TremorAndShake when _statusEffectsSystem.HasStatusEffect(uid, "Drunk", statusEffectsComp): + Timer.SpawnRepeating(timer, () => _stamina.TakeStaminaDamage(uid, 15F), token); + _statusEffectsSystem.TryAddTime(uid, "Drunk", TimeSpan.FromSeconds(slur), statusEffectsComp); + break; + + case NarcoticEffects.Shake when _statusEffectsSystem.HasStatusEffect(uid, "Drunk", statusEffectsComp): + _statusEffectsSystem.TryAddTime(uid, "Drunk", TimeSpan.FromSeconds(slur), statusEffectsComp); + break; + + case NarcoticEffects.StunAndShake when _statusEffectsSystem.HasStatusEffect(uid, "Drunk", statusEffectsComp): + Timer.SpawnRepeating(timer, () => _standingStateSystem.TryLieDown(uid, standingComp), token); + _statusEffectsSystem.TryAddTime(uid, "Drunk", TimeSpan.FromSeconds(slur), statusEffectsComp); + break; + + case NarcoticEffects.Stun: + Timer.SpawnRepeating(timer, () => _standingStateSystem.TryLieDown(uid, standingComp), token); + break; + + case NarcoticEffects.TremorAndShake: + Timer.SpawnRepeating(timer, () => _stamina.TakeStaminaDamage(uid, 15F), token); + _statusEffectsSystem.TryAddStatusEffect(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp); + break; + + case NarcoticEffects.Tremor: + Timer.SpawnRepeating(timer, () => _stamina.TakeStaminaDamage(uid, 15F), token); + break; + + case NarcoticEffects.Shake: + _statusEffectsSystem.TryAddStatusEffect(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp); + break; + + case NarcoticEffects.StunAndShake: + Timer.SpawnRepeating(timer, () => _standingStateSystem.TryLieDown(uid, standingComp), token); + _statusEffectsSystem.TryAddStatusEffect(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp); + break; + } + } +} diff --git a/Content.Shared/_White/Chemistry/NarcoticEffectComponent.cs b/Content.Shared/_White/Chemistry/NarcoticEffectComponent.cs new file mode 100644 index 0000000000..f23182685e --- /dev/null +++ b/Content.Shared/_White/Chemistry/NarcoticEffectComponent.cs @@ -0,0 +1,30 @@ +using System.Threading; +using Robust.Shared.Serialization; + +namespace Content.Shared._White.Chemistry; + +/// +/// This is used for... +/// +[RegisterComponent] +public sealed partial class NarcoticEffectComponent : Component +{ + [ViewVariables(VVAccess.ReadWrite), DataField] + public CancellationTokenSource CancelTokenSource = new(); + + [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 }; +} + +[Serializable, NetSerializable] +public enum NarcoticEffects +{ + Stun, + Tremor, + Shake, + TremorAndShake, + StunAndShake +} diff --git a/Resources/Prototypes/Reagents/narcotics.yml b/Resources/Prototypes/Reagents/narcotics.yml index ba86e86406..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 @@ -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..539b9a2a68 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: 2 \ 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