Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # • SAO HUD
- #==============================================================================
- # Autor: Dax
- # Versão: 1.3
- # Site: www.dax-soft.weebly.com
- # Requerimento: Dax Core
- #==============================================================================
- # • Descrição:
- #------------------------------------------------------------------------------
- # Trata-se de uma HUD baseada no anime Sword Art Online, Quando a barra
- # estiver mais ou menos na metade ela irá ficar alaranjada é quando
- # estiver quase no fim ficará meio avermelhada e quando estiver cheia verde.
- # Nela irá mostrar o nome, hp, level do personagem, de certo modo igual ao Anime.
- #==============================================================================
- # • Como usar:
- #------------------------------------------------------------------------------
- # Para ativar/desativar a HUD.. Basta chamar o comando
- # $game_temp.sao_hud | no 'Chamar Script'..
- # * Para ativar : $game_temp.sao_hud = true
- # * Para desativar : $game_temp.sao_hud = false
- #==============================================================================
- Dax.register(:sao_hud, "dax", 1.3) {
- #==============================================================================
- # • Para Ativar/Desativar HUD.
- #==============================================================================
- class Game_Temp
- #----------------------------------------------------------------------------
- # • Variável pública do módulo.
- #----------------------------------------------------------------------------
- attr_accessor :sao_hud # Ativar/Desativar HUD.
- #----------------------------------------------------------------------------
- # • Initialize
- #----------------------------------------------------------------------------
- alias :sao_hud_inititalize :initialize
- def initialize
- sao_hud_inititalize
- @sao_hud = true
- end
- #----------------------------------------------------------------------------
- # • Setup
- #----------------------------------------------------------------------------
- def sao
- return {
- id_actor: 0, # ID do Personagem.
- background: "Base Hud", # Nome da imagem de fundo da HUD.
- x: 16, # Posição no eicho X onde a HUD se encontra.
- y: 16, # Posição no eicho Y onde a HUD se encontra.
- z: 200, # Prioridade da HUD no mapa.
- bar_hp: "Hp", # Nome da imagem da barra de HP.
- speed_fade_to_map: 6, # Velocidade para aparecer no mapa.
- key_hide: :D, # Chave para ativar/desativar HUD.
- dead: true, # Morrer quando chegar a 0 o HP.
- }
- end
- end
- #==============================================================================
- # • Objeto da HUD.
- #==============================================================================
- class SAO_HUD
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #----------------------------------------------------------------------------
- def initialize
- @actor = $game_party.members[$game_temp.sao[:id_actor]]
- @background = Sprite.new("S: " + $game_temp.sao[:background])
- @background.x, @background.y, @background.z = $game_temp.sao[:x],$game_temp.sao[:y],$game_temp.sao[:z]
- @bitmap_hp = Cache.system($game_temp.sao[:bar_hp])
- @hp = Sprite.new([@background.width, @background.height])
- @hp.x, @hp.y, @hp.z = @background.x, @background.y, @background.z
- percent = @bitmap_hp.width.to_p(@actor.hp, @actor.mhp)
- @hp.bitmap.blt(82, 8, @bitmap_hp, Rect.new(0,0,percent,@bitmap_hp.height))
- @hp.bitmap.hue_change(percent >= 100 ? -360 : percent >= 10 ? -51 : -81)
- @name = Sprite_Text.new(@background.x+36, @background.y+5, 48, 20, @actor.name)
- @number_hp = Sprite_Text.new(@background.x+174,@background.y+23,64,16,"#{@actor.hp}/#{@actor.mhp}")
- @level = Sprite_Text.new(@background.x+235,@background.y+23,64,16,"Lv. #{@actor.level}")
- @fade_to_map = false
- [@background, @hp, @name, @number_hp, @level].each { |i| i.opacity = 0 }
- [@background, @hp, @name, @number_hp, @level].each { |i| i.visible = $game_temp.sao_hud }
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- [@background, @hp, @name, @number_hp, @level].each(&:dispose)
- end
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- def update
- SceneManager.goto(Scene_Gameover) if $game_temp.sao[:dead] and @actor.hp <= 1
- [@name, @number_hp, @level].each(&:update)
- [@number_hp, @level].each_with_index{|i,a|i.bitmap.font.size = 14-(a*4)}
- if trigger?($game_temp.sao[:key_hide])
- $game_temp.sao_hud = $game_temp.sao_hud ? false : true
- [@background, @hp, @name, @number_hp, @level].each { |i| i.visible = $game_temp.sao_hud }
- end
- unless @fade_to_map
- [@background, @hp, @name, @number_hp, @level].each { |i| i.opacity += $game_temp.sao[:speed_fade_to_map] unless i.opacity >= 255}
- @fade_to_map = @level.opacity >= 255
- end
- @number_hp.text = "#{@actor.hp}/#{@actor.mhp}"
- @level.text = "Lv. #{@actor.level}"
- @name.text = @actor.name unless @name.text == @actor.name
- @hp.bitmap.clear
- percent = @bitmap_hp.width.to_p(@actor.hp, @actor.mhp)
- @hp.bitmap.blt(82, 8, @bitmap_hp, Rect.new(0,0,percent,@bitmap_hp.height))
- @hp.bitmap.hue_change(percent >= 100 ? -360 : percent >= 10 ? -51 : -81)
- end
- end
- #==============================================================================
- # • Desenhar no Mapa.
- #==============================================================================
- class Scene_Map < Scene_Base
- #----------------------------------------------------------------------------
- # • Principal dos objetos.
- #----------------------------------------------------------------------------
- alias :hud_sao_main :main
- def main
- @sao_hud = SAO_HUD.new
- hud_sao_main
- @sao_hud.dispose
- end
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- alias :hud_sao_update :update
- def update
- hud_sao_update
- @sao_hud.update
- end
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement