#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :par_hud # sets the par hud variable
attr_accessor :bar_style # Bar Style
attr_accessor :bar_opacity # The Bars Opacity
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias nathmatt_config initialize
def initialize
nathmatt_config
@par_hud = true
@bar_style = 0
@bar_opacity = 255
end
end
#==============================================================================
# Hud
#------------------------------------------------------------------------------
# This class was modified to support SR display and modify the number of
# skills left to use.
#==============================================================================
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(@hud_width, @hud_height)
# set font
self.bitmap.font.name = 'Arial'
# set font size
self.bitmap.font.size = 16
# set font to bold
self.bitmap.font.bold = true
# set x, y position
self.x, self.y = 4, 4
# 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
@original_width = @hud_width = 275
@original_height = @hud_height = 120
@face_x,@face_y, @exp_x, @exp_y = 4, 4, 4, 100
@name_x, @name_y, @level_x, @level_y = 167, 1, 112, 1
@hp_x, @hp_y, @sp_x, @sp_y = 130, 37, 110, 63
@hot_x, @hot_y, @left_x, @left_y = 580, 150, 610, 150
end
#----------------------------------------------------------------------------
# draw_basic
# Draws the HUD template.
#----------------------------------------------------------------------------
def draw_basic
# fill with grey rectangle
self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height,
Color.new(0, 0, 0, 0))
# set font color
self.bitmap.font.color = system_color
# draw "LV"
self.bitmap.draw_text_full(@level_x, @level_y, 20, 20, 'LV')
# if direct hotkey option is turned off
unless BlizzABS::Config::DIRECT_HOTKEYS
# draw "Skill:"
self.bitmap.draw_text_full(@hot_x, @hot_y+50, 48, 20, 'Skill:')
# draw "Item:"
self.bitmap.draw_text_full(@hot_x, @hot_y, 48, 20, 'Item:')
end
# draw "HP"
self.bitmap.draw_text_full(@hp_x, @hp_y, 32, 20, $data_system.words.hp)
# draw "SP"
self.bitmap.draw_text_full(@sp_x, @sp_y, 32, 20, $data_system.words.sp)
# draw "SP"
self.bitmap.draw_text_full(@exp_x, @exp_y, 32, 20, 'EXP')
end
#----------------------------------------------------------------------------
# draw_empty
# Draws the HP and SP display when actor doesn't exist.
#----------------------------------------------------------------------------
def draw_empty
# draw empty bars
self.bitmap.gradient_bar_hud(@hp_x+32, @hp_y+3, 114, 0, 'hud_green_bar', 1)
# draw empty bars
self.bitmap.gradient_bar_hud(@sp_x+32, @sp_y+3, 114, 0, 'hud_blue_bar', 2)
# set font color
self.bitmap.font.color = disabled_color
# draw empty HP
self.bitmap.draw_text_full(@hp_x+38, @hp_y, 48, 20, '0', 2)
self.bitmap.draw_text_full(@hp_x+86, @hp_y, 12, 20, '/', 1)
self.bitmap.draw_text_full(@hp_x+98, @hp_y, 48, 20, '0')
# draw empty SP
self.bitmap.draw_text_full(@sp_x+38, @sp_y, 48, 20, '0', 2)
self.bitmap.draw_text_full(@sp_x+86, @sp_y, 12, 20, '/', 1)
self.bitmap.draw_text_full(@sp_x+98, @sp_y, 48, 20, '0')
# reset all flag variables
@name = @level = @hp = @sp = @maxhp = @maxsp = @exp = @states = @skill =
@skills_left = @item = @items_left = @gold = nil
end
#----------------------------------------------------------------------------
# draw_name
# Draws the name display.
#----------------------------------------------------------------------------
def draw_name
# set current variable
@name = actor.name
# remove old display
self.bitmap.fill_rect(@name_x, @name_y, 104, 20, Color.new(0, 0, 0, 0))
# set font color
self.bitmap.font.color = Color.new(0, 255, 0)
# draw actor's name
self.bitmap.draw_text_full(@name_x, @name_y, 104, 20, @name)
end
#----------------------------------------------------------------------------
# draw_face
# Draws the face display.
#----------------------------------------------------------------------------
def draw_face
# set current variable
@face = actor.name
# remove old display
self.bitmap.fill_rect(@face_x, @face_y, 100, 100, Color.new(0, 0, 0, 0))
# load bitmap
bitmap = RPG::Cache.picture('Faces/'+@face+'_L')
# draw bitmap
self.bitmap.blt(@face_x, @face_y, bitmap, Rect.new(0, 0, 100, 100))
end
#----------------------------------------------------------------------------
# draw_level
# Draws the level display.
#----------------------------------------------------------------------------
def draw_level
# set current variable
@level = actor.level
# remove old display
self.bitmap.fill_rect(@level_x+20, @level_y, 20, 20, Color.new(0, 0, 0, 0))
# set font color
self.bitmap.font.color = normal_color
# draw actor's level
self.bitmap.draw_text_full(@level_x+20, @level_y, 20, 20, @level.to_s, 2)
end
#----------------------------------------------------------------------------
# draw_hp
# Draws the HP display.
#----------------------------------------------------------------------------
def draw_hp
# set current variables
@hp, @maxhp = actor.hp, actor.maxhp
# remove old display
self.bitmap.fill_rect(@hp_x+22, @hp_y, 114, 14, Color.new(0, 0, 0, 0))
# Calculate The Rate
rate = (actor.maxhp > 0 ? actor.hp.to_f / actor.maxhp : 0)
# Draw Color For The Bar
if rate > 0.6
color1 = Color.new(80 - 150 * (rate-0.6), 80, 50 * (rate-0.6), 192)
color2 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
elsif rate > 0.2 && rate <= 0.6
color1 = Color.new(80, 200 * (rate-0.2), 0, 192)
color2 = Color.new(240, 600 * (rate-0.2), 0, 192)
elsif rate <= 0.2
color1 = Color.new(400 * rate, 0, 0, 192)
color2 = Color.new(240, 0, 0, 192)
end
# background color
color3 = Color.new(0, 80, 0, 192)
# draw gradient bar
self.bitmap.gradient_bar(@hp_x+22,@hp_y-15,114,color1,color2,color3,rate)
# set font color depending on how many HP left
self.bitmap.font.color = @hp == 0 ? knockout_color :
@hp <= @maxhp / 4 ? crisis_color : normal_color
# draw HP
self.bitmap.draw_text_full(@hp_x+28, @hp_y, 48, 20, @hp.to_s, 2)
# set color
self.bitmap.font.color = normal_color
# draw "/"
self.bitmap.draw_text_full(@hp_x+76, @hp_y, 12, 20, '/', 1)
# draw max HP
self.bitmap.draw_text_full(@hp_x+88, @hp_y, 48, 20, @maxhp.to_s)
end
#----------------------------------------------------------------------------
# draw_sp
# Draws the SP display.
#----------------------------------------------------------------------------
def draw_sp
# set current variables
@sp, @maxsp = actor.sp, actor.maxsp
# remove old display
self.bitmap.fill_rect(@sp_x+22, @sp_y, 114, 14, Color.new(0, 0, 0, 0))
# Calculate The Rate
rate = (actor.maxsp > 0 ? actor.sp.to_f / actor.maxsp : 0)
# Draw Color For The Bar
if rate > 0.4
color1 = Color.new(60 - 66 * (rate-0.4), 20, 80, 192)
color2 = Color.new(180 - 200 * (rate-0.4), 60, 240, 192)
elsif rate <= 0.4
color1 = Color.new(20 + 100 * rate, 50 * rate, 26 + 166 * rate, 192)
color2 = Color.new(60 + 300 * rate, 150 * rate, 80 + 400 * rate, 192)
end
# background color
color3 = Color.new(0, 80, 0, 192)
# draw gradient bar
self.bitmap.gradient_bar(@sp_x+22, @sp_y-15, 114, color1, color2, color3, rate)
# set font color depending on how many SP left
self.bitmap.font.color = @sp == 0 ? knockout_color :
@sp <= @maxsp / 4 ? crisis_color : normal_color
# draw SP
self.bitmap.draw_text_full(@sp_x+28, @sp_y, 48, 20, @sp.to_s, 2)
# set font color
self.bitmap.font.color = normal_color
# draw "/"
self.bitmap.draw_text_full(@sp_x+76, @sp_y, 12, 20, '/', 1)
# draw max SP
self.bitmap.draw_text_full(@sp_x+88, @sp_y, 48, 20, @maxsp.to_s)
end
#----------------------------------------------------------------------------
# draw_exp
# Draws the EXP display.
#----------------------------------------------------------------------------
def draw_exp
# set current variables
@now_exp, @next_exp = actor.now_exp, actor.next_exp
# remove old display
self.bitmap.fill_rect(@exp_x+32, @exp_y, 58, 14, Color.new(0, 0, 0, 0))
# Calculate The Rate
rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
# Draw Color For The Bar
if rate < 0.5
color1 = Color.new(20 * rate, 60, 80, 192)
color2 = Color.new(60 * rate, 180, 240, 192)
elsif rate >= 0.5
color1 = Color.new(20 + 120 * (rate-0.5), 60 + 40 * (rate-0.5), 80, 192)
color2 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
end
# background color
color3 = Color.new(0, 80, 0, 192)
# draw gradient bar
self.bitmap.gradient_bar(@exp_x+32, @exp_y-18, 57, color1, color2, color3, rate)
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, @hot_y+74, 24, 24, Color.new(0, 0, 0, 0))
# 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, @hot_y+74, 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+50, 24, 16, Color.new(0, 0, 0, 0))
# 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+50, 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+50, 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 @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, @hot_y+24, 24, 24, Color.new(0, 0, 0, 0))
# 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, @hot_y+24, 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, @left_y, 24, 16, Color.new(0, 0, 0, 0))
# 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, @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, @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 actor
draw_name
draw_face
draw_level
draw_hp
draw_sp
draw_exp
# remove flag
$game_temp.hud_refresh = nil
else
# draw data that needs to ve updated
test_name
test_face
test_level
test_hp
test_sp
test_exp
end
# empty HUD wasn't drawn
@empty_hud_drawn = false
end
end
#----------------------------------------------------------------------------
# test_face
# Tests and draws the name.
#----------------------------------------------------------------------------
def test_face
# draw new face if face has changed
draw_face if actor.name != @face
end
#----------------------------------------------------------------------------
# test_exp
# Tests and draws the name.
#----------------------------------------------------------------------------
def test_exp
# draw new name if name has changed
draw_exp if actor.now_exp != @now_exp|| actor.next_exp != @next_exp
end
#----------------------------------------------------------------------------
# test_name
# Tests and draws the name.
#----------------------------------------------------------------------------
def test_name
# draw new name if name has changed
draw_name if actor.name != @name
end
#----------------------------------------------------------------------------
# test_level
# Tests and draws the level.
#----------------------------------------------------------------------------
def test_level
# draw new level if level has changed
draw_level if actor.level != @level
end
#----------------------------------------------------------------------------
# test_hp
# Tests and draws the HP.
#----------------------------------------------------------------------------
def test_hp
# draw new HP if HP or max HP have changed
draw_hp if actor.hp != @hp || actor.maxhp != @maxhp
end
#----------------------------------------------------------------------------
# test_sp
# Tests and draws the SP.
#----------------------------------------------------------------------------
def test_sp
# draw new SP if SP or max SP have changed
draw_sp if actor.sp != @sp || actor.maxsp != @maxsp
end
#----------------------------------------------------------------------------
# test_hskill
# Tests and draws the hskill.
#----------------------------------------------------------------------------
def test_hskill
# draw new skill icon if assigned skill has changed
draw_hskill if actor.skill != @skill
end
#----------------------------------------------------------------------------
# test_lskill
# Tests and draws the lskill.
#----------------------------------------------------------------------------
def test_lskill
# draw how many skills left to use if this number has changed
draw_lskill if get_skills_left != @skills_left
end
#----------------------------------------------------------------------------
# test_hitem
# Tests and draws the hitem.
#----------------------------------------------------------------------------
def test_hitem
# draw new item icon if assigned item has changed
draw_hitem if actor.item != @item
end
#----------------------------------------------------------------------------
# test_litem
# Tests and draws the litem.
#----------------------------------------------------------------------------
def test_litem
# draw how many items left to use if this number has changed
draw_litem if $game_party.item_number(@item) != @items_left
end
#----------------------------------------------------------------------------
# actor
# Returns the party leader's battler for easier reference.
#----------------------------------------------------------------------------
def actor
return $BlizzABS.battlers[0].battler
end
end
#==============================================================================
# Hud
#------------------------------------------------------------------------------
# This class was modified to support SR display and modify the number of
# skills left to use.
#==============================================================================
class Par_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(@hud_width, @hud_height)
# set font
self.bitmap.font.name = 'Arial'
# set font size
self.bitmap.font.size = 10
# set font to bold
self.bitmap.font.bold = true
# set x, y position
self.x, self.y = 4, 124
# set z coordinate
self.z = 1000
# draw basic HUD
(0...$game_party.actors.size - 1).each{|i| draw_basic(i)}
# 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
@face_y = @exp_y = @name_y = @level_y = @hp_y = @sp_y = []
@face = @now_exp = @next_exp = @name = @level = @hp = @maxhp = []
@sp = @maxsp = []
(0...$game_party.actors.size - 1).each{|i|
y = i*80
@original_width = @hud_width = 150
@original_height = @hud_height = 80+y
@face_x,@face_y[i], @exp_x, @exp_y[i] = 4, 4+y, 4, 50+y
@name_x, @name_y[i], @level_x, @level_y[i] = 85, 1+y, 55, 1+y
@hp_x, @hp_y[i], @sp_x, @sp_y[i] = 70, 20+y, 60, 30+y
@hot_x, @hot_y, @left_x, @left_y = 580, 150, 610, 150}
end
#----------------------------------------------------------------------------
# draw_basic
# Draws the HUD template.
#----------------------------------------------------------------------------
def draw_basic(i)
# fill with grey rectangle
self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height,
Color.new(0, 0, 0, 0))
# set font color
self.bitmap.font.color = system_color
# draw "LV"
self.bitmap.draw_text_full(@level_x, @level_y[i], 20, 20, 'LV')
# draw "HP"
self.bitmap.draw_text_full(@hp_x, @hp_y[i], 32, 20, $data_system.words.hp)
# draw "SP"
self.bitmap.draw_text_full(@sp_x, @sp_y[i], 32, 20, $data_system.words.sp)
# draw "SP"
self.bitmap.draw_text_full(@exp_x, @exp_y[i], 32, 20, 'EXP')
end
#----------------------------------------------------------------------------
# draw_name
# Draws the name display.
#----------------------------------------------------------------------------
def draw_name(i)
# set current variable
@name[i] = actor(i).name
# remove old display
self.bitmap.fill_rect(@name_x, @name_y[i], 20, 20, Color.new(0, 0, 0, 0))
# set font color
self.bitmap.font.color = Color.new(0, 255, 0)
# draw actor's name
self.bitmap.draw_text_full(@name_x, @name_y[i], 20, 20, @name[i])
end
#----------------------------------------------------------------------------
# draw_face
# Draws the face display.
#----------------------------------------------------------------------------
def draw_face(i)
# set current variable
@face[i] = actor(i).name
# remove old display
self.bitmap.fill_rect(@face_x, @face_y[i], 50, 50, Color.new(0, 0, 0, 0))
# load bitmap
bitmap = RPG::Cache.picture('Faces/'+@face+'_S')
# draw bitmap
self.bitmap.blt(@face_x, @face_y[i], bitmap, Rect.new(0, 0, 50, 50))
end
#----------------------------------------------------------------------------
# draw_level
# Draws the level display.
#----------------------------------------------------------------------------
def draw_level(i)
# set current variable
@level[i] = actor(i).level
# remove old display
self.bitmap.fill_rect(@level_x+20, @level_y[i], 5, 20, Color.new(0, 0, 0, 0))
# set font color
self.bitmap.font.color = normal_color
# draw actor's level
self.bitmap.draw_text_full(@level_x+20, @level_y[i], 5, 20, @level[i].to_s, 2)
end
#----------------------------------------------------------------------------
# draw_hp
# Draws the HP display.
#----------------------------------------------------------------------------
def draw_hp(i)
# set current variables
@hp[i], @maxhp[i] = actor(i).hp, actor(i).maxhp
# remove old display
self.bitmap.fill_rect(@hp_x+15, @hp_y[i]+7, 100, 14, Color.new(0, 0, 0, 0))
# Calculate The Rate
rate = (@maxhp[i] > 0 ? @hp[i].to_f / @maxhp[i] : 0)
# Draw Color For The Bar
if rate > 0.6
color1 = Color.new(80 - 150 * (rate-0.6), 80, 50 * (rate-0.6), 192)
color2 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
elsif rate > 0.2 && rate <= 0.6
color1 = Color.new(80, 200 * (rate-0.2), 0, 192)
color2 = Color.new(240, 600 * (rate-0.2), 0, 192)
elsif rate <= 0.2
color1 = Color.new(400 * rate, 0, 0, 192)
color2 = Color.new(240, 0, 0, 192)
end
# background color
color3 = Color.new(0, 80, 0, 192)
# draw gradient bar
self.bitmap.gradient_bar(@hp_x+15,@hp_y[i]-15,57,color1,color2,color3,rate)
# 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_full(@hp_x+22, @hp_y[i], 20, 20, @hp[i].to_s, 2)
# set color
self.bitmap.font.color = normal_color
# draw "/"
self.bitmap.draw_text_full(@hp_x+44, @hp_y[i], 5, 20, '/', 1)
# draw max HP
self.bitmap.draw_text_full(@hp_x+51, @hp_y[i], 20, 20, @maxhp[i].to_s)
end
#----------------------------------------------------------------------------
# draw_sp
# Draws the SP display.
#----------------------------------------------------------------------------
def draw_sp(i)
# set current variables
@sp[i], @maxsp[i] = actor(i).sp, actor(i).maxsp
# remove old display
self.bitmap.fill_rect(@sp_x+15, @sp_y[i]+7, 100, 14, Color.new(0, 0, 0, 0))
# Calculate The Rate
rate = (@maxsp[i] > 0 ? @sp[i].to_f / @maxsp[i] : 0)
# Draw Color For The Bar
if rate > 0.4
color1 = Color.new(60 - 66 * (rate-0.4), 20, 80, 192)
color2 = Color.new(180 - 200 * (rate-0.4), 60, 240, 192)
elsif rate <= 0.4
color1 = Color.new(20 + 100 * rate, 50 * rate, 26 + 166 * rate, 192)
color2 = Color.new(60 + 300 * rate, 150 * rate, 80 + 400 * rate, 192)
end
# background color
color3 = Color.new(0, 80, 0, 192)
# draw gradient bar
self.bitmap.gradient_bar(@sp_x+15, @sp_y[i]-15, 57, color1, color2, color3, rate)
# set font color depending on how many SP left
self.bitmap.font.color = @sp == 0 ? knockout_color :
@sp[i] <= @maxsp[i] / 4 ? crisis_color : normal_color
# draw SP
self.bitmap.draw_text_full(@sp_x+22, @sp_y[i], 20, 20, @sp[i].to_s, 2)
# set font color
self.bitmap.font.color = normal_color
# draw "/"
self.bitmap.draw_text_full(@sp_x+44, @sp_y[i], 5, 20, '/', 1)
# draw max SP
self.bitmap.draw_text_full(@sp_x+51, @sp_y[i], 20, 20, @maxsp[i].to_s)
end
#----------------------------------------------------------------------------
# draw_exp
# Draws the EXP display.
#----------------------------------------------------------------------------
def draw_exp(i)
# set current variables
@now_exp[i], @next_exp[i] = actor(i).now_exp, actor(i).next_exp
# remove old display
self.bitmap.fill_rect(@exp_x+20, @exp_y[i], 27, 14, Color.new(0, 0, 0, 0))
# Calculate The Rate
rate = (@next_exp[i] != 0 ? @now_exp[i].to_f / @next_exp[i] : 1)
# Draw Color For The Bar
if rate < 0.5
color1 = Color.new(20 * rate, 60, 80, 192)
color2 = Color.new(60 * rate, 180, 240, 192)
elsif rate >= 0.5
color1 = Color.new(20 + 120 * (rate-0.5), 60 + 40 * (rate-0.5), 80, 192)
color2 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
end
# background color
color3 = Color.new(0, 80, 0, 192)
# draw gradient bar
self.bitmap.gradient_bar(@exp_x+20, @exp_y[i]-18, 27, color1, color2, color3, rate)
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, @hot_y+74, 24, 24, Color.new(0, 0, 0, 0))
# 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, @hot_y+74, 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+50, 24, 16, Color.new(0, 0, 0, 0))
# 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+50, 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+50, 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 @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, @hot_y+24, 24, 24, Color.new(0, 0, 0, 0))
# 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, @hot_y+24, 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, @left_y, 24, 16, Color.new(0, 0, 0, 0))
# 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, @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, @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 HUD needs refresh
if $game_temp.hud_refresh
# draw all data about actor
(0...$game_party.actors.size - 1).each{|i|
draw_name(i)
draw_face(i)
draw_level(i)
draw_hp(i)
draw_sp(i)
draw_exp(i)}
# remove flag
$game_temp.hud_refresh = nil
else
# draw data that needs to ve updated
(0...$game_party.actors.size - 1).each{|i|
test_name(i)
test_face(i)
test_level(i)
test_hp(i)
test_sp(i)
test_exp(i)}
end
# empty HUD wasn't drawn
@empty_hud_drawn = false
end
#----------------------------------------------------------------------------
# test_face
# Tests and draws the name.
#----------------------------------------------------------------------------
def test_face(i)
# draw new face if face has changed
draw_face(i) if actor(i).name != @face[i]
end
#----------------------------------------------------------------------------
# test_exp
# Tests and draws the name.
#----------------------------------------------------------------------------
def test_exp(i)
# draw new name if name has changed
draw_exp(i) if actor(i).now_exp != @now_exp[i]||
actor(i).next_exp != @next_exp[i]
end
#----------------------------------------------------------------------------
# test_name
# Tests and draws the name.
#----------------------------------------------------------------------------
def test_name(i)
# draw new name if name has changed
draw_name(i) if actor(i).name != @name[i]
end
#----------------------------------------------------------------------------
# test_level
# Tests and draws the level.
#----------------------------------------------------------------------------
def test_level(i)
# draw new level if level has changed
draw_level(i) if actor(i).level != @level[i]
end
#----------------------------------------------------------------------------
# test_hp
# Tests and draws the HP.
#----------------------------------------------------------------------------
def test_hp(i)
# draw new HP if HP or max HP have changed
draw_hp(i) if actor(i).hp != @hp[i] || actor(i).maxhp != @maxhp[i]
end
#----------------------------------------------------------------------------
# test_sp
# Tests and draws the SP.
#----------------------------------------------------------------------------
def test_sp(i)
# draw new SP if SP or max SP have changed
draw_sp(i) if actor(i).sp != @sp[i] || actor(i).maxsp != @maxsp[i]
end
#----------------------------------------------------------------------------
# test_hskill
# Tests and draws the hskill.
#----------------------------------------------------------------------------
def test_hskill
# draw new skill icon if assigned skill has changed
draw_hskill if actor.skill != @skill
end
#----------------------------------------------------------------------------
# test_lskill
# Tests and draws the lskill.
#----------------------------------------------------------------------------
def test_lskill
# draw how many skills left to use if this number has changed
draw_lskill if get_skills_left != @skills_left
end
#----------------------------------------------------------------------------
# test_hitem
# Tests and draws the hitem.
#----------------------------------------------------------------------------
def test_hitem
# draw new item icon if assigned item has changed
draw_hitem if actor.item != @item
end
#----------------------------------------------------------------------------
# test_litem
# Tests and draws the litem.
#----------------------------------------------------------------------------
def test_litem
# draw how many items left to use if this number has changed
draw_litem if $game_party.item_number(@item) != @items_left
end
#----------------------------------------------------------------------------
# actor
# Returns the party leader's battler for easier reference.
#----------------------------------------------------------------------------
def actor(id = 0)
return $BlizzABS.battlers[id+1].battler
end
end
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Bitmap
#------------------------------------------------------------------------------
# Adds gradiant_bar to bitmap.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Bitmap
#----------------------------------------------------------------------------
# gradient_bar
# x - x coordinate
# y - y coordinate
# w - width of the bar to be drawn
# color1 - primary color
# color2 - secondary color
# color3 - back color
# rate - fill rate
# This special method is able to draw one out of 7 styles.
#----------------------------------------------------------------------------
def gradient_bar(x, y, w, color1, color2, color3, rate, flag = true)
# stop if not active or out of range
return unless flag
return if $game_system.bar_style < 0 || $game_system.bar_style > 6
# styles with "vertical" black borders
styles = [1, 3, 4, 5, 6]
# setup of coordinates and offsets depending on style
offs = 5
x += offs
y += 26
if styles.include?($game_system.bar_style)
offs += 2
y -= 1
[5, 6].include?($game_system.bar_style) ? y -= 2 : x += 1
# quantizes the width so it looks better (remove it and see what happens)
w = w / 8 * 8
end
# temporary variable
a = $game_system.bar_opacity
if $game_system.bar_style < 5
# draw black slanted back
(0...(offs+3)).each {|i| fill_rect(x-i, y+i-2, w+3, 1, Color.new(0, 0, 0))}
# draw white slanted back onto black, but let black borders stay
(0...(offs+1)).each {|i| fill_rect(x-i, y+i-1, w+1, 1, Color.new(255, 255, 255))}
if $game_system.bar_style < 2
# iterate through each vertical bar
(0...w+offs).each {|i|
# calculate color
r = color3.red * i / (w+offs)
g = color3.green * i / (w+offs)
b = color3.blue * i / (w+offs)
# special offset calculation
oy = i < offs ? offs-i : 0
off = i < offs ? i : i > w ? w+offs-i : offs
# draw this part of the bar
fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
# if slanted bar is out of critical area
if (w*rate).to_i >= offs
# draw the little triangular part on the left
(0...((w*rate).to_i+offs)).each {|i|
r = color1.red + (color2.red-color1.red)*i / ((w+offs)*rate)
g = color1.green + (color2.green-color1.green)*i / ((w+offs)*rate)
b = color1.blue + (color2.blue-color1.blue)*i / ((w+offs)*rate)
oy = i < offs ? offs-i : 0
off = i < offs ? i : i > w*rate ? (w*rate).to_i+offs-i : offs
fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
else
# draw the little triangular part on the left using special method
(0...(w * rate).to_i).each {|i| (0...offs).each {|j|
r = color1.red + (color2.red-color1.red)*i / (w*rate)
g = color1.green + (color2.green-color1.green)*i / (w*rate)
b = color1.blue + (color2.blue-color1.blue)*i / (w*rate)
set_pixel(x+i-j+1, y+j-1, Color.new(r, g, b, a))}}
end
else
# iterate through all horizontal lines
(0...offs).each {|i|
# calculate colors
r = color3.red * i / offs
g = color3.green * i / offs
b = color3.blue * i / offs
# draw background line
fill_rect(x-i+1, y+i-1, w, 1, Color.new(r, g, b, a))}
if $game_system.bar_style == 4
# iterate through half of all horizontal lines
(0...offs/2+1).each {|i|
# calculate colors
r = color2.red * (i+1) / (offs/2)
g = color2.green * (i+1) / (offs/2)
b = color2.blue * (i+1) / (offs/2)
# draw bar line
fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))
# draw bar line mirrored vertically
fill_rect(x-offs+i+2, y+offs-i-2, w*rate, 1, Color.new(r, g, b, a))}
else
# iterate through all horizontal lines
(0...offs).each {|i|
# calculate colors
r = color1.red + (color2.red-color1.red)*i / offs
g = color1.green + (color2.green-color1.green)*i / offs
b = color1.blue + (color2.blue-color1.blue)*i / offs
# draw bar line
fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))}
end
end
# if style with black vertical slanted intersections
if styles.include?($game_system.bar_style)
# add black bars on 1st and 8th column every 8 pixels
(0...w).each {|i| (0...offs).each {|j|
if styles.include?($game_system.bar_style) && i % 8 < 2
set_pixel(x+i-j+1, y+j-1, Color.new(0, 0, 0, a))
end}}
end
else
# fill white background
fill_rect(x+1, y-3, w+2, 12, Color.new(255, 255, 255, a))
# iterate through each of 6 lines
(1...6).each {|i|
# calculate background color
color = Color.new(color3.red*i/5, color3.green*i/5, color3.blue*i/5, a)
# draw background
fill_rect(x+2, y+i-3, w, 12-i*2, color)
# calculate bar color
color = Color.new(color2.red*i/5, color2.green*i/5, color2.blue*i/5, a)
# draw bar
fill_rect(x+2, y+i-3, w*rate, 12-i*2, color)}
# if style 5 (with vertical borders)
if $game_system.bar_style == 5
# add black bars on 1st and 8th column every 8 pixels
(0...w/8).each {|i|
fill_rect(x+2+i*8, y-2, 1, 10, Color.new(0, 0, 0, a))
fill_rect(x+2+(i+1)*8-1, y-2, 1, 10, Color.new(0, 0, 0, a))}
end
end
end
end
#==============================================================================
# Game_Actor
#==============================================================================
class Game_Actor
#----------------------------------------------------------------------------
# now_exp
# Returns the EXP collected in this level.
#----------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end
#----------------------------------------------------------------------------
# next_exp
# Returns the EXP needed to level up as number.
#----------------------------------------------------------------------------
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
#==============================================================================
# Scene_Map
#------------------------------------------------------------------------------
# This class was enhanced to support HUD control and creation system and
# Blizz-ABS battle handling and level up text display.
#==============================================================================
class Scene_Map
#----------------------------------------------------------------------------
# override main
#----------------------------------------------------------------------------
alias main_blizzabs_later_nathmatt main
def main
# create HUD if HUD is turned on and HUD active
@hud = Hud.new if BlizzABS::Config::HUD_ENABLED && $game_system.hud
@par_hud = Par_Hud.new if $game_system.par_hud &&
$game_party.actors.size > 1
# if HOTKEYS is turned on and assignment display active
if BlizzABS::Config::HOTKEYS && $game_system.hotkeys
# create assignment display
@hotkeys = Hotkey_Assignment.new
end
# if MINIMAP is turned on and minimap active
if BlizzABS::Config::MINIMAP && $game_system.minimap > 0
# create HUD
@minimap = Minimap.new
end
# tests and sets the in_battle flag
test_in_battle
# call original method
main_blizzabs_later
# set in_battle flag
$game_temp.in_battle = false
# delete HUD elements that exist
[@hud, @par_hud, @hotkeys, @minimap].each {|s| s.dispose if s != nil}
end
#----------------------------------------------------------------------------
# hud_update
# This method contains a couple of routine calls to handle with the HUD.
#----------------------------------------------------------------------------
def hud_update
# check activation of HUD parts
check_huds
# update minimap
update_minimap
# update hotkey assignment display
update_hotkeys
# iterate through all the HUD sprites
[@hud, @par_hud, @minimap, @hotkeys].each {|s|
# if sprite exists
if s != nil
# update sprite
s.update
# if player is on the same position as one of the sprites on the screen
if $game_player.screen_x < s.vx + s.vw + 16 &&
$game_player.screen_y < s.vy + s.vh + 48 &&
$game_player.screen_x > s.vx && $game_player.screen_y > s.vy &&
(s != @minimap || $game_system.minimap < 2)
# decrease opacity quickly if critical opacity not reached
s.opacity -= 25 if s.opacity > 80
# if not full opacity
elsif s.opacity <= 255
# increase opacity quickly if critical opacity not reached
s.opacity += 25
end
end}
end
#----------------------------------------------------------------------------
# check_huds
# This method handles enabling and disabling the HUD parts on the map.
#----------------------------------------------------------------------------
def check_huds
# if minimap button is enabled and pressed
if $game_system.minimap_button && Input.trigger?(Input::Minimap)
# trigger minimap active
$game_system.minimap = ($game_system.minimap + 1) % 3
end
# if hotkey display button is enabled and pressed
if $game_system.hotkey_button && Input.trigger?(Input::Hotkey)
# trigger hotkey display active
$game_system.hotkeys = (!$game_system.hotkeys)
end
# if HUD button is enabled and pressed
if $game_system.hud_button && Input.trigger?(Input::Hud)
# trigger it active
$game_system.hud = (!$game_system.hud)
$game_system.par_hud = (!$game_system.par_hud)
end
# if minimap not active and minimap exists
if $game_system.minimap == 0 && @minimap != nil
# delete it
@minimap.dispose
@minimap = nil
# if minimap is turned on and active and doesn't exist
elsif BlizzABS::Config::MINIMAP && $game_system.minimap > 0
# create it
@minimap = Minimap.new if @minimap == nil
end
# if assignment display not active and exists
if !$game_system.hotkeys && @hotkeys != nil
# delete it
@hotkeys.dispose
@hotkeys = nil
# if HOTKEYS is turned on and active and doesn't exist
elsif BlizzABS::Config::HOTKEYS && $game_system.hotkeys
# create it
@hotkeys = Hotkey_Assignment.new if @hotkeys == nil
end
# if HUD not active and HUD exists
if !$game_system.hud && @hud != nil
# delete it
@hud.dispose
@hud = nil
@par_hud.dispose
@par_hud = nil
# if HUD is turned on and HUD active and HUD doesn't exist
elsif BlizzABS::Config::HUD_ENABLED && $game_system.par_hud
# create it
@hud = Hud.new if @hud == nil
@par_hud = Par_Hud.new if @par_hud == nil &&
$game_party.actors.size > 1
end
end
end