Yanfly State/Buff Core, HoT/DoTs killing and reviving target

Sometimes, a damage over time effect will kill an actor then a healing over time effect will save him.


What it will do is do everything that would happen if the target has been killing, including triggering event if actor 0% life, removing MP and TP which result in a big mess.


Is there a way to fix that or i'm stuck again with asking a plugin for a bug that should has been in the base of the plugin?
Its probably due to the lunatic code you're using in the states of the DOT effects that's causing this. Make sure the code checks if the actor is still alive when applied, because if it doesn't, then what you mentioned will always happen.


If you cannot find anything in the lunatic code that is causing this, please post the entire screenshot of the offending states. By default, HP regen won't cause this (as all HP regen is summed up, so -5% HP regen + 5% HP regen = 0% HP regen, so nothing would happen), so it has to be something else.
Its probably due to the lunatic code you're using in the states of the DOT effects that's causing this. Make sure the code checks if the actor is still alive when applied, because if it doesn't, then what you mentioned will always happen.


If you cannot find anything in the lunatic code that is causing this, please post the entire screenshot of the offending states. By default, HP regen won't cause this (as all HP regen is summed up, so -5% HP regen + 5% HP regen = 0% HP regen, so nothing would happen), so it has to be something else.

So it mean the hpgain effect will remove the death state and all l have to do is a user.isAlive condition on each HoT.


But thats mean the hot happen after the dot so the heal will never happen.


So the best solution would be to add an immortal state when the regeneration happen and if the result goes below 1 hp, kill the actor maybe?
You might want to post a screenshot of your state, might be easier to see what you are suggesting that way. But in theory I think what you mentioned should work. Or, you could just check to see if the user has hp > 0 before you apply positive HP regen in the first place.


Now, if you want the two states to cancel each other out, afraid that's not possible as a built in effect (you might be able to do lunatic code for what to do if another state is present when it runs the code for that state, but that's about it). There's NO way to provide support for everyone's built in lunatic code into the engine. As it is, the way lunatic mode works is it parses each state in order, and applies the effect as it finds them. It has no way to know what you did for that code though, and no way to know to wait or sum up effects, as the code will just run each HP regen as it finds them, and since they are separate states, it will find them at separate times.
I just tested something randomly and it worked


A higher priority will make a state work before the other.


So thats mean by putting HoT as higher priority will never make the scenario that an actor will die and then rez himself from hots.


The only problem with that is the hot won't heal if the actor is already full hp before a dot but l guess this cannot be fixed as theyre different states.
Based on what you posted, there *might* be an ad hoc solution then. However, I don't know enough javascript to tell you how to do it, just the idea.


Idea: Have all your DOT and regen states store their changes to HP in a variable, then give every actor an invisible state (probably best done as a passive state via Yanfly's scripts, so no one can remove it, ever) set at priority 1 (should be so low that no states are below it), which only applies the change to HP from that variable. The problems I can see are how to initialize the variable, that might require a second passive at priority 99 (higher than all states) to set it to 0 every round. Could work, in theory, but I don't know enough JavaScript to show you via code.
Good idea, this will work for sure.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-state-buff-core-hot-dots-killing-and-reviving-target.65752/