Conditional Branch for enemy HP

Started by MarkHest, June 04, 2016, 01:09:12 pm

Previous topic - Next topic

MarkHest

Hi. I need a small script to put into a conditional branch to check whether an enemy's HP is 0 or not. I need this because during a battle i'm making an enemy will be change every time he reaches 0Hp and then heals. I'm gona make this conditional branch check every turn of the battle. I can't use the event to check HP because it only does it once and then no more.
Thanks :)
   

Blizzard

If IS kinda weird that this isn't possible through events.
Use this to get the enemy HP:


$game_troop.enemies[INDEX].hp


And this is obviously how you check the HP value:


if $game_troop.enemies[INDEX].hp <= 0

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

MarkHest

June 09, 2016, 04:08:46 pm #2 Last Edit: June 09, 2016, 04:09:51 pm by MarkHest
Doesn't that check the HP of the entire troop? I need the HP of one specific enemy only.
How do I use this code? :P
   

Blizzard

No, it just checks one enemy in the troop. Hence the INDEX parameter. You use it just like I wrote it down above and change INDEX to the index number of the enemy. e.g. 0 is the first, 1 is the second, etc.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

MarkHest

June 10, 2016, 08:26:18 am #4 Last Edit: June 10, 2016, 08:28:19 am by MarkHest
I'm not sure I'm doing this right...

if $game_troop.enemies[2].hp <= 0 should be in the conditional branch, right? When I put it there I get an error that says "The script is hanging"

EDIT: Nevermind, I got it to work. Thanks a lot :)
   

Blizzard

If you are putting it in the conditional branch, it goes with the "if".
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.