tweak: timers, effects

This commit is contained in:
CaYpeN1
2024-03-21 14:01:32 +05:00
parent d7b064d900
commit cf4d6f8344
3 changed files with 26 additions and 13 deletions

View File

@@ -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!;
/// <inheritdoc/>
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<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])
{
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<DrunkComponent>(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<DrunkComponent>(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<DrunkComponent>(uid, "Drunk", TimeSpan.FromSeconds(slur), true, statusEffectsComp);
break;
}
}

View File

@@ -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<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 };
}

View File

@@ -32,8 +32,8 @@
key: Stutter
component: StutteringAccent
- !type:GenericStatusEffect
key: BlurryVision
component: BlurryVision
key: NarcoticEffect
component: NarcoticEffect
- !type:Jitter
- !type:GenericStatusEffect
key: Stun