From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sun, 5 May 2024 09:23:43 +0000 (-0400) Subject: Scattershot antag fixes (#27429) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=5183f3ed8ba40527808610596d7e3eef3c925eef;p=space-station-14.git Scattershot antag fixes (#27429) * scattershot antag fixes * this too? * dawg fuck this code * ok so we kinda need this? --- diff --git a/Content.Server/Access/Systems/PresetIdCardSystem.cs b/Content.Server/Access/Systems/PresetIdCardSystem.cs index 696b7a1dcf..3e775b9c35 100644 --- a/Content.Server/Access/Systems/PresetIdCardSystem.cs +++ b/Content.Server/Access/Systems/PresetIdCardSystem.cs @@ -33,8 +33,8 @@ public sealed class PresetIdCardSystem : EntitySystem var station = _stationSystem.GetOwningStation(uid); // If we're not on an extended access station, the ID is already configured correctly from MapInit. - if (station == null || !Comp(station.Value).ExtendedAccess) - return; + if (station == null || !TryComp(station.Value, out var jobsComp) || !jobsComp.ExtendedAccess) + continue; SetupIdAccess(uid, card, true); SetupIdName(uid, card); diff --git a/Content.Server/Antag/AntagSelectionSystem.API.cs b/Content.Server/Antag/AntagSelectionSystem.API.cs index f8ec5bcafc..6acd17a35b 100644 --- a/Content.Server/Antag/AntagSelectionSystem.API.cs +++ b/Content.Server/Antag/AntagSelectionSystem.API.cs @@ -7,6 +7,7 @@ using Content.Shared.Chat; using Content.Shared.Mind; using JetBrains.Annotations; using Robust.Shared.Audio; +using Robust.Shared.Enums; using Robust.Shared.Player; namespace Content.Server.Antag; @@ -63,15 +64,17 @@ public sealed partial class AntagSelectionSystem /// public int GetTargetAntagCount(Entity ent, AntagSelectionPlayerPool? pool, AntagSelectionDefinition def) { - var poolSize = pool?.Count ?? _playerManager.Sessions.Length; + var poolSize = pool?.Count ?? _playerManager.Sessions + .Count(s => s.State.Status is not SessionStatus.Disconnected and not SessionStatus.Zombie); + // factor in other definitions' affect on the count. var countOffset = 0; foreach (var otherDef in ent.Comp.Definitions) { - countOffset += Math.Clamp(poolSize / otherDef.PlayerRatio, otherDef.Min, otherDef.Max) * otherDef.PlayerRatio; + countOffset += Math.Clamp((poolSize - countOffset) / otherDef.PlayerRatio, otherDef.Min, otherDef.Max) * otherDef.PlayerRatio; } // make sure we don't double-count the current selection - countOffset -= Math.Clamp((poolSize + countOffset) / def.PlayerRatio, def.Min, def.Max) * def.PlayerRatio; + countOffset -= Math.Clamp(poolSize / def.PlayerRatio, def.Min, def.Max) * def.PlayerRatio; return Math.Clamp((poolSize - countOffset) / def.PlayerRatio, def.Min, def.Max); } diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 6bfb7394f5..57df82d6fd 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -280,11 +280,13 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem(player, out var spawnerComp)) { - Log.Error("Antag spawner with GhostRoleAntagSpawnerComponent."); + Log.Error($"Antag spawner {player} does not have a GhostRoleAntagSpawnerComponent."); return; } @@ -293,6 +295,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem ent, List sessions, AntagSelectionDefinition def) { var preferredList = new List(); - var secondBestList = new List(); + var fallbackList = new List(); var unwantedList = new List(); var invalidList = new List(); foreach (var session in sessions) @@ -344,7 +343,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem def.FallbackRoles.Contains(p))) { - secondBestList.Add(session); + fallbackList.Add(session); } else { @@ -352,7 +351,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem diff --git a/Resources/Prototypes/GameRules/midround.yml b/Resources/Prototypes/GameRules/midround.yml index 428735709f..c417132992 100644 --- a/Resources/Prototypes/GameRules/midround.yml +++ b/Resources/Prototypes/GameRules/midround.yml @@ -43,7 +43,7 @@ playerRatio: 1 lateJoinAdditional: true allowNonHumans: true - multiAntagSetting: All + multiAntagSetting: NotExclusive startingGear: ThiefGear components: - type: Pacified