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

Change Kill Person to "Teach person a lesson" #2184

Merged
merged 13 commits into from
Nov 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
namespace Content.Server.Objectives.Components;

/// <summary>
/// Requires that a target dies or, if <see cref="RequireDead"/> is false, is not on the emergency shuttle.
/// Requires that a target dies once and only once.
/// Depends on <see cref="TargetObjectiveComponent"/> to function.
/// </summary>
[RegisterComponent, Access(typeof(TeachLessonConditionSystem))]
public sealed partial class TeachLessonConditionComponent : Component
{
/// <summary>
/// Whether the target must be truly dead, ignores missing evac.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool RequireDead = false;
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System.Linq;
using Content.Server.Objectives.Components;
using Content.Shared.GameTicking; //DeltaV Teach lesson
using Content.Server.Revolutionary.Components;
using Content.Server.Shuttles.Systems;
using Content.Server.Objectives.Components;
using Content.Shared.GameTicking;
using Content.Shared.Mind;
using Content.Shared.Objectives.Components;
using Robust.Shared.Configuration;
using Robust.Shared.Random;

namespace Content.Server.Objectives.Systems;
Expand All @@ -15,8 +11,6 @@ namespace Content.Server.Objectives.Systems;
/// </summary>
public sealed class TeachLessonConditionSystem : EntitySystem
{
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly TargetObjectiveSystem _target = default!;
Expand All @@ -28,106 +22,32 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<TeachLessonConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
SubscribeLocalEvent<TeachLessonPickRandomPersonComponent, ObjectiveAssignedEvent>(OnPersonAssigned);
SubscribeLocalEvent<TeachLessonPickRandomHeadComponent, ObjectiveAssignedEvent>(OnHeadAssigned);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundEnd); //DeltaV Kill objective
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundEnd);
}

private void OnGetProgress(EntityUid uid, TeachLessonConditionComponent comp, ref ObjectiveGetProgressEvent args)
{
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved
if (!_target.GetTarget(uid, out var target))
return;

args.Progress = GetProgress(target.Value, comp.RequireDead);
args.Progress = GetProgress(target.Value);
}

private void OnPersonAssigned(EntityUid uid, TeachLessonPickRandomPersonComponent comp, ref ObjectiveAssignedEvent args)
{
AssignRandomTarget(uid, args, _ => true);
}

private void OnHeadAssigned(EntityUid uid, TeachLessonPickRandomHeadComponent comp, ref ObjectiveAssignedEvent args)
{
AssignRandomTarget(uid, args, mind => HasComp<CommandStaffComponent>(uid));
}

private void AssignRandomTarget(EntityUid uid, ObjectiveAssignedEvent args, Predicate<EntityUid> filter, bool fallbackToAny = true)
{
// invalid prototype
if (!TryComp<TargetObjectiveComponent>(uid, out var target))
{
args.Cancelled = true;
return;
}

// target already assigned
if (target.Target != null)
return;

// Get all alive humans, filter out any with TargetObjectiveImmuneComponent
var allHumans = _mind.GetAliveHumansExcept(args.MindId)
.Where(mindId =>
{
if (!TryComp<MindComponent>(mindId, out var mindComp) || mindComp.OwnedEntity == null)
return false;
return !HasComp<TargetObjectiveImmuneComponent>(mindComp.OwnedEntity.Value);
})
.ToList();

// Filter out targets based on the filter
var filteredHumans = allHumans.Where(mind => filter(mind)).ToList();

// There's no humans and we can't fall back to any other target
if (filteredHumans.Count == 0 && !fallbackToAny)
{
args.Cancelled = true;
return;
}

// Pick between humans matching our filter or fall back to all humans alive
var selectedHumans = filteredHumans.Count > 0 ? filteredHumans : allHumans;

_target.SetTarget(uid, _random.Pick(selectedHumans), target);
}
// DeltaV - start making people only die once from EE
private float GetProgress(EntityUid target, bool requireDead)
private float GetProgress(EntityUid target)
{
// deleted or gibbed or something, counts as dead
if (!TryComp<MindComponent>(target, out var mind) || mind.OwnedEntity == null)
{
if (!requireDead && !_wasKilled.Contains(target)) _wasKilled.Add(target);
return 1f;
}

// dead is success
if (_mind.IsCharacterDeadIc(mind))
if (!TryComp<MindComponent>(target, out var mind) || mind.OwnedEntity == null || _mind.IsCharacterDeadIc(mind) || !_wasKilled.Contains(target))
{
if (!requireDead && !_wasKilled.Contains(target)) _wasKilled.Add(target);
_wasKilled.Add(target);
return 1f;
}

return 0f;
}
// if the target has to be dead dead then don't check evac stuff
// if (requireDead)
// return 0f;

// if evac is disabled then they really do have to be dead
// if (!_config.GetCVar(CCVars.EmergencyShuttleEnabled))
// return 0f;

// target is escaping so you fail
// if (_emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value))
// return 0f;
//
// // evac has left without the target, greentext since the target is afk in space with a full oxygen tank and coordinates off.
// if (_emergencyShuttle.ShuttlesLeft)
// return 1f;
//
// // if evac is still here and target hasn't boarded, show 50% to give you an indicator that you are doing good
// return _emergencyShuttle.EmergencyShuttleArrived ? 0.5f : 0f;
// Clear the wasKilled list on round end
private void OnRoundEnd(RoundRestartCleanupEvent ev)
=> _wasKilled.Clear();
{
_wasKilled.Clear();
}
// DeltaV - end making people only die once from EE
}
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private void OnGetProgress(EntityUid uid, KillPersonConditionComponent comp, ref
args.Progress = GetProgress(target.Value, comp.RequireDead);
}

private void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref ObjectiveAssignedEvent args)
public void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref ObjectiveAssignedEvent args)
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved
{
AssignRandomTarget(uid, args, _ => true);
}
Expand Down

This file was deleted.

21 changes: 1 addition & 20 deletions Resources/Prototypes/DeltaV/Objectives/traitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
components:
- SocialObjective


- type: entity
parent: [BaseTraitorObjective,BaseTeachLessonObjective]
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved
id: TeachLessonRandomPersonObjective
Expand All @@ -78,23 +77,5 @@
unique: false
- type: TargetObjective
title: objective-condition-teach-person-title
- type: TeachLessonPickRandomPerson
- type: PickRandomPerson
- type: TeachLessonCondition

- type: entity
parent: [BaseTraitorObjective,BaseTeachLessonObjective]
id: TeachLessonRandomHeadObjective
description: We need this head gone and you probably know why. Good luck, agent.
components:
- type: Objective
# technically its still possible for KillRandomPersonObjective to roll a head but this is guaranteed, so higher difficulty
difficulty: 3.0
# killing 1 head is enough
unique: true
- type: TargetObjective
title: objective-condition-teach-head-title
- type: TeachLessonPickRandomHead
- type: TeachLessonCondition #DeltaV change to teach lesson
# don't count missing evac as killing as heads are higher profile, so you really need to do the dirty work
# if ce flies a shittle to centcom you better find a way onto it
requireDead: true
7 changes: 3 additions & 4 deletions Resources/Prototypes/Objectives/objectiveGroups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
- type: weightedRandom
id: TraitorObjectiveGroupKill
weights:
# KillRandomPersonObjective: 1 DeltaV- Replaced for Teach Lesson
TeachRandomPersonObjective: 1
# KillRandomHeadObjective: 0.25 DeltaV- Replaced for Teach Lesson
TeachRandomHeadObjective: 0.25
#KillRandomPersonObjective: 1 DeltaV- Replaced for Teach Lesson
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved
TeachLessonRandomPersonObjective: 1
KillRandomHeadObjective: 0.25

- type: weightedRandom
id: TraitorObjectiveGroupState
Expand Down
Loading