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.

Custom HUD

Hi there, I'm looking for a simple HUD, not to display HP or SP, but to display the map name, and the equipable items named "Myst"
I just want it to look like this:
http://img236.imageshack.us/img236/6558 ... iewpo1.png[/img]
I want the outline to be displayed through a graphic in the picture folder, named "HUD" or something, And can it just be text for the other things?
Like, Display the actor name, then the icon of the accessory equipped with the attribute "Myst", With 5 actors, and the Map display is optional, I'd rather it be there, but I don't need it.
Sorry if I'm not being specific enough.
 

khmp

Sponsor

I think I can do this, if you have no objections that is. But first I would like clarification on a few things.

You don't want this information in a window? You want it displayed on a graphic. Do you only want the map name written on the graphic, like the picture shows? Do you want the names of the actor to be displayed only if they have a myst item? Do you want the actor name and the possible myst icon to be free floating text. Meaning they aren't tethered or displayed on a window or graphic?
 
I'd like it to be in a Window with about 122 Opacity, and if there is an actor without a Myst Icon, could it just show a "-"(hyphen) instead? And Could the Map name be in a Full 255 Opacity Window at the Top left of the other window?
Thank you very much for responding.
 

khmp

Sponsor

Alright thanks for the clarification.

Code:
#==============================================================================
# ** HUD_Properties
#------------------------------------------------------------------------------
#  This class holds the constants that are shared across the HUD classes.
#==============================================================================

class HUD_Properties
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  HUD_Position_X = 0
  HUD_Position_Y = 130
  HUD_Width = 150
  HUD_Mapnames_Height = 64
  HUD_Namemyst_Height = 130
end

#==============================================================================
# ** Window_MapName
#------------------------------------------------------------------------------
#  This window displays the map name in Scene_Map.
#==============================================================================

class Window_MapName < Window_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  MAPINFOSHASH = load_data('./Data/MapInfos.rxdata')
  INIT_OPACITY = 200
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Initialize our window with the proper values determined in the shared
    # constants class of this HUD.
    super(HUD_Properties::HUD_Position_X, 
      HUD_Properties::HUD_Position_Y, 
      HUD_Properties::HUD_Width, 
      HUD_Properties::HUD_Mapnames_Height)
    # Our drawing surface.
    self.contents = Bitmap.new(width - 32, height - 32)
    
    # Define its initial opacity.
    self.back_opacity = INIT_OPACITY
    
    # Redraw the MapName window.
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Draw the map name.
    self.contents.draw_text(0, 0, width - 32, 32, 
      MAPINFOSHASH[$game_map.map_id].name, 1)
  end
end

#==============================================================================
# ** Window_NameMyst
#------------------------------------------------------------------------------
#  This window displays the actor's name and his myst accessory if applicable.
#==============================================================================

class Window_NameMyst < Window_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  INIT_OPACITY = 128
  NO_MYST_ICON = '-'
  #------------------------------------------------------------------------
  # * MYST_EQUIPID
  #     The ids of the equipment none as myst equipment. Accesories Only.
  #------------------------------------------------------------------------
  MYST_EQUIPID = [25,]
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Initialize our window with the proper values determined in the shared
    # constants class of this HUD.
    super(HUD_Properties::HUD_Position_X, 
      HUD_Properties::HUD_Position_Y + HUD_Properties::HUD_Mapnames_Height, 
      HUD_Properties::HUD_Width, 
      HUD_Properties::HUD_Namemyst_Height)
    # Our drawing surface.
    self.contents = Bitmap.new(width - 32, height - 32)
    
    # Define its initial opacity.
    self.back_opacity = INIT_OPACITY
    
    # Redraw the NameMyst window
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    y = 0
    self.contents.font.size = 20
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      self.contents.draw_text(0, y, 80, 24, actor.name)
      self.contents.draw_text(80, y, 8, 24, ':')
      
      unless MYST_EQUIPID.include?(actor.armor4_id)
        self.contents.draw_text(90, y, 24, 24, NO_MYST_ICON, 1)
      else
        self.contents.blt(90, y, Bitmap.new('Graphics/Icons/' + 
          $data_armors[actor.armor4_id].icon_name), Rect.new(0, 0, 24, 24))
      end
      
      y += 24
    end
  end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :trif_custom_HUD_scene_map_main, :main
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Create the window we will be showing.
    @map_names = Window_MapName.new
    @name_myst = Window_NameMyst.new
    
    # Call the old code.
    trif_custom_HUD_scene_map_main
    
    # Dispose of the windows.
    @map_names.dispose
    @name_myst.dispose
  end
end

Uh any Accessories that you consider myst items. Take their ids and put them into the MYST_EQUIPID array in Window_NameMyst. I only put 25 in there so the Ring of Strength in a new project was considered a Myst item. But I'm sure you've made edits to the database just be aware that in order to see the icon in game you will need to adjust the array to your project.

Good luck with it Triforce! :thumb:

If you have any questions, comments or concerns about the script feel free to voice them.
 

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