Deal damage after State ends.

Hi, i've been using Yanfly's Buff & States Core to create a state that takes 3 turns to finish(basically a time bomb).
After it ends, deals damage equals to a variable that counts the amount of times the skill was casted, thanks to Ellye's State Damage.

The problem is that, when the battler aplies the state on a enemy, at the end of the first turn, deals damage even if
the state didn't end.

The way i'm doing this:

1) Created a state called "Time Bomb". Takes 3 turns to dissapear. With Yanfly's Plugin an Ellye's Plugin, I added to the comment box:
<Custom Leave Effect>
<formula: v[1]*5>
</Custom Leave Effect>
2) Created a skill called "Time Bomb". It applies the state "Time Bomb" and runs a common event called "Time Bomb" that adds +1 to a variable, previously set to 0 by a parallel event on the map.

When I test the skill ingame, the battler casts the skill, applies the state and the turns ends normally, except for the state. It deals damage even if the state timer didn't end.

Do you guys think there is a more efficient way to do this?
Thanks!
Moved to: Javascript/Plugin Support
Please edit your post to include links to the web pages where you got those plugins. That way if anyone needs to check something before giving advice, they won't have to go hunting.
It looks like Ellye's plugin may be for specifying damage per turn? 😅

Maybe try something like this instead:
Code:
<Custom Leave Effect>
// calculate damage
var dmg = $gameVariables.value(1) * 5;
// apply damage
user.gainHp(-dmg);
// show an animation~ (optional, of course)
user.startAnimation(2);
</Custom Leave Effect>
Great! That was very useful. Thank you!
Thats kind of cool ! Do you know how to use the attacker mat instead of the variable formula ?

I try something like ...

<Custom Leave Effect>
// calculate damage
var dmg = a.mat;
// apply damage
user.gainHp(-dmg);
// show an animation~ (optional, of course)
user.startAnimation(2);
</Custom Leave Effect>


But thats not the attacker stats, thats the one from the monster...so he doesnt realy work well...
Thats kind of cool ! Do you know how to use the attacker mat instead of the variable formula ?
👋 States don't have an "attacker", since they're not actions. They do have an origin, though, i.e. the one who applied the state. You could try something like this:
Code:
<Custom Leave Effect>
// calculate damage
var dmg = origin.mat * 5;
// apply damage
user.gainHp(-dmg);
// show an animation~ (optional, of course)
user.startAnimation(2);
</Custom Leave Effect>


Edit: oh, but if you're using one of the action-based notetags, e.g. <Custom React Effect>, then you can refer to the current attacker/defender using attacker or defender, respectively. 😅

Original thread: https://forums.rpgmakerweb.com/threads/deal-damage-after-state-ends.109704/