From 6a125b55df70aef54f25640b5a20838b3054e43a Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sun, 13 Aug 2023 23:34:18 -0400 Subject: [PATCH] Fix various IC states not counting as dead (#19049) --- Content.Server/Mind/MindSystem.cs | 17 +++++++++++++++++ .../Conditions/KillPersonCondition.cs | 5 +---- Content.Server/Silicons/Borgs/BorgSystem.cs | 6 ++++++ Content.Server/Zombies/ZombieSystem.cs | 7 +++++++ .../Entities/Objects/Specific/Robotics/mmi.yml | 3 --- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Content.Server/Mind/MindSystem.cs b/Content.Server/Mind/MindSystem.cs index da004d40cc..d10511ccf6 100644 --- a/Content.Server/Mind/MindSystem.cs +++ b/Content.Server/Mind/MindSystem.cs @@ -650,6 +650,15 @@ public sealed class MindSystem : EntitySystem /// public bool IsCharacterDeadIc(Mind mind) { + if (mind.OwnedEntity is { } owned) + { + var ev = new GetCharactedDeadIcEvent(null); + RaiseLocalEvent(owned, ref ev); + + if (ev.Dead != null) + return ev.Dead.Value; + } + return IsCharacterDeadPhysically(mind); } @@ -665,3 +674,11 @@ public sealed class MindSystem : EntitySystem return "(originally " + mind.OriginalOwnerUserId + ")"; } } + +/// +/// Raised on an entity to determine whether or not they are "dead" in IC-logic. +/// If not handled, then it will simply check if they are dead physically. +/// +/// +[ByRefEvent] +public record struct GetCharactedDeadIcEvent(bool? Dead); diff --git a/Content.Server/Objectives/Conditions/KillPersonCondition.cs b/Content.Server/Objectives/Conditions/KillPersonCondition.cs index 0c243e217a..8543fd9547 100644 --- a/Content.Server/Objectives/Conditions/KillPersonCondition.cs +++ b/Content.Server/Objectives/Conditions/KillPersonCondition.cs @@ -24,15 +24,12 @@ namespace Content.Server.Objectives.Conditions { get { - var targetName = string.Empty; + var targetName = Target?.CharacterName ?? "Unknown"; var jobName = Target?.CurrentJob?.Name ?? "Unknown"; if (Target == null) return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName)); - if (Target.OwnedEntity is {Valid: true} owned) - targetName = EntityManager.GetComponent(owned).EntityName; - return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName)); } } diff --git a/Content.Server/Silicons/Borgs/BorgSystem.cs b/Content.Server/Silicons/Borgs/BorgSystem.cs index 0aef37e62c..afae963862 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.cs @@ -53,6 +53,7 @@ public sealed partial class BorgSystem : SharedBorgSystem SubscribeLocalEvent(OnPowerCellChanged); SubscribeLocalEvent(OnPowerCellSlotEmpty); SubscribeLocalEvent(OnUIOpenAttempt); + SubscribeLocalEvent(OnGetDeadIC); SubscribeLocalEvent(OnBrainMindAdded); @@ -198,6 +199,11 @@ public sealed partial class BorgSystem : SharedBorgSystem args.Cancel(); } + private void OnGetDeadIC(EntityUid uid, BorgChassisComponent component, ref GetCharactedDeadIcEvent args) + { + args.Dead = true; + } + private void OnBrainMindAdded(EntityUid uid, BorgBrainComponent component, MindAddedMessage args) { if (!Container.TryGetOuterContainer(uid, Transform(uid), out var container)) diff --git a/Content.Server/Zombies/ZombieSystem.cs b/Content.Server/Zombies/ZombieSystem.cs index eee9ed2c1e..659bc16414 100644 --- a/Content.Server/Zombies/ZombieSystem.cs +++ b/Content.Server/Zombies/ZombieSystem.cs @@ -7,6 +7,7 @@ using Content.Server.Drone.Components; using Content.Server.Inventory; using Content.Shared.Bed.Sleep; using Content.Server.Emoting.Systems; +using Content.Server.Mind; using Content.Server.Speech.EntitySystems; using Content.Shared.Damage; using Content.Shared.Inventory; @@ -49,6 +50,7 @@ namespace Content.Server.Zombies SubscribeLocalEvent(OnMobState); SubscribeLocalEvent(OnZombieCloning); SubscribeLocalEvent(OnSleepAttempt); + SubscribeLocalEvent(OnGetCharacterDeadIC); SubscribeLocalEvent(OnPendingMapInit); @@ -116,6 +118,11 @@ namespace Content.Server.Zombies args.Cancelled = true; } + private void OnGetCharacterDeadIC(EntityUid uid, ZombieComponent component, ref GetCharactedDeadIcEvent args) + { + args.Dead = true; + } + private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartup args) { if (component.EmoteSoundsId == null) diff --git a/Resources/Prototypes/Entities/Objects/Specific/Robotics/mmi.yml b/Resources/Prototypes/Entities/Objects/Specific/Robotics/mmi.yml index 9dab1513db..9d4985d6a2 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Robotics/mmi.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Robotics/mmi.yml @@ -34,9 +34,6 @@ proto: robot - type: Speech speechSounds: Pai - - type: MobState - allowedStates: - - Alive - type: ItemSlots slots: brain_slot: