Need a script

I'm trying to create a skill that will check the target's HP, and if it's below 10% then it triggers an event. Can somebody tell me how to script that?
If I'm not wrong, I believe you can do this without a script.

1. Go to "troops"
2. Click on the tab next to "condition"
3. You should see a a bar that says "actor". Click it
4. You can toy around with the conditions like HP percentage
5. From there, simply mess around with events that lead up to that condition

Unless you're asking for this to happen on command, then I'm not sure how to help you. Perhaps a veteran scripter would be more useful than me. Sorry if I caused you any inconvenience!

EDIT: I just realized this is for MV, not VXACE, so I dunno if my "solution" work the same. Good luck finding a proper solution though!
MV does it the same way
I'm not sure how the above is dependent on a skill.

I would attach a common event to the skill, but you'd have to have a way of detecting who the target was.
I think my explanation of what I need might not have been good enough. I'm trying to make a spell called Reapers Grasp. It's a player- specific skill that will check the HP of an opponent, and if its below 10% it will ask if you want to send the target to heaven or hell. Whichever decision you make will kill the target with a specific animation, and change your character's karma level simultaneously. So far the only idea I've worked out is to set an event on each one of my troops which will determine their Max HP at the beginning of the battle and store it in a variable (up to five different Max HP variables for multiple enemies) then switch to another page where it will check their current HP each turn and store it in a separate variable. Then I linked the skill to a common event called Reapers Grasp INI which checks the current HP variables against the corresponding Max HP variables*0.1
If the current HP is less than Max HP*0.1, then it displays the choice of heaven or hell. When you decide, the game does a HP check again on each of the enemies, and turns on either Heaven or Hell switch 1-5 (depending on which targets are determined to have less than 10% HP)
finally, back on the troop page, there is a turn by turn conditional branch stating that if the enemies corresponding heaven/hell switch is on, they burst into flames/light and die, thereby resetting all their relative variables and changing your karma scale.

The only problem I'm running into now is not being familiar enough with java to know exactly what's wrong with the script I wrote. It keeps telling me there's an unexpected token. If someone could simply correct my script for me, and possibly give me ideas on how to ensure that the spell only hits the target rather than all foes below 10%, I would be very grateful.

Reapers grasp INI:
if ($game_variables[1] <= $game_variables[6]*0.1) ({$gameTemp.reserveCommonEvent[2] }) Else ({$gameTemp.reserveCommonEvent[3] })

Reapers grasp success:
if ($game_variables[1] <= $game_variables[6]*0.1) ({ $gameSwitches.setValue (1, true) }) Else ({ $gameTemp.reserveCommonEvent[3] })
no need for all that complexity.
the skill needs to have two effects: an invisible target state for identifying which enemy was targeted and a common event.
the common event needs to check which of the eigth enemies has the target state, and then do the following sequence (needs to be repeated for all theoretical enemies):
1) check is current HP is smaller than MaxHP divided by 10
2) show choice with the options
3) do whatever you want with the target.

If you cannot use common events then you can do something similiar with the damage formula, but in that case the choice can't be done that easily. but you can use if in the damage formula, and b.mhp to get the targets max HP (b.hp is current HP)
Could you give me an example? I'm not sure what you mean by an invisible target state, and I'm also not sure how I would call a common event with the damage formula. This may be the most complex idea I've ever had lol
An invisible target state is a state that does nothing and has no icon or text assigned (resulting in nothing to see if it is added) and has a name like "targeted with skill X". You can then use conditional branch "X has state "targeted with skill X" applied" to identify which of the enemies had been targeted with that skill during the turn (this is needed because common events are executed at the end of the turn, not during the skill sequence).

And the common event is NOT called in the damage formula, it is called in the skill effects.
That is why I said you can't use a choice in the damage formula if you have to go that way - that were two different ways to implement a solution.
But how do I tell the game to only apply the state if they're at or below 10%? And I'd also like the game to relay a message if they aren't at 10% or below stating that's the case. Is that possible?

Edit- never mind, I think I get it actually. Just had to reread lol. I'll check back if anything goes wrong again. Thank you!
just in case you go wrong again:
the target state will always be applied - that is one reason why it has to be invisible and without text.
the check if something is above 10% or not and all messages will be done in the common event if you go that way, but again that might result in something out of sequence and is the reason why I mentioned the other solution by damage formula.
With the damage formula solution you would have to use part of your original idea (switch on a switch as a signal) for the results, but you can use if b.hp<b.mhp/10 (exact syntax depends on which maker your're using) to make the test there.
That worked perfectly! I just had to do kind of a complicated damage formula to ensure that they only get the state at 10% or below HP, that way it doesn't freak out if multiple enemies have it and are below 10%. Thanks again for your help. With this vital component, my project is underway!
@itachi11115 If this has solved your query completely, please Report your opening post and ask for the thread to be closed. Mods might not see an individual post, but will see a Report.

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/need-a-script.97188/