[Solved] Yanfly Buff States Core: Custom Apply to Change State Duration

Hey there, everyone! I've run into a little dilemma!

So, I have a state where the duration is supposed to be equal to the afflicted's Luck stat, and Yanfly's Buffs States Core has a feature that should be absolutely perfect for making this work. However, when I've attempted to apply this, it doesn't really work as intended.

For testing purposes, I've set the state's auto-removal to 1 turn, so that way I know that if it disappears at the end of the turn, the script didn't work. Strangely, however, instead of the buff lasting one turn or the amount of turns equal to the user's luck (in this case, 2), it just lasts forever. It's definitely a start since this effect implies that it's doing something, but given it's far from the result I desire, I was hoping someone around here might be able to catch where I went wrong here.

Thank you!
1578031018199.png


Edit: Okay, so I've discovered something while trying to debug this. If I set the turn length to 1, the state will last 1 turn no matter what (regardless of what I set the state duration as in the database). However, setting it to 2 does not have this effect, and the state continues infinitely. I have no idea why it would occur this way, but at least I've made a little progress in figuring this out.

Edit 2: OKAY I FIXED IT! Basically, the state was applied from a common event that occurred whenever the user attacks which would increase a variable and check if the variable was high enough to apply the state. For testing, I made the variable 1, which meant that every time the character attacked while in the state, it would reapply the state from scratch.

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/solved-yanfly-buff-states-core-custom-apply-to-change-state-duration.116903/