Enemy HP Bars

Vlue

Talent Extraordinaire
Member
Joined
Mar 13, 2012
Messages
589
Reaction score
382
First Language
English
Primarily Uses
Basic Enemy HP Bars v2.1
Basic Enemy HP Bars Lite v1.0.2

by V.M.
Introduction
Provides basic hp gauges over enemies in battle with options for displaying percentage or absolute value of remaining hp, as well as customizing color, size, and position. And now with the option to use a custom image from file!

New Lite version without the option for a customizable gauge, for use with Sleek Gauges

Features
- Plug and play with default settings
- Customizable colors, size, position
- Can display remaining hp as percentage or absolute value
- Can use custom image from file

Screenshots
How to Use
Plug and play, no editing required for default bars.
Customization can be found right in the script with comments explaining the values.

Script
Convenient pastebin right... over there >> Here!
And to play around, a image file I made for the custom image feature:


Lite version: http://pastebin.com/dEkBwmPw


FAQ
None Available

Credit and Thanks
- By V.M. of D.T.
- Free to use in any project with credit given
 
Last edited by a moderator:

DarkWaker

Villager
Member
Joined
Mar 21, 2012
Messages
9
Reaction score
1
First Language
English
Primarily Uses
This is a great script! Awesome! :)
 

amerk

Veteran
Veteran
Joined
Mar 13, 2012
Messages
1,433
Reaction score
495
First Language
English
Primarily Uses
Very simple but effective. I like the setup with the rats (2nd screenshot) the best, mainly because it's based on a percentage of remaining health.
 

Chaos17

Dreamer
Veteran
Joined
Mar 13, 2012
Messages
1,311
Reaction score
485
First Language
French
Hi,

How can I move the percentage to be at the same level as the bar ?

I want like to put the percentage at the right of the bar, next to it.
 
Last edited by a moderator:

Vlue

Talent Extraordinaire
Member
Joined
Mar 13, 2012
Messages
589
Reaction score
382
First Language
English
Primarily Uses
Hi,

How can I move the percentage to be at the same level as the bar ?

I want like to put the percentage at the right of the bar, next to it.
Get the newest version and play with the values under XT_OFFSET and YT_OFFSET to move the percentage to wherever you want to.
 

Chaos17

Dreamer
Veteran
Joined
Mar 13, 2012
Messages
1,311
Reaction score
485
First Language
French
It's good and now how can I change the font size, please ?

I tried to change the number 24 in the script but it didn't change the size and the number was cut in half.
 

Vlue

Talent Extraordinaire
Member
Joined
Mar 13, 2012
Messages
589
Reaction score
382
First Language
English
Primarily Uses
It's good and now how can I change the font size, please ?

I tried to change the number 24 in the script but it didn't change the size and the number was cut in half.
Below the line "percentage = enemy.hp_rate * 100" Add "self.contents.font.size = ##" Where ## is equal to the font size you want.
 
Last edited by a moderator:
Joined
Apr 30, 2012
Messages
216
Reaction score
35
First Language
Spanish
Primarily Uses
This is a great script! Thanks you very much Vlue.
 
Last edited by a moderator:

Kaiser

Veteran
Veteran
Joined
Mar 20, 2012
Messages
1,578
Reaction score
79
First Language
English
Primarily Uses
I got scared by the spider screenshot ;_; but this is a really good script, been wanting to show enemy health bars so players (or even myself) has that sense of "is it dead yet!?"
 

Morpheus

Jack-of-Trades
Veteran
Joined
Mar 14, 2012
Messages
237
Reaction score
85
First Language
english
Primarily Uses
N/A
How do I make it display the actual HP of the enemy and not percentages?

Nevermind.
 
Last edited by a moderator:

deilin

Ranger/Elementalist
Veteran
Joined
Mar 13, 2012
Messages
1,188
Reaction score
172
First Language
English
I modified the script to do some extra stuff.

if interested...

Screens:





Script:

## Basic Enemy HP Bars (DeiLin mod)
### Adds slightly customizable hp bars to enemies in battle. See configuration
# below for more detail.
## Usage: Plug and play, no editing required.
#------
##-- Script by: V.M of D.T
#--- Free to use in any project with credit given
#Edited by DeiLin
#no outside bars anymore
#Now can do MP and TP as well
#----------------------------------
#can exclude enemy id to show none on certain enemies by changing the 0 in
# " and enemy.enemy_id != 0"
# to a specific enemy id to have no bars appear
#in my troops, this ID is what spawns, then on turn 0,
#they morph to other enemies, and the bars appear.
#the morph script is in the troop event to randomize troop encounter
#also, it says "enemy" appears then what will actually appear until they do like
#the half hide option.
#-------------------------------
#This script also colors your bars with similar colors.
#--------------------------------
class Window_HPBar < Window_Base
#-----#
#Sets the colors for the frame and hp bars: (Values in RGB mode, 0-255)
#-----#
$COLOR_OUTSIDE = Color.new( 0, 0, 0) #Border of guage
$COLOR_INSIDE = Color.new(255,255,255) #Base of guage(between hp and border)
$COLOR_BACK = Color.new( 50, 0, 0) #Back of guage(behind hp)
$COLOR_HP = Color.new(250, 50, 50) #Color of HP bar
$COLOR_HP2 = Color.new(250, 200, 200) #Second HP bar color, for gradient
$COLOR_BACK2 = Color.new( 0, 0, 50) #Back of guage(behind mp)
$COLOR_MP = Color.new(50, 50, 250) #Color of MP bar
$COLOR_MP2 = Color.new(200, 200, 250) #Second MP bar color, for gradient
$COLOR_BACK3 = Color.new( 0, 50, 0) #Back of guage(behind hp)
$COLOR_TP = Color.new(50, 250, 50) #Color of TP bar
$COLOR_TP2 = Color.new(200, 255, 200) #Second TP bar color, for gradient
#-----#
#Sets the parameters of the bar
#-----#
WITH_BORDER = true
BAR_HEIGHT = 8 #Sets the height of the bar(Value of 5 or greater)
BAR_WIDTH = 75 #Sets the width of the bar(Value of 5 or greater)
#-----#
#Sets the location of the bar
#-----#
X_OFFSET = -35 #Offsets location of bar on the x-axis
Y_OFFSET = -35 #Offsets location of bar on the y-axis
ABOVE_MONSTER = false #Sets whether to draw bar above or below monster
#-----#
#Deals with displaying hp numbers with the bar
#-----#
WITH_MP = true #Displays enemies MP bar
WITH_TP = true #Displays enemies TP bar. will be right under hp if mp isn't active
DISPLAY_NUMBER = true #True to display enemy's hp in number
SHOW_ABSOLUTE = true #True for absolute hp, false for percentage hp
DISPLAY_ABOVE = true #Display number above or below the hp bar
THRESHOLD = 20 #Only show number if hp below this percentage
#(101 to disable)
#-----#
def initialize
super(0,0,544,416)
self.z = 0
self.opacity = 0
end
def update
refresh
end
def refresh
self.contents.clear
for enemy in $game_troop.members
if enemy.hp_rate != 0 and enemy.enemy_id != 3
$bh = BAR_HEIGHT
$bh = $bh + 5 if WITH_MP
$bh = $bh + 5 if WITH_TP
hpwidth = ((BAR_WIDTH - 4) * enemy.hp_rate).to_i
mpwidth = ((BAR_WIDTH - 4) * enemy.mp_rate).to_i
tpwidth = ((BAR_WIDTH - 4) * enemy.tp_rate).to_i
if ABOVE_MONSTER
tmpbit = Cache.battler(enemy.battler_name, 0)
yy = (enemy.screen_y - tmpbit.height) - 35 + Y_OFFSET
yyy = enemy.screen_y + Y_OFFSET + 4
yyyy = enemy.screen_y + Y_OFFSET + 4 #no mp bar
yyyy = enemy.screen_y + Y_OFFSET + 8 if WITH_MP #mp bar active
if yy < BAR_HEIGHT + 24 then yy = BAR_HEIGHT + 24 end
else
yy = enemy.screen_y + Y_OFFSET
yyy = enemy.screen_y + Y_OFFSET + 4
yyyy = enemy.screen_y + Y_OFFSET + 4 #no mp bar
yyyy = enemy.screen_y + Y_OFFSET + 8 if WITH_MP #mp bar active
end
xx = enemy.screen_x + X_OFFSET
$bh = BAR_HEIGHT
$bh = $bh + 4 if WITH_MP
$bh = $bh + 4 if WITH_TP
self.contents.fill_rect(xx, yy, BAR_WIDTH, $bh, $COLOR_OUTSIDE) if WITH_BORDER
self.contents.fill_rect(xx+1,yy+1, BAR_WIDTH-2, $bh - 2, $COLOR_INSIDE) if WITH_BORDER
self.contents.fill_rect(xx+2,yy+2, BAR_WIDTH-4, BAR_HEIGHT-4, $COLOR_BACK)
self.contents.gradient_fill_rect(xx+2,yy+2, hpwidth, BAR_HEIGHT-4, $COLOR_HP, $COLOR_HP2)
if WITH_MP
self.contents.fill_rect(xx+2,yyy+2, BAR_WIDTH-4, BAR_HEIGHT-4, $COLOR_BACK2)
self.contents.gradient_fill_rect(xx+2,yyy+2, mpwidth, BAR_HEIGHT-4, $COLOR_MP, $COLOR_HP2)
end
if WITH_TP
self.contents.fill_rect(xx+2,yyyy+2, BAR_WIDTH-4, BAR_HEIGHT-4, $COLOR_BACK3)
self.contents.gradient_fill_rect(xx+2,yyyy+2, tpwidth, BAR_HEIGHT-4, $COLOR_TP, $COLOR_HP2)
end
if DISPLAY_NUMBER
percentage = enemy.hp_rate * 100
if DISPLAY_ABOVE then yy -= BAR_HEIGHT + 24 end
if SHOW_ABSOLUTE
draw_text(xx,yy+BAR_HEIGHT,width,24,enemy.hp)
elsif percentage < THRESHOLD
draw_text(xx,yy+BAR_HEIGHT,width,24,percentage.to_i.to_s + "%")
end
end
end
end

Code:
EDIT: Re added the outside border option, and it will adjust to wether or not MP and TP are shown
 
Last edited by a moderator:

Jetstopia

Villager
Member
Joined
Sep 6, 2012
Messages
22
Reaction score
1
First Language
English
Primarily Uses
I had trouble getting the Basic Enemy HP Bars v1.1 by V.M. (First script) to work as a Plug and Play script (I also have ZERO scripting experience and don't plan on getting involved anytime soon).

I got a dynamic constant assignment error for line 51: for Enemy in $game_troop.members

I did a quick look on the net and found someting about capital letters and dynamic constant assignment errors so changed it to this:

51: for enemy in $game_troop.members

simple matter of chaning the 'E' in Enemy to a 'e' and it worked fine after that.

I can't get the DeiLin (second script) to work though. It has the same Enemy/enemy change that needs to be made (Line 71)

After that I get a syntax error on line 118. After a little search I found that it is because the 'end' terms are not right or something but I haven't got it to work.

All I wanted was an energy bar for enemies though, and the first one by V.M works fine now after that line 51 fix.

Thanks

EDIT:

I have also found that when V.M's script is on you can not cancel an action in a battle window. Such as selecting 'Magic' then wanting to go back a menu screen.

I got around this by copying the entire Scene_Battle script and pasting it above V.M's script. Far from an elegant solution but it got the job done for now.
 
Last edited by a moderator:

Chickan117

Villager
Member
Joined
Sep 17, 2012
Messages
5
Reaction score
2
First Language
English
Primarily Uses
This script is fantastic :) So nice and simple.

I was wondering; is it possible to make the enemy HP display as current / max. So 37/150 for example?

I'm new to scripting and tried a couple of things that seemed logical without success. I couldn't even get it to add a string to the end of the number displayed! Lol
 

Vlue

Talent Extraordinaire
Member
Joined
Mar 13, 2012
Messages
589
Reaction score
382
First Language
English
Primarily Uses
Change the line that reads:

draw_text(xx + XT_OFFSET,yy+YT_OFFSET+BAR_HEIGHT,width,24,enemy.hp)

To read:

draw_text(xx + XT_OFFSET,yy+YT_OFFSET+BAR_HEIGHT,width,24,enemy.hp.to_s + "/" + enemy.mhp.to_s)
 
Last edited by a moderator:

Chickan117

Villager
Member
Joined
Sep 17, 2012
Messages
5
Reaction score
2
First Language
English
Primarily Uses
Looks like I'd done all the code right... except adding .to_s (which I assume converts the values to a string).

Thank you so much! This really helps make the game look that much better :)
 

Jonathang

Level 3 Beginner EXP: 36%
Veteran
Joined
Aug 17, 2012
Messages
53
Reaction score
3
First Language
English
Primarily Uses
Does this script work for the Side battle system? (Showing HP % left)

Hm it doesn't seem to work because of an error in line 80....

Is there a script like this for the Side battle system script?
 
Last edited by a moderator:

Vlue

Talent Extraordinaire
Member
Joined
Mar 13, 2012
Messages
589
Reaction score
382
First Language
English
Primarily Uses
That was a weird coincidence, I spend the morning rewriting the entire thing and someone posts! Oh well.

New version up, 2.0, that I've completely rewritten. Just all around better and easier (hopefully) to use, as well as a nice little feature to use a custom image file as an hp bar!

And just as it happens I made a very simple one just for random use: http://i1175.photobu...e/Custom_HP.png

As for your error Jonathang, I'm not sure. If you tell me what the error says however, I can tell you if it's fixable or not (Or you can grab the new version and see if that helps)
 

Jonathang

Level 3 Beginner EXP: 36%
Veteran
Joined
Aug 17, 2012
Messages
53
Reaction score
3
First Language
English
Primarily Uses
Whoops, used it in the wrong RPM engine..... I used it in XP, sorry, it worked for ace BTW. Love the script :D , and sorry for my carelessness....

EDIT: Hello Vlue, I think I can think of a new feature for the script (Sorry if it has been implemented). You see, in my game when an enemy dies, they can revive. I want the revived enemies to have the bar, but the bar doesn't appear... Again, I'm sorry if it was actually a feature already, but if its not, I'd appreciate it if you added the feature. Thank you for your attention. :)
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Gamedev for relaxing? yes or no?
I've been having a rough couple of months and as such let down some friends of mine in the RPG Maker community. I still need time to get back to my normal self, but it's nice to be back, to read articles, and to design again (albeit at a slow pace). Hope to give updates on Kid Crescent soon.
Friendly reminder that you don't have to be able to do absolutely everything. It's okay to scale back features or assets if things are too much - especially if you're the only one working on the game! And you can always add things in later. <3
My new cutscene system makes it so much easier to add parallel stuff happening in the background, I can easily fill the whole screen with action.

I remember once when I was at Disney's Animal Kingdom and I got to dance with some of the cast members! It was so much fun! After the show my dad and I got frozen lemonade and some ice cream. It makes me feel better remembering the good things about my dad... maybe I will return to Orlando.

Forum statistics

Threads
107,734
Messages
1,031,726
Members
139,867
Latest member
angeallen
Top