Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kill objectives only target people with jobs #2799

Merged
merged 7 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace Content.Server.Objectives.Components;
[RegisterComponent, Access(typeof(KillPersonConditionSystem))]
public sealed partial class PickRandomPersonComponent : Component
{
/// <summary>
/// DeltaV: If true a target must have a job with SetPreference set to true.
/// </summary>
[DataField]
public bool NeedsOrganic; // Goobstation: Only pick non-silicon players.
public bool OnlyChoosableJobs;
}
20 changes: 18 additions & 2 deletions Content.Server/Objectives/Systems/KillPersonConditionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
using Content.Shared.CCVar;
using Content.Shared.Mind;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles; // DeltaV
using Content.Shared.Roles.Jobs; // DeltaV
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes; // DeltaV
using Robust.Shared.Random;
using System.Linq;

Expand All @@ -18,8 +21,10 @@ public sealed class KillPersonConditionSystem : EntitySystem
{
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly IPrototypeManager _proto = default!; // DeltaV
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly SharedRoleSystem _role = default!; // DeltaV
[Dependency] private readonly TargetObjectiveSystem _target = default!;

public override void Initialize()
Expand All @@ -41,7 +46,7 @@ private void OnGetProgress(EntityUid uid, KillPersonConditionComponent comp, ref

private void OnPersonAssigned(Entity<PickRandomPersonComponent> ent, ref ObjectiveAssignedEvent args)
{
AssignRandomTarget(ent, ref args, _ => true);
AssignRandomTarget(ent, ref args, _ => true, ent.Comp.OnlyChoosableJobs); // DeltaV: pass onlyJobs
}

private void OnHeadAssigned(Entity<PickRandomHeadComponent> ent, ref ObjectiveAssignedEvent args)
Expand All @@ -52,7 +57,8 @@ mind.OwnedEntity is { } ownedEnt &&
HasComp<CommandStaffComponent>(ownedEnt));
}

private void AssignRandomTarget(EntityUid uid, ref ObjectiveAssignedEvent args, Predicate<EntityUid> filter, bool fallbackToAny = true)
// DeltaV: added onlyJobs
private void AssignRandomTarget(EntityUid uid, ref ObjectiveAssignedEvent args, Predicate<EntityUid> filter, bool onlyJobs = true, bool fallbackToAny = true)
{
// invalid prototype
if (!TryComp<TargetObjectiveComponent>(uid, out var target))
Expand All @@ -75,6 +81,16 @@ private void AssignRandomTarget(EntityUid uid, ref ObjectiveAssignedEvent args,
})
.ToList();

// Begin DeltaV Additions: Only target people with jobs
if (onlyJobs)
{
allHumans.RemoveAll(mindId => !(
_role.MindHasRole<JobRoleComponent>((mindId.Owner, mindId.Comp), out var role) &&
role?.Comp1.JobPrototype is {} jobId &&
_proto.Index(jobId).SetPreference));
}
// End DeltaV Additions

// Can't have multiple objectives to kill the same person
foreach (var objective in args.Mind.Objectives)
{
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Objectives/traitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
- type: TargetObjective
title: objective-condition-kill-person-title
- type: PickRandomPerson
onlyChoosableJobs: true # DeltaV

- type: entity
parent: [BaseTraitorObjective, BaseKillObjective]
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/_DV/Objectives/traitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
- type: TargetObjective
title: objective-condition-teach-person-title
- type: PickRandomPerson
onlyChoosableJobs: true

# Kill fellow traitor objective
- type: entity
Expand Down
Loading