# (Conditional Branch) check if an actor's HP is full (percentage)?

#### RicoRob

##### Veteran
- Example:

-
I know this code: \$gameActors.actor(n)._hp = x
however I can only replace the x with specific numbers, I want to check for percentages, but I have no idea how.

Is there a way to use only script calls for this? Without storing numbers in variables, adding invisible states and the like?

#### Soulrender

Calculating percentage is simple:

(a / b) * 100

so replace a with \$gameActors.actor(n).hp
then replace b with \$gameActors.actor(n).mhp

multiply it by 100 and you get result in percentage.

Oh, to get more precise result, use Math.floor() function

example:
var x = Math.floor((a/b)*100);

#### ramza

##### Lunatic Coder
hpRate() returns a float of the current HP percentage.

So for your script, use \$gameActors.actor(n).hpRate() == 1

#### Astfgl66

##### Veteran
You can also use
Code:
``\$gameActors.actor(n).hp === \$gameActors.actor(n).mhp``
Edit: oh didn't see it had to be a percentage check, my bad.

#### RicoRob

##### Veteran
@ramza That does the trick!

@Astfgl66 that also works! Just want to check if the HP bar is full.

Thanks everyone!

#### Killerslash

##### Veteran
If I want to make Hp actor is zero, how?

#### Soulrender

\$gameActors.actor(id).gainHp(-\$gameActors.actor(id).mhp);

This will set actor's HP to 0

Thanks

### Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no?
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design...
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??