Advertisement
Archeia

Yanfly Engine Ace - Battle Command List v1.09b

Mar 30th, 2014
5,095
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 41.60 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ¥ Yanfly Engine Ace - Battle Command List v1.09b
  4. # -- Last Updated: 2012.12.18
  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.12.18 - Completely fixed the command hide switch bug.
  17. # 2012.12.17 - Fixed Bug with command hide until switch.
  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/‘fÞ 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.   end # BATTLE_COMMANDS
  257. end # YEA
  258.  
  259. #==============================================================================
  260. # ¥ Editting anything past this point may potentially result in causing
  261. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  262. # halitosis so edit at your own risk.
  263. #==============================================================================
  264.  
  265. module YEA
  266.   module REGEXP
  267.   module BASEITEM
  268.    
  269.     COMMAND_LIST_ON  = /<(?:COMMAND_LIST|command list)>/i
  270.     COMMAND_LIST_OFF = /<\/(?:COMMAND_LIST|command list)>/i
  271.    
  272.   end # BASEITEM
  273.   module USABLEITEM
  274.    
  275.     COMMAND_NAME = /<(?:COMMAND NAME|command name):[ ](.*)>/i
  276.     COMMAND_HIDE_LEARN =
  277.       /<(?:COMMAND_HIDE_UNTIL_LEARN|command hide until learn)>/i
  278.     COMMAND_HIDE_USABLE =
  279.       /<(?:COMMAND_HIDE_UNTIL_USABLE|command hide until usable)>/i
  280.     COMMAND_HIDE_SWITCH =
  281.       /<(?:COMMAND_HIDE_UNTIL_SWITCH|command hide until switch):[ ](\d+)>/i
  282.    
  283.   end # USABLEITEM
  284.   end # REGEXP
  285. end # YEA
  286.  
  287. #==============================================================================
  288. # ¡ DataManager
  289. #==============================================================================
  290.  
  291. module DataManager
  292.  
  293.   #--------------------------------------------------------------------------
  294.   # alias method: load_database
  295.   #--------------------------------------------------------------------------
  296.   class <<self; alias load_database_bcl load_database; end
  297.   def self.load_database
  298.     load_database_bcl
  299.     load_notetags_bcl
  300.   end
  301.  
  302.   #--------------------------------------------------------------------------
  303.   # new method: load_notetags_bcl
  304.   #--------------------------------------------------------------------------
  305.   def self.load_notetags_bcl
  306.     groups = [$data_actors, $data_classes, $data_skills, $data_items]
  307.     for group in groups
  308.       for obj in group
  309.         next if obj.nil?
  310.         obj.load_notetags_bcl
  311.       end
  312.     end
  313.   end
  314.  
  315. end # DataManager
  316.  
  317. #==============================================================================
  318. # ¡ RPG::BaseItem
  319. #==============================================================================
  320.  
  321. class RPG::BaseItem
  322.  
  323.   #--------------------------------------------------------------------------
  324.   # public instance variables
  325.   #--------------------------------------------------------------------------
  326.   attr_accessor :battle_commands
  327.  
  328.   #--------------------------------------------------------------------------
  329.   # common cache: load_notetags_bcl
  330.   #--------------------------------------------------------------------------
  331.   def load_notetags_bcl
  332.     @battle_commands = []
  333.     @command_list = false
  334.     #---
  335.     self.note.split(/[\r\n]+/).each { |line|
  336.       case line
  337.       #---
  338.       when YEA::REGEXP::BASEITEM::COMMAND_LIST_ON
  339.         @command_list = true
  340.       when YEA::REGEXP::BASEITEM::COMMAND_LIST_OFF
  341.         @command_list = false
  342.       else
  343.         next unless @command_list
  344.         @battle_commands.push(line.to_s.upcase)
  345.       #---
  346.       end
  347.     } # self.note.split
  348.     #---
  349.     if @battle_commands == [] and self.is_a?(RPG::Class)
  350.       @battle_commands = YEA::BATTLE_COMMANDS::DEFAULT_ACTOR_COMMANDS
  351.     end
  352.   end
  353.  
  354. end # RPG::BaseItem
  355.  
  356. #==============================================================================
  357. # ¡ RPG::UsableItem
  358. #==============================================================================
  359.  
  360. class RPG::UsableItem < RPG::BaseItem
  361.  
  362.   #--------------------------------------------------------------------------
  363.   # public instance variables
  364.   #--------------------------------------------------------------------------
  365.   attr_accessor :command_name
  366.   attr_accessor :command_hide_until_learn
  367.   attr_accessor :command_hide_until_usable
  368.   attr_accessor :command_hide_until_switch
  369.  
  370.   #--------------------------------------------------------------------------
  371.   # common cache: load_notetags_bcl
  372.   #--------------------------------------------------------------------------
  373.   def load_notetags_bcl
  374.     @command_name = @name.clone
  375.     @command_hide_until_switch = 0
  376.     #---
  377.     self.note.split(/[\r\n]+/).each { |line|
  378.       case line
  379.       #---
  380.       when YEA::REGEXP::USABLEITEM::COMMAND_NAME
  381.         @command_name = $1.to_s
  382.       when YEA::REGEXP::USABLEITEM::COMMAND_HIDE_LEARN
  383.         @command_hide_until_learn = true
  384.       when YEA::REGEXP::USABLEITEM::COMMAND_HIDE_USABLE
  385.         @command_hide_until_usable = true
  386.       when YEA::REGEXP::USABLEITEM::COMMAND_HIDE_SWITCH
  387.         @command_hide_until_switch = $1.to_i
  388.       #---
  389.       end
  390.     } # self.note.split
  391.     #---
  392.   end
  393.  
  394. end # RPG::UsableItem
  395.  
  396. #==============================================================================
  397. # ¡ Game_Actor
  398. #==============================================================================
  399.  
  400. class Game_Actor < Game_Battler
  401.  
  402.   #--------------------------------------------------------------------------
  403.   # new method: battle_commands
  404.   #--------------------------------------------------------------------------
  405.   def battle_commands
  406.     return self.actor.battle_commands unless actor.battle_commands == []
  407.     return self.class.battle_commands
  408.   end
  409.  
  410.   #--------------------------------------------------------------------------
  411.   # new method: next_command_valid?
  412.   #--------------------------------------------------------------------------
  413.   def next_command_valid?
  414.     if $imported["YEA-BattleSystem-FTB"] && BattleManager.btype?(:ftb)
  415.       return false
  416.     end
  417.     return false if @action_input_index >= @actions.size - 1
  418.     return true
  419.   end
  420.  
  421. end # Game_Actor
  422.  
  423. #==============================================================================
  424. # ¡ Window_PartyCommand
  425. #==============================================================================
  426.  
  427. class Window_PartyCommand < Window_Command
  428.  
  429.   #--------------------------------------------------------------------------
  430.   # overwrite method: make_command_list
  431.   #--------------------------------------------------------------------------
  432.   def make_command_list
  433.     for command in YEA::BATTLE_COMMANDS::PARTY_COMMANDS
  434.       case command
  435.       when :fight
  436.         add_command(Vocab::fight, :fight)
  437.       when :escape
  438.         add_command(Vocab::escape, :escape, BattleManager.can_escape?)
  439.       when :combatlog
  440.         next unless $imported["YEA-CombatLogDisplay"]
  441.         add_command(YEA::COMBAT_LOG::COMMAND_NAME, :combatlog)
  442.       when :autobattle
  443.         next unless $imported["YEA-CommandAutobattle"]
  444.         add_autobattle_command
  445.       when :party
  446.         next unless $imported["YEA-PartySystem"]
  447.         next unless $imported["YEA-CommandParty"]
  448.         add_party_command
  449.       else
  450.         process_custom_command(command)
  451.       end
  452.     end
  453.   end
  454.  
  455.   #--------------------------------------------------------------------------
  456.   # new method: process_custom_command
  457.   #--------------------------------------------------------------------------
  458.   def process_custom_command(command)
  459.     return unless YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS.include?(command)
  460.     show = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][2]
  461.     continue = show <= 0 ? true : $game_switches[show]
  462.     return unless continue
  463.     text = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][0]
  464.     switch = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][1]
  465.     enabled = switch <= 0 ? true : $game_switches[switch]
  466.     add_command(text, command, enabled)
  467.   end
  468.  
  469. end # Window_PartyCommand
  470.  
  471. #==============================================================================
  472. # ¡ Window_ConfirmCommand
  473. #==============================================================================
  474.  
  475. class Window_ConfirmCommand < Window_Command
  476.  
  477.   #--------------------------------------------------------------------------
  478.   # initialize
  479.   #--------------------------------------------------------------------------
  480.   def initialize
  481.     super(0, 0)
  482.     deactivate
  483.     hide
  484.   end
  485.  
  486.   #--------------------------------------------------------------------------
  487.   # window_width
  488.   #--------------------------------------------------------------------------
  489.   def window_width; return 128; end
  490.  
  491.   #--------------------------------------------------------------------------
  492.   # visible_line_number
  493.   #--------------------------------------------------------------------------
  494.   def visible_line_number; return 4; end
  495.  
  496.   #--------------------------------------------------------------------------
  497.   # overwrite method: make_command_list
  498.   #--------------------------------------------------------------------------
  499.   def make_command_list
  500.     for command in YEA::BATTLE_COMMANDS::CONFIRM_COMMANDS
  501.       case command
  502.       when :execute
  503.         text = YEA::BATTLE_COMMANDS::EXECUTE_VOCAB
  504.         add_command(text, :execute)
  505.       when :combatlog
  506.         next unless $imported["YEA-CombatLogDisplay"]
  507.         add_command(YEA::COMBAT_LOG::COMMAND_NAME, :combatlog)
  508.       else
  509.         process_custom_command(command)
  510.       end
  511.     end
  512.   end
  513.  
  514.   #--------------------------------------------------------------------------
  515.   # new method: process_custom_command
  516.   #--------------------------------------------------------------------------
  517.   def process_custom_command(command)
  518.     return unless YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS.include?(command)
  519.     show = YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS[command][2]
  520.     continue = show <= 0 ? true : $game_switches[show]
  521.     return unless continue
  522.     text = YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS[command][0]
  523.     switch = YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS[command][1]
  524.     enabled = switch <= 0 ? true : $game_switches[switch]
  525.     add_command(text, command, enabled)
  526.   end
  527.  
  528.   #--------------------------------------------------------------------------
  529.   # setup
  530.   #--------------------------------------------------------------------------
  531.   def setup
  532.     clear_command_list
  533.     make_command_list
  534.     refresh
  535.     select(0)
  536.     activate
  537.     self.openness = 255
  538.     show
  539.   end
  540.  
  541.   #--------------------------------------------------------------------------
  542.   # process_handling
  543.   #--------------------------------------------------------------------------
  544.   if $imported["YEA-BattleEngine"]
  545.   def process_handling
  546.     return unless open? && active
  547.     return process_dir4 if Input.repeat?(:LEFT)
  548.     return super
  549.   end
  550.  
  551.   #--------------------------------------------------------------------------
  552.   # process_dir4
  553.   #--------------------------------------------------------------------------
  554.   def process_dir4
  555.     Sound.play_cursor
  556.     Input.update
  557.     deactivate
  558.     call_handler(:dir4)
  559.   end
  560.   end # $imported["YEA-BattleEngine"]
  561.  
  562. end # Window_ConfirmCommand
  563.  
  564. #==============================================================================
  565. # ¡ Window_ActorCommand
  566. #==============================================================================
  567.  
  568. class Window_ActorCommand < Window_Command
  569.  
  570.   #--------------------------------------------------------------------------
  571.   # alias method: setup
  572.   #--------------------------------------------------------------------------
  573.   alias window_actorcommand_setup_bcl setup
  574.   def setup(actor)
  575.     window_actorcommand_setup_bcl(actor)
  576.     show
  577.   end
  578.  
  579.   #--------------------------------------------------------------------------
  580.   # overwrite method: make_command_list
  581.   #--------------------------------------------------------------------------
  582.   def make_command_list
  583.     return if @actor.nil?
  584.     @stype_list = []
  585.     for command in @actor.battle_commands
  586.       case command.upcase
  587.       #---
  588.       when /ATTACK/i
  589.         add_attack_command
  590.       when /SKILL LIST/i
  591.         add_skill_commands
  592.       when /DEFEND/i
  593.         add_guard_command
  594.       when /ITEMS/i
  595.         add_item_command
  596.       #---
  597.       when /SKILL TYPE[ ](\d+)/i
  598.         add_skill_type_command($1.to_i)
  599.       when /SKILL[ ](\d+)/i
  600.         add_skill_id_command($1.to_i)
  601.       when /ITEM[ ](\d+)/i
  602.         add_item_id_command($1.to_i)
  603.       #---
  604.       when /AUTOBATTLE/i
  605.         next unless $imported["YEA-CommandAutobattle"]
  606.         add_autobattle_command
  607.       when /EQUIP/i
  608.         next unless $imported["YEA-CommandEquip"]
  609.         add_equip_command
  610.       when /SUBCLASS LIST/i
  611.         add_subclass_skill_types
  612.       #---
  613.       else; next        
  614.       end
  615.     end
  616.   end
  617.  
  618.   #--------------------------------------------------------------------------
  619.   # overwrite method: add_skill_commands
  620.   #--------------------------------------------------------------------------
  621.   def add_skill_commands
  622.     @actor.added_skill_types.each do |stype_id|
  623.       next if @stype_list.include?(stype_id)
  624.       next if include_subclass_type?(stype_id)
  625.       add_skill_type_command(stype_id)
  626.     end
  627.   end
  628.  
  629.   #--------------------------------------------------------------------------
  630.   # new method: include_subclass_type?
  631.   #--------------------------------------------------------------------------
  632.   def include_subclass_type?(stype_id)
  633.     return false unless $imported["YEA-ClassSystem"]
  634.     return @actor.subclass_skill_types.include?(stype_id)
  635.   end
  636.  
  637.   #--------------------------------------------------------------------------
  638.   # new method: add_subclass_skill_types
  639.   #--------------------------------------------------------------------------
  640.   def add_subclass_skill_types
  641.     return unless $imported["YEA-ClassSystem"]
  642.     return if @actor.subclass.nil?
  643.     @actor.subclass_skill_types.sort.each do |stype_id|
  644.       next if @stype_list.include?(stype_id)
  645.       add_skill_type_command(stype_id)
  646.     end
  647.   end
  648.  
  649.   #--------------------------------------------------------------------------
  650.   # new method: add_skill_type_command
  651.   #--------------------------------------------------------------------------
  652.   def add_skill_type_command(stype_id)
  653.     return unless @actor.added_skill_types.include?(stype_id)
  654.     return if @stype_list.include?(stype_id)
  655.     @stype_list.push(stype_id)
  656.     name = $data_system.skill_types[stype_id]
  657.     add_command(name, :skill, true, stype_id)
  658.   end
  659.  
  660.   #--------------------------------------------------------------------------
  661.   # new method: add_skill_id_command
  662.   #--------------------------------------------------------------------------
  663.   def add_skill_id_command(skill_id)
  664.     return if $data_skills[skill_id].nil?
  665.     return unless add_use_skill?(skill_id)
  666.     name = $data_skills[skill_id].command_name
  667.     add_command(name, :use_skill, use_skill_valid?(skill_id), skill_id)
  668.   end
  669.  
  670.   #--------------------------------------------------------------------------
  671.   # new method: add_use_skill?
  672.   #--------------------------------------------------------------------------
  673.   def add_use_skill?(skill_id)
  674.     skill = $data_skills[skill_id]
  675.     return false if hide_until_learn?(skill)
  676.     return false if hide_until_usable?(skill)
  677.     return false if hide_until_switch?(skill)
  678.     return true
  679.   end
  680.  
  681.   #--------------------------------------------------------------------------
  682.   # new method: hide_until_learn?
  683.   #--------------------------------------------------------------------------
  684.   def hide_until_learn?(skill)
  685.     return false unless skill.command_hide_until_learn
  686.     return false if @actor.skill_learn?(skill)
  687.     return false if @actor.added_skills.include?(skill.id)
  688.     return true
  689.   end
  690.  
  691.   #--------------------------------------------------------------------------
  692.   # new method: hide_until_usable?
  693.   #--------------------------------------------------------------------------
  694.   def hide_until_usable?(skill)
  695.     return false unless skill.command_hide_until_usable
  696.     return false if @actor.usable?(skill)
  697.     return true
  698.   end
  699.  
  700.   #--------------------------------------------------------------------------
  701.   # new method: hide_until_switch?
  702.   #--------------------------------------------------------------------------
  703.   def hide_until_switch?(skill)
  704.     return false unless skill.command_hide_until_switch > 0
  705.     return false if $game_switches[skill.command_hide_until_switch]
  706.     return true
  707.   end
  708.  
  709.   #--------------------------------------------------------------------------
  710.   # new method: use_skill_valid?
  711.   #--------------------------------------------------------------------------
  712.   def use_skill_valid?(skill_id)
  713.     skill = $data_skills[skill_id]
  714.     return false unless @actor.skill_conditions_met?(skill)
  715.     return true
  716.   end
  717.  
  718.   #--------------------------------------------------------------------------
  719.   # new method: add_item_id_command
  720.   #--------------------------------------------------------------------------
  721.   def add_item_id_command(item_id)
  722.     return if $data_items[item_id].nil?
  723.     return unless add_use_item?(item_id)
  724.     name = $data_items[item_id].command_name
  725.     add_command(name, :use_item, use_item_valid?(item_id), item_id)
  726.   end
  727.  
  728.   #--------------------------------------------------------------------------
  729.   # new method: add_use_item?
  730.   #--------------------------------------------------------------------------
  731.   def add_use_item?(item_id)
  732.     item = $data_items[item_id]
  733.     return false if hide_until_usable?(item)
  734.     return false if hide_until_switch?(item)
  735.     return true
  736.   end
  737.  
  738.   #--------------------------------------------------------------------------
  739.   # new method: use_item_valid?
  740.   #--------------------------------------------------------------------------
  741.   def use_item_valid?(item_id)
  742.     item = $data_items[item_id]
  743.     return false unless @actor.item_conditions_met?(item)
  744.     return true
  745.   end
  746.  
  747. end # Window_ActorCommand
  748.  
  749. #==============================================================================
  750. # ¡ Scene_Battle
  751. #==============================================================================
  752.  
  753. class Scene_Battle < Scene_Base
  754.  
  755.   #--------------------------------------------------------------------------
  756.   # alias method: create_all_windows
  757.   #--------------------------------------------------------------------------
  758.   alias scene_battle_create_all_windows_bcl create_all_windows
  759.   def create_all_windows
  760.     scene_battle_create_all_windows_bcl
  761.     create_confirm_command_window
  762.   end
  763.  
  764.   #--------------------------------------------------------------------------
  765.   # alias method: create_party_command_window
  766.   #--------------------------------------------------------------------------
  767.   alias create_party_command_window_bcl create_party_command_window
  768.   def create_party_command_window
  769.     create_party_command_window_bcl
  770.     process_custom_party_commands
  771.   end
  772.  
  773.   #--------------------------------------------------------------------------
  774.   # new method: process_custom_party_commands
  775.   #--------------------------------------------------------------------------
  776.   def process_custom_party_commands
  777.     for command in YEA::BATTLE_COMMANDS::PARTY_COMMANDS
  778.       next unless YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS.include?(command)
  779.       called_method = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][3]
  780.       @party_command_window.set_handler(command, method(called_method))
  781.     end
  782.   end
  783.  
  784.   #--------------------------------------------------------------------------
  785.   # alias method: create_actor_command_window
  786.   #--------------------------------------------------------------------------
  787.   alias create_actor_command_window_bcl create_actor_command_window
  788.   def create_actor_command_window
  789.     create_actor_command_window_bcl
  790.     @actor_command_window.set_handler(:use_skill, method(:command_use_skill))
  791.     @actor_command_window.set_handler(:use_item, method(:command_use_item))
  792.   end
  793.  
  794.   #--------------------------------------------------------------------------
  795.   # alias method: start_actor_command_selection
  796.   #--------------------------------------------------------------------------
  797.   alias start_actor_command_selection_bcl start_actor_command_selection
  798.   def start_actor_command_selection
  799.     @confirm_command_window.hide unless @confirm_command_window.nil?
  800.     start_actor_command_selection_bcl
  801.     @actor_command_window.show
  802.   end
  803.  
  804.   #--------------------------------------------------------------------------
  805.   # new method: command_use_skill
  806.   #--------------------------------------------------------------------------
  807.   def command_use_skill
  808.     @skill = $data_skills[@actor_command_window.current_ext]
  809.     BattleManager.actor.input.set_skill(@skill.id)
  810.     BattleManager.actor.last_skill.object = @skill
  811.     status_redraw_target(BattleManager.actor)
  812.     if $imported["YEA-BattleEngine"]
  813.       $game_temp.battle_aid = @skill
  814.       if @skill.for_opponent?
  815.         select_enemy_selection
  816.       elsif @skill.for_friend?
  817.         select_actor_selection
  818.       else
  819.         next_command
  820.         $game_temp.battle_aid = nil
  821.       end
  822.     else
  823.       if !@skill.need_selection?
  824.         next_command
  825.       elsif @skill.for_opponent?
  826.         select_enemy_selection
  827.       else
  828.         select_actor_selection
  829.       end
  830.     end
  831.   end
  832.  
  833.   #--------------------------------------------------------------------------
  834.   # new method: command_use_item
  835.   #--------------------------------------------------------------------------
  836.   def command_use_item
  837.     @item = $data_items[@actor_command_window.current_ext]
  838.     BattleManager.actor.input.set_item(@item.id)
  839.     status_redraw_target(BattleManager.actor)
  840.     if $imported["YEA-BattleEngine"]
  841.       $game_temp.battle_aid = @item
  842.       if @item.for_opponent?
  843.         select_enemy_selection
  844.       elsif @item.for_friend?
  845.         select_actor_selection
  846.       else
  847.         next_command
  848.         $game_temp.battle_aid = nil
  849.       end
  850.     else
  851.       if !@item.need_selection?
  852.         next_command
  853.       elsif @item.for_opponent?
  854.         select_enemy_selection
  855.       else
  856.         select_actor_selection
  857.       end
  858.     end
  859.   end
  860.  
  861.   #--------------------------------------------------------------------------
  862.   # alias method: on_actor_ok
  863.   #--------------------------------------------------------------------------
  864.   alias scene_battle_on_actor_ok_bcl on_actor_ok
  865.   def on_actor_ok
  866.     scene_battle_on_actor_ok_bcl
  867.     return if !@confirm_command_window.nil? && @confirm_command_window.visible
  868.     @actor_command_window.show
  869.   end
  870.  
  871.   #--------------------------------------------------------------------------
  872.   # alias method: on_actor_cancel
  873.   #--------------------------------------------------------------------------
  874.   alias scene_battle_on_actor_cancel_bcl on_actor_cancel
  875.   def on_actor_cancel
  876.     scene_battle_on_actor_cancel_bcl
  877.     case @actor_command_window.current_symbol
  878.     when :use_skill, :use_item
  879.       @help_window.hide
  880.       @status_window.show
  881.       @actor_command_window.activate
  882.       status_redraw_target(BattleManager.actor)
  883.     end
  884.   end
  885.  
  886.   #--------------------------------------------------------------------------
  887.   # alias method: on_enemy_ok
  888.   #--------------------------------------------------------------------------
  889.   alias scene_battle_on_enemy_ok_bcl on_enemy_ok
  890.   def on_enemy_ok
  891.     scene_battle_on_enemy_ok_bcl
  892.     return if !@confirm_command_window.nil? && @confirm_command_window.visible
  893.     @actor_command_window.show
  894.   end
  895.  
  896.   #--------------------------------------------------------------------------
  897.   # alias method: on_enemy_cancel
  898.   #--------------------------------------------------------------------------
  899.   alias scene_battle_on_enemy_cancel_bcl on_enemy_cancel
  900.   def on_enemy_cancel
  901.     scene_battle_on_enemy_cancel_bcl
  902.     case @actor_command_window.current_symbol
  903.     when :use_skill, :use_item
  904.       @help_window.hide
  905.       @status_window.show
  906.       @actor_command_window.activate
  907.       status_redraw_target(BattleManager.actor)
  908.     end
  909.   end
  910.  
  911.   #--------------------------------------------------------------------------
  912.   # new method: status_redraw_target
  913.   #--------------------------------------------------------------------------
  914.   def status_redraw_target(target)
  915.     return unless target.actor?
  916.     @status_window.draw_item($game_party.battle_members.index(target))
  917.   end
  918.  
  919.   #--------------------------------------------------------------------------
  920.   # new method: create_confirm_command_window
  921.   #--------------------------------------------------------------------------
  922.   def create_confirm_command_window
  923.     return unless YEA::BATTLE_COMMANDS::USE_CONFIRM_WINDOW
  924.     @confirm_command_window = Window_ConfirmCommand.new
  925.     @confirm_command_window.viewport = @info_viewport
  926.     @confirm_command_window.set_handler(:execute, method(:command_execute))
  927.     @confirm_command_window.set_handler(:cancel, method(:on_confirm_cancel))
  928.     @confirm_command_window.set_handler(:dir4, method(:on_confirm_cancel))
  929.     @confirm_command_window.unselect
  930.     @confirm_command_window.x = Graphics.width
  931.     process_custom_confirm_commands
  932.     process_confirm_compatibility_commands
  933.   end
  934.  
  935.   #--------------------------------------------------------------------------
  936.   # new method: process_custom_confirm_commands
  937.   #--------------------------------------------------------------------------
  938.   def process_custom_confirm_commands
  939.     for command in YEA::BATTLE_COMMANDS::CONFIRM_COMMANDS
  940.       next unless YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS.include?(command)
  941.       called_method = YEA::BATTLE_COMMANDS::CUSTOM_CONFIRM_COMMANDS[command][3]
  942.       @party_command_window.set_handler(command, method(called_method))
  943.     end
  944.   end
  945.  
  946.   #--------------------------------------------------------------------------
  947.   # new method: process_confirm_compatibility_commands
  948.   #--------------------------------------------------------------------------
  949.   def process_confirm_compatibility_commands
  950.     #---
  951.     if $imported["YEA-CombatLogDisplay"]
  952.       @confirm_command_window.set_handler(:combatlog, method(:open_combatlog))
  953.     end
  954.     #---
  955.   end
  956.  
  957.   #--------------------------------------------------------------------------
  958.   # new method: start_confirm_command_selection
  959.   #--------------------------------------------------------------------------
  960.   def start_confirm_command_selection
  961.     if $imported["YEA-BattleEngine"]
  962.       @status_window.show
  963.       redraw_current_status
  964.       @status_aid_window.hide
  965.     end
  966.     @status_window.unselect
  967.     @actor_command_window.hide
  968.     @confirm_command_window.setup
  969.   end
  970.  
  971.   #--------------------------------------------------------------------------
  972.   # new method: on_confirm_cancel
  973.   #--------------------------------------------------------------------------
  974.   def on_confirm_cancel
  975.     @confirm_command_window.hide unless @confirm_command_window.nil?
  976.     @actor_command_window.show
  977.     @actor_command_window.setup(BattleManager.actor)
  978.     @status_window.select(BattleManager.actor.index)
  979.     prior_command unless BattleManager.actor.inputable?
  980.   end
  981.  
  982.   #--------------------------------------------------------------------------
  983.   # alias method: next_command
  984.   #--------------------------------------------------------------------------
  985.   alias scene_battle_next_command_bcl next_command
  986.   def next_command
  987.     if prompt_next_actor?
  988.       scene_battle_next_command_bcl
  989.     elsif YEA::BATTLE_COMMANDS::USE_CONFIRM_WINDOW
  990.       start_confirm_command_selection
  991.     else
  992.       turn_start
  993.     end
  994.   end
  995.  
  996.   #--------------------------------------------------------------------------
  997.   # new method: prompt_next_actor?
  998.   #--------------------------------------------------------------------------
  999.   def prompt_next_actor?
  1000.     index = @status_window.index
  1001.     last_index = $game_party.battle_members.size - 1
  1002.     for member in $game_party.battle_members.reverse
  1003.       break if member.inputable?
  1004.       last_index -= 1
  1005.     end
  1006.     if index >= last_index
  1007.       actor = $game_party.battle_members[index]
  1008.       return true if prompt_ftb_action?(actor)
  1009.       return true if actor.next_command_valid?
  1010.       return false if YEA::BATTLE_COMMANDS::USE_CONFIRM_WINDOW
  1011.     end
  1012.     return true
  1013.   end
  1014.  
  1015.   #--------------------------------------------------------------------------
  1016.   # new method: prompt_ftb_action?
  1017.   #--------------------------------------------------------------------------
  1018.   def prompt_ftb_action?(actor)
  1019.     return false unless $imported["YEA-BattleEngine"]
  1020.     return false unless $imported["YEA-BattleSystem-FTB"]
  1021.     return false unless BattleManager.btype?(:ftb)
  1022.     return actor.current_action.valid?
  1023.   end
  1024.  
  1025.   #--------------------------------------------------------------------------
  1026.   # new method: command_execute
  1027.   #--------------------------------------------------------------------------
  1028.   def command_execute
  1029.     @confirm_command_window.close
  1030.     turn_start
  1031.   end
  1032.  
  1033.   #--------------------------------------------------------------------------
  1034.   # new method: command_name1
  1035.   #--------------------------------------------------------------------------
  1036.   def command_name1
  1037.     # Do nothing.
  1038.   end
  1039.  
  1040.   #--------------------------------------------------------------------------
  1041.   # new method: command_name2
  1042.   #--------------------------------------------------------------------------
  1043.   def command_name2
  1044.     # Do nothing.
  1045.   end
  1046.  
  1047. end # Scene_Battle
  1048.  
  1049. #==============================================================================
  1050. #
  1051. # ¥ End of File
  1052. #
  1053. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement