]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Scattershot antag fixes (#27429)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sun, 5 May 2024 09:23:43 +0000 (05:23 -0400)
committerGitHub <noreply@github.com>
Sun, 5 May 2024 09:23:43 +0000 (19:23 +1000)
* scattershot antag fixes

* this too?

* dawg fuck this code

* ok so we kinda need this?

Content.Server/Access/Systems/PresetIdCardSystem.cs
Content.Server/Antag/AntagSelectionSystem.API.cs
Content.Server/Antag/AntagSelectionSystem.cs
Resources/Prototypes/GameRules/midround.yml

index 696b7a1dcfd2a8c52adbc522c03d519fb6e75528..3e775b9c35da4a43726e20cccb511ede386f43c9 100644 (file)
@@ -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<StationJobsComponent>(station.Value).ExtendedAccess)
-                return;
+            if (station == null || !TryComp<StationJobsComponent>(station.Value, out var jobsComp) || !jobsComp.ExtendedAccess)
+                continue;
 
             SetupIdAccess(uid, card, true);
             SetupIdName(uid, card);
index f8ec5bcafcd4650420581334892a3c1543543099..6acd17a35b273f236ed427d355f4af50c953dd8d 100644 (file)
@@ -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
     /// </summary>
     public int GetTargetAntagCount(Entity<AntagSelectionComponent> 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);
     }
index 6bfb7394f5bcf23f0d198914b6691bd380f9cb16..57df82d6fd9bd780d498211ad92ae08d92fd980a 100644 (file)
@@ -280,11 +280,13 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
             _transform.SetMapCoordinates((player, playerXform), pos);
         }
 
+        // If we want to just do a ghost role spawner, set up data here and then return early.
+        // This could probably be an event in the future if we want to be more refined about it.
         if (isSpawner)
         {
             if (!TryComp<GhostRoleAntagSpawnerComponent>(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<AntagSelection
             return;
         }
 
+        // The following is where we apply components, equipment, and other changes to our antagonist entity.
         EntityManager.AddComponents(player, def.Components);
         _stationSpawning.EquipStartingGear(player, def.StartingGear);
 
@@ -308,11 +311,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
             _mind.TransferTo(curMind.Value, antagEnt, ghostCheckOverride: true);
             _role.MindAddRoles(curMind.Value, def.MindComponents);
             ent.Comp.SelectedMinds.Add((curMind.Value, Name(player)));
-        }
-
-        if (def.Briefing is { } briefing)
-        {
-            SendBriefing(session, briefing);
+            SendBriefing(session, def.Briefing);
         }
 
         var afterEv = new AfterAntagEntitySelectedEvent(session, player, ent, def);
@@ -325,7 +324,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
     public AntagSelectionPlayerPool GetPlayerPool(Entity<AntagSelectionComponent> ent, List<ICommonSession> sessions, AntagSelectionDefinition def)
     {
         var preferredList = new List<ICommonSession>();
-        var secondBestList = new List<ICommonSession>();
+        var fallbackList = new List<ICommonSession>();
         var unwantedList = new List<ICommonSession>();
         var invalidList = new List<ICommonSession>();
         foreach (var session in sessions)
@@ -344,7 +343,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
             }
             else if (def.FallbackRoles.Count != 0 && pref.AntagPreferences.Any(p => def.FallbackRoles.Contains(p)))
             {
-                secondBestList.Add(session);
+                fallbackList.Add(session);
             }
             else
             {
@@ -352,7 +351,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
             }
         }
 
-        return new AntagSelectionPlayerPool(new() { preferredList, secondBestList, unwantedList, invalidList });
+        return new AntagSelectionPlayerPool(new() { preferredList, fallbackList, unwantedList, invalidList });
     }
 
     /// <summary>
index 428735709f082421ea92ff8e73fd048602560805..c417132992184b1cccff939cc897bb2974932daa 100644 (file)
@@ -43,7 +43,7 @@
       playerRatio: 1
       lateJoinAdditional: true
       allowNonHumans: true
-      multiAntagSetting: All
+      multiAntagSetting: NotExclusive
       startingGear: ThiefGear
       components:
       - type: Pacified