Skip to content
Draft
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
@@ -0,0 +1,8 @@

namespace Content.Server.ADT.Objectives.Components;

/// <summary>
/// Use this to mark a player as immune to any target objectives, useful for ghost roles or events.
/// </summary>
[RegisterComponent]
public sealed partial class TargetObjectiveImmuneComponent : Component;
32 changes: 30 additions & 2 deletions Content.Server/Objectives/Systems/PickObjectiveTargetSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
using Content.Server.Revolutionary.Components;
using Robust.Shared.Random;
using System.Linq;
//ADT-Tweak-Start
using Content.Server.ADT.Objectives.Components;
using Content.Shared.Mindshield.Components;
//ADT-Tweak-End

namespace Content.Server.Objectives.Systems;

Expand All @@ -31,6 +35,16 @@ public override void Initialize()
SubscribeLocalEvent<RandomTraitorAliveComponent, ObjectiveAssignedEvent>(OnRandomTraitorAliveAssigned);
}

//ADT-Tweak-Start
private bool HasTargetImmunity(EntityUid? body)
{
if (body == null)
return false;

return HasComp<TargetObjectiveImmuneComponent>(body.Value) && !HasComp<MindShieldComponent>(body.Value);
}
//ADT-Tweak-End

private void OnSpecificPersonAssigned(Entity<PickSpecificPersonComponent> ent, ref ObjectiveAssignedEvent args)
{
// invalid objective prototype
Expand Down Expand Up @@ -75,6 +89,11 @@ private void OnRandomPersonAssigned(Entity<PickRandomPersonComponent> ent, ref O

var allHumans = _mind.GetAliveHumans(args.MindId);

//ADT-Tweak-Start
// Filter out immune targets
allHumans.RemoveWhere(p => HasTargetImmunity(p.Comp.OwnedEntity));
//ADT-Tweak-End

// Can't have multiple objectives to kill the same person
foreach (var objective in args.Mind.Objectives)
{
Expand Down Expand Up @@ -109,6 +128,12 @@ private void OnRandomHeadAssigned(Entity<PickRandomHeadComponent> ent, ref Objec

// no other humans to kill
var allHumans = _mind.GetAliveHumans(args.MindId);

//ADT-Tweak-Start
// Filter out immune targets
allHumans.RemoveWhere(p => HasTargetImmunity(p.Comp.OwnedEntity));
//ADT-Tweak-End

if (allHumans.Count == 0)
{
args.Cancelled = true;
Expand All @@ -118,12 +143,15 @@ private void OnRandomHeadAssigned(Entity<PickRandomHeadComponent> ent, ref Objec
var allHeads = new HashSet<Entity<MindComponent>>();
foreach (var person in allHumans)
{
if (TryComp<MindComponent>(person, out var mind) && mind.OwnedEntity is { } owned && HasComp<CommandStaffComponent>(owned))
//ADT-Tweak-Start
var mind = person.Comp;
if (mind.OwnedEntity is { } owned && HasComp<CommandStaffComponent>(owned))
//ADT-Tweak-End
allHeads.Add(person);
}

if (allHeads.Count == 0)
allHeads = allHumans; // fallback to non-head target
allHeads = new HashSet<Entity<MindComponent>>(allHumans); //ADT-Tweak

_target.SetTarget(ent.Owner, _random.Pick(allHeads), target);
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/Locale/ru-RU/ADT/traits/categories.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
trait-category-quirks = Особенности
trait-category-height = Рост

trait-category-meta = Мета
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/ADT/traits/meta.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trait-protected-name = Неприметный
trait-protected-desc = Вы не будете помечаться как цель для убийства до тех пор, пока у вас не будет импланта защиты разума.
6 changes: 5 additions & 1 deletion Resources/Prototypes/ADT/Traits/categories.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
- type: traitCategory
id: Height
name: trait-category-height
maxTraitPoints: 1
maxTraitPoints: 1

- type: traitCategory
id: Meta
name: trait-category-meta
8 changes: 8 additions & 0 deletions Resources/Prototypes/ADT/Traits/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- type: trait
id: MarkedAsProtected
name: trait-protected-name
description: trait-protected-desc
category: Meta
components:
- type: TargetObjectiveImmune
cost: 0
Loading