Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: MarkHest on June 04, 2016, 01:09:12 pm

Title: Conditional Branch for enemy HP
Post by: MarkHest on June 04, 2016, 01:09:12 pm
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 :)
Title: Re: Conditional Branch for enemy HP
Post by: Blizzard on June 04, 2016, 02:39:47 pm
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

Title: Re: Conditional Branch for enemy HP
Post by: MarkHest on June 09, 2016, 04:08:46 pm
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
Title: Re: Conditional Branch for enemy HP
Post by: Blizzard on June 10, 2016, 01:47:47 am
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.
Title: Re: Conditional Branch for enemy HP
Post by: MarkHest on June 10, 2016, 08:26:18 am
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 :)
Title: Re: Conditional Branch for enemy HP
Post by: Blizzard on June 10, 2016, 11:05:12 am
If you are putting it in the conditional branch, it goes with the "if".