--- /dev/null
+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; }
+}
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;
[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()
{
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
_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
--- /dev/null
+- 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