Advertisement
Guest User

Untitled

a guest
Jan 17th, 2015
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.52 KB | None | 0 0
  1. #------------------------------------------------------------------------------#
  2. #  Galv's Party Selector
  3. #------------------------------------------------------------------------------#
  4. #  For: RPGMAKER VX ACE
  5. #  Version 1.8
  6. #------------------------------------------------------------------------------#
  7. #  2013-06-12 - Version 1.8 - minor change for compatibility reasons
  8. #  2013-02-27 - Version 1.7 - fixed a bug with lots of party members
  9. #  2013-01-09 - Version 1.6 - added party call without the leader
  10. #  2013-01-09 - Version 1.5 - setting added for number of faces visible
  11. #  2013-01-07 - Version 1.4 - fixed more than 5 actors and bugs
  12. #  2013-01-07 - Version 1.2 - added ability to set list of actors to choose
  13. #  2013-01-06 - Version 1.1 - bug fixes
  14. #  2013-01-06 - Version 1.0 - release
  15. #------------------------------------------------------------------------------#
  16. # A simple window that allows you to select one of your party members and like
  17. # the 'select key item' window, it stores the actor ID of the party member
  18. # chosen into the variable you set in the settings. You then use this in a
  19. # conditional branch.
  20. #
  21. # NOTE: This script is not a full-blown party recruit system and I won't be
  22. # updating it to be as such. It's meant to be a simple event utility script.
  23. #
  24. #------------------------------------------------------------------------------#
  25. #  INSTRUCTIONS:
  26. #------------------------------------------------------------------------------#
  27. #  Put script under Materials and above Main
  28. #  Images go in /Graphics/Pictures folder.
  29. #
  30. #------------------------------------------------------------------------------#
  31. #  SCRIPT CALLS:
  32. #------------------------------------------------------------------------------#
  33. #
  34. #  party_select(0)     # Calls party select window with current party members
  35. #
  36. #  party_select(-1)    # Calls party select window without the leader
  37. #
  38. #  party_select(1,2,3,4,5) # Calls party select window with list of actors with
  39. #                          # ID's included in this list.
  40. #------------------------------------------------------------------------------#
  41.  
  42. ($imported ||= {})["Galvs_PartySelector"] = true
  43. module Galv_PartyPick
  44.  
  45. #------------------------------------------------------------------------------#
  46. #  SCRIPT SETTINGS
  47. #------------------------------------------------------------------------------#
  48.  
  49.   VARIABLE_ID = 7           # Variable ID the actor ID is stored in.
  50.    
  51.   FACES_VISIBLE = 5        # Number of faces visible on screen.
  52.  
  53. #------------------------------------------------------------------------------#
  54. #  END SCRIPT SETTINGS
  55. #------------------------------------------------------------------------------#
  56.  
  57. end
  58.  
  59.  
  60. class Window_Message < Window_Base
  61.    
  62.   alias galv_partypick_create_all_windows create_all_windows
  63.   def create_all_windows
  64.     galv_partypick_create_all_windows
  65.     @partypick_window = Window_Party_Selector.new
  66.   end
  67.    
  68.   alias galv_partypick_dispose_all_windows dispose_all_windows
  69.   def dispose_all_windows
  70.     galv_partypick_dispose_all_windows
  71.     @partypick_window.dispose
  72.   end
  73.    
  74.   alias galv_partypick_update_all_windows update_all_windows
  75.   def update_all_windows
  76.     galv_partypick_update_all_windows
  77.     @partypick_window.update
  78.   end
  79.    
  80.   alias galv_partypick_process_input process_input
  81.   def process_input
  82.     if $game_message.party_select == true
  83.       return party_select
  84.     end
  85.     galv_partypick_process_input
  86.   end
  87.  
  88.   def party_select
  89.     @partypick_window.start
  90.     Fiber.yield while @partypick_window.active
  91.   end
  92.    
  93. end # Window_Message < Window_Base
  94.  
  95.  
  96. class Window_Party_Selector < Window_Selectable
  97.  
  98.   def initialize
  99.       super(window_x, 0, window_width, 96 + standard_padding * 2)
  100.       self.openness = 0
  101.       @set = true
  102.       get_item_max
  103.       refresh
  104.       deactivate
  105.       set_handler(:ok,     method(:on_ok))
  106.       set_handler(:cancel, method(:on_cancel))
  107.     end
  108.      
  109.   def window_x
  110.     (Graphics.width - window_width) / 2
  111.   end
  112.    
  113.   def window_width
  114.     return (96 * col_max) + (standard_padding * 2)
  115.   end
  116.  
  117.   def visible_line_number
  118.     return 1
  119.   end
  120.  
  121.   def col_max
  122.     return Galv_PartyPick::FACES_VISIBLE
  123.   end
  124.    
  125.   def spacing
  126.     return 0
  127.   end
  128.    
  129.   def get_item_max
  130.     if $game_message.party_list == [0] || $game_message.party_list[0] < 0
  131.       @item_max = $game_party.members.count
  132.       @item_max -= 1 if $game_message.party_list[0] < 0
  133.     else
  134.       @item_max = $game_message.party_list.count
  135.     end
  136.   end
  137.    
  138.   def contents_width
  139.     0  #item_width * (item_max + 23) - spacing
  140.   end
  141.    
  142.   def contents_height
  143.     item_height
  144.   end
  145.    
  146.   def start
  147.     get_item_max
  148.     update_y
  149.     refresh
  150.     select(0)
  151.     open
  152.     activate
  153.   end
  154.    
  155.   def update_y
  156.     if $game_message.position == 2
  157.       self.y = 0
  158.     else
  159.       self.y = Graphics.height - height
  160.     end
  161.   end
  162.    
  163.   def refresh
  164.       self.contents.clear
  165.       self.contents = Bitmap.new(@item_max * 96, 96)
  166.       for i in 0...@item_max
  167.          draw_item(i) unless i == nil
  168.       end
  169.   end
  170.    
  171.   def check_item_max
  172.     @data_max = 0
  173.     @data_max -= 1 if $game_message.party_list[0] < 0
  174.     if $game_message.party_list == [0] || $game_message.party_list[0] < 0
  175.        
  176.       @data_max = $game_party.members.count
  177.     else
  178.        
  179.         @data_max = $game_message.party_list.count
  180.        
  181.     end
  182.   end
  183.    
  184.   def item_height
  185.     96
  186.   end
  187.  
  188.   def item_width
  189.     96
  190.   end
  191.    
  192.   def draw_item(index)
  193.     x = index * (item_width + spacing)
  194.     y = 0
  195.     check_item_max
  196.     if $game_message.party_list == [0]
  197.       @mem = $game_party.members
  198.       draw_face(@mem[index].face_name, @mem[index].face_index, x, y, @set)
  199.       draw_text(x, y, 128, line_height, $game_party.members[index].name, 1)
  200.     elsif $game_message.party_list[0] < 0
  201.       @mem = $game_party.members
  202.       draw_face(@mem[index+1].face_name, @mem[index+1].face_index, x, y, @set)
  203.       draw_text(x, y, 128, line_height, $game_party.members[index+1].name, 1)
  204.     else
  205.       @mem = $game_actors
  206.       @plist = $game_message.party_list
  207.       draw_face(@mem[@plist[index]].face_name, @mem[@plist[index]].face_index, x, y, @set)
  208.       draw_text(x, y, 128, line_height, @mem[@plist[index]].name, 1)
  209.     end
  210.   end
  211.  
  212.   def item_max
  213.     return @item_max == nil ? 0 : @item_max
  214.   end      
  215.    
  216.   def on_ok
  217.     if $game_message.party_list == [0]
  218.       $game_variables[Galv_PartyPick::VARIABLE_ID] = @mem[index].id
  219.     elsif $game_message.party_list[0] < 0
  220.       $game_variables[Galv_PartyPick::VARIABLE_ID] = @mem[index+1].id
  221.     else
  222.       $game_variables[Galv_PartyPick::VARIABLE_ID] = @plist[index]
  223.     end
  224.     $game_message.party_select = false
  225.     close
  226.   end
  227.  
  228.   def on_cancel
  229.     $game_variables[Galv_PartyPick::VARIABLE_ID] = 0
  230.     $game_message.party_select = false
  231.     close
  232.   end
  233.    
  234.   def top_col
  235.     ox / (item_width + spacing)
  236.   end
  237.  
  238.   def top_col=(col)
  239.     col = 0 if col < 0
  240.     col = item_max if col > item_max
  241.     self.ox = col * (item_width + spacing)
  242.   end
  243.  
  244.   def bottom_col
  245.     top_col + col_max - 1
  246.   end
  247.  
  248.   def bottom_col=(col)
  249.     self.top_col = col - (col_max - 1)
  250.   end
  251.  
  252.   def ensure_cursor_visible
  253.     self.top_col = index if index < top_col
  254.     self.bottom_col = index if index > bottom_col
  255.   end
  256.  
  257.   def item_rect(index)
  258.     rect = super
  259.     rect.x = index * (item_width + spacing)
  260.     rect.y = 0
  261.     rect
  262.   end
  263.    
  264. end #Window_Party_Selector < Window_Selectable
  265.  
  266.  
  267. class Game_Message
  268.   attr_accessor :party_select
  269.   attr_accessor :party_list
  270.    
  271.   alias galv_partypick_clear clear
  272.   def clear
  273.     galv_partypick_clear
  274.     @party_select = false
  275.     @party_list = [0]
  276.   end
  277. end # Game_Message
  278.  
  279. class Game_Interpreter
  280.   def party_select(*args)
  281.     wait_for_message
  282.  
  283.     $game_message.party_list = [*args]
  284.     $game_message.party_select = true
  285.  
  286.     if @list[@index + 2].code == 401
  287.        
  288.       if @list[@index + 1].code == 101
  289.         $game_message.face_name = @list[@index + 1].parameters[0]
  290.         $game_message.face_index = @list[@index + 1].parameters[1]
  291.         $game_message.background = @list[@index + 1].parameters[2]
  292.         $game_message.position = @list[@index + 1].parameters[3]
  293.       end
  294.        
  295.       while @list[@index + 2].code == 401
  296.       @index += 1
  297.       $game_message.add(@list[@index + 1].parameters[0])
  298.       end
  299.        
  300.     else
  301.       $game_message.add("")
  302.       $game_message.background = 2
  303.       $game_message.position = 2
  304.     end
  305.     wait_for_message
  306.  
  307.   end
  308. end # Game_Interpreter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement