#================================================= =============================
# ★ RGSS2
#enemy # STR15_ HP Gauge v1.1 08/08/10
# Suporte: http://strcatyou.u-abel.net/
#
# Inimigos mostram uma barra de HP.
# Ela aparece quando eles levam um hit.
#
#------------------------------------------------- -----------------------------
#
# O que tem de novo?
# ◇ 1.0 → 1.1
# O cursor.
# Agora nós podemos ver a barra.
# Barra atualizada porque o tempo de resposta não estava correto.
# ◇ 0.9 → 1.0
# Agora consertada a parte que não podia se ver a barra.
# ◇ 0.8 → 0.9
# Trabalho mais leve.
# Melhorado o tempo de resposta.
#
#================================================= =============================
# ★ script para habilitar isso
# if true
#================================================= =============================
# ■ Sprite_Battler
#================================================= =============================
class Sprite_Battler < Sprite_Base
# ƒQ[ƒW”ñ•\Ž¦ƒƒ‚•¶Žš—ñ
GAUGE_M = "ƒQ[ƒW”ñ•\Ž¦"
# ƒQ[ƒWƒoƒbƒN‚ÌF@[˜g‚ÌF, ˜g’†‚ÌF]
GAUGE_BC = [Color.new(0,0,0), Color.new(32,48,64)]
# ƒQ[ƒW‚̃Oƒ‰ƒf[ƒVƒ‡ƒ“F@[¶, ‰E]
GAUGE_GC = [Color.new(64,128,96), Color.new(96,192,160)]
#
GAUGE_W = 96 # ƒQ[ƒW•
GAUGE_H = 6 # ƒQ[ƒW‚‚³
GAUGE_S = 8 # ƒQ[ƒWƒXƒs[ƒh@2 ˆÈã‚Ì
”
GAUGE_T = 640 # ƒQ[ƒW•\Ž¦ŽžŠÔ@510 ˆÈã
GAUGE_O = 16 # ƒQ[ƒW•s“§–¾“xŒ¸¬’l
#
GAUGE_V = false # ƒJ[ƒ\ƒ‹‚ðƒ^[ƒQƒbƒg‚É‚ ‚킹‚½‚Æ‚«‚ɃQ[ƒW•\Ž¦
# ¦XP•—ƒoƒgƒ‹‚𓱓ü‚µ‚Ä‚È‚¢ê‡‚Í—LŒø‚É‚µ‚È‚¢‚Å‚¬‚¾‚³‚¢
#--------------------------------------------------------------------------
# Criar
#--------------------------------------------------------------------------
def create_enhpgauge
g_width = GAUGE_W # •
g_height = GAUGE_H # ‚‚³
f_color = GAUGE_BC # ƒQ[ƒWƒoƒbƒNƒJƒ‰[
g_color = GAUGE_GC # ƒQ[ƒWƒJƒ‰[
# ƒrƒbƒgƒ}ƒbƒvì¬
bitmap = Bitmap.new(g_width, g_height * 2)
# 㔼•ª:ƒQ[ƒWƒoƒbƒN
bitmap.fill_rect(0, 0, g_width, g_height, f_color[0]) # ˜gŠO
bitmap.fill_rect(1, 1, g_width - 2, g_height - 2, f_color[1]) # ˜g“à
# ‰º”¼•ª:ƒOƒ‰ƒfƒQ[ƒW
bitmap.gradient_fill_rect(1, g_height + 1, g_width - 2, g_height - 2,
g_color[0], g_color[1]) # ƒOƒ‰ƒf
# ƒXƒvƒ‰ƒCƒgì¬ # [0] = ƒQ[ƒWƒoƒbƒN; [1] = ƒQ[ƒW
@hp_gauge = [Sprite.new, Sprite.new]
for i in 0..1
sprite = @hp_gauge[i]
sprite.viewport = self.viewport
sprite.bitmap = bitmap
sprite.src_rect.set(0, 0, g_width, g_height)
sprite.src_rect.y = g_height if i == 1
sprite.x = @battler.screen_x
sprite.y = @battler.screen_y - 8
sprite.ox = g_width / 2
sprite.oy = g_height / 2
sprite.z = 200
sprite.z += 20 if i == 1
sprite.opacity = 0
end
# ‚¢‚ë‚¢‚ë
@enid = @battler.enemy_id
@hp = @battler.hp
@gauge_width = GAUGE_W + 1
@gauge_opacity = 0
end
#--------------------------------------------------------------------------
# Atualizar a barra
#--------------------------------------------------------------------------
def enhpgauge_update
# ƒGƒlƒ~[ID‚ª•Ï“
‚µ‚Ä‚¢‚½‚烃‚‚Ì“à—e‚ðĎ擾E‰ÂŽ‹ó‘Ô‚àXV
if @enid != @battler.enemy_id
@enid = @battler.enemy_id
@gauge_visible = true
@gauge_visible = false if $data_enemies[@enid].note.include?(GAUGE_M)
for i in @hp_gauge do i.visible = @gauge_visible end
end
return unless @gauge_visible
# ƒQ[ƒWXV
if @hp != @battler.hp
g_width = (@battler.hp / (@battler.maxhp * 1.0))
@gauge_width = ((GAUGE_W * g_width) + 1).truncate
@gauge_opacity = GAUGE_T
@hp = @battler.hp
end
# •
g_width = @hp_gauge[1].src_rect.width
speed = GAUGE_S
rect = @hp_gauge[1].src_rect
rect.width = (@gauge_width + (g_width * (speed - 1))) / speed
if rect.width != @gauge_width
if rect.width > @gauge_width
rect.width -= 1
else
rect.width += 1
end
end
rect.width = 2 if rect.width <= 1 and @hp > 0
# “§–¾“x
if GAUGE_V and @battler.cursor_flash
@gauge_opacity += GAUGE_O * 2 if @gauge_opacity <= GAUGE_T / 2
else
@gauge_opacity -= GAUGE_O if @gauge_opacity > 0
end
# “§–¾“x“K—p
for i in @hp_gauge do i.opacity = @gauge_opacity end
end
#--------------------------------------------------------------------------
# Iniciar Objeto (alias)
#--------------------------------------------------------------------------
alias initialize_str15 initialize
def initialize(viewport, battler = nil)
initialize_str15(viewport, battler)
if @battler.is_a?(Game_Enemy)
create_enhpgauge
@gauge_visible = true
@gauge_visible = false if $data_enemies[@enid].note.include?(GAUGE_M)
for i in @hp_gauge do i.visible = @gauge_visible end
end
end
#--------------------------------------------------------------------------
# Liberação (alias)
#--------------------------------------------------------------------------
alias dispose_str15 dispose
def dispose
dispose_str15
if @battler.is_a?(Game_Enemy)
@hp_gauge[0].bitmap.dispose
@hp_gauge[0].dispose
@hp_gauge[1].dispose
end
end
#--------------------------------------------------------------------------
# Atualizar Frame (alias)
#--------------------------------------------------------------------------
alias update_str15 update
def update
update_str15
enhpgauge_update if @battler.is_a?(Game_Enemy)
end
end
#end