CODE
#------------------------------------------------------------------------------
# * Munkis' Actor HUD V 1.3 -- Animated States Version
# * Made by munkis; assisted by Woogie
# ╔══════════╗
# ║ FEATURES ║
# ╚══════════╝
# * Displays character's face, name, and states. Use Input::X to toggle the
# appearance of the HUD, and cycle through party members with Input::Z Use
# Input::Y to do a one-time update of the HUD if
# $game_system.always_update == false
# * V 1.0: Initial release
# * V 1.1: Improved lag reduction (not the way BigEd781 meant, but this'll work
# until I can wrap my brain around it). The HUD now automatically
# refreshes by default; however the current methodology of lag
# reduction this script uses means that this cannot be turned off.
# Input::Y is now used to cycle through actors, and Input::Z is no
# longer used. Aliased command_311, command_312, and command_313 of
# Game_Interpreter (Change HP, Change MP, Change State respectively)
# to account for the other changes made. Also fixed a minor n00b
# error where the script would cycle through actors even though there
# was only one in the party. Added options for custom HUD skins (you
# can either use a custom pic or an internally generated basic skin).
# Options for this are handled within a seperate config array. The
# pic skin can be up to screen size, but let's face it; having a
# 544X416 pic for the HUD skin would be pretty stupid;)
# * V 1.2: With IceDragon's assistance, the icons now animate properly,
# without the need for ziifee's script. Also removed some code that
# was rendered redundant from this change.
# * V 1.3: Added the option to keep the HUD on-screen (can't be hidden by
# Input::X) However, the the HUD can still be toggled manually with
# $game_system.show_hud = true/false. Useful if you have YEM Keyboard
# Input in your project and need to free up the keys.
#------------------------------------------------------------------------------
module MNK_Actor_HUD
#CONFIG_PROPERTIES = [window opacity, appearance SE, disappearance SE,
#default visibility, actor cycle SE]
#The fourth setting is overridden if $game_system.show_hud == false
CONFIG_PROPERTIES = [0,"Up","Down",false,"Book"]
#CUSTOM_SKIN_PROPERTIES = [use custom skin, use pic for skin, use generated
#skin, pic for skin, generated skin color 1, generated skin color 2]
#Color.new(Red,Green,Blue,Alpha(opacity))
CUSTOM_SKIN_PROPERTIES = [false,false,false,"",Color.new(0,0,0,128),Color.new(255,0,0,160)]
end
$imported = {} if $imported == nil
$imported["Munkis_HUD"] = true
class Bitmap
def draw_icon(x, y, icon_index, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
self.blt(x, y, bitmap, rect, enabled ? 255 : 128)
end
end
class Game_System
attr_accessor :show_hud
attr_accessor :keep_static
alias munkis_hud_initialize initialize
def initialize
@show_hud = true
@keep_static = false
munkis_hud_initialize
end
end
class Hud_Custom_Skin < Window_Base
def initialize
super(-16, -16, 576, 448)
self.opacity = 0
self.visible = false
if MNK_Actor_HUD::CUSTOM_SKIN_PROPERTIES[1] == true and MNK_Actor_HUD::CUSTOM_SKIN_PROPERTIES[0] == true
self.contents.clear
bitmap = Cache.picture(MNK_Actor_HUD::CUSTOM_SKIN_PROPERTIES[3])
rect = Rect.new(0, 0, 0, 0)
rect.x = -16
rect.y = -16
rect.width = 560
rect.height = 432
self.contents.blt(x, y, bitmap, rect)
bitmap.dispose
end
if MNK_Actor_HUD::CUSTOM_SKIN_PROPERTIES[2] == true and MNK_Actor_HUD::CUSTOM_SKIN_PROPERTIES[0] == true
rect = Rect.new(0, 0, 0, 0)
rect.x = 0
rect.y = 0
rect.width = 128
rect.height = 128
contents.fill_rect(rect, MNK_Actor_HUD::CUSTOM_SKIN_PROPERTIES[4])
lsize = 2
lcolor = MNK_Actor_HUD::CUSTOM_SKIN_PROPERTIES[5]
contents.fill_rect(rect.x, rect.y, lsize, rect.height, lcolor)
contents.fill_rect(rect.x, rect.y, rect.width, lsize, lcolor)
contents.fill_rect(rect.x + rect.width - lsize, rect.y, lsize, rect.height, lcolor)
contents.fill_rect(rect.x, rect.y + rect.height - lsize, rect.width, lsize, lcolor)
end
end
end
class Hud_Main < Window_Base
def initialize
super(0, 352, 128, 128)
if $game_system.show_hud == true
self.visible = MNK_Actor_HUD::CONFIG_PROPERTIES[3]
else
self.visible = false
end
if MNK_Actor_HUD::CUSTOM_SKIN_PROPERTIES[0] == true
self.opacity = 0
else
self.opacity = MNK_Actor_HUD::CONFIG_PROPERTIES[0]
end
@selected_actor_index = 0
@next_state = 0
@@stored_actor = $game_party.members[1]
end
def refresh
self.contents.clear
@party_size = $game_party.members.size
for actor in $game_party.members
next if actor.index != @selected_actor_index
draw_state_icons(actor, x + 24, y + 72)
draw_actor_information(actor, x, y)
@@stored_actor = actor.clone
end
end
def change_displayed_actor
Audio.se_play("audio/se/"+MNK_Actor_HUD::CONFIG_PROPERTIES[4],100,100)
@selected_actor_index += 1
@selected_actor_index = 0 if @selected_actor_index >= @party_size
end
def draw_actor_information(actor, x, y)
draw_actor_face(actor, x, 0)
draw_actor_name(actor, x, 0)
draw_actor_hp(actor, x, 16, 96)
draw_actor_mp(actor, x, 32, 96)
end
def draw_state_icons(actor, x, y)
dispose_states_sprite
@sprite_state = []
@state_change_wait = 0
return if actor == nil
for i in 0..actor.states.size
next if actor.states[i] == nil
@sprite_state[i] = Sprite.new
@sprite_state[i].bitmap = Bitmap.new(32, 32)
icon = actor.states[i].icon_index
@sprite_state[i].bitmap.draw_icon(0, 0, icon)
@sprite_state[i].x = x
@sprite_state[i].y = y
@sprite_state[i].z = 4000
@sprite_state[i].visible = false
end
if @sprite_state[0] != nil
@sprite_state[0].visible = true
end
end
def something_changed?
return true if @@stored_actor == nil
return true if @@stored_actor.hp != $game_actors[@@stored_actor.id].hp
return true if @@stored_actor.mp != $game_actors[@@stored_actor.id].mp
return true if @@stored_actor.states != $game_actors[@@stored_actor.id].states
return false
end
def update
refresh if something_changed?
update_state_icons
end
def update_state_icons
return if @sprite_state == nil
if @state_change_wait == 60 and @sprite_state[@next_state] != nil
@sprite_state[@next_state].visible = false
@next_state = (@next_state + 1) % @sprite_state.size
@sprite_state[@next_state].visible = true
@state_change_wait = 0
end
@state_change_wait += 1
end
def dispose
super
dispose_states_sprite
end
def dispose_states_sprite
return if @sprite_state == nil
for spr in @sprite_state
next if spr == nil
spr.dispose
spr = nil
end
@sprite_state = []
end
end
class Scene_Map < Scene_Base
alias munkis_hud_update update
alias munkis_hud_terminate terminate
alias munkis_hud_main main
def main
@selected_actor_index = 0
@hudskin = Hud_Custom_Skin.new
@hudmain = Hud_Main.new
munkis_hud_main
end
def update
if $game_system.show_hud == false
@hudmain.visible = false
@hudskin.visible = false
end
if $game_system.keep_static == true
@hudmain.visible = $game_system.show_hud
@hudskin.visible = $game_system.show_hud
end
if Input.trigger?(Input::X) and @hudmain.visible == true and @hudskin.visible == true and $game_system.keep_static == false and $game_system.show_hud == true
Audio.se_play("audio/se/"+MNK_Actor_HUD::CONFIG_PROPERTIES[2],100,100)
@hudmain.visible = false
@hudmain.dispose_states_sprite
@hudskin.visible = false
elsif Input.trigger?(Input::X) and @hudmain.visible == false and @hudskin.visible == false and $game_system.keep_static == false and $game_system.show_hud == true
Audio.se_play("audio/se/"+MNK_Actor_HUD::CONFIG_PROPERTIES[1],100,100)
@hudmain.visible = true
@hudskin.visible = true
@hudmain.refresh
elsif Input.trigger?(Input::Y) and @hudmain.visible == true and $game_party.members.size >= 2
@hudmain.change_displayed_actor
end
munkis_hud_update
@hudmain.update if @hudmain.visible
end
def terminate
munkis_hud_terminate
@hudmain.dispose
@hudskin.dispose
return
end
end