Basic HUD


Version v1.0
Author TheDreamWriter
Release Date August 1st, 2012

Plaform RGSS3 (RPG Maker VX ACE)

Script exclusively available at RPG RPG Revolution.


Introduction
This script displays a basic HUD on the map in the top left corner.

Features
It appears on map after activation through a menu choice.
Can be activated and deactivated through the menu choice.
Updates automatically when HP or MP changes.

Script
CODE
#===============================================================================
# Title: Basic HUD
# by TheDreamWriter
# with assistance from The Law G14
# and diamondandplatinum3
#-------------------------------------------------------------------------------
# This window will display actor name, HP and MP
#===============================================================================

#-------------------------------------------------------------------------------
# Instructions
#-------------------------------------------------------------------------------
# Plug 'n' Play
# Place either above Main or in Materials
# Change HUD switch below
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
# Changelog
#-------------------------------------------------------------------------------
# Will make it possible to customise font, color, size, window color, opacity
# and bars in the HUD in the near future.
# Keep an eye out for updates!
# ~TDW
#-------------------------------------------------------------------------------

module TheDreamWriterHud
  Event_Switch_ID = 1 # Change the number to assign a different switch to the
                      # HUD
end

#===============================================================================
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
#===============================================================================

class Window_Advanced < Window_Base
  #---------------------------------------------------------------------------
  # * Object Initialization
  #---------------------------------------------------------------------------
  def initialize
    #super(x, y, width, height)
    super(0, 0, 160, 115)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #---------------------------------------------------------------------------
  # * Refresh
  #---------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.name = "VL-Gothic-Regular"
    self.contents.font.size = 24
    # ...(actor, x, y)
    actor = $game_party.members[000]
    @actor = actor
    @hp = actor.hp
    @mp = actor.mp
    draw_actor_name(@actor, 0, 0)
    draw_actor_hp(@actor, 0, 30)
    draw_actor_mp(@actor, 0, 60)
    self.opacity = 100
  end
  #---------------------------------------------------------------------------
  # * Update
  #---------------------------------------------------------------------------
  def update
    # Call parent method
    super
    # Make it so that hp and sp are constantly updated (this is the simple
    # version by the way to not confuse you
    if @actor.hp != @hp or @actor.mp != @mp
      refresh
    end
  end    
end




#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
#  This command window appears on the menu screen.
#==============================================================================

class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  alias thedreamwriter_mcl make_command_list
  def make_command_list
    add_main_commands
    add_formation_command
    add_original_commands
    add_hud_command
    add_save_command
    add_game_end_command
  end
  
  
  
  
  def add_hud_command
    add_command("HUD", :hud)
  end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  alias thedreamwriter_ccw create_command_window
  def create_command_window
    @command_window = Window_MenuCommand.new
    @command_window.set_handler(:item,      method(:command_item))
    @command_window.set_handler(:skill,     method(:command_personal))
    @command_window.set_handler(:equip,     method(:command_personal))
    @command_window.set_handler(:status,    method(:command_personal))
    @command_window.set_handler(:formation, method(:command_formation))
    @command_window.set_handler(:hud,       method(:command_hud))
    @command_window.set_handler(:save,      method(:command_save))
    @command_window.set_handler(:game_end,  method(:command_game_end))
    @command_window.set_handler(:cancel,    method(:return_scene))
  end
  #-------------------------------------------------------------------------
  # * HUD Command
  #-------------------------------------------------------------------------
  def command_hud
    if $game_switches[TheDreamWriterHud::Event_Switch_ID] == true
      $game_switches[TheDreamWriterHud::Event_Switch_ID] = false
      $windowhud.dispose unless $windowhud.disposed?
      return_scene
    else
      $game_switches[TheDreamWriterHud::Event_Switch_ID] = true
      $windowhud = Window_Advanced.new
      return_scene
    end
  end
end

  
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  alias thedreamwriter_scnmapstart start
  def start
    $windowhud = Window_Advanced.new if $game_switches[TheDreamWriterHud::Event_Switch_ID] && $windowhud.disposed?
    thedreamwriter_scnmapstart
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias thedreamwriter_scnmapupdate update
  def update
    thedreamwriter_scnmapupdate
    $windowhud.update if $game_switches[TheDreamWriterHud::Event_Switch_ID]
  end
end


#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Post-Start Processing
  #--------------------------------------------------------------------------
  alias thedreamwriter_poststart post_start
  def post_start
    $windowhud.dispose if $game_switches[TheDreamWriterHud::Event_Switch_ID]
    thedreamwriter_poststart
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  alias thedreamwriter_terminate terminate
  def terminate
    thedreamwriter_terminate
    $windowhud = Window_Advanced.new if $game_switches[TheDreamWriterHud::Event_Switch_ID]
  end
end


#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
#  This class performs game over screen processing.
#==============================================================================
class Scene_Gameover < Scene_Base
  #--------------------------------------------------------------------------
  # * Transition to Title Screen
  #--------------------------------------------------------------------------
  alias thedreamwriter_gototitle goto_title
  def goto_title
    $windowhud.dispose if $game_switches[TheDreamWriterHud::Event_Switch_ID]
    thedreamwriter_terminate
  end
end


#==============================================================================
# ** Scene_End
#------------------------------------------------------------------------------
#  This class performs game over screen processing.
#==============================================================================

class Scene_End < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * [Go to Title] Command
  #--------------------------------------------------------------------------
  alias thedreamwriter_commdtotitle command_to_title
  def command_to_title
    $windowhud.dispose if $game_switches[TheDreamWriterHud::Event_Switch_ID]
    thedreamwriter_commdtotitle
  end
end
#==============================================================================
#
# *** END OF SCRIPT ***
#
#==============================================================================


Customisation
Plug 'n' Play with no customisation (at the moment - watch out for future releases)

Compatability
This script adds an option to the menu so it may have problems if put with other menu-altering scripts.

Screenshots
The Menu Option

The HUD


Installation Instructions
Plug 'n' Play
Place above Main or in the Materials Section

Credits
Free for use in non-commercial games. Please PM me if you want to use this in a commercial game (seriously?).

Credit TheDreamWriter, The Law G14 who has taught me RGSSx and helped with this script and diamondandplatinum3 who tweaked the script and produced the final product.