Advertisement
Zetu

Party System

May 27th, 2011
1,292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.63 KB | None | 0 0
  1.                             #======================#
  2.                             #  Z-Systems by: Zetu  #
  3. #===========================#======================#===========================#
  4. #                     *  *  *  Party System v1.03  *  *  *                     #
  5. #=#==========================================================================#=#
  6.   # CONTROLS :                                                               #
  7.   # $game_party.full_party = Array of all actors based on FULLPARTY's indexs #
  8.   # (ACTOR).unlock  = Gives access to this charactor.                        #
  9.   #   Starting party members are automatically unlocked!                     #
  10.   #   Actors added to the party using the Add Event are automatically        #
  11.   #     unlocked if actor is disabled.                                       #
  12.   # (ACTOR).lock    = Prevents actor from joining/leaving party.             #
  13.   # (ACTOR).disable = Disables access to this charactor.                     #
  14.   #   Good for if an actor permenatly leaves a party or dies (poor Aeris)    #
  15.   # (ACOTR).locked?   = Checks if an actor is locked.                        #
  16.   # (ACTOR).unlocked? = Checks if an actor is enabled.                       #
  17.   #==========================================================================#
  18.   # This script does NOT have a default menu positon.  Use the call script   #
  19.   # '$scene = Scene_PartySys' for an event call and                          #
  20.   # '$scene = Scene_PartySys(true)' for menu scripts.  Recommend use for     #
  21.   # Neo Menu System (http://www.rpgmakervx.net/index.php?showtopic=42742)    #
  22.   #==========================================================================#
  23.   # OVERWRITES:                                                              #
  24.   # * Game_Interpreter::command_129                                          #
  25.   #==========================================================================#
  26.   # VERSION HISTORY:                                                         #
  27.   # v1.02                                                                    #
  28.   # * General Bug Fixes                                                      #
  29.   # * Frames Added                                                           #
  30.   # * No longer draws disabled actors                                        #
  31.   # v1.03                                                                    #
  32.   # * Step Fix                                                               #
  33.   #==========================================================================#
  34.  
  35. module Z_Systems
  36.   module Party_System
  37.     FULLPARTY = 1..8 #Array of indexs for all party members to be included
  38.                      #within the menu.  Max 8! 0 is NOT a valid index.
  39.     INDEX = 4 #Index of Menu
  40.   end
  41. end
  42. #========#======================#====#================================#========#
  43. #--------#                      #----# DO NOT EDIT PAST THIS POINT!!! #--------#
  44. #--------# End of Customization #----# Editing will cause death by    #--------#
  45. #--------#                      #----# brain asplosions.              #--------#
  46. #========#======================#====#================================#========#
  47.  
  48. class Scene_PartySys < Scene_Base
  49.  
  50.   def initialize(from_menu = false)
  51.     @window_a = Window_PartySys_A.new
  52.     @window_b = Window_PartySys_B.new
  53.     @window_a.active = true
  54.     @from_menu = from_menu
  55.   end
  56.  
  57.   def update
  58.     super
  59.     if @window_a.active
  60.       update_window_a
  61.     elsif @window_b.active
  62.       update_window_b
  63.     end
  64.   end
  65.  
  66.   def return_scene
  67.     if @from_menu
  68.       $scene = Scene_Menu.new(Z_Systems::Party_System::INDEX)
  69.     else
  70.       $scene = Scene_Map.new
  71.     end
  72.   end
  73.  
  74.   def update_window_a
  75.     if Input.trigger?(Input::B)
  76.       if $game_party.members.size == 0
  77.         Sound.play_buzzer
  78.       else
  79.         Sound.play_cancel
  80.         return_scene
  81.       end
  82.     elsif Input.trigger?(Input::C)
  83.       actor = $game_party.members[@window_a.index]
  84.       if $game_party.lock_array[@window_a.index] == true
  85.         Sound.play_buzzer
  86.         return
  87.       end
  88.       if actor == nil
  89.         Sound.play_buzzer
  90.         return
  91.       end
  92.       $game_party.remove_actor(actor.actor_index)
  93.       Sound.play_cancel
  94.       @window_a.refresh
  95.       @window_b.refresh
  96.     elsif Input.trigger?(Input::DOWN)
  97.       @window_a.index += 1
  98.       @window_a.index %= 4
  99.     elsif Input.trigger?(Input::UP)
  100.       @window_a.index += 3
  101.       @window_a.index %= 4
  102.     elsif Input.trigger?(Input::RIGHT)
  103.       @window_a.active = false
  104.       @window_b.active = true
  105.       @window_b.index = 2*@window_a.index
  106.       @window_a.index = -1
  107.     end
  108.   end
  109.    
  110.   def update_window_b
  111.     if Input.trigger?(Input::B)
  112.       if $game_party.members.size == 0
  113.         Sound.play_buzzer
  114.       else
  115.         Sound.play_cancel
  116.         return_scene
  117.       end
  118.     elsif Input.trigger?(Input::C)
  119.       actor = $game_party.full_party[@window_b.index]
  120.       if actor.locked?
  121.         Sound.play_buzzer
  122.         return
  123.       end
  124.       if actor == nil
  125.         Sound.play_buzzer
  126.         return
  127.       end
  128.       if $game_party.members.include?(actor)
  129.         Sound.play_buzzer
  130.         return
  131.       end
  132.       $game_party.add_actor(actor.actor_index)
  133.       Sound.play_decision
  134.       @window_a.refresh
  135.       @window_b.refresh
  136.     elsif Input.trigger?(Input::DOWN)
  137.       @window_b.index += 2
  138.       @window_b.index %= 8
  139.     elsif Input.trigger?(Input::UP)
  140.       @window_b.index += 6
  141.       @window_b.index %= 8
  142.     elsif Input.trigger?(Input::LEFT)
  143.       if @window_b.index%2 == 0
  144.         @window_a.active = true
  145.         @window_b.active = false
  146.         @window_a.index = @window_b.index/2
  147.         @window_b.index = -1
  148.       else
  149.         @window_b.index -= 1
  150.       end
  151.     elsif Input.trigger?(Input::RIGHT)
  152.       @window_b.index += 1
  153.       @window_b.index %= 8
  154.     end
  155.   end
  156.  
  157.   def terminate
  158.     @window_a.dispose
  159.     @window_b.dispose
  160.   end
  161.  
  162. end
  163.  
  164. class Game_Party < Game_Unit
  165.  
  166.   def full_party
  167.     result = []
  168.     for i in Z_Systems::Party_System::FULLPARTY
  169.       result.push($game_actors[i])
  170.     end
  171.     return result
  172.   end
  173.  
  174.   def lock_array
  175.     result = []
  176.     for actor in members
  177.       result.push(actor.locked?)
  178.     end
  179.     return result
  180.   end
  181.  
  182. end
  183.  
  184. class Game_Actor < Game_Battler
  185.  
  186.   alias zsps_setup setup
  187.   def setup(actor_id)
  188.     zsps_setup(actor_id)
  189.     @locked   = $data_system.party_members.include?(actor_id) == false
  190.     @unlocked = $data_system.party_members.include?(actor_id)
  191.   end
  192.  
  193.   def locked?
  194.     return @locked
  195.   end
  196.  
  197.   def unlocked?
  198.     return @unlocked
  199.   end
  200.  
  201.   def unlock
  202.     @locked   = false
  203.     @unlocked = true
  204.   end
  205.  
  206.   def lock
  207.     @locked = true
  208.   end
  209.  
  210.   def disable
  211.     @locked   = true
  212.     @unlocked = false
  213.   end
  214.  
  215.   def actor_index
  216.     return @actor_id
  217.   end
  218.  
  219. end
  220.  
  221.  
  222.  
  223. class Game_Interpreter
  224.  
  225.   def command_129                                                     #OVERWRITE
  226.     actor = $game_actors[@params[0]]
  227.     if actor != nil
  228.       if @params[1] == 0
  229.         if @params[2] == 1
  230.           $game_actors[@params[0]].setup(@params[0])
  231.         end
  232.         $game_party.add_actor(@params[0])
  233.       else
  234.         $game_party.remove_actor(@params[0])
  235.       end
  236.       $game_map.need_refresh = true
  237.     end
  238.     $game_actors[@params[0]].unlock if @params[1] == 0
  239.     return true
  240.   end
  241.  
  242. end
  243.  
  244.  
  245.  
  246. class Window_PartySys_A < Window_Selectable
  247.  
  248.   def initialize
  249.     super(0, 0, 192, 416)
  250.     refresh
  251.     self.index = 0
  252.   end
  253.  
  254.   def refresh
  255.     self.contents.clear
  256.     @item_max = 4
  257.     for actor in $game_party.members
  258.       draw_actor_face(actor, 2, actor.index * 96 + 2, 92)
  259.       x = 56
  260.       y = actor.index * 96 + WLH / 2
  261.       if actor.locked? == true
  262.         draw_actor_face(actor, 2, actor.index * 96 + 2, 92)
  263.         draw_frame(1, y - WLH/2, 158, 94, text_color(14))
  264.         draw_actor_name(actor, x, y)
  265.         draw_actor_class(actor, x, y + WLH)
  266.         draw_actor_level(actor, x, y + WLH * 2)
  267.       else
  268.         draw_actor_face(actor, 2, actor.index * 96 + 2, 92)
  269.         draw_frame(1, y - WLH/2, 158, 94, text_color(3))
  270.         draw_actor_name(actor, x, y)
  271.         draw_actor_class(actor, x, y + WLH)
  272.         draw_actor_level(actor, x, y + WLH * 2)
  273.       end
  274.     end
  275.   end
  276.  
  277.   def update_cursor
  278.     if @index < 0               # No cursor
  279.       self.cursor_rect.empty
  280.     elsif @index < @item_max    # Normal
  281.       self.cursor_rect.set(0, @index * 96, contents.width, 96)
  282.     elsif @index >= 100         # Self
  283.       self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
  284.     else                        # All
  285.       self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
  286.     end
  287.   end
  288.  
  289. end
  290.  
  291.  
  292.  
  293. class Window_PartySys_B < Window_Selectable
  294.  
  295.   def initialize
  296.     super(192, 0, 352, 416)
  297.     refresh
  298.     self.active = false
  299.     self.index = -1
  300.   end
  301.  
  302.   def refresh
  303.     self.contents.clear
  304.     @item_max = 8
  305.     xo = 0
  306.     for actor in $game_party.full_party
  307.       x = 160 * (xo%2) + 56
  308.       y = xo/2 * 96 + WLH / 2
  309.       if actor.unlocked? != true
  310.         draw_frame(1 + 160 * (xo%2), y - WLH/2, 158, 94, text_color(7))
  311.       elsif actor.locked? == true or $game_party.members.include?(actor)
  312.         draw_actor_face(actor, 2 + 160 * (xo%2), y - WLH/2, 92)
  313.         draw_frame(1 + 160 * (xo%2), y - WLH/2, 158, 94, text_color(14))
  314.         draw_actor_name(actor, x, y)
  315.         draw_actor_class(actor, x, y + WLH)
  316.         draw_actor_level(actor, x, y + WLH * 2)
  317.       else
  318.         draw_actor_face(actor, 2 + 160 * (xo%2), y - WLH/2, 92)
  319.         draw_frame(1 + 160 * (xo%2), y - WLH/2, 158, 94, text_color(3))
  320.         draw_actor_name(actor, x, y)
  321.         draw_actor_class(actor, x, y + WLH)
  322.         draw_actor_level(actor, x, y + WLH * 2)
  323.       end
  324.       xo += 1
  325.     end
  326.   end
  327.  
  328.   def update_cursor
  329.     if @index < 0               # No cursor
  330.       self.cursor_rect.empty
  331.     elsif @index < @item_max    # Normal
  332.       self.cursor_rect.set(160*(@index%2), (@index/2) * 96, contents.width/2, 96)
  333.     elsif @index >= 100         # Self
  334.       self.cursor_rect.set(160*(@index%2), ((@index/2) - 100) * 96, contents.width/2, 96)
  335.     else                        # All
  336.       self.cursor_rect.set(160*(@index%2), 0, contents.width/2, @item_max/2 * 96)
  337.     end
  338.   end
  339.  
  340. end
  341.  
  342. class Window_Base < Window
  343.  
  344.   def draw_frame(x, y, width, height, color = normal_color)
  345.     self.contents.fill_rect(x, y, 1, height, color)
  346.     self.contents.fill_rect(x, y, width, 1, color)
  347.     self.contents.fill_rect(x + width - 1, y, 1, height, color)
  348.     self.contents.fill_rect(x, y + height - 1, width, 1, color)
  349.   end
  350.  
  351. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement