]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
missing nukies can be filled in by ghost roles (#28316)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Tue, 28 May 2024 15:35:08 +0000 (15:35 +0000)
committerGitHub <noreply@github.com>
Tue, 28 May 2024 15:35:08 +0000 (11:35 -0400)
Content.Server/Antag/AntagSelectionSystem.cs
Content.Server/Antag/Components/AntagSelectionComponent.cs
Resources/Prototypes/Entities/Markers/Spawners/ghost_roles.yml
Resources/Prototypes/GameRules/roundstart.yml

index a86611bedb399769a3b99b987d4afb98c17f30e9..b42831cbde81e6fed863f02ee1642078f5bc4356 100644 (file)
@@ -205,16 +205,24 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
         var playerPool = GetPlayerPool(ent, pool, def);
         var count = GetTargetAntagCount(ent, GetTotalPlayerCount(pool), def);
 
+        // if there is both a spawner and players getting picked, let it fall back to a spawner.
+        var noSpawner = def.SpawnerPrototype == null;
         for (var i = 0; i < count; i++)
         {
             var session = (ICommonSession?) null;
             if (def.PickPlayer)
             {
-                if (!playerPool.TryPickAndTake(RobustRandom, out session))
+                if (!playerPool.TryPickAndTake(RobustRandom, out session) && noSpawner)
+                {
+                    Log.Warning($"Couldn't pick a player for {ToPrettyString(ent):rule}, no longer choosing antags for this definition");
                     break;
+                }
 
-                if (ent.Comp.SelectedSessions.Contains(session))
+                if (session != null && ent.Comp.SelectedSessions.Contains(session))
+                {
+                    Log.Warning($"Somehow picked {session} for an antag when this rule already selected them previously");
                     continue;
+                }
             }
 
             MakeAntag(ent, session, def);
index 3464ee56662a04fa49d146d7431b16777473bea5..f70c27d12f28e5cbbfed88262bad94b9a4415b09 100644 (file)
@@ -104,6 +104,7 @@ public partial struct AntagSelectionDefinition()
 
     /// <summary>
     /// Whether or not players should be picked to inhabit this antag or not.
+    /// If no players are left and <see cref="SpawnerPrototype"/> is set, it will make a ghost role.
     /// </summary>
     [DataField]
     public bool PickPlayer = true;
index 25d1330d06b95074a5491d1239bf43b2c62e852f..7942d26f3212b68ea4a11c1f0b78bb8071202dcd 100644 (file)
       - sprite: Structures/Wallmounts/signs.rsi
         state: radiation
 
+- type: entity
+  noSpawn: true
+  parent: SpawnPointLoneNukeOperative
+  id: SpawnPointNukeopsCommander
+  components:
+  - type: GhostRole
+    name: roles-antag-nuclear-operative-commander-name
+    description: roles-antag-nuclear-operative-commander-objective
+
+- type: entity
+  noSpawn: true
+  parent: SpawnPointLoneNukeOperative
+  id: SpawnPointNukeopsMedic
+  components:
+  - type: GhostRole
+    name: roles-antag-nuclear-operative-agent-name
+    description: roles-antag-nuclear-operative-agent-objective
+
+- type: entity
+  noSpawn: true
+  parent: SpawnPointLoneNukeOperative
+  id: SpawnPointNukeopsOperative
+  components:
+  - type: GhostRole
+    name: roles-antag-nuclear-operative-name
+    description: roles-antag-nuclear-operative-objective
+
 - type: entity
   parent: MarkerBase
   id: SpawnPointGhostDragon
index 57e59f10e213a8db8e1b43e3b97b81640969f1b1..93350163f68f98b1413b5160613bda2fd10186c8 100644 (file)
@@ -90,8 +90,7 @@
     definitions:
     - prefRoles: [ NukeopsCommander ]
       fallbackRoles: [ Nukeops, NukeopsMedic ]
-      max: 1
-      playerRatio: 10
+      spawnerPrototype: SpawnPointNukeopsCommander
       startingGear: SyndicateCommanderGearFull
       components:
       - type: NukeOperative
         prototype: NukeopsCommander
     - prefRoles: [ NukeopsMedic ]
       fallbackRoles: [ Nukeops, NukeopsCommander ]
-      max: 1
-      playerRatio: 10
+      spawnerPrototype: SpawnPointNukeopsMedic
       startingGear: SyndicateOperativeMedicFull
       components:
       - type: NukeOperative
         prototype: NukeopsMedic
     - prefRoles: [ Nukeops ]
       fallbackRoles: [ NukeopsCommander, NukeopsMedic ]
-      min: 0
+      spawnerPrototype: SpawnPointNukeopsOperative
       max: 3
       playerRatio: 10
       startingGear: SyndicateOperativeGearFull