event trigger by player HP

I want to make an event which will walk around normally
but if player enter the map with low HP the event will come to player to say sth
how can I achieve this?
This is going to be an ugly bit of code, just letting you know. All you have to do is listen close, and then copy/paste the code. Here are the instructions.
On the event that is supposed to approach the player, set their trigger to parallel process. In their event code, create a conditional branch.
In the settings for the branch, go to the fourth tab.
Select the last option, 'script'.
Past the following string of code.
$gameActors.actor($gameParty._actors[0]).hp < $dataClasses[$gameActors.actor($gameParty._actors[0])._classId].params[0][$gameActors.actor($gameParty._actors[0])._level] *.25

That statement will create a condition that goes like this:
If the FIRST player in your party has a current HP that is less than 25% of their maxHp

Any code you put inside of that branch will run if the FIRST CHARACTER IN THE PARTY has less than 25% HP.
If you want a different percentage, simply change the .25 to that value (eg 50% = .50, 10% = .10)

If you need the code to behave differently or more specifically/flexibly, let me know and we'll try to work on a different solution.

Also, of course, if you're confused with my answer, I understand, I'm happy to clarify
no need for such a mess of code, it can easily be done with event commands alone

you make an autorun events somewhere near the point where the player will enter the map.
1) control variable: Player HP (get that from the game data section of the command, no need for a script)
if neccessary, use several control variable commands for mathematics to calculate percentages
2) conditional branch to check if the value is low or not, if it is then remote-control the other event to approach the player.
thanks so much for the reply!

I think both of the method will work!
but maybe the one using code is too complicate to me haha
@arashiya I looked around a good bit trying to remember how to find Max HP through event codes, I forgot it was only through the control variable function, that is a much more user-friendly solution. It's been so long since I used many of the event commands, I do a lot of my work trhough script.

@Andar lol I already referred to it as a 'ugly bit of code', you didn't help anything by mentioning my code as a 'mess'. I acknowledged that it may look intimidating, and offered the user any clarification or further assistance. However, thank you for reiterating my point by repeating it back in a slightly different form <3

Original thread: https://forums.rpgmakerweb.com/threads/event-trigger-by-player-hp.110564/