Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Blizzard's HUD

EDIT: Never mind. I've added a couple more systems to my game engine that seem to prompt the HUD into changing properly. The problem with the HUD still exists, but I've worked out a workaround.

Hi!
I'm running Blizzards "Blizz-Art lagless HUD" 1.43b in my game (uses SDK), and it works fine... or so I thought.
It seems to be updating the HUD apart from the bar that displays how much EXP you need until the next level. When I go to the menu screen and then go back again, it updates itself properly, but not when transferring between maps or on the map.

Now, I'm not really a scripter. I'm on the level of hacking bits about with mixed results. I've tried hacking bits off and adding bits on unsuccessfully and I was wondering if anyone would be prepared to have a look at the script to see if they can get the thing to update properly. I've included the script below. Thanks! :) BTW, sorry it's a bit long. I didn't know what bit was relevant.

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Blizz-Art lagless HUD by Blizzard
# Version: 1.43b
# Type: Game Playability Improvement
# Date: 16.12.2006
# Date v1.1b: 12.1.2007
# Date v1.2b: 11.3.2007
# Date v1.3b: 7.7.2007
# Date v1.4b: 17.2.2008
# Date v1.41b: 3.4.2008
# Date v1.42b: 22.8.2008
# Date v1.43b: 24.11.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# IMPORTANT:
#
#   The "not simple" method of using this add-on REQUIRES Blizz-Art Gradient
#   styler for HP/SP/EXP bars. Blizz-ABS disables this add-on automatically and
#   uses the Blizz-ABS HUD system.
#
#
# Instructions:
#
#   This add-on will add a HUD into your game. Configure the part below. The
#   meanings of the variables are:
#
#     SIMPLE       - set this to false to use Blizz-Art Gradient styler instead
#                    of the normal bars
#     FULL_DISPLAY - set to true to show the stats of all party members in the
#                    display (otherwise hold D and press Q/W to cycle through
#                    the actors)
#     TOP          - set this value to false and the HUD will appear on the
#                    bottom
#   
#
# Side-Note:
#
#   This add-on comes BELOW the Gradient Styler. This HUD was made for an
#   infinite number of party members, but if using FULL_DISPLAY, only the first
#   4 members will be displayed.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Start HUD Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

SIMPLE = true
FULL_DISPLAY = false
TOP = true

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# End HUD Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  attr_accessor :index
  attr_accessor :bar_style unless FULL_DISPLAY
  attr_reader   :bar_opacity
  #----------------------------------------------------------------------------
  # initialize
  #  Added variables for bar styles if Blizz-Art bars are being used.
  #----------------------------------------------------------------------------
  alias init_blizzart_hud_later initialize
  def initialize
    init_blizzart_hud_later
    @index = 0 unless FULL_DISPLAY
    unless $Blizz_Art
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#
#   Configure this part manually if you have no "Options" controller for the
#   styles and the opacity. (style: 0~5, opacity: 0~255)
#   Note that this WILL be overriden if you use Blizz-Art Gradient Styler.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
      @bar_style = 5
      self.bar_opacity = 255
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
  end
 
  def bar_opacity=(alpha)
    @bar_opacity = [[alpha, 0].max, 255].min
  end
 
end

#==============================================================================
# Bitmap
#==============================================================================

class Bitmap
 
  #----------------------------------------------------------------------------
  # gradient_bar_simple
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - width of the bar to be drawn
  #  color1 - bar color
  #  color2 - back color
  #  rate   - fill rate
  #  Very fast method to draw the 7th style from Blizz-Art.
  #----------------------------------------------------------------------------
  def gradient_bar_simple(x, y, w, color1, color2, rate)
    # quantizes the width so it looks better (remove it and see what happens)
    w = w / 8 * 8
    alpha = $game_system.bar_opacity
    # iterate through each of 6 lines
    (1..6).each {|i|
        # calculate background color
        color = Color.new(color2.red*i/6, color2.green*i/6, color2.blue*i/6, alpha)
        # draw background
        fill_rect(x + 2, y + i, w, 14 - i * 2, color)
        # calculate bar color
        color = Color.new(color1.red*i/6, color1.green*i/6, color1.blue*i/6, alpha)
        # draw bar
        fill_rect(x + 2, y + i, w * rate, 14 - i * 2, color)}
  end
  # if not defined already
  unless $Blizz_Art
  #----------------------------------------------------------------------------
  # draw_text
  #  x2    - x coordinate or rectangle
  #  y2    - y coordinate or text
  #  w2    - width or align
  #  h2    - height
  #  text2 - the text to be drawn
  #  a2    - align
  #  Added additional drawing to make the text look like shaded.
  #----------------------------------------------------------------------------
  alias draw_text_shaded_later draw_text
  def draw_text(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
    # set coordinates whether x2 is rectangle
    if x2.is_a?(Rect)
      x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
    else
      x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
    end
    # if active
    if $game_system != nil && $game_system.SHADED_TEXT
      # store font color
      save_color = self.font.color.clone
      # set font color to black
      self.font.color = Color.new(0, 0, 0)
      # draw shade
      draw_text_shaded_later(x+1, y+1, w, h, text, a)
      # restore font color
      self.font.color = save_color
    end
    # draw normal text
    draw_text_shaded_later(x, y, w, h, text, a)
  end
  #----------------------------------------------------------------------------
  # draw_text_full
  #  x2    - x coordinate or rectangle
  #  y2    - y coordinate or text
  #  w2    - width or align
  #  h2    - height
  #  text2 - the text to be drawn
  #  a2    - align
  #  Draws outlines text.
  #----------------------------------------------------------------------------
  def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
    # set coordinates whether x2 is rectangle
    if x2.is_a?(Rect)
      x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
    else
      x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
    end
    # store font color
    save_color = self.font.color.clone
    # set font color to black
    self.font.color = Color.new(0, 0, 0)
    # draw outline
    draw_text_shaded_later(x+1, y+1, w, h, text, a)
    draw_text_shaded_later(x-1, y+1, w, h, text, a)
    draw_text_shaded_later(x-1, y-1, w, h, text, a)
    draw_text_shaded_later(x+1, y-1, w, h, text, a)
    # restore font color
    self.font.color = save_color
    # draw normal text
    draw_text_shaded_later(x, y, w, h, text, a)
  end
  end
 
end

#==============================================================================
# Window_Base
#==============================================================================

class Window_Base

  #----------------------------------------------------------------------------
  # draw_actor_exp_alt
  #  actor - actor
  #  x     - x coordinate or rectangle
  #  y     - y coordinate or text
  #  Draw the "EXP needed for next level" text.
  #----------------------------------------------------------------------------
  def draw_actor_exp_alt(actor, x, y)
    # set color and draw "next"
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 64, 32, 'next')
    # set color and draw value
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 56, y, 84, 32, actor.next_rest_exp_s, 2)
  end
  #----------------------------------------------------------------------------
  # draw_actor_exp_alt
  #  actor - actor
  #  x     - x coordinate or rectangle
  #  y     - y coordinate or text
  #  w     - width of the bar
  #  Added fill rate calculation and bar drawing.
  #----------------------------------------------------------------------------
  alias draw_actor_exp_alt_blizzart_hud_later draw_actor_exp_alt
  def draw_actor_exp_alt(actor, x, y, w = 148)
    w -= 12
    # calculate fill rate
    rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
    # create color depending on fill rate
    if rate < 0.5
      color1 = Color.new(20 * rate, 60, 80, 192)
      color2 = Color.new(60 * rate, 180, 240, 192)
    elsif rate >= 0.5
      color1 = Color.new(20 + 120 * (rate-0.5), 60 + 40 * (rate-0.5), 80, 192)
      color2 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
    end
    # background color
    color3 = Color.new(80, 80, 80, 192)
    # draw bar
    self.contents.gradient_bar(x, y, w, color1, color2, color3, rate)
    draw_actor_exp_alt_blizzart_hud_later(actor, x, y)
  end
  #----------------------------------------------------------------------------
  # draw_actor_hp_hud
  #  actor - actor
  #  x     - x coordinate or rectangle
  #  y     - y coordinate or text
  #  w     - width of the bar
  #  This method calculates the fill rate and draws the bar in the HUD for HP.
  #----------------------------------------------------------------------------
  def draw_actor_hp_hud(actor, x, y, w = 148)
    # calculate fill rate
    rate = (actor.maxhp > 0 ? actor.hp.to_f / actor.maxhp : 0)
    # create color depending on fill rate
    if rate > 0.6
      color1 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
    elsif rate > 0.2 && rate <= 0.6
      color1 = Color.new(240, 600 * (rate-0.2), 0, 192)
    elsif rate <= 0.2
      color1 = Color.new(240, 0, 0, 192)
    end
    # background color
    color2 = Color.new(0, 80, 0, 192)
    # draw bar
    self.contents.gradient_bar_simple(x + 32, y, w - 48, color1, color2, rate)
    # fix y coordinate
    y -= 9
    self.contents.font.color = system_color
    # draw HP word
    self.contents.draw_text_full(x, y, 32, 32, $data_system.words.hp)
    # set offset
    hp_x = x + w - 122
    # set colors and draw values
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text_full(hp_x, y, 48, 32, actor.hp.to_s, 2)
    self.contents.font.color = normal_color
    self.contents.draw_text_full(hp_x + 48, y, 12, 32, '/', 1)
    self.contents.draw_text_full(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    self.contents.font.color.alpha = 255
  end
  #----------------------------------------------------------------------------
  # draw_actor_sp_hud
  #  actor - actor
  #  x     - x coordinate or rectangle
  #  y     - y coordinate or text
  #  w     - width of the bar
  #  This method calculates the fill rate and draws the bar in the HUD for SP.
  #----------------------------------------------------------------------------
  def draw_actor_sp_hud(actor, x, y, w = 148)
    # calculate fill rate
    rate = (actor.maxsp > 0 ? actor.sp.to_f / actor.maxsp : 0)
    # create color depending on fill rate
    if rate > 0.4
      color1 = Color.new(180 - 200 * (rate-0.4), 60, 240, 192)
    elsif rate <= 0.4
      color1 = Color.new(60 + 300 * rate, 150 * rate, 80 + 400 * rate, 192)
    end
    # background color
    color2 = Color.new(0, 0, 80, 192)
    # draw bar
    self.contents.gradient_bar_simple(x + 32, y, w - 48, color1, color2, rate)
    # fix y coordinate
    y -= 9
    self.contents.font.color = system_color
    # draw SP word
    self.contents.draw_text_full(x, y, 32, 32, $data_system.words.sp)
    # set offset
    sp_x = x + w - 122
    # set colors and draw values
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text_full(sp_x, y, 48, 32, actor.sp.to_s, 2)
    self.contents.font.color = normal_color
    self.contents.draw_text_full(sp_x + 48, y, 12, 32, '/', 1)
    self.contents.draw_text_full(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
  end
  #----------------------------------------------------------------------------
  # draw_actor_exp_hud
  #  actor - actor
  #  x     - x coordinate or rectangle
  #  y     - y coordinate or text
  #  w     - width of the bar
  #  This method calculates the fill rate and draws the bar in the HUD for EXP.
  #----------------------------------------------------------------------------
  def draw_actor_exp_hud(actor, x, y, w = 148)
    # calculate fill rate
    rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
    # create color depending on fill rate
    if rate < 0.5
      color1 = Color.new(60 * rate, 180, 240, 192)
    elsif rate >= 0.5
      color1 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
    end
    # background color
    color2 = Color.new(80, 80, 80, 192)
    # draw bar
    self.contents.gradient_bar_simple(x + 32, y, w - 48, color1, color2, rate)
    # fix y coordinate
    y -= 9
    self.contents.font.color = system_color
    # draw "next"
    self.contents.draw_text_full(x, y, 80, 32, 'next')
    self.contents.font.color = normal_color
    # draw value
    self.contents.draw_text_full(x + 56, y, 84, 32, actor.next_rest_exp_s, 2)
    self.contents.font.color.alpha = 255
  end
 
end

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor
 
  #----------------------------------------------------------------------------
  # now_exp
  #  Returns the EXP collected in this level.
  #----------------------------------------------------------------------------
  def now_exp
    return @exp - @exp_list[@level]
  end
  #----------------------------------------------------------------------------
  # next_exp
  #  Returns the EXP needed to level up as number.
  #----------------------------------------------------------------------------
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
 
end

#==============================================================================
# Hud
#==============================================================================

class Hud < Window_Base
 
  #----------------------------------------------------------------------------
  # initialize
  #----------------------------------------------------------------------------
  def initialize
    super(-12, -16, 192, 112)
    # invisible background
    self.opacity = 0
    # if not on top position
    unless TOP
      # move down
      self.y += 400
      # move up a bit if not SIMPLE mode
      self.y -= 16 unless SIMPLE
    end
    # increase height if not SIMPLE mode
    self.height += 32 unless SIMPLE
    self.z = 5000
    refresh
  end
  #----------------------------------------------------------------------------
  # refresh
  #  Draws all the details.
  #----------------------------------------------------------------------------
  def refresh
    # remove bitmap if already existing
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # change width
    self.width = FULL_DISPLAY ? 32 + 160 * $game_party.actors.size : 192
    # create new bitmap
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    # set font style
    self.contents.font.name = 'Arial'
    self.contents.font.size = 16
    self.contents.font.bold = true
    # initialize data
    @names, @levels, @hps, @sps, @exps = [], [], [], [], []
    # iterate through all actor indices
    $game_party.actors.each_index {|i|
        # get actor depending on FULL_DISPLAY option
        actor = $game_party.actors[(FULL_DISPLAY ? i : $game_system.index)]
        # set style and draw name
        self.contents.font.italic = true
        self.contents.font.size += 2
        self.contents.font.color = system_color
        self.contents.draw_text(i*160, -8, 152, 32, actor.name, 1)
        # reset style
        self.contents.font.italic = false
        if SIMPLE
          # draw other HP, SP and EXP on HUD
          self.contents.font.size -= 2
          draw_actor_hp_hud(actor, i*160, 16, 160)
          draw_actor_sp_hud(actor, i*160, 32, 160)
          draw_actor_exp_hud(actor, i*160, 48, 160)
        else
          # draw other HP, SP and EXP on HUD using Blizz-Art
          draw_actor_hp(actor, i*160, 8, 160)
          draw_actor_sp(actor, i*160, 32, 160)
          draw_actor_exp_alt(actor, i*160, 56, 160)
          self.contents.font.size -= 2
        end}
    # draw gold text
    self.contents.font.color = Color.new(255, 255, 0)
    self.contents.draw_text(0, (SIMPLE ? 56 : 84), 148, 32, $data_system.words.gold)
    self.contents.draw_text(0, (SIMPLE ? 56 : 84), 148, 32, $game_party.gold.to_s, 2)
    # iterate through all party members and add stats to data arrays
    $game_party.actors.each {|actor|
        @names.push(actor.name)
        @levels.push(actor.level)
        @hps.push(actor.hp)
        @sps.push(actor.sp)
        @exps.push(actor.exp)}
    @gold = $game_party.gold
  end
  #----------------------------------------------------------------------------
  # test_changed
  #  Tests if the HUD should be redrawn.
  #----------------------------------------------------------------------------
  def test_changes
    # draw if gold had changed
    return true if $game_party.gold != @gold
    # if all actors on HUD
    if FULL_DISPLAY
      # draw if any actor has changes
      $game_party.actors.each_index {|i|
          actor = $game_party.actors
          if actor.name != @names || actor.level != @levels ||
              actor.hp != @hps || actor.sp != @sps
            return true
          end}
    else
      # draw if current actor had changes
      actor = $game_party.actors[$game_system.index]
      if actor.name != @names[$game_system.index] ||
          actor.level != @levels[$game_system.index] ||
          actor.hp != @hps[$game_system.index] ||
          actor.sp != @sps[$game_system.index]
        return true
      end
    end
    return false
  end
 
end

#==============================================================================
# Scene_Map
#==============================================================================

class Scene_Map
 
  #----------------------------------------------------------------------------
  # main
  #  Added HUD window creation.
  #----------------------------------------------------------------------------
  alias main_blizzart_hud_later main
  def main
    if (!$BlizzABS || BlizzABS::VERSION < 1.01) && $game_system.HUD
      @hud = Hud.new
    end
    main_blizzart_hud_later
    @hud.dispose unless @hud == nil || @hud.disposed?
  end
  #----------------------------------------------------------------------------
  # update
  #  Added HUD handling.
  #----------------------------------------------------------------------------
  alias upd_blizzart_hud_later update
  def update
    # skip if Blizz-ABS enabled
    if !$BlizzABS || BlizzABS::VERSION < 1.01
      # if HUD active
      if $game_system.HUD
        # create new if not existing
        @hud = Hud.new if @hud == nil
      # if HUD exists
      elsif @hud != nil
        # remove HUD
        @hud.dispose
        @hud = nil
      end
      # if HUD still exists
      if @hud != nil
        # change display depenging on button input
        if Input.press?(Input::Z) && Input.trigger?(Input::L)
          $game_system.index += $game_party.actors.size - 1
          $game_system.index %= $game_party.actors.size
          @hud.refresh
        elsif Input.press?(Input::Z) && Input.trigger?(Input::R)
          $game_system.index += 1
          $game_system.index %= $game_party.actors.size
          @hud.refresh
        elsif @hud.test_changes
          @hud.refresh
        end
      end
    end
    upd_blizzart_hud_later
  end
 
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top