Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Animated Bar?

VCA

Member

Me again. I think I requested this before. Maybe I didn't explain very well. Anyways I was requesting a script than Animates a HP or SP bar. I try explaining this as best as I can. Say the HP or SP bar is full, as an enemy attacks you and deals damage to you, your HP or SP goes down but not in a flash, but IT goes down SMOOTHLY, like if you were drinking water with a straw. The way as the water is being drain or sucked out thats what I mean. I'm sorry if I didn't make it clear enough. But if you do get what i'm saying can you help me out with this request. If anyone has any infomation about this script, please let me know. Thanx.
 
Interesting idea. There are several "Gradient Bars" & "HP/SP Bars" scripts available already, but I don't think any of them are "smooth".

I think most of the scripts are add-ons to the Window_BattleStatus script. In this case I think they would need to be individual sprites that can update.

Here's a dilemma: Say you kill a monster (or you get killed) in one hit. Do you want the system to wait until the HP bar gradually gets to zero before the character dies?

Why didn't you use the template?
 

Atoa

Member

I Had a smothing bar script, but i lost it.

But i will remake it since i'm goig to use it on my project.

If no one makes one like this, i will send you mine when i finnish

@Tyrant-Rave
I suppose not, since this bar is drawn with an fill_rect and draw_text, these methods have an really slow update.
 
I've got this script by Trickster, its an animated gradient bars script and it uses graphics for the actual bars.

Code:
=begin

#==============================================================================

# ●● Animated Gradient Bars 

#------------------------------------------------------------------------------

# Trickster ([email=tricksterguy@hotmail.com]tricksterguy@hotmail.com[/email])

# 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 = false

  #--------------------------------------------------------------------------

  # * 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 = '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, 'Window_BattleStatus' => '014-Reds01'}

  Sp_Bar_Graphic.default = '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'

  #--------------------------------------------------------------------------

  # * 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

  #--------------------------------------------------------------------------

  # * (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 = [Color.white, Color.blue, Color.black, Color.blue]

  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

  #     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_hp(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_sp(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_exp(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

It requires SDK Parts 1, 2 and 3 though, I donno if thats an issue or not. Also, you obviously need these to get started, I wouldn't bother unzipping it in a single project folder I just put these directly into the RTP so I don't have to copy and paste them all the time. And the nice thing is, if you're a graphics guru, you can easily make your own custom bars =P

Graphics/Gradients

You can download them all here
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top