Yanfly Auto Passive States once per battle?

I was wondering if it was possible to make an auto-passive state proc once per battle? I have a passive state that grants the user regeneration once they hit under 25% HP, but I don't want it to continually apply each time they reach that state.

Like I have one passive that auto revives the user, and I want it to be a passive that can only activate once per battle, but currently it just applies the passive whenever condition X is met, so he can essentially endlessly revive.
I was wondering if it was possible to make an auto-passive state proc once per battle? I have a passive state that grants the user regeneration once they hit under 25% HP, but I don't want it to continually apply each time they reach that state.

Like I have one passive that auto revives the user, and I want it to be a passive that can only activate once per battle, but currently it just applies the passive whenever condition X is met, so he can essentially endlessly revive.
I'm also interested in this as well, as I would like to able to make a variety of accessories that either gives the wearer a Buff state at the start of a battle (i.e. Begin the battle with a Attack Up buff that lasts for 5 turns before it wears off) or gives them a Buff state when their HP drops below 25%.
This is pretty easy to do. Create a second dummy state for your regen, and have the passive state apply it as well. Have the passive state check for the 30% threshold and the dummy state. Set this so that if the dummy state is active, then the passive can not be reapplied. This should allow the passive to start the first time the target reaches 30% and lock it out for the rest of the battle. Just make sure that you set the dummy state to be removed at the end of battle.
So on my custom select, I did this.

<Custom Deselect Effect>

// Check if the target's HP is 0 or is currently in the death state.

if ((target.hp <= 0 || target.isDead()) && !target.isStateAffected(27)) {

// Play the auto-life animation on target.

target.startAnimation(49);

// Set the amount of HP recovered to 10%.

var rate = 0.10;

// Calculate the HP healed.

var heal = Math.floor(target.mhp * rate);

// Remove the Auto-Life state.

target.removeState(26);

// Add the dummy state.

target.addState(27);


// 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>

Is that the way I'm supposed to go about it? It seems to work with it now, thankfully. My dummy state is blank though (has no tags besides bypass death tags). It works (revives then doesn't revive anymore), but it also keeps the state icon for some reason on the battle screen when resurrected.

The icon for the passive also doesn't show up anymore when it activates (though it still works)



I also have another effect (this is a buff that applies under 25% hp) that doesn't seem to work though. Maybe I wrote something wrong?


<Custom Passive Condition>
if (!target.isStateAffected(26) && target.hpRate() <= 0.25) {
condition = true;
target.addState(26);
}
else {
condition = false;
}
</Custom Passive Condition>
Doh. I should read everything twice before replying.

Just something I do see right offhand though. Your passive is looking for state 26 but then it also tries to apply the same state when the condition is met. Maybe you mean it should have state 25 and then apply state 26 or something?
Couldn't you do this with troop events? Set a troop event to run if player HP < 25% and the passive state applied, then add regen state? You'd have to make check for each player that can equip the item, but you can do all the checks in the same troop event. Then, just set span of the event so that it only runs the first time it is true, and it should only occur once per battle.

Though you'll have to either put the check in each troop event or use a troop common event plug-in for it to work well, but it can work, as I used something like this to set up one time use skills which trigger automatically if the skill was learned and the condition was met for that skill to trigger.
That's true, I could use the troop event simply as well. I didn't know about that script, so I had been using auto-passives to apply.

My passive looks for state 27(if you don't have it applied) and if that's true (meaning you don't have the dummy on) then it will go ahead with the condition and remove your autolife (state 26) that was applied, then add the dummy state 27, meaning the condition can not go through anymore. Though I'm not sure if I'm messing that up.

Tried the troop events. Works lovely, so I might go with that for now since I can set up events for each passive, though it can get pretty crowded.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-auto-passive-states-once-per-battle.87864/