Return Target Index Before Performing Action

Yoraee

Veteran
Veteran
Joined
May 29, 2016
Messages
211
Reaction score
486
Primarily Uses
Hi all

I am trying to determine if there's a way to obtain the enemy target index of a skill before the skill is executed. After I select my skills for all actors and determine the targets, the data must be stored somewhere I'm assuming. I just can't figure out where.

Some searching has led me to BattleManager._action._targetIndex, but as I understand the index is returned after performing the skill in this case. Using the damage formula is no good either as it needs to run before the target index us returned.

Could it be somewhere in the $gameActors.actor()._actions[] array? I know the selected skill ids are stored there, so maybe the target indexes as well?

Any help or hints are appreciated!
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
If you use Yanfly buffs and states core, you can try to find it through Custom initiate effect notetag, because the user's target will surely hold his ID somewhere inside himself.
 

Yoraee

Veteran
Veteran
Joined
May 29, 2016
Messages
211
Reaction score
486
Primarily Uses
I've looked through the buffs and states core plugin and what I found was target.index(), but I can't seem to find where target itself is defined.

Some searching has led me to BattleManager._subject.currentAction().makeTargets().clone()[0]._enemyId, which returns the enemy id (not the index but I can live with that) of the current actor's target. It even returns the value before the actor even executes the skill.

I am certain the IDs for all actors' target IDs are stored in an array somewhere. Can't figure out where though!
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
You can grab that info in the actor action array.
Code:
$gameActors.actor(actorId)._actions[actionIndex]._targetIndex
I ran an event at turn start: it runs before any action take place. I had it send to the console actor 1, and then pause combat execution by putting a message. The actor action array contained the info you seek each time. The battle manager action object contains only the action being processed. In that case it was appropriately empty (null) because the event runs before any action can take place.
You have to keep in mind though that if the target dies or is rendered untargetable before the action can take place, it will select another target at random once the action is executed.

Disclaimer: I use a lot of yanfly's plugins, so that info may not translate in a vanilla game.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top