]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix brains, borgs etc not counting as marooned (#37148)
authorScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Tue, 6 May 2025 17:24:26 +0000 (19:24 +0200)
committerGitHub <noreply@github.com>
Tue, 6 May 2025 17:24:26 +0000 (13:24 -0400)
* init

* comments

* comment

* no more debug

Content.Server/Objectives/Systems/KillPersonConditionSystem.cs
Content.Server/Silicons/Borgs/BorgSystem.cs
Content.Server/Zombies/ZombieSystem.cs
Content.Shared/Mind/SharedMindSystem.cs

index 012fb80f76923e07017b22782c3e4a01b7bb72cb..9c8fa0b3350986af5efd19af0e2b4026b3c25b15 100644 (file)
@@ -39,7 +39,7 @@ public sealed class KillPersonConditionSystem : EntitySystem
             return 1f;
 
         var targetDead = _mind.IsCharacterDeadIc(mind);
-        var targetOnShuttle = _emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value);
+        var targetMarooned = !_emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value) || _mind.IsCharacterUnrevivableIc(mind);
         if (!_config.GetCVar(CCVars.EmergencyShuttleEnabled) && requireMaroon)
         {
             requireDead = true;
@@ -55,11 +55,11 @@ public sealed class KillPersonConditionSystem : EntitySystem
 
         // If the shuttle hasn't left, give 50% progress if the target isn't on the shuttle as a "almost there!"
         if (requireMaroon && !_emergencyShuttle.ShuttlesLeft)
-            return targetOnShuttle ? 0f : 0.5f;
+            return targetMarooned ? 0.5f : 0f;
 
         // If the shuttle has already left, and the target isn't on it, 100%
         if (requireMaroon && _emergencyShuttle.ShuttlesLeft)
-            return targetOnShuttle ? 0f : 1f;
+            return targetMarooned ? 1f : 0f;
 
         return 1f; // Good job you did it woohoo
     }
index 82e247cb0b5246c75f4d78372fac32dfbb43c843..7c096f17299a11f898cb87c04d1ea0610da582ff 100644 (file)
@@ -72,6 +72,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
         SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged);
         SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
         SubscribeLocalEvent<BorgChassisComponent, GetCharactedDeadIcEvent>(OnGetDeadIC);
+        SubscribeLocalEvent<BorgChassisComponent, GetCharacterUnrevivableIcEvent>(OnGetUnrevivableIC);
         SubscribeLocalEvent<BorgChassisComponent, ItemToggledEvent>(OnToggled);
 
         SubscribeLocalEvent<BorgBrainComponent, MindAddedMessage>(OnBrainMindAdded);
@@ -218,6 +219,11 @@ public sealed partial class BorgSystem : SharedBorgSystem
         args.Dead = true;
     }
 
+    private void OnGetUnrevivableIC(EntityUid uid, BorgChassisComponent component, ref GetCharacterUnrevivableIcEvent args)
+    {
+        args.Unrevivable = true;
+    }
+
     private void OnToggled(Entity<BorgChassisComponent> ent, ref ItemToggledEvent args)
     {
         var (uid, comp) = ent;
index 054bd0f6ecfba10202107a3d2ccd67e43d2cf5aa..8f8dd36ad4009101a899985323b2bc96df3cfe99 100644 (file)
@@ -66,6 +66,7 @@ namespace Content.Server.Zombies
             SubscribeLocalEvent<ZombieComponent, CloningEvent>(OnZombieCloning);
             SubscribeLocalEvent<ZombieComponent, TryingToSleepEvent>(OnSleepAttempt);
             SubscribeLocalEvent<ZombieComponent, GetCharactedDeadIcEvent>(OnGetCharacterDeadIC);
+            SubscribeLocalEvent<ZombieComponent, GetCharacterUnrevivableIcEvent>(OnGetCharacterUnrevivableIC);
             SubscribeLocalEvent<ZombieComponent, MindAddedMessage>(OnMindAdded);
             SubscribeLocalEvent<ZombieComponent, MindRemovedMessage>(OnMindRemoved);
 
@@ -168,6 +169,11 @@ namespace Content.Server.Zombies
             args.Dead = true;
         }
 
+        private void OnGetCharacterUnrevivableIC(EntityUid uid, ZombieComponent component, ref GetCharacterUnrevivableIcEvent args)
+        {
+            args.Unrevivable = true;
+        }
+
         private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartup args)
         {
             if (component.EmoteSoundsId == null)
index ab17a4221ea7b87ab0e4f8d607b7817e09706fa4..de8d4f0567f278aded89594ac17f4f43d8fc1a30 100644 (file)
@@ -253,6 +253,24 @@ public abstract partial class SharedMindSystem : EntitySystem
         return _mobState.IsDead(mind.OwnedEntity.Value, targetMobState);
     }
 
+    /// <summary>
+    ///     True if the OwnedEntity of this mind is physically unrevivable.
+    ///     This is mainly to check whether a mind is able to inherit their "original" character again without the need for creating a new one.
+    ///     In cases of being a brain, being borged or a zombie they are "unrevivable"
+    /// </summary>
+    public bool IsCharacterUnrevivablePhysically(MindComponent mind)
+    {
+        if (mind.OwnedEntity == null)
+            return true;
+
+        // This entity cannot be dead, alive or crit, so it makes sense it cannot be revived to begin with.
+        if (!HasComp<MobStateComponent>(mind.OwnedEntity))
+            return true;
+
+        // Could use checks for the amount of damage they have, but with chemistry you can never tell what damage means someone is truly "unrevivable".
+        return false;
+    }
+
     public virtual void Visit(EntityUid mindId, EntityUid entity, MindComponent? mind = null)
     {
     }
@@ -556,6 +574,27 @@ public abstract partial class SharedMindSystem : EntitySystem
         return IsCharacterDeadPhysically(mind);
     }
 
+    /// <summary>
+    ///     True if this Mind is 'sufficiently unrevivable' IC (Objectives, EndText).
+    ///     Note that this is *IC logic*, it's not necessarily tied to any specific truth.
+    ///     "If administrators decide that zombies are unrevivable, this returns true for zombies."
+    ///     Alternative IsCharacterDeadIC that checks for whether they will be able to inherit their body again.
+    ///     State in which they must be given a new body to "live" (borging, being a brain, etc) should count as "unrevivable".
+    /// </summary>
+    public bool IsCharacterUnrevivableIc(MindComponent mind)
+    {
+        if (mind.OwnedEntity is { } owned)
+        {
+            var ev = new GetCharacterUnrevivableIcEvent(null);
+            RaiseLocalEvent(owned, ref ev);
+
+            if (ev.Unrevivable != null)
+                return ev.Unrevivable.Value;
+        }
+
+        return IsCharacterUnrevivablePhysically(mind);
+    }
+
     /// <summary>
     ///     A string to represent the mind for logging
     /// </summary>
@@ -602,3 +641,11 @@ public abstract partial class SharedMindSystem : EntitySystem
 /// <param name="Dead"></param>
 [ByRefEvent]
 public record struct GetCharactedDeadIcEvent(bool? Dead);
+
+/// <summary>
+/// Raised on an entity to determine whether or not they are "unrevivable" in IC-logic.
+/// Used to check for things such as being borged or a zombie.
+/// </summary>
+/// <param name="Unrevivable"></param>
+[ByRefEvent]
+public record struct GetCharacterUnrevivableIcEvent(bool? Unrevivable);