CrowMakerVX

LootContainers1.0

May 2nd, 2014
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 53.59 KB | None | 0 0
  1. ################################################################################
  2. #                         LOOT CONTAINERS
  3. #                            By: Ixfuru
  4. ################################################################################
  5. # This script enables you to create Containers.  Containers are objects which
  6. # hold items which the player can find.  There is a lot of customization you can
  7. # do to this script, and with it, you can make as many containers as you want
  8. # to.  The first step for you to use this script will be to go into the
  9. # Containers module and create containers under the 'CONTAINERS' constant.
  10. #
  11. # There you can give the container a name, capacity, create its initial contents
  12. # and gold, as well as several other settings.   Once you create the container,
  13. # Then go to the script call command of any event and call:
  14. #
  15. #                $scene = Scene_Container(x)  
  16. #
  17. # With 'x' being the ID of the container you created in the CONTAINER hash.
  18. #
  19. # For further script calls related to the system, see the section titled:
  20. #                  'Extended Script Calls'
  21. #
  22. #-------------------------------------------------------------------------------
  23. # Make sure you follow the instructions carefully for best results, and if you
  24. # have any trouble, be sure to contact me in the RPGMakerVX.net forums or
  25. # the RMRK.net forums for assistance.  You can either post in the topic where
  26. # you found the script or you contact me via personal message.
  27. #-------------------------------------------------------------------------------
  28. # This script is non-commercially free.  If you choose to use it in a commercial
  29. # project, you must receive my (Ixfuru's) permission and you either way,
  30. # I must be creditted.
  31. #-------------------------------------------------------------------------------
  32. #===============================================================================
  33.  
  34. #===============================================================================
  35. #                      Module Containers
  36. #===============================================================================
  37. module Ixfuru
  38.   module Containers
  39.    
  40.     ############################################################################
  41.     #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  42.     #                             CREATING A CONTAINER
  43.     #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  44.     ############################################################################
  45.     # Below is the CONTAINERS hash.  In it, you will set up all the properties
  46.     # of the container.   There are some settings which are NECESSARY and some
  47.     # that aren't.  For instance, if your container is not 'lockable' you don't
  48.     # have to have the setting for :locked or :key.  
  49.     #
  50.     # Here is a list of settings your container MUST HAVE:
  51.     #
  52.     #           :name
  53.     #           :capacity
  54.     #           :contents
  55.     #           :lockable
  56.     #           :gold
  57.     #
  58.     # It doesn't matter what order you place them in, as long as they are
  59.     # present in your container.  If not, your container will give an
  60.     # error message when you try to access it.
  61.     #
  62.     # Here is a list of optional settings your container can have.
  63.     #
  64.     #           :graphic
  65.     #           :opening_se
  66.     #           :closing_se
  67.     #           :locked (:key)
  68.     #
  69.     # If you do not provide these settings, the system will assume you want to
  70.     # use the default settings for these.  However, it is important to note that
  71.     # if you place a :locked setting then you MUST HAVE a :key setting.
  72.     #---------------------------------------------------------------------------
  73.     #
  74.     # So, to create the container, follow this formula:
  75.     #
  76.     #       container_id => {settings => properties}
  77.     #
  78.     # For example:
  79.     #
  80.     #         3 => {:name => "Container",
  81.     #               :capacity => 8,
  82.     #               :contents => [],
  83.     #               :gold => 44,
  84.     #               :lockable => true},
  85.     #
  86.     # In the example, if you were to call $scene = Scene_Container.new(3),
  87.     # this container would be opened in the new scene.
  88.     #
  89.     #---------------------------------------------------------------------------
  90.     #
  91.     # The following is a list of all the settings with a description of each,
  92.     # including what the system expects to find for the properties of each.
  93.     #
  94.     # :name - This is just a string, double-quoted ("") which will be used to
  95.     #         display to the player what container he/she is in.  You can have
  96.     #         multiple containers with the same name, it's basically just for
  97.     #         looks.  Here are some examples of good :name settings:
  98.     #
  99.     #               "Box", "Sack", "Bag", "Crate", "Urn", etc.
  100.     #                
  101.     #                                   ***
  102.     #
  103.     # :capacity - This value should be an integer, at least one, but there is no
  104.     #             limit to how big :capacity can be.  :capacity sets how many
  105.     #             items can be placed into the container before it is full and
  106.     #             can no longer accept more items.
  107.     #
  108.     #                                   ***
  109.     #
  110.     # :contents - This is an array, holding the items (if any) which are to be
  111.     #             in the container at the start of the game.  This must be
  112.     #             set up precisely to the rules found below.  Note that if you
  113.     #             want to start out with an empty container, simply use [] as the
  114.     #             properties for :contents.
  115.     #            
  116.     #             Each item in the :contents array is made up of a two-element
  117.     #             inner array:
  118.     #
  119.     #                          [item_type, item_id]
  120.     #
  121.     #             item_type : 0 for item, 1 for weapon, 2 for armor
  122.     #             item_id   : the database ID of the item you wish to place in
  123.     #                         the container at startup.
  124.     #
  125.     #             So by placing:
  126.     #
  127.     #                          [2, 21]
  128.     #
  129.     #             We are saying, place the armor with the ID of 21 in the database
  130.     #             into the chest at start up. So, a full :contents property can
  131.     #             be as many of these entries as you prefer.  Here's an example
  132.     #             of a contents property with five starting items.
  133.     #
  134.     #                      [[0, 2], [1, 4], [0, 6], [2, 2], [2, 5]]
  135.     #
  136.     #             In the above example, the container would start out with
  137.     #             database items 2 and 6, database weapon 4 and armors 2 and 5.
  138.     #
  139.     #             Conversely, you can use a string as the argument instead of
  140.     #             an array.  The string must say:
  141.     #
  142.     #                           "MFx"
  143.     #
  144.     #             With X being the id of the item pool from which you want to
  145.     #             get the item to be placed.  By using a string instead of an
  146.     #             array, you are telling the system to pick an item at random
  147.     #             from the TREASURES hash in the 'Creating Manifested
  148.     #             Treasures' settings found below the container's settings.
  149.     #             So, by calling: "MF2", you are saying, get the item from
  150.     #             the TREASURES pool with an ID of 2.  For more on this, skip
  151.     #             to that section for details on how to set up the item pools
  152.     #             for use with :contents string elements.
  153.     #
  154.     #                                   ***
  155.     #
  156.     # :gold - This is the amount of gold you want the container to start out with.
  157.     #         You can start it out as 0, or as much as you want.  It just needs
  158.     #         to be an integer for a preset amount.
  159.     #
  160.     #          Conversely, you can use a string in order to pull a random
  161.     #          number of gold from the GOLDS hash in the section titled
  162.     #          'Creating Manifested Treasures'.  Basically, this involves you
  163.     #          placing the string:
  164.     #
  165.     #                         "Gx"
  166.     #
  167.     #          With 'x' being the ID of the gold pool you provide in the GOLDS
  168.     #          hash.  For further details, see the settings of that section.
  169.     #
  170.     # :lockable - This is a boolean value (true or false) which tells whether or
  171.     #             not the container can be locked.  If a container is locked,
  172.     #             the player must have a key in order to unlock it or lock it
  173.     #             again.  
  174.     #
  175.     # :graphic - This is a two-element array:
  176.     #
  177.     #           [graphic_when_locked, graphic_when_unlocked]
  178.     #
  179.     #           graphic_when_locked : [filename, index]
  180.     #           graphic_when_unlocked : [filename, index]
  181.     #
  182.     #           filename : the name of the graphic in the "Graphics/Characters/"
  183.     #                      folder of your project.
  184.     #           index : the index on the character sheet
  185.     #
  186.     #           So, the :graphic array should look like this:
  187.     #
  188.     #                   [["Chest", 3], ["Chest", 5]]
  189.     #
  190.     #           In the above example, the container would display Chest-3 when
  191.     #           locked, and Chest-5 when unlocked.
  192.     #
  193.     #           The graphic setting is optional, and if you don't set it, it will
  194.     #           not use a graphic in the container.  The setting is basically for
  195.     #           looks.  It has no bearing in functionality.  But if you use a
  196.     #           graphic, it will be displayed next to the name of the container
  197.     #           during the scene.
  198.     #
  199.     # :opening_se/:closing_se - This setting tells the system what sound effect to
  200.     #                           play when the container is opening and closing.
  201.     #                           It is a three element array:
  202.     #
  203.     #                           [filename, volume, pitch]
  204.     #
  205.     #                           filename : the file from your "Audio/SE" folder
  206.     #                           volumne : how loud the sound should be
  207.     #                           pitch : the pitch of the sound effect when played
  208.     #        
  209.     # :locked - This setting is a boolean (true or false).  It tells the system
  210.     #           whether or not the container should be locked or not at startup.
  211.     #           If a container is locked, you will be unable to see the contents
  212.     #           of the container until it is unlocked.  If you set this to true
  213.     #           YOU MUST also give a ':key' setting in order to unlock it at
  214.     #           runtime.
  215.     #
  216.     # :key - This is the database ID of the item you wish to use for unlocking/
  217.     #        locking the container.
  218.     #
  219.     #===========================================================================
  220.     #
  221.     #
  222.    
  223.     CONTAINERS = {# Don't delete that.
  224.    
  225.     0 => {:name => "Box",
  226.           :capacity => 5,
  227.           :contents => [[0, 12], [0, 4], [1, 8], [2, 3], [0, 25]],
  228.           :lockable => false,
  229.           :graphic => [["!Chest", 6], ["!Chest", 6]],
  230.           :gold => 156,
  231.           :opening_se => ["Chest", 80, 100],
  232.           :closing_se => ["Close1", 80, 100],
  233.           :locked => false,
  234.           :key => nil},
  235.          
  236.     1 => {:name => "Chest",
  237.           :capacity => 10,
  238.           :contents => ["MF0", "MF0", "MF1", "MF2", "MF3", "MF4"],
  239.           :lockable => true,
  240.           :graphic => [["!Chest", 4], ["!Chest", 4]],
  241.           :gold => "G3",
  242.           :locked => true,
  243.           :key => 25},
  244.          
  245.     }
  246.    
  247.     ############################################################################
  248.     #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  249.     ############################################################################
  250.    
  251.     # The text you want to be displayed if the container is locked
  252.     LOCKED_TEXT = "LOCKED!"
  253.    
  254.     # The text color of LOCKED_TEXT when displayed
  255.     LOCKED_COLOR = 2
  256.    
  257.     # The button which will perform locking/unlocking procedure
  258.     LOCK_BUTTON = Input::Y
  259.    
  260.     # The SE [filename, volume, pitch] which will played when you lock/unlock the
  261.     # container
  262.     LOCK_SOUND = ["Key", 80, 100]
  263.    
  264.     # The index of the icon you wan to use in the gold windows
  265.     GOLD_LOOT_INDEX = 147
  266.    
  267.     # The text you want to display when a slot of the container has nothing in it
  268.     LOOT_EMPTY_TEXT = "-EMPTY-"
  269.    
  270.     # The text you want to display when the container is locked and you can't
  271.     # see the contents.
  272.     HIDDEN_LOOT_TEXT = "?????"
  273.    
  274.     # The button you want to take ALL the contents/gold of the container
  275.     TAKE_ALL_BUTTON = Input::A
  276.    
  277.     # This sets which buttons you wish to control how you jump from one
  278.     # window to the next in the scene.  If you use 0, you will push Q and W
  279.     # in order to change the active windows.  If you use 1, you'll use the
  280.     # arrow keys right and left instead.
  281.     WINDOW_CONTROL_INPUT = 1  
  282.    
  283.     # The sound you want to play when you take a single item from the container
  284.     # [filename, volume, pitch]
  285.     TAKE_SOUND = ["Decision2", 80, 100]
  286.    
  287.     # The sound played when you modify gold in the gold windows
  288.     # [filename, volume, pitch]
  289.     GOLD_SOUND = ["Shop", 80, 100]
  290.    
  291.     # The sound played when you Take ALL of the items in the container/gold window
  292.     TAKE_ALL_SOUND = ["Sword3", 80, 100]
  293.    
  294.     # The sound played when you place an item from the party into the container
  295.     GIVE_SOUND = ["Close2", 80, 100]
  296.    
  297.     # The sound played when the container opens (if not set in the settings)
  298.     DEFAULT_OPENING_SE = ["Chest", 80, 100]
  299.    
  300.     # The sound played when the container closes (if not set in the settings)
  301.     DEFAULT_CLOSING_SE = ["Close1", 80, 100]
  302.    
  303.   end
  304.  
  305.   #=============================================================================
  306.   #                       Module Manifest Treasure
  307.   #=============================================================================
  308.   module ManifestTreasure
  309.    
  310.     ############################################################################
  311.     #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  312.     #                          Creating Manifested Treasures
  313.     ############################################################################
  314.     # Manifested treasures are treasures chosen from a pool you create.  This will
  315.     # make it so that even you, as the creator, can't say exactly what is in the
  316.     # containers you create.  When you place "MFx" as a :content entry in the
  317.     # CONTAINERS hash above, the system will sort through the TREASURES hash,
  318.     # find the one with the ID of x and choose an item from the pools given.
  319.     #
  320.     # So to create one, you need to use this formula:
  321.     #
  322.     #           treasure_id => {:items => [item_ids],
  323.     #                           :weapons => [weapon_ids],
  324.     #                           :armors => [armor_id]},
  325.     #
  326.     # You don't have to have all three (:items, :weapons, :armors) keys in the
  327.     # hash.  If you just wnat the pool to render items, just put the :items one.
  328.     # for the item_ids/weapon_ids/armor_ids place the database ID of the item
  329.     # you want to be placed into the pool
  330.     #
  331.     # For example:
  332.     #
  333.     #            5 => {:items => [4, 6, 7, 8],
  334.     #                  :armors => [12, 25]},
  335.     #
  336.     # In the above example, the pool will consist of items 4, 6, 7, and 8, as wells
  337.     # as armors 12 and 25.  And to choose from this pool, you would place "MF5"
  338.     # in the :contents setting of a container.
  339.     ############################################################################
  340.    
  341.     TREASURES = {
  342.    
  343.     # Curing Rations
  344.     0 => {:items => [5, 6, 7, 8]},
  345.    
  346.     # Potions
  347.     1 => {:items => [1, 2, 3, 4]},
  348.      
  349.     # Weapons
  350.     2 => {:weapons => [1, 2, 3, 4, 5]},
  351.        
  352.     # Armors
  353.     3 => {:armors => [1, 2, 3, 4, 5]},
  354.    
  355.     # Mixed Bag
  356.     4 => {:items => [1, 2, 3, 4, 5, 6, 7, 8],
  357.           :weapons => [1, 2, 3, 4, 5],
  358.           :armors => [1, 2, 3, 4, 5]},
  359.    
  360.     }
  361.    
  362.     #===========================================================================
  363.     # Manifested gold acts much the same as the manifested treasures pool.  
  364.     # The difference is that you call it by placing "Gx" in the :gold setting
  365.     # of a container.  And you only need to provide a low and high amount in the
  366.     # pools.
  367.     #
  368.     # For example:
  369.     #
  370.     # 3 => [52, 88],
  371.     #
  372.     # The above example would place gold amount between 52 and 88 inside the
  373.     # container and you would call the pool by using "G3" in the :gold setting
  374.     # of a container you create.
  375.     #===========================================================================
  376.    
  377.     GOLDS = {
  378.    
  379.     0 => [1, 10],
  380.     1 => [11, 25],
  381.     2 => [26, 50],
  382.     3 => [51, 100],
  383.     4 => [101, 200],
  384.     5 => [201, 400],
  385.     6 => [401, 800],
  386.     7 => [801, 1600],
  387.    
  388.     }
  389.    
  390.   end
  391.  
  392.   ##############################################################################
  393.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  394.   #                      Extended Script Calls
  395.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  396.   # All containers can be called with the script call:
  397.   #
  398.   #               $containers[x]
  399.   #
  400.   # With 'x' being the ID of the container.
  401.   #
  402.   # There are a number of procedures you can use to access and perform actions
  403.   # on the containers:
  404.   #-----------------------------------------------------------------------------
  405.   #                             ***
  406.   #          $containers[x].add_gold(amount, true)
  407.   #
  408.   #             add amount to container x's gold
  409.   #-----------------------------------------------------------------------------
  410.   #                 $containers[x].full?
  411.   #
  412.   #             checks to see if container x is full
  413.   #-----------------------------------------------------------------------------
  414.   #                             ***
  415.   #                $containers[x].add_to_contents(item, true)
  416.   #
  417.   #   item : database item/weapon/armor you want to add to container x
  418.   #-----------------------------------------------------------------------------
  419.   #                             ***
  420.   #                 $containers[x].locked?
  421.   #
  422.   #             checks to see if container x is locked
  423.   #-----------------------------------------------------------------------------
  424.   #                             ***
  425.   #                 $containers[x].add_capacity(amount)
  426.   #
  427.   #               adds amount to container x capacity
  428.   #-----------------------------------------------------------------------------                
  429.   #                             ***
  430.   #                $containers[x].decrease_capacity(amount)
  431.   #            
  432.   #           reduces the space of container[x] by amount
  433.   #-----------------------------------------------------------------------------
  434.   #                             ***
  435.   #                 $containers[x].lock(true)
  436.   #
  437.   #                       locks container[x]
  438.   #-----------------------------------------------------------------------------
  439.   #                             ***
  440.   #                 $containers[x].unlock
  441.   #                    
  442.   #                   unlocks container x
  443.   #-----------------------------------------------------------------------------
  444.  
  445.   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  446.   #                DON'T EDIT FURTHER!  DON'T EDIT FURTHER!
  447.   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  448.  
  449.   #=============================================================================
  450.   #                       Module Regexp
  451.   #=============================================================================
  452.   module Regexp
  453.    
  454.     NO_CONTAINER = /<no_container>/i
  455.     MANIFEST_TREASURE = /MF(\d+)/i
  456.     MANIFEST_GOLD = /G(\d+)/i
  457.    
  458.   end
  459.  
  460. end
  461.  
  462. ################################################################################
  463. #*******************************************************************************
  464. #                          RPG::BaseItem
  465. ################################################################################
  466. class RPG::BaseItem
  467.  
  468.   #-----------------------------------------------------------------------------
  469.   # No Container
  470.   #-----------------------------------------------------------------------------
  471.   def no_container
  472.     self.note.split(/[\r\n]/).each { |line|
  473.     case line
  474.     when Ixfuru::Regexp::NO_CONTAINER
  475.       return true
  476.     end
  477.     }
  478.     return false
  479.   end
  480.  
  481. end
  482.  
  483. ################################################################################
  484. #*******************************************************************************
  485. #                         Scene Title
  486. ################################################################################
  487. class Scene_Title < Scene_Base
  488.  
  489.   #--------------------------------------------------------------------------
  490.   # * Create Game Objects (Aliased)*
  491.   #--------------------------------------------------------------------------
  492.   alias ixfuru_containers_create_game_objects create_game_objects unless $@
  493.   def create_game_objects
  494.     ixfuru_containers_create_game_objects
  495.     $containers = {}
  496.   end
  497.  
  498. end
  499.  
  500. ################################################################################
  501. #*******************************************************************************
  502. #                        Scene File
  503. ################################################################################
  504. class Scene_File < Scene_Base
  505.  
  506.    #--------------------------------------------------------------------------
  507.   # * Write Save Data (Aliased)*
  508.   #     file : write file object (opened)
  509.   #--------------------------------------------------------------------------
  510.   alias ixfuru_containers_write write_save_data unless $@
  511.   def write_save_data(file)
  512.     ixfuru_containers_write(file)
  513.     Marshal.dump($containers, file)
  514.   end
  515.  
  516.   #--------------------------------------------------------------------------
  517.   # * Read Save Data (OVERWRITTEN!)
  518.   #     file : file object for reading (opened)
  519.   #--------------------------------------------------------------------------
  520.   def read_save_data(file)
  521.     characters           = Marshal.load(file)
  522.     Graphics.frame_count = Marshal.load(file)
  523.     @last_bgm            = Marshal.load(file)
  524.     @last_bgs            = Marshal.load(file)
  525.     $game_system         = Marshal.load(file)
  526.     $game_message        = Marshal.load(file)
  527.     $game_switches       = Marshal.load(file)
  528.     $game_variables      = Marshal.load(file)
  529.     $game_self_switches  = Marshal.load(file)
  530.     $game_actors         = Marshal.load(file)
  531.     $game_party          = Marshal.load(file)
  532.     $game_troop          = Marshal.load(file)
  533.     $game_map            = Marshal.load(file)
  534.     $game_player         = Marshal.load(file)
  535.      $containers         = Marshal.load(file)
  536.     if $game_system.version_id != $data_system.version_id
  537.       $game_map.setup($game_map.map_id)
  538.       $game_player.center($game_player.x, $game_player.y)
  539.     end
  540.   end
  541.  
  542. end
  543.  
  544. ################################################################################
  545. #*******************************************************************************
  546. #                         Container
  547. ################################################################################
  548. class Container
  549.  
  550.   attr_reader :container_id
  551.   attr_accessor :name
  552.   attr_accessor :capacity
  553.   attr_accessor :contents
  554.   attr_accessor :gold
  555.   attr_accessor :locked
  556.   attr_accessor :lockable
  557.   attr_accessor :key
  558.  
  559.   def initialize(container_id)
  560.     @container_id = container_id
  561.     setup
  562.   end
  563.  
  564.   #-----------------------------------------------------------------------------
  565.   # Setup
  566.   #-----------------------------------------------------------------------------
  567.   def setup
  568.     base = Ixfuru::Containers::CONTAINERS[@container_id]
  569.     @name = base[:name]
  570.     @capacity = base[:capacity]
  571.     @contents = base[:contents]
  572.     @lockable = base[:lockable]
  573.     @locked = base[:locked].nil? ? false : base[:locked]
  574.     @key = base[:key].nil? ? nil : base[:key]
  575.     @graphic = base[:graphic].nil? ? [] : base[:graphic]
  576.     @opening_se = base[:opening_se].nil? ? Ixfuru::Containers::DEFAULT_OPENING_SE : base[:opening_se]
  577.     @closing_se = base[:closing_se].nil? ? Ixfuru::Containers::DEFAULT_CLOSING_SE : base[:closing_se]
  578.     @gold = base[:gold].nil? ? 0 : base[:gold]
  579.     update_manifests
  580.     $containers[@container_id] = self
  581.   end
  582.  
  583.   #-----------------------------------------------------------------------------
  584.   # Update Manifests
  585.   #-----------------------------------------------------------------------------
  586.   def update_manifests
  587.     for i in 0...@contents.size
  588.       next unless @contents[i].is_a?(String)
  589.       next unless Ixfuru::Regexp::MANIFEST_TREASURE =~ @contents[i]
  590.       t = $1.to_i
  591.       picks = []
  592.       treasures = Ixfuru::ManifestTreasure::TREASURES[t]
  593.       if treasures.has_key?(:items)
  594.         for item in treasures[:items]
  595.           picks.push([0, item])
  596.         end
  597.       end
  598.       if treasures.has_key?(:weapons)
  599.         for weapon in treasures[:weapons]
  600.           picks.push([1, weapon])
  601.         end
  602.       end
  603.       if treasures.has_key?(:armors)
  604.         for armor in treasures[:armors]
  605.           picks.push([2, armor])
  606.         end
  607.       end
  608.       @contents[i] = picks[rand(picks.size)]
  609.     end
  610.     if @gold.is_a?(String) && Ixfuru::Regexp::MANIFEST_GOLD =~ @gold
  611.       g = $1.to_i
  612.       amounts = []
  613.       golds = Ixfuru::ManifestTreasure::GOLDS[g]
  614.       for a in golds[0]..golds[1]
  615.         amounts.push(a)
  616.       end
  617.       @gold = amounts[rand(amounts.size)]
  618.     end
  619.   end
  620.  
  621.   #-----------------------------------------------------------------------------
  622.   # Open
  623.   #-----------------------------------------------------------------------------
  624.   def open
  625.     se = @opening_se
  626.     RPG::SE.new(se[0], se[1], se[2]).play
  627.   end
  628.  
  629.   #-----------------------------------------------------------------------------
  630.   # Close
  631.   #-----------------------------------------------------------------------------
  632.   def close
  633.     se = @closing_se
  634.     RPG::SE.new(se[0], se[1], se[2]).play
  635.   end
  636.  
  637.   #-----------------------------------------------------------------------------
  638.   # Character
  639.   #-----------------------------------------------------------------------------
  640.   def character
  641.     return nil if @graphic.empty?
  642.     return @graphic[0] if locked?
  643.     return @graphic[1]
  644.   end
  645.  
  646.   #-----------------------------------------------------------------------------
  647.   # Current Contents
  648.   #-----------------------------------------------------------------------------
  649.   def current_contents
  650.     result = []
  651.     return result if @contents.empty?
  652.     for content in @contents
  653.       case content[0]
  654.       when 0 # item
  655.         result.push($data_items[content[1]])
  656.       when 1 # weapon
  657.         result.push($data_weapons[content[1]])
  658.       when 2 # Armor
  659.         result.push($data_armors[content[1]])
  660.       end
  661.     end
  662.     return result
  663.   end
  664.  
  665.   #-----------------------------------------------------------------------------
  666.   # Toggler
  667.   #
  668.   # direction : button to jump left or right
  669.   #-----------------------------------------------------------------------------
  670.   def toggler(direction)
  671.     case Ixfuru::Containers::WINDOW_CONTROL_INPUT
  672.     when 0
  673.       case direction
  674.       when 0 # left
  675.         return Input::L
  676.       when 1 # right
  677.         return Input::R
  678.       end
  679.     when 1
  680.       case direction
  681.       when 0 # left
  682.         return Input::LEFT
  683.       when 1 # right
  684.         return Input::RIGHT
  685.       end
  686.     end
  687.   end
  688.  
  689.   #-----------------------------------------------------------------------------
  690.   # Add Gold
  691.   #-----------------------------------------------------------------------------
  692.   def add_gold(amount, bypass = false)
  693.     if bypass
  694.       @gold += amount
  695.       return
  696.     end
  697.     if $game_party.gold - amount >= 0
  698.       play_gold
  699.       @gold += amount
  700.       $game_party.lose_gold(amount)
  701.     end
  702.   end
  703.  
  704.   #-----------------------------------------------------------------------------
  705.   # Take Gold
  706.   #-----------------------------------------------------------------------------
  707.   def take_gold(amount)
  708.     if @gold - amount >= 0
  709.       play_gold
  710.       @gold -= amount
  711.       $game_party.gain_gold(amount)
  712.     end
  713.   end
  714.  
  715.   #-----------------------------------------------------------------------------
  716.   # Gold Amount
  717.   #-----------------------------------------------------------------------------
  718.   def gold_amount
  719.     return @gold
  720.   end      
  721.  
  722.   #-----------------------------------------------------------------------------
  723.   # Take All Button
  724.   #-----------------------------------------------------------------------------
  725.   def take_all_button
  726.     return Ixfuru::Containers::TAKE_ALL_BUTTON
  727.   end
  728.  
  729.   #-----------------------------------------------------------------------------
  730.   # Locked?
  731.   #-----------------------------------------------------------------------------
  732.   def locked?
  733.     return false if !@lockable
  734.     return @locked
  735.   end
  736.  
  737.   #-----------------------------------------------------------------------------
  738.   # Full?
  739.   #-----------------------------------------------------------------------------
  740.   def full?
  741.     return true if @contents.size == @capacity
  742.     return false
  743.   end
  744.  
  745.   #-----------------------------------------------------------------------------
  746.   # Add Capacity
  747.   #-----------------------------------------------------------------------------
  748.   def add_capacity(space)
  749.     @capacity += space
  750.   end
  751.  
  752.   #-----------------------------------------------------------------------------
  753.   # Decrease Capacity
  754.   #-----------------------------------------------------------------------------
  755.   def decrease_capacity(space)
  756.     @capacity -= space
  757.   end
  758.  
  759.   #-----------------------------------------------------------------------------
  760.   # Take All
  761.   #-----------------------------------------------------------------------------
  762.   def take_all
  763.     return if @contents.empty?
  764.     play_take_all
  765.     for content in current_contents
  766.       $game_party.gain_item(content, 1)
  767.     end
  768.     @contents.clear
  769.   end
  770.  
  771.   #-----------------------------------------------------------------------------
  772.   # Play Take All
  773.   #-----------------------------------------------------------------------------
  774.   def play_take_all
  775.     se = Ixfuru::Containers::TAKE_ALL_SOUND
  776.     RPG::SE.new(se[0], se[1], se[2]).play
  777.   end
  778.  
  779.   #-----------------------------------------------------------------------------
  780.   # Add To Contents
  781.   #
  782.   # When adding gold to the contents, you need to pass a string "gold" appended
  783.   # with the amount you wish to add, "gold456" would add 456 gold.
  784.   #-----------------------------------------------------------------------------
  785.   def add_to_contents(item, bypass = false)
  786.     i = content_item(item)
  787.     if bypass
  788.       @contents.push(i)
  789.       return
  790.     end
  791.     play_give
  792.     @contents.push(i)
  793.     $game_party.lose_item(item, 1)
  794.   end
  795.  
  796.   #-----------------------------------------------------------------------------
  797.   # Content Item
  798.   #-----------------------------------------------------------------------------
  799.   def content_item(item)
  800.     case item
  801.     when RPG::Item
  802.       i = 0
  803.       a = item.id
  804.     when RPG::Weapon
  805.       i = 1
  806.       a = item.id
  807.     when RPG::Armor
  808.       i = 2
  809.       a = item.id
  810.     end
  811.     return [i, a]
  812.   end
  813.  
  814.   #-----------------------------------------------------------------------------
  815.   # Play Lock
  816.   #-----------------------------------------------------------------------------
  817.   def play_lock
  818.     se = Ixfuru::Containers::LOCK_SOUND
  819.     RPG::SE.new(se[0], se[1], se[2]).play
  820.   end
  821.  
  822.   #-----------------------------------------------------------------------------
  823.   # Lock
  824.   #-----------------------------------------------------------------------------
  825.   def lock(bypass = false)
  826.     return if locked?
  827.     return if !@lockable
  828.     if bypass
  829.       @locked = true
  830.       return
  831.     end
  832.     k = container_key
  833.     return if !$game_party.has_item?(k)
  834.     play_lock
  835.     @locked = true
  836.   end
  837.  
  838.   #-----------------------------------------------------------------------------
  839.   # Container Key
  840.   #-----------------------------------------------------------------------------
  841.   def container_key
  842.     return $data_items[@key]
  843.   end
  844.  
  845.   #-----------------------------------------------------------------------------
  846.   # Unlock
  847.   #-----------------------------------------------------------------------------
  848.   def unlock(bypass = false)
  849.     return if !locked?
  850.     return if !@lockable
  851.     if bypass
  852.       @locked = false
  853.       return
  854.     end
  855.     k = container_key
  856.     return if k.nil?
  857.     return if !$game_party.has_item?(k)
  858.     play_lock
  859.     @locked = false
  860.   end
  861.  
  862.   #-----------------------------------------------------------------------------
  863.   # Take
  864.   #-----------------------------------------------------------------------------
  865.   def take(index)
  866.     i = content_item(@contents[index])
  867.     play_take
  868.     $game_party.gain_item(current_contents[index], 1)
  869.     @contents.delete_at(index)
  870.   end
  871.  
  872.   #-----------------------------------------------------------------------------
  873.   # Play Gold
  874.   #-----------------------------------------------------------------------------
  875.   def play_gold
  876.     se = Ixfuru::Containers::GOLD_SOUND
  877.     RPG::SE.new(se[0], se[1], se[2]).play
  878.   end
  879.  
  880.   #-----------------------------------------------------------------------------
  881.   # Play Take
  882.   #-----------------------------------------------------------------------------
  883.   def play_take
  884.     se = Ixfuru::Containers::TAKE_SOUND
  885.     RPG::SE.new(se[0], se[1], se[2]).play
  886.   end
  887.  
  888.   #-----------------------------------------------------------------------------
  889.   # Play Give
  890.   #-----------------------------------------------------------------------------
  891.   def play_give
  892.     se = Ixfuru::Containers::GIVE_SOUND
  893.     RPG::SE.new(se[0], se[1], se[2]).play
  894.   end
  895.  
  896.  
  897. end
  898.  
  899. ################################################################################
  900. #*******************************************************************************
  901. #                            WINDOW CONTAINER INSTRUCTIONS
  902. ################################################################################
  903. class Window_ContainerInstructions < Window_Base
  904.  
  905.   attr_accessor :active_window
  906.  
  907.   #-----------------------------------------------------------------------------
  908.   # Initialize
  909.   #-----------------------------------------------------------------------------
  910.   def initialize(container, active_window)
  911.     super(0, 0, 272, 80)
  912.     @container = container
  913.     @active_window = active_window
  914.     refresh
  915.   end
  916.  
  917.   #-----------------------------------------------------------------------------
  918.   # Refresh
  919.   #-----------------------------------------------------------------------------
  920.   def refresh
  921.     self.contents.clear
  922.     ss = select_string
  923.     ls = lock_string
  924.     tas = take_all_string
  925.     self.contents.font.size = 12
  926.     lh = 16
  927.     self.contents.font.color = system_color
  928.     self.contents.draw_text(0, 0, self.width - 32, lh, ss, 1)
  929.     self.contents.draw_text(0, lh, self.width - 32, lh, ls, 1)
  930.     unless @active_window.is_a?(Window_Belongings) ||
  931.         @active_window.is_a?(Window_ContainerGold) && @party
  932.       self.contents.draw_text(0, lh * 2, self.width - 32, lh, tas, 1)
  933.     end
  934.   end
  935.  
  936.   #-----------------------------------------------------------------------------
  937.   # Select String
  938.   #-----------------------------------------------------------------------------
  939.   def select_string
  940.     if @active_window.is_a?(Window_ContainerContents)
  941.       return "Press SPACE to take"
  942.     elsif @active_window.is_a?(Window_Belongings)
  943.       return "Press SPACE to place item in " + @container.name
  944.     elsif @active_window.is_a?(Window_ContainerGold)
  945.       case @active_window.party
  946.       when true
  947.         return "Press SPACE to place " + Vocab::gold + " into " + @container.name
  948.       when false
  949.         return "Press SPACE to take " + Vocab::gold
  950.       end
  951.     end
  952.   end
  953.  
  954.   #-----------------------------------------------------------------------------
  955.   # Button Return String
  956.   #-----------------------------------------------------------------------------
  957.   def button_return_string(button)
  958.     case button
  959.     when Input::C
  960.       return "SPACE"
  961.     when Input::B
  962.       return "X"
  963.     when Input::A
  964.       return "SHIFT"
  965.     when Input::X
  966.       return "A"
  967.     when Input::Y
  968.       return "S"
  969.     when Input::Z
  970.       return "D"
  971.     when Input::L
  972.       return "Q"
  973.     when Input::R
  974.       return "W"
  975.     end
  976.   end
  977.  
  978.   #-----------------------------------------------------------------------------
  979.   # Lock String
  980.   #-----------------------------------------------------------------------------
  981.   def lock_string
  982.     button = Ixfuru::Containers::LOCK_BUTTON
  983.     str = @container.locked? ? "unlock" : "lock"
  984.     return "Press " + button_return_string(button) + " to " + str
  985.   end
  986.  
  987.   #-----------------------------------------------------------------------------
  988.   # Take All String
  989.   #-----------------------------------------------------------------------------
  990.   def take_all_string
  991.     button = Ixfuru::Containers::TAKE_ALL_BUTTON
  992.     return "Press " + button_return_string(button) + " " + "to take all"
  993.   end
  994.  
  995. end
  996.  
  997. ################################################################################
  998. #*******************************************************************************
  999. #                             WINDOW CONTAINTER STATUS
  1000. ################################################################################
  1001. class Window_ContainerStatus < Window_Base
  1002.  
  1003.   attr_accessor :container
  1004.  
  1005.   #-----------------------------------------------------------------------------
  1006.   # Initialize
  1007.   #-----------------------------------------------------------------------------
  1008.   def initialize(container)
  1009.     super(272, 0, 272, 80)
  1010.     @container = container
  1011.     @name = @container.name
  1012.     @character = @container.character
  1013.     refresh
  1014.   end
  1015.  
  1016.   #-----------------------------------------------------------------------------
  1017.   # Refresh
  1018.   #-----------------------------------------------------------------------------
  1019.   def refresh
  1020.     self.contents.clear
  1021.     @holdings = @container.contents.size
  1022.     @capacity = @container.capacity
  1023.     self.contents.font.color = system_color
  1024.     if !@character.nil?
  1025.       nts = self.contents.text_size(@name).width + 72
  1026.       name_pointx = ((self.width - 32) / 2) - (nts / 2)
  1027.       draw_character(@character[0], @character[1], name_pointx, 32)
  1028.       self.contents.draw_text(name_pointx + 36, 0, self.width - 32, WLH, @name)
  1029.     else
  1030.       nts = self.contents.text_size(@name)
  1031.       name_pointx = ((self.width - 32) / 2) - (nts / 2)
  1032.       self.contents.draw_text(name_pointx, 0, self.width - 32, WLH, @name)
  1033.     end
  1034.     if @container.locked?
  1035.       self.contents.font.color = text_color(Ixfuru::Containers::LOCKED_COLOR)
  1036.       self.contents.draw_text(0, WLH, self.width - 32, WLH, Ixfuru::Containers::LOCKED_TEXT, 1)
  1037.     else
  1038.       self.contents.font.color = normal_color
  1039.       self.contents.draw_text(0, WLH, self.width - 32, WLH, "(" + @holdings.to_s + "/" + @capacity.to_s + ")", 1)
  1040.     end
  1041.   end
  1042.  
  1043. end
  1044.  
  1045. ################################################################################
  1046. #*******************************************************************************
  1047. #                          WINDOW CONTAINER CONTENTS
  1048. ################################################################################
  1049. class Window_ContainerContents < Window_Selectable
  1050.  
  1051.   attr_accessor :container
  1052.   attr_accessor :loot
  1053.  
  1054.   #-----------------------------------------------------------------------------
  1055.   # Initialize
  1056.   #-----------------------------------------------------------------------------
  1057.   def initialize(container)
  1058.     super(272, 80, 272, 280)
  1059.     @container = container
  1060.     @loot = @container.current_contents
  1061.     refresh
  1062.     self.index = 0
  1063.   end
  1064.  
  1065.   #-----------------------------------------------------------------------------
  1066.   # Refresh
  1067.   #-----------------------------------------------------------------------------
  1068.   def refresh
  1069.     @loot = @container.current_contents
  1070.     @item_max = @container.capacity
  1071.     create_contents
  1072.     for i in 0...@item_max
  1073.       draw_loot(i)
  1074.     end
  1075.   end
  1076.  
  1077.   #-----------------------------------------------------------------------------
  1078.   # Draw Loot
  1079.   #-----------------------------------------------------------------------------
  1080.   def draw_loot(index)
  1081.     rect = item_rect(index)
  1082.     rect.x += 4
  1083.     rect.width += 8
  1084.     if @loot[index].nil?
  1085.       self.contents.font.color = system_color
  1086.       self.contents.draw_text(rect, Ixfuru::Containers::LOOT_EMPTY_TEXT, 1)
  1087.     elsif @container.locked?
  1088.       self.contents.font.color = system_color
  1089.       self.contents.draw_text(rect, Ixfuru::Containers::HIDDEN_LOOT_TEXT)
  1090.     else
  1091.       self.contents.font.color = normal_color
  1092.       draw_item_name(@loot[index], rect.x, rect.y)
  1093.     end
  1094.   end
  1095.  
  1096. end
  1097.  
  1098. ################################################################################
  1099. #*******************************************************************************
  1100. #                            WINDOW BELONGINGS
  1101. ################################################################################
  1102. class Window_Belongings < Window_Selectable
  1103.  
  1104.   attr_accessor :belongings
  1105.  
  1106.   #-----------------------------------------------------------------------------
  1107.   # Initialize
  1108.   #-----------------------------------------------------------------------------
  1109.   def initialize
  1110.     super(0, 80, 272, 280)
  1111.     refresh
  1112.     self.index = 0
  1113.     self.active = false
  1114.   end
  1115.  
  1116.   #------------------------------------------------------------------------------
  1117.   # Refresh
  1118.   #-----------------------------------------------------------------------------
  1119.   def refresh
  1120.     @belongings = $game_party.items
  1121.     @item_max = @belongings.size
  1122.     create_contents
  1123.     unless @belongings.empty?
  1124.       for i in 0...@item_max
  1125.         draw_belonging(i)
  1126.       end
  1127.     end
  1128.   end
  1129.  
  1130.   #-----------------------------------------------------------------------------
  1131.   # Draw Belonging
  1132.   #-----------------------------------------------------------------------------
  1133.   def draw_belonging(index)
  1134.     rect = item_rect(index)
  1135.     rect.x += 4
  1136.     rect.width -= 8
  1137.     self.contents.font.color.alpha = enabled?(index) ? 255 : 128
  1138.     draw_item_name(@belongings[index], rect.x, rect.y, enabled?(index))
  1139.     self.contents.draw_text(rect, $game_party.item_number(@belongings[index]), 2)
  1140.   end
  1141.  
  1142.   #-----------------------------------------------------------------------------
  1143.   # Enabled?
  1144.   #-----------------------------------------------------------------------------
  1145.   def enabled?(index)
  1146.     return false if @belongings[index].no_container
  1147.     return true
  1148.   end
  1149.  
  1150. end
  1151.  
  1152. ################################################################################
  1153. #*******************************************************************************
  1154. #                        WINDOW CONTAINER GOLD
  1155. ################################################################################
  1156. class Window_ContainerGold < Window_Selectable
  1157.  
  1158.   attr_reader :party
  1159.  
  1160.   #-----------------------------------------------------------------------------
  1161.   # Initialize
  1162.   #-----------------------------------------------------------------------------
  1163.   def initialize(container, party = false)
  1164.     @container = container
  1165.     @party = party
  1166.     if @party
  1167.       super(0, 360, 272, 56)
  1168.     else
  1169.       super(272, 360, 272, 56)
  1170.     end
  1171.     @item_max = 1
  1172.     refresh
  1173.     self.index = 0
  1174.     self.active = false
  1175.   end
  1176.  
  1177.   #-----------------------------------------------------------------------------
  1178.   # Window Gold
  1179.   #-----------------------------------------------------------------------------
  1180.   def window_gold
  1181.     return $game_party.gold if @party
  1182.     return @container.gold
  1183.   end
  1184.  
  1185.   #-----------------------------------------------------------------------------
  1186.   # Refresh
  1187.   #-----------------------------------------------------------------------------
  1188.   def refresh
  1189.     self.contents.clear
  1190.     @gold = window_gold
  1191.     for i in 0...@item_max
  1192.       draw_gold(i)
  1193.     end
  1194.   end
  1195.  
  1196.   #-----------------------------------------------------------------------------
  1197.   # Draw Gold
  1198.   #-----------------------------------------------------------------------------
  1199.   def draw_gold(index)
  1200.     rect = item_rect(index)
  1201.     rect.x += 4
  1202.     rect.width -= 8
  1203.     gw = self.contents.text_size(@gold.to_s).width + 26
  1204.     xpoint = ((self.width - 32) / 2) - (gw / 2)
  1205.     draw_icon(Ixfuru::Containers::GOLD_LOOT_INDEX, xpoint, 0)
  1206.     if @container.locked? && !@party
  1207.       str = Ixfuru::Containers::HIDDEN_LOOT_TEXT
  1208.       self.contents.font.color = system_color
  1209.       self.contents.draw_text(xpoint + 26, 0, self.width - 32, WLH, str)
  1210.     else
  1211.       self.contents.font.color = normal_color
  1212.       self.contents.draw_text(xpoint + 26, 0, self.width - 32, WLH, @gold.to_s)
  1213.     end
  1214.   end
  1215.  
  1216. end
  1217.  
  1218. ################################################################################
  1219. #*******************************************************************************
  1220. #                          SCENE CONTAINER
  1221. ################################################################################
  1222. class Scene_Container < Scene_Base
  1223.  
  1224.   #-----------------------------------------------------------------------------
  1225.   # Initialize
  1226.   #-----------------------------------------------------------------------------
  1227.   def initialize(container_id)
  1228.     @container_id = container_id
  1229.     if $containers.has_key?(container_id)
  1230.       @container = $containers[container_id]
  1231.     else
  1232.       @container = Container.new(container_id)
  1233.     end
  1234.     @amount_return = 1
  1235.   end
  1236.  
  1237.   #-----------------------------------------------------------------------------
  1238.   # Start
  1239.   #-----------------------------------------------------------------------------
  1240.   def start
  1241.     super
  1242.     create_menu_background
  1243.     @win_status = Window_ContainerStatus.new(@container)
  1244.     @win_contents = Window_ContainerContents.new(@container)
  1245.     @win_belongings = Window_Belongings.new
  1246.     @win_partygold = Window_ContainerGold.new(@container, true)
  1247.     @win_containergold = Window_ContainerGold.new(@container)
  1248.     @win_instructions = Window_ContainerInstructions.new(@container, @win_belongings)
  1249.     @container.open
  1250.   end
  1251.  
  1252.   #-----------------------------------------------------------------------------
  1253.   # Update
  1254.   #-----------------------------------------------------------------------------
  1255.   def update
  1256.     super
  1257.     update_lock
  1258.     if @win_partygold.active
  1259.       update_partygold
  1260.     elsif @win_containergold.active
  1261.       update_containergold
  1262.     elsif @win_contents.active
  1263.       update_contents
  1264.     elsif @win_belongings.active
  1265.       update_belongings
  1266.     end
  1267.   end
  1268.  
  1269.   #-----------------------------------------------------------------------------
  1270.   # Refresh Windows
  1271.   #-----------------------------------------------------------------------------
  1272.   def refresh_windows
  1273.     @win_partygold.refresh
  1274.     @win_containergold.refresh
  1275.     @win_belongings.refresh
  1276.     @win_contents.refresh
  1277.     @win_status.refresh
  1278.     @win_instructions.refresh
  1279.   end
  1280.  
  1281.   #-----------------------------------------------------------------------------
  1282.   # Update Lock
  1283.   #-----------------------------------------------------------------------------
  1284.   def update_lock
  1285.     if Input.trigger?(Ixfuru::Containers::LOCK_BUTTON)
  1286.       if @container.locked?
  1287.         @container.unlock
  1288.       else
  1289.         @container.lock
  1290.       end
  1291.       refresh_windows
  1292.     end
  1293.   end
  1294.  
  1295.   #-----------------------------------------------------------------------------
  1296.   # Update Instructions
  1297.   #-----------------------------------------------------------------------------
  1298.   def update_instructions
  1299.     caw = current_active_window
  1300.     return if caw.nil?
  1301.     @win_instructions.active_window = caw
  1302.     @win_instructions.refresh
  1303.   end
  1304.  
  1305.   #-----------------------------------------------------------------------------
  1306.   # Currently Active Window
  1307.   #-----------------------------------------------------------------------------
  1308.   def current_active_window
  1309.     windows = [@win_belongings, @win_contents, @win_partygold, @win_containergold]
  1310.     for window in windows
  1311.       if window.active
  1312.         return window
  1313.       end
  1314.     end
  1315.     return nil
  1316.   end
  1317.  
  1318.   #-----------------------------------------------------------------------------
  1319.   # Update Contents
  1320.   #-----------------------------------------------------------------------------
  1321.   def update_contents
  1322.     @win_contents.update
  1323.     item = @win_contents.loot[@win_contents.index]
  1324.     if Input.trigger?(Input::C)
  1325.       if !item.nil? && !@container.locked?
  1326.         @container.take(@win_contents.index)
  1327.         @win_contents.refresh
  1328.         @win_belongings.refresh
  1329.         @win_status.refresh
  1330.       else
  1331.         Sound.play_buzzer
  1332.       end
  1333.     elsif Input.trigger?(Input::B)
  1334.       @container.close
  1335.       $scene = Scene_Map.new
  1336.     elsif Input.trigger?(@container.toggler(0)) # jump left
  1337.       Sound.play_decision
  1338.       @win_contents.active = false
  1339.       @win_partygold.active = true
  1340.       update_instructions
  1341.     elsif Input.trigger?(@container.toggler(1)) # jump right
  1342.       Sound.play_decision
  1343.       @win_contents.active = false
  1344.       @win_containergold.active = true
  1345.       update_instructions
  1346.     elsif Input.trigger?(@container.take_all_button)
  1347.       @container.take_all
  1348.       @win_contents.refresh
  1349.       @win_belongings.refresh
  1350.       @win_status.refresh
  1351.     end
  1352.   end
  1353.  
  1354.   #-----------------------------------------------------------------------------
  1355.   # Update Belongings
  1356.   #-----------------------------------------------------------------------------
  1357.   def update_belongings
  1358.     @win_belongings.update
  1359.     item = @win_belongings.belongings[@win_belongings.index]
  1360.     if Input.trigger?(Input::C)
  1361.       if !@container.full? && !item.nil? && !item.no_container && !@container.locked?
  1362.         @container.add_to_contents(item)
  1363.         @win_contents.refresh
  1364.         @win_belongings.refresh
  1365.         @win_status.refresh
  1366.         if @win_belongings.index >= @win_belongings.belongings.size
  1367.           @win_belongings.index = @win_belongings.belongings.size - 1
  1368.         end
  1369.       else
  1370.         Sound.play_buzzer
  1371.       end
  1372.     elsif Input.trigger?(Input::B)
  1373.       @container.close
  1374.       $scene = Scene_Map.new
  1375.     elsif Input.trigger?(@container.toggler(0)) # jump left
  1376.       Sound.play_decision
  1377.       @win_belongings.active = false
  1378.       @win_containergold.active = true
  1379.       update_instructions
  1380.     elsif Input.trigger?(@container.toggler(1)) # jump right
  1381.       Sound.play_decision
  1382.       @win_belongings.active = false
  1383.       @win_partygold.active = true
  1384.       update_instructions
  1385.     end
  1386.   end
  1387.  
  1388.   #-----------------------------------------------------------------------------
  1389.   # Update Gold Windows
  1390.   #-----------------------------------------------------------------------------
  1391.   def update_gold_windows
  1392.     @win_partygold.refresh
  1393.     @win_containergold.refresh
  1394.   end
  1395.  
  1396.   #-----------------------------------------------------------------------------
  1397.   # Update Partygold
  1398.   #-----------------------------------------------------------------------------
  1399.   def update_partygold
  1400.     @win_partygold.update
  1401.     if Input.press?(Input::C)
  1402.       unless @container.locked?
  1403.         @container.add_gold(1)
  1404.         update_gold_windows
  1405.       end
  1406.     elsif Input.trigger?(Input::B)
  1407.       @container.close
  1408.       $scene = Scene_Map.new
  1409.     elsif Input.trigger?(@container.toggler(0)) #jump left
  1410.       Sound.play_decision
  1411.       @win_partygold.active = false
  1412.       @win_belongings.index = 0
  1413.       @win_belongings.active = true
  1414.       update_instructions
  1415.     elsif Input.trigger?(@container.toggler(1)) # jump right
  1416.       Sound.play_decision
  1417.       @win_partygold.active = false
  1418.       @win_contents.index = 0
  1419.       @win_contents.active = true
  1420.       update_instructions
  1421.     end
  1422.   end
  1423.  
  1424.   #-----------------------------------------------------------------------------
  1425.   # Update ContainerGold
  1426.   #------------------------------------------------------------------------------
  1427.   def update_containergold
  1428.     @win_containergold.update
  1429.     if Input.press?(Input::C)
  1430.       unless @container.locked?
  1431.         @container.take_gold(1)
  1432.         update_gold_windows
  1433.       end
  1434.     elsif Input.trigger?(Input::B)
  1435.       @container.close
  1436.       $scene = Scene_Map.new
  1437.     elsif Input.trigger?(@container.take_all_button)
  1438.       @container.play_gold
  1439.       @container.take_gold(@container.gold)
  1440.       update_gold_windows
  1441.     elsif Input.trigger?(@container.toggler(0)) # jump left
  1442.       Sound.play_decision
  1443.       @win_containergold.active = false
  1444.       @win_contents.index = 0
  1445.       @win_contents.active = true
  1446.       update_instructions
  1447.     elsif Input.trigger?(@container.toggler(1)) # jump right
  1448.       Sound.play_decision
  1449.       @win_containergold.active = false
  1450.       @win_belongings.index = 0
  1451.       @win_belongings.active = true
  1452.       update_instructions
  1453.     end
  1454.   end
  1455.  
  1456.   #-----------------------------------------------------------------------------
  1457.   # Terminate
  1458.   #-----------------------------------------------------------------------------
  1459.   def terminate
  1460.     super
  1461.     dispose_menu_background
  1462.     windows = [@win_containergold, @win_partygold, @win_belongings, @win_status,
  1463.     @win_contents, @win_instructions]
  1464.     for window in windows
  1465.       window.dispose
  1466.     end
  1467.   end    
  1468.  
  1469. end
Advertisement
Add Comment
Please, Sign In to add comment