Advertisement
roninator2

Galv's Item Storage - Removed Gold Option

Dec 6th, 2024
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 25.33 KB | None | 0 0
  1. #------------------------------------------------------------------------------#
  2. #  Galv's Item Storage
  3. #------------------------------------------------------------------------------#
  4. #  For: RPGMAKER VX ACE
  5. #  Version 1.9. -1/4 - for removing gold
  6. #  Mod by roninator2
  7. #------------------------------------------------------------------------------#
  8. #  2016-06-09 - Version 1.9 - Bug with removing an entire stack fixed
  9. #  2015-11-12 - Version 1.8 - Bug with stored item stacks and counting.
  10. #  2012-10-24 - Version 1.7 - Added multiple storages controlled with variable.
  11. #                           - Changed name to Item/Bank Storage
  12. #                           - changed alias naming for compatibility
  13. #  2012-10-19 - Version 1.6 - Bug fixes
  14. #  2012-10-19 - Version 1.5 - Fixed a max gold and withdrawing issue.
  15. #                           - Added deposit all and withdraw all gold buttons.
  16. #                           - party gold and item limits can now be set or use
  17. #                           - the limit from a limit breaking script. (in theory)
  18. #  2012-10-18 - Version 1.4 - Other small fixes
  19. #  2012-10-18 - Version 1.3 - Added banking SE
  20. #  2012-10-18 - Version 1.2 - Added gold storage and more script calls
  21. #  2012-10-17 - Version 1.1 - Added script calls to control stored items.
  22. #  2012-10-16 - Version 1.0 - Released
  23. #------------------------------------------------------------------------------#
  24. #  An item storage script. Allows the player to store as many items as he/she
  25. #  requires in bank-like storage that can be accessed from anywhere.
  26. #    
  27. #  This script differs to my "Multiple Storage containers" script in that you
  28. #  can have "banks" that store items and gold and can be accessed from anywhere.
  29. #  It was designed to be used for one bank, but now has option to have more if
  30. #  required.
  31. #
  32. #  My "Multiple Storage Containers" script stores only items within certain
  33. #  events that can only be accessed by activating the particular event. This was
  34. #  designed for location specific containers like chests, barrels, etc.
  35. #
  36. #  Here are some script calls that might be useful:
  37. #------------------------------------------------------------------------------#
  38. #
  39. #  open_storage                         # Opens the item storage scene
  40. #
  41. #  store_add(type, id, amount)          # creates an item in storage
  42. #  store_rem(type, id, amount)          # destroys an item in storage
  43. #  store_count(type, id)                # returns amount of an item in storage
  44. #
  45. #------------------------------------------------------------------------------#
  46. #  EXPLAINATION:
  47. #  type      this can be "weapon", "armor" or "item"
  48. #  id        the ID of the item/armor/weapon
  49. #  amount    the number of the item/armor/weapon/gold you want to remove
  50. #
  51. #  EXAMPLE OF USE:
  52. #  store_add("weapon", 5, 20)
  53. #  store_rem("item", 18, 99)
  54. #  store_count("armor", 1)
  55. #------------------------------------------------------------------------------#
  56. #  More setup options further down.
  57. #------------------------------------------------------------------------------#
  58.  
  59. $imported = {} if $imported.nil?
  60. $imported["Item_Storage"] = true
  61.  
  62. module Storage
  63.  
  64. #------------------------------------------------------------------------------#
  65. #  SCRIPT SETUP OPTIONS
  66. #------------------------------------------------------------------------------#
  67.  
  68.   # BOX VARIABLE
  69.   BOX_VAR = 3    # This is the variable ID to use to determine which box you are
  70.                  # adding/removing items from. Set the variable to a box number
  71.                  # right before any add/remove or opening storage script calls
  72.                  # to tell them which box they will affect.
  73.                  # Set to 0 if you only want 1 box storage in your game. You
  74.                  # then don't have to change a variable before each script call.
  75.  
  76.  
  77.   # COMMAND LIST VOCAB
  78.   STORE = "Store Item"
  79.   REMOVE = "Remove Item"
  80.   CANCEL = "Cancel"
  81.  
  82.   # OTHER VOCAB
  83.   IN_STORAGE = "In Storage"
  84.   IN_INVENTORY = "In Inventory"
  85.    
  86.   # OTHER OPTIONS
  87.   SE = ["Equip2", 90, 100]        # Sound effect when storing/removing an item
  88.   SE_BANK = ["Shop", 50, 150]     # Repeating sound effect when banking gold
  89.                                   # ["SE Name", volume, pitch]
  90.    
  91.   STORE_PRICELESS = true          # Items worth 0 can be stored? true or false
  92.   STORE_KEY = true                # Key items can be stored? true or false
  93.  
  94.    
  95.   # PARTY LIMITS
  96.   # NOTE: These limits set to 0 will use the default limits. In theory this will
  97.   # be compatible with a limit breaker script by leaving them at 0. Or you can
  98.   # set the party limits below to whatever you like.
  99.    
  100.                                   # This will overwrite the default limit.
  101.                                   # 0 means do not use this.
  102.  
  103.   MAX_ITEMS = 0                   # Max items your PARTY can carry.
  104.                                   # This will overwrite the default limit.
  105.                                   # 0 means do not use this.
  106.  
  107.  
  108. #------------------------------------------------------------------------------#
  109. #  SCRIPT SETUP OPTIONS
  110. #------------------------------------------------------------------------------#
  111.  
  112. end
  113.  
  114.  
  115. class Scene_ItemBank < Scene_MenuBase
  116.   def start
  117.     super
  118.     check_storage_exists
  119.     create_help_window
  120.     create_command_window
  121.     create_dummy_window
  122.     create_number_window
  123.     create_status_window
  124.     create_category_window
  125.     create_take_window
  126.     create_give_window
  127.      
  128.   end
  129.    
  130.   def check_storage_exists
  131.     if $game_party.multi_storage.nil?
  132.       $game_party.create_storage_contents
  133.     end
  134.   end
  135.    
  136.    
  137.   #--------------------------------------------------------------------------
  138.   # Create Windows
  139.   #--------------------------------------------------------------------------
  140.   def create_command_window
  141.     @command_window = Window_BankCommand.new(Graphics.width)
  142.     @command_window.viewport = @viewport
  143.     @command_window.y = @help_window.height
  144.     @command_window.set_handler(:give,   method(:command_give))
  145.     @command_window.set_handler(:take,    method(:command_take))
  146.     @command_window.set_handler(:cancel, method(:return_scene))
  147.   end
  148.   def create_dummy_window
  149.     wy = @command_window.y + @command_window.height
  150.     wh = Graphics.height - wy
  151.     @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
  152.     @dummy_window.viewport = @viewport
  153.   end
  154.   def create_number_window
  155.     wy = @dummy_window.y
  156.     wh = @dummy_window.height
  157.     @number_window = Window_BankNumber.new(0, wy, wh)
  158.     @number_window.viewport = @viewport
  159.     @number_window.hide
  160.     @number_window.set_handler(:ok,     method(:on_number_ok))
  161.     @number_window.set_handler(:cancel, method(:on_number_cancel))
  162.   end
  163.   def create_status_window
  164.     wx = @number_window.width
  165.     wy = @dummy_window.y
  166.     ww = Graphics.width - wx
  167.     wh = @dummy_window.height
  168.     @status_window = Window_BankItems.new(wx, wy, ww, wh)
  169.     @status_window.viewport = @viewport
  170.     @status_window.hide
  171.   end
  172.   def create_category_window
  173.     @category_window = Window_ItemCategory.new
  174.     @category_window.viewport = @viewport
  175.     @category_window.help_window = @help_window
  176.     @category_window.y = @dummy_window.y
  177.     @category_window.hide.deactivate
  178.     @category_window.set_handler(:ok,     method(:on_category_ok))
  179.     @category_window.set_handler(:cancel, method(:on_category_cancel))
  180.   end
  181.   def create_give_window
  182.     wy = @category_window.y + @category_window.height
  183.     wh = Graphics.height - wy
  184.     @give_window = Window_BankGive.new(0, wy, Graphics.width, wh)
  185.     @give_window.viewport = @viewport
  186.     @give_window.help_window = @help_window
  187.     @give_window.hide
  188.     @give_window.set_handler(:ok,     method(:on_give_ok))
  189.     @give_window.set_handler(:cancel, method(:on_give_cancel))
  190.     @category_window.item_window = @give_window
  191.   end
  192.   def create_take_window
  193.     wy = @command_window.y + @command_window.height
  194.     wh = Graphics.height - wy
  195.     @take_window = Window_BankTake.new(0, wy, Graphics.width, wh)
  196.     @take_window.viewport = @viewport
  197.     @take_window.help_window = @help_window
  198.     @take_window.hide
  199.     @take_window.set_handler(:ok,     method(:on_take_ok))
  200.     @take_window.set_handler(:cancel, method(:on_take_cancel))
  201.     @category_window.item_window = @take_window
  202.   end
  203.  
  204.   #--------------------------------------------------------------------------
  205.   # * Activate Windows
  206.   #--------------------------------------------------------------------------
  207.   def activate_give_window
  208.     @category_window.show
  209.     @give_window.refresh
  210.     @give_window.show.activate
  211.     @status_window.hide
  212.   end
  213.   def activate_take_window
  214.     @take_window.select(0)
  215.     @take_window.refresh
  216.     @take_window.show.activate
  217.     @status_window.hide
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # HANDLER METHODS
  221.   #--------------------------------------------------------------------------
  222.   def on_category_ok
  223.     activate_give_window
  224.     @give_window.select(0)
  225.   end
  226.   def on_category_cancel
  227.     @command_window.activate
  228.     @dummy_window.show
  229.     @category_window.hide
  230.     @give_window.hide
  231.   end
  232.   def command_give
  233.     @dummy_window.hide
  234.     @category_window.show.activate
  235.     @give_window.show
  236.     @give_window.unselect
  237.     @give_window.refresh
  238.   end
  239.   def on_give_ok
  240.     @item = @give_window.item
  241.     if @item.nil?
  242.       RPG::SE.stop
  243.       Sound.play_buzzer
  244.       @give_window.activate
  245.       @give_window.refresh
  246.       return
  247.     else
  248.       @status_window.item = @item
  249.       @category_window.hide
  250.       @give_window.hide
  251.       @number_window.set(@item, max_give)
  252.       @number_window.show.activate
  253.       @status_window.show
  254.     end
  255.   end
  256.   def on_give_cancel
  257.     @give_window.unselect
  258.     @category_window.activate
  259.     @status_window.item = nil
  260.     @help_window.clear
  261.   end
  262.   def command_take
  263.     @dummy_window.hide
  264.     activate_take_window
  265.     @take_window.show
  266.     @take_window.refresh
  267.   end
  268.   def on_take_ok
  269.     @item = @take_window.item
  270.     if @item.nil? || $game_party.multi_storage.empty? || $game_party.item_number(@item) == $game_party.max_item_number(@item)
  271.       RPG::SE.stop
  272.       Sound.play_buzzer
  273.       @take_window.activate
  274.       @take_window.refresh
  275.       return
  276.     elsif
  277.       @item = @take_window.item
  278.       @status_window.item = @item
  279.       @take_window.hide
  280.       @number_window.set(@item, max_take)
  281.       @number_window.show.activate
  282.       @status_window.show
  283.     end
  284.   end
  285.   def on_take_cancel
  286.     @take_window.unselect
  287.     @command_window.activate
  288.     @dummy_window.show
  289.     @take_window.hide
  290.     @status_window.item = nil
  291.     @help_window.clear
  292.   end
  293.   def on_number_ok
  294.     RPG::SE.new(Storage::SE[0], Storage::SE[1], Storage::SE[2]).play
  295.     case @command_window.current_symbol
  296.     when :take
  297.       do_take(@number_window.number)
  298.     when :give
  299.       do_give(@number_window.number)
  300.     end
  301.     end_number_input
  302.     @status_window.refresh
  303.   end
  304.   def on_number_cancel
  305.     Sound.play_cancel
  306.     end_number_input
  307.   end
  308.   def end_number_input
  309.     @number_window.hide
  310.     case @command_window.current_symbol
  311.     when :take
  312.       activate_take_window
  313.     when :give
  314.       activate_give_window
  315.     end
  316.   end  
  317.    
  318.   #--------------------------------------------------------------------------
  319.   # * Giving and taking methods
  320.   #--------------------------------------------------------------------------
  321.   def max_take
  322.     if $game_party.multi_storage(@item) > $game_party.max_item_number(@item) - $game_party.item_number(@item)
  323.       $game_party.max_item_number(@item) - $game_party.item_number(@item)
  324.     else
  325.       $game_party.multi_storage(@item)
  326.     end
  327.   end
  328.   def max_give
  329.     $game_party.item_number(@item)
  330.   end
  331.   def do_give(number)
  332.     $game_party.lose_item(@item, number)
  333.     if $game_party.multi_storage(@item).nil? || $game_party.multi_storage(@item) <= 0
  334.       $game_party.multi_storage_set(@item,number)
  335.     else
  336.       $game_party.multi_storage_change(@item,number)
  337.     end
  338.   end
  339.   def do_take(number)
  340.     return if @item.nil?
  341.     $game_party.gain_item(@item, number)
  342.     $game_party.multi_storage_change(@item,-number)
  343.     #$game_party.multi_storage.delete(@item) if $game_party.multi_storage(@item) <= 0
  344.     if $game_party.multi_storage.empty?
  345.       @take_window.activate
  346.     end
  347.   end
  348.    
  349. end # Scene_ItemBank < Scene_MenuBase
  350.  
  351.  
  352. #------------------------------------------------------------------------------#
  353. #  Window Stored Items
  354. #------------------------------------------------------------------------------#
  355.  
  356. class Window_StoreList_Bank < Window_Selectable
  357.   def initialize(x, y, width, height)
  358.     super
  359.     @category = :none
  360.     @data = []
  361.   end
  362.   def category=(category)
  363.     return if @category == category
  364.     @category = category
  365.     refresh
  366.     self.oy = 0
  367.   end
  368.   def col_max
  369.     return 2
  370.   end
  371.   def item_max
  372.     @data ? @data.size : 1
  373.   end
  374.   def item
  375.     @data && index >= 0 ? @data[index] : nil
  376.   end
  377.   def current_item_enabled?
  378.     enable?(@data[index])
  379.   end
  380.   def include?(item)
  381.     case @category
  382.     when :item
  383.       item.is_a?(RPG::Item) && !item.key_item?
  384.     when :weapon
  385.       item.is_a?(RPG::Weapon)
  386.     when :armor
  387.       item.is_a?(RPG::Armor)
  388.     when :key_item
  389.       item.is_a?(RPG::Item) && item.key_item?
  390.     else
  391.       false
  392.     end
  393.   end
  394.   def enable?(item)
  395.     $game_party.multi_storage.has_key?(item)
  396.   end
  397.   def make_item_list
  398.     @data = $game_party.multi_storage_all.keys {|item| include?(item) }
  399.     @data.push(nil) if include?(nil)
  400.   end
  401.   def select_last
  402.     select(@data.index($game_party.last_item.object) || 0)
  403.   end
  404.   def draw_item(index)
  405.     item = @data[index]
  406.     if item
  407.       rect = item_rect(index)
  408.       rect.width -= 4
  409.       draw_item_name(item, rect.x, rect.y, enable?(item))
  410.       draw_item_number(rect, item)
  411.     end
  412.   end
  413.   def draw_item_number(rect, item)
  414.     draw_text(rect, sprintf(":%2d", $game_party.multi_storage(item)), 2)
  415.   end
  416.   def update_help
  417.     @help_window.set_item(item)
  418.   end
  419.   def refresh
  420.     make_item_list
  421.     create_contents
  422.     draw_all_items
  423.   end
  424. end # Window_StoreList_Bank < Window_Selectable
  425.  
  426.  
  427. #------------------------------------------------------------------------------#
  428. #  Window Stored Item amount
  429. #------------------------------------------------------------------------------#
  430.  
  431. class Window_BankNumber < Window_Selectable
  432.   attr_reader :number
  433.   def initialize(x, y, height)
  434.     super(x, y, window_width, height)
  435.     @item = nil
  436.     @max = 1
  437.     @number = 1
  438.   end
  439.   def window_width
  440.     return 304
  441.   end
  442.   def set(item, max)
  443.     @item = item
  444.     @max = max
  445.     @number = 1
  446.     refresh
  447.   end
  448.   def refresh
  449.     contents.clear
  450.     draw_item_name(@item, 0, item_y)
  451.     draw_number
  452.   end
  453.   def draw_number
  454.     change_color(normal_color)
  455.     draw_text(cursor_x - 28, item_y, 22, line_height, "×")
  456.     draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
  457.   end
  458.   def item_y
  459.     contents_height / 2 - line_height * 3 / 2
  460.   end
  461.   def cursor_width
  462.     figures * 10 + 12
  463.   end
  464.   def cursor_x
  465.     contents_width - cursor_width - 4
  466.   end
  467.   def figures
  468.     return 2
  469.   end
  470.   def update
  471.     super
  472.     if active
  473.       last_number = @number
  474.       update_number
  475.       if @number != last_number
  476.         Sound.play_cursor
  477.         refresh
  478.       end
  479.     end
  480.   end
  481.   def update_number
  482.     change_number(1)   if Input.repeat?(:RIGHT)
  483.     change_number(-1)  if Input.repeat?(:LEFT)
  484.     change_number(10)  if Input.repeat?(:UP)
  485.     change_number(-10) if Input.repeat?(:DOWN)
  486.   end
  487.   def change_number(amount)
  488.     @number = [[@number + amount, @max].min, 1].max
  489.   end
  490.   def update_cursor
  491.     cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
  492.   end
  493.    
  494. end # Window_BankNumber < Window_Selectable
  495.  
  496.  
  497. #------------------------------------------------------------------------------#
  498. #  Window Store Item Status
  499. #------------------------------------------------------------------------------#
  500.  
  501. class Window_BankItems < Window_Base
  502.   def initialize(x, y, width, height)
  503.     super(x, y, width, height)
  504.     @item = nil
  505.     @page_index = 0
  506.     refresh
  507.   end
  508.   def refresh
  509.     contents.clear
  510.     draw_possession(4, 0)
  511.     draw_stored(4, line_height)
  512.     draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem)
  513.   end
  514.   def item=(item)
  515.     @item = item
  516.     refresh
  517.   end
  518.   def draw_possession(x, y)
  519.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  520.     change_color(system_color)
  521.     draw_text(rect, Storage::IN_INVENTORY)
  522.     change_color(normal_color)
  523.     draw_text(rect, $game_party.item_number(@item), 2)
  524.   end
  525.   def draw_stored(x, y)
  526.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  527.     change_color(system_color)
  528.     draw_text(rect, Storage::IN_STORAGE)
  529.     change_color(normal_color)
  530.     stored_amount = $game_party.multi_storage(@item)
  531.     stored_amount = 0 if stored_amount.nil?
  532.     draw_text(rect, stored_amount, 2)
  533.   end
  534.   def draw_equip_info(x, y)
  535.     status_members.each_with_index do |actor, i|
  536.       draw_actor_equip_info(x, y + line_height * (i * 2.4), actor)
  537.     end
  538.   end
  539.   def status_members
  540.     $game_party.members[@page_index * page_size, page_size]
  541.   end
  542.   def page_size
  543.     return 4
  544.   end
  545.   def page_max
  546.     ($game_party.members.size + page_size - 1) / page_size
  547.   end
  548.   def draw_actor_equip_info(x, y, actor)
  549.     enabled = actor.equippable?(@item)
  550.     change_color(normal_color, enabled)
  551.     draw_text(x, y, 112, line_height, actor.name)
  552.     item1 = current_equipped_item(actor, @item.etype_id)
  553.     draw_actor_param_change(x, y, actor, item1) if enabled
  554.     draw_item_name(item1, x, y + line_height, enabled)
  555.   end
  556.   def draw_actor_param_change(x, y, actor, item1)
  557.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  558.     change = @item.params[param_id] - (item1 ? item1.params[param_id] : 0)
  559.     change_color(param_change_color(change))
  560.     draw_text(rect, sprintf("%+d", change), 2)
  561.   end
  562.   def param_id
  563.     @item.is_a?(RPG::Weapon) ? 2 : 3
  564.   end
  565.   def current_equipped_item(actor, etype_id)
  566.     list = []
  567.     actor.equip_slots.each_with_index do |slot_etype_id, i|
  568.       list.push(actor.equips[i]) if slot_etype_id == etype_id
  569.     end
  570.     list.min_by {|item| item ? item.params[param_id] : 0 }
  571.   end
  572.   def update
  573.     super
  574.     update_page
  575.   end
  576.   def update_page
  577.     if visible && Input.trigger?(:A) && page_max > 1
  578.       @page_index = (@page_index + 1) % page_max
  579.       refresh
  580.     end
  581.   end
  582.    
  583. end # Window_BankItems < Window_Base
  584.  
  585.  
  586. #------------------------------------------------------------------------------#
  587. #  Window Give Item
  588. #------------------------------------------------------------------------------#
  589.  
  590. class Window_BankGive < Window_ItemList
  591.   def initialize(x, y, width, height)
  592.     super(x, y, width, height)
  593.   end
  594.   def current_item_enabled?
  595.  
  596.     enable?(@data[index])
  597.   end
  598.   def enable?(item)
  599.     if item.is_a?(RPG::Item)
  600.       return false if item.key_item? && !Storage::STORE_KEY
  601.     end
  602.     if Storage::STORE_PRICELESS
  603.       true
  604.     else
  605.       item && item.price > 0
  606.     end
  607.   end
  608. end
  609.  
  610.  
  611. #------------------------------------------------------------------------------#
  612. #  Window Take Item
  613. #------------------------------------------------------------------------------#
  614.  
  615. class Window_BankTake < Window_StoreList_Bank
  616.   def initialize(x, y, width, height)
  617.     super(x, y, width, height)
  618.   end
  619.   def current_item_enabled?
  620.     enable?(@data[index])
  621.   end
  622.   def enable?(item)
  623.     $game_party.multi_storage[item] != 0 && $game_party.item_number(item) < $game_party.max_item_number(@item)
  624.   end
  625. end
  626.  
  627.  
  628. #------------------------------------------------------------------------------#
  629. #  Window Command
  630. #------------------------------------------------------------------------------#
  631.  
  632. class Window_BankCommand < Window_HorzCommand
  633.   def initialize(window_width)
  634.     @window_width = window_width
  635.     super(0, 0)
  636.   end
  637.   def window_width
  638.     @window_width
  639.   end
  640.   def col_max
  641.     return 3
  642.   end
  643.   def make_command_list
  644.     add_command(Storage::STORE,    :give)
  645.     add_command(Storage::REMOVE,   :take)
  646.     add_command(Storage::CANCEL, :cancel)
  647.   end
  648. end
  649.  
  650. #------------------------------------------------------------------------------#
  651. #  Game Party Additions
  652. #------------------------------------------------------------------------------#
  653.  
  654.  
  655. class Game_Party < Game_Unit
  656.   attr_accessor :multi_storage
  657.   attr_accessor :gold_stored
  658.    
  659.   alias galv_bank_init_all_items init_all_items
  660.   def init_all_items
  661.     galv_bank_init_all_items
  662.     @storage = {}
  663.   end
  664.    
  665.   def multi_storage(item = nil)
  666.     # Test for storage, create if not there.
  667.     @storage[$game_variables[Storage::BOX_VAR]] ||= {:w => {},:a => {}, :i => {}}
  668.      
  669.     if !item
  670.       return @storage[$game_variables[Storage::BOX_VAR]]
  671.     else
  672.       type = mstore_type(item)
  673.       @storage[$game_variables[Storage::BOX_VAR]][type][item.id] ||= 0
  674.       return @storage[$game_variables[Storage::BOX_VAR]][type][item.id]
  675.     end
  676.   end
  677.    
  678.   def multi_storage_all
  679.     all = {}
  680.      
  681.     @storage[$game_variables[Storage::BOX_VAR]][:i].each { |id|
  682.       all[$data_items[id[0]]] = id[1] if id[1] > 0
  683.     }
  684.     @storage[$game_variables[Storage::BOX_VAR]][:w].each { |id|
  685.       all[$data_weapons[id[0]]] = id[1] if id[1] > 0
  686.     }
  687.     @storage[$game_variables[Storage::BOX_VAR]][:a].each { |id|
  688.       all[$data_armors[id[0]]] = id[1] if id[1] > 0
  689.     }
  690.     return all
  691.   end
  692.    
  693.   def mstore_type(item)
  694.     if item.is_a?(RPG::Weapon)
  695.       return :w
  696.     elsif item.is_a?(RPG::Armor)
  697.       return :a
  698.     else
  699.       return :i
  700.     end
  701.   end
  702.    
  703.   def multi_storage_change(item,amount)
  704.     type = mstore_type(item)
  705.     @storage[$game_variables[Storage::BOX_VAR]][type][item.id] ||= 0
  706.     @storage[$game_variables[Storage::BOX_VAR]][type][item.id] += amount
  707.      
  708.     if @storage[$game_variables[Storage::BOX_VAR]][type][item.id] <= 0
  709.       @storage[$game_variables[Storage::BOX_VAR]][type].delete_if { |key,value|
  710.         value <= 0
  711.       }
  712.     end
  713.      
  714.   end
  715.    
  716.   def multi_storage_set(item, amount)
  717.     type = mstore_type(item)
  718.     @storage[$game_variables[Storage::BOX_VAR]][type][item.id] ||= 0
  719.     @storage[$game_variables[Storage::BOX_VAR]][type][item.id] = amount
  720.      
  721.     if @storage[$game_variables[Storage::BOX_VAR]][type][item.id] <= 0
  722.       @storage[$game_variables[Storage::BOX_VAR]][type].delete_if { |key,value|
  723.         key >= 0
  724.       }
  725.     end
  726.   end
  727.  
  728.   alias galv_bank_max_item_number max_item_number
  729.   def max_item_number(item)
  730.     return Storage::MAX_ITEMS if Storage::MAX_ITEMS > 0
  731.     return 99 if item.nil?
  732.     galv_bank_max_item_number(item)
  733.   end
  734.    
  735. end # Game_Party < Game_Unit
  736.  
  737.  
  738. class Game_Interpreter
  739.   def store_add(type, id, amount)
  740.     if $game_party.multi_storage.nil?
  741.       $game_party.create_storage_contents
  742.     end
  743.     case type
  744.     when "weapon"
  745.       @item = $data_weapons[id]
  746.     when "item"
  747.       @item = $data_items[id]
  748.     when "armor"
  749.       @item = $data_armors[id]
  750.     end
  751.     if $game_party.multi_storage(@item).nil?
  752.       $game_party.multi_storage_set(@item,amount)
  753.     else
  754.       $game_party.multi_storage_change(@item,amount)
  755.     end
  756.   end
  757.   def store_rem(type, id, amount)
  758.     if $game_party.multi_storage.nil?
  759.       $game_party.create_storage_contents
  760.     end
  761.     case type
  762.     when "weapon"
  763.       @item = $data_weapons[id]
  764.     when "item"
  765.       @item = $data_items[id]
  766.     when "armor"
  767.       @item = $data_armors[id]
  768.     end
  769.     return if $game_party.multi_storage(@item).nil?
  770.     if $game_party.multi_storage(@item) <= amount
  771.       #$game_party.multi_storage.delete(@item)
  772.       $game_party.multi_storage_set(@item,-amount)
  773.     else
  774.       $game_party.multi_storage_change(@item,-amount)
  775.     end
  776.   end
  777.  
  778.   def store_count(type, id)
  779.     if $game_party.multi_storage.nil?
  780.       $game_party.create_storage_contents
  781.     end
  782.     case type
  783.     when "weapon"
  784.       @item = $data_weapons[id]
  785.     when "item"
  786.       @item = $data_items[id]
  787.     when "armor"
  788.       @item = $data_armors[id]
  789.     end
  790.     # Issue here with item instance being different when game saves - therefore
  791.     # the count is incorrect.
  792.     # This issue is also persistant when adding things to storage
  793.     # needs fixing
  794.     # p "Store item referring issue"
  795.     return 0 if $game_party.multi_storage(@item).nil?
  796.     $game_party.multi_storage(@item)
  797.   end
  798.  
  799.   def open_storage
  800.     SceneManager.call(Scene_ItemBank)
  801.   end
  802. end
  803.  
  804. # GGZiron mod
  805. class Game_Interpreter
  806.  
  807.   # Snippet that allows to move all items from inventory
  808.   # to the storage. Addon to Galv's Item/Bank Storage
  809.   # Script calls:
  810.   # move_all_items_to_storage
  811.   # Will move all items without the equipments
  812.   #
  813.   # move_all_items_to_storage(true)
  814.   # Will move all items including the equipments
  815.  
  816.   def move_all_items_to_storage(equips_included = false)
  817.     if equips_included
  818.       $game_party.all_members.each do |member|
  819.         member.clear_equipments
  820.       end
  821.     end
  822.  
  823.     $game_party.instance_variable_get(:@items).each do |k, v|
  824.       store_add("item", k, v)
  825.     end
  826.  
  827.     $game_party.instance_variable_get(:@weapons).each do |k, v|
  828.       store_add("weapon", k, v)
  829.     end
  830.  
  831.     $game_party.instance_variable_get(:@armors).each do |k, v|
  832.       store_add("armor", k, v)
  833.     end
  834.  
  835.     $game_party.galv_bank_init_all_items
  836.   end
  837.  
  838. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement