Vlue

VMoDT Enemy HP Bars

69 posts in this topic

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
ENEMYHP1.pngENEMYHP2.pngENEMYHP3.png



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: Custom_HP.png

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 Edited by Vlue

Share this post


Link to post
Share on other sites

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.

Vlue likes this

Share this post


Link to post
Share on other sites

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.

Edited by Chaos17

Share this post


Link to post
Share on other sites

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 likes this

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Edited by Vlue
Chaos17 likes this

Share this post


Link to post
Share on other sites

This is a great script! Thanks you very much Vlue.

Edited by Megablackdragon31
Vlue likes this

Share this post


Link to post
Share on other sites

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!?"

Vlue and Jonathang like this

Share this post


Link to post
Share on other sites

How do I make it display the actual HP of the enemy and not percentages?

Nevermind.

Edited by Aaronc53

Share this post


Link to post
Share on other sites

I modified the script to do some extra stuff.

if interested...

Screens:

deux_gague01.png

deux_gague02.png

deux_gague03.png

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

EDIT: Re added the outside border option, and it will adjust to wether or not MP and TP are shown

Edited by deilin
Puppet of Fate and Roxas162 like this

Share this post


Link to post
Share on other sites

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.

Edited by Jetstopia

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Edited by Vlue
Chickan117 likes this

Share this post


Link to post
Share on other sites

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 :)

Vlue likes this

Share this post


Link to post
Share on other sites

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?

Edited by Jonathang

Share this post


Link to post
Share on other sites

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 likes this

Share this post


Link to post
Share on other sites

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. :)

Edited by Jonathang
Vlue likes this

Share this post


Link to post
Share on other sites

Hey, I modified the script just a bit to enable the use of simple critical HP display (the bar change's color when the enemy's hp is under certain threshold). Still, 99.9% of the script is V.M.'s original, and I don't claim credit or need to be credited in anyway ever. Hope someone gets benefitted.

http://pastebin.com/CyskpRTJ

Thanks for that script, V.M., helped my a lot.

Share this post


Link to post
Share on other sites

First, thanks for this nice script.

But, i only want to show enemy HP bars in Bossbattles. can someone tell me, how to use with scan state ?

Share this post


Link to post
Share on other sites

Set Scane state to say.. 20 and make a dummy state on state id 20 in the database that is applied to all bosses.

Share this post


Link to post
Share on other sites

can you make a scrip like that but the enemy in maps... i'm using khas battle engine ... please..

Share this post


Link to post
Share on other sites

That should be something you ask of the author of that script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.