tweak: timers, effects
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Content.Server.Speech.EntitySystems;
|
||||||
using Content.Server.Stunnable;
|
using Content.Server.Stunnable;
|
||||||
using Content.Shared._White.Mood;
|
using Content.Shared._White.Mood;
|
||||||
using Content.Shared.Alert;
|
|
||||||
using Content.Shared.Damage.Systems;
|
using Content.Shared.Damage.Systems;
|
||||||
|
using Content.Shared.Drunk;
|
||||||
|
using Content.Shared.StatusEffect;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Timer = Robust.Shared.Timing.Timer;
|
using Timer = Robust.Shared.Timing.Timer;
|
||||||
|
|
||||||
@@ -15,8 +17,8 @@ public sealed class NarcoticEffect : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly StunSystem _stun = default!;
|
[Dependency] private readonly StunSystem _stun = default!;
|
||||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||||
|
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
||||||
[Dependency] private readonly StaminaSystem _stamina = default!;
|
[Dependency] private readonly StaminaSystem _stamina = default!;
|
||||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -37,35 +39,40 @@ public sealed class NarcoticEffect : EntitySystem
|
|||||||
private void OnRemove(EntityUid uid, NarcoticEffectComponent component, ComponentRemove args)
|
private void OnRemove(EntityUid uid, NarcoticEffectComponent component, ComponentRemove args)
|
||||||
{
|
{
|
||||||
component.cancelTokenSource.Cancel();
|
component.cancelTokenSource.Cancel();
|
||||||
_alertsSystem.ClearAlert(uid, AlertType.Bleeding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Effects(EntityUid uid, NarcoticEffectComponent component, int index)
|
private void Effects(EntityUid uid, NarcoticEffectComponent component, int index)
|
||||||
{
|
{
|
||||||
RaiseLocalEvent(uid, new MoodEffectEvent("Stimulator"));
|
RaiseLocalEvent(uid, new MoodEffectEvent("Stimulator"));
|
||||||
CancellationToken token = component.cancelTokenSource.Token;
|
CancellationToken token = component.cancelTokenSource.Token;
|
||||||
|
|
||||||
|
TryComp<StatusEffectsComponent>(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])
|
switch (component.Effects[index])
|
||||||
{
|
{
|
||||||
case "Stun":
|
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;
|
break;
|
||||||
|
|
||||||
case "TremorAndShake":
|
case "TremorAndShake":
|
||||||
Timer.SpawnRepeating(6000, () => _stamina.TakeStaminaDamage(uid, 20F), token);
|
Timer.SpawnRepeating(timer, () => _stamina.TakeStaminaDamage(uid, 20F), token);
|
||||||
_alertsSystem.ShowAlert(uid, AlertType.Bleeding);
|
_statusEffectsSystem.TryAddStatusEffect<DrunkComponent>(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Tremor":
|
case "Tremor":
|
||||||
Timer.SpawnRepeating(6000, () => _stamina.TakeStaminaDamage(uid, 20F), token);
|
Timer.SpawnRepeating(timer, () => _stamina.TakeStaminaDamage(uid, 20F), token);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Shake":
|
case "Shake":
|
||||||
_alertsSystem.ShowAlert(uid, AlertType.Bleeding);
|
_statusEffectsSystem.TryAddStatusEffect<DrunkComponent>(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "StunAndShake":
|
case "StunAndShake":
|
||||||
Timer.SpawnRepeating(10000, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token);
|
Timer.SpawnRepeating(timer, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token);
|
||||||
_alertsSystem.ShowAlert(uid, AlertType.Bleeding);
|
_statusEffectsSystem.TryAddStatusEffect<DrunkComponent>(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,17 @@ namespace Content.Server._White.Chemistry;
|
|||||||
public sealed partial class NarcoticEffectComponent : Component
|
public sealed partial class NarcoticEffectComponent : Component
|
||||||
{
|
{
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||||
public float StunTime = 3f;
|
public float StunTime = 2.5f;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||||
public CancellationTokenSource cancelTokenSource = new();
|
public CancellationTokenSource cancelTokenSource = new();
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadOnly), DataField]
|
[ViewVariables(VVAccess.ReadOnly), DataField]
|
||||||
public List<string> Effects = new() { "Stun", "TremorAndShake", "Tremor", "Shake", "StunAndShake" };
|
public List<string> Effects = new() { "Stun", "TremorAndShake", "Tremor", "Shake", "StunAndShake" };
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadOnly), DataField]
|
||||||
|
public List<int> TimerInterval = new() { 3000, 6000, 3800, 7000, 5000 };
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadOnly), DataField]
|
||||||
|
public List<int> SlurTime = new() { 35, 60, 80, 90, 45 };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
key: Stutter
|
key: Stutter
|
||||||
component: StutteringAccent
|
component: StutteringAccent
|
||||||
- !type:GenericStatusEffect
|
- !type:GenericStatusEffect
|
||||||
key: BlurryVision
|
key: NarcoticEffect
|
||||||
component: BlurryVision
|
component: NarcoticEffect
|
||||||
- !type:Jitter
|
- !type:Jitter
|
||||||
- !type:GenericStatusEffect
|
- !type:GenericStatusEffect
|
||||||
key: Stun
|
key: Stun
|
||||||
|
|||||||
Reference in New Issue
Block a user