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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
| #=============================================================
# *** Silent's HUD
# ** Version - 1.1 RMVX
# * Fecha - 28/01/08 DD/MM/YY Version 1.1 -> 07/02/08
#----------------------------------------------------------------------------#
# * Description - Simple HUD pour montrer les PV, PM et expérience du joueur
# principal sur la carte, idéal pour des A-RPG.
#
# * Placer le script au-dessus du script Main.
#
# >*< 0; Haut gauche 1; Haut droite 2; Bas gauche 3; Bas droite
#============================================================================#
LUGAR = 0 # Position des barres >*<
HUD_BAR_HP = true # Montrer barre HP
HUD_BAR_MP = true # Montrer Barre MP
HUD_BAR_EP = true # Montrer barre EXP
ON_OFF_SWITCH = 10 # Numéro de l'interrupteur pour montrer/cacher le HUD.
#============================================================================#
# ** Window_HUD
# - Ventana donde se muestra la info en el mapa
#============================================================================#
class Window_HUD < Window_Base
#--------------------------------------------------------------------------#
# * Metodo Initialize
#--------------------------------------------------------------------------#
def initialize
super(0, 0, 280, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
#--------------------------------------------------------------------------#
# * Refresh
#--------------------------------------------------------------------------#
def refresh
actor = $game_actors[1]
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 110-2, 22, $game_actors[1].name, 2)
draw_hud_actor_hp(actor, 30, 20) if HUD_BAR_HP == true
draw_hud_actor_mp(actor, 30, 50) if HUD_BAR_MP == true
draw_hud_actor_exp(actor, 30, 80) if HUD_BAR_EP == true
end
end
#============================================================================#
# ** Scene_Map alias
# - alias a Scene_Map con metodos del HUD
#============================================================================#
class Scene_Map
alias hud_main main
alias hud_update update
alias hud_terminate terminate
#--------------------------------------------------------------------------#
# * Metodo Principal
#--------------------------------------------------------------------------#
def main
@lalalah = $game_actors[1].hp
@lalalas = $game_actors[1].mp
@lalalae = $game_actors[1].exp
@hud = Window_HUD.new
case LUGAR
when 0
@hud.y = 0
@hud.x = 0
when 1
@hud.y = 280
@hud.x = 0
when 2
@hud.y = 0
@hud.x = 340
when 3
@hud.y = 280
@hud.x = 340
end
@hud.visible = false
hud_main
end
#--------------------------------------------------------------------------#
# * Update
#--------------------------------------------------------------------------#
def update
if $game_switches[ON_OFF_SWITCH] == true
@hud.visible = true
$game_map.refresh
else
@hud.visible = false
$game_map.refresh
end
if $game_switches[ON_OFF_SWITCH] == true
if $game_actors[1].hp != @lalalah and HUD_BAR_HP == true
@hud.refresh
@lalalah = $game_actors[1].hp
@hud.update
end
if $game_actors[1].mp != @lalalas and HUD_BAR_MP == true
@hud.refresh
@lalalas = $game_actors[1].mp
@hud.update
end
if $game_actors[1].exp != @lalalae and HUD_BAR_EP == true
@hud.refresh
@lalalae = $game_actors[1].exp
@hud.update
end
end
hud_update
end
#--------------------------------------------------------------------------#
# * Terminate
#--------------------------------------------------------------------------#
def terminate
@hud.dispose
hud_terminate
end
end
#============================================================================#
# ** Adiciones a Window_Base
# - Metodo de dibujado de barra de exp, hp y mp
#============================================================================#
class Window_Base < Window
#--------------------------------------------------------------------------#
# * Metodo de dibujado de la barra de hp
#--------------------------------------------------------------------------#
def draw_hp_bar(actor, x, y)
hpwidth = (actor.hp * 10) / actor.maxhp * 12 * (1)
self.contents.fill_rect(x + 0, y + 0, 1 * 120 + 4, 14, Color.new(0, 0, 0, 100))
self.contents.fill_rect(x + 1, y + 1, 1 * 120 + 2, 12, Color.new(255, 255, 255))
self.contents.fill_rect(x + 2, y + 2, 1 * 120, 10, Color.new(0, 0, 0, 150))
self.contents.fill_rect(x + 2, y + 2, hpwidth, 10, Color.new(155, 50, 50, 100))
end
#--------------------------------------------------------------------------#
# * Metodo de dibujado de la barra de mp
#--------------------------------------------------------------------------#
def draw_mp_bar(actor, x, y)
mpwidth = (actor.mp * 10) / actor.maxmp * 12 * (1)
self.contents.fill_rect(x + 0, y + 0, 1 * 120 + 4, 14, Color.new(0, 0, 0, 100))
self.contents.fill_rect(x + 1, y + 1, 1 * 120 + 2, 12, Color.new(255, 255, 255))
self.contents.fill_rect(x + 2, y + 2, 1 * 120, 10, Color.new(0, 0, 0, 150))
self.contents.fill_rect(x + 2, y + 2, mpwidth, 10, Color.new(50, 50, 155, 100))
end
#--------------------------------------------------------------------------#
# * Metodo de dibujado de la barra de exp
#--------------------------------------------------------------------------#
def draw_exp_bar(actor, x, y)
exp = actor.exp_s.to_i
max_exp = actor.next_exp_s.to_i
expwidth = (exp * 10) / max_exp * 12 * (1)
self.contents.fill_rect(x + 0, y + 0, 1 * 120 + 4, 14, Color.new(0, 0, 0, 100))
self.contents.fill_rect(x + 1, y + 1, 1 * 120 + 2, 12, Color.new(255, 255, 255))
self.contents.fill_rect(x + 2, y + 2, 1 * 120, 10, Color.new(0, 0, 0, 150))
self.contents.fill_rect(x + 2, y + 2, expwidth, 10, Color.new(50, 155, 50, 100))
end
#--------------------------------------------------------------------------#
# * Draw EXP Editado
#--------------------------------------------------------------------------#
def draw_hud_actor_exp(actor, x, y)
self.contents.font.color = Color.new(10, 100, 10)
draw_exp_bar(actor, x, y + 16)
self.contents.draw_text(x - 30, y + 6, 32, 32, 'E')
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 84, 32, actor.exp_s, 2)
self.contents.draw_text(x + 84, y, 12, 32, '/', 1)
self.contents.draw_text(x + 96, y, 84, 32, actor.next_exp_s)
end
#--------------------------------------------------------------------------#
# * Draw HP Editado
#--------------------------------------------------------------------------#
def draw_hud_actor_hp(actor, x, y, width = 144)
self.contents.font.color = Color.new(100, 10, 10)
if width - 32 >= 108
hp_x = x + width - 108
flag = true
elsif width - 32 >= 48
hp_x = x + width - 48
flag = false
end
draw_hp_bar(actor, hp_x - 36, y + 16)
self.contents.draw_text(x - 30, y + 6, 32, 32, Vocab::hp_a)
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
if flag
self.contents.font.color = normal_color
self.contents.draw_text(hp_x + 48, y, 12, 32, '/', 1)
self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
end
end
#--------------------------------------------------------------------------#
# * Draw mp Editado
#--------------------------------------------------------------------------#
def draw_hud_actor_mp(actor, x, y, width = 144)
self.contents.font.color = Color.new(10, 10, 100)
if width - 32 >= 108
mp_x = x + width - 108
flag = true
elsif width - 32 >= 48
mp_x = x + width - 48
flag = false
end
draw_mp_bar(actor, mp_x - 36, y + 16)
self.contents.draw_text(x - 30, y + 6, 32, 32, Vocab::mp_a)
self.contents.font.color = actor.mp == 0 ? knockout_color :
actor.mp <= actor.maxmp / 4 ? crisis_color : normal_color
self.contents.draw_text(mp_x, y, 48, 32, actor.mp.to_s, 2)
if flag
self.contents.font.color = normal_color
self.contents.draw_text(mp_x + 48, y, 12, 32, '/', 1)
self.contents.draw_text(mp_x + 60, y, 48, 32, actor.maxmp.to_s)
end
end
#----------------------------------------------------------------------------#
end |