Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Submission: Slanted Hp,Sp,Exp, and parameters, Slanted bars by sephirothspawn
jens009
post Jul 2 2007, 10:20 PM
Post #1


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




This is perhaps the coolest hp and sp bars customization script out there! Not to mention the most famous one. Anyway, this script should be self explanatory. It creates slanted hp, sp, exp and parameter bars.

Script Title: SephirothSpawn's Slanted Bars
Script Version: Not Specified
Author:SephirothSpawn

Description: Draws a slanted bars to indicate HP,SP,EXP and parameters. Think of how final fantasy X bars look like. Colors are completely customizable and the script itself could make slanted bars for other scripts that require one or is able to have one.

Screenshots: From my game but just look at the slanted hp, sp and limit break bars.

CODE
class Window_Base < Window  
  
  alias raz_bars_base_exp draw_actor_exp
  alias raz_bars_base_parameter draw_actor_parameter
  
  #--------------------------------------------------------------------------
  # * Draw Slant Bar(by SephirothSpawn)
  #--------------------------------------------------------------------------
  def draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # * Draw HP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    
    if $game_temp.in_battle
      bar_width = hp_x - x + 50
      else
      bar_width = hp_x - x + 100
    end

    # Draw HP
    draw_slant_bar(x, y + 18, actor.hp, actor.maxhp, bar_width, 6, bar_color = Color.new(100, 0, 0, 255), end_color = Color.new(255, 0, 0, 255))
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    # Draw MaxHP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    # Calculate if there is draw space for MaxHP
    
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    
    if $game_temp.in_battle
      bar_width = sp_x - x + 50
      else
      bar_width = sp_x - x + 100
    end

    # Draw SP
    draw_slant_bar(x, y + 18, actor.sp, actor.maxsp, bar_width, 6, bar_color = Color.new(0, 0, 100, 255), end_color = Color.new(0, 0, 255, 255))
    # Draw "SP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    # Draw MaxSP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end
  end

  def draw_actor_exp(actor, x, y)
    if actor.level == 99
    draw_slant_bar(x, y + 18, 1, 1, 190, 6, bar_color = Color.new(0, 100, 0, 255), end_color = Color.new(0, 255, 0, 255))
      else
    draw_slant_bar(x, y + 18, actor.now_exp, actor.next_exp, 190, 6, bar_color = Color.new(0, 100, 0, 255), end_color = Color.new(0, 255, 0, 255))
    end
    raz_bars_base_exp(actor, x, y)
  end
  

    def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      para_color1 = Color.new(100,0,0)
      para_color2 = Color.new(255,0,0)
      para_begin = actor.atk
    when 1
      para_color1 = Color.new(100,100,0)
      para_color2 = Color.new(255,255,0)
      para_begin = actor.pdef
    when 2
      para_color1 = Color.new(100,0,100)
      para_color2 = Color.new(255,0,255)
      para_begin = actor.mdef
    when 3
      para_color1 = Color.new(50,0,100)
      para_color2 = Color.new(50,0,255)
      para_begin = actor.str
    when 4
      para_color1 = Color.new(0,100,0)
      para_color2 = Color.new(0,255,0)
      para_begin = actor.dex
    when 5
      para_color1 = Color.new(50,0,50)
      para_color2 = Color.new(255,0,255)
      para_begin = actor.agi
    when 6
      para_color1 = Color.new(0,100,100)
      para_color2 = Color.new(0,255,255)
      para_begin = actor.int
    end
    draw_slant_bar(x, y + 18, para_begin, 999, 155, 4, bar_color = para_color1, end_color = para_color2)
    raz_bars_base_parameter(actor, x, y, type)
  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
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
end


Instructions:Copy the script and paste above main. To further modify the colors, look at the color.new sections of the scripts. To add bars for other uses, use the template of draw_slant_bar(x, y, min, max, width = 152, height = 6). Other than that, the script is pretty much plug and play

Demo Link: This is a waste of bandwidth and time don't you think? Seriously. The script itself is 1kb.

Compatibiliy: The script is expected to be compatible with anything except for scripts that modify the bars too, or uses the same aliases. Which is highly unlikely, I mean... Who would want a slanted bar script with a non slanted bar script? The only way this thing could be incompatible is after you have messed around with the scripts enough I believe.

Credits and Thanks:SephirotSpawn for making the script, Raziel for support with the creation of the script and me I suppose for submitting it in.

This post has been edited by jens009: Jul 14 2007, 11:50 AM


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
tehpwnz
post Sep 15 2008, 11:44 PM
Post #2


Level 1
Group Icon

Group: Member
Posts: 8
Type: Event Designer
RM Skill: Skilled




Hey this is pretty cool. You said that its a ss from your game? I like your menu/ layout. what is it?

Go to the top of the page
 
+Quote Post
   
Blizzard
post Sep 16 2008, 04:52 AM
Post #3


Where am I?
Group Icon

Group: Revolutionary
Posts: 613
Type: Scripter
RM Skill: Masterful




Is this a new version or still the old laggy one unlike mine? I assume the latter. tongue.gif


__________________________


Please keep in mind that I have retired from RMXP and that I am not active here anymore! If you can't get any support for my scripts here, try at Chaos Project.
Go to the top of the page
 
+Quote Post
   
Dario8676
post Sep 18 2008, 05:09 PM
Post #4


Level 1
Group Icon

Group: Member
Posts: 8
Type: None
RM Skill: Undisclosed




what's the syntax to add a slanted bar through the call script command in the event editor?
Go to the top of the page
 
+Quote Post
   
jens009
post Dec 21 2008, 11:09 AM
Post #5


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




@dario:
You have to manually change them to follow this format:
CODE
draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))

For example the hp bar follows this format
CODE
    draw_slant_bar(x, y + 18, actor.hp, actor.maxhp, bar_width, 6, bar_color = Color.new(100, 0, 0, 255), end_color = Color.new(255, 0, 0, 255))


QUOTE (Blizzard @ Sep 16 2008, 04:52 AM) *
Is this a new version or still the old laggy one unlike mine? I assume the latter. tongue.gif

Blizzard, it's the old laggy one.
Do you mind posting your version?


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
Blizzard
post Dec 21 2008, 11:30 AM
Post #6


Where am I?
Group Icon

Group: Revolutionary
Posts: 613
Type: Scripter
RM Skill: Masterful




It's included in Tons of Add-ons already. smile.gif But here's the code for the bars if somebody wants to compare:

CODE
#==============================================================================
# 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 = false)
    # stop if not active or out of range
    return unless $game_system.BARS || 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
  
end


This is for all 7 styles, not just the slant (I should probably refactor the code and make 7 methods instead >.< ). I used a little trick to avoid lag when drawing. The gradient is actually not slanted, but it can't be noticed. wink.gif


__________________________


Please keep in mind that I have retired from RMXP and that I am not active here anymore! If you can't get any support for my scripts here, try at Chaos Project.
Go to the top of the page
 
+Quote Post
   
jens009
post Dec 21 2008, 11:39 AM
Post #7


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Perfect! I love how you reduce lag with your nifty ways. XD

Speaking of Tons of Add-ons, I'm currently updating the forums RGSS script listings. As I go through the 15 pages of scripts (currently on page 4), I noticed that you continuously point to many members to use your Tons of Add-ons script.

If you haven't made an official thread for it in RRR, can you make one? That way I can make an official link for the Tons of Add Ons script in the RGSS scripting list.

Thanks once again for updating the slanted bars script.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
xenos922
post Dec 23 2008, 09:21 AM
Post #8



Group Icon

Group: Member
Posts: 2
Type: Artist
RM Skill: Undisclosed




Hey, I was wondering if someone would help me? I'm kind of new to all this scripting stuff and this one seemed pretty straight forward but I'm getting an error. I copied the code and pasted it above main but I get this error when trying to start my game. "undefined method 'draw_actor_exp' for class 'Window_Base' . Also, how would I add in that add-on posted above to get rid of the lag? Thanks!
Go to the top of the page
 
+Quote Post
   
jens009
post Dec 23 2008, 10:35 AM
Post #9


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




QUOTE (xenos922 @ Dec 23 2008, 09:21 AM) *
Hey, I was wondering if someone would help me? I'm kind of new to all this scripting stuff and this one seemed pretty straight forward but I'm getting an error. I copied the code and pasted it above main but I get this error when trying to start my game. "undefined method 'draw_actor_exp' for class 'Window_Base' . Also, how would I add in that add-on posted above to get rid of the lag? Thanks!

The error is saying that there is no draw_actor_exp method for the window base class. I'm really not sure why this error is occuring because draw_actor_exp is a default method for the RMXP. All this script is doing is that it is redrawing that method.

Are you sure you are using RMXP? Because this script is an add on for RMXP only. If you do want it for RMVX, you have to do slight modifications to the script which isn't that difficult.

Regardless, try making a new project and paste the script once again above main. Save your game and try it again.

As for your second concern, the post made by Blizzard is the alternative script. If you don't have enough scripting experience, I wouldn't recommend to use that one since you have to do more modifications in thw Window_Base class.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
xenos922
post Dec 23 2008, 12:10 PM
Post #10



Group Icon

Group: Member
Posts: 2
Type: Artist
RM Skill: Undisclosed




Oh I figured it out. Just a small stupid error on my behalf. I have some scripting experience. I'm just sort of new as to how it works with RMXP. But I think I have it all figured out now. Everything works perfectly now. Thanks. smile.gif
Go to the top of the page
 
+Quote Post
   
Alex898
post Mar 25 2009, 07:26 PM
Post #11


Level 7
Group Icon

Group: Revolutionary
Posts: 100
Type: Developer
RM Skill: Skilled




I like this script but it gives me alot of lag. Sorry if this is a dumb question, but where do I paste the add-on so there is less lag? I tried pasting it in the script but it didn't have any effect..


__________________________

COMPLETE 25 hour long RPG Adventure! Check it out!



My Youtube Page

My IMDB Page
Go to the top of the page
 
+Quote Post
   
jens009
post Mar 31 2009, 09:43 PM
Post #12


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




QUOTE (Alex898 @ Mar 25 2009, 08:26 PM) *
I like this script but it gives me alot of lag. Sorry if this is a dumb question, but where do I paste the add-on so there is less lag? I tried pasting it in the script but it didn't have any effect..

The modifications have to be made on your own.
Luckily, I did it for you. =p
[Show/Hide] Blizzard's Slanted Bars

CODE
#==============================================================================
# Game_System
#==============================================================================

class Game_System
  
  alias init_tons_of_addons1_later initialize
  def initialize
    init_tons_of_addons1_later
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration 1-2, GRAPHIC add-ons
#
#   You can enable/disable any add-on here if you wish. Set the value to false
#   to disable it initially. To turn it on/off ingame, just use the Call script
#   command with one of these syntaxes:
#
#     $game_system.NAME_OF_THE_ADDON = true
#     $game_system.NAME_OF_THE_ADDON = false
#
#   where NAME_OF_THE_ADDON is the same variable as the one used below.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    @BARS                       = true
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration 1-2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  end
  
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# It is recommended that you don't edit anything below this line except for
# the configurations for the add-ons.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  attr_accessor :BARS

  
end


#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Blizz-Art Gradient Styler with HP/SP/EXP bars by Blizzard
# Version: 4.51b
# Type: Game Playability Improvement
# Date v4.0: 13.11.2006
# Date v4.11: 12.1.2007
# Date v4.2b: 12.3.2007
# Date v4.4b: 14.7.2007
# Date v4.41b: 23.10.2007
# Date v4.5b: 25.10.2007
# Date v4.51b: 28.1.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# new in v2.x:
#   - 2 styles, better code
#
# new in v3.x:
#   - 6 styles, far better code
#
# new in v4.0:
#   - 6 styles, overworked and extremely delagged, enjoy the most lagless
#     gradient/slant bar code ever
#
# new in v4.11:
#   - added instructions and a recognition constant for plugins
#
# new in v4.2b:
#   - improved code
#
# new in v4.4b:
#   - improved code, now 7 styles
#
# new in v4.41b:
#   - resolved issue
#
# new in v4.5b:
#   - improved coding
#   - removed drawing glitch that was caused by using a variable name shorter
#     than 4 letters
#
# new in v4.51b:
#   - fixed glitch with StormTronics CMS
#
#
# 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 - number from 0 to 6 and is the ID number of the style
#   Y - number from 0 to 255 and indicates the opacity
#  
#   Values out of range will be corrected.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

$Blizz_Art = true

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

class Game_System
  
  attr_accessor :bar_style
  attr_reader   :bar_opacity
  #----------------------------------------------------------------------------
  # initialize
  #  Added bar style variables.
  #----------------------------------------------------------------------------
  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~6, opacity: 0~255)
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    @bar_style = 3
    self.bar_opacity = 155
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  end
  #----------------------------------------------------------------------------
  # bar_opacity=
  #  alpha - opacity
  #  Encapsulation and range limitation of opacity.
  #----------------------------------------------------------------------------
  def bar_opacity=(alpha)
    @bar_opacity = [[alpha, 0].max, 255].min
  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

#==============================================================================
# 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 = false)
    # stop if not active or out of range
    return unless $game_system.BARS || 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
  
end


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

class Window_Base

  #----------------------------------------------------------------------------
  # draw_actor_hp
  #  actor - the actor
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - reserved max width
  #  Added fill rate calculation and bar drawing.
  #----------------------------------------------------------------------------
  alias draw_actor_hp_blizzart_later draw_actor_hp
  def draw_actor_hp(actor, x, y, w = 148)
    if $game_system.BARS
      # RTAB compatibility fix
      if !(defined? Window_DetailsStatus) || !self.is_a?(Window_DetailsStatus)
        w -= 12
      end
      # calculate bar fill rate
      rate = (actor.maxhp > 0 ? actor.hp.to_f / actor.maxhp : 0)
      # create colors depending on rate
      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
      # background color
      color3 = Color.new(0, 80, 0, 192)
      # draw bar with coordinates and colors
      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
    else
      draw_actor_hp_blizzart_later(actor, x, y, w)
    end
  end
  #----------------------------------------------------------------------------
  # draw_actor_sp
  #  actor - the actor
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - reserved max width
  #  Added fill rate calculation and bar drawing.
  #----------------------------------------------------------------------------
  alias draw_actor_sp_blizzart_later draw_actor_sp
  def draw_actor_sp(actor, x, y, w = 148)
    if $game_system.BARS
      # RTAB compatibility fix
      if !(defined? Window_DetailsStatus) || !self.is_a?(Window_DetailsStatus)
        w -= 12
      end
      # calculate bar fill rate
      rate = (actor.maxsp > 0 ? actor.sp.to_f / actor.maxsp : 0)
      # create colors depending on rate
      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
      # background color
      color3 = Color.new(0, 0, 80, 192)
      # draw bar with coordinates and colors
      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
    else
      draw_actor_sp_blizzart_later(actor, x, y, w)
    end
  end
  #----------------------------------------------------------------------------
  # draw_actor_exp
  #  actor - the actor
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - reserved max width
  #  Added fill rate calculation and bar drawing.
  #----------------------------------------------------------------------------
  alias draw_actor_exp_blizzart_later draw_actor_exp
  def draw_actor_exp(actor, x, y, w = 148)
    if $game_system.BARS
      w += 12
      # calculate bar fill rate
      rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
      # create colors depending on rate
      if rate < 0.4
        color1 = Color.new(20 * rate, 60, 80, 192)
        color2 = Color.new(60 * rate, 180, 240, 192)
      elsif rate >= 0.4
        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
      # background color
      color3 = Color.new(80, 80, 80, 192)
      # draw bar with coordinates and colors
      self.contents.gradient_bar(x, y, w, color1, color2, color3, rate)
    end
    draw_actor_exp_blizzart_later(actor, x, y)
  end    
end



__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
vvalkingman
post Apr 9 2009, 09:56 AM
Post #13


The Traveling Bard ;)
Group Icon

Group: Revolutionary
Posts: 210
Type: Developer
RM Skill: Intermediate




ok ive plugged in your script and it pulls up fine. By plugging it in, I mean that I created a new script above "Main" and threw in your script(not blizzard's) and for some reason I get this:


Which is cool and all but the EXP isnt filling correctly. I then went and battled alittle bit to see if it would improve as the game progressed and this is what i got:


I'm not using any other scripts so there shouldnt be anything conflicting with it. Any ideas? Btw HP and SP work perfectly.


__________________________

Thank you X-M-O for my sexy new banner! ;)

Project I'm currently racking my brain on:
"Modern Witch" Project(tentative name): 5% done
Goshiki: The Five Paths: 40% done

Projects on the backburner:
The Great Thief of Mango City: 5% done
Knights of the Black Gate: 10% done
The Venting: 74% done
Go to the top of the page
 
+Quote Post
   
jens009
post Apr 9 2009, 04:54 PM
Post #14


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Hmm.. I'm not quite sure what the problem is. Are you sure you loaded up a New Game instead of a Continued game?
If that doesn't fix the problem, try using the script above your post.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
vvalkingman
post Apr 14 2009, 02:38 PM
Post #15


The Traveling Bard ;)
Group Icon

Group: Revolutionary
Posts: 210
Type: Developer
RM Skill: Intermediate




QUOTE (jens009 @ Apr 9 2009, 05:54 PM) *
Hmm.. I'm not quite sure what the problem is. Are you sure you loaded up a New Game instead of a Continued game?
If that doesn't fix the problem, try using the script above your post.


Sorry it took so long for me to answer. Yes I have been starting a New Game each time I test. And when I put in the code that was above my last post, I encountered the same issue. I thought that perhaps it had something to do with my characters not starting at lvl 1. So i did a test with that and it looked ok, but when I gained xp from a monster fight I received 1000 XP and I was only 100xp away from my next level but according to the xp bar I was only about 1/4th of my way into my level o_O just like how my last post discribed. It's weird. Any ideas? (Again I am not using any other scripts, this is a new game)


__________________________

Thank you X-M-O for my sexy new banner! ;)

Project I'm currently racking my brain on:
"Modern Witch" Project(tentative name): 5% done
Goshiki: The Five Paths: 40% done

Projects on the backburner:
The Great Thief of Mango City: 5% done
Knights of the Black Gate: 10% done
The Venting: 74% done
Go to the top of the page
 
+Quote Post
   
vvalkingman
post Apr 15 2009, 05:55 AM
Post #16


The Traveling Bard ;)
Group Icon

Group: Revolutionary
Posts: 210
Type: Developer
RM Skill: Intermediate




o_o Ok Im an idiot. The 2500/2700 thing was throwing me off lol I was like "im about to lvl why is the bar at the beginning like that?!" sooooo yea, thanks it works fine ^^


__________________________

Thank you X-M-O for my sexy new banner! ;)

Project I'm currently racking my brain on:
"Modern Witch" Project(tentative name): 5% done
Goshiki: The Five Paths: 40% done

Projects on the backburner:
The Great Thief of Mango City: 5% done
Knights of the Black Gate: 10% done
The Venting: 74% done
Go to the top of the page
 
+Quote Post
   
vvalkingman
post Apr 15 2009, 06:17 AM
Post #17


The Traveling Bard ;)
Group Icon

Group: Revolutionary
Posts: 210
Type: Developer
RM Skill: Intermediate




Here is another question though. Is there a way to remove the xp numbers from the menu_status screen? I'm talking about the whole "2405/2629" on top of the experience bar when you first open the status menu, like you see here:


Thank you for all of your help!

-Will


__________________________

Thank you X-M-O for my sexy new banner! ;)

Project I'm currently racking my brain on:
"Modern Witch" Project(tentative name): 5% done
Goshiki: The Five Paths: 40% done

Projects on the backburner:
The Great Thief of Mango City: 5% done
Knights of the Black Gate: 10% done
The Venting: 74% done
Go to the top of the page
 
+Quote Post
   
samsonite789
post Sep 20 2009, 11:43 AM
Post #18



Group Icon

Group: Member
Posts: 3
Type: Event Designer
RM Skill: Beginner




Hello,

I just recently got back in RMXP. This is a great script and I love how it looks, but there's one thing I just can't figure out. I'm using Animated Battlers, RTAB, and Battle Status Modification (Basically mimicking FF side view) and I just want to resize and move the slanted bars. When I change the width or the x location of the ATG, however, the actual gauge itself moves (that is, the part that fills up), but the empty background bar stays at the same width and x, y coordinates. I've tried everything I can think of, but I can't seem to change where the empty background bar goes.

Could you help a poor little newb figure out how to change the size and location of the entire gauge?

Thanks!

EDIT:

Sooo, I actually just answered my own question. Let's hear it for tenacity!

In case anyone else has the same question, here's the answer:


Changing ATG width (Using RTAB 1.16, Battle Status Modifications, and of course the Seph Slant Bar script):

1. Be sure to place SlantBar Modification ABOVE the Battle Status Modification
2. Go to Battle Status Modification
3. Find the class Window_DetailsStatus
4. Find the refresh method (def refresh)
5. Depending on whether you are drawing text left to right and whether or not you are displaying the

enemy window, change the corresponding draw_actor_atg call as follows:

draw_actor_atg (actor, #, #, [CHANGE THIS NUMBER!!!])

The last number is the width of the gauge. If you leave all other settings in the RTAB and SlantBar

script having to do with width alone, this will resize it to your preferences.


This post has been edited by samsonite789: Sep 20 2009, 12:10 PM
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 10:05 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker