Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Sign in to follow this  
Noob Saibot

Trickster's Animated Gradient Bars

Recommended Posts

I pull a post from the RMXPU.net archive posted by DerVVulfman.

 

Trickster's Animated Gradient Bars

for Limit Break (DVV)

Version: 1.0

 

Introduction

This script is merely a single page based on, and utilizes Trickster's Animated Gradient Bars... an SDK 2.0+ script system. This is an add-on for use with my Limit Break script.

 

Screenshots

Didn't make any

 

Demo

None... but it's fairly plug-n-play.

 

Instructions

You place THIS script below the Limit Break script...

 

Your best bet is to have the SDK, Battlesystem, Gradient Bars, LimitBreak script, and THIS script... in this order.

 

Only for users of Trickster's Gradient Bars, and as such... only for 'Legal/Non-Postality' Users. You will only find the Gradient Bars script available in DEMO format and can only be accessed by Official English-Version users. For his Gradient Bar topic, click HERE!

 

FAQ

This is merely an edit of Trickster's HP/SP/EXP page, and STILL requires the rest of his Gradient Bars script.

 

Compatibility

This is not designed for KGC's OverDrive system (though a few changes 'could' be made for it to work. It IS an SDK script (heh... so Limit Break is SDK-Compatible...) and requires BOTH Trickster's Gradient Bars demo (no script available), and my Limit Break script.

 

Credits and Thanks

Definite thanks goes to Trickster for the Gradient Bars script. This is 99.98% his work.

 

Script

#==============================================================================
# ** Animated Gradient Bars...
#    Limit Break Bars v 1.0
#------------------------------------------------------------------------------
# Main code designed by:
# Trickster (tricksterguy@hotmail.com)
# based on version 3.6 code.
# Original code date 3/16/07
#------------------------------------------------------------------------------
# Coding merely edited for Limit Break bars
# by DerVVulfman
#------------------------------------------------------------------------------
#
# INTRODUCTION:
# This  simple code  is used  to insert  'Animated Gradient'  bars designed  by
# Trickster into projects utilizing the Limit Break script by DerVVulfman.
#
# It merely mimics Trickster's original code, with the small difference in that
# instead of aliasing the 'draw_actor_hp' and etc.,  it re-creates & overwrites
# the required 'draw_actor_lb' def used in the Limit Break script.
#
# Again, this is a simple mimic of his code, and changes to the defs within it
# were performed only to keep it separate from his HP, SP and EXP bar systems.
#
# The position of the Trickster-based Limit Break bar is still goverened within
# the Limit Break script itself, and the 'Flexible Positioning System' I wrote.
# As far as the location of the bar in battle, I recommend a setting of:
#
#  $lb_battle_pos = [ 0,  -32, 120]
#
# ...to position the bar behind the actor's names.
#
#------------------------------------------------------------------------------
#
#  REQUIRES:
#  This script requires SDK version 2.0+ (parts 1,2 & 3), requires the Gradient
#  bars system  designed by Trickster,  and of course...  the Limit Break (DVV)
#  system by DerVVulfman.
#
#  For use with the SDK and SDK battlesystems, Limit Break must be placed below
#  the SDK battlesystems.  And to use this script,  it must be placed below the
#  Limit Break (DVV) script in order to replace the Bar system built into it.
#
#==============================================================================


#--------------------------------------------------------------------------
# ● Begin SDK Log
#--------------------------------------------------------------------------
SDK.log('Limit Break Animated Gradient Bars', 'T & DVV', 1.0, '4/05/07')
#--------------------------------------------------------------------------
# ● Begin SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2.0, [1, 2, 3], ['Window Sprites'])
#--------------------------------------------------------------------------
# ● Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Limit Break 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 = 1  # (Formerly 20... Gets all the bars to update instantly.)
#--------------------------------------------------------------------------
# * Update Delay
#   - Number of Frames Before Bar Updates
#--------------------------------------------------------------------------
Update_Delay = 1  # (Formerly 10... Again...  instantaneous reactions.)
#--------------------------------------------------------------------------
# * Limit Break Bar Graphic
#   - See Graphics/Gradients for file names
#--------------------------------------------------------------------------
Lb_Bar_Graphic = '018-Simple03'
#--------------------------------------------------------------------------
# * Slanted Bars (Slightly buggy)
#   - Draw Slanted Gradient Bars
#--------------------------------------------------------------------------
Slanted_Bars = false
#--------------------------------------------------------------------------
# * Bar Border File
#   - See Graphics/Gradients for file names
#--------------------------------------------------------------------------
Border = 'Back'
#--------------------------------------------------------------------------
# * Bar Background File
#   - See Graphics/Gradients for file names
#--------------------------------------------------------------------------
Background = 'Back2'
#--------------------------------------------------------------------------
# * Border Dimension
#   - Bar Border Width and Height
#--------------------------------------------------------------------------
Border_Dim = 1
#--------------------------------------------------------------------------
# * Background Dimension
#   - Bar Backgoround Width and Height
#--------------------------------------------------------------------------
Background_Dim = 1
#--------------------------------------------------------------------------
# * Limit Break 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]
#--------------------------------------------------------------------------
Lb_Color_Proc = nil
#--------------------------------------------------------------------------
# * Limit Break '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
#--------------------------------------------------------------------------
Lb_Flourish = []
#--------------------------------------------------------------------------
# * Limit Break 'Flourishing' Speed
#   - Speed of 'Flourishing'
#   - I Recommend something high 50-200
#--------------------------------------------------------------------------
Lb_Flourish_Speed = 200
#--------------------------------------------------------------------------
# * Limit Break 'Flourishing' Opacity
#   - Alpha Blending for 'Flourish' Use a Low Value (16-128)
#   - The Higher the Value the less it blends in
#--------------------------------------------------------------------------
Lb_Flourish_Alpha = 32
end

class Sprite_ActorLbBar < Sprite_GradientBar
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor, x, y, width, height)
  # 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, @rate = actor, actor.limitbreak, 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
  # If Slanted Mode Draw A Slanted Background
  draw_slanted_background if Gradient_Bars::Slanted_Bars
  # Get Gradient File
  @file = Gradient_Bars::Lb_Bar_Graphic
  # Set Blending to Addition
  self.blend_type = 1
  # Setup Florish if Conditions are correct
  if Gradient_Bars::Lb_Flourish.size > 1
    # Setup Change Rate Array
    @change_rate = []
    # Current Index is zero
    @current_flourish = 0
    # Get RGB Array from color
    rgb = Gradient_Bars::Lb_Flourish[0].to_rgb
    # Set Red, Green, and Blue
    color.red, color.green, color.blue = *rgb
    # Setup Alpha for Blending
    color.alpha = Gradient_Bars::Lb_Flourish_Alpha
    # Setup Flourishing
    setup_flourish
  end
  # Refresh Sprite
  refresh
end
#--------------------------------------------------------------------------
# * Setup "Flourishing"
#--------------------------------------------------------------------------
def setup_flourish
  # Get RGB Array from color
  rgb = Gradient_Bars::Lb_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::Lb_Flourish.size
  # Get HSB Array from next color
  next_hsb = Gradient_Bars::Lb_Flourish[next_flourish].to_hsb
  # Get Rate of Change (Speed)
  rate = Gradient_Bars::Lb_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
#--------------------------------------------------------------------------
# * Start Animation
#--------------------------------------------------------------------------
def start
  @update_count = Gradient_Bars::Update_Delay
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::Lb_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.limitbreak - @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.limitbreak - @last).sign * Gradient_Bars::Update_Rate
  end
  # Restrict last to actor.hp, actor.maxhp if decreasing
  @last = [[@last, @actor.limitbreak].max, LB_MAX].min if @last > @actor.limitbreak
  # Restrict last to 0, actor.hp if increasing
  @last = [[@last, 0].max, @actor.limitbreak].min if @last < @actor.limitbreak
  # Refresh the bar
  refresh
end
#--------------------------------------------------------------------------
# * Updatable?
#--------------------------------------------------------------------------
def updatable?
  return @last != @actor.limitbreak && @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, LB_MAX, file, width,
    height, Gradient_Bars::Border, bx, by, Gradient_Bars::Slanted_Bars)
  # Return if no Color Proc given
  return if Gradient_Bars::Lb_Color_Proc == nil
  # Prevent Division by Zero
  percent = LB_MAX != 0 ? @last.to_f / LB_MAX : 0
  # Call Proc and send the percent to get color values
  new_color = Gradient_Bars::Lb_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 Scene_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :spriteset
end

class Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :trick_lb_gradient_bars_base_initialize, :initialize
def initialize(*args)
  # Setup Bar Sprites
  @lb_bar_sprites = {}
  # The Usual
  trick_lb_gradient_bars_base_initialize(*args)
end
#--------------------------------------------------------------------------
# * Draw LB
#     actor : actor
#     x     : draw spot x-coordinate
#     y     : draw spot y-coordinate
#     width : draw spot width
#--------------------------------------------------------------------------
def draw_actor_lb(actor, x, y, width = 144)
  # If Bar Sprites not setup for actor in question
  if @lb_bar_sprites[actor] == nil
    # Setup the bar
    draw_x, draw_y = self.x + x + 16, self.y + y + 32
    # Create Bar
    sprite = Sprite_ActorLbBar.new(actor, draw_x, draw_y, width, 8)
    # Get Z
    z = sprite.viewport.nil? ? self.z + 1 : actor.screen_z + 1
    # Tag Sprite
    sprite.tag(self)
    # Set Z
    sprite.z = z
    # Set Reference
    @lb_bar_sprites[actor] = sprite
    # Add Sprite to Window Sprites
    @window_sprites << sprite
  else
    # Start Updating
    @lb_bar_sprites[actor].start
  end
end
#--------------------------------------------------------------------------
# * Get Gradient Sprites
#--------------------------------------------------------------------------
def get_lb_gradient_sprites
  # Setup Bar Sprites
  @lb_bar_sprites = {} if @lb_bar_sprites.nil?
  return @lb_bar_sprites.values
end
end

class Window_Help < Window_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
if @trick_lb_gradient_bars_help.nil?
  alias_method :trick_lb_gradient_bars_help_visible=, :visible=
  @trick_lb_gradient_bars_help = true
end
#--------------------------------------------------------------------------
# * Set Visibility
#--------------------------------------------------------------------------
def visible=(bool)
  # The Usual
  self.trick_lb_gradient_bars_help_visible = bool
  # If Setting to Invisible
  if bool == false
    # Dispose All
    get_lb_gradient_sprites.each {|sprite| sprite.dispose}
    # Remove Each From Window Sprites
    get_lb_gradient_sprites.each {|sprite| @window_sprites.delete(sprite)}
    # Set LB to Empty Hash
    @lb_bar_sprites  = {}
  # If Actor Defined
  elsif @actor != nil
    # Set All to Invisible
    get_lb_gradient_sprites.each {|sprite| sprite.visible = false}
    # Set LB Bar to Visible
    @lb_bar_sprites[@actor].visible = true
  end
end
#--------------------------------------------------------------------------
# * Set Actor
#     actor : status displaying actor
#--------------------------------------------------------------------------
alias_method :trick_lb_gradient_bars_help_set_actor, :set_actor
def set_actor(actor)
  # If Actor Change and An Actor
  if actor != @actor and @actor != nil
    # Set Old Actor LB Bar to invisible
    @lb_bar_sprites[@actor].visible = false
    # Set LB Sprites for Actor to be visible if bar exists
    @lb_bar_sprites[actor].visible = true if @lb_bar_sprites.has_key?(actor)
  end
  # The Usual
  trick_lb_gradient_bars_help_set_actor(actor)
end
#--------------------------------------------------------------------------
# * Set Text
#--------------------------------------------------------------------------
alias_method :trick_lb_gradient_bars_help_set_text, :set_text
def set_text(*args)
  # Dispose All
  get_lb_gradient_sprites.each {|sprite| sprite.dispose}
  # Remove Each From Window Sprites
  get_lb_gradient_sprites.each {|sprite| @window_sprites.delete(sprite)}
  # Set All to Empty Hash
  @lb_bar_sprites = {}
  # The Usual
  trick_lb_gradient_bars_help_set_text(*args)
end
end
#--------------------------------------------------------------------------
#  End SDK Enabled Check
#--------------------------------------------------------------------------
end

This post has been edited by DerVVulfman on April 06, 2007 11:11 pm

 

Original Post: RMXPU.net Archive

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...