Cyborg health alert and damage examining (#20084)

* 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
This commit is contained in:
Doru991
2023-09-15 06:14:47 +03:00
committed by GitHub
parent c25b769132
commit eaecdb4336
15 changed files with 153 additions and 14 deletions

View 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;

View File

@@ -48,7 +48,8 @@ namespace Content.Shared.Alert
Debug4,
Debug5,
Debug6,
SuitPower
SuitPower,
BorgHealth
}
}

View 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;
}
}

View 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:

View File

@@ -42,3 +42,8 @@
license: "CC-BY-SA-3.0"
copyright: "Taken from /tg/station"
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"

Binary file not shown.

View File

@@ -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]

View File

@@ -178,6 +178,25 @@
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

View File

@@ -48,6 +48,18 @@
- 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
@@ -124,6 +136,15 @@
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

View File

@@ -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"
}
]
}