Advertisement
TheSixth

Party Switcher Addon for Tsukihime's Party Manager by Sixth

Sep 2nd, 2015
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.45 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Party Switcher Addon
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.3
  6. # * Released: 21/01/2015
  7. # * Requires: Tsukihime's Party Manager script
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (07/12/2014)
  12. #   - Initial release.
  13. # * Version 1.1 (10/12/2014)
  14. #   - Fixed a crash issue that happened when the current party ID got into the
  15. #     reserved party list. Switching the party afterwards resulted in a crash.
  16. #     No idea why would anyone do this, but it is crash-proof now for sure.
  17. #   - The reserve party script call will no longer add party IDs to the list
  18. #     which are already included in the reserved list. This messed up the correct
  19. #     order of party switching in certain cases.
  20. # * Version 1.2 (14/12/2014)
  21. #   - Fixed the check for Falcao's Interactive Tools System.
  22. #     There won't be any more crash because of that check! Sorry about those!
  23. # * Version 1.3 (21/01/2015)
  24. #   - Fixed the initialization of the reserved party list.
  25. #-------------------------------------------------------------------------------
  26. # * < Description >
  27. #-------------------------------------------------------------------------------
  28. # * This script makes party switching as easy as a button press.
  29. #   Separate button triggers for switching to the previous and next party!
  30. # * Reserved parties option, to prevent changing party to some specific parties
  31. #   you reserved for whatever reason(s)!
  32. # * Enable/disable party switching on the fly whenever you want!
  33. # * Add/remove parties to/from the reserved parties list on the fly!
  34. #-------------------------------------------------------------------------------
  35. # * < Script Calls >
  36. #-------------------------------------------------------------------------------
  37. # * To enable/disable the button trigger for the party switching, you can use
  38. #   the following script calls:
  39. #
  40. #     pm_party_switcher(true)  # Enables the party switching.
  41. #     pm_party_switcher(false) # Disables the party switching.
  42. #
  43. # * To add/remove parties to/from the reserved parties list, you can use the
  44. #   following script calls:
  45. #
  46. #     pm_reserve_party([party_ids]) # Adds the parties to reserve.
  47. #     pm_release_party([party_ids]) # Removes the parties from reserve.
  48. #
  49. #   Replace 'party_ids' with any number of party IDs.
  50. #   Examples:
  51. #
  52. #     pm_reserve_party([2,3]) # Adds the parties with ID 2 and 3 to reserve.
  53. #     pm_release_party([4])   # Removes the party with ID 4 from reserve.
  54. #
  55. #   NOTE: Do not ever add the same party ID as your current party's ID to the
  56. #         reserve party list! Make sure that never happens or you will get an
  57. #         error coming your way when you want to change parties!
  58. #
  59. #   No more script calls! o.o
  60. #-------------------------------------------------------------------------------
  61. # * < Installation >
  62. #-------------------------------------------------------------------------------
  63. # * In the script editor, place this script below Tsukihime's Party Manager and
  64. #   above Main.
  65. #-------------------------------------------------------------------------------
  66. # * < Compatibility Info >
  67. #-------------------------------------------------------------------------------
  68. # * This script isn't compatible with "Khas Pixel Movement" script...
  69. #   At least when I last checked, this was the case.
  70. #   If this has been changed since then, please let me know!
  71. # * Includes compatibility with the following scripts:
  72. #   - FA: Interactive Tools
  73. #   - CSCA: Dungeon Tools
  74. #   You won't be able to switch parties when the player uses a hook or has
  75. #   something picked up, for example.
  76. #-------------------------------------------------------------------------------
  77. # * < Known Issues >
  78. #-------------------------------------------------------------------------------
  79. # * No known issues that I know of.
  80. #-------------------------------------------------------------------------------
  81. # * < Terms of Use >
  82. #-------------------------------------------------------------------------------
  83. # * Free to use for whatever purposes you want.
  84. # * Credit me (Sixth) in your game, pretty please! :P
  85. # * Posting modified versions of this script is allowed as long as you notice me
  86. #   about it with a link to it!
  87. #===============================================================================
  88. $imported = {} if $imported.nil?
  89. $imported["SixthPartySwitcher"] = true
  90. #===============================================================================
  91. # Settings:
  92. #===============================================================================
  93. module Party_Switcher_S
  94.  
  95.   Next_Button = :L # Button for switching to the next available party.
  96.   Prev_Button = :R # Button for switching to the previous available party.
  97.  
  98.   # Reserved parties. The numbers in the array represent party IDs.
  99.   # Parties with these IDs can never get selected with the party switcher buttons.
  100.   # It is recommended to have at least one reserved party, which can act as a
  101.   # placeholder in case all of your other parties are at maximum party member
  102.   # capacity. If this ever happens, the remaining party members can stay in these
  103.   # parties and are available at a later point in the game to be synchronized
  104.   # with the other parties. These parties will hold their inventory as well, so
  105.   # you can bring up the party trade menu anytime if you ever need to get some
  106.   # items from these parties.
  107.   Reserved_Parties = [1]
  108.    
  109. end
  110. #===============================================================================
  111. # End of Settings! You can modify things below too if you don't mind the risk
  112. # of flaming potatoes dropping down on your PC...
  113. #===============================================================================
  114.  
  115. #==============================================================================
  116. # Game_Interpreter
  117. #------------------------------------------------------------------------------
  118. # Adding the new script call here.
  119. #==============================================================================
  120. class Game_Interpreter
  121.   #--------------------------------------------------------------------------
  122.   # Enable/Disable Party Switcher Script Call
  123.   #--------------------------------------------------------------------------
  124.   def pm_party_switcher(enable)
  125.     $game_system.button_party_switcher = enable
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # Reserve Party Script Call
  129.   #--------------------------------------------------------------------------
  130.   def pm_reserve_party(party_id)
  131.     party_id.each do |id|
  132.       $game_system.reserved_parties.push(id) if !$game_system.reserved_parties.include?(id)
  133.     end
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # Release Party Script Call
  137.   #--------------------------------------------------------------------------
  138.   def pm_release_party(party_id)
  139.     party_id.each do |id|
  140.       $game_system.reserved_parties.delete(id) if $game_system.reserved_parties.include?(id)
  141.     end
  142.   end
  143. end
  144. #==============================================================================
  145. # Game_System
  146. #------------------------------------------------------------------------------
  147. # Adding the party switch enable flag here.
  148. #==============================================================================
  149. class Game_System
  150.   #--------------------------------------------------------------------------
  151.   # New Public Instance Variable
  152.   #--------------------------------------------------------------------------
  153.   attr_accessor  :button_party_switcher,  :reserved_parties
  154.   #--------------------------------------------------------------------------
  155.   # Alias Method: Initialize
  156.   #--------------------------------------------------------------------------
  157.   alias sixth_party_switcher123 initialize
  158.   def initialize
  159.     sixth_party_switcher123
  160.     @button_party_switcher = true
  161.     @reserved_parties = Party_Switcher_S::Reserved_Parties
  162.   end
  163. end
  164. #==============================================================================
  165. # Module: Graphics
  166. #------------------------------------------------------------------------------
  167. # Adding the new button switch effect here.
  168. #==============================================================================
  169. module Graphics
  170.   class << self
  171.     alias :sixth_party_update122 :update
  172.   end
  173.   #---------------------------------------------------------------------------
  174.   # alias method: update
  175.   #---------------------------------------------------------------------------
  176.   def self.update(*args)
  177.     sixth_party_update122(*args)
  178.     if SceneManager.scene_is?(Scene_Map) && $game_system.button_party_switcher == true
  179.       # Switch to next party if the defined button is pressed
  180.       if Input.trigger?(Party_Switcher_S::Next_Button)
  181.         return if $game_party.in_battle
  182.         return if $game_player.moving? || $game_player.jumping?
  183.         return if $game_player.party_switching?
  184.         if defined?(FalInt) # checking for FA - Interactive Tools script
  185.           return if $game_player.grabing != nil
  186.           return if $game_player.showing_hook || $game_player.showing_fire
  187.           return if $game_player.gamebarrel.picked || $game_player.gamebomb.picked
  188.           for event in $game_map.events.values
  189.             return if event.picked
  190.           end
  191.         end
  192.         if $imported["CSCA-DungeonTools"] # checking for CSCA: Dungeon Tools script
  193.           return if $game_map.using_tool? && ($game_map.tooltype? == :hookshot || $game_map.tooltype? == :boomarang)
  194.         end
  195.         # starting switch next process
  196.         @total_p = Array.new
  197.         $game_parties.each do |party|
  198.           if !$game_system.reserved_parties.include?(party.id) && party.members.size > 0
  199.             @total_p.push(party.id)
  200.           end
  201.         end
  202.         @id = @total_p.index($game_party.id)
  203.         @done = false
  204.         @total_p.each do |pid|
  205.           if !@id.nil? && @total_p.index(pid) > @id && @done == false
  206.             $game_parties.switch_party(pid)
  207.             @done = true
  208.           end
  209.         end
  210.         if @done == false && $game_parties[@total_p[0]] && $game_party.id != @total_p[0] && $game_parties[@total_p[0]].members.size > 0
  211.           $game_parties.switch_party(@total_p[0])
  212.         end
  213.       end # next press check end
  214.       # Switch to previous party if the defined button is pressed
  215.       if Input.trigger?(Party_Switcher_S::Prev_Button)
  216.         return if $game_party.in_battle
  217.         return if $game_player.moving? || $game_player.jumping?
  218.         return if $game_player.party_switching?
  219.         if defined?(FalInt) # checking for FA - Interactive Tools script
  220.           return if $game_player.grabing != nil
  221.           return if $game_player.showing_hook || $game_player.showing_fire
  222.           return if $game_player.gamebarrel.picked || $game_player.gamebomb.picked
  223.           for event in $game_map.events.values
  224.             return if event.picked
  225.           end
  226.         end
  227.         if $imported["CSCA-DungeonTools"] # checking for CSCA: Dungeon Tools script
  228.           return if $game_map.using_tool? && ($game_map.tooltype? == :hookshot || $game_map.tooltype? == :boomarang)
  229.         end
  230.         # starting switch previous process
  231.         @total_p = Array.new
  232.         $game_parties.each do |party|
  233.           if !$game_system.reserved_parties.include?(party.id) && party.members.size > 0
  234.             @total_p.push(party.id)
  235.           end
  236.         end
  237.         @id = @total_p.index($game_party.id)
  238.         @done = false
  239.         @total_p.reverse.each do |pid|
  240.           if !@id.nil? && @total_p.index(pid) < @id && @done == false
  241.             $game_parties.switch_party(pid)
  242.             @done = true
  243.           end
  244.         end
  245.         if @done == false && $game_parties[@total_p[-1]] && $game_party.id != @total_p[-1] && $game_parties[@total_p[-1]].members.size > 0
  246.           $game_parties.switch_party(@total_p[-1])
  247.         end
  248.       end # prev press check end
  249.     end # Scene_Map check end
  250.   end # def update end
  251. end # module end
  252. #==============================================================================
  253. # !!END OF SCRIPT!!
  254. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement