Advertisement
DaxSoft

Sao Hud Script

May 20th, 2016
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.52 KB | None | 0 0
  1. #==============================================================================
  2. # • SAO HUD
  3. #==============================================================================
  4. # Autor: Dax
  5. # Versão: 1.3
  6. # Site: www.dax-soft.weebly.com
  7. # Requerimento: Dax Core
  8. #==============================================================================
  9. # • Descrição:
  10. #------------------------------------------------------------------------------
  11. #  Trata-se de uma HUD baseada no anime Sword Art Online, Quando a barra  
  12. # estiver mais ou menos na metade ela irá ficar alaranjada é quando
  13. # estiver quase no fim ficará meio avermelhada e quando estiver cheia verde.
  14. # Nela irá mostrar o nome, hp, level do personagem, de certo modo igual ao Anime.
  15. #==============================================================================
  16. # • Como usar:
  17. #------------------------------------------------------------------------------
  18. #     Para ativar/desativar a HUD.. Basta chamar o comando
  19. # $game_temp.sao_hud | no 'Chamar Script'..
  20. #  * Para ativar : $game_temp.sao_hud = true
  21. #  * Para desativar :  $game_temp.sao_hud = false
  22. #==============================================================================
  23. Dax.register(:sao_hud, "dax", 1.3) {
  24. #==============================================================================
  25. # • Para Ativar/Desativar HUD.
  26. #==============================================================================
  27. class Game_Temp
  28.   #----------------------------------------------------------------------------
  29.   # • Variável pública do módulo.
  30.   #----------------------------------------------------------------------------
  31.   attr_accessor :sao_hud            # Ativar/Desativar HUD.
  32.   #----------------------------------------------------------------------------
  33.   # • Initialize
  34.   #----------------------------------------------------------------------------
  35.   alias :sao_hud_inititalize :initialize
  36.   def initialize
  37.     sao_hud_inititalize
  38.     @sao_hud = true
  39.   end
  40.   #----------------------------------------------------------------------------
  41.   # • Setup
  42.   #----------------------------------------------------------------------------
  43.   def sao
  44.     return {
  45.       id_actor: 0, # ID do Personagem.
  46.       background: "Base Hud", # Nome da imagem de fundo da HUD.
  47.       x: 16, # Posição no eicho X onde a HUD se encontra.
  48.       y: 16, # Posição no eicho Y onde a HUD se encontra.
  49.       z: 200, # Prioridade da HUD no mapa.
  50.       bar_hp: "Hp", # Nome da imagem da barra de HP.
  51.       speed_fade_to_map: 6, # Velocidade para aparecer no mapa.
  52.       key_hide: :D, # Chave para ativar/desativar HUD.
  53.       dead: true, # Morrer quando chegar a 0 o HP.
  54.     }
  55.   end
  56. end
  57. #==============================================================================
  58. # • Objeto da HUD.
  59. #==============================================================================
  60. class SAO_HUD
  61.   #----------------------------------------------------------------------------
  62.   # • Inicialização dos objetos.
  63.   #----------------------------------------------------------------------------
  64.   def initialize
  65.     @actor = $game_party.members[$game_temp.sao[:id_actor]]
  66.     @background = Sprite.new("S: " + $game_temp.sao[:background])
  67.     @background.x, @background.y, @background.z = $game_temp.sao[:x],$game_temp.sao[:y],$game_temp.sao[:z]
  68.     @bitmap_hp = Cache.system($game_temp.sao[:bar_hp])
  69.     @hp = Sprite.new([@background.width, @background.height])
  70.     @hp.x, @hp.y, @hp.z = @background.x, @background.y, @background.z
  71.     percent = @bitmap_hp.width.to_p(@actor.hp, @actor.mhp)
  72.     @hp.bitmap.blt(82, 8, @bitmap_hp, Rect.new(0,0,percent,@bitmap_hp.height))
  73.     @hp.bitmap.hue_change(percent >= 100 ? -360 : percent >= 10 ? -51 : -81)
  74.     @name = Sprite_Text.new(@background.x+36, @background.y+5, 48, 20, @actor.name)
  75.     @number_hp = Sprite_Text.new(@background.x+174,@background.y+23,64,16,"#{@actor.hp}/#{@actor.mhp}")
  76.     @level = Sprite_Text.new(@background.x+235,@background.y+23,64,16,"Lv. #{@actor.level}")
  77.     @fade_to_map = false
  78.     [@background, @hp, @name, @number_hp, @level].each { |i| i.opacity = 0 }
  79.     [@background, @hp, @name, @number_hp, @level].each { |i| i.visible = $game_temp.sao_hud }
  80.   end
  81.   #----------------------------------------------------------------------------
  82.   # • Renovação dos objetos.
  83.   #----------------------------------------------------------------------------
  84.   def dispose
  85.     [@background, @hp, @name, @number_hp, @level].each(&:dispose)
  86.   end
  87.   #----------------------------------------------------------------------------
  88.   # • Atualização dos objetos.
  89.   #----------------------------------------------------------------------------
  90.   def update
  91.     SceneManager.goto(Scene_Gameover) if $game_temp.sao[:dead] and @actor.hp <= 1
  92.     [@name, @number_hp, @level].each(&:update)
  93.     [@number_hp, @level].each_with_index{|i,a|i.bitmap.font.size = 14-(a*4)}
  94.     if trigger?($game_temp.sao[:key_hide])
  95.       $game_temp.sao_hud = $game_temp.sao_hud ? false : true
  96.       [@background, @hp, @name, @number_hp, @level].each { |i| i.visible = $game_temp.sao_hud }
  97.     end
  98.     unless @fade_to_map
  99.       [@background, @hp, @name, @number_hp, @level].each { |i| i.opacity += $game_temp.sao[:speed_fade_to_map] unless i.opacity >= 255}
  100.       @fade_to_map = @level.opacity >= 255
  101.     end
  102.     @number_hp.text = "#{@actor.hp}/#{@actor.mhp}"
  103.     @level.text = "Lv. #{@actor.level}"
  104.     @name.text = @actor.name unless @name.text == @actor.name
  105.     @hp.bitmap.clear
  106.     percent = @bitmap_hp.width.to_p(@actor.hp, @actor.mhp)
  107.     @hp.bitmap.blt(82, 8, @bitmap_hp, Rect.new(0,0,percent,@bitmap_hp.height))
  108.     @hp.bitmap.hue_change(percent >= 100 ? -360 : percent >= 10 ? -51 : -81)
  109.   end
  110. end
  111. #==============================================================================
  112. # • Desenhar no Mapa.
  113. #==============================================================================
  114. class Scene_Map < Scene_Base
  115.   #----------------------------------------------------------------------------
  116.   # • Principal dos objetos.
  117.   #----------------------------------------------------------------------------
  118.   alias :hud_sao_main :main
  119.   def main
  120.     @sao_hud = SAO_HUD.new
  121.     hud_sao_main
  122.     @sao_hud.dispose
  123.   end
  124.   #----------------------------------------------------------------------------
  125.   # • Atualização dos objetos.
  126.   #----------------------------------------------------------------------------
  127.   alias :hud_sao_update :update
  128.   def update
  129.     hud_sao_update
  130.     @sao_hud.update
  131.   end
  132. end
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement