Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - nathmatt

61
im trying to make a blizzabs controls config but i keep getting an error heres the code

(0...256).each{|i|
if Input.trigger?(i)
  Input::Up = [[Input::Key[Input::Key.index(i)]]]
  break
end}
62
RMXP Script Database / [XP] Picture Command
June 02, 2010, 01:16:53 pm
Picture Command
Authors: Nathmatt
Version: 1.00
Type: Command
Key Term: Menu Add-on



Introduction
This script makes a real picture command


Features


  • The ability to change distance between each picture
  • The ability to use a picture cursor or not
  • The ability to change the offset of the cursor if one is used



Screenshots


made with just this


Demo

No Demo


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Picture Command by Nathmatt
# Version: 1.01
# Type: Command
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  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.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# Picture Command Config
#==============================================================================
module Picture_Command_Config
 Distance         = 5                   # Distance between pictures
 Replace_Selector = false               # New picture or false
 Piture_Selector  = false               # Curser piture or false for default
 Selctor_Off_X    = 30                  # curser's x offset
 Selctor_Off_Y    = 20                  # curser's x offset
end
#==============================================================================
# Picture Command
#==============================================================================
class Picture_Command < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     width    : window width
 #     commands : command text string array
 #--------------------------------------------------------------------------
 def initialize(commands,graphic)
   @bitmap = RPG::Cache.picture(graphic)
   @cw = @bitmap.width
   @ch = @bitmap.height
   @dis = Picture_Command_Config::Distance
   super(0, 0, @cw + 32, commands.size * (@ch + @dis) + 32)
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, height - 32)
   self.index = -1
   refresh
   self.x -= 10
   self.index = 0
   self.opacity = 0
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   (0...@item_max).each{|i|draw_item(i, normal_color)}
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #     index : item number
 #     color : text color
 #--------------------------------------------------------------------------
 def draw_item(i, color)
   pic = (Picture_Command_Config::Piture_Selector != false ?
   Picture_Command_Config::Piture_Selector: @bitmap)
   self.contents.font.color = color
   self.contents.fill_rect(0, (@ch + @dis) * i, @cw, @ch, Color.new(0,0,0,0))
   rect = Rect.new(0, 0, @cw, @ch)
   self.contents.blt(0, (@ch + @dis) * i, pic, rect)
   rect = Rect.new(0, (@ch + @dis) * i, @cw, @ch)
   self.contents.draw_text(rect, @commands[i],1)
 end
 #--------------------------------------------------------------------------
 # * Disable Item
 #     index : item number
 #--------------------------------------------------------------------------
 def disable_item(index)
   draw_item(index, disabled_color)
 end
 #--------------------------------------------------------------------------
 # * Cursor Rectangle Update
 #--------------------------------------------------------------------------
 def update_cursor_rect
   if @index < 0
     self.cursor_rect.empty
   elsif Picture_Command_Config::Piture_Selector != false
     if @curser_selsect == nil
       @curser_selsect = Sprite.new
       @curser_selsect.bitmap = RPG::Cache.picture(
       Picture_Command_Config::Piture_Selector)
     end
     @curser_selsect.x = Picture_Command_Config::Selctor_Off_X
     @curser_selsect.y = (@index * (@ch + @dis)
     ) + Picture_Command_Config::Selctor_Off_Y
     @curser_selsect.z = 9999
   else
     self.cursor_rect.set(0, @index * (@ch + @dis), @cw, @ch)
   end
 end
end



Instructions
Just set up the config and use Picture_Command.new(commands,picture)
instead of Window_Command.new(width,commands)


Compatibility
no Compatibility known


Credits and Thanks


  • Nathmatt



Author's Notes

Just post any suggestions
63
Entertainment / Chad vador
May 30, 2010, 10:44:01 pm
http://m.youtube.com/index?desktop_uri=%2F&gl=US#/results?client=mv-google&q=chad%20vader&aq=0&oq=chad
64
i made a class of script calls with things like chapter save inn messages random npc messages just thought i also combined this with a AMS i made to go with it just some scripting ideas

edit: what I meant was to give ppl a suggestion to create a class for everything they use a lot i may mess around with it some and post it up with a small tutorial on how to add to it

edit:  OK here is what i have

calls
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Script Calls / AMS by Nathmatt
# Version: 1.00
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                                    PART 1
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  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 Calls
 
  # The Game_Variables id used to store all you locations
  variable_id = 13
  #-----------------------------------------------------------------------------
  # These are used for the AMS
  #-----------------------------------------------------------------------------
  # NPC random chat
  #-----------------------------------------------------------------------------
  # the gender can be any condition you want
  def random_message(gender)
    id = rand(9)
    if gender == 'female'
      case id
      when 0 then return 'Can i help you with somthing?'
      when 1 then return 'Do you need somthing?'
      when 2 then return 'Hey sweetie.'
      when 3 then return 'Hi.'
      when 4 then return 'Hello.'
      when 5 then return 'Have you met my daughter?'
      when 6 then return 'Sorry i am married.'
      when 7 then return 'If only i was younger.'
      when 8 then return 'Better not let my husband see you.'
      when 9 then return '...'
      end
    elsif gender == 'male'
      case id
      when 0 then return 'What do you want?'
      when 1 then return 'Nice day isnt it?'
      when 2 then return 'What?'
      when 3 then return 'Get out of my face.'
      when 4 then return 'Hi.'
      when 5 then return 'Hello'
      when 6 then return 'Can i help you with somthing?'
      when 7 then return 'Did you need somthing.'
      when 8 then return 'Back off.'
      when 9 then return '...'
      end
    end
  end
  #-----------------------------------------------------------------------------
  # Basic
  #-----------------------------------------------------------------------------
  def Basic_Messages(name,i)
    case i
    when 0 then return "\\Name[#{name}]Sorry you do not have enough."
    when 1 then return "\\Name[#{name}]Come again."
    end
  end
  #-----------------------------------------------------------------------------
  # Inn
  #-----------------------------------------------------------------------------
  def Inn(name,gold)
    $game_temp.choice_start += 1
    return "\\Name[Inn Keeper]Would you Like to stay at the \\c[2]#{name}\\c[0]" +
    "\n for \\c[6]#{gold}\\c[0] \\gold."
  end
  #-----------------------------------------------------------------------------
  # Shop
  #-----------------------------------------------------------------------------
  def Shop(name)
    return "\\Name[Shop Keeper]Would you Like to check out my wares."
  end
  #-----------------------------------------------------------------------------
  # Icon
  #-----------------------------------------------------------------------------
  def Icon(type,id)
    case type
    when 'i'
      data = $data_items[id]
    when 'w'
      data = $data_weapons[id]
    when 'a'
      data = $data_armors[id]
    when 's'
      data = $data_skills[id]
    end
    return RPG::Cache.icon(type.icon_name)
  end
  #-----------------------------------------------------------------------------
  # initialize
  #-----------------------------------------------------------------------------
  def initialize
    @map_infos = load_data('Data/MapInfos.rxdata')
    @map_infos.keys.each {|key| @map_infos[key] = @map_infos[key].name}
  end
  #-----------------------------------------------------------------------------
  # Map Name
  #-----------------------------------------------------------------------------
  def Map_Name
    @map_infos[$game_map.map_id]
  end
  #-----------------------------------------------------------------------------
  # These are used the script calls
  #-----------------------------------------------------------------------------
  # Play Time
  #-----------------------------------------------------------------------------
  def Play_Time
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    time = sprintf("%02d:%02d:%02d", hour, min, sec)
    return time.to_s
  end
  #-----------------------------------------------------------------------------
  # Save Location
  #-----------------------------------------------------------------------------
  def Save_Location(id)
    $game_variables[variable_id][id] = [$game_map.map_id,$game_player.x,
    $game_player.y,$game_player.direction]
    return
  end
  #-----------------------------------------------------------------------------
  # Load Location
  #-----------------------------------------------------------------------------
  def Load_Location(id)
    loc = $game_variables[variable_id][id]
    $game_temp.player_new_map_id = loc[0]
    $game_temp.player_new_x = loc[1]
    $game_temp.player_new_y = loc[2]
    $game_temp.player_new_direction = loc[3]
    return
  end
  #-----------------------------------------------------------------------------
  # Chapter Save
  #-----------------------------------------------------------------------------
  def Save(index)
    filename = "Auto_Save/Chapter#{index}.rxdata"
    file = File.open(filename, "wb")
    characters = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.character_name, actor.character_hue])
    end
    # Write character data for drawing save file
    Marshal.dump(characters, file)
    # Wrire frame count for measuring play time
    Marshal.dump(Graphics.frame_count, file)
    # Save magic number
    # (A random value will be written each time saving with editor)
    $game_system.magic_number = $data_system.magic_number
    # Write each type of game object
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, file)
    Marshal.dump($game_actors, file)
    Marshal.dump($game_party, file)
    Marshal.dump($game_troop, file)
    Marshal.dump($game_map, file)
    Marshal.dump($game_player, file)
    file.close
  end
  #-----------------------------------------------------------------------------
  # Call Self Switch
  #-----------------------------------------------------------------------------
  def Call_Self_Switch(id,condition,let = 'A')
    $game_self_switches[[$game_map.map_id, id, let]] = conditon
    return
  end
 
end

$calls = Calls.new


AMS
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Script Calls / AMS by Nathmatt
# Version: 1.00
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                                    PART 2
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  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.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# Window_Message
#==============================================================================
class Window_Message < Window_Selectable

  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    x = y = 0
    @cursor_width = 0
    # Indent if choice
    if $game_temp.choice_start == 0
      x = 8
    end
    # If waiting for a message to be displayed
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      # Control text processing
      begin
        last_text = text.clone
        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
        # calls shop messages with \shop[id]
        text.gsub!(/\\[Ss]hop\[(\S+)\]/) { $calls.Shop($1) }
        # calls Inn messages with \inn[inn name,price]
        text.gsub!(/\\[Ii]nn\[([\S, ]+)\]/) {
        data = $1.split(',')
        $calls.Inn(data[0],data[1]) }
        # calls basic messages with \basic[npc's name,id]
        text.gsub!(/\\[Bb]asic\[([\S, ]+)\]/) {
        data = $1.split(',')
        $calls.Basic_Messages(data[0],data[1].to_i) }
      end until text == last_text
      # calls actors name with \n[id]
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      # calls random messages with \r[gender]
      text.gsub!(/\\[Rr]\[(\S+)\]/) do
        $calls.random_message($1)
      end
      # calls map name with \m
      text.gsub!(/\\[Mm]/) do
        $calls.Map_Name
      end
      text.gsub!(/\\[Gg]old/) do
        $data_system.words.gold
      end
      # returns \\
      text.gsub!(/\\\\/)                {"\000"}
      # changes text color with \c[id]
      text.gsub!(/\\[Cc]\[([0-9]+)\]/)  {"\001[#{$1}]"}
      # calls gold window with \g
      text.gsub!(/\\[Gg]/)              {"\002"}
      # calls name window with \name[name]
      text.gsub!(/\\[Nn]ame\[(.+?)\]/)  {"\003[#{$1}]"}
      # calls face Graphic with \name[name]
      text.gsub!(/\\[Ff]\[(\S+)\]/)     {"\004[#{$1}]" }
      # calls icon with \i[type,id] type is i for item a for armor w for weapon
      # & s for skills
      text.gsub!(/\\[Ii]\[([\S, ]+)\]/) {"\005[#{$1}]" }
      # Get 1 text character in c (loop until unable to get text)
      while ((c = text.slice!(/./m)) != nil)
        # If \\
        if c == "\000"
          # Return to original text
          c = "\\"
        end
        # If \C[n]
        if c == "\001"
          # Change text color
          text.sub!(/\[([0-9]+)\]/, "")
          color = $1.to_i
          if color >= 0 and color <= 7
            self.contents.font.color = text_color(color)
          end
          # go to next text
          next
        end
        # If \G
        if c == "\002"
          # Make gold window
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          # go to next text
          next
        end
        if c == "\003"
          # Make name window
          text.sub!(/\[(.+?)\]/, "")
          @name_window = Name_Window.new($1,self.x,self.y)
          nwidth = contents.text_size($1).width
          @name_back = Window_Base.new(self.x,self.y-32,nwidth+8,32)
          @name_back.opacity = self.opacity
          @name_back.back_opacity = self.back_opacity
          next
        end
        if c == "\004"
          # Make face window
           text.sub!(/\[(\S+)\]/, "")
          if @face_window == nil
            @face_window = Face_Window.new($1,self.x-10,self.y-10)
            left = true
          end
          next
        end
        if c == "\005"
          # Make Icons
          text.sub!(/\[([\S, ]+)\]/, "")
          data =  $1.split(',')
          data = $calls.Icon(data[0].to_s,data[1].to_i)
          self.contents.blt(x + (left != nil ? 96 : 0), y, data[0],
          Rect.new(0, 0, 24, 24), opacity)
          x += 24
          w = self.contents.text_size(data[1]).width
          self.contents.draw_text(4 + x + (left != nil ? 96 : 0),
          32 * y, w, 32, data[1])
          x += w
          next
        end
        # If new line text
        if c == "\n"
          # Update cursor width if choice
          if y >= $game_temp.choice_start
            @cursor_width = [@cursor_width, x].max
          end
          # Add 1 to y
          y += 1
          x = 0
          # Indent if choice
          if y >= $game_temp.choice_start
            x = 8
          end
          # go to next text
          next
        end
        # Draw text
        self.contents.draw_text(4 + x + (left != nil ? 96 : 0),
        32 * y, 40, 32, c)
        # Add x to drawn text width
        x += self.contents.text_size(c).width
      end
    end
    # If choice
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    # If number input
    if $game_temp.num_input_variable_id > 0
      digits_max = $game_temp.num_input_digits_max
      number = $game_variables[$game_temp.num_input_variable_id]
      @input_number_window = Window_InputNumber.new(digits_max)
      @input_number_window.number = number
      @input_number_window.x = self.x + 8
      @input_number_window.y = self.y + $game_temp.num_input_start * 32
    end
  end

  alias cms_terminate_message terminate_message
  def terminate_message
    cms_terminate_message
    if @name_window != nil
      @name_window.dispose
      @name_window = nil
    end
    if @name_back != nil
      @name_back.dispose
      @name_back = nil
    end
    if @face_window != nil
      @face_window.dispose
      @face_window = nil
    end
  end
 
  alias cms_update update
  def update
    if @contents_showing && Graphics.frame_rate == 80
      if $game_temp.choice_max > 0
        $game_system.se_play($data_system.decision_se)
        $game_temp.choice_proc.call(self.index)
      end
      terminate_message
    end
    cms_update
  end
 
end
#==============================================================================
# Name_Window
#==============================================================================
class Name_Window < Sprite
 
  def initialize(name,x,y)
    super()
    w = (name.length * 32)
    self.bitmap = Bitmap.new(w, 32)
    self.x = x
    self.y = y - 32
    self.z = 500
    @name = name
    refresh
  end
 
  def refresh
    w = bitmap.text_size(@name).width
    self.bitmap.draw_text(4,0,w,32,@name.to_s)
  end
end
#==============================================================================
# Face_Window
#==============================================================================
class Face_Window < Sprite
 
  def initialize(file,x,y,flip = nil)
    super()
    self.bitmap = RPG::Cache.picture(file + '.png')
    self.x = x +20
    self.y = y +20
    self.z = 9999
    if flip
      self.mirror = true
      self.x += (460-self.bitmap.width)
    end
  end
 
  def size
    return self.bitmap.width
  end
 
end


now y i did not post this under scripts because i figure you wont use this as is im got to help you add to it for ur own game for it purposes

so first off if you notice the inn in the script calls
 def Inn(name,gold)
    $game_temp.choice_start += 1
    return "\\Name[Inn Keeper]Would you Like to stay at the \\c[2]#{name}\\c[0]" +
    "\n for \\c[6]#{gold}\\c[0] \\gold."
 end

If your using msg calls you have to add \\ instead of \ for it to read it also using #{variable} will allow you to add that variable to your msg as long as you use the double quotations ("") and if you are using the choice selector in your msg the for every line after the first 1 you need to add 1 to $game_temp.choice_start OK that is a bit about how to use a msg call now how i added it to the msg script
text.gsub!(/\\[Ii]nn\[([\S, ]+)\]/) { 
        data = $1.split(',')
        $calls.Inn(data[0],data[1]) }

the text.gsub!(/\\[Ii]nn\[([\S, ]+)\]/) is used to find either \Inn or \inn then in the brackets we have \S, that tells it i want to get anything but spaces in the bracket the comma tells it i want an array size of 2 the $1.split(',') i used store the $1 array into data then i called my script call from my Calls class $calls.Inn(data[0],data[1])  i store the inns name in data[0] and the price in data[1] by using \inn[name,price] now to add your own just define something in the Calls class then have it call it that way but change the [Ii]nn if its an array if not use can use this to call 1 with one variable or none
text.gsub!(/\\[Mm]/) do
        $calls.Map_Name
      end

as you can see we used text.gsub!(/\\[Mm]/) do $calls.Map_Name this tells it when \M or \M call $calls.Map_Name which i store the maps name in in my Calls class
text.gsub!(/\\[Rr]\[(\S+)\]/) do $calls.random_message($1) stores one variable and calls $calls.random_message($1) same as above

if you need any help addind any thing else or want something added to whats already here post


65
RPG Maker Scripts / (resolved)gsub
May 21, 2010, 03:17:28 pm
i was wondering if there was something that better described how things like this .gsub!(/\\lock\[(\d+)\]/) {"#[$1]"} work
66
RMXP Script Database / [XP] Party Swap
May 07, 2010, 02:41:56 pm
Party Swap
Authors: Nathmatt
Version: 1.01
Type: Party Controller
Key Term: Misc Add-on



Introduction
This script allows you have multiple parties and swap between the easily


Features


  • Allows creating a new party and storing the current along with the players position in a $game_variable
  • Allows swapping the current party and position of the player with a $game_variable
  • Allows combining the parties inventory and gold stored in the $game_variable to the party



Screenshots

no screenshot


Demo
no demo


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Party Swap by Nathmatt
# Version: 1.00
# Type: Party Controller
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  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.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Script Calls:
#
#   Party.new_party(var_id) - This stores the current party and player postion    
#                             in $game_varirables[var_id]
#  
#   Party.swap(var_id)      - This will swap the current party and positon with
#                             the 1 stored in $game_varirables[var_id]
#
#   Party.combine_party(var_id) - Adds money,gold,items,armor,and weapons from
#                                 $game_varirables[var_id] to the party
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  Party
#------------------------------------------------------------------------------
#  This module controls the party.
#==============================================================================
module Party

 
 def self.new_party(var_id)
   $game_variables[var_id] = [$game_party,$game_map.map_id,
   $game_player.x,$game_player.y,$game_player.direction]
   $game_party = Game_Party.new
 end
 
 def self.swap(var_id)
   par = [$game_party,$game_map.map_id,
   $game_player.x,$game_player.y,$game_player.direction]
   $game_party = $game_variables[var_id][0]
   $game_player.refresh
   $game_temp.player_transferring = true
   $game_temp.player_new_map_id = $game_variables[var_id][1]
   $game_temp.player_new_x = $game_variables[var_id][2]
   $game_temp.player_new_y = $game_variables[var_id][3]
   $game_temp.player_new_direction = $game_variables[var_id][4]
   $game_variables[var_id] = par
 end
 
 def self.combine_party(var_id)
   $game_variables[var_id][0].items.each_pair {| key, value |
   $game_party.gain_item(key, value)}
   $game_variables[var_id][0].weapons.each_pair {| key, value |
   $game_party.gain_weapon(key, value)}
   $game_variables[var_id][0].armors.each_pair {| key, value |
   $game_party.gain_armor(key, value)}
   $game_party.gain_gold($game_variables[var_id][0].gold)
 end
 
end
#============================================================================
# Game_Party
#----------------------------------------------------------------------------
# This class was enhanced to support accessing the parties inventory
#============================================================================
class Game_Party
 
 attr_reader   :items
 attr_reader   :weapons
 attr_reader   :armors
 
end



Instructions
in the script


Compatibility
Should not have any compatibility issues


Credits and Thanks


  • Nathmatt
  • Blizzard for little tricks about party storing
  • lonely_cubone for asking how to combine the stored inventory and gold to the party



Author's Notes

If you have any suggestions or problems with the instructions post here
67
Norton keeps telling me to manually remove it says This but if i click on Disable System Restore it wants to remove everything in it is it really safe to remove everything in your system restore & what is the virus definitions it says to update that i updated Norton is that something else i need to update and how
68
General Discussion / SDK develepment
April 22, 2010, 07:15:43 am
features i was thinking about creating an actual that adds features i was just woundering what features ppl get SDK for so i could start with them
69
RMXP Script Database / [XP] Character Drop Down Menu
April 15, 2010, 06:53:01 pm
Character Drop Down Menu
Authors: Nathmatt
Version: 1.15
Type: Misc System
Key Term: Custom Menu System



Introduction
creates a drop down menu for the character you right click on
Requires RMX-OS & Mouse Controller by Blizzard


Features

  • Add Buddy & trade always
  • Kick & Ban if you have any mod status
  • Guild Invite if your a guild leader
  • Add Party if Blizz-ABS Controller is being used



Screenshots
Spoiler: ShowHide



Demo

No Demo


Script
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Character Drop Down Menu by Nathmatt
# Version: 1.15
# Type: Misc System
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  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 Character_Drop_Down_Menu
 
  def initialize
    username = ''
    @mini_list_array = ['Add Buddy','Trade']
    @mini_list_array.insert(1,'Add Party') if $blizzabs_rmxos != nil
    if $network.guildleader == $network.username
      @mini_list_array.insert(0,'Guild Invite')
    end
    @mini_list_array.push('Kick','Ban') if $network.usergroup > 0
    @confirm_window = Window_Confirm.new
    @mini_list = Window_Mini_List.new(@mini_list_array)
    @mini_list.visible = false
    @wait = 0
  end

  def update
    @wait -= 1 if @wait > 0
    if Input.trigger?(Input::Key['Mouse Right'])
      return if @wait != 0
      @mx,@my = $mouse.pos
      @sx,@sy = $mouse.position
      @player_username = $network.check_player(@mx,@my)
      @players_info = $network.get_player(@mx,@my)
      if @player_username != nil
        @mini_list.visible = true
        @mini_list.active = true
        @mini_list.x = @sx
        @mini_list.y = @sy
        $MCES.disabled = true
      end
      @wait = 5
    end
   
    if @mini_list.active
      @mini_list.update
      if Input.trigger?(Input::Key['Mouse Left'])
        return if @wait != 0
        if @mini_list.index >= 0
          @confirm_window.set_commands(@mini_list.item,@player_username)
        end
        @mini_list.visible = false
        @mini_list.active = false
        @wait = 5
      end
    end
   
    if @confirm_window.active
      @confirm_window.update
      if Input.trigger?(Input::Key['Mouse Left'])
        return if @wait != 0
        case @confirm_window.index
        when 0
          case @mini_list.item
          when 'Add Buddy'
            $network.command_buddy_add(@player_username)
          when 'Trade'     
            $network.command_trade_request(@player_username)
          when 'Guild Invite'
            $network.command_guild_invite(@player_username)
          when 'Kick'
            $network.command_kick_player(@player_username)
          when 'Ban'
            $network.command_ban_player(@player_username)
          when 'Add Party'
            $network.command_party_invite(@player_username)
          end
          @confirm_window.visible = false
          @confirm_window.active = false
        else
          @confirm_window.visible = false
          @confirm_window.active = false
        end
        $MCES.disabled = false
        $MCES.wait = 5
        @wait = 5
      end
    end
   
  end
   
end
#==============================================================================
# Scene_Map
#==============================================================================
class Scene_Map
 
  alias character_drop_down_menu_main main
  def main
    @mini_menu = Character_Drop_Down_Menu.new
    character_drop_down_menu_main
  end
 
  alias character_drop_down_menu_update update
  def update
    @mini_menu.update
    character_drop_down_menu_update
  end
 
end
#==============================================================================
# Mouse
#==============================================================================
class Mouse
 
  attr_accessor :cursor
 
  def pos
    x, y = self.position
    x = ( x + $game_map.display_x / 4) / 32
    y = ( y + $game_map.display_y / 4) / 32
    return x, y
  end
   
end
#==============================================================================
# Window_list
#==============================================================================
class Window_Mini_List < Window_Selectable
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(list)
    super(476, 175, 104, 300)
    @list = list
    @column_max = 1
    refresh
    self.index = 0
    self.opacity = 0
    self.active = false
    self.z = 10000
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index] if self.index >= 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    @list.each {|i| @data.push(i)}
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.fill_rect(0,0,width,height,Color.new(0, 0, 0, 160))
      @data.each_index {|i| draw_item(i)}
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = index % 1 * (288 + 32)
    y = index / 1 * 32
    self.contents.font.size = 16
    self.contents.draw_text(x, y, width - 32, 32, @data[index].to_s, 1)
  end
end
#==============================================================================
# Window_Confirm
#==============================================================================
class Window_Confirm < Window_Selectable
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(100, 100, 300, 150)
    @data = ['Yes','No']
    @column_max = 2
    @command = nil
    @user = nil
    refresh
    self.index = 0
    self.opacity = 0
    self.active = false
    self.visible = false
    self.z = 10000
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index] if self.index >= 0
  end
  #--------------------------------------------------------------------------
  # * reset
  #--------------------------------------------------------------------------
  def set_commands(command,user)
    @command = command
    @user = user
    self.visible = true
    self.active  = true
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, 20 + row_max * 32)
      self.contents.font.size = 16
      self.contents.fill_rect(0,0,width,height,Color.new(0, 0, 0, 160))
      self.contents.draw_text(0,0,width,20,
      'Are you sure you want to '+ @command.to_s + ' ' + @user.to_s)
      @data.each_index {|i| draw_item(i)}
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = index * (width - 32) / 2
    self.contents.draw_text(x, 20, (width - 32) / 2, 32, @data[index].to_s, 1)
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(self.index * (width - 32) / 2, 25,
     (width - 32) / 2 , 20)
    end
  end
end
#============================================================================
# RMXOS::Network
#============================================================================
class RMXOS::Network
  def check_player(x,y)
    @players.any? {|key, value|
    return value.username if value.x == x && value.y == y}
    return nil
  end
  def get_player(x,y)
    if $blizzabs_rmxos != nil
      @players.any? {|key, value|
      return value.battler if value.x == x && value.y == y}
    end
    return nil
  end
end
# Load the network
$network = RMXOS::Network.new



Instructions
place below Mouse Controller script & below my Mouse Path Finder


Compatibility
no compatibility issues known


Credits and Thanks


  • Nathmatt
  • Blizzard for the Mouse Controller script and  RMX-OS



Author's Notes
Any suggestions for updates are appreciated
70
RPG Maker Scripts / scripting event commands
April 13, 2010, 04:49:06 pm
if you want to know to to script an event command check Interpreter

if i want to know how to change the parties gold all i need to search for is command_125
use ctrl + shift + f to find it ezer
Spoiler: ShowHide
case @list[@index].code
    when 101  # Show Text
      return command_101
    when 102  # Show Choices
      return command_102
    when 402  # When [**]
      return command_402
    when 403  # When Cancel
      return command_403
    when 103  # Input Number
      return command_103
    when 104  # Change Text Options
      return command_104
    when 105  # Button Input Processing
      return command_105
    when 106  # Wait
      return command_106
    when 111  # Conditional Branch
      return command_111
    when 411  # Else
      return command_411
    when 112  # Loop
      return command_112
    when 413  # Repeat Above
      return command_413
    when 113  # Break Loop
      return command_113
    when 115  # Exit Event Processing
      return command_115
    when 116  # Erase Event
      return command_116
    when 117  # Call Common Event
      return command_117
    when 118  # Label
      return command_118
    when 119  # Jump to Label
      return command_119
    when 121  # Control Switches
      return command_121
    when 122  # Control Variables
      return command_122
    when 123  # Control Self Switch
      return command_123
    when 124  # Control Timer
      return command_124
    when 125  # Change Gold
      return command_125
    when 126  # Change Items
      return command_126
    when 127  # Change Weapons
      return command_127
    when 128  # Change Armor
      return command_128
    when 129  # Change Party Member
      return command_129
    when 131  # Change Windowskin
      return command_131
    when 132  # Change Battle BGM
      return command_132
    when 133  # Change Battle End ME
      return command_133
    when 134  # Change Save Access
      return command_134
    when 135  # Change Menu Access
      return command_135
    when 136  # Change Encounter
      return command_136
    when 201  # Transfer Player
      return command_201
    when 202  # Set Event Location
      return command_202
    when 203  # Scroll Map
      return command_203
    when 204  # Change Map Settings
      return command_204
    when 205  # Change Fog Color Tone
      return command_205
    when 206  # Change Fog Opacity
      return command_206
    when 207  # Show Animation
      return command_207
    when 208  # Change Transparent Flag
      return command_208
    when 209  # Set Move Route
      return command_209
    when 210  # Wait for Move's Completion
      return command_210
    when 221  # Prepare for Transition
      return command_221
    when 222  # Execute Transition
      return command_222
    when 223  # Change Screen Color Tone
      return command_223
    when 224  # Screen Flash
      return command_224
    when 225  # Screen Shake
      return command_225
    when 231  # Show Picture
      return command_231
    when 232  # Move Picture
      return command_232
    when 233  # Rotate Picture
      return command_233
    when 234  # Change Picture Color Tone
      return command_234
    when 235  # Erase Picture
      return command_235
    when 236  # Set Weather Effects
      return command_236
    when 241  # Play BGM
      return command_241
    when 242  # Fade Out BGM
      return command_242
    when 245  # Play BGS
      return command_245
    when 246  # Fade Out BGS
      return command_246
    when 247  # Memorize BGM/BGS
      return command_247
    when 248  # Restore BGM/BGS
      return command_248
    when 249  # Play ME
      return command_249
    when 250  # Play SE
      return command_250
    when 251  # Stop SE
      return command_251
    when 301  # Battle Processing
      return command_301
    when 601  # If Win
      return command_601
    when 602  # If Escape
      return command_602
    when 603  # If Lose
      return command_603
    when 302  # Shop Processing
      return command_302
    when 303  # Name Input Processing
      return command_303
    when 311  # Change HP
      return command_311
    when 312  # Change SP
      return command_312
    when 313  # Change State
      return command_313
    when 314  # Recover All
      return command_314
    when 315  # Change EXP
      return command_315
    when 316  # Change Level
      return command_316
    when 317  # Change Parameters
      return command_317
    when 318  # Change Skills
      return command_318
    when 319  # Change Equipment
      return command_319
    when 320  # Change Actor Name
      return command_320
    when 321  # Change Actor Class
      return command_321
    when 322  # Change Actor Graphic
      return command_322
    when 331  # Change Enemy HP
      return command_331
    when 332  # Change Enemy SP
      return command_332
    when 333  # Change Enemy State
      return command_333
    when 334  # Enemy Recover All
      return command_334
    when 335  # Enemy Appearance
      return command_335
    when 336  # Enemy Transform
      return command_336
    when 337  # Show Battle Animation
      return command_337
    when 338  # Deal Damage
      return command_338
    when 339  # Force Action
      return command_339
    when 340  # Abort Battle
      return command_340
    when 351  # Call Menu Screen
      return command_351
    when 352  # Call Save Screen
      return command_352
    when 353  # Game Over
      return command_353
    when 354  # Return to Title Screen
      return command_354
    when 355  # Script
      return command_355
71
Mouse Controller Enhancement Script
Authors: Nathmatt
Version: 1.72
Type: ADD_ON
Key Term: Custom Movement System



Introduction
Adds movement by clicking the mouse to the Mouse Controller Script by Blizzard
Requires Mouse Controller by Blizzard


Features

  • Movement by clicking the mouse
  • Activate events when you reach them by clicking
  • Activate events by clicking on them
  • Allows changing the mouse icon while over a special named event
  • Allows displaying text over special named event while the mouse is over them
  • Configurable no click terrain tag
  • Configurable event message text color
  • Configurable event message text size
  • Configurable click graphic that will be placed when you click on a location
  • Configurable range if clicked distance is higher than the set range you will not move
  • Allows right click event commands
  • Allows unlocking doors doors
  • Allows disabling with $MCES.disabled
  • Allows disabling movement with $MCES.movement_disabled
  • Allows true event clicking meaning if you click an empty spot on the sprite it will not run



Screenshots
no screenshot needed


Demo

No Demo


Script



Instructions

place below Mouse Controler

in the script


Compatibility
not compatible with pixel movement will automatically turn it off


Credits and Thanks


  • Nathmatt
  • Blizzard for the Mouse Controller script and the path finder from Blizz-Abs
  • Near Fantastica and Zeriab for the input module that allows you to use without any other input modules



Author's Notes
Any suggestions for updates are appreciated
72
RMXP Script Database / [XP] Simple Event Ai
March 03, 2010, 07:08:00 pm
Simple Event Ai
Authors: Nathmatt
Version: 1.16
Type: Add-on
Key Term: Misc Add-on



Introduction
Makes events chase you when you get within range.
If the event gets to far from original location return to original location,
allows events to run from you, and when events see you turns on a configurable switch


Features


  • all configurations are done in events name



Screenshots
no screen shot needed


Demo
will add when i can make an actual demo


Script
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Simple Event Ai by Nathmatt
# Version: 1.16
# Type: Add On
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  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.
# #  
# #-----------------------------------------------------------------------------
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Config  
#-------------------------------------------------------------------------------
#  This module provides the configurations.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
module Config
 # the event tag that blocks the view events
 Wall = 1
end
#==============================================================================
# Game_Map
#------------------------------------------------------------------------------
#  This class adds check names to the original Game_Map.
#==============================================================================
class Game_Map
 attr_reader   :map
 alias setup_Event_Ai_later setup
 def setup(map_id)
   setup_Event_Ai_later(map_id)
   check_names
 end
 #--------------------------------------------------------------------------
 # check_names
 #  This calls the check_event_names on all the event on the map.
 #--------------------------------------------------------------------------
 def check_names
   $game_map.events.each_key {|i|
   check_event_names(i) if $game_map.events[i] != nil}
 end
 #--------------------------------------------------------------------------
 # check_event_name
 #  event_id - event ID
 #  Checks events name and adds its id to the proper array.
 #  Then stores a few needed variables
 #--------------------------------------------------------------------------
 def check_event_names(event_id)
   event = @map.events[event_id]
   if event.name.clone.gsub!(/\\[Pp]\[([\d, ]+)\]/) {"#[$1]"}
     get = eval("[#{$1}]")
     view = get[0]
     range = get[1]
     target_id = get[2]
     type = 4
   end
   if event.name.clone.gsub!(/\\[Rr]\[([\d, ]+)\]/) {"#[$1]"}
     get = eval("[#{$1}]")
     view = get[0]
     target_id = get[1]
     type = 2
   end
   if event.name.clone.gsub!(/\\[Cc]\[([\d, ]+)\]/) {"#[$1]"}
     get = eval("[#{$1}]")
     view = get[0]
     target_id = get[1]
     type = 1
   end
   if event.name.clone.gsub!(/\\[Vv]\[([\d, ]+)\]/) {"#[$1]"}
     get = eval("[#{$1}]")
     view = get[0]
     switch_id = get[1]
     target_id = get[2]
     type = 3
   end
   if type.is_a?(Numeric) && type != nil
     view = 0 if !view.is_a?(Numeric) || view == nil
     target_id = 0 if target_id == nil
     $game_map.events[event_id] = Ai_Event.new($game_map.map_id,event,view,type,
     range,event.x,event.y,target_id,switch_id)
   end
 end
end
Location_Holder = Struct.new(:x, :y)
#==============================================================================
# ** Ai_Event
#------------------------------------------------------------------------------
#  This is a modified version of Game_Event that controls the events movements
#  @ whether or not the event can see its target.
#==============================================================================

class Ai_Event < Game_Character
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader   :trigger                  # trigger
 attr_reader   :list                     # list of event commands
 attr_reader   :starting                 # starting flag
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     map_id : map ID
 #     event  : event (RPG::Event)
 #--------------------------------------------------------------------------
 def initialize(map_id,event,view,type,range,start_x,start_y,target_id,
   switch_id = nil)
   super()
   @map_id        = map_id
   @event         = event
   @id            = event.id
   @view          = view
   @type          = type
   @range         = range
   @switch_id     = switch_id
   @erased        = false
   @starting      = false
   @through       = true
   #call dummy class
   @start = Location_Holder.new(start_x,start_y)
   # get type from type
   @target = check_target(target_id)
   # Move to starting position
   moveto(@event.x, @event.y)
   refresh
 end
 #--------------------------------------------------------------------------
 # * Clear Starting Flag
 #--------------------------------------------------------------------------
 def clear_starting
   @starting = false
 end
 #--------------------------------------------------------------------------
 # * Determine if Over Trigger
 #    (whether or not same position is starting condition)
 #--------------------------------------------------------------------------
 def over_trigger?
   # If not through situation with character as graphic
   # Starting determinant is face
   return false if @character_name != "" and not @through
   # If this position on the map is impassable
   # Starting determinant is face
   return false unless $game_map.passable?(@x, @y, 0)
   # Starting determinant is same position
   return true
 end
 #--------------------------------------------------------------------------
 # * Start Event
 #--------------------------------------------------------------------------
 def start
   # If list of event commands is not empty
   @starting = true if @list.size > 1
 end
 #--------------------------------------------------------------------------
 # * Temporarily Erase
 #--------------------------------------------------------------------------
 def erase
   @erased = true
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   # Initialize local variable: new_page
   new_page = nil
   # If not temporarily erased
   unless @erased
     # Check in order of large event pages
     @event.pages.reverse.each { |page|
     # Make possible referrence for event condition with c
     c = page.condition
     # Switch 1 condition confirmation
     if c.switch1_valid
       next if $game_switches[c.switch1_id] == false
     end
     # Switch 2 condition confirmation
     if c.switch2_valid
       next if $game_switches[c.switch2_id] == false
     end
     # Variable condition confirmation
     if c.variable_valid
       next if $game_variables[c.variable_id] < c.variable_value
     end
     # Self switch condition confirmation
     if c.self_switch_valid
       key = [@map_id, @event.id, c.self_switch_ch]
       next if $game_self_switches[key] != true
     end
     # Set local variable: new_page
     new_page = page
     # Remove loop
     break}
   end
   # If event page is the same as last time
   return if new_page == @page
   # Set @page as current event page
   @page = new_page
   # Clear starting flag
   clear_starting
   # If no page fulfills conditions
   if @page == nil
     # Set each instance variable
     @tile_id = 0
     @character_name = ""
     @character_hue = 0
     @move_type = 0
     @through = true
     @trigger = nil
     @list = nil
     @interpreter = nil
     # End method
     return
   end
   # Set each instance variable
   @tile_id = @page.graphic.tile_id
   @character_name = @page.graphic.character_name
   @character_hue = @page.graphic.character_hue
   if @original_direction != @page.graphic.direction
     @direction = @page.graphic.direction
     @original_direction = @direction
     @prelock_direction = 0
   end
   if @original_pattern != @page.graphic.pattern
     @pattern = @page.graphic.pattern
     @original_pattern = @pattern
   end
   @opacity = @page.graphic.opacity
   @blend_type = @page.graphic.blend_type
   @original_type = @page.move_type
   @move_speed = @page.move_speed
   @move_frequency = @page.move_frequency
   @move_route = @page.move_route
   @move_route_index = 0
   @move_route_forcing = false
   @walk_anime = @page.walk_anime
   @step_anime = @page.step_anime
   @direction_fix = @page.direction_fix
   @through = @page.through
   @always_on_top = @page.always_on_top
   @trigger = @page.trigger
   @list = @page.list
   @interpreter = nil
   # If trigger is [parallel process]
   # Create parallel process interpreter
   @interpreter = Interpreter.new if @trigger == 4
   # Auto event start determinant
   check_event_trigger_auto
 end
 #--------------------------------------------------------------------------
 # * Touch Event Starting Determinant
 #--------------------------------------------------------------------------
 def check_event_trigger_touch(x, y)
   # If event is running
   return if $game_system.map_interpreter.running?
   # If trigger is [touch from event] and consistent with player coordinates
   if @trigger == 2 && x == $game_player.x && y == $game_player.y
     # If starting determinant other than jumping is front event
     start if ! jumping? && ! over_trigger?
   end
 end
 #--------------------------------------------------------------------------
 # * Automatic Event Starting Determinant
 #--------------------------------------------------------------------------
 def check_event_trigger_auto
   # If trigger is [touch from event] and consistent with player coordinates
   if @trigger == 2 && @x == $game_player.x && @y == $game_player.y
     # If starting determinant other than jumping is same position event
     start if ! jumping? && over_trigger?
   end
   # If trigger is [auto run]
   start if @trigger == 3
 end
 #------------------------------------------------------------------------
 # check_event_trigger_at
 #  x - x-coordinate
 #  y - y-coordinate
 #  Check event if it was triggered at a specific position.(pixel movement)
 #------------------------------------------------------------------------
 def check_event_trigger_at(x, y)
   # get pixel movement rate
   pix = $BlizzABS.pixel
   # if player touched this event and not jumping and not over_trigger
   if !jumping? && !over_trigger? && $BlizzABS.util.rect_intersection(
     Rect.new(@x * pix, @y * pix, pix, pix), Rect.new(x, y, pix, pix))
     # start
     start
     # started
     return true
   end
   # not started
   return false
 end
 #--------------------------------------------------------------------------
 # distance_from_target(target)
 #  target - is the target
 #  Checks the distance from self and target and returns it.
 #--------------------------------------------------------------------------
 def distance_from_target(target)
   return Math.hypot((@x - target.x),(@y - target.y))
 end
 #--------------------------------------------------------------------------
 # check_target(target_id)
 #  target_id - is the event id unless it equals 0 thean its the player
 #  Checks what kind of target and returns it.
 #--------------------------------------------------------------------------
 def check_target(target_id)
   return $game_player if target_id == 0
   return $game_map.events[target_id] if target_id > 0
 end
 #--------------------------------------------------------------------------
 # move_type_away
 #  moves self away from target if in view
 #--------------------------------------------------------------------------
 def move_type_away
   if distance_from_target(@target) <= @view
     move_away
   else
     @original_type
   end
 end
 #--------------------------------------------------------------------------
 # move_type_toward
 #  moves self toward from target if in view
 #--------------------------------------------------------------------------
 def move_type_toward
   if distance_from_target(@target) <= @view
     move_toward(@target)
   else
     @original_type
   end
 end
 #--------------------------------------------------------------------------
 # view_type
 #  turns on defined switch if event can_see? self
 #--------------------------------------------------------------------------
 def view_type
   if can_see?
     $game_switches[@switch_id] = true
     $game_map.refresh
   end
   return
 end
 #--------------------------------------------------------------------------
 # passave_type
 #  moves self toward target unless it gets out of range from start
 #--------------------------------------------------------------------------
 def passave_type
   if distance_from_target(@target) < @view
     if distance_from_target(@start) > @range
       move_toward(@start)
     else
       move_toward(@target)
     end
   else
     return move_toward(@start)
   end
 end
 #--------------------------------------------------------------------------
 # change_type
 #--------------------------------------------------------------------------
 def change_type(type,view,target_id = nil,range = nil,switch_id = nil)
   @type = type
   @view = view
   @target_id = target_id if target_id != nil
   @range = range if range != nil
   @swith_id = switch_id if switch_id != nil
 end
 #--------------------------------------------------------------------------
 # can_see?
 #  event_id - is the events id
 #  This checks to see if the event can see you.
 #--------------------------------------------------------------------------
 def can_see?
   (0...@view).each { |r|
   case @direction
   when 2
     if $game_map.terrain_tag(@x, (@y + r)) == Config::Wall
       break
     elsif @target.x == @x && @target.y == (@y + r)
       return true
     end
   when 4
     if $game_map.terrain_tag((@x - r), @y) == Config::Wall
       break
     elsif @target.x == (@x - r) && @target.y == @y
       return true
     end
   when 6
     if $game_map.terrain_tag((@x + r), @y) == Config::Wall
       break
     elsif @target.x == (@x + r) && @target.y == @y
       return true
     end
   when 8
     if $game_map.terrain_tag(@x, (@y - r)) == Config::Wall
       break
     elsif @target.x == @x && @target.y == (@y - r)
       return true
     end
   end}
   return false
 end
 def check_other(x,y,d)
   case d
   when 2
     if passable?(x, y,4)
       return move_left
     elsif passable?(x, y,6)
       return move_right
     elsif passable?(x, y,8)  
       return move_up
     end
   when 4
     if passable?(x, y,2)
       return move_down
     elsif passable?(x, y,8)
       return move_up
     elsif passable?(x, y,6)
       return move_right
     end
   when 6
     if passable?(x, y,2)
       return move_down
     elsif passable?(x, y,8)
       return move_up
     elsif passable?(x, y,4)
       return move_left
     end
   when 8
     if passable?(x, y,4)
       return move_left
     elsif passable?(x, y,6)
       return move_right
     elsif passable?(x, y,2)
       return move_down
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Move toward target
 #--------------------------------------------------------------------------
 def move_toward(target)
   # Returns if it is targeting itself
   return if target == @event
   # Get difference in target and selfs coordinates
   sx = @x - target.x
   sy = @y - target.y
   # If coordinates are equal
   return @original_type if sx == 0 && sy == 0
   # Get absolute value of difference
   abs_sx = sx.abs
   abs_sy = sy.abs
   # If horizontal and vertical distances are equal
   # Increase one of them randomly by 1
   rand(2) == 0 ? abs_sx += 1 : abs_sy += 1 if abs_sx == abs_sy
   # If horizontal distance is longer
   if abs_sx > abs_sy
     # Move towards player, prioritize left and right directions
     sx > 0 ? move_left : move_right
     sy > 0 ? move_up : move_down if ! moving? && sy != 0
     # If vertical distance is longer
   else
     # Move towards player, prioritize up and down directions
     sy > 0 ? move_up : move_down
     sx > 0 ? move_left : move_right if ! moving? && sx != 0
   end
   return
 end
 #--------------------------------------------------------------------------
 # * Move away from target
 #--------------------------------------------------------------------------
 def move_away
   # Returns if it is targeting itself
   return if @target == @event
   # Get difference in target and selfs coordinates
   sx = @x - @target.x
   sy = @y - @target.y
   if !passable?(@x, @y,@direction)
     check_other(@x, @y,@direction)
   else  
     # If coordinates are equal
     return if sx == 0 && sy == 0
     # Get absolute value of difference
     abs_sx = sx.abs
     abs_sy = sy.abs
     # If horizontal and vertical distances are equal
     # Increase one of them randomly by 1
     rand(2) == 0 ? abs_sx += 1 : abs_sy += 1 if abs_sx == abs_sy
     # If horizontal distance is longer
     if abs_sx > abs_sy
       # Move away from player, prioritize left and right directions
       sx > 0 ? move_right : move_left
       sy > 0 ? move_down : move_up if ! moving? && sy != 0
       # If vertical distance is longer
     else
       # Move away from player, prioritize up and down directions
       sy > 0 ? move_down : move_up
       sx > 0 ? move_right : move_left if ! moving? && sx != 0
     end
   end
   return
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   super
   # Automatic event starting determinant
   check_event_trigger_auto
   # If parallel process is valid
   if @interpreter != nil
     # If not running
     unless @interpreter.running?
       # Set up event
       @interpreter.setup(@list, @event.id)
     end
     # Update interpreter
     @interpreter.update
   end
   # If stop count exceeds a certain value (computed from move frequency)
   if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
     @move_type = case @type
     when 1
       move_type_toward
     when 2
       move_type_away
     when 3
       view_type
     when 4
       passave_type
     end
   end
 end
end

class Control_Sprite_Character
 
 #----------------------------------------------------------------------------
 # character_valid?
 #  Checks if this sprite should be displayed and updated.
 #----------------------------------------------------------------------------
 def character_valid?
   return (@character.is_a?(Game_Event) || @character.is_a?(Ai_Event) ||
       @character.is_a?(Map_Enemy) &&
       @character.precondition || @character.is_a?(Map_Remote) ||
       @character.dropped?) && @character.update? ||
       !@character.is_a?(Map_Enemy) && !@character.is_a?(Map_Remote) &&
       @character.is_a?(Map_Battler)
 end
     
end



Instructions
just name ur event  \p[array] where array is add array of ranges
(example \p[5,7] would be when your distance is 5 from them they chase you and when they get 7 distance from there original location they run back
if you want them to run from you name them \r[range] range is how close you get before they start running from you
/v[range,switch_id] range is the events cant see you switch_id is the id of the switch that turns on when the event
sees you
\c[range,target] event will chase the target when within range
target is either 0 for player or event_id


Compatibility
no compatible issues known


Credits and Thanks


  • Nathmatt
  • Blizzard for his check event name
  • Game_Guy For the events run from you



Author's Notes
no notes
73
RMXP Script Database / [XP] Nathmatt's Command_Window
February 17, 2010, 01:01:48 pm
Nathmatt's Command_Window
Authors: Nathmatt
Version: 1.00
Type: Command-replacement
Key Term:Menu Add-on



Introduction

A replacement for the normal command window


Features


  • Allows you to set the height so you can fit the command any where you want
  • Allows you to choose an alignment default 0 (left)
  • Allows you to add as many commands you want without increasing the height past the height



Screenshots

no screenshot needed



Demo

No Demo


Script

Above Main
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Nathmatt's Command_Window by Nathmatt
# Version: 1.00
# Type: Command-replacement
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  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.
# #  
# #-----------------------------------------------------------------------------
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Directions
#------------------------------------------------------------------------------
#  Window_Commands.new(width,height,commands,align)
#  
#  width    ~ is the width of the command window.
#  height   ~ is the height of the command window.
#  commands ~ is the array of the commands same as normal command.
#  align    ~ set align to 1 to center the text and to 2 to right-align it.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# ** Window_Commands
#------------------------------------------------------------------------------
#  This window displays the command list
#==============================================================================
class Window_Commands < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     actor : actor
 #--------------------------------------------------------------------------
 def initialize(width,height,commands = [],align = 0)
   super(0, 0, width, height)
   @commands = commands
   @width = width - 32
   @align = align
   @column_max = 1
   @size = @commands.size
   refresh
 end
 #--------------------------------------------------------------------------
 # * Get Item
 #--------------------------------------------------------------------------
 def item
   return @data[self.index]
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   # Add item
   (0...@size).each { |i| @data.push(@commands[i])}
   # If item count is not 0, make a bit map and draw all items
   @item_max = @data.size
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, row_max * 32)
     (0...@item_max).each{ |i| draw_item(i)}
   end
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #     index : item number
 #--------------------------------------------------------------------------
 def draw_item(index)
   item = @data[index]
   x = index % 1 * (@width)
   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))
   self.contents.draw_text(x, y, @width, 32, item,@align)
 end
end



Instructions

Window_Commands.new(width,height,commands,align)

 width    ~ is the width of the command window.
 height   ~ is the height of the command window.
 commands ~ is the array of the commands same as normal command.
 align    ~ set align to 1 to center the text and to 2 to right-align it.



Compatibility

no compatibility issues known


Credits and Thanks


  • Nathmatt


74
General Discussion / Menu
February 01, 2010, 01:54:02 pm
Didn't know where to put this just wanted to know what you thing of my menu so far

Spoiler: ShowHide

Spoiler: ShowHide

Spoiler: ShowHide

Spoiler: ShowHide

Spoiler: ShowHide
75
General Discussion / What game is this menu from
January 21, 2010, 08:09:56 pm
i came across screen shot of this menu but don't know what game its from any 1 know
didn't really know where to put this
thats alright i just made the widows how i figured it should work 

Spoiler: ShowHide
76
Resources / sprite help
January 20, 2010, 10:10:56 am
just want to see what you think of these what can i do to improve here,s a screen shot of the ones ive made so far

edit: no one has any feedback
edit2: animated it


Spoiler: ShowHide


Spoiler: ShowHide
77
RPG Maker Scripts / Party hud
January 16, 2010, 07:34:45 am
ok so be4 i make it where the hud redraws more then 1nce the all my ys are fine but as soon as i tell it to draw edit it to make more than 1 they get all shoved together

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

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

class Bitmap

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

class Game_Actor
 
  #----------------------------------------------------------------------------
  # now_exp
  #  Returns the EXP collected in this level.
  #----------------------------------------------------------------------------
  def now_exp
    return @exp - @exp_list[@level]
  end
  #----------------------------------------------------------------------------
  # next_exp
  #  Returns the EXP needed to level up as number.
  #----------------------------------------------------------------------------
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
 
end
78
RPG Maker Scripts / Over Drive in HUD(resolved)
January 15, 2010, 07:10:47 pm
ok i added over drive to my hud but when it = 2.0 the fill_rect that refreshes it over lays it does fine when it = 1.0 but after that it over lays

#==============================================================================
# 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
   # create positions
   create_positions
   # create bitmap
   self.bitmap = Bitmap.new(@hud_width, @hud_height)
   # set font
   self.bitmap.font.name = 'Arial'
   # set font size
   self.bitmap.font.size = 16
   # set font to bold
   self.bitmap.font.bold = true
   # set x, y position
   self.x, self.y = -4, 4
   # set z coordinate
   self.z = 1000
   # draw basic HUD
   draw_basic
   # update
   update
 end
 #----------------------------------------------------------------------------
 # create_positions
 #  Sets drawing positions. This method can be aliased and the positions
 #  modified to create a different HUD.
 #----------------------------------------------------------------------------
 def create_positions
   @original_width = @hud_width = 275
   @original_height = @hud_height = 120
   @face_x,@face_y, @exp_x, @exp_y = 4, 4, 4, 100
   @name_x, @name_y, @level_x, @level_y = 167, 1, 112, 1
   @hp_x, @hp_y, @sp_x, @sp_y = 125, 42, 115, 55
   @hot_x, @hot_y, @left_x, @left_y = 580, 150, 610, 150
   @over_drive_x, @over_drive_y = 105, 68
 end
 #----------------------------------------------------------------------------
 # draw_basic
 #  Draws the HUD template.
 #----------------------------------------------------------------------------
 def draw_basic
   # fill with grey rectangle
   self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height,
       Color.new(0, 0, 0, 0))
   # set font color
   self.bitmap.font.color = system_color
   # draw "LV"
   self.bitmap.draw_text_full(@level_x, @level_y, 20, 20, 'LV')
   # if direct hotkey option is turned off
   unless BlizzABS::Config::DIRECT_HOTKEYS
     # draw "Skill:"
     self.bitmap.draw_text_full(@hot_x, @hot_y+50, 48, 20, 'Skill:')
     # draw "Item:"
     self.bitmap.draw_text_full(@hot_x, @hot_y, 48, 20, 'Item:')
   end
   # draw "HP"
   self.bitmap.draw_text_full(@hp_x, @hp_y, 32, 20, $data_system.words.hp)
   # draw "SP"
   self.bitmap.draw_text_full(@sp_x, @sp_y, 32, 20, $data_system.words.sp)
   # draw "EXP"
   self.bitmap.draw_text_full(@exp_x, @exp_y, 32, 20, 'EXP')
   # draw "OVERDRIVE"
   self.bitmap.draw_text_full(@over_drive_x, @over_drive_y, 32, 20,
   BlizzCFG::OVERDRIVE_NAME.to_s)
   
 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(@hp_x+32, @hp_y+3, 114, 0, 'hud_green_bar', 1)
   # draw empty bars
   self.bitmap.gradient_bar_hud(@sp_x+32, @sp_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(@hp_x+38, @hp_y, 48, 20, '0', 2)
   self.bitmap.draw_text_full(@hp_x+86, @hp_y, 12, 20, '/', 1)
   self.bitmap.draw_text_full(@hp_x+98, @hp_y, 48, 20, '0')
   # draw empty SP
   self.bitmap.draw_text_full(@sp_x+38, @sp_y, 48, 20, '0', 2)
   self.bitmap.draw_text_full(@sp_x+86, @sp_y, 12, 20, '/', 1)
   self.bitmap.draw_text_full(@sp_x+98, @sp_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_name
   # set current variable
   @name = actor.name
   # remove old display
   self.bitmap.fill_rect(@name_x, @name_y, 104, 20, Color.new(0, 0, 0, 0))
   # set font color
   self.bitmap.font.color = Color.new(0, 255, 0)
   # draw actor's name
   self.bitmap.draw_text_full(@name_x, @name_y, 104, 20, @name)
 end
 #----------------------------------------------------------------------------
 # draw_face
 #  Draws the face display.
 #----------------------------------------------------------------------------
 def draw_face
   # set current variable
   @face = actor.name
   # remove old display
   self.bitmap.fill_rect(@face_x, @face_y, 100, 100, Color.new(0, 0, 0, 0))
   # load bitmap
   bitmap = RPG::Cache.picture('Faces/'+@face+'_L')
   # draw bitmap
   self.bitmap.blt(@face_x, @face_y, bitmap, Rect.new(0, 0, 100, 100))
 end
 #----------------------------------------------------------------------------
 # draw_level
 #  Draws the level display.
 #----------------------------------------------------------------------------
 def draw_level
   # set current variable
   @level = actor.level
   # remove old display
   self.bitmap.fill_rect(@level_x+20, @level_y, 20, 20, Color.new(0, 0, 0, 0))
   # set font color
   self.bitmap.font.color = normal_color
   # draw actor's level
   self.bitmap.draw_text_full(@level_x+20, @level_y, 20, 20, @level.to_s, 2)
 end
 #----------------------------------------------------------------------------
 # draw_hp
 #  Draws the HP display.
 #----------------------------------------------------------------------------
 def draw_hp
   # set current variables
   @hp, @maxhp = actor.hp, actor.maxhp
   # remove old display
   self.bitmap.fill_rect(@hp_x+22, @hp_y+15, 150, 14, Color.new(0, 0, 0, 0))
   # Calculate The Rate
   rate = (actor.maxhp > 0 ? actor.hp.to_f / actor.maxhp : 0)
   # Draw Color For The Bar
   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 gradient bar
   self.bitmap.gradient_bar(@hp_x+22,@hp_y-15,114,color1,color2,color3,rate)
   # set font color depending on how many HP left
   self.bitmap.font.color = @hp == 0 ? knockout_color :
       @hp <= @maxhp / 4 ? crisis_color : normal_color
   # draw HP
   self.bitmap.draw_text_full(@hp_x+28, @hp_y, 48, 20, @hp.to_s, 2)
   # set color
   self.bitmap.font.color = normal_color
   # draw "/"
   self.bitmap.draw_text_full(@hp_x+76, @hp_y, 12, 20, '/', 1)
   # draw max HP
   self.bitmap.draw_text_full(@hp_x+88, @hp_y, 48, 20, @maxhp.to_s)
 end
 #----------------------------------------------------------------------------
 # draw_sp
 #  Draws the SP display.
 #----------------------------------------------------------------------------
 def draw_sp
   # set current variables
   @sp, @maxsp = actor.sp, actor.maxsp
   # remove old display
   self.bitmap.fill_rect(@sp_x+22, @sp_y+15, 150, 14, Color.new(0, 0, 0, 0))
   # Calculate The Rate
   rate = (actor.maxsp > 0 ? actor.sp.to_f / actor.maxsp : 0)
   # Draw Color For The Bar
   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, 80, 0, 192)
   # draw gradient bar
   self.bitmap.gradient_bar(@sp_x+22, @sp_y-15, 114, color1, color2, color3,
   rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = @sp == 0 ? knockout_color :
       @sp <= @maxsp / 4 ? crisis_color : normal_color
   # draw SP
   self.bitmap.draw_text_full(@sp_x+28, @sp_y, 48, 20, @sp.to_s, 2)
   # set font color
   self.bitmap.font.color = normal_color
   # draw "/"
   self.bitmap.draw_text_full(@sp_x+76, @sp_y, 12, 20, '/', 1)
   # draw max SP
   self.bitmap.draw_text_full(@sp_x+88, @sp_y, 48, 20, @maxsp.to_s)
 end
 #----------------------------------------------------------------------------
 # draw_over_drive
 #  Draws the over_drive display.
 #----------------------------------------------------------------------------
 def draw_over_drive
   # set current variables
   @over_drive = $game_party.actors[0].overdrive
   # remove old display
   self.bitmap.fill_rect(@over_drive_x+22, @over_drive_y+15, 150, 14,
   Color.new(0, 0, 0, 0))
   # draw gradient bar
   self.bitmap.draw_actor_overdrive_with_bar(actor, @over_drive_x+22,
   @over_drive_y-15, 124)
   self.bitmap.draw_text_full(@over_drive_x+76, @over_drive_y, 48, 20,
   actor.overdrive_text)
 end
 #----------------------------------------------------------------------------
 # draw_exp
 #  Draws the EXP display.
 #----------------------------------------------------------------------------
 def draw_exp
   # set current variables
   @now_exp, @next_exp = actor.now_exp, actor.next_exp
   # remove old display
   self.bitmap.fill_rect(@exp_x+32, @exp_y, 58, 14, Color.new(0, 0, 0, 0))
   # Calculate The Rate
   rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
   # Draw Color For The Bar
   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
   # background color
   color3 = Color.new(0, 80, 0, 192)
   # draw gradient bar
   self.bitmap.gradient_bar(@exp_x+32, @exp_y-18, 57, color1, color2, color3,
   rate)
 end
 #----------------------------------------------------------------------------
 # draw_hskill
 #  Draws the hot skill display.
 #----------------------------------------------------------------------------
 def draw_hskill
   # set current variable
   @skill = actor.skill
   # remove old display
   self.bitmap.fill_rect(@hot_x, @hot_y+74, 24, 24, Color.new(0, 0, 0, 0))
   # if skill hot skill exists
   if @skill != 0
     # load bitmap
     bitmap = RPG::Cache.icon($data_skills[@skill].icon_name)
     # draw bitmap
     self.bitmap.blt(@hot_x, @hot_y+74, bitmap, Rect.new(0, 0, 24, 24))
   end
   # removes skills left to use display
   draw_lskill
 end
 #----------------------------------------------------------------------------
 # draw_lskill
 #  Draws the skills left to use display.
 #----------------------------------------------------------------------------
 def draw_lskill
   # remove old display
   self.bitmap.fill_rect(@left_x, @left_y+50, 24, 16, Color.new(0, 0, 0, 0))
   # get the number of skills left
   @skills_left = get_skills_left
   # if hot skill exists
   if @skill != nil && @skill > 0
     # if normal SP cost
     if @skills_left >= 0
       # if not enough sp to use
       if @skills_left == 0
         # set font color
         self.bitmap.font.color = Color.new(255, 0, 0)
       # if enough SP for 5 or less skill uses
       elsif @skills_left <= 5
         # set font color
         self.bitmap.font.color = Color.new(255, 255, 0)
       else
         # set font color
         self.bitmap.font.color = normal_color
       end
       # decrease font color
       self.bitmap.font.size -= 2
       # draw number how many skills left to use
       self.bitmap.draw_text_full(@left_x, @left_y+50, 24, 20,
       @skills_left.to_s, 1)
       # increase font size
       self.bitmap.font.size += 2
     # if infinite skills left
     elsif @skills_left == -1
       # set font color
       self.bitmap.font.color = Color.new(0, 255, 0)
       # increase font size
       self.bitmap.font.size += 4
       # draw "∞" skill uses left
       self.bitmap.draw_text_full(@left_x, @left_y+50, 24, 20, '∞', 1)
       # decrease font size
       self.bitmap.font.size -= 4
     end
   end
 end
 #----------------------------------------------------------------------------
 # get_skills_left
 #  Gets the number of skill usages left.
 #----------------------------------------------------------------------------
 def get_skills_left
   # if skill hot skill exists
   if @skill != nil && @skill > 0
     # if SP cost is zero
     if $data_skills[@skill].sp_cost > 0
       # get basic SP cost
       sp_cost = $data_skills[@skill].sp_cost
       # if using SP Cost Mod Status
       if $tons_version != nil && $tons_version >= 6.54 &&
           $game_system.SP_COST_MOD
         # get modified cost
         sp_cost = BlizzCFG.get_cost_mod(actor.states, sp_cost)
       end
       # infinite
       return -1 if sp_cost == 0
       # calculate skills left to use
       return @sp / sp_cost
     end
     # set flag
     return -1
   end
   # set flag
   return -2
 end
 #----------------------------------------------------------------------------
 # draw_hitem
 #  Draws the hot item display.
 #----------------------------------------------------------------------------
 def draw_hitem
   # set current variable
   @item = actor.item
   # remove old display
   self.bitmap.fill_rect(@hot_x, @hot_y+24, 24, 24, Color.new(0, 0, 0, 0))
   # if hot item exists
   if @item != 0
     # load bitmap
     bitmap = RPG::Cache.icon($data_items[@item].icon_name)
     # draw bitmap
     self.bitmap.blt(@hot_x, @hot_y+24, bitmap, Rect.new(0, 0, 24, 24))
   end
   # removes items left to use display
   draw_litem
 end
 #----------------------------------------------------------------------------
 # draw_litem
 #  Draws the items left to use display.
 #----------------------------------------------------------------------------
 def draw_litem
   # set current variable
   @items_left = $game_party.item_number(@item)
   # remove old display
   self.bitmap.fill_rect(@left_x, @left_y, 24, 16, Color.new(0, 0, 0, 0))
   # if hot item exists
   if @item != nil && @item > 0
     # if item exists and cannot be consumed
     if $data_items[@item] != nil && !$data_items[@item].consumable
       # set font color
       self.bitmap.font.color = Color.new(0, 255, 0)
       # increase font size
       self.bitmap.font.size += 4
       # draw "∞" items left
       self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, '∞', 1)
       # decrease font size
       self.bitmap.font.size -= 4
     else
       # if no items left
       if @items_left == 0
         # set font color
         self.bitmap.font.color = Color.new(255, 0, 0)
       # if equal or less items left
       elsif @items_left <= 10
         # set font color
         self.bitmap.font.color = Color.new(255, 255, 0)
       else
         # set font color
         self.bitmap.font.color = normal_color
       end
       # decrease font color
       self.bitmap.font.size -= 2
       # draw number how many items left to use
       self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, @items_left.to_s, 1)
       # increase font size
       self.bitmap.font.size += 2
     end
   end
 end
 #----------------------------------------------------------------------------
 # update
 #  Checks if HUD needs refreshing.
 #----------------------------------------------------------------------------
 def update
   
   # if 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_name
       draw_face
       draw_level
       draw_hp
       draw_sp
       draw_exp
       draw_over_drive
       # remove flag
       $game_temp.hud_refresh = nil
     else
       # draw data that needs to ve updated
       test_name
       test_face
       test_level
       test_hp
       test_sp
       test_exp
       test_over_drive
     end
     # empty HUD wasn't drawn
     @empty_hud_drawn = false
   end
 end
 #----------------------------------------------------------------------------
 # test_face
 #  Tests and draws the name.
 #----------------------------------------------------------------------------
 def test_face
   # draw new face if face has changed
  draw_face if actor.name != @face
 end
 #----------------------------------------------------------------------------
 # test_exp
 #  Tests and draws the name.
 #----------------------------------------------------------------------------
 def test_over_drive
   # draw new name if name has changed
   draw_over_drive if  @over_drive != $game_party.actors[0].overdrive
 end
 #----------------------------------------------------------------------------
 # test_exp
 #  Tests and draws the name.
 #----------------------------------------------------------------------------
 def test_exp
   # draw new name if name has changed
   draw_exp if actor.now_exp != @now_exp|| actor.next_exp != @next_exp
 end
 #----------------------------------------------------------------------------
 # test_name
 #  Tests and draws the name.
 #----------------------------------------------------------------------------
 def test_name
   # draw new name if name has changed
   draw_name if actor.name != @name
 end
 #----------------------------------------------------------------------------
 # test_level
 #  Tests and draws the level.
 #----------------------------------------------------------------------------
 def test_level
   # draw new level if level has changed
   draw_level if actor.level != @level
 end
 #----------------------------------------------------------------------------
 # test_hp
 #  Tests and draws the HP.
 #----------------------------------------------------------------------------
 def test_hp
   # draw new HP if HP or max HP have changed
   draw_hp if actor.hp != @hp || actor.maxhp != @maxhp
 end
 #----------------------------------------------------------------------------
 # test_sp
 #  Tests and draws the SP.
 #----------------------------------------------------------------------------
 def test_sp
   # draw new SP if SP or max SP have changed
   draw_sp if actor.sp != @sp || actor.maxsp != @maxsp
 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
79
Script Troubleshooting / Blizz-ABS custum hud
January 14, 2010, 01:59:04 pm
my positions aren't working right on my par hud

full script

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of
#  this class.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :par_hud                # sets the par hud variable
  attr_accessor :bar_style              # Bar Style
  attr_accessor :bar_opacity            # The Bars Opacity
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias nathmatt_config initialize
  def initialize
    nathmatt_config
    @par_hud        = true
    @bar_style      = 0
    @bar_opacity    = 255
  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
    # create positions
    create_positions
    # create bitmap
    self.bitmap = Bitmap.new(@hud_width, @hud_height)
    # set font
    self.bitmap.font.name = 'Arial'
    # set font size
    self.bitmap.font.size = 16
    # set font to bold
    self.bitmap.font.bold = true
    # set x, y position
    self.x, self.y = 4, 4
    # set z coordinate
    self.z = 1000
    # draw basic HUD
    draw_basic
    # update
    update
  end
  #----------------------------------------------------------------------------
  # create_positions
  #  Sets drawing positions. This method can be aliased and the positions
  #  modified to create a different HUD.
  #----------------------------------------------------------------------------
  def create_positions
    @original_width = @hud_width = 275
    @original_height = @hud_height = 120
    @face_x,@face_y, @exp_x, @exp_y = 4, 4, 4, 100
    @name_x, @name_y, @level_x, @level_y = 167, 1, 112, 1
    @hp_x, @hp_y, @sp_x, @sp_y = 130, 37, 110, 63
    @hot_x, @hot_y, @left_x, @left_y = 580, 150, 610, 150
  end
  #----------------------------------------------------------------------------
  # draw_basic
  #  Draws the HUD template.
  #----------------------------------------------------------------------------
  def draw_basic
    # fill with grey rectangle
    self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height,
        Color.new(0, 0, 0, 0))
    # set font color
    self.bitmap.font.color = system_color
    # draw "LV"
    self.bitmap.draw_text_full(@level_x, @level_y, 20, 20, 'LV')
    # if direct hotkey option is turned off
    unless BlizzABS::Config::DIRECT_HOTKEYS
      # draw "Skill:"
      self.bitmap.draw_text_full(@hot_x, @hot_y+50, 48, 20, 'Skill:')
      # draw "Item:"
      self.bitmap.draw_text_full(@hot_x, @hot_y, 48, 20, 'Item:')
    end
    # draw "HP"
    self.bitmap.draw_text_full(@hp_x, @hp_y, 32, 20, $data_system.words.hp)
    # draw "SP"
    self.bitmap.draw_text_full(@sp_x, @sp_y, 32, 20, $data_system.words.sp)
    # draw "SP"
    self.bitmap.draw_text_full(@exp_x, @exp_y, 32, 20, 'EXP')
  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(@hp_x+32, @hp_y+3, 114, 0, 'hud_green_bar', 1)
    # draw empty bars
    self.bitmap.gradient_bar_hud(@sp_x+32, @sp_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(@hp_x+38, @hp_y, 48, 20, '0', 2)
    self.bitmap.draw_text_full(@hp_x+86, @hp_y, 12, 20, '/', 1)
    self.bitmap.draw_text_full(@hp_x+98, @hp_y, 48, 20, '0')
    # draw empty SP
    self.bitmap.draw_text_full(@sp_x+38, @sp_y, 48, 20, '0', 2)
    self.bitmap.draw_text_full(@sp_x+86, @sp_y, 12, 20, '/', 1)
    self.bitmap.draw_text_full(@sp_x+98, @sp_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_name
    # set current variable
    @name = actor.name
    # remove old display
    self.bitmap.fill_rect(@name_x, @name_y, 104, 20, Color.new(0, 0, 0, 0))
    # set font color
    self.bitmap.font.color = Color.new(0, 255, 0)
    # draw actor's name
    self.bitmap.draw_text_full(@name_x, @name_y, 104, 20, @name)
  end
  #----------------------------------------------------------------------------
  # draw_face
  #  Draws the face display.
  #----------------------------------------------------------------------------
  def draw_face
    # set current variable
    @face = actor.name
    # remove old display
    self.bitmap.fill_rect(@face_x, @face_y, 100, 100, Color.new(0, 0, 0, 0))
    # load bitmap
    bitmap = RPG::Cache.picture('Faces/'+@face+'_L')
    # draw bitmap
    self.bitmap.blt(@face_x, @face_y, bitmap, Rect.new(0, 0, 100, 100))
  end
  #----------------------------------------------------------------------------
  # draw_level
  #  Draws the level display.
  #----------------------------------------------------------------------------
  def draw_level
    # set current variable
    @level = actor.level
    # remove old display
    self.bitmap.fill_rect(@level_x+20, @level_y, 20, 20, Color.new(0, 0, 0, 0))
    # set font color
    self.bitmap.font.color = normal_color
    # draw actor's level
    self.bitmap.draw_text_full(@level_x+20, @level_y, 20, 20, @level.to_s, 2)
  end
  #----------------------------------------------------------------------------
  # draw_hp
  #  Draws the HP display.
  #----------------------------------------------------------------------------
  def draw_hp
    # set current variables
    @hp, @maxhp = actor.hp, actor.maxhp
    # remove old display
    self.bitmap.fill_rect(@hp_x+22, @hp_y, 114, 14, Color.new(0, 0, 0, 0))
    # Calculate The Rate
    rate = (actor.maxhp > 0 ? actor.hp.to_f / actor.maxhp : 0)
    # Draw Color For The Bar
    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 gradient bar
    self.bitmap.gradient_bar(@hp_x+22,@hp_y-15,114,color1,color2,color3,rate)
    # set font color depending on how many HP left
    self.bitmap.font.color = @hp == 0 ? knockout_color :
        @hp <= @maxhp / 4 ? crisis_color : normal_color
    # draw HP
    self.bitmap.draw_text_full(@hp_x+28, @hp_y, 48, 20, @hp.to_s, 2)
    # set color
    self.bitmap.font.color = normal_color
    # draw "/"
    self.bitmap.draw_text_full(@hp_x+76, @hp_y, 12, 20, '/', 1)
    # draw max HP
    self.bitmap.draw_text_full(@hp_x+88, @hp_y, 48, 20, @maxhp.to_s)
  end
  #----------------------------------------------------------------------------
  # draw_sp
  #  Draws the SP display.
  #----------------------------------------------------------------------------
  def draw_sp
    # set current variables
    @sp, @maxsp = actor.sp, actor.maxsp
    # remove old display
    self.bitmap.fill_rect(@sp_x+22, @sp_y, 114, 14, Color.new(0, 0, 0, 0))
    # Calculate The Rate
    rate = (actor.maxsp > 0 ? actor.sp.to_f / actor.maxsp : 0)
    # Draw Color For The Bar
    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, 80, 0, 192)
    # draw gradient bar
    self.bitmap.gradient_bar(@sp_x+22, @sp_y-15, 114, color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = @sp == 0 ? knockout_color :
        @sp <= @maxsp / 4 ? crisis_color : normal_color
    # draw SP
    self.bitmap.draw_text_full(@sp_x+28, @sp_y, 48, 20, @sp.to_s, 2)
    # set font color
    self.bitmap.font.color = normal_color
    # draw "/"
    self.bitmap.draw_text_full(@sp_x+76, @sp_y, 12, 20, '/', 1)
    # draw max SP
    self.bitmap.draw_text_full(@sp_x+88, @sp_y, 48, 20, @maxsp.to_s)
  end
  #----------------------------------------------------------------------------
  # draw_exp
  #  Draws the EXP display.
  #----------------------------------------------------------------------------
  def draw_exp
    # set current variables
    @now_exp, @next_exp = actor.now_exp, actor.next_exp
    # remove old display
    self.bitmap.fill_rect(@exp_x+32, @exp_y, 58, 14, Color.new(0, 0, 0, 0))
    # Calculate The Rate
    rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
    # Draw Color For The Bar
    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
    # background color
    color3 = Color.new(0, 80, 0, 192)
    # draw gradient bar
    self.bitmap.gradient_bar(@exp_x+32, @exp_y-18, 57, color1, color2, color3, rate)
  end
  #----------------------------------------------------------------------------
  # draw_hskill
  #  Draws the hot skill display.
  #----------------------------------------------------------------------------
  def draw_hskill
    # set current variable
    @skill = actor.skill
    # remove old display
    self.bitmap.fill_rect(@hot_x, @hot_y+74, 24, 24, Color.new(0, 0, 0, 0))
    # if skill hot skill exists
    if @skill != 0
      # load bitmap
      bitmap = RPG::Cache.icon($data_skills[@skill].icon_name)
      # draw bitmap
      self.bitmap.blt(@hot_x, @hot_y+74, bitmap, Rect.new(0, 0, 24, 24))
    end
    # removes skills left to use display
    draw_lskill
  end
  #----------------------------------------------------------------------------
  # draw_lskill
  #  Draws the skills left to use display.
  #----------------------------------------------------------------------------
  def draw_lskill
    # remove old display
    self.bitmap.fill_rect(@left_x, @left_y+50, 24, 16, Color.new(0, 0, 0, 0))
    # get the number of skills left
    @skills_left = get_skills_left
    # if hot skill exists
    if @skill != nil && @skill > 0
      # if normal SP cost
      if @skills_left >= 0
        # if not enough sp to use
        if @skills_left == 0
          # set font color
          self.bitmap.font.color = Color.new(255, 0, 0)
        # if enough SP for 5 or less skill uses
        elsif @skills_left <= 5
          # set font color
          self.bitmap.font.color = Color.new(255, 255, 0)
        else
          # set font color
          self.bitmap.font.color = normal_color
        end
        # decrease font color
        self.bitmap.font.size -= 2
        # draw number how many skills left to use
        self.bitmap.draw_text_full(@left_x, @left_y+50, 24, 20, @skills_left.to_s, 1)
        # increase font size
        self.bitmap.font.size += 2
      # if infinite skills left
      elsif @skills_left == -1
        # set font color
        self.bitmap.font.color = Color.new(0, 255, 0)
        # increase font size
        self.bitmap.font.size += 4
        # draw "∞" skill uses left
        self.bitmap.draw_text_full(@left_x, @left_y+50, 24, 20, '∞', 1)
        # decrease font size
        self.bitmap.font.size -= 4
      end
    end
  end
  #----------------------------------------------------------------------------
  # get_skills_left
  #  Gets the number of skill usages left.
  #----------------------------------------------------------------------------
  def get_skills_left
    # if skill hot skill exists
    if @skill != nil && @skill > 0
      # if SP cost is zero
      if $data_skills[@skill].sp_cost > 0
        # get basic SP cost
        sp_cost = $data_skills[@skill].sp_cost
        # if using SP Cost Mod Status
        if $tons_version != nil && $tons_version >= 6.54 &&
            $game_system.SP_COST_MOD
          # get modified cost
          sp_cost = BlizzCFG.get_cost_mod(actor.states, sp_cost)
        end
        # infinite
        return -1 if sp_cost == 0
        # calculate skills left to use
        return @sp / sp_cost
      end
      # set flag
      return -1
    end
    # set flag
    return -2
  end
  #----------------------------------------------------------------------------
  # draw_hitem
  #  Draws the hot item display.
  #----------------------------------------------------------------------------
  def draw_hitem
    # set current variable
    @item = actor.item
    # remove old display
    self.bitmap.fill_rect(@hot_x, @hot_y+24, 24, 24, Color.new(0, 0, 0, 0))
    # if hot item exists
    if @item != 0
      # load bitmap
      bitmap = RPG::Cache.icon($data_items[@item].icon_name)
      # draw bitmap
      self.bitmap.blt(@hot_x, @hot_y+24, bitmap, Rect.new(0, 0, 24, 24))
    end
    # removes items left to use display
    draw_litem
  end
  #----------------------------------------------------------------------------
  # draw_litem
  #  Draws the items left to use display.
  #----------------------------------------------------------------------------
  def draw_litem
    # set current variable
    @items_left = $game_party.item_number(@item)
    # remove old display
    self.bitmap.fill_rect(@left_x, @left_y, 24, 16, Color.new(0, 0, 0, 0))
    # if hot item exists
    if @item != nil && @item > 0
      # if item exists and cannot be consumed
      if $data_items[@item] != nil && !$data_items[@item].consumable
        # set font color
        self.bitmap.font.color = Color.new(0, 255, 0)
        # increase font size
        self.bitmap.font.size += 4
        # draw "∞" items left
        self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, '∞', 1)
        # decrease font size
        self.bitmap.font.size -= 4
      else
        # if no items left
        if @items_left == 0
          # set font color
          self.bitmap.font.color = Color.new(255, 0, 0)
        # if equal or less items left
        elsif @items_left <= 10
          # set font color
          self.bitmap.font.color = Color.new(255, 255, 0)
        else
          # set font color
          self.bitmap.font.color = normal_color
        end
        # decrease font color
        self.bitmap.font.size -= 2
        # draw number how many items left to use
        self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, @items_left.to_s, 1)
        # increase font size
        self.bitmap.font.size += 2
      end
    end
  end
  #----------------------------------------------------------------------------
  # update
  #  Checks if HUD needs refreshing.
  #----------------------------------------------------------------------------
  def update
   
    # if 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_name
        draw_face
        draw_level
        draw_hp
        draw_sp
        draw_exp
        # remove flag
        $game_temp.hud_refresh = nil
      else
        # draw data that needs to ve updated
        test_name
        test_face
        test_level
        test_hp
        test_sp
        test_exp
      end
      # empty HUD wasn't drawn
      @empty_hud_drawn = false
    end
  end
  #----------------------------------------------------------------------------
  # test_face
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_face
    # draw new face if face has changed
   draw_face if actor.name != @face
  end
  #----------------------------------------------------------------------------
  # test_exp
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_exp
    # draw new name if name has changed
    draw_exp if actor.now_exp != @now_exp|| actor.next_exp != @next_exp
  end
  #----------------------------------------------------------------------------
  # test_name
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_name
    # draw new name if name has changed
    draw_name if actor.name != @name
  end
  #----------------------------------------------------------------------------
  # test_level
  #  Tests and draws the level.
  #----------------------------------------------------------------------------
  def test_level
    # draw new level if level has changed
    draw_level if actor.level != @level
  end
  #----------------------------------------------------------------------------
  # test_hp
  #  Tests and draws the HP.
  #----------------------------------------------------------------------------
  def test_hp
    # draw new HP if HP or max HP have changed
    draw_hp if actor.hp != @hp || actor.maxhp != @maxhp
  end
  #----------------------------------------------------------------------------
  # test_sp
  #  Tests and draws the SP.
  #----------------------------------------------------------------------------
  def test_sp
    # draw new SP if SP or max SP have changed
    draw_sp if actor.sp != @sp || actor.maxsp != @maxsp
  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 $BlizzABS.battlers[0].battler
  end
 
end
#==============================================================================
# Hud
#------------------------------------------------------------------------------
#  This class was modified to support SR display and modify the number of
#  skills left to use.
#==============================================================================

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

class Bitmap

  #----------------------------------------------------------------------------
  # gradient_bar
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - width of the bar to be drawn
  #  color1 - primary color
  #  color2 - secondary color
  #  color3 - back color
  #  rate   - fill rate
  #  This special method is able to draw one out of 7 styles.
  #----------------------------------------------------------------------------
  def gradient_bar(x, y, w, color1, color2, color3, rate, flag = true)
    # stop if not active or out of range
    return unless flag
    return if $game_system.bar_style < 0 || $game_system.bar_style > 6
    # styles with "vertical" black borders
    styles = [1, 3, 4, 5, 6]
    # setup of coordinates and offsets depending on style
    offs = 5
    x += offs
    y += 26
    if styles.include?($game_system.bar_style)
      offs += 2
      y -= 1
      [5, 6].include?($game_system.bar_style) ? y -= 2 :  x += 1
      # quantizes the width so it looks better (remove it and see what happens)
      w = w / 8 * 8
    end
    # temporary variable
    a = $game_system.bar_opacity
    if $game_system.bar_style < 5
      # draw black slanted back
      (0...(offs+3)).each {|i| fill_rect(x-i, y+i-2, w+3, 1, Color.new(0, 0, 0))}
      # draw white slanted back onto black, but let black borders stay
      (0...(offs+1)).each {|i| fill_rect(x-i, y+i-1, w+1, 1, Color.new(255, 255, 255))}
      if $game_system.bar_style < 2
        # iterate through each vertical bar
        (0...w+offs).each {|i|
            # calculate color
            r = color3.red * i / (w+offs)
            g = color3.green * i / (w+offs)
            b = color3.blue * i / (w+offs)
            # special offset calculation
            oy = i < offs ? offs-i : 0
            off = i < offs ? i : i > w ? w+offs-i : offs
            # draw this part of the bar
            fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
        # if slanted bar is out of critical area
        if (w*rate).to_i >= offs
          # draw the little triangular part on the left
          (0...((w*rate).to_i+offs)).each {|i|
              r = color1.red + (color2.red-color1.red)*i / ((w+offs)*rate)
              g = color1.green + (color2.green-color1.green)*i / ((w+offs)*rate)
              b = color1.blue + (color2.blue-color1.blue)*i / ((w+offs)*rate)
              oy = i < offs ? offs-i : 0
              off = i < offs ? i : i > w*rate ? (w*rate).to_i+offs-i : offs
              fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
        else
          # draw the little triangular part on the left using special method
          (0...(w * rate).to_i).each {|i| (0...offs).each {|j|
              r = color1.red + (color2.red-color1.red)*i / (w*rate)
              g = color1.green + (color2.green-color1.green)*i / (w*rate)
              b = color1.blue + (color2.blue-color1.blue)*i / (w*rate)
              set_pixel(x+i-j+1, y+j-1, Color.new(r, g, b, a))}}
        end
      else
        # iterate through all horizontal lines
        (0...offs).each {|i|
            # calculate colors
            r = color3.red * i / offs
            g = color3.green * i / offs
            b = color3.blue * i / offs
            # draw background line
            fill_rect(x-i+1, y+i-1, w, 1, Color.new(r, g, b, a))}
        if $game_system.bar_style == 4
          # iterate through half of all horizontal lines
          (0...offs/2+1).each {|i|
              # calculate colors
              r = color2.red * (i+1) / (offs/2)
              g = color2.green * (i+1) / (offs/2)
              b = color2.blue * (i+1) / (offs/2)
              # draw bar line
              fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))
              # draw bar line mirrored vertically
              fill_rect(x-offs+i+2, y+offs-i-2, w*rate, 1, Color.new(r, g, b, a))}
        else
          # iterate through all horizontal lines
          (0...offs).each {|i|
              # calculate colors
              r = color1.red + (color2.red-color1.red)*i / offs
              g = color1.green + (color2.green-color1.green)*i / offs
              b = color1.blue + (color2.blue-color1.blue)*i / offs
              # draw bar line
              fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))}
        end
      end
      # if style with black vertical slanted intersections
      if styles.include?($game_system.bar_style)
        # add black bars on 1st and 8th column every 8 pixels
        (0...w).each {|i| (0...offs).each {|j|
            if styles.include?($game_system.bar_style) && i % 8 < 2
              set_pixel(x+i-j+1, y+j-1, Color.new(0, 0, 0, a))
            end}}
      end
    else
      # fill white background
      fill_rect(x+1, y-3, w+2, 12, Color.new(255, 255, 255, a))
      # iterate through each of 6 lines
      (1...6).each {|i|
          # calculate background color
          color = Color.new(color3.red*i/5, color3.green*i/5, color3.blue*i/5, a)
          # draw background
          fill_rect(x+2, y+i-3, w, 12-i*2, color)
          # calculate bar color
          color = Color.new(color2.red*i/5, color2.green*i/5, color2.blue*i/5, a)
          # draw bar
          fill_rect(x+2, y+i-3, w*rate, 12-i*2, color)}
      # if style 5 (with vertical borders)
      if $game_system.bar_style == 5
        # add black bars on 1st and 8th column every 8 pixels
        (0...w/8).each {|i|
            fill_rect(x+2+i*8, y-2, 1, 10, Color.new(0, 0, 0, a))
            fill_rect(x+2+(i+1)*8-1, y-2, 1, 10, Color.new(0, 0, 0, a))}
      end
    end
  end
 
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
#==============================================================================
# Scene_Map
#------------------------------------------------------------------------------
#  This class was enhanced to support HUD control and creation system and
#  Blizz-ABS battle handling and level up text display.
#==============================================================================

class Scene_Map
 
  #----------------------------------------------------------------------------
  # override main
  #----------------------------------------------------------------------------
  alias main_blizzabs_later_nathmatt main
  def main
    # create HUD if HUD is turned on and HUD active
    @hud = Hud.new if BlizzABS::Config::HUD_ENABLED && $game_system.hud
    @par_hud = Par_Hud.new if $game_system.par_hud &&
    $game_party.actors.size > 1
    # if HOTKEYS is turned on and assignment display active
    if BlizzABS::Config::HOTKEYS && $game_system.hotkeys
      # create assignment display
      @hotkeys = Hotkey_Assignment.new
    end
    # if MINIMAP is turned on and minimap active
    if BlizzABS::Config::MINIMAP && $game_system.minimap > 0
      # create HUD
      @minimap = Minimap.new
    end
    # tests and sets the in_battle flag
    test_in_battle
    # call original method
    main_blizzabs_later
    # set in_battle flag
    $game_temp.in_battle = false
    # delete HUD elements that exist
    [@hud, @par_hud, @hotkeys, @minimap].each {|s| s.dispose if s != nil}
  end
  #----------------------------------------------------------------------------
  # hud_update
  #  This method contains a couple of routine calls to handle with the HUD.
  #----------------------------------------------------------------------------
  def hud_update
    # check activation of HUD parts
    check_huds
    # update minimap
    update_minimap
    # update hotkey assignment display
    update_hotkeys
    # iterate through all the HUD sprites
    [@hud, @par_hud, @minimap, @hotkeys].each {|s|
        # if sprite exists
        if s != nil
          # update sprite
          s.update
          # if player is on the same position as one of the sprites on the screen
          if $game_player.screen_x < s.vx + s.vw + 16 &&
              $game_player.screen_y < s.vy + s.vh + 48 &&
              $game_player.screen_x > s.vx && $game_player.screen_y > s.vy &&
              (s != @minimap || $game_system.minimap < 2)
            # decrease opacity quickly if critical opacity not reached
            s.opacity -= 25 if s.opacity > 80
          # if not full opacity
          elsif s.opacity <= 255
            # increase opacity quickly if critical opacity not reached
            s.opacity += 25
          end
        end}
      end
      #----------------------------------------------------------------------------
  # check_huds
  #  This method handles enabling and disabling the HUD parts on the map.
  #----------------------------------------------------------------------------
  def check_huds
    # if minimap button is enabled and pressed
    if $game_system.minimap_button && Input.trigger?(Input::Minimap)
      # trigger minimap active
      $game_system.minimap = ($game_system.minimap + 1) % 3
    end
    # if hotkey display button is enabled and pressed
    if $game_system.hotkey_button && Input.trigger?(Input::Hotkey)
      # trigger hotkey display active
      $game_system.hotkeys = (!$game_system.hotkeys)
    end
    # if HUD button is enabled and pressed
    if $game_system.hud_button && Input.trigger?(Input::Hud)
      # trigger it active
      $game_system.hud = (!$game_system.hud)
      $game_system.par_hud = (!$game_system.par_hud)
    end
    # if minimap not active and minimap exists
    if $game_system.minimap == 0 && @minimap != nil
      # delete it
      @minimap.dispose
      @minimap = nil
    # if minimap is turned on and active and doesn't exist
    elsif BlizzABS::Config::MINIMAP && $game_system.minimap > 0
      # create it
      @minimap = Minimap.new if @minimap == nil
    end
    # if assignment display not active and exists
    if !$game_system.hotkeys && @hotkeys != nil
      # delete it
      @hotkeys.dispose
      @hotkeys = nil
    # if HOTKEYS is turned on and active and doesn't exist
    elsif BlizzABS::Config::HOTKEYS && $game_system.hotkeys
      # create it
      @hotkeys = Hotkey_Assignment.new if @hotkeys == nil
    end
    # if HUD not active and HUD exists
    if !$game_system.hud && @hud != nil
      # delete it
      @hud.dispose
      @hud = nil
      @par_hud.dispose
      @par_hud = nil
    # if HUD is turned on and HUD active and HUD doesn't exist
    elsif BlizzABS::Config::HUD_ENABLED && $game_system.par_hud
      # create it
      @hud = Hud.new if @hud == nil
      @par_hud = Par_Hud.new if @par_hud == nil &&
      $game_party.actors.size > 1
    end
  end
 
end
80
Script Troubleshooting / Script help (resolved)
January 08, 2010, 12:00:12 pm
i have no idea why im getting this error but its cant convert Game_Actor to integer im not event messing with game actor any ideas heres the script it has to do where i define name lol was using it over looked it

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Info_Book by Nathmatt
# Version: 1.00
# Type: Add On
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                                    PART 1
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  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.
# #  
# #-----------------------------------------------------------------------------
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# Info_Book
#------------------------------------------------------------------------------
#  This is the master control, configuration.
#  module for Info_Book.
#==============================================================================
module Info_Book
 @max_number   = 5   # The max amount of people in your infor book    
# Dont touch these
 Name         = []
 Race         = []
 Pclass       = []
 Age          = []
 Gender       = []
 Picture      = []
 Description1 = []
 Description2 = []
 Description3 = []
#==============================================================================
#  Add the info for the people you will be adding under here.
#  Like this
#  Name[0]         = 'John'
#  Race[0]         = 'Human
#  Pclass[0]       = 'Black Smith'
#  Age[0]          = 20
#  Gender[0]       = 'Male'
#  Picture[0]      = '105-Civilian05'
#  Description1[0] = 'Line 1
#  Description2[0] = 'Line 2'
#  Description3[0] = 'Line 3'
#
#  Now this will tell the system that the person in the first slot is
#  Name:    John
#  Age:     20
#  Gender:  Male
#  Race:    Human
#  
#  Then you would add another 1 by doing the same thing but puttting 1 in the []
#  then 2 ect...
#==============================================================================
Name[0]         = 'John'
Race[0]         = 'Human'
Pclass[0]       = 'Black Smith'
Age[0]          =  20
Gender[0]       = 'Male'
Picture[0]      = '105-Civilian05'
Description1[0] = 'Line 1'
Description2[0] = 'Line 2'
Description3[0] = 'Line 3'
end

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Info_Book by Nathmatt
# Version: 1.00
# Type: Add On
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                                    PART 2
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  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.
# #  
# #-----------------------------------------------------------------------------
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# Game_People
#------------------------------------------------------------------------------
#  This defines everything that needs to be defined.
#==============================================================================
class Game_People
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader   :name         # The name of the people
 attr_reader   :race         # The race of the people
 attr_reader   :pclass       # The class of the people
 attr_reader   :age          # The age of the people
 attr_reader   :gender       # The Gender of the people
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   # Create actor array
   @name    = Info_Book::Name
   @race    = Info_Book::Race
   @pclass  = Info_Book::Pclass
   @age     = Info_Book::Age
   @gender  = Info_Book::Gender
 end
 #--------------------------------------------------------------------------
 # * Add an Actor
 #     people_id : actor ID
 #--------------------------------------------------------------------------
 def add_people(people_id)
   # Get actor
   @people = $game_people[people_id]
 end
 #--------------------------------------------------------------------------
 # * age
 #     people_id : people's ID
 #--------------------------------------------------------------------------
 def age(people_id)
   # the age of the people
   return @age[people_id]
 end
 #--------------------------------------------------------------------------
 # * name
 #     people_id : people's ID
 #--------------------------------------------------------------------------
 def name(people_id)
   # the age of the people
   return @name[people_id]
 end
 #--------------------------------------------------------------------------
 # * gender
 #     people_id : people's ID
 #--------------------------------------------------------------------------
 def gender(people_id)
   # the age of the people
   return @gender[people_id]
 end
 #--------------------------------------------------------------------------
 # * prace
 #     people_id : people's ID
 #--------------------------------------------------------------------------
 def race(people_id)
   # the age of the people
   return @race[people_id]
 end
 #--------------------------------------------------------------------------
 # * pclass
 #     people_id : people's ID
 #--------------------------------------------------------------------------
 def pclass(people_id)
   # the age of the people
   return @pclass[people_id]
 end
 
end
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
#  This class performs status screen processing.
#==============================================================================

class Scene_Info_Book
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     actor_index : actor index
 #--------------------------------------------------------------------------
 def initialize(actor_index = 0)
   @actor_index = actor_index
 end
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Get actor
   @actor = $game_party.actors[@actor_index]
   # Make status window
   @info_window = Window_Info.new(@actor)
   #@picture_window = Window_picture.new(@actor)
   #@description_window = Window_description.new(@actor)
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end
   # Prepare for transition
   Graphics.freeze
   # Dispose of windows
   @info_window.dispose
   #@picture_window.dispose
   #@description_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Switch to menu screen
     $scene = Scene_Map.new
     return
   end
   # If R button was pressed
   if Input.trigger?(Input::R)
     # Play cursor SE
     $game_system.se_play($data_system.cursor_se)
     @actor_index += 1
     @actor_index %= Info_Book::max_number
     $scene = Scene_Info_Book.new(@actor_index)
     return
   end
   # If L button was pressed
   if Input.trigger?(Input::L)
     # Play cursor SE
     $game_system.se_play($data_system.cursor_se)
     @actor_index += Info_Book::max_number - 1
     @actor_index %= Info_Book::max_number
     $scene = Scene_Info_Book.new(@actor_index)
     return
   end
 end
end
#==============================================================================
# ** Window_Info
#------------------------------------------------------------------------------
#  This window displays the info of the people.
#==============================================================================

class Window_Info < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize(actor)
   super(400, 0, 250, 250)
   self.contents = Bitmap.new(width - 32, height - 32)
   @actor = actor
   @game_people = Game_People.new
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 0, 120, 32, 'Name:', 2)
   self.contents.draw_text(35, 0, 120, 32, @game_people.name(@actor).to_s, 2)
   self.contents.draw_text(4, 64, 120, 32, 'Race:', 2)
   self.contents.draw_text(35, 64, 120, 32, @game_people.race(@actor).to_s, 2)
   self.contents.draw_text(4, 96, 120, 32, 'Class:', 2)
   self.contents.draw_text(35, 96, 120, 32, @game_people.pclass(@actor).to_s, 2)
   self.contents.draw_text(4, 128, 120, 32, 'Age:', 2)
   self.contents.draw_text(35, 128, 120, 32, @game_people.age(@actor).to_s, 2)
   self.contents.draw_text(4, 160, 120, 32, 'Gender:', 2)
   self.contents.draw_text(35, 160, 120, 32, @game_people.gender(@actor).to_s, 2)
 end
end
81
Script Troubleshooting / need cms help (resolved)
January 04, 2010, 01:24:47 pm
ok im making a cms my problem right now is i cant get the icons to appear in my menu & i cant get my black bar to cover the moving text

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     menu_index : command cursor's initial position
 #--------------------------------------------------------------------------
 def initialize(menu_index = 0)
   @menu_index = menu_index
 end
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Make command window
   @command_window = Window_Command2.new(160,['Items','Symbology','Equipment',
   'Status','Config','Tactics','Dictionary','Card'])
   @command_window.index = @menu_index
   @command_window.y = 70
   # Execute transition
   Graphics.transition
   @menu_window = Window_Menu.new
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end
   # Prepare for transition
   Graphics.freeze
   # Dispose of windows
   @command_window.dispose
   @menu_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @command_window.update
   @menu_window.update
   # If command window is active: call update_command
   if @command_window.active
     update_command
     return
   end
   # If status window is active: call update_status
   if @status_window.active
     update_status
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when command window is active)
 #--------------------------------------------------------------------------
 def update_command
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Switch to map screen
     $scene = Scene_Map.new
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # If command other than save or end game, and party members = 0
     if $game_party.actors.size == 0 and @command_window.index < 4
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # Branch by command window cursor position
     case @command_window.index
     when 0  # item
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to item screen
       $scene = Scene_Item.new
     when 1  # skill
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Make status window active
       @command_window.active = false
       @status_window.active = true
       @status_window.index = 0
     when 2  # equipment
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Make status window active
       @command_window.active = false
       @status_window.active = true
       @status_window.index = 0
     when 3  # status
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Make status window active
       @command_window.active = false
       @status_window.active = true
       @status_window.index = 0
     when 4  # save
       # If saving is forbidden
       if $game_system.save_disabled
         # Play buzzer SE
         $game_system.se_play($data_system.buzzer_se)
         return
       end
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to save screen
       $scene = Scene_Save.new
     when 5  # end game
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to end game screen
       $scene = Scene_End.new
     end
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when status window is active)
 #--------------------------------------------------------------------------
 def update_status
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Make command window active
     @command_window.active = true
     @status_window.active = false
     @status_window.index = -1
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Branch by command window cursor position
     case @command_window.index
     when 1  # skill
       # If this actor's action limit is 2 or more
       if $game_party.actors[@status_window.index].restriction >= 2
         # Play buzzer SE
         $game_system.se_play($data_system.buzzer_se)
         return
       end
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to skill screen
       $scene = Scene_Skill.new(@status_window.index)
     when 2  # equipment
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to equipment screen
       $scene = Scene_Equip.new(@status_window.index)
     when 3  # status
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to status screen
       $scene = Scene_Status.new(@status_window.index)
     end
     return
   end
 end
end
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command2 < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     width    : window width
 #     commands : command text string array
 #--------------------------------------------------------------------------
def initialize(width, commands)
   # Compute window height from command quantity
   super(0, 0, width, commands.size * 32 + 32)
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, @item_max * 32)
   refresh
   self.index = 0
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   for i in 0...@item_max
     draw_item(i, normal_color)
   end
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #     index : item number
 #     color : text color
 #--------------------------------------------------------------------------
 def draw_item(i, color)
   self.contents.fill_rect(0, i*32, 148, 32, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon(@commands[i])
   self.contents.font.color = color
   self.contents.draw_text(32, i*32, 148, 32, @commands[i])
 end
 #--------------------------------------------------------------------------
 # * Disable Item
 #     index : item number
 #--------------------------------------------------------------------------
 def disable_item(index)
   draw_item(index, disabled_color)
 end
end
#==============================================================================
# ** Window_Steps
#------------------------------------------------------------------------------
#  This window displays step count on the menu screen.
#==============================================================================

class Window_Menu < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 0, 640, 480)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.opacity = 0
   @Help_Window = 'View Items'
   @x = 640
   update
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def update
   if @x == 0
     @x=640
   else
     @x-=2
   end
   self.contents.clear
   self.contents.font.size = Font.default_size
   self.contents.font.color = normal_color
   self.contents.fill_rect(0, 0, 120, 32, Color.new(0,0,0))
   self.contents.draw_text(0, 0, 120, 32, 'Main Menu',2)
   self.contents.draw_text(@x, 0, 120, 32, @Help_Window.to_s,2)
   self.contents.font.size = 15
   self.contents.draw_text(15, 30, 120, 32, 'HELP')
   self.contents.fill_rect(0, 32, width, 3, normal_color)
   self.contents.fill_rect(0, 33, 5, 2, normal_color)
   self.contents.fill_rect(1, 35, 5, 2, normal_color)
   self.contents.fill_rect(2, 37, 5, 2, normal_color)
   self.contents.fill_rect(3, 39, 5, 2, normal_color)
   self.contents.fill_rect(4, 41, 5, 2, normal_color)
   self.contents.fill_rect(5, 42, 5, 2, normal_color)
   self.contents.fill_rect(6, 43, 5, 2, normal_color)
   self.contents.fill_rect(7, 44, 5, 2, normal_color)
  end
end
82
RMXP Script Database / [XP] Simple Jump Script
November 12, 2009, 06:55:44 am
Simple Jump Script
Authors: Nathmatt
Version: 1.04
Type: Jump System
Key Term: Custom Movement System



Introduction

Its a simple Jumping script.



Features


  • Configurable jumping distance
  • Configurable off switch
  • Configurable no jump terrain tag
  • Configurable jump key if your using custom controls from tuns
  • Possibility to use jumping sprites



Screenshots

Um screenshot would be just ur player jumping


Demo

no demo


Script

Above main
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Simple Jump System by Nathmatt
# Version: 1.04
# Type: Custom Movement System
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  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.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This is the config:
#
#   (Jump_Distance) is how far you want to jump.
#   
#   (Cant_Jump) is the terrain tag that you cant jump on.
#
#   (Off_Switch_id) is the swith id used to turn off the jump.
#
#   (Jump_key) is the key used to jump if using tons ads custom controls.
#
#   (Jump_Animation) is if you want a speacial graphic for jumping
#   add _jmp  so 001-Fighter01 would be 001-Fighter01_jmp.

#-------------------------------------------------------------------------------
module SJS_Config
  Jump_Distance = 2
  Jump_Animation = false
  Off_Switch_id = 50
  Jump_Key = 'Space'
  # Terrain_Tags
  Cant_Jump = 1
end
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This is the update method:
#
#-------------------------------------------------------------------------------
 
class  Game_Player < Game_Character
 
   
  alias nathmatt_update update
  def update
    nathmatt_update
    actor = $game_party.actors[0] unless actor == $game_party.actors[0]
    if check_key && !jumping? && !$game_switches[SJS_Config::Off_Switch_id]
      d =  SJS_Config::Jump_Distance
      case direction
        when 2 then jump(0,d,false)
        when 4 then jump(-d,0,false)
        when 6 then jump(d,0,false)
        when 8 then jump(0,-d,false)
      end
    end
    if jumping? && SJS_Config::Jump_Animation
      @character_name_org = actor.character_name
      @character_name = @character_name_org+'_jmp'
    end
    if @character_name != actor.character_name && !jumping?
      @character_name = actor.character_name
    end
     
  end
   
  def check_key
    if $tons_version != nil && $tons_version >= 5.40 &&
        TONS_OF_ADDONS::CUSTOM_CONTROLS
      return Input.trigger?(Input::Key[SJS_Config::Jump_Key])
    else
      return Input.trigger?(Input::A) 
    end
  end
 
  alias SJS_jump jump
  def jump(x,y,c=true)
    px = $game_player.x + x
    py = $game_player.y + y
    if c
      SJS_jump(x,y)
    elsif $game_map.terrain_tag(px,py) != SJS_Config::Cant_Jump
      SJS_jump(x,y)
    end
  end

end



Instructions
Configuration in script
Uses default button (A) to jump


Compatibility
no compatible problems known


Credits and Thanks


  • Nathmatt
  • Blizzard for his jump system in Blizz-Abs i used to make this



Author's Notes
No notes
83
RPG Maker Scripts / CMS help
October 15, 2009, 03:24:11 pm
need help editing hotkeys ai behavior & ai triggers to work in Samo the thiefthe script is located here

http://www.creationasylum.net/forum/index.php?showtopic=18307

edit:  im trying to get BLABS hotkeys ai behavior & ai triggers go in the same window as everything else goes in
84
ok i trying to add an item to a variable but i cant get it to add it here what i have im trying to make it when i press R it addes the selected item to variables 12

Spoiler: ShowHide
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs item screen processing.
#==============================================================================

class Scene_Item
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    @help_window = Window_Help.new
    @item_window = Window_Item.new
    # Associate help window
    @item_window.help_window = @help_window
    # Make target window (set to invisible / inactive)
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @item_window.dispose
    @target_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @item_window.update
    @target_window.update
    # If item window is active: call update_item
    if @item_window.active
      update_item
      return
    end
    # If target window is active: call update_target
    if @target_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(0)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @item_window.item
      # If not a use item
      unless @item.is_a?(RPG::Item)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If it can't be used
      unless $game_party.item_can_use?(@item.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if Input.trigger?(Input::key"R")
      # Get currently selected data on the item window
      @item = @item_window.item
      $game_variables[12] = $data_items[@item.id]
      # If not a use item
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # If effect scope is an ally
      if @item.scope >= 3
        # Activate target window
        @item_window.active = false
        @target_window.x = (@item_window.index + 1) % 2 * 304
        @target_window.visible = true
        @target_window.active = true
        # Set cursor position to effect scope (single / all)
        if @item.scope == 4 || @item.scope == 6
          @target_window.index = -1
        else
          @target_window.index = 0
        end
      # If effect scope is other than an ally
      else
        # If command event ID is valid
        if @item.common_event_id > 0
          # Command event call reservation
          $game_temp.common_event_id = @item.common_event_id
          # Play item use SE
          $game_system.se_play(@item.menu_se)
          # If consumable
          if @item.consumable
            # Decrease used items by 1
            $game_party.lose_item(@item.id, 1)
            # Draw item window item
            @item_window.draw_item(@item_window.index)
          end
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when target window is active)
  #--------------------------------------------------------------------------
  def update_target
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # If unable to use because items ran out
      unless $game_party.item_can_use?(@item.id)
        # Remake item window contents
        @item_window.refresh
      end
      # Erase target window
      @item_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If items are used up
      if $game_party.item_number(@item.id) == 0
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If target is all
      if @target_window.index == -1
        # Apply item effects to entire party
        used = false
        for i in $game_party.actors
          used |= i.item_effect(@item)
        end
      end
      # If single target
      if @target_window.index >= 0
        # Apply item use effects to target actor
        target = $game_party.actors[@target_window.index]
        used = target.item_effect(@item)
      end
      # If an item was used
      if used
        # Play item use SE
        $game_system.se_play(@item.menu_se)
        # If consumable
        if @item.consumable
          # Decrease used items by 1
          $game_party.lose_item(@item.id, 1)
          # Redraw item window item
          @item_window.draw_item(@item_window.index)
        end
        # Remake target window contents
        @target_window.refresh
        # If all party members are dead
        if $game_party.all_dead?
          # Switch to game over screen
          $scene = Scene_Gameover.new
          return
        end
        # If common event ID is valid
        if @item.common_event_id > 0
          # Common event call reservation
          $game_temp.common_event_id = @item.common_event_id
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      # If item wasn't used
      unless used
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
  end
end
85
Electronic and Computer Section / graphic card question
September 08, 2009, 12:05:11 pm
ok i was trying to update the driver on my graphic card but i dont see mine is the ati radeon xpress 200 series and ati radeon xpress 200  the same graphic card

edit: i think it is but i dont want to do that 1 without being 100% since it is a driver
86
Resource Requests / charset recolor request
September 01, 2009, 06:57:31 pm
i would like this charset recolored for this faceset

Spoiler: ShowHide


the faceset

Spoiler: ShowHide
87
Troubleshooting / Help / up key stuck in rpg maker xp
August 23, 2009, 04:33:17 pm
i had this problem be4 but cant remember how it stopped no mater what game i open the up button is stuck not using the up key
88
Resource Requests / werewolf charset request
August 11, 2009, 05:04:44 pm
i had  a charset for this battler 1 time but i lost it any1 know where it might be

Spoiler: ShowHide


here

Spoiler: ShowHide
89
General Discussion / House On Haunted Hill criticism
August 08, 2009, 07:26:54 am
ok i want to see want you think if my Title, Logo & Game Over

Title tileset made by zanyzora

Title script is a little modded version of mogs

Text generated from http://projects.ericshalov.com/text/

demo: http://www.megaupload.com/?d=CDE0WAMC

edit : forgot to change the Game Over lol

edit no thoughts at all ?
90
Script Troubleshooting / Mog help
August 06, 2009, 09:22:40 am
Ok i have everything how i want it except when it shows the second tital i want it to play the thunderclap Se

Spoiler: ShowHide
#_________________________________________________
# MOG Animated Title Celia V1.4           
#_________________________________________________
# By Moghunter   
# http://www.atelier-rgss.com
#_________________________________________________
# Tela de titulo animada por frames.
# Para nomear os frames de imagens nomeie da seguinte forma.
#
# Title0.jpg /Title1.jpg / Title2.jpg / Title3.jpg /...
#
# Coloque o nome Title + o numero do frame.
# (A quantidade de frames é ilimitada.)
# Ainda serão necessários as imagens de comando.
#
# Com_01.jpg / Com_02.jpg / Com_03.jpg
#
# Todas as imagens devem ficar na pasta GRAPHICS/TITLES/
#----------------------------------
# Scene_Title
#----------------------------------
$mogscript = {} if $mogscript == nil
$mogscript["title_celia"] = true
$full_screen = 0
class Scene_Title
  def main
    if $BTEST
      battle_test
      return
    end
    $full_screen += 1
    if MOG::FULL_SCREEN == true and $full_screen == 1
    $showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ' '
    $showm.call(18,0,0,0)
    $showm.call(13,0,0,0)
    $showm.call(13,0,2,0)
    $showm.call(18,0,2,0)
    end             
    $data_actors        = load_data("Data/Actors.rxdata")
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_skills        = load_data("Data/Skills.rxdata")
    $data_items         = load_data("Data/Items.rxdata")
    $data_weapons       = load_data("Data/Weapons.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    $data_enemies       = load_data("Data/Enemies.rxdata")
    $data_troops        = load_data("Data/Troops.rxdata")
    $data_states        = load_data("Data/States.rxdata")
    $data_animations    = load_data("Data/Animations.rxdata")
    $data_tilesets      = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system        = load_data("Data/System.rxdata")
    $game_system = Game_System.new
    s1 = "New Game"
    s2 = "Continue"
    s3 = "Shutdown"
    @command_window = Window_Command.new(192, [s1, s2, s3])
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288
    @command_window.visible = false
    @com = Sprite.new
    @com.bitmap = RPG::Cache.title("Com_01") rescue nil
    @com.z = 10
    @com.x = (MOG::COM_X)
    @com.y = (MOG::COM_Y)
    @continue_enabled = false
    @frmtitle = Sprite.new
    @frmtitle.bitmap = Bitmap.new(640,480)
    @frmtitle.bitmap = RPG::Cache.title("Title0") rescue nil
    @text = Sprite.new
    @text.bitmap = Bitmap.new(640,480)
    @text.bitmap = RPG::Cache.title("Name") rescue nil
    @text.x = 50
    @text.y = 100
    @backtitleref = 0
    @backtitlespeed = 0
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
    Audio.se_stop
    Audio.bgs_stop
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @frmtitle.dispose
    @com.dispose
    @text.dispose
  end
  def update
    @command_window.update
     case @command_window.index
     when 0
     @com.bitmap = RPG::Cache.title("Com_01") rescue nil       
     when 1
     @com.bitmap = RPG::Cache.title("Com_02") rescue nil       
     when 2
     @com.bitmap = RPG::Cache.title("Com_03") rescue nil
     end       
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0 
        command_new_game
      when 1 
        command_continue
      when 2
        command_shutdown
      end
    end
     @backtitlespeed += 1   
  if @backtitlespeed > MOG::BACKTITLESPEED
     @backtitleref += 1
     @backtitlespeed = 0
  end
  if @frmtitle.bitmap != nil
  @frmtitle.bitmap = RPG::Cache.title("Title" + @backtitleref.to_s) rescue nil
  end
  if @frmtitle.bitmap == nil
     @backtitleref = 0
  @frmtitle.bitmap = RPG::Cache.title("Title" + @backtitleref.to_s) rescue nil
  end 
  end
  def command_new_game
    $game_system.se_play($data_system.decision_se)
    Audio.bgm_stop
    Graphics.frame_count = 0
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    $game_party.setup_starting_members
    $game_map.setup($data_system.start_map_id)
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    $game_player.refresh
    $game_map.autoplay
    $game_map.update
    $scene = Scene_Map.new
  end
  def command_continue
    unless @continue_enabled
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    $game_system.se_play($data_system.decision_se)
    $scene = Scene_Load.new
  end
  def command_shutdown
    $game_system.se_play($data_system.decision_se)
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    $scene = nil
  end
  def battle_test
    $data_actors        = load_data("Data/BT_Actors.rxdata")
    $data_classes       = load_data("Data/BT_Classes.rxdata")
    $data_skills        = load_data("Data/BT_Skills.rxdata")
    $data_items         = load_data("Data/BT_Items.rxdata")
    $data_weapons       = load_data("Data/BT_Weapons.rxdata")
    $data_armors        = load_data("Data/BT_Armors.rxdata")
    $data_enemies       = load_data("Data/BT_Enemies.rxdata")
    $data_troops        = load_data("Data/BT_Troops.rxdata")
    $data_states        = load_data("Data/BT_States.rxdata")
    $data_animations    = load_data("Data/BT_Animations.rxdata")
    $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
    $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
    $data_system        = load_data("Data/BT_System.rxdata")
    Graphics.frame_count = 0
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    $game_party.setup_battle_test_members
    $game_temp.battle_troop_id = $data_system.test_troop_id
    $game_temp.battle_can_escape = true
    $game_map.battleback_name = $data_system.battleback_name
    $game_system.se_play($data_system.battle_start_se)
    $game_system.bgm_play($game_system.battle_bgm)
    $scene = Scene_Battle.new
  end
end