State that when wears off play a skill

Hi ! i am using almost all plugins of Yanfly (Battle Core, Buff and States etc....)
And i want to do a state that when it wears off will do a skill.

For exemple this state can be put on a foe and will stay for 3 turns then damage him when the state wears off.

Is someone know a code that can do this ? It will help me a lot.

Thanks in advance.

I've moved this thread to Plugin Requests. Thank you.

Yep, easily done with Buff/States. Make sure you have the state set to last 3 turns, or however many you plan.

Spoiler: Quick Draft
<Custom Leave Effect>
// Get the damage skill.
var skill = {{INSERT SKILL NUMBER HERE}};
// Get the 'self' index.
var target = 0;
// Queue the forced action.
BattleManager.queueForceAction(user, skill, target);
</Custom Leave Effect

If that doesn't work let me know, I'll play around with it for you.
Yep, easily done with Buff/States. Make sure you have the state set to last 3 turns, or however many you plan.

Spoiler: Quick Draft
<Custom Leave Effect>
// Get the damage skill.
var skill = {{INSERT SKILL NUMBER HERE}};
// Get the 'self' index.
var target = 0;
// Queue the forced action.
BattleManager.queueForceAction(user, skill, target);
</Custom Leave Effect

If that doesn't work let me know, I'll play around with it for you.

Hi artoni, thanks for help ! Sorry for the place of the post, it's my first one here.

It work good but the problem now is the damages. I did a Trap, it wears off after 3 Turns but then when the skill plays there is no damage.
My formula is a.mat * 4 - b.mdf * 2. I don't know if its a problem of formula here or that the code you give me just loose who is "a" and who is "b"
I am terrible with coding, i am learning by myself ^^

In this spell i use a formule of Yanfly to make the spell having a critical damage if the ennemy is on Fire.
So basicaly my trap will deal damage after 3 turns and can be critical if the foe is on Fire.

Thanks for your help
Well, for one, I forgot to add the last > on </Custom Leave Effect> - whups.

You might want to consider creating a new skill with ActSeqPack as well; below is a skill I have that does damage to the person who uses it (for a battle cutscene).

Spoiler: Bad Flare
<Setup Action>
display action
perform start
motion chant: user
wait: 20
motion spell: user
wait: 20
</Setup Action>

<Target Action>
animation 58: user
WAIT: 20
action effect: user
motion damage: user
WAIT: 20
</Target action>

<Finish Action>
clear battle log
perform finish
</Finish Action>

Alternatively, see if the scope "The User" works?
Mhh, didn't change anything but i figure it out by myself

I put this code :

<Custom Leave Effect>
target.startAnimation(67)
user.gainHp(-1 * origin.mat * 4 + target.mdf *2)
target.startDamagePopup()
target.addState(16)
</Custom Leave Effect>

Now eveything is fine the foe takes damages, then he get on fire. The only thing now that change is that the spell is not aymore a Fire element
and it will not deal critical if the foe is already on Fire. But i don't know if it's important. So let's say that my problem is solved ^^

Thank you a lot for your attention, it helped me to understand more about the codes and how it works 😉

Original thread: https://forums.rpgmakerweb.com/threads/state-that-when-wears-off-play-a-skill.104347/