]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Do not wake up NPC if there is still a mind attached. (#27651)
authorVasilis <vasilis@pikachu.systems>
Sat, 11 May 2024 15:01:28 +0000 (18:01 +0300)
committerGitHub <noreply@github.com>
Sat, 11 May 2024 15:01:28 +0000 (11:01 -0400)
* Do not wake up NPC if there is still a mind attached.

This became apparent with diona nymphs (?) and slime gyras (?). This caused players that disconnected while a nymph, gyras or other npc to resume their NPC behavior. Which I would call unwanted. This fixes that.

* Zombies become AI anyway

* Update Content.Server/NPC/Systems/NPCSystem.cs

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Content.Server/NPC/Systems/NPCSystem.cs
Content.Server/Zombies/ZombieSystem.Transform.cs

index 910862943502895b7627b6d3ccccef459ac95405..bc21916976e59592b54e1a2fc2e113f213f3cb52 100644 (file)
@@ -2,6 +2,8 @@ using System.Diagnostics.CodeAnalysis;
 using Content.Server.NPC.Components;
 using Content.Server.NPC.HTN;
 using Content.Shared.CCVar;
+using Content.Shared.Mind;
+using Content.Shared.Mind.Components;
 using Content.Shared.Mobs;
 using Content.Shared.Mobs.Systems;
 using Content.Shared.NPC;
@@ -49,6 +51,10 @@ namespace Content.Server.NPC.Systems
             if (_mobState.IsIncapacitated(uid) || TerminatingOrDeleted(uid))
                 return;
 
+            // This NPC has an attached mind, so it should not wake up.
+            if (TryComp<MindContainerComponent>(uid, out var mindContainer) && mindContainer.HasMind)
+                return;
+
             WakeNPC(uid, component);
         }
 
index 23e1c2bb92092c50e24daf51ca82812a7b0e642e..a2c13ed71c1fc05c74756fed32b0974f6697bcce 100644 (file)
@@ -79,7 +79,7 @@ namespace Content.Server.Zombies
         /// <param name="target">the entity being zombified</param>
         /// <param name="mobState"></param>
         /// <remarks>
-        ///     ALRIGHT BIG BOY. YOU'VE COME TO THE LAYER OF THE BEAST. THIS IS YOUR WARNING.
+        ///     ALRIGHT BIG BOYS, GIRLS AND ANYONE ELSE. YOU'VE COME TO THE LAYER OF THE BEAST. THIS IS YOUR WARNING.
         ///     This function is the god function for zombie stuff, and it is cursed. I have
         ///     attempted to label everything thouroughly for your sanity. I have attempted to
         ///     rewrite this, but this is how it shall lie eternal. Turn back now.
@@ -226,6 +226,11 @@ namespace Content.Server.Zombies
 
             _identity.QueueIdentityUpdate(target);
 
+            var htn = EnsureComp<HTNComponent>(target);
+            htn.RootTask = new HTNCompoundTask() { Task = "SimpleHostileCompound" };
+            htn.Blackboard.SetValue(NPCBlackboard.Owner, target);
+            _npc.SleepNPC(target, htn);
+
             //He's gotta have a mind
             var hasMind = _mind.TryGetMind(target, out var mindId, out _);
             if (hasMind && _mind.TryGetSession(mindId, out var session))
@@ -241,9 +246,6 @@ namespace Content.Server.Zombies
             }
             else
             {
-                var htn = EnsureComp<HTNComponent>(target);
-                htn.RootTask = new HTNCompoundTask() { Task = "SimpleHostileCompound" };
-                htn.Blackboard.SetValue(NPCBlackboard.Owner, target);
                 _npc.WakeNPC(target, htn);
             }