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.

Messages - Various

1
Script Troubleshooting / Re: [XP] Window Item Description
November 21, 2015, 08:46:12 pm
oh wow... it took me a translator but I understood everything now, its all fixed on this to, thank you
2
Script Troubleshooting / Re: [XP] Window Item Description
November 21, 2015, 02:50:26 pm
thanks, but the description of a item with long description Is still like



instead of dividing
3
Script Troubleshooting / Re: [XP] Window Item Description
November 20, 2015, 06:18:27 pm
Uploaded the whole project map, I will pm you the link
4
Script Troubleshooting / Re: [XP] Window Item Description
November 20, 2015, 01:28:09 pm
this is the error i get.
it shows up when i go to the ITEMS menu on my tab (customized menu)




This is the menu (just in case)

Spoiler: ShowHide

5
Script Troubleshooting / Re: [XP] Window Item Description
November 19, 2015, 06:33:13 pm
hmm okay but now I have a little problem (maybe I should've said it before)
it collides with a localization script


This is the error:
Script 'Localization' line 411:TypeError occurred.
cannot convert array into string

this is the part of code it errors with

class Bitmap
  alias old_draw_text draw_text
  def draw_text(*args)
    args.each_index {|i| if args[i].is_a?(String) then args[i] = Localization.scan(args[i]) end }
    old_draw_text(*args)
  end
end




and this is the script
Spoiler: ShowHide
#===============================================================================
# * Localization
#
#
#-------------------------------------------------------------------------------
# Description:
#
# Language Localization,
# supports most languages except chinese, korean and japanese
#-------------------------------------------------------------------------------
# Setup:
#
# Translate files in language folder
#
# Edit everything underneath
#-------------------------------------------------------------------------------
# Commands:
#
# Localization.change('behavior',\'HERE')   Use either 'Strict' or 'Loose'
#
# Localization.change('method',\'HERE')   Use either 'Cached' or 'Streaming'
#
# Localization.change('language',\'HERE')   Change for a different language
#===============================================================================

module Localization
 
  LOCALIZATION_DELIMITER = '='        #delimiter for each dialogue pairs
  LOCALIZATION_DEFAULT = 'EN'         #default language
  LOCALIZATION_CREDITS_LINE = 1       #credits line number
  LOCALIZATION_METHOD_LINE = 2        #used method
  LOCALIZATION_START_LINE = 3         #starting line number
  LOCALIZATION_FOLDER = 'language'    #location of localization folder
  LOCALIZATION_CONFIG = 'config.txt'  #name of the configuration file
  LOCALIZATION_TEXT_DEFAULT = 'empty' #replacement for empty values
  LOCALIZATION_MAX_LINE = 4           #maximum lines allowed for each dialogue
  MESSAGE_WINDOW_WIDTH = 380          #The maximum width of text in message windows
  MESSAGE_WINDOW_HEIGHT = 160         #The maximum height of text in message windows
 
  @method = 'cached'     #Cached = already loaded   streaming = constant loading
  @behavior = 'loose'    #strict = exit upon error  loose = warning upon error
  @dialogues = Hash.new  #initialize container to store dialogues
  @split_method = '>'    #splitting method
  @character_split = 1   #initialization method declaration
 
  def self.init
    @errors = {
      :folder => nil,
      :def_lang => nil,
      :cur_lang => nil,
      :save_lang => nil,
      :change_lang => nil,
      :bad_id => Array.new,
      :duplicate => Array.new,
      :empty => Array.new,
      :line => Array.new,
      :size => Array.new
    }
   
    #make sure localization folder exists
    if !File.directory?(LOCALIZATION_FOLDER) then @errors[:folder] = 1 ; self.check end
    #make sure default language file exists
    if !File.exist?("#{LOCALIZATION_FOLDER}\\#{LOCALIZATION_DEFAULT}.txt") then @errors[:def_lang] = 1 ; self.check end
    #set localization configuration file
    @filename = "#{LOCALIZATION_FOLDER}\\#{LOCALIZATION_CONFIG}"
    if !File.exists?(@filename)
      begin
      File.open(@filename, 'wb') {|file| file.write(LOCALIZATION_DEFAULT) }
      rescue
        @errors[:save_lang] = 1
        self.check
      end
    end
    change('language')
  end
 
  def self.read(id)
    text = ''
    case @method
      when 'streaming'
        text = ''
        found = false
        @file = File.new(@filename)
        index = 1
        @file.each { |line|
          if !line.empty? && index >= LOCALIZATION_START_LINE && line.include?('=')
            key = line.split(LOCALIZATION_DELIMITER)[0]
            if !(key =~ /^(\w+)$/) then @errors[:bad_id].push(index) end
            if @dialogues.has_key?(key.to_sym) then @errors[:duplicate].push(index) end
            if key == id
                val = line.slice(key.size+LOCALIZATION_DELIMITER.size,line.size).squeeze(" ")
                if self.get('cur_width',val) < MESSAGE_WINDOW_WIDTH * LOCALIZATION_MAX_LINE
                  if self.get('cur_width',val) >= MESSAGE_WINDOW_WIDTH then
                    last = ''
                    adjusted_string = ''
                    run = 1
                    new_line = true
                    text_chunks = Array.new
                    line_chunks = Array.new
                    tolerance = 0
                    if @split_method == 'char' then @character_split = self.get('max_line_width') end
                    val.split('\n').each { |fragment| text_chunks.push(fragment) }
                    text_chunks = text_chunks.reverse
                    while text_chunks.size > 0
                      last = text_chunks[text_chunks.size - 1] + "\n"
                      text_chunks.pop
                      if self.get('cur_width',last) >= MESSAGE_WINDOW_WIDTH
                        if @split_method == 'word'
                          last.split(' ').each { |fragment2| line_chunks.push(fragment2) }
                          line_chunks = line_chunks.reverse
                          while line_chunks.size > 0
                            if self.get('cur_width',adjusted_string) + self.get('cur_width',line_chunks[line_chunks.size - 1]) - tolerance > MESSAGE_WINDOW_WIDTH * run then adjusted_string << "\n" ; run += 1 ; newline = true ; end
                            if newline == true
                              adjusted_string << line_chunks[line_chunks.size - 1]
                              newline = false
                            else
                              adjusted_string << ' ' + line_chunks[line_chunks.size - 1]
                            end
                            line_chunks.pop
                          end
                        elsif @split_method == 'char'
                          adjusted_string = last.scan(/.{#{@character_split}}|.+/).join("\n")
                        end
                      else
                        tolerance += self.get('cur_width',last)
                        adjusted_string << last
                        newline = true
                      end
                    end
                    val = adjusted_string.lstrip
                  end
                 
                  if val.empty?
                    text = LOCALIZATION_TEXT_DEFAULT
                  elsif val.scan(/\n/).size - 1 > LOCALIZATION_MAX_LINE
                    text = "Warning, this text has too many lines, line #{index}"
                  else
                    text = val
                  end
                else
                  text = "Warning, this text was too big, line #{index}"
                end
              found = true
            end
          end
          index += 1
        }
        if !found then text = "ID[#{id}] not found" end
      else
        if @dialogues[id.to_sym] != nil
          text = String.new(@dialogues[id.to_sym])
        else
          text = "invalid ID specified"
        end
      end
      return text.chomp
  end
 
  def self.check()
    @errors.each { |key,val|
      if val != nil && val.class != Array
        case key
          when :folder
            print "Localization folder is missing,\nthis game will not run without its contents"
            exit
          when :def_lang
            print "Default language file is missing,\nthis game will not run without it"
            exit
          when :save_lang
            #this error is very rare, only happen in a very strictly set UAC or intentional file modification by user
            print "Unable to modify localization file\nPlease make sure this game has elevated priveleges"
            print "Run the game as administrator\nOr simply place the game folder in other than C:/ drive"
            exit
          when :change_lang
            print "Language has been changed into : #{val}"
          when :cur_lang
            if @behavior == 'strict'
              print "#{@current_language} was not found\nMake sure the specified language file is present in Localization folder"
              exit
            else
              print "#{@current_language} was not found, switching to default language"
            end
        end
      elsif val != nil && val.class == Array
        if val.size > 0
          text = ''
          val.each { |v|
            if text.empty?
              text << (v.to_s)
            else
              text << (', ' + v.to_s)
            end
          }
          case key
            when :bad_id
              print "Bad IDs detected on line :\n#{text}\nAlphabets, numbers & Underscores only\n"
            when :empty
              print "Empty values detected on line :\n#{text}\nEmpty values will return 'empty value'\n"
            when :duplicate
              print "Duplicate keys detected on line :\n#{text}\nDuplicate values are be ignored\n"
            when :line
              print "Too many lines detected on line :\n#{text}\nThis game allow a maximum of #{LOCALIZATION_MAX_LINE} lines per dialogue\n"
            when :size
              print "Big text detected on line :\n#{text}\nThis game allow a maximum of #{MESSAGE_WINDOW_WIDTH*LOCALIZATION_MAX_LINE} total dialogue width\n"
          end
          if @behavior == 'strict' then exit end
        end
      end 
    }
    @errors = {
      :folder => nil,
      :def_lang => nil,
      :cur_lang => nil,
      :save_lang => nil,
      :change_lang => nil,
      :bad_id => Array.new,
      :duplicate => Array.new,
      :empty => Array.new,
      :line => Array.new,
      :size => Array.new
    }
  end
 
  #change different variables which will change how localization works in general
  def self.change(subject,value = nil)
    case subject
    when 'behavior'
      @behavior = value
    when 'method'
      @method = value
    when 'language'
      different_language = false
      @filename = "#{LOCALIZATION_FOLDER}\\#{LOCALIZATION_CONFIG}"
      @dialogues.clear
      if value != nil && value != @current_language
        begin
        File.open(@filename, 'wb') {|file| file.write(value.upcase) }
        rescue
          @errors[:save_lang] = 1
          self.check
        end
        different_language = true
      end
     
      @current_language = IO.readlines(@filename)[0].chomp.upcase
      @filename = "#{LOCALIZATION_FOLDER}\\#{@current_language}.txt"
      if !File.exists?(@filename)
        @errors[:cur_lang] = 1
        self.check
        change('language',LOCALIZATION_DEFAULT)
        return
      end
     
      #retrieve split method and language name from localization file
      @split_method = IO.readlines(@filename)[LOCALIZATION_METHOD_LINE - 1].chomp
      if @split_method != 'word' && @split_method != 'char' then @split_method = 'word' end
      if @split_method == 'char' then @character_split = self.get('max_line_width') end
      @language_name = IO.readlines(@filename)[LOCALIZATION_CREDITS_LINE - 1].split('-')[0]
      if different_language then @errors[:change_lang] = @language_name ; self.check end
     
      if @method != 'streaming'
        @file = File.new(@filename)
        index = 1
        @file.each { |line|
          if !line.empty? && index >= LOCALIZATION_START_LINE && line.include?('=')
            key = line.split(LOCALIZATION_DELIMITER)[0]
            if !(key =~ /^(\w+)$/)
              @errors[:bad_id].push(index)
            else
              if @dialogues.has_key?(key.to_sym)
                @errors[:duplicate].push(index)
              else
                val = line.slice(key.size+LOCALIZATION_DELIMITER.size,line.size).squeeze(" ")
                if self.get('cur_width',val) < MESSAGE_WINDOW_WIDTH * LOCALIZATION_MAX_LINE
                  if self.get('cur_width',val) >= MESSAGE_WINDOW_WIDTH then
                    last = ''
                    adjusted_string = ''
                    run = 1
                    new_line = true
                    text_chunks = Array.new
                    line_chunks = Array.new
                    tolerance = 0
                   
                    val.split('\n').each { |fragment| text_chunks.push(fragment) }
                    text_chunks = text_chunks.reverse
                    while text_chunks.size > 0
                      last = text_chunks[text_chunks.size - 1] + "\n"
                      text_chunks.pop
                      if self.get('cur_width',last) >= MESSAGE_WINDOW_WIDTH
                        if @split_method == 'word'
                          last.split(' ').each { |fragment2| line_chunks.push(fragment2) }
                          line_chunks = line_chunks.reverse
                          while line_chunks.size > 0
                            if self.get('cur_width',adjusted_string) + self.get('cur_width',line_chunks[line_chunks.size - 1]) - tolerance > MESSAGE_WINDOW_WIDTH * run then adjusted_string << "\n" ; run += 1 ; newline = true ; end
                            if newline == true
                              adjusted_string << line_chunks[line_chunks.size - 1]
                              newline = false
                            else
                              adjusted_string << ' ' + line_chunks[line_chunks.size - 1]
                            end
                            line_chunks.pop
                          end
                        elsif @split_method == 'char'
                          adjusted_string = last.scan(/.{#{@character_split}}|.+/).join("\n")
                        end
                      else
                        tolerance += self.get('cur_width',last)
                        adjusted_string << last
                        newline = true
                      end
                    end
                    val = adjusted_string.lstrip
                  end
                  if val.empty?
                    @errors[:empty].push(index)
                  elsif val.scan(/\n/).size - 1 > LOCALIZATION_MAX_LINE
                    @errors[:line].push(index)
                  else
                    @dialogues[key.to_sym] = val
                  end
                else
                  @errors[:size].push(index)
                end
              end
            end
          end
          index += 1
        }
      end
      self.check
    end
  end
 
  #get various attributes
  def self.get(subject,value = nil)
    case subject
      when 'cur_width'; return Bitmap.new(1, 1).text_size(value).width
      when 'cur_height'; return Bitmap.new(1, 1).text_size(value).height
      when 'max_line_width'
        multiplier = 1
        text = 'あ' * multiplier
        while Bitmap.new(1, 1).text_size(text).width < MESSAGE_WINDOW_WIDTH
          multiplier += 1
          text = 'あ' * multiplier
        end
        return multiplier
    end
  end
 
  #scan any localization-related command and return its result to draw text method
  def self.scan(command)
    if command != nil
      return command.gsub(/\\[Rr][Ee][Cc]\[(.+)\]/) { self.read($1) }
    end
  end
 
  Localization.init
end

#-------------------------------------------------------------------------------
# - Over Ride
#-------------------------------------------------------------------------------
class Game_Temp
  def message_text=(string)
    @message_text = Localization.scan(string)
  end
end

class Interpreter
  alias old_command_101 command_101
 
  def command_101
    if $game_temp.message_text != nil
      return false
    end
    @message_waiting = true
    $game_temp.message_proc = Proc.new { @message_waiting = false }
    $game_temp.message_text = Localization.scan(@list[@index].parameters[0]) + "\n"
    line_count = $game_temp.message_text.scan(/\n/).size
    loop do
      if @list[@index+1].code == 401
        $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
        line_count += 1
      else
        if @list[@index+1].code == 102
          if @list[@index+1].parameters[0].size <= 4 - line_count
            @index += 1
            $game_temp.choice_start = line_count
            setup_choices(@list[@index].parameters)
          end
        elsif @list[@index+1].code == 103
          if line_count < 4
            @index += 1
            $game_temp.num_input_start = line_count
            $game_temp.num_input_variable_id = @list[@index].parameters[0]
            $game_temp.num_input_digits_max = @list[@index].parameters[1]
          end
        end
        return true
      end
      @index += 1
    end
  end
end

class Bitmap
  alias old_draw_text draw_text
  def draw_text(*args)
    args.each_index {|i| if args[i].is_a?(String) then args[i] = Localization.scan(args[i]) end }
    old_draw_text(*args)
  end
end
6
Script Troubleshooting / Re: [XP] Window Item Description
November 19, 2015, 06:09:04 pm
it looks like this


#===============================================================================
# * Window_Item_Help
#-------------------------------------------------------------------------------
#  It is the window which indicates the item description the skill and the
#  status etc. of the actor.
#===============================================================================

class Window_Item_Help < Window_Base
 
  #-----------------------------------------------------------------------------
  # - Object initialization
  #-----------------------------------------------------------------------------
  def initialize
    super(0, 352, 403, 128)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
 
  #-----------------------------------------------------------------------------
  # - Text setting
  #     text  : The character string which is indicated in the window
  #     align : Alignment:
  #  0. The left arranging
  #  1. Central arranging
  #  2. The right it arranges
  #-----------------------------------------------------------------------------
  def set_text(text, align = 0)
    # When at least one side of the text and the alignment it is different
    #  from the last time
    if text != @text or align != @align
      text= self.contents.slice_text("string", 400)
      # Redrawing the text
      self.contents.clear
      self.contents.font.color = normal_color
    text.each_index {|i|
        self.contents.draw_text(4, 0 + i*32, 40, 32, text[i])}
      @text = text
      @align = align
      @actor = nil
    end
    self.visible = true
  end
 
  #-----------------------------------------------------------------------------
  # - Actor setting
  #     actor : The actor who indicates status
  #-----------------------------------------------------------------------------
  def set_actor(actor)
    if actor != @actor
      self.contents.clear
      draw_actor_name(actor, 4, 0)
      draw_actor_state(actor, 140, 0)
      draw_actor_hp(actor, 284, 0)
      draw_actor_sp(actor, 460, 0)
      @actor = actor
      @text = nil
      self.visible = true
    end
  end
 
  #-----------------------------------------------------------------------------
  # - Enemy setting
  #     enemy : The enemy which indicates name and the state
  #-----------------------------------------------------------------------------
  def set_enemy(enemy)
    text = enemy.name
    state_text = make_battler_state_text(enemy, 112, false)
    if state_text != ""
      text += "  " + state_text
    end
    set_text(text, 1)
  end
end

  #-----------------------------------------------------------------------------
  # - Bitmap
  #-----------------------------------------------------------------------------
class Bitmap
  def slice_text(text, width)
    words = text.split(' ')
    return words if words.size == 1
    result, current_text = [], words.shift
    words.each_index {|i|
        if self.text_size("#{current_text} #{words[i]}").width > width
          result.push(current_text)
          current_text = words[i]
        else
          current_text = "#{current_text} #{words[i]}"
        end
        result.push(current_text) if i >= words.size - 1}
    return result
  end
end
7
Script Troubleshooting / Re: [XP] Window Item Description
November 19, 2015, 05:49:31 pm
ummm then I did something really wrong or I don't get it, cause when I add those things to the script, every, but really every item has the same description
8
Script Troubleshooting / Re: [XP] Window Item Description
November 19, 2015, 04:38:57 pm
i tried to understand it... but i just dont get it ...
i ended up editing the script but i messed up again, it made every description go to 'String'
which i didnt understood since it draws all descriptions the same...
9
Hello chaos-project community.
ive been busy with a edit of a the item description window which i use in a new menu layout (resident evil styled)
but the problem is that the original item description is 1 big line.

but i need it to divide itself to another line if it reaches the end of my box (its 403 px)
because i am now getting this:
Spoiler: ShowHide


and i want it to be like
Spoiler: ShowHide



this is the script itself. (small edits)
Spoiler: ShowHide

#===============================================================================
# * Window_Item_Help
#-------------------------------------------------------------------------------
#  It is the window which indicates the item description the skill and the
#  status etc. of the actor.
#===============================================================================

class Window_Item_Help < Window_Base
 
 #-----------------------------------------------------------------------------
 # - Object initialization
 #-----------------------------------------------------------------------------
 def initialize
   super(0, 352, 403, 128)
   self.contents = Bitmap.new(width - 32, height - 32)
 end
 
 #-----------------------------------------------------------------------------
 # - Text setting
 #     text  : The character string which is indicated in the window
 #     align : Alignment:
 #  0. The left arranging
 #  1. Central arranging
 #  2. The right it arranges
 #-----------------------------------------------------------------------------
 def set_text(text, align = 0)
   # When at least one side of the text and the alignment it is different
   #  from the last time
   if text != @text or align != @align
     # Redrawing the text
     self.contents.clear
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
     @text = text
     @align = align
     @actor = nil
   end
   self.visible = true
 end
 
 #-----------------------------------------------------------------------------
 # - Actor setting
 #     actor : The actor who indicates status
 #-----------------------------------------------------------------------------
 def set_actor(actor)
   if actor != @actor
     self.contents.clear
     draw_actor_name(actor, 4, 0)
     draw_actor_state(actor, 140, 0)
     draw_actor_hp(actor, 284, 0)
     draw_actor_sp(actor, 460, 0)
     @actor = actor
     @text = nil
     self.visible = true
   end
 end
 
 #-----------------------------------------------------------------------------
 # - Enemy setting
 #     enemy : The enemy which indicates name and the state
 #-----------------------------------------------------------------------------
 def set_enemy(enemy)
   text = enemy.name
   state_text = make_battler_state_text(enemy, 112, false)
   if state_text != ""
     text += "  " + state_text
   end
   set_text(text, 1)
 end
end


can anyone help me with this?

greets, various
10
RMVX Ace Script Database / [VXA] Auction House
January 25, 2013, 06:56:40 am
Auction House
Authors: Ninjamida
Version: 1.0
Type: Auction house
Key Term: Misc Add-on



Introduction

this script makes a auction house for items, weapons and armours
complete with AI bidders that can overbid you


Features


  • normal, fast and rare auction

  • can get overbid by computer bidders

  • change bidders max money, how agressive they bid and more




Screenshots

if people want a screenshot i will add, but it doesnt make sence to add a screenshot of some bidders


Demo

sorry no demo


Script

Spoiler: ShowHide
################################
## Auction House Scene Script ##
################################
##        By Ninjamida        ##
################################

### Compatibility: This operates in its own scene. Therefore, it should
###                be compatible with just about anything. However, it may
###                have issues with scripts that modify how windows work. It
###                is compatible with resolution-changing scripts. However you
###                may need to adjust the size of the windows to suit any other
###                resolution but the standard one (they will still fill the
###                screen, but the offer window will be disproportionately large).
###
### Dependancies: None. This script will work in vanilla RMVXA projects.

### Configuration:
###
### Most of the configuration is below and explained next to the options.
### However, the prices for items is set in the database via notetag.
### <start price: xxx>
### <reserve price: xxx>
### <max price: xxx>
### <increment: xxx>
### Use these notetags to set the prices for an item.
### An item will start at the start price. The final sale price will be
### no less than the reserve and no more than the maximum.
### The increment is how much the value goes up with each bid.
### If any of these are not set for an item, the default ones from the
### configuration below will be used.
###
### If you want an item to only be winnable once, this is also set via
### notetags. Add the following notetag to an item:
### <unique>
### If you set this, the item can only be won in an auction once ever,
### even if there's more than one hash containing it. This does not in
### any way prevent another one of it from being obtained elsewhere in
### the game, whether pre- or post- winning it in an auction. Just for
### the record, this tag will apply across all auction types, not just
### special auctions.

######################
### Config Options ###
######################

module Ninjamida
  module Auction
   
    ##############################
    ### Auction General Config ###
    ##############################
   
    ### Width of Auction Type and Gold Windows
    TYPE_WINDOW_WIDTH = 200
    ### You can set Special Auctions to be disabled (by turning off the switch
    ### that enables them) when they've been won or lost. Note that this disables
    ### the set as a whole. If you just want to make one item not winnable again,
    ### set it as unique using the notetag described above.
    DISABLE_SPECIAL_ON_LOSE = false
    DISABLE_SPECIAL_ON_WIN = false
    ### Reserved switch. This switch is used by the script, do not use elsewhere
    ### in your project.
    RESERVED_SWITCH = 1
    ### Set the names of the auction types
    NORMAL_AUCTION = "Normal Auction"
    FAST_AUCTION = "Quick Auction"
    SPECIAL_AUCTION = "Rare Auction"
    ### Set the description of the auction types
    NORMAL_DESC = "A standard auction."
    FAST_DESC = "A higher-speed auction."
    SPECIAL_DESC = "A special auction with rare items."
    ### Set the text to appear in the help window once the auction starts.
    FIRST_LINE = "Press OK button to bid."
    SECOND_LINE = "Time Remaining: "
    ### Display remaining time at end of 2nd line in help window? This will
    ### show in minutes/seconds, not frames.
    SHOW_REMAINING_TIME = true
    ### Text expressions for various events.
    BID_TEXT = "%1$s bids %2$s%3$s." #%1$s = bidder, %2$s = amount, %3$s = currency
    PLAYER_NAME = "$game_party.leader.name" #Player name. You can use Ruby code here.
    WIN_TEXT = "Bought %1$s for %3$s %4$s!" #%1$s = item, %2$s = player name, %3$s = amount, %4$s = currency
    LOSE_TEXT = "%2$s bought %1$s for %3$s %4$s." #Same as above, %2$s = winning bidder
    FINISHED_HELP_TEXT = "The auction has ended! Press OK button to exit." #Plain text only.
    ### Sound effects for various events. (Filename, Volume, Pitch)
    PLAYER_BID_SFX = RPG::SE.new("Confirm (FF7)", 100, 100) #When player bids
    AI_BID_SFX = RPG::SE.new("Decision1", 100, 100) #When an AI bids
    CANT_BID_SFX = RPG::SE.new("Buzzer (FF7)", 100, 100) #When player cannot bid
    WIN_ITEM_SFX = RPG::SE.new("Distant Worlds II - Victory Theme", 100, 100) #When player wins
    LOSE_ITEM_SFX = RPG::SE.new("Failed Dance (FF7)", 100, 100) #When an AI wins
    ### Duration of the auctions. This is in frames. Assuming you don't have
    ### any script that changes it, 1 second = 60 frames.
    NORMAL_DURATION = 3600
    FAST_DURATION = 900
    SPECIAL_DURATION = 3600
    ### If a bid is placed (whether by the player or by AI) when the auction
    ### is close to ending, the auction can extend. Set the number of frames
    ### to extend by here. The extension will only occur if the auction already
    ### has fewer than that many frames remaining. Set this to 0 if you want
    ### no extensions. (eg: if set to 180, and auction has less than 180 frames
    ### remaining and a bid is placed, auction will extend by 180 frames)
    NORMAL_EXTEND = 0
    FAST_EXTEND = 0
    SPECIAL_EXTEND = 0
    ### Set the default prices. These will be used for any item that doesn't
    ### have its own prices set.
    DEFAULT_START_PRICE = 500
    DEFAULT_RESERVE_PRICE = 1000
    DEFAULT_MAX_PRICE = 1500
    DEFAULT_INCREMENT = 50
   
    ####################
    ### Prize Config ###
    ####################
   
    ### Each prize hash should be surrounded by [ ]
    ### Inside this, set [x, y] where x is item type and y is item ID
    ### Item type is 0 for items, 1 for weapons, 2 for armors
    ### The minimum number of prizes in a set is 1
    ### There is no maximum number of prizes in a set
    ### You may have a different amount of items in different sets
    NORMAL_PRIZE =  [ # For normal prizes, simply set each item
                     [[0, 1], [0, 8], [0, 13], [0, 31]], # X-Potion/Dry Ether/Phoenix Ember/Remedy
                     [[0, 4], [0, 5], [0, 6], [0, 140]], # Al Bhed Items
                     [[0, 15], [0, 16], [0, 17], [0, 10]], # Special Battle Items
                     [[0, 33], [0, 36], [0, 39], [0, 42]], # Elemental Items
                     [[0, 57], [0, 59], [0, 61], [0, 64]], # State Items
                     [[0, 3], [0, 8], [0, 31], [0, 79]], # Deconstructor Special
                     [[0, 83], [0, 84], [0, 144], [0, 146]], # ALL UNIQUE
                     [[0, 66], [0, 67], [0, 70], [0, 128]], # Fixed Dice Special
                     [[1, 6], [1, 25], [1, 55], [1, 69]], # Weapons
                     [[2, 6], [2, 33], [2, 34], [2, 69]], # Shield
                     [[2, 66], [2, 68], [2, 70], [2, 146]], # Armor
                     [[1, 80], [1, 108], [2, 7], [2, 8]], # Weapon & Shield
                     [[2, 111], [2, 125], [2, 135], [2, 148]] # Relics & Armor
                    ]
    FAST_PRIZE =    [ # If fast prizes is left blank, it will copy normal
                     
                    ]
    SPECIAL_PRIZE = [ # For special auctions, the lone number is the switch
                     [2, [2, 231]],
                     [3, [2, 240]]
                    ]
                   
    #########################             
    ### AI Bidders Config ###
    #########################
   
    ### To add a bidder, use the following format:
    ### ["NAME", Min, Max, Agr, Std, Rbd, Nrm, Fst, Spc]
    ### "NAME" is the name of the bidder. Must be in quotes!
    ### Min is the minimum starting price of an item for them to bid on.
    ###    If an item's starting price is below this, that bidder will never
    ###    appear in the auction.
    ### Max is the highest amount that bidder will ever bid on an item.
    ###    Note that the bidder may still participate even if the max or reserve
    ###    price is higher than their maximum, as long as the starting price
    ###    is equal to or less than it.
    ### Agr determines how aggresively the bidder will bid for an
    ###    item. This is a value from 0 to 100. A value of 0 means they will never
    ###    bid once the reserve has been reached, a value of 100 means they will
    ###    bid without fail once their delay is up unless it would exceed their
    ###    maximum price.
    ### Std is how many frames from the start of the auction until this
    ###    bidder will place a starting bid. Note that the starting bid is 100%
    ###    guaranteed to occur, provided no other bid has been placed by that
    ###    time. So basically, unless the player does first, whichever AI bidder
    ###    has the lowest StartDelay will end up placing the starting bid.
    ### Rbd is how many frames from a previous bid the bidder will wait
    ###    before possibly placing their next bid. Whether or not they actually
    ###    place one is random, dependant on their aggressiveness.
    ### Nrm, Fst and Spc are whether that bidder will take part in normal, fast
    ###    and special auctions respectively.
    ### Note that AI bidders may bid more often than their aggressiveness would
    ###    usually allow for if it's to ensure the reserve price is met. They
    ###    will not exceed their maximum to do so unless you enable them to.
    ### If you need to access them outside this script for any reason, they get
    ###    loaded into $ninjamida_bidders. @name, @min_gold, @max_gold, @aggression,
    ###    @start_delay, @rebid_delay, @auction_types[0=normal, 1=fast, 2=special].
    ###    $ninjamida_bidders is used for both the data and the actively-used object.
    ###
    AI_BIDDERS = [
                  ["Stella", 1, 10000, 35, 30, 240, true, true, true],
                  ["Dona", 1, 22000, 60, 40, 240, true, true, true],
                  ["Gordon", 1, 30000, 33, 30, 240, true, true, true],
                  ["Raine", 1, 32000, 25, 300, 120, true, true, true],
                  ["Maechen", 1, 35000, 80, 300, 240, true, true, true],
                  ["Brahne", 1, 45000, 50, 240, 60, true, true, true],
                  ["Goldor", 1, 75000, 75, 600, 180, false, false, true],
                  ["Setzer", 1, 40000, 40, 120, 30, true, true, false],
                  ["Gestahl", 1, 50000, 15, 60, 90, true, true, true],
                  ["Ellone", 1, 60000, 50, 256, 120, true, true, true],
                  ["Don Corneo", 1, 100000, 90, 450, 150, false, false, true],
                  ["Shera", 1, 20000, 20, 150, 60, true, true, true]
                 ]
    ### To ensure that the reserve price is met, you can allow AI bidders to
    ### exceed their maximum bid if the going price is less than reserve. They
    ### still will only do so if none of the AI bidders in the auction have a
    ### maximum price higher than the reserve. It's reccomended to enable this
    ### just in case you set an item's reserve higher than any of your bidders.
    ALLOW_EXCESS_BID = true
    ### Select how many AI bidders will be present in an auction. The bidders
    ### who enter will be randomly selected, and when possible at least one will
    ### have a maximum price equal or higher than the item's reserve price. Note
    ### that if not enough valid bidders (by price range or auction type) exist,
    ### fewer than this may end up being selected. If enough are available, this
    ### amount will always be picked.
    NUM_AI_BIDDERS = 4
    ### You can set points at which the AI bidders will get more aggressive to
    ### ensure the reserve is met. This is a global setting to all AI bidders.
    ### These are set as a % of the remaining auction time. Once the reserve is
    ### met, aggressiveness returns to normal. If any is set to 0, it will
    ### not occur.
    LOW_AGR_POINT = 75   # At this point, aggressiveness increases
    MID_AGR_POINT = 50   # At this point, aggressiveness raises to 100%
    HIGH_AGR_POINT = 25  # At this point, rebid delay is halved
    ### Please note that no check is performed at the end to ensure that reserve
    ### is met. Therefore, if your bidders aren't aggressive enough and/or these
    ### high aggression points aren't used, there is a chance the player will be
    ### able to buy items for lower than the reserve price.
    ### If anyone wants to know, the increase at the low agression point will
    ### halve their chance of *not* bidding. So basically:
    ### new_agr = 100 - ((100 - agr) / 2)
   
  end
end

### Auction Scene

class Scene_Auction < Scene_Base
 
  ### Setup Scene ###
  def start
    super
    pick_auction_offers
    $game_switches[Ninjamida::Auction::RESERVED_SWITCH] = not(@special_offer.nil?)
    create_help_window
    create_atype_window
    create_gold_window
    create_offer_window
    create_process_window
    finish_setup_atype_window
  end
 
  ### Pick the prize selections
  def pick_auction_offers
    normaloffers = Ninjamida::Auction::NORMAL_PRIZE.clone
    fastoffers = Ninjamida::Auction::FAST_PRIZE.clone
    specialoffers = Ninjamida::Auction::SPECIAL_PRIZE.clone
    fastoffers = normaloffers if fastoffers.empty?
   
    @normal_offer = normaloffers[rand(normaloffers.size)]
    @fast_offer = fastoffers[rand(fastoffers.size)]
   
    specialpool = []
    specialoffers.each do |spof|
      specialpool += [spof] if $game_switches[spof[0]]
    end
   
    if specialpool.empty?
      @special_offer = nil
    else
      @special_offer = specialpool[rand(specialpool.size)].clone
      @special_offer.delete_at(0)
      $game_party.unique_items_won.each do |it|
        @special_offer.delete(it)
      end
      @special_offer = nil if @special_offer.empty?
    end

  end
 
  ### Create Help Window
  def create_help_window
    @help_window = Window_AuctionHelp.new
    @help_window.viewport = @viewport
  end
 
  ### Create Auction Type Window
  def create_atype_window
    @atype_window = Window_AuctionType.new
    @atype_window.set_handler(:standard,  method(:start_standard_auction))
    @atype_window.set_handler(:fast,      method(:start_fast_auction))
    @atype_window.set_handler(:special,   method(:start_special_auction))
    @atype_window.set_handler(:cancel,    method(:return_scene))
  end
 
  ### These need to be run for atype after ALL windows set up.
  def finish_setup_atype_window
    @atype_window.offers = [@normal_offer, @fast_offer, @special_offer]
    @atype_window.offer_window = @offer_window
    @atype_window.help_window = @help_window
  end
 
  ### Create Gold Window
  def create_gold_window
    @gold_window = Window_AuctionGold.new
    @gold_window.y = @help_window.height + @atype_window.height
  end
 
  ### Create Offer Window
  def create_offer_window
    @offer_window = Window_AuctionOffer.new
    @offer_window.unselect
    @offer_window.deactivate
    @offer_window.set_handler(:cancel,    method(:return_type))
    @offer_window.set_handler(:ok,        method(:start_auction))
    @offer_window.help_window = @help_window
  end
 
  ### Create Process Window
  def create_process_window
    @process_window = Window_AuctionProcess.new
    @process_window.help_window = @help_window
  end
 
  ### Select Standard Auction
  def start_standard_auction
    @auction_type = 0
    @duration = Ninjamida::Auction::NORMAL_DURATION
    @extend = Ninjamida::Auction::NORMAL_EXTEND
    to_offer_window
  end
 
  ### Select Fast Auction
  def start_fast_auction
    @auction_type = 1
    @duration = Ninjamida::Auction::FAST_DURATION
    @extend = Ninjamida::Auction::FAST_EXTEND
    to_offer_window
  end
 
  ### Select Special Auction
  def start_special_auction
    @auction_type = 2
    @duration = Ninjamida::Auction::SPECIAL_DURATION
    @extend = Ninjamida::Auction::SPECIAL_EXTEND
    to_offer_window
  end
 
  ### Activate Item Selection
  def to_offer_window
    @atype_window.deactivate
    @offer_window.select(0)
    @offer_window.activate
  end
 
  ### Return to Type Selection
  def return_type
    @offer_window.unselect
    @offer_window.deactivate
    @atype_window.activate
  end
 
  ### Start The Auction
  def start_auction
    case @auction_type
    when 0
      @prize = @normal_offer[@offer_window.index]
    when 1
      @prize = @fast_offer[@offer_window.index]
    when 2
      @prize = @special_offer[@offer_window.index]
    end
    case @prize[0]
    when 0
      @prize = $data_items[@prize[1]]
    when 1
      @prize = $data_weapons[@prize[1]]
    when 2
      @prize = $data_armors[@prize[1]]
    end
    @process_window.start_point = Graphics.frame_count
    @process_window.duration = @duration
    @process_window.display_help_message
    @opponents = select_other_bidders
    @auction_length = @duration
    reset_other_bidders
    run_auction
  end
 
  def select_other_bidders
    start_price = @prize.auction_start_price
    potentials = []
    $ninjamida_bidders.each do |bidder|
      bidder_okay = bidder.auction_types[@auction_type]
      bidder_okay = false if start_price > bidder.max_gold
      bidder_okay = false if start_price < bidder.min_gold
      potentials += [bidder] if bidder_okay
    end
    return [$ninjamida_bidders[0]] if potentials.empty?
    until potentials.size <= Ninjamida::Auction::NUM_AI_BIDDERS
      potentials.delete_at(rand(potentials.size))
    end
    return potentials
  end
 
  def reset_other_bidders
    @opponents.each do |opp|
      opp.reset
    end
  end   
 
  ### Run The Auction
  def run_auction
    @price = @prize.auction_start_price
    @reserve = @prize.auction_reserve_price
    @maxprice = @prize.auction_max_price
    @increm = @prize.auction_increment
    @gold = $game_party.gold
   
    @leading_bidder = -2
    @messages = ['', '', '']
   
    update_action_time(true)
   
    until @duration == 0
      check_player_bid
      check_cpu_bid
      check_aggression_updates if @price < @reserve
      next_frame
      @process_window.display_help_message if Ninjamida::Auction::SHOW_REMAINING_TIME
    end
   
    if @leading_bidder == -1
      process_player_win
    else
      process_cpu_win
    end
  end
 
  def process_player_win
    winmsg = sprintf(Ninjamida::Auction::WIN_TEXT, @prize.name, eval(Ninjamida::Auction::PLAYER_NAME), @price, $data_system.currency_unit)
    new_line(winmsg)
    $game_party.gain_item(@prize, 1)
    $game_party.lose_gold(@price)
    Ninjamida::Auction::WIN_ITEM_SFX.play
    wait_for_ok
  end
 
  def process_cpu_win
    losemsg = sprintf(Ninjamida::Auction::LOSE_TEXT, @prize.name, $ninjamida_bidders[@leading_bidder].name, @price, $data_system.currency_unit)
    new_line(losemsg)
    Ninjamida::Auction::LOSE_ITEM_SFX.play
    wait_for_ok
  end
 
  def wait_for_ok
    @help_window.set_text(Ninjamida::Auction::FINISHED_HELP_TEXT)
    until Input.trigger?(:C)
      update_basic
    end
    return_scene
  end
 
  def check_player_bid
    if Input.trigger?(:C)
      if not(@price + @increm > @gold or @leading_bidder == -1)
        update_action_time
        @leading_bidder = -1
        Ninjamida::Auction::PLAYER_BID_SFX.play
        increase_bid
      else
        Ninjamida::Auction::CANT_BID_SFX.play
      end
    end
  end
 
  def check_cpu_bid
    return false if @price >= @prize.auction_max_price
    @opponents.each do |ai_bidder|
      unless @leading_bidder == ai_bidder.id
        if ai_bidder.place_bid?(@price + @increm)
          update_action_time
          @leading_bidder = ai_bidder.id
          increase_bid
          Ninjamida::Auction::AI_BID_SFX.play
        end
      end
    end
  end
 
  def check_aggression_updates
    set_aggression(1) if @duration == (@auction_length * 100 / Ninjamida::Auction::LOW_AGR_POINT).to_i
    set_aggression(2) if @duration == (@auction_length * 100 / Ninjamida::Auction::MID_AGR_POINT).to_i
    set_aggression(3) if @duration == (@auction_length * 100 / Ninjamida::Auction::HIGH_AGR_POINT).to_i
  end
 
  def check_first_bid
    if @leading_bidder == -2
      @opponents.each do |ai_bidder|
        ai_bidder.first_bid
      end
    end
  end
 
  def set_reserve_met
    @opponents.each do |ai_bidder|
      ai_bidder.reserve_met
    end
  end
 
  def set_aggression(agrlevel)
    @opponents.each do |ai_bidder|
      ai_bidder.set_aggression_level(agrlevel)
    end
  end
 
  def increase_bid
    @price += @increm
    if @leading_bidder == -1
      new_line(make_bid_text(eval(Ninjamida::Auction::PLAYER_NAME), @price))
    else
      new_line(make_bid_text($ninjamida_bidders[@leading_bidder].name, @price))
    end
    set_reserve_met if @price >= @reserve
    check_extension
  end
 
  def check_extension
    if @duration < @extend
      @duration += @extend
      @auction_length += @extend
      @process_window.duration = @auction_length
    end
  end
 
  def update_action_time(initializing = false)
    check_first_bid if not initializing
    @opponents.each do |ai_bidder|
      ai_bidder.set_last_action(Graphics.frame_count)
    end
  end
 
  def make_auction_message(updatewindow=true)
    outmsg = @messages[0] + "\n" + @messages[1] + "\n" + @messages[2]
    @process_window.update_message(outmsg) if updatewindow
    return outmsg
  end
 
  def new_line(nltext, updatewindow=true)
    @messages.delete_at(2)
    @messages = [nltext] + @messages
    make_auction_message if updatewindow
  end
 
  def make_bid_text(bidder, bidamt)
    bidtxt = sprintf(Ninjamida::Auction::BID_TEXT, bidder, bidamt, $data_system.currency_unit)
    return bidtxt
  end
 
  ### Advance Frame
  def next_frame
    @duration -= 1
    update_basic
  end
 
end

class Game_Party < Game_Unit
 
  attr_accessor :unique_items_won
 
  alias ninjamida_auction_initialize initialize
  def initialize
    ninjamida_auction_initialize
    @unique_items_won = []
  end
 
end

class Ninjamida_AuctionBidder
 
  attr_accessor :id
  attr_accessor :name
  attr_accessor :min_gold
  attr_accessor :max_gold
  attr_accessor :aggression
  attr_accessor :start_delay
  attr_accessor :rebid_delay
  attr_accessor :auction_types
 
  def initialize(id)
    @id = id
    @name = Ninjamida::Auction::AI_BIDDERS[id][0]
    @min_gold = Ninjamida::Auction::AI_BIDDERS[id][1]
    @max_gold = Ninjamida::Auction::AI_BIDDERS[id][2]
    @aggression = Ninjamida::Auction::AI_BIDDERS[id][3]
    @start_delay = Ninjamida::Auction::AI_BIDDERS[id][4]
    @rebid_delay = Ninjamida::Auction::AI_BIDDERS[id][5]
    normal_auction = Ninjamida::Auction::AI_BIDDERS[id][6]
    fast_auction = Ninjamida::Auction::AI_BIDDERS[id][7]
    special_auction = Ninjamida::Auction::AI_BIDDERS[id][8]
    @auction_types = [normal_auction, fast_auction, special_auction]
    reset
  end
 
  def reset
    @last_action = Graphics.frame_count
    @aggression_level = 0
    @first_bid_placed = false
    @reserve_met = false
  end
 
  def set_last_action(action_time)
    @last_action = action_time
  end
 
  def set_aggression_level(level)
    @aggression_level = level
  end
 
  def first_bid
    @first_bid_placed = true
  end
 
  def reserve_met
    @aggression_level = 0
    @reserve_met = true
  end
   
  def place_bid?(item_price)
    return false if not check_bid_time
    return false if not check_bid_price(item_price)
    set_last_action(Graphics.frame_count)
    return determine_bid
  end
 
  def aggression
    case @aggression_level
    when 0
      return @aggression
    when 1
      return 100 - ((100 - @aggression) / 2)
    else
      return 100
    end
  end
 
  def check_bid_time
    delay = @rebid_delay
    delay = @start_delay if not @first_bid_placed
    delay /= 2 if @aggression_level == 3
    return true if Graphics.frame_count >= @last_action + delay
    return false
  end
 
  def check_bid_price(item_price)
    return true if Ninjamida::Auction::ALLOW_EXCESS_BID and not(@reserve_met)
    return true if item_price < @max_gold
    return false
  end
 
  def determine_bid
    return true if rand(100) < aggression
    return false
  end 
 
end

module DataManager
  class << self
   
    alias ninjamida_auction_create_game_objects create_game_objects
    def create_game_objects
      ninjamida_auction_create_game_objects
      $ninjamida_bidders = self.load_auction_bidders
    end
   
    def load_auction_bidders
      bidders = []
      Ninjamida::Auction::AI_BIDDERS.each_index do |id|
        bidders += [Ninjamida_AuctionBidder.new(id)]
      end
      return bidders
    end
  end
end

###### Auction Windows ######

### Customized Help Window
class Window_AuctionHelp < Window_Help

end

### Customized Gold Window
class Window_AuctionGold < Window_Gold
 
  ### Change Width
  def window_width
    return Ninjamida::Auction::TYPE_WINDOW_WIDTH
  end
 
end

### New window: Auction Type Window
class Window_AuctionType < Window_Command
 
  ### Setup Window
  def initialize
    super(0, fitting_height(2))
    @help_texts = [Ninjamida::Auction::NORMAL_DESC,
                   Ninjamida::Auction::FAST_DESC,
                   Ninjamida::Auction::SPECIAL_DESC]
  end
   
  ### Add The Options
  def make_command_list
    spswitch = $game_switches[Ninjamida::Auction::RESERVED_SWITCH]
    add_command(Ninjamida::Auction::NORMAL_AUCTION, :standard, true)
    add_command(Ninjamida::Auction::FAST_AUCTION, :fast, true)
    add_command(Ninjamida::Auction::SPECIAL_AUCTION, :special, spswitch)
  end
 
  ### Show Help Comments
  def update_help
    @help_window.set_text(@help_texts[@index])
    @offer_window.set_item_hash(@offers[@index])
  end
 
  ### Change The Width
  def window_width
    return Ninjamida::Auction::TYPE_WINDOW_WIDTH
  end
 
  ### Change The Height
  def window_height
    return Graphics.height - (fitting_height(2) + fitting_height(3) + fitting_height(1))
  end
 
  ### Set Hashes
  def offers=(offers)
    @offers = offers
  end
 
  ### Set Offer Window
  def offer_window=(offwin)
    @offer_window = offwin
  end
 
end

### New window: Auction Offer Window
class Window_AuctionOffer < Window_ItemList
 
  ### Setup Window
  def initialize
    super(Ninjamida::Auction::TYPE_WINDOW_WIDTH, fitting_height(2), window_width, window_height)
  end
 
  ### Change The Width
  def window_width
    return Graphics.width - Ninjamida::Auction::TYPE_WINDOW_WIDTH
  end
 
  ### Change The Height
  def window_height
    return Graphics.height - (fitting_height(2) + fitting_height(3))
  end
 
  ### Change Displayed Hash
  def set_item_hash(itemhash)
    @itemset = []
    if not itemhash.nil?
      itemhash.each do |thishash|
        case thishash[0]
        when 0
          @itemset += [$data_items[thishash[1]]]
        when 1
          @itemset += [$data_weapons[thishash[1]]]
        when 2
          @itemset += [$data_armors[thishash[1]]]
        end
      end
    end
    refresh
    return @itemset
  end
 
  ### Show Current Offers
  def make_item_list
    @data = @itemset
  end

  ### Override Showing Item By Type
  def include?(item)
    return true
  end
 
  ### Don't show items side-by-side
  def col_max
    return 1
  end
 
  ### Replace number display with starting price. Heh. Kludgy but works.
  def draw_item_number(rect, item)
    draw_text(rect, sprintf(item.auction_start_price.to_s + $data_system.currency_unit), 2)
  end
 
  ### Override the enable setting
  def enable?(item)
    $game_party.gold >= item.auction_start_price
  end
 
end

### Auction Processing Window
class Window_AuctionProcess < Window_Base
 
  def initialize
    super(0, Graphics.height - fitting_height(3), window_width, window_height)
    self.y = Graphics.height - fitting_height(3)
    self.openness = 255
  end
 
  def window_width
    Graphics.width
  end
 
  def window_height
    fitting_height(3)
  end
 
  def help_window=(help_window)
    @help_window = help_window
  end
 
  def start_point=(start_point)
    @start_point = start_point
  end
 
  def duration=(duration)
    @duration = duration
  end
 
  def display_help_message
    text = Ninjamida::Auction::FIRST_LINE + "\n" + Ninjamida::Auction::SECOND_LINE
    if Ninjamida::Auction::SHOW_REMAINING_TIME
      remtime = (Graphics.frame_count - @start_point)
      remtime = @duration - remtime
      remtime /= 60
      text += remtime.to_s + "s"
    end
    @help_window.set_text(text)
  end
 
  def update_message(text)
    create_contents
    draw_text_ex(0, 0, text)
  end
 
end
 

### Modify item structure so it can include auction data
class RPG::BaseItem
 
  def auction_start_price
    if @auction_start_price.nil?
      if @note =~ /<(?:start price):[ ](\d+)>/i
        @auction_start_price = $1.to_i
      else
        @auction_start_price = Ninjamida::Auction::DEFAULT_START_PRICE
      end
    end
    @auction_start_price
  end
 
  def auction_reserve_price
    if @auction_reserve_price.nil?
      if @note =~ /<(?:reserve price):[ ](\d+)>/i
        @auction_reserve_price = $1.to_i
      else
        @auction_reserve_price = Ninjamida::Auction::DEFAULT_RESERVE_PRICE
      end
    end
    @auction_reserve_price
  end
 
  def auction_max_price
    if @auction_max_price.nil?
      if @note =~ /<(?:max price):[ ](\d+)>/i
        @auction_max_price = $1.to_i
      else
        @auction_max_price = Ninjamida::Auction::DEFAULT_MAX_PRICE
      end
    end
    @auction_max_price
  end
 
  def auction_increment
    if @auction_increment.nil?
      if @note =~ /<(?:increment):[ ](\d+)>/i
        @auction_increment = $1.to_i
      else
        @auction_increment = Ninjamida::Auction::DEFAULT_INCREMENT
      end
    end
    @auction_increment
  end
 
  def auction_unique
    if @auction_unique.nil?
      if @note =~ /<(?:unique)>/i
        @auction_unique = true
      else
        @auction_unique = false
      end
    end
    @auction_unique
  end
 
end



Instructions

can be found inside the script


Compatibility

it may not work properly when changing window files


Credits and Thanks


  • Ninjamida




Author's Notes

this was used in a final fantasy game, so thats why the final fantasy music
11
RMVX Ace Script Database / [VXA] Custom Save File
January 25, 2013, 06:43:56 am
Custom Save File
Authors: various
Version: 1.0
Type: save file editor
Key Term: Title / Save / Load / GameOver Add-on



Introduction

this script changes your extension/name to the one you desire


Features


  • have your own custom savefile suchs as "Save.variouss" or anything else you want




Screenshots

screenshots of a save file is kinda boring...


Demo

not needed since its only for save files


Script

Spoiler: ShowHide
#==================#
# Custom Save File #
#==================#===========================#
# This script allows you to easily change your #
# save file name and extension                 #
#                                              #
# Instructions:                                #
#  add it in script database and change        #
#  here extension and filename                 #
#==============================================#

module DataManager
#================#
# Customization: #
#================#==================================================#
# SAVEFILENAME is the details before the number and extension       #
# SAVEFILEEXTENSION is the extension of the file, defail is Rvdata2 #
#===================================================================#
  SAVEFILENAME   = "SAVE"
  SAVEFILEEXTENSION = "Rvdata2"
  def self.save_file_exists?
    !Dir.glob(SAVEFILENAME + "*" + SAVEFILEEXTENSION).empty?
  end
  def self.make_filename(index)
    sprintf(SAVEFILENAME + "%02d." + SAVEFILEEXTENSION, index + 1)
  end
end



Instructions

add the script in your script database and fill in the extension and filename


Credits and Thanks


  • Various




Author's Notes

i dont know if this is compatible with xp and vx , i dont own xp anymore so if someone tests and it works please tell me
12
no i mean fog :p
panorama is also cool but if you add fog it looks like this



if you add long hallways there is a chance you wont see the end because of the fog, making it perfect for zombie games
13
if you add fog to the map it looks awesome :P
14
RPG Maker Scripts / Re: [VXA][XP] Design a HUD (WIP)
January 08, 2013, 09:40:18 am
thats pretty usefull :P my scripting knowledge is 0% but i know allot of html, now i can create a hud that fits my game :P level up
15
First Person Labyrint Explorer
Authors: MGC
Version: V1.5
Type: First Person System
Key Term: Custom Environment System



Introduction

First of all, this is not my script, i just add it because it isnt on the forum yet

this is a first person system made by MGC


Features


  • Supports compatability with H-mode7 (V.1.4.4)

  • Activable only on certain maps

  • Supports forward/backward movement, strafe left/right and 90° rotation

  • Mapping with RMXP editor

  • 4 different resolutions to prevent lag

  • Supports events opacity and blending type




Limitations


  • This engine is not suited for moving events (it may work though)

  • Idem for animations : launched animations are displayed above all

  • No more than 8 different textures per tileset (8 for walls / 8 for ceiling / 8 for floor)

  • No jump




Screenshots




Demo

http://www.mediafire.com/?ci88bxoqs7o7tvl


Instructions

Mapping

Floor, walls and ceiling
In the RMXP editor, the first layer represents the floor, the second layer the walls and the third layer the ceiling.
A FPLE tileset has three lines of 8 tiles, and each line must have a corresponding file of textures.
The first line of the tileset is used for the floor, the second line for walls, and the third for the ceiling.
Passages must be set to these values :



The three files of textures that you have to create must be named tileset_name_Ground, tileset_name_Wall and tileset_name_Ceiling (height = 8 * width).
The three must have the same dimensions per tileset.
You can obtain the maximal quality by using 640 * 5120px files (in the demo the textures have a width of 480px).

To activate FPLE mode for a map, add [FPLE] to its name.

Events

Events chraracters are displayed vertically (like walls), centered and always facing the player by default.
Using the "Comment..." event command, you can modify the rendering :
"Type 0" : the character surface always face the player (default value)
"Type 1" : in the RMXP editor's view, the character surface is horizontal. So if the player's direction is up or down in the absolute frame of reference, the surface will be facing the player, and if the direction is left or right, the surface will be rendered like a "side" wall.
"Type 2" : in the RMXP editor's view, the character surface is vertical.
"Stretch" : the picture is stretched to fit a wall's dimensions. This option is set by default if the dimensions of the picture to display are too big.
"V-Align 0" : vertical alignment : top (only if not stretched).
"V-Align 1" : vertical alignment : center - default value (only if not stretched).
"V-Align 2" : vertical alignment : down (only if not stretched).
"D-Align 0", "D-Align 1", "D-Align 2" : depth alignment, only for types 1 and 2, see diagram below.



Technical parameters

The resolution affects the quality of the rendering only during movements.
You can adjust the value in the Game_System class (fple_resolution).

Surfaces are rendered within a fixed distance, arbitrarily defaulted to 6 squares.
You can adjust the default value in the Game_System class (fple_view_distance) or use the event command :
$game_temp.set_view(value)
Use lower values to increase performances.

To prevent surfaces popping, a "light" distance specify in how much squares the opacity of surfaces will be null. This fading works with OPACITY : without panorama, as the background is black, surfaces will be darker and darker with the distance.
This fading distance is arbitrarily defaulted to 5 squares. You can adjust the default value in the Game_System class (fple_light_distance) or use the event command :
$game_temp.set_light(value)

There are two other events commands that modify progressively this distance (+/- 1) :
$game_temp.increase_light
$game_temp.decrease_light

This fading effect can be deactivated with a distance value of 0;


Compatibility

Not compatible with any script that modifies the maps


Credits and Thanks


  • 99.9% credits to MGC for making the script

  • 0.1% credits to me for posting it

16
Script Requests / Re: FFXIII-like Encyclopedya
May 21, 2012, 04:36:25 am
im busy with scripts for your datalog, it contains all 12 sections, 13 chapters, 6 enemy section and those also have 13 sections, i have FF XIII for xbox so i can copy allot, except for the enemys because im only at cd2, chapter 9

within this week its completed and it works with a library script, but if you have a better book script post it so i can add the script to it and make it work


greets, various
17
Script Requests / Re: FFXIII-like Encyclopedya
May 17, 2012, 10:24:15 am
this is a bit what you search for (i think)

http://forum.chaos-project.com/index.php/topic,6783.0.html
18
the only thing i have different then your picture is that ur name of the event is an actor, if that will be my problem then i have to database break up to 9999999 actors or something...
my game counts over 10K NPC (non playable characters) and that only on a few maps

here
Spoiler: ShowHide


Edit: nvm im using V4 now and that one works perfect for me
19
hi people :P

ive found a Show Event Name script that was perfect for my game but i got an error when trying

this script uses a ''Comment : Show Name'' to show the name of the event but i got this error

''Script 'Show event name' line 210: typeError occurred.''
''cannot convert nil into string''

line 210 is part of this :
Spoiler: ShowHide

 #--------------------------------------------------------------------------
 # * Draw Name
 #--------------------------------------------------------------------------
 def draw_name
   if defined? Bitmap.draw_hemming_text
     @name_event.bitmap.draw_hemming_text(0, 0, 100, 20, @char ,4)
   else
     @name_event.bitmap.draw_text(0, 0, 100, 20, @char ,4)
   end
 end


this is line 210      @name_event.bitmap.draw_text(0, 0, 100, 20, @char ,4)


this is the full script (if maybe more is wrong)

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# [Xp/Vx] Show Event Name
# Version: 3.14
# Author : LiTTleDRAgo
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   - This script shows event name in map
#
# Instructions:
#
#   - Setup the few configurations below.  
#   - This script uses comments in the event's pages at any line.
#    
#     Comment : Show Name
#
#   That's all
#
#   To show name actor, set the event name to \a[ ActorID ]
#   To show value of variable, set to \v[ VariableID ]
#
#  Extra Function
#     \fontsize[ Size ]
#     \bold
#     \italic
#     \fontname[ Fontname ]
#     \color[ R, G, B, ALPHA ]
#     \sn[ Name ]
#
#  Press Z and C together to turn on the name on / off
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

module EventName

 FONT        = ['Calibri',12]   # Font Name and Font Size
 BOLD        = true             # Toggle Bold
 ITALIC      = true             # Toggle Italic
 PLAYER_NAME = true             # Show the player name too?
 SWITCH      = 50               # Switch for Disable Show Event Name
 PRESS_BTN   = [Input::A,       # (Z Keyboard XP) (Shift Keyboard VX)
                Input::C]       # (C/Enter Keyboard XP) (Z/Enter Keyboard VX)
 COLOR       = Color.new(255,255,255,240) # Color Default
 POSITION    = "A"              # A = Above, B = Below
 RANGE       = 3                # Range from character to show the name

end



#------------------------------------------------------------------------------
# SDK Check
#------------------------------------------------------------------------------
if Object.const_defined?('SDK')
SDK.log('Show Event Name', 'LiTTleDRAgo', 3, '03.02.11')
@event_name_disabled = !SDK.enabled?('Show Event Name')
end

if !@event_name_disabled
 
Sprite_Base = RPG::Sprite  if !defined? Sprite_Base
#==============================================================================
# ** Sprite_EventName
#------------------------------------------------------------------------------
#  This sprite is used to display Event Name. It observes a instance of the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================
class Sprite_EventName < Sprite_Base
 
 FONT          = EventName::FONT
 BOLD          = EventName::BOLD
 ITALIC        = EventName::ITALIC
 PLAYER_NAME   = EventName::PLAYER_NAME
 DIS_EV_SWITCH = EventName::SWITCH
 PRESS_BTN     = EventName::PRESS_BTN
 COLOR         = EventName::COLOR
 POS           = EventName::POSITION
 RANGE         = EventName::RANGE
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_accessor :character
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     viewport  : viewport
 #     character : character (Game_Character)
 #--------------------------------------------------------------------------
 def initialize(v,character)
   super(v)
   @character = character
   @name_event = Sprite.new
   @name_event.bitmap = Bitmap.new(100,280)
   @name_event.visible = true
   refresh_name
   update
 end
 #--------------------------------------------------------------------------
 # * Coloring
 #--------------------------------------------------------------------------
 def coloring
   size, name, bold, italic, color = FONT[1], FONT[0], BOLD, ITALIC, COLOR
     if $xrxs_xas
       @char.gsub!(/<Enemy(\d+)>/i) do color = Color.new(255,0,0,240) end
     elsif $BlizzABS && @character.is_a?(Map_Battler)
       case @character.ai.group
       when 1 then color = Color.new(0  , 0  , 255, 240)
       when 2 then color = Color.new(255, 0  , 0  , 240)
       when 3 then color = Color.new(128, 128, 128, 240)
       when 4 then color = Color.new(128, 128, 128, 240)
       when 5 then color = Color.new(255, 255, 0  , 240)
       when 6 then color = Color.new(0  , 255, 0  , 240)
       end
     end
     @char.gsub!(/\\fontsize\[(\d+)\]/) do size   = $1.to_i  end
     @char.gsub!('\\bold')              do bold   = true     end
     @char.gsub!('\\italic')            do italic = true     end
     @char.gsub!(/\\fontname\[(.*?)\]/) do name   = $1.to_s  end
     @char.gsub!(/\\color\[(\d+),(\d+),(\d+),(\d+)\]/) do
       color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i)    end
   @name_event.bitmap.font.name   = name
   @name_event.bitmap.font.bold   = bold
   @name_event.bitmap.font.italic = italic
   @name_event.bitmap.font.size   = size
   @name_event.bitmap.font.color  = color
 end
 #--------------------------------------------------------------------------
 # * Check Name
 #--------------------------------------------------------------------------
 def event_name_check
   @char.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
   @char.gsub!(/\\[Aa]\[([0-9]+)\]/) { !$game_actors[$1.to_i].nil? ?
                                       $game_actors[$1.to_i].name : ''}
   @char.gsub!(/\\fontsize\[(\d+)\]/) {''}
   @char.gsub!('\\bold')              {''}
   @char.gsub!('\\italic')            {''}
   @char.gsub!(/\\fontname\[(.*?)\]/) {''}
   @char.gsub!(/\\color\[(\d+),(\d+),(\d+),(\d+)\]/) {''}
   if $xrxs_xas
     @char.gsub!(/<Footstep>/i) {''}
     @char.gsub!(/<Throw(\d+)>/i) {''}
     @char.gsub!(/<Somaria(\d+)>/i) {''}
     @char.gsub!(/<Hookshot(\d+)>/i) {''}
     @char.gsub!(/<Enemy(\d+)>/i) { !$data_enemies[$1.to_i].nil? ?
                                    $data_enemies[$1.to_i].name : ''}
   end
   @char.gsub!(/\\[Ss][Nn]\[(.*?)\]/) do @char = $1.to_s end
 end
 #--------------------------------------------------------------------------
 # * Update
 #--------------------------------------------------------------------------
 def update
   super
   if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       (!rpgvx? && @character_hue != @character.character_hue)
     @tile_id, @character_name = @character.tile_id, @character.character_name
     @character_hue = @character.character_hue  if !rpgvx?
     refresh_name
   end
   return @name_event.visible = false if !DIS_EV_SWITCH.nil? and
      (@character.opacity < 50 or $game_switches[DIS_EV_SWITCH])
   visibility if !PRESS_BTN.nil?
   if @name_event.visible
     refresh_name if @cw.nil?
     @name_event.x = @character.screen_x - (@cw.nil? ? 0 : @cw /2)
     @name_event.y = @character.screen_y - (POS == "A" ? @ch : 0)
     @name_event.z = 1
     @name_event.opacity    = @character.opacity
     @name_event.blend_type = @character.blend_type
     @name_event.bush_depth = @character.bush_depth
   end
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh_name
   return if @name_event.nil? or @name_event.bitmap.nil? or
   @name_event.disposed? or !@name_event.visible or @character.name_effect.nil?
   @name_event.bitmap.clear
   @character.name_effect.each {|@char| coloring; event_name_check }
   draw_name if ($BlizzABS && @character.is_a?(Map_Actor) && PLAYER_NAME) or
           ($BlizzABS && @character.is_a?(Map_Enemy) && @character.nametag) or
           (@character.is_a?(Game_Event) && @character.nametag) or
           (@character.is_a?(Game_Player) && PLAYER_NAME) or
           ($xas_caterpillar && @character.is_a?(Game_Party) && PLAYER_NAME)
   @x_frame, @y_frame = 4, 4
   if POS == "A"
     if rpgvx?
       @cw = @name_event.bitmap.width / @x_frame / 2
       @ch = @name_event.bitmap.height / @y_frame - 40
       return
     end
     bit = RPG::Cache.character(@character.character_name,
         @character.character_hue)
     @cw = bit.width / @x_frame / 2
     @ch = bit.height / @y_frame + 15
   else
     @cw = @name_event.bitmap.width / @x_frame / 2
     @ch = @name_event.bitmap.height / @y_frame - 40
   end
 end
 #--------------------------------------------------------------------------
 # * Draw Name
 #--------------------------------------------------------------------------
 def draw_name
   if defined? Bitmap.draw_hemming_text
     @name_event.bitmap.draw_hemming_text(0, 0, 100, 20, @char ,4)
   else
     @name_event.bitmap.draw_text(0, 0, 100, 20, @char ,4)
   end
 end
 #--------------------------------------------------------------------------
 # * Dispose
 #--------------------------------------------------------------------------
 def dispose
   super
   @name_event.dispose
 end
 #--------------------------------------------------------------------------
 # * Visibility
 #--------------------------------------------------------------------------
 def visibility
   pressed = Input.press?(PRESS_BTN[0]) && Input.trigger?(PRESS_BTN[1])
   if RANGE != nil && !@pressed
     x = ($game_player.x-@character.x).abs+($game_player.y-@character.y).abs
     @name_event.visible = (x <= RANGE)
   end
   if !@pressed && pressed
     @name_event.visible, @pressed = false, true
   elsif @pressed && pressed
     @name_event.visible, @pressed = true, false
   end
 end  
end

#==============================================================================
# ** Kernel
#==============================================================================
module Kernel
 def rpgvx?() return (defined? Graphics.resize_screen) end
end
 
Cache = RPG::Cache if !defined? Cache
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================
class Game_Party
 #--------------------------------------------------------------------------
 # * Name
 #--------------------------------------------------------------------------
 def name_effect() leader_name  end
 #--------------------------------------------------------------------------
 # * Leader Name
 #--------------------------------------------------------------------------
 def leader_name
   return @actors[0].nil? ? '' : @actors[0].name if !rpgvx?
   return members[0].nil? ? '' : members[0].name
 end  
end

#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event
 #--------------------------------------------------------------------------
 # * Name
 #--------------------------------------------------------------------------
 def name_effect() @event.name  end
 #--------------------------------------------------------------------------
 # * Nametag
 #--------------------------------------------------------------------------
 def nametag
   return (!@list.nil? && @list.any? {|i| i.code == 108 &&
     i.parameters == ['Show Name']})
 end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Player
 #--------------------------------------------------------------------------
 # * Name
 #--------------------------------------------------------------------------
 def name_effect() return $game_party.leader_name end
end

#==============================================================================
# ** Map Battler
#------------------------------------------------------------------------------
#  This class handles battlers in Blizz ABS
#==============================================================================
if $BlizzABS  
 class Map_Battler
   def name_effect() return @battler.name end
   def nametag
     return (!@list.nil? && @list.any? {|i| i.code == 108 &&
       i.parameters == ['Show Name']})
   end
 end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
class Scene_Map
 attr_accessor :spriteset
end

 #--------------------------------------------------------------------------
 # * Refresh Name
 #--------------------------------------------------------------------------
 def refresh_name(val=nil)  
   return $scene.spriteset.eventname[val].refresh_name if !val.nil?
   $scene.spriteset.eventname.each {|i| i.refresh_name}
 end
 
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
 
 PRESS_BTN     = EventName::PRESS_BTN
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_accessor :eventname
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def init_eventname
   @eventname = []
   @eventname[0] = Sprite_EventName.new(@viewport1,$game_player)  
   ($game_map.events.keys.sort).each {|i|
     @eventname[i] = Sprite_EventName.new(@viewport1,$game_map.events[i])}
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 alias update_eventname_earlier update
 def update
   @eventname.nil? ? init_eventname : @eventname.each {|i|i.update if !i.nil?}
   update_eventname_earlier
 end  
 #--------------------------------------------------------------------------
 # * Dispose
 #--------------------------------------------------------------------------
 alias dispose_eventname dispose
 def dispose
   @eventname.each {|i| i.dispose if !i.nil?}
   dispose_eventname
 end
end
#--------------------------------------------------------------------------
# SDK Check End
#--------------------------------------------------------------------------
end
#--------------------------------------------------------------------------
# END OF SCRIPT
#--------------------------------------------------------------------------


in my eyes it would be perfect and would have no problem, does someone know whats wrong ? or is it something i use

''Scripts i use''
Spoiler: ShowHide

Item storage - game_guy
Anti Event Lag System - Zeriab
Blacksmith System - ForeverZer0
Multi Slot - Guillaume777
Quest System - (sorry dunno the author)


Maybe the script aint compatible with one of the scripts im using

greets, various
20
couldnt fit 2 scripts in 1 post this time (sorry double post x.x)

Multi-slot script : Windows
Spoiler: ShowHide
#==============================================================================
# Multi-slot equipment script
#------------------------------------------------------------------------------
# Section 3:  Windows
#------------------------------------------------------------------------------
# Guillaume777
# 6.2.1
# 2006/02/14
#==============================================================================

#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
#  This class performs equipment screen processing.
#==============================================================================
class Scene_Equip
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias g7_ms_scene_equip_main main
  def main
    @additional_initialize_done = false
    g7_ms_scene_equip_main
    for i in 5...@item_windows.size
      @item_windows[i].dispose unless @item_windows[i].nil?
    end
  end
  #--------------------------------------------------------------------------
  # * Initialize the extra right windows
  #--------------------------------------------------------------------------
  def g7_ms_scene_equip_additional_initialize
  unless @additional_initialize_done
    @item_windows = []
    @item_windows[0] = @item_window1  # Weapon
    @item_windows[1] = @item_window2  # Shield
    @item_windows[2] = @item_window3  # Helmet
    @item_windows[3] = @item_window4  # Armor
    @item_windows[4] = @item_window5  # acc
    nb_old_windows = @item_windows.size
    for i in nb_old_windows...@actor.armor_slots.max+1
      # Add the remaining windows for extra slots
      @item_windows.push(Window_EquipItem.new(@actor, i) )
      @item_windows[i].help_window = @help_window
    end
    @item_windows.push(Window_EquipOffHand.new(@actor, 0))
    @item_windows[-1].help_window = @help_window
    # If windows_stretch is true, stretch window
    if G7_MS_MOD::WINDOWS_STRETCH
      h = (@actor.weapon_slots.size + @actor.armor_slots.size + 1) * 32
      h2 = (G7_MS_MOD::MAX_SHOW_SLOTS+1) * 32
      h = [h, h2].min
      @right_window.height = h
      if @right_window.index > @actor.weapon_slots.size + @actor.armor_slots.size - 1
        @right_window.index = @actor.weapon_slots.size + @actor.armor_slots.size - 1
      end
      if @left_window.y + @left_window.height == 256
        @left_window.height = @right_window.height
      elsif G7_MS_MOD::HELP_AT_BOTTOM == true and @left_window.height == 416 then
        # Make left window shorter
        @left_window.height -= 64
      end
      y_pos = (@right_window.y + @right_window.height)
      y_space = 480 - y_pos
      # If help at bottom, reduce bottom item window size
      if G7_MS_MOD::HELP_AT_BOTTOM == true then y_space -= 64  end
      for item_window in @item_windows
        next if item_window.nil?
        item_window.y = y_pos
        item_window.height = y_space
      end
    end
    @additional_initialize_done = true
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh and make visible the correct right window
  #--------------------------------------------------------------------------
  alias g7_ms_scene_equip_refresh refresh
  def refresh
    # This part is used to refresh the equipped item at the right window
    g7_ms_scene_equip_additional_initialize
    @actor.translucent_texts.fill(false)
    @actor.equip_type_force = index_to_equip_part(@right_window.index)
    @right_window.item_fix_on
    @right_window.scroll_fix_on
    save = @right_window.index
    @right_window.index = index_to_equip_kind(@right_window.index)
    if @right_window.index == 0 and @actor.ignore_offhand? != true then
      if @actor.nb_offhand_required(save) > 0 then
        @right_window.index = @item_windows.size-1
      end
    end
    @actor.equip_from_menu = true
    # Ensure current equipment will get properly stored...
    @actor.equip_mode = 'STORE'
    # ...and re-equiped
    @item_window = @item_windows[@right_window.index]
    @item_windows[@right_window.index].visible = true
    for i in 0...@item_windows.size
      if i != @right_window.index then
      @item_windows[i].visible = false
      end
    end
    # Equip and remove item
    g7_ms_scene_equip_refresh
    @actor.equip_from_menu = false                           
    @actor.equip_mode = nil
    @actor.equip_type_force = nil
    @right_window.index = save
    @right_window.scroll_fix_off
    @right_window.item_fix_off
    if @item_window.index != @old_index
      @right_window.refresh
    end
    @old_index = @item_window.index
  end
  #--------------------------------------------------------------------------
  # * Convert the right_window.index to equip_type
  #--------------------------------------------------------------------------
  alias g7_ms_scene_equip_update_item update_item
  def update_item
    # This changes the @right_window.index to the correct value to take
    # account of extra slots
    @actor.equip_type_force = index_to_equip_part(@right_window.index)
    @right_window.item_fix_on
    @right_window.scroll_fix_on
    save = @right_window.index
    @right_window.index = index_to_equip_kind(@right_window.index)
    @actor.equip_from_menu = true
    # Equip item
    g7_ms_scene_equip_update_item
    @actor.equip_from_menu = false
    @actor.equip_type_force = nil
    # If not in item_window screen
    if @item_window.index == -1
      # If shield-weapon can modify each other
      if @actor.shield_hand_wield == true and
        if @right_window.index == @actor.shield_hand_slot then
          @item_windows[0].refresh
          @item_windows[-1].refresh
        elsif @right_window.index == 0
          # Refresh the shield slot
          @item_windows[@actor.shield_hand_slot].refresh
        end
      end
      if @right_window.index == 0 and @actor.ignore_offhand? != true then
        if @item_window == @item_windows[-1] then
          @item_windows[0].refresh
        elsif @item_window == @item_windows[0] then
          @item_windows[-1].refresh
        end
      end
    end
    @right_window.index = save
    @right_window.scroll_fix_off
    @right_window.item_fix_off
    @actor.equip_type_force = nil
  end
  #--------------------------------------------------------------------------
  # * Convert index to equip part
  #     index : slot number
  #--------------------------------------------------------------------------
  def index_to_equip_part(index)
    # Return index of slot in the
    # array [0, @actor.armor_slots, actor.weapon_slots]
    # If Armor
    if index >= @actor.weapon_slots.size
      return index - (@actor.weapon_slots.size - 1)
    # If extra weapon
    elsif index >= 1
      # Make it last
      return index + [@actor.armor_slots.size, 4].max
    else
      return 0
    end
end
  #--------------------------------------------------------------------------
  # Convert index to equip kind
  #     index : slot number
  #--------------------------------------------------------------------------
  def index_to_equip_kind(index)
    # Return index of slot in either actor.weapon_slots or actor.armor_slots
    i = index_to_equip_part(index)
    # If armor
    if index >= @actor.weapon_slots.size
      set = @actor.armor_slots[i-1]
    # If weapon 
    else
      i = i == 0 ? 0 : i - [@actor.armor_slots.size, 4].max
      set = @actor.weapon_slots[i]
    end
    return set != nil ? set : 0
  end
  #--------------------------------------------------------------------------
  # * End of CLASS:  Scene Equip
  #-------------------------------------------------------------------------- 
end



#==============================================================================
# ** Window_EquipRight
#------------------------------------------------------------------------------
#  This window displays items the actor is currently equipped with on the
#  equipment screen.
#==============================================================================
class Window_EquipRight < Window_Selectable
  #--------------------------------------------------------------------------
  # * Item Fix On
  #--------------------------------------------------------------------------
  def item_fix_on
    # Fix window
    @fixed_item = @data[self.index]
    @fixed = true
  end
  #--------------------------------------------------------------------------
  # * Item Fix Off
  #--------------------------------------------------------------------------
  def item_fix_off
    #stop fixing window
    @fixed_item = nil
    @fixed = false
  end
  #--------------------------------------------------------------------------
  # * Don't scroll right window if you press L or R
  #--------------------------------------------------------------------------
  def update
    if Input.repeat?(Input::R) or  Input.repeat?(Input::L) then
      return
    else
      super
    end
  end
  #--------------------------------------------------------------------------
  # Draws equipped items with support of translucent and cursed items
  #     item        : item
  #     x           : draw spot x-coordinate
  #     y           : draw spot y-coordinate
  #     translucent : draw translucent
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y, translucent = false)
    if item == nil
      return
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    if item.cursed
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
      self.contents.font.color = G7_MS_MOD::CURSED_COLOR
    elsif translucent
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 128)
      self.contents.font.color = disabled_color
    else
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
      self.contents.font.color = normal_color
    end
    self.contents.draw_text(x + 28, y, 212, 32, item.name)
  end
  #--------------------------------------------------------------------------
  # * Prevent needless update of item quantities in item window
  #--------------------------------------------------------------------------
  alias g7_ms_window_equipright_item item
  def item
    # This ensures that the number of items doesn't get updated if you move
    # cursor in item window
    return @fixed_item if @fixed
    return g7_ms_window_equipright_item
  end
  #--------------------------------------------------------------------------
  # * Change the height of right windows to fit the slots
  #     actor : actor
  #--------------------------------------------------------------------------
  alias g7_ms_window_equipright_initialize initialize
  def initialize(actor)
    # Initialize with a different height
    g7_ms_window_equipright_initialize(actor)
    # Total height of right window
    h = (actor.weapon_slots.size + actor.armor_slots.size) * 32
    # Change the height                                                       
    self.contents = Bitmap.new(width - 32, h)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Shows the slot names and the name of the items you have equipped
  #--------------------------------------------------------------------------
  def refresh
    # Replaced method to show caption of all items and slot
    self.contents.clear
    @data = []
    # Begin Multi-slot equipment script Edit
    self.contents.font.name = G7_MS_MOD::FONT_NAME
    for i in 0...@actor.weapon_slots.size
      # Push the name(s) of the weapon(s)
      @data.push($data_weapons[@actor.weapon_ids[i]])
    end
    for i in 0...@actor.armor_slots.size
      # Push the names of the armors
      @data.push($data_armors[@actor.armor_ids[i]])
    end
    @caption = []
    for i in 0...@actor.weapon_slots.size
      # Push the name(s) of the weapon slots
      @caption.push(@actor.weapon_slot_names[i])
    end
    for i in 0...@actor.armor_slots.size
      # Push the names of the armor slots
      @caption.push(@actor.armor_slot_names[@actor.armor_slots[i]-1])
    end
    @item_max = @data.size
    if @actor.translucent_texts == nil then @actor.translucent_texts = Array.new end
    for i in 0...@data.size
      if @caption[i] != nil
        self.contents.font.color = system_color
        # Draw the name of the slots
        self.contents.draw_text(4, 32 * i, 92, 32, @caption[i])
      end
      # Draw the name of the equipment
      draw_item_name(@data[i], 92, 32 * i, @actor.translucent_texts[i])
    end
    # Support for other script
    if defined? xrxs_additional_refresh
      xrxs_additional_refresh
    end
  # End Multi-slot equipment script Edit
  end
  #--------------------------------------------------------------------------
  # * End of CLASS:  Window EquipRight
  #--------------------------------------------------------------------------
end



#============================================================================
# ** Window_EquipOffHand
#----------------------------------------------------------------------------
#  A new window class that displays an equipped item in the actor's off hand.
#============================================================================
class Window_EquipOffHand < Window_EquipItem
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add equippable weapons
    weapon_set = $data_classes[@actor.class_id].weapon_set
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
        weapon = $data_weapons[i]
        if weapon.needs_offhand == false
          if G7_MS_MOD::TWOHANDED_IN_OFFHAND != false and weapon.nb_hands <= 1 then
            @data.push(weapon)
          end
        end
      end
    end
    # Add blank page
    @data.push(nil)
    # Make a bit map and draw all items
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    self.contents.font.name = G7_MS_MOD::FONT_NAME
    #self.contents.font.size = 24
    for i in 0...@item_max-1
      draw_item(i)
    end
    if G7_MS_MOD::SHOW_REMOVE then
       i = @item_max -1
       x = 4 + i % @column_max * (288 + 32)
       y = i / @column_max * 32
       self.contents.draw_text(x+4, y, 100, 32, '[Remove]')
    end
  end
  #--------------------------------------------------------------------------
  # * End of CLASS:  Window EquipOffHand
  #--------------------------------------------------------------------------
end



#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
#  This window class contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable < Window_Base
  #--------------------------------------------------------------------------
  # * Scroll Fix On
  #--------------------------------------------------------------------------
  def scroll_fix_on
    @scroll_fixed = true
  end
  #--------------------------------------------------------------------------
  # * Scroll Fix Off
  #-------------------------------------------------------------------------- 
  def scroll_fix_off
    @scroll_fixed = false
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  alias g7_ms_update_cursor_rect update_cursor_rect
  def update_cursor_rect
    # This prevents the windows from scrolling if scroll is fixed
    # This was added to ensure that if there are few slots, the right equip
    # screen doesn't scroll needlessly
    return if @scroll_fixed
    g7_ms_update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * End of CLASS:  Window Selectable
  #-------------------------------------------------------------------------- 
end



#==============================================================================
# *** Global IF condition
#     Shows a new status window if Status_window_arrange is true
#==============================================================================
if G7_MS_MOD::STATUS_WINDOW_ARRANGE
  #============================================================================
  # ** Window_Status
  #----------------------------------------------------------------------------
  #  This window displays full status specs on the status screen.
  #============================================================================
  class Window_Status < Window_Base
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
      # Begin Multi-slot equipment script Edit
      self.contents.font.name = G7_MS_MOD::FONT_NAME
      # End Multi-slot equipment script Edit
      self.contents.clear
      draw_actor_graphic(@actor, 40, 112)
      draw_actor_name(@actor, 4, 0)
      draw_actor_class(@actor, 4 + 144, 0)
      draw_actor_level(@actor, 96, 32)
      draw_actor_state(@actor, 96, 64)
      draw_actor_hp(@actor, 96, 112, 172)
      draw_actor_sp(@actor, 96, 144, 172)
      draw_actor_parameter(@actor, 96, 192, 0)
      draw_actor_parameter(@actor, 96, 224, 1)
      draw_actor_parameter(@actor, 96, 256, 2)
      draw_actor_parameter(@actor, 96, 304, 3)
      draw_actor_parameter(@actor, 96, 336, 4)
      draw_actor_parameter(@actor, 96, 368, 5)
      draw_actor_parameter(@actor, 96, 400, 6)
      # Begin Multi-slot equipment script Edit
      if G7_MS_MOD::EVADE
        # Activate if you have a draw_actor_paramter method that draws evade
        draw_actor_parameter(@actor, 96, 432, 7)
      end
      self.contents.font.color = system_color
      self.contents.draw_text(320, 16, 80, 32, 'EXP')
      self.contents.draw_text(320, 48, 80, 32, 'NEXT')
      self.contents.font.color = normal_color
      self.contents.draw_text(320 + 80, 16, 84, 32, @actor.exp_s, 2)
      self.contents.draw_text(320 + 80, 48, 84, 32, @actor.next_rest_exp_s, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(320, 80, 96, 32, 'Equipment')
      y = 108
      for i in 0...@actor.weapon_slots.size
        draw_item_name($data_weapons[@actor.weapon_ids[i]], 320 + 16, y)
        y += G7_MS_MOD::STATUS_WINDOW_SPACING
      end
      for i in 0...@actor.armor_slots.size
        draw_item_name($data_armors[@actor.armor_ids[i]], 320 + 16, y)
        y += G7_MS_MOD::STATUS_WINDOW_SPACING
      end
      # End Multi-slot equipment script Edit     
    end
    #------------------------------------------------------------------------
    # * End of CLASS:  Window Status
    #------------------------------------------------------------------------
  end
  #--------------------------------------------------------------------------
  # * End of Global IF condition
  #--------------------------------------------------------------------------
end