じ☆ve冰风 发表于 2026-8-2 13:19:52

Simple Map HUD with Variable Gauge

Map HUD​
Introduction
This script was created to display the HUD on the map.
HUD Contains information on Face, character, name, class, HP, MP, Exp, Map, and you can add variables as gauge.
Terms of Use
Free to use in commercial and non-commercial project.
Credit me for use this script.
Script
Spoiler                Ruby:       
#===============================================================================
# ♦ IneptAttorney Simple Map HUD
#-------------------------------------------------------------------------------
# Author: IneptAttorney
# Date: 8th April 2020
# Engine: RMVX Ace
# Type: Graphics Scripts
#-------------------------------------------------------------------------------
# ♦ Introduction
#   This script was created to display the HUD on the map.
#   HUD Contains information on Face, character, name, class, HP, MP, Exp, Map,
#   and you can add variables as gauge.
#-------------------------------------------------------------------------------
# ♦ Instruction
#   Set the configuration below.
#   Use script calls to show or hide HUD.
#-------------------------------------------------------------------------------
# ♦ Script Call
#   hud <------ To show the HUD. or you can use ------> hud(true)
#   hud(false) <---------- To hide the HUD.
#-------------------------------------------------------------------------------
# ♦ Terms of Use
#   Free to use for non-commercial and commercial projects.
#   Credit me in your project.
#===============================================================================
module INPTATTRNY
module MAP_HUD
    #-------------------------------------------------------------
    # Set this to true if you want to display the actor's face.
    # Set this to false to display the actor's character.
    #-------------------------------------------------------------
    USE_FACE = true
    #-------------------------------------------------------------
    # Set the background for your HUD. leave configuration ""
    # if you don't want to use Background.
    #-------------------------------------------------------------
    BACK_GRAPHIC = ""
    #-------------------------------------------------------------
    # Set the background Opacity.
    #-------------------------------------------------------------
    BACK_OPAC = 255
    #-------------------------------------------------------------
    # Set this to true if you want to use custom geague
    #-------------------------------------------------------------
    USE_VARIABLE = true
    #-------------------------------------------------------------
    # Set the name displayed Set the name to display on the custom gauge.
    #-------------------------------------------------------------
    VAR_NAME = "Variable"
    #-------------------------------------------------------------
    # Set the color for the gauge.
    #-------------------------------------------------------------
    # Format:Color.new(R,   G,   B, Alpha)
    COLOR1 =   Color.new(110, 255,   0, 255)
    COLOR2 =   Color.new(0,   255, 213, 255)
    #-------------------------------------------------------------
    # Set the Variable ID to display on custom gauge.
    #-------------------------------------------------------------
    VARIABLE_ID = 1
    #-------------------------------------------------------------
    # Set the Variable Max to display on sutom gauge.
    #-------------------------------------------------------------
    VARIABLE_MAX = 100
   
end
end
#===============================================================================
# Below there is no configuration area anymore!
# Don't change all the texts below unless you know how they work
#===============================================================================
#---------------------------------------------------------
# * Window IAHUD
#---------------------------------------------------------
class Window_IAHUD < Window_Base

def initialize
    super(0,0,Graphics.width,Graphics.width)
    self.opacity = 0
    @actor = $game_party.leader
    refresh
end

def show
    self.visible = true
    self
end

def hide
    self.visible = false
    self
end

def refresh
    contents.clear
    var = INPTATTRNY::MAP_HUD::VARIABLE_ID
    if INPTATTRNY::MAP_HUD::USE_FACE == true
      draw_actor_face(@actor,0,-32)
    else
      draw_actor_graphic(@actor, 62, line_height+18)
    end
    draw_actor_name(@actor,96+32,0)
    draw_actor_class(@actor,96+32,line_height)
    draw_actor_hp(@actor,220,0)
    draw_actor_mp(@actor,220,line_height)
    draw_iaactor_exp(@actor,124,Graphics.height-50,Graphics.width-156)
    draw_currency_value($game_party.gold,Vocab::currency_unit,366,0,154)
    draw_map_name(0,Graphics.height-50,124)
    draw_variable_geague(var,366,line_height,154) if INPTATTRNY::MAP_HUD::USE_VARIABLE == true
end

#-----------------------------------------------
# * Draw Map Name
#-----------------------------------------------
def draw_map_name(x,y,width)
    unless $game_map.display_name.empty?
      text = $game_map.display_name
      draw_text(x,y,width,line_height,text)
    end
end
#-----------------------------------------------
# * Draw Custom Gauge
#_----------------------------------------------
def draw_variable_geague(var_id,x,y,width)
    ecolor = INPTATTRNY::MAP_HUD::COLOR1
    ecolor2 = INPTATTRNY::MAP_HUD::COLOR2
    varer = $game_variables
    varer_max = INPTATTRNY::MAP_HUD::VARIABLE_MAX
    draw_gauge(x, y, width, varer, ecolor, ecolor2)
    change_color(system_color)
    draw_text(x, y, 100, line_height, INPTATTRNY::MAP_HUD::VAR_NAME)
    draw_current_and_max_values(x, y, width, varer, varer_max,
   system_color, normal_color)
end
#-----------------------------------------------
# * Draw_exp
#-----------------------------------------------
def draw_iaactor_exp(actor, x, y, width = 124)
    nicolor = Color.new(255,238,0,255)
    nicolor2 = Color.new(255,157,0,255)
    next_exp = actor.exp_for_level(@actor.level+1)
    eexp = actor.exp
    draw_gauge(x, y, width, actor.exp, nicolor, nicolor2)
    change_color(system_color)
    draw_text(x, y, 30, line_height, "Exp")
    draw_current_and_max_values(x, y, width, eexp, next_exp,
   mp_color(actor), normal_color)
end

end
#===============================================================================
class Sprite_Back < Sprite_Base
#===============================================================================
def initialize(viewport)
    super(viewport)
    update
end

def dispose
    bitmap.dispose if bitmap
    super
end

def show
    self.visible = true
end

def hide
    self.visible = false
end

def update
    super
    update_bitmap
    update_origin
    update_bright
end

def update_bright
    self.opacity = INPTATTRNY::MAP_HUD::BACK_OPAC
end

def update_bitmap
    if INPTATTRNY::MAP_HUD::BACK_GRAPHIC == ""
      self.bitmap = nil
    else
      self.bitmap = Cache.picture(INPTATTRNY::MAP_HUD::BACK_GRAPHIC)
    end
end

def update_origin
      self.ox = 0
      self.oy = 0
end

end
#===============================================================================
class Scene_Map < Scene_Base
#===============================================================================
alias inpt_hud_allwindow create_all_windows
def create_all_windows
    create_hud_window
    create_back_sprite
    inpt_hud_allwindow
end

def create_back_sprite
    @sprite_back = Sprite_Back.new(@viewport)
end
   
def create_hud_window
    @hud_window = Window_IAHUD.new
    @hud_window.viewport = @viewport
end

def show_hud
    @hud_window.show
    @sprite_back.show
end

def hide_hud
    @hud_window.hide
    @sprite_back.hide
end

end
#===============================================================================
class Game_Interpreter
#===============================================================================
def hud(bool=true)
    if bool == true
      SceneManager.scene.show_hud
    else
      SceneManager.scene.hide_hud
    end
end
end





Indonesian version
Spoiler                Ruby:       
#===============================================================================
# ♦ IneptAttorney Simple Map HUD
#-------------------------------------------------------------------------------
# Author: IneptAttorney
# Date: 8th April 2020
# Engine: RMVX Ace
# Type: Graphics Scripts
#-------------------------------------------------------------------------------
# ♦ Introduction
#   Skrip ini gunanya buat nampilin HUD pada Map.
#   HUD berisi Nama, kelas, wajah, karakter, HP, MP, Exp, nama Map
#   dan kamu bisa bikin variable gauge.
#-------------------------------------------------------------------------------
# ♦ Instruction
#   Atur konfigurasi dibawah
#   Gunain script call buat nampilin dan nyembunyiin HUD
#-------------------------------------------------------------------------------
# ♦ Script Call
#   hud <------ Buat nampilin HUD. Ato bisa juga make ------> hud(true)
#   hud(false) <---------- Buat nyembunyiin HUD
#-------------------------------------------------------------------------------
# ♦ Terms of Use
#   Gratis buat dipake di proyek komersil maupun nonkomersil
#   Credit saya di proyek kamu. \(0=0\)
#===============================================================================
module INPTATTRNY
module MAP_HUD
    #-------------------------------------------------------------
    # Atur ke true kalo kamu mau nampilin wajah aktor di HUD nya
    # Atur ke false kalo kamu mau nampilin karakter aktor di HUD nya
    #-------------------------------------------------------------
    USE_FACE = true
    #-------------------------------------------------------------
    # Atur background buat HUD kamu. kosongin aja kalo gamau pake Background.
    #-------------------------------------------------------------
    BACK_GRAPHIC = ""
    #-------------------------------------------------------------
    # Atur Opasitas background kamu
    #-------------------------------------------------------------
    BACK_OPAC = 255
    #-------------------------------------------------------------
    # Atur ini ke true kalo kamu mau ngegunain Variable gauge.
    #-------------------------------------------------------------
    USE_VARIABLE = true
    #-------------------------------------------------------------
    # Atur nama yang bakal ditampilin di variable gauge.
    #-------------------------------------------------------------
    VAR_NAME = "Variable"
    #-------------------------------------------------------------
    # Atur Warna buat Variable gauge nya
    #-------------------------------------------------------------
    # Formatnya:Color.new(R,   G,   B, Alpha)
    COLOR1 =      Color.new(110, 255,   0, 255)
    COLOR2 =      Color.new(0,   255, 213, 255)
    #-------------------------------------------------------------
    # Atur Variable ID buat dipake sebagai variable gauge.
    #-------------------------------------------------------------
    VARIABLE_ID = 1
    #-------------------------------------------------------------
    # Atur maksimal variable buat dipake sebagai variable gauge.
    #-------------------------------------------------------------
    VARIABLE_MAX = 100
   
end
end
#===============================================================================
# Dibawah sini udah bukan area konfigurasi!
# Jangan ganti teks yang ada dibawah kecuali kalian tau cara kerja nya.
#===============================================================================
#---------------------------------------------------------
# * Window IAHUD
#---------------------------------------------------------
class Window_IAHUD < Window_Base

def initialize
    super(0,0,Graphics.width,Graphics.width)
    self.opacity = 0
    @actor = $game_party.leader
    refresh
end

def show
    self.visible = true
    self
end

def hide
    self.visible = false
    self
end

def refresh
    contents.clear
    var = INPTATTRNY::MAP_HUD::VARIABLE_ID
    if INPTATTRNY::MAP_HUD::USE_FACE == true
      draw_actor_face(@actor,0,-32)
    else
      draw_actor_graphic(@actor, 62, line_height+18)
    end
    draw_actor_name(@actor,96+32,0)
    draw_actor_class(@actor,96+32,line_height)
    draw_actor_hp(@actor,220,0)
    draw_actor_mp(@actor,220,line_height)
    draw_iaactor_exp(@actor,124,Graphics.height-50,Graphics.width-156)
    draw_currency_value($game_party.gold,Vocab::currency_unit,366,0,154)
    draw_map_name(0,Graphics.height-50,124)
    draw_variable_geague(var,366,line_height,154) if INPTATTRNY::MAP_HUD::USE_VARIABLE == true
end

#-----------------------------------------------
# * Draw Map Name
#-----------------------------------------------
def draw_map_name(x,y,width)
    unless $game_map.display_name.empty?
      text = $game_map.display_name
      draw_text(x,y,width,line_height,text)
    end
end
#-----------------------------------------------
# * Draw Custom Gauge
#_----------------------------------------------
def draw_variable_geague(var_id,x,y,width)
    ecolor = INPTATTRNY::MAP_HUD::COLOR1
    ecolor2 = INPTATTRNY::MAP_HUD::COLOR2
    varer = $game_variables
    varer_max = INPTATTRNY::MAP_HUD::VARIABLE_MAX
    draw_gauge(x, y, width, varer, ecolor, ecolor2)
    change_color(system_color)
    draw_text(x, y, 100, line_height, INPTATTRNY::MAP_HUD::VAR_NAME)
    draw_current_and_max_values(x, y, width, varer, varer_max,
   system_color, normal_color)
end
#-----------------------------------------------
# * Draw_exp
#-----------------------------------------------
def draw_iaactor_exp(actor, x, y, width = 124)
    nicolor = Color.new(255,238,0,255)
    nicolor2 = Color.new(255,157,0,255)
    next_exp = actor.exp_for_level(@actor.level+1)
    eexp = actor.exp
    draw_gauge(x, y, width, actor.exp, nicolor, nicolor2)
    change_color(system_color)
    draw_text(x, y, 30, line_height, "Exp")
    draw_current_and_max_values(x, y, width, eexp, next_exp,
   mp_color(actor), normal_color)
end

end
#===============================================================================
class Sprite_Back < Sprite_Base
#===============================================================================
def initialize(viewport)
    super(viewport)
    update
end

def dispose
    bitmap.dispose if bitmap
    super
end

def show
    self.visible = true
end

def hide
    self.visible = false
end

def update
    super
    update_bitmap
    update_origin
    update_bright
end

def update_bright
    self.opacity = INPTATTRNY::MAP_HUD::BACK_OPAC
end

def update_bitmap
    if INPTATTRNY::MAP_HUD::BACK_GRAPHIC == ""
      self.bitmap = nil
    else
      self.bitmap = Cache.picture(INPTATTRNY::MAP_HUD::BACK_GRAPHIC)
    end
end

def update_origin
      self.ox = 0
      self.oy = 0
end

end
#===============================================================================
class Scene_Map < Scene_Base
#===============================================================================
alias inpt_hud_allwindow create_all_windows
def create_all_windows
    create_hud_window
    create_back_sprite
    inpt_hud_allwindow
end

def create_back_sprite
    @sprite_back = Sprite_Back.new(@viewport)
end
   
def create_hud_window
    @hud_window = Window_IAHUD.new
    @hud_window.viewport = @viewport
end

def show_hud
    @hud_window.show
    @sprite_back.show
end

def hide_hud
    @hud_window.hide
    @sprite_back.hide
end

end
#===============================================================================
class Game_Interpreter
#===============================================================================
def hud(bool=true)
    if bool == true
      SceneManager.scene.show_hud
    else
      SceneManager.scene.hide_hud
    end
end
end





Credits

[*]Enterbrain
[*]IneptAttorney



本贴来自国际rpgmaker官方论坛作者:IneptAttoney处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/simple-map-hud-with-variable-gauge.119931/
页: [1]
查看完整版本: Simple Map HUD with Variable Gauge