CrowMakerVX

Party ReOrder 1.0

Dec 13th, 2012
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.52 KB | None | 0 0
  1. ################################################################################
  2. #                          ReOrderParty 1.0
  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.  
  42. end
  43. ################################################################################
  44. #             CUSTOMIZE END
  45. ################################################################################
  46.  
  47. ################################################################################
  48. #===============================================================================
  49. ################################################################################
  50.  
  51. #-------------------------------------------------------------------------------
  52. #                Game_Party
  53. #-------------------------------------------------------------------------------
  54. class Game_Party < Game_Unit
  55.  
  56.   def get_reorder(order)
  57.     p order
  58.     for i in 0...order.size
  59.       add_actor(order[i])
  60.     end
  61.   end
  62.  
  63.   def remove_all_actors
  64.     for member in members
  65.       remove_actor(member.id)
  66.     end
  67.   end
  68.  
  69. end
  70.  
  71. #-------------------------------------------------------------------------------
  72. #                       WindowRopPopUp
  73. #-------------------------------------------------------------------------------
  74. class Window_Rop_Pop < Window_Selectable
  75.  
  76.   include IROP
  77.  
  78.   def initialize(x, y)
  79.     super(x, y, 180, 120)
  80.     @commands = [REORDER_CONFIRM_TEXT, REORDER_CANCEL_TEXT]
  81.     @item_max = @commands.size
  82.     refresh
  83.     self.index = 0
  84.   end
  85.  
  86.   def refresh
  87.     self.contents.clear
  88.     for i in 0...@item_max
  89.       draw_item(i)
  90.     end
  91.   end
  92.  
  93.   def draw_item(index, enabled = true)
  94.     rect = item_rect(index)
  95.     rect.x += 4
  96.     rect.width -= 8
  97.     self.contents.font.color = normal_color
  98.     self.contents.draw_text(rect, @commands[index])
  99.   end
  100.  
  101. end
  102.  
  103. #-------------------------------------------------------------------------------
  104. #                         WindowRopTitle
  105. #-------------------------------------------------------------------------------
  106. class Window_Rop_Title < Window_Base
  107.  
  108.   include IROP
  109.  
  110.   def initialize(x, y)#pass 60, 0
  111.     super(x, y, 360, 60)
  112.     refresh
  113.   end
  114.  
  115.   def refresh
  116.     self.contents.clear
  117.     self.contents.font.color = text_color(ROP_TITLE_COLOR)
  118.     self.contents.draw_text(-8, 0, self.width, WLH, REORDER_TITLE, 1)
  119.   end
  120.  
  121. end
  122.  
  123.  
  124. #-------------------------------------------------------------------------------
  125. #                       WindowRopHelp
  126. #-------------------------------------------------------------------------------
  127. class Window_Rop_Help < Window_Base
  128.  
  129.   include IROP
  130.  
  131.   attr_writer :helptext
  132.  
  133.   def initialize(x, y)#pass 60, 311
  134.     super(x, y, 360, 60)
  135.     @helptext = 0
  136.     refresh
  137.   end
  138.  
  139.   def refresh
  140.     self.contents.clear
  141.     self.contents.font.color = text_color(ROP_HELP_COLOR)
  142.     if @helptext == 0
  143.       self.contents.draw_text(-8, 0, self.width, WLH, "C: Select, B:Exit", 1)
  144.     elsif @helptext == 1
  145.       self.contents.draw_text(-8, 0, self.width, WLH, "C:Select, B:Exit, A:Delete", 1)
  146.     elsif @helptext == 2
  147.       self.contents.draw_text(-8, 0, self.width, WLH, "C:Select", 1)
  148.     end
  149.   end
  150.  
  151. end
  152.  
  153.    
  154. #-------------------------------------------------------------------------------
  155. #                         WindowOrder
  156. #-------------------------------------------------------------------------------
  157.  
  158. class Window_Order < Window_Selectable
  159.  
  160.   attr_accessor :disableds
  161.   attr_accessor :commands
  162.  
  163.   def initialize(x, y)
  164.     super(x, y, 180, 230)
  165.     @commands = []
  166.     for i in 0...$game_party.members.size
  167.       @commands.push($game_party.members[i].name)
  168.     end
  169.     @disableds = []
  170.     get_disabled
  171.     @item_max = @commands.size
  172.     refresh
  173.     self.index = 0
  174.   end
  175.  
  176.   def refresh
  177.     self.contents.clear
  178.     for i in 0...@item_max
  179.       if @disableds != nil
  180.         if @disableds[i] == false
  181.           draw_item(i)
  182.         else
  183.           draw_item(i, false)
  184.         end
  185.       else
  186.         draw_item(i)
  187.       end
  188.     end
  189.   end
  190.  
  191.   def draw_item(index, enabled = true)
  192.     rect = item_rect(index)
  193.     rect.x += 4
  194.     rect.width -= 8
  195.     self.contents.clear_rect(rect)
  196.     self.contents.font.color = normal_color
  197.     self.contents.draw_text(rect, @commands[index])
  198.   end
  199.  
  200.   def get_disabled
  201.     for i in 0...@item_max
  202.       @disableds.push(false)
  203.     end
  204.   end
  205.  
  206. end
  207.  
  208. #-------------------------------------------------------------------------------
  209. #                     WindowReOrder
  210. #-------------------------------------------------------------------------------
  211.  
  212. class Window_ReOrder < Window_Selectable
  213.  
  214.   attr_accessor :placed
  215.   attr_accessor :commands
  216.  
  217.   def initialize(x, y)
  218.     super(x, y, 180, 230)
  219.     @commands = []
  220.     for i in 0...$game_party.members.size
  221.       @commands.push("")
  222.     end
  223.     @placed = []
  224.     get_placed
  225.     @item_max = @commands.size
  226.     refresh
  227.     self.index = 0
  228.   end
  229.  
  230.   def refresh
  231.     self.contents.clear
  232.     for i in 0...@item_max
  233.       draw_item(i)
  234.     end
  235.   end
  236.  
  237.   def draw_item(index, enabled = true)
  238.     rect = item_rect(index)
  239.     rect.x += 4
  240.     rect.width -= 8
  241.     self.contents.clear_rect(rect)
  242.     self.contents.font.color = normal_color
  243.     self.contents.draw_text(rect, @commands[index])
  244.   end
  245.  
  246.   def change_specific_command(index, command_index)
  247.     @commands[index] = $game_party.members[command_index].name
  248.     @placed[index] = true
  249.   end
  250.  
  251.   def get_placed
  252.     for i in 0...@commands.size
  253.       @placed.push(false)
  254.     end
  255.   end
  256.  
  257.   def unplace_from_order(where)
  258.     @commands[where] = ""
  259.     @placed[where] = false
  260.   end
  261.  
  262. end
  263.  
  264. #-------------------------------------------------------------------------------
  265. #                           Scene ReOrder
  266. #-------------------------------------------------------------------------------
  267.  
  268. class Scene_ReOrder < Scene_Base
  269.  
  270.   include IROP
  271.  
  272.   def start
  273.     super
  274.     @lastplaced = 0
  275.     @wincount = 0
  276.     @new_order = []
  277.     for i in 0...$game_party.members.size
  278.       @new_order.push(0)
  279.     end
  280.     @win_title = Window_Rop_Title.new(60, 0)
  281.     @win_help = Window_Rop_Help.new(60, 311)
  282.     @win_order = Window_Order.new(60, 60)
  283.     @win_reorder = Window_ReOrder.new(241, 60)
  284.     @win_order.get_disabled
  285.     @win_order.active = true
  286.   end
  287.  
  288.   def update
  289.     if @win_order.active
  290.       @win_help.refresh
  291.       @win_order.update
  292.       if Input.trigger?(Input::C) and @win_order.disableds[@win_order.index] == false
  293.         Sound.play_decision
  294.         make_reorder_active(0)
  295.       elsif Input.trigger?(Input::C) and @win_order.disableds[@win_order.index] == true
  296.         Sound.play_cancel
  297.       elsif Input.trigger?(Input::B)
  298.         Sound.play_cancel
  299.         $scene = Scene_Map.new
  300.       end
  301.     elsif @win_reorder.active
  302.       @win_help.refresh
  303.       @win_reorder.update
  304.       if Input.trigger?(Input::C) and @win_reorder.placed[@win_reorder.index] == false
  305.         Sound.play_decision
  306.         @win_order.disableds[@win_order.index] = true
  307.         @new_order[@win_reorder.index] = $game_party.members[@win_order.index].id
  308.         @win_reorder.change_specific_command(@win_reorder.index, @win_order.index)
  309.         @win_reorder.refresh
  310.         @win_order.refresh
  311.         @win_help.refresh
  312.         @lastplaced = @win_reorder.index
  313.         check_full
  314.       elsif Input.trigger?(Input::C) and @win_reorder.placed[@win_reorder.index] == true
  315.         Sound.play_cancel
  316.       elsif Input.trigger?(Input::B)
  317.         Sound.play_cancel
  318.         make_order_active
  319.       elsif Input.trigger?(Input::A) and @win_reorder.placed[@win_reorder.index] == true
  320.         RPG::SE.new(ROP_DELETE_SOUND, 80, 100).play
  321.         @new_order[@win_reorder.index] = -1
  322.         @win_order.disableds[@win_order.index] = false
  323.         @win_reorder.unplace_from_order(@win_reorder.index)
  324.         make_order_active
  325.         @win_reorder.refresh
  326.         @win_order.refresh
  327.         @win_help.refresh
  328.       end
  329.     elsif @win_pop.active
  330.       @win_help.refresh
  331.       @win_pop.update
  332.       if Input.trigger?(Input::C) and @win_pop.index == 0
  333.         $game_party.remove_all_actors
  334.         $game_party.get_reorder(@new_order)
  335.         $scene = Scene_Map.new
  336.       elsif Input.trigger?(Input::C) and @win_pop.index == 1
  337.         RPG::SE.new(ROP_DELETE_SOUND, 80, 100).play # Requires deleting a selection
  338.         @new_order[@win_reorder.index] = -1
  339.         @win_order.disableds[@win_order.index] = false
  340.         @win_reorder.unplace_from_order(@win_reorder.index)
  341.         @wincount = 0
  342.         make_reorder_active(1)
  343.       end
  344.     end
  345.   end
  346.  
  347.   def check_full
  348.     spots_full = 0
  349.     for i in 0...@new_order.size
  350.       if @new_order[i] > 0
  351.         spots_full += 1
  352.       end
  353.     end
  354.     if spots_full == @new_order.size
  355.       RPG::SE.new(ROP_FULL_SOUND, 80, 100).play
  356.       @win_pop = Window_Rop_Pop.new(200, 175)
  357.       @wincount = 1
  358.       make_pop_active
  359.     else
  360.       make_order_active
  361.     end
  362.   end
  363.  
  364.  
  365.   def make_order_active
  366.     @win_help.helptext = 0
  367.     @win_reorder.active = false
  368.     @win_order.active = true
  369.   end
  370.  
  371.   def make_reorder_active(from)
  372.     if from == 0
  373.       @win_help.helptext = 1
  374.       @win_order.active = false
  375.       @win_reorder.active = true
  376.     elsif from == 1
  377.       @win_pop.dispose
  378.       @win_help.helptext = 1
  379.       @win_reorder.active = true
  380.     end
  381.   end
  382.  
  383.   def make_pop_active
  384.     @win_help.helptext = 2
  385.     @win_reorder.active = false
  386.     @win_pop.active = true
  387.   end
  388.  
  389.   def terminate
  390.     if @wincount == 1
  391.       @win_pop.dispose
  392.       @win_title.dispose
  393.       @win_help.dispose
  394.       @win_order.dispose
  395.       @win_reorder.dispose
  396.     else
  397.       @win_title.dispose
  398.       @win_help.dispose
  399.       @win_order.dispose
  400.       @win_reorder.dispose
  401.     end
  402.   end
  403.  
  404. end
Advertisement
Add Comment
Please, Sign In to add comment