Advertisement
Zetu

Party System

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