Confira o Videos Épicos #45!
6 Respostas   345 Visualizações
0 Membros e 1 Visitante estão vendo este tópico.
#==============================================================================#------------------------------------------------------------------------------# por Masked#==============================================================================($imported ||= {})[:mbs_hud] = truemodule MBS module HUD#==============================================================================# Configurações#============================================================================== # Imagens (na pasta Graphics) @@_img = { BASE: 'Pictures/Base', HP: 'Pictures/hp', MP: 'Pictures/mp', EXP: 'Pictures/exp', } # Posições (X, Y) @@_pos = { BASE: [238,538], CHAR: [900,45], HP: [5,5], MP: [279,5], EXP: [243,575], } # Dimensões (largura, altura) @@_dim = { CHAR: [25,60], }#==============================================================================# Fim das configurações#============================================================================== extend self # Criação dos métodos legais :3 [:img, :pos, :dim].each do |sym| class_variable_get("@@_#{sym}".to_sym).each do |k, v| define_method("#{sym}_#{k.to_s.downcase}".to_sym) { v } end end endend#==============================================================================# ** Sprite_HUD#==============================================================================class Sprite_HUD < Sprite include MBS @@base = Bitmap.new("Graphics/#{HUD.img_base}") @@hp = Bitmap.new("Graphics/#{HUD.img_hp}") @@mp = Bitmap.new("Graphics/#{HUD.img_mp}") @@exp = Bitmap.new("Graphics/#{HUD.img_exp}") #-------------------------------------------------------------------------- # * Inicialização do objeto #-------------------------------------------------------------------------- def initialize(viewport=nil) super(viewport) self.x, self.y = *HUD.pos_base self.bitmap = @@base.dup self.visible = true self.z = 0 refresh end #-------------------------------------------------------------------------- # * Atualização do objeto #-------------------------------------------------------------------------- def update super refresh end #-------------------------------------------------------------------------- # * Atualização dos valores #-------------------------------------------------------------------------- def update_values @old_hp, @old_mhp = actor.hp, actor.mhp @old_mp, @old_mmp = actor.mp, actor.mmp @old_xp = actor.exp @old_id = actor.id end #-------------------------------------------------------------------------- # * Redesenho do sprite #-------------------------------------------------------------------------- def refresh redraw_hp if hp_changed? redraw_mp if mp_changed? redraw_xp if xp_changed? redraw_char if actor_changed? update_values if any_changed? end #-------------------------------------------------------------------------- # * Redesenho do HP #-------------------------------------------------------------------------- def redraw_hp if HUD.method_defined?(:dim_hp) rect = Rect.new(*HUD.pos_hp, *HUD.dim_hp) else rect = Rect.new(*HUD.pos_hp, @@hp.width, @@hp.height) end self.bitmap.blt(rect.x,rect.y,@@base,rect) self.bitmap.blt(*HUD.pos_hp,@@hp,hp_rect) end #-------------------------------------------------------------------------- # * Redesenho do MP #-------------------------------------------------------------------------- def redraw_mp if HUD.method_defined?(:dim_mp) rect = Rect.new(*HUD.pos_mp, *HUD.dim_mp) else rect = Rect.new(*HUD.pos_mp, @@mp.width, @@mp.height ) end self.bitmap.blt(rect.x,rect.y,@@base,rect) self.bitmap.blt(*HUD.pos_mp,@@mp,mp_rect) end #-------------------------------------------------------------------------- # * Redesenho do EXP #-------------------------------------------------------------------------- def redraw_xp if HUD.method_defined?(:dim_xp) rect = Rect.new(*HUD.pos_exp, *HUD.dim_exp) else rect = Rect.new(*HUD.pos_exp, @@exp.width, @@exp.height) end self.bitmap.blt(rect.x,rect.y,@@base,rect) self.bitmap.blt(*HUD.pos_exp,@@exp,xp_rect) end #-------------------------------------------------------------------------- # * Redesenho do HP #-------------------------------------------------------------------------- def redraw_char rect = Rect.new(*HUD.pos_char, *HUD.dim_char) self.bitmap.blt(*HUD.pos_char,char_bitmap,char_rect) end #-------------------------------------------------------------------------- # * Aquisição do retângulo do HP #-------------------------------------------------------------------------- def hp_rect unless HUD.method_defined?(:dim_hp) Rect.new(0,0,@@hp.width,@@hp.height * actor.hp / actor.mhp) else Rect.new(0,0,*HUD.dim_hp) end end #-------------------------------------------------------------------------- # * Aquisição do retângulo do MP #-------------------------------------------------------------------------- def mp_rect unless HUD.method_defined?(:dim_mp) Rect.new(0,0,@@mp.width,@@mp.height * actor.mp / actor.mmp) else Rect.new(0,0,*HUD.dim_mp) end end #-------------------------------------------------------------------------- # * Aquisição do retângulo do XP #-------------------------------------------------------------------------- def xp_rect unless HUD.method_defined?(:dim_exp) xp = actor.exp - actor.current_level_exp mxp = actor.next_level_exp - actor.current_level_exp Rect.new(0,0,@@exp.width,@@exp.height * xp / mxp) else Rect.new(0,0,*HUD.dim_exp) end end #-------------------------------------------------------------------------- # * Aquisição do retângulo do char #-------------------------------------------------------------------------- def char_rect unless HUD.method_defined?(:dim_char) Rect.new(0,0,@@hp.width * actor.hp / actor.mhp,@@hp.height) else Rect.new(0,0,*HUD.dim_char) end end #-------------------------------------------------------------------------- # * Aquisição do bitmap do char do personagem #-------------------------------------------------------------------------- def char_bitmap bitmap = Bitmap.new(*HUD.dim_char) char = Cache.character(actor.character_name) sign = actor.character_name[/^[\!\$]./] if sign && sign.include?('$') cw = char.width / 3 ch = char.height / 4 else cw = char.width / 12 ch = char.height / 8 end n = actor.character_index src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch) bitmap.blt(bitmap.width/2-cw/2,0,char,src_rect) bitmap end #-------------------------------------------------------------------------- # * Aquisição do personagem #-------------------------------------------------------------------------- def actor $game_party.battle_members.first end #-------------------------------------------------------------------------- # * Verificação de alteração no hp #-------------------------------------------------------------------------- def hp_changed? !(@old_hp == actor.hp && @old_mhp == actor.mhp) end #-------------------------------------------------------------------------- # * Verificação de alteração no hp #-------------------------------------------------------------------------- def mp_changed? !(@old_hp == actor.mp && @old_mhp == actor.mmp) end #-------------------------------------------------------------------------- # * Verificação de alteração no xp #-------------------------------------------------------------------------- def xp_changed? @old_exp != actor.exp end #-------------------------------------------------------------------------- # * Verificação de alteração no hp #-------------------------------------------------------------------------- def actor_changed? @old_id != actor.id end #-------------------------------------------------------------------------- # * Verificação de alteração de qualquer coisa #-------------------------------------------------------------------------- def any_changed? hp_changed? || mp_changed? || xp_changed? || actor_changed? end end#==============================================================================# ** Scene_Map#==============================================================================class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # Alias #-------------------------------------------------------------------------- alias mbsstart2 start alias mbsupdate update alias mbstermit terminate #-------------------------------------------------------------------------- # * Inicialização do processo #-------------------------------------------------------------------------- def start mbsstart2 @mbshud = Sprite_HUD.new end #-------------------------------------------------------------------------- # * Atualização do processo #-------------------------------------------------------------------------- def update mbsupdate @mbshud.update end #-------------------------------------------------------------------------- # * Finalização do processo #-------------------------------------------------------------------------- def terminate mbstermit @mbshud.dispose endend
def redraw_hp if HUD.method_defined?(:dim_hp) rect = Rect.new(*HUD.pos_hp, *HUD.dim_hp) else rect = Rect.new(*HUD.pos_hp, @@hp.width, @@hp.height) end self.bitmap.blt(rect.x,rect.y,@@base,rect) y = (@old_hp.to_f / @old_mhp.to_f) * @@hp.height self.bitmap.blt(*HUD.pos_hp[0], *HUD.pos_hp[0] + y,@@hp,hp_rect) end
#==============================================================================#------------------------------------------------------------------------------# por Masked#==============================================================================($imported ||= {})[:mbs_hud] = truemodule MBS module HUD#==============================================================================# Configurações#============================================================================== # Imagens (na pasta Graphics) @@_img = { BASE: 'Pictures/Base', HP: 'Pictures/hp', MP: 'Pictures/mp', EXP: 'Pictures/exp', } # Posições (X, Y) @@_pos = { BASE: [110,350], CHAR: [900,45], HP: [5,5], MP: [279,5], EXP: [243,575], } # Dimensões (largura, altura) @@_dim = { CHAR: [25,60], }#==============================================================================# Fim das configurações#============================================================================== extend self # Criação dos métodos legais :3 [:img, :pos, :dim].each do |sym| class_variable_get("@@_#{sym}".to_sym).each do |k, v| define_method("#{sym}_#{k.to_s.downcase}".to_sym) { v } end end endend#==============================================================================# ** Sprite_HUD#==============================================================================class Sprite_HUD < Sprite include MBS @@base = Bitmap.new("Graphics/#{HUD.img_base}") @@hp = Bitmap.new("Graphics/#{HUD.img_hp}") @@mp = Bitmap.new("Graphics/#{HUD.img_mp}") @@exp = Bitmap.new("Graphics/#{HUD.img_exp}") #-------------------------------------------------------------------------- # * Inicialização do objeto #-------------------------------------------------------------------------- def initialize(viewport=nil) super(viewport) self.x, self.y = *HUD.pos_base self.bitmap = @@base.dup self.visible = true self.z = 0 refresh end #-------------------------------------------------------------------------- # * Atualização do objeto #-------------------------------------------------------------------------- def update super refresh end #-------------------------------------------------------------------------- # * Atualização dos valores #-------------------------------------------------------------------------- def update_values @old_hp, @old_mhp = actor.hp, actor.mhp @old_mp, @old_mmp = actor.mp, actor.mmp @old_xp = actor.exp @old_id = actor.id end #-------------------------------------------------------------------------- # * Redesenho do sprite #-------------------------------------------------------------------------- def refresh redraw_hp if hp_changed? redraw_mp if mp_changed? redraw_xp if xp_changed? redraw_char if actor_changed? update_values if any_changed? end #-------------------------------------------------------------------------- # * Redesenho do HP #-------------------------------------------------------------------------- def redraw_hp if HUD.method_defined?(:dim_hp) rect = Rect.new(*HUD.pos_hp, *HUD.dim_hp) else rect = Rect.new(*HUD.pos_hp, @@hp.width, @@hp.height) end self.bitmap.blt(rect.x,rect.y,@@base,rect) HUD.pos_hp[1] = 47 - (@@hp.height * actor.hp / actor.mhp) self.bitmap.blt(*HUD.pos_hp, @@hp, hp_rect) end #-------------------------------------------------------------------------- # * Redesenho do MP #-------------------------------------------------------------------------- def redraw_mp if HUD.method_defined?(:dim_mp) rect = Rect.new(*HUD.pos_mp, *HUD.dim_mp) else rect = Rect.new(*HUD.pos_mp, @@mp.width, @@mp.height ) end self.bitmap.blt(rect.x,rect.y,@@base,rect) HUD.pos_mp[1] = 47 - (@@mp.height * actor.mp / actor.mmp) self.bitmap.blt(*HUD.pos_mp,@@mp,mp_rect) end #-------------------------------------------------------------------------- # * Redesenho do EXP #-------------------------------------------------------------------------- def redraw_xp if HUD.method_defined?(:dim_xp) rect = Rect.new(*HUD.pos_exp, *HUD.dim_exp) else rect = Rect.new(*HUD.pos_exp, @@exp.width, @@exp.height) end self.bitmap.blt(rect.x,rect.y,@@base,rect) self.bitmap.blt(*HUD.pos_exp,@@exp,xp_rect) end #-------------------------------------------------------------------------- # * Redesenho do HP #-------------------------------------------------------------------------- def redraw_char rect = Rect.new(*HUD.pos_char, *HUD.dim_char) self.bitmap.blt(*HUD.pos_char,char_bitmap,char_rect) end #-------------------------------------------------------------------------- # * Aquisição do retângulo do HP #-------------------------------------------------------------------------- def hp_rect unless HUD.method_defined?(:dim_hp) Rect.new(0, 0, @@hp.width, @@hp.height * actor.hp / actor.mhp) else Rect.new(0, 0, *HUD.dim_hp) end end #-------------------------------------------------------------------------- # * Aquisição do retângulo do MP #-------------------------------------------------------------------------- def mp_rect unless HUD.method_defined?(:dim_mp) Rect.new(0,0,@@mp.width,@@mp.height * actor.mp / actor.mmp) else Rect.new(0,0,*HUD.dim_mp) end end #-------------------------------------------------------------------------- # * Aquisição do retângulo do XP #-------------------------------------------------------------------------- def xp_rect unless HUD.method_defined?(:dim_exp) xp = actor.exp - actor.current_level_exp mxp = actor.next_level_exp - actor.current_level_exp Rect.new(0,0,@@exp.width,@@exp.height * xp / mxp) else Rect.new(0,0,*HUD.dim_exp) end end #-------------------------------------------------------------------------- # * Aquisição do retângulo do char #-------------------------------------------------------------------------- def char_rect unless HUD.method_defined?(:dim_char) Rect.new(0,0,@@hp.width * actor.hp / actor.mhp,@@hp.height) else Rect.new(0,0,*HUD.dim_char) end end #-------------------------------------------------------------------------- # * Aquisição do bitmap do char do personagem #-------------------------------------------------------------------------- def char_bitmap bitmap = Bitmap.new(*HUD.dim_char) char = Cache.character(actor.character_name) sign = actor.character_name[/^[\!\$]./] if sign && sign.include?('$') cw = char.width / 3 ch = char.height / 4 else cw = char.width / 12 ch = char.height / 8 end n = actor.character_index src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch) bitmap.blt(bitmap.width/2-cw/2,0,char,src_rect) bitmap end #-------------------------------------------------------------------------- # * Aquisição do personagem #-------------------------------------------------------------------------- def actor $game_party.battle_members.first end #-------------------------------------------------------------------------- # * Verificação de alteração no hp #-------------------------------------------------------------------------- def hp_changed? !(@old_hp == actor.hp && @old_mhp == actor.mhp) end #-------------------------------------------------------------------------- # * Verificação de alteração no hp #-------------------------------------------------------------------------- def mp_changed? !(@old_hp == actor.mp && @old_mhp == actor.mmp) end #-------------------------------------------------------------------------- # * Verificação de alteração no xp #-------------------------------------------------------------------------- def xp_changed? @old_exp != actor.exp end #-------------------------------------------------------------------------- # * Verificação de alteração no hp #-------------------------------------------------------------------------- def actor_changed? @old_id != actor.id end #-------------------------------------------------------------------------- # * Verificação de alteração de qualquer coisa #-------------------------------------------------------------------------- def any_changed? hp_changed? || mp_changed? || xp_changed? || actor_changed? end end#==============================================================================# ** Scene_Map#==============================================================================class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # Alias #-------------------------------------------------------------------------- alias mbsstart2 start alias mbsupdate update alias mbstermit terminate #-------------------------------------------------------------------------- # * Inicialização do processo #-------------------------------------------------------------------------- def start mbsstart2 @mbshud = Sprite_HUD.new end #-------------------------------------------------------------------------- # * Atualização do processo #-------------------------------------------------------------------------- def update mbsupdate @mbshud.update end #-------------------------------------------------------------------------- # * Finalização do processo #-------------------------------------------------------------------------- def terminate mbstermit @mbshud.dispose endend