Introdução
Apesar de simples faz várias modificações na HUD padrão da engine
Como troca de opacidade ,cores, desativar face, tamanhos de barra ,mostra nome classe e nível do jogador
A customização fica na parte do topo do script
Sobre o Script
Todo por código não requer gráficos
você pode alterar as cores das barras assim como tamanho delas , ativar ou desativar a face
Os efeitos negativos fica abaixo da face... a barra de XP foi realocada para baixo da barra de MP
deixando tudo no mesmo local
Tamanho da fonte também é modificável
Adição do nome do personagem em seguida abaixo a classe dele barra de HP,MP,XP e Level
Assim como o background (cor e tamanho) ...entre outras
Antes de tudo faça um backup do seu projeto
Printscreen
Obs: os números em relação as barras é proposital para estarem ai mesmo deixa a HUD mais dinâmica
Substitua o [VS] Sprite_HUD todo pelo código abaixo
- Código:
#==============================================================================
#Sprite_HUD
#------------------------------------------------------------------------------
# Esta classe lida com a exibição da HUD do personagem
#------------------------------------------------------------------------------
# Autor: Merim
#==============================================================================
module HUDConfig
HP_BAR_COLOR = Color.new(255, 0, 0)
MP_BAR_COLOR = Color.new(0, 0, 255)
EXP_BAR_COLOR = Color.new(0, 255, 0)
BACKGROUND_COLOR = Color.new(0, 0, 0, 128)
HP_TEXT_COLOR = Color.new(255, 255, 255)
MP_TEXT_COLOR = Color.new(255, 255, 255)
EXP_TEXT_COLOR = Color.new(255, 255, 255)
NAME_TEXT_COLOR = Color.new(255, 255, 255)
CLASS_TEXT_COLOR = Color.new(255, 255, 255)
LEVEL_TEXT_COLOR = Color.new(255, 255, 255)
FONT_SIZE = 14 # Adicionando opção de tamanho da fonte
FACE_VISIBLE = true
LEVEL_VISIBLE = true
HP_BAR_WIDTH = 123
MP_BAR_WIDTH = 123
EXP_BAR_WIDTH = 239
BAR_HEIGHT = 10
HUD_OPACITY = 255
end
class Sprite_HUD < Sprite
attr_reader :exp_sprite
def initialize
super
self.bitmap = Bitmap.new(255, 140) # Ajuste para caber todos os elementos
self.x = 11
self.y = 9
self.z = 50
self.opacity = HUDConfig::HUD_OPACITY
self.bitmap.font.size = HUDConfig::FONT_SIZE
self.bitmap.font.bold = true
create_exp_sprite
@dragging = false
refresh
end
def dispose
super
@exp_sprite.dispose if @exp_sprite
end
def create_exp_sprite
@exp_sprite = Sprite.new(self.viewport)
@exp_sprite.bitmap = Bitmap.new(HUDConfig::HP_BAR_WIDTH, HUDConfig::BAR_HEIGHT)
@exp_sprite.x = self.x + 107
@exp_sprite.y = self.y + 99
@exp_sprite.z = self.z + 1
@exp_sprite.opacity = HUDConfig::HUD_OPACITY
@exp_sprite.instance_variable_set(:@dragging, false)
end
def adjust_x
Graphics.width / 2 - 109
end
def adjust_y
Graphics.height - 28
end
def refresh
draw_background
draw_face if HUDConfig::FACE_VISIBLE
draw_name
draw_class
draw_hp_bar
draw_mp_bar
draw_exp_bar_and_text
draw_level if HUDConfig::LEVEL_VISIBLE
end
def draw_background
self.bitmap.clear
self.bitmap.fill_rect(0, 0, 255, 140, HUDConfig::BACKGROUND_COLOR)
end
def draw_face
face = $game_actors[1].face_name.empty? ? Bitmap.new(96, 96) : Cache.face($game_actors[1].face_name)
rect = Rect.new($game_actors[1].face_index % 4 * 96, $game_actors[1].face_index / 4 * 96, 96, 96)
self.bitmap.blt(8, 15, face, rect) # Face do personagem mais abaixo
end
def draw_name
self.bitmap.font.color = HUDConfig::NAME_TEXT_COLOR
self.bitmap.font.size = HUDConfig::FONT_SIZE
self.bitmap.draw_text(107, 0, 148, 18, $game_actors[1].name, 1)
end
def draw_class
self.bitmap.font.color = HUDConfig::CLASS_TEXT_COLOR
self.bitmap.font.size = HUDConfig::FONT_SIZE
self.bitmap.draw_text(107, 18, 148, 18, $game_actors[1].class.name, 1)
end
def draw_hp_bar
hp_rate = $game_actors[1].hp.to_f / $game_actors[1].mhp
self.bitmap.font.color = HUDConfig::HP_TEXT_COLOR
self.bitmap.font.size = HUDConfig::FONT_SIZE
self.bitmap.draw_text(111, 26, 25, 18, Vocab::hp_a) # Texto acima da barra
self.bitmap.fill_rect(107, 45, HUDConfig::HP_BAR_WIDTH, HUDConfig::BAR_HEIGHT, Color.new(0, 0, 0))
self.bitmap.fill_rect(107, 45, (HUDConfig::HP_BAR_WIDTH * hp_rate).to_i, HUDConfig::BAR_HEIGHT, HUDConfig::HP_BAR_COLOR)
self.bitmap.draw_text(0, 45, 229, 18, "#{$game_actors[1].hp}/#{$game_actors[1].mhp}", 2)
end
def draw_mp_bar
mp_rate = $game_actors[1].mp.to_f / $game_actors[1].mmp
self.bitmap.font.color = HUDConfig::MP_TEXT_COLOR
self.bitmap.font.size = HUDConfig::FONT_SIZE
self.bitmap.draw_text(111, 54, 25, 18, Vocab::mp_a) # Texto acima da barra
self.bitmap.fill_rect(107, 72, HUDConfig::MP_BAR_WIDTH, HUDConfig::BAR_HEIGHT, Color.new(0, 0, 0))
self.bitmap.fill_rect(107, 72, (HUDConfig::MP_BAR_WIDTH * mp_rate).to_i, HUDConfig::BAR_HEIGHT, HUDConfig::MP_BAR_COLOR)
self.bitmap.draw_text(0, 72, 229, 18, "#{$game_actors[1].mp}/#{$game_actors[1].mmp}", 2)
end
def draw_exp_bar_and_text
exp_rate = $game_actors[1].now_exp.to_f / $game_actors[1].next_exp
self.bitmap.font.color = HUDConfig::EXP_TEXT_COLOR
self.bitmap.font.size = HUDConfig::FONT_SIZE
self.bitmap.draw_text(111, 81, 25, 18, "XP") # Texto acima da barra
self.bitmap.fill_rect(107, 99, HUDConfig::MP_BAR_WIDTH, HUDConfig::BAR_HEIGHT, Color.new(0, 0, 0))
self.bitmap.fill_rect(107, 99, (HUDConfig::MP_BAR_WIDTH * exp_rate).to_i, HUDConfig::BAR_HEIGHT, HUDConfig::EXP_BAR_COLOR)
exp = $game_actors[1].level >= Configs::MAX_LEVEL ? Vocab::MaxLevel : "#{$game_actors[1].now_exp * 100 / $game_actors[1].next_exp}%"
self.bitmap.draw_text(0, 99, 229, 18, exp, 2)
end
def draw_level
self.bitmap.font.color = HUDConfig::LEVEL_TEXT_COLOR
self.bitmap.font.size = HUDConfig::FONT_SIZE
self.bitmap.draw_text(0, 117, 255, 18, "Level: #{$game_actors[1].level}", 1)
end
def update
super
refresh
update_opacity
update_drag
end
def update_opacity
self.opacity = HUDConfig::HUD_OPACITY
end
def change_opacity
update_opacity
end
def update_drag
if Input.press?(:L)
if !@dragging && in_hud_area?(Input.mouse_x, Input.mouse_y)
@dragging = true
end
else
@dragging = false
end
if @dragging
self.x = Input.mouse_x - self.bitmap.width / 2
self.y = Input.mouse_y - self.bitmap.height / 2
end
end
def in_hud_area?(mouse_x, mouse_y)
mouse_x >= self.x && mouse_x <= self.x + self.bitmap.width &&
mouse_y >= self.y && mouse_y <= self.y + self.bitmap.height
end
end
- Código:
#==============================================================================
#Sprite_TargetHUD
#------------------------------------------------------------------------------
# Autor: Merim
#==============================================================================
class Sprite_TargetHUD < Sprite2
def initialize
super
self.bitmap = Bitmap.new(175, 72)
# Cria os ícones, cuja visibilidade é alterada no método `visible`
create_all_icons
self.x = adjust_x
self.y = 63
self.z = 50
self.visible = false
self.bitmap.font.size = 18
self.bitmap.font.bold = true
@dragable = true
end
def create_all_icons
@icons = []
@icons << Icon.new(nil, 0, 0, Configs::PRIVATE_ICON, Vocab::Private) { private_chat }
@icons << Icon.new(nil, 0, 0, Configs::BLOCK_ICON, Vocab::Block) { block }
@icons << Icon.new(nil, 0, 0, Configs::UNLOCK_ICON, Vocab::Unlock) { unlock }
@icons << Icon.new(nil, 0, 0, Configs::FRIEND_ICON, Vocab::Friend) { add_friend }
@icons << Icon.new(nil, 0, 0, Configs::TRADE_ICON, Vocab::Trade) { trade_request }
@icons << Icon.new(nil, 0, 0, Configs::PARTY_ICON, Vocab::Party) { party_request }
@icons << Icon.new(nil, 0, 0, Configs::GUILD_ICON, Vocab::Guild) { guild_request }
end
def adjust_x
Graphics.width / 2 - 87
end
def dispose
super
@icons.each(&:dispose)
end
def visible=(visible)
super
visible_icons = (visible && $game_player.target.is_a?(Game_NetPlayer))
@icons.each { |icon| icon.visible = visible_icons }
end
def hide
self.visible = false
end
def x=(x)
super
value = 0
@icons.each do |icon|
icon.x = x + value
value += 25
end
end
def y=(y)
super
@icons.each { |icon| icon.y = self.y + 48 }
end
def refresh
draw_name
draw_level
draw_hp_bar
end
def draw_name
self.bitmap.clear
self.bitmap.font.color.set(text_color(name_color))
self.bitmap.draw_text(1, 0, self.bitmap.width, 18, $game_player.target.actor.name)
end
def name_color
return Configs::ADMIN_COLOR if $game_player.target.admin?
return Configs::MONITOR_COLOR if $game_player.target.monitor?
return Configs::ENEMY_COLOR if $game_player.target.is_a?(Game_Event)
return Configs::DEFAULT_COLOR
end
def draw_level
self.bitmap.font.color.set(normal_color)
self.bitmap.draw_text(0, 0, self.bitmap.width, 18, "#{Vocab::level_a}. #{$game_player.target.actor.level}", 2) if $game_player.target.is_a?(Game_NetPlayer)
end
def draw_hp_bar
bitmap = Cache.system('TargetHPBar')
rect = Rect.new(0, 0, self.bitmap.width, 26)
self.bitmap.blt(0, 20, bitmap, rect)
rect = Rect.new(0, 26, self.bitmap.width * $game_player.target.actor.hp / $game_player.target.actor.mhp, 26)
self.bitmap.blt(0, 20, bitmap, rect)
self.bitmap.draw_text(4, 25, 25, 18, Vocab::hp_a)
self.bitmap.draw_text(0, 25, 173, 18, "#{$game_player.target.actor.hp}/#{$game_player.target.actor.mhp}", 2)
end
def private_chat
$windows[:chat].private($game_player.target.actor.name)
end
def block
return if $game_player.blocked.include?($game_player.target.actor.name)
$game_player.blocked << $game_player.target.actor.name
$windows[:chat].write_message("#{$game_player.target.actor.name} #{Vocab::Blocked}", Configs::ERROR_COLOR)
end
def unlock
return unless $game_player.blocked.include?($game_player.target.actor.name)
$game_player.blocked.delete($game_player.target.actor.name)
$windows[:chat].write_message("#{$game_player.target.actor.name} #{Vocab::Unlocked}", Configs::SUCCESS_COLOR)
end
def add_friend
if $game_actors[1].friends.include?($game_player.target.actor.name)
$error_msg = Vocab::FriendExist
elsif $game_actors[1].friends.size >= Configs::MAX_FRIENDS
$error_msg = Vocab::FullFriends
elsif !$game_player.in_range?($game_player.target, 10)
$error_msg = Vocab::PlayerNotInRange
else
$network.send_request(Enums::Request::FRIEND, $game_player.target.id)
end
end
def trade_request
if !$game_player.in_range?($game_player.target, 10)
$error_msg = Vocab::PlayerNotInRange
elsif $windows[:my_trade].visible
$error_msg = Vocab::InTrade
else
$network.send_request(Enums::Request::TRADE, $game_player.target.id)
end
end
def party_request
if $game_actors[1].party_members.size >= Configs::MAX_PARTY_MEMBERS - 1
$error_msg = Vocab::FullParty
elsif !$game_player.in_range?($game_player.target, 10)
$error_msg = Vocab::PlayerNotInRange
else
$network.send_request(Enums::Request::PARTY, $game_player.target.id)
end
end
def guild_request
if $game_actors[1].guild_name.empty?
$error_msg = Vocab::NotGuild
elsif !$game_player.target.actor.guild_name.empty?
$error_msg = "#{$game_player.target.actor.name} #{Vocab::PlayerInGuild} #{$game_player.target.actor.guild_name}."
else
$network.send_request(Enums::Request::GUILD, $game_player.target.id)
end
end
def update
super
@icons.each { |icon| icon.update if icon.visible }
change_opacity
end
end
Qualquer bug ou algo do tipo favor reportar nesse post , até o presente momento não tive nenhum
Grande abraço ! e bom desenvolvimento a todos.