missing nukies can be filled in by ghost roles (#28316)

This commit is contained in:
deltanedas
2024-05-28 15:35:08 +00:00
committed by GitHub
parent bec21d443f
commit 229c3cd729
4 changed files with 41 additions and 7 deletions

View 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);

View 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;

View File

@@ -102,6 +102,33 @@
- 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

View File

@@ -90,8 +90,7 @@
definitions:
- prefRoles: [ NukeopsCommander ]
fallbackRoles: [ Nukeops, NukeopsMedic ]
max: 1
playerRatio: 10
spawnerPrototype: SpawnPointNukeopsCommander
startingGear: SyndicateCommanderGearFull
components:
- type: NukeOperative
@@ -107,8 +106,7 @@
prototype: NukeopsCommander
- prefRoles: [ NukeopsMedic ]
fallbackRoles: [ Nukeops, NukeopsCommander ]
max: 1
playerRatio: 10
spawnerPrototype: SpawnPointNukeopsMedic
startingGear: SyndicateOperativeMedicFull
components:
- type: NukeOperative
@@ -124,7 +122,7 @@
prototype: NukeopsMedic
- prefRoles: [ Nukeops ]
fallbackRoles: [ NukeopsCommander, NukeopsMedic ]
min: 0
spawnerPrototype: SpawnPointNukeopsOperative
max: 3
playerRatio: 10
startingGear: SyndicateOperativeGearFull