Advertisement
Guest User

Yanfly Battle Command List

a guest
Aug 1st, 2012
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 42.79 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Battle Command List v1.08
  4. # -- Last Updated: 2012.08.02
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-BattleCommandList"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.08.02 - Edited to include overdrive system and hidden skill types
  17. #              by state. #Xypher
  18. # 2012.01.10 - Compatibility Update: Battle System FTB
  19. # 2011.12.30 - Bug Fixed: Disappearing windows when no confirm window is used.
  20. # 2011.12.26 - Bug Fixed: Actor Command Window disappears without Battle Engine
  21. #              Ace installed.
  22. # 2011.12.19 - Compatibility Update: Class System
  23. #            - New Actor Command: Subclass List
  24. # 2011.12.17 - Bug Fixed: Item command from Actor Command Window fixed.
  25. # 2011.12.15 - Bug Fixed: Prevented multiple actions per battler.
  26. # 2011.12.13 - Compatibility Update: Command Equip
  27. #              Compatibility Update: Add-On: Command Party
  28. # 2011.12.12 - Compatibility Update: Command Autobattle
  29. # 2011.12.10 - Started Script and Finished.
  30. #            - Compatibility Update: Combat Log Display
  31. #
  32. #==============================================================================
  33. # ▼ Introduction
  34. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  35. # This script allows you to change the order to commands that appear in battle
  36. # for the Party Command Window and Actor Command Window. In addition to the
  37. # ability to change the order commands appear, you may also add commands to the
  38. # Actor Command Window that can trigger the usage of skills and/or items. The
  39. # Confirm Command Window is also a new addition that appears at the end of the
  40. # action select phase (after the last actor has made a choice) before entering
  41. # the battle phase.
  42. #
  43. #==============================================================================
  44. # ▼ Instructions
  45. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  46. # To install this script, open up your script editor and copy/paste this script
  47. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  48. #
  49. # -----------------------------------------------------------------------------
  50. # Actor Notetags - These notetags go in the actors notebox in the database.
  51. # -----------------------------------------------------------------------------
  52. # <command list>
  53. #  string
  54. #  string
  55. # </command list>
  56. # These lines go inside of an actor's notebox to adjust the battle commands
  57. # that appear in the actor's Actor Command Window. Refer to the module as to
  58. # what to use for the strings. If a custom command list is used for an actor,
  59. # it will take priority over its class's custom command list, which takes place
  60. # over the default command list.
  61. #
  62. # -----------------------------------------------------------------------------
  63. # Class Notetags - These notetags go in the class notebox in the database.
  64. # -----------------------------------------------------------------------------
  65. # <command list>
  66. #  string
  67. #  string
  68. # </command list>
  69. # These lines go inside of a class's notebox to adjust the battle commands
  70. # that appear in the actor's Actor Command Window. Refer to the module as to
  71. # what to use for the strings. A custom command list for a class does not take
  72. # priority over an actor's custom command list, but it does take priority over
  73. # the default command list.
  74. #
  75. # -----------------------------------------------------------------------------
  76. # Skill Notetags - These notetags go in the skill notebox in the database.
  77. # -----------------------------------------------------------------------------
  78. # <command name: string>
  79. # If this skill is being used as a command, it will use "string" to replace the
  80. # skill's name in the command list window.
  81. #
  82. # <command hide until learn>
  83. # This hides the command until the actor has learned the respective skill for
  84. # the command to appear in the actor's command list.
  85. #
  86. # <command hide until usable>
  87. # This hides the command until the actor is capable of using the command by
  88. # meeting TP costs or MP costs.
  89. #
  90. # <command hide until switch: x>
  91. # This switch x is OFF, then the command remains hidden. If the switch is ON,
  92. # then the command becomes enabled and appears in the command list.
  93. #
  94. # -----------------------------------------------------------------------------
  95. # Item Notetags - These notetags go in the item notebox in the database.
  96. # -----------------------------------------------------------------------------
  97. # <command name: string>
  98. # If this item is being used as a command, it will use "string" to replace the
  99. # item's name in the command list window.
  100. #
  101. # <command hide until usable>
  102. # This hides the command until the actor is capable of using the command as
  103. # long as that item is usable normally.
  104. #
  105. # <command hide until switch: x>
  106. # This switch x is OFF, then the command remains hidden. If the switch is ON,
  107. # then the command becomes enabled and appears in the command list.
  108. #
  109. #==============================================================================
  110. # ▼ Compatibility
  111. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  112. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  113. # it will run with RPG Maker VX without adjusting.
  114. #
  115. # For maximum compatibility with Yanfly Engine Ace - Ace Battle Engine, place
  116. # this script under Ace Battle Engine.
  117. #
  118. #==============================================================================
  119.  
  120. module YEA
  121.   module BATTLE_COMMANDS
  122.    
  123.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  124.     # - Party Command Window Settings -
  125.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  126.     # This section adjusts the commands for the Party Command Window. Rearrange
  127.     # commands as you see fit or add in new ones. Here's a list of which
  128.     # command does what:
  129.     #
  130.     # -------------------------------------------------------------------------
  131.     # :command         Description
  132.     # -------------------------------------------------------------------------
  133.     # :fight           Enters the command selection phase for actors. Default.
  134.     # :escape          Party attempts to escape from battle. Default.
  135.     #
  136.     # :combatlog       Requires YEA - Combat Log Display.
  137.     # :autobattle      Requires YEA - Command Autobattle.
  138.     # :party           Requires YEA - Party System Add-On: Command Party.
  139.     #
  140.     # And that's all of the currently available commands. This list will be
  141.     # updated as more scripts become available.
  142.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  143.     # This array arranges the order of which the commands appear in the Party
  144.     # Command window.
  145.     PARTY_COMMANDS =[
  146.       :fight,
  147.       :autobattle,
  148.       :party,
  149.     # :custom1,
  150.     # :custom2,
  151.       :escape,
  152.     ] # Do not remove this.
  153.    
  154.     #--------------------------------------------------------------------------
  155.     # - Party Command Custom Commands -
  156.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  157.     # For those who use scripts to that may produce unique effects in battle,
  158.     # use this hash to manage the custom commands for the Party Command Window.
  159.     # You can disable certain commands or prevent them from appearing by using
  160.     # switches. If you don't wish to bind them to a switch, set the proper
  161.     # switch to 0 for it to have no impact.
  162.     #--------------------------------------------------------------------------
  163.     CUSTOM_PARTY_COMMANDS ={
  164.     # :command => ["Display Name", EnableSwitch, ShowSwitch, Handler Method],
  165.       :custom1 => [ "Custom Name",            0,         0, :command_name1],
  166.       :custom2 => [ "Custom Name",           13,         0, :command_name2],
  167.     } # Do not remove this.
  168.    
  169.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  170.     # - Actor Command Window Settings -
  171.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  172.     # This section only adjusts the default commands for actors. If you wish
  173.     # for an actor to have a unique command list, use the notetags listed in
  174.     # the instructions to apply them. The custom command lists for actors will
  175.     # override this command list.
  176.     #
  177.     # Here's a list of which command does what:
  178.     #
  179.     # -------------------------------------------------------------------------
  180.     # :command         Description
  181.     # -------------------------------------------------------------------------
  182.     # "ATTACK"         Normal attack for actor. Default.
  183.     # "SKILL LIST"     All of the skill types the actor can use. Default.
  184.     # "DEFEND"         Set defend action for actor. Default.
  185.     # "ITEMS"          Opens up the item menu for the actor. Default.
  186.     #
  187.     # "SKILL TYPE X"   Specifically puts in skill type X if actor has it.
  188.     # "SKILL X"        Uses Skill X in that slot.
  189.     # "ITEM X"         Uses Item X in that slot.
  190.     #
  191.     # "AUTOBATTLE"     Requires YEA - Command Autobattle.
  192.     # "EQUIP"          Requires YEA - Command Equip
  193.     # "SUBCLASS LIST"  Requires YEA - Class System. Adds subclass skill types.
  194.     #
  195.     # And that's all of the currently available commands. This list will be
  196.     # updated as more scripts become available.
  197.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  198.     # This array arranges the order of which the commands appear in the Actor
  199.     # Command window if the actor does not have a custom command list.
  200.     DEFAULT_ACTOR_COMMANDS =[
  201.     # "AUTOBATTLE",
  202.       "ATTACK",
  203.       "SKILL LIST",
  204.       "SUBCLASS LIST",
  205.       "DEFEND",
  206.       "ITEMS",
  207.       "EQUIP",
  208.     ] # Do not remove this.
  209.    
  210.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  211.     # - Confirm Command Window Settings -
  212.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  213.     # The confirm window is something new that's been added. It shows after the
  214.     # last actor has made a decision as to what actions the player wishes to
  215.     # take for the turn Here's a list of which command does what:
  216.     #
  217.     # -------------------------------------------------------------------------
  218.     # :command         Description
  219.     # -------------------------------------------------------------------------
  220.     # :execute         Start the battle turn. Comes with this script.
  221.     #
  222.     # :combatlog       Requires YEA - Combat Log Display.
  223.     #
  224.     # And that's all of the currently available commands. This list will be
  225.     # updated as more scripts become available.
  226.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  227.     USE_CONFIRM_WINDOW = true    # Set to false if you don't wish to use it.
  228.    
  229.     # This array arranges the order of which the commands appear in the Party
  230.     # Command window.
  231.     CONFIRM_COMMANDS =[
  232.       :execute,
  233.       :combatlog,
  234.     # :custom1,
  235.     # :custom2,
  236.     ] # Do not remove this.
  237.    
  238.     # This sets what text appears for the execute command.
  239.     EXECUTE_VOCAB = "Execute"
  240.    
  241.     #--------------------------------------------------------------------------
  242.     # - Confirm Command Custom Commands -
  243.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  244.     # For those who use scripts to that may produce unique effects in battle,
  245.     # use this hash to manage the custom commands for the Confirm Command
  246.     # Window. You can disable certain commands or prevent them from appearing
  247.     # by using switches. If you don't wish to bind them to a switch, set the
  248.     # proper switch to 0 for it to have no impact.
  249.     #--------------------------------------------------------------------------
  250.     CUSTOM_CONFIRM_COMMANDS ={
  251.     # :command => ["Display Name", EnableSwitch, ShowSwitch, Handler Method],
  252.       :custom1 => [ "Custom Name",            0,          0, :command_name1],
  253.       :custom2 => [ "Custom Text",           13,          0, :command_name2],
  254.     } # Do not remove this.
  255.    
  256.    
  257.    
  258.     #--------------------------------------------------------------------------
  259.     # - Edits by Xypher
  260.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  261.     # OVERDRIVE_STYPE
  262.     # Set OVERDRIVE_STYPE to the skill type you want to hide until
  263.     # the actor's tp is whatever OVERDRIVE_TP is set to.
  264.     #
  265.     # OVERDRIVE_TP
  266.     # Set this to how much tp is required before the
  267.     # Overdrive skill type appears.
  268.     #
  269.     # STYPES_STATES
  270.     # STYPES_STATES is an array for skill types you want to be hidden
  271.     # if they are inflicted with a certain state.
  272.     # syntax: STYPES_STATES = [[skill_type, state_id]]
  273.     # Supports multiple entrys
  274.     # eg: STYPES_STATES = [[2, 4], [7, 3], [4, 5], [3, 3]]
  275.     #--------------------------------------------------------------------------
  276.     OVERDRIVE_STYPE = 5
  277.     OVERDRIVE_TP    = 100
  278.    
  279.     STYPES_STATES   = [[2, 4]]
  280.    
  281.   end # BATTLE_COMMANDS
  282. end # YEA
  283.  
  284. #==============================================================================
  285. # ▼ Editting anything past this point may potentially result in causing
  286. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  287. # halitosis so edit at your own risk.
  288. #==============================================================================
  289.  
  290. module YEA
  291.   module REGEXP
  292.   module BASEITEM
  293.    
  294.     COMMAND_LIST_ON  = /<(?:COMMAND_LIST|command list)>/i
  295.     COMMAND_LIST_OFF = /<\/(?:COMMAND_LIST|command list)>/i
  296.    
  297.   end # BASEITEM
  298.   module USABLEITEM
  299.    
  300.     COMMAND_NAME = /<(?:COMMAND NAME|command name):[ ](.*)>/i
  301.     COMMAND_HIDE_LEARN =
  302.       /<(?:COMMAND_HIDE_UNTIL_LEARN|command hide until learn)>/i
  303.     COMMAND_HIDE_USABLE =
  304.       /<(?:COMMAND_HIDE_UNTIL_USABLE|command hide until usable)>/i
  305.     COMMAND_HIDE_SWITCH =
  306.       /<(?:COMMAND_HIDE_UNTIL_SWITCH|command hide until switch):[ ](\d+)>/i
  307.    
  308.   end # USABLEITEM
  309.   end # REGEXP
  310. end # YEA
  311.  
  312. #==============================================================================
  313. # ■ DataManager
  314. #==============================================================================
  315.  
  316. module DataManager
  317.  
  318.   #--------------------------------------------------------------------------
  319.   # alias method: load_database
  320.   #--------------------------------------------------------------------------
  321.   class <<self; alias load_database_bcl load_database; end
  322.   def self.load_database
  323.     load_database_bcl
  324.     load_notetags_bcl
  325.   end
  326.  
  327.   #--------------------------------------------------------------------------
  328.   # new method: load_notetags_bcl
  329.   #--------------------------------------------------------------------------
  330.   def self.load_notetags_bcl
  331.     groups = [$data_actors, $data_classes, $data_skills, $data_items]
  332.     for group in groups
  333.       for obj in group
  334.         next if obj.nil?
  335.         obj.load_notetags_bcl
  336.       end
  337.     end
  338.   end
  339.  
  340. end # DataManager
  341.  
  342. #==============================================================================
  343. # ■ RPG::BaseItem
  344. #==============================================================================
  345.  
  346. class RPG::BaseItem
  347.  
  348.   #--------------------------------------------------------------------------
  349.   # public instance variables
  350.   #--------------------------------------------------------------------------
  351.   attr_accessor :battle_commands
  352.  
  353.   #--------------------------------------------------------------------------
  354.   # common cache: load_notetags_bcl
  355.   #--------------------------------------------------------------------------
  356.   def load_notetags_bcl
  357.     @battle_commands = []
  358.     @command_list = false
  359.     #---
  360.     self.note.split(/[\r\n]+/).each { |line|
  361.       case line
  362.       #---
  363.       when YEA::REGEXP::BASEITEM::COMMAND_LIST_ON
  364.         @command_list = true
  365.       when YEA::REGEXP::BASEITEM::COMMAND_LIST_OFF
  366.         @command_list = false
  367.       else
  368.         next unless @command_list
  369.         @battle_commands.push(line.to_s.upcase)
  370.       #---
  371.       end
  372.     } # self.note.split
  373.     #---
  374.     if @battle_commands == [] and self.is_a?(RPG::Class)
  375.       @battle_commands = YEA::BATTLE_COMMANDS::DEFAULT_ACTOR_COMMANDS
  376.     end
  377.   end
  378.  
  379. end # RPG::BaseItem
  380.  
  381. #==============================================================================
  382. # ■ RPG::UsableItem
  383. #==============================================================================
  384.  
  385. class RPG::UsableItem < RPG::BaseItem
  386.  
  387.   #--------------------------------------------------------------------------
  388.   # public instance variables
  389.   #--------------------------------------------------------------------------
  390.   attr_accessor :command_name
  391.   attr_accessor :command_hide_until_learn
  392.   attr_accessor :command_hide_until_usable
  393.   attr_accessor :command_hide_until_switch
  394.  
  395.   #--------------------------------------------------------------------------
  396.   # common cache: load_notetags_bcl
  397.   #--------------------------------------------------------------------------
  398.   def load_notetags_bcl
  399.     @command_name = @name.clone
  400.     @command_hide_until_switch = 0
  401.     #---
  402.     self.note.split(/[\r\n]+/).each { |line|
  403.       case line
  404.       #---
  405.       when YEA::REGEXP::USABLEITEM::COMMAND_NAME
  406.         @command_name = $1.to_s
  407.       when YEA::REGEXP::USABLEITEM::COMMAND_HIDE_LEARN
  408.         @command_hide_until_learn = true
  409.       when YEA::REGEXP::USABLEITEM::COMMAND_HIDE_USABLE
  410.         @command_hide_until_usable = true
  411.       when YEA::REGEXP::USABLEITEM::COMMAND_HIDE_USABLE
  412.         command_hide_until_switch = $1.to_i
  413.       #---
  414.       end
  415.     } # self.note.split
  416.     #---
  417.   end
  418.  
  419. end # RPG::UsableItem
  420.  
  421. #==============================================================================
  422. # ■ Game_Actor
  423. #==============================================================================
  424.  
  425. class Game_Actor < Game_Battler
  426.  
  427.   #--------------------------------------------------------------------------
  428.   # new method: battle_commands
  429.   #--------------------------------------------------------------------------
  430.   def battle_commands
  431.     return self.actor.battle_commands unless actor.battle_commands == []
  432.     return self.class.battle_commands
  433.   end
  434.  
  435.   #--------------------------------------------------------------------------
  436.   # new method: next_command_valid?
  437.   #--------------------------------------------------------------------------
  438.   def next_command_valid?
  439.     if $imported["YEA-BattleSystem-FTB"] && BattleManager.btype?(:ftb)
  440.       return false
  441.     end
  442.     return false if @action_input_index >= @actions.size - 1
  443.     return true
  444.   end
  445.  
  446. end # Game_Actor
  447.  
  448. #==============================================================================
  449. # ■ Window_PartyCommand
  450. #==============================================================================
  451.  
  452. class Window_PartyCommand < Window_Command
  453.  
  454.   #--------------------------------------------------------------------------
  455.   # overwrite method: make_command_list
  456.   #--------------------------------------------------------------------------
  457.   def make_command_list
  458.     for command in YEA::BATTLE_COMMANDS::PARTY_COMMANDS
  459.       case command
  460.       when :fight
  461.         add_command(Vocab::fight, :fight)
  462.       when :escape
  463.         add_command(Vocab::escape, :escape, BattleManager.can_escape?)
  464.       when :combatlog
  465.         next unless $imported["YEA-CombatLogDisplay"]
  466.         add_command(YEA::COMBAT_LOG::COMMAND_NAME, :combatlog)
  467.       when :autobattle
  468.         next unless $imported["YEA-CommandAutobattle"]
  469.         add_autobattle_command
  470.       when :party
  471.         next unless $imported["YEA-PartySystem"]
  472.         next unless $imported["YEA-CommandParty"]
  473.         add_party_command
  474.       else
  475.         process_custom_command(command)
  476.       end
  477.     end
  478.   end
  479.  
  480.   #--------------------------------------------------------------------------
  481.   # new method: process_custom_command
  482.   #--------------------------------------------------------------------------
  483.   def process_custom_command(command)
  484.     return unless YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS.include?(command)
  485.     show = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][2]
  486.     continue = show <= 0 ? true : $game_switches[show]
  487.     return unless continue
  488.     text = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][0]
  489.     switch = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][1]
  490.     enabled = switch <= 0 ? true : $game_switches[switch]
  491.     add_command(text, command, enabled)
  492.   end
  493.  
  494. end # Window_PartyCommand
  495.  
  496. #==============================================================================
  497. # ■ Window_ConfirmCommand
  498. #==============================================================================
  499.  
  500. class Window_ConfirmCommand < Window_Command
  501.  
  502.   #--------------------------------------------------------------------------
  503.   # initialize
  504.   #--------------------------------------------------------------------------
  505.   def initialize
  506.     super(0, 0)
  507.     deactivate
  508.     hide
  509.   end
  510.  
  511.   #--------------------------------------------------------------------------
  512.   # window_width
  513.   #--------------------------------------------------------------------------
  514.   def window_width; return 128; end
  515.  
  516.   #--------------------------------------------------------------------------
  517.   # visible_line_number
  518.   #--------------------------------------------------------------------------
  519.   def visible_line_number; return 4; end
  520.  
  521.   #--------------------------------------------------------------------------
  522.   # overwrite method: make_command_list
  523.   #--------------------------------------------------------------------------
  524.   def make_command_list
  525.     for command in YEA::BATTLE_COMMANDS::CONFIRM_COMMANDS
  526.       case command
  527.       when :execute
  528.         text = YEA::BATTLE_COMMANDS::EXECUTE_VOCAB
  529.         add_command(text, :execute)
  530.       when :combatlog
  531.         next unless $imported["YEA-CombatLogDisplay"]
  532.         add_command(YEA::COMBAT_LOG::COMMAND_NAME, :combatlog)
  533.       else
  534.         process_custom_command(command)
  535.       end
  536.     end
  537.   end
  538.  
  539.   #--------------------------------------------------------------------------
  540.   # new method: process_custom_command
  541.   #--------------------------------------------------------------------------
  542.   def process_custom_command(command)
  543.     return unless YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS.include?(command)
  544.     show = YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS[command][2]
  545.     continue = show <= 0 ? true : $game_switches[show]
  546.     return unless continue
  547.     text = YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS[command][0]
  548.     switch = YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS[command][1]
  549.     enabled = switch <= 0 ? true : $game_switches[switch]
  550.     add_command(text, command, enabled)
  551.   end
  552.  
  553.   #--------------------------------------------------------------------------
  554.   # setup
  555.   #--------------------------------------------------------------------------
  556.   def setup
  557.     clear_command_list
  558.     make_command_list
  559.     refresh
  560.     select(0)
  561.     activate
  562.     self.openness = 255
  563.     show
  564.   end
  565.  
  566.   #--------------------------------------------------------------------------
  567.   # process_handling
  568.   #--------------------------------------------------------------------------
  569.   if $imported["YEA-BattleEngine"]
  570.   def process_handling
  571.     return unless open? && active
  572.     return process_dir4 if Input.repeat?(:LEFT)
  573.     return super
  574.   end
  575.  
  576.   #--------------------------------------------------------------------------
  577.   # process_dir4
  578.   #--------------------------------------------------------------------------
  579.   def process_dir4
  580.     Sound.play_cursor
  581.     Input.update
  582.     deactivate
  583.     call_handler(:dir4)
  584.   end
  585.   end # $imported["YEA-BattleEngine"]
  586.  
  587. end # Window_ConfirmCommand
  588.  
  589. #==============================================================================
  590. # ■ Window_ActorCommand
  591. #==============================================================================
  592.  
  593. class Window_ActorCommand < Window_Command
  594.  
  595.   #--------------------------------------------------------------------------
  596.   # alias method: setup
  597.   #--------------------------------------------------------------------------
  598.   alias window_actorcommand_setup_bcl setup
  599.   def setup(actor)
  600.     window_actorcommand_setup_bcl(actor)
  601.     show
  602.   end
  603.  
  604.   #--------------------------------------------------------------------------
  605.   # overwrite method: make_command_list
  606.   #--------------------------------------------------------------------------
  607.   def make_command_list
  608.     return if @actor.nil?
  609.     @stype_list = []
  610.     for command in @actor.battle_commands
  611.       case command.upcase
  612.       #---
  613.       when /ATTACK/i
  614.         add_attack_command
  615.       when /SKILL LIST/i
  616.         add_skill_commands
  617.       when /DEFEND/i
  618.         add_guard_command
  619.       when /ITEMS/i
  620.         add_item_command
  621.       #---
  622.       when /SKILL TYPE[ ](\d+)/i
  623.         add_skill_type_command($1.to_i)
  624.       when /SKILL[ ](\d+)/i
  625.         add_skill_id_command($1.to_i)
  626.       when /ITEM[ ](\d+)/i
  627.         add_item_id_command($1.to_i)
  628.       #---
  629.       when /AUTOBATTLE/i
  630.         next unless $imported["YEA-CommandAutobattle"]
  631.         add_autobattle_command
  632.       when /EQUIP/i
  633.         next unless $imported["YEA-CommandEquip"]
  634.         add_equip_command
  635.       when /SUBCLASS LIST/i
  636.         add_subclass_skill_types
  637.       #---
  638.       else; next        
  639.       end
  640.     end
  641.   end
  642.  
  643.   #--------------------------------------------------------------------------
  644.   # overwrite method: add_skill_commands
  645.   #--------------------------------------------------------------------------
  646.   def add_skill_commands
  647.     @actor.added_skill_types.each do |stype_id|
  648.       next if @stype_list.include?(stype_id)
  649.       next if include_subclass_type?(stype_id)
  650.       add_skill_type_command(stype_id)
  651.     end
  652.   end
  653.  
  654.   #--------------------------------------------------------------------------
  655.   # new method: include_subclass_type?
  656.   #--------------------------------------------------------------------------
  657.   def include_subclass_type?(stype_id)
  658.     return false unless $imported["YEA-ClassSystem"]
  659.     return @actor.subclass_skill_types.include?(stype_id)
  660.   end
  661.  
  662.   #--------------------------------------------------------------------------
  663.   # new method: add_subclass_skill_types
  664.   #--------------------------------------------------------------------------
  665.   def add_subclass_skill_types
  666.     return unless $imported["YEA-ClassSystem"]
  667.     return if @actor.subclass.nil?
  668.     @actor.subclass_skill_types.sort.each do |stype_id|
  669.       next if @stype_list.include?(stype_id)
  670.       add_skill_type_command(stype_id)
  671.     end
  672.   end
  673.  
  674.   #--------------------------------------------------------------------------
  675.   # new method: add_skill_type_command
  676.   #--------------------------------------------------------------------------
  677.   def add_skill_type_command(stype_id)
  678.     return unless @actor.added_skill_types.include?(stype_id)
  679.     for i in 0..YEA::BATTLE_COMMANDS::STYPES_STATES.size - 1
  680.     return if stype_id==YEA::BATTLE_COMMANDS::STYPES_STATES[i][0] && @actor.state?(YEA::BATTLE_COMMANDS::STYPES_STATES[i][1])
  681.     end
  682.     return if @actor.tp!=YEA::BATTLE_COMMANDS::OVERDRIVE_TP && stype_id==YEA::BATTLE_COMMANDS::OVERDRIVE_STYPE
  683.     return if @stype_list.include?(stype_id)
  684.     @stype_list.push(stype_id)
  685.     name = $data_system.skill_types[stype_id]
  686.     add_command(name, :skill, true, stype_id)
  687.   end
  688.    
  689.  
  690.   #--------------------------------------------------------------------------
  691.   # new method: add_skill_id_command
  692.   #--------------------------------------------------------------------------
  693.   def add_skill_id_command(skill_id)
  694.     return if $data_skills[skill_id].nil?
  695.     return unless add_use_skill?(skill_id)
  696.     name = $data_skills[skill_id].command_name
  697.     add_command(name, :use_skill, use_skill_valid?(skill_id), skill_id)
  698.   end
  699.  
  700.   #--------------------------------------------------------------------------
  701.   # new method: add_use_skill?
  702.   #--------------------------------------------------------------------------
  703.   def add_use_skill?(skill_id)
  704.     skill = $data_skills[skill_id]
  705.     return false if hide_until_learn?(skill)
  706.     return false if hide_until_usable?(skill)
  707.     return false if hide_until_switch?(skill)
  708.     return true
  709.   end
  710.  
  711.   #--------------------------------------------------------------------------
  712.   # new method: hide_until_learn?
  713.   #--------------------------------------------------------------------------
  714.   def hide_until_learn?(skill)
  715.     return false unless skill.command_hide_until_learn
  716.     return false if @actor.skill_learn?(skill)
  717.     return false if @actor.added_skills.include?(skill.id)
  718.     return true
  719.   end
  720.  
  721.   #--------------------------------------------------------------------------
  722.   # new method: hide_until_usable?
  723.   #--------------------------------------------------------------------------
  724.   def hide_until_usable?(skill)
  725.     return false unless skill.command_hide_until_usable
  726.     return false if @actor.usable?(skill)
  727.     return true
  728.   end
  729.  
  730.   #--------------------------------------------------------------------------
  731.   # new method: hide_until_switch?
  732.   #--------------------------------------------------------------------------
  733.   def hide_until_switch?(skill)
  734.     return false unless skill.command_hide_until_switch > 0
  735.     return false if $game_switches[skill.command_hide_until_switch]
  736.     return true
  737.   end
  738.  
  739.   #--------------------------------------------------------------------------
  740.   # new method: use_skill_valid?
  741.   #--------------------------------------------------------------------------
  742.   def use_skill_valid?(skill_id)
  743.     skill = $data_skills[skill_id]
  744.     return false unless @actor.skill_conditions_met?(skill)
  745.     return true
  746.   end
  747.  
  748.   #--------------------------------------------------------------------------
  749.   # new method: add_item_id_command
  750.   #--------------------------------------------------------------------------
  751.   def add_item_id_command(item_id)
  752.     return if $data_items[item_id].nil?
  753.     return unless add_use_item?(item_id)
  754.     name = $data_items[item_id].command_name
  755.     add_command(name, :use_item, use_item_valid?(item_id), item_id)
  756.   end
  757.  
  758.   #--------------------------------------------------------------------------
  759.   # new method: add_use_item?
  760.   #--------------------------------------------------------------------------
  761.   def add_use_item?(item_id)
  762.     item = $data_items[item_id]
  763.     return false if hide_until_usable?(item)
  764.     return false if hide_until_switch?(item)
  765.     return true
  766.   end
  767.  
  768.   #--------------------------------------------------------------------------
  769.   # new method: use_item_valid?
  770.   #--------------------------------------------------------------------------
  771.   def use_item_valid?(item_id)
  772.     item = $data_items[item_id]
  773.     return false unless @actor.item_conditions_met?(item)
  774.     return true
  775.   end
  776.  
  777. end # Window_ActorCommand
  778.  
  779. #==============================================================================
  780. # ■ Scene_Battle
  781. #==============================================================================
  782.  
  783. class Scene_Battle < Scene_Base
  784.  
  785.   #--------------------------------------------------------------------------
  786.   # alias method: create_all_windows
  787.   #--------------------------------------------------------------------------
  788.   alias scene_battle_create_all_windows_bcl create_all_windows
  789.   def create_all_windows
  790.     scene_battle_create_all_windows_bcl
  791.     create_confirm_command_window
  792.   end
  793.  
  794.   #--------------------------------------------------------------------------
  795.   # alias method: create_party_command_window
  796.   #--------------------------------------------------------------------------
  797.   alias create_party_command_window_bcl create_party_command_window
  798.   def create_party_command_window
  799.     create_party_command_window_bcl
  800.     process_custom_party_commands
  801.   end
  802.  
  803.   #--------------------------------------------------------------------------
  804.   # new method: process_custom_party_commands
  805.   #--------------------------------------------------------------------------
  806.   def process_custom_party_commands
  807.     for command in YEA::BATTLE_COMMANDS::PARTY_COMMANDS
  808.       next unless YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS.include?(command)
  809.       called_method = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][3]
  810.       @party_command_window.set_handler(command, method(called_method))
  811.     end
  812.   end
  813.  
  814.   #--------------------------------------------------------------------------
  815.   # alias method: create_actor_command_window
  816.   #--------------------------------------------------------------------------
  817.   alias create_actor_command_window_bcl create_actor_command_window
  818.   def create_actor_command_window
  819.     create_actor_command_window_bcl
  820.     @actor_command_window.set_handler(:use_skill, method(:command_use_skill))
  821.     @actor_command_window.set_handler(:use_item, method(:command_use_item))
  822.   end
  823.  
  824.   #--------------------------------------------------------------------------
  825.   # alias method: start_actor_command_selection
  826.   #--------------------------------------------------------------------------
  827.   alias start_actor_command_selection_bcl start_actor_command_selection
  828.   def start_actor_command_selection
  829.     @confirm_command_window.hide unless @confirm_command_window.nil?
  830.     start_actor_command_selection_bcl
  831.     @actor_command_window.show
  832.   end
  833.  
  834.   #--------------------------------------------------------------------------
  835.   # new method: command_use_skill
  836.   #--------------------------------------------------------------------------
  837.   def command_use_skill
  838.     @skill = $data_skills[@actor_command_window.current_ext]
  839.     BattleManager.actor.input.set_skill(@skill.id)
  840.     BattleManager.actor.last_skill.object = @skill
  841.     status_redraw_target(BattleManager.actor)
  842.     if $imported["YEA-BattleEngine"]
  843.       $game_temp.battle_aid = @skill
  844.       if @skill.for_opponent?
  845.         select_enemy_selection
  846.       elsif @skill.for_friend?
  847.         select_actor_selection
  848.       else
  849.         next_command
  850.         $game_temp.battle_aid = nil
  851.       end
  852.     else
  853.       if !@skill.need_selection?
  854.         next_command
  855.       elsif @skill.for_opponent?
  856.         select_enemy_selection
  857.       else
  858.         select_actor_selection
  859.       end
  860.     end
  861.   end
  862.  
  863.   #--------------------------------------------------------------------------
  864.   # new method: command_use_item
  865.   #--------------------------------------------------------------------------
  866.   def command_use_item
  867.     @item = $data_items[@actor_command_window.current_ext]
  868.     BattleManager.actor.input.set_item(@item.id)
  869.     status_redraw_target(BattleManager.actor)
  870.     if $imported["YEA-BattleEngine"]
  871.       $game_temp.battle_aid = @item
  872.       if @item.for_opponent?
  873.         select_enemy_selection
  874.       elsif @item.for_friend?
  875.         select_actor_selection
  876.       else
  877.         next_command
  878.         $game_temp.battle_aid = nil
  879.       end
  880.     else
  881.       if !@item.need_selection?
  882.         next_command
  883.       elsif @item.for_opponent?
  884.         select_enemy_selection
  885.       else
  886.         select_actor_selection
  887.       end
  888.     end
  889.   end
  890.  
  891.   #--------------------------------------------------------------------------
  892.   # alias method: on_actor_ok
  893.   #--------------------------------------------------------------------------
  894.   alias scene_battle_on_actor_ok_bcl on_actor_ok
  895.   def on_actor_ok
  896.     scene_battle_on_actor_ok_bcl
  897.     return if !@confirm_command_window.nil? && @confirm_command_window.visible
  898.     @actor_command_window.show
  899.   end
  900.  
  901.   #--------------------------------------------------------------------------
  902.   # alias method: on_actor_cancel
  903.   #--------------------------------------------------------------------------
  904.   alias scene_battle_on_actor_cancel_bcl on_actor_cancel
  905.   def on_actor_cancel
  906.     scene_battle_on_actor_cancel_bcl
  907.     case @actor_command_window.current_symbol
  908.     when :use_skill, :use_item
  909.       @help_window.hide
  910.       @status_window.show
  911.       @actor_command_window.activate
  912.       status_redraw_target(BattleManager.actor)
  913.     end
  914.   end
  915.  
  916.   #--------------------------------------------------------------------------
  917.   # alias method: on_enemy_ok
  918.   #--------------------------------------------------------------------------
  919.   alias scene_battle_on_enemy_ok_bcl on_enemy_ok
  920.   def on_enemy_ok
  921.     scene_battle_on_enemy_ok_bcl
  922.     return if !@confirm_command_window.nil? && @confirm_command_window.visible
  923.     @actor_command_window.show
  924.   end
  925.  
  926.   #--------------------------------------------------------------------------
  927.   # alias method: on_enemy_cancel
  928.   #--------------------------------------------------------------------------
  929.   alias scene_battle_on_enemy_cancel_bcl on_enemy_cancel
  930.   def on_enemy_cancel
  931.     scene_battle_on_enemy_cancel_bcl
  932.     case @actor_command_window.current_symbol
  933.     when :use_skill, :use_item
  934.       @help_window.hide
  935.       @status_window.show
  936.       @actor_command_window.activate
  937.       status_redraw_target(BattleManager.actor)
  938.     end
  939.   end
  940.  
  941.   #--------------------------------------------------------------------------
  942.   # new method: status_redraw_target
  943.   #--------------------------------------------------------------------------
  944.   def status_redraw_target(target)
  945.     return unless target.actor?
  946.     @status_window.draw_item($game_party.battle_members.index(target))
  947.   end
  948.  
  949.   #--------------------------------------------------------------------------
  950.   # new method: create_confirm_command_window
  951.   #--------------------------------------------------------------------------
  952.   def create_confirm_command_window
  953.     return unless YEA::BATTLE_COMMANDS::USE_CONFIRM_WINDOW
  954.     @confirm_command_window = Window_ConfirmCommand.new
  955.     @confirm_command_window.viewport = @info_viewport
  956.     @confirm_command_window.set_handler(:execute, method(:command_execute))
  957.     @confirm_command_window.set_handler(:cancel, method(:on_confirm_cancel))
  958.     @confirm_command_window.set_handler(:dir4, method(:on_confirm_cancel))
  959.     @confirm_command_window.unselect
  960.     @confirm_command_window.x = Graphics.width
  961.     process_custom_confirm_commands
  962.     process_confirm_compatibility_commands
  963.   end
  964.  
  965.   #--------------------------------------------------------------------------
  966.   # new method: process_custom_confirm_commands
  967.   #--------------------------------------------------------------------------
  968.   def process_custom_confirm_commands
  969.     for command in YEA::BATTLE_COMMANDS::CONFIRM_COMMANDS
  970.       next unless YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS.include?(command)
  971.       called_method = YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS[command][3]
  972.       @party_command_window.set_handler(command, method(called_method))
  973.     end
  974.   end
  975.  
  976.   #--------------------------------------------------------------------------
  977.   # new method: process_confirm_compatibility_commands
  978.   #--------------------------------------------------------------------------
  979.   def process_confirm_compatibility_commands
  980.     #---
  981.     if $imported["YEA-CombatLogDisplay"]
  982.       @confirm_command_window.set_handler(:combatlog, method(:open_combatlog))
  983.     end
  984.     #---
  985.   end
  986.  
  987.   #--------------------------------------------------------------------------
  988.   # new method: start_confirm_command_selection
  989.   #--------------------------------------------------------------------------
  990.   def start_confirm_command_selection
  991.     if $imported["YEA-BattleEngine"]
  992.       @status_window.show
  993.       redraw_current_status
  994.       @status_aid_window.hide
  995.     end
  996.     @status_window.unselect
  997.     @actor_command_window.hide
  998.     @confirm_command_window.setup
  999.   end
  1000.  
  1001.   #--------------------------------------------------------------------------
  1002.   # new method: on_confirm_cancel
  1003.   #--------------------------------------------------------------------------
  1004.   def on_confirm_cancel
  1005.     @confirm_command_window.hide unless @confirm_command_window.nil?
  1006.     @actor_command_window.show
  1007.     @actor_command_window.setup(BattleManager.actor)
  1008.     @status_window.select(BattleManager.actor.index)
  1009.     prior_command unless BattleManager.actor.inputable?
  1010.   end
  1011.  
  1012.   #--------------------------------------------------------------------------
  1013.   # alias method: next_command
  1014.   #--------------------------------------------------------------------------
  1015.   alias scene_battle_next_command_bcl next_command
  1016.   def next_command
  1017.     if prompt_next_actor?
  1018.       scene_battle_next_command_bcl
  1019.     elsif YEA::BATTLE_COMMANDS::USE_CONFIRM_WINDOW
  1020.       start_confirm_command_selection
  1021.     else
  1022.       turn_start
  1023.     end
  1024.   end
  1025.  
  1026.   #--------------------------------------------------------------------------
  1027.   # new method: prompt_next_actor?
  1028.   #--------------------------------------------------------------------------
  1029.   def prompt_next_actor?
  1030.     index = @status_window.index
  1031.     last_index = $game_party.battle_members.size - 1
  1032.     for member in $game_party.battle_members.reverse
  1033.       break if member.inputable?
  1034.       last_index -= 1
  1035.     end
  1036.     if index >= last_index
  1037.       actor = $game_party.battle_members[index]
  1038.       return true if prompt_ftb_action?(actor)
  1039.       return true if actor.next_command_valid?
  1040.       return false if YEA::BATTLE_COMMANDS::USE_CONFIRM_WINDOW
  1041.     end
  1042.     return true
  1043.   end
  1044.  
  1045.   #--------------------------------------------------------------------------
  1046.   # new method: prompt_ftb_action?
  1047.   #--------------------------------------------------------------------------
  1048.   def prompt_ftb_action?(actor)
  1049.     return false unless $imported["YEA-BattleEngine"]
  1050.     return false unless $imported["YEA-BattleSystem-FTB"]
  1051.     return false unless BattleManager.btype?(:ftb)
  1052.     return actor.current_action.valid?
  1053.   end
  1054.  
  1055.   #--------------------------------------------------------------------------
  1056.   # new method: command_execute
  1057.   #--------------------------------------------------------------------------
  1058.   def command_execute
  1059.     @confirm_command_window.close
  1060.     turn_start
  1061.   end
  1062.  
  1063.   #--------------------------------------------------------------------------
  1064.   # new method: command_name1
  1065.   #--------------------------------------------------------------------------
  1066.   def command_name1
  1067.     # Do nothing.
  1068.   end
  1069.  
  1070.   #--------------------------------------------------------------------------
  1071.   # new method: command_name2
  1072.   #--------------------------------------------------------------------------
  1073.   def command_name2
  1074.     # Do nothing.
  1075.   end
  1076.  
  1077. end # Scene_Battle
  1078.  
  1079. #==============================================================================
  1080. #
  1081. # ▼ End of File
  1082. #
  1083. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement