Timed States

I wish to add a state that counts down 3 turns, now, the engine will let me do this, however, I want that once this state reaches 0 turns, it will activate a skill (along with it showing an animation)...

Thinking of using this for instant deaths and other special game mechanics...
the plugin you might need is buff and state core by yanfly.
while the plugin might be paid, you can let it work with lunatic code
which im bad in. because it require some bit javascript.

peoples that know his plugin can help you with the lunatic code if you explain exactly what need
to be happen using this mechanic.
Yanfly's buffs & states plugin is one of the free ones, so price is a non-issue.

The lunatic code and script call you'd need for a skill to happen when a state runs out should be this one:

Code:
<Custom Leave Effect>
this.forceAction(skillId, targetIndex)
</Custom Leave Effect>

Note that the user of the skill will be the actor/enemy who had the state.

SkillId = Id of the skill you want to be used
targetIndex can probably be left at 0, assuming that the skill has its scope set to 'The User'.
Yanfly's buffs & states plugin is one of the free ones, so price is a non-issue.

The lunatic code and script call you'd need for a skill to happen when a state runs out should be this one:

Code:
<Custom Leave Effect>
this.forceAction(skillId, targetIndex)
</Custom Leave Effect>

Note that the user of the skill will be the actor/enemy who had the state.

SkillId = Id of the skill you want to be used
targetIndex can probably be left at 0, assuming that the skill has its scope set to 'The User'.
This goes in the State's notetag right
Moved to: JS Plugin Requests
Yanfly's buffs & states plugin is one of the free ones, so price is a non-issue.

The lunatic code and script call you'd need for a skill to happen when a state runs out should be this one:

Code:
<Custom Leave Effect>
this.forceAction(skillId, targetIndex)
</Custom Leave Effect>

Note that the user of the skill will be the actor/enemy who had the state.

SkillId = Id of the skill you want to be used
targetIndex can probably be left at 0, assuming that the skill has its scope set to 'The User'.

I placed the code in the state's notetag and nothing happens.

The skill has -9999HP in the Effects box....
It seems that the script call for force action isn't quite as straightforward as I thought.

However, if instant death is what you want, then this should work at least:

Code:
<Custom Leave Effect>
this.addState(1)
</Custom Leave Effect>

Once the state wears of due to turn decay, the actor with the state will be inflicted with state 1 (the death state)

Edit:

I figured it out. Regarding my earlier lunatic code, this should work:

Code:
<Custom Leave Effect>
this.forceAction(SkillId, TargetIndex)
BattleManager.forceAction(this)
</Custom Leave Effect>

As before: SkillId is the Id of the skill you want to be used and TargetIndex determines the target (can be left at 0 if the scope is set to 'the user')
It seems that the script call for force action isn't quite as straightforward as I thought.

However, if instant death is what you want, then this should work at least:

Code:
<Custom Leave Effect>
this.addState(1)
</Custom Leave Effect>

Once the state wears of due to turn decay, the actor with the state will be inflicted with state 1 (the death state)

Edit:

I figured it out. Regarding my earlier lunatic code, this should work:

Code:
<Custom Leave Effect>
this.forceAction(SkillId, TargetIndex)
BattleManager.forceAction(this)
</Custom Leave Effect>

As before: SkillId is the Id of the skill you want to be used and TargetIndex determines the target (can be left at 0 if the scope is set to 'the user')

Ahhh I can do so much with this! Thank you very much <3

*Edit*
Im sorry but theres a tinyyy problem! When all actors are affected, only one dies, how can I make it apply to anyone else who's also infect and whose state expires at the same time?

Example

P1 2 turns left
P2 1 turn left
P3 1 turn left
P4 5 turn left

-NEXT TURN-

P1 1 turn left
P2 *dies*
P3 *doesnt die, state removed*
P4 1 turn left

Original thread: https://forums.rpgmakerweb.com/threads/timed-states.115660/