Giving Actors a Chance to Revive, but not Enemies

Hello,

I am looking for a way to give Actor's a chance to revive, but not have the same apply to enemies.

By using Yanfly's Buffs and States Core, I was able to make it so there was a 5% chance of revival after 3 turns of being Knocked Out (State 1). If you were not revived in those 3 turns, you will Die (State 2).

Code:
<Custom Leave Effect>
var chanceDie = Math.random();
if (chanceDie < 0.95)) {
target.addState(2);
}
</Custom Leave Effect>

However, I don't want this to apply to Enemies, only Actors. However, no matter how I seem to write the custom script, it just doesn't seem to work.

I am open to using any of Yanfly's plugins.

Link to plugin referenced earlier: http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/
Hello,

I am looking for a way to give Actor's a chance to revive, but not have the same apply to enemies.

By using Yanfly's Buffs and States Core, I was able to make it so there was a 5% chance of revival after 3 turns of being Knocked Out (State 1). If you were not revived in those 3 turns, you will Die (State 2).

Code:
<Custom Leave Effect>
var chanceDie = Math.random();
if (chanceDie < 0.95)) {
target.addState(2);
}
</Custom Leave Effect>

However, I don't want this to apply to Enemies, only Actors. However, no matter how I seem to write the custom script, it just doesn't seem to work.

I am open to using any of Yanfly's plugins.

Link to plugin referenced earlier: http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/

Code:
<Custom Leave Effect>
var chanceDie = Math.random();
if (chanceDie < 0.95 && target.isActor()) {
 target.addState(2);
} else {
 target.addState(2);
}
</Custom Leave Effect>
@Isabella Ava Thanks for the help, but I've tried this exact script before, and enemies still revive.

Edit: I will note they revive every time, so the check is working fine, it's the "else" that isn't, in this case.
Yanfly has a tutorial on this very effect (Living Dead) but you may want to alter it such that it doesn't need healing but instead relies on a chance value.

I've also noticed that Isabella's code checks for the target; target in a state means the other battler involved in that case. user is what is used for the owner of a state (this is reversed in React checks).
It appears to have worked by switching target to user. I was certain I tried that before, but I guess not!

Thanks!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/giving-actors-a-chance-to-revive-but-not-enemies.101130/