Fix borg mobstates (#21307)

* Add dead states to borgs

* this?

* ack
This commit is contained in:
Nemanja
2023-11-09 18:14:06 -05:00
committed by GitHub
parent 4de0cf66d7
commit ac5e9cd70b
17 changed files with 107 additions and 36 deletions

View File

@@ -1,4 +1,5 @@
using Content.Shared.Silicons.Borgs; using Content.Shared.Mobs;
using Content.Shared.Silicons.Borgs;
using Content.Shared.Silicons.Borgs.Components; using Content.Shared.Silicons.Borgs.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -22,7 +23,7 @@ public sealed class BorgSystem : SharedBorgSystem
{ {
if (args.Sprite == null) if (args.Sprite == null)
return; return;
UpdateBorgAppearnce(uid, component, args.Component, args.Sprite); UpdateBorgAppearance(uid, component, args.Component, args.Sprite);
} }
protected override void OnInserted(EntityUid uid, BorgChassisComponent component, EntInsertedIntoContainerMessage args) protected override void OnInserted(EntityUid uid, BorgChassisComponent component, EntInsertedIntoContainerMessage args)
@@ -31,7 +32,7 @@ public sealed class BorgSystem : SharedBorgSystem
return; return;
base.OnInserted(uid, component, args); base.OnInserted(uid, component, args);
UpdateBorgAppearnce(uid, component); UpdateBorgAppearance(uid, component);
} }
protected override void OnRemoved(EntityUid uid, BorgChassisComponent component, EntRemovedFromContainerMessage args) protected override void OnRemoved(EntityUid uid, BorgChassisComponent component, EntRemovedFromContainerMessage args)
@@ -40,10 +41,10 @@ public sealed class BorgSystem : SharedBorgSystem
return; return;
base.OnRemoved(uid, component, args); base.OnRemoved(uid, component, args);
UpdateBorgAppearnce(uid, component); UpdateBorgAppearance(uid, component);
} }
private void UpdateBorgAppearnce(EntityUid uid, private void UpdateBorgAppearance(EntityUid uid,
BorgChassisComponent? component = null, BorgChassisComponent? component = null,
AppearanceComponent? appearance = null, AppearanceComponent? appearance = null,
SpriteComponent? sprite = null) SpriteComponent? sprite = null)
@@ -51,6 +52,15 @@ public sealed class BorgSystem : SharedBorgSystem
if (!Resolve(uid, ref component, ref appearance, ref sprite)) if (!Resolve(uid, ref component, ref appearance, ref sprite))
return; return;
if (_appearance.TryGetData<MobState>(uid, MobStateVisuals.State, out var state, appearance))
{
if (state != MobState.Alive)
{
sprite.LayerSetVisible(BorgVisualLayers.Light, false);
return;
}
}
if (!_appearance.TryGetData<bool>(uid, BorgVisuals.HasPlayer, out var hasPlayer, appearance)) if (!_appearance.TryGetData<bool>(uid, BorgVisuals.HasPlayer, out var hasPlayer, appearance))
hasPlayer = false; hasPlayer = false;

View File

@@ -218,11 +218,9 @@ public sealed class DefibrillatorSystem : EntitySystem
} }
else else
{ {
_mobThreshold.SetAllowRevives(target, true, thresholds);
if (_mobState.IsDead(target, mob)) if (_mobState.IsDead(target, mob))
_damageable.TryChangeDamage(target, component.ZapHeal, true, origin: uid); _damageable.TryChangeDamage(target, component.ZapHeal, true, origin: uid);
_mobState.ChangeMobState(target, MobState.Critical, mob, uid); _mobState.ChangeMobState(target, MobState.Critical, mob, uid);
_mobThreshold.SetAllowRevives(target, false, thresholds);
if (_mind.TryGetMind(target, out var mindId, out var mind) && if (_mind.TryGetMind(target, out var mindId, out var mind) &&
mind.Session is { } playerSession) mind.Session is { } playerSession)

View File

@@ -11,6 +11,8 @@ using Content.Shared.IdentityManagement;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Mind; using Content.Shared.Mind;
using Content.Shared.Mind.Components; using Content.Shared.Mind.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
using Content.Shared.PowerCell; using Content.Shared.PowerCell;
using Content.Shared.PowerCell.Components; using Content.Shared.PowerCell.Components;
@@ -39,6 +41,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
[Dependency] private readonly HandsSystem _hands = default!; [Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!; [Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly SharedMindSystem _mind = default!; [Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!; [Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly ThrowingSystem _throwing = default!;
@@ -56,6 +59,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
SubscribeLocalEvent<BorgChassisComponent, AfterInteractUsingEvent>(OnChassisInteractUsing); SubscribeLocalEvent<BorgChassisComponent, AfterInteractUsingEvent>(OnChassisInteractUsing);
SubscribeLocalEvent<BorgChassisComponent, MindAddedMessage>(OnMindAdded); SubscribeLocalEvent<BorgChassisComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<BorgChassisComponent, MindRemovedMessage>(OnMindRemoved); SubscribeLocalEvent<BorgChassisComponent, MindRemovedMessage>(OnMindRemoved);
SubscribeLocalEvent<BorgChassisComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged); SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged);
SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty); SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
SubscribeLocalEvent<BorgChassisComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt); SubscribeLocalEvent<BorgChassisComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
@@ -98,7 +102,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
{ {
if (_mind.TryGetMind(used, out _, out var mind) && mind.Session != null) if (_mind.TryGetMind(used, out _, out var mind) && mind.Session != null)
{ {
if (!CanPlayerBeBorgged(mind.Session)) if (!CanPlayerBeBorged(mind.Session))
{ {
Popup.PopupEntity(Loc.GetString("borg-player-not-allowed"), used, args.User); Popup.PopupEntity(Loc.GetString("borg-player-not-allowed"), used, args.User);
return; return;
@@ -154,6 +158,19 @@ public sealed partial class BorgSystem : SharedBorgSystem
BorgDeactivate(uid, component); BorgDeactivate(uid, component);
} }
private void OnMobStateChanged(EntityUid uid, BorgChassisComponent component, MobStateChangedEvent args)
{
if (args.NewMobState == MobState.Alive)
{
if (_mind.TryGetMind(uid, out _, out _))
_powerCell.SetPowerCellDrawEnabled(uid, true);
}
else
{
_powerCell.SetPowerCellDrawEnabled(uid, false);
}
}
private void OnPowerCellChanged(EntityUid uid, BorgChassisComponent component, PowerCellChangedEvent args) private void OnPowerCellChanged(EntityUid uid, BorgChassisComponent component, PowerCellChangedEvent args)
{ {
UpdateBatteryAlert(uid); UpdateBatteryAlert(uid);
@@ -172,7 +189,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
if (_powerCell.HasDrawCharge(uid, draw)) if (_powerCell.HasDrawCharge(uid, draw))
{ {
// only reenable the powerdraw if a player has the role. // only reenable the powerdraw if a player has the role.
if (!draw.Drawing && _mind.TryGetMind(uid, out _, out _)) if (!draw.Drawing && _mind.TryGetMind(uid, out _, out _) && _mobState.IsAlive(uid))
_powerCell.SetPowerCellDrawEnabled(uid, true); _powerCell.SetPowerCellDrawEnabled(uid, true);
EnableBorgAbilities(uid, component); EnableBorgAbilities(uid, component);
@@ -213,7 +230,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
if (!_mind.TryGetMind(uid, out var mindId, out var mind) || mind.Session == null) if (!_mind.TryGetMind(uid, out var mindId, out var mind) || mind.Session == null)
return; return;
if (!CanPlayerBeBorgged(mind.Session)) if (!CanPlayerBeBorged(mind.Session))
{ {
Popup.PopupEntity(Loc.GetString("borg-player-not-allowed-eject"), uid); Popup.PopupEntity(Loc.GetString("borg-player-not-allowed-eject"), uid);
Container.RemoveEntity(containerEnt, uid); Container.RemoveEntity(containerEnt, uid);
@@ -249,7 +266,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
/// <summary> /// <summary>
/// Activates the borg, enabling all of its modules. /// Activates the borg, enabling all of its modules.
/// </summary> /// </summary>
public void EnableBorgAbilities(EntityUid uid, BorgChassisComponent component) public void EnableBorgAbilities(EntityUid uid, BorgChassisComponent component, PowerCellDrawComponent? powerCell = null)
{ {
if (component.Activated) if (component.Activated)
return; return;
@@ -302,7 +319,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
/// Checks that a player has fulfilled the requirements for the borg job. /// Checks that a player has fulfilled the requirements for the borg job.
/// If they don't have enough hours, they cannot be placed into a chassis. /// If they don't have enough hours, they cannot be placed into a chassis.
/// </summary> /// </summary>
public bool CanPlayerBeBorgged(ICommonSession session) public bool CanPlayerBeBorged(ICommonSession session)
{ {
if (_banManager.GetJobBans(session.UserId)?.Contains(BorgJobId) == true) if (_banManager.GetJobBans(session.UserId)?.Contains(BorgJobId) == true)
return false; return false;

View File

@@ -198,12 +198,10 @@ namespace Content.Server.Zombies
if (TryComp<TemperatureComponent>(target, out var tempComp)) if (TryComp<TemperatureComponent>(target, out var tempComp))
tempComp.ColdDamage.ClampMax(0); tempComp.ColdDamage.ClampMax(0);
_mobThreshold.SetAllowRevives(target, true);
//Heals the zombie from all the damage it took while human //Heals the zombie from all the damage it took while human
if (TryComp<DamageableComponent>(target, out var damageablecomp)) if (TryComp<DamageableComponent>(target, out var damageablecomp))
_damageable.SetAllDamage(target, damageablecomp, 0); _damageable.SetAllDamage(target, damageablecomp, 0);
_mobState.ChangeMobState(target, MobState.Alive); _mobState.ChangeMobState(target, MobState.Alive);
_mobThreshold.SetAllowRevives(target, false);
var factionComp = EnsureComp<NpcFactionMemberComponent>(target); var factionComp = EnsureComp<NpcFactionMemberComponent>(target);
foreach (var id in new List<string>(factionComp.Factions)) foreach (var id in new List<string>(factionComp.Factions))

View File

@@ -49,7 +49,9 @@ namespace Content.Shared.Alert
Debug5, Debug5,
Debug6, Debug6,
SuitPower, SuitPower,
BorgHealth BorgHealth,
BorgCrit,
BorgDead
} }
} }

View File

@@ -36,7 +36,8 @@ public partial class MobStateSystem
} }
/// <summary> /// <summary>
/// Change the MobState and trigger MobState update events /// Change the MobState without triggering UpdateMobState events.
/// WARNING: use this sparingly when you need to override other systems (MobThresholds)
/// </summary> /// </summary>
/// <param name="entity">Target Entity we want to change the MobState of</param> /// <param name="entity">Target Entity we want to change the MobState of</param>
/// <param name="mobState">The new MobState we want to set</param> /// <param name="mobState">The new MobState we want to set</param>
@@ -48,9 +49,7 @@ public partial class MobStateSystem
if (!Resolve(entity, ref component)) if (!Resolve(entity, ref component))
return; return;
var ev = new UpdateMobStateEvent {Target = entity, Component = component, Origin = origin, State = mobState}; ChangeState(entity, component, mobState, origin: origin);
RaiseLocalEvent(entity, ref ev);
ChangeState(entity, component, ev.State);
} }
#endregion #endregion

View File

@@ -197,6 +197,24 @@
minSeverity: 0 minSeverity: 0
maxSeverity: 4 maxSeverity: 4
- type: alert
id: BorgCrit
category: Health
icons:
- sprite: /Textures/Interface/Alerts/borg_critical.rsi
state: critical
name: alerts-crit-name
description: alerts-crit-desc
- type: alert
id: BorgDead
category: Health
icons:
- sprite: /Textures/Interface/Alerts/borg_dead.rsi
state: dead
name: alerts-dead-name
description: alerts-dead-desc
- type: alert - type: alert
id: BorgBattery id: BorgBattery
category: Battery category: Battery

View File

@@ -1,4 +1,5 @@
- type: entity - type: entity
parent: BaseMob
id: BaseBorgChassis id: BaseBorgChassis
name: cyborg name: cyborg
description: A man-machine hybrid that assists in station activity. They love being asked to state their laws over and over. description: A man-machine hybrid that assists in station activity. They love being asked to state their laws over and over.
@@ -8,23 +9,16 @@
- type: Reactive - type: Reactive
groups: groups:
Acidic: [Touch] Acidic: [Touch]
- type: Input
context: "human"
- type: InputMover
- type: DamageOnHighSpeedImpact - type: DamageOnHighSpeedImpact
damage: damage:
types: types:
Blunt: 5 Blunt: 5
soundHit: soundHit:
path: /Audio/Effects/hit_kick.ogg path: /Audio/Effects/hit_kick.ogg
- type: Clickable
- type: CombatMode - type: CombatMode
- type: NoSlip - type: NoSlip
- type: StaticPrice - type: StaticPrice
price: 1250 price: 1250
- type: InteractionOutline
- type: Physics
bodyType: KinematicController
- type: Fixtures - type: Fixtures
fixtures: fixtures:
fix1: fix1:
@@ -41,18 +35,24 @@
baseSprintSpeed : 4.5 baseSprintSpeed : 4.5
- type: Sprite - type: Sprite
sprite: Mobs/Silicon/chassis.rsi sprite: Mobs/Silicon/chassis.rsi
noRot: true - type: RotationVisuals
drawdepth: Mobs horizontalRotation: 90
- type: MobState - type: MobState
allowedStates: allowedStates:
- Alive - Alive
- Critical
- Dead
- type: MobThresholds - type: MobThresholds
thresholds: thresholds:
0: Alive 0: Alive
150: Dead 100: Critical
200: Dead
stateAlertDict: stateAlertDict:
Alive: BorgHealth Alive: BorgHealth
Critical: BorgCrit
Dead: BorgDead
showOverlays: false showOverlays: false
allowRevives: true
- type: HealthExaminable - type: HealthExaminable
examinableTypes: examinableTypes:
- Blunt - Blunt
@@ -113,15 +113,12 @@
slots: slots:
cell_slot: cell_slot:
name: power-cell-slot-component-slot-name-default name: power-cell-slot-component-slot-name-default
- type: DoAfter
- type: Eye
- type: Body - type: Body
- type: StatusEffects - type: StatusEffects
allowed: allowed:
- Stun - Stun
- KnockedDown - KnockedDown
- SlowedDown - SlowedDown
- type: Actions
- type: TypingIndicator - type: TypingIndicator
proto: robot proto: robot
- type: Speech - type: Speech
@@ -148,7 +145,7 @@
volume: 5 volume: 5
- trigger: - trigger:
!type:DamageTrigger !type:DamageTrigger
damage: 150 damage: 300
behaviors: behaviors:
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: /Audio/Effects/metalbreak.ogg sound: /Audio/Effects/metalbreak.ogg
@@ -190,10 +187,7 @@
- type: Pullable - type: Pullable
- type: Puller - type: Puller
needsHands: false needsHands: false
- type: Examiner
- type: Appearance
- type: StandingState - type: StandingState
- type: Alerts
- type: Tag - type: Tag
tags: tags:
- ShoesRequiredStepTriggerImmune - ShoesRequiredStepTriggerImmune

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -0,0 +1,21 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/tgstation/tgstation/blob/42ebbb4202b472cf94561974a30e00a0b00e11bc/icons/mob/screen1_robot.dmi",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "critical",
"delays": [
[
0.1,
0.1,
0.1
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

View File

@@ -0,0 +1,14 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/tgstation/tgstation/blob/42ebbb4202b472cf94561974a30e00a0b00e11bc/icons/mob/screen1_robot.dmi",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "dead"
}
]
}