Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 32.97 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Battle System Add-On: Free Turn Battle v1.02
  4. # -- Last Updated: 2012.01.15
  5. # -- Level: Normal, Hard
  6. # -- Requires: Yanfly Engine Ace - Ace Battle Engine v1.15+
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-BattleSystem-FTB"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.15 - Bug fixed: Battle victory log doesn't play twice.
  17. # 2012.01.11 - Bug fixed: Dead actors are no longer inputable.
  18. # 2012.01.10 - Finished Script.
  19. # 2012.01.09 - Started Script.
  20. #
  21. #==============================================================================
  22. # ▼ Introduction
  23. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24. # Free Turn Battle is a type of battle system made for Ace Battle Engine, where
  25. # actors perform their actions immediately (unless under the effects of berserk
  26. # or any other form of autobattle) as they're selected. After all of their
  27. # actions have been performed, the enemies will take their turn in battling the
  28. # actors. This becomes a system where actors and enemies will take turns
  29. # attacking one another as a whole.
  30. #
  31. #==============================================================================
  32. # ▼ Instructions
  33. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  34. # To install this script, open up your script editor and copy/paste this script
  35. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  36. #
  37. # First, set the default battle system for your game to be :ftb by either going
  38. # to the Ace Battle Engine script and setting DEFAULT_BATTLE_SYSTEM as :ftb or
  39. # by using the following script call:
  40. #
  41. # $game_system:set_battle_system(:ftb)
  42. #
  43. # -----------------------------------------------------------------------------
  44. # Actor Notetags - These notetags go in the actors notebox in the database.
  45. # -----------------------------------------------------------------------------
  46. # <ftb actions: +x>
  47. # <ftb actions: -x>
  48. # This increases or decreases the maximum number of actions available to an
  49. # actor by x. While an actor's individual maximum can be any value, it does not
  50. # provide more than the party maximum applied in the module. An actor's total
  51. # maximum cannot go below 1.
  52. #
  53. # -----------------------------------------------------------------------------
  54. # Class Notetags - These notetags go in the classes notebox in the database.
  55. # -----------------------------------------------------------------------------
  56. # <ftb actions: +x>
  57. # <ftb actions: -x>
  58. # This increases or decreases the maximum number of actions available to an
  59. # actor by x. While an actor's individual maximum can be any value, it does not
  60. # provide more than the party maximum applied in the module. An actor's total
  61. # maximum cannot go below 1.
  62. #
  63. # -----------------------------------------------------------------------------
  64. # Skill Notetags - These notetags go in the skills notebox in the database.
  65. # -----------------------------------------------------------------------------
  66. # <ftb cost: x>
  67. # This causes the skill to have an FTB cost of x. The FTB Cost does not occur
  68. # for individual chain skills, individual input skills, specialized input
  69. # skills, or instant skills. However, an FTB Cost can be used to put a specific
  70. # requirement on those listed types of skills.
  71. #
  72. # -----------------------------------------------------------------------------
  73. # Item Notetags - These notetags go in the items notebox in the database.
  74. # -----------------------------------------------------------------------------
  75. # <ftb cost: x>
  76. # This causes the item to have an FTB cost of x. The FTB Cost does not occur
  77. # for instant items. If items cost more actions than the party has available,
  78. # then the items will not appear in the usable item list during battle.
  79. #
  80. # -----------------------------------------------------------------------------
  81. # Weapon Notetags - These notetags go in the weapons notebox in the database.
  82. # -----------------------------------------------------------------------------
  83. # <ftb actions: +x>
  84. # <ftb actions: -x>
  85. # This increases or decreases the maximum number of actions available to an
  86. # actor by x. While an actor's individual maximum can be any value, it does not
  87. # provide more than the party maximum applied in the module. An actor's total
  88. # maximum cannot go below 1.
  89. #
  90. # -----------------------------------------------------------------------------
  91. # Armour Notetags - These notetags go in the armour notebox in the database.
  92. # -----------------------------------------------------------------------------
  93. # <ftb actions: +x>
  94. # <ftb actions: -x>
  95. # This increases or decreases the maximum number of actions available to an
  96. # actor by x. While an actor's individual maximum can be any value, it does not
  97. # provide more than the party maximum applied in the module. An actor's total
  98. # maximum cannot go below 1.
  99. #
  100. # -----------------------------------------------------------------------------
  101. # State Notetags - These notetags go in the state notebox in the database.
  102. # -----------------------------------------------------------------------------
  103. # <ftb actions: +x>
  104. # <ftb actions: -x>
  105. # This increases or decreases the maximum number of actions available to an
  106. # actor by x. While an actor's individual maximum can be any value, it does not
  107. # provide more than the party maximum applied in the module. An actor's total
  108. # maximum cannot go below 1.
  109. #
  110. #==============================================================================
  111. # ▼ Compatibility
  112. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  113. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  114. # it will run with RPG Maker VX without adjusting.
  115. #
  116. # This script requires Yanfly Engine Ace - Ace Battle Engine v1.15+ and the
  117. # script must be placed under Ace Battle Engine in the script listing.
  118. #
  119. #==============================================================================
  120.  
  121. module YEA
  122.   module FTB
  123.    
  124.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  125.     # - General FTB Settings -
  126.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  127.     # These settings adjust various general Free Turn Battle constants such as
  128.     # the icons used for actions and no actions, whether or not party members
  129.     # will have limited actions (or unlimited).
  130.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  131.     ICON_ACTION = 188      # Icon displayed when there are actions left.
  132.     ICON_EMPTY  = 185      # Icon displayed to indicate a used action.
  133.    
  134.     # For every x% above the base AGI, actors will gain an extra action. Change
  135.     # the value below to adjust the percentage needed.
  136.     EXTRA_FTB_ACTION_BONUS = 0.20
  137.    
  138.     # This is the maximum number of actions that the party can have despite the
  139.     # maximum number of individual actor actions totalling to more than this.
  140.     MAXIMUM_FTB_ACTIONS = 10
  141.    
  142.     # If this setting is on, then each member can only perform a limited amount
  143.     # of actions per turn as opposed to freely performing actions until the
  144.     # party's action usage is depleted.
  145.     LIMITED_ACTIONS_PER_MEMBER = true
  146.    
  147.   end # FTB
  148. end # YEA
  149.  
  150. #==============================================================================
  151. # ▼ Editting anything past this point may potentially result in causing
  152. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  153. # halitosis so edit at your own risk.
  154. #==============================================================================
  155.  
  156. module YEA
  157.   module REGEXP
  158.   module BASEITEM
  159.    
  160.     FTB_ACTIONS = /<(?:FTB_ACTIONS|ftb actions):[ ]([\+\-]\d+)>/i
  161.    
  162.   end # BASEITEM
  163.   module USABLEITEM
  164.    
  165.     FTB_COST = /<(?:FTB_COST|ftb cost):[ ](\d+)>/i
  166.    
  167.   end # USABLEITEM
  168.   end # REGEXP
  169. end # YEA
  170.  
  171. #==============================================================================
  172. # ■ Icon
  173. #==============================================================================
  174.  
  175. module Icon
  176.  
  177.   #--------------------------------------------------------------------------
  178.   # self.ftb_action
  179.   #--------------------------------------------------------------------------
  180.   def self.ftb_action
  181.     return YEA::FTB::ICON_ACTION
  182.   end
  183.  
  184.   #--------------------------------------------------------------------------
  185.   # self.ftb_empty
  186.   #--------------------------------------------------------------------------
  187.   def self.ftb_empty
  188.     return YEA::FTB::ICON_EMPTY
  189.   end
  190.  
  191. end # Icon
  192.  
  193. #==============================================================================
  194. # ■ DataManager
  195. #==============================================================================
  196.  
  197. module DataManager
  198.  
  199.   #--------------------------------------------------------------------------
  200.   # alias method: load_database
  201.   #--------------------------------------------------------------------------
  202.   class <<self; alias load_database_ftb load_database; end
  203.   def self.load_database
  204.     load_database_ftb
  205.     load_notetags_ftb
  206.   end
  207.  
  208.   #--------------------------------------------------------------------------
  209.   # new method: load_notetags_ftb
  210.   #--------------------------------------------------------------------------
  211.   def self.load_notetags_ftb
  212.     groups = [$data_skills, $data_items, $data_actors, $data_classes,
  213.       $data_weapons, $data_armors, $data_states]
  214.     for group in groups
  215.       for obj in group
  216.         next if obj.nil?
  217.         obj.load_notetags_ftb
  218.       end
  219.     end
  220.   end
  221.  
  222. end # DataManager
  223.  
  224. #==============================================================================
  225. # ■ RPG::BaseItem
  226. #==============================================================================
  227.  
  228. class RPG::BaseItem
  229.  
  230.   #--------------------------------------------------------------------------
  231.   # public instance variables
  232.   #--------------------------------------------------------------------------
  233.   attr_accessor :ftb_actions
  234.  
  235.   #--------------------------------------------------------------------------
  236.   # common cache: load_notetags_ftb
  237.   #--------------------------------------------------------------------------
  238.   def load_notetags_ftb
  239.     @ftb_actions = 0
  240.     #---
  241.     self.note.split(/[\r\n]+/).each { |line|
  242.       case line
  243.       #---
  244.       when YEA::REGEXP::BASEITEM::FTB_ACTIONS
  245.         @ftb_actions = $1.to_i
  246.       end
  247.     } # self.note.split
  248.     #---
  249.   end
  250.  
  251. end # RPG::BaseItem
  252.  
  253. #==============================================================================
  254. # ■ RPG::UsableItem
  255. #==============================================================================
  256.  
  257. class RPG::UsableItem < RPG::BaseItem
  258.  
  259.   #--------------------------------------------------------------------------
  260.   # public instance variables
  261.   #--------------------------------------------------------------------------
  262.   attr_accessor :ftb_cost
  263.  
  264.   #--------------------------------------------------------------------------
  265.   # common cache: load_notetags_ftb
  266.   #--------------------------------------------------------------------------
  267.   def load_notetags_ftb
  268.     @ftb_cost = 1
  269.     #---
  270.     self.note.split(/[\r\n]+/).each { |line|
  271.       case line
  272.       #---
  273.       when YEA::REGEXP::USABLEITEM::FTB_COST
  274.         @ftb_cost = $1.to_i
  275.       end
  276.     } # self.note.split
  277.     #---
  278.   end
  279.  
  280. end # RPG::UsableItem
  281.  
  282. #==============================================================================
  283. # ■ BattleManager
  284. #==============================================================================
  285.  
  286. module BattleManager
  287.  
  288.   #--------------------------------------------------------------------------
  289.   # alias method: make_action_orders
  290.   #--------------------------------------------------------------------------
  291.   class <<self; alias make_action_orders_ftb make_action_orders; end
  292.   def self.make_action_orders
  293.     make_action_orders_ftb
  294.     make_ftb_action_orders if btype?(:ftb)
  295.   end
  296.  
  297.   #--------------------------------------------------------------------------
  298.   # new method: make_ftb_action_orders
  299.   #--------------------------------------------------------------------------
  300.   def self.make_ftb_action_orders
  301.     @action_battlers = []
  302.     @action_battlers += $game_party.members unless @surprise
  303.     @action_battlers += $game_troop.members unless @preemptive
  304.     @action_battlers.each { |battler| battler.make_speed }
  305.     @action_battlers.sort! {|a,b| a.screen_x <=> b.screen_x }
  306.   end
  307.  
  308.   #--------------------------------------------------------------------------
  309.   # alias method: judge_win_loss
  310.   #--------------------------------------------------------------------------
  311.   class <<self; alias judge_win_loss_ftb judge_win_loss; end
  312.   def self.judge_win_loss
  313.     if @phase && $game_troop.all_dead? && SceneManager.scene_is?(Scene_Battle)
  314.       SceneManager.scene.hide_ftb_gauge
  315.     end
  316.     judge_win_loss_ftb
  317.   end
  318.  
  319. end # BattleManager
  320.  
  321. #==============================================================================
  322. # ■ Game_BattlerBase
  323. #==============================================================================
  324.  
  325. class Game_BattlerBase
  326.  
  327.   #--------------------------------------------------------------------------
  328.   # new method: init_ftb_actions
  329.   #--------------------------------------------------------------------------
  330.   def init_ftb_actions
  331.     @used_ftb_actions = 0
  332.   end
  333.  
  334.   #--------------------------------------------------------------------------
  335.   # new method: ftb_actions
  336.   #--------------------------------------------------------------------------
  337.   def ftb_actions
  338.     init_ftb_actions if @used_ftb_actions.nil?
  339.     return @used_ftb_actions
  340.   end
  341.  
  342.   #--------------------------------------------------------------------------
  343.   # new method: max_ftb_actions
  344.   #--------------------------------------------------------------------------
  345.   def max_ftb_actions
  346.     n = make_action_times
  347.     n += agi_bonus_max_ftb_actions
  348.     n += trait_bonus_max_ftb_actions
  349.     return [n, 1].max
  350.   end
  351.  
  352.   #--------------------------------------------------------------------------
  353.   # new method: agi_bonus_max_ftb_actions
  354.   #--------------------------------------------------------------------------
  355.   def agi_bonus_max_ftb_actions
  356.     bonus_agi = agi - param_base(6)
  357.     value_agi = param_base(6) * YEA::FTB::EXTRA_FTB_ACTION_BONUS
  358.     return (bonus_agi / value_agi).to_i
  359.   end
  360.  
  361.   #--------------------------------------------------------------------------
  362.   # new method: trait_bonus_max_ftb_actions
  363.   #--------------------------------------------------------------------------
  364.   def trait_bonus_max_ftb_actions
  365.     n = 0
  366.     if actor?
  367.       n += self.actor.ftb_actions
  368.       n += self.class.ftb_actions
  369.       for equip in equips
  370.         next if equip.nil?
  371.         n += equip.ftb_actions
  372.       end
  373.     end
  374.     for state in states
  375.       next if state.nil?
  376.       n += state.ftb_actions
  377.     end
  378.     return n
  379.   end
  380.  
  381.   #--------------------------------------------------------------------------
  382.   # new method: use_ftb_action
  383.   #--------------------------------------------------------------------------
  384.   def use_ftb_action(value = 1)
  385.     init_ftb_actions if @used_ftb_actions.nil?
  386.     @used_ftb_actions += value
  387.   end
  388.  
  389.   #--------------------------------------------------------------------------
  390.   # alias method: inputable?
  391.   #--------------------------------------------------------------------------
  392.   alias game_battlerbase_inputable_ftb inputable?
  393.   def inputable?
  394.     result = game_battlerbase_inputable_ftb
  395.     return false unless result
  396.     return result unless SceneManager.scene_is?(Scene_Battle)
  397.     return result unless BattleManager.btype?(:ftb)
  398.     return result unless YEA::FTB::LIMITED_ACTIONS_PER_MEMBER
  399.     return max_ftb_actions > ftb_actions
  400.   end
  401.  
  402.   #--------------------------------------------------------------------------
  403.   # alias method: skill_conditions_met?
  404.   #--------------------------------------------------------------------------
  405.   alias game_battlerbase_skill_conditions_met_ftb skill_conditions_met?
  406.   def skill_conditions_met?(skill)
  407.     return false unless ftb_item_conditions_met?(skill)
  408.     return game_battlerbase_skill_conditions_met_ftb(skill)
  409.   end
  410.  
  411.   #--------------------------------------------------------------------------
  412.   # alias method: item_conditions_met?
  413.   #--------------------------------------------------------------------------
  414.   alias game_battlerbase_item_conditions_met_ftb item_conditions_met?
  415.   def item_conditions_met?(item)
  416.     return false unless ftb_item_conditions_met?(item)
  417.     return game_battlerbase_item_conditions_met_ftb(item)
  418.   end
  419.  
  420.   #--------------------------------------------------------------------------
  421.   # new method: ftb_item_conditions_met?
  422.   #--------------------------------------------------------------------------
  423.   def ftb_item_conditions_met?(item)
  424.     return true unless actor?
  425.     return true unless SceneManager.scene_is?(Scene_Battle)
  426.     return true unless BattleManager.btype?(:ftb)
  427.     return true if BattleManager.in_turn?
  428.     return $game_party.ftb_actions_remaining >= item.ftb_cost
  429.   end
  430.  
  431. end # Game_BattlerBase
  432.  
  433. #==============================================================================
  434. # ■ Game_Battler
  435. #==============================================================================
  436.  
  437. class Game_Battler < Game_BattlerBase
  438.  
  439.   #--------------------------------------------------------------------------
  440.   # alias method: on_battle_start
  441.   #--------------------------------------------------------------------------
  442.   alias game_battler_on_battle_start_ftb on_battle_start
  443.   def on_battle_start
  444.     game_battler_on_battle_start_ftb
  445.     init_ftb_actions
  446.   end
  447.  
  448.   #--------------------------------------------------------------------------
  449.   # alias method: on_turn_end
  450.   #--------------------------------------------------------------------------
  451.   alias game_battler_on_turn_end_ftb on_turn_end
  452.   def on_turn_end
  453.     game_battler_on_turn_end_ftb
  454.     init_ftb_actions
  455.   end
  456.  
  457.   #--------------------------------------------------------------------------
  458.   # alias method: make_action_times
  459.   #--------------------------------------------------------------------------
  460.   alias game_battler_make_action_times_ftb make_action_times
  461.   def make_action_times
  462.     if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?(:ftb)
  463.       return make_ftb_action_times
  464.     else
  465.       return game_battler_make_action_times_ftb
  466.     end
  467.   end
  468.  
  469.   #--------------------------------------------------------------------------
  470.   # new method: make_ftb_action_times
  471.   #--------------------------------------------------------------------------
  472.   def make_ftb_action_times
  473.     return action_plus_set.inject(1) {|r, p| p > 0.01 ? r + 1 : r }
  474.   end
  475.  
  476. end # Game_Battler
  477.  
  478. #==============================================================================
  479. # ■ Game_Actor
  480. #==============================================================================
  481.  
  482. class Game_Actor < Game_Battler
  483.  
  484.   #--------------------------------------------------------------------------
  485.   # alias method: next_command
  486.   #--------------------------------------------------------------------------
  487.   alias game_actor_next_command_ftb next_command
  488.   def next_command
  489.     if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?(:ftb)
  490.       return false
  491.     end
  492.     return game_actor_next_command_ftb
  493.   end
  494.  
  495.   #--------------------------------------------------------------------------
  496.   # alias method: prior_command
  497.   #--------------------------------------------------------------------------
  498.   alias game_actor_prior_command_ftb prior_command
  499.   def prior_command
  500.     if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?(:ftb)
  501.       return false
  502.     end
  503.     return game_actor_prior_command_ftb
  504.   end
  505.  
  506. end # Game_Actor
  507.  
  508. #==============================================================================
  509. # ■ Game_Party
  510. #==============================================================================
  511.  
  512. class Game_Party < Game_Unit
  513.  
  514.   #--------------------------------------------------------------------------
  515.   # alias method: inputable?
  516.   #--------------------------------------------------------------------------
  517.   alias game_party_inputable_ftb inputable?
  518.   def inputable?
  519.     return false unless meet_ftb_requirements?
  520.     return game_party_inputable_ftb
  521.   end
  522.  
  523.   #--------------------------------------------------------------------------
  524.   # new method: meet_ftb_requirements?
  525.   #--------------------------------------------------------------------------
  526.   def meet_ftb_requirements?
  527.     return true unless BattleManager.btype?(:ftb)
  528.     return ftb_actions_remaining > 0
  529.   end
  530.  
  531.   #--------------------------------------------------------------------------
  532.   # new method: ftb_actions_remaining
  533.   #--------------------------------------------------------------------------
  534.   def ftb_actions_remaining
  535.     return ftb_actions_maximum - ftb_actions_used
  536.   end
  537.  
  538.   #--------------------------------------------------------------------------
  539.   # new method: ftb_actions_maximum
  540.   #--------------------------------------------------------------------------
  541.   def ftb_actions_maximum
  542.     n = 0
  543.     for member in $game_party.members
  544.       next unless member.game_battlerbase_inputable_ftb
  545.       n += member.max_ftb_actions
  546.     end
  547.     return [n, YEA::FTB::MAXIMUM_FTB_ACTIONS].min
  548.   end
  549.  
  550.   #--------------------------------------------------------------------------
  551.   # new method: ftb_actions_used
  552.   #--------------------------------------------------------------------------
  553.   def ftb_actions_used
  554.     n = 0
  555.     for member in $game_party.members
  556.       next unless member.game_battlerbase_inputable_ftb
  557.       n += member.ftb_actions
  558.     end
  559.     return n
  560.   end
  561.  
  562. end # Game_Party
  563.  
  564. #==============================================================================
  565. # ■ Window_BattleStatus
  566. #==============================================================================
  567.  
  568. class Window_BattleStatus < Window_Selectable
  569.  
  570.   #--------------------------------------------------------------------------
  571.   # alias method: action_icon
  572.   #--------------------------------------------------------------------------
  573.   alias window_battlestatus_action_icon_ftb action_icon
  574.   def action_icon(actor)
  575.     if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?(:ftb)
  576.       return Icon.ftb_action if act_ftb_valid?(actor)
  577.     end
  578.     return window_battlestatus_action_icon_ftb(actor)
  579.   end
  580.  
  581.   #--------------------------------------------------------------------------
  582.   # new method: act_ftb_valid?
  583.   #--------------------------------------------------------------------------
  584.   def act_ftb_valid?(actor)
  585.     return false unless actor.current_action.nil? ||
  586.       actor.current_action.item.nil?
  587.     return true unless YEA::FTB::LIMITED_ACTIONS_PER_MEMBER
  588.     return actor.max_ftb_actions > actor.ftb_actions
  589.   end
  590.  
  591. end # Window_BattleStatus
  592.  
  593. #==============================================================================
  594. # ■ Window_FTB_Gauge
  595. #==============================================================================
  596.  
  597. class Window_FTB_Gauge < Window_Base
  598.  
  599.   #--------------------------------------------------------------------------
  600.   # initialize
  601.   #--------------------------------------------------------------------------
  602.   def initialize(help_window)
  603.     @help_window = help_window
  604.     super(0, 0, Graphics.width, fitting_height(1))
  605.     self.opacity = 0
  606.     self.contents_opacity = 0
  607.     self.z = 200
  608.   end
  609.  
  610.   #--------------------------------------------------------------------------
  611.   # refresh
  612.   #--------------------------------------------------------------------------
  613.   def refresh
  614.     contents.clear
  615.     draw_empty_icons
  616.     draw_filled_icons
  617.   end
  618.  
  619.   #--------------------------------------------------------------------------
  620.   # draw_empty_icons
  621.   #--------------------------------------------------------------------------
  622.   def draw_empty_icons
  623.     n = $game_party.ftb_actions_maximum
  624.     dx = contents.width
  625.     n.times do
  626.       dx -= 24
  627.       draw_icon(Icon.ftb_empty, dx, 0)
  628.     end
  629.   end
  630.  
  631.   #--------------------------------------------------------------------------
  632.   # draw_filled_icons
  633.   #--------------------------------------------------------------------------
  634.   def draw_filled_icons
  635.     n = $game_party.ftb_actions_maximum - $game_party.ftb_actions_used
  636.     dx = contents.width
  637.     n.times do
  638.       dx -= 24
  639.       draw_icon(Icon.ftb_action, dx, 0)
  640.     end
  641.   end
  642.  
  643.   #--------------------------------------------------------------------------
  644.   # update
  645.   #--------------------------------------------------------------------------
  646.   def update
  647.     super
  648.     self.contents_opacity = 0 unless SceneManager.scene_is?(Scene_Battle)
  649.     return unless SceneManager.scene_is?(Scene_Battle)
  650.     return unless BattleManager.btype?(:ftb)
  651.     change_contents_opacity
  652.     change_y_position
  653.   end
  654.  
  655.   #--------------------------------------------------------------------------
  656.   # change_contents_opacity
  657.   #--------------------------------------------------------------------------
  658.   def change_contents_opacity
  659.     rate = BattleManager.in_turn? ? -8 : 8
  660.     self.contents_opacity += rate
  661.   end
  662.  
  663.   #--------------------------------------------------------------------------
  664.   # change_y_position
  665.   #--------------------------------------------------------------------------
  666.   def change_y_position
  667.     self.y = @help_window.visible ? @help_window.height : 0
  668.   end
  669.  
  670. end # Window_FTB_Gauge
  671.  
  672. #==============================================================================
  673. # ■ Scene_Battle
  674. #==============================================================================
  675.  
  676. class Scene_Battle < Scene_Base
  677.  
  678.   #--------------------------------------------------------------------------
  679.   # alias method: create_all_windows
  680.   #--------------------------------------------------------------------------
  681.   alias scene_battle_create_all_windows_ftb create_all_windows
  682.   def create_all_windows
  683.     scene_battle_create_all_windows_ftb
  684.     create_ftb_gauge
  685.   end
  686.  
  687.   #--------------------------------------------------------------------------
  688.   # new method: create_ftb_gauge
  689.   #--------------------------------------------------------------------------
  690.   def create_ftb_gauge
  691.     @ftb_gauge = Window_FTB_Gauge.new(@help_window)
  692.   end
  693.  
  694.   #--------------------------------------------------------------------------
  695.   # alias method: start_party_command_selection
  696.   #--------------------------------------------------------------------------
  697.   alias start_party_command_selection_ftb start_party_command_selection
  698.   def start_party_command_selection
  699.     start_party_command_selection_ftb
  700.     refresh_ftb_gauge
  701.   end
  702.  
  703.   #--------------------------------------------------------------------------
  704.   # alias method: start_actor_command_selection
  705.   #--------------------------------------------------------------------------
  706.   alias start_actor_command_selection_ftb start_actor_command_selection
  707.   def start_actor_command_selection
  708.     start_actor_command_selection_ftb
  709.     refresh_ftb_gauge
  710.   end
  711.  
  712.   #--------------------------------------------------------------------------
  713.   # new method: refresh_ftb_gauge
  714.   #--------------------------------------------------------------------------
  715.   def refresh_ftb_gauge
  716.     @ftb_gauge.refresh
  717.   end
  718.  
  719.   #--------------------------------------------------------------------------
  720.   # new method: hide_ftb_gauge
  721.   #--------------------------------------------------------------------------
  722.   def hide_ftb_gauge
  723.     @ftb_gauge.hide
  724.   end
  725.  
  726.   #--------------------------------------------------------------------------
  727.   # alias method: next_command
  728.   #--------------------------------------------------------------------------
  729.   alias scene_battle_next_command_ftb next_command
  730.   def next_command
  731.     if ftb_action?
  732.       perform_ftb_action
  733.     else
  734.       scene_battle_next_command_ftb
  735.     end
  736.   end
  737.  
  738.   #--------------------------------------------------------------------------
  739.   # new method: ftb_action?
  740.   #--------------------------------------------------------------------------
  741.   def ftb_action?
  742.     return false unless BattleManager.btype?(:ftb)
  743.     return false if BattleManager.actor.nil?
  744.     return false if BattleManager.actor.current_action.nil?
  745.     action = BattleManager.actor.current_action.item
  746.     return !action.nil?
  747.   end
  748.  
  749.   #--------------------------------------------------------------------------
  750.   # new method: perform_ftb_action
  751.   #--------------------------------------------------------------------------
  752.   def perform_ftb_action
  753.     hide_ftb_action_windows
  754.     @subject = BattleManager.actor
  755.     item = @subject.current_action.item
  756.     execute_action
  757.     process_event
  758.     loop do
  759.       @subject.remove_current_action
  760.       break if $game_troop.all_dead?
  761.       break unless @subject.current_action
  762.       @subject.current_action.prepare
  763.       execute_action if @subject.current_action.valid?
  764.     end
  765.     return if $game_troop.alive_members.size <= 0
  766.     process_action_end
  767.     consume_ftb_action(item)
  768.     @subject.make_actions
  769.     @subject = nil
  770.     show_ftb_action_windows
  771.   end
  772.  
  773.   #--------------------------------------------------------------------------
  774.   # new method: consume_ftb_action
  775.   #--------------------------------------------------------------------------
  776.   def consume_ftb_action(item)
  777.     @subject.use_ftb_action(item.ftb_cost) unless item.nil?
  778.     refresh_ftb_gauge
  779.   end
  780.  
  781.   #--------------------------------------------------------------------------
  782.   # new method: hide_ftb_action_windows
  783.   #--------------------------------------------------------------------------
  784.   def hide_ftb_action_windows
  785.     @info_viewport.visible = true
  786.     @status_aid_window.hide
  787.     @status_window.show
  788.     @actor_command_window.show
  789.   end
  790.  
  791.   #--------------------------------------------------------------------------
  792.   # new method: show_ftb_action_windows
  793.   #--------------------------------------------------------------------------
  794.   def show_ftb_action_windows
  795.     @info_viewport.visible = true
  796.     end_ftb_action
  797.   end
  798.  
  799.   #--------------------------------------------------------------------------
  800.   # new method: end_ftb_action
  801.   #--------------------------------------------------------------------------
  802.   def end_ftb_action
  803.     if $game_party.inputable?
  804.       select_next_member
  805.     else
  806.       status_redraw_target(BattleManager.actor)
  807.       BattleManager.next_command
  808.       turn_start
  809.     end
  810.   end
  811.  
  812.   #--------------------------------------------------------------------------
  813.   # new method: select_next_member
  814.   #--------------------------------------------------------------------------
  815.   def select_next_member
  816.     status_redraw_target(BattleManager.actor)
  817.     last_index = $game_party.battle_members.size - 1
  818.     for member in $game_party.battle_members.reverse
  819.       break if member.inputable?
  820.       last_index -= 1
  821.     end
  822.     next_command if next_ftb_member?(last_index)
  823.     return if BattleManager.actor.nil?
  824.     if BattleManager.actor.index >= last_index && !BattleManager.actor.inputable?
  825.       prior_command
  826.     else
  827.       start_actor_command_selection
  828.       status_redraw_target(BattleManager.actor)
  829.     end
  830.   end
  831.  
  832.   #--------------------------------------------------------------------------
  833.   # new method: next_ftb_member?
  834.   #--------------------------------------------------------------------------
  835.   def next_ftb_member?(last_index)
  836.     actor = BattleManager.actor
  837.     return true if actor.nil?
  838.     return false if actor.max_ftb_actions > actor.ftb_actions
  839.     return false if BattleManager.actor.index >= last_index
  840.     return BattleManager.actor.index != last_index
  841.   end
  842.  
  843.   #--------------------------------------------------------------------------
  844.   # alias method: hide_extra_gauges
  845.   #--------------------------------------------------------------------------
  846.   alias scene_battle_hide_extra_gauges_ftb hide_extra_gauges
  847.   def hide_extra_gauges
  848.     scene_battle_hide_extra_gauges_ftb
  849.     @ftb_gauge.hide
  850.   end
  851.  
  852.   #--------------------------------------------------------------------------
  853.   # alias method: show_extra_gauges
  854.   #--------------------------------------------------------------------------
  855.   alias scene_battle_show_extra_gauges_ftb show_extra_gauges
  856.   def show_extra_gauges
  857.     scene_battle_show_extra_gauges_ftb
  858.     @ftb_gauge.show
  859.   end
  860.  
  861. end # Scene_Battle
  862.  
  863. #==============================================================================
  864. #
  865. # ▼ End of File
  866. #
  867. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement