From 22468b4d408ae4c39b8c85b935a61ece08e293e4 Mon Sep 17 00:00:00 2001
From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Date: Tue, 15 Apr 2025 18:24:58 -0400
Subject: [PATCH] Sentient Artifacts Can Self-Activate Again (#36598)
Sentient Artifacts
---
.../Artifact/Components/XenoArtifactComponent.cs | 12 ++++++++++++
.../Artifact/SharedXenoArtifactSystem.XAE.cs | 6 ++++--
.../Artifact/SharedXenoArtifactSystem.cs | 9 +++++++++
.../Specific/Xenoarchaeology/xenoartifacts.yml | 16 ++++++++++++++++
Resources/Prototypes/XenoArch/effects.yml | 3 ---
5 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/Content.Shared/Xenoarchaeology/Artifact/Components/XenoArtifactComponent.cs b/Content.Shared/Xenoarchaeology/Artifact/Components/XenoArtifactComponent.cs
index fb118602c7..85462d0efc 100644
--- a/Content.Shared/Xenoarchaeology/Artifact/Components/XenoArtifactComponent.cs
+++ b/Content.Shared/Xenoarchaeology/Artifact/Components/XenoArtifactComponent.cs
@@ -1,3 +1,4 @@
+using Content.Shared.Actions;
using Content.Shared.Destructible.Thresholds;
using Content.Shared.EntityTable.EntitySelectors;
using Content.Shared.Xenoarchaeology.Artifact.Prototypes;
@@ -158,4 +159,15 @@ public sealed partial class XenoArtifactComponent : Component
Variation = 0.1f
}
};
+
+ ///
+ /// Action that allows the artifact to self activate.
+ ///
+ [DataField]
+ public EntProtoId SelfActivateAction = "ActionArtifactActivate";
}
+
+///
+/// Event raised by sentient artifact to activate itself at no durability cost.
+///
+public sealed partial class ArtifactSelfActivateEvent : InstantActionEvent;
diff --git a/Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.XAE.cs b/Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.XAE.cs
index fb592a03f1..d98fa059f3 100644
--- a/Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.XAE.cs
+++ b/Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.XAE.cs
@@ -51,12 +51,14 @@ public abstract partial class SharedXenoArtifactSystem
/// Character that attempted to activate artifact.
/// Target, on which artifact activation attempt was used (for hand-held artifact - it can be 'clicked' over someone).
/// Coordinates of entity.
+ /// Whether this activation will deplete durability on the activated nodes.
/// True, if activation was successful, false otherwise.
public bool TryActivateXenoArtifact(
Entity artifact,
EntityUid? user,
EntityUid? target,
- EntityCoordinates coordinates
+ EntityCoordinates coordinates,
+ bool consumeDurability = true
)
{
XenoArtifactComponent xenoArtifactComponent = artifact;
@@ -69,7 +71,7 @@ public abstract partial class SharedXenoArtifactSystem
var success = false;
foreach (var node in GetActiveNodes(artifact))
{
- success |= ActivateNode(artifact, node, user, target, coordinates);
+ success |= ActivateNode(artifact, node, user, target, coordinates, consumeDurability: consumeDurability);
}
if (!success)
diff --git a/Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.cs b/Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.cs
index aad2f51239..a4a4cfc45a 100644
--- a/Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.cs
+++ b/Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.cs
@@ -1,3 +1,4 @@
+using Content.Shared.Actions;
using Content.Shared.Popups;
using Content.Shared.Xenoarchaeology.Artifact.Components;
using Robust.Shared.Containers;
@@ -17,6 +18,7 @@ public abstract partial class SharedXenoArtifactSystem : EntitySystem
[Dependency] private readonly INetManager _net = default!;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
[Dependency] protected readonly IRobustRandom RobustRandom = default!;
+ [Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
@@ -24,6 +26,7 @@ public abstract partial class SharedXenoArtifactSystem : EntitySystem
public override void Initialize()
{
SubscribeLocalEvent(OnStartup);
+ SubscribeLocalEvent(OnSelfActivate);
InitializeNode();
InitializeUnlock();
@@ -42,9 +45,15 @@ public abstract partial class SharedXenoArtifactSystem : EntitySystem
/// As all artifacts have to contain nodes - we ensure that they are containers.
private void OnStartup(Entity ent, ref ComponentStartup args)
{
+ _actions.AddAction(ent, ent.Comp.SelfActivateAction);
ent.Comp.NodeContainer = _container.EnsureContainer(ent, XenoArtifactComponent.NodeContainerId);
}
+ private void OnSelfActivate(Entity ent, ref ArtifactSelfActivateEvent args)
+ {
+ args.Handled = TryActivateXenoArtifact(ent, ent, null, Transform(ent).Coordinates, false);
+ }
+
public void SetSuppressed(Entity ent, bool val)
{
if (ent.Comp.Suppressed == val)
diff --git a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/xenoartifacts.yml b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/xenoartifacts.yml
index b9db84b58e..74a78cee59 100644
--- a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/xenoartifacts.yml
+++ b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/xenoartifacts.yml
@@ -1,5 +1,6 @@
- type: entity
id: BaseXenoArtifact
+ parent: BaseMob # we use this since it can technically get inhabited
name: artifact
description: A strange artifact from time unknown. Looks like a good time.
abstract: true
@@ -29,6 +30,9 @@
- type: Actions
- type: Physics
bodyType: Dynamic
+ - type: MovementSpeedModifier
+ baseWalkSpeed: 0.25
+ baseSprintSpeed: 0.5
- type: UseDelay
- type: StealTarget
stealGroup: XenoArtifact
@@ -41,3 +45,15 @@
# These components are needed for certain triggers to work.
- type: RadiationReceiver
- type: Reactive
+
+- type: entity
+ id: ActionArtifactActivate
+ name: Activate Artifact
+ description: Activate yourself, causing chaos to those near you.
+ components:
+ - type: InstantAction
+ icon:
+ sprite: Objects/Specific/Xenoarchaeology/xeno_artifacts.rsi
+ state: ano29
+ useDelay: 300
+ event: !type:ArtifactSelfActivateEvent
diff --git a/Resources/Prototypes/XenoArch/effects.yml b/Resources/Prototypes/XenoArch/effects.yml
index 01a316d780..e02514d2c2 100644
--- a/Resources/Prototypes/XenoArch/effects.yml
+++ b/Resources/Prototypes/XenoArch/effects.yml
@@ -363,9 +363,6 @@
mindRoles:
- MindRoleGhostRoleFreeAgent
- type: GhostTakeoverAvailable
- - type: MovementSpeedModifier
- baseWalkSpeed: 0.25
- baseSprintSpeed: 0.5
- type: entity
id: XenoArtifactOmnitool
--
2.51.2