Skip to content

Commit

Permalink
New artifact trigger: Expressions!
Browse files Browse the repository at this point in the history
Emote to trigger artifacts!

Also removes the deep music trigger because we don't need as many deep triggers to pad out!
  • Loading branch information
TheGrimbeeper committed Feb 11, 2025
1 parent b7e4ad4 commit f3b7744
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;

/// <summary>
/// Triggers when a nearby entity emotes
/// </summary>
[RegisterComponent]
public sealed partial class ArtifactExpressionTriggerComponent : Component
{
/// <summary>
/// How close to the emote event the artifact has to be for it to trigger.
/// </summary>
[DataField("range")]
public float Range = 2f;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
using Content.Server.Chat.Systems;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;

public sealed class ArtifacExpressionTriggerSystem : EntitySystem
{
[Dependency] private readonly ArtifactSystem _artifact = default!;

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<TransformComponent, EmoteEvent>(OnEmote);
}

private void OnEmote(EntityUid emoter, TransformComponent component, EmoteEvent args)
{
var emoterXform = Transform(emoter);

var toActivate = new List<Entity<ArtifactExpressionTriggerComponent>>();
var query = EntityQueryEnumerator<ArtifactExpressionTriggerComponent, TransformComponent>();

while (query.MoveNext(out var uid, out var trigger, out var xform))
{
if (!emoterXform.Coordinates.TryDistance(EntityManager, xform.Coordinates, out var distance))
continue;

if (distance > trigger.Range)
continue;

toActivate.Add((uid, trigger));
}

foreach (var a in toActivate)
{
_artifact.TryActivateArtifact(a);
}
}
}
1 change: 1 addition & 0 deletions Resources/Locale/en-US/xenoarchaeology/artifact-hints.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ artifact-trigger-hint-examine = Examination
artifact-trigger-hint-resurrection = Resurrection
artifact-trigger-hint-medical = Therapeutic chemicals
artifact-trigger-hint-funny = Slapstick comedy
artifact-trigger-hint-expression = Expressiveness
artifact-trigger-hint-drink-classic-martini = Beverage "Classically shaken"
artifact-trigger-hint-drink-caffine = Beverage "Caffinated"
Expand Down
25 changes: 18 additions & 7 deletions Resources/Prototypes/_Impstation/XenoArch/artifact_triggers.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
- type: artifactTrigger
id: TriggerExpression
targetDepth: 2
triggerProb: 0.5
triggerHint: artifact-trigger-hint-expression
components:
- type: ArtifactExpressionTrigger
range: 4

- type: artifactTrigger
id: TriggerResurrection
targetDepth: 4
Expand All @@ -22,6 +31,15 @@
components:
- type: ArtifactStunTrigger

- type: artifactTrigger
id: TriggerExpressionDeep
targetDepth: 4
triggerProb: 0.7
triggerHint: artifact-trigger-hint-expression
components:
- type: ArtifactExpressionTrigger
range: 3

# Separate drinks into twenty chunks. one chunk has a total probability of 1/20, so all drinks together have same prob as normal trigger
# Some Chunks have multiple drinks (such as the tricky drink chunk)

Expand Down Expand Up @@ -388,13 +406,6 @@
- !type:ActivateArtifact

# Below exist to pad out the depth 4 triggers. Can remove some of those when we get more triggers implemented
- type: artifactTrigger
id: TriggerMusicDeep
targetDepth: 4
triggerHint: artifact-trigger-hint-music
components:
- type: ArtifactMusicTrigger

- type: artifactTrigger
id: TriggerExamineDeep
targetDepth: 4
Expand Down

0 comments on commit f3b7744

Please sign in to comment.