diff --git a/Content.Server/_DeltaV/Objectives/Components/TeachLessonConditionComponent.cs b/Content.Server/_DeltaV/Objectives/Components/TeachLessonConditionComponent.cs new file mode 100644 index 00000000000000..2251b6a02ea7c1 --- /dev/null +++ b/Content.Server/_DeltaV/Objectives/Components/TeachLessonConditionComponent.cs @@ -0,0 +1,11 @@ +using Content.Server.DeltaV.Objectives.Systems; +using Content.Server.Objectives.Components; + +namespace Content.Server.DeltaV.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 00000000000000..d8b426644e37d1 --- /dev/null +++ b/Content.Server/_DeltaV/Objectives/Systems/TeachLessonConditionSystem.cs @@ -0,0 +1,46 @@ +using Content.Server.DeltaV.Objectives.Components; +using Content.Server.Objectives.Components; +using Content.Server.Objectives.Systems; +using Content.Shared.Mind; +using Content.Shared.Mobs; + +namespace Content.Server.DeltaV.Objectives.Systems; + +/// +/// Handles teach a lesson condition logic, does not assign target. +/// +public sealed class TeachLessonConditionSystem : EntitySystem +{ + [Dependency] private readonly CodeConditionSystem _codeCondition = default!; + [Dependency] private readonly SharedMindSystem _mind = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnMobStateChanged); + } + + // TODO: subscribe by ref at some point in the future + private void OnMobStateChanged(MobStateChangedEvent args) + { + if (args.NewMobState != MobState.Dead) + return; + + // Get the mind of the entity that just died (if it has one) + if (!_mind.TryGetMind(args.Target, out var mindId, out _)) + return; + + // Get all TeachLessonConditionComponent entities + var query = EntityQueryEnumerator(); + + while (query.MoveNext(out var uid, out _, out var targetObjective)) + { + // Check if this objective's target matches the entity that died + if (targetObjective.Target != mindId) + continue; + + _codeCondition.SetCompleted(uid); + } + } +} 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 00000000000000..292db0a91ac1dd --- /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/Objectives/objectiveGroups.yml b/Resources/Prototypes/Objectives/objectiveGroups.yml index 3c59ab9a1830cf..bd1d92ed942f7d 100644 --- a/Resources/Prototypes/Objectives/objectiveGroups.yml +++ b/Resources/Prototypes/Objectives/objectiveGroups.yml @@ -28,6 +28,7 @@ weights: KillRandomPersonObjective: 1 KillRandomHeadObjective: 0.25 + TeachLessonRandomPersonObjective: 1 #Harmony objective - type: weightedRandom id: TraitorObjectiveGroupState diff --git a/Resources/Prototypes/_DeltaV/Objectives/traitor.yml b/Resources/Prototypes/_DeltaV/Objectives/traitor.yml new file mode 100644 index 00000000000000..87010908056be9 --- /dev/null +++ b/Resources/Prototypes/_DeltaV/Objectives/traitor.yml @@ -0,0 +1,31 @@ +# Base +# teach lesson +- type: entity + abstract: true + parent: BaseTargetObjective + id: BaseTeachLessonObjective + components: + - type: Objective + unique: false + icon: + sprite: Objects/Weapons/Melee/fireaxe.rsi + state: icon + - type: TeachLessonCondition + - type: CodeCondition + - type: ObjectiveBlacklistRequirement + blacklist: + components: + - SocialObjective + +# Kill +- 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