From 39d9ea854d66a1397bed89b6cb40179a358c7ca2 Mon Sep 17 00:00:00 2001
From: Lyndomen <49795619+Lyndomen@users.noreply.github.com>
Date: Sun, 17 Nov 2024 22:33:27 -0500
Subject: [PATCH] Change Kill Person to "Teach person a lesson" (#2184)
* bogos binted
* bogos binted
* bogos binted
* bogos binted
* bogos binted
* bogos binted
* bogos binted
* fixes, still doesnt stay completed.
* fixed real
* meow
* meow
---
.../TeachLessonConditionComponent.cs | 10 ++++
.../Systems/TeachLessonConditionSystem.cs | 48 +++++++++++++++++++
.../objectives/conditions/teach-person.ftl | 1 +
.../Prototypes/DeltaV/Objectives/traitor.yml | 29 +++++++++++
.../Prototypes/Objectives/objectiveGroups.yml | 3 +-
5 files changed, 90 insertions(+), 1 deletion(-)
create mode 100644 Content.Server/DeltaV/Objectives/Components/TeachLessonConditionComponent.cs
create mode 100644 Content.Server/DeltaV/Objectives/Systems/TeachLessonConditionSystem.cs
create mode 100644 Resources/Locale/en-US/deltav/objectives/conditions/teach-person.ftl
diff --git a/Content.Server/DeltaV/Objectives/Components/TeachLessonConditionComponent.cs b/Content.Server/DeltaV/Objectives/Components/TeachLessonConditionComponent.cs
new file mode 100644
index 00000000000..ee86f4851b3
--- /dev/null
+++ b/Content.Server/DeltaV/Objectives/Components/TeachLessonConditionComponent.cs
@@ -0,0 +1,10 @@
+using Content.Server.Objectives.Systems;
+
+namespace Content.Server.Objectives.Components;
+
+///
+/// Requires that a target dies once and only once.
+/// Depends on to function.
+///
+[RegisterComponent, Access(typeof(TeachLessonConditionSystem))]
+public sealed partial class TeachLessonConditionComponent : Component;
diff --git a/Content.Server/DeltaV/Objectives/Systems/TeachLessonConditionSystem.cs b/Content.Server/DeltaV/Objectives/Systems/TeachLessonConditionSystem.cs
new file mode 100644
index 00000000000..8e3ca19f885
--- /dev/null
+++ b/Content.Server/DeltaV/Objectives/Systems/TeachLessonConditionSystem.cs
@@ -0,0 +1,48 @@
+using Content.Server.Objectives.Components;
+using Content.Shared.GameTicking;
+using Content.Shared.Mind;
+using Content.Shared.Objectives.Components;
+
+namespace Content.Server.Objectives.Systems;
+
+///
+/// Handles teach a lesson condition logic, does not assign target.
+///
+public sealed class TeachLessonConditionSystem : EntitySystem
+{
+ [Dependency] private readonly SharedMindSystem _mind = default!;
+ [Dependency] private readonly TargetObjectiveSystem _target = default!;
+
+ private readonly List _wasKilled = [];
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnGetProgress);
+ SubscribeLocalEvent(OnRoundEnd);
+ }
+
+ private void OnGetProgress(Entity ent, ref ObjectiveGetProgressEvent args)
+ {
+ if (!_target.GetTarget(ent, out var target))
+ return;
+
+ args.Progress = GetProgress(target.Value);
+ }
+
+ private float GetProgress(EntityUid target)
+ {
+ if (TryComp(target, out var mind) && mind.OwnedEntity != null && !_mind.IsCharacterDeadIc(mind))
+ return _wasKilled.Contains(target) ? 1f : 0f;
+
+ _wasKilled.Add(target);
+ return 1f;
+ }
+
+ // Clear the wasKilled list on round end
+ private void OnRoundEnd(RoundRestartCleanupEvent ev)
+ {
+ _wasKilled.Clear();
+ }
+}
diff --git a/Resources/Locale/en-US/deltav/objectives/conditions/teach-person.ftl b/Resources/Locale/en-US/deltav/objectives/conditions/teach-person.ftl
new file mode 100644
index 00000000000..292db0a91ac
--- /dev/null
+++ b/Resources/Locale/en-US/deltav/objectives/conditions/teach-person.ftl
@@ -0,0 +1 @@
+objective-condition-teach-person-title = Teach {$targetName}, {CAPITALIZE($job)} a lesson
diff --git a/Resources/Prototypes/DeltaV/Objectives/traitor.yml b/Resources/Prototypes/DeltaV/Objectives/traitor.yml
index cb8f5455823..28bd9a1f895 100644
--- a/Resources/Prototypes/DeltaV/Objectives/traitor.yml
+++ b/Resources/Prototypes/DeltaV/Objectives/traitor.yml
@@ -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
diff --git a/Resources/Prototypes/Objectives/objectiveGroups.yml b/Resources/Prototypes/Objectives/objectiveGroups.yml
index d870db5d364..bfc7122c6d6 100644
--- a/Resources/Prototypes/Objectives/objectiveGroups.yml
+++ b/Resources/Prototypes/Objectives/objectiveGroups.yml
@@ -32,7 +32,8 @@
- type: weightedRandom
id: TraitorObjectiveGroupKill
weights:
- KillRandomPersonObjective: 1
+ # KillRandomPersonObjective: 1 # DeltaV Replaced for Teach Lesson
+ TeachLessonRandomPersonObjective: 1
KillRandomHeadObjective: 0.25
- type: weightedRandom