CrowMakerVX

Party ReOrder 1.1a

Dec 14th, 2012
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.87 KB | None | 0 0
  1. ################################################################################
  2. #                          ReOrderParty 1.1a
  3. #                             By: Ixfuru
  4. #
  5. #                      As Requested by: Esperhunter
  6. ################################################################################
  7.  
  8. # This script provides a simple, effecient way to manage the position your party
  9. # is arranged in.  THIS IS NOT A PARTY RESERVE SCRIPT!   You call the scene by
  10. # placing a script call command in an event (third page of event commands) and
  11. # entering the following line:
  12. #
  13. #                  $scene = Scene_ReOrder.new
  14. #
  15. # The controls of the scene are listed in a visible help window.  From a keyboard,
  16. # the controls are:
  17. #
  18. #               A: Shift
  19. #               B: Cancel Button (X, ESC)
  20. #               C: Action Button(Space, Enter or Z)
  21. #
  22. # There are few customization options.  But the script is pretty simple.  
  23. ################################################################################
  24. # Feel free to use this script for commercial or NON commercial projects.  Just
  25. # give credit to IXFURU somewhere and send me a link to your project.
  26. ################################################################################
  27.  
  28. ################################################################################
  29. #                 CUSTOMIZE BELOW
  30. ################################################################################
  31.  
  32. module IROP
  33.  
  34.   REORDER_TITLE = "Reorder the Party" #The title displayed on the scene
  35.   ROP_TITLE_COLOR = 22 #The color of the title's text
  36.   ROP_HELP_COLOR = 31 #Help information text color
  37.   ROP_DELETE_SOUND = "Blow2" #sound when an actor is removed from new position
  38.   ROP_FULL_SOUND = "Chime2" #sound when last member is placed into new position
  39.   REORDER_CONFIRM_TEXT = "Continue" #text shown in order to confirm you are finished
  40.   REORDER_CANCEL_TEXT = "Cancel" #text shown as option to cancel finishing the scene
  41.   USE_FROM_MENU = false #Set to true if you want the ability to have the scene from the menu
  42.  
  43.   # You only have to worry about the last two if you set the USE_FROM_MENU as true
  44.   IROP_NOACCESS_SWITCH = 1 #When this switch is ON, the menu command will be inaccessible
  45.   MENU_REORDER_COMMAND = "Reorder" #String to display as string in menu
  46. end
  47. ################################################################################
  48. #             CUSTOMIZE END
  49. ################################################################################
  50.  
  51. ################################################################################
  52. #===============================================================================
  53. ################################################################################
  54.  
  55. #-------------------------------------------------------------------------------
  56. #                 Game_Temp
  57. #-------------------------------------------------------------------------------
  58. class Game_Temp
  59.  
  60.   attr_accessor :reorder_from #make access to value for whether scene reorder is
  61.                                 #accessed from map or menu
  62.                                
  63.   alias irop_gt_initialize initialize unless $@
  64.   def initialize
  65.     irop_gt_initialize
  66.     @reorder_from = 0
  67.   end
  68.  
  69. end
  70.  
  71.  
  72. #-------------------------------------------------------------------------------
  73. #                Game_Party
  74. #-------------------------------------------------------------------------------
  75. class Game_Party < Game_Unit
  76.  
  77.   def get_reorder(order)
  78.     for i in 0...order.size
  79.       add_actor(order[i])
  80.     end
  81.   end
  82.  
  83.   def remove_all_actors
  84.     for member in members
  85.       remove_actor(member.id)
  86.     end
  87.   end
  88.  
  89. end
  90.  
  91. #-------------------------------------------------------------------------------
  92. #                       WindowRopPopUp
  93. #-------------------------------------------------------------------------------
  94. class Window_Rop_Pop < Window_Selectable
  95.  
  96.   include IROP
  97.  
  98.   def initialize(x, y)
  99.     super(x, y, 180, 90)
  100.     @commands = [REORDER_CONFIRM_TEXT, REORDER_CANCEL_TEXT]
  101.     @item_max = @commands.size
  102.     refresh
  103.     self.index = 0
  104.   end
  105.  
  106.   def refresh
  107.     self.contents.clear
  108.     for i in 0...@item_max
  109.       draw_item(i)
  110.     end
  111.   end
  112.  
  113.   def draw_item(index, enabled = true)
  114.     rect = item_rect(index)
  115.     rect.x += 4
  116.     rect.width -= 8
  117.     self.contents.font.color = normal_color
  118.     self.contents.draw_text(rect, @commands[index])
  119.   end
  120.  
  121. end
  122.  
  123. #-------------------------------------------------------------------------------
  124. #                         WindowRopTitle
  125. #-------------------------------------------------------------------------------
  126. class Window_Rop_Title < Window_Base
  127.  
  128.   include IROP
  129.  
  130.   def initialize(x, y)#pass 60, 0
  131.     super(x, y, 360, 60)
  132.     refresh
  133.   end
  134.  
  135.   def refresh
  136.     self.contents.clear
  137.     self.contents.font.color = text_color(ROP_TITLE_COLOR)
  138.     self.contents.draw_text(-8, 0, self.width, WLH, REORDER_TITLE, 1)
  139.   end
  140.  
  141. end
  142.  
  143.  
  144. #-------------------------------------------------------------------------------
  145. #                       WindowRopHelp
  146. #-------------------------------------------------------------------------------
  147. class Window_Rop_Help < Window_Base
  148.  
  149.   include IROP
  150.  
  151.   attr_writer :helptext
  152.  
  153.   def initialize(x, y)#pass 60, 311
  154.     super(x, y, 360, 60)
  155.     @helptext = 0
  156.     refresh
  157.   end
  158.  
  159.   def refresh
  160.     self.contents.clear
  161.     self.contents.font.color = text_color(ROP_HELP_COLOR)
  162.     if @helptext == 0
  163.       self.contents.draw_text(-8, 0, self.width, WLH, "C: Select, B:Exit", 1)
  164.     elsif @helptext == 1
  165.       self.contents.draw_text(-8, 0, self.width, WLH, "C:Select, B:Exit, A:Delete", 1)
  166.     elsif @helptext == 2
  167.       self.contents.draw_text(-8, 0, self.width, WLH, "C:Select", 1)
  168.     end
  169.   end
  170.  
  171. end
  172.  
  173.    
  174. #-------------------------------------------------------------------------------
  175. #                         WindowOrder
  176. #-------------------------------------------------------------------------------
  177.  
  178. class Window_Order < Window_Selectable
  179.  
  180.   attr_accessor :disableds
  181.   attr_accessor :commands
  182.  
  183.   def initialize(x, y)
  184.     super(x, y, 180, 230)
  185.     @commands = []
  186.     for i in 0...$game_party.members.size
  187.       @commands.push($game_party.members[i].name)
  188.     end
  189.     @disableds = []
  190.     get_disabled
  191.     @item_max = @commands.size
  192.     refresh
  193.     self.index = 0
  194.   end
  195.  
  196.   def refresh
  197.     self.contents.clear
  198.     for i in 0...@item_max
  199.       if @disableds != nil
  200.         if @disableds[i] == false
  201.           draw_item(i)
  202.         else
  203.           draw_item(i, false)
  204.         end
  205.       else
  206.         draw_item(i)
  207.       end
  208.     end
  209.   end
  210.  
  211.   def draw_item(index, enabled = true)
  212.     rect = item_rect(index)
  213.     rect.x += 4
  214.     rect.width -= 8
  215.     self.contents.clear_rect(rect)
  216.     self.contents.font.color = normal_color
  217.     self.contents.draw_text(rect, @commands[index])
  218.   end
  219.  
  220.   def get_disabled
  221.     for i in 0...$game_party.members.size
  222.       @disableds.push(false)
  223.     end
  224.   end
  225.  
  226. end
  227.  
  228. #-------------------------------------------------------------------------------
  229. #                     WindowReOrder
  230. #-------------------------------------------------------------------------------
  231.  
  232. class Window_ReOrder < Window_Selectable
  233.  
  234.   attr_accessor :placed
  235.   attr_accessor :commands
  236.  
  237.   def initialize(x, y)
  238.     super(x, y, 180, 230)
  239.     @commands = [] #create array for commands
  240.     for i in 0...$game_party.members.size # in every selection option
  241.       @commands.push("") #create a blank option
  242.     end
  243.     @placed = [] #create array for slots filled in new order
  244.     get_placed
  245.     @item_max = @commands.size
  246.     refresh
  247.     self.index = 0
  248.   end
  249.  
  250.   def refresh
  251.     self.contents.clear
  252.     for i in 0...@item_max
  253.       draw_item(i)
  254.     end
  255.   end
  256.  
  257.   def draw_item(index, enabled = true)
  258.     rect = item_rect(index)
  259.     rect.x += 4
  260.     rect.width -= 8
  261.     self.contents.clear_rect(rect)
  262.     self.contents.font.color = normal_color
  263.     self.contents.draw_text(rect, @commands[index])
  264.   end
  265.  
  266.   def change_specific_command(index, command_index)
  267.     @commands[index] = $game_party.members[command_index].name # change option to new order actor's name
  268.     @placed[index] = true #flag the new order position as placed
  269.   end
  270.  
  271.   def get_placed
  272.     for i in 0...@commands.size #once for every position available to place
  273.       @placed.push(false) #flag all positions as unplaced
  274.     end
  275.   end
  276.  
  277.   def unplace_from_order(where)
  278.     @commands[where] = ""
  279.     @placed[where] = false
  280.   end
  281.  
  282. end
  283.  
  284. #-------------------------------------------------------------------------------
  285. #                           Scene ReOrder
  286. #-------------------------------------------------------------------------------
  287.  
  288. class Scene_ReOrder < Scene_Base
  289.  
  290.   include IROP
  291.  
  292.   def start
  293.     super
  294.     @lastplaced = 0
  295.     @wincount = 0
  296.     @new_order = []
  297.     for i in 0...$game_party.members.size
  298.       @new_order.push(0)
  299.     end
  300.     @win_title = Window_Rop_Title.new(100, 0)
  301.     @win_help = Window_Rop_Help.new(100, 291)
  302.     @win_order = Window_Order.new(100, 61)
  303.     @win_reorder = Window_ReOrder.new(281, 61)
  304.     @win_order.active = true
  305.   end
  306.  
  307.   def update
  308.     if @win_order.active
  309.       @win_help.refresh
  310.       @win_order.update
  311.       if Input.trigger?(Input::C) and @win_order.disableds[@win_order.index] == false
  312.         Sound.play_decision
  313.         make_reorder_active(0)
  314.       elsif Input.trigger?(Input::C) and @win_order.disableds[@win_order.index] == true
  315.         Sound.play_cancel
  316.       elsif Input.trigger?(Input::B)
  317.         Sound.play_cancel
  318.         case $game_temp.reorder_from
  319.         when 0
  320.           $scene = Scene_Map.new
  321.         when 1
  322.           $scene = Scene_Menu.new
  323.           $game_temp.reorder_from = 0
  324.         end
  325.       end
  326.     elsif @win_reorder.active
  327.       @win_help.refresh
  328.       @win_reorder.update
  329.       if Input.trigger?(Input::C) and @win_reorder.placed[@win_reorder.index] == false
  330.         Sound.play_decision
  331.         @win_order.disableds[@win_order.index] = true
  332.         @new_order[@win_reorder.index] = $game_party.members[@win_order.index].id
  333.         @win_reorder.change_specific_command(@win_reorder.index, @win_order.index)
  334.         @win_reorder.refresh
  335.         @win_order.refresh
  336.         @win_help.refresh
  337.         @lastplaced = @win_reorder.index
  338.         check_full
  339.       elsif Input.trigger?(Input::C) and @win_reorder.placed[@win_reorder.index] == true
  340.         Sound.play_cancel
  341.       elsif Input.trigger?(Input::B)
  342.         Sound.play_cancel
  343.         make_order_active
  344.       elsif Input.trigger?(Input::A) and @win_reorder.placed[@win_reorder.index] == true
  345.         RPG::SE.new(ROP_DELETE_SOUND, 80, 100).play
  346.         @new_order[@win_reorder.index] = -1
  347.         undo_disabled(@win_reorder.commands[@win_reorder.index])
  348.         @win_reorder.unplace_from_order(@win_reorder.index)
  349.         make_order_active
  350.         @win_reorder.refresh
  351.         @win_order.refresh
  352.         @win_help.refresh
  353.       end
  354.     elsif @win_pop.active
  355.       @win_help.refresh
  356.       @win_pop.update
  357.       if Input.trigger?(Input::C) and @win_pop.index == 0
  358.         $game_party.remove_all_actors
  359.         $game_party.get_reorder(@new_order)
  360.         case $game_temp.reorder_from
  361.         when 0
  362.           $scene = Scene_Map.new
  363.         when 1
  364.           $scene = Scene_Menu.new
  365.           $game_temp.reorder_from = 0
  366.         end
  367.       elsif Input.trigger?(Input::C) and @win_pop.index == 1
  368.         RPG::SE.new(ROP_DELETE_SOUND, 80, 100).play # Requires deleting a selection
  369.        @new_order[@win_reorder.index] = -1
  370.         undo_disabled(@win_reorder.commands[@win_reorder.index])
  371.         @win_reorder.unplace_from_order(@win_reorder.index)
  372.         @wincount = 0
  373.         make_reorder_active(1)
  374.       end
  375.     end
  376.   end
  377.  
  378.   def undo_disabled(name)
  379.     for i in 0...@win_order.commands.size
  380.       if @win_order.commands[i] == name
  381.         @win_order.disableds[i] = false
  382.       end
  383.     end
  384.   end
  385.    
  386.   def check_full
  387.     spots_full = 0
  388.     for i in 0...@new_order.size
  389.       if @new_order[i] > 0
  390.         spots_full += 1
  391.       end
  392.     end
  393.     if spots_full == @new_order.size
  394.       RPG::SE.new(ROP_FULL_SOUND, 80, 100).play
  395.       @win_pop = Window_Rop_Pop.new(200, 175)
  396.       @wincount = 1
  397.       make_pop_active
  398.     else
  399.       make_order_active
  400.     end
  401.   end
  402.  
  403.  
  404.   def make_order_active
  405.     @win_help.helptext = 0
  406.     @win_reorder.active = false
  407.     @win_order.active = true
  408.   end
  409.  
  410.   def make_reorder_active(from)
  411.     if from == 0
  412.       @win_help.helptext = 1
  413.       @win_order.active = false
  414.       @win_reorder.active = true
  415.     elsif from == 1
  416.       @win_pop.dispose
  417.       @win_help.helptext = 1
  418.       @win_reorder.active = true
  419.     end
  420.   end
  421.  
  422.   def make_pop_active
  423.     @win_help.helptext = 2
  424.     @win_reorder.active = false
  425.     @win_pop.active = true
  426.   end
  427.  
  428.   def terminate
  429.     if @wincount == 1
  430.       @win_pop.dispose
  431.       @win_title.dispose
  432.       @win_help.dispose
  433.       @win_order.dispose
  434.       @win_reorder.dispose
  435.     else
  436.       @win_title.dispose
  437.       @win_help.dispose
  438.       @win_order.dispose
  439.       @win_reorder.dispose
  440.     end
  441.   end
  442.  
  443. end
  444.  
  445. #-------------------------------------------------------------------------------
  446. #                             Scene_Menu
  447. #-------------------------------------------------------------------------------
  448. class Scene_Menu < Scene_Base
  449.  
  450.   include IROP
  451.  
  452.   alias irop_sm_start start unless $@
  453.   def start
  454.     if USE_FROM_MENU
  455.       super
  456.       create_menu_background
  457.       if USE_FROM_MENU
  458.         create_command_window_irop
  459.       else
  460.         create_command_window
  461.       end
  462.       @gold_window = Window_Gold.new(0, 360)
  463.       @status_window = Window_MenuStatus.new(160, 0)
  464.     else
  465.       irop_sm_start
  466.     end
  467.   end
  468.  
  469.   def create_command_window_irop
  470.     s1 = Vocab::item
  471.     s2 = Vocab::skill
  472.     s3 = Vocab::equip
  473.     s4 = Vocab::status
  474.     s5 = MENU_REORDER_COMMAND
  475.     s6 = Vocab::save
  476.     s7 = Vocab::game_end
  477.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
  478.     @command_window.index = @menu_index
  479.     if $game_party.members.size == 0          # If number of party members is 0
  480.       @command_window.draw_item(0, false)     # Disable item
  481.       @command_window.draw_item(1, false)     # Disable skill
  482.       @command_window.draw_item(2, false)     # Disable equipment
  483.       @command_window.draw_item(3, false)     # Disable status
  484.       @command_window.draw_item(4, false)     # Disable reorder
  485.     end
  486.     if $game_system.save_disabled             # If save is forbidden
  487.       @command_window.draw_item(5, false)     # Disable save
  488.     end
  489.   end
  490.  
  491.   alias irop_sm_update update unless $@
  492.   def update
  493.     if USE_FROM_MENU
  494.       super
  495.       update_menu_background
  496.       @command_window.update
  497.       @gold_window.update
  498.       @status_window.update
  499.       if @command_window.active
  500.         update_command_selection_irop
  501.       elsif @status_window.active
  502.         update_actor_selection
  503.       end
  504.     else
  505.       irop_sm_update
  506.     end
  507.   end
  508.  
  509.   def update_command_selection_irop
  510.     if Input.trigger?(Input::B)
  511.       Sound.play_cancel
  512.       $scene = Scene_Map.new
  513.     elsif Input.trigger?(Input::C)
  514.       if $game_party.members.size == 0 and @command_window.index < 5
  515.         Sound.play_buzzer
  516.         return
  517.       elsif $game_system.save_disabled and @command_window.index == 5
  518.         Sound.play_buzzer
  519.         return
  520.       end
  521.       Sound.play_decision
  522.       case @command_window.index
  523.       when 0      # Item
  524.         $scene = Scene_Item.new
  525.       when 1,2,3  # Skill, equipment, status
  526.         start_actor_selection
  527.       when 4  #ReOrder
  528.         $game_temp.reorder_from = 1
  529.         $scene = Scene_ReOrder.new
  530.       when 5      # Save
  531.         $scene = Scene_File.new(true, false, false)
  532.       when 6      # End Game
  533.         $scene = Scene_End.new
  534.       end
  535.     end
  536.   end
  537.  
  538. end
Advertisement
Add Comment
Please, Sign In to add comment