#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
# Blizz-ABS Party HUD by Winkio
# Version: 1.25
#|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
#==============================================================================
# PARHUD_CONFIG
#------------------------------------------------------------------------------
# This module is the configuration section
#==============================================================================
module PARHUD_CONFIG
# Keeps health bar same color no matter what hp
COLOR_FIX = false
# Centers the hud display
CENTER_DISPLAY = false
# shows facesets. If set to true, must have a max party size of 4 or less.
# If set to false, must have a max party size of 6 or less.
FACESETS = true
# display map name in hud
MAPNAME = true
# background picture for top hud. If you have one, put it in Pictures.
# Set this variable to the file name, for example, "mybg.png"
# It should be 640 pixels wide and 50+TOPSPACE pixels tall.
BGTOP = ""
# space between top of HUD and top of screen. must be between 0 and 14
TOPSPACE = 2
# allow minimap to be fullscreen
MINIMAP_FULLSCREEN = true
end
#==============================================================================
# Game_System
#------------------------------------------------------------------------------
# This class was modified to support the party hud
#==============================================================================
class Game_System
attr_accessor :parhud
alias initialize_parhud_later initialize
def initialize
@parhud = true
initialize_parhud_later
end
end
#==============================================================================
# Scene_Title
#==============================================================================
class Scene_Title
alias main_parhud_later main
def main
$map_infos = load_data('Data/MapInfos.rxdata')
$map_infos.keys.each {|key| $map_infos[key] = $map_infos[key].name}
main_parhud_later
end
end
#==============================================================================
# Game_Map
#==============================================================================
class Game_Map
def name
return $map_infos[@map_id]
end
end
#==============================================================================
# ParHud
#------------------------------------------------------------------------------
# This class creates the top hud that shows the hp/sp of all party members and
# their names.
#==============================================================================
class ParHud < Sprite
#----------------------------------------------------------------------------
# Initialization
# viewport - the viewport for the sprite
#----------------------------------------------------------------------------
def initialize(viewport = nil)
# call superclass method
super
# create positions
create_positions
# create bitmap
self.bitmap = Bitmap.new(640, 50+PARHUD_CONFIG::TOPSPACE)
# set font
self.bitmap.font.name = 'Geometrix'
# set font size
self.bitmap.font.size = 20
# set font to bold
self.bitmap.font.bold = true
# set z coordinate
self.z = 1000
# set party size
@psize = $game_party.actors.size
@poffset = 0
test_offset
@hp, @maxhp = [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]
@sp, @maxsp = [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]
# draw basic HUD
draw_basic
# update
update
end
#----------------------------------------------------------------------------
# create_positions
# Sets drawing positions. This method can be aliased and the positions
# modified to create a different HUD.
#----------------------------------------------------------------------------
def create_positions
@name_x, @name_y, @hp_x, @hp_y, @sp_x, @sp_y = [], [], [], [], [], []
if PARHUD_CONFIG::FACESETS
@face_x, @face_y = [], []
end
if !PARHUD_CONFIG::CENTER_DISPLAY
@maxpsize = BlizzABS::Config::MAX_PARTY
@name_x, @name_y, @hp_x, @hp_y, @sp_x, @sp_y = [], [], [], [], [], []
@face_x, @face_y = [], []
(0...@maxpsize).each {|i|
if PARHUD_CONFIG::FACESETS
xdat = i*640/@maxpsize + 320/@maxpsize-25
@face_x.push(xdat-52)
@face_y.push(PARHUD_CONFIG::TOPSPACE)
else
xdat = i*640/@maxpsize + 320/@maxpsize-50
end
@name_x.push(xdat)
@name_y.push(PARHUD_CONFIG::TOPSPACE)
@hp_x.push(xdat)
@hp_y.push(16+PARHUD_CONFIG::TOPSPACE)
@sp_x.push(xdat)
@sp_y.push(33+PARHUD_CONFIG::TOPSPACE)}
else
if (@psize == nil)
#@psize = 1
@psize = $game_party.actors.size
end
(0...@psize).each {|i|
if PARHUD_CONFIG::FACESETS
xdat = i*640/@psize + 320/@psize-25
@face_x.push(xdat-52)
@face_y.push(PARHUD_CONFIG::TOPSPACE)
else
xdat = i*640/@psize + 320/@psize-50
end
@name_x.push(xdat)
@name_y.push(PARHUD_CONFIG::TOPSPACE)
@hp_x.push(xdat)
@hp_y.push(16+PARHUD_CONFIG::TOPSPACE)
@sp_x.push(xdat)
@sp_y.push(33+PARHUD_CONFIG::TOPSPACE)}
end
end
#----------------------------------------------------------------------------
# draw_basic
# Draws the HUD template.
#----------------------------------------------------------------------------
def draw_basic
self.bitmap.font.size = 16
color = Color.new(255, 255, 255, 0)
if PARHUD_CONFIG::BGTOP != ""
# load bitmap
bitmap = RPG::Cache.picture(PARHUD_CONFIG::BGTOP)
# draw bitmap
self.bitmap.blt(0, 0, bitmap, Rect.new(0, 0, 640, 50+PARHUD_CONFIG::TOPSPACE))
end
self.bitmap.font.color = Color.new(255, 255, 255)
# if color exists
if color.is_a?(Color)
(0...@psize).each {|i|
# draw outlines in color
self.bitmap.fill_rect(@hp_x[i], @hp_y[i], 102, 14, color)
self.bitmap.fill_rect(@sp_x[i], @sp_y[i], 102, 14, color)
# draw actor's names and faces
self.bitmap.draw_text(@name_x[i], @name_y[i], 104, 20, actor(i).name, 1)
# self.bitmap.draw_text_full(@name_x[i], @name_y[i], 104, 20, actor(i).name, 1)
if PARHUD_CONFIG::FACESETS
self.bitmap.fill_rect(@face_x[i], @face_y[i], 50, 50, color)
# load bitmap
bitmap = RPG::Cache.picture("actor"+actor(i).id.to_s+".png")
# draw bitmap
self.bitmap.blt(@face_x[i]+1, @face_y[i]+1, bitmap, Rect.new(0, 0, 48, 48))
end
}
end
self.bitmap.font.size = 14
end
#----------------------------------------------------------------------------
# draw_empty
# Draws the HP and SP display when actor doesn't exist.
#----------------------------------------------------------------------------
def draw_empty
# set font color
self.bitmap.font.color = disabled_color
(0...@psize).each {|i|
# draw empty bars
self.bitmap.gradient_bar_hud(@hp_x[i], @hp_y[i], 100, 0, 'hud_green_bar')
self.bitmap.gradient_bar_hud(@sp_x[i], @sp_y[i], 100, 0, 'hud_blue_bar')
# draw empty HP/SP
self.bitmap.draw_text(@hp_x[i]+48, @hp_y[i]-3, 48, 20, '0', 2)
# self.bitmap.draw_text_full(@hp_x[i]+48, @hp_y[i]-3, 48, 20, '0', 2)
self.bitmap.draw_text(@sp_x[i]+48, @sp_y[i]-3, 48, 20, '0', 2)
# self.bitmap.draw_text_full(@sp_x[i]+48, @sp_y[i]-3, 48, 20, '0', 2)
}
# reset all flag variables
@hp = @sp = @maxhp = @maxsp = nil
end
#----------------------------------------------------------------------------
# draw_hp
# Draws the HP display.
#----------------------------------------------------------------------------
def draw_hp
@hp, @maxhp = [], []
self.bitmap.font.color = normal_color
(0...@psize).each {|i|
# set current variables
@hp.push(actor(i).hp)
@maxhp.push(actor(i).maxhp)
rate = (@maxhp[i] > 0 ? @hp[i].to_f / @maxhp[i] : 0)
self.bitmap.font.name = "Astrolyte"
if PARHUD_CONFIG::COLOR_FIX
# draw gradient bar
self.bitmap.gradient_bar_hud(@hp_x[i], @hp_y[i], 100, rate, 'hud_green_bar', 0)
# draw HP
self.bitmap.draw_text(@hp_x[i]+1, @hp_y[i], 100, 11, @hp[i].to_s, 1)
# self.bitmap.draw_text_full(@hp_x[i]+1, @hp_y[i], 100, 11, @hp[i].to_s, 1)
else
# draw gradient bar
self.bitmap.gradient_bar_hud(@hp_x[i], @hp_y[i], 100, rate, 'hud_green_bar', 1)
# set font color depending on how many HP left
self.bitmap.font.color = @hp[i] == 0 ? knockout_color :
@hp[i] <= @maxhp[i] / 4 ? crisis_color : normal_color
# draw HP
self.bitmap.draw_text(@hp_x[i]-20, @hp_y[i]+2, 100, 11, @hp[i].to_s, 2)
# self.bitmap.draw_text_full(@hp_x[i]-20, @hp_y[i]+2, 100, 11, @hp[i].to_s, 2)
self.bitmap.font.color = normal_color
end
}
end
#----------------------------------------------------------------------------
# draw_sp
# Draws the SP display.
#----------------------------------------------------------------------------
def draw_sp
@sp, @maxsp = [], []
self.bitmap.font.color = normal_color
(0...@psize).each {|i|
# set current variables
@sp.push(actor(i).sp)
@maxsp.push(actor(i).maxsp)
rate = (@maxsp[i] > 0 ? @sp[i].to_f / @maxsp[i] : 0)
# draw gradient bar
self.bitmap.gradient_bar_hud(@sp_x[i], @sp_y[i], 100, rate, 'hud_blue_bar', 0)
# set font color depending on how many HP left
self.bitmap.font.color = @sp[i] == 0 ? knockout_color :
@sp[i] <= @maxsp[i] / 4 ? crisis_color : normal_color
# draw SP
self.bitmap.draw_text(@sp_x[i]-20, @sp_y[i]+2, 100, 11, @sp[i].to_s, 2)
# self.bitmap.draw_text_full(@sp_x[i]-20, @sp_y[i]+2, 100, 11, @sp[i].to_s, 2)
}
end
#----------------------------------------------------------------------------
# update
# Checks if HUD needs refreshing.
#----------------------------------------------------------------------------
def update
# if actor doesn't exist
if actor == nil
# unless already drawn empty HUD
unless @empty_hud_drawn
# draw HUD template
draw_basic
# draw empty HP, SP and EXP bars
draw_empty
# empty HUD was drawn
@empty_hud_drawn = true
end
else
if @psize != $game_party.actors.size
@psize = $game_party.actors.size
self.bitmap.clear
create_positions
test_offset
draw_basic
end
# if HUD needs refresh
if $game_temp.hud_refresh
# draw all data about actors
draw_hp
draw_sp
# remove flag
$game_temp.hud_refresh = nil
else
# draw data that needs to be updated
test_offset
test_hp
test_sp
end
# empty HUD wasn't drawn
@empty_hud_drawn = false
end
end
#----------------------------------------------------------------------------
# test_hp
# Tests and draws the HP.
#----------------------------------------------------------------------------
def test_hp
(0...@psize).each {|i|
# draw new HP if HP or max HP have changed
if actor(i).hp != @hp[i] || actor(i).maxhp != @maxhp[i]
draw_hp
return
end}
end
#----------------------------------------------------------------------------
# test_sp
# Tests and draws the SP.
#----------------------------------------------------------------------------
def test_sp
(0...@psize).each {|i|
# draw new HP if HP or max HP have changed
if actor(i).sp != @sp[i] || actor(i).maxsp != @maxsp[i]
draw_sp
return
end}
end
#----------------------------------------------------------------------------
# test_offset
# Tests and draws the SP.
#----------------------------------------------------------------------------
def test_offset
(0...@psize).each {|i|
if actor(0).name != $game_actors[1].name
@poffset = (@poffset + 1) % @psize
else
return
end}
end
#----------------------------------------------------------------------------
# actor
# Returns the party leader's battler for easier reference.
#----------------------------------------------------------------------------
def actor(id = 0)
return $game_party.actors[(id + @poffset)%@psize]
end
#----------------------------------------------------------------------------
# dispose
# disposes of the sprite.
#----------------------------------------------------------------------------
def dispose
super
end
end
#==============================================================================
# Hud
#------------------------------------------------------------------------------
# This class was modified to support SR display and modify the number of
# skills left to use.
# Displays HUD window and exp/level bar
#==============================================================================
class Hud < Sprite
#----------------------------------------------------------------------------
# Initialization
# viewport - the viewport for the sprite
#----------------------------------------------------------------------------
def initialize(viewport = nil)
# call superclass method
super
# create positions
create_positions
# create bitmap
self.bitmap = Bitmap.new(170, 90)
# set font
self.bitmap.font.name = 'Geometrix'
# set font size
self.bitmap.font.size = 16
# set font to bold
self.bitmap.font.bold = true
# set x and y coordinates
self.x, self.y = @hud_x, @hud_y
# set z coordinate
self.z = 1000
# draw basic HUD
draw_basic
# update
update
end
#----------------------------------------------------------------------------
# create_positions
# Sets drawing positions. This method can be aliased and the positions
# modified to create a different HUD.
#----------------------------------------------------------------------------
def create_positions
@hud_height, @hud_width, @hud_x, @hud_y = 90, 120, 0, 390
@level_x, @level_y = 0, 0
@gold_x, @gold_y, @loc_x, @loc_y = 10, 20, 10, 40
@sbar_x, @sbar_y = 65, 60
if !BlizzABS::Config::DIRECT_HOTKEYS
@hot_x, @hot_y, @left_x, @left_y = 4, 60, 4, 74
end
end
#----------------------------------------------------------------------------
# draw_basic
# Draws the HUD template.
#----------------------------------------------------------------------------
def draw_basic
# fill with grey rectangle
self.bitmap.fill_rect(0, 0, @hud_width, @hud_height,
Color.new(0, 0, 0, 64))
color = Color.new(255, 255, 255, 0)
# if color exists
if color.is_a?(Color)
# draw outlines in color
self.bitmap.fill_rect(@level_x, @level_y, 120, 14, color)
end
if !BlizzABS::Config::DIRECT_HOTKEYS
# draw "Skill:"
self.bitmap.draw_text(@hot_x, @hot_y, 48, 20, 'S')
# self.bitmap.draw_text_full(@hot_x, @hot_y, 48, 20, 'S')
# draw "Item:"
self.bitmap.draw_text(@hot_x+60, @hot_y, 48, 20, 'I')
# self.bitmap.draw_text_full(@hot_x+60, @hot_y, 48, 20, 'I')
end
# set font color
self.bitmap.font.color = system_color
# draw "Gold"
self.bitmap.font.name = "Geometrix"
self.bitmap.draw_text(@gold_x-10, @gold_y + 10, 40, 20, 'G')
# self.bitmap.draw_text_full(@gold_x-10, @gold_y + 10, 40, 20, 'G')
end
#----------------------------------------------------------------------------
# draw_empty
# Draws the HP and SP display when actor doesn't exist.
#----------------------------------------------------------------------------
def draw_empty
self.bitmap.gradient_bar_hud(@level_x+1, @level_y+1, 118, 'hud_white_bar', 1)
# set font color
self.bitmap.font.color = disabled_color
# draw empty HP
self.bitmap.draw_text_full(@level_x, @level_y, 118, 11, '0', 1)
# reset all flag variables
@name = @level = @hp = @sp = @maxhp = @maxsp = @exp = @states = @skill =
@skills_left = @item = @items_left = @gold = nil
end
#----------------------------------------------------------------------------
# draw_exp
# Draws the EXP display.
#----------------------------------------------------------------------------
def draw_exp
# set current variables
@exp, @level = actor.exp, actor.level
# set fill rate
self.bitmap.font.name = "Astrolyte"
self.bitmap.font.bold = true
# self.bitmap.font.size = 28
rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
# draw gradient bar
self.bitmap.gradient_bar_hud(@level_x, @level_y, 118, rate, 'hud_white_bar', 2)
# set font color depending on how many HP left
self.bitmap.font.color = normal_color
# draw EXP
colorR = Color.new(0, 187, 0, 255)
self.bitmap.font.color = colorR
self.bitmap.draw_text(@level_x+30, @level_y-3, 118, 20, actor.next_rest_exp_s, 1)
# self.bitmap.draw_text_full(@level_x+30, @level_y-3, 118, 20, actor.next_rest_exp_s, 1)
self.bitmap.font.color = normal_color
self.bitmap.draw_text(@level_x-20, @level_y+3, 118, 20, 'NEXT: ', 1)
# self.bitmap.draw_text_full(@level_x-20, @level_y+3, 118, 20, 'NEXT: ', 1)
self.bitmap.font.size = 12
self.bitmap.fill_rect(@level_x+68, @level_y+15, 44, 10, Color.new(0, 0, 0, 64))
self.bitmap.draw_text(@level_x+30, @level_y+10, 118, 20, 'LV. ' + @level.to_s, 1)
# self.bitmap.draw_text_full(@level_x+30, @level_y+10, 118, 20, 'LV. ' + @level.to_s, 1)
self.bitmap.font.size = 16
end
#----------------------------------------------------------------------------
# draw_gold
# Draws the gold display.
#----------------------------------------------------------------------------
def draw_gold
# set current variable
@gold = $game_party.gold
# remove old display
self.bitmap.font.name = "Astrolyte"
self.bitmap.fill_rect(@gold_x+10, @gold_y+10, 90, 20, Color.new(0, 0, 0, 64))
# set font color
self.bitmap.font.color = crisis_color
# draw party's gold
self.bitmap.draw_text(@gold_x+10, @gold_y+10, 115, 20, $game_party.gold.to_s, 0)
# self.bitmap.draw_text_full(@gold_x+10, @gold_y+10, 115, 20, $game_party.gold.to_s, 0)
end
#----------------------------------------------------------------------------
# draw_loc
# Draws the map location display.
#----------------------------------------------------------------------------
def draw_loc
# set current variable
@loc = $game_map.name
# remove old display
self.bitmap.fill_rect(@loc_x-10, @loc_y+10, 120, 20, Color.new(0, 0, 0, 64))
# set font color
color2 = Color.new(128, 128, 255, 255)
self.bitmap.font.color = color2
# draw party's location
self.bitmap.font.name = "Geometrix"
self.bitmap.draw_text(@loc_x-10, @loc_y+10, 120, 20, $game_map.name, 0)
# self.bitmap.draw_text_full(@loc_x-10, @loc_y+10, 120, 20, $game_map.name, 0)
end
#----------------------------------------------------------------------------
# draw_hskill
# Draws the hot skill display.
#----------------------------------------------------------------------------
def draw_hskill
# set current variable
@skill = actor.skill
# remove old display
self.bitmap.fill_rect(@hot_x+28, @hot_y+4, 24, 24, Color.new(0, 0, 0, 128))
# if skill hot skill exists
if @skill != 0
# load bitmap
bitmap = RPG::Cache.icon($data_skills[@skill].icon_name)
# draw bitmap
self.bitmap.blt(@hot_x+28, @hot_y+4, bitmap, Rect.new(0, 0, 24, 24))
end
# removes skills left to use display
draw_lskill
end
#----------------------------------------------------------------------------
# draw_lskill
# Draws the skills left to use display.
#----------------------------------------------------------------------------
def draw_lskill
# remove old display
self.bitmap.fill_rect(@left_x, @left_y+4, 24, 16, Color.new(0, 0, 0, 128))
# get the number of skills left
@skills_left = get_skills_left
# if hot skill exists
if @skill != nil && @skill > 0
# if normal SP cost
if @skills_left >= 0
# if not enough sp to use
if @skills_left == 0
# set font color
self.bitmap.font.color = Color.new(255, 0, 0)
# if enough SP for 5 or less skill uses
elsif @skills_left <= 5
# set font color
self.bitmap.font.color = Color.new(255, 255, 0)
else
# set font color
self.bitmap.font.color = normal_color
end
# decrease font color
self.bitmap.font.size -= 2
# draw number how many skills left to use
self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, @skills_left.to_s, 1)
# increase font size
self.bitmap.font.size += 2
# if infinite skills left
elsif @skills_left == -1
# set font color
self.bitmap.font.color = Color.new(0, 255, 0)
# increase font size
self.bitmap.font.size += 4
# draw "∞" skill uses left
self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, '∞', 1)
# decrease font size
self.bitmap.font.size -= 4
end
end
end
#----------------------------------------------------------------------------
# get_skills_left
# Gets the number of skill usages left.
#----------------------------------------------------------------------------
def get_skills_left
# if skill hot skill exists
if @skill != nil && @skill > 0
# if SP cost is zero
if $data_skills[@skill].sp_cost > 0
# get basic SP cost
sp_cost = $data_skills[@skill].sp_cost
# if using SP Cost Mod Status
if $tons_version != nil && $tons_version >= 6.54 &&
$game_system.SP_COST_MOD
# get modified cost
sp_cost = BlizzCFG.get_cost_mod(actor.states, sp_cost)
end
# infinite
return -1 if sp_cost == 0
# calculate skills left to use
return actor.sp / sp_cost
end
# set flag
return -1
end
# set flag
return -2
end
#----------------------------------------------------------------------------
# draw_hitem
# Draws the hot item display.
#----------------------------------------------------------------------------
def draw_hitem
# set current variable
@item = actor.item
# remove old display
self.bitmap.fill_rect(@hot_x+88, @hot_y+4, 24, 24, Color.new(0, 0, 0, 128))
# if hot item exists
if @item != 0
# load bitmap
bitmap = RPG::Cache.icon($data_items[@item].icon_name)
# draw bitmap
self.bitmap.blt(@hot_x+88, @hot_y+4, bitmap, Rect.new(0, 0, 24, 24))
end
# removes items left to use display
draw_litem
end
#----------------------------------------------------------------------------
# draw_litem
# Draws the items left to use display.
#----------------------------------------------------------------------------
def draw_litem
# set current variable
@items_left = $game_party.item_number(@item)
# remove old display
self.bitmap.fill_rect(@left_x+60, @left_y+4, 24, 16, Color.new(0, 0, 0, 128))
# if hot item exists
if @item != nil && @item > 0
# if item exists and cannot be consumed
if $data_items[@item] != nil && !$data_items[@item].consumable
# set font color
self.bitmap.font.color = Color.new(0, 255, 0)
# increase font size
self.bitmap.font.size += 4
# draw "∞" items left
self.bitmap.draw_text_full(@left_x+60, @left_y, 24, 20, '∞', 1)
# decrease font size
self.bitmap.font.size -= 4
else
# if no items left
if @items_left == 0
# set font color
self.bitmap.font.color = Color.new(255, 0, 0)
# if equal or less items left
elsif @items_left <= 10
# set font color
self.bitmap.font.color = Color.new(255, 255, 0)
else
# set font color
self.bitmap.font.color = normal_color
end
# decrease font color
self.bitmap.font.size -= 2
# draw number how many items left to use
self.bitmap.draw_text_full(@left_x+60, @left_y, 24, 20, @items_left.to_s, 1)
# increase font size
self.bitmap.font.size += 2
end
end
end
#----------------------------------------------------------------------------
# update
# Checks if HUD needs refreshing.
#----------------------------------------------------------------------------
def update
# if actor doesn't exist
if actor == nil
# unless already drawn empty HUD
unless @empty_hud_drawn
# draw HUD template
draw_basic
# draw empty HP, SP and EXP bars
draw_empty
# empty HUD was drawn
@empty_hud_drawn = true
end
else
# if HUD needs refresh
if $game_temp.hud_refresh
# draw all data about actors
draw_exp
draw_gold
if PARHUD_CONFIG::MAPNAME
draw_loc
end
unless BlizzABS::Config::DIRECT_HOTKEYS
draw_hskill
draw_lskill
draw_hitem
draw_litem
end
# remove flag
$game_temp.hud_refresh = nil
else
# draw data that needs to be updated
test_exp
test_gold
if PARHUD_CONFIG::MAPNAME
test_loc
end
unless BlizzABS::Config::DIRECT_HOTKEYS
test_hskill
test_lskill
test_hitem
test_litem
end
end
# empty HUD wasn't drawn
@empty_hud_drawn = false
end
end
#----------------------------------------------------------------------------
# test_exp
# Tests and draws the EXP.
#----------------------------------------------------------------------------
def test_exp
# draw new HP if HP or max HP have changed
draw_exp if actor.exp != @exp
end
#----------------------------------------------------------------------------
# test_gold
# Tests and draws the gold.
#----------------------------------------------------------------------------
def test_gold
# draw new er if er has changed
draw_gold if $game_party.gold != @gold
end
#----------------------------------------------------------------------------
# test_loc
# Tests and draws the loc.
#----------------------------------------------------------------------------
def test_loc
# draw new er if er has changed
draw_loc if $game_map.name != @loc
end
#----------------------------------------------------------------------------
# actor
# Returns the party leader's battler for easier reference.
#----------------------------------------------------------------------------
def actor
return $game_player.battler
end
#----------------------------------------------------------------------------
# dispose
# Removes PARHUD from screen and memory.
#----------------------------------------------------------------------------
def dispose
@parhud = nil
super
end
end
#==============================================================================
# Hotkey_Assignment
#------------------------------------------------------------------------------
# This class creates and display currently assigned hotkeys and is more
# effiecient than the Window class.
# Changed to display at bottom of screen with new graphics.
#==============================================================================
class Hotkey_Assignment < Sprite
#----------------------------------------------------------------------------
# Initialization
# viewport - the viewport for the sprite
#----------------------------------------------------------------------------
def initialize(viewport = nil)
# call superclass
super
# create bitmap
self.bitmap = Bitmap.new(320, 32)
# set font to bold
self.bitmap.font.bold = true
# decrease font size
self.bitmap.font.size -= 8
# set font color
self.bitmap.font.color = system_color
# set x and y position
self.x, self.y, self.z = 160, 448, 1100
@page = 1
# skill IDs on hotkeys
@skills = BlizzABS::Cache::EmptyKeys
# item IDs on hotkeys
@items = BlizzABS::Cache::EmptyKeys
# update display
update
end
#----------------------------------------------------------------------------
# draw
# Draws the hotkey display.
#----------------------------------------------------------------------------
def draw(index = nil)
# iterate through all hotkeys
(index == nil ? BlizzABS::Cache::HotkeyRange : [index]).each {|i|
# if hotkey is skill hotkey
if $game_player.skill_hotkeys[i%10] != 0
# temporary object
object = $data_skills[$game_player.skill_hotkeys[i%10]]
# if hotkey is item hotkey
elsif $game_player.item_hotkeys[i%10] != 0
# temporary object
object = $data_items[$game_player.item_hotkeys[i%10]]
end
# if any change applied (10 is used for 0)
if @items[i%10] != $game_player.item_hotkeys[i%10] ||
@skills[i%10] != $game_player.skill_hotkeys[i%10]
# remove this icon
self.bitmap.fill_rect(32*(i-1), 0, 32, 32, Color.new(0, 0, 0, 0))
# fill icon bachground
self.bitmap.fill_rect(32*(i-1)+4, 4, 24, 24, Color.new(0, 0, 0, 128))
# if object exists
if object != nil
# load bitmap
bitmap = RPG::Cache.icon(object.icon_name)
# draw bitmap
self.bitmap.blt(32*(i-1)+4, 4, bitmap, Rect.new(0, 0, 24, 24))
end
# draw hotkey number
self.bitmap.draw_text(32*(i-1), 10, 30, 32, (i%10).to_s, 2)
# self.bitmap.draw_text_full(32*(i-1), 10, 30, 32, (i%10).to_s, 2)
end}
# set new items
@items = $game_player.item_hotkeys.clone
# set new skills
@skills = $game_player.skill_hotkeys.clone
end
end
#==============================================================================
# Minimap
#------------------------------------------------------------------------------
# This class creates and handels the minimap/fullscreen map display and is
# more efficient than the Window class.
# Changed to 6x6 tiles with rounded edges
#==============================================================================
class Minimap < Sprite
# setting all accessible variables
attr_reader :map_id
#----------------------------------------------------------------------------
# Initialization
#----------------------------------------------------------------------------
def initialize
# call superclass method
super(Viewport.new(520, 390, 120, 90))
# get autotile image from Blizz-ABS Cache
@autotile = minimap_autotile
# creates the passable floor map
create_passable_floor
# set x and y position
self.x, self.y = 0, 0
# set z position
viewport.z = 5000
# store events
@events, @names = check_events
# create sprites for events
create_sevents
# set all sprites visible
self.visible = true
end
#--------------------------------------------------------------------------
# minimap_autotile
# Creates the minimap autotile for passability.
#--------------------------------------------------------------------------
def minimap_autotile
b = Bitmap.new(18, 24)
c1 = Color.new(191, 191, 191)
c2 = Color.new(255, 255, 255)
b.fill_rect(0, 0, 6, 6, c1)
b.fill_rect(12, 0, 6, 6, c1)
#bottom 3x3 square
b.fill_rect(2, 8, 14, 14, c1)
b.fill_rect(1, 10, 1, 10, c1)
b.fill_rect(4, 7, 10, 1, c1)
b.fill_rect(16, 10, 1, 10, c1)
b.fill_rect(4, 22, 10, 1, c1)
#highlight pixels
b.fill_rect(4, 6, 10, 1, c2)
b.fill_rect(14, 7, 2, 1, c2)
b.fill_rect(16, 8, 1, 2, c2)
b.fill_rect(17, 10, 1, 10, c2)
b.fill_rect(16, 20, 1, 2, c2)
b.fill_rect(14, 22, 2, 1, c2)
b.fill_rect(4, 23, 10, 1, c2)
b.fill_rect(2, 22, 2, 1, c2)
b.fill_rect(1, 20, 1, 2, c2)
b.fill_rect(0, 10, 1, 10, c2)
b.fill_rect(1, 8, 1, 2, c2)
b.fill_rect(2, 7, 2, 1, c2)
return b
end
#----------------------------------------------------------------------------
# create_passable_floor
# Creates the passable floor map on the bitmap.
#----------------------------------------------------------------------------
def create_passable_floor
# delete bitmap if bitmap exists
self.bitmap.dispose if self.bitmap != nil
# store new map ID
@map_id = $game_map.map_id
# temporary width and height
w, h = $game_map.width, $game_map.height
# create bitmap
self.bitmap = Bitmap.new(6*w, 6*h)
# fill rectangle
self.bitmap.fill_rect(0, 0, 6*w, 6*h, Color.new(0, 0, 0, 128))
# get passability data
v_map = $game_map.virtual_passability
# iterate through all tiles
(0...v_map.xsize).each {|x| (0...v_map.ysize).each {|y|
# depending on passable direction, draw the path using the autotile
case v_map[x, y]
when 0x01 # D
self.bitmap.blt(x*6, y*6+3, @autotile, Rect.new(0, 0, 6, 3), 128)
when 0x02 # L
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(3, 0, 3, 6), 128)
when 0x03 # LD
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(12, 6, 6, 6), 128)
when 0x04 # R
self.bitmap.blt(x*6+3, y*6, @autotile, Rect.new(0, 0, 3, 6), 128)
when 0x05 # R D
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(0, 6, 6, 6), 128)
when 0x06 # RL
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(6, 6, 6, 3), 128)
self.bitmap.blt(x*6, y*6+3, @autotile, Rect.new(6, 21, 6, 3), 128)
when 0x07 # RLD
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(6, 6, 6, 6), 128)
when 0x08 # U
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(0, 3, 6, 3), 128)
when 0x09 # U D
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(0, 12, 3, 6), 128)
self.bitmap.blt(x*6+3, y*6, @autotile, Rect.new(15, 12, 3, 6), 128)
when 0x0A # U L
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(12, 18, 6, 6), 128)
when 0x0B # U LD
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(12, 12, 6, 6), 128)
when 0x0C # UR
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(0, 18, 6, 6), 128)
when 0x0D # UR D
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(0, 12, 6, 6), 128)
when 0x0E # URL
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(6, 18, 6, 6), 128)
when 0x0F # URLD
self.bitmap.blt(x*6, y*6, @autotile, Rect.new(6, 12, 6, 6), 128)
end}}
end
#----------------------------------------------------------------------------
# update
# Updates the minimap and sprite movement on the minimap.
#----------------------------------------------------------------------------
def update(override = false)
# creates the passable floor map if new map entered
create_passable_floor if @map_id != $game_map.map_id
# get events
ev = check_events
# if events or names changed
if [@events, @names] != ev
# store new events and names
@events, @names = ev
# delete sprites of events
destroy_sevents
# create sprites of events
create_sevents
end
# if minimap not in fullscreen mode
if $game_system.minimap < 2
# set offset display
self.ox, self.oy = $game_map.display_x * 6 / 128, $game_map.display_y * 6 / 128
# if not pressed the turn button to scroll map around
elsif !($game_system.turn_button && Input.press?(Input::Turn)) || override
# if map can be scrolled horizontally
if self.bitmap.width > 640
# coordinate
border = $game_player.real_x * 6 / 128 - 320
# get right border
border_x = self.bitmap.width - 640
# set offset
if border < 0
self.ox = 0
elsif border > border_x
self.ox = border_x
else
self.ox = border
end
else
# center map display horizontally
self.ox = self.bitmap.width/2 - 320
end
# if map can be scrolled vertically
if self.bitmap.height > 480
# coordinate
border = $game_player.real_y * 6 / 128 - 240
# get lower border
border_y = self.bitmap.height - 480
# set offset
if border < 0
self.oy = 0
elsif border > border_y
self.oy = border_y
else
self.oy = border
end
else
# center map display vertically
self.oy = self.bitmap.height/2 - 240
end
end
# iterate through all sprites
@sevents.each_index {|i|
# if minimap is not in fullscreen mode and within the range of ABSEAL
if $game_system.minimap == 2 || @events[i].update?
# set new coordinates
@sevents[i].x = self.x + @events[i].real_x * 6 / 128
@sevents[i].y = self.y + @events[i].real_y * 6 / 128
# set offsets
@sevents[i].ox, @sevents[i].oy = self.ox, self.oy
# if event has a spriteset
if @names[i] != '' && !@events[i].dropped &&
(@events[i].is_a?(Map_Actor) ||
!@events[i].name.clone.gsub!('\box') {''})
# depending on the facing direction of the event
@sevents[i].src_rect.set((@events[i].direction-2)*7, 0, 14, 14)
# change offsets
@sevents[i].ox += 3
@sevents[i].oy += 3
end
end}
end
#----------------------------------------------------------------------------
# create_sevents
# Creates for each event on the map a sprite on the minimap.
#----------------------------------------------------------------------------
def create_sevents
# set empty array
@sevents = []
# ierate through all events on the minimap
@events.each_index {|i|
# create sprite
sprite = Sprite.new(viewport)
# temporary variable
rect = Rect.new(0, 0, 56, 14)
# if event is player
if @events[i] == $game_player
# if player has spriteset
if @names[i] != ''
# create bitmap
sprite.bitmap = Bitmap.new(56, 14)
# get green arrow
sprite.bitmap.blt(0, 0, $BlizzABS.cache.image('green_arrow'), rect, 128)
end
# highest sprite
sprite.z = 100
# if event is actor
elsif @events[i].is_a?(Map_Actor)
# if actor has spriteset
if @names[i] != ''
# create bitmap
sprite.bitmap = Bitmap.new(56, 14)
# get blue arrow
sprite.bitmap.blt(0, 0, $BlizzABS.cache.image('blue_arrow'), rect, 128)
end
# 2nd highest sprite
sprite.z = 80
# if event is enemy
elsif @events[i].class == Map_Enemy
# if event without spriteset or "boxdraw" enforcing
if @names[i] == '' || @events[i].name.clone.gsub!('\box') {''}
# create bitmap
sprite.bitmap = Bitmap.new(6, 6)
# fill rectangle with black color
sprite.bitmap.fill_rect(0, 0, 6, 6, Color.new(0, 0, 0, 128))
# fill rectangle with red color
sprite.bitmap.fill_rect(1, 1, 4, 4, Color.new(255, 0, 0, 128))
else
# create bitmap
sprite.bitmap = Bitmap.new(56, 14)
# get red arrow
sprite.bitmap.blt(0, 0, $BlizzABS.cache.image('red_arrow'), rect, 128)
end
# 5th highest sprite
sprite.z = 50
# if event is dropped item
elsif @events[i].dropped
# create bitmap
sprite.bitmap = Bitmap.new(8, 8)
# fill rectangle with black color
sprite.bitmap.fill_rect(0, 0, 8, 8, Color.new(0, 0, 0, 128))
# fill rectangle with cyan color
sprite.bitmap.fill_rect(1, 1, 6, 6, Color.new(0, 255, 255, 128))
# 3rd highest sprite
sprite.z = 70
# if event is normal event
elsif @events[i].class == Game_Event
# if event has spc command
if @events[i].name.clone.gsub!('\spc') {''}
# temporary variables, 4th highest sprite
color, arrow, sprite.z = Color.new(255, 255, 0, 128), 'yellow_arrow', 60
# if event code exists and te
elsif @events[i].teleport
# temporary variables, 6th highest sprite
color, arrow, sprite.z = Color.new(128, 0, 255, 128), 'violet_arrow', 40
end
# if event without spriteset or "boxdraw" enforcing
if @names[i] == '' || @events[i].name.clone.gsub!('\box') {''}
# create bitmap
sprite.bitmap = Bitmap.new(6, 6)
# fill rectangle with black color
sprite.bitmap.fill_rect(0, 0, 6, 6, Color.new(0, 0, 0, 128))
# fill rectangle with yellow color
sprite.bitmap.fill_rect(1, 1, 4, 4, color)
else
# create bitmap
sprite.bitmap = Bitmap.new(56, 14)
# get yellow or violet arrow
sprite.bitmap.blt(0, 0, $BlizzABS.cache.image(arrow), rect, 128)
end
# if event without spriteset or "boxdraw" enforcing
elsif @names[i] == '' || @events[i].name.clone.gsub!('\box') {''}
# create bitmap
sprite.bitmap = Bitmap.new(6, 6)
# fill rectangle with black color
sprite.bitmap.fill_rect(0, 0, 6, 6, Color.new(0, 0, 0, 128))
# fill rectangle with default white color
sprite.bitmap.fill_rect(1, 1, 4, 4, Color.new(255, 255, 255, 128))
else
# create bitmap
sprite.bitmap = Bitmap.new(56, 14)
# get white arrow
sprite.bitmap.blt(0, 0, $BlizzABS.cache.image('white_arrow'), Rect.new(0, 0, 56, 14), 128)
end
# create a little dummy bitmap in case no bitmap was created before
sprite.bitmap = Bitmap.new(1, 1) if sprite.bitmap == nil
# get sprite out of map screen so ABSEAL can work correctly
sprite.ox = sprite.oy = 64
# if event has a spriteset
if sprite.bitmap.width != 6
# depending on the facing direction of the event
sprite.src_rect.set((@events[i].direction-2)*7, 0, 14, 14)
end
# add sprite to array
@sevents.push(sprite)}
end
end
#==============================