[april fools] The world feels different today. You examine objects around you but can't quite make out what's in front of you. (#35879)

* maybeAccentuate

* accentuate examine nodes

* working prototype

* random accentuator

* fix SingleAccentuator.cs

* french, mumble, slurred

* mobster, pirate, stutter

* remove examine prediction (for one day)

* random accents per examine, not per sentence

* Revert "random accents per examine, not per sentence"

This reverts commit 0dfa644bb760e4b3f760f43db8870f43ea75e64d.

* crew manifest

* tweak examine reaccentuation chance

* alert level announcement

* event centcom announcements

* tweak accent system signatures

* nuke annoucement, tweak manifest chance

* accentuation rarer and a bit more messed up

* examine tooltips

* more centcom announcements

* reformat

* sophisticated reformatting

* less

* tweak

---------

Co-authored-by: Milon <milonpl.git@proton.me>
This commit is contained in:
qwerltaz 2025-03-31 14:35:12 +02:00 • committed by GitHub
parent e518b28861
commit 20c962aae1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 178 additions and 8 deletions

View file

@ -361,7 +361,6 @@ namespace Content.Client.Examine
// If we get it wrong, server will correct us later anyway.
// This will usually be correct (barring server-only components, which generally only adds, not replaces text)
message = GetExamineText(entity, playerEnt);
UpdateTooltipInfo(playerEnt.Value, entity, message);
if (!IsClientSide(entity))
{

View file

@ -1,5 +1,6 @@
using System.Linq;
using Content.Server.Chat.Systems;
using Content.Server.Speech.EntitySystems;
using Content.Server.Station.Systems;
using Content.Shared.CCVar;
using Robust.Shared.Audio;
@ -188,6 +189,7 @@ public sealed class AlertLevelSystem : EntitySystem
if (announce)
{
announcementFull = RandomAccentuator.MaybeAccentuate(announcementFull);
_chatSystem.DispatchStationAnnouncement(station, announcementFull, playDefaultSound: playDefault,
colorOverride: detail.Color, sender: stationName);
}

View file

@ -381,6 +381,9 @@ public sealed partial class ChatSystem : SharedChatSystem
{
sender ??= Loc.GetString("chat-manager-sender-announcement");
if (!sender.Equals(Loc.GetString("comms-console-announcement-title-station"), StringComparison.OrdinalIgnoreCase))
message = RandomAccentuator.MaybeAccentuate(message);
var wrappedMessage = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender), ("message", FormattedMessage.EscapeText(message)));
var station = _stationSystem.GetOwningStation(source);

View file

@ -1,6 +1,7 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.EUI;
using Content.Server.Speech.EntitySystems;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.StationRecords;
@ -230,7 +231,7 @@ public sealed class CrewManifestSystem : EntitySystem
foreach (var recordObject in iter)
{
var record = recordObject.Item2;
var entry = new CrewManifestEntry(record.Name, record.JobTitle, record.JobIcon, record.JobPrototype);
var entry = new CrewManifestEntry(RandomAccentuator.MaybeAccentuate(record.Name, reaccentuationChance: 0.03f), RandomAccentuator.MaybeAccentuate(record.JobTitle, reaccentuationChance: 0.2f), record.JobIcon, record.JobPrototype);
_prototypeManager.TryIndex(record.JobPrototype, out JobPrototype? job);
entriesSort.Add((job, entry));

View file

@ -1,4 +1,5 @@
using System.Linq;
using Content.Server.Speech.EntitySystems;
using Content.Server.Verbs;
using Content.Shared.Examine;
using Content.Shared.Verbs;
@ -36,6 +37,8 @@ namespace Content.Server.Examine
if (getVerbs)
verbs = _verbSystem.GetLocalVerbs(target, player, typeof(ExamineVerb));
message = RandomAccentuator.MaybeAccentuate(message, 0.1f);
var ev = new ExamineSystemMessages.ExamineInfoResponseMessage(
GetNetEntity(target), 0, message, verbs?.ToList(), centerAtCursor
);
@ -70,6 +73,8 @@ namespace Content.Server.Examine
verbs = _verbSystem.GetLocalVerbs(entity, playerEnt, typeof(ExamineVerb));
var text = GetExamineText(entity, player.AttachedEntity);
text = RandomAccentuator.MaybeAccentuate(text, 0.05f);
RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage(
request.NetEntity, request.Id, text, verbs?.ToList()), channel);
}

View file

@ -4,6 +4,7 @@ using Content.Server.Chat.Systems;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Pinpointer;
using Content.Server.Popups;
using Content.Server.Speech.EntitySystems;
using Content.Server.Station.Systems;
using Content.Shared.Audio;
using Content.Shared.Containers.ItemSlots;
@ -478,6 +479,7 @@ public sealed class NukeSystem : EntitySystem
("time", (int) component.RemainingTime),
("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString((uid, nukeXform)))));
var sender = Loc.GetString("nuke-component-announcement-sender");
announcement = RandomAccentuator.MaybeAccentuate(announcement);
_chatSystem.DispatchStationAnnouncement(stationUid ?? uid, announcement, sender, false, null, Color.Red);
_sound.PlayGlobalOnStation(uid, _audio.ResolveSound(component.ArmSound));
@ -518,6 +520,7 @@ public sealed class NukeSystem : EntitySystem
// warn a crew
var announcement = Loc.GetString("nuke-component-announcement-unarmed");
var sender = Loc.GetString("nuke-component-announcement-sender");
announcement = RandomAccentuator.MaybeAccentuate(announcement);
_chatSystem.DispatchStationAnnouncement(uid, announcement, sender, false);
component.PlayedNukeSong = false;

View file

@ -21,7 +21,12 @@ public sealed class FrenchAccentSystem : EntitySystem
SubscribeLocalEvent<FrenchAccentComponent, AccentGetEvent>(OnAccentGet);
}
public string Accentuate(string message, FrenchAccentComponent component)
public string Accentuate(string message, FrenchAccentComponent _)
{
return Accentuate(message);
}
public string Accentuate(string message)
{
var msg = message;

View file

@ -25,7 +25,12 @@ public sealed class MobsterAccentSystem : EntitySystem
SubscribeLocalEvent<MobsterAccentComponent, AccentGetEvent>(OnAccentGet);
}
public string Accentuate(string message, MobsterAccentComponent component)
private string Accentuate(string message, MobsterAccentComponent component)
{
return Accentuate(message, component.IsBoss);
}
public string Accentuate(string message, bool isBoss = true)
{
// Order:
// Do text manipulations first
@ -72,7 +77,7 @@ public sealed class MobsterAccentSystem : EntitySystem
//So the suffix can be allcapped
var lastWordAllCaps = !RegexLastWord.Match(msg).Value.Any(char.IsLower);
var suffix = "";
if (component.IsBoss)
if (isBoss)
{
var pick = _random.Next(1, 4);
suffix = Loc.GetString($"accent-mobster-suffix-boss-{pick}");
@ -90,6 +95,7 @@ public sealed class MobsterAccentSystem : EntitySystem
return msg;
}
private void OnAccentGet(EntityUid uid, MobsterAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message, component);

View file

@ -13,7 +13,12 @@ public sealed class MumbleAccentSystem : EntitySystem
SubscribeLocalEvent<MumbleAccentComponent, AccentGetEvent>(OnAccentGet);
}
public string Accentuate(string message, MumbleAccentComponent component)
private string Accentuate(string message, MumbleAccentComponent _)
{
return Accentuate(message);
}
public string Accentuate(string message)
{
return _replacement.ApplyReplacements(message, "mumble");
}

View file

@ -1,5 +1,6 @@
using Content.Server.Speech.Components;
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.Speech.EntitySystems
{

View file

@ -42,6 +42,11 @@ public sealed class PirateAccentSystem : EntitySystem
return msg;
}
public string Accentuate(string message)
{
return Accentuate(message, new PirateAccentComponent { YarrChance = 0.3f });
}
private void OnAccentGet(EntityUid uid, PirateAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message, component);

View file

@ -0,0 +1,66 @@
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.Speech.EntitySystems;
public static class RandomAccentuator
{
private const float DefaultAccentuationChance = 0.25f;
private const float DefaultReaccentuationChance = 0.15f;
private const float MaxReaccentuations = 4;
public static string MaybeAccentuate(string message,
float chance = DefaultAccentuationChance,
float reaccentuationChance = DefaultReaccentuationChance)
{
var random = IoCManager.Resolve<IRobustRandom>();
var singleAccentuator = new SingleAccentuator();
return random.Prob(chance)
? MaybeAccentuateDirect(message, singleAccentuator, random, reaccentuationChance)
: message;
}
public static FormattedMessage MaybeAccentuate(FormattedMessage message,
float chance = DefaultAccentuationChance,
float reaccentuationChance = DefaultReaccentuationChance)
{
var random = IoCManager.Resolve<IRobustRandom>();
var singleAccentuator = new SingleAccentuator();
var newMessage = new FormattedMessage();
foreach (var node in message)
{
if (random.Prob(chance) && node.Name is null && node.Value.TryGetString(out var text) &&
!string.IsNullOrWhiteSpace(text))
{
var accentedText = MaybeAccentuateDirect(text, singleAccentuator, random, reaccentuationChance);
newMessage.PushTag(new MarkupNode(accentedText));
}
else
{
newMessage.PushTag(node);
}
}
return newMessage;
}
private static string MaybeAccentuateDirect(string message,
SingleAccentuator singleAccentuator,
IRobustRandom random,
float reaccentuationChance)
{
for (var i = 0; i < MaxReaccentuations; i++)
{
if (i > 0 && !random.Prob(reaccentuationChance))
continue;
singleAccentuator.NextSystem();
message = singleAccentuator.Accentuate(message);
}
return message;
}
}

View file

@ -0,0 +1,59 @@
using Robust.Shared.Random;
namespace Content.Server.Speech.EntitySystems;
public sealed class SingleAccentuator
{
private EntitySystem? _accentSystem;
private readonly IReadOnlyList<EntitySystem> _accentSystems;
public SingleAccentuator()
{
var entMan = IoCManager.Resolve<IEntityManager>();
_accentSystems = new List<EntitySystem>
{
entMan.EntitySysManager.GetEntitySystem<OwOAccentSystem>(),
entMan.EntitySysManager.GetEntitySystem<GermanAccentSystem>(),
entMan.EntitySysManager.GetEntitySystem<RussianAccentSystem>(),
entMan.EntitySysManager.GetEntitySystem<FrenchAccentSystem>(),
entMan.EntitySysManager.GetEntitySystem<MumbleAccentSystem>(),
entMan.EntitySysManager.GetEntitySystem<SlurredSystem>(),
entMan.EntitySysManager.GetEntitySystem<MobsterAccentSystem>(),
entMan.EntitySysManager.GetEntitySystem<PirateAccentSystem>(),
entMan.EntitySysManager.GetEntitySystem<MonkeyAccentSystem>(),
entMan.EntitySysManager.GetEntitySystem<StutteringSystem>(),
};
NextSystem();
}
public void NextSystem()
{
_accentSystem = GetRandomAccentSystem();
}
private EntitySystem GetRandomAccentSystem()
{
var random = IoCManager.Resolve<IRobustRandom>();
return random.Pick(_accentSystems);
}
public string Accentuate(string message)
{
return _accentSystem switch
{
OwOAccentSystem owoAccentSystem => owoAccentSystem.Accentuate(message),
GermanAccentSystem germanAccentSystem => germanAccentSystem.Accentuate(message),
RussianAccentSystem russianAccentSystem => russianAccentSystem.Accentuate(message),
FrenchAccentSystem frenchAccentSystem => frenchAccentSystem.Accentuate(message),
MumbleAccentSystem mumbleAccentSystem => mumbleAccentSystem.Accentuate(message),
SlurredSystem slurredSystem => slurredSystem.Accentuate(message),
MobsterAccentSystem mobsterAccentSystem => mobsterAccentSystem.Accentuate(message),
PirateAccentSystem pirateAccentSystem => pirateAccentSystem.Accentuate(message),
MonkeyAccentSystem monkeyAccentSystem => monkeyAccentSystem.Accentuate(message),
StutteringSystem stutteringSystem => stutteringSystem.Accentuate(message),
_ => message
};
}
}

View file

@ -54,7 +54,7 @@ public sealed class SlurredSystem : SharedSlurredSystem
args.Message = Accentuate(args.Message, scale);
}
private string Accentuate(string message, float scale)
public string Accentuate(string message, float scale = 0.3f)
{
var sb = new StringBuilder();

View file

@ -70,5 +70,10 @@ namespace Content.Server.Speech.EntitySystems
return finalMessage.ToString();
}
public string Accentuate(string message)
{
return Accentuate(message, new StutteringAccentComponent());
}
}
}

View file

@ -2,6 +2,7 @@ using Content.Server.Administration.Logs;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Server.Speech.EntitySystems;
using Content.Server.Station.Systems;
using Content.Server.StationEvents.Components;
using Content.Shared.Database;
@ -46,7 +47,11 @@ public abstract class StationEventSystem<T> : GameRuleSystem<T> where T : ICompo
Filter allPlayersInGame = Filter.Empty().AddWhere(GameTicker.UserHasJoinedGame);
if (stationEvent.StartAnnouncement != null)
ChatSystem.DispatchFilteredAnnouncement(allPlayersInGame, Loc.GetString(stationEvent.StartAnnouncement), playSound: false, colorOverride: stationEvent.StartAnnouncementColor);
{
var announcement = Loc.GetString(stationEvent.StartAnnouncement);
announcement = RandomAccentuator.MaybeAccentuate(announcement);
ChatSystem.DispatchFilteredAnnouncement(allPlayersInGame, announcement, playSound: false, colorOverride: stationEvent.StartAnnouncementColor);
}
Audio.PlayGlobal(stationEvent.StartAudio, allPlayersInGame, true);
}