## 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