The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: ixis on November 28, 2006, 06:18:26 PM

Title: Health and Magic bar RGB values are where now?
Post by: ixis on November 28, 2006, 06:18:26 PM
Heya,

I want to customize the coloring of my HP and MP bars but I can't find the RGB values in the scrpits. Which script stores these values and what line (if you know it)?

Thanks in advance.
Title: Re: Health and Magic bar RGB values are where now?
Post by: Falcon on November 28, 2006, 08:27:00 PM
Post your bar script, RMXP has no default bar scripts built in.
Title: Re: Health and Magic bar RGB values are where now?
Post by: ixis on November 28, 2006, 08:29:59 PM
I don't have a bar script, I wanted to edit the script already in RMXP. I figured it would be using a hex-code for the color values instead of a .png, and if I could find where those hex-values are stored in RMXP's script database I could change them myself.
Title: Re: Health and Magic bar RGB values are where now?
Post by: Falcon on November 28, 2006, 08:36:53 PM
There is no HP/MP script built in with RMXP. If there was, there wouldn't be so many bar scripts :P
Title: Re: Health and Magic bar RGB values are where now?
Post by: ixis on November 28, 2006, 08:45:17 PM
Well then, how does RMXP generate it's HP/MP bars? ??? There has to be some code somewhere that tells the computer how to draw out the bars. Is it just not available for edit in the ruby script?
Title: Re: Health and Magic bar RGB values are where now?
Post by: Falcon on November 28, 2006, 08:46:34 PM
It's not built in, that's all, you need to put a script in to use bars.
If your game has bars, look in the script database and find the script.
Title: Re: Health and Magic bar RGB values are where now?
Post by: ixis on November 28, 2006, 08:49:34 PM
Ok, thanks.

EDIT: Still looking for the script. Just to make sure though, I'm talking about the standard HP/MP bars,

Image here (http://studentpages.scad.edu/~kcampb22/whatimean.tif) (Tiff was the best I could do on this old computer without Photoshop/PSP.)

There's nothing customized about them except Blizzard's Add-on script that changes the shape. I'm going to look through his script again and see if there's RGB values I can tinker around with. Other than that, if Blizzard's script can edit the HP/MP bars then it means that script is affecting another script elsewhere. Another script that controls the way RMXP displays HP/MP. If this is the case I'm willing to bet there's a RGB hex code somewhere that dictates the green and blue values of the bars (I want to change them to Red and Black to better fit my style of game.)
Title: Re: Health and Magic bar RGB values are where now?
Post by: &&&&&&&&&&&&& on November 28, 2006, 09:18:34 PM
does you mean in the menu?
Title: Re: Health and Magic bar RGB values are where now?
Post by: ixis on November 28, 2006, 09:23:02 PM
Quote from: BanisherOfEden on November 28, 2006, 09:18:34 PM
does you mean in the menu?

Precisely my good sir.
Title: Re: Health and Magic bar RGB values are where now?
Post by: Falcon on November 28, 2006, 09:25:12 PM
Post the script here and I'll edit it for you.
Title: Re: Health and Magic bar RGB values are where now?
Post by: ixis on November 28, 2006, 09:32:47 PM
Ok, but it's BLizzard's script, not mine. The specific code is:

#==============================================================================
# Blizz-Art Gradient styler with HP/SP/EXP bars by Blizzard
# Version: 4.0
# Date: 13.11.2006
#
# 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
#==============================================================================

if TONS_OF_ADDONS::BARS

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  attr_accessor :bar_style
  attr_reader   :bar_opacity
 
  alias init_blizzart_later initialize
  def initialize
    init_blizzart_later
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#
# Configure this part manually if you have no "Options" controller for the
# styles and the opacity. (style: 0~5, opacity: 0~256)
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    @bar_style = 2
    @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)
    styles = [1, 3, 4, 5]
    rx = color3.red
    gx = color3.green
    bx = color3.blue
    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 = (r + r_rate) * (i+1) / (offset / 2)
              green = (g + g_rate) * (i+1) / (offset / 2)
              blue = (b + b_rate) * (i+1) / (offset / 2)
            else
              red = (r + r_rate) * (offset+1-i) / (offset / 2 + 1)
              green = (g + g_rate) * (offset+1-i) / (offset / 2 + 1)
              blue = (b + b_rate) * (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 = rx * (i+1) / 5
          green = gx * (i+1) / 5
          blue = bx * (i+1) / 5
        else
          red = rx * (11-i) / 6
          green = gx * (11-i) / 6
          blue = bx * (11-i) / 6
        end
        fill_rect(x+2, y+i-2, w, 1, Color.new(red, green, blue, alpha))
        if i < 5
          red = (r + r_rate) * (i+1) / 5
          green = (g + g_rate) * (i+1) / 5
          blue = (b + b_rate) * (i+1) / 5
        else
          red = (r + r_rate) * (11-i) / 6
          green = (g + g_rate) * (11-i) / 6
          blue = (b + b_rate) * (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+2+(i+1)*8-1, 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
    rate = actor.hp.to_f / actor.maxhp
    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
    rate = actor.sp.to_f / actor.maxsp
    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
 
end

end


Hope that helps. :(
Title: Re: Health and Magic bar RGB values are where now?
Post by: Blizzard on November 29, 2006, 08:07:20 AM
All the methods like:

alias draw_actor_sp_blizzart_later draw_actor_sp
  def draw_actor_sp(actor, x, y, w = 148)
    w -= 12
    rate = actor.sp.to_f / actor.maxsp
    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


You need to mod the Color.new(R, G, B, A) according to the rate to affect gradiating. The style inside determines how the colors are drawn while the colors themselves can be changed in these methods. Have fun editing it, Darklord. ;)