From af7327e59f9831d866022dc9018ae79311602f04 Mon Sep 17 00:00:00 2001 From: Guillaume E <262623+quatre@users.noreply.github.com> Date: Wed, 10 Jan 2024 13:00:21 +0100 Subject: [PATCH] Show how close bodies are to rotting (#23530) * Show how close bodies are to rotting When examining a dead body, you will be able to see of close it is to rotting. - "It still looks fresh.", in the first third of the pre-rot period - "It looks ripe.", in the second third - "It's starting to look bad.", in the last third This could help players prioritize medical care. * Alter the wording of the pre-rot indicator * Use numeric rotting stages in FTL --------- Co-authored-by: Kevin Zheng --- Content.Server/Atmos/Rotting/RottingSystem.cs | 26 +++++++++++++++++++ Resources/Locale/en-US/disease/miasma.ftl | 3 +++ 2 files changed, 29 insertions(+) diff --git a/Content.Server/Atmos/Rotting/RottingSystem.cs b/Content.Server/Atmos/Rotting/RottingSystem.cs index db0815f3a6..246758532a 100644 --- a/Content.Server/Atmos/Rotting/RottingSystem.cs +++ b/Content.Server/Atmos/Rotting/RottingSystem.cs @@ -32,6 +32,7 @@ public sealed class RottingSystem : EntitySystem SubscribeLocalEvent(OnPerishableMapInit); SubscribeLocalEvent(OnPerishableUnpaused); SubscribeLocalEvent(OnMobStateChanged); + SubscribeLocalEvent(OnPerishableExamined); SubscribeLocalEvent(OnRottingUnpaused); SubscribeLocalEvent(OnShutdown); @@ -122,6 +123,31 @@ public sealed class RottingSystem : EntitySystem tileMix?.AdjustMoles(Gas.Ammonia, molsToDump); } + private void OnPerishableExamined(Entity perishable, ref ExaminedEvent args) + { + int maxStages = 3; + int stage = PerishStage(perishable, maxStages); + if (stage < 1 || stage > maxStages) + { + // We dont push an examined string if it hasen't started "perishing" or it's already rotting + return; + } + + var description = "perishable-" + stage; + args.PushMarkup(Loc.GetString(description)); + } + + /// + /// Return an integer from 0 to maxStage representing how close to rotting an entity is. Used to + /// generate examine messages for items that are starting to rot. + /// + public int PerishStage(Entity perishable, int maxStages) + { + if (perishable.Comp.RotAfter.TotalSeconds == 0 || perishable.Comp.RotAccumulator.TotalSeconds == 0) + return 0; + return (int)(1 + maxStages * perishable.Comp.RotAccumulator.TotalSeconds / perishable.Comp.RotAfter.TotalSeconds); + } + private void OnExamined(EntityUid uid, RottingComponent component, ExaminedEvent args) { var stage = RotStage(uid, component); diff --git a/Resources/Locale/en-US/disease/miasma.ftl b/Resources/Locale/en-US/disease/miasma.ftl index cc0c4117e5..06c96bc73d 100644 --- a/Resources/Locale/en-US/disease/miasma.ftl +++ b/Resources/Locale/en-US/disease/miasma.ftl @@ -1,4 +1,7 @@ ammonia-smell = Something smells pungent! +perishable-1 = [color=green]It still looks fresh.[/color] +perishable-2 = [color=orangered]It looks somewhat fresh.[/color] +perishable-3 = [color=red]It doesn't look fresh anymore.[/color] rotting-rotting = [color=orange]It's rotting![/color] rotting-bloated = [color=orangered]It's bloated![/color] rotting-extremely-bloated = [color=red]It's extremely bloated![/color]