[MV] Trying to use Yanfly's Auto Passive States to call a Common Event.

Hi, I'm trying to have a passive state on an actor that calls a common event when they go below 50%HP.

I can make the passive state activate when they go below 50%HP, I can call the common event using skills, but I can't get the state to call the common event when it's activated. The common event is changing the actors image and stats.

My code is just
<Passive Condition: HP Below 50%>
<Custom Apply Effect>
$gameTemp.reserveCommonEvent(2);
</Custom Apply Effect>

Please if anyone has any idea where I'm going wrong, please let me know.
Even just how to change an Actors Battler and Face image with a state.

I've tried to add the code from http://www.yanfly.moe/wiki/Actor_Transformations_(MV_Plugin_Tips_&_Tricks) but I think I'm an idiot because adding this into the state notetag box doesn't work either even without the HP Below 50% specification.
Passive states don't apply or remove - they're always on the actor and they toggle on and off.
Instead, try this notetag in a passive state:
Code:
<Custom Respond Effect>
if (target.hp<target.hp/2 && !$gameSwitches.value(X))
{
    $gameSwitches.setValue(X, true);
    $gameTemp.reserveCommonEvent(2);
}
else if (target.hp>=target.hp/2 && $gameSwitches.value(X))
{
    $gameSwitches.setValue(X, false);
    $gameTemp.reserveCommonEvent(ID);
}
</Custom Respond Effect>

Replace X with the ID of a game switch you're not using for anything else. The second part, after else if is assuming you want to undo the transformation if their health goes back up. I provided the code to turn the switch back off, but you'd have to insert the ID of the appropriate common event there.

If more than one actor can do this, they'll each need their own passive state and common events.
Thank you for the quick response!

I've tried adding the following as a note-tag in the passive skill (after removing everything else from it) but it didn't seem to activate the common event still. I just used a blank switch, number 1000.
<Custom Respond Effect>

if (target.hp<target.hp/2 && !$gameSwitches.value(1000))

{

$gameSwitches.setValue(1000, true);

$gameTemp.reserveCommonEvent(2);

}

else if (target.hp>=target.hp/2 && $gameSwitches.value(1000))

{

$gameSwitches.setValue(1000, false);

$gameTemp.reserveCommonEvent(3);

}

</Custom Respond Effect>
The Common event is ◆Change Actor Images:Actor1, Faceset6(2), None, Actor2_2
with no trigger selected, though even if I run it with needing the switch, nothing happens.

Do you know where I could be going wrong? Does Custom Respond Effect require a plugin I may have missed?
It requires Yanfly's Buffs & States Core, I did fail to mention that in my previous post.

There's also a typo in my code - hp can never be less than hp/2, nor can it ever be >= hp/2, right? Mathematically impossible.

That should read target.hp<target.mhp/2 and target.hp>=target.mhp/2
Thank you so much! That works like a charm now! This is a big issue solved for me thank you again!

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/mv-trying-to-use-yanflys-auto-passive-states-to-call-a-common-event.158978/