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
@@ -0,0 +1,10 @@
using Content.Server.Objectives.Systems;

namespace Content.Server.Objectives.Components;

/// <summary>
/// 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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Content.Server.Objectives.Components;
using Content.Shared.GameTicking;
using Content.Shared.Mind;
using Content.Shared.Objectives.Components;
using Microsoft.EntityFrameworkCore.Query.Internal;
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved

namespace Content.Server.Objectives.Systems;

/// <summary>
/// Handles teach a lesson condition logic, does not assign target.
/// </summary>
public sealed class TeachLessonConditionSystem : EntitySystem
{
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly TargetObjectiveSystem _target = default!;

private List<EntityUid> _wasKilled = new();
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<TeachLessonConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundEnd);
}

private void OnGetProgress(Entity<TeachLessonConditionComponent> ent, ref ObjectiveGetProgressEvent args)
{
if (!_target.GetTarget(ent, out var target))
return;

args.Progress = GetProgress(target.Value);
}

private float GetProgress(EntityUid target)
{
// deleted or gibbed or something, counts as dead
if (!TryComp<MindComponent>(target, out var mind) || mind.OwnedEntity == null || _mind.IsCharacterDeadIc(mind))
{
_wasKilled.Add(target);
return 1f;
}
if (_wasKilled.Contains(target))
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved
{
return _wasKilled.Contains(target) ? 1f : 0f;
}
return 0f;
}
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved
// Clear the wasKilled list on round end
private void OnRoundEnd(RoundRestartCleanupEvent ev)
{
_wasKilled.Clear();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
objective-condition-teach-person-title = Teach {$targetName}, {CAPITALIZE($job)} a lesson
29 changes: 29 additions & 0 deletions Resources/Prototypes/DeltaV/Objectives/traitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,32 @@
- type: StealCondition
stealGroup: AnimalSilvia
owner: job-name-cmo

# teach lesson
- type: entity
abstract: true
parent: BaseTargetObjective
id: BaseTeachLessonObjective
components:
- type: Objective
unique: false
icon:
sprite: Objects/Weapons/Guns/Pistols/viper.rsi
state: icon
- type: ObjectiveBlacklistRequirement
blacklist:
components:
- SocialObjective

- type: entity
parent: [BaseTraitorObjective, BaseTeachLessonObjective]
id: TeachLessonRandomPersonObjective
description: Kill them, and show everyone we mean business. They only need to die once.
components:
- type: Objective
difficulty: 1.75
unique: false
- type: TargetObjective
title: objective-condition-teach-person-title
- type: PickRandomPerson
- type: TeachLessonCondition
3 changes: 2 additions & 1 deletion Resources/Prototypes/Objectives/objectiveGroups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
- type: weightedRandom
id: TraitorObjectiveGroupKill
weights:
KillRandomPersonObjective: 1
#KillRandomPersonObjective: 1 # DeltaV- Replaced for Teach Lesson
Lyndomen marked this conversation as resolved.
Show resolved Hide resolved
TeachLessonRandomPersonObjective: 1
KillRandomHeadObjective: 0.25

- type: weightedRandom
Expand Down
Loading