Advertisement
TheSixth

Battle Inventory

Jan 18th, 2019
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.02 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Battle Inventory
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.1
  6. # * Updated: 19/01/2019
  7. # * Requires: IMP1's Storage Boxes
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (19/01/2019)
  12. #   - Initial release.
  13. # * Version 1.1 (19/01/2019)
  14. #   - Fixed an issue with item usability in battle.
  15. #-------------------------------------------------------------------------------
  16. # * < Description >
  17. #-------------------------------------------------------------------------------
  18. # * This script will designate a box from IMP1's script to be a storage for
  19. #   "battle supplies". The player can only use items from this box during the
  20. #   battle.
  21. #-------------------------------------------------------------------------------
  22. # * < Installation >
  23. #-------------------------------------------------------------------------------
  24. # * Place this script between Materials and Main!
  25. #-------------------------------------------------------------------------------
  26. # * < Compatibility Info >
  27. #-------------------------------------------------------------------------------
  28. # * No known incompatibilities.
  29. #-------------------------------------------------------------------------------
  30. # * < Known Issues >
  31. #-------------------------------------------------------------------------------
  32. # * No known issues.
  33. #-------------------------------------------------------------------------------
  34. # * < Terms of Use >
  35. #-------------------------------------------------------------------------------
  36. # * Free to use for whatever purposes you want.
  37. # * Credit me (Sixth) in your game, pretty please! :P
  38. # * Posting modified versions of this script is allowed as long as you notice me
  39. #   about it with a link to it!
  40. #===============================================================================
  41. $imported = {} if $imported.nil?
  42. $imported["SixthBBox"] = true
  43. #===============================================================================
  44. # Settings:
  45. #===============================================================================
  46. module BattleBox
  47.   #-----------------------------------------------------------------------------
  48.   # Battle Inventory Settings
  49.   #-----------------------------------------------------------------------------
  50.   # You have 5 little settings here, so lets get started...
  51.   #
  52.   #   :id => box_id,
  53.   # The ID of the box you want to use for the battle inventory.
  54.   #
  55.   #   :show => true/false/switch_id,
  56.   # This will let you add a new command to the main menu.
  57.   # The new command will open the battle inventory and will let the player place
  58.   # or take items to/from it.
  59.   # You can set it to true, and it will always be enabled.
  60.   # Setting it to false will disable this feature, in which case the rest of
  61.   # the setting options here won't do anything.
  62.   # You can also set it to a switch ID, in which case the command will be shown
  63.   # when that switch is turned ON, and it will be hidden when that switch is
  64.   # turned OFF.
  65.   # You can also use methods and code strings for this, but I won't detail that
  66.   # here. It requires coding knowledge to do that, so if you have some, just
  67.   # check the code and you should be able to figure it out how to do this on
  68.   # your own. :P
  69.   #
  70.   #   :enable => true/false/switch_id,
  71.   # Similar to the previous option, this one lets you enable or disable the new
  72.   # command.
  73.   # You can setup this the same way as the previous setting option.
  74.   #
  75.   #   :name => "command name",
  76.   # This will be the name of the new command. Must be a string!
  77.   #
  78.   #   :index => command_index,
  79.   # This will decide where the new command will appear on the command list.
  80.   # 0 means it will be the first command, 1 will be the second command, and so
  81.   # on.
  82.   # You can also use negative numbers to setup the place from the last command
  83.   # instead. In this case, -1 is the last command, -2 is the second last, and
  84.   # so on.
  85.   #
  86.   # That's it, I guess.
  87.   #-----------------------------------------------------------------------------
  88.   Data = {
  89.     :id     => 2,                 # Battle box ID.
  90.     :show   => true,              # Show battle box menu command?
  91.     :enable => true,              # Enable battle box menu command?
  92.     :name   => "Battle Supplies", # Menu command name
  93.     :index  => 1,                 # Menu command index
  94.   }
  95.  
  96. end
  97. #===============================================================================
  98. # End of settings! Editing anything below may lead to... you know it, right? o.o
  99. #===============================================================================
  100.  
  101. class Game_Battler < Game_BattlerBase
  102.  
  103.   alias battle_use0027 consume_item
  104.   def consume_item(it)
  105.     if SceneManager.scene_is?(Scene_Battle) || $game_party.in_battle
  106.       if it.is_a?(RPG::Item) && it.consumable
  107.         $game_boxes.remove_item(it, 1, BattleBox::Data[:id], false)
  108.       end
  109.     else
  110.       battle_use0027(it)
  111.     end
  112.   end
  113.  
  114. end
  115.  
  116. class Game_Party < Game_Unit
  117.  
  118.   alias bbox_patch0071 has_item?
  119.   def has_item?(it, eq = false)
  120.     if SceneManager.scene_is?(Scene_Battle) || $game_party.in_battle
  121.       box = $game_boxes.box(BattleBox::Data[:id])
  122.       return (box[it] || 0) > 0
  123.     else
  124.       return bbox_patch0071(it,eq)
  125.     end
  126.   end
  127.  
  128. end
  129.  
  130. class Window_BattleItem < Window_ItemList
  131.  
  132.   def make_item_list
  133.     box = $game_boxes.box(BattleBox::Data[:id])
  134.     @data = box.keys.select {|it| include?(it)}
  135.     @data.push(nil) if include?(nil)
  136.   end
  137.  
  138.   def draw_item_number(rect, it)
  139.     tx = sprintf(":%2d", $game_boxes.box(BattleBox::Data[:id])[it])
  140.     draw_text(rect, tx, 2)
  141.   end
  142.  
  143. end
  144.  
  145. class Window_MenuCommand < Window_Command
  146.  
  147.   alias add_bbox_cmd1232 make_command_list
  148.   def make_command_list
  149.     add_bbox_cmd1232
  150.     return unless cond?(BattleBox::Data[:show])
  151.     cmd = {
  152.       :name => BattleBox::Data[:name], :symbol=> :bbox,
  153.       :enabled => cond?(BattleBox::Data[:enable]), :ext => nil
  154.     }
  155.     @list.insert(BattleBox::Data[:index],cmd)
  156.   end
  157.  
  158.   def cond?(dt)
  159.     case dt
  160.     when Integer; return $game_switches[dt]
  161.     when Symbol;  return send(dt)
  162.     when Array;   return send(*dt)
  163.     when String;  return eval(dt)
  164.     else;         return dt
  165.     end
  166.   end
  167.  
  168. end
  169.  
  170. class Scene_Menu < Scene_MenuBase
  171.  
  172.   alias add_bbox_cmd9826 create_command_window
  173.   def create_command_window
  174.     add_bbox_cmd9826
  175.     @command_window.set_handler(:bbox, method(:bbox_menu))
  176.   end
  177.  
  178.   def bbox_menu
  179.     SceneManager.call(Scene_ItemStorage)
  180.     SceneManager.scene.prepare(BattleBox::Data[:id])
  181.   end
  182.  
  183. end
  184. #==============================================================================
  185. # !!END OF SCRIPT - OHH, NOES!!
  186. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement