Autor:
VitorJ
Descripción:
Crea una HUD que muestra la cabeza del chara, HP y PM.
Ademas no solo muestra la HUD del personaje, si no que también demuestra la del resto del grupo.
No necesita imágenes y tiene varias cosas para personalizar.
Imagen de muestra:
Script:
Espero que les guste chavales, hasta pronto.
Saludos.
VitorJ
Descripción:
Crea una HUD que muestra la cabeza del chara, HP y PM.
Ademas no solo muestra la HUD del personaje, si no que también demuestra la del resto del grupo.
No necesita imágenes y tiene varias cosas para personalizar.
Imagen de muestra:
Script:
Código:
#==============================================================================#
# HUD Simples By VitorJ
# Cria uma HUD simples que não despõe de imagen, mas com um design agradavel
# mostrando o HP, MP , EXP, E o grafico do personagen de cada char
# no grupo, ou só do primeiro.
# tem muitas opções para personalizar a seu gosto
#==============================================================================#
# Classes modificadas com esse Script:
# Scene_Map , Game_Actor
#==============================================================================#
module Hud_Edit
START = true # A hud vai começar inicializada? se não, é preciso liga a switch
e = 160 # (Opcional) Coloque aqui o espaço entre uma hud e outra
HUDX = [0*e,1*e,2*e,3*e] # Posição X Da HUD [char1,char2,char3,char4]
HUDY = [10,10,10,10] # Posição Y Da HUD [char1,char2,char3,char4]
SWITCH = 1 # Switch que mostrara a HUD.
FONTNAME = "Palatino Linotype" # Fonte das Letras
EXPX = 0 # Posição X Da Barra de EXP
EXPY = 472 # Posição Y Da Barra de EXP
SP = "SP" # Nome do MP
HP = "HP" # Nome do HP
PARTY = true # Vai mostrar a HUD dos outros membros?
FACE_AJUST = 0 # Coloque um ajuste para face do personagen.
BORD = true # vai usar borda nos textos?
GRADIENT = true # ativar o gradient? se não só vai usar a cor inicial do hp
HP_EFF = 1 # efeito do hp, -1 \====\, 0 |====| , 1 /====/
SP_EFF = 1 # efeito do sp, -1 \====\, 0 |====| , 1 /====/
# Cor das Barras, coloque Color.new(r,g,b,opacity)
C_INI_HP = Color.new(0,100,0) #Cor Inicial da barra de HP
C_FIN_HP = Color.new(253,209,77) #Cor Final da barra de HP
C_INI_SP = Color.new(67,89,153) #Cor Inicial da barra de SP
C_FIN_SP = Color.new(2,58,218) #Cor Final da barra de SP
C_INI_XP = Color.new(198,218,2) #Cor Inicial da barra de EXP
C_FIN_XP = Color.new(232,253,77) #Cor Final da barra de EXP
C_INI_BA = Color.new(255,255,255) #Cor Inicial da borda
C_FIN_BA = Color.new(255,255,255) #Cor Final da borda
BAR_BACK1 = Color.new(100,100,100) # Cor inicial do fundo das barras
BAR_BACK2 = Color.new(100,100,100) # Cor final do fundo das barras
end
class Bitmap
#--------------------------------------------------------------------------
# * Draws a gauge
#--------------------------------------------------------------------------
def draw_gradient_gauge(x, y, width, height, color, color2, dif = 0)
if (dif == 0)
r_add = (color2.red - color.red) / width.to_f
g_add = (color2.green - color.green) / width.to_f
b_add = (color2.blue - color.blue) / width.to_f
if (r_add == 0 and g_add == 0 and b_add == 0)
self.fill_rect(x, y, width, height, color)
return
end
r = color.red
g = color.green
b = color.blue
for i in 0...width
self.fill_rect(x + i, y, 1, height, Color.new(r, g, b))
r += r_add
g += g_add
b += b_add
end
elsif (dif < 0)
real_w = width - dif
return if (real_w <= 0)
temp = Bitmap.new(real_w, 1)
temp.draw_gradient_gauge(0, 0, real_w, 1, color, color2)
for i in 0...height
self.blt(x + i, y + i, temp, temp.rect)
end
elsif (dif > 0)
real_w = width - dif
return if (real_w <= 0)
temp = Bitmap.new(real_w, 1)
temp.draw_gradient_gauge(0, 0, real_w, 1, color, color2)
for i in 0...height
self.blt(x + dif - 1 - i, y + i, temp, temp.rect)
end
end
end
#--------------------------------------------------------------------------
# * Draws a gauge
#--------------------------------------------------------------------------
def draw_gradient_gauge_filled(x, y, width, height, filled, back, color, color2, dif = 0)
if (back.is_a?(Color))
draw_gradient_gauge(x, y, width, height, back, back, dif)
end
return if (filled <= 2)
return if (height <= 2)
if (dif == 0)
r_add = (color2.red - color.red) / width.to_f
g_add = (color2.green - color.green) / width.to_f
b_add = (color2.blue - color.blue) / width.to_f
if (r_add == 0 and g_add == 0 and b_add == 0)
self.fill_rect(x + 1, y + 1, filled - 2, height - 2, color)
return
end
r = color.red
g = color.green
b = color.blue
for i in 0...(filled - 2)
self.fill_rect(x + 1 + i, y + 1, 1, height - 2, Color.new(r, g, b))
r += r_add
g += g_add
b += b_add
end
elsif (dif < 0)
real_w = filled - 2 - dif
return if (real_w <= 0)
temp = Bitmap.new(real_w, 1)
temp.draw_gradient_gauge(0, 0, filled, 1, color, color2)
for i in 0...(height - 2)
self.blt(x + 1 + i, y + i + 1, temp, temp.rect)
end
elsif (dif > 0)
real_w = filled - 2 - dif
return if (real_w <= 0)
temp = Bitmap.new(real_w, 1)
temp.draw_gradient_gauge(0, 0, filled, 1, color, color2)
for i in 0...(height - 2)
self.blt(x + dif - 1 - i, y + i + 1, temp, temp.rect)
end
end
end
end
class Simple_Hud_Sprite < Sprite
include Hud_Edit
def initialize(viewport,actor,pchar)
super(viewport)
self.bitmap = Bitmap.new(640, 480)
self.bitmap.font.name = FONTNAME
self.visible = $game_switches[SWITCH]
@actor = actor
@pchar = pchar
start if actor != nil
end
def start
actor = @actor
@hp = actor.hp
@sp = actor.sp
@maxhp = actor.maxhp
@maxsp = actor.maxsp
@name = actor.name
@level = actor.level
@exp = actor.exp
@gold = $game_party.gold.to_s
draw_char
draw_hp
draw_sp
draw_xp
#draw_name
#draw_gold
end
def draw_char
actor = @actor
x = HUDX[@pchar]
y = HUDY[@pchar]+8
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4 / 2
src_rect = Rect.new(0, 0+FACE_AJUST, cw, ch)
self.bitmap.fill_rect(Rect.new(x, y, cw, ch), Color.new(0,0,0,0))
self.bitmap.blt(x, y, bitmap, src_rect)
end
def draw_name
x = HUDX[@pchar]+8
y = HUDY[@pchar]
end
def draw_hp
x = HUDX[@pchar]+8
y = HUDY[@pchar]
x1 = x
x1 += 1 if HP_EFF < 0
self.bitmap.fill_rect(Rect.new(x-3, y-6, 115, 15), Color.new(0,0,0,0))
self.bitmap.draw_gradient_gauge(x,y,102,8,C_INI_BA,C_FIN_BA,HP_EFF)
x2 = x
x2 += 1 if SP_EFF < 0
x2 -= 1 if SP_EFF > 0
self.bitmap.draw_gradient_gauge(x2+1,y+1,100,6,BAR_BACK1,BAR_BACK2,SP_EFF)
cw = 102 * @hp / @maxhp
ch = 8
self.bitmap.draw_gradient_gauge_filled(x1,y,102,ch,cw,nil,C_INI_HP,C_FIN_HP,HP_EFF)
self.bitmap.font.size = 15
text = HP
size = self.bitmap.text_size(text)
rx = 200 * @hp / @maxhp
draw_text(x-2, y-12,size.width,size.height,text,Color.new(rx+55,0,0,255))
self.bitmap.font.size = 15
text = "#{@hp} / #{@maxhp}"
size = self.bitmap.text_size(text)
c = 255 * @hp / @maxhp
draw_text(x+50, y-8,size.width,size.height, text,Color.new(255,c,c,255))
end
def draw_sp
x = HUDX[@pchar]+32
y = HUDY[@pchar]+20
x1 = x
x1 += 1 if SP_EFF < 0
#x += 1 if SP_EFF > 0
self.bitmap.fill_rect(Rect.new(x-3, y-6, 115, 15), Color.new(0,0,0,0))
self.bitmap.draw_gradient_gauge(x,y,102,8,C_INI_BA,C_FIN_BA,SP_EFF)
t = 0
t = 1 if SP_EFF > 0
x2 = x
x2 += 1 if SP_EFF < 0
self.bitmap.draw_gradient_gauge(x2+1-t,y+1,100,6,BAR_BACK1,BAR_BACK2,SP_EFF)
cw = 101 * @sp / @maxsp
ch = 8
self.bitmap.draw_gradient_gauge_filled(x1+1,y,101,ch,cw,nil,C_INI_SP,C_FIN_SP,SP_EFF)
self.bitmap.font.size = 15
text = SP
size = self.bitmap.text_size(text)
draw_text(x-2, y-12,size.width,size.height,text,Color.new(255,255,255))
self.bitmap.font.size = 15
text = "#{@sp} / #{@maxsp}"
size = self.bitmap.text_size(text)
c = 255
draw_text(x+50, y-8,size.width,size.height, text,Color.new(255,c,c,255))
end
def draw_xp
x = HUDX[@pchar]
y = HUDY[@pchar]+29
w = 32
c = 5
actor = @actor
self.bitmap.fill_rect(Rect.new(x, y, w, c), Color.new(0,0,0,0))
if actor.next_exp != 0
rate = actor.now_exp.to_f / actor.next_exp
else
rate = 1
end
if @actor.level < 99
cw = w * rate
else
cw = w
end
ch = 5
self.bitmap.draw_gradient_gauge(x,y,w,c,C_INI_BA,C_FIN_BA)
self.bitmap.draw_gradient_gauge(x+1,y+1,w-2,c-2,BAR_BACK1,BAR_BACK2)
self.bitmap.draw_gradient_gauge_filled(x,y,(w-2),ch,cw,nil,C_INI_XP,C_FIN_XP)
self.bitmap.font.size = 15
#text = "Level: #{@level}"
#size = self.bitmap.text_size(text)
#draw_text(x, y-8,size.width,size.height, text,Color.new(255,255,255,255))
end
def draw_text(x,y,width,height,text,color)
if Hud_Edit::BORD
self.bitmap.font.color = Color.new(0,0,0,255)
self.bitmap.draw_text(Rect.new(x-1, y,width,height), text)
self.bitmap.draw_text(Rect.new(x+1, y,width,height), text)
self.bitmap.draw_text(Rect.new(x, y-1,width,height), text)
self.bitmap.draw_text(Rect.new(x, y+1,width,height), text)
end
self.bitmap.font.color = color
self.bitmap.draw_text(Rect.new(x, y,width,height), text)
end
def update(pchar)
if $game_party.actors[@pchar] != nil
actor = $game_party.actors[@pchar]
else
actor = $game_actors[0]
end
if @actor != actor
@actor = actor
start
end
if @hp != actor.hp or @maxhp != actor.maxhp
@hp = actor.hp
@maxhp = actor.maxhp
draw_hp
end
if @sp != actor.sp or @maxsp != actor.maxsp
@sp = actor.sp
@maxsp = actor.maxsp
draw_sp
end
if @exp != actor.exp or @level != actor.level
@exp = actor.exp
@level = actor.level
draw_xp
end
self.visible = $game_switches[SWITCH]
end
def need_update?(i)
actor = $game_actors[0]
actor = $game_actors[i] if @pchar != nil
return true if @actor != actor
return true if @hp != actor.hp
return true if @maxhp != actor.maxhp
return true if @sp != actor.sp
return true if @maxsp != actor.maxsp
return true if @exp != actor.exp
return true if @level != actor.level
return true if @name != actor.name
end
end
class Simple_Hud
def initialize
@viewport = Viewport.new(0, 0, 640, 480)
@viewport.z = 9999
@simple_hud = []
@sprites = []
@psize = $game_party.actors.size
if Hud_Edit::PARTY == true
for i in 0...4#$game_party.actors.size
actor = $game_actors[0]
actor = $game_party.actors[i] if $game_party.actors[i] != nil
pchar = i
@simple_hud[i] = Simple_Hud_Sprite.new(@viewport,actor,pchar)
@sprites.push(@simple_hud[i])
end
else
actor = $game_actors[0]
actor = $game_party.actors[0] if $game_party.actors[0] != nil
pchar = 0
@simple_hud[0] = Simple_Hud_Sprite.new(@viewport,actor,pchar)
@sprites.push(@simple_hud[0])
end
@visible = true
end
def update
if @psize != $game_party.actors.size
if Hud_Edit::PARTY == true
for i in 0...@psize
@simple_hud[i].visible = false
end
for i in 0...$game_party.actors.size
actor = $game_actors[0]
actor = $game_party.actors[i] if $game_party.actors[i] != nil
pchar = i
@simple_hud[i].update(i)
end
else
actor = $game_actors[0]
actor = $game_party.actors[0] if $game_party.actors[0] != nil
pchar = 0
@simple_hud[0].update(0)
end
else
if Hud_Edit::PARTY == true
for i in 0...$game_party.actors.size
@simple_hud[i].update(i)
end
else
@simple_hud[0].update(0)
end
end
end
def dispose
for sprite in @sprites
next if sprite.nil?
sprite.dispose
end
@sprites = []
end
def need_update?
if Hud_Edit::PARTY == true
for i in 0...$game_party.actors.size
return true if @simple_hud[i].need_update?(i)
end
else
return true if @simple_hud[0].need_update?(0)
end
return false
end
end
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
class Scene_Map
$vjhud = false if $vjhud == nil
alias simple_hud_main main
def main
if Hud_Edit::START and (not $vjhud)
$vjhud = true
$game_switches[Hud_Edit::SWITCH] = true
end
@hud = Simple_Hud.new
simple_hud_main
@hud.dispose
end
alias simple_hud_update update
def update
@hud.update if @hud.need_update?
simple_hud_update
end
end
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
class Game_Actor < Game_Battler
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
Espero que les guste chavales, hasta pronto.
Saludos.