Introdução
Este script cria uma barra de HP sobre o monstro, mostrando a Porcentagem, ou o Hp do monstro, sendo isso a sua escolha.
Caracteristicas
- Cores, tamanho e posição customizavel.
- Mostra o Hp com porcentagem, ou em valor absoluto, ou sem valor.
Screenshots
- Spoiler:
Script
- Código:
## Basic Enemy HP Bars ##
# 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
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( 0, 0, 0) #Back of guage(behind hp)
COLOR_HP = Color.new(250, 50, 50) #Color of HP bar
COLOR_HP2 = Color.new(150, 30, 30) #Second HP bar color, for gradient
#-----#
#Sets the parameters of the bar
#-----#
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 = 0 #Offsets location of bar on the y-axis
ABOVE_MONSTER = true #Sets whether to draw bar above or below monster
#-----#
#Deals with displaying hp numbers with the bar
#-----#
DISPLAY_NUMBER= true #True to display enemy's hp in number
SHOW_ABSOLUTE = false #True for absolute hp, false for percentage hp
DISPLAY_ABOVE = true #Display number above or below the hp bar
THRESHOLD = 101 #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
hpwidth = ((BAR_WIDTH - 4) * enemy.hp_rate).to_i
if ABOVE_MONSTER
tmpbit = Cache.battler(enemy.battler_name, 0)
yy = (enemy.screen_y - tmpbit.height) - 35 + Y_OFFSET
if yy < BAR_HEIGHT + 24 then yy = BAR_HEIGHT + 24 end
else
yy = enemy.screen_y + Y_OFFSET
end
xx = enemy.screen_x + X_OFFSET
self.contents.fill_rect(xx, yy, BAR_WIDTH, BAR_HEIGHT, COLOR_OUTSIDE)
self.contents.fill_rect(xx+1,yy+1, BAR_WIDTH-2, BAR_HEIGHT-2, COLOR_INSIDE)
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 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
end
end
class Scene_Battle < Scene_Base
alias hpbar_update update
alias hpbar_create_all_windows create_all_windows
def update
@wdam.update
hpbar_update
end
def create_all_windows
hpbar_create_all_windows
@wdam = Window_HPBar.new
end
end
Créditos
-A VLue por criar o script.
-A Hatsurugi por postar na Aldeia.
Espero que seja de agrado de todos.
De sua atiradora
Hatsurugi