How can I make enemies HP remain the same after escaping battles?

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
76
Reaction score
9
First Language
English
Primarily Uses
RMMV
Hi guys! I have a question that I'm curious about that I haven't seen answered on this forum...

As the title says, I'm wondering how I can make the HP of an enemy remain the same after the player has escaped from a battle, instead of it going back to full health again.

If there isn't a plugin for this, I hope this is easy enough to achieve.

I'd super appreciate any help! <3
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
649
Reaction score
362
First Language
English
Primarily Uses
RMMV
Depends on how your battles are setup. If they're just random encounters, I don't see this being possible, so I can only assume you must have encounters on the map.

If all your encounters are unique troops, you could maybe have a couple troop events to set each enemy's HP to a variable at the end of each turn and set a switch unique to that troop on, then have a turn 0 troop event that checks if the switch is on and sets each enemy's HP equal to their various variables if it is. Something like:

Code:
Turn 0:
If (switch[1] on) {
  enemy1 HP = variable 1
  enemy2 HP = variable 2
} else {
  switch[1] = on
}

Turn 1 + X:
variable 1 = enemy1 HP
variable 2 = enemy2 HP

If your encounters are not unique troops, then you'd have to know how to tell the difference between one instance of the troop and the next, which means you'd end up with a set of variables for each evented encounter.

As an example, suppose you have a troop that has 2 bats in it, with two events on the map that both make use of that troop. If you fight the 2 bats in the first event, you have to make sure you're not carrying the health values over to the second, so each event would need to keep track of its own set of troop health variables.
 

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
76
Reaction score
9
First Language
English
Primarily Uses
RMMV
Thank you so much!

Yes, the enemies are on the map so that makes this possible. ^_^

I'm getting there with this but I have two problems... (I hope this makes sense...)
1) I've successfully set the enemy HP to a variable at the end of each turn, but I'm having trouble calling that variable at Turn 0. I see an event command that allows me to "Change Enemy HP" to a variable. That works, but that only allows increase or decease. I want it to be equal to. I must be looking in the wrong place?
2) When the battle starts, the enemy HP doesn't instantly change. I'm using Yanfly's Visual HP Gauges so you can see the enemy has full HP for a moment before it changes. What's the easiest solution to make this instant?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,887
Reaction score
8,240
First Language
German
Primarily Uses
RMMV
That works, but that only allows increase or decease. I want it to be equal to.
Mathematics
all enemies start at max value, if you want them to have a specific value instead you'll have to use control variables commands to calculate the difference and then decrease the enemy by that difference.

as for the gauge - if that is created in the setup for the battle before the troop event takes place, then the only way to change that behaviour is to modify the plugin - either to delay the display or to give a script command that would work before the battlesetup.
I can't tell you which way to go because I don't know how yanfly programmed the plugin.
 

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
76
Reaction score
9
First Language
English
Primarily Uses
RMMV
Mathematics
all enemies start at max value, if you want them to have a specific value instead you'll have to use control variables commands to calculate the difference and then decrease the enemy by that difference.

Haha, mathematics!! That's the one word I feared. :D This seems so much more complicated than I hoped it would be. I've stored the enemy HP in a variable when the player escapes the battle, and all I want to do is call that exact variable when the player goes into battle with the enemy again, and have its HP be the exact same as it was when the player escaped. I really hope there's an easier solution for this.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
649
Reaction score
362
First Language
English
Primarily Uses
RMMV
I installed Yanfly's Battle Engine Core and Visual HP Gauges into a new project and tried the following two troop event pages:

QcRLt7d.png

ORIkpgY.png

You can directly set an enemy's HP with a bit of JavaScript code. I'm assuming that you know what variable maps to what enemy index in your troop if you're doing something similar, so you can set that index's _hp property based on the corresponding variable.
Code:
var enemies = $gameTroop.members(); // This gives you an array of all the Game_Enemy instances in the current troop
// Arrays start at 0, so the first enemy in the troop is 0, the second is 1, etc.
// You'll want to replace "8" with whatever variable you're storing this enemy's HP in
// Also note that the property is _hp, not hp. enemies[0].hp cannot be used to set a value.
enemies[0]._hp = $gameVariables.value(8);

It looks like the Visual HP Gauges Plugin will automatically redraw the gauge when the enemy's HP is changed this way.

One thing you'll have to figure out is how to handle enemies that were killed previously, since when you start a battle, they all get revived and returned to full health. I added some logic to my first troop event page that checks each enemy's HP after setting them with variables and, if they're supposed to be dead, adds the death state and performs the collapse animation. You could use the JavaScript snippet I have in my screenshot, or you could do the same like so:

F32gx10.png


If you want the enemies to be dead and not appear at all if they were killed in the previous encounter, I think you'll need a Plugin to handle that logic.
 
Last edited:

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
76
Reaction score
9
First Language
English
Primarily Uses
RMMV
Awesome!! This works now. I appreciate your help, Zevia!

Just need to figure out how to make Yanfly's HP Gauge redraw the gauge instantly so we don't see the HP as full before the Turn 0 switch triggers. I'll attempt to modify the plugin and see if I can do it, but if anyone here knows how to do it, please let me know. I'd super appreciate it.
 

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
76
Reaction score
9
First Language
English
Primarily Uses
RMMV
Aside from the Yanfly HP Gauge problem I mentioned above, I also have another issue... I've set the enemy HP as as a variable in an event on the map/field outside of battle, but it isn't recognizing it. (I'm using the Orange HUD plugin to show the variable and it just appears as 0 HP. I also see enemies are just appearing as '?' below instead of their name in the database.)

HWWu86c.png


I've been googling this and it seems RPG Maker MV only allows you to set variables for enemies in the actual Troops menu, and not on the map/field. It would be AWESOME if there is a way to get around this though because I'm hoping to use the Orange HUD to show the enemy data on the map/field.

And again, thanks for all the help. <3
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
649
Reaction score
362
First Language
English
Primarily Uses
RMMV
To clarify your ask: suppose you have a troop of 2 bats. You have one event on the map that represents that encounter, and no other events reference that troop. If the player encounters that troop and, say, kills 1 bat and brings the other down to 50 HP, then you want the ability to show the state of that troop on the map.

Can you provide some screenshots/mockups of how the Orange HUD works and maybe what you'd like to see as an end result?
 

Latest Threads

Latest Profile Posts

Stop shutting the damn power down! Why always like this
Working on a slightly experimental horror game. It will be finished in approximately 88888888888 years.
Y'all will enjoy it though, I put lots of effort into making it stand out.

It's called Red Light and it's inspired by another obscure RPG Maker horror game, but I don't want to give too much away just yet.
Ohh man, Weapon animations plugin feels so mandatory. Seeing that same image regardless of the icon of the weapon....ugh :p
Ok so......Maaaaybe I've taken a ''little'' bit of inspiration from FF9 when it comes to battle hud xD

ff9.PNG

Just maybe....

Forum statistics

Threads
112,354
Messages
1,067,709
Members
146,003
Latest member
Oudi
Top