How to transform an enemy back to its original form when player has more than 50% HP?

I can easily transform the enemy when the HP of the player is below 50%, but when the player gets healed and their HP becomes more than 50% the enemy doesnt revert back to its original form.
What I want to do:
When player has less than 50% HP -> Enemy transforms
When player has more than 50% HP -> Enemy goes back to original form
The battle would be like that until the enemy is defeated

Any help? Thank you
There are ways to do it without scripts such as converting the enemy's Max HP and Current HP into variables and then comparing them every turn, but the easiest and most accurate way to do it, by far, is Hime's Custom Page Conditions script. Use it. It's quite possibly the single most globally useful script ever made for Ace.

The syntax you'll want to use to check the enemy's HP rate is: $game_troop.members[x].hp_rate * 100 > 50 where "x" is the zero-based Index of the enemy (so if it's the first enemy in the troop, x should be 0; if it's the second enemy, x should be 1, etc.).

The battle would be like that until the enemy is defeated

In order to allow this to happen multiple times without repeatedly trying to process every time, you could set a Switch ON or OFF based on whether the enemy is currently transformed, and use that Switch as a second Page Condition (easy to do with that script). So whenever the Switch indicates that he isn't transformed, but his HP Rate is under 50%, he transforms, then you set the switch to note that he's transformed. And whenever it indicates that he is transformed, but his HP rate is over 50%, he un-transforms (transforms back to his original form), and you set the switch back to note it.
Thanks for responding.
It still doesnt what I want, or at least Im not understanding it well.

After the <page condition> I did a condition where I put the script you gave me and in the exception put the transformation back to the original from.
When I started the battle the enemy instantly transform even though my character had 100% HP.
After trying different methods I couldnt get it to work :/
I just saw your quotation so I tried but it still doesnt work, I dont quite understand how I have to do it.
Here's how I have the events. The first one is for when it is not transformed and the second when it is transformed.
a1.PNG
a2.PNG
Your "official" Page Condition is "No escapar" which I'm guessing translates to "Do Not Run" or similar. Both your official Page Condition and your custom Page Conditions must be true in order to run the event. Reserve a Switch and turn it ON at the beginning of the game (and also turn it on at the beginning of each battle if you want, so that you can test it inside the editor properly), and use that Switch being ON as the official page condition, in addition to your custom conditions.

Also, all event content inside the Custom Page Conditions will be ignored. Place the event body AFTER the entire conditional branch(es) that make up the Custom Page Conditions.

Additionally, it looks like you have two pages, and Page 2 only requires that Switch 250 is set a certain way (encendido). Now, since Page 1 is going to set that Switch to encendido as soon as it runs, so Page 2 will run immediately after and transform the battler back. The correct way to set it up would be to have each page have two Custom Conditions as such:

PAGE ONE
Page Condition: Switch X "Always On" is ON ..... Span: MOMENT
Comment: <page condition>
Conditional Branch: If HP is less than 42% (your syntax is correct)
End Branch
Comment: <page condition>
Conditional Branch: If Switch Y "Has Already Transformed" is OFF
End Branch
Transform Enemy (to the "transformed" type)
Set Switch Y to ON
Wait 1 frame (not necessary, but I like doing this just to make sure the event won't try to start itself again immediately)

PAGE TWO
Page Condition: Switch X "Always On" is ON ..... Span: MOMENT
Comment: <page condition>
Conditional Branch: If HP is more than 42%
End Branch
Comment: <page condition>
Conditional Branch: If Switch Y "Has Already Transformed" is ON
End Branch
Transform Enemy (to the "normal" type)
Set Switch Y to OFF
Wait 1 frame (again not necessary but preferred)

I hope this helps you get it working! 🙂
I did it exactly as you said and also tried putting them inside the branches and whatnot and it still doesnt work.
The enemy doesnt even transform this time 🙁
a1.PNG
a2.PNG
It's weird that it doesn't work; your eventing looks solid this time.

The only two things I can think of offhand would be that the script was copied into the Script Editor incorrectly (or had a conflict with another script, which is unlikely), or that Switch 250 isn't ON when you start the battle. Try adding an event page that runs on Turn 0 (with no other conditions) that turns that Switch ON. See if that helps.

If that doesn't work, the way I like to solve mysterious problems like this is to kind of go through one step at a time and see which one is causing the issue. For example, I might add a Sound Effect to each page, right underneath the Page Conditions, to see if the page is running at all. If not, I might remove one or both Custom Page Conditions on each page, to see if those are causing the page to not run when it should run. Stuff like that.

Anyone else have ideas about what might be going wrong here? 🙁
Ok so I tried some of those methods you said and it appears that the pages dont event start running at all but I think I'll just do another thing for the fight cause I have to get this donde before monday. Anyway thank you very much for your help, I really appreciate it!!
In the end I did that the enemy transforms every few turns and then transform back every another few turns. We can close this thread now
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/how-to-transform-an-enemy-back-to-its-original-form-when-player-has-more-than-50-hp.103544/