Party hud

Started by nathmatt, January 16, 2010, 07:34:45 am

Previous topic - Next topic

nathmatt

ok so be4 i make it where the hud redraws more then 1nce the all my ys are fine but as soon as i tell it to draw edit it to make more than 1 they get all shoved together

script
#==============================================================================
# Par_Hud
#------------------------------------------------------------------------------
#  This class was modified to support SR display and modify the number of
#  skills left to use.
#==============================================================================

class Par_Hud < Sprite
 
  #----------------------------------------------------------------------------
  # Initialization
  #  viewport - the viewport for the sprite
  #----------------------------------------------------------------------------
  def initialize(viewport = nil)
    # call superclass method
    super
    # create positions
    create_positions
    # create bitmap
    self.bitmap = Bitmap.new(@hud_width, @hud_height)
    # set font
    self.bitmap.font.name = 'Arial'
    # set font size
    self.bitmap.font.size = 10
    # set font to bold
    self.bitmap.font.bold = true
    # set x, y position
    self.x, self.y = -4, 124
    # set z coordinate
    self.z = 1000
    # draw basic HUD
    (0...@maxpsize).each {|i| draw_basic(i) }
    # update
    update
  end
  #----------------------------------------------------------------------------
  # create_positions
  #  Sets drawing positions. This method can be aliased and the positions
  #  modified to create a different HUD.
  #----------------------------------------------------------------------------
  def create_positions
    if BlizzABS::Config::MAX_PARTY > $game_party.actors.size
      @maxpsize = $game_party.actors.size - 1
    else
      @maxpsize = BlizzABS::Config::MAX_PARTY
    end
    @face_y = @name_y = @level_y = @hp_y = @sp_y = @exp_y =[]
    @face = @name = @level = @hp = @sp = @exp = []
    @maxhp = @maxsp = @next_exp = []
    (0...@maxpsize).each {|i|
    ys = i*80
    @original_width = @hud_width = 150
    @original_height = @hud_height = 80
    @face_x = 4
    @face_y.push(4+ys)
    @exp_x = 4
    @exp_y.push(50+ys)
    @name_x = 85
    @name_y.push(1+ys)
    @level_x = 55
    @level_y.push(1+ys)
    @hp_x = 70
    @hp_y.push(20+ys)
    @sp_x = 60
    @sp_y.push(30+ys)
    }
  end
  #----------------------------------------------------------------------------
  # draw_basic
  #  Draws the HUD template.
  #----------------------------------------------------------------------------
  def draw_basic(i)
    # fill with grey rectangle
    self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height,
        Color.new(0, 0, 0, 0))
    # set font color
    self.bitmap.font.color = system_color
    # draw "LV"
    self.bitmap.draw_text_full(@level_x, @level_y[i], 20, 20, 'LV')
    # draw "HP"
    self.bitmap.draw_text_full(@hp_x, @hp_y[i], 32, 20, $data_system.words.hp)
    # draw "SP"
    self.bitmap.draw_text_full(@sp_x, @sp_y[i], 32, 20, $data_system.words.sp)
    # draw "SP"
    self.bitmap.draw_text_full(@exp_x, @exp_y[i], 32, 20, 'EXP')
  end
  #----------------------------------------------------------------------------
  # draw_name
  #  Draws the name display.
  #----------------------------------------------------------------------------
  def draw_name(i)
    # set current variable
    @name[i] = actor(i).name
    # remove old display
    self.bitmap.fill_rect(@name_x, @name_y[i], 20, 20, Color.new(0, 0, 0, 0))
    # set font color
    self.bitmap.font.color = Color.new(0, 255, 0)
    # draw actor's name
    self.bitmap.draw_text_full(@name_x, @name_y[i], 20, 20, @name[i])
  end
  #----------------------------------------------------------------------------
  # draw_face
  #  Draws the face display.
  #----------------------------------------------------------------------------
  def draw_face(i)
    # set current variable
    @face[i] = actor(i).name
    # remove old display
    self.bitmap.fill_rect(@face_x, @face_y[i], 50, 50, Color.new(0, 0, 0, 0))
    # load bitmap
    bitmap = RPG::Cache.picture('Faces/'+@face[i]+'_S')
    # draw bitmap
    self.bitmap.blt(@face_x, @face_y[i], bitmap, Rect.new(0, 0, 50, 50))
  end
  #----------------------------------------------------------------------------
  # draw_level
  #  Draws the level display.
  #----------------------------------------------------------------------------
  def draw_level(i)
    # set current variable
    @level[i] = actor(i).level
    # remove old display
    self.bitmap.fill_rect(@level_x+20, @level_y[i], 5, 20, Color.new(0, 0, 0, 0))
    # set font color
    self.bitmap.font.color = normal_color
    # draw actor's level
    self.bitmap.draw_text_full(@level_x+20, @level_y[i], 5, 20, @level[i].to_s, 2)
  end
  #----------------------------------------------------------------------------
  # draw_hp
  #  Draws the HP display.
  #----------------------------------------------------------------------------
  def draw_hp(i)
    # set current variables
    @hp[i] = actor(i).hp
    @maxhp[i] = actor(i).maxhp
    # remove old display
    self.bitmap.fill_rect(@hp_x+15, @hp_y[i]+7, 100, 14, Color.new(0, 0, 0, 0))
    # draw gradient bar
    self.bitmap.gradient_bar_hp(actor(i), @hp_x+15, @hp_y[i]-15, 57)
    # set font color depending on how many HP left
    self.bitmap.font.color = @hp[i] == 0 ? knockout_color :
        @hp[i] <= @maxhp[i] / 4 ? crisis_color : normal_color
    # draw HP
    self.bitmap.draw_text_full(@hp_x+22, @hp_y[i], 20, 20, @hp[i].to_s, 2)
    # set color
    self.bitmap.font.color = normal_color
    # draw "/"
    self.bitmap.draw_text_full(@hp_x+44, @hp_y[i], 5, 20, '/', 1)
    # draw max HP
    self.bitmap.draw_text_full(@hp_x+51, @hp_y[i], 20, 20, @maxhp[i].to_s)
  end
  #----------------------------------------------------------------------------
  # draw_sp
  #  Draws the SP display.
  #----------------------------------------------------------------------------
  def draw_sp(i)
    # set current variables
    @sp[i] = actor(i).sp
    @maxsp[i] = actor(i).maxsp
    # remove old display
    self.bitmap.fill_rect(@sp_x+15, @sp_y[i]+7, 100, 14, Color.new(0, 0, 0, 0))
    # draw gradient bar
    self.bitmap.gradient_bar_sp(actor(i), @sp_x+15, @sp_y[i]-15, 57)
    # set font color depending on how many SP left
    self.bitmap.font.color = @sp[i] == 0 ? knockout_color :
        @sp[i] <= @maxsp[i] / 4 ? crisis_color : normal_color
    # draw SP
    self.bitmap.draw_text_full(@sp_x+22, @sp_y[i], 20, 20, @sp[i].to_s, 2)
    # set font color
    self.bitmap.font.color = normal_color
    # draw "/"
    self.bitmap.draw_text_full(@sp_x+44, @sp_y[i], 5, 20, '/', 1)
    # draw max SP
    self.bitmap.draw_text_full(@sp_x+51, @sp_y[i], 20, 20, @maxsp[i].to_s)
  end
  #----------------------------------------------------------------------------
  # draw_exp
  #  Draws the EXP display.
  #----------------------------------------------------------------------------
  def draw_exp(i)
    # set current variables
    @exp[i] = actor(i).now_exp
    @next_exp[i] = actor(i).next_exp
    # remove old display
    self.bitmap.fill_rect(@exp_x+20, @exp_y[i], 27, 14, Color.new(0, 0, 0, 0))
    # draw gradient bar
    self.bitmap.gradient_bar_exp(actor(i), @exp_x+20, @exp_y[i]-18, 27)
  end
  #----------------------------------------------------------------------------
  # draw_hskill
  #  Draws the hot skill display.
  #----------------------------------------------------------------------------
  def draw_hskill
    # set current variable
    @skill = actor.skill
    # remove old display
    self.bitmap.fill_rect(@hot_x, @hot_y+74, 24, 24, Color.new(0, 0, 0, 0))
    # if skill hot skill exists
    if @skill != 0
      # load bitmap
      bitmap = RPG::Cache.icon($data_skills[@skill].icon_name)
      # draw bitmap
      self.bitmap.blt(@hot_x, @hot_y+74, bitmap, Rect.new(0, 0, 24, 24))
    end
    # removes skills left to use display
    draw_lskill
  end
  #----------------------------------------------------------------------------
  # draw_lskill
  #  Draws the skills left to use display.
  #----------------------------------------------------------------------------
  def draw_lskill
    # remove old display
    self.bitmap.fill_rect(@left_x, @left_y+50, 24, 16, Color.new(0, 0, 0, 0))
    # get the number of skills left
    @skills_left = get_skills_left
    # if hot skill exists
    if @skill != nil && @skill > 0
      # if normal SP cost
      if @skills_left >= 0
        # if not enough sp to use
        if @skills_left == 0
          # set font color
          self.bitmap.font.color = Color.new(255, 0, 0)
        # if enough SP for 5 or less skill uses
        elsif @skills_left <= 5
          # set font color
          self.bitmap.font.color = Color.new(255, 255, 0)
        else
          # set font color
          self.bitmap.font.color = normal_color
        end
        # decrease font color
        self.bitmap.font.size -= 2
        # draw number how many skills left to use
        self.bitmap.draw_text_full(@left_x, @left_y+50, 24, 20,
        @skills_left.to_s, 1)
        # increase font size
        self.bitmap.font.size += 2
      # if infinite skills left
      elsif @skills_left == -1
        # set font color
        self.bitmap.font.color = Color.new(0, 255, 0)
        # increase font size
        self.bitmap.font.size += 4
        # draw "∞" skill uses left
        self.bitmap.draw_text_full(@left_x, @left_y+50, 24, 20, '∞', 1)
        # decrease font size
        self.bitmap.font.size -= 4
      end
    end
  end
  #----------------------------------------------------------------------------
  # get_skills_left
  #  Gets the number of skill usages left.
  #----------------------------------------------------------------------------
  def get_skills_left
    # if skill hot skill exists
    if @skill != nil && @skill > 0
      # if SP cost is zero
      if $data_skills[@skill].sp_cost > 0
        # get basic SP cost
        sp_cost = $data_skills[@skill].sp_cost
        # if using SP Cost Mod Status
        if $tons_version != nil && $tons_version >= 6.54 &&
            $game_system.SP_COST_MOD
          # get modified cost
          sp_cost = BlizzCFG.get_cost_mod(actor.states, sp_cost)
        end
        # infinite
        return -1 if sp_cost == 0
        # calculate skills left to use
        return @sp / sp_cost
      end
      # set flag
      return -1
    end
    # set flag
    return -2
  end
  #----------------------------------------------------------------------------
  # draw_hitem
  #  Draws the hot item display.
  #----------------------------------------------------------------------------
  def draw_hitem
    # set current variable
    @item = actor.item
    # remove old display
    self.bitmap.fill_rect(@hot_x, @hot_y+24, 24, 24, Color.new(0, 0, 0, 0))
    # if hot item exists
    if @item != 0
      # load bitmap
      bitmap = RPG::Cache.icon($data_items[@item].icon_name)
      # draw bitmap
      self.bitmap.blt(@hot_x, @hot_y+24, bitmap, Rect.new(0, 0, 24, 24))
    end
    # removes items left to use display
    draw_litem
  end
  #----------------------------------------------------------------------------
  # draw_litem
  #  Draws the items left to use display.
  #----------------------------------------------------------------------------
  def draw_litem
    # set current variable
    @items_left = $game_party.item_number(@item)
    # remove old display
    self.bitmap.fill_rect(@left_x, @left_y, 24, 16, Color.new(0, 0, 0, 0))
    # if hot item exists
    if @item != nil && @item > 0
      # if item exists and cannot be consumed
      if $data_items[@item] != nil && !$data_items[@item].consumable
        # set font color
        self.bitmap.font.color = Color.new(0, 255, 0)
        # increase font size
        self.bitmap.font.size += 4
        # draw "∞" items left
        self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, '∞', 1)
        # decrease font size
        self.bitmap.font.size -= 4
      else
        # if no items left
        if @items_left == 0
          # set font color
          self.bitmap.font.color = Color.new(255, 0, 0)
        # if equal or less items left
        elsif @items_left <= 10
          # set font color
          self.bitmap.font.color = Color.new(255, 255, 0)
        else
          # set font color
          self.bitmap.font.color = normal_color
        end
        # decrease font color
        self.bitmap.font.size -= 2
        # draw number how many items left to use
        self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, @items_left.to_s, 1)
        # increase font size
        self.bitmap.font.size += 2
      end
    end
  end
  #----------------------------------------------------------------------------
  # update
  #  Checks if HUD needs refreshing.
  #----------------------------------------------------------------------------
  def update
      # if HUD needs refresh
      if $game_temp.hud_refresh
        # draw all data about actor
        (0...@maxpsize).each {|i|
        draw_name(i)
        draw_face(i)
        draw_level(i)
        draw_hp(i)
        draw_sp(i)
        draw_exp(i)
        }
        # remove flag
        $game_temp.hud_refresh = nil
      else
        # draw data that needs to ve updated
        (0...@maxpsize).each {|i|
        test_name(i)
        test_face(i)
        test_level(i)
        test_hp(i)
        test_sp(i)
        test_exp(i)
        }
      end
      # empty HUD wasn't drawn
      @empty_hud_drawn = false
  end
  #----------------------------------------------------------------------------
  # test_face
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_face(i)
    # draw new face if face has changed
   draw_face(i) if actor(i).name != @face[i]
  end
  #----------------------------------------------------------------------------
  # test_exp
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_exp(i)
    # draw new name if name has changed
    draw_exp(i) if actor(i).now_exp != @exp[i] ||
    actor(i).next_exp != @next_exp[i]
  end
  #----------------------------------------------------------------------------
  # test_name
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_name(i)
    # draw new name if name has changed
    draw_name(i) if actor(i).name != @name[i]
  end
  #----------------------------------------------------------------------------
  # test_level
  #  Tests and draws the level.
  #----------------------------------------------------------------------------
  def test_level(i)
    # draw new level if level has changed
    draw_level(i) if actor(i).level != @level[i]
  end
  #----------------------------------------------------------------------------
  # test_hp
  #  Tests and draws the HP.
  #----------------------------------------------------------------------------
  def test_hp(i)
    # draw new HP if HP or max HP have changed
    draw_hp(i) if actor(i).hp != @hp[i] || actor(i).maxhp != @maxhp[i]
  end
  #----------------------------------------------------------------------------
  # test_sp
  #  Tests and draws the SP.
  #----------------------------------------------------------------------------
  def test_sp(i)
    # draw new SP if SP or max SP have changed
    draw_sp(i) if actor(i).sp != @sp[i] || actor(i).maxsp != @maxsp[i]
  end
  #----------------------------------------------------------------------------
  # test_hskill
  #  Tests and draws the hskill.
  #----------------------------------------------------------------------------
  def test_hskill
    # draw new skill icon if assigned skill has changed
    draw_hskill if actor.skill != @skill
  end
  #----------------------------------------------------------------------------
  # test_lskill
  #  Tests and draws the lskill.
  #----------------------------------------------------------------------------
  def test_lskill
    # draw how many skills left to use if this number has changed
    draw_lskill if get_skills_left != @skills_left
  end
  #----------------------------------------------------------------------------
  # test_hitem
  #  Tests and draws the hitem.
  #----------------------------------------------------------------------------
  def test_hitem
    # draw new item icon if assigned item has changed
    draw_hitem if actor.item != @item
  end
  #----------------------------------------------------------------------------
  # test_litem
  #  Tests and draws the litem.
  #----------------------------------------------------------------------------
  def test_litem
    # draw how many items left to use if this number has changed
    draw_litem if $game_party.item_number(@item) != @items_left
  end
  #----------------------------------------------------------------------------
  # actor
  #  Returns the party leader's battler for easier reference.
  #----------------------------------------------------------------------------
  def actor(i)
    return $BlizzABS.battlers[i+1].battler
  end
 
end
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Bitmap
#------------------------------------------------------------------------------
#  Adds gradiant_bar to bitmap.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

class Bitmap

  #----------------------------------------------------------------------------
  # gradient_bar
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - width of the bar to be drawn
  #  color1 - primary color
  #  color2 - secondary color
  #  color3 - back color
  #  rate   - fill rate
  #  This special method is able to draw one out of 7 styles.
  #----------------------------------------------------------------------------
  def gradient_bar(x, y, w, color1, color2, color3, rate, flag = true)
    # stop if not active or out of range
    return unless flag
    return if $game_system.bar_style < 0 || $game_system.bar_style > 6
    # styles with "vertical" black borders
    styles = [1, 3, 4, 5, 6]
    # setup of coordinates and offsets depending on style
    offs = 5
    x += offs
    y += 26
    if styles.include?($game_system.bar_style)
      offs += 2
      y -= 1
      [5, 6].include?($game_system.bar_style) ? y -= 2 :  x += 1
      # quantizes the width so it looks better (remove it and see what happens)
      w = w / 8 * 8
    end
    # temporary variable
    a = $game_system.bar_opacity
    if $game_system.bar_style < 5
      # draw black slanted back
      (0...(offs+3)).each {|i| fill_rect(x-i, y+i-2, w+3, 1, Color.new(0, 0, 0))}
      # draw white slanted back onto black, but let black borders stay
      (0...(offs+1)).each {|i| fill_rect(x-i, y+i-1, w+1, 1, Color.new(255, 255,
      255))}
      if $game_system.bar_style < 2
        # iterate through each vertical bar
        (0...w+offs).each {|i|
            # calculate color
            r = color3.red * i / (w+offs)
            g = color3.green * i / (w+offs)
            b = color3.blue * i / (w+offs)
            # special offset calculation
            oy = i < offs ? offs-i : 0
            off = i < offs ? i : i > w ? w+offs-i : offs
            # draw this part of the bar
            fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
        # if slanted bar is out of critical area
        if (w*rate).to_i >= offs
          # draw the little triangular part on the left
          (0...((w*rate).to_i+offs)).each {|i|
              r = color1.red + (color2.red-color1.red)*i / ((w+offs)*rate)
              g = color1.green + (color2.green-color1.green)*i / ((w+offs)*rate)
              b = color1.blue + (color2.blue-color1.blue)*i / ((w+offs)*rate)
              oy = i < offs ? offs-i : 0
              off = i < offs ? i : i > w*rate ? (w*rate).to_i+offs-i : offs
              fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
        else
          # draw the little triangular part on the left using special method
          (0...(w * rate).to_i).each {|i| (0...offs).each {|j|
              r = color1.red + (color2.red-color1.red)*i / (w*rate)
              g = color1.green + (color2.green-color1.green)*i / (w*rate)
              b = color1.blue + (color2.blue-color1.blue)*i / (w*rate)
              set_pixel(x+i-j+1, y+j-1, Color.new(r, g, b, a))}}
        end
      else
        # iterate through all horizontal lines
        (0...offs).each {|i|
            # calculate colors
            r = color3.red * i / offs
            g = color3.green * i / offs
            b = color3.blue * i / offs
            # draw background line
            fill_rect(x-i+1, y+i-1, w, 1, Color.new(r, g, b, a))}
        if $game_system.bar_style == 4
          # iterate through half of all horizontal lines
          (0...offs/2+1).each {|i|
              # calculate colors
              r = color2.red * (i+1) / (offs/2)
              g = color2.green * (i+1) / (offs/2)
              b = color2.blue * (i+1) / (offs/2)
              # draw bar line
              fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))
              # draw bar line mirrored vertically
              fill_rect(x-offs+i+2, y+offs-i-2, w*rate, 1, Color.new(r, g, b, a))}
        else
          # iterate through all horizontal lines
          (0...offs).each {|i|
              # calculate colors
              r = color1.red + (color2.red-color1.red)*i / offs
              g = color1.green + (color2.green-color1.green)*i / offs
              b = color1.blue + (color2.blue-color1.blue)*i / offs
              # draw bar line
              fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))}
        end
      end
      # if style with black vertical slanted intersections
      if styles.include?($game_system.bar_style)
        # add black bars on 1st and 8th column every 8 pixels
        (0...w).each {|i| (0...offs).each {|j|
            if styles.include?($game_system.bar_style) && i % 8 < 2
              set_pixel(x+i-j+1, y+j-1, Color.new(0, 0, 0, a))
            end}}
      end
    else
      # fill white background
      fill_rect(x+1, y-3, w+2, 12, Color.new(255, 255, 255, a))
      # iterate through each of 6 lines
      (1...6).each {|i|
          # calculate background color
          color = Color.new(color3.red*i/5, color3.green*i/5, color3.blue*i/5, a)
          # draw background
          fill_rect(x+2, y+i-3, w, 12-i*2, color)
          # calculate bar color
          color = Color.new(color2.red*i/5, color2.green*i/5, color2.blue*i/5, a)
          # draw bar
          fill_rect(x+2, y+i-3, w*rate, 12-i*2, color)}
      # if style 5 (with vertical borders)
      if $game_system.bar_style == 5
        # add black bars on 1st and 8th column every 8 pixels
        (0...w/8).each {|i|
            fill_rect(x+2+i*8, y-2, 1, 10, Color.new(0, 0, 0, a))
            fill_rect(x+2+(i+1)*8-1, y-2, 1, 10, Color.new(0, 0, 0, a))}
      end
    end
  end
  #----------------------------------------------------------------------------
  # gradient_bar_hp
  #  actor  - is the actor
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - width of the bar to be drawn
  #----------------------------------------------------------------------------
  def gradient_bar_hp(actor, x, y, w)
    rate = (actor.maxhp > 0 ? actor.hp.to_f / actor.maxhp : 0)
    if rate > 0.6
      color1 = Color.new(80 - 150 * (rate-0.6), 80, 50 * (rate-0.6), 192)
      color2 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
    elsif rate > 0.2 && rate <= 0.6
      color1 = Color.new(80, 200 * (rate-0.2), 0, 192)
      color2 = Color.new(240, 600 * (rate-0.2), 0, 192)
    elsif rate <= 0.2
      color1 = Color.new(400 * rate, 0, 0, 192)
      color2 = Color.new(240, 0, 0, 192)
    end
    color3 = Color.new(0, 80, 0, 192)
    self.gradient_bar(x,y,w,color1,color2,color3,rate)
  end
  #----------------------------------------------------------------------------
  # gradient_bar_sp
  #  actor  - is the actor
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - width of the bar to be drawn
  #----------------------------------------------------------------------------
  def gradient_bar_sp(actor, x, y, w)
    rate = (actor.maxsp > 0 ? actor.sp.to_f / actor.maxsp : 0)
    if rate > 0.4
      color1 = Color.new(60 - 66 * (rate-0.4), 20, 80, 192)
      color2 = Color.new(180 - 200 * (rate-0.4), 60, 240, 192)
    elsif rate <= 0.4
      color1 = Color.new(20 + 100 * rate, 50 * rate, 26 + 166 * rate, 192)
      color2 = Color.new(60 + 300 * rate, 150 * rate, 80 + 400 * rate, 192)
    end
    color3 = Color.new(0, 80, 0, 192)
    self.gradient_bar(x,y,w,color1,color2,color3,rate)
  end
  #----------------------------------------------------------------------------
  # gradient_bar_hp
  #  actor  - is the actor
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - width of the bar to be drawn
  #---------------------------------------------------------------------------- 
  def gradient_bar_exp(actor, x, y, w)
    rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
    if rate < 0.5
      color1 = Color.new(20 * rate, 60, 80, 192)
      color2 = Color.new(60 * rate, 180, 240, 192)
    elsif rate >= 0.5
      color1 = Color.new(20 + 120 * (rate-0.5), 60 + 40 * (rate-0.5), 80, 192)
      color2 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
    end
    color3 = Color.new(0, 80, 0, 192)
    self.gradient_bar(x,y,w,color1,color2,color3,rate)
  end
  #----------------------------------------------------------------------------
  # gradient_bar_overdrive
  #  actor  - is the actor
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - width of the bar to be drawn
  #----------------------------------------------------------------------------
  def gradient_bar_overdrive(actor, x, y, w)
    rate = actor.overdrive.to_f / 1000
    color1 = Color.new(80, 0, 0, 192)
    color2 = Color.new(240, 0, 0, 192)
    color3 = Color.new(80, 0, 0, 192)
    self.gradient_bar(x, y, w, color1, color2, color3, rate)
  end
 
end
#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor
 
  #----------------------------------------------------------------------------
  # now_exp
  #  Returns the EXP collected in this level.
  #----------------------------------------------------------------------------
  def now_exp
    return @exp - @exp_list[@level]
  end
  #----------------------------------------------------------------------------
  # next_exp
  #  Returns the EXP needed to level up as number.
  #----------------------------------------------------------------------------
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
 
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script