]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Added Pain Numbness Trait (#34538)
authorCoolsurf6 <coolsurf24@yahoo.com.au>
Mon, 27 Jan 2025 10:34:20 +0000 (20:34 +1000)
committerGitHub <noreply@github.com>
Mon, 27 Jan 2025 10:34:20 +0000 (11:34 +0100)
* added pain-numbness component and system

* added numb as a trait that pulls the pain numbness component

* removed new event as mob threshold event as already being fired

* checked for MobThresholdsComponent first before running VerifyThresholds

* refacted force say to using LocalizedDatasetPrototype and added numb messages

* added severity check alert

* added comment for BeforeForceSayEvent

* removed space formatting

* changed Cancelled to CancelUpdate, fixed spacing and added two more damage-force-say-numb

* changed prefix damage-force-say-numb to 5 (whoops)

14 files changed:
Content.Client/UserInterface/Systems/DamageOverlays/DamageOverlayUiController.cs
Content.Server/Damage/ForceSay/DamageForceSaySystem.cs
Content.Shared/Bed/Sleep/SleepingComponent.cs
Content.Shared/Bed/Sleep/SleepingSystem.cs
Content.Shared/Damage/Events/BeforeForceSayEvent.cs [new file with mode: 0644]
Content.Shared/Damage/ForceSay/DamageForceSayComponent.cs
Content.Shared/Mobs/Events/BeforeAlertSeverityCheckEvent.cs [new file with mode: 0644]
Content.Shared/Mobs/Systems/MobThresholdSystem.cs
Content.Shared/Traits/Assorted/PainNumbnessComponent.cs [new file with mode: 0644]
Content.Shared/Traits/Assorted/PainNumbnessSystem.cs [new file with mode: 0644]
Resources/Locale/en-US/damage/damage-force-say.ftl
Resources/Locale/en-US/traits/traits.ftl
Resources/Prototypes/Datasets/damage_force_say.yml [new file with mode: 0644]
Resources/Prototypes/Traits/disabilities.yml

index c10c33a99020cbae949f400b3cda62510a0e4ff8..9d9dd30911648aa00eed31187e54eb16c558dbb2 100644 (file)
@@ -3,6 +3,7 @@ using Content.Shared.FixedPoint;
 using Content.Shared.Mobs;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Mobs.Systems;
+using Content.Shared.Traits.Assorted;
 using JetBrains.Annotations;
 using Robust.Client.Graphics;
 using Robust.Client.Player;
@@ -94,7 +95,11 @@ public sealed class DamageOverlayUiController : UIController
         {
             case MobState.Alive:
             {
-                if (damageable.DamagePerGroup.TryGetValue("Brute", out var bruteDamage))
+                if (EntityManager.HasComponent<PainNumbnessComponent>(entity))
+                {
+                    _overlay.BruteLevel = 0;
+                }
+                else if (damageable.DamagePerGroup.TryGetValue("Brute", out var bruteDamage))
                 {
                     _overlay.BruteLevel = FixedPoint2.Min(1f, bruteDamage / critThreshold).Float();
                 }
index bc61c5d141a8e1bf23e03671f17dac3f4eb25791..8dfe665541c9e921d6cb7126e3bb42949728cd80 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Shared.Bed.Sleep;
 using Content.Shared.Damage;
+using Content.Shared.Damage.Events;
 using Content.Shared.Damage.ForceSay;
 using Content.Shared.FixedPoint;
 using Content.Shared.Mobs;
@@ -47,7 +48,7 @@ public sealed class DamageForceSaySystem : EntitySystem
         }
     }
 
-    private void TryForceSay(EntityUid uid, DamageForceSayComponent component, bool useSuffix=true, string? suffixOverride = null)
+    private void TryForceSay(EntityUid uid, DamageForceSayComponent component, bool useSuffix=true)
     {
         if (!TryComp<ActorComponent>(uid, out var actor))
             return;
@@ -57,7 +58,13 @@ public sealed class DamageForceSaySystem : EntitySystem
             _timing.CurTime < component.NextAllowedTime)
             return;
 
-        var suffix = Loc.GetString(suffixOverride ?? component.ForceSayStringPrefix + _random.Next(1, component.ForceSayStringCount));
+        var ev = new BeforeForceSayEvent(component.ForceSayStringDataset);
+        RaiseLocalEvent(uid, ev);
+
+        if (!_prototype.TryIndex(ev.Prefix, out var prefixList))
+            return;
+
+        var suffix = Loc.GetString(_random.Pick(prefixList.Values));
 
         // set cooldown & raise event
         component.NextAllowedTime = _timing.CurTime + component.Cooldown;
@@ -80,7 +87,7 @@ public sealed class DamageForceSaySystem : EntitySystem
         if (!args.FellAsleep)
             return;
 
-        TryForceSay(uid, component, true, "damage-force-say-sleep");
+        TryForceSay(uid, component);
         AllowNextSpeech(uid);
     }
 
index cbea0a0516f03dcd88be7ba55b462df46e4942db..dbabb8bb9fda5bff4e7b808f3f39a1c705e00911 100644 (file)
@@ -1,6 +1,8 @@
+using Content.Shared.Dataset;
 using Content.Shared.FixedPoint;
 using Robust.Shared.Audio;
 using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
 
 namespace Content.Shared.Bed.Sleep;
 
@@ -39,4 +41,11 @@ public sealed partial class SleepingComponent : Component
     {
         Params = AudioParams.Default.WithVariation(0.05f)
     };
+
+    /// <summary>
+    ///     The fluent string prefix to use when picking a random suffix
+    ///     This is only active for those who have the sleeping component
+    /// </summary>
+    [DataField]
+    public ProtoId<LocalizedDatasetPrototype> ForceSaySleepDataset = "ForceSaySleepDataset";
 }
index 90e1fd38e862bbee2931b8022fcc0e7081dd2cae..d0c6c753deb58c4fa1f63f64d3371da8e9d3325b 100644 (file)
@@ -1,6 +1,7 @@
 using Content.Shared.Actions;
 using Content.Shared.Buckle.Components;
 using Content.Shared.Damage;
+using Content.Shared.Damage.Events;
 using Content.Shared.Damage.ForceSay;
 using Content.Shared.Emoting;
 using Content.Shared.Examine;
@@ -18,6 +19,7 @@ using Content.Shared.Sound.Components;
 using Content.Shared.Speech;
 using Content.Shared.StatusEffect;
 using Content.Shared.Stunnable;
+using Content.Shared.Traits.Assorted;
 using Content.Shared.Verbs;
 using Robust.Shared.Audio.Systems;
 using Robust.Shared.Prototypes;
@@ -63,6 +65,8 @@ public sealed partial class SleepingSystem : EntitySystem
         SubscribeLocalEvent<ForcedSleepingComponent, ComponentInit>(OnInit);
         SubscribeLocalEvent<SleepingComponent, UnbuckleAttemptEvent>(OnUnbuckleAttempt);
         SubscribeLocalEvent<SleepingComponent, EmoteAttemptEvent>(OnEmoteAttempt);
+
+        SubscribeLocalEvent<SleepingComponent, BeforeForceSayEvent>(OnChangeForceSay, after: new []{typeof(PainNumbnessSystem)});
     }
 
     private void OnUnbuckleAttempt(Entity<SleepingComponent> ent, ref UnbuckleAttemptEvent args)
@@ -317,6 +321,11 @@ public sealed partial class SleepingSystem : EntitySystem
     {
         args.Cancel();
     }
+
+    private void OnChangeForceSay(Entity<SleepingComponent> ent, ref BeforeForceSayEvent args)
+    {
+        args.Prefix = ent.Comp.ForceSaySleepDataset;
+    }
 }
 
 
diff --git a/Content.Shared/Damage/Events/BeforeForceSayEvent.cs b/Content.Shared/Damage/Events/BeforeForceSayEvent.cs
new file mode 100644 (file)
index 0000000..9e35f6c
--- /dev/null
@@ -0,0 +1,14 @@
+using Content.Shared.Dataset;
+using Robust.Shared.Prototypes;
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Damage.Events;
+
+/// <summary>
+///     Event for interrupting and changing the prefix for when an entity is being forced to say something
+/// </summary>
+[Serializable, NetSerializable]
+public sealed class BeforeForceSayEvent(ProtoId<LocalizedDatasetPrototype> prefixDataset) : EntityEventArgs
+{
+    public ProtoId<LocalizedDatasetPrototype> Prefix = prefixDataset;
+}
index 163cc7cbf4ccb33db9b07155524b12d2fecb67da..e184f4beb97c8db900d1ee8c1a5d2ca197ab67df 100644 (file)
@@ -1,8 +1,8 @@
 using Content.Shared.Damage.Prototypes;
+using Content.Shared.Dataset;
 using Content.Shared.FixedPoint;
 using Robust.Shared.GameStates;
 using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
 
 namespace Content.Shared.Damage.ForceSay;
 
@@ -30,14 +30,7 @@ public sealed partial class DamageForceSayComponent : Component
     ///     The fluent string prefix to use when picking a random suffix
     /// </summary>
     [DataField]
-    public string ForceSayStringPrefix = "damage-force-say-";
-
-    /// <summary>
-    ///     The number of suffixes that exist for use with <see cref="ForceSayStringPrefix"/>.
-    ///     i.e. (prefix)-1 through (prefix)-(count)
-    /// </summary>
-    [DataField]
-    public int ForceSayStringCount = 7;
+    public ProtoId<LocalizedDatasetPrototype> ForceSayStringDataset = "ForceSayStringDataset";
 
     /// <summary>
     ///     The amount of total damage between <see cref="ValidDamageGroups"/> that needs to be taken before
diff --git a/Content.Shared/Mobs/Events/BeforeAlertSeverityCheckEvent.cs b/Content.Shared/Mobs/Events/BeforeAlertSeverityCheckEvent.cs
new file mode 100644 (file)
index 0000000..e729314
--- /dev/null
@@ -0,0 +1,16 @@
+using Content.Shared.Alert;
+using Robust.Shared.Prototypes;
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Mobs.Events;
+
+/// <summary>
+///     Event for allowing the interrupting and change of the mob threshold severity alert
+/// </summary>
+[Serializable, NetSerializable]
+public sealed class BeforeAlertSeverityCheckEvent(ProtoId<AlertPrototype> currentAlert, short severity) : EntityEventArgs
+{
+    public bool CancelUpdate = false;
+    public ProtoId<AlertPrototype> CurrentAlert = currentAlert;
+    public short Severity = severity;
+}
index eeaecc24d800b6bb023d2c23b0f0a3bde57b8583..a059c18dd8f40358bd3483b221d8348678e37ff3 100644 (file)
@@ -4,6 +4,7 @@ using Content.Shared.Alert;
 using Content.Shared.Damage;
 using Content.Shared.FixedPoint;
 using Content.Shared.Mobs.Components;
+using Content.Shared.Mobs.Events;
 using Robust.Shared.GameStates;
 
 namespace Content.Shared.Mobs.Systems;
@@ -391,6 +392,16 @@ public sealed class MobThresholdSystem : EntitySystem
         if (alertPrototype.SupportsSeverity)
         {
             var severity = _alerts.GetMinSeverity(currentAlert);
+
+            var ev = new BeforeAlertSeverityCheckEvent(currentAlert, severity);
+            RaiseLocalEvent(target, ev);
+
+            if (ev.CancelUpdate)
+            {
+                _alerts.ShowAlert(target, ev.CurrentAlert, ev.Severity);
+                return;
+            }
+
             if (TryGetNextState(target, currentMobState, out var nextState, threshold) &&
                 TryGetPercentageForState(target, nextState.Value, damageable.TotalDamage, out var percentage))
             {
diff --git a/Content.Shared/Traits/Assorted/PainNumbnessComponent.cs b/Content.Shared/Traits/Assorted/PainNumbnessComponent.cs
new file mode 100644 (file)
index 0000000..9ae72c6
--- /dev/null
@@ -0,0 +1,16 @@
+using Content.Shared.Dataset;
+using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
+
+namespace Content.Shared.Traits.Assorted;
+
+[RegisterComponent, NetworkedComponent]
+public sealed partial class PainNumbnessComponent : Component
+{
+    /// <summary>
+    ///     The fluent string prefix to use when picking a random suffix
+    ///     This is only active for those who have the pain numbness component
+    /// </summary>
+    [DataField]
+    public ProtoId<LocalizedDatasetPrototype> ForceSayNumbDataset = "ForceSayNumbDataset";
+}
diff --git a/Content.Shared/Traits/Assorted/PainNumbnessSystem.cs b/Content.Shared/Traits/Assorted/PainNumbnessSystem.cs
new file mode 100644 (file)
index 0000000..3ded133
--- /dev/null
@@ -0,0 +1,46 @@
+using Content.Shared.Damage.Events;
+using Content.Shared.Mobs.Components;
+using Content.Shared.Mobs.Events;
+using Content.Shared.Mobs.Systems;
+
+namespace Content.Shared.Traits.Assorted;
+
+public sealed class PainNumbnessSystem : EntitySystem
+{
+    [Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
+
+    public override void Initialize()
+    {
+        SubscribeLocalEvent<PainNumbnessComponent, ComponentInit>(OnComponentInit);
+        SubscribeLocalEvent<PainNumbnessComponent, ComponentRemove>(OnComponentRemove);
+        SubscribeLocalEvent<PainNumbnessComponent, BeforeForceSayEvent>(OnChangeForceSay);
+        SubscribeLocalEvent<PainNumbnessComponent, BeforeAlertSeverityCheckEvent>(OnAlertSeverityCheck);
+    }
+
+    private void OnComponentRemove(EntityUid uid, PainNumbnessComponent component, ComponentRemove args)
+    {
+        if (!HasComp<MobThresholdsComponent>(uid))
+            return;
+
+        _mobThresholdSystem.VerifyThresholds(uid);
+    }
+
+    private void OnComponentInit(EntityUid uid, PainNumbnessComponent component, ComponentInit args)
+    {
+        if (!HasComp<MobThresholdsComponent>(uid))
+            return;
+
+        _mobThresholdSystem.VerifyThresholds(uid);
+    }
+
+    private void OnChangeForceSay(Entity<PainNumbnessComponent> ent, ref BeforeForceSayEvent args)
+    {
+        args.Prefix = ent.Comp.ForceSayNumbDataset;
+    }
+
+    private void OnAlertSeverityCheck(Entity<PainNumbnessComponent> ent, ref BeforeAlertSeverityCheckEvent args)
+    {
+        if (args.CurrentAlert == "HumanHealth")
+            args.CancelUpdate = true;
+    }
+}
index a436035114570f82a14529395ef216e18d672b2f..83934a181e02b9c42a46f8ebfe1995c53dd4f7bc 100644 (file)
@@ -9,4 +9,10 @@ damage-force-say-5 = OW!
 damage-force-say-6 = URGH!
 damage-force-say-7 = HRNK!
 
-damage-force-say-sleep = zzz...
+damage-force-say-sleep-1 = zzz...
+
+damage-force-say-numb-1 = oh-
+damage-force-say-numb-2 = ow-
+damage-force-say-numb-3 = oof-
+damage-force-say-numb-4 = ah-
+damage-force-say-numb-5 = ugh-
index 7f4dcfe2ecab05ddb8961073b3f81abfa361a710..f4e5736db5d80b445728de853cff95012181953f 100644 (file)
@@ -59,3 +59,6 @@ trait-french-desc = Your accent seems to have a certain «je ne sais quoi».
 
 trait-spanish-name = Spanish accent
 trait-spanish-desc = Hola señor, donde esta la biblioteca.
+
+trait-painnumbness-name = Numb
+trait-painnumbness-desc = You lack any sense of feeling pain, being unaware of how hurt you may be.
diff --git a/Resources/Prototypes/Datasets/damage_force_say.yml b/Resources/Prototypes/Datasets/damage_force_say.yml
new file mode 100644 (file)
index 0000000..a3d2c28
--- /dev/null
@@ -0,0 +1,17 @@
+- type: localizedDataset
+  id: ForceSayStringDataset
+  values:
+    prefix: damage-force-say-
+    count: 7
+
+- type: localizedDataset
+  id: ForceSaySleepDataset
+  values:
+    prefix: damage-force-say-sleep-
+    count: 1
+
+- type: localizedDataset
+  id: ForceSayNumbDataset
+  values:
+    prefix: damage-force-say-numb-
+    count: 5
index c562c2fec0e36a43ee873530f0141f64e33cf45f..b7b3ba1ddc47a329bf7b0d2d2eb7f94d3ae5465d 100644 (file)
       maxSoundDistance: 7
       sounds:
         collection: Paracusia
+
+- type: trait
+  id: PainNumbness
+  name: trait-painnumbness-name
+  description: trait-painnumbness-desc
+  category: Disabilities
+  components:
+  - type: PainNumbness