From a436032963c1c382deb10f14a38c3a1fb52c60a0 Mon Sep 17 00:00:00 2001
From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Date: Wed, 16 Apr 2025 22:23:40 +1000
Subject: [PATCH] Fix tippy speech time (#36616)
---
Content.Server/Tips/TipsSystem.cs | 20 +++++++++++++++++++-
Content.Shared/Tips/TippyEvent.cs | 2 ++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Content.Server/Tips/TipsSystem.cs b/Content.Server/Tips/TipsSystem.cs
index 2f7edd45d6..effbb7ba87 100644
--- a/Content.Server/Tips/TipsSystem.cs
+++ b/Content.Server/Tips/TipsSystem.cs
@@ -35,6 +35,16 @@ public sealed class TipsSystem : EntitySystem
private string _tipsDataset = "";
private float _tipTippyChance;
+ ///
+ /// Always adds this time to a speech message. This is so really short message stay around for a bit.
+ ///
+ private const float SpeechBuffer = 3f;
+
+ ///
+ /// Expected reading speed.
+ ///
+ private const float Wpm = 180f;
+
[ViewVariables(VVAccess.ReadWrite)]
private TimeSpan _nextTipTime = TimeSpan.Zero;
@@ -127,6 +137,8 @@ public sealed class TipsSystem : EntitySystem
if (args.Length > 3)
ev.SpeakTime = float.Parse(args[3]);
+ else
+ ev.SpeakTime = GetSpeechTime(ev.Msg);
if (args.Length > 4)
ev.SlideTime = float.Parse(args[4]);
@@ -183,6 +195,12 @@ public sealed class TipsSystem : EntitySystem
_tipTippyChance = value;
}
+ public static float GetSpeechTime(string text)
+ {
+ var wordCount = (float)text.Split().Length;
+ return SpeechBuffer + wordCount * (60f / Wpm);
+ }
+
private void AnnounceRandomTip()
{
if (!_prototype.TryIndex(_tipsDataset, out var tips))
@@ -194,7 +212,7 @@ public sealed class TipsSystem : EntitySystem
if (_random.Prob(_tipTippyChance))
{
var ev = new TippyEvent(msg);
- ev.SpeakTime = 1 + tip.Length * 0.05f;
+ ev.SpeakTime = GetSpeechTime(msg);
RaiseNetworkEvent(ev);
} else
{
diff --git a/Content.Shared/Tips/TippyEvent.cs b/Content.Shared/Tips/TippyEvent.cs
index 4370e9c822..e5dc0b7f35 100644
--- a/Content.Shared/Tips/TippyEvent.cs
+++ b/Content.Shared/Tips/TippyEvent.cs
@@ -13,6 +13,8 @@ public sealed class TippyEvent : EntityEventArgs
public string Msg;
public string? Proto;
+
+ // TODO: Why are these defaults even here, have the caller specify. This get overriden only most of the time.
public float SpeakTime = 5;
public float SlideTime = 3;
public float WaddleInterval = 0.5f;
--
2.51.2