IceDragon200

IRS-MA-ReserveParty addon thingy

Apr 7th, 2011
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.42 KB | None | 0 0
  1. IRS_DISBAND_LABEL = "Disband"
  2. IRS_CHANGE_LABEL  = "Change"
  3. # Actor ids who can be discarded
  4. IRS_DISCARDABLES  = [1, 2]
  5. # // $game_actors[id].discardable = bool
  6. # // $game_actors[8].discardable = true
  7. # // $game_actors[1].discardable = false
  8.  
  9. module PartyManage
  10.  
  11.   module_function
  12.  
  13.   def discard_member(actor_id)
  14.     $game_party.remove_actor(actor_id)
  15.   end
  16.  
  17.   def discardable_member?(actor_id)
  18.     $game_actors[actor_id].discardable
  19.   end
  20.  
  21. end  
  22.  
  23. class Game_Actor < Game_Battler
  24.  
  25.   attr_accessor :discardable
  26.  
  27.   alias irp_ga_initialize initialize unless $@
  28.   def initialize(*args)
  29.     irp_ga_initialize(*args)
  30.     @discardable = false
  31.     @discardable = true if IRS_DISCARDABLES.include?(@actor_id)
  32.   end
  33.  
  34. end
  35.  
  36. class Window_MenuStatus
  37.  
  38.   def actor_at(index)
  39.     mems = $game_party.members
  40.     memsrev = $game_party.ma_reserve_members
  41.     case index
  42.     when 0...4
  43.       return mems[index]
  44.     when 4...PARTY_CHANGE_MAX_RESERVE_SIZE+4
  45.       return memsrev[index-4]
  46.     end
  47.     return nil
  48.   end
  49.  
  50. end
  51.  
  52. class Scene_Menu < Scene_Base
  53.  
  54.   def create_irs_window
  55.     Sound.play_decision
  56.     @irs_window = Window_Command.new(160, [IRS_CHANGE_LABEL, IRS_DISBAND_LABEL])
  57.     @irs_window.x = @status_window.x + ((@status_window.width-@irs_window.width)/2)
  58.     @irs_window.y = @status_window.y + ((@status_window.height-@irs_window.height)/2)
  59.     update_irs_command
  60.   end
  61.  
  62.   def update_irs_command
  63.     actor_at_index = @status_window.actor_at(@status_window.index)
  64.     if actor_at_index.nil?
  65.       @irs_window.draw_item(1, false)
  66.     elsif !actor_at_index.discardable
  67.       @irs_window.draw_item(1, false)
  68.     end  
  69.     loop do
  70.       Graphics.update
  71.       Input.update
  72.       @irs_window.update
  73.       if Input.trigger?(Input::C)
  74.         case @irs_window.index
  75.         when 1
  76.           if actor_at_index != nil
  77.             if PartyManage.discardable_member?(actor_at_index.id)
  78.               Sound.play_decision
  79.               PartyManage.discard_member(actor_at_index.id)
  80.               @status_window.refresh
  81.               @irs_window.dispose
  82.               return 2
  83.             else ; Sound.play_buzzer end
  84.           else ; Sound.play_buzzer end
  85.         when 0  
  86.           Sound.play_decision
  87.           @irs_window.dispose
  88.           return 1
  89.         end  
  90.       elsif Input.trigger?(Input::B)
  91.         Sound.play_cancel
  92.         @irs_window.dispose
  93.         return 0
  94.       end  
  95.     end  
  96.   end
  97.  
  98.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  99.   # * Update Actor Selection
  100.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  101.   def update_actor_selection
  102.     # If in Party switching mode
  103.     if @switching_party
  104.       # If exiting the scene
  105.       if Input.trigger? (Input::B)
  106.         Sound.play_cancel
  107.         # If no other position selected already, exit party arrangement
  108.         if @selected_index == -1
  109.           @status_window.create_contents (false)
  110.           y = ($game_party.members.size - @status_window.top_row)*96 + 16
  111.           @disabledactors_sprite.create_bitmap (false, y)
  112.           @switching_party = false
  113.           end_actor_selection
  114.         else
  115.           # Remove previously selected index
  116.           @selected_index = -1
  117.           @selected_actorcursor.visible = false
  118.         end
  119.       # If an actor is selected
  120.       elsif Input.trigger? (Input::C)
  121.         index = @status_window.index
  122.         ans = create_irs_window
  123.         return if [0, 2].include?(ans)
  124.         # If selecting previously selected slot
  125.         if index == @selected_index
  126.           Sound.play_cancel
  127.           @selected_index = -1
  128.           @selected_actorcursor.visible = false
  129.           return
  130.         end
  131.         # If selecting from a reserve slot
  132.         if index >= $game_party.ma_max_active_size
  133.           ma_select_reserve (index)
  134.         else # If selecting from active party
  135.           ma_select_active (index)
  136.         end
  137.       end
  138.     else
  139.       changed = false
  140.       if @command_window.index > PARTY_CHANGE_MENU_INDEX
  141.         @command_window.index = (@command_window.index - 1) % @command_window.commands.size
  142.         changed = true
  143.       end
  144.       # Run Original Method
  145.       modalg_resev_prty_upd_actr_selct
  146.       @command_window.index = (@command_window.index + 1) % @command_window.commands.size if changed
  147.       $game_party.ma_return_reserve_members = true unless $scene.is_a? (Scene_Menu)
  148.     end
  149.   end
  150.  
  151. end
Advertisement
Add Comment
Please, Sign In to add comment