MV Evolving a stacked up Chill State to a Freeze State [Help]

So the idea is to get state "Chilled" change/evolve after enough stacks to state "Frozen".
If my character uses Frost Bolt it has a Duration of 3 Turns. This stacks thanks to YEP Plugins, so if this stack reaches the number 5 the target gets frozen.
I've searched through the internet for hours now, but my miserable .js skills don't really help me to achieve my goal...

I've found this under a Driftwood Video about Frozen to Drench State:
"you could do this with the "BuffsStatesCore" plugin, I use literally the same mechanic: Use this code in the freeze state, put every fire skill you got in the bracket(101, 102, 103, 104, ...):
<Custom React Effect>
if (this.isSkill( 101, 102, 103, 104)) {
target.removeState(74);
target.addState(77); }
</Custom React Effect>


And this in another Help Thread on this forum about dealing damage equal to the stacked number of a state:

"Buffs and States core has a build in 'counter' function, which can be used to add stacks to a state. In using this, you only need one state, not (up to) 10, and reapplying the state will increase the counter of that state automatically. You can then use a custom turn end effect to deal damage directly to affected battlers, using the number of stacks the state has as the base for the damage dealt.


<Custom Apply Effect>
target.addStateCounter(38, 1); //38 is the number of the state
if (target.getStateCounter(38) > 10){
target.setStateCounter(38, 10)}
</Custom Apply Effect>
<Custom Turn End Effect>
var rnd = 20 //the variance of the damage you want to deal
var formula = Math.round(15 * this.getStateCounter(38)); // this state will do 15 damage per stack. modify as you see fit
var total = Math.floor(formula * ((Math.random()*(rnd * 2)+(100-rnd))/100) // this should make the effect deal damage with 20% variance
this.gainHp(-total);
this.startDamagePopup();
if (this.isDead())
{
this.performCollapse();
}
</Custom Turn End Effect>
<Custom Leave Effect>
//this is so that the effect deals damage on the last turn it is active
var rnd = 20
var formula = Math.round(15 * this.getStateCounter(38));
var total = Math.floor(formula * ((Math.random()*(rnd * 2)+(100-rnd))/100)
this.gainHp(-total);
this.startDamagePopup();
if (this.isDead())
{
this.performCollapse();
}
</Custom Leave Effect>"

So I thought adding both together will have the wanted effect, but not RPG Maker MV's watch...
//15 = Chilled //16 = Frozen

<Custom React Effect>
if (target.getStateCounter(15) > 5){
target.removeState(15);
target.addState(16);}
</Custom React Effect>


Any help would be nice 🙂
The stacks increase when the state is applied, so maybe try something like this:

<Custom Apply Effect> target.addStateCounter(15, 1); if (target.getStateCounter(15) >= 5) { target.addState(16); target.removeState(15); } </Custom Apply Effect>
I.e. when the Chilled state is applied to a target:
  • +1 to their counter for state 15 (Chilled);
  • If that counter is now 5 or more...
    • Add state 16 (Frozen); and
    • Remove state 15 (Chilled).

Original thread: https://forums.rpgmakerweb.com/threads/evolving-a-stacked-up-chill-state-to-a-freeze-state-help.145549/