Guest User

Untitled

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