]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Wizard Mind Swap Spell (#33416)
authorActiveMammmoth <140334666+ActiveMammmoth@users.noreply.github.com>
Mon, 16 Dec 2024 12:12:45 +0000 (07:12 -0500)
committerGitHub <noreply@github.com>
Mon, 16 Dec 2024 12:12:45 +0000 (15:12 +0300)
* working mind swap spell

* Removing unncessary spacing

Co-authored-by: Thomas <87614336+Aeshus@users.noreply.github.com>
* Changing mind swap speech

Co-authored-by: keronshb <54602815+keronshb@users.noreply.github.com>
* All requested changes in review

* Stores owned by mind instead of body

* Requested changes, traitor uplink fixed

* Revert "Requested changes, traitor uplink fixed"

This reverts commit 2ceac6733d6a28890f60d2ccef3dafa160a702fd.

* Revert "Stores owned by mind instead of body"

This reverts commit dfb72ab70ed66db50312617f2dce02d0a4e4dfce.

* Separate target and performer stun duration

---------

Co-authored-by: Thomas <87614336+Aeshus@users.noreply.github.com>
Co-authored-by: keronshb <54602815+keronshb@users.noreply.github.com>
Content.Shared/Magic/Events/MindSwapSpellEvent.cs [new file with mode: 0644]
Content.Shared/Magic/SharedMagicSystem.cs
Resources/Locale/en-US/magic/spells-actions.ftl
Resources/Locale/en-US/store/spellbook-catalog.ftl
Resources/Prototypes/Catalog/spellbook_catalog.yml
Resources/Prototypes/Magic/mindswap_spell.yml [new file with mode: 0644]

diff --git a/Content.Shared/Magic/Events/MindSwapSpellEvent.cs b/Content.Shared/Magic/Events/MindSwapSpellEvent.cs
new file mode 100644 (file)
index 0000000..8931909
--- /dev/null
@@ -0,0 +1,15 @@
+using Content.Shared.Actions;
+
+namespace Content.Shared.Magic.Events;
+
+public sealed partial class MindSwapSpellEvent : EntityTargetActionEvent, ISpeakSpell
+{
+    [DataField]
+    public TimeSpan PerformerStunDuration = TimeSpan.FromSeconds(10);
+
+    [DataField]
+    public TimeSpan TargetStunDuration = TimeSpan.FromSeconds(10);
+
+    [DataField]
+    public string? Speech { get; private set; }
+}
index 21e137346ef062f972cc779893ac10af492caea4..acedaf05f65755280215aae4646a17a36d757278 100644 (file)
@@ -22,6 +22,7 @@ using Content.Shared.Physics;
 using Content.Shared.Popups;
 using Content.Shared.Speech.Muting;
 using Content.Shared.Storage;
+using Content.Shared.Stunnable;
 using Content.Shared.Tag;
 using Content.Shared.Weapons.Ranged.Components;
 using Content.Shared.Weapons.Ranged.Systems;
@@ -62,6 +63,7 @@ public abstract class SharedMagicSystem : EntitySystem
     [Dependency] private readonly MobStateSystem _mobState = default!;
     [Dependency] private readonly SharedAudioSystem _audio = default!;
     [Dependency] private readonly SharedMindSystem _mind = default!;
+    [Dependency] private readonly SharedStunSystem _stun = default!;
 
     public override void Initialize()
     {
@@ -77,6 +79,7 @@ public abstract class SharedMagicSystem : EntitySystem
         SubscribeLocalEvent<KnockSpellEvent>(OnKnockSpell);
         SubscribeLocalEvent<ChargeSpellEvent>(OnChargeSpell);
         SubscribeLocalEvent<RandomGlobalSpawnSpellEvent>(OnRandomGlobalSpawnSpell);
+        SubscribeLocalEvent<MindSwapSpellEvent>(OnMindSwapSpell);
 
         // Spell wishlist
         //  A wishlish of spells that I'd like to implement or planning on implementing in a future PR
@@ -542,6 +545,37 @@ public abstract class SharedMagicSystem : EntitySystem
         _audio.PlayGlobal(ev.Sound, ev.Performer);
     }
 
+    #endregion
+    #region Mindswap Spells
+
+    private void OnMindSwapSpell(MindSwapSpellEvent ev)
+    {
+        if (ev.Handled || !PassesSpellPrerequisites(ev.Action, ev.Performer))
+            return;
+
+        ev.Handled = true;
+        Speak(ev);
+
+        // Need performer mind, but target mind is unnecessary, such as taking over a NPC
+        // Need to get target mind before putting performer mind into their body if they have one
+        // Thus, assign bool before first transfer, then check afterwards
+
+        if (!_mind.TryGetMind(ev.Performer, out var perMind, out var perMindComp))
+            return;
+
+        var tarHasMind = _mind.TryGetMind(ev.Target, out var tarMind, out var tarMindComp);
+
+        _mind.TransferTo(perMind, ev.Target);
+
+        if (tarHasMind)
+        {
+            _mind.TransferTo(tarMind, ev.Performer);
+        }
+
+        _stun.TryParalyze(ev.Target, ev.TargetStunDuration, true);
+        _stun.TryParalyze(ev.Performer, ev.PerformerStunDuration, true);
+    }
+
     #endregion
     // End Spells
     #endregion
index 21109066d3deb3f57b86a2468b5924c836c1460a..faf5d7743696133185c169dc4218575e4f0e7d59 100644 (file)
@@ -5,3 +5,4 @@ action-speech-spell-summon-magicarp = AIE KHUSE EU
 action-speech-spell-fireball = ONI'SOMA!
 action-speech-spell-summon-guns = YOR'NEE VES-KORFA
 action-speech-spell-summon-magic = RYGOIN FEMA-VERECO
+action-speech-spell-mind-swap = GIN'YU CAPAN!
index dff918b0bc97b85015f82e8337ec135918e7e28b..1450cc86082fe4667eecee21a8783af6f53f7793 100644 (file)
@@ -20,6 +20,9 @@ spellbook-charge-desc = Adds a charge back to your wand!
 spellbook-ethereal-jaunt-name = Ethereal Jaunt
 spellbook-ethereal-jaunt-description = Slip into the ethereal plane to slip away from your enemies!
 
+spellbook-mind-swap-name = Mind Swap
+spellbook-mind-swap-description = Exchange bodies with another person!
+
 # Equipment
 
 spellbook-wand-polymorph-door-name = Wand of Entrance
index 57172dc6657b1e01d1351f2b272fd2ac77a1ee45..d5a9b0f1b9a3a1d751d194a57201bacea2ef94ff 100644 (file)
   - !type:ListingLimitedStockCondition
     stock: 1
 
+- type: listing
+  id: SpellbookMindSwap
+  name: spellbook-mind-swap-name
+  description: spellbook-mind-swap-description
+  productAction: ActionMindSwap
+  cost:
+    WizCoin: 2
+  categories:
+  - SpellbookUtility
+  conditions:
+  - !type:ListingLimitedStockCondition
+    stock: 1
+
 # Equipment
 - type: listing
   id: SpellbookWandDoor
diff --git a/Resources/Prototypes/Magic/mindswap_spell.yml b/Resources/Prototypes/Magic/mindswap_spell.yml
new file mode 100644 (file)
index 0000000..19b3d41
--- /dev/null
@@ -0,0 +1,20 @@
+- type: entity
+  id: ActionMindSwap
+  name: Mind Swap
+  description: Exchange bodies with another person!
+  components:
+  - type: EntityTargetAction
+    useDelay: 300
+    itemIconStyle: BigAction
+    whitelist:
+      components:
+      - Body
+    canTargetSelf: false
+    interactOnMiss: false
+    sound: !type:SoundPathSpecifier
+      path: /Audio/Magic/staff_animation.ogg
+    icon:
+      sprite: Mobs/Species/Human/organs.rsi
+      state: brain
+    event: !type:MindSwapSpellEvent
+      speech: action-speech-spell-mind-swap