Advertisement
LiTTleDRAgo

[RGSS/2] DRG Inventory System

Mar 31st, 2012
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 114.46 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # DRG Inventory System
  3. # Version: 2.04
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. ($imported ||={})[:drg_inv_sys] = $drg_inv_sys = 2.04
  7. module LiTTleDRAgo
  8. #==============================================================================
  9. # *** EDITABLE SECTION
  10. #==============================================================================
  11.   NONDISCARD = {0 => [23,24,25,50,51,52],   # item nondiscardable
  12.                 1 => [],                    # weapon nondiscardable
  13.                 2 => []}                    # armor nondiscardable
  14.                  
  15.   DEFAULT_MAX_SIZE   = 10 # Max size inventory default (can be changed in game)
  16.  
  17.   DEFAULT_ITEM_STACK = {   # Max Item stack
  18.             0 => 90,       # For All Unlisted Item
  19.             3 => 80,       # For item ID 3 (Full Potion)
  20.   }
  21.  
  22.   #------------------------------------------------------------
  23.   #*** ADDITIONAL SECTION (Can be deleted)
  24.   #------------------------------------------------------------
  25.   #------------------------------------------------------
  26.   # COMBINE ITEM (Reference : Resident Evil series)
  27.   # Format
  28.   #  'Item(ID-1) + Item(ID-2)' => 'Item(ID-Result)'
  29.   #------------------------------------------------------
  30.   # delete if you don't want to use it
  31.  
  32.   COMBINE_ITEM = {
  33.  
  34.     'Item(1) + Item(1)'     => 'Item(2)',
  35.     'Item(1) + Item(2)'     => 'Item(3)',
  36.    
  37.       # Means :
  38.       # Item ID 1 (potion) + Item ID 1 (potion)   => Item ID 2 (Hipotion)
  39.       # Item ID 1 (potion) + Item ID 2 (Hipotion) => Item ID 3 (Fullpotion)
  40.       #------------------------------------------------------
  41.        
  42.     'Item(1) + Weapon(1)'   => 'Weapon(2)',
  43.     'Weapon(1) + Weapon(2)' => 'Weapon(3)',
  44.     'Weapon(1) + Armor(1)'  => 'Weapon(4)',
  45.    
  46.   }
  47.  
  48.   SOUND_COMBINE = '055-Right01' # SE Used when combining item
  49.   # end delete
  50.  
  51.   #------------------------------------------------------
  52.   # RARITY SISTEM
  53.   # Format
  54.   # Type = { ID Item => Star (max 8) }
  55.   #------------------------------------------------------
  56.   # delete if you don't want to use it
  57.   RARITY = {
  58.  
  59.     'Item'   => {
  60.                   1 => 1,
  61.                   2 => 3,
  62.                 },
  63.       # Means :
  64.       # Item ID 1 (potion)     will have 1 star
  65.       # Item ID 2 (Hipotion)   will have 3 star
  66.       #------------------------------------------------------
  67.     'Weapon' =>  {
  68.                   1 => 2,
  69.                   2 => 3,
  70.                  },
  71.                      
  72.     'Armor' => {
  73.                   1 => 2,
  74.                   2 => 3,
  75.                 },
  76.                  
  77.   }
  78.   # end delete
  79.  
  80.   #------------------------------------------------------------
  81.   # *** ADDITIONAL SECTION END
  82.   #------------------------------------------------------------
  83.  
  84.   #------------------------------------------------------------
  85.   #                            EDITABLE DETAIL
  86.   #------------------------------------------------------------
  87.  
  88.   BACKGROUND  = 'Mn_Back'     # Animated background graphic    
  89.   TRAN_TIME   = 20            # Transition Time
  90.   TRAN_TYPE   = "004-Blind04" # Transition Type (Name)  
  91.  
  92.   # STRING SECTION
  93.   ITEM_WELCOME     = "In %s's Bag"
  94.   EQUIP_WELCOME    = "Press Shift button to Unequip"
  95.   ASK_MANY         = "How Many?"
  96.   GET_COMB         = "Get %2$s x %1$s"
  97.   PARTY_INV        = "%s's Inventory"
  98.   LOOT_INV         = "Discarded Item"
  99.   USE_COM          = "Use"
  100.   COMBINE_COM      = "Combine"     # Insert nil to disable permanently
  101.   EQ_COM           = nil           # Insert nil to disable permanently
  102.   TRANSFER_COM     = "Transfer"    # Insert nil to disable permanently
  103.   UNEQUIP_COM      = "Unequip"
  104.   UNEQUIPALL_COM   = "Unequip All"
  105.   DIS_COM          = "Discard"
  106.   CANCEL_COM       = "Cancel"
  107.   FULL_INVENTORY   = 'Inventory is full'
  108.   ELEMENT_TOO_MANY = 'Too Complex'
  109.  
  110.   MAIN_INVENTORY_LEADER = true   # Main inventory is always set to party leader
  111.                                  # when changing party
  112.                                  # (won't do a thing if TRANSFER_COM is nil)
  113.   ELEMENT_STATUS_MARQUEE = true  # using marque text if element or status
  114.                                  # effect is too many to show
  115.   SHOW_ITEM_STACK = true         # show max item stack in inventory?
  116.                                  # ex : Potion 1/80
  117.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118.   # You can disable combine and equip feature by using script call
  119.   #
  120.   #       $game_party.disable_combine = true / false
  121.   #       $game_party.disable_equip = true / false
  122.   #
  123.   # You can change the inventory size by using script call
  124.   #
  125.   #       $game_party.resize_inventory(new_size)
  126.   #
  127.   # You can switch the main inventory with the call script
  128.   #
  129.   #       $game_party.switch_inventory(ID_Actor)
  130.   #
  131.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  132.  
  133. #==============================================================================
  134. # *** END of EDITABLE SECTION
  135. #==============================================================================
  136. end
  137.  
  138. #==============================================================================
  139. # ** Window_Base
  140. #------------------------------------------------------------------------------
  141. #  This class is for all in-game windows.
  142. #==============================================================================
  143. if $imported[:drg_inv_sys]
  144.   VX  = defined?(Window_ActorCommand)
  145.   VXA = defined?(Window_BattleActor)
  146.   raise "This script is only for RMXP" if VX or VXA
  147.  
  148.   class Window_Base < Window
  149.     #--------------------------------------------------------------------------
  150.     # * Draw Icon
  151.     #--------------------------------------------------------------------------
  152.     define_method(:cache) { VX ? Cache : RPG::Cache }
  153.     def draw_icon_vx_a(file_name,icon_index, x, y, enabled = true)
  154.       bitmap = cache.picture(file_name.to_s)
  155.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  156.       self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  157.     end
  158.     #--------------------------------------------------------------------------
  159.     # * Draw Icon
  160.     #--------------------------------------------------------------------------
  161.     def draw_icon_vx(icon_index=1, x=0, y=0, enabled = true)
  162.       bitmap = cache.system("Iconset")
  163.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  164.       self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  165.     end
  166.   end
  167.  
  168.   #==============================================================================
  169.   # ** Window_Selectable_Drago / Window_Command
  170.   #------------------------------------------------------------------------------
  171.   #  
  172.   #==============================================================================
  173.   class Window_Selectable_Drago < Window_Selectable; end unless VX
  174.   Class = [:Equip,:Battle,:Menu].map {|s| :"Scene_#{s}"}
  175.   Class = [:"#{VX ? 'Game_' : ''}Interpreter", Class ,:Window_Command] +
  176.         [:Spriteset_Map].map {|s| :"#{s}_Drago < #{s}"}
  177.   #==============================================================================
  178.   # ** Window_Welcome
  179.   #------------------------------------------------------------------------------
  180.   #  Window for the welcome at the top.
  181.   #==============================================================================
  182.  
  183.   class Window_Welcome < Window_Base
  184.     #--------------------------------------------------------------------------
  185.     # * Object Initialization
  186.     #--------------------------------------------------------------------------
  187.     def initialize(about = nil)
  188.       case about
  189.       when nil,'help'
  190.         super(0, 0, 640, 64)
  191.       when 'statistic'
  192.         super(352, 64, 288, 416)
  193.       end
  194.       self.contents = Bitmap.new(width - 32, height - 32)
  195.       self.contents.font.name = "Sylfaen"
  196.       refresh if about == nil
  197.     end
  198.        
  199.     def resize_window(w = width, h = height)
  200.       self.width  = w
  201.       self.height = h
  202.     end
  203.    
  204.     def refresh(x=nil)
  205.       self.contents.clear
  206.       @text,@align = "#{$game_party.limit_inventory.slots.size} / " +
  207.               "#{$game_party.limit_inventory.max_size}",4
  208.       return self.contents.draw_text(0, 0, 255, 32,  x.to_s, 4) if !x.nil?
  209.       actor = $game_actors[$game_party.inventory].name rescue ''
  210.       text = sprintf(LiTTleDRAgo::ITEM_WELCOME,actor)
  211.       self.contents.draw_text(0, 0, 255, 32,  text, 4)
  212.       if $game_party.limit_inventory.nil?
  213.         $game_party.limit_inventory =
  214.         Game_LimitedInventory.new(LiTTleDRAgo::DEFAULT_MAX_SIZE)
  215.       end
  216.       self.contents.draw_text(550,0,100,32, @text ,@align )
  217.     end
  218.     #--------------------------------------------------------------------------
  219.     # * Set Text
  220.     #--------------------------------------------------------------------------
  221.     def set_text(text, align = 0,item=nil)
  222.       if text != @text or align != @align
  223.         self.contents.clear
  224.         self.contents.font.color = normal_color
  225.         if defined?(LiTTleDRAgo.ItemColor) && !item.nil?
  226.           color = case item
  227.           when RPG::Item   then LiTTleDRAgo.ItemColor  (item.id)
  228.           when RPG::Weapon then LiTTleDRAgo.WeaponColor(item.id)
  229.           when RPG::Armor  then LiTTleDRAgo.ArmorColor (item.id)
  230.           end
  231.         end
  232.         self.contents.font.color = color if !color.nil?
  233.         draw_colored_words(4, 0, self.width - 40, 32, text, align)
  234.         @text,@align = text, align
  235.       end
  236.     end
  237.     #--------------------------------------------------------------------------
  238.     # * Draw Colored Words
  239.     #--------------------------------------------------------------------------
  240.     def draw_colored_words(x,y,width,height,message='',align=0)
  241.       xx = [0, self.contents.font.color.dup]
  242.       t = message.clone
  243.       t.gsub!(/ : /) { "\001[0] : " }
  244.       t.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  245.       while ((c = t.slice!(/./m)) != nil)
  246.         if c == "\001"
  247.           t.sub!(/\[([0-9]+)\]/, "")
  248.           self.contents.font.color = text_color($1.to_i)
  249.           next
  250.         end
  251.         self.contents.draw_text(x + xx[0], y, width, height, c)
  252.         xx[0] += self.contents.text_size(c).width
  253.       end
  254.       self.contents.font.color = xx[1]
  255.     end
  256.   end #of class
  257.   #==============================================================================
  258.   # ** Window_Target_Drago
  259.   #------------------------------------------------------------------------------
  260.   #  This window selects a use target for the actor on item and skill screens.
  261.   #==============================================================================
  262.   class Window_Target_Drago < Window_Selectable_Drago
  263.     #--------------------------------------------------------------------------
  264.     # * Object Initialization
  265.     #--------------------------------------------------------------------------
  266.     def initialize
  267.       super(202, 170, 288, 160)
  268.       self.contents = Bitmap.new(width - 32, height - 32)
  269.       self.contents.font.name = "Sylfaen"
  270.       self.z += 10
  271.       @item_max = $game_party.actors.size
  272.       @column_max = 4
  273.     end
  274.     #--------------------------------------------------------------------------
  275.     # * Cursor Rectangle Update
  276.     #--------------------------------------------------------------------------
  277.     define_method(:refresh) { update_cursor_rect }
  278.     def update_cursor_rect
  279.       self.contents.clear
  280.       for i in 0...$game_party.actors.size
  281.         x = 10 + i * 60
  282.         y = 0
  283.         actor = $game_party.actors[i]
  284.         draw_actor_name(actor, x, y)
  285.         draw_actor_graphic(actor, x + 20, y + 80)
  286.         draw_actor_level(actor, x, y + 66)
  287.       end
  288.       actor = $game_party.actors[self.index]
  289.       x = y = 0
  290.       draw_actor_hp(actor, x + 60, y + 86)
  291.       VX ? draw_actor_mp(actor, x + 60, y + 106) :
  292.         draw_actor_sp(actor, x + 60, y + 106)
  293.       if @index <= -2
  294.         self.cursor_rect.set(0, (@index + 10) * 60, 60, 96)
  295.       elsif @index == -1
  296.         self.cursor_rect.set(0, 0, 60, @item_max * 116 - 20)
  297.       else
  298.         self.cursor_rect.set(@index * 60, 0, 60, 96)
  299.       end
  300.     end
  301.     #--------------------------------------------------------------------------
  302.     # * Draw Level2
  303.     #--------------------------------------------------------------------------
  304.     def draw_actor_level(actor, x, y)
  305.       self.contents.font.color = system_color
  306.       self.contents.draw_text(x, y, 32, 32, "Lv:")
  307.       self.contents.font.color = normal_color
  308.       self.contents.draw_text(x + 16, y, 24, 32, actor.level.to_s, 2)
  309.     end
  310.   end
  311.   #==============================================================================
  312.   # ** RPG::Item
  313.   #------------------------------------------------------------------------------
  314.   #  This class is core of item module
  315.   #==============================================================================
  316.   ['Item','Armor','Weapon'].each {|s| eval "
  317.  class RPG::#{s}
  318.    alias_method(:drg123_name, :name)
  319.    define_method(:name) { true_name.clone.gsub(/\\[Cc]\[([0-9]+)\]/) { '' }}
  320.    define_method(:true_name) { drg123_name}
  321.  end#"}
  322.  
  323.   #==============================================================================
  324.   # ** Bitmap
  325.   #------------------------------------------------------------------------------
  326.   #  This class is for slice text method
  327.   #==============================================================================
  328.   class Bitmap
  329.     def slice_text(text, width)
  330.       words = text.split(' ')
  331.       return words if words.size == 1
  332.       result, current_text = [], words.shift
  333.       words.each_index {|i|
  334.           if self.text_size("#{current_text} #{words[i]}").width > width
  335.             result.push(current_text)
  336.             current_text = words[i]
  337.           else
  338.             current_text = "#{current_text} #{words[i]}"
  339.           end
  340.           result.push(current_text) if i >= words.size - 1}
  341.       return result
  342.     end
  343.   end
  344.   #==============================================================================
  345.   # ** Scene_Item
  346.   #------------------------------------------------------------------------------
  347.   #  This class performs item screen processing.
  348.   #==============================================================================
  349.  
  350.   class Scene_Item
  351.     #--------------------------------------------------------------------------
  352.     # * Stats Text Update
  353.     #--------------------------------------------------------------------------
  354.     def update_stats
  355.       @x = @y = 0
  356.       unless @hp_word
  357.         @hp_word    = VX ? "#{Vocab.hp} :"    : "#{$data_system.words.hp} :"
  358.         @sp_word    = VX ? "#{Vocab.mp} :"    : "#{$data_system.words.sp} :"
  359.         @str_word   = VX ? ''                 : "#{$data_system.words.str} :"
  360.         @dex_word   = VX ? ''                 : "#{$data_system.words.dex} :"
  361.         @agi_word   = VX ? "#{Vocab.agi} :"   : "#{$data_system.words.agi} :"
  362.         @int_word   = VX ? "#{Vocab.spi} :"   : "#{$data_system.words.int} :"
  363.         @atk_word   = VX ? "#{Vocab.atk} :"   : "#{$data_system.words.atk} :"
  364.         @pdef_word  = VX ? "#{Vocab.def} :"   : "#{$data_system.words.pdef} :"
  365.         @mdef_word  = VX ? ''                 : "#{$data_system.words.mdef} :"
  366.         @guard_word = VX ? "#{Vocab.guard} :" : "#{$data_system.words.guard} :"
  367.       end
  368.       if @item_window[0].active && @item_window[0].item != 0
  369.         @item = @item_window[0].item
  370.         update_item
  371.       elsif @item_window[1].active &&  @item_window[1].item != 0
  372.         @item = @item_window[1].item
  373.       end
  374.       case @item
  375.       when RPG::Item   then update_item_values('Item')   if window_index_update?
  376.       when RPG::Weapon then update_item_values('Weapon') if window_index_update?
  377.       when RPG::Armor  then update_item_values('Armor')  if window_index_update?
  378.       end
  379.       update_guardset_status
  380.     end
  381.     def window_index_update?
  382.       if @must_update
  383.         @must_update = nil
  384.         return true
  385.       elsif @item_window[0].active && @old_index != @item_window[0].index
  386.         @old_index = @item_window[0].index
  387.         return true
  388.       elsif @item_window[1].active && @old_index != @item_window[1].index
  389.         @old_index = @item_window[1].index
  390.         return true
  391.       end
  392.       return false
  393.     end
  394.     #--------------------------------------------------------------------------
  395.     # * Set Rarity
  396.     #--------------------------------------------------------------------------
  397.     def set_rarity(about='',id=0)
  398.       rarity = LiTTleDRAgo::RARITY rescue {}
  399.       if rarity[about] != nil && rarity[about][id] != nil && !$drg_inv_sys_no_star
  400.         rarity[about][id].abs.times do |i|
  401.           src_rect = Rect.new(0, 0, 24, 24)
  402.           cache = VX ? Cache : RPG::Cache
  403.           icon = cache.icon('star') rescue 'no_icon'
  404.           if icon == 'no_icon'
  405.             opac = @item_window[2].opacity
  406.             @item_window[2].opacity -= 150
  407.             $drg_inv_sys_no_star = true
  408.             report_missing_image('star.png','Icons')
  409.             @item_window[2].opacity = opac
  410.           else
  411.             @sta_window['stat'].contents.blt(@x-32*i+230, @y + 24, icon, src_rect)
  412.           end
  413.         end
  414.       end
  415.     end
  416.     #--------------------------------------------------------------------------
  417.     # * Draw Colored Words
  418.     #--------------------------------------------------------------------------
  419.     def draw_colored_words(x,y,width,height,message='',a = 0)
  420.       xx = [0, @sta_window['stat'].contents.font.color.dup]
  421.       t = message.clone
  422.       t.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  423.       while ((c = t.slice!(/./m)) != nil)
  424.         if c == "\001"
  425.           t.sub!(/\[([0-9]+)\]/, "")
  426.           @sta_window['stat'].contents.font.color =
  427.                @sta_window['stat'].text_color($1.to_i)
  428.           next
  429.         end
  430.         @sta_window['stat'].contents.draw_text(x + xx[0],y,width,height,c) if a<10
  431.         xx[0] += @sta_window['stat'].contents.text_size(c).width
  432.       end
  433.       @sta_window['stat'].contents.font.color = xx[1] if a<10
  434.     end
  435.     #--------------------------------------------------------------------------
  436.     # * slice_col_words
  437.     #--------------------------------------------------------------------------
  438.     def slice_col_words(text, width)
  439.       space = ' '
  440.       words = text.split(space)
  441.       return words if words.size == 1
  442.       result, current_text = [], words.shift
  443.       words.each_index {|i|
  444.       t = "#{current_text}#{space}#{words}"
  445.       if @sta_window['stat'].contents.text_size(t).width > width
  446.         result.push(current_text)
  447.         current_text = words[i]
  448.       else
  449.         current_text = "#{current_text}#{space}#{words[i]}"
  450.       end
  451.       result.push(current_text) if i >= words.size - 1}
  452.       return result
  453.     end
  454.     #--------------------------------------------------------------------------
  455.     # * Update Item Values
  456.     #--------------------------------------------------------------------------
  457.     def update_item_values(type='Item')
  458.       @sta_window['stat'].contents.clear
  459.       if defined?(G7_MS_MOD) && type == 'Armor' && @item.kind > 3
  460.         add  = G7_MS_MOD::EXTRA_SLOT_NAMES[@item.kind-4]
  461.       else
  462.         add = type == 'Armor' ? (VX ? eval("Vocab.armor#{@item.kind + 1}") :
  463.             $data_system.words.send("armor#{@item.kind + 1}")) : ''
  464.       end
  465.       add = " -> #{add}" if type == 'Armor'
  466.       string = case type
  467.         when 'Item' then ['Enhancements: ','Range: ','Recovery: ',
  468.                           'Elements: ','Status Effects: ','','','','']
  469.         when 'Weapon' then [ @atk_word, @pdef_word, @mdef_word,
  470.                          @str_word, @dex_word, @agi_word, @int_word,
  471.                         'Elements: ' ,'Status Effects: ']
  472.         when 'Armor' then [@pdef_word, @mdef_word, 'EVA : ',
  473.                        @str_word, @dex_word, @agi_word, @int_word,
  474.                        'Guard Elements: ','Guard Effects: ']
  475.         end
  476.       vy = VX ? -60 : 0
  477.       @sta_window['stat'].contents.font.color = Color.new(192, 224, 255, 255)
  478.       @sta_window['stat'].contents.font.bold = true
  479.       set_rarity(type,@item.id)
  480.       @sta_window['stat'].contents.draw_text(@x,@y    ,212,32, "Name: "      )    
  481.       @sta_window['stat'].contents.draw_text(@x,@y+42 ,212,32, "Description:")
  482.       @sta_window['stat'].contents.draw_text(@x,@y+106+6,212,32, "Item Type: " )
  483.       @sta_window['stat'].contents.draw_text(@x,@y+140,212,32, "Statistics: ")
  484.       size = @sta_window['stat'].contents.font.size
  485.       @sta_window['stat'].contents.font.size -= 3
  486.       @sta_window['stat'].contents.font.bold = false
  487.       @sta_window['stat'].contents.font.color = Color.new(255, 255, 255, 255)
  488.       bio = [@item.description.clone.gsub(/\\[Cc]\[([0-9]+)\]/) { '' },
  489.             250]
  490.       bio = @sta_window['stat'].contents.slice_text(*bio)
  491.       if defined?(LiTTleDRAgo.ItemColor)
  492.         color = case @item
  493.         when RPG::Item   then LiTTleDRAgo.ItemColor  (@item.id)
  494.         when RPG::Weapon then LiTTleDRAgo.WeaponColor(@item.id)
  495.         when RPG::Armor  then LiTTleDRAgo.ArmorColor (@item.id)
  496.         end
  497.       end
  498.       @sta_window['stat'].contents.font.color = color if !color.nil?
  499.       @sta_window['stat'].contents.font.size = size
  500.       draw_colored_words(@x+60,@y,212,32,@item.true_name)
  501.       @sta_window['stat'].contents.font.size -= 3
  502.       @sta_window['stat'].contents.font.color = Color.new(255, 255, 255, 255)
  503.       bio.each_index {|i|
  504.       @sta_window['stat'].contents.draw_text(@x,(@y+62)+i*15,250,32,bio[i])}
  505.       @sta_window['stat'].contents.font.size = size
  506.       @sta_window['stat'].contents.font.color = Color.new(255, 255, 255, 255)
  507.       @sta_window['stat'].contents.draw_text(@x+95,@y+106+6,212,32,type+add,0)
  508.       begin;  return if @item.card?;  rescue;  nil end
  509.       @sta_window['stat'].contents.font.color = Color.new(192, 224, 255, 255)
  510.       @sta_window['stat'].contents.draw_text(@x,@y+165   ,212,32,string[0])
  511.       @sta_window['stat'].contents.draw_text(@x,@y+185   ,212,32,string[1])
  512.       @sta_window['stat'].contents.draw_text(@x,@y+205   ,212,32,string[2])
  513.       @sta_window['stat'].contents.draw_text(@x,@y+225   ,212,32,string[3])
  514.       @sta_window['stat'].contents.draw_text(@x,@y+245   ,212,32,string[4])
  515.       @sta_window['stat'].contents.draw_text(@x,@y+265+vy,212,32,string[5])
  516.       @sta_window['stat'].contents.draw_text(@x,@y+285+vy,212,32,string[6])
  517.       @sta_window['stat'].contents.draw_text(@x,@y+305+vy,212,32,string[7])
  518.       @sta_window['stat'].contents.draw_text(@x,@y+325+vy,212,32,string[8])
  519.       @sta_window['stat'].contents.font.color = Color.new(255, 255, 255, 255)
  520.       if type == 'Item'
  521.         text = [case @item.parameter_type
  522.         when 0 then "None"
  523.         when 1 then "Max #{@hp_word} + #{@item.parameter_points}"
  524.         when 2 then "Max #{@sp_word} + #{@item.parameter_points}"
  525.         when 3 then "#{@str_word} + #{@item.parameter_points}"
  526.         when 4 then "#{@dex_word} + #{@item.parameter_points}"
  527.         when 5 then "#{@agi_word} + #{@item.parameter_points}"
  528.         when 6 then "#{@int_word} + #{@item.parameter_points}"
  529.         end, case @item.scope
  530.         when 0,1 then @item.scope == 0 ? "None"        : "One Enemy"
  531.         when 2,3 then @item.scope == 2 ? "All Enemies" : "One Ally"
  532.         when 4,5 then @item.scope == 4 ? "All Allies"  : "One Ally"
  533.         when 6,7 then @item.scope == 6 ? "All Allies"  : "This User"
  534.         end, VX ? [@item.hp_recovery, @item.mp_recovery] :
  535.                   [@item.recover_hp, @item.recover_sp]].flatten
  536.         @sta_window['stat'].contents.draw_text(@x+110,@y+165,212,32,text[0])
  537.         @sta_window['stat'].contents.draw_text(@x+110,@y+185,212,32,text[1])
  538.         @sta_window['stat'].contents.draw_text(@x+110,@y+205,212,32,"#{text[2]} HP")
  539.         @sta_window['stat'].contents.draw_text(@x+180,@y+205,212,32,"#{text[3]} SP")
  540.       else
  541.         atk = type == 'Weapon' ? @item.atk : @item.eva
  542.         pdef = VX ? "#{@item.def}" : @item.pdef
  543.         mdef = VX ? '' : @item.mdef
  544.         str = VX ? '' : @item.str_plus
  545.         dex = VX ? '' : @item.dex_plus
  546.         agi = VX ? @item.agi : @item.agi_plus
  547.         int = VX ? @item.spi : @item.int_plus
  548.         text = ["#{atk}","#{pdef}","#{mdef}","#{atk}"]
  549.         text.shift if type == 'Armor'
  550.         ev = type == 'Armor' ? vy/3 : 0
  551.         @sta_window['stat'].contents.draw_text(@x+120,@y+165,212,32,text[0])
  552.         @sta_window['stat'].contents.draw_text(@x+120,@y+185,212,32,text[1])
  553.         @sta_window['stat'].contents.draw_text(@x+120,@y+205+ev,212,32,text[2])
  554.         @sta_window['stat'].contents.draw_text(@x+120,@y+225,212,32,"#{str}")
  555.         @sta_window['stat'].contents.draw_text(@x+120,@y+245,212,32,"#{dex}")
  556.         @sta_window['stat'].contents.draw_text(@x+120,@y+265+vy,212,32,"#{agi}")
  557.         @sta_window['stat'].contents.draw_text(@x+120,@y+285+vy,212,32,"#{int}")
  558.       end
  559.       guardset = [ case type
  560.             when 'Item', 'Weapon' then @item.element_set
  561.             when 'Armor' then VX ? @item.element_set : @item.guard_element_set
  562.             end, case type
  563.             when 'Item' then @item.plus_state_set
  564.             when 'Weapon' then VX ? @item.state_set : @item.plus_state_set
  565.             when 'Armor' then VX ? @item.state_set : @item.guard_state_set
  566.             end]
  567.       @element = @status = ''
  568.       guardset[0].each_with_index {|i,s| @element += ", " if s > 0
  569.                                     @element += $data_system.elements[i] }
  570.       guardset[1].each_with_index {|i,s| @status += ", " if s > 0
  571.                                     @status += $data_states[i].name }
  572.       @element = 'None' if @element == ''
  573.       @element += ', ' if  @element.size > 20
  574.       @status = 'None' if @status == ''  
  575.       @status += ', '  if @status.size > 20
  576.       pos = type == 'Item' ? [@x+110,@y+230] : [@x+120,@y+310+vy]
  577.       @sta_window['stat'].contents.draw_text(pos[0],pos[1],420,24,@element)
  578.       @sta_window['stat'].contents.draw_text(pos[0],pos[1]+20,420,24,@status)
  579.     end
  580.     #--------------------------------------------------------------------------
  581.     # * Update guardset status
  582.     #--------------------------------------------------------------------------
  583.     def update_guardset_status
  584.       @time_status = (@time_status || 0) + 1
  585.       return if @item.nil? || @time_status < 8
  586.       vy,@time_status = VX ? -60 : 0 ,0
  587.       pos = @item.is_a?(RPG::Item) ? [@x+110,@y+230] : [@x+120,@y+310+vy]
  588.       kuu = LiTTleDRAgo::ELEMENT_TOO_MANY
  589.       if  @element != nil && @element.size > 20
  590.         rect = Rect.new(pos[0], pos[1], @sta_window['stat'].width  - 32, 24)
  591.         if LiTTleDRAgo::ELEMENT_STATUS_MARQUEE
  592.           @sta_window['stat'].contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  593.           array = @element.split(//)
  594.           array << array[0]
  595.           array.shift
  596.           @element = array.join
  597.           @sta_window['stat'].contents.draw_text(pos[0],pos[1],420,24,@element)
  598.         else
  599.           @sta_window['stat'].contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  600.           @sta_window['stat'].contents.draw_text(pos[0],pos[1],420,24,kuu)
  601.         end
  602.       end
  603.       if  @status != nil && @status.size > 20
  604.         rect = Rect.new(pos[0], pos[1]+20, @sta_window['stat'].width  - 32, 24)
  605.         if LiTTleDRAgo::ELEMENT_STATUS_MARQUEE
  606.           @sta_window['stat'].contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  607.           array = @status.split(//)
  608.           array << array[0]
  609.           array.shift
  610.           @status = array.join
  611.           @sta_window['stat'].contents.draw_text(pos[0],pos[1]+20,420,24,@status)
  612.         else
  613.           @sta_window['stat'].contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  614.           @sta_window['stat'].contents.draw_text(pos[0],pos[1]+20,420,24,kuu)
  615.         end
  616.       end
  617.     end
  618.   end #of class
  619.   #==============================================================================
  620.   # ** Game_Actor
  621.   #------------------------------------------------------------------------------
  622.   #  This class handles the actor. It's used within the Game_Actors class
  623.   #  ($game_actors) and refers to the Game_Party class ($game_party).
  624.   #==============================================================================
  625.   class Game_Actor < Game_Battler
  626.     @@equip = VX ? 'change_equip' : 'equip'
  627.     eval "
  628.    alias drg146_equip #{@@equip} unless method_defined?(:drg146_equip)
  629.    def equip_fix?(*args) fix_equipment end if VX
  630.    def #{@@equip}(*args)
  631.      max = $game_party.limit_inventory.max_size
  632.      $game_party.limit_inventory.resize (max+1)
  633.      drg146_equip(*args)
  634.      $game_party.limit_inventory.resize (max)
  635.    end#"
  636.   end
  637.   #==============================================================================
  638.   # ** Game_Temp
  639.   #------------------------------------------------------------------------------
  640.   #  This class handles temporary data that is not included with save data.
  641.   #  Refer to "$game_temp" for the instance of this class.
  642.   #==============================================================================
  643.   class Game_Temp
  644.     alias_method :drg137_init, :initialize unless method_defined?(:drg137_init)
  645.     attr_accessor :slots_to_discard, :inventory
  646.     define_method(:initialize) { [drg137_init,
  647.                            @slots_to_discard = Game_LimitedInventory.new(-1)] }
  648.   end
  649.   #==============================================================================
  650.   # ** Game_Party
  651.   #------------------------------------------------------------------------------
  652.   #  This class handles the party. It includes information on amount of gold
  653.   #  and items. Refer to "$game_party" for the instance of this class.
  654.   #==============================================================================
  655.   class Game_Party
  656.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  657.     # * Public Instance Variables
  658.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  659.     attr_reader :inventories
  660.     attr_accessor :inventory,:gold,:disable_combine,:disable_equip
  661.     attr_accessor :no_multi_use
  662.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  663.     # * Aliased Method
  664.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  665.     unless method_defined?(:drg146_can_use)
  666.       alias drg146_init initialize
  667.       alias drg146_can_use item_can_use?
  668.       alias drg146_number item_number
  669.     end
  670.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  671.     # * Object Initialization
  672.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  673.     def initialize(*args)
  674.       drg146_init(*args)
  675.       init_multi_inventory
  676.     end
  677.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  678.     # * Object Initialization
  679.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  680.     def limit_inventory(id=@inventory,val=nil)
  681.       @limit_inventory = {} if @limit_inventory.nil?
  682.       if @limit_inventory[id].nil?
  683.         @limit_inventory[id] =
  684.             Game_LimitedInventory.new(LiTTleDRAgo::DEFAULT_MAX_SIZE)
  685.       end
  686.       return val ? @limit_inventory[id] = val : @limit_inventory[id]
  687.     end
  688.    
  689.     def stack_item(item_id)
  690.       stack = LiTTleDRAgo::DEFAULT_ITEM_STACK
  691.       return stack[item_id] || stack[0]
  692.     end  
  693.    
  694.     if VX
  695.       def actors() members end
  696.       def weapon_number(v) item_number($data_weapons[v]) end
  697.       def armor_number(v) item_number($data_armors[v]) end
  698.       def item_can_use?(item)
  699.         item = $data_items[item] if item.is_a?(Integer)
  700.         drg146_can_use(item)
  701.       end
  702.       def item_number(item)
  703.         item = $data_items[item] if item.is_a?(Integer)
  704.         drg146_number(item)
  705.       end
  706.     end
  707.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  708.     # * Gain Item (or Lose)
  709.     #       item  >> item / item_id
  710.     #       n     >> number
  711.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  712.     def drg137_gain_item(id, n)
  713.       @items[id] = [item_number(id) + n, 0].max if id > 0
  714.     end
  715.     def drg137_gain_weapon(id, n)
  716.       @weapons[id] = [weapon_number(id) + n, 0].max if id > 0
  717.     end
  718.     def drg137_gain_armor(id, n)
  719.       @armors[id] = [armor_number(id) + n, 0].max if id > 0
  720.     end
  721.    
  722.     def gain_item(item, n, include_equip = false)
  723.       return if item.nil?
  724.       case item
  725.       when RPG::Item, Numeric
  726.         array = item.is_a?(RPG::Item) ? [item,item.id] : [$data_items[item],item]
  727.         ammount = n
  728.         while ammount > 1
  729.           gain_proses(array[0], 1)
  730.           drg137_gain_item(array[1], 1)
  731.           ammount -= 1
  732.         end
  733.         gain_proses(array[0], ammount)
  734.         drg137_gain_item(array[1], ammount)
  735.       when RPG::Weapon then gain_weapon(item.id, n)
  736.       when RPG::Armor  then gain_armor(item.id, n)
  737.       end
  738.       return unless VX
  739.       number = item_number(item)
  740.       n += number
  741.       if include_equip and n < 0
  742.         for actor in actors
  743.           while n < 0 and actor.equips.include?(item)
  744.             actor.discard_equip(item)
  745.             n += 1
  746.           end
  747.         end
  748.       end
  749.     end
  750.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  751.     # * Gain Weapon And Armor (or Lose)
  752.     #       item_id  >> weapon / armor id
  753.     #       n        >> number
  754.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  755.     def gain_weapon(item_id, n)
  756.       ammount = n
  757.       while ammount > 1
  758.         drg137_gain_weapon(item_id, 1)
  759.         gain_proses($data_weapons[item_id],1)
  760.         ammount -= 1
  761.       end
  762.       drg137_gain_weapon(item_id, ammount)
  763.       gain_proses($data_weapons[item_id],ammount)
  764.     end
  765.    
  766.     def gain_armor(item_id, n)
  767.       ammount = n
  768.       while ammount > 1
  769.         drg137_gain_armor(item_id, 1)
  770.         gain_proses($data_armors[item_id],1)
  771.         ammount -= 1
  772.       end
  773.       drg137_gain_armor(item_id, ammount)
  774.       gain_proses($data_armors[item_id],ammount)
  775.     end
  776.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  777.     # * Reduce_Item (for synchronize default item number and limited item number)
  778.     #       item  >> item
  779.     #       n     >> number
  780.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  781.     def reduce_item(item, n)
  782.       case item
  783.       when RPG::Item then  drg137_gain_item(item.id, -n)
  784.       when RPG::Weapon then drg137_gain_weapon(item.id, -n)
  785.       when RPG::Armor then drg137_gain_armor(item.id, -n)
  786.       end
  787.     end
  788.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  789.     # * Gain Proses
  790.     #       item  >> item
  791.     #       n     >> number
  792.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  793.     def gain_proses(item,n)
  794.       init_multi_inventory if @inventories.nil?
  795.       return if item == nil
  796.       type = item.is_a?(RPG::Item) ? 0 : item.is_a?(RPG::Weapon) ? 1 : 2
  797.       if n > 0
  798.         n2 = limit_inventory.add_item(type, item.id, n)
  799.         n -= n2
  800.         if LiTTleDRAgo::NONDISCARD[type].include?(item.id)
  801.           while n2 > 0
  802.             for i in 0...limit_inventory.slots.size
  803.               x = limit_inventory.slots.size - 1 - i
  804.               slot = limit_inventory.slots[x]
  805.               if !LiTTleDRAgo::NONDISCARD[slot.item_type].include?(slot.item_id)
  806.                 l_type, id = slot.item_type, slot.item_id
  807.                 while l_type == slot.item_type && id == slot.item_id
  808.                   x -= 1
  809.                   slot = limit_inventory.slots[x]
  810.                 end
  811.                 l_item, l_n = limit_inventory.slots[x + 1].item, limit_inventory.slots[x + 1].amount
  812.                 break
  813.               end
  814.             end
  815.             return if l_item.nil? or l_n.nil?
  816.             gain_proses(l_item, -1*l_n)
  817.             $game_temp.slots_to_discard.add_item(l_type, id, l_n)
  818.             n3 = limit_inventory.add_item(type, item.id, n2)
  819.             n -= n3
  820.             n2 = n3
  821.           end
  822.         end
  823.       else
  824.         n2 = limit_inventory.remove_item(type, item.id, -1*n)
  825.         n += n2
  826.         n2 *= -1
  827.       end
  828.       if n2 > 0
  829.         $game_temp.slots_to_discard.add_item(type, item.id, n2)
  830.       elsif n2 < 0
  831.         $game_temp.slots_to_discard.remove_item(type, item.id, -1*n2)
  832.       end
  833.     end
  834.     #--------------------------------------------------------------------------
  835.     # * Item Number
  836.     #--------------------------------------------------------------------------
  837.     def all_item_number(item)
  838.       case item
  839.       when RPG::Item   then item_number(item.id)
  840.       when RPG::Weapon then weapon_number(item.id)
  841.       when RPG::Armor  then armor_number(item.id)
  842.       end
  843.     end
  844.    
  845.     def transfer_item(item, n, invent, target)
  846.       item = $data_items[item] if item.is_a?(Integer)
  847.       transfer_process(item, n, invent, target)
  848.     end
  849.    
  850.     def transfer_weapon(item, n, invent, target)
  851.       item = $data_weapons[item] if item.is_a?(Integer)
  852.       transfer_process(item, n, invent, target)
  853.     end
  854.    
  855.     def transfer_armor(item, n, invent, target)
  856.       item = $data_armors[item] if item.is_a?(Integer)
  857.       transfer_process(item, n, invent, target)
  858.     end
  859.    
  860.     def transfer_process(item, n, invent, target)
  861.       return if item.nil? || invent == target || n < 0
  862.       type = item.is_a?(RPG::Item) ? 0 : item.is_a?(RPG::Weapon) ? 1 : 2
  863.       d = @inventory
  864.       stack = item.is_a?(RPG::Item) ? stack_item(item.id) : 1
  865.       n.times {
  866.         slot = limit_inventory(target).slots
  867.         limit_max = limit_inventory(target).max_size
  868.         number =  all_item_number(item)
  869.         unless slot.size >= limit_max && (number <= 0 || (number % stack) == 0)
  870.           switch_inventory(invent)
  871.           if all_item_number(item) >= 1
  872.             gain_item(item, -1)
  873.             switch_inventory(target)
  874.             gain_item(item, 1)
  875.           end
  876.         end}
  877.       switch_inventory(d)
  878.     end
  879.     #--------------------------------------------------------------------------
  880.     # * Initialize Multi Inventory
  881.     #--------------------------------------------------------------------------
  882.     def init_multi_inventory
  883.       @inventory ||= @actors[0] ? @actors[0].id : nil
  884.       @inventory ||= $data_system.party_members[0] || 1
  885.       @inventories ||= [[@items, @weapons, @armors, @gold]]
  886.     end
  887.     #--------------------------------------------------------------------------
  888.     # * Switch Inventory
  889.     #--------------------------------------------------------------------------
  890.     def switch_inventory(id)
  891.       return if @inventory == id
  892.       init_multi_inventory if @inventories.nil?
  893.       new_inventory = @inventories[id] || [{}, {}, {}, 0]
  894.       @inventories[@inventory] = [@items, @weapons, @armors, @gold]
  895.       @items   = new_inventory[0]
  896.       @weapons = new_inventory[1]
  897.       @armors  = new_inventory[2]
  898.       @gold    = new_inventory[3]
  899.       @inventory = id
  900.     end
  901.     #--------------------------------------------------------------------------
  902.     # * Destroy Inventory
  903.     #--------------------------------------------------------------------------
  904.     def destroy_inventory(id=0)
  905.       init_multi_inventory if @inventories.nil?
  906.       @inventories[id] = [{}, {}, {}, 0]
  907.       return unless @inventory == id
  908.       @items,@weapons,@armors,@gold = {}, {}, {}, 0
  909.       limit_inventory.clear
  910.     end
  911.     #--------------------------------------------------------------------------
  912.     # * Resize Inventory
  913.     #--------------------------------------------------------------------------
  914.     def resize_inventory(new_size)
  915.       $game_party.limit_inventory.resize(new_size)
  916.     end
  917.     #--------------------------------------------------------------------------
  918.     # * Combine Inventory
  919.     #--------------------------------------------------------------------------
  920.     def combine_inventory(base_id, merge_id, overflow = false)
  921.       base_id = @inventory if base_id == nil
  922.       base, merge = @inventories[base_id], @inventories[merge_id]
  923.       base_items, base_weapons, base_armors, base_gold = base
  924.       items, weapons, armors, gold = merge
  925.       items.each do |item_id, amount|
  926.         number = base_items[item_id].to_i + amount
  927.         items[item_id] = overflow && number > 99 ? number - 99 : 0
  928.         base_items[item_id] = overflow && number > 99 ? 99 : number
  929.       end
  930.       weapons.each do |weapon_id, amount|
  931.         number = base_weapons[weapon_id].to_i + amount
  932.         weapons[weapon_id] = overflow && number > 99 ? number - 99 : 0
  933.         base_weapons[weapon_id] = overflow && number > 99 ? 99 : number
  934.       end
  935.       armors.each do |armor_id, amount|
  936.         number = base_armors[armor_id].to_i + amount
  937.         armors[armor_id] = overflow && number > 99 ? number - 99 : 0
  938.         base_armors[armor_id] = overflow && number > 99 ? 99 : number
  939.       end
  940.       number = base_gold + gold
  941.       base[3] = overflow && number > 9999999 ? 9999999 : number
  942.       merge[3] = overflow && number > 9999999 ? number - 9999999 : 0
  943.     end
  944.   end
  945.   #==============================================================================
  946.   # ** Scene_Menu
  947.   #------------------------------------------------------------------------------
  948.   #  This class performs menu screen processing.
  949.   #==============================================================================
  950.   Class.flatten.each_with_index {|h,i|
  951.      j = [:command,:status,:actor].collect {|k|
  952.       :"update_#{ k }#{ VX ? '_selection' : '' }" }
  953.   eval "
  954.  class #{h}
  955.    attr_accessor :commands if #{i} == 4
  956.    if #{i} == 0
  957.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  958.      # * Resize Inventory (change inventory size)
  959.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  960.      def resize_inventory(new_size)
  961.        $game_party.limit_inventory.resize(new_size)
  962.      end
  963.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  964.      # * Command End
  965.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  966.      unless method_defined?(:drg150_com_end) || !method_defined?(:command_end)
  967.        alias drg150_com_end command_end
  968.        alias drg150_com_129 command_129
  969.      end
  970.      define_method(:command_end) { [drg150_com_end,check_discard_item] }
  971.      #--------------------------------------------------------------------------
  972.      # * Change Party Member
  973.      #--------------------------------------------------------------------------
  974.      def command_129
  975.        result = drg150_com_129
  976.        leader = $game_party.actors.compact.first
  977.        if (LiTTleDRAgo::MAIN_INVENTORY_LEADER &&
  978.          LiTTleDRAgo::TRANSFER_COM) && !leader.nil?
  979.          $game_party.init_multi_inventory
  980.          $game_party.switch_inventory(leader.id)
  981.        end
  982.        return result
  983.      end
  984.      #--------------------------------------------------------------------------
  985.      # * check_discard_item
  986.      #--------------------------------------------------------------------------
  987.      def check_discard_item
  988.        $scene = Scene_Loot.new  unless $game_temp.slots_to_discard.slots.empty?
  989.      end
  990.      #next
  991.    end
  992.    if #{i} == 5
  993.      #--------------------------------------------------------------------------
  994.      # * Create Viewport
  995.      #--------------------------------------------------------------------------
  996.      def create_viewports
  997.        @viewport1 = Viewport.new(0, 0, 640, 480)
  998.        @viewport2 = Viewport.new(0, 0, 640, 480)
  999.        @viewport3 = Viewport.new(0, 0, 640, 480)
  1000.        @viewport2.z, @viewport3.z = 50, 100
  1001.      end
  1002.      #next
  1003.    end
  1004.    if [1,2,3].include?(#{i})
  1005.      #--------------------------------------------------------------------------
  1006.      # * Alias Listing
  1007.      #--------------------------------------------------------------------------
  1008.      alias drg137_main main unless method_defined?(:drg137_main)
  1009.      alias drg137_batend battle_end unless method_defined?(:drg137_batend) ||
  1010.                                           !method_defined?(:battle_end)
  1011.      if LiTTleDRAgo::TRANSFER_COM && #{i} == 3
  1012.        alias drg150_upd_com #{j[0]} unless method_defined?(:drg150_upd_com)
  1013.        alias drg150_upd_sta #{!VX ? j[1] : j[2]} unless method_defined?(:drg150_upd_sta)
  1014.        #--------------------------------------------------------------------------
  1015.        # * Frame Update (when command window is active)
  1016.        #--------------------------------------------------------------------------
  1017.        def #{j[0]}
  1018.          if Input.trigger?(Input::C) && $game_party.actors.size > 0
  1019.            if @command_window.index == 0
  1020.              sound_play('decision')
  1021.              if $game_party.actors.size == 1
  1022.                $scene = Scene_Item.new($game_party.actors[0].id)
  1023.                return
  1024.              end
  1025.              20.times {[Graphics,Input].each {|s| s.update }}
  1026.              @command_window.active = false
  1027.              @status_window.active = true
  1028.              @status_window.index = 0
  1029.              return
  1030.            end
  1031.          end
  1032.          drg150_upd_com
  1033.        end
  1034.        #--------------------------------------------------------------------------
  1035.        # Sound Play
  1036.        #--------------------------------------------------------------------------
  1037.        def sound_play(se)
  1038.          case se
  1039.          when 'cursor'
  1040.            VX ? Sound.play_cursor : $game_system.se_play($data_system.cursor_se)
  1041.          when 'cancel'
  1042.            VX ? Sound.play_cancel : $game_system.se_play($data_system.cancel_se)
  1043.          when 'equip'
  1044.            VX ? Sound.play_equip : $game_system.se_play($data_system.equip_se)
  1045.          when 'use_item'
  1046.            VX ? Sound.play_use_item : $game_system.se_play(@item.menu_se)
  1047.          when 'decision'
  1048.            VX ? VXA ? Sound.play_ok : Sound.play_decision :
  1049.            $game_system.se_play($data_system.decision_se)
  1050.          when 'buzzer'
  1051.            VX ? Sound.play_buzzer : $game_system.se_play($data_system.buzzer_se)
  1052.          end
  1053.        end
  1054.        #--------------------------------------------------------------------------
  1055.        # * Frame Update (when status window is active)
  1056.        #--------------------------------------------------------------------------
  1057.        def #{!VX ? j[1] : j[2]}
  1058.          if Input.trigger?(Input::C) && @command_window.index == 0
  1059.            if @status_window.active
  1060.              item = $game_party.actors[@status_window.index].id
  1061.              sound_play('decision')
  1062.              return $scene = Scene_Item.new(item)
  1063.            end
  1064.          end
  1065.          drg150_upd_sta
  1066.        end
  1067.      end
  1068.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1069.      # * Main
  1070.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1071.      def main
  1072.        drg137_main
  1073.        $scene = Scene_Loot.new if !$game_temp.slots_to_discard.slots.empty?
  1074.      end if #{i} == 1
  1075.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1076.      # * battle_end
  1077.      #     open up loot management if inventory is full in the end of battle
  1078.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1079.      def battle_end(result)
  1080.        drg137_batend(result)
  1081.        if !$game_temp.slots_to_discard.slots.empty? && !$scene.is_a?(Scene_Gameover)
  1082.          $scene = Scene_Loot.new
  1083.        end
  1084.      end if #{i} == 2
  1085.    end
  1086.  end#"}
  1087.  
  1088.   #==============================================================================
  1089.   # ** Game LimInvSlot
  1090.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1091.   #  This class holds the data on a single slot of the inventory
  1092.   #==============================================================================
  1093.   class Game_LimInvSlot
  1094.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1095.     # * Public Instance Variables
  1096.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1097.     attr_reader   :item_type,:item_id,:amount
  1098.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1099.     # * Object Initialization
  1100.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1101.     def initialize
  1102.       @item_type = -1
  1103.       @item_id = 0
  1104.       @amount = 0
  1105.     end
  1106.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1107.     # * Add Item
  1108.     #    n         >> the amount to add
  1109.     #    item_type >> the type of item being added
  1110.     #    item_id   >> the ID of item being added
  1111.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1112.     def add_item(n, item_type = -1, item_id = 0)
  1113.       if item_type != -1
  1114.         @item_type = item_type
  1115.         @item_id = item_id
  1116.       end
  1117.       if n > space_left
  1118.         @amount += space_left
  1119.         return n - space_left
  1120.       else
  1121.         @amount += n
  1122.         return 0
  1123.       end
  1124.     end
  1125.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1126.     # * Remove Item
  1127.     #    n >> the amount to remove
  1128.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1129.     def remove_item(n)
  1130.       @amount -= n
  1131.       if @amount <= 0
  1132.         n = -1*@amount
  1133.         @item_type = -1
  1134.         @item_id = 0
  1135.         @amount = 0
  1136.         return n
  1137.       end
  1138.       return 0
  1139.     end
  1140.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1141.     # * Item
  1142.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1143.     def item
  1144.       return case @item_type
  1145.       when -1 then nil
  1146.       when 0 then $data_items[@item_id]
  1147.       when 1 then $data_weapons[@item_id]
  1148.       when 2 then $data_armors[@item_id]
  1149.       end
  1150.     end
  1151.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1152.     # * Space Left
  1153.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1154.     def space_left
  1155.       return 1 if item == nil
  1156.       return $game_party.stack_item(item.id) - @amount  if item.is_a?(RPG::Item)
  1157.       return 1 - @amount
  1158.     end
  1159.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1160.     # * Equal?
  1161.     #    other : another Game_LimInvSlot
  1162.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1163.     def ==(other)
  1164.       return false if !other.is_a?(Game_LimInvSlot)
  1165.       return false if other.item_type != @item_type
  1166.       return false if other.item_id != @item_id
  1167.       return false if other.amount != @amount
  1168.       return super(other)
  1169.     end
  1170.   end
  1171.  
  1172.   #==============================================================================
  1173.   # ** Game_LimitedInventory
  1174.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1175.   #  This is an array to store the party's inventory
  1176.   #==============================================================================
  1177.   class Game_LimitedInventory
  1178.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1179.     # * Public Instance Variable
  1180.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1181.     attr_reader   :max_size
  1182.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1183.     # * Object Initialization
  1184.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1185.     def initialize(size)
  1186.       @max_size = size
  1187.       clear
  1188.     end
  1189.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1190.     # * Clear
  1191.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1192.     def clear()  @items,@weapons,@armors = [],[],[] end
  1193.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1194.     # * Resize
  1195.     #    size : the number of slots available
  1196.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1197.     def resize(size)
  1198.       old_size = slots.size
  1199.       if size < old_size
  1200.         index = slots.size - 1
  1201.         while slots.size > size
  1202.           slot = slots[index]
  1203.           if !LiTTleDRAgo::NONDISCARD[slot.item_type].include?(slot.item_id)
  1204.             type, id, n = slot.item_type, slot.item_id, slot.amount
  1205.             remove_item(type, id, n)
  1206.             $game_temp.slots_to_discard.add_item(type, id, n)
  1207.             index -= 1
  1208.           else
  1209.             index -= 1
  1210.           end
  1211.           break if index < 0
  1212.         end
  1213.       end
  1214.       @max_size = size
  1215.     end
  1216.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1217.     # * Add Item
  1218.     #    type : the type of item being added
  1219.     #    id   : the ID of item being added
  1220.     #    n    : the amount to add
  1221.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1222.     def add_item(type, id, n = 1)
  1223.       array = case type
  1224.       when 0 then @items
  1225.       when 1 then @weapons
  1226.       when 2 then @armors
  1227.       end
  1228.       sort_index = 0
  1229.       array.each { |slot|
  1230.         if slot.item_id == id
  1231.           n = slot.add_item(n, type, id)
  1232.           break if n == 0
  1233.           sort_index += 1
  1234.         elsif slot.item_id < id
  1235.           sort_index += 1
  1236.         else
  1237.           break
  1238.         end }
  1239.       if n > 0
  1240.         while @max_size == -1 || ((@items.size + @weapons.size + @armors.size) < @max_size)
  1241.           slot = Game_LimInvSlot.new
  1242.           n = slot.add_item(n, type, id)
  1243.           array.insert(sort_index, slot)
  1244.           sort_index += 1
  1245.           break if n == 0
  1246.         end
  1247.       end
  1248.       return n
  1249.     end
  1250.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1251.     # * Add Item
  1252.     #    type : the type of item being added
  1253.     #    id   : the ID of item being added
  1254.     #    n    : the amount to add
  1255.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1256.     def add_item_reverse(type, id, n = 1)
  1257.       array = case type
  1258.       when 0 then @items
  1259.       when 1 then @weapons
  1260.       when 2 then @armors
  1261.       end
  1262.       sort_index = 0
  1263.       array.reverse.each { |slot|
  1264.         if slot.item_id == id
  1265.           n = slot.add_item(n, type, id)
  1266.           break if n == 0
  1267.           sort_index += 1
  1268.         elsif slot.item_id < id
  1269.           sort_index += 1
  1270.         else
  1271.           break
  1272.         end }
  1273.       if n > 0
  1274.         while @max_size == -1 || ((@items.size + @weapons.size + @armors.size) < @max_size)
  1275.           slot = Game_LimInvSlot.new
  1276.           n = slot.add_item(n, type, id)
  1277.           array.insert(sort_index, slot)
  1278.           sort_index += 1
  1279.           break if n == 0
  1280.         end
  1281.       end
  1282.       return n
  1283.     end
  1284.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1285.     # * Remove Item
  1286.     #    type : the type of item being removed
  1287.     #    id   : the ID of item being removed
  1288.     #    n    : the amount to remove
  1289.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1290.     def remove_item(type, id, n = 1)
  1291.       array = case type
  1292.       when 0 then @items
  1293.       when 1 then @weapons
  1294.       when 2 then @armors
  1295.       end
  1296.       array.reverse.each { |slot|
  1297.         if slot.item_type == type && slot.item_id == id
  1298.           n = slot.remove_item(n)
  1299.           array.delete(slot) if slot.amount == 0
  1300.           break if n == 0
  1301.         end }
  1302.       return n
  1303.     end
  1304.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1305.     # * Remove Item
  1306.     #    type : the type of item being removed
  1307.     #    id   : the ID of item being removed
  1308.     #    n    : the amount to remove
  1309.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1310.     def remove_item_reverse(type, id, n = 1)
  1311.       array = case type
  1312.       when 0 then @items
  1313.       when 1 then @weapons
  1314.       when 2 then @armors
  1315.       end
  1316.       array.each { |slot|
  1317.         if slot.item_type == type && slot.item_id == id
  1318.           n = slot.remove_item(n)
  1319.           array.delete(slot) if slot.amount == 0
  1320.           break if n == 0
  1321.         end }
  1322.       return n
  1323.     end
  1324.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1325.     # * Slots
  1326.     #    get all slot in the inventory
  1327.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1328.     def slots
  1329.       return @items + @weapons + @armors
  1330.     end
  1331.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1332.     # * slot
  1333.     #    get slot for the certain item
  1334.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1335.     def slot(item)
  1336.       array = @items
  1337.       array = @weapons if item.is_a?(RPG::Weapon)
  1338.       array = @armors if item.is_a?(RPG::Armor)
  1339.       for i in 0...array.size
  1340.         slot = array[i]
  1341.         break if slot.item_id == item.id
  1342.       end
  1343.       return slot
  1344.     end
  1345.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1346.     # * slot
  1347.     #    get slot for the certain item
  1348.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1349.     def slot_reverse(item)
  1350.       array = @items
  1351.       array = @weapons if item.is_a?(RPG::Weapon)
  1352.       array = @armors if item.is_a?(RPG::Armor)
  1353.       array.reverse!
  1354.       for i in 0...array.size
  1355.         slot = array[i]
  1356.         break if slot.item_id == item.id
  1357.       end
  1358.       return slot
  1359.     end
  1360.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1361.     # * Check Space
  1362.     #    slot : an Game_InvSlot object
  1363.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1364.     def enough_space?(slot)
  1365.       return true if @max_size == -1 || slots.size < @max_size
  1366.       array = [@items, @weapons, @armors][slot.item_type]
  1367.       array.each { |i|
  1368.         if i.item_id > slot.item_id
  1369.           break
  1370.         elsif i.item_id == slot.item_id
  1371.           l = $game_party.stack_item(i.item_id)
  1372.           x = slot.item.is_a?(RPG::Item) ? l : 1
  1373.           break if i.space_left == 0
  1374.           return true if i.space_left < x
  1375.         end }
  1376.       return false
  1377.     end
  1378.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1379.     # * Equals?
  1380.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1381.     def ==(other)
  1382.       return false unless other.is_a?(Game_LimitedInventory)
  1383.       return false if @max_size != other.max_size
  1384.       return false if slots != other.slots
  1385.       return super(other)
  1386.     end
  1387.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1388.     # * Cek Amount
  1389.     #    cek amount of an item in the inventory
  1390.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1391.     def cek_amount(type, id)
  1392.       array = case type
  1393.       when 0 then @items
  1394.       when 1 then @weapons
  1395.       when 2 then @armors
  1396.       end
  1397.       @n = 0
  1398.       array.each { |slot|  @n += slot.amount if slot.item_id == id   }
  1399.       return @n
  1400.     end
  1401.   end
  1402.  
  1403.   #==============================================================================
  1404.   # ** Window_Item
  1405.   #------------------------------------------------------------------------------
  1406.   #  The Item Grid Window. Based off a 10 column coding.
  1407.   #==============================================================================
  1408.   class Window_Item_Fake_Grid < Window_Selectable_Drago
  1409.    #--------------------------------------------------------------------------
  1410.    # * Public Instance Variables
  1411.    #--------------------------------------------------------------------------
  1412.    attr_accessor :item,:item_max
  1413.     #--------------------------------------------------------------------------
  1414.     # * Object Initialization
  1415.     #--------------------------------------------------------------------------
  1416.     def initialize(inventory = $game_party.limit_inventory,
  1417.                    discard = $game_temp.slots_to_discard )
  1418.       if inventory.is_a?(String)
  1419.         s = eval(inventory)
  1420.         inventory = nil
  1421.       else
  1422.         s = inventory.is_a?(Array) ? inventory.size :
  1423.              $game_party.limit_inventory.max_size
  1424.       end
  1425.       if s >= 35 &&  $scene.is_a?(Scene_Loot)
  1426.         super(55, 160, 200+32, 32*6)
  1427.         @column_max = 6
  1428.       else
  1429.         if s <= 6 then super(100, 200, 200-32*2, 32*3)
  1430.         elsif s <= 10 then super(100, 200, 200, 32*3)
  1431.         elsif s <= 15 then super(100, 200, 200, 32*4)
  1432.         elsif s <= 24 then super(80, 180, 200+32, 32*5)
  1433.         elsif s <= 30 then super(80, 160, 200+32, 32*6)
  1434.         elsif s <= 42 then super(60, 140, 200+32*2, 32*7)
  1435.         elsif s <= 49 then super(60, 120, 200+32*2, 32*8)
  1436.         elsif s <= 56 then super(40, 120, 200+32*3, 32*8)
  1437.         elsif s <= 64 then super(40, 100, 200+32*3, 32*9)
  1438.         elsif s <= 72 then super(20, 100, 200+32*4, 32*9)
  1439.         elsif s <= 81 then super(20, 70, 200+32*4, 32*10)
  1440.         elsif s <= 90 then super(0, 70, 200+32*5, 32*10)
  1441.         elsif s <= 100 then super(0, 70, 200+32*5, 32*10)
  1442.         elsif s <= 110 then super(0, 68, 200+32*5, 32*10)
  1443.         else super(0, 64, 200+32*5, 32*10)
  1444.         end
  1445.         if s <= 6 then @column_max = 3
  1446.         elsif s <= 10 then @column_max = 5
  1447.         elsif s <= 15 then @column_max = 5
  1448.         elsif s <= 24 then @column_max = 6
  1449.         elsif s <= 30 then @column_max = 6
  1450.         elsif s <= 42 then @column_max = 7
  1451.         elsif s <= 49 then @column_max = 7
  1452.         elsif s <= 56 then @column_max = 8
  1453.         elsif s <= 64 then @column_max = 8
  1454.         elsif s <= 72 then @column_max = 9
  1455.         elsif s <= 81 then @column_max = 9
  1456.         elsif s <= 90 then @column_max = 10
  1457.         elsif s <= 100 then @column_max = 10
  1458.         elsif s <= 110 then @column_max = 10
  1459.         else @column_max = 10
  1460.         end
  1461.       end
  1462.       @inventory = inventory
  1463.       return self.contents = Bitmap.new(width-32, height-32) if inventory == nil
  1464.       return self.contents = Bitmap.new(width-32, height-32) if discard == nil
  1465.       self.opacity = 0
  1466.       refresh
  1467.       self.index = 0
  1468.       if $game_temp.in_battle && !$BlizzABS
  1469.         self.x = 144
  1470.         self.y = 64
  1471.         self.back_opacity = 250
  1472.       end
  1473.     end
  1474.     #--------------------------------------------------------------------------
  1475.     # * Get Inventory
  1476.     #--------------------------------------------------------------------------
  1477.     def inventory() @inventory end
  1478.     #--------------------------------------------------------------------------
  1479.     # * Get Disabled Text Color
  1480.     #--------------------------------------------------------------------------
  1481.     def disabled_color() Color.new(255, 255, 255, 128) end
  1482.     #--------------------------------------------------------------------------
  1483.     # * Update Cursor Rectangle
  1484.     #--------------------------------------------------------------------------
  1485.     def update_cursor_rect
  1486.       return if @inventory == nil
  1487.       return  self.cursor_rect.empty if @index < 0
  1488.       row = @index / @column_max
  1489.       self.top_row = row if row < self.top_row
  1490.       if row > self.top_row + (self.page_row_max - 1)
  1491.         self.top_row = row - (self.page_row_max - 1)
  1492.       end
  1493.       cursor_width = self.width / @column_max - 32
  1494.       cursor_width =  32
  1495.       x = @index % @column_max * (cursor_width)
  1496.       y = @index / @column_max * 32 - self.oy
  1497.       self.cursor_rect.set(x, y, cursor_width, 32)
  1498.     end
  1499.     #--------------------------------------------------------------------------
  1500.     # * Get Item
  1501.     #--------------------------------------------------------------------------
  1502.     def item
  1503.       @data ||= []
  1504.       return nil if @data[self.index] == nil
  1505.       return @data[self.index].item
  1506.     end
  1507.     #--------------------------------------------------------------------------
  1508.     # * Refresh
  1509.     #--------------------------------------------------------------------------
  1510.     def refresh
  1511.       return if @inventory == nil
  1512.       if self.contents != nil
  1513.         self.contents.dispose
  1514.         self.contents = nil
  1515.       end
  1516.       @data,@text,@align  = [], nil, nil
  1517.       @inventory.slots.each {|slot| @data.push(slot) if slot.item != nil }
  1518.       @data = @data.sort {|a,b| a.item_id <=> b.item_id }
  1519.       @item_max = @data.size
  1520.       if @data.size > 0
  1521.         self.contents = Bitmap.new(width - 32, row_max * 32)
  1522.         @data.each_index {|i|   draw_item(i)}
  1523.       end
  1524.     end
  1525.     #--------------------------------------------------------------------------
  1526.     # * Draw Item
  1527.     #     index : item number
  1528.     #--------------------------------------------------------------------------
  1529.     def draw_item(index)
  1530.       @data ||= []
  1531.       return if @inventory == nil || @data[index] == nil
  1532.       item, number = @data[index].item, @data[index].amount
  1533.       if item.is_a?(RPG::Item) && $game_party.item_can_use?(item.id)
  1534.         self.contents.font.color = normal_color
  1535.       else
  1536.         self.contents.font.color = disabled_color
  1537.       end
  1538.       x = index % @column_max * (32) +2
  1539.       y = index / @column_max * 32
  1540.       s = self.contents.font.size
  1541.       rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  1542.       self.contents.font.size = 18
  1543.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  1544.       opacity = self.contents.font.color == normal_color ? 255 : 128
  1545.       unless VX
  1546.         bitmap = RPG::Cache.icon(item.icon_name) rescue RPG::Cache.icon('')
  1547.         self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  1548.       else
  1549.         draw_icon(item.icon_index, x, y, opacity == 255)
  1550.       end
  1551.       if item.is_a?(RPG::Item) && number > 1
  1552.         a = "/#{$game_party.stack_item(item.id)}" if LiTTleDRAgo::SHOW_ITEM_STACK
  1553.         self.contents.font.size = 16
  1554.         self.contents.draw_text(x + 2-5, y + 9+1, 32, 32, "#{number}#{a}", 2)
  1555.        end
  1556.        self.contents.font.size = s
  1557.     end
  1558.     #--------------------------------------------------------------------------
  1559.     # * Set Text
  1560.     #--------------------------------------------------------------------------
  1561.     def set_text(text, align = 0)
  1562.       if text != @text or align != @align
  1563.         self.contents.clear
  1564.         self.contents.font.color = normal_color
  1565.         #draw_colored_words(4, 0, self.width - 40, 32, text)
  1566.         self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
  1567.         @text,@align = text, align
  1568.       end
  1569.     end
  1570.     #--------------------------------------------------------------------------
  1571.     # * Draw Colored Words
  1572.     #--------------------------------------------------------------------------
  1573.     def draw_colored_words(x,y,width,height,message='',align=0)
  1574.       xx = [0, self.contents.font.color.dup]
  1575.       t = message.clone
  1576.       t.gsub!(/ : /) { "\c[0] : " }
  1577.       t.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  1578.       while ((c = t.slice!(/./m)) != nil)
  1579.         if c == "\001"
  1580.           t.sub!(/\[([0-9]+)\]/, "")
  1581.           self.contents.font.color = text_color($1.to_i)
  1582.           next
  1583.         end
  1584.         self.contents.draw_text(x + xx[0], y, width, height, c)
  1585.         xx[0] += self.contents.text_size(c).width
  1586.       end
  1587.       self.contents.font.color = xx[1]
  1588.     end
  1589.     #------------------------------------------------------------------------
  1590.     # * Update Help Text
  1591.     #------------------------------------------------------------------------
  1592.     def update_help
  1593.       i = @help_window.is_a?(Window_Welcome) ?  
  1594.       @help_window.set_text(self.item.nil? ? '' :
  1595.         "#{self.item.true_name} : #{self.item.description}",0,self.item) :
  1596.       @help_window.set_text(self.item.nil? ? '' :
  1597.         "#{self.item.name} : #{self.item.description}")
  1598.     end
  1599.   end
  1600.   #==============================================================================
  1601.   # ** Window Item Count
  1602.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1603.   #  Class for title of the inventory
  1604.   #==============================================================================
  1605.   class Window_Item_Count < Window_Base
  1606.     #--------------------------------------------------------------------------
  1607.     # * Object Initialization
  1608.     #    inventory >> an Game_LimitedInventory object
  1609.     #--------------------------------------------------------------------------
  1610.     def initialize(inventory)
  1611.       super(0, 64+15, 320, 64)
  1612.       @inventory = inventory
  1613.       self.x = 320 if inventory == $game_temp.slots_to_discard
  1614.       self.contents = Bitmap.new(width - 32, height - 32)
  1615.       self.contents.font.name = "Sylfaen"
  1616.       refresh
  1617.     end
  1618.     #--------------------------------------------------------------------------
  1619.     # * Refresh
  1620.     #--------------------------------------------------------------------------
  1621.     def refresh
  1622.       self.contents.clear
  1623.       width = self.contents.width
  1624.       actor = $game_actors[$game_party.inventory].name rescue ''
  1625.       text = sprintf(LiTTleDRAgo::PARTY_INV,actor)
  1626.       if @inventory == $game_party.limit_inventory
  1627.         self.contents.draw_text(0,0,width,32,text)
  1628.         self.contents.draw_text(0,0,width,32,@inventory.slots.size.to_s + " / " + @inventory.max_size.to_s,2)
  1629.       else
  1630.         self.contents.draw_text(0,0,width,32,LiTTleDRAgo::LOOT_INV)
  1631.       end
  1632.     end
  1633.   end
  1634.  
  1635.   class Window_Eq_Show < Window_Base
  1636.     def initialize(actor=nil)
  1637.       super(0, 152, 200, 176)
  1638.       @actor = actor
  1639.       self.contents = Bitmap.new(width - 32, height - 32)
  1640.       return if actor.nil?
  1641.       refresh
  1642.     end
  1643.     def refresh(s=nil)
  1644.       @actor = s if !s.nil?
  1645.       @arm = [] if @arm.nil?
  1646.       if !@actor.nil? && (@actor != @old_act ||
  1647.         @actor.weapon_id != @arm[0] ||
  1648.         @actor.armor1_id != @arm[1] ||
  1649.         @actor.armor2_id != @arm[2] ||
  1650.         @actor.armor3_id != @arm[3] ||
  1651.         @actor.armor4_id != @arm[4])
  1652.         @old_act = @actor
  1653.         @arm = [@actor.weapon_id, @actor.armor1_id, @actor.armor2_id,
  1654.                 @actor.armor3_id, @actor.armor4_id]
  1655.         self.contents.clear
  1656.         self.contents.font.color = system_color
  1657.         draw_item_name($data_weapons[@arm[0]], 0 , 0)
  1658.         draw_item_name($data_armors[@arm[1]], 0 , 28*1)
  1659.         draw_item_name($data_armors[@arm[2]], 0 , 28*2)
  1660.         draw_item_name($data_armors[@arm[3]], 0 , 28*3)
  1661.         draw_item_name($data_armors[@arm[4]], 0 , 28*4)
  1662.       end
  1663.     end
  1664.   end
  1665.  
  1666.   #==============================================================================
  1667.   # ** Scene_Item
  1668.   #------------------------------------------------------------------------------
  1669.   #  This class performs item screen processing.
  1670.   #==============================================================================
  1671.  
  1672.   class Scene_Item
  1673.     @@z = 2000
  1674.     #--------------------------------------------------------------------------
  1675.     # * Initialize
  1676.     #--------------------------------------------------------------------------
  1677.     def initialize(inv=$game_party.inventory)
  1678.       $game_temp.inventory = $game_party.inventory
  1679.       $game_party.switch_inventory(inv)
  1680.     end
  1681.     #--------------------------------------------------------------------------
  1682.     # * Main Processing
  1683.     #--------------------------------------------------------------------------
  1684.     def main
  1685.       @sta_window = {}
  1686.       @sta_window['help'] = Window_Help.new
  1687.       @sta_window['help'].z = @@z
  1688.       @sta_window['help'].x = 999
  1689.       @item_window = [  Window_Item_Fake_Grid.new,
  1690.                         Window_Item_Fake_Grid.new]
  1691.       @item_window.each {|i| i.help_window = @sta_window['help'] }
  1692.       @item_window[2] = Window_Item_Fake_Grid.new(nil)
  1693.       create_inv_com_window
  1694.       create_input_number
  1695.       @all_window = [ @sta_window['stat']   = Window_Welcome.new('statistic'),
  1696.                       @sta_window['well']   = Window_Welcome.new,
  1697.                       @sta_window['target'] = Window_Target_Drago.new,
  1698.                       @sta_window['eq']     = Window_Eq_Show.new,
  1699.                       @inpnum_window, @sta_window['help'], @item_window, @invcom_window]
  1700.       @sta_window['stat'].x = 999
  1701.       @sta_window['eq'].active =
  1702.       @sta_window['target'].active =
  1703.       @sta_window['target'].visible =
  1704.       @item_window[1].active =
  1705.       @item_window[1].visible = false
  1706.       @item_window.each {|i| i.z += @@z }
  1707.       @item_window[2].z = @item_window[0].z - 10
  1708.       @sta_window['target'].z = @item_window[0].z + 50
  1709.       @sta_window['eq'].x = -200
  1710.       @sta_window['eq'].z = @item_window[0].z + 100
  1711.       @sta_window['well'].refresh
  1712.       @sta_window['stat'].y -= 40
  1713.       @sta_window['stat'].z = @@z - 1
  1714.       @sta_window['well'].y = 405
  1715.       @sta_window['well'].x = -200
  1716.       @sta_window['well'].z = @sta_window['stat'].z + 2
  1717.       unless $drg_inv_sys_no_layout
  1718.         @sta_window['well'].opacity = 0
  1719.         @sta_window['well'].contents_opacity = 0
  1720.       end
  1721.       Graphics.transition(LiTTleDRAgo::TRAN_TIME, 'Graphics/Transitions/' +
  1722.             LiTTleDRAgo::TRAN_TYPE) rescue Graphics.transition
  1723.       while $scene == self
  1724.         [Graphics,Input].each {|i| i.update}
  1725.         update
  1726.       end
  1727.       30.times {    @sta_window['well'].x += 20
  1728.                     @sta_window['help'].x += 20
  1729.                     @item_window.each {|i| i.x += 20 }
  1730.                     @sta_window['eq'].x -= 20
  1731.                     @sta_window['stat'].x += 15
  1732.                     Graphics.update  
  1733.                     @item_lay.opacity -= 15
  1734.                     @item_lay.zoom_x += 0.2
  1735.                     @sta_window['help'].contents_opacity -= 15     }
  1736.       Graphics.freeze
  1737.       @all_window.each {|i| i.dispose rescue nil }
  1738.       exit_normalize_inventory
  1739.       return unless !$game_temp.slots_to_discard.slots.empty? &&
  1740.                                  !$scene.is_a?(Scene_Gameover)
  1741.       $scene = Scene_Loot.new($game_party.inventory)
  1742.     end
  1743.     #--------------------------------------------------------------------------
  1744.     # * create_input_number
  1745.     #--------------------------------------------------------------------------
  1746.     def create_input_number
  1747.       @inpnum_window = [ Window_InputNumber.new(4),
  1748.                          Window_Item_Fake_Grid.new('6')]
  1749.       @inpnum_window.each {|i| i.x = 258
  1750.                                i.y = 150
  1751.                                i.z = @@z + 300 + 50
  1752.                                i.visible = i.active = false}
  1753.       @inpnum_window[0].y += 32
  1754.       @inpnum_window[0].x += 12
  1755.       @inpnum_window[1].set_text(LiTTleDRAgo::ASK_MANY,1)
  1756.     end
  1757.     #--------------------------------------------------------------------------
  1758.     # * exit_normalize_inventory
  1759.     #--------------------------------------------------------------------------
  1760.     def exit_normalize_inventory
  1761.       Graphics.resize_screen($game_temp_screen[0],$game_temp_screen[1]) if VX
  1762.       return if $game_temp.inventory.nil?
  1763.       return unless $game_temp.inventory != $game_party.inventory
  1764.       $game_party.switch_inventory($game_temp.inventory)
  1765.     end
  1766.     #--------------------------------------------------------------------------
  1767.     # * create_inv_com_window
  1768.     #--------------------------------------------------------------------------
  1769.     def create_inv_com_window
  1770.       comb = combine_not_exist? ? '' : LiTTleDRAgo::COMBINE_COM
  1771.       equ  = equip_not_exist?   ? '' : LiTTleDRAgo::EQ_COM
  1772.       del  = [LiTTleDRAgo::DIS_COM, LiTTleDRAgo::CANCEL_COM]
  1773.       use  = LiTTleDRAgo::USE_COM
  1774.       nocb = combine_not_exist? ||  $game_party.disable_combine
  1775.       noeq = equip_not_exist? || $game_party.disable_equip
  1776.       tra  = transfer_com
  1777.       command_item = tra != '' && !bypass_one_actor?(1) ?
  1778.                 (nocb ? [use,tra,del[0],del[1]] : [use,tra,comb,del[0]]) :
  1779.                 (nocb ? [use,del].flatten       : [use, comb, del[0]] )
  1780.       command_weap = tra != '' && !bypass_one_actor?(1)  ?
  1781.                 (nocb ? noeq ? [del[0],tra,del[1]] : [equ,tra,del[0]] :
  1782.                  noeq ? [comb,tra,del[0],del[1]] : [comb,tra,equ,del[0]]) :
  1783.                 (nocb ? noeq ? [del].flatten : [equ,del[0]] :
  1784.                  noeq ? [comb,del[0],del[1]] : [comb,equ,del[0]])        
  1785.       @invcom_window = [Window_Command.new(160, command_item),
  1786.                         Window_Command.new(160, command_weap),
  1787.                         Window_Command.new(160,[comb,del[1]]),
  1788.                         Window_Command.new(190,['',''])]
  1789.       @invcom_window.each_with_index {|i,s|  i.x = s == 3 ? 228 : 258
  1790.                                 i.y = 160 + 1*32
  1791.                                 i.z = @@z + @item_window[0].z + 200
  1792.                                 i.active = i.visible = false }
  1793.     end
  1794.     #--------------------------------------------------------------------------
  1795.     # * Frame Update
  1796.     #--------------------------------------------------------------------------
  1797.     def update
  1798.       return update_scene_loot if $scene.is_a?(Scene_Loot)
  1799.       @sta_window['well'].update
  1800.       @sta_window['help'].update
  1801.       @item_window[0].update
  1802.       @sta_window['stat'].x = [@sta_window['stat'].x - 10,352].max
  1803.       @sta_window['well'].x = [@sta_window['well'].x+10,0].min
  1804.       welcome_opac = @sta_window['well'].contents_opacity
  1805.       @sta_window['well'].contents_opacity = [welcome_opac+15,255].max  
  1806.       if @equip_window_active
  1807.         @sta_window['eq'].active = true
  1808.         @actor = $game_party.actors[@sta_window['target'].index]
  1809.         @sta_window['eq'].refresh(@actor)
  1810.         @sta_window['eq'].x = [@sta_window['eq'].x+10,0].min
  1811.       else
  1812.         if @sta_window['eq'].x > -200
  1813.           @actor = $game_party.actors[@sta_window['target'].index]
  1814.           @sta_window['eq'].refresh(@actor)
  1815.           @sta_window['eq'].x -= 10
  1816.         elsif @sta_window['eq'].x <= -200
  1817.           @sta_window['eq'].active = false
  1818.         end
  1819.       end
  1820.       if @item_window[0].active
  1821.         update_item
  1822.         update_stats
  1823.         if VX
  1824.           @sta_window['stat'].x += 1
  1825.           @sta_window['stat'].x -= 1
  1826.         end
  1827.         @sta_window['stat'].visible = @item != nil
  1828.         return
  1829.       end
  1830.       if @invcom_window[0].active || @invcom_window[1].active ||
  1831.         @invcom_window[3].active || @inpnum_window[0].active
  1832.         @invcom_window.each {|i| i.update if i.active }
  1833.         check_max_input
  1834.         return update_command
  1835.       end
  1836.       if @sta_window['target'].active
  1837.         @sta_window['target'].update
  1838.         return update_target
  1839.       end
  1840.       if @item_window[1].active
  1841.         @item_window[1].update
  1842.         update_stats
  1843.         update_combine
  1844.         return
  1845.       end
  1846.       if @invcom_window[2].active
  1847.         @invcom_window[2].update
  1848.         return update_command
  1849.       end
  1850.     end
  1851.     #--------------------------------------------------------------------------
  1852.     # * check_max_input
  1853.     #--------------------------------------------------------------------------
  1854.     def check_max_input
  1855.       @inpnum_window[0].update if @inpnum_window[0].active
  1856.       return unless @inpnum_window[0].number > (@number_item || 0)
  1857.       @inpnum_window[0].number, @number_overload = !@number_overload ?
  1858.             [@number_item, true] : [0 , false]
  1859.     end
  1860.     #--------------------------------------------------------------------------
  1861.     # * Update Command Window
  1862.     #--------------------------------------------------------------------------
  1863.     def update_command
  1864.       if Input.trigger?(Input::B)
  1865.         return cancel_combination
  1866.       end
  1867.       if Input.trigger?(Input::C)
  1868.         if @item.is_a?(RPG::Item) && @invcom_window[0].active &&
  1869.           !@invcom_window[2].active && !@invcom_window[3].active
  1870.           nocomb = combine_not_exist? || $game_party.disable_combine
  1871.           if @invcom_window[1].commands.size != 4
  1872.             case @invcom_window[0].index
  1873.             when 0 then use_item
  1874.             when 1 then nocomb ? discard_item : combine_item
  1875.             when 2 then nocomb ? cancel_combination : discard_item
  1876.             end
  1877.           else
  1878.             case @invcom_window[0].index
  1879.             when 0 then use_item
  1880.             when 1 then transfer_item
  1881.             when 2 then nocomb ? discard_item : combine_item
  1882.             when 3 then nocomb ? cancel_combination : discard_item
  1883.             end
  1884.           end
  1885.         elsif (@item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)) &&
  1886.           @invcom_window[1].active && !@invcom_window[3].active
  1887.           noeq = equip_not_exist? || $game_party.disable_equip
  1888.           nocomb = 0
  1889.           nocomb += 1 if @invcom_window[1].commands.size == 2
  1890.           if @invcom_window[1].commands.size != 4
  1891.             case @invcom_window[1].index + nocomb
  1892.             when 0 then combine_item
  1893.             when 1 then noeq ? discard_item : equip_item
  1894.             when 2 then noeq ? cancel_combination : discard_item
  1895.             end
  1896.           else
  1897.             case @invcom_window[1].index + nocomb
  1898.             when 0 then combine_item
  1899.             when 1 then transfer_item
  1900.             when 2 then noeq ? discard_item : equip_item
  1901.             when 3 then noeq ? cancel_combination : discard_item
  1902.             end
  1903.           end
  1904.         elsif @invcom_window[2].active && !@invcom_window[0].active
  1905.           case @invcom_window[2].index
  1906.           when 0 then combination
  1907.           when 1 then cancel_combination
  1908.           end
  1909.         elsif @invcom_window[3].active
  1910.           case @invcom_window[3].index
  1911.           when 0 then update_unequip(0)
  1912.           when 1 then update_unequip(1)
  1913.           when 2 then cancel_combination
  1914.           end
  1915.         elsif @inpnum_window[0].active
  1916.           discard_item_value  if @number_purpose == 'Discard'
  1917.           transfer_item_value if @number_purpose == 'Transfer'
  1918.         end
  1919.         @invcom_window.each {|i| i.index = 0 }
  1920.         return
  1921.       end
  1922.     end
  1923.     #--------------------------------------------------------------------------
  1924.     # * combine_not_exist?
  1925.     #--------------------------------------------------------------------------
  1926.     def combine_not_exist?
  1927.       mtd = [LiTTleDRAgo::COMBINE_ITEM,LiTTleDRAgo::COMBINE_COM] rescue []
  1928.       result = mtd[0].nil? || mtd[0] == {} || mtd[0] == [] ||
  1929.               mtd[1].nil? || mtd[1] == ''
  1930.       return result
  1931.     end
  1932.     #--------------------------------------------------------------------------
  1933.     # * transfer_com
  1934.     #--------------------------------------------------------------------------
  1935.     def transfer_com()  LiTTleDRAgo::TRANSFER_COM || '' rescue ''  end
  1936.     #--------------------------------------------------------------------------
  1937.     # * equip_not_exist?
  1938.     #--------------------------------------------------------------------------
  1939.     def equip_not_exist?
  1940.       result = LiTTleDRAgo::EQ_COM.nil? ||
  1941.                LiTTleDRAgo::EQ_COM == '' rescue true
  1942.       return result
  1943.     end
  1944.     #--------------------------------------------------------------------------
  1945.     # * cancel_combination
  1946.     #--------------------------------------------------------------------------
  1947.     def cancel_combination
  1948.       sound_play('cancel')
  1949.       discard_item_value(0) if @inpnum_window[0].active
  1950.       @item_window[0].active  = true  unless @inpnum_window[0].active
  1951.       @item_window[0].visible = true  unless @inpnum_window[0].active
  1952.       @item_window[1].active  = false unless @inpnum_window[0].active
  1953.       @item_window[1].visible = false unless @inpnum_window[0].active
  1954.       @invcom_window.each {|i|  i.active = i.visible = false }
  1955.       @inpnum_window.each {|i|  i.active = i.visible = false }
  1956.       @equip_window_active = @number_overload = nil
  1957.       @sta_window['well'].refresh
  1958.       @number_item = 0
  1959.       return
  1960.     end
  1961.     #--------------------------------------------------------------------------
  1962.     # * Use Item Processing
  1963.     #--------------------------------------------------------------------------
  1964.     def equip_item
  1965.       @sta_window['eq'].refresh(@actor) if !@sta_window['eq'].nil?
  1966.       return sound_play('buzzer') if @item.is_a?(RPG::Item)
  1967.       sound_play('decision')
  1968.       @invcom_window.each {|i|  i.active = i.visible = false }
  1969.       @sta_window['target'].active  =
  1970.       @sta_window['target'].visible =
  1971.       @equip_window_active = true
  1972.       @sta_window['target'].index = 0
  1973.       @sta_window['well'].set_text(LiTTleDRAgo::EQUIP_WELCOME)
  1974.     end  
  1975.     #--------------------------------------------------------------------------
  1976.     # * transfer_item_update
  1977.     #--------------------------------------------------------------------------
  1978.     def transfer_item_update
  1979.       @transfer_flag = false
  1980.       slot = @item_window[0].inventory.slot(@item) rescue nil
  1981.       return sound_play('buzzer') if slot.nil?
  1982.       type, id, @number_item = slot.item_type, slot.item_id, slot.amount
  1983.       return sound_play('buzzer') if LiTTleDRAgo::NONDISCARD[type].include?(id)
  1984.       sound_play('decision')
  1985.       @invcom_window.each {|i| i.active = i.visible = false }
  1986.       @inpnum_window.each {|i| i.active = i.visible = true  }
  1987.       @inpnum_window[0].number = 0
  1988.       @number_purpose = 'Transfer'
  1989.     end
  1990.     #--------------------------------------------------------------------------
  1991.     # * transfer_item_value
  1992.     #--------------------------------------------------------------------------
  1993.     def transfer_item_value
  1994.       @transfer_flag = false
  1995.       @actor = $game_party.actors[@sta_window['target'].index]
  1996.       sound_play('decision')
  1997.       inv, n = $game_party.inventory, @inpnum_window[0].number
  1998.       n.times { $game_party.transfer_process(@item,1,inv,@actor.id) }
  1999.       @item_window.each {|i| i.refresh }
  2000.       @inpnum_window.each {|i| i.active = i.visible = false }
  2001.       @item_window[0].active = true
  2002.       @sta_window['target'].active  =
  2003.       @sta_window['target'].visible = false
  2004.       @item_window[0].index = [[@item_window[0].index,0].max,
  2005.                                 @item_window[0].item_max-1].min
  2006.       @sta_window['well'].refresh
  2007.       @must_update = true
  2008.     end
  2009.     #--------------------------------------------------------------------------
  2010.     # * Discard Item Processing
  2011.     #--------------------------------------------------------------------------
  2012.     def discard_item
  2013.       slot = @item_window[0].inventory.slot_reverse(@item) rescue nil
  2014.       return if slot.nil?
  2015.       type, id, @number_item = slot.item_type, slot.item_id, item_number(@item)
  2016.       return sound_play('buzzer') if LiTTleDRAgo::NONDISCARD[type].include?(id)
  2017.       sound_play('decision')
  2018.       @invcom_window.each {|i| i.active = i.visible = false }
  2019.       @inpnum_window.each {|i| i.active = i.visible = true  }
  2020.       @inpnum_window[0].number = 0
  2021.       @number_purpose = 'Discard'
  2022.     end
  2023.     #--------------------------------------------------------------------------
  2024.     # * discard_item_value
  2025.     #--------------------------------------------------------------------------
  2026.     def discard_item_value(number = @inpnum_window[0].number)
  2027.       slot = @item_window[0].inventory.slot_reverse(@item) rescue nil
  2028.       return if slot.nil?
  2029.       type, id, n = slot.item_type, slot.item_id, number
  2030.       return sound_play('buzzer') if LiTTleDRAgo::NONDISCARD[type].include?(id)
  2031.       sound_play(number > 0 ? 'decision' : 'cancel')
  2032.       $game_party.no_multi_use = true
  2033.       n.times {  $game_party.lose_item(@item, 1) if item_number(@item) > 0  }
  2034.       @sta_window['well'].refresh
  2035.       @item_window.each {|i| i.refresh }
  2036.       @inpnum_window.each {|i| i.active = i.visible = false }
  2037.       @item_window[0].active = true
  2038.       @item_window[0].index = [[@item_window[0].index-1,0].max,
  2039.                                 @item_window[0].item_max-1].min
  2040.       $game_party.no_multi_use = false
  2041.       @equip_window_active = false
  2042.       @must_update = true
  2043.     end
  2044.     #--------------------------------------------------------------------------
  2045.     # * Transfer Item Processing
  2046.     #--------------------------------------------------------------------------
  2047.     def transfer_item
  2048.       sound_play('decision')
  2049.       @invcom_window.each {|i|  i.active = i.visible = false }
  2050.       @sta_window['target'].active  =  
  2051.       @sta_window['target'].visible = true
  2052.       @equip_window_active = false
  2053.       @sta_window['target'].index = 0
  2054.       @transfer_flag = true
  2055.     end
  2056.     #--------------------------------------------------------------------------
  2057.     # * Use Item Processing
  2058.     #--------------------------------------------------------------------------
  2059.     def use_item
  2060.       unless @item.is_a?(RPG::Item) || $game_party.item_can_use?(@item.id)
  2061.         return sound_play('buzzer')
  2062.       end
  2063.       if $xrxs_xas
  2064.         if XAS::XASITEM_ID[@item.id] != nil && $game_player.can_action?
  2065.           sound_play('decision')
  2066.           $game_system.xas_item_id = @item.id
  2067.           $scene = Scene_Map.new
  2068.           $game_player.active_item
  2069.         end  
  2070.         return  
  2071.       end
  2072.       sound_play('decision') unless bypass_one_actor?
  2073.       if @item.scope >= 3
  2074.         @invcom_window.each {|i|  i.active = i.visible = false }
  2075.         @sta_window['target'].active  = true
  2076.         @sta_window['target'].visible = bypass_one_actor? ? false : true  
  2077.         @equip_window_active = false
  2078.         if @item.scope == 4 || @item.scope == 6
  2079.           @sta_window['target'].index = -1
  2080.         else
  2081.           @sta_window['target'].index = 0
  2082.         end
  2083.       else
  2084.         if @item.common_event_id > 0
  2085.           $game_temp.common_event_id = @item.common_event_id
  2086.           sound_play('use_item')
  2087.           if @item.consumable
  2088.             @sta_window['well'].refresh
  2089.             $game_party.lose_item(@item.id, 1)
  2090.             @item_window[0].draw_item(@item_window[0].index)
  2091.           end
  2092.           return $scene = Scene_Map.new
  2093.         end
  2094.       end
  2095.     end  
  2096.     #--------------------------------------------------------------------------
  2097.     # * Use Item Processing
  2098.     #--------------------------------------------------------------------------
  2099.     def combine_item
  2100.       sound_play('decision')
  2101.       @invcom_window.each {|i| i.active = i.visible = false }
  2102.       @invcom_window[2].active  = true
  2103.       @invcom_window[2].visible = false
  2104.       @item_window.each_with_index {|i,s|
  2105.                 i.active = i.visible = s == 0 ? false : true }
  2106.       @equip_window_active = false
  2107.       @item_window[1].index = 0
  2108.     end  
  2109.     #--------------------------------------------------------------------------
  2110.     # * Frame Update (combine item window is active)
  2111.     #--------------------------------------------------------------------------
  2112.     def update_combine
  2113.       if Input.trigger?(Input::B)
  2114.         sound_play('cancel')
  2115.         return $scene = Scene_Menu.new(0)
  2116.       end
  2117.       if Input.trigger?(Input::C)
  2118.         @item_1 = @item_window[0].item
  2119.         @item_2 = @item_window[1].item
  2120.         if @item_1 != nil && @item_2 != nil
  2121.           c = combine_result rescue nil
  2122.           c.nil? ? @invcom_window[2].disable_item(0) : @invcom_window[2].refresh
  2123.           @invcom_window.each {|i| i.active = i.visible = false }
  2124.           @invcom_window[2].active  =
  2125.           @invcom_window[2].visible = true
  2126.           @item_window[1].active =  
  2127.           @equip_window_active = false
  2128.           @number_item = 0
  2129.         else
  2130.           sound_play('buzzer')
  2131.         end
  2132.         return
  2133.       end
  2134.     end
  2135.     #--------------------------------------------------------------------------
  2136.     # * Frame Update (when item window is active)
  2137.     #--------------------------------------------------------------------------
  2138.     def update_item
  2139.       if Input.trigger?(Input::B)
  2140.         sound_play('cancel')
  2141.         return $scene = Scene_Menu.new(0)
  2142.       end
  2143.       if Input.trigger?(Input::C)
  2144.         @item = @item_window[0].item
  2145.         if @item != nil
  2146.           sound_play('decision')
  2147.           if @item.is_a?(RPG::Item)
  2148.             @invcom_window.each {|i| i.active = i.visible = false }
  2149.             @invcom_window[0].active  =  
  2150.             @invcom_window[0].visible = true
  2151.             @item_window[0].active = false
  2152.           elsif @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  2153.             @invcom_window.each {|i| i.active = i.visible = false }
  2154.             @invcom_window[1].active  =  
  2155.             @invcom_window[1].visible = true
  2156.             @item_window[0].active =  
  2157.             @equip_window_active      = false
  2158.           end
  2159.         else
  2160.           sound_play('buzzer')
  2161.         end
  2162.         return
  2163.       end
  2164.     end
  2165.     #--------------------------------------------------------------------------
  2166.     # * update_unequip
  2167.     #--------------------------------------------------------------------------
  2168.     def update_unequip(type=0,siz=$game_party.limit_inventory.slots.size >=
  2169.                        $game_party.limit_inventory.max_size)
  2170.       if type == 0
  2171.         if @item.is_a?(RPG::Weapon) && !@actor.equip_fix?(0) && !siz
  2172.           @actor.equip(0, 0)
  2173.           sound_play('equip')
  2174.         elsif @item.is_a?(RPG::Armor)&& !@actor.equip_fix?(@item.kind+1) && !siz
  2175.           @actor.equip(@item.kind+1, 0)
  2176.           sound_play('equip')
  2177.         else
  2178.           sound_play('buzzer')
  2179.           @sta_window['well'].set_text(LiTTleDRAgo::FULL_INVENTORY) if siz
  2180.         end
  2181.       else
  2182.         @play_unequip = []
  2183.         (0...4).each {|i| @play_unequip[1] =
  2184.                              ($game_party.limit_inventory.slots.size >=
  2185.                               $game_party.limit_inventory.max_size)
  2186.                           unless @actor.equip_fix?(i) || @play_unequip[1]
  2187.                             @actor.equip(i, 0)
  2188.                             @play_unequip[0] = true
  2189.                           end}
  2190.         @play_unequip[0] ? sound_play('equip') : sound_play('buzzer')
  2191.         @sta_window['well'].set_text(LiTTleDRAgo::FULL_INVENTORY) if @play_unequip[1]
  2192.       end
  2193.       @item_window.each {|i| i.refresh }
  2194.       @invcom_window[3].active  =  
  2195.       @invcom_window[3].visible = false
  2196.       @sta_window['target'].visible =  
  2197.       @sta_window['target'].active  = true
  2198.     end
  2199.     #--------------------------------------------------------------------------
  2200.     # * cancel_target
  2201.     #--------------------------------------------------------------------------
  2202.     def cancel_target
  2203.       @item_window.each {|i| i.refresh }
  2204.       @item_window[0].active = true
  2205.       @sta_window['target'].visible =  
  2206.       @sta_window['target'].active  = false
  2207.       @sta_window['well'].refresh
  2208.       @equip_window_active = nil
  2209.     end
  2210.     #--------------------------------------------------------------------------
  2211.     # * update_target
  2212.     #--------------------------------------------------------------------------
  2213.     def update_target
  2214.       if Input.trigger?(Input::B)
  2215.         sound_play('cancel')
  2216.         return cancel_target
  2217.       end
  2218.       if @transfer_flag
  2219.         transfer_item_update if Input.trigger?(Input::C)
  2220.         return
  2221.       end
  2222.       if Input.trigger?(Input::A)
  2223.         @actor = $game_party.actors[@sta_window['target'].index]
  2224.         if @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  2225.           sound_play('decision')
  2226.           del = [LiTTleDRAgo::UNEQUIP_COM, LiTTleDRAgo::UNEQUIPALL_COM,
  2227.                 LiTTleDRAgo::CANCEL_COM]
  2228.           items = case @item
  2229.           when RPG::Weapon then 'Weapon'
  2230.           when RPG::Armor then VX ? eval("Vocab.armor#{@item.kind + 1}") :
  2231.                                $data_system.words.send("armor#{@item.kind + 1}")
  2232.           end
  2233.           @invcom_window[3].commands = ["#{del[0]} #{items}" ,del[1], del[2]]
  2234.           @invcom_window[3].refresh
  2235.           @invcom_window[3].active  =  
  2236.           @invcom_window[3].visible = true
  2237.           @sta_window['target'].visible =  
  2238.           @sta_window['target'].active  = false
  2239.           return @must_update = true
  2240.         end
  2241.       end
  2242.       if Input.trigger?(Input::C) || bypass_one_actor?
  2243.         @actor = $game_party.actors[@sta_window['target'].index]
  2244.         if @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  2245.           if !@actor.equippable?(@item) ||
  2246.            (@item.is_a?(RPG::Weapon) && @actor.equip_fix?(0)) ||
  2247.            (@item.is_a?(RPG::Armor) && @actor.equip_fix?(@item.kind+1))
  2248.             cancel_target if bypass_one_actor?
  2249.             return sound_play('buzzer')
  2250.           end
  2251.           sound_play('equip')
  2252.           if @item.is_a?(RPG::Weapon)
  2253.             @actor.equip(0, @item.nil? ? 0 : @item.id)
  2254.           elsif @item.is_a?(RPG::Armor)
  2255.             @actor.equip(@item.kind+1, @item.nil? ? 0 : @item.id)
  2256.           end
  2257.           @sta_window['eq'].refresh(@actor)
  2258.           @item_window[0].refresh    
  2259.           return @must_update = true
  2260.         end
  2261.         return sound_play('buzzer') if $game_party.item_number(@item.id) == 0  
  2262.         if @sta_window['target'].index == -1
  2263.           used = false
  2264.           for i in $game_party.actors
  2265.             used |= i.item_effect(@item)
  2266.           end
  2267.         end
  2268.         if @sta_window['target'].index >= 0
  2269.           target = $game_party.actors[@sta_window['target'].index]
  2270.           used = target.item_effect(@item)
  2271.         end
  2272.         if used
  2273.           sound_play('use_item')
  2274.           if @item.consumable
  2275.             $game_party.lose_item(@item.id, 1)
  2276.             @item_window[0].draw_item(@item_window[0].index)
  2277.             @item_window[0].refresh
  2278.             @sta_window['well'].refresh
  2279.           end
  2280.           @sta_window['target'].refresh
  2281.           return $scene = Scene_Gameover.new if $game_party.all_dead?
  2282.           if @item.common_event_id > 0
  2283.             $game_temp.common_event_id = @item.common_event_id
  2284.             return $scene = Scene_Map.new
  2285.           end
  2286.         end
  2287.         cancel_target if bypass_one_actor?
  2288.         sound_play('buzzer') unless used
  2289.         return
  2290.       end
  2291.     end
  2292.     #--------------------------------------------------------------------------
  2293.     # * Bypass one actor
  2294.     #--------------------------------------------------------------------------
  2295.     def bypass_one_actor?(type=0)
  2296.       return true if $game_party.actors.size == 1 && type == 1
  2297.       return true if $game_party.actors.size == 1 &&
  2298.                      @item.is_a?(RPG::Item) && type == 0
  2299.     end
  2300.     #--------------------------------------------------------------------------
  2301.     # * Combine Result
  2302.     #--------------------------------------------------------------------------
  2303.     def combine_result
  2304.       req, com = [], LiTTleDRAgo::COMBINE_ITEM
  2305.       req[0] = case @item_1
  2306.       when RPG::Item then 'Item(' + @item_1.id.to_s + ')'
  2307.       when RPG::Weapon then 'Weapon(' + @item_1.id.to_s + ')'
  2308.       when RPG::Armor then 'Armor(' + @item_1.id.to_s + ')'
  2309.       end
  2310.       req[1] = case @item_2
  2311.       when RPG::Item then 'Item(' + @item_2.id.to_s + ')'
  2312.       when RPG::Weapon then 'Weapon(' + @item_2.id.to_s + ')'
  2313.       when RPG::Armor then 'Armor(' + @item_2.id.to_s + ')'
  2314.       end
  2315.       req[3] = com[req[0] + ' + ' + req[1]] rescue nil
  2316.       req[3] = req[3] ? req[3] : com[req[1] + ' + ' + req[0]] rescue ''
  2317.       if req[3] =~ /item/i
  2318.         item = req[3].downcase.gsub(/item\(([0-9]+)\)/) { $1 }
  2319.         item = $data_items[item.to_i]
  2320.       elsif req[3] =~ /weapon/i
  2321.         item = req[3].downcase.gsub(/weapon\(([0-9]+)\)/) { $1 }
  2322.         item = $data_weapons[item.to_i]
  2323.       elsif req[3] =~ /armor/i
  2324.         item = req[3].downcase.gsub(/armor\(([0-9]+)\)/) { $1 }
  2325.         item = $data_armors[item.to_i]
  2326.       end
  2327.       return item
  2328.     end
  2329.     #--------------------------------------------------------------------------
  2330.     # * Item Number
  2331.     #--------------------------------------------------------------------------
  2332.     def item_number(item)
  2333.       case item
  2334.       when RPG::Item   then $game_party.item_number(item.id)
  2335.       when RPG::Weapon then $game_party.weapon_number(item.id)
  2336.       when RPG::Armor  then $game_party.armor_number(item.id)
  2337.       end
  2338.     end
  2339.     #--------------------------------------------------------------------------
  2340.     # * Combination
  2341.     #--------------------------------------------------------------------------
  2342.     def combination
  2343.       c = combine_result rescue nil
  2344.       number = [item_number(@item_1), item_number(@item_2)]
  2345.       if c != nil && ((@item_1 != @item_2 && number[0] > 0 && number[1] > 0) ||
  2346.         (@item_1 == @item_2 && number[0] > 1))
  2347.         number[2],text = item_number(c),LiTTleDRAgo::GET_COMB
  2348.         stack = c.is_a?(RPG::Item) ? $game_party.stack_item(c.id) : 1
  2349.         if slot.size>=limit_max && (number[2] <= 0 || (number[2]%stack) == 0) &&
  2350.           ((@item_1 != @item_2 && number[0] > 1 && number[1] > 1) ||
  2351.           (@item_1 == @item_2 && number[0] > 2))
  2352.           @sta_window['well'].refresh(LiTTleDRAgo::FULL_INVENTORY)
  2353.           return sound_play('buzzer')
  2354.         end
  2355.         $game_party.lose_item(@item_1,1)
  2356.         $game_party.lose_item(@item_2,1)
  2357.         $game_party.gain_item(c,1)
  2358.         @item_window.each {|i| i.refresh }        
  2359.         @number_item = (@number_item || 0) + 1
  2360.         @sta_window['well'].set_text(sprintf(text, c.name,@number_item))
  2361.         cancel_combination if item_number(@item_1) <= 0||item_number(@item_2) <= 0
  2362.         @must_update = true
  2363.         sound = LiTTleDRAgo::SOUND_COMBINE rescue ''
  2364.         return Audio.se_play("Audio/SE/#{sound}", 80, 100) rescue nil
  2365.       else
  2366.         return sound_play('buzzer')
  2367.       end
  2368.     end
  2369.    
  2370.     def slot()            $game_party.limit_inventory.slots    end
  2371.     def limit_max()       $game_party.limit_inventory.max_size end
  2372.     #--------------------------------------------------------------------------
  2373.     # Sound Play
  2374.     #--------------------------------------------------------------------------
  2375.     def sound_play(se)
  2376.       case se
  2377.       when 'cursor'
  2378.         VX ? Sound.play_cursor : $game_system.se_play($data_system.cursor_se)
  2379.       when 'cancel'
  2380.         VX ? Sound.play_cancel : $game_system.se_play($data_system.cancel_se)
  2381.       when 'equip'
  2382.         VX ? Sound.play_equip : $game_system.se_play($data_system.equip_se)
  2383.       when 'use_item'
  2384.         VX ? Sound.play_use_item : $game_system.se_play(@item.menu_se)
  2385.       when 'decision'
  2386.         VX ? VXA ? Sound.play_ok : Sound.play_decision :
  2387.         $game_system.se_play($data_system.decision_se)
  2388.       when 'buzzer'
  2389.         VX ? Sound.play_buzzer : $game_system.se_play($data_system.buzzer_se)
  2390.       end
  2391.     end
  2392.     #--------------------------------------------------------------------------
  2393.     # * report_no_star
  2394.     #--------------------------------------------------------------------------
  2395.     def report_missing_image(image,loc)
  2396.       return unless $DEBUG || $TEST
  2397.       bit = Bitmap.new(480, 72)
  2398.       bit.font.size = 16
  2399.       bit.font.bold = true
  2400.       bit.draw_text(4,52,472,24,
  2401.                 "Image #{image} can\'t be found at folder #{loc}.", 1)
  2402.       Graphics.freeze
  2403.       $spr = Sprite.new
  2404.       $spr.bitmap = bit
  2405.       $spr.x, $spr.y = 320-(472/2), 240-(72/2)
  2406.       $spr.z = 1000
  2407.       Graphics.transition
  2408.       3600.times  {  [Graphics,Input].each {|i| i.update }
  2409.                       break if Input.trigger?(Input::C)  }
  2410.       Graphics.freeze
  2411.       $spr.bitmap.dispose
  2412.       $spr.dispose
  2413.       Graphics.transition
  2414.     end
  2415.     #--------------------------------------------------------------------------
  2416.     # * Create Layout
  2417.     #--------------------------------------------------------------------------
  2418.     def create_layout
  2419.       $game_temp_screen = [Graphics.width,Graphics.height] if VX
  2420.       Graphics.resize_screen(640,480) if VX
  2421.       @item_lay, @btm = Sprite.new,'Item_Lay'
  2422.       @map_back = VX ? Spriteset_Map_Drago.new : Spriteset_Map.new
  2423.       @mnback = Plane.new
  2424.       cache = VX ? Cache : RPG::Cache
  2425.       unless $drg_inv_sys_no_layout || @btm == ''
  2426.         image = cache.picture(@btm) rescue ''
  2427.         if image == ''
  2428.           report_missing_image(@btm.to_s,'Pictures')
  2429.           $drg_inv_sys_no_layout,@btm = true,''
  2430.         end
  2431.       else
  2432.         @btm = ''
  2433.       end
  2434.       @item_lay.bitmap = cache.picture(@btm)
  2435.       @item_lay.z = @@z
  2436.       @btm = LiTTleDRAgo::BACKGROUND
  2437.       unless $drg_inv_sys_no_background || @btm == ''
  2438.         image = cache.picture(@btm) rescue cache.windowskin(@btm) rescue ''
  2439.         if image == ''
  2440.           report_missing_image(@btm.to_s,'Pictures')
  2441.           $drg_inv_sys_no_background,@btm = true,''
  2442.         end
  2443.       else
  2444.         @btm = ''
  2445.       end
  2446.       @mnback.bitmap = cache.picture(@btm) rescue cache.windowskin(@btm) rescue ''
  2447.       @mnback.z = @@z-1
  2448.       @mnback.opacity = 155
  2449.       @mnback.blend_type = 0
  2450.     end
  2451.     #--------------------------------------------------------------------------
  2452.     # Update Layout
  2453.     #--------------------------------------------------------------------------
  2454.     def update_layout
  2455.       unless @all_window.include?(@mnback)
  2456.         @all_window << [@mnback,@item_lay,@map_back]
  2457.         @all_window.flatten!
  2458.       end
  2459.       @mnback.visible = true
  2460.       @mnback.ox += 1
  2461.       @mnback.oy += 1
  2462.     end
  2463.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2464.     # * Aliased Method
  2465.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2466.     alias drg112_main main  unless method_defined?(:drg112_main)
  2467.     alias drg112_upd update unless method_defined?(:drg112_upd)
  2468.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2469.     # * Main Processing
  2470.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2471.     def main
  2472.       create_layout
  2473.       drg112_main
  2474.     end
  2475.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2476.     # * Frame Update
  2477.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2478.     def update
  2479.       update_layout
  2480.       drg112_upd
  2481.     end
  2482.   end #of class
  2483.   #==============================================================================
  2484.   # ** Scene_Loot
  2485.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2486.   #  Loot management scene
  2487.   #==============================================================================
  2488.   class Scene_Loot < Scene_Item
  2489.     #--------------------------------------------------------------------------
  2490.     # * MainProcessing
  2491.     #--------------------------------------------------------------------------
  2492.     define_method(:refresh){[@all_party,@all_loot].flatten.each {|i| i.refresh}}
  2493.     def main
  2494.       dis = $game_temp.slots_to_discard
  2495.       create_layout
  2496.       @all_window = [
  2497.         @help_window     = Window_Welcome.new('help'),
  2498.         @item_window     = Window_Item_Fake_Grid.new,
  2499.         @dummy1_window   = Window_Item_Fake_Grid.new(nil),
  2500.         @loot_window     = Window_Item_Fake_Grid.new(dis),
  2501.         @dummy2_window   = Window_Item_Fake_Grid.new(dis,nil),
  2502.         @party_item_window = Window_Item_Count.new($game_party.limit_inventory),
  2503.         @loot_item_window  = Window_Item_Count.new($game_temp.slots_to_discard)]
  2504.       @item_window.help_window = @help_window
  2505.       @loot_window.help_window = @help_window
  2506.       @loot_window.active = false
  2507.       @loot_window.x = 320
  2508.       @item_window.z = @loot_window.z += @@z + 1
  2509.       @dummy2_window.x = @loot_window.x
  2510.       create_input_number
  2511.       @all_window <<  @inpnum_window
  2512.       @all_dummy = [@dummy1_window,@dummy2_window]
  2513.       @all_party = [@party_item_window,@item_window,@dummy1_window]
  2514.       @all_loot = [@loot_item_window,@loot_window,@dummy2_window]
  2515.       @all_atas = [@party_item_window,@loot_item_window]
  2516.       if true
  2517.         @sprite_qw = Sprite.new
  2518.         @sprite_qw.bitmap = Bitmap.new(640,480)
  2519.         @sprite_qw.bitmap.font.name = "Sylfaen"
  2520.         @sprite_qw.bitmap.font.size = 50
  2521.         @sprite_qw.bitmap.draw_text(0,230,640,72,'  <Q',0)
  2522.         @sprite_qw.bitmap.draw_text(0,230,640,72,'W>  ',2)
  2523.         @sprite_qw.z = @item_window.z
  2524.         @sprite_qw.opacity = 0
  2525.         @all_window << @sprite_qw
  2526.       end
  2527.       @loot_item_window.x = 320
  2528.       @help_window.y = 405
  2529.       @help_window.x = -200
  2530.       @help_window.z = @item_window.z
  2531.       @item_window_x = @item_window.x
  2532.       @all_atas.each {|i| i.z = @mnback.z + 1
  2533.                             i.opacity = 180 }
  2534.       @all_party.each {|i| i.x -= 320 }
  2535.       @all_loot.each  {|i| i.x += 320 }
  2536.       @all_dummy.each {|i| i.z = @item_window.z - 100
  2537.                             i.opacity = 180 }
  2538.       unless $drg_inv_sys_no_layout
  2539.         @help_window.opacity = 0
  2540.         @help_window.contents_opacity = 0
  2541.       end
  2542.       Graphics.transition(LiTTleDRAgo::TRAN_TIME, 'Graphics/Transitions/' +
  2543.             LiTTleDRAgo::TRAN_TYPE) rescue Graphics.transition
  2544.       while $scene == self
  2545.         [Graphics,Input].each {|i| i.update}
  2546.         update
  2547.       end
  2548.       30.times { [Graphics,Input].each {|i| i.update}
  2549.                   @sprite_qw.opacity -= 10
  2550.                   @sprite_qw.zoom_x += 0.2
  2551.                   @sprite_qw.x -= 22
  2552.                   @help_window.x += 15    
  2553.                   @all_party.each {|i| i.x -= 10 }
  2554.                   @all_loot.each {|i| i.x += 10 }
  2555.                   @item_lay.opacity -= 10
  2556.                   @item_lay.zoom_x += 0.2}
  2557.       Graphics.freeze
  2558.       @all_window.each {|i| i.dispose  rescue nil }
  2559.       exit_normalize_inventory
  2560.     end
  2561.     #--------------------------------------------------------------------------
  2562.     # * update animated_position
  2563.     #--------------------------------------------------------------------------
  2564.     def update_animated_position
  2565.       @help_window.x = [@help_window.x+10,0].min
  2566.       @help_window.contents_opacity = [@help_window.contents_opacity+15,255].max
  2567.       if @party_item_window.x == 0
  2568.         @sprite_qw.opacity = [@sprite_qw.opacity+15,255].min
  2569.         if @sprite_qw.oy < 50 && !@below
  2570.           @sprite_qw.oy += 1
  2571.           @below = true if @sprite_qw.oy >= 50
  2572.         elsif @sprite_qw.oy > 0 && @below
  2573.           @sprite_qw.oy -= 1
  2574.           @below = false if @sprite_qw.oy <= 0
  2575.         end
  2576.       end
  2577.       @all_party.each_with_index {|i,s|  i.x = [i.x + 10,
  2578.                                   s == 0 ? 0 : @item_window_x].min }
  2579.       @all_loot.each_with_index {|i,s| i.x = [i.x - 10,
  2580.                           320 + (s == 0 ? 0 : (100-@item_window_x).abs)].max }
  2581.     end
  2582.     #--------------------------------------------------------------------------
  2583.     # * update Frame
  2584.     #--------------------------------------------------------------------------
  2585.     def update
  2586.       update_scene_loot
  2587.     end
  2588.    
  2589.     def update_scene_loot
  2590.       update_animated_position
  2591.       update_layout
  2592.       if Input.trigger?(Input::B)
  2593.         sound_play('cancel')
  2594.         if @inpnum_window[0].active
  2595.           @inpnum_window.each {|i| i.active = i.visible = false }
  2596.           @item_active = @loot_active = false
  2597.           return
  2598.         end
  2599.         if !$game_temp.slots_to_discard.slots.empty?
  2600.           $game_temp.slots_to_discard.slots.each { |slot|
  2601.             $game_party.reduce_item(slot.item, slot.amount) }
  2602.           $game_temp.slots_to_discard.clear
  2603.         end
  2604.         return  $scene = Scene_Map.new
  2605.       end
  2606.       if @inpnum_window[0].active
  2607.         #@inpnum_window[0].update
  2608.         check_max_input
  2609.       end
  2610.       if @item_window.active
  2611.         @item_window.update unless @item_active
  2612.         return update_item
  2613.       end
  2614.       if @loot_window.active
  2615.         @loot_window.update unless @loot_active
  2616.         return update_loot
  2617.       end
  2618.     end
  2619.     #--------------------------------------------------------------------------
  2620.     # * Update Item Window
  2621.     #--------------------------------------------------------------------------
  2622.     def update_item
  2623.       if Input.trigger?(Input::C)
  2624.         @inpnum_window[0].active ? item_to_loot_value : item_to_loot
  2625.         return
  2626.       end
  2627.       if Input.repeat?(Input::R)
  2628.         @item_window.active = false
  2629.         @loot_window.active = true
  2630.         @loot_window.index = 0
  2631.         @item_window.index = -1
  2632.         sound_play('decision')
  2633.         return
  2634.       end
  2635.     end
  2636.     #--------------------------------------------------------------------------
  2637.     # * Update Loot Window
  2638.     #--------------------------------------------------------------------------
  2639.     def update_loot
  2640.       if Input.trigger?(Input::C)
  2641.         @inpnum_window[0].active ? loot_to_item_value : loot_to_item
  2642.         return
  2643.       end
  2644.       if Input.repeat?(Input::L)
  2645.         @item_window.active = true
  2646.         @loot_window.active = false
  2647.         @loot_window.index = -1
  2648.         @item_window.index = 0
  2649.         sound_play('decision')
  2650.         return
  2651.       end
  2652.     end
  2653.     #--------------------------------------------------------------------------
  2654.     # * item_to_loot
  2655.     #--------------------------------------------------------------------------
  2656.     def item_to_loot
  2657.       item = @item_window.item
  2658.       return if item.nil?
  2659.       slot = @item_window.inventory.slot(item)
  2660.       type, id, @number_item = slot.item_type, slot.item_id, slot.amount
  2661.       return sound_play('buzzer') if LiTTleDRAgo::NONDISCARD[type].include?(item.id)
  2662.       sound_play('decision')
  2663.       @inpnum_window.each {|i| i.active = i.visible = true }
  2664.       @inpnum_window[0].number = @number_item
  2665.       @item_active = true
  2666.     end
  2667.     #--------------------------------------------------------------------------
  2668.     # * item_to_loot_value
  2669.     #--------------------------------------------------------------------------
  2670.     def item_to_loot_value
  2671.       item = @item_window.item
  2672.       return if item.nil?
  2673.       @item_active = false
  2674.       slot = @item_window.inventory.slot(item)
  2675.       type, id, n = slot.item_type, slot.item_id, @inpnum_window[0].number
  2676.       sound_play('decision')
  2677.       n.times {  $game_party.limit_inventory.remove_item(type, id, 1)
  2678.                  $game_temp.slots_to_discard.add_item(type, id, 1) }
  2679.       @inpnum_window.each {|i| i.active = i.visible = false }
  2680.       refresh
  2681.     end
  2682.     #--------------------------------------------------------------------------
  2683.     # * loot_to_item
  2684.     #--------------------------------------------------------------------------
  2685.     def loot_to_item
  2686.       item = @loot_window.item
  2687.       return if item.nil?
  2688.       slot = @loot_window.inventory.slot_reverse(item)
  2689.       type, id, @number_item = slot.item_type, slot.item_id, slot.amount
  2690.       sound_play('decision')
  2691.       @inpnum_window.each {|i| i.active = i.visible = true }
  2692.       @inpnum_window[0].number = @number_item
  2693.       @loot_active = true
  2694.     end
  2695.     #--------------------------------------------------------------------------
  2696.     # * loot_to_item_value
  2697.     #--------------------------------------------------------------------------
  2698.     def loot_to_item_value
  2699.       item = @loot_window.item
  2700.       return if item.nil?
  2701.       @loot_active = false
  2702.       slot = @loot_window.inventory.slot_reverse(item)
  2703.       type, id, n = slot.item_type, slot.item_id, @inpnum_window[0].number
  2704.       n.times {
  2705.       oth = @item_window.inventory.slots[$game_party.limit_inventory.max_size-1]
  2706.       oth = oth.nil? ? 0 : oth.amount
  2707.       stack = item.is_a?(RPG::Item) ? $game_party.stack_item(item.id) : 1
  2708.       slots = $game_party.limit_inventory.slots
  2709.       limit_max = $game_party.limit_inventory.max_size
  2710.       unless slots.size >= limit_max && oth >= stack
  2711.         sound_play('decision')
  2712.         $game_party.limit_inventory.add_item(type, id, 1)
  2713.         $game_temp.slots_to_discard.remove_item(type, id, 1)
  2714.       else
  2715.         sound_play('buzzer')
  2716.       end }
  2717.       @inpnum_window.each {|i| i.active = i.visible = false }
  2718.       refresh
  2719.     end
  2720.   end
  2721. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement