Guest User

Tweaked Command Party

a guest
May 30th, 2022
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.82 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Party System Add-On: Command Party v1.01
  4. # -- Last Updated: 2012.01.10
  5. # -- Level: Easy, Normal
  6. # -- Requires: YEA - Party System v1.00+
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-CommandParty"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.10 - Compatibility Update: Ace Battle Engine v1.15+
  17. # 2011.12.13 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # An add-on to the Yanfly Engine Ace - Party System script. This script allows
  23. # the player to change party members during the middle of battle from the
  24. # Party Command Window (the Fight/Escape window).
  25. #
  26. #==============================================================================
  27. # ▼ Instructions
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # To install this script, open up your script editor and copy/paste this script
  30. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  31. #
  32. # Note, if you do not give your player access to the party formation menu
  33. # available in the Party System script, this script will disable itself.
  34. #
  35. #==============================================================================
  36. # ▼ Compatibility
  37. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  38. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  39. # it will run with RPG Maker VX without adjusting.
  40. #
  41. # This script requires Yanfly Engine Ace - Party System v1.00+.
  42. #
  43. #==============================================================================
  44.  
  45. module YEA
  46.   module COMMAND_PARTY
  47.    
  48.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  49.     # - Command Party Settings -
  50.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  51.     # This is just how the text appears visually in battle for your party and
  52.     # how often the can change party in battle. Furthermore, there's two
  53.     # switches that may be enabled or disabled to add the command to the
  54.     # game. Adjust it as you see fit. Set the switches to 0 to not use them.
  55.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  56.     COMMAND_TEXT   = "Switch"    # Text used for the command.
  57.     PARTY_COOLDOWN = 1          # Turns that must pass between each change.
  58.     SHOW_SWITCH    = 1          # If switch is on, show command. 0 to disable.
  59.     ENABLE_SWITCH  = 1          # If switch is on, enable command. 0 to disable.
  60.    
  61.   end # COMMAND_PARTY
  62. end # YEA
  63.  
  64. #==============================================================================
  65. # ▼ Editting anything past this point may potentially result in causing
  66. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  67. # halitosis so edit at your own risk.
  68. #==============================================================================
  69.  
  70. if $imported["YEA-PartySystem"]
  71.  
  72. #==============================================================================
  73. # ■ SceneManager
  74. #==============================================================================
  75.  
  76. module SceneManager
  77.  
  78.   #--------------------------------------------------------------------------
  79.   # new method: self.force_recall
  80.   #--------------------------------------------------------------------------
  81.   def self.force_recall(scene_class)
  82.     @scene = scene_class
  83.   end
  84.  
  85. end # SceneManager
  86.  
  87. #==============================================================================
  88. # ■ Game_Unit
  89. #==============================================================================
  90.  
  91. class Game_Unit
  92.  
  93.   #--------------------------------------------------------------------------
  94.   # alias method: on_battle_start
  95.   #--------------------------------------------------------------------------
  96.   alias game_unit_on_battle_start_cpt on_battle_start
  97.   def on_battle_start
  98.     game_unit_on_battle_start_cpt
  99.     reset_party_cooldown
  100.   end
  101.  
  102.   #--------------------------------------------------------------------------
  103.   # new method: reset_party_cooldown
  104.   #--------------------------------------------------------------------------
  105.   def reset_party_cooldown
  106.     @party_cooldown = 0
  107.   end
  108.  
  109.   #--------------------------------------------------------------------------
  110.   # new method: update_party_cooldown
  111.   #--------------------------------------------------------------------------
  112.   def update_party_cooldown
  113.     reset_party_cooldown if @party_cooldown.nil?
  114.     @party_cooldown = [@party_cooldown - 1, 0].max
  115.   end
  116.  
  117.   #--------------------------------------------------------------------------
  118.   # new method: battle_party_change?
  119.   #--------------------------------------------------------------------------
  120.   def battle_party_change?
  121.     switch = YEA::COMMAND_PARTY::ENABLE_SWITCH
  122.     enabled = switch <= 0 ? true : $game_switches[switch]
  123.     return false unless enabled
  124.     reset_party_cooldown if @party_cooldown.nil?
  125.     return @party_cooldown <= 0
  126.   end
  127.  
  128.   #--------------------------------------------------------------------------
  129.   # new method: set_party_cooldown
  130.   #--------------------------------------------------------------------------
  131.   def set_party_cooldown
  132.     @party_cooldown = YEA::COMMAND_PARTY::PARTY_COOLDOWN
  133.   end
  134.  
  135.   #--------------------------------------------------------------------------
  136.   # alias method: on_battle_end
  137.   #--------------------------------------------------------------------------
  138.   alias game_unit_on_battle_end_cpt on_battle_end
  139.   def on_battle_end
  140.     game_unit_on_battle_end_cpt
  141.     reset_party_cooldown
  142.   end
  143.  
  144. end # Game_Unit
  145.  
  146. #==============================================================================
  147. # ■ Window_PartyCommand
  148. #==============================================================================
  149.  
  150. class Window_ActorCommand < Window_Command
  151.  
  152.   #--------------------------------------------------------------------------
  153.   # alias method: make_command_list
  154.   #--------------------------------------------------------------------------
  155.   alias window_partycommand_make_command_list_cpt make_command_list
  156.   def make_command_list
  157.     window_partycommand_make_command_list_cpt
  158.     return if $imported["YEA-BattleCommandList"]
  159.     add_party_command
  160.   end
  161.  
  162.   #--------------------------------------------------------------------------
  163.   # new method: add_party_command
  164.   #--------------------------------------------------------------------------
  165.   def add_party_command
  166.     return unless YEA::PARTY::ENABLE_MENU
  167.     show = YEA::COMMAND_PARTY::SHOW_SWITCH
  168.     continue = show == 0 ? true : $game_switches[show]
  169.     continue = false if $game_party.all_members.size < 2
  170.     return unless continue
  171.     text = YEA::COMMAND_PARTY::COMMAND_TEXT
  172.     add_command(text, :party, $game_party.battle_party_change?)
  173.   end
  174.  
  175. end # Window_PartyCommand
  176.  
  177. #==============================================================================
  178. # ■ Scene_Battle
  179. #==============================================================================
  180.  
  181. class Scene_Battle < Scene_Base
  182.  
  183.   #--------------------------------------------------------------------------
  184.   # alias method: create_party_command_window
  185.   #--------------------------------------------------------------------------
  186.   alias create_actor_command_window_cpt create_actor_command_window
  187.   def create_actor_command_window
  188.     create_actor_command_window_cpt
  189.     @actor_command_window.set_handler(:party, method(:command_party))
  190.   end
  191.  
  192.   #--------------------------------------------------------------------------
  193.   # new method: command_party
  194.   #--------------------------------------------------------------------------
  195.   def command_party
  196.     Graphics.freeze
  197.     @info_viewport.visible = false
  198.     hide_extra_gauges if $imported["YEA-BattleEngine"]
  199.     SceneManager.snapshot_for_background
  200.     previous_party = $game_party.battle_members.clone
  201.     index = @party_command_window.index
  202.     oy = @party_command_window.oy
  203.     #---
  204.     SceneManager.call(Scene_Party)
  205.     SceneManager.scene.main
  206.     SceneManager.force_recall(self)
  207.     #---
  208.     show_extra_gauges if $imported["YEA-BattleEngine"]
  209.     if previous_party != $game_party.battle_members
  210.       $game_party.make_actions
  211.       $game_party.set_party_cooldown
  212.     else
  213.       BattleManager.prior_command
  214.     end
  215.     @info_viewport.visible = true
  216.     @status_window.refresh
  217.     @party_command_window.setup
  218.     @party_command_window.select(index)
  219.     @party_command_window.oy = oy
  220.     perform_transition
  221.   end
  222.  
  223.   #--------------------------------------------------------------------------
  224.   # alias method: turn_end
  225.   #--------------------------------------------------------------------------
  226.   alias scene_battle_turn_end_cpt turn_end
  227.   def turn_end
  228.     scene_battle_turn_end_cpt
  229.     return if $imported["YEA-BattleEngine"]
  230.     update_party_cooldowns
  231.   end
  232.  
  233.   #--------------------------------------------------------------------------
  234.   # new method: update_party_cooldowns
  235.   #--------------------------------------------------------------------------
  236.   def update_party_cooldowns
  237.     $game_party.update_party_cooldown
  238.     $game_troop.update_party_cooldown
  239.   end
  240.  
  241. end # Scene_Battle
  242. end # $imported["YEA-PartySystem"]
  243.  
  244. #==============================================================================
  245. #
  246. # ▼ End of File
  247. #
  248. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment