[NEW STATUS SYSTEM] Drunkenness, Stuttering, Slurred Speech, and Bloodloss (#38678)
* The only commit that matters * I had to stop playing with my cat to push this change * Yaml removal * Proper drunk status effect and remove shitcode * Review changes * whoops * Whoops x2 * Update master fix merge conflicts * Fix merge conflicts * Dunk Component kill * MORE RELAYS * Holy fucking breaking changes * Ough * 46 file diff * Fix bad commits * Erm what the test fail? * Fix those last two * Merge conflicts * Me when I fix the merge conflicts --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d737e39a98
commit
6b73d320b9
@@ -418,7 +418,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
}
|
||||
}
|
||||
|
||||
_stuttering.DoStutter(uid, time * StutteringTimeMultiplier, refresh, statusEffects);
|
||||
_stuttering.DoStutter(uid, time * StutteringTimeMultiplier, refresh);
|
||||
_jittering.DoJitter(uid, time * JitterTimeMultiplier, refresh, JitterAmplitude, JitterFrequency, true, statusEffects);
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-popup-player"), uid, uid);
|
||||
|
||||
@@ -6,29 +6,25 @@ namespace Content.Server.Speech.Components
|
||||
/// <summary>
|
||||
/// Percentage chance that a stutter will occur if it matches.
|
||||
/// </summary>
|
||||
[DataField("matchRandomProb")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField]
|
||||
public float MatchRandomProb = 0.8f;
|
||||
|
||||
/// <summary>
|
||||
/// Percentage chance that a stutter occurs f-f-f-f-four times.
|
||||
/// </summary>
|
||||
[DataField("fourRandomProb")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField]
|
||||
public float FourRandomProb = 0.1f;
|
||||
|
||||
/// <summary>
|
||||
/// Percentage chance that a stutter occurs t-t-t-three times.
|
||||
/// </summary>
|
||||
[DataField("threeRandomProb")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField]
|
||||
public float ThreeRandomProb = 0.2f;
|
||||
|
||||
/// <summary>
|
||||
/// Percentage chance that a stutter cut off.
|
||||
/// </summary>
|
||||
[DataField("cutRandomProb")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField]
|
||||
public float CutRandomProb = 0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ using Content.Server.Speech.Components;
|
||||
using Content.Shared.Drunk;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Speech.EntitySystems;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.StatusEffectNew;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -12,26 +11,15 @@ namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
public sealed class SlurredSystem : SharedSlurredSystem
|
||||
{
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _status = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
private static readonly ProtoId<StatusEffectPrototype> SlurKey = "SlurredSpeech";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<SlurredAccentComponent, AccentGetEvent>(OnAccent);
|
||||
}
|
||||
|
||||
public override void DoSlur(EntityUid uid, TimeSpan time, StatusEffectsComponent? status = null)
|
||||
{
|
||||
if (!Resolve(uid, ref status, false))
|
||||
return;
|
||||
|
||||
if (!_statusEffectsSystem.HasStatusEffect(uid, SlurKey, status))
|
||||
_statusEffectsSystem.TryAddStatusEffect<SlurredAccentComponent>(uid, SlurKey, time, true, status);
|
||||
else
|
||||
_statusEffectsSystem.TryAddTime(uid, SlurKey, time, status);
|
||||
SubscribeLocalEvent<SlurredAccentComponent, StatusEffectRelayedEvent<AccentGetEvent>>(OnAccentRelayed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,15 +27,33 @@ public sealed class SlurredSystem : SharedSlurredSystem
|
||||
/// </summary>
|
||||
private float GetProbabilityScale(EntityUid uid)
|
||||
{
|
||||
if (!_statusEffectsSystem.TryGetTime(uid, SharedDrunkSystem.DrunkKey, out var time))
|
||||
if (!_status.TryGetMaxTime<DrunkStatusEffectComponent>(uid, out var time))
|
||||
return 0;
|
||||
|
||||
var curTime = _timing.CurTime;
|
||||
var timeLeft = (float) (time.Value.Item2 - curTime).TotalSeconds;
|
||||
return Math.Clamp((timeLeft - 80) / 1100, 0f, 1f);
|
||||
// This is a magic number. Why this value? No clue it was made 3 years before I refactored this.
|
||||
var magic = SharedDrunkSystem.MagicNumber;
|
||||
|
||||
if (time.Item2 != null)
|
||||
{
|
||||
var curTime = _timing.CurTime;
|
||||
magic = (float) (time.Item2 - curTime).Value.TotalSeconds - 80f;
|
||||
}
|
||||
|
||||
return Math.Clamp(magic / SharedDrunkSystem.MagicNumber, 0f, 1f);
|
||||
}
|
||||
|
||||
private void OnAccent(EntityUid uid, SlurredAccentComponent component, AccentGetEvent args)
|
||||
private void OnAccent(Entity<SlurredAccentComponent> entity, ref AccentGetEvent args)
|
||||
{
|
||||
GetAccent(entity, ref args);
|
||||
}
|
||||
|
||||
private void OnAccentRelayed(Entity<SlurredAccentComponent> entity, ref StatusEffectRelayedEvent<AccentGetEvent> args)
|
||||
{
|
||||
var ev = args.Args;
|
||||
GetAccent(args.Args.Entity, ref ev);
|
||||
}
|
||||
|
||||
private void GetAccent(EntityUid uid, ref AccentGetEvent args)
|
||||
{
|
||||
var scale = GetProbabilityScale(uid);
|
||||
args.Message = Accentuate(args.Message, scale);
|
||||
|
||||
@@ -3,14 +3,13 @@ using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Speech.EntitySystems;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.StatusEffectNew;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems
|
||||
{
|
||||
public sealed class StutteringSystem : SharedStutteringSystem
|
||||
{
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
// Regex of characters to stutter.
|
||||
@@ -20,19 +19,36 @@ namespace Content.Server.Speech.EntitySystems
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<StutteringAccentComponent, AccentGetEvent>(OnAccent);
|
||||
|
||||
SubscribeLocalEvent<StutteringAccentComponent, StatusEffectRelayedEvent<AccentGetEvent>>(OnAccent);
|
||||
}
|
||||
|
||||
public override void DoStutter(EntityUid uid, TimeSpan time, bool refresh, StatusEffectsComponent? status = null)
|
||||
public override void DoStutter(EntityUid uid, TimeSpan time, bool refresh)
|
||||
{
|
||||
if (!Resolve(uid, ref status, false))
|
||||
return;
|
||||
|
||||
_statusEffectsSystem.TryAddStatusEffect<StutteringAccentComponent>(uid, StutterKey, time, refresh, status);
|
||||
if (refresh)
|
||||
Status.TryUpdateStatusEffectDuration(uid, Stuttering, time);
|
||||
else
|
||||
Status.TryAddStatusEffectDuration(uid, Stuttering, time);
|
||||
}
|
||||
|
||||
private void OnAccent(EntityUid uid, StutteringAccentComponent component, AccentGetEvent args)
|
||||
public override void DoRemoveStutterTime(EntityUid uid, TimeSpan timeRemoved)
|
||||
{
|
||||
args.Message = Accentuate(args.Message, component);
|
||||
Status.TryAddTime(uid, Stuttering, -timeRemoved);
|
||||
}
|
||||
|
||||
public override void DoRemoveStutter(EntityUid uid)
|
||||
{
|
||||
Status.TryRemoveStatusEffect(uid, Stuttering);
|
||||
}
|
||||
|
||||
private void OnAccent(Entity<StutteringAccentComponent> entity, ref AccentGetEvent args)
|
||||
{
|
||||
args.Message = Accentuate(args.Message, entity.Comp);
|
||||
}
|
||||
|
||||
private void OnAccent(Entity<StutteringAccentComponent> entity, ref StatusEffectRelayedEvent<AccentGetEvent> args)
|
||||
{
|
||||
args.Args.Message = Accentuate(args.Args.Message, entity.Comp);
|
||||
}
|
||||
|
||||
public string Accentuate(string message, StutteringAccentComponent component)
|
||||
|
||||
Reference in New Issue
Block a user