]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Sentient Artifacts Can Self-Activate Again (#36598)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Tue, 15 Apr 2025 22:24:58 +0000 (18:24 -0400)
committerGitHub <noreply@github.com>
Tue, 15 Apr 2025 22:24:58 +0000 (08:24 +1000)
Sentient Artifacts

Content.Shared/Xenoarchaeology/Artifact/Components/XenoArtifactComponent.cs
Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.XAE.cs
Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.cs
Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/xenoartifacts.yml
Resources/Prototypes/XenoArch/effects.yml

index fb118602c77faf1cdd8d382eb5b9b2f26f0fda06..85462d0efc32f1b52e4da9b35d1636b2b7ae32e3 100644 (file)
@@ -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
         }
     };
+
+    /// <summary>
+    /// Action that allows the artifact to self activate.
+    /// </summary>
+    [DataField]
+    public EntProtoId<InstantActionComponent> SelfActivateAction = "ActionArtifactActivate";
 }
+
+/// <summary>
+/// Event raised by sentient artifact to activate itself at no durability cost.
+/// </summary>
+public sealed partial class ArtifactSelfActivateEvent : InstantActionEvent;
index fb592a03f142dbe24cd350bc18edaf43ab5c22ec..d98fa059f37e7828c09407c4dd0451b9b8bd2ad7 100644 (file)
@@ -51,12 +51,14 @@ public abstract partial class SharedXenoArtifactSystem
     /// <param name="user">Character that attempted to activate artifact.</param>
     /// <param name="target">Target, on which artifact activation attempt was used (for hand-held artifact - it can be 'clicked' over someone).</param>
     /// <param name="coordinates">Coordinates of <paramref name="target"/> entity.</param>
+    /// <param name="consumeDurability">Whether this activation will deplete durability on the activated nodes.</param>
     /// <returns>True, if activation was successful, false otherwise.</returns>
     public bool TryActivateXenoArtifact(
         Entity<XenoArtifactComponent> 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)
index aad2f51239bbb281c7e14ef564b44c075ae058db..a4a4cfc45a83ff43c6edb64ca46ee9e14b6517fd 100644 (file)
@@ -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<XenoArtifactComponent, ComponentStartup>(OnStartup);
+        SubscribeLocalEvent<XenoArtifactComponent, ArtifactSelfActivateEvent>(OnSelfActivate);
 
         InitializeNode();
         InitializeUnlock();
@@ -42,9 +45,15 @@ public abstract partial class SharedXenoArtifactSystem : EntitySystem
     /// <summary> As all artifacts have to contain nodes - we ensure that they are containers. </summary>
     private void OnStartup(Entity<XenoArtifactComponent> ent, ref ComponentStartup args)
     {
+        _actions.AddAction(ent, ent.Comp.SelfActivateAction);
         ent.Comp.NodeContainer = _container.EnsureContainer<Container>(ent, XenoArtifactComponent.NodeContainerId);
     }
 
+    private void OnSelfActivate(Entity<XenoArtifactComponent> ent, ref ArtifactSelfActivateEvent args)
+    {
+        args.Handled = TryActivateXenoArtifact(ent, ent, null, Transform(ent).Coordinates, false);
+    }
+
     public void SetSuppressed(Entity<XenoArtifactComponent> ent, bool val)
     {
         if (ent.Comp.Suppressed == val)
index b9db84b58e7c96f5b69bd8aa201cdf6d3bec9587..74a78cee59d5d05df2af351444df80dcea718e0e 100644 (file)
@@ -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
   # 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
index 01a316d7808d7aafc783fb3ad3f4d5b7bc5923ec..e02514d2c2b477058d4d1323ac03dabf5a720783 100644 (file)
       mindRoles:
       - MindRoleGhostRoleFreeAgent
     - type: GhostTakeoverAvailable
-    - type: MovementSpeedModifier
-      baseWalkSpeed: 0.25
-      baseSprintSpeed: 0.5
 
 - type: entity
   id: XenoArtifactOmnitool