State Shift to Random State

Hello everyone, first time poster.


I've been trying to create a state that:


Once expired, will change to another random state. So in other words, the character will be in State A for X turns, and once it expires, they will be in States B-K.


Extremely simply put, it's the 悪夢 (Nightmare?) state from Legend of Heroes: Trails of Cold Steel (閃の軌跡)


Experimenting with the State Common Events on here, I managed something...unfortunately the issues are:


1. When the state expires, the entire party (not just the affected character) goes into the 2nd state.


2. It's 9 or so nested loop statements and extremely unrobust.


Would there be a plugin that can do this much more efficiently?
Hello and welcome!


You can use YEP Buff States Core and this notetag on the state:


<Custom Leave Effect>
var stateIds = [4, 5, 6];
var randomState = stateIds[Math.floor(Math.random() * stateIds.length)];

this.addState(randomState);
</Custom Leave Effect>


In the stateIds array, you will put the ids of the state choices you want to randomly apply. Hope this helps!

Original thread: https://forums.rpgmakerweb.com/threads/state-shift-to-random-state.66415/