I'm trying make you can stack a debuff (like poison or bleeding), and when get enough stacks, it explodes (the debuff dissapear) doing lots of damage to the creature what had that debuff.
The problem is, I don't know how make the debuff explode when reach certain stacks and dissapear, doing the damage.
I'm using VisuStella MZ T1 plugins
I assume you mean states. It's usually done something like this:
<JS On Add State>
target._poisonStacks = target._poisonStacks || 0;
target._poisonStacks++;
if (target._poisonStacks >= 5) {
delete target._poisonStacks;
target.gainHp(-100);
target.removeState(X);
}
</JS On Add State>
<JS On Erase State>
delete target._poisonStacks;
</JS On Erase State>
EDIT: Added line to remove state (replace X with state Id). Also, if you want animation to play when it "explodes", add the script line: $gameTemp.requestAnimation([target], animationId);
There's 2 notetags, both go to states' notes. You need VS Skills & States Core.
The code is like create your own property on the battler, make it keep its value (or create it and set it to 0 if it doesn't exist). Then increase the property by 1. Then check if the value is 5 (or more) and run the effects. Actually I think you don't even need the delete part in the 'if' part, because the remove state gets run which deletes it, but it doesn't matter because there shouldn't be a problem deleting a property that doesn't exist.
I tested it and it seems to work for me.
Show some screenshots. Also, did you make sure that you're adding the state?
Not sure what you mean? You need to apply it 5 times. Are you using the skill that causes the state 5 times? If you are, then you need to show some screenshots.
The VS state display stuff is independent of the turn counters. Put it in the add state notetag that I posted earlier (below code needs stateIds and X changed):
<JS On Add State>
target._poisonStacks = target._poisonStacks || 0;
target._poisonStacks++;
let displayN = target.getStateDisplay(stateId) || 0;
target.setStateDisplay(stateId, displayN+1);
if (target._poisonStacks >= 5) {
delete target._poisonStacks;
target.gainHp(-100);
target.removeState(X);
}
</JS On Add State>
Don't understand what your problem with the icon is?
If you want it to do like "poison"-damage every turn, you can use the slip damage notetags. Like state notetags, I think it's:
<JS HP Slip Damage>
damage = 15 * target._poisonStacks;
</JS HP Slip Damage>
<JS Slip Refresh>