General RGSS/RGSS2/RGSS3 Help

Started by G_G, March 04, 2009, 12:14:28 am

Previous topic - Next topic

Xelias

November 07, 2009, 07:59:02 am #300 Last Edit: November 07, 2009, 08:00:16 am by Xelias
In class Game Battler, what is the syntax for
"If the attacker's Weapon Id is equal to..."
I tried "If attacker.weapon_id = ..." and it doesn't work:
I wanted to modify the algorithm of ONE weapon and all my weapons are changed !


My sprites
Kuja Tales of the World style :

G_G

use this
    if attacker.is_a?(Game_Actor)
      if attacker.weapon_id == 1
        # Code here
      end
    end

Got to make sure the attacker is a Game_Actor because when enemies use that same method when attacking and enemies dont have weapons.

Xelias

It works, but...
after the attack with the special weapon, I get an error
"Nil can't be coerced into fixnum"
at "self.hp -= self.damage"


My sprites
Kuja Tales of the World style :

G_G

post the code and I'll see whats wrong

Xelias

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Alternative Attack Algorithms  by Xelias
# Version: 7.39b
# Type: Battle Add-ON
# Date v1.00b:   7.11.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#  How to use this script :
# This allows your weapons to follow different damage algorithms.
# ATMA_WEAPON_ID = X ; The weapon with an ID equal to X will inflict
# more damage depending on the user's HP. If HP are full, attack power is doubled.
# If HP are at minimum, attack power is normal. If HP are equal to half, attack power
# is equal to 1,5 of the normal Attack power, and so on...
#
#
#
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

  ATMA_WEAPON_ID = 10

class Game_Battler

def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
          if attacker.is_a?(Game_Actor)
      if attacker.weapon_id == ATMA_WEAPON_ID
        # Code here
     atk = [attacker.atk - self.pdef / 2,0].max
     atk2 = atk * (20 + attacker.str) / 20
    self.damage = atk2 + (atk2*(attacker.hp/attacker.maxhp))
  else 
    atk = [attacker.atk - self.pdef / 2, 0].max
     self.damage = atk * (20 + attacker.str) / 20
   end
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.agi / self.pdef
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
        if rand(100) < ((self.pdef*10)/25)
          self.damage = 0
        end
        end
      end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
     # If hit occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to "Miss"
      self.damage = "Miss"
      # Clear critical flag
      self.critical = false
    end
    # End Method
    return true
  end
end
end




My sprites
Kuja Tales of the World style :

Ryex

all if statements need to be closed with an end statement after the

if attacker.is_a?(Game_Actor)
  if attacker.weapon_id == ATMA_WEAPON_ID

put

  end
end
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Xelias

November 07, 2009, 09:21:11 am #306 Last Edit: November 07, 2009, 10:56:54 am by Xelias
I don't understand where I should place them. I tried after the formula ; I tried after BOTH formulas ; I tried at the end of the script and all of those tries  create strange bugs. Can you help me by putting the "End"s directly in my script please?  
EDIT : ...Whatever. I modified something in the defending part, and it worked. Thanks.


My sprites
Kuja Tales of the World style :

Aqua

The nil is when you have no equipped weapon.
So you gotta make a check for if you're fighting with just bare hands.

Xelias

Thanks, but you're a little to late. It works now.  :haha:


My sprites
Kuja Tales of the World style :

nathmatt

ok i cant figure out what im doing wrong so im initializing @name = [] then im updating
for i in 0 ..BlizzABS::Config::MAX_PARTY - 1 then im using this code
it keeps saying @name is nill i can post the whole script if you need it

#----------------------------------------------------------------------------
  # draw_name
  #  Draws the name display.
  #----------------------------------------------------------------------------
  def draw_name(id)
    actors = $game_party.actors[id]
    # set current variable
    @name[id] = actors.name
    # 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+@all_y, 104, 20, @name[id])
  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


Blizzard

So, even if there is only 1 person in the party, you're still iterating through "0 ..BlizzABS::Config::MAX_PARTY - 1", are you?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

nathmatt

actually im going through 1..BlizzABS::Config::MAX_PARTY - 1 because the first 1 is done differently fixed the party member problem heres the full script its an edited version or ur BlizzABS hud


Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
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 = 2
    self.bar_opacity = 255
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# 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 = 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
 
end

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

class Hud < Sprite
 
  #----------------------------------------------------------------------------
  # Initialization
  #  viewport - the viewport for the sprite
  #----------------------------------------------------------------------------
  def initialize(viewport = nil)
    # call superclass method
    super
    @name = []
    @level = []
    @hp = []
    @sp = []
    @exp = []
    # create ids
    create_ids
    # get height
    h = BlizzABS::Config::DIRECT_HOTKEYS ? @hud_height - 28 : @hud_height
    # create bitmap
    self.bitmap = Bitmap.new(@hud_width, h)
    # set font
    self.bitmap.font.name = 'Arial'
    # set font to bold
    self.bitmap.font.bold = true
    # set x, y id
    self.x, self.y = 0, 0
    # set z coordinate
    self.z = 1000
    # draw basic HUD
    draw_basic
    # update
    update
  end
  #----------------------------------------------------------------------------
  # create_ids
  #  Sets drawing ids. This method can be aliased and the ids
  #  modified to create a different HUD.
  #----------------------------------------------------------------------------
  def create_ids
    @original_width = @hud_width = 250
    @original_height = @hud_height = 480
    @name1_x, @name1_y, @level1_x, @level1_y = 150, 1, 105, 1
    @hp1_x, @hp1_y, @sp1_x, @sp1_y, @exp1_x, @exp1_y = 130, 13, 105, 33, 5, 100
    @hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
    @face1_x, @face1_y = 5, 5
    @name_x, @name_y, @level_x, @level_y = 150, 1, 105, 1
    @hp_x, @hp_y, @sp_x, @sp_y, @exp_x, @exp_y = 130, 13, 105, 33, 5, 100
    @hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
    @face_x, @face_y = 5, 5
  end
  #----------------------------------------------------------------------------
  # draw_basic
  #  Draws the HUD template.
  #----------------------------------------------------------------------------
  def draw_basic
    # set font color
    self.bitmap.font.color = system_color
    # draw "LV"
    self.bitmap.draw_text_full(@level1_x, @level1_y, 20, 20, 'LV',2)
  end
  #----------------------------------------------------------------------------
  # draw_empty
  #  Draws the HP and SP display when actor doesn't exist.
  #----------------------------------------------------------------------------
  def draw_empty
    # draw empty bars
    self.bitmap.gradient_bar_hud(@hp1_x+32, @hp1_y+3, 114, 0, 'hud_green_bar', 1)
    # draw empty bars
    self.bitmap.gradient_bar_hud(@sp1_x+32, @sp1_y+3, 114, 0, 'hud_blue_bar', 2)
    # set font color
    self.bitmap.font.color = disabled_color
    # draw empty HP
    self.bitmap.draw_text_full(@hp1_x+38, @hp1_y, 48, 20, '0', 2)
    self.bitmap.draw_text_full(@hp1_x+86, @hp1_y, 12, 20, '/', 1)
    self.bitmap.draw_text_full(@hp1_x+98, @hp1_y, 48, 20, '0')
    # draw empty SP
    self.bitmap.draw_text_full(@sp1_x+38, @sp1_y, 48, 20, '0', 2)
    self.bitmap.draw_text_full(@sp1_x+86, @sp1_y, 12, 20, '/', 1)
    self.bitmap.draw_text_full(@sp1_x+98, @sp1_y, 48, 20, '0')
    # reset all flag variables
    @name = @level = @hp = @sp = @maxhp = @maxsp = @exp = @states = @skill =
        @skills_left = @item = @items_left = @gold = nil
  end
  #----------------------------------------------------------------------------
  # draw_name
  #  Draws the name display.
  #----------------------------------------------------------------------------
  def draw_name1
    # set current variable
    @name1 = actor.name
    # set font color
    self.bitmap.font.color = Color.new(0, 255, 0)
    # draw actor's name
    self.bitmap.draw_text_full(@name1_x, @name1_y, 104, 20, @name1)
  end
  #----------------------------------------------------------------------------
  # draw_face
  #  Draws the face display.
  #----------------------------------------------------------------------------
  def draw_face1
    # set current variable
    @sprite1 = Sprite.new
    # draw actor's face
    @sprite1.bitmap = RPG::Cache.picture(actor.name + '_f')
    @sprite1.x, @sprite1.y = @face1_x, @face1_y
    @sprite1.mirror = true
  end
  #----------------------------------------------------------------------------
  # draw_level
  #  Draws the level display.
  #----------------------------------------------------------------------------
  def draw_level1
    # set current variable
    @level1 = actor.level
    # set font color
    self.bitmap.font.color = normal_color
    # draw actor's level
    self.bitmap.draw_text_full(@level1_x+20, @level1_y, 20, 20, @level.to_s, 2)
  end
  #----------------------------------------------------------------------------
  # draw_hp
  #  Draws the HP display.
  #----------------------------------------------------------------------------
  def draw_hp1
    # set current variables
    @hp1, @maxhp1 = actor.hp, actor.maxhp
    # set fill rate
    rate = (@maxhp1 > 0 ? @hp1.to_f / @maxhp1 : 0)
    # create color
    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)
    # draw gradient bar
    self.bitmap.gradient_bar(@hp1_x,@hp1_y - 10,114,color1,color2,color3,rate)
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@hp1_x, @hp1_y, 32, 32, $data_system.words.hp)
    # set font color depending on how many HP left
    # set colors and draw values
    self.bitmap.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.bitmap.draw_text_full(@hp1_x, @hp1_y, 48, 32, actor.hp.to_s, 2)
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@hp1_x + 48, @hp1_y, 12, 32, '/', 1)
    self.bitmap.draw_text_full(@hp1_x + 60, @hp1_y, 48, 32, actor.maxhp.to_s)
    self.bitmap.font.color.alpha = 255
  end
  #----------------------------------------------------------------------------
  # draw_sp
  #  Draws the SP display.
  #----------------------------------------------------------------------------
  def draw_sp1
    # set current variables
    @sp1, @maxsp1 = actor.sp, actor.maxsp
    # set fill rate
    rate = (@maxsp1 > 0 ? @sp1.to_f / @maxsp1 : 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)
    # draw gradient bar
    self.bitmap.gradient_bar(@sp1_x,@sp1_y-10,114,color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@sp1_x, @sp1_y, 32, 32, $data_system.words.sp)
    # set offset
    # set colors and draw values
    self.bitmap.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.bitmap.draw_text_full(@sp1_x, @sp1_y, 48, 32, actor.sp.to_s, 2)
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@sp1_x + 48, @sp1_y, 12, 32, '/', 1)
    self.bitmap.draw_text_full(@sp1_x + 60, @sp1_y, 48, 32, actor.maxsp.to_s)
  end
  #----------------------------------------------------------------------------
  # draw_exp
  #  Draws the exp display.
  #----------------------------------------------------------------------------
  def draw_exp1
    # set current variables
    @now_exp1, @next_exp1 = actor.now_exp, actor.next_exp
    # set fill rate
    rate = (@next_exp1 != 0 ? @now_exp1.to_f / @next_exp1 : 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)
    # draw gradient bar
    self.bitmap.gradient_bar(@exp1_x,@exp1_y-10,114/2,color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@exp1_x, @exp1_y, 32, 32, 'EXP')

  end
  #----------------------------------------------------------------------------
  # draw_name
  #  Draws the name display.
  #----------------------------------------------------------------------------
  def draw_name(id)
    actors = $game_party.actors[id]
    # set current variable
    @name[id] = actors.name
    # 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+@all_y, 104, 20, @name[id])
  end
  #----------------------------------------------------------------------------
  # draw_face
  #  Draws the face display.
  #----------------------------------------------------------------------------
  def draw_face(id)
    actors = $game_party.actors[id]
    # set current variable
    @sprite[id] = Sprite.new
    # draw actor's face
    @sprite[id].bitmap = RPG::Cache.picture(actors.name + '_f')
    @sprite[id].x, @sprite[id].y = @face_x, @face_y+@all_y
    @sprite[id].mirror = true
  end
  #----------------------------------------------------------------------------
  # draw_level
  #  Draws the level display.
  #----------------------------------------------------------------------------
  def draw_level(id)
    actors = $game_party.actors[id]
    # set current variable
    @level[id] = actors.level
    # set font color
    self.bitmap.font.color = normal_color
    # draw actor's level
    self.bitmap.draw_text_full(@level_x+20, @level_y+@all_y, 20, 20, @level.to_s, 2)
  end
  #----------------------------------------------------------------------------
  # draw_hp
  #  Draws the HP display.
  #----------------------------------------------------------------------------
  def draw_hp(id)
    actors = $game_party.actors[id]
    # set current variables
    @hp[id], @maxhp[id] = actors.hp, actors.maxhp
    # set fill rate
    rate = (@maxhp[id] > 0 ? @hp[id].to_f / @maxhp[id] : 0)
    # create color
    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)
    # draw gradient bar
    self.bitmap.gradient_bar(@hp_x,@hp_y+@all_y - 10,114/2,color1,color2,color3,rate)
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@hp_x, @hp_y+@all_y, 32, 32, $data_system.words.hp)
    # set font color depending on how many HP left
    # set colors and draw values
    self.bitmap.font.color = actors.hp == 0 ? knockout_color :
      actors.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.bitmap.draw_text_full(@hp_x, @hp_y+@all_y, 48, 32, actors.hp.to_s, 2)
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@hp_x + 48, @hp_y+@all_y, 12, 32, '/', 1)
    self.bitmap.draw_text_full(@hp_x + 60, @hp_y+@all_y, 48, 32, actors.maxhp.to_s)
    self.bitmap.font.color.alpha = 255
  end
  #----------------------------------------------------------------------------
  # draw_sp
  #  Draws the SP display.
  #----------------------------------------------------------------------------
  def draw_sp(id)
    actors = $game_party.actors[id]
    # set current variables
    @sp[id], @maxsp[id] = actors.sp, actors.maxsp
    # set fill rate
    rate = (@maxsp[id] > 0 ? @sp[id].to_f / @maxsp[id] : 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)
    # draw gradient bar
    self.bitmap.gradient_bar(@sp_x,@sp_y-10+@all_y,114/2,color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@sp_x, @sp_y+@all_y, 32, 32, $data_system.words.sp)
    # set offset
    # set colors and draw values
    self.bitmap.font.color = actors.sp == 0 ? knockout_color :
      actors.sp <= actors.maxhp / 4 ? crisis_color : normal_color
    self.bitmap.draw_text_full(@sp+@all_y_x, @sp_y+@all_y, 48, 32, actors.sp.to_s, 2)
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@sp_x + 48, @sp_y+@all_y, 12, 32, '/', 1)
    self.bitmap.draw_text_full(@sp_x + 60, @sp_y+@all_y, 48, 32, actors.maxsp.to_s)
  end
  #----------------------------------------------------------------------------
  # draw_exp
  #  Draws the exp display.
  #----------------------------------------------------------------------------
  def draw_exp(id)
    actors = $game_party.actors[id]
    # set current variables
    @now_exp[id], next_exp[id] = actors.now_exp, actors.next_exp
    # set fill rate
    rate = (next_exp[id] != 0 ? @now_exp[id].to_f / @next_exp[id] : 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)
    # draw gradient bar
    self.bitmap.gradient_bar(@exp_x,@exp_y-10+@all_y,114/4,color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@exp_x, @exp_y+@all_y, 32, 32, 'EXP')

  end
  #----------------------------------------------------------------------------
  # draw_hskill
  #  Draws the hot skill display.
  #----------------------------------------------------------------------------
  def draw_hskill
    # set current variable
    @skill = actor.skill
    # 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+48, @hot_y+4, 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
    # 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, 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, 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
    # 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+124, @hot_y+4, 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)
    # 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+76, @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+76, @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 actor doesn't exist
    if actor == nil
      # unless already drawn empty HUD
      unless @empty_hud_drawn
        # draw HUD template
        draw_basic
        # draw empty HP, SP and EXP bars
        draw_empty
        # empty HUD was drawn
        @empty_hud_drawn = true
      end
    else
      # if HUD needs refresh
      if $game_temp.hud_refresh
        # draw all data about actor
         self.bitmap.font.size = 16
        draw_name1
        draw_level1
        draw_hp1
        draw_sp1
        draw_exp1
        draw_face1
        if $game_party.actors.size < 1..BlizzABS::Config::MAX_PARTY - 1
         @max = $game_party.actors.size
        else
         @max = BlizzABS::Config::MAX_PARTY - 1
        end
        for i in 1..@max
         self.bitmap.font.size = 8
          @all_y = 60 + i *70
          draw_name(i)
          draw_level(i)
          draw_hp(i)
          draw_sp(i)
          draw_exp(i)
          draw_face(i)
        end
        unless BlizzABS::Config::DIRECT_HOTKEYS
          draw_hskill
          draw_lskill
          draw_hitem
          draw_litem
        end
        # remove flag
        $game_temp.hud_refresh = nil
      else
        # draw data that needs to ve updated
        test_name1
        test_level1
        test_hp1
        test_sp1
        test_exp1
        test_face1
        for i in 1..BlizzABS::Config::MAX_PARTY - 1
         test_name(i)
         test_level(i)
         test_hp(i)
         test_sp(i)
         test_exp(i)
         test_face(i)
        end
        unless BlizzABS::Config::DIRECT_HOTKEYS
          test_hskill
          test_lskill
          test_hitem
          test_litem
        end
      end
      # empty HUD wasn't drawn
      @empty_hud_drawn = false
    end
  end
  #----------------------------------------------------------------------------
  # test_name
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_name1
    # draw new name if name has changed
    draw_name1 if actor.name != @name1
  end
  #----------------------------------------------------------------------------
  # test_face
  #  Tests and draws the face.
  #----------------------------------------------------------------------------
  def test_face1
    # draw new name if name has changed
    draw_face1
  end
  #----------------------------------------------------------------------------
  # test_level
  #  Tests and draws the level.
  #----------------------------------------------------------------------------
  def test_level1
    # draw new level if level has changed
    draw_level1 if actor.level != @level1
  end
  #----------------------------------------------------------------------------
  # test_hp
  #  Tests and draws the HP.
  #----------------------------------------------------------------------------
  def test_hp1
    # draw new HP if HP or max HP have changed
    draw_hp1 if actor.hp != @hp1 || actor.maxhp != @maxhp1
  end
  #----------------------------------------------------------------------------
  # test_sp
  #  Tests and draws the SP.
  #----------------------------------------------------------------------------
  def test_sp1
    # draw new SP if SP or max SP have changed
    draw_sp1 if actor.sp != @sp1 || actor.maxsp != @maxsp1
  end
  #----------------------------------------------------------------------------
  # test_exp
  #  Tests and draws the EXP.
  #----------------------------------------------------------------------------
  def test_exp1
    # draw new SP if SP or max SP have changed
    draw_exp1 if actor.now_exp != @now_exp1
  end
  #----------------------------------------------------------------------------
  # test_name
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_name(id)
    actors = $game_party.actors[id]
    # draw new name if name has changed
    draw_name(id) if actors.name != @name[id]
  end
  #----------------------------------------------------------------------------
  # test_face
  #  Tests and draws the face.
  #----------------------------------------------------------------------------
  def test_face(id)
    # draw new name if name has changed
    draw_face(id)
  end
  #----------------------------------------------------------------------------
  # test_level
  #  Tests and draws the level.
  #----------------------------------------------------------------------------
  def test_level(id)
    actors = $game_party.actors[id]
    # draw new level if level has changed
    draw_level(id) if actors.level != @level[id]
  end
  #----------------------------------------------------------------------------
  # test_hp
  #  Tests and draws the HP.
  #----------------------------------------------------------------------------
  def test_hp(id)
    actors = $game_party.actors[id]
    # draw new HP if HP or max HP have changed
    draw_hp(id) if actors.hp != @hp[id] || actors.maxhp != @maxhp[id]
  end
  #----------------------------------------------------------------------------
  # test_sp
  #  Tests and draws the SP.
  #----------------------------------------------------------------------------
  def test_sp(id)
    actors = $game_party.actors[id]
    # draw new SP if SP or max SP have changed
    draw_sp(id) if actors.sp != @sp[id] || actors.maxsp != @maxsp[id]
  end
  #----------------------------------------------------------------------------
  # test_exp
  #  Tests and draws the EXP.
  #----------------------------------------------------------------------------
  def test_exp(id)
    actors = $game_party.actors[id]
    # draw new SP if SP or max SP have changed
    draw_exp(id) if actors.now_exp != @now_exp[id]
  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
    return $game_player.battler
  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


Blizzard

You need to use "1...$game_party.actors.size" instead. Your code tries to access non-existing actors if the party isn't full. It's MAX_PARTY, not CURRENT_PARTY or something like that.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

nathmatt

November 09, 2009, 07:34:42 pm #313 Last Edit: November 09, 2009, 08:02:00 pm by nathmatt
ok here the new code but its lagging realy bad & the exp for the other chars stays full also how should i update the faces

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
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 = 2
   self.bar_opacity = 255
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# 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 = 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
 
end

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

class Hud < Sprite
 
 #----------------------------------------------------------------------------
 # Initialization
 #  viewport - the viewport for the sprite
 #----------------------------------------------------------------------------
 def initialize(viewport = nil)
   # call superclass method
   super
   @name = @level = @hp = @maxhp = @sp = @maxsp = @now_exp = @next_exp = @sprite = Array.new
   # create ids
   create_ids
   # get height
   h = BlizzABS::Config::DIRECT_HOTKEYS ? @hud_height - 28 : @hud_height
   # create bitmap
   self.bitmap = Bitmap.new(@hud_width, h)
   # set font
   self.bitmap.font.name = 'Times New Roman'
   # set font to bold
   self.bitmap.font.bold = true
   # set x, y id
   self.x, self.y = 0, 0
   # set z coordinate
   self.z = 1000
   # update
   update
 end
 #----------------------------------------------------------------------------
 # create_ids
 #  Sets drawing ids. This method can be aliased and the ids
 #  modified to create a different HUD.
 #----------------------------------------------------------------------------
 def create_ids
   @original_width = @hud_width = 250
   @original_height = @hud_height = 480
   @name1_x, @name1_y, @level1_x, @level1_y = 150, 1, 105, 1
   @hp1_x, @hp1_y, @sp1_x, @sp1_y, @exp1_x, @exp1_y = 130, 13, 105, 33, 5, 100
   @hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
   @face1_x, @face1_y = 5, 5
   @name_x, @name_y, @level_x, @level_y = 120, 1, 50, 1
   @hp_x, @hp_y, @sp_x, @sp_y, @exp_x, @exp_y = 80, 13, 70, 33, 5, 50
   @hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
   @face_x, @face_y = 5, 5
 end
 #----------------------------------------------------------------------------
 # draw_empty
 #  Draws the HP and SP display when actor doesn't exist.
 #----------------------------------------------------------------------------
 def draw_empty
   # draw empty bars
   self.bitmap.gradient_bar_hud(@hp1_x+32, @hp1_y+3, 114, 0, 'hud_green_bar', 1)
   # draw empty bars
   self.bitmap.gradient_bar_hud(@sp1_x+32, @sp1_y+3, 114, 0, 'hud_blue_bar', 2)
   # set font color
   self.bitmap.font.color = disabled_color
   # draw empty HP
   self.bitmap.draw_text_full(@hp1_x+38, @hp1_y, 48, 20, '0', 2)
   self.bitmap.draw_text_full(@hp1_x+86, @hp1_y, 12, 20, '/', 1)
   self.bitmap.draw_text_full(@hp1_x+98, @hp1_y, 48, 20, '0')
   # draw empty SP
   self.bitmap.draw_text_full(@sp1_x+38, @sp1_y, 48, 20, '0', 2)
   self.bitmap.draw_text_full(@sp1_x+86, @sp1_y, 12, 20, '/', 1)
   self.bitmap.draw_text_full(@sp1_x+98, @sp1_y, 48, 20, '0')
   # reset all flag variables
   @name = @level = @hp = @sp = @maxhp = @maxsp = @exp = @states = @skill =
       @skills_left = @item = @items_left = @gold = nil
 end
 #----------------------------------------------------------------------------
 # draw_name
 #  Draws the name display.
 #----------------------------------------------------------------------------
 def draw_name1
   # set current variable
   @name1 = actor.name
   # set font color
   self.bitmap.font.color = Color.new(0, 255, 0)
   # draw actor's name
   self.bitmap.draw_text_full(@name1_x, @name1_y, 104, 20, @name1)
 end
 #----------------------------------------------------------------------------
 # draw_face
 #  Draws the face display.
 #----------------------------------------------------------------------------
 def draw_face1
   # set current variable
   @sprite1 = Sprite.new
   # draw actor's face
   @sprite1.bitmap = RPG::Cache.picture(actor.name + '_f')
   @sprite1.x, @sprite1.y = @face1_x, @face1_y
   @sprite1.mirror = true
 end
 #----------------------------------------------------------------------------
 # draw_level
 #  Draws the level display.
 #----------------------------------------------------------------------------
 def draw_level1
   # set current variable
   @level1 = actor.level
   # set font color
   self.bitmap.font.color = normal_color
   # draw actor's level
   self.bitmap.draw_text_full(@level1_x+20, @level1_y, 20, 20, @level1.to_s, 2)
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@level1_x, @level1_y, 20, 20, 'LV',2)
 end
 #----------------------------------------------------------------------------
 # draw_hp
 #  Draws the HP display.
 #----------------------------------------------------------------------------
 def draw_hp1
   # set current variables
   @hp1, @maxhp1 = actor.hp, actor.maxhp
   # set fill rate
   rate = (@maxhp1 > 0 ? @hp1.to_f / @maxhp1 : 0)
   # create color
   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)
   # draw gradient bar
   self.bitmap.gradient_bar(@hp1_x,@hp1_y - 10,114,color1,color2,color3,rate)
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@hp1_x, @hp1_y, 32, 32, $data_system.words.hp)
   # set font color depending on how many HP left
   # set colors and draw values
   self.bitmap.font.color = actor.hp == 0 ? knockout_color :
     actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
   self.bitmap.draw_text_full(@hp1_x, @hp1_y, 48, 32, actor.hp.to_s, 2)
   self.bitmap.font.color = normal_color
   self.bitmap.draw_text_full(@hp1_x + 48, @hp1_y, 12, 32, '/', 1)
   self.bitmap.draw_text_full(@hp1_x + 60, @hp1_y, 48, 32, actor.maxhp.to_s)
   self.bitmap.font.color.alpha = 255
 end
 #----------------------------------------------------------------------------
 # draw_sp
 #  Draws the SP display.
 #----------------------------------------------------------------------------
 def draw_sp1
   # set current variables
   @sp1, @maxsp1 = actor.sp, actor.maxsp
   # set fill rate
   rate = (@maxsp1 > 0 ? @sp1.to_f / @maxsp1 : 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)
   # draw gradient bar
   self.bitmap.gradient_bar(@sp1_x,@sp1_y-10,114,color1, color2, color3, rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@sp1_x, @sp1_y, 32, 32, $data_system.words.sp)
   # set offset
   # set colors and draw values
   self.bitmap.font.color = actor.sp == 0 ? knockout_color :
     actor.sp <= actor.maxhp / 4 ? crisis_color : normal_color
   self.bitmap.draw_text_full(@sp1_x, @sp1_y, 48, 32, actor.sp.to_s, 2)
   self.bitmap.font.color = normal_color
   self.bitmap.draw_text_full(@sp1_x + 48, @sp1_y, 12, 32, '/', 1)
   self.bitmap.draw_text_full(@sp1_x + 60, @sp1_y, 48, 32, actor.maxsp.to_s)
 end
 #----------------------------------------------------------------------------
 # draw_exp
 #  Draws the exp display.
 #----------------------------------------------------------------------------
 def draw_exp1
   # set current variables
   @now_exp1, @next_exp1 = actor.now_exp, actor.next_exp
   # set fill rate
   rate = (@next_exp1 != 0 ? @now_exp1.to_f / @next_exp1 : 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)
   # draw gradient bar
   self.bitmap.gradient_bar(@exp1_x,@exp1_y-10,114/2,color1, color2, color3, rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@exp1_x, @exp1_y, 32, 32, 'EXP')

 end
 #----------------------------------------------------------------------------
 # draw_name
 #  Draws the name display.
 #----------------------------------------------------------------------------
 def draw_name(id)
   actors = $game_party.actors[id]
   # set current variable
   @name[id] = actors.name
   # 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+@all_y, 104, 20, @name[id])
 end
 #----------------------------------------------------------------------------
 # draw_face
 #  Draws the face display.
 #----------------------------------------------------------------------------
 def draw_face(id)
   actors = $game_party.actors[id]
   # set current variable
   @sprite[id] = Sprite.new
   # draw actor's face
   @sprite[id].bitmap = RPG::Cache.picture(actors.name + '_f')
   @sprite[id].x, @sprite[id].y = @face_x, @face_y+@all_y
   @sprite[id].zoom_x, @sprite[id].zoom_y = @sprite[id].zoom_x / 2 ,@sprite[id].zoom_y / 2
   @sprite[id].mirror = true
 end
 #----------------------------------------------------------------------------
 # draw_level
 #  Draws the level display.
 #----------------------------------------------------------------------------
 def draw_level(id)
   actors = $game_party.actors[id]
   # set current variable
   @level[id] = actors.level
   # set font color
   self.bitmap.font.color = normal_color
   # draw actor's level
   self.bitmap.draw_text_full(@level_x+20, @level_y+@all_y, 20, 20, @level[id].to_s, 2)
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@level_x, @level_y+@all_y, 20, 20, 'LV',2)
 end
 #----------------------------------------------------------------------------
 # draw_hp
 #  Draws the HP display.
 #----------------------------------------------------------------------------
 def draw_hp(id)
   actors = $game_party.actors[id]
   # set current variables
   @hp[id], @maxhp[id] = actors.hp, actors.maxhp
   # set fill rate
   rate = (@maxhp[id] > 0 ? @hp[id].to_f / @maxhp[id] : 0)
   # create color
   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)
   # draw gradient bar
   self.bitmap.gradient_bar(@hp_x,@hp_y+@all_y - 10,114/2,color1,color2,color3,rate)
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@hp_x, @hp_y+@all_y, 32, 32, $data_system.words.hp)
   # set font color depending on how many HP left
   # set colors and draw values
   self.bitmap.font.color = actors.hp == 0 ? knockout_color :
     actors.hp <= actor.maxhp / 4 ? crisis_color : normal_color
   self.bitmap.draw_text_full(@hp_x, @hp_y+@all_y, 48, 32, actors.hp.to_s, 2)
   self.bitmap.font.color = normal_color
   self.bitmap.draw_text_full(@hp_x + 18, @hp_y+@all_y, 12, 32, '/', 1)
   self.bitmap.draw_text_full(@hp_x + 20, @hp_y+@all_y, 48, 32, actors.maxhp.to_s)
   self.bitmap.font.color.alpha = 255
 end
 #----------------------------------------------------------------------------
 # draw_sp
 #  Draws the SP display.
 #----------------------------------------------------------------------------
 def draw_sp(id)
   actors = $game_party.actors[id]
   # set current variables
   @sp[id], @maxsp[id] = actors.sp, actors.maxsp
   # set fill rate
   rate = (@maxsp[id] > 0 ? @sp[id].to_f / @maxsp[id] : 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)
   # draw gradient bar
   self.bitmap.gradient_bar(@sp_x,@sp_y-10+@all_y,114/2,color1, color2, color3, rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@sp_x, @sp_y+@all_y, 32, 32, $data_system.words.sp)
   # set offset
   # set colors and draw values
   self.bitmap.font.color = actors.sp == 0 ? knockout_color :
     actors.sp <= actors.maxhp / 4 ? crisis_color : normal_color
   self.bitmap.draw_text_full(@sp_x, @sp_y+@all_y, 48, 32, actors.sp.to_s, 2)
   self.bitmap.font.color = normal_color
   self.bitmap.draw_text_full(@sp_x + 18, @sp_y+@all_y, 12, 32, '/', 1)
   self.bitmap.draw_text_full(@sp_x + 20, @sp_y+@all_y, 48, 32, actors.maxsp.to_s)
 end
 #----------------------------------------------------------------------------
 # draw_exp
 #  Draws the exp display.
 #----------------------------------------------------------------------------
 def draw_exp(id)
   actors = $game_party.actors[id]
   # set current variables
   @now_exp[id], @next_exp[id] = actors.now_exp, actors.next_exp
   # set fill rate
   rate = (@next_exp[id] != 0 ? @now_exp[id].to_f / @next_exp[id] : 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)
   # draw gradient bar
   self.bitmap.gradient_bar(@exp_x,@exp_y-10+@all_y,114/4,color1, color2, color3, rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@exp_x, @exp_y+@all_y, 32, 32, 'EXP')

 end
 #----------------------------------------------------------------------------
 # draw_hskill
 #  Draws the hot skill display.
 #----------------------------------------------------------------------------
 def draw_hskill
   # set current variable
   @skill = actor.skill
   # 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+48, @hot_y+4, 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
   # 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, 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, 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
   # 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+124, @hot_y+4, 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)
   # 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+76, @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+76, @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 actor doesn't exist
   if actor == nil
     # unless already drawn empty HUD
     unless @empty_hud_drawn
       # draw HUD template
       draw_basic
       # draw empty HP, SP and EXP bars
       draw_empty
       # empty HUD was drawn
       @empty_hud_drawn = true
     end
   else
     # if HUD needs refresh
     if $game_temp.hud_refresh
       # draw all data about actor
       draw_name1
       draw_level1
       draw_hp1
       draw_sp1
       draw_exp1
       draw_face1
       for i in 1..$game_party.actors.size - 1
         draw_name(i)
         draw_level(i)
         draw_hp(i)
         draw_sp(i)
         draw_exp(i)
         draw_face(i)
       end
       unless BlizzABS::Config::DIRECT_HOTKEYS
         draw_hskill
         draw_lskill
         draw_hitem
         draw_litem
       end
       # remove flag
       $game_temp.hud_refresh = nil
     else
       # draw data that needs to ve updated
       self.bitmap.font.size = 16
       test_name1
       test_level1
       test_hp1
       test_sp1
       test_exp1
       test_face1
       for i in 1..$game_party.actors.size - 1
        self.bitmap.font.size = 10
        @all_y = 60 + i *70
        test_name(i)
        test_level(i)
        test_hp(i)
        test_sp(i)
        test_exp(i)
        test_face(i)
       end
       unless BlizzABS::Config::DIRECT_HOTKEYS
         test_hskill
         test_lskill
         test_hitem
         test_litem
       end
     end
     # empty HUD wasn't drawn
     @empty_hud_drawn = false
   end
 end
 #----------------------------------------------------------------------------
 # test_name
 #  Tests and draws the name.
 #----------------------------------------------------------------------------
 def test_name1
   # draw new name if name has changed
   draw_name1 if actor.name != @name1
 end
 #----------------------------------------------------------------------------
 # test_face
 #  Tests and draws the face.
 #----------------------------------------------------------------------------
 def test_face1
   # draw new name if name has changed
   draw_face1
 end
 #----------------------------------------------------------------------------
 # test_level
 #  Tests and draws the level.
 #----------------------------------------------------------------------------
 def test_level1
   # draw new level if level has changed
   draw_level1 if actor.level != @level1
 end
 #----------------------------------------------------------------------------
 # test_hp
 #  Tests and draws the HP.
 #----------------------------------------------------------------------------
 def test_hp1
   # draw new HP if HP or max HP have changed
   draw_hp1 if actor.hp != @hp1 || actor.maxhp != @maxhp1
 end
 #----------------------------------------------------------------------------
 # test_sp
 #  Tests and draws the SP.
 #----------------------------------------------------------------------------
 def test_sp1
   # draw new SP if SP or max SP have changed
   draw_sp1 if actor.sp != @sp1 || actor.maxsp != @maxsp1
 end
 #----------------------------------------------------------------------------
 # test_exp
 #  Tests and draws the EXP.
 #----------------------------------------------------------------------------
 def test_exp1
   # draw new SP if SP or max SP have changed
   draw_exp1 if actor.now_exp != @now_exp1
 end
 #----------------------------------------------------------------------------
 # test_name
 #  Tests and draws the name.
 #----------------------------------------------------------------------------
 def test_name(id)
   actors = $game_party.actors[id]
   # draw new name if name has changed
   draw_name(id) if actors.name != @name[id]
 end
 #----------------------------------------------------------------------------
 # test_face
 #  Tests and draws the face.
 #----------------------------------------------------------------------------
 def test_face(id)
   # draw new name if name has changed
   draw_face(id)
 end
 #----------------------------------------------------------------------------
 # test_level
 #  Tests and draws the level.
 #----------------------------------------------------------------------------
 def test_level(id)
   actors = $game_party.actors[id]
   # draw new level if level has changed
   draw_level(id) if actors.level != @level[id]
 end
 #----------------------------------------------------------------------------
 # test_hp
 #  Tests and draws the HP.
 #----------------------------------------------------------------------------
 def test_hp(id)
   actors = $game_party.actors[id]
   # draw new HP if HP or max HP have changed
   draw_hp(id) if actors.hp != @hp[id] || actors.maxhp != @maxhp[id]
 end
 #----------------------------------------------------------------------------
 # test_sp
 #  Tests and draws the SP.
 #----------------------------------------------------------------------------
 def test_sp(id)
   actors = $game_party.actors[id]
   # draw new SP if SP or max SP have changed
   draw_sp(id) if actors.sp != @sp[id] || actors.maxsp != @maxsp[id]
 end
 #----------------------------------------------------------------------------
 # test_exp
 #  Tests and draws the EXP.
 #----------------------------------------------------------------------------
 def test_exp(id)
   actors = $game_party.actors[id]
   # draw new EXP if EXP was changed
   draw_exp(id) if actor.now_exp != @now_exp[id]
 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
   return $game_player.battler
 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


Blizzard

You probably did something wrong so it keeps refreshing it all the time rather than refreshing only when something changes.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

I'm all full of questions today.
How do I create a whole new event on a map?
All I need to know is setting up X, Y, Graphic, and Name

Blizzard

Check out how I did it with drop events in Blizz-ABS.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

November 12, 2009, 10:00:26 am #317 Last Edit: November 12, 2009, 10:17:16 am by game_guy
EDIT:
Fixed that
module GameGuy
  def self.spawn_enemy(id,x,y,name,graphic)
    event = RPG::Event.new(0,0)
    event.x, event.y = x, y
    keys = $game_map.events.keys
    event.id = (keys.size == 0 ? 1 : keys.max + 1)
    event.name = name
    event.pages[0].graphic.character_name = graphic
    event.pages[0].graphic.character_hue = 0
    event.pages[0].trigger = 0
    drop = Game_Event.new($game_map.map_id, event)
    $game_map.events[event.id] = drop
    sprite = Sprite_Character.new($scene.spriteset.viewport1, drop)
    $scene.spriteset.character_sprites.push(sprite)
  end
end


But now the enemy wont appear it all on the map

Blizzard

IDK. Maybe you did something wrong. There are more than 1 method involved.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Satoh

Ok, I'm trying to make ONLY weapons display in this menu, and each weapon separate(Instead of
  • Iron Sword: 2,

    it would be

  • Iron Sword
  • Iron Sword)

    I'm trying to modify the existing draw_item code (in a new class) but it doesn't seem to be working...

      def draw_item(index)
       item = @data[index]
       case item
       when RPG::Weapon
         number = $game_party.weapon_number(item.id)
       end
       if item.is_a?(RPG::Weapon)
         self.contents.font.color = normal_color
       end
       
       if number != nil
       for i in 1..number
         x = 4 + index % 1 * (288 + 32)
         y = index / 1 * 32
         rect = Rect.new(x, y, self.width / @column_max - 32, 32)
         self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
         bitmap = RPG::Cache.icon(item.icon_name)
         opacity = self.contents.font.color == normal_color ? 255 : 128
         self.contents.blt(x - 2, y + 2, bitmap, Rect.new(0, 0, 28, 28), opacity)
         self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
         if number > 1
           index += 1
           number -= 1
         end
         
         #self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
         #@number -= 1
       end
       end
     end


    What am I doing wrong exactly?
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources