1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
| #================================================= =============================
# ★ RGSS2
# Enemy HP Gauge v1.1 08/08/10
# STR15
# 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.
#
#================================================= =============================
#================================================= =============================
# ■ Sprite_Battler
#================================================= =============================
class Sprite_Battler < Sprite_Base
# Adicione ao campo "notas" do imigo para não mostrar a barra
GAUGE_M = "<nobar>"
GAUGE_BC = [Color.new(0,0,0), Color.new(32,48,64)]
GAUGE_GC = [Color.new(64,128,96), Color.new(96,192,160)]
# Ajustes de Posição da barra
GAUGE_W = 96
GAUGE_H = 6
GAUGE_S = 8
GAUGE_T = 640
GAUGE_O = 16
#
GAUGE_V = false
#--------------------------------------------------------------------------
# Criar
#--------------------------------------------------------------------------
def create_enhpgauge
g_width = GAUGE_W
g_height = GAUGE_H
f_color = GAUGE_BC
g_color = GAUGE_GC
bitmap = Bitmap.new(g_width, g_height * 2)
bitmap.fill_rect(0, 0, g_width, g_height, f_color[0])
bitmap.fill_rect(1, 1, g_width - 2, g_height - 2, f_color[1])
bitmap.gradient_fill_rect(1, g_height + 1, g_width - 2, g_height - 2,
g_color[0], g_color[1])
@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
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
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
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 |