Yanfly Buffs & States Core: how do you subtract a state turn for a user's state when the skill's tar

I poured myself over the documentation and code attempting to figure out how to do this. I'm at a loss... 


Basically, I have a state called surge that I use to Instant Cast Eval a skill. So as long as the user has the surge state, whatever skill is being used is an instant cast. I am using turns as though they are stacks, and attempting to remove a turn upon using specific skills.


Ex. Leo has 3 turns on Surge. He uses Heavy strike (which is setup to remove 1 turn of surge) and that uses 1 turn of Surge. He uses Second Wind (which is instant cast but isn't setup to remove any turns) and that uses no turns of Surge. Leo then follows up with 2 more Heavy Strikes and that removes the Surge state from Leo leaving him one more action before ending his turn.


Now the note tags:


<State 12 Turns: -1> 


Only affect the scope/target. So if I add this note tag to Heavy Strike, it will attempt to remove 1 turn of surge from the enemy I just targeted. I want the use of this skill to remove 1 turn from the user of said skill... How do I do that?


Thanks in advance!
Yup, Yanfly's notetags are very flawed and can only affect the target. Unfortunately, we can't guess the script call either to make the user loses a turn state due to useless documentation on his plugins.


What l did to fix this is instead of turns, I used a counter.


So everytime you do an instant attack that shouldn't be instant, each skill should look like this


<After Eval>


user._Surge = user._Surge || 0;


user._Surge = user._Surge - 1


user.setStateCounter(X,user._Surge)


if (user._Surge <= 0) {


user.removeState(X) }


</After Eval>


The surge skill should have this:


<After Eval>


target._Surge = 3


target.setStateCounter(X,target._Surge)


</After Eval>


No duration unless you want it to expires after some turns.


Didn't test so there might be a bug, just let me know if it's not working properly.
Thanks for all the help!


I gave this a spin this morning before work and it functioned as expected; though I will need to tweak a few things on my end before it behaves visually like I want it to. Every turn I add the surge state manually at level 5 to imitate Extra Attacks from D&D (if you couldn't tell that's what I am doing here... imitating a fighter's Action Surge ability). So, what this looks like is the turn count on the state icon's right side and the counters we are manipulating at the bottom, lol. I will see about just moving everything state related to counters and nixing the turn count all together. Your approach is definitely the way to go. Thanks again.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-buffs-states-core-how-do-you-subtract-a-state-turn-for-a-users-state-when-the-skills-tar.71745/