WolfwoodSama
Member
Firstly, the scripts:
Enemy HP Bars
Trickster's Animated Gradient Bars
How would I go about using Trickster's animated bars to show the enemies' HP?
Enemy HP Bars
Code:
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw Slant Bar(by SephirothSpawn)
#--------------------------------------------------------------------------
def draw_slant_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
# Draw Border
for i in 0..height
self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
end
# Draw Background
for i in 1..(height - 1)
r = 100 * (height - i) / height + 0 * i / height
g = 100 * (height - i) / height + 0 * i / height
b = 100 * (height - i) / height + 0 * i / height
a = 255 * (height - i) / height + 255 * i / height
self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
end
# Draws Bar
for i in 1..( (min / max.to_f) * width - 1)
for j in 1..(height - 1)
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
end
class Window_EnemyHP < Window_Base
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
def refresh
self.contents.clear
for i in 0...$game_troop.enemies.size
@enemy = $game_troop.enemies[i]
@percent = (@enemy.hp * 100) / @enemy.maxhp
unless @enemy.hp == 0
draw_slant_bar(@enemy.screen_x - 55, @enemy.screen_y - 10, @enemy.hp, @enemy.maxhp, width = 75, height = 6, bar_color = Color.new(0, 100, 0, 255), end_color = Color.new(0, 150, 0, 255))
#self.contents.draw_text(@enemy.screen_x - 39, @enemy.screen_y - 22, 100, 32, "#{@percent}" + "%")
end
end
end
end
class Scene_Battle
alias raz_update update
alias raz_update_phase5 update_phase5
alias raz_update_phase4_step1 update_phase4_step1
alias raz_update_phase4_step5 update_phase4_step5
alias raz_enemy_hp_main main
def main
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
@enemy_window = Window_EnemyHP.new
@enemy_window.z = 95
raz_enemy_hp_main
@enemy_window.dispose
end
def update
@enemy_window.update
raz_update
end
def update_phase5
# If wait count is larger than 0
if @phase5_wait_count > 0
# Decrease wait count
@phase5_wait_count -= 1
# If wait count reaches 0
if @phase5_wait_count == 0
@enemy_window.visible = false
# Show result window
@result_window.visible = true
# Clear main phase flag
$game_temp.battle_main_phase = false
# Refresh status window
@status_window.refresh
@enemy_window.refresh
end
return
end
raz_update_phase5
end
def update_phase4_step1
raz_update_phase4_step1
@enemy_window.refresh
end
def update_phase4_step5
# Hide help window
@help_window.visible = false
# Refresh status window
@status_window.refresh
@enemy_window.refresh
raz_update_phase4_step5
end
end
Code:
=begin
#==============================================================================
# â—â— Animated Gradient Bars
#------------------------------------------------------------------------------
# Trickster (tricksterguy@hotmail.com)
# Version 4.01
# Date 4/18/07
# Goto rmxp.org for updates/support/bug reports
#------------------------------------------------------------------------------
# This script allows you to use Gradient Bars Anywhere. They are also animated
# and they smoothly decrease or increase to their value. This script comes with
# Hp/Sp/Exp bars for non scripters and a template for creating a gradient sprite
# for scripters. The Hp/Sp/Exp bars are configurable.
#==============================================================================
=end
#--------------------------------------------------------------------------
# â— Begin SDK Log
#--------------------------------------------------------------------------
SDK.log('Animated Gradient Bars', 'Trickster', 4.01, '5/12/07')
#--------------------------------------------------------------------------
# â— Begin SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2.0, [1, 2, 3])
#--------------------------------------------------------------------------
# â— Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Animated Gradient Bars')
module Gradient_Bars
#--------------------------------------------------------------------------
# * Use Viewport
# - Use A Viewport for the Sprite (For Side View Battle Systems
#--------------------------------------------------------------------------
Use_Viewport = true
#--------------------------------------------------------------------------
# * Bar Update Speed
# - Number of Frames at which the bar updates
#--------------------------------------------------------------------------
Update_Speed = 1
#--------------------------------------------------------------------------
# * Bar Update Rate
# - How fast the bar gets to destination (set to nil to disable0
#--------------------------------------------------------------------------
Update_Rate = nil
#--------------------------------------------------------------------------
# * Bar Update Time
# - Number of Frames to Get to the amount. Overides Update_Rate
#--------------------------------------------------------------------------
Update_Time = 20
#--------------------------------------------------------------------------
# * Hp Bar Graphic
# - Syntax 'Class' => File
# - See Graphics/Gradients for file names
# - note: set to nil to draw no bar
#--------------------------------------------------------------------------
Hp_Bar_Graphic = {'Window_Help' => nil, 'Window_MenuStatus' => '003-Primary03'}
Hp_Bar_Graphic.default = 'BevelGreen' #'015-Greens01'
#--------------------------------------------------------------------------
# * Sp Bar Graphic
# - Syntax 'Class' => File
# - See Graphics/Gradients for file names
# - note: set to nil to draw no bar
#--------------------------------------------------------------------------
Sp_Bar_Graphic = {'Window_Help' => nil}
Sp_Bar_Graphic.default = 'BevelPurple' #'013-Blues01'
#--------------------------------------------------------------------------
# * Exp Bar Graphic
# - Syntax 'Class' => File
# - See Graphics/Gradients for file names
# - note: set to nil to draw no bar
#--------------------------------------------------------------------------
Exp_Bar_Graphic = {'Window_Help' => nil}
Exp_Bar_Graphic.default = '014-Reds01'
#--------------------------------------------------------------------------
# * Slanted Bars
# - Draw Slanted Gradient Bars (Only Gradient Will be Slanted)
#--------------------------------------------------------------------------
Slanted_Bars = false
#--------------------------------------------------------------------------
# * Bar Border File
# - See Graphics/Gradients for file names
#--------------------------------------------------------------------------
Border = 'Back'
Border2 = 'BigBack'
#--------------------------------------------------------------------------
# * Bar Background File
# - See Graphics/Gradients for file names
#--------------------------------------------------------------------------
Background = 'Back2'
Background2 = 'BigBackground'
#--------------------------------------------------------------------------
# * Border Dimension
# - Bar Border Width and Height
#--------------------------------------------------------------------------
Border_Dim = 1
#--------------------------------------------------------------------------
# * Background Dimension
# - Bar Backgoround Width and Height
#--------------------------------------------------------------------------
Background_Dim = 1
#--------------------------------------------------------------------------
# * (Hp|Sp|Exp) Tone Proc
# - Bars Change Color Based on Amount
# - Example Block
# proc do |percent|
# case percent * 100
# when 0...25
# [percent*255+64,0,0,128]
# when 25...50
# [percent*255,percent*128-32,0,96]
# when 50...75
# [percent*255,percent*255,0,64]
# when 75..100
# [(1-percent)*255,percent*255,0,32]
# end
# end
# - Note: Must return an array with these values [red, green, blue, alpha]
#--------------------------------------------------------------------------
Hp_Color_Proc = proc {|percent|
[255*(1-percent), 255*(percent), 255*(percent), 160*(1-percent)+10]}
Sp_Color_Proc = nil
Exp_Color_Proc = nil
#--------------------------------------------------------------------------
# * (HP|SP|EXP) 'Flourish' Colors
# - These Colors are Blended into the sprite.
# - Note: There must be at least two colors in the array for it to work
# - Shortcut Color methods:
# Color.red, Color.green, Color.blue, Color.yellow, Color.purple,
# Color.orange, Color.white, Color.black, Color.gray
#--------------------------------------------------------------------------
Hp_Flourish = []
Sp_Flourish = []
Exp_Flourish = [
Color.red, Color.new(128,0,0), Color.new(64,0,0), Color.black,
Color.new(64,0,0), Color.new(128,0,0)]
#--------------------------------------------------------------------------
# * (HP|SP|EXP) 'Flourishing' Speed
# - Speed of 'Flourishing'
# - I Recommend something high 50-200
#--------------------------------------------------------------------------
Hp_Flourish_Speed = 75
Sp_Flourish_Speed = 100
Exp_Flourish_Speed = 25
#--------------------------------------------------------------------------
# * (HP|SP|EXP) 'Flourishing' Opacity
# - Alpha Blending for 'Flourish' Use a Low Value (16-128)
# - The Higher the Value the less it blends in
#--------------------------------------------------------------------------
Hp_Flourish_Alpha = 64
Sp_Flourish_Alpha = 64
Exp_Flourish_Alpha = 32
end
class Sprite_ActorHpBar < Sprite_GradientBar
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor, x, y, width, height, file)
# Get Actor Viewport if in scene battle else nil
#viewport = $game_temp.in_battle ? $scene.spriteset.viewport2 : nil
# Set Viewport to nil if not using viewport
viewport = nil if not Gradient_Bars::Use_Viewport
# Get Border and Background
back, back2 = Gradient_Bars::Border, Gradient_Bars::Background
# Call Sprite_GradientBar#initialize
super(x, y, width, height, 1, 1, 1, back, back2, viewport)
# Setup Borders
self.bx = Gradient_Bars::Border_Dim
self.by = Gradient_Bars::Border_Dim
# Setup Instance Variables
@actor, @last, @file, @rate = actor, actor.hp, file, nil
# Setup Speed and Update Count
@speed, @update_count = Gradient_Bars::Update_Speed, 0
# Setup Background Borders
background.bx = Gradient_Bars::Background_Dim
background.by = Gradient_Bars::Background_Dim
# Refresh Boarder to Suit New Border
background.refresh
# Set Blending to Addition
self.blend_type = 1
# Setup Florish if Conditions are correct
if Gradient_Bars::Hp_Flourish.size > 1
# Setup Change Rate Array
@change_rate = []
# Current Index is zero
@current_flourish = 0
# Get RGB Array from color
rgb = Gradient_Bars::Hp_Flourish[0].to_rgb
# Set Red, Green, and Blue
color.red, color.green, color.blue = *rgb
# Setup Alpha for Blending
color.alpha = Gradient_Bars::Hp_Flourish_Alpha
# Setup Flourishing
setup_flourish
end
# Refresh Sprite
refresh
end
#--------------------------------------------------------------------------
# * Setup "Flourishing"
#--------------------------------------------------------------------------
def setup_flourish
# Get RGB Array from color
rgb = Gradient_Bars::Hp_Flourish[@current_flourish].to_rgb
# Set Red, Green, and Blue
color.red, color.green, color.blue = *rgb
# Get HSB Array from color
hsb = color.to_hsb
# Get Next Color to move to
next_flourish = (@current_flourish + 1) % Gradient_Bars::Hp_Flourish.size
# Get HSB Array from next color
next_hsb = Gradient_Bars::Hp_Flourish[next_flourish].to_hsb
# Get Rate of Change (Speed)
rate = Gradient_Bars::Hp_Flourish_Speed
# Clear Change Rate
@change_rate.clear
# Reset Count
@count_flourish = rate
# Set Values for Change Rate
3.times {|i| @change_rate[i] = (next_hsb[i] - hsb[i]) / rate}
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
# Call Sprite_GradientBar's update method
# which in turn only calls Sprite's update method
super
# Increase frame counter
@count += 1
# Decrease Update Counter
@update_count -= 1 if @update_count > 0
# Update Flourish if Conditions are right
update_flourish if @change_rate != nil
# Skip update if no speed or speed frames have not passed or in battle
return if @speed == 0 or @count % @speed != 0
# Update Bars
update_bars
end
#--------------------------------------------------------------------------
# * Update "Flourishing"
#--------------------------------------------------------------------------
def update_flourish
# Update Hue, Saturation, and Value
color.hue += @change_rate[0]
color.saturation += @change_rate[1]
color.value += @change_rate[2]
# Decrease Count
@count_flourish -= 1
# Return if not zero
return if @count_flourish != 0
# Add one and Restrict to [0, size)
@current_flourish = (@current_flourish + 1) % Gradient_Bars::Hp_Flourish.size
# Setup Flourishing
setup_flourish
end
#--------------------------------------------------------------------------
# * Update Bars, Decrease Contents Steadily
#--------------------------------------------------------------------------
def update_bars
# Return if not updating
return if not updatable?
# If Update Rate is nil then increment by current - last / time * +-1
if Gradient_Bars::Update_Rate == nil
# Get Rate
@rate = (@actor.hp - @last) / Gradient_Bars::Update_Time.to_f
# Increase By Rate
@last += @rate
else
# Increment Last By + 1 or -1 times Update Rate (move to current hp)
@last += (@actor.hp - @last).sign * Gradient_Bars::Update_Rate
end
# Restrict last to actor.hp, actor.maxhp if decreasing
@last = [[@last, @actor.hp].max, @actor.maxhp].min if @last > @actor.hp
# Restrict last to 0, actor.hp if increasing
@last = [[@last, 0].max, @actor.hp].min if @last < @actor.hp
# Refresh the bar
refresh
end
#--------------------------------------------------------------------------
# * Updatable?
#--------------------------------------------------------------------------
def updatable?
return @last != @actor.hp && @update_count <= 0 && @actor.damage == nil
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Redraw Bar
bitmap.clear
# Draw Substance
bitmap.draw_trick_gradient_bar_sub(0, 0, @last, @actor.maxhp, file, width,
height, Gradient_Bars::Border, bx, by, Gradient_Bars::Slanted_Bars)
# Return if no Color Proc given
return if Gradient_Bars::Hp_Color_Proc == nil
# Prevent Division by Zero
percent = @actor.maxhp != 0 ? @last.to_f / @actor.maxhp : 0
# Call Proc and send the percent to get color values
new_color = Gradient_Bars::Hp_Color_Proc.call(percent)
# Set New Color Size
if new_color.size == 3
# Set Red Green Blue
color.red, color.green, color.blue = *new_color
else
# Set Red Green Blue Alpha
color.red, color.green, color.blue, color.alpha = *new_color
end
end
end
class Sprite_ActorSpBar < Sprite_GradientBar
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor, x, y, width, height, file)
# Get Actor Viewport if in scene battle else nil
viewport = $game_temp.in_battle ? $scene.spriteset.viewport2 : nil
# Set Viewport to nil if not using viewport
viewport = nil if not Gradient_Bars::Use_Viewport
# Get Border and Background
back, back2 = Gradient_Bars::Border, Gradient_Bars::Background
# Call Sprite_GradientBar#initialize
super(x, y, width, height, 1, 1, 1, back, back2, viewport)
# Setup Borders
self.bx = Gradient_Bars::Border_Dim
self.by = Gradient_Bars::Border_Dim
# Setup Instance Variables
@actor, @last, @file, @rate = actor, actor.sp, file, nil
# Setup Speed and Update Count
@speed, @update_count = Gradient_Bars::Update_Speed, 0
# Setup Background Borders
background.bx = Gradient_Bars::Background_Dim
background.by = Gradient_Bars::Background_Dim
# Refresh Boarder to Suit New Border
background.refresh
# Set Blending to Addition
self.blend_type = 1
# Setup Florish if Conditions are correct
if Gradient_Bars::Sp_Flourish.size > 1
# Setup Change Rate Array
@change_rate = []
# Current Index is zero
@current_flourish = 0
# Get RGB Array from color
rgb = Gradient_Bars::Sp_Flourish[0].to_rgb
# Set Red, Green, and Blue
color.red, color.green, color.blue = *rgb
# Setup Alpha for Blending
color.alpha = Gradient_Bars::Sp_Flourish_Alpha
# Setup Flourishing
setup_flourish
end
# Refresh Sprite
refresh
end
#--------------------------------------------------------------------------
# * Setup "Flourishing"
#--------------------------------------------------------------------------
def setup_flourish
# Get RGB Array from color
rgb = Gradient_Bars::Sp_Flourish[@current_flourish].to_rgb
# Set Red, Green, and Blue
color.red, color.green, color.blue = *rgb
# Get HSB Array from color
hsb = color.to_hsb
# Get Next Color to move to
next_flourish = (@current_flourish + 1) % Gradient_Bars::Sp_Flourish.size
# Get HSB Array from next color
next_hsb = Gradient_Bars::Sp_Flourish[next_flourish].to_hsb
# Get Rate of Change (Speed)
rate = Gradient_Bars::Sp_Flourish_Speed
# Clear Change Rate
@change_rate.clear
# Reset Count
@count_flourish = rate
# Set Values for Change Rate
3.times {|i| @change_rate[i] = (next_hsb[i] - hsb[i]) / rate}
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
# Call Sprite_GradientBar's update method
# which in turn only calls Sprite's update method
super
# Increase frame counter
@count += 1
# Decrease Update Counter
@update_count -= 1 if @update_count > 0
# Update Flourish if Conditions are right
update_flourish if @change_rate != nil
# Skip update if no speed or speed frames have not passed
return if @speed == 0 or @count % @speed != 0
# Update Bars
update_bars
end
#--------------------------------------------------------------------------
# * Update "Flourishing"
#--------------------------------------------------------------------------
def update_flourish
# Update Hue, Saturation, and Value
color.hue += @change_rate[0]
color.saturation += @change_rate[1]
color.value += @change_rate[2]
# Decrease Count
@count_flourish -= 1
# Return if not zero
return if @count_flourish != 0
# Add one and Restrict to [0, size)
@current_flourish = (@current_flourish + 1) % Gradient_Bars::Sp_Flourish.size
# Setup Flourishing
setup_flourish
end
#--------------------------------------------------------------------------
# * Update Bars, Decrease Contents Steadily
#--------------------------------------------------------------------------
def update_bars
return if not updatable?
# If Update Rate is nil then increment by current - last / time * +-1
if Gradient_Bars::Update_Rate == nil
# Get Rate
@rate = (@actor.sp - @last) / Gradient_Bars::Update_Time.to_f
# Increase By Rate
@last += @rate
else
# Increment Last By + 1 or -1 times Update Rate (move to current sp)
@last += (@actor.sp - @last).sign * Gradient_Bars::Update_Rate
end
# Restrict last to actor.sp, actor.maxsp if decreasing
@last = [[@last, @actor.sp].max, @actor.maxsp].min if @last > @actor.sp
# Restrict last to 0, actor.sp if increasing
@last = [[@last, 0].max, @actor.sp].min if @last < @actor.sp
# Refresh the bar
refresh
end
#--------------------------------------------------------------------------
# * Updatable?
#--------------------------------------------------------------------------
def updatable?
return @last != @actor.sp && @update_count <= 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Redraw Bar
bitmap.clear
# Draw Substance
bitmap.draw_trick_gradient_bar_sub(0, 0, @last, @actor.maxsp, file, width,
height, Gradient_Bars::Border, bx, by, Gradient_Bars::Slanted_Bars)
# If no Color Process Given
return if Gradient_Bars::Sp_Color_Proc == nil
# Prevent Division by Zero
percent = @actor.maxsp != 0 ? @last.to_f / @actor.maxsp : 0
# Call Proc and send the percent to get color values
new_color = Gradient_Bars::Sp_Color_Proc.call(percent)
# Argument expansion on returned array
if new_color.size == 3
color.red, color.green, color.blue = *new_color
else
color.red, color.green, color.blue, color.alpha = *new_color
end
end
end
class Sprite_ActorExpBar < Sprite_GradientBar
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor, x, y, width, height, file)
# Get Actor Viewport if in scene battle else nil
viewport = $game_temp.in_battle ? $scene.spriteset.viewport2 : nil
# Set Viewport to nil if not using viewport
viewport = nil if not Gradient_Bars::Use_Viewport
# Get Border and Background
back, back2 = Gradient_Bars::Border, Gradient_Bars::Background
# Call Sprite_GradientBar#initialize
super(x, y, width, height, 1, 1, 1, back, back2, viewport)
# Setup Borders
self.bx = Gradient_Bars::Border_Dim
self.by = Gradient_Bars::Border_Dim
# Setup Instance Variables
@actor, @last, @file, @rate = actor, actor.now_exp, file, nil
# Setup Speed and Update Count
@speed, @update_count = Gradient_Bars::Update_Speed, 0
# Setup Background Borders
background.bx = Gradient_Bars::Background_Dim
background.by = Gradient_Bars::Background_Dim
# Refresh Boarder to Suit New Border
background.refresh
# Set Blending to Addition
self.blend_type = 1
# Setup Florish if Conditions are correct
if Gradient_Bars::Exp_Flourish.size > 1
# Setup Change Rate Array
@change_rate = []
# Current Index is zero
@current_flourish = 0
# Get RGB Array from color
rgb = Gradient_Bars::Exp_Flourish[0].to_rgb
# Set Red, Green, and Blue
color.red, color.green, color.blue = *rgb
# Setup Alpha for Blending
color.alpha = Gradient_Bars::Exp_Flourish_Alpha
# Setup Flourishing
setup_flourish
end
# Refresh Sprite
refresh
end
#--------------------------------------------------------------------------
# * Setup "Flourishing"
#--------------------------------------------------------------------------
def setup_flourish
# Get RGB Array from color
rgb = Gradient_Bars::Exp_Flourish[@current_flourish].to_rgb
# Set Red, Green, and Blue
color.red, color.green, color.blue = *rgb
# Get HSB Array from color
hsb = color.to_hsb
# Get Next Color to move to
next_flourish = (@current_flourish + 1) % Gradient_Bars::Exp_Flourish.size
# Get HSB Array from next color
next_hsb = Gradient_Bars::Exp_Flourish[next_flourish].to_hsb
# Get Rate of Change (Speed)
rate = Gradient_Bars::Exp_Flourish_Speed
# Clear Change Rate
@change_rate.clear
# Reset Count
@count_flourish = rate
# Set Values for Change Rate
3.times {|i| @change_rate[i] = (next_hsb[i] - hsb[i]) / rate}
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
# Call Sprite_GradientBar's update method
# which in turn only calls Sprite's update method
super
# Increase frame counter
@count += 1
# Decrease Update Counter
@update_count -= 1 if @update_count > 0
# Update Flourish if Conditions are right
update_flourish if @change_rate != nil
# Skip update if no speed or speed frames have not passed
return if @speed == 0 or @count % @speed != 0
# Update Bars
update_bars
end
#--------------------------------------------------------------------------
# * Update "Flourishing"
#--------------------------------------------------------------------------
def update_flourish
# Update Hue, Saturation, and Value
color.hue += @change_rate[0]
color.saturation += @change_rate[1]
color.value += @change_rate[2]
# Decrease Count
@count_flourish -= 1
# Return if not zero
return if @count_flourish != 0
# Add one and Restrict to [0, size)
@current_flourish = (@current_flourish + 1) % Gradient_Bars::Exp_Flourish.size
# Setup Flourishing
setup_flourish
end
#--------------------------------------------------------------------------
# * Update Bars, Decrease Contents Steadily
#--------------------------------------------------------------------------
def update_bars
# Return if not updating
return if not updatable?
# If Update Rate is nil then increment by current - last / time * +-1
if Gradient_Bars::Update_Rate == nil
# Get Rate
@rate = (@actor.now_exp - @last) / Gradient_Bars::Update_Time.to_f
# Increase By Rate
@last += @rate
else
# Increment Last By + 1 or -1 times Update Rate (move to current exp)
@last += (@actor.now_exp - @last).sign * Gradient_Bars::Update_Rate
end
# Restrict last to actor.now_exp, actor.next_exp if decreasing
@last = [[@last, @actor.now_exp].max, @actor.next_exp].min if @last > @actor.now_exp
# Restrict last to 0, actor.now_exp if increasing
@last = [[@last, 0].max, @actor.now_exp].min if @last < @actor.now_exp
# Refresh the bar
refresh
end
#--------------------------------------------------------------------------
# * Updatable?
#--------------------------------------------------------------------------
def updatable?
return @last != @actor.now_exp && @update_count <= 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Clear Bitmap
bitmap.clear
# Draw Substance
bitmap.draw_trick_gradient_bar_sub(0, 0, @last, @actor.next_exp, file, width,
height, Gradient_Bars::Border, bx, by, Gradient_Bars::Slanted_Bars)
# Return if no color proc given
return if Gradient_Bars::Exp_Color_Proc == nil
# Prevent Division by Zero
percent = @actor.next_exp != 0 ? @last.to_f / @actor.next_exp : 0
# Call Proc and send the percent to get color values
new_color = Gradient_Bars::Exp_Color_Proc.call(percent)
# Argument expansion on returned array
if new_color.size == 3
color.red, color.green, color.blue = *new_color
else
color.red, color.green, color.blue, color.alpha = *new_color
end
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :spriteset
end
class Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :trick_gradient_bars_base_initialize, :initialize
def initialize(*args)
# Setup Bar Sprites
@hp_bar_sprites = {}
@sp_bar_sprites = {}
@exp_bar_sprites = {}
# The Usual
trick_gradient_bars_base_initialize(*args)
end
#--------------------------------------------------------------------------
# * Draw HP GradBar
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
alias_method :trick_gradient_bars_base_draw_actor_hp, :draw_actor_hp
def draw_actor_hpgbar(actor, x, y, width = 144)
# Draw HP
#trick_gradient_bars_base_draw_actor_hp(actor, x, y, width)
# Get Gradient File
file = Gradient_Bars::Hp_Bar_Graphic[self.class.to_s]
# Return if sprite has been setup
return if @hp_bar_sprites[actor] != nil or file == nil
# Setup the bar
draw_x, draw_y = self.x + x + 16, self.y + y + 32
# Create Bar
sprite = Sprite_ActorHpBar.new(actor, draw_x, draw_y, width, 32, file)
# Set Y Coordinate
sprite.y = self.y + y + 32 + (8 - sprite.height)
# Tag Sprite
sprite.tag(self)
# Set Reference
@hp_bar_sprites[actor] = sprite
# Add Sprite to Window Sprites
@window_sprites << sprite
end
#--------------------------------------------------------------------------
# * Draw SP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
alias_method :trick_gradient_bars_base_draw_actor_sp, :draw_actor_sp
def draw_actor_spgbar(actor, x, y, width = 144)
# The Usual
#trick_gradient_bars_base_draw_actor_sp(actor, x, y, width)
# Get Gradient File
file = Gradient_Bars::Sp_Bar_Graphic[self.class.to_s]
# Return if bar is already setup
return if @sp_bar_sprites[actor] != nil or file == nil
# Setup the bar
draw_x, draw_y = self.x + x + 16, self.y + y + 32
# Create Bar
sprite = Sprite_ActorSpBar.new(actor, draw_x, draw_y, width, 32, file)
# Set Y Coordinate
sprite.y = self.y + y + 32 + (8 - sprite.height)
# Tag Sprite
sprite.tag(self)
# Set Reference
@sp_bar_sprites[actor] = sprite
# Add Sprite to Window Sprites
@window_sprites << sprite
end
#--------------------------------------------------------------------------
# * Draw Exp
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
alias_method :trick_gradient_bars_base_draw_actor_exp, :draw_actor_exp
def draw_actor_expgbar(actor, x, y)
# The Usual
#trick_gradient_bars_base_draw_actor_exp(actor, x, y)
# Get Gradient File
file = Gradient_Bars::Exp_Bar_Graphic[self.class.to_s]
# If Sprites is already setup for actor
return if @exp_bar_sprites[actor] != nil or file == nil
# Setup the bar
draw_x, draw_y = self.x + x + 16, self.y + y + 32
# Create Bar
sprite = Sprite_ActorExpBar.new(actor, draw_x, draw_y, 204, 32, file)
# Set Y Coordinate
sprite.y = self.y + y + 32 + (8 - sprite.height)
# Tag Sprite
sprite.tag(self)
# Set Reference
@exp_bar_sprites[actor] = sprite
# Add Sprite to Window Sprites
@window_sprites << sprite
end
end
class Game_Actor
#--------------------------------------------------------------------------
# * Get the current EXP
#--------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end
#--------------------------------------------------------------------------
# * Get the next level's EXP
#--------------------------------------------------------------------------
def next_exp
exp = @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
return exp
end
end
class Window_Help
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
if @trick_gradient_bars_help.nil?
alias_method :trick_gradient_bars_help_visible=, :visible=
@trick_gradient_bars_help = true
end
#--------------------------------------------------------------------------
# * Set Visibility
#--------------------------------------------------------------------------
def visible=(bool)
# The Usual
self.trick_gradient_bars_help_visible = bool
# If Setting to Invisible
if bool == false
# Dispose All
get_gradient_sprites.each {|sprite| sprite.dispose}
# Remove Each From Window Sprites
get_gradient_sprites.each {|sprite| @window_sprites.delete(sprite)}
# Clear All
@hp_bar_sprites.clear
@sp_bar_sprites.clear
@exp_bar_sprites.clear
# If Actor Defined
elsif @actor != nil
# Set All to Invisible
get_gradient_sprites.each {|sprite| sprite.visible = false}
# If Key Exists in Hp Bar Sprite
if @hp_bar_sprites.has_key?(@actor)
# Set Old Actor Hp Bar to invisible
@hp_bar_sprites[@actor].visible = true
end
# If Key Exists in Sp Bar Sprite
if @sp_bar_sprites.has_key?(@actor)
# Set Old Actor Sp Bar to invisible
@sp_bar_sprites[@actor].visible = true
end
# If Key Exists in Exp Bar Sprite
if @exp_bar_sprites.has_key?(@actor)
# Set Old Actor Exp Bar to invisible
@exp_bar_sprites[@actor].visible = true
end
end
end
#--------------------------------------------------------------------------
# * Set Actor
# actor : status displaying actor
#--------------------------------------------------------------------------
alias_method :trick_gradient_bars_help_set_actor, :set_actor
def set_actor(actor)
# If Actor Change and An Actor
if actor != @actor and @actor != nil
# If Key Exists in Hp Bar Sprite
if @hp_bar_sprites.has_key?(@actor)
# Set Old Actor Hp Bar to invisible
@hp_bar_sprites[@actor].visible = false
end
# If Key Exists in Sp Bar Sprite
if @sp_bar_sprites.has_key?(@actor)
# Set Old Actor Sp Bar to invisible
@sp_bar_sprites[@actor].visible = false
end
# If Key Exists in Exp Bar Sprite
if @exp_bar_sprites.has_key?(@actor)
# Set Old Actor Exp Bar to invisible
@exp_bar_sprites[@actor].visible = false
end
# If Key Exists in Hp Bar Sprite
if @hp_bar_sprites.has_key?(actor)
# Set Old Actor Hp Bar to invisible
@hp_bar_sprites[actor].visible = true
end
# If Key Exists in Sp Bar Sprite
if @sp_bar_sprites.has_key?(actor)
# Set Old Actor Sp Bar to invisible
@sp_bar_sprites[actor].visible = true
end
# If Key Exists in Exp Bar Sprite
if @exp_bar_sprites.has_key?(actor)
# Set Old Actor Exp Bar to invisible
@exp_bar_sprites[actor].visible = true
end
end
# The Usual
trick_gradient_bars_help_set_actor(actor)
end
#--------------------------------------------------------------------------
# * Set Text
#--------------------------------------------------------------------------
alias_method :trick_gradient_bars_help_set_text, :set_text
def set_text(*args)
# Dispose All
get_gradient_sprites.each {|sprite| sprite.dispose}
# Remove Each From Window Sprites
get_gradient_sprites.each {|sprite| @window_sprites.delete(sprite)}
# Clear All
@hp_bar_sprites.clear
@sp_bar_sprites.clear
@exp_bar_sprites.clear
# The Usual
trick_gradient_bars_help_set_text(*args)
end
#--------------------------------------------------------------------------
# * Get Gradient Sprites
#--------------------------------------------------------------------------
def get_gradient_sprites
return (@hp_bar_sprites.values + @sp_bar_sprites.values +
@exp_bar_sprites.values)
end
end
#--------------------------------------------------------------------------
# End SDK Enabled Check
#--------------------------------------------------------------------------
end
How would I go about using Trickster's animated bars to show the enemies' HP?