O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

Nightmare Custom HUD

Iniciado por Black_Zero, 24/01/2014 às 21:28






Criado por: Black_Zero
Compativel com: RPG Maker VX Ace
Compatibilidade: Boa
Facilidade de uso: Fácil
Lag gerado: Baixo

[box class=titlebg]
Condições de Uso
[/box]
Você pode usá-lo em seu projeto, seja ele gratuito ou comercial, desde que dê os devidos créditos ao criador.

[box class=titlebg]
Para que serve o script
[/box]
Fiz essa HUD com o objetivo de deixá-la o mais personalizável e fácil de utilizar possível, assim aqueles que não entendem de RGSS poderão usá-lo em seu projeto.
Eu postei a versão 1.0 na MRM, só lembrei de postar aqui quando fui fazer um upgrade no script, na nova versão adicionei alguns extras, como a possibilidade de adicionar a barra de experiencia, nome e nível do heroi, além de remover o método de "desenhar" a face do heroi, esse método foi substituído permanentemente pelo char do heroi, assim diminuindo o tamanho da HUD para caber na janela do jogo.

[box class=titlebg]
Imagens
[/box]
Essa é uma print da versão 1.0, somente para demostração.

[box class=titlebg]
Download e Script
[/box]
#==============================================================================
#                         .:: Nightmare Custom HUD ::.
#                         .::         v1.1         ::.
#------------------------------------------------------------------------------
# Criado por: Black_Zero      Data: 09/01/2014      Ultima Revisão: 24/01/2014
#------------------------------------------------------------------------------
module Nightmare_Config
#------------------------------------------------------------------------------
# Configure a HUD abaixo:
#------------------------------------------------------------------------------
  MP = true                   # Habilitar a barra de MP?
  EXP = false                  # Habilitar a barra de Exp?
  HERO = true                 # habilitar a char do heroi?
  NAME = false                 # Habilitar o nome do heroi?
  LEVEL = false                # Habilitar o nível do heroi?
#------------------------------------------------------------------------------
  HUD_BASE = 'HUD_Base'       # Nome da imagem que será a "base" da HUD
  HP_BAR = 'HP_Bar'           # Nome da imagem que será a barra de HP
  MP_BAR = 'MP_Bar'           # Nome da imagem que será a barra de MP
  EXP_BAR = 'EXP_Bar'         # Nome da imagem que será a barra de Exp
#------------------------------------------------------------------------------
  BASE_POS = [1,1]            # Posição da base da HUD
  HP_POS = [44,6]             # Posição da barra de HP
  MP_POS = [44,24]            # Posição da barra de MP
  EXP_POS = [44,42]           # Posição da barra de Exp
  IMG_POS = [3,3]             # Posição da imagem do heroi
  NAME_POS = [5,36]           # Posição do nome do heroi
  LEVEL_POS = [64,36]         # Posição do nível do heroi
#------------------------------------------------------------------------------
# OBS: A posição deve ser definida da seguinte maneira:
#      [Posição X da tela*, Posição Y da tela*]
#      *: em pixeis, ex: [25,1].
#------------------------------------------------------------------------------
end
#------------------------------------------------------------------------------
# Scene_Map modificada para adicionar a HUD a tela do jogo
#------------------------------------------------------------------------------
class Scene_Map < Scene_Base
  include Nightmare_Config
  alias night_start start
  alias night_update update
  alias night_terminate terminate
  def start
    night_start
    @hero = $game_party.members[0]
    create_hud
    update_variables
  end
  def update
    night_update
    update_if_necessary
    update_variables
  end
  def terminate
    night_terminate
    dispose_hud
  end
#------------------------------------------------------------------------------
# Criação e atualização da HUD
#------------------------------------------------------------------------------
  def create_hud
    create_sprites
    create_bitmaps
    set_sprite_pos
    get_bitmap_size
    draw_hp_bar
    draw_mp_bar if MP == true
    draw_exp_bar if EXP == true
    draw_actor_char if HERO == true
    draw_actor_name if NAME == true
    draw_actor_level if LEVEL == true
  end
  def update_if_necessary
    draw_hp_bar if hp_need_update?
    draw_mp_bar if mp_need_update? and MP == true
    draw_exp_bar if exp_need_update? and EXP == true
    draw_actor_char if char_need_update? and HERO == true
    draw_actor_name if name_need_update? and NAME == true
    draw_actor_level if level_need_update? and LEVEL == true
  end
#------------------------------------------------------------------------------
# Métodos para criar, "matar" e definir a posição das Sprites
#------------------------------------------------------------------------------
  def create_sprites
    @base = Sprite.new
    @hp = Sprite.new
    @mp = Sprite.new if MP == true
    @exp = Sprite.new if EXP == true
    @actor = Sprite.new if HERO == true
    @name = Sprite.new if NAME == true
    @level = Sprite.new if NAME == true
  end
  def create_bitmaps
    @base.bitmap = Cache.system(HUD_BASE)
    @hp.bitmap = Bitmap.new("Graphics/System/#{HP_BAR}")
    @mp.bitmap = Bitmap.new("Graphics/System/#{MP_BAR}") if MP == true
    @exp.bitmap = Bitmap.new("Graphics/System/#{EXP_BAR}") if EXP == true
    @actor.bitmap = Bitmap.new(32,32) if HERO == true
    @name.bitmap = Bitmap.new(160,20) if NAME == true
    @level.bitmap = Bitmap.new(40,20) if LEVEL == true
  end
#------------------------------------------------------------------------------
  def set_sprite_pos
    @base.x = BASE_POS[0]
    @hp.x = HP_POS[0]
    @mp.x = MP_POS[0] if MP == true
    @exp.x = EXP_POS[0] if EXP == true
    @actor.x = IMG_POS[0] if HERO == true
    @name.x = NAME_POS[0] if NAME == true
    @level.x = LEVEL_POS[0] if LEVEL == true
    @base.y = BASE_POS[1]
    @hp.y = HP_POS[1]
    @mp.y = MP_POS[1] if MP == true
    @exp.y = EXP_POS[1] if EXP == true
    @actor.y = IMG_POS[1] if HERO == true
    @name.y = NAME_POS[1] if NAME == true
    @level.y = LEVEL_POS[1] if LEVEL == true
  end
#------------------------------------------------------------------------------
  def dispose_hud
    @base.dispose
    @hp.dispose
    @mp.dispose if MP == true
    @exp.dispose if EXP == true
    @actor.dispose if HERO == true
    @name.dispose if NAME == true
    @level.dispose if LEVEL == true
  end
#------------------------------------------------------------------------------
# Métodos que "desenham" tudo na HUD
#------------------------------------------------------------------------------
  def draw_hp_bar
    @hp.bitmap.clear
    @hp.bitmap = Bitmap.new(@hpw,@hph)
    hpw = @hpw * @hero.hp / @hero.mhp
    hph = @hph
    hp_rect = Rect.new(0,0,hpw,hph)
    @hp.bitmap.blt(0,0,Cache.system(HP_BAR),hp_rect)
  end
  def draw_mp_bar
    @mp.bitmap.clear
    @mp.bitmap = Bitmap.new(@mpw,@mph)
    mpw = @mpw * @hero.mp / @hero.mmp
    mph = @mph
    mp_rect = Rect.new(0,0,mpw,mph)
    @mp.bitmap.blt(0,0,Cache.system(MP_BAR),mp_rect)
  end
  def draw_exp_bar
    @exp.bitmap.clear
    @exp.bitmap = Bitmap.new(@exw,@exh)
    exp = @hero.exp - @hero.current_level_exp
    max = @hero.next_level_exp - @hero.current_level_exp
    exw = @exw * exp / max
    exh = @exh
    hp_rect = Rect.new(0,0,exw,exh)
    @exp.bitmap.blt(0,0,Cache.system(EXP_BAR),hp_rect)
  end
  def draw_actor_char
    @actor.bitmap.clear
    char_bmp = Cache.character(@hero.character_name)
    sign = @hero.character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      cw = char_bmp.width / 3
      ch = char_bmp.height / 4
    else
      cw = char_bmp.width / 12
      ch = char_bmp.height / 8
    end
    @actor.bitmap = Bitmap.new(cw,ch)
    idx = @hero.character_index
    char_rect = Rect.new((idx%4*3+1)*cw,(idx/4*4)*ch,cw,ch)
    @actor.bitmap.blt(0,0,char_bmp,char_rect)
  end
  def draw_actor_name
    @name.bitmap.clear
    @name.bitmap = Bitmap.new(160,20)
    @name.bitmap.draw_text(0,0,160,20,@hero.name.to_s,0)
  end
  def draw_actor_level
    @level.bitmap.clear
    @level.bitmap = Bitmap.new(40,20)
    @level.bitmap.draw_text(0,0,40,20,@hero.level.to_s,1)
  end
#------------------------------------------------------------------------------
# Variáveis de atualização e o método para obter o tamanho das imagens
#------------------------------------------------------------------------------
  def update_variables
    @actor_hp = @hero.hp
    @actor_mhp = @hero.mhp
    @actor_mp = @hero.mp if MP == true
    @actor_mmp = @hero.mmp if MP == true
    @actor_exp = @hero.exp if EXP == true
    @char_name = @hero.character_name if HERO == true
    @char_index = @hero.character_index if HERO == true
    @actor_name = @hero.name if NAME == true
    @actor_level = @hero.level if LEVEL == true
  end
#------------------------------------------------------------------------------
  def get_bitmap_size
    @hpw = @hp.bitmap.width
    @hph = @hp.bitmap.height
    @mpw = @mp.bitmap.width if MP == true
    @mph = @mp.bitmap.height if MP == true
    @exw = @exp.bitmap.width if EXP == true
    @exh = @exp.bitmap.height if EXP == true
  end
#------------------------------------------------------------------------------
# Métodos de atualização, eles retornam verdadeiro se a HUD precisar atualizar
#------------------------------------------------------------------------------
  def hp_need_update?
    return true unless @actor_hp == @hero.hp
    return true unless @actor_mhp == @hero.mhp
  end
  def mp_need_update?
    return true unless @actor_mp == @hero.mp
    return true unless @actor_mmp == @hero.mmp
  end
  def exp_need_update?
    return true unless @actor_exp == @hero.exp
  end
  def char_need_update?
    return true unless @char_name == @hero.character_name
    return true unless @char_index == @hero.character_index
  end
  def name_need_update?
    return true unless @actor_name == @hero.name
  end
  def level_need_update?
    return true unless @actor_level == @hero.level
  end
end
#==============================================================================
#                            .:: Fim do Script ::.
#==============================================================================

Cara, estou com uma dúvida: está faltando algum arquivo para download ou eu não entendi o processo?

Vi Nightmare pensei que seria algo de terror, me pareceu simples, mas legal
bom trabalho.

E simples porém bonita. Realmente, com Nightmare pensei que fosse algo meio sombrio, mas você fez um ótimo trabalho!!
O mundo não se divide em pessoas boas e más. Todos temos Luz e Trevas dentro de nós...

O que importa é o lado o qual decidimos agir. Isso é o que realmente somos!

Amigo...está faltando os arquivos da Graphics/System para que a HUD funcione..você poderia disponibiliza-los para nós?