MZ Get the targeted actor of an item through scripts

Hi. I have an ITEM that is supposed to change the weapon of the actor selected by the player.

I have a common event that checks the current weapons equipped on the selected actor- so, if the actor has two weapons equipped already, it will ask them which weapon do they want to switch.

"Why not just make it a weapon?" -> Because, following the theme of my game, they are not physical weapons but rather "contracts" made with deities to give specific powers. Also, it's sorta of a rogue-lite and characters that die on a run cannot be revived, so I need a way to keep the weapons available on the player's inventory until the run is over.

Besides that, this is a crucial part of the strategy, as each weapon has unique effects and boost specific attributes, so through combat you may need to change your equipped weapon to adapt your strategy against certain enemies, and making an item possible to change it through combat seemed to me like the easiest option available.

Anyway. Said item works just fine while on a battle. Problem is, I'm having trouble to get a reference of the actor selected by the item outside of the battle, while on the Menu Screen.

1755650882345.png


Last action script calls won't work when being activated outside of battle... I was thinking of making a "custom selection screen" but I think it would be too ugly since there is already a "character selection screen" when using items by default.

Is there some hidden variable that hold the information of said character I've selected when using the item, or anything like it? A plugin perhaps?

Thanks!
Off the top of my head, it could $gameParty._menuActorId.
If that doesn't work, might be worth posting what the setup of your item looks like.
Off the top of my head, it could $gameParty._menuActorId.
If that doesn't work, might be worth posting what the setup of your item looks like.
Your answer was very helpful, I didn't think about searching on the $gameParty script calls. Turns out there are these two:

$gameParty.menuActor()
$gameParty.targetActor()

I don't know why the first one didn't work but the second one is working just fine, so thanks a lot 🙂
an indirect alternative has always been the option to add an invisible state "target" as an effect to the item, and then check which actor got said state
if the state has no message and no icon, the player will never learn it was there - you just have to remember to remove it from the actor when your processing is done

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/get-the-targeted-actor-of-an-item-through-scripts.179663/