]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cyborg health alert and damage examining (#20084)
authorDoru991 <75124791+Doru991@users.noreply.github.com>
Fri, 15 Sep 2023 03:14:47 +0000 (06:14 +0300)
committerGitHub <noreply@github.com>
Fri, 15 Sep 2023 03:14:47 +0000 (23:14 -0400)
* Option for alt health alert and no overlay

* Fancy borg health indicator

* Borg damage examine localization

* EENENGHHHH ENNNGHHH

* Requested code changes

* Legal sound

* Revert "Legal sound"

This reverts commit 35715c88898aeb78dfe800319852c230395fdd7e.

I misunderstood what Sloth meant

* Annoying buzzer is back

15 files changed:
Content.Client/UserInterface/Systems/DamageOverlays/DamageOverlayUiController.cs
Content.Shared/Alert/AlertType.cs
Content.Shared/Mobs/Components/MobThresholdsComponent.cs
Content.Shared/Mobs/Systems/MobThresholdSystem.cs
Resources/Audio/Machines/attributions.yml
Resources/Audio/Machines/warning_buzzer.ogg [new file with mode: 0644]
Resources/Locale/en-US/health-examinable/health-examinable-silicon.ftl [new file with mode: 0644]
Resources/Prototypes/Alerts/alerts.yml
Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml
Resources/Textures/Interface/Alerts/borg_alive.rsi/health0.png [new file with mode: 0644]
Resources/Textures/Interface/Alerts/borg_alive.rsi/health1.png [new file with mode: 0644]
Resources/Textures/Interface/Alerts/borg_alive.rsi/health2.png [new file with mode: 0644]
Resources/Textures/Interface/Alerts/borg_alive.rsi/health3.png [new file with mode: 0644]
Resources/Textures/Interface/Alerts/borg_alive.rsi/health4.png [new file with mode: 0644]
Resources/Textures/Interface/Alerts/borg_alive.rsi/meta.json [new file with mode: 0644]

index 4a5731a528617824cfed57bf60d64c0b25b121dd..0836314dbc46a18ef5385628b2ddbe796076fdf6 100644 (file)
@@ -1,4 +1,4 @@
-using Content.Client.Alerts;
+using Content.Client.Alerts;
 using Content.Shared.Damage;
 using Content.Shared.FixedPoint;
 using Content.Shared.Mobs;
@@ -79,9 +79,15 @@ public sealed class DamageOverlayUiController : UIController
             damageable == null && !EntityManager.TryGetComponent(entity, out  damageable))
             return;
 
-
         if (!_mobThresholdSystem.TryGetIncapThreshold(entity, out var foundThreshold, thresholds))
             return; //this entity cannot die or crit!!
+
+        if (!thresholds.ShowOverlays)
+        {
+            ClearOverlay();
+            return; //this entity intentionally has no overlays
+        }
+
         var critThreshold = foundThreshold.Value;
         _overlay.State = mobState.CurrentState;
 
index 8ba35ae282a98e31349990ac23d263e169644a10..e0a7ac99f85ee65b43db5bdad378b5702b357b8b 100644 (file)
@@ -48,7 +48,8 @@ namespace Content.Shared.Alert
         Debug4,
         Debug5,
         Debug6,
-        SuitPower
+        SuitPower,
+        BorgHealth
     }
 
 }
index 49481787d4f783271389b9c92979aacba2ceb894..e97d3672a2153480a013a4c067a8c17eb2a08c34 100644 (file)
@@ -1,4 +1,5 @@
-using Content.Shared.FixedPoint;
+using Content.Shared.Alert;
+using Content.Shared.FixedPoint;
 using Content.Shared.Mobs.Systems;
 using Robust.Shared.GameStates;
 using Robust.Shared.Serialization;
@@ -9,7 +10,7 @@ namespace Content.Shared.Mobs.Components;
 [Access(typeof(MobThresholdSystem))]
 public sealed partial class MobThresholdsComponent : Component
 {
-    [DataField("thresholds", required:true)]
+    [DataField("thresholds", required: true)]
     public SortedDictionary<FixedPoint2, MobState> Thresholds = new();
 
     [DataField("triggersAlerts")]
@@ -18,6 +19,24 @@ public sealed partial class MobThresholdsComponent : Component
     [DataField("currentThresholdState")]
     public MobState CurrentThresholdState;
 
+    /// <summary>
+    /// The health alert that should be displayed for player controlled entities.
+    /// Used for alternate health alerts (silicons, for example)
+    /// </summary>
+    [DataField("stateAlertDict")]
+    public Dictionary<MobState, AlertType> StateAlertDict = new()
+    {
+        {MobState.Alive, AlertType.HumanHealth},
+        {MobState.Critical, AlertType.HumanCrit},
+        {MobState.Dead, AlertType.HumanDead},
+    };
+
+    /// <summary>
+    /// Whether or not this entity should display damage overlays (robots don't feel pain, black out etc.)
+    /// </summary>
+    [DataField("showOverlays")]
+    public bool ShowOverlays = true;
+
     /// <summary>
     /// Whether or not this entity can be revived out of a dead state.
     /// </summary>
@@ -34,13 +53,25 @@ public sealed class MobThresholdsComponentState : ComponentState
 
     public MobState CurrentThresholdState;
 
+    public Dictionary<MobState, AlertType> StateAlertDict = new()
+    {
+        {MobState.Alive, AlertType.HumanHealth},
+        {MobState.Critical, AlertType.HumanCrit},
+        {MobState.Dead, AlertType.HumanDead},
+    };
+
+    public bool ShowOverlays;
+
     public bool AllowRevives;
 
-    public MobThresholdsComponentState(Dictionary<FixedPoint2, MobState> unsortedThresholds, bool triggersAlerts, MobState currentThresholdState, bool allowRevives)
+    public MobThresholdsComponentState(Dictionary<FixedPoint2, MobState> unsortedThresholds, bool triggersAlerts, MobState currentThresholdState,
+        Dictionary<MobState, AlertType> stateAlertDict, bool showOverlays, bool allowRevives)
     {
         UnsortedThresholds = unsortedThresholds;
         TriggersAlerts = triggersAlerts;
         CurrentThresholdState = currentThresholdState;
+        StateAlertDict = stateAlertDict;
+        ShowOverlays = showOverlays;
         AllowRevives = allowRevives;
     }
 }
index 93e89c32b86fc55bf8c93a59c12df702b8651df7..1cb32543ebbd212173f7be694660d6c63931ee7c 100644 (file)
@@ -1,10 +1,11 @@
-using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using Content.Shared.Alert;
 using Content.Shared.Damage;
 using Content.Shared.FixedPoint;
 using Content.Shared.Mobs.Components;
 using Robust.Shared.GameStates;
+using Robust.Shared.Utility;
 
 namespace Content.Shared.Mobs.Systems;
 
@@ -34,6 +35,8 @@ public sealed class MobThresholdSystem : EntitySystem
         args.State = new MobThresholdsComponentState(thresholds,
             component.TriggersAlerts,
             component.CurrentThresholdState,
+            component.StateAlertDict,
+            component.ShowOverlays,
             component.AllowRevives);
     }
 
@@ -341,28 +344,37 @@ public sealed class MobThresholdSystem : EntitySystem
         if (!threshold.TriggersAlerts)
             return;
 
+        var dict = threshold.StateAlertDict;
+        var healthAlert = AlertType.HumanHealth;
+        var critAlert = AlertType.HumanCrit;
+        var deadAlert = AlertType.HumanDead;
+
+        dict.TryGetValue(MobState.Alive, out healthAlert);
+        dict.TryGetValue(MobState.Critical, out critAlert);
+        dict.TryGetValue(MobState.Dead, out deadAlert);
+
         switch (currentMobState)
         {
             case MobState.Alive:
             {
-                var severity = _alerts.GetMinSeverity(AlertType.HumanHealth);
+                var severity = _alerts.GetMinSeverity(healthAlert);
                 if (TryGetIncapPercentage(target, damageable.TotalDamage, out var percentage))
                 {
                     severity = (short) MathF.Floor(percentage.Value.Float() *
-                                                   _alerts.GetSeverityRange(AlertType.HumanHealth));
-                    severity += _alerts.GetMinSeverity(AlertType.HumanHealth);
+                                                   _alerts.GetSeverityRange(healthAlert));
+                    severity += _alerts.GetMinSeverity(healthAlert);
                 }
-                _alerts.ShowAlert(target, AlertType.HumanHealth, severity);
+                _alerts.ShowAlert(target, healthAlert, severity);
                 break;
             }
             case MobState.Critical:
             {
-                _alerts.ShowAlert(target, AlertType.HumanCrit);
+                _alerts.ShowAlert(target, critAlert);
                 break;
             }
             case MobState.Dead:
             {
-                _alerts.ShowAlert(target, AlertType.HumanDead);
+                _alerts.ShowAlert(target, deadAlert);
                 break;
             }
             case MobState.Invalid:
index 53cbc4748c02ccca7b78df18f5b23cd94c94e86a..bbf4ea9ac09f254ebf7fafc106185e86f47ffe63 100644 (file)
@@ -41,4 +41,9 @@
 - files: ["timer.ogg"]
   license: "CC-BY-SA-3.0"
   copyright: "Taken from /tg/station"
-  source: "https://github.com/tgstation/tgstation/blob/d4f678a1772007ff8d7eddd21cf7218c8e07bfc0/sound/items/timer.ogg"
\ No newline at end of file
+  source: "https://github.com/tgstation/tgstation/blob/d4f678a1772007ff8d7eddd21cf7218c8e07bfc0/sound/items/timer.ogg"
+
+- files: ["warning_buzzer.ogg"]
+  license: "CC-BY-SA-3.0"
+  copyright: "Taken from TG station."
+  source: "https://github.com/tgstation/tgstation/blob/d4f678a1772007ff8d7eddd21cf7218c8e07bfc0/sound/machines/warning-buzzer.ogg"
\ No newline at end of file
diff --git a/Resources/Audio/Machines/warning_buzzer.ogg b/Resources/Audio/Machines/warning_buzzer.ogg
new file mode 100644 (file)
index 0000000..55bb179
Binary files /dev/null and b/Resources/Audio/Machines/warning_buzzer.ogg differ
diff --git a/Resources/Locale/en-US/health-examinable/health-examinable-silicon.ftl b/Resources/Locale/en-US/health-examinable/health-examinable-silicon.ftl
new file mode 100644 (file)
index 0000000..03eaf07
--- /dev/null
@@ -0,0 +1,18 @@
+health-examinable-silicon-none = There is no obvious damage to be seen.
+
+health-examinable-silicon-Blunt-25 = [color=red]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } minor dents on { POSS-ADJ($target) } chassis.[/color]
+health-examinable-silicon-Blunt-50 = [color=crimson]{ CAPITALIZE(POSS-ADJ($target)) } chassis is severely dented![/color]
+health-examinable-silicon-Blunt-75 = [color=crimson]{ CAPITALIZE(POSS-ADJ($target)) } chassis is almost completely caved in![/color]
+
+health-examinable-silicon-Slash-10 = [color=red]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } some minor scratches.[/color]
+health-examinable-silicon-Slash-25 = [color=red]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } significant scratches on { POSS-ADJ($target) } chassis.[/color]
+health-examinable-silicon-Slash-50 = [color=crimson]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } major gashes across { POSS-ADJ($target) } plating![/color]
+health-examinable-silicon-Slash-75 = [color=crimson]{ CAPITALIZE(POSS-ADJ($target)) } chassis is torn up![/color]
+
+health-examinable-silicon-Piercing-50 = [color=crimson]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } large holes all over { POSS-ADJ($target) } chassis![/color]
+
+health-examinable-silicon-Heat-25 = [color=orange]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } superficial burns across { POSS-ADJ($target) } chassis.[/color]
+health-examinable-silicon-Heat-50 = [color=orange]{ CAPITALIZE(POSS-ADJ($target)) } chassis is significantly charred.[/color]
+health-examinable-silicon-Heat-75 = [color=orange]{ CAPITALIZE(POSS-ADJ($target)) } chassis is partially melted![/color]
+
+health-examinable-silicon-Shock-50 = [color=lightgoldenrodyellow]{ CAPITALIZE(POSS-ADJ($target)) } circuits seem partially fried![/color]
index ce6b2d05100f6186f7418336a98a81a897f97160..e71a8ed38190ea78f9d6ed0c4201274465336b3a 100644 (file)
   minSeverity: 0
   maxSeverity: 4
 
+- type: alert
+  id: BorgHealth
+  category: Health
+  icons:
+  - sprite: /Textures/Interface/Alerts/borg_alive.rsi
+    state: health0
+  - sprite: /Textures/Interface/Alerts/borg_alive.rsi
+    state: health1
+  - sprite: /Textures/Interface/Alerts/borg_alive.rsi
+    state: health2
+  - sprite: /Textures/Interface/Alerts/borg_alive.rsi
+    state: health3
+  - sprite: /Textures/Interface/Alerts/borg_alive.rsi
+    state: health4
+  name: alerts-health-name
+  description: alerts-health-desc
+  minSeverity: 0
+  maxSeverity: 4
+
 - type: alert
   id: BorgBattery
   category: Battery
index fb58b5a644d8a2a7056447b37eb6d7e1b4c1ace3..25e4271b1065295a76e916b906547a3755a36f11 100644 (file)
   - type: MobThresholds
     thresholds:
       0: Alive
+      100: Dead
+    stateAlertDict:
+      Alive: BorgHealth
+    showOverlays: false
+  - type: HealthExaminable
+    examinableTypes:
+      - Blunt
+      - Slash
+      - Piercing
+      - Heat
+      - Shock
+    locPrefix: silicon
   - type: UserInterface
     interfaces:
     - key: enum.SiliconLawsUiKey.Key
     damageContainer: Inorganic
   - type: Destructible
     thresholds:
+    - trigger:
+        !type:DamageTrigger
+        damage: 50
+      behaviors:
+      - !type:PlaySoundBehavior
+        sound:
+          path: /Audio/Machines/warning_buzzer.ogg
+          params:
+            volume: 5
     - trigger:
         !type:DamageTrigger
         damage: 100
diff --git a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health0.png b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health0.png
new file mode 100644 (file)
index 0000000..b94d636
Binary files /dev/null and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health0.png differ
diff --git a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health1.png b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health1.png
new file mode 100644 (file)
index 0000000..c58c73f
Binary files /dev/null and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health1.png differ
diff --git a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health2.png b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health2.png
new file mode 100644 (file)
index 0000000..2447ba0
Binary files /dev/null and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health2.png differ
diff --git a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health3.png b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health3.png
new file mode 100644 (file)
index 0000000..fd4e7cc
Binary files /dev/null and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health3.png differ
diff --git a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health4.png b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health4.png
new file mode 100644 (file)
index 0000000..449d442
Binary files /dev/null and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health4.png differ
diff --git a/Resources/Textures/Interface/Alerts/borg_alive.rsi/meta.json b/Resources/Textures/Interface/Alerts/borg_alive.rsi/meta.json
new file mode 100644 (file)
index 0000000..048a7bb
--- /dev/null
@@ -0,0 +1,26 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "Original from https://github.com/tgstation/tgstation/blob/42ebbb4202b472cf94561974a30e00a0b00e11bc/icons/mob/screen1_robot.dmi, edited by @Doru991",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "health0"
+    },
+    {
+      "name": "health1"
+    },
+    {
+      "name": "health2"
+    },
+    {
+      "name": "health3"
+    },
+    {
+      "name": "health4"
+    }
+  ]
+}