diff --git a/Content.Server/Objectives/Conditions/KillRandomHeadCondition.cs b/Content.Server/Objectives/Conditions/KillRandomHeadCondition.cs new file mode 100644 index 0000000000..4476c0106a --- /dev/null +++ b/Content.Server/Objectives/Conditions/KillRandomHeadCondition.cs @@ -0,0 +1,47 @@ +using Content.Server.Mind.Components; +using Content.Server.Objectives.Interfaces; +using Content.Server.Roles; +using Content.Shared.Mobs.Components; +using Robust.Shared.Random; +using System.Linq; + +namespace Content.Server.Objectives.Conditions; + +[DataDefinition] +public sealed class KillRandomHeadCondition : KillPersonCondition +{ + public override IObjectiveCondition GetAssigned(Mind.Mind mind) + { + RequireDead = true; + + var allHumans = EntityManager.EntityQuery(true).Where(mc => + { + var entity = mc.Mind?.OwnedEntity; + + if (entity == default) + return false; + + return EntityManager.TryGetComponent(entity, out MobStateComponent? mobState) && + MobStateSystem.IsAlive(entity.Value, mobState) && + mc.Mind != mind; + }).Select(mc => mc.Mind).ToList(); + + if (allHumans.Count == 0) + return new DieCondition(); // I guess I'll die + + var allHeads = allHumans.Where(mind => mind?.AllRoles.Any(role => { + if (role is not Job job) + return false; + + // basically a command department check, pretty sussy but whatever + return job.Prototype.RequireAdminNotify; + }) ?? false).ToList(); + + if (allHeads.Count == 0) + allHeads = allHumans; // fallback to non-head target + + return new KillRandomHeadCondition {Target = IoCManager.Resolve().Pick(allHeads)}; + } + + public string Description => Loc.GetString("objective-condition-kill-head-description"); +} diff --git a/Resources/Locale/en-US/objectives/conditions/kill-head-condition.ftl b/Resources/Locale/en-US/objectives/conditions/kill-head-condition.ftl new file mode 100644 index 0000000000..ad8861ba06 --- /dev/null +++ b/Resources/Locale/en-US/objectives/conditions/kill-head-condition.ftl @@ -0,0 +1 @@ +objective-condition-kill-head-description = We need this head gone and you probably know why. Good luck, agent. diff --git a/Resources/Prototypes/Objectives/traitorObjectives.yml b/Resources/Prototypes/Objectives/traitorObjectives.yml index c2bcb936e6..45ff9b3da3 100644 --- a/Resources/Prototypes/Objectives/traitorObjectives.yml +++ b/Resources/Prototypes/Objectives/traitorObjectives.yml @@ -25,6 +25,22 @@ - !type:KillRandomPersonCondition {} canBeDuplicate: true +# technically its still possible for KillRandomObjective to roll a head but this is guaranteed, so higher difficulty +# this also will not count missing evac as killing as heads are higher profile, so you really need to do the dirty work +- type: objective + id: KillRandomHeadObjective + issuer: syndicate + difficultyOverride: 3.0 + requirements: + - !type:TraitorRequirement {} + - !type:IncompatibleConditionsRequirement + conditions: + - RandomTraitorAliveCondition + conditions: + - !type:KillRandomHeadCondition {} + # killing 1 head is enough + canBeDuplicate: false + - type: objective id: RandomTraitorAliveObjective issuer: syndicate