Hello,
I need help improving a condition I found on the Yanfly site.
This is the "Auto life" state which allows you to instantly resuscitate a character mit KO (or rather, it prevents him from dying).
Here is the code:
This effect works very well when the character's HP is reduced to 0. My problem is that it does not work on instant death effects. For example, for an attack that directly inflicts the "Dead" state. The character is KO and the "Auto life" state simply disappears.
Can anyone modify the code to correct this problem please?
I need help improving a condition I found on the Yanfly site.
This is the "Auto life" state which allows you to instantly resuscitate a character mit KO (or rather, it prevents him from dying).
Here is the code:
Code:
<Category: Bypass Death Removal>
<Custom Deselect Effect>
// Check if the target's HP is 0 or is currently in the death state.
if (target.hp <= 0 || target.isDead()) {
// Play the auto-life animation on target.
target.startAnimation(260);
// Set the amount of HP recovered to 20%.
var rate = 0.20;
// Calculate the HP healed.
var heal = Math.floor(target.mhp * rate);
// Remove the Auto-Life state.
target.removeState(stateId);
// Heal the target.
target.gainHp(heal);
// Make the damage popup show for the heal.
target.startDamagePopup();
// Clear the target's results.
target.clearResult();
}
</Custom Deselect Effect>
This effect works very well when the character's HP is reduced to 0. My problem is that it does not work on instant death effects. For example, for an attack that directly inflicts the "Dead" state. The character is KO and the "Auto life" state simply disappears.
Can anyone modify the code to correct this problem please?