Guest User

Untitled

a guest
Aug 22nd, 2014
228
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 = 142 # Icon displayed when there are actions left.
  132. ICON_EMPTY = 141 # 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 = 6
  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 = false
  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 false if @has_defended #grs
  399. return result unless YEA::FTB::LIMITED_ACTIONS_PER_MEMBER
  400. return max_ftb_actions > ftb_actions
  401. end
  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. #print "Check: #{@has_defended}\n"
  429. #return false if @has_defended == true #grs
  430. return $game_party.ftb_actions_remaining >= item.ftb_cost
  431. end
  432.  
  433. attr_accessor :has_defended #grs
  434.  
  435. end # Game_BattlerBase
  436.  
  437. #==============================================================================
  438. # ¦ Game_Battler
  439. #==============================================================================
  440.  
  441. class Game_Battler < Game_BattlerBase
  442.  
  443. #--------------------------------------------------------------------------
  444. # alias method: on_battle_start
  445. #--------------------------------------------------------------------------
  446. alias game_battler_on_battle_start_ftb on_battle_start
  447. def on_battle_start
  448. game_battler_on_battle_start_ftb
  449. init_ftb_actions
  450. @has_defended = false #grs
  451. end
  452.  
  453. #--------------------------------------------------------------------------
  454. # alias method: on_turn_end
  455. #--------------------------------------------------------------------------
  456. alias game_battler_on_turn_end_ftb on_turn_end
  457. def on_turn_end
  458. game_battler_on_turn_end_ftb
  459. init_ftb_actions
  460. @has_defended = false #grs
  461. end
  462.  
  463.  
  464. #--------------------------------------------------------------------------
  465. # alias method: make_action_times
  466. #--------------------------------------------------------------------------
  467. alias game_battler_make_action_times_ftb make_action_times
  468. def make_action_times
  469. if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?(:ftb)
  470. return make_ftb_action_times
  471. else
  472. return game_battler_make_action_times_ftb
  473. end
  474. end
  475.  
  476. #--------------------------------------------------------------------------
  477. # new method: make_ftb_action_times
  478. #--------------------------------------------------------------------------
  479. def make_ftb_action_times
  480. return action_plus_set.inject(1) {|r, p| p > 0.01 ? r + 1 : r }
  481. end
  482.  
  483. end # Game_Battler
  484.  
  485. #==============================================================================
  486. # ¦ Game_Actor
  487. #==============================================================================
  488.  
  489. class Game_Actor < Game_Battler
  490.  
  491. #--------------------------------------------------------------------------
  492. # alias method: next_command
  493. #--------------------------------------------------------------------------
  494. alias game_actor_next_command_ftb next_command
  495. def next_command
  496. if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?(:ftb)
  497. return false
  498. end
  499. return game_actor_next_command_ftb
  500. end
  501.  
  502. #--------------------------------------------------------------------------
  503. # alias method: prior_command
  504. #--------------------------------------------------------------------------
  505. alias game_actor_prior_command_ftb prior_command
  506. def prior_command
  507. if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?(:ftb)
  508. return false
  509. end
  510. return game_actor_prior_command_ftb
  511. end
  512.  
  513. end # Game_Actor
  514.  
  515. #==============================================================================
  516. # ¦ Game_Party
  517. #==============================================================================
  518.  
  519. class Game_Party < Game_Unit
  520.  
  521. #--------------------------------------------------------------------------
  522. # alias method: inputable?
  523. #--------------------------------------------------------------------------
  524. alias game_party_inputable_ftb inputable?
  525. def inputable?
  526. return false unless meet_ftb_requirements?
  527. return game_party_inputable_ftb
  528. end
  529.  
  530. #--------------------------------------------------------------------------
  531. # new method: meet_ftb_requirements?
  532. #--------------------------------------------------------------------------
  533. def meet_ftb_requirements?
  534. return true unless BattleManager.btype?(:ftb)
  535. return false if battle_members.all? { |x| x.has_defended } #grs
  536. return ftb_actions_remaining > 0
  537. end
  538.  
  539. #--------------------------------------------------------------------------
  540. # new method: ftb_actions_remaining
  541. #--------------------------------------------------------------------------
  542. def ftb_actions_remaining
  543. return ftb_actions_maximum - ftb_actions_used
  544. end
  545.  
  546. #--------------------------------------------------------------------------
  547. # new method: ftb_actions_maximum
  548. #--------------------------------------------------------------------------
  549. def ftb_actions_maximum
  550. n = 2
  551. for member in $game_party.members
  552. next unless member.game_battlerbase_inputable_ftb
  553. n += member.max_ftb_actions
  554. end
  555. return [n, YEA::FTB::MAXIMUM_FTB_ACTIONS].min
  556. end
  557.  
  558. #--------------------------------------------------------------------------
  559. # new method: ftb_actions_used
  560. #--------------------------------------------------------------------------
  561. def ftb_actions_used
  562. n = 0
  563. for member in $game_party.members
  564. next unless member.game_battlerbase_inputable_ftb
  565. n += member.ftb_actions
  566. end
  567. return n
  568. end
  569.  
  570. end # Game_Party
  571.  
  572. #==============================================================================
  573. # ¦ Window_BattleStatus
  574. #==============================================================================
  575.  
  576. class Window_BattleStatus < Window_Selectable
  577.  
  578. #--------------------------------------------------------------------------
  579. # alias method: action_icon
  580. #--------------------------------------------------------------------------
  581. alias window_battlestatus_action_icon_ftb action_icon
  582. def action_icon(actor)
  583. if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?(:ftb)
  584. return Icon.ftb_action if act_ftb_valid?(actor)
  585. end
  586. return window_battlestatus_action_icon_ftb(actor)
  587. end
  588.  
  589. #--------------------------------------------------------------------------
  590. # new method: act_ftb_valid?
  591. #--------------------------------------------------------------------------
  592. def act_ftb_valid?(actor)
  593. return false unless actor.current_action.nil? ||
  594. actor.current_action.item.nil?
  595. return false if actor.has_defended #grs
  596. return true unless YEA::FTB::LIMITED_ACTIONS_PER_MEMBER
  597. return actor.max_ftb_actions > actor.ftb_actions
  598. end
  599.  
  600.  
  601. end # Window_BattleStatus
  602.  
  603. #==============================================================================
  604. # ¦ Window_FTB_Gauge
  605. #==============================================================================
  606.  
  607. class Window_FTB_Gauge < Window_Base
  608.  
  609. #--------------------------------------------------------------------------
  610. # initialize
  611. #--------------------------------------------------------------------------
  612. def initialize(help_window)
  613. @help_window = help_window
  614. super(0, 0, Graphics.width, fitting_height(1))
  615. self.opacity = 0
  616. self.contents_opacity = 0
  617. self.z = 200
  618. end
  619.  
  620. #--------------------------------------------------------------------------
  621. # refresh
  622. #--------------------------------------------------------------------------
  623. def refresh
  624. contents.clear
  625. draw_empty_icons
  626. draw_filled_icons
  627. end
  628.  
  629. #--------------------------------------------------------------------------
  630. # draw_empty_icons
  631. #--------------------------------------------------------------------------
  632. def draw_empty_icons
  633. n = $game_party.ftb_actions_maximum
  634. dx = contents.width
  635. n.times do
  636. dx -= 24
  637. draw_icon(Icon.ftb_empty, dx, 0)
  638. end
  639. end
  640.  
  641. #--------------------------------------------------------------------------
  642. # draw_filled_icons
  643. #--------------------------------------------------------------------------
  644. def draw_filled_icons
  645. n = $game_party.ftb_actions_maximum - $game_party.ftb_actions_used
  646. dx = contents.width
  647. n.times do
  648. dx -= 24
  649. draw_icon(Icon.ftb_action, dx, 0)
  650. end
  651. end
  652.  
  653. #--------------------------------------------------------------------------
  654. # update
  655. #--------------------------------------------------------------------------
  656. def update
  657. super
  658. self.contents_opacity = 0 unless SceneManager.scene_is?(Scene_Battle)
  659. return unless SceneManager.scene_is?(Scene_Battle)
  660. return unless BattleManager.btype?(:ftb)
  661. change_contents_opacity
  662. change_y_position
  663. end
  664.  
  665. #--------------------------------------------------------------------------
  666. # change_contents_opacity
  667. #--------------------------------------------------------------------------
  668. def change_contents_opacity
  669. rate = BattleManager.in_turn? ? -8 : 8
  670. self.contents_opacity += rate
  671. end
  672.  
  673. #--------------------------------------------------------------------------
  674. # change_y_position
  675. #--------------------------------------------------------------------------
  676. def change_y_position
  677. self.y = @help_window.visible ? @help_window.height : 0
  678. end
  679.  
  680. end # Window_FTB_Gauge
  681.  
  682. #==============================================================================
  683. # ¦ Scene_Battle
  684. #==============================================================================
  685.  
  686. class Scene_Battle < Scene_Base
  687.  
  688. #--------------------------------------------------------------------------
  689. # alias method: create_all_windows
  690. #--------------------------------------------------------------------------
  691. alias scene_battle_create_all_windows_ftb create_all_windows
  692. def create_all_windows
  693. scene_battle_create_all_windows_ftb
  694. create_ftb_gauge
  695. end
  696.  
  697. #--------------------------------------------------------------------------
  698. # new method: create_ftb_gauge
  699. #--------------------------------------------------------------------------
  700. def create_ftb_gauge
  701. @ftb_gauge = Window_FTB_Gauge.new(@help_window)
  702. end
  703.  
  704. #--------------------------------------------------------------------------
  705. # alias method: start_party_command_selection
  706. #--------------------------------------------------------------------------
  707. alias start_party_command_selection_ftb start_party_command_selection
  708. def start_party_command_selection
  709. start_party_command_selection_ftb
  710. refresh_ftb_gauge
  711. end
  712.  
  713. #--------------------------------------------------------------------------
  714. # alias method: start_actor_command_selection
  715. #--------------------------------------------------------------------------
  716. alias start_actor_command_selection_ftb start_actor_command_selection
  717. def start_actor_command_selection
  718. start_actor_command_selection_ftb
  719. refresh_ftb_gauge
  720. end
  721.  
  722. #--------------------------------------------------------------------------
  723. # new method: refresh_ftb_gauge
  724. #--------------------------------------------------------------------------
  725. def refresh_ftb_gauge
  726. @ftb_gauge.refresh
  727. end
  728.  
  729. #--------------------------------------------------------------------------
  730. # new method: hide_ftb_gauge
  731. #--------------------------------------------------------------------------
  732. def hide_ftb_gauge
  733. @ftb_gauge.hide
  734. end
  735.  
  736. #--------------------------------------------------------------------------
  737. # alias method: next_command
  738. #--------------------------------------------------------------------------
  739. alias scene_battle_next_command_ftb next_command
  740. def next_command
  741. if ftb_action?
  742. perform_ftb_action
  743. else
  744. scene_battle_next_command_ftb
  745. end
  746. end
  747.  
  748. #--------------------------------------------------------------------------
  749. # new method: ftb_action?
  750. #--------------------------------------------------------------------------
  751. def ftb_action?
  752. return false unless BattleManager.btype?(:ftb)
  753. return false if BattleManager.actor.nil?
  754. return false if BattleManager.actor.current_action.nil?
  755. action = BattleManager.actor.current_action.item
  756. return !action.nil?
  757. end
  758.  
  759. #--------------------------------------------------------------------------
  760. # new method: perform_ftb_action
  761. #--------------------------------------------------------------------------
  762. def perform_ftb_action
  763. hide_ftb_action_windows
  764. @subject = BattleManager.actor
  765. item = @subject.current_action.item
  766. execute_action
  767. process_event
  768. loop do
  769. @subject.remove_current_action
  770. break if $game_troop.all_dead?
  771. break unless @subject.current_action
  772. @subject.current_action.prepare
  773. execute_action if @subject.current_action.valid?
  774. end
  775. return if $game_troop.alive_members.size <= 0
  776. process_action_end
  777. consume_ftb_action(item)
  778. @subject.make_actions
  779. @subject = nil
  780. show_ftb_action_windows
  781. end
  782.  
  783. #--------------------------------------------------------------------------
  784. # new method: consume_ftb_action
  785. #--------------------------------------------------------------------------
  786. def consume_ftb_action(item)
  787. @subject.use_ftb_action(item.ftb_cost) unless item.nil?
  788. refresh_ftb_gauge
  789. end
  790.  
  791. #--------------------------------------------------------------------------
  792. # new method: hide_ftb_action_windows
  793. #--------------------------------------------------------------------------
  794. def hide_ftb_action_windows
  795. @info_viewport.visible = true
  796. @status_aid_window.hide
  797. @status_window.show
  798. @actor_command_window.show
  799. end
  800.  
  801. #--------------------------------------------------------------------------
  802. # new method: show_ftb_action_windows
  803. #--------------------------------------------------------------------------
  804. def show_ftb_action_windows
  805. @info_viewport.visible = true
  806. end_ftb_action
  807. end
  808.  
  809. #--------------------------------------------------------------------------
  810. # new method: end_ftb_action
  811. #--------------------------------------------------------------------------
  812. def end_ftb_action
  813. if $game_party.inputable?
  814. select_next_member
  815. else
  816. status_redraw_target(BattleManager.actor)
  817. BattleManager.next_command
  818. turn_start
  819. end
  820. end
  821.  
  822. #--------------------------------------------------------------------------
  823. # new method: select_next_member
  824. #--------------------------------------------------------------------------
  825. def select_next_member
  826. status_redraw_target(BattleManager.actor)
  827. last_index = $game_party.battle_members.size - 1
  828. for member in $game_party.battle_members.reverse
  829. break if member.inputable?
  830. last_index -= 1
  831. end
  832. next_command if next_ftb_member?(last_index)
  833. return if BattleManager.actor.nil?
  834. if BattleManager.actor.index >= last_index && !BattleManager.actor.inputable?
  835. prior_command
  836. elsif !BattleManager.actor.inputable? #grs
  837. next_command #grs
  838. else
  839. start_actor_command_selection
  840. status_redraw_target(BattleManager.actor)
  841. end
  842. end
  843.  
  844. #--------------------------------------------------------------------------
  845. # new method: next_ftb_member?
  846. #--------------------------------------------------------------------------
  847. def next_ftb_member?(last_index)
  848. actor = BattleManager.actor
  849. return true if actor.nil?
  850. return false if actor.max_ftb_actions > actor.ftb_actions
  851. return false if BattleManager.actor.index >= last_index
  852. return BattleManager.actor.index != last_index
  853. end
  854.  
  855. #--------------------------------------------------------------------------
  856. # alias method: hide_extra_gauges
  857. #--------------------------------------------------------------------------
  858. alias scene_battle_hide_extra_gauges_ftb hide_extra_gauges
  859. def hide_extra_gauges
  860. scene_battle_hide_extra_gauges_ftb
  861. @ftb_gauge.hide
  862. end
  863.  
  864. #--------------------------------------------------------------------------
  865. # alias method: show_extra_gauges
  866. #--------------------------------------------------------------------------
  867. alias scene_battle_show_extra_gauges_ftb show_extra_gauges
  868. def show_extra_gauges
  869. scene_battle_show_extra_gauges_ftb
  870. @ftb_gauge.show
  871. end
  872.  
  873. #grs
  874. alias :command_guard_grs_ftb_def :command_guard unless $@
  875. def command_guard
  876. BattleManager.actor.has_defended = true
  877. command_guard_grs_ftb_def
  878. end
  879.  
  880. end # Scene_Battle
  881.  
  882. #==============================================================================
  883. #
  884. # ? End of File
  885. #
  886. #==============================================================================
RAW Paste Data