Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # XS - Actor Hud
- # Author: Nicke
- # Created: 13/08/2012
- # Edited: 13/01/2013
- # Version: 1.0c
- #==============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ? Materials but above ? Main. Remember to save.
- #==============================================================================
- # Requires: XS - Core Script.
- #==============================================================================
- # An actor hud that will be displayed on the map showing the current HP, MP and
- # TP for the party leader.
- #
- # Note: Make sure the switch is on to enable the actor hud. (Default is id 1)
- #
- # If you wish to remove a actor bar simply remove one of the :hp, :mp, :tp lines
- # in the settings. You may want to remove the icon for that as well.
- #
- # *** Only for RPG Maker VX Ace. ***
- #==============================================================================
- ($imported ||= {})["XAIL-ACTOR-HUD"] = true
- module XAIL
- module ACTOR_HUD
- #--------------------------------------------------------------------------#
- # * Settings
- #--------------------------------------------------------------------------#
- # FONT = [name, size, color, bold, shadow]
- FONT = [["Shark Random Funnyness"], 15, Color.new(-225,255,255), true, true]
- # HUD = [width, height, x, y, z, opacity, contents_opacity, skin]
- HUD = [150, 200, -6, -15, 200, 0, 200, nil]
- # Visbility switch.
- # HUD_SWITCH = switch_id
- HUD_SWITCH = 25
- # actor_bars = [vocab, width, height, value, color1, color2]
- def self.actor_bars(actor)
- actor_bars = {
- :hp => ["MP", 110, 14, actor.hp_rate, Color.new(255,30,30,75), Color.new(255,10,10,225)],
- :mp => ["HP", 110, 14, actor.mp_rate, Color.new(30,30,255,130), Color.new(10,10,255,225)],
- :tp => ["TP", 110, 14, actor.tp_rate, Color.new(30,255,30,130), Color.new(10,255,10,225)]
- } # Don't remove this line!
- end
- # ICONS[id] = icon_id
- # Set the icons. (optional)
- ICONS = []
- ICONS[0] = 117 # HP
- ICONS[1] = 103 # MP
- ICONS[2] = 122 # TP
- end
- end
- # *** Don't edit below unless you know what you are doing. ***
- #==============================================================================#
- # ** Error Handler
- #==============================================================================#
- unless $imported["XAIL-XS-CORE"]
- # // Error handler when XS - Core is not installed.
- msg = "The script %s requires the latest version of XS - Core in order to function properly."
- name = "XS - Actor Hud"
- msgbox(sprintf(msg, name))
- exit
- end
- #==============================================================================#
- # ** Window_Actor_Hud
- #==============================================================================#
- class Window_Actor_Hud < Window_Base
- def initialize
- # // Method to initialize the window.
- super(0, 0, window_width, window_height)
- @actor = $game_party.leader
- @refresh_ok = false
- @last_hp = @actor.hp
- @last_mp = @actor.mp
- @last_tp = @actor.tp
- refresh
- end
- def window_width
- # // Method to return the width.
- return XAIL::ACTOR_HUD::HUD[0]
- end
- def window_height
- # // Method to return the height.
- return XAIL::ACTOR_HUD::HUD[1]
- end
- def refresh
- # // Method to refresh the hud.
- contents.clear
- draw_actor_hud
- end
- def draw_actor_hud
- # // Method to draw the actor hud.
- y = line_height
- # // Draw actor name and level. (size is hard coded)
- draw_font_text(@actor.name, 6, 12, contents.width, 0, XAIL::ACTOR_HUD::FONT[0], 18, XAIL::ACTOR_HUD::FONT[2], XAIL::ACTOR_HUD::FONT[3], XAIL::ACTOR_HUD::FONT[4])
- draw_font_text("#{Vocab::level}: #{@actor.level}", 0, 12, contents.width, 2, XAIL::ACTOR_HUD::FONT[0], 18, XAIL::ACTOR_HUD::FONT[2], XAIL::ACTOR_HUD::FONT[3], XAIL::ACTOR_HUD::FONT[4])
- for i in XAIL::ACTOR_HUD.actor_bars(@actor).values
- # // Draw hp, mp and tp gauges and icons.
- draw_gauge_ex(20, y, i[1], i[2], i[3], i[4], i[5])
- draw_icons(XAIL::ACTOR_HUD::ICONS, :vertical, 0, line_height + 12)
- draw_font_text(i[0], 26, y + 12, i[1], 0, XAIL::ACTOR_HUD::FONT[0], XAIL::ACTOR_HUD::FONT[1], XAIL::ACTOR_HUD::FONT[2], XAIL::ACTOR_HUD::FONT[3], XAIL::ACTOR_HUD::FONT[4])
- y += line_height
- end
- end
- def update
- # // Method to update the actor hud if a value has been changed.
- super
- check_actor_stats
- if @refresh_ok
- @refresh_ok = false
- refresh
- end
- end
- def check_actor_stats
- # // Method to check if a stat has been changed.
- @refresh_ok = true ; @last_hp = @actor.hp if @last_hp != @actor.hp
- @refresh_ok = true ; @last_mp = @actor.mp if @last_mp != @actor.mp
- @refresh_ok = true ; @last_tp = @actor.tp if @last_tp != @actor.tp
- end
- end
- #==============================================================================
- # ** Scene_Map
- #==============================================================================
- class Scene_Map < Scene_Base
- alias xail_actor_hud_start start
- def start(*args, &block)
- # // Method to start the actor hud on the map.
- xail_actor_hud_start(*args, &block)
- create_actor_hud
- check_actor_hud
- end
- def create_actor_hud
- # // Method to create the actor hud.
- @actor_window = Window_Actor_Hud.new
- @actor_window.x = XAIL::ACTOR_HUD::HUD[2]
- @actor_window.y = XAIL::ACTOR_HUD::HUD[3]
- @actor_window.z = XAIL::ACTOR_HUD::HUD[4]
- @actor_window.opacity = XAIL::ACTOR_HUD::HUD[5]
- @actor_window.contents_opacity = XAIL::ACTOR_HUD::HUD[6]
- @actor_window.windowskin = Cache.system(XAIL::ACTOR_HUD::HUD[7]) unless XAIL::ACTOR_HUD::HUD[7].nil?
- end
- alias xail_actor_hud_update update
- def update(*args, &block)
- # // Method to update the actor hud.
- xail_actor_hud_update(*args, &block)
- check_actor_hud
- end
- def check_actor_hud
- # // Method to check actor hud if it is enabled/disabled.
- if $game_switches[XAIL::ACTOR_HUD::HUD_SWITCH]
- create_actor_hud if @actor_window.nil?
- else
- dispose_actor_hud
- end
- end
- def dispose_actor_hud
- # // Method to dipose actor hud.
- @actor_window.dispose unless @actor_window.nil?
- @actor_window = nil
- end
- end # END OF FILE
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment