Fix Being Drunk! (#41002)

* Drunk moment

* push

* fix test fails + a smidge of cleanup

* two smidges of cleanup

* Unpredicted so don't need the workaround

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
Princess Cheeseballs
2025-10-21 13:12:36 -07:00
committed by GitHub
parent 04a2c2e968
commit 4aac3dbc9d
9 changed files with 47 additions and 47 deletions

View File

@@ -15,6 +15,16 @@ public sealed class SlurredSystem : SharedSlurredSystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IGameTiming _timing = default!;
/// <summary>
/// Divisor applied to total seconds used to get the odds of slurred speech occuring.
/// </summary>
private const float SlurredModifier = 1100f;
/// <summary>
/// Minimum amount of time on the slurred accent for it to start taking effect.
/// </summary>
private const float SlurredThreshold = 80f;
public override void Initialize()
{
SubscribeLocalEvent<SlurredAccentComponent, AccentGetEvent>(OnAccent);
@@ -32,15 +42,9 @@ public sealed class SlurredSystem : SharedSlurredSystem
return 0;
// This is a magic number. Why this value? No clue it was made 3 years before I refactored this.
var magic = SharedDrunkSystem.MagicNumber;
var magic = time.Item2 == null ? SlurredModifier : (float) (time.Item2 - _timing.CurTime).Value.TotalSeconds - SlurredThreshold;
if (time.Item2 != null)
{
var curTime = _timing.CurTime;
magic = (float) (time.Item2 - curTime).Value.TotalSeconds - 80f;
}
return Math.Clamp(magic / SharedDrunkSystem.MagicNumber, 0f, 1f);
return Math.Clamp(magic / SlurredModifier, 0f, 1f);
}
private void OnAccent(Entity<SlurredAccentComponent> entity, ref AccentGetEvent args)