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.

Could someone make this happen?

I found a nice bar script on RMRK. I would like to have it made compatible with DerVVulfman's Limit System.
Code:
#==============================================================================
# Blizz-Art Gradient styler with HP/SP/EXP bars by Blizzard
# Version: 4.2b
# Date v4.0: 13.11.2006
# Date v4.11: 12.1.2007
# Date v4.2b: 12.3.2007
# 
# 
# v2.0+
# - 2 styles, better code
# v3.0+
# - 6 styles, far better code
# v4.0+
# - 6 styles, overworked and extremely delagged, enjoy the most lagless
#   gradient/slant bar code ever
# v4.11
# - added instructions and a recognition constant for plugins
# v4.2b
# - improved code
# 
# 
# Instructions:
# 
# You can change style and opacity by using the "Call script" event command.
# Use one of of these syntaxes:
# 
# $game_system.bar_style = X
# $game_system.bar_opacity = Y
# 
# X is a number from 0 to 5 and is the ID number of the style. Y is a number
# from 0 to 255 and indicates the opacity. Values out of range will be
# corrected.
#==============================================================================
#==============================================================================
# Game_System
#==============================================================================

class Game_System
  
  attr_accessor :bar_style
  attr_reader   :bar_opacity
  
  alias init_blizzart initialize
  def initialize
    init_blizzart
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
# 
# Configure this part manually if you have no "Options" controller for the
# styles and the opacity. (style: 0~5, opacity: 0~256) (256 is the same as 255)
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    @bar_style = 5
    @bar_opacity = 256
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  end
  
  def bar_opacity=(alpha)
    if alpha > 256
      alpha = 256
    elsif alpha < 0
      alpha = 0
    end
    @bar_opacity = alpha
  end  
end

#==============================================================================
# Game_Actor 
#==============================================================================

class Game_Actor < Game_Battler 
  
  def now_exp 
    return @exp - @exp_list[@level] 
  end   
  def next_exp 
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end   
end

#==============================================================================
# Bitmap
#==============================================================================

class Bitmap

  def gradient_bar(x, y, w, color1, color2, color3, rate)
    return if $game_system.bar_style < 0 or $game_system.bar_style > 5
    styles = [1, 3, 4, 5]
    offset = 5
    x += offset
    y += 26
    if styles.include?($game_system.bar_style)
      offset += 2
      w = w / 8 * 8
      y -= 1
      if $game_system.bar_style == 5
        y -= 2
      else
        x += 1
      end
    end
    r = color1.red
    g = color1.green
    b = color1.blue
    r_rate = color2.red - r
    g_rate = color2.green - g
    b_rate = color2.blue - b
    alpha = $game_system.bar_opacity
    return if alpha == 0
    alpha -= 1 if alpha == 256
    if $game_system.bar_style < 5
      for i in 0...(offset+3)
        fill_rect(x-i, y+i-2, w+3, 1, Color.new(0, 0, 0, 255))
      end
      for i in 0...(offset+1)
        fill_rect(x-i, y+i-1, w+1, 1, Color.new(255, 255, 255, 255))
      end
      if $game_system.bar_style < 2
        for i in 0...(w+offset)
          red = color3.red * i / (w + offset)
          green = color3.green * i / (w + offset)
          blue = color3.blue * i / (w + offset)
          oy = i < offset ? offset-i : 0
          off = i < offset ? i : i > w ? w+offset-i : offset
          fill_rect(x+i-offset+1, y+oy-1, 1, off, Color.new(red, green, blue, alpha))
        end
        if (w*rate).to_i >= offset
          for i in 0...((w*rate).to_i+offset)
            red = r + r_rate * i / ((w + offset)*rate)
            green = g + g_rate * i / ((w + offset)*rate)
            blue = b + b_rate * i / ((w + offset)*rate)
            oy = i < offset ? offset-i : 0
            off = i < offset ? i : i > w*rate ? (w*rate).to_i+offset-i : offset
            fill_rect(x+i-offset+1, y+oy-1, 1, off, Color.new(red, green, blue, alpha))
          end
        else
          for i in 0...(w*rate).to_i
            for j in 0...offset
              red = r + r_rate * i / (w * rate)
              green = g + g_rate * i / (w * rate)
              blue = b + b_rate * i / (w * rate)
              set_pixel(x+i-j+1, y+j-1, Color.new(red, green, blue, alpha))
            end
          end
        end
      else
        for i in 0...offset
          red = color3.red * i / offset
          green = color3.green * i / offset
          blue = color3.blue * i / offset
          fill_rect(x-i+1, y+i-1, w, 1, Color.new(red, green, blue, alpha))
          if $game_system.bar_style == 4
            if i < offset / 2
              red = color2.red * (i+1) / (offset/2) 
              green = color2.green * (i+1) / (offset/2)
              blue = color2.blue * (i+1) / (offset/2)
            else
              red = color2.red * (offset+1-i) / (offset/2 + 1)
              green = color2.green * (offset+1-i) / (offset/2 + 1)
              blue = color2.blue * (offset+1-i) / (offset/2 + 1) 
            end
          else
            red = r + r_rate * i / offset
            green = g + g_rate * i / offset
            blue = b + b_rate * i / offset
          end
          fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(red, green, blue, alpha))
        end
      end
      if styles.include?($game_system.bar_style)
        for i in 0...w
          for j in 0...offset
            if styles.include?($game_system.bar_style) and i % 8 < 2
              set_pixel(x+i-j+1, y+j-1, Color.new(0, 0, 0, alpha))
            end
          end
        end
      end
    else
      fill_rect(x+1, y-3, w+2, 12, Color.new(255, 255, 255, 192))
      for i in 0...10
        if i < 5
          red = color3.red * (i+1) / 5
          green = color3.green * (i+1) / 5
          blue = color3.blue * (i+1) / 5
        else
          red = color3.red * (11-i) / 6
          green = color3.green * (11-i) / 6
          blue = color3.blue * (11-i) / 6
        end
        fill_rect(x+2, y+i-2, w, 1, Color.new(red, green, blue, alpha))
        if i < 5
          red = color2.red * (i+1) / 5
          green = color2.green * (i+1) / 5
          blue = color2.blue * (i+1) / 5
        else
          red = color2.red * (11-i) / 6
          green = color2.green * (11-i) / 6
          blue = color2.blue * (11-i) / 6
        end
        fill_rect(x+2, y+i-2, w*rate, 1, Color.new(red, green, blue, alpha))
      end
      for i in 0...w/8
        fill_rect(x+2+i*8, y-2, 1, 10, Color.new(0, 0, 0, alpha))
        fill_rect(x+9+i*8, y-2, 1, 10, Color.new(0, 0, 0, alpha))
      end
    end
  end  
end

#==============================================================================
# Window_Base
#==============================================================================

class Window_Base < Window

  alias draw_actor_hp_blizzart_later draw_actor_hp
  def draw_actor_hp(actor, x, y, w = 148)
    w -= 12
    if actor.maxhp > 0
      rate = actor.hp.to_f / actor.maxhp
    else
      rate = 0
    end
    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 and 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.contents.gradient_bar(x, y, w, color1, color2, color3, rate)
    if $scene.is_a?(Scene_Battle)
      draw_actor_hp_blizzart_later(actor, x, y, w)
    else
      draw_actor_hp_blizzart_later(actor, x, y)
    end
  end

  alias draw_actor_sp_blizzart_later draw_actor_sp
  def draw_actor_sp(actor, x, y, w = 148)
    w -= 12
    if actor.maxsp > 0
      rate = actor.sp.to_f / actor.maxsp
    else
      rate = 0
    end
    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, 0, 80, 192) 
    self.contents.gradient_bar(x, y, w, color1, color2, color3, rate)
    if $scene.is_a?(Scene_Battle)
      draw_actor_sp_blizzart_later(actor, x, y, w)
    else
      draw_actor_sp_blizzart_later(actor, x, y)
    end
  end

  alias draw_actor_exp_blizzart_later draw_actor_exp
  def draw_actor_exp(actor, x, y, w = 148)
    w += 12
    if actor.next_exp != 0 
      rate = actor.now_exp.to_f / actor.next_exp 
    else 
      rate = 1 
    end 
    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(80, 80, 80, 192) 
    self.contents.gradient_bar(x, y, w, color1, color2, color3, rate)
    draw_actor_exp_blizzart_later(actor, x, y)
  end

If this could be done, I'd be really grateful, as these bars look really good in game.
Thanks again,

A.
 
Paste this below the bar script. It take advantage of the config and bar drawing routines already in place.

Code:
#==============================================================================
# Window_Base
#==============================================================================

class Window_Base < Window
  def draw_actor_lb(actor, x, y, w = 148)
    w -= 12
    if actor.limitbreak > 0
      rate = actor.limitbreak.to_f / LB_MAX
    else
      rate = 0
    end
    color1 = Color.new(255 + (100 * rate), 155 - (100 * rate), 0, 192)
    color2 = Color.new(155 + (100 * rate), 155 - (100 * rate), 0, 192)
    color3 = Color.new(0, 80, 0, 192)
    self.contents.gradient_bar(x, y, w, color1, color2, color3, rate)
  end
end
 

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