Advertisement
Black_Mage

Party Changer RMVXAce Script

Feb 14th, 2015 (edited)
1,584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 13.19 KB | Source Code | 0 0
  1. #------------------------------------------------------------------------------
  2. # Lizzie S Party Changer for RMVXA
  3. #
  4. # This script is recreated from scratch on RGSS3 to mimic Lizzie S's Party
  5. # Changer script on RMXP.
  6. #
  7. # https://burningwizard.wordpress.com/2015/02/15/party-changer-menu-script-rmvxace-rgss3/
  8. #------------------------------------------------------------------------------
  9.  
  10. =begin
  11. #==============================================================================
  12. # MIT License
  13. #==============================================================================
  14. Copyright 2015-2024 Black Mage
  15.  
  16. Permission is hereby granted, free of charge, to any person obtaining a copy of
  17. this software and associated documentation files (the “Software”), to deal in
  18. the Software without restriction, including without limitation the rights to use,
  19. copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
  20. Software, and to permit persons to whom the Software is furnished to do so,
  21. subject to the following conditions:
  22.  
  23. The above copyright notice and this permission notice shall be included in all
  24. copies or substantial portions of the Software.
  25.  
  26. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  27. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  28. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  29. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  30. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. #==============================================================================
  33. =end
  34.  
  35. #==============================================================================
  36. # Changelog
  37. #==============================================================================
  38. # Version 1.3
  39. #   – Fix a bug where the reserve party is missing upon loading a save file.
  40. #   – Fixing more bugs.
  41. #   – Tidying up the script.
  42. #
  43. # Version 1.2
  44. #   - Make the script to be able to replace the default Formation menu.
  45. #
  46. # Version 1.1
  47. #   - Add Face Mode.
  48. #
  49. # Version 1.0
  50. #   - Initial version.
  51. #==============================================================================
  52.  
  53. #-------------------------------------------------------------------------------
  54. # Settings
  55. #-------------------------------------------------------------------------------
  56. module BM_Party_Changer
  57.  
  58.   DisplayMode = 0
  59.   # Put 0 to use walking sprite instead of face.
  60.   # Put 1 to use face instead of walking sprite.
  61.  
  62.   # Set this to true to replace the Formation option from main menu to Party
  63.   # Changer.
  64.   ReplaceFormation = true
  65.  
  66. end
  67. # End of Settings -------------------------------------------------------------
  68.  
  69. #------------------------------------------------------------------------------
  70. # * Beyond this is the sacred land of code. You need programming qualification
  71. #   to dwelve deeper, or it'll cause many unnecessary problems. Proceed on your
  72. #   own risk.
  73. #------------------------------------------------------------------------------
  74.  
  75. #------------------------------------------------------------------------------
  76. # * Initialize
  77. #------------------------------------------------------------------------------
  78. class Game_System
  79.   attr_accessor :partylock
  80.   attr_accessor :partychanger
  81.   alias bm_party_changer_init initialize
  82.   def initialize
  83.     bm_party_changer_init; @partylock = []; @partychanger = []
  84.   end
  85. end
  86. #------------------------------------------------------------------------------
  87.  
  88.  
  89. #------------------------------------------------------------------------------
  90. # * Change Formation Option to Party Changer.
  91. #------------------------------------------------------------------------------
  92. class Window_MenuCommand < Window_Command
  93.   alias b_party_form_enabled formation_enabled
  94.   def formation_enabled
  95.     if BM_Party_Changer::ReplaceFormation
  96.       return party_enabled
  97.     else
  98.       return b_party_form_enabled
  99.     end
  100.   end
  101.   def party_enabled
  102.     $game_party.members.size >= 1 && !$game_system.formation_disabled
  103.   end
  104. end
  105. class Scene_Menu < Scene_MenuBase
  106.   alias b_party_command_formation command_formation
  107.   def command_formation
  108.     if BM_Party_Changer::ReplaceFormation
  109.       SceneManager.call(Scene_Changer)
  110.     else
  111.       b_party_command_formation
  112.     end
  113.   end
  114. end
  115. #------------------------------------------------------------------------------
  116.  
  117.  
  118. #------------------------------------------------------------------------------
  119. # * Scene Changer.
  120. #------------------------------------------------------------------------------
  121. class Scene_Changer < Scene_MenuBase
  122.   def initialize; end
  123.  
  124.   def start
  125.     super
  126.     create_help_party_window
  127.     create_current_party_window
  128.     current_party_check
  129.     create_reserve_party_window
  130.     @current_party_window.activate
  131.     @current_party_window.select(0)
  132.     @current_party_window.refresh
  133.   end
  134.  
  135.   def current_party_check
  136.     $game_party.members.size.times {|i| party_check(i)}
  137.   end
  138.  
  139.   def party_check(index)
  140.     $game_system.partychanger[$game_party.members[index].id - 1] == true
  141.   end
  142.  
  143.   def create_help_party_window
  144.     @party_help_window = Window_Help.new(1)
  145.     @party_help_window.set_text('Choose your party.')
  146.   end
  147.  
  148.   def create_current_party_window
  149.     wy = @party_help_window.height
  150.     wh = Graphics.height - wy
  151.     @current_party_window = Window_CurrentParty.new(0, wy, (Graphics.width)/2, wh)
  152.     @current_party_window.viewport = @viewport
  153.     @current_party_window.set_handler(:ok, method(:current_party_ok))
  154.     @current_party_window.set_handler(:cancel, method(:current_party_cancel))
  155.   end
  156.   def current_party_cancel; SceneManager.return; end
  157.   def current_party_ok
  158.     if $game_party.members[@current_party_window.index].nil?
  159.       @reserve_party_window.activate
  160.       @reserve_party_window.select(0)
  161.       @current_party_window.index      
  162.     elsif $game_system.partylock[$game_party.members[@current_party_window.index].id - 1] == true
  163.       Sound.play_buzzer
  164.       @current_party_window.activate      
  165.       @current_party_window.select(@current_party_window.index)      
  166.     elsif $game_party.members.size == 1 && @current_party_window.index == 0
  167.       Sound.play_buzzer
  168.       @current_party_window.activate      
  169.       @current_party_window.select(@current_party_window.index)
  170.     else
  171.       @reserve_party_window.activate
  172.       @reserve_party_window.select(0)
  173.       @current_party_window.index
  174.     end
  175.   end
  176.  
  177.   def create_reserve_party_window
  178.     wy = @party_help_window.height
  179.     wh = Graphics.height - wy
  180.     @reserve_party_window = Window_ReserveParty.new((Graphics.width)/2, wy, (Graphics.width)/2, wh)
  181.     @reserve_party_window.viewport = @viewport
  182.     @reserve_party_window.refresh
  183.     @reserve_party_window.set_handler(:ok, method(:reserve_party_ok))
  184.     @reserve_party_window.set_handler(:cancel, method(:reserve_party_cancel))
  185.   end
  186.   def reserve_party_cancel
  187.     @reserve_party_window.select(-1)
  188.     @reserve_party_window.deactivate
  189.     @current_party_window.activate
  190.     @current_party_window.select(@current_party_window.index)
  191.   end
  192.  
  193.   def reserve_party_ok
  194.     if @reserve_party_window.data(@reserve_party_window.index).nil?
  195.       reserve_end_method
  196.     elsif $game_system.partylock[@reserve_party_window.data(@reserve_party_window.index).id - 1] == true
  197.       Sound.play_buzzer
  198.       @reserve_party_window.activate
  199.       @reserve_party_window.select(@reserve_party_window.index)
  200.     else
  201.       reserve_end_method
  202.     end
  203.   end
  204.  
  205.   def reserve_end_method
  206.     @party = []
  207.     @partytemp = []
  208.     for i in 1..$game_party.members.size
  209.       @party[i-1] = $game_party.members[i-1].id
  210.       @partytemp[i-1] = $game_party.members[i-1].id
  211.     end
  212.    
  213.     if @reserve_party_window.data(@reserve_party_window.index).nil?
  214.       @party[@current_party_window.index] = nil
  215.       @party2 = []
  216.       for i in 0..@party.size
  217.         @party2.push(@party[i]) if !@party[i].nil?
  218.       end
  219.       @party = @party2
  220.     else
  221.       @party[@current_party_window.index] = @reserve_party_window.data(@reserve_party_window.index).id
  222.     end
  223.    
  224.     for i in 1..@partytemp.size
  225.       $game_party.remove_actor($game_actors[@partytemp[i-1]].id)
  226.     end
  227.    
  228.     for i in 1..@party.size
  229.       $game_party.add_actor(@party[i-1])
  230.     end
  231.    
  232.     @current_party_window.refresh
  233.     @reserve_party_window.refresh
  234.     @reserve_party_window.select(0)
  235.     @reserve_party_window.select(-1)
  236.     @reserve_party_window.deactivate
  237.     @current_party_window.activate
  238.     @current_party_window.select(@current_party_window.index)
  239.   end
  240. end
  241.  
  242. #------------------------------------------------------------------------------
  243. # * Current Party Window.
  244. #------------------------------------------------------------------------------
  245. class Window_CurrentParty < Window_Selectable
  246.   def initialize(x, y, width, height); super; @data = []; end
  247.   def line_height; 86; end
  248.   def item_max
  249.     if $game_party.members.size == 4
  250.       $game_party.members.size
  251.     else
  252.       ($game_party.members.size) + 1
  253.     end
  254.   end
  255.   def draw_all_items; item_max.times {|i| draw_item(i)}; end
  256.   def draw_item(index)
  257.     @actor = $game_party.members[index]
  258.     if !@actor.nil?
  259.       mode = BM_Party_Changer::DisplayMode
  260.       case mode
  261.       when 0
  262.         x_pos = 60; draw_actor_graphic(@actor, 30, index*86 + 60)
  263.       when 1
  264.         x_pos = 90; draw_actor_face(@actor, 2, index*86 + 2)
  265.       end
  266.       draw_actor_name(@actor, x_pos, index*86 - 16)
  267.       draw_actor_level(@actor, x_pos, index*86 + 16)
  268.     end
  269.   end
  270.  
  271.   # Draw Face Custom
  272.   def draw_face(face_name, face_index, x, y, enabled = true)
  273.     bitmap = Cache.face(face_name)
  274.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 82, 82)
  275.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  276.     bitmap.dispose
  277.   end
  278.  
  279.   def draw_actor_name(actor, x, y, width = 112)
  280.     if $game_system.partylock[@actor.id - 1]
  281.       change_color(normal_color, false)
  282.     else
  283.       change_color(hp_color(actor))
  284.     end
  285.     draw_text(x, y, width, line_height, actor.name)
  286.   end
  287.   def draw_actor_level(actor, x, y)
  288.     if $game_system.partylock[@actor.id - 1]
  289.       change_color(normal_color, false)
  290.       draw_text(x, y, 32, line_height, Vocab::level_a)
  291.       change_color(normal_color, false)
  292.       draw_text(x + 32, y, 24, line_height, actor.level, 2)
  293.     else
  294.       change_color(system_color)
  295.       draw_text(x, y, 32, line_height, Vocab::level_a)
  296.       change_color(normal_color)
  297.       draw_text(x + 32, y, 24, line_height, actor.level, 2)
  298.     end
  299.   end
  300.   def refresh; contents.clear; draw_all_items; end
  301. end
  302.  
  303. #------------------------------------------------------------------------------
  304. # * Reserve Party Window.
  305. #------------------------------------------------------------------------------
  306. class Window_ReserveParty < Window_Selectable
  307.   def initialize(x, y, width, height); super; @data = []; self.oy = 0; end
  308.   def line_height; 86; end
  309.   def item_max; data = @data.nil? ? 1 : @data.size + 1; data; end
  310.   def get_data
  311.     @data = []
  312.     if $game_system.partychanger.size > 0
  313.       for i in 0..$game_system.partychanger.size
  314.         if $game_system.partychanger[i]
  315.           @partycheck = false
  316.           for a in 1..$game_party.members.size            
  317.             if $game_party.members[a-1].id == i + 1
  318.               @partycheck = true
  319.             end
  320.           end
  321.           @data.push($game_actors[i+1]) if !@partycheck
  322.         end
  323.       end
  324.     end
  325.   end
  326.   def draw_all_items; item_max.times {|i| draw_item(i)}; end
  327.   def draw_item(index)
  328.     if @data[index] != nil
  329.       @actor = @data[index]
  330.       mode = BM_Party_Changer::DisplayMode
  331.       case mode
  332.       when 0
  333.         x_pos = 60; draw_actor_graphic(@actor, 30, index*86 + 60)
  334.       when 1
  335.         x_pos = 90; draw_actor_face(@actor, 2, index*86 + 2)
  336.       end
  337.       draw_actor_name(@actor, x_pos, index*86 - 16)
  338.       draw_actor_level(@actor, x_pos, index*86 + 16)
  339.     end
  340.   end
  341.  
  342.   # Draw Face Custom
  343.   def draw_face(face_name, face_index, x, y, enabled = true)
  344.     bitmap = Cache.face(face_name)
  345.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 82, 82)
  346.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  347.     bitmap.dispose
  348.   end
  349.  
  350.   def draw_actor_name(actor, x, y, width = 112)
  351.     if $game_system.partylock[@actor.id - 1]
  352.       change_color(normal_color, false)
  353.     else
  354.       change_color(hp_color(actor))
  355.     end
  356.     draw_text(x, y, width, line_height, actor.name)
  357.   end
  358.   def draw_actor_level(actor, x, y)
  359.     if $game_system.partylock[@actor.id - 1]
  360.       change_color(normal_color, false)
  361.       draw_text(x, y, 32, line_height, Vocab::level_a)
  362.       change_color(normal_color, false)
  363.       draw_text(x + 32, y, 24, line_height, actor.level, 2)
  364.     else
  365.       change_color(system_color)
  366.       draw_text(x, y, 32, line_height, Vocab::level_a)
  367.       change_color(normal_color)
  368.       draw_text(x + 32, y, 24, line_height, actor.level, 2)
  369.     end
  370.   end
  371.   def refresh; contents.clear; get_data; create_contents; draw_all_items; end
  372.   def data(index); @data[index]; end
  373. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement