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

Port DeltaV syndicate objective "teach a lesson" #232

Merged
merged 14 commits into from
Dec 25, 2024
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Content.Server.DeltaV.Objectives.Systems;
using Content.Server.Objectives.Components;

namespace Content.Server.DeltaV.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,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;

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

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

SubscribeLocalEvent<MobStateChangedEvent>(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<TeachLessonConditionComponent, TargetObjectiveComponent>();

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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
objective-condition-teach-person-title = Teach {$targetName}, {CAPITALIZE($job)} a lesson
1 change: 1 addition & 0 deletions Resources/Prototypes/Objectives/objectiveGroups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
weights:
KillRandomPersonObjective: 1
KillRandomHeadObjective: 0.25
TeachLessonRandomPersonObjective: 1 #Harmony objective

- type: weightedRandom
id: TraitorObjectiveGroupState
Expand Down
31 changes: 31 additions & 0 deletions Resources/Prototypes/_DeltaV/Objectives/traitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Base
# teach lesson
- type: entity
abstract: true
parent: BaseTargetObjective
id: BaseTeachLessonObjective
FluffMe marked this conversation as resolved.
Show resolved Hide resolved
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
Loading