Advertisement
CrowMakerVX

LootContainers1.0a

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