Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ** Esteem - HUD Sprite
- #==============================================================================
- # ► Script por: Revali / Skyloftian
- #------------------------------------------------------------------------------
- # ► Atualizações: 05/05/18 - v1.0 - Código finalizado e revisado
- #==============================================================================
- # ► Descrição: Cria uma HUD básica. Script feito a pedido do membro Saggi.
- #==============================================================================
- # ► Comandos: Existem dois comandos para a utilização da HUD. Estes são:
- #
- # esteem_hudsprite_enable - Ativa a HUD
- # esteem_hudsprite_disable - Desativa a HUD
- #
- # * OBSERVAÇÃO: Estes comandos devem ser usados através do comando de evento
- # Chamar Script / Script Call.
- #==============================================================================
- # * Para configurar vide a área configurável abaixo.
- #==============================================================================
- module Esteem
- module HUD_Sprite
- #==============================================================================
- # ► Configurações
- #==============================================================================
- #===========================================================================
- # ► Cores das Barras
- #===========================================================================
- # * Configure as duas cores de cada barra(HP, MP e TP) utilizando-se do
- # esquema RGB(Red, Green, Blue) / VVA (Vermelho, Verde, Azul). As duas
- # cores formarão um gradiente.
- #---------------------------------------------------------------------------
- # NÃO_MUDE = [RED, GREEN, BLUE]
- #===========================================================================
- HP_COLOR1 = [115, 4, 4] # Primeira cor HP
- HP_COLOR2 = [210, 12, 12] # Segunda cor HP
- MP_COLOR1 = [ 0, 144, 255] # Primeira cor MP
- MP_COLOR2 = [171, 218, 255] # Segunda cor MP
- TP_COLOR1 = [ 30, 252, 157] # Primeira cor TP
- TP_COLOR2 = [147, 255, 209] # Segunda cor TP
- B_COLOR = [109, 109, 109] # Cor do fundo das barras
- TX_COLOR = [ 0, 0, 255] # Cor do texto indicativo dos parâmetros
- #==============================================================================
- # ► Fim das Configurações | Não mude mais nada caso não entenda
- #==============================================================================
- end # HUD_Sprite
- end # Esteem
- class Scene_Map < Scene_Base
- def hud_manager
- if !@hud
- @hud = EHS_Hud.new
- else
- @hud.update
- end
- end
- alias :ehs_update :update
- def update
- ehs_update
- hud_manager if $game_system.ehs_switch
- @hud.dispose if !$game_system.ehs_switch && @hud
- end
- alias :ehs_terminate :terminate
- def terminate
- @hud.dispose if @hud
- end
- end # Scene_Map
- class EHS_Hud
- include Esteem::HUD_Sprite
- def initialize
- super
- draw_contents
- end
- def draw_contents
- @sprites = []
- actor = $game_party.members[0]
- all_width = (Graphics.width - 20) / 3
- draw_actor_gauges(actor, all_width)
- draw_actor_values(actor, all_width)
- draw_actor_icons(actor, all_width * 2)
- end
- def draw_actor_gauges(actor, gauge_width)
- draw_gauge(actor.hp_rate, 5 , 19, gauge_width, HP_COLOR1, HP_COLOR2)
- draw_gauge(actor.mp_rate, 10 + gauge_width, 19 , gauge_width, MP_COLOR1, MP_COLOR2)
- draw_gauge(actor.tp_rate, 15 + gauge_width * 2, 19 , gauge_width, TP_COLOR1, TP_COLOR2)
- end
- def draw_actor_values(actor, text_width)
- draw_cam_values(actor.hp, actor.mhp, Vocab::hp_a, 5, 2, text_width, true)
- draw_cam_values(actor.mp, actor.mmp, Vocab::mp_a, 10 + text_width, 2, text_width, true)
- draw_cam_values(actor.tp, 100, Vocab::tp_a, 15 + text_width * 2, 2, text_width, false)
- end
- def draw_actor_icons(actor, icons_width)
- icons = (actor.state_icons + actor.buff_icons)[0, icons_width / 24]
- icons.each_with_index {|n, i| draw_icon(n, 5 + 24 * i, 28) }
- end
- def draw_gauge(rate, x, y, width, colora, colorb, colorc = B_COLOR)
- color1 = Color.new(colora[0], colora[1], colora[2])
- color2 = Color.new(colorb[0], colorb[1], colorb[2])
- colorb = Color.new(colorc[0], colorc[1], colorc[2])
- fill_w = (width * rate).to_i
- gauge_back = Sprite.new
- gauge_back.x = x ; gauge_back.y = y
- gauge_back.bitmap = Bitmap.new(width, 6)
- gauge_back.bitmap.fill_rect(0, 0, width, 6, colorb)
- gauge = Sprite.new
- gauge.x = x ; gauge.y = y
- gauge.bitmap = Bitmap.new(width, 6)
- gauge.bitmap.gradient_fill_rect(0, 0, fill_w, 6, color1, color2)
- @sprites.push(gauge_back, gauge)
- end
- def draw_cam_values(current, max, vocab, x, y, width, change)
- color1 = Color.new(TX_COLOR[0], TX_COLOR[1], TX_COLOR[2])
- current < max / 4 && change ? color2 = Color.new(255, 255, 0, 255) : color2 = Color.new(255, 255, 255, 255)
- text = Sprite.new ; values = Sprite.new
- text.x = x ; values.x = x
- text.y = y ; values.y = y
- text.z = 1 ; values.z = 1
- text.bitmap = Bitmap.new(width, 25) ; values.bitmap = text.bitmap
- text.bitmap.font.color = color1
- text.bitmap.draw_text(0, 0, width, 25, vocab, 0)
- values.bitmap.font.color = color2
- values.bitmap.draw_text(0, 0, width, 25, current.to_s + "/" + max.to_s, 2)
- @sprites.push(text, values)
- end
- def draw_icon(icon_index, x, y, enabled = true)
- icon = Sprite.new
- icon.x = x ; icon.y = y
- icon.bitmap = Cache.system("Iconset")
- icon.src_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- @sprites.push(icon)
- end
- def update
- refresh
- end
- def refresh
- dispose
- draw_contents
- end
- def dispose
- @sprites.each {|sprite| sprite.dispose}
- end
- end # EHS_Hud
- class Game_System
- attr_accessor :ehs_switch
- alias :ehs_initialize :initialize
- def initialize
- ehs_initialize
- @ehs_switch = false
- end
- end # Game_System
- class Game_Interpreter
- def esteem_hudsprite_enable
- $game_system.ehs_switch = true
- end
- def esteem_hudsprite_disable
- $game_system.ehs_switch = false
- end
- end # Game_Interpreter
RAW Paste Data