Setting Enemy HP as a Variable

Hyrte

Villager
Member
Joined
Dec 25, 2017
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hello,
I am new to RPG Maker MV and am trying to set up a system to detect when an enemy has less than 50% health left. I wanted to make a variable to detect the enemies max HP using Control variables and using the game data option, but in the enemies tab it only has question marks, it doesnt say the enemies names (i.e #1 Bat), so as a result the variable doesnt work. I know I can use script like $gameTroop.members()[1].mhp to get max hp, but Im using action based battle system, so I'm dealing with enemies rather than troops. Any help/advice would be appreciated. Thanks!!
upload_2017-12-25_1-14-27.png
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I would do that in the troop event, not in a separate on map event.
In the troop event, set your variable to the specific enemy you want to check in turn zero.
On a new page, set the condition as turn 1 plus 1, and the span to Turn.
Have a conditional check the variable to see if it is equal to or less than 50% of the HP (has to be done by a number, not a percentage).
If yes, do stuff,
If not, do other stuff.
 

Hyrte

Villager
Member
Joined
Dec 25, 2017
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
I would do that in the troop event, not in a separate on map event.
In the troop event, set your variable to the specific enemy you want to check in turn zero.
On a new page, set the condition as turn 1 plus 1, and the span to Turn.
Have a conditional check the variable to see if it is equal to or less than 50% of the HP (has to be done by a number, not a percentage).
If yes, do stuff,
If not, do other stuff.
Thanks for the reply and the help! My only issue is that since I'm using action based system, there aren't really any turns or a battle sequence. From what I've tried, making events in the troop section doesnt do anything for me since my characters don't encounter troops per say (since they dont enter a battle), rather they just encounter events that mimic enemies (not troops) (by creating an event and making a note <enemy:[id]> as shown in my initial picture). Thanks for your help, but it didn't seem to do the trick. Any other suggestions from you or anyone else? Thanks for all the help!
 

Hyrte

Villager
Member
Joined
Dec 25, 2017
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
I would do that in the troop event, not in a separate on map event.
In the troop event, set your variable to the specific enemy you want to check in turn zero.
On a new page, set the condition as turn 1 plus 1, and the span to Turn.
Have a conditional check the variable to see if it is equal to or less than 50% of the HP (has to be done by a number, not a percentage).
If yes, do stuff,
If not, do other stuff.[/QUOTE
Thanks for the reply and the help! My only issue is that since I'm using action based system, there aren't really any turns or a battle sequence. From what I've tried, making events in the troop section doesnt do anything for me since my characters don't encounter troops per say (since they dont enter a battle), rather they just encounter events that mimic enemies (not troops) (by creating an event and making a note <enemy:[id]> as shown in my initial picture). Thanks for your help, but it didn't seem to do the trick. Any other suggestions from you or anyone else? Thanks for all the help!
action battle system (ABS), sorry for the mistype
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Even if you are using an ABS system, you have to have a troop event in the database even for a single enemy because otherwise, what do you input when you use the Battle Processing command? That always and invariably asks you to designate a troop if you want to have a battle of any description. What you are doing is simply using a form of evented battle which operates the same whether it is turn based or ABS. If you don't have turns, then try setting the span to 'Moment' instead.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
By default, enemies only exist in troops within a battle. So any commands that relate to enemies can only be run within troop events.

If you are using some other system to show enemies on the map, then you are also using some other system to keep track of the enemy's stats, so you'll have to revert to that system instead of Game Data.
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,704
Reaction score
2,208
First Language
English
Primarily Uses
RMMV
Use Yanfly's Self Switches and Self Variables plugin. This will allow you to create localized variables for all of your enemies stats like HP. If you have lots of the same enemy used over and over again, I'd recommend Galv's Event Spawner so that you can create one copy of an enemy and reuse it wherever you need.

If you do spawn in enemies, make the first event tab run a parallel process to Initialize all of an enemy's stats and then self switch to the next tab when that's done.
 
Last edited:

Hyrte

Villager
Member
Joined
Dec 25, 2017
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
Thanks for all the help everyone. Awesome community. Shaz, your method worked, I ended up going into the ABS plugin I was using and figuring out a way to set current enemy hp as a variable. Thanks!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top