How do I save a spellcaster's ID into a variable?

Hello, everyone! Good afternoon! Sorry to be bothering you all again so soon!

So, I'm trying to make a spell that forcibly equips a weapon onto the hand of whoever cast it, and although I've got most of what I want to do to achieve that figured out, I'm having immense trouble making the spell actually identify who's casting it!

Which is why I've decided I need the caster's actor ID! Having that, I can set up common events and conditional branches that allow the desired effect to take place!

Is there a way to save a caster's actor ID? Maybe in the damage formula?

Thank you for the time!
Hiya!

I believe RPG Maker MV came with some DLC plugins by default that you can add, from the 'KadokawaPlugins' folder in the DLC folder. (This is the case on Steam, so I'm not sure how a standalone installation handles it)

But here, there's a LastSubjectActor.js plugin, that allows you to save the ID of the last person who acted into a variable of your choice. Which I believe would be what you were looking for in this case, correct?

I think there's other ways you can handle this too by having a dummy state be applied to whoever casts the spell and then verifying from there in a common event, but the LastSubjectActor.js way may be the most elegant!
You can definitely do what @FrigidGaze suggests, use that plugin and then a common event that equips the item.

You could also just stick it in the damage formula of the skill, presuming it does damage of some type.
Code:
$gameVariables.setValue(69, a.actorId()); your formula here
that will put the actor's ID into variable 69.

Or, if you're going to use any plugin, I'd suggest using Yanfly's Skill Core to just do everything in one step. Give the skill the notetag:
Code:
<After Eval>
user.forceChangeEquip(0, $dataWeapons[69]);
</After Eval>

And that will equip weapon ID 69 after using the skill, presuming weapon is still the first equip slot.
Code:
$gameVariables.setValue(69, a.actorId()); your formula here

This can be a lot easier:
Code:
v[69] = a.actorId() ; your formula here

However, note that this skill (with my formula, or ATT's formula) can only be used by ACTORS and not by ENEMIES, since they have no actor ID. I don't know if the engine will crash or just ignore it when an enemy uses the skill, though, but it is important to keep that in mind.

If enemies are supposed to use this skill, you need to make a different version of the skill to be used by enemies.
and as a last option if you have problems with scripting or plugins, there is a way to identify the caster (or any skill target) by applying an invisible state.

you'll need a target state that does nothing and has no icon or message. have the skill place that state on its target (which is set to user usually).

then in the common event, you make one conditional branch for each possible actor checking if that actor has the state. if yes you have identified the target and can do in the branch whatever you want.
Unfortunately it gets rather tedious if you have a lot of actors in the game.
Thanks for the help, everyone! You guys are the best!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-save-a-spellcasters-id-into-a-variable.162200/