From 31747a089c11fc5050b96704946a63c8f01efe97 Mon Sep 17 00:00:00 2001 From: lzk <124214523+lzk228@users.noreply.github.com> Date: Thu, 19 Sep 2024 00:23:12 +0200 Subject: [PATCH] Ignore intern roles for traitor kill objective --- .../Objectives/Components/PickRandomPersonComponent.cs | 7 +++++++ .../Objectives/Systems/KillPersonConditionSystem.cs | 7 +++++++ Resources/Prototypes/Objectives/traitor.yml | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/Content.Server/Objectives/Components/PickRandomPersonComponent.cs b/Content.Server/Objectives/Components/PickRandomPersonComponent.cs index 4188b1da3d2507..65901c6d37f08d 100644 --- a/Content.Server/Objectives/Components/PickRandomPersonComponent.cs +++ b/Content.Server/Objectives/Components/PickRandomPersonComponent.cs @@ -1,4 +1,6 @@ using Content.Server.Objectives.Systems; +using Content.Shared.Roles; +using Robust.Shared.Prototypes; namespace Content.Server.Objectives.Components; @@ -8,4 +10,9 @@ namespace Content.Server.Objectives.Components; [RegisterComponent, Access(typeof(KillPersonConditionSystem))] public sealed partial class PickRandomPersonComponent : Component { + /// + /// List of jobs, that won't be kill objectives + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public List?> IgnoredJobs = new(); } diff --git a/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs b/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs index c1caa819e449ed..fc7cba404da2d0 100644 --- a/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs +++ b/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Roles.Jobs; using Robust.Shared.Configuration; using Robust.Shared.Random; +using System.Linq; namespace Content.Server.Objectives.Systems; @@ -55,6 +56,12 @@ private void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref // no other humans to kill var allHumans = _mind.GetAliveHumansExcept(args.MindId); + + // filter jobs that we don't want to be kill objectives + allHumans = allHumans + .Where(human => !_job.MindTryGetJobId(human, out var jobId) || !comp.IgnoredJobs.Contains(jobId)) + .ToList(); + if (allHumans.Count == 0) { args.Cancelled = true; diff --git a/Resources/Prototypes/Objectives/traitor.yml b/Resources/Prototypes/Objectives/traitor.yml index a156061a9aeb87..80ae1e31593267 100644 --- a/Resources/Prototypes/Objectives/traitor.yml +++ b/Resources/Prototypes/Objectives/traitor.yml @@ -92,6 +92,10 @@ - type: TargetObjective title: objective-condition-kill-person-title - type: PickRandomPerson + ignoredJobs: + - TechnicalAssistant + - MedicalIntern + - ResearchAssistant - type: entity parent: [BaseTraitorObjective, BaseKillObjective]