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 Robust.Client.GameObjects;
using Robust.Shared.Containers;
@@ -22,7 +23,7 @@ public sealed class BorgSystem : SharedBorgSystem
{
if (args.Sprite == null)
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)
@@ -31,7 +32,7 @@ public sealed class BorgSystem : SharedBorgSystem
return;
base.OnInserted(uid, component, args);
UpdateBorgAppearnce(uid, component);
UpdateBorgAppearance(uid, component);
}
protected override void OnRemoved(EntityUid uid, BorgChassisComponent component, EntRemovedFromContainerMessage args)
@@ -40,10 +41,10 @@ public sealed class BorgSystem : SharedBorgSystem
return;
base.OnRemoved(uid, component, args);
UpdateBorgAppearnce(uid, component);
UpdateBorgAppearance(uid, component);
}
private void UpdateBorgAppearnce(EntityUid uid,
private void UpdateBorgAppearance(EntityUid uid,
BorgChassisComponent? component = null,
AppearanceComponent? appearance = null,
SpriteComponent? sprite = null)
@@ -51,6 +52,15 @@ public sealed class BorgSystem : SharedBorgSystem
if (!Resolve(uid, ref component, ref appearance, ref sprite))
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))
hasPlayer = false;

View File

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

View File

@@ -11,6 +11,8 @@ using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Systems;
using Content.Shared.PowerCell;
using Content.Shared.PowerCell.Components;
@@ -39,6 +41,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
@@ -56,6 +59,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
SubscribeLocalEvent<BorgChassisComponent, AfterInteractUsingEvent>(OnChassisInteractUsing);
SubscribeLocalEvent<BorgChassisComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<BorgChassisComponent, MindRemovedMessage>(OnMindRemoved);
SubscribeLocalEvent<BorgChassisComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged);
SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
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 (!CanPlayerBeBorgged(mind.Session))
if (!CanPlayerBeBorged(mind.Session))
{
Popup.PopupEntity(Loc.GetString("borg-player-not-allowed"), used, args.User);
return;
@@ -154,6 +158,19 @@ public sealed partial class BorgSystem : SharedBorgSystem
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)
{
UpdateBatteryAlert(uid);
@@ -172,7 +189,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
if (_powerCell.HasDrawCharge(uid, draw))
{
// 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);
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)
return;
if (!CanPlayerBeBorgged(mind.Session))
if (!CanPlayerBeBorged(mind.Session))
{
Popup.PopupEntity(Loc.GetString("borg-player-not-allowed-eject"), uid);
Container.RemoveEntity(containerEnt, uid);
@@ -249,7 +266,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
/// <summary>
/// Activates the borg, enabling all of its modules.
/// </summary>
public void EnableBorgAbilities(EntityUid uid, BorgChassisComponent component)
public void EnableBorgAbilities(EntityUid uid, BorgChassisComponent component, PowerCellDrawComponent? powerCell = null)
{
if (component.Activated)
return;
@@ -302,7 +319,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
/// 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.
/// </summary>
public bool CanPlayerBeBorgged(ICommonSession session)
public bool CanPlayerBeBorged(ICommonSession session)
{
if (_banManager.GetJobBans(session.UserId)?.Contains(BorgJobId) == true)
return false;

View File

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

View File

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

View File

@@ -36,7 +36,8 @@ public partial class MobStateSystem
}
/// <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>
/// <param name="entity">Target Entity we want to change the MobState of</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))
return;
var ev = new UpdateMobStateEvent {Target = entity, Component = component, Origin = origin, State = mobState};
RaiseLocalEvent(entity, ref ev);
ChangeState(entity, component, ev.State);
ChangeState(entity, component, mobState, origin: origin);
}
#endregion

View File

@@ -197,6 +197,24 @@
minSeverity: 0
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
id: BorgBattery
category: Battery

View File

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