Advertisement
TheSixth

Auto-Unequip Tools for Falcao's ABS by Sixth

Jan 5th, 2016
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.41 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Auto-Unequip Tools for Falcao's Pearl ABS Liquid v3
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.3
  6. # * Updated: 18/11/2016
  7. # * Requires: Falcao's Pearl ABS Liquid v3
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (06/01/2016)
  12. #   - Initial release.
  13. # * Version 1.1 (12/05/2016)
  14. #   - Fixed the ammo display for auto-unequipped tools.
  15. # * Version 1.2 (10/08/2016)
  16. #   - Item tools did not unequip if another tool caused the party to lose the
  17. #     item (by assigning an item cost for that tool). This is fixed now.
  18. # * Version 1.3 (18/11/2016)
  19. #   - Fixed a bug with unequipping tools.
  20. #-------------------------------------------------------------------------------
  21. # * < Description >
  22. #-------------------------------------------------------------------------------
  23. # * Tools which can not be used due to insufficient item or variable
  24. #   requirements can be unequipped automatically with this script.
  25. #   Note that the player will NOT be able to equip any of these tools after it
  26. #   is unequipped automatically until the player got enough item/variable to
  27. #   use them again!
  28. # * The variable requirement mentioned above is from another ABS addon I made,
  29. #   but it is not necessary for this script to work!
  30. #-------------------------------------------------------------------------------
  31. # * < Installation >
  32. #-------------------------------------------------------------------------------
  33. # * Place this scipt below the last script from Falcao's Pearl ABS Liquid v3
  34. #   script series but above Main!
  35. # * If you are using my Tool Variable Usage for Falcao's ABS script, you must
  36. #   put this one below that one!
  37. # * If you are using my Tool Cycler Addon for Falcao's ABS, you must put this
  38. #   script below that one!
  39. # * You can do an optional edit in the "Pearl Item Pop Up" script. This edit
  40. #   will prevent the item gain popup when the tool is automatically equipped
  41. #   due to this script. It's kinda annoying and looks bad to see that popup
  42. #   everytime the tool is unequipped automatically.
  43. #
  44. #   Anyway, here is what you need to do:
  45. #   Right at the start, after the settings part, you will see this method:
  46. #
  47. #~   alias falcaopearl_itempop_gain gain_item
  48. #~   def gain_item(item, amount, include_equip = false)
  49. #~     if !item_container(item.class).nil? && SceneManager.scene_is?(Scene_Map)
  50. #~       if amount > 0
  51. #~         $game_system.item_object = [item, amount]
  52. #~         RPG::SE.new(PearlItemPop::ItemSe, 80).play rescue nil
  53. #~       end
  54. #~     end
  55. #~     falcaopearl_itempop_gain(item, amount, include_equip = false)
  56. #~   end
  57. #
  58. #   Replace that whole definition with the one below:
  59. #
  60. #~   alias falcaopearl_itempop_gain gain_item
  61. #~   def gain_item(item, amount, include_equip = false)
  62. #~     unless $game_system.disable_item_pop == true
  63. #~       if !item_container(item.class).nil? && SceneManager.scene_is?(Scene_Map)
  64. #~         if amount > 0
  65. #~           $game_system.item_object = [item, amount]
  66. #~           RPG::SE.new(PearlItemPop::ItemSe, 80).play rescue nil
  67. #~         end
  68. #~       end
  69. #~     end
  70. #~     falcaopearl_itempop_gain(item, amount, include_equip = false)
  71. #~   end
  72. #
  73. #   I couldn't just overwrite it, because that would make compatibility issues
  74. #   with many scripts, and I could not alias it in any way, because the popup
  75. #   mechanic is already in it, so that would be called no matter how I alias it.
  76. #
  77. #   Simply copy the above method, and paste it over the old method, deleting
  78. #   the old one in the process. After this, select the copied method and press
  79. #   CTRL+Q while it's highlighted to remove the comment sings from it.
  80. #   Do NOT remove the comment signs from this header!
  81. #
  82. #   I hope this little copy/paste job won't be hard to do for anyone. :P
  83. #-------------------------------------------------------------------------------
  84. # * < Compatibility Info >
  85. #-------------------------------------------------------------------------------
  86. # * No known incompatibilities.
  87. #-------------------------------------------------------------------------------
  88. # * < Known Issues >
  89. #-------------------------------------------------------------------------------
  90. # * No known issues.
  91. #-------------------------------------------------------------------------------
  92. # * < Terms of Use >
  93. #-------------------------------------------------------------------------------
  94. # * Free to use for whatever purposes you want.
  95. # * Credit me (Sixth) in your game, pretty please! :P
  96. # * Posting modified versions of this script is allowed as long as you notice me
  97. #   about it with a link to it!
  98. #===============================================================================
  99. $imported = {} if $imported.nil?
  100. $imported["SixthABSToolAutoUnequip"] = true
  101. #===============================================================================
  102. # No settings! O.o
  103. #===============================================================================
  104.  
  105. unless $imported && $imported["SixthABSToolCycler"]
  106.   class Game_System
  107.    
  108.     attr_accessor :disable_item_pop
  109.    
  110.     alias disable_pop_switch9974 initialize
  111.     def initialize
  112.       @disable_item_pop = false
  113.       disable_pop_switch9974
  114.     end
  115.    
  116.   end
  117. end
  118.  
  119. class Game_Actor < Game_Battler
  120.  
  121.   def unequip_tool(item)
  122.     $game_system.disable_item_pop = true
  123.     change_equip(0, nil) if item == equips[0]
  124.     change_equip(1, nil) if item == equips[1]
  125.     @assigned_item = nil if @assigned_item && item.id == @assigned_item.id
  126.     @assigned_item2 = nil if @assigned_item2 && item.id == @assigned_item2.id
  127.     @assigned_skill = nil if @assigned_skill && item.id == @assigned_skill.id
  128.     @assigned_skill2 = nil if @assigned_skill2 && item.id == @assigned_skill2.id
  129.     @assigned_skill3 = nil if @assigned_skill3 && item.id == @assigned_skill3.id
  130.     @assigned_skill4 = nil if @assigned_skill4 && item.id == @assigned_skill4.id
  131.     $game_system.disable_item_pop = false
  132.   end
  133.  
  134. end
  135.  
  136. class Game_CharacterBase
  137.  
  138.   alias auto_unequip8753 load_abs_tool
  139.   def load_abs_tool(item)
  140.     auto_unequip8753(item)
  141.     if battler.is_a?(Game_Actor) && item
  142.       if $imported && $imported["SixthABSToolVariables"]
  143.         if item.var_req != 0 && $game_variables[item.var_req] <= 0
  144.           $game_party.members.each {|mem| mem.unequip_tool(item)}
  145.           if SceneManager.scene_is?(Scene_Map)
  146.             SceneManager.scene.spriteset.pearl_tool_sprite.refresh_texts
  147.           end
  148.         end
  149.       end
  150.       if PearlKernel.tool_itemcost && PearlKernel.tool_itemcost != 0
  151.         if $game_party.item_number($data_items[PearlKernel.tool_itemcost]) <= 0
  152.           $game_party.members.each {|mem|
  153.             mem.unequip_tool(item)
  154.             mem.unequip_tool($data_items[PearlKernel.tool_itemcost])
  155.           }
  156.           if SceneManager.scene_is?(Scene_Map)
  157.             SceneManager.scene.spriteset.pearl_tool_sprite.refresh_texts
  158.           end
  159.         end
  160.       end
  161.       if item.is_a?(RPG::Item)
  162.         if item.consumable && $game_party.item_number(item) <= 0
  163.           $game_party.members.each {|mem| mem.unequip_tool(item)}
  164.           if SceneManager.scene_is?(Scene_Map)
  165.             SceneManager.scene.spriteset.pearl_tool_sprite.refresh_texts
  166.           end
  167.         end
  168.       end
  169.     end
  170.   end
  171.    
  172. end
  173.  
  174. class Spriteset_Map
  175.  
  176.   attr_accessor :pearl_tool_sprite
  177.  
  178. end
  179.  
  180. class Scene_Map < Scene_Base
  181.  
  182.   attr_reader :spriteset
  183.  
  184. end
  185.  
  186. class Scene_QuickTool < Scene_MenuBase
  187.  
  188.   alias disable_unusable_tools6653 perform_item_ok
  189.   def perform_item_ok
  190.     return if @items_w.item.nil?
  191.     icst = @items_w.item.tool_data("Tool Item Cost = ")
  192.     if icst && icst > 0 && $game_party.item_number($data_items[icst]) <= 0
  193.       Sound.play_buzzer; return
  194.     end
  195.     if $imported && $imported["SixthABSToolVariables"]
  196.       if @items_w.item.var_req != 0 && $game_variables[@items_w.item.var_req] <= 0
  197.         Sound.play_buzzer; return
  198.       end
  199.     end
  200.     disable_unusable_tools6653
  201.   end
  202.  
  203. end
  204. #==============================================================================
  205. # !!END OF SCRIPT - OHH, NOES!!
  206. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement