User gain state depending on the index targeted

I'm trying to do it using Yanfly's Skill Core


So far i've tried


<Post-Damage Eval>


if (user.lastTargetIndex === 1) {


user.addState(14) }


if (user.lastTargetIndex === 2) {


user.addState(15) }


if (user.lastTargetIndex === 3) {


user.addState(16) }


</Post-Damage Eval>


<Post-Damage Eval>


if (target.Index === 1) {


user.addState(14) }


if (target.index === 2) {


user.addState(15) }


if (target.index === 3) {


user.addState(16) }


</Post-Damage Eval>


<Post-Damage Eval>


if (user.TargetIndex === 1) {


user.addState(14) }


if (user.TargetIndex === 2) {


user.addState(15) }


if ( user.TargetIndex === 3) {


user.addState(16) }


</Post-Damage Eval>


All the rest caused errors, I can't find anything else in objects.
why not have a skill store the current target index, and use the result when the next skill is executed only?


OK, that will probably require additional code in every skill in your project and is a lot of work to implement, but keep this alternative in mind in case you don't find another solution.


Because there might be a problem with when "lasttargetindex" is defined...
I'm using a blank skill first that apply the state.


The point of this is to make players know who the enemy is going to target.
3 days
The variable name is actually _lastTargetIndex, as in user._lastTargetIndex

Original thread: https://forums.rpgmakerweb.com/threads/user-gain-state-depending-on-the-index-targeted.60631/