Skill Design - Random Debuff Skill that increases the more its used

Hey y'all! I'm trying to make a skill that gives all enemies a random debuff (this part I have done already, doing it through the damage formula), but I also want to make the skill apply a stackable state to all enemies. Then, if the skill is used again and there is now a state with a counter of 1, then the skill gives 2 random debuffs and adds another stack, if used again, then 3 times, so on and so forth.

I have access to all of YEP's plugins and have been trying to do it through the built-in Counters on the Buffs & States Core, but it doesn't seem to be working, any ideas on how I could go about this idea?

I think it's also worth mentioning that I can't have the state be the thing that applies the random debuff, at least not through normal state properties. This is because I'm trying to have this skill work in tandem with another skill already done, called Unravel that clears all active buffs and debuffs and does damage and heal based on how many of them were cleared (Unravel is basically YEP's Buff Breaker, but in reverse). So the gameplay strat, would be to use this skill, continue to stack random debuffs on the enemy, then wipe them all out with Unravel and do massive damage!

It's probably also worth mentioning that I'd like to do something very similar to this skill with another skill that instead adds random buffs to the party that stacks. If I can potentially use the same state for both, then cool, if not then whatever, I can make two lol.

Please let me know if this is feasible! I'm very new to coding but will try to answer all concept questions possible!
i dont know how your skill looks like, but this should work well enough for what you asked the way you asked it. just change the x's for the state's id, change turns to fit your game, add 0 and 1 to the list of debuffs if you want hp and mp debuffs to be included and i think thats it.

Code:
<After Eval>
var debuffs = [2,3,4,5,6,7];
var turns = 3;

if (target.isStateAffected(x)) target.setStateCounter(x, target.getStateCounter(x)+1 || 1);
else target.addState(x);

target.addDebuff(debuffs[Math.floor(Math.random()*debuffs.length)], turns);
for (var i = 0; i < target.getStateCounter(x); i++){
  target.addDebuff(debuffs[Math.floor(Math.random()*debuffs.length)], turns);
}
</After Eval>
have been trying to do it through the built-in Counters on the Buffs & States Core, but it doesn't seem to be working, any ideas on how I could go about this idea?
Please provide screenshots/copy-paste the notetags that you've made that don't seem to be working.

I think it's also worth mentioning that I can't have the state be the thing that applies the random debuff
That explanation is not clear to me why you can't have the code be on the state.
After trying out the code, it looks like it's working correctly, I will continue to do more testing. Here is a screenshot of the state itself in case you notice anything that would throw the code above off.

What I kinda meant was I was mostly interested in not putting the debuff as like a parameter in the state, because I want it to be cleared with Unravel. If it was a parameter in the state then Unravel wouldn't do anything because it doesn't clear states. That was mostly what I meant, applying the debuff on the state is fine too through the code, just not a parameter thing, if that makes sense lol.

Sorry for any confusion!
After trying out the code, it looks like it's working correctly, I will continue to do more testing. Here is a screenshot of the state itself in case you notice anything that would throw the code above off.
a quick glance under the hood of the buffs and states plugin says that increaseStateCounter isnt a function in it. How did you come by it? Did the console not give an error for that?

since the skill is handling the state counter in this case, trying to add something to increase the state counter on state application will just cause it to double increment. best to either remove that from the state entirely, or fix it, let the state increment itself on application, remove that from the skill, and let the skill only be responsible for applying the state and debuffs(or at that point let state application also apply the debuffs based on its own counter too. just another option)

also did you intend for the state to increase accuracy, or decrease evasion chance?
To be honest, I was working on this skill very late last night and don't really recall where I got that, maybe I saw something while frantically googling? Idk lol, it surprisingly didn't give me any errors for some reason. But I went ahead and did what you said already, all the state does now is just define the counter font size and location, and the skill itself manages all of the effects and counter adding.

Everything works like a charm now, thank you guys so much!

Also, I did originally want it to decrease evasion chance, but I decided against it all altogether, this character is already kinda busted in my opinion lol, it doesn't need another thing.
Also, I did originally want it to decrease evasion chance, but I decided against it all altogether, this character is already kinda busted in my opinion lol, it doesn't need another thing.
its not relevant anymore then. its just "+hit rate" increases the physical accuracy of the battler affected by the state. not their chance to get hit, which is what it had felt like you were going for. Regardless, the problem is solved. Go and make Unravel the monster you intend it to be

Original thread: https://forums.rpgmakerweb.com/threads/skill-design-random-debuff-skill-that-increases-the-more-its-used.162744/