CyberForte

Party Swap Redux

Apr 4th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.80 KB | None | 0 0
  1. # Instructions: First, decide how many parties you want to use and initialize
  2. # them with a script call of:
  3. #   setup_multiple_parties(number)
  4. # In theory, number can go as high as you want. Tested for 2, however.
  5. # Next, initialize each party with a scrip call of:
  6. #   define_party(number, member1, member 2, ...)
  7. # The first number in this script call determines which party you're defining
  8. # (note that parties start at 0, not 1), while the following numbers are the
  9. # actor ids of the members of that party. Actor ids start at 1, not 0, and
  10. # should not have leading zeros.
  11. # Finally, when you want to swap parties, use this call:
  12. #   swap_party(first_party, second_party)
  13. # first_party and second_party are the numbers of the two parties you want to
  14. # swap. first_party is the one you're swapping out and second_party is the one
  15. # you're swapping in.
  16.  
  17. # This script goes below materials and above main. Since all the methods are
  18. # new, it should be highly unlikely to have compatibility issues.
  19.  
  20. #==============================================================================
  21. # ■ Game_Party
  22. #==============================================================================
  23.  
  24. class Game_Party < Game_Unit
  25.  
  26.   def setup_multiple_parties(number)
  27.     @multiple_parties = []
  28.     i = 0
  29.     while i < number
  30.       @multiple_parties[i] = []
  31.       i += 1
  32.     end
  33.   end
  34.  
  35.   def multiple_parties(index, index2)
  36.     return @multiple_parties[index][index2]
  37.   end
  38.  
  39.  
  40.   def swap_party(first_party, second_party)
  41.     i = 0
  42.     while i < @multiple_parties[first_party].length
  43.       @multiple_parties[first_party][i] = $game_party.members[i].id
  44.       i += 1
  45.     end
  46.     i = 0
  47.     while i < @multiple_parties[first_party].length
  48.       $game_party.remove_actor(@multiple_parties[first_party][i])
  49.       i += 1
  50.     end    
  51.     i = 0
  52.     while i < @multiple_parties[second_party].length
  53.       $game_party.add_actor(@multiple_parties[second_party][i])
  54.       i += 1
  55.     end  
  56.   end
  57.  
  58.  
  59.   def party_clear(number)
  60.     @multiple_parties[number] = []
  61.   end
  62.  
  63.   def party_member_add(number, member)
  64.     @multiple_parties[number].push(member)
  65.   end
  66.  
  67.  
  68. end # Game_Party
  69.  
  70.  
  71. #==============================================================================
  72. # ■ Game_Interpreter
  73. #==============================================================================
  74.  
  75. class Game_Interpreter
  76.  
  77.   def swap_party(first_party, second_party)
  78.     $game_party.swap_party(first_party, second_party)
  79.   end
  80.  
  81.   def define_party(number, *members)
  82.     return if members.empty?
  83.       $game_party.party_clear(number)
  84.     for member in members
  85.       $game_party.party_member_add(number, member)
  86.     end
  87.   end
  88.  
  89.   def setup_multiple_parties(number)  
  90.     $game_party.setup_multiple_parties(number)
  91.   end
  92.  
  93. end
Add Comment
Please, Sign In to add comment