Skip to content

Commit

Permalink
Merge pull request #232 from Ermucat/teachalesson
Browse files Browse the repository at this point in the history
Port DeltaV syndicate objective "teach a lesson"
  • Loading branch information
spanky-spanky authored Dec 25, 2024
2 parents 5ddc3ec + 933afe2 commit 2318ecb
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
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
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

0 comments on commit 2318ecb

Please sign in to comment.