DerpyHerps

Yami's PCTB (Reupload)

Jun 8th, 2016
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.37 KB | None | 0 0
  1. #==============================================================================
  2. # Found this script here:
  3. #http://rm-vx-ace.de/WBB4/index.php/Thread/565-YSA-Battle-System-Predicted-Charge-Turn-Battle-BROKEN/
  4. #==============================================================================
  5. # ▼ YSA Battle System: Predicted Charge Turn Battle
  6. # -- Last Updated: 2012.03.17
  7. # -- Level: Easy, Normal
  8. # -- Requires: n/a
  9. #
  10. #==============================================================================
  11.  
  12. $imported = {} if $imported.nil?
  13. $imported["YSA-PCTB"] = true
  14.  
  15. #==============================================================================
  16. # ▼ Updates
  17. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  18. # 2012.03.17 - Compatible Issue: YEA - Battle Engine Ace.
  19. # - Stand Alone fixed.
  20. # 2012.02.20 - Reduced lag a little.
  21. # 2012.02.19 - Fixed: Press Left/Right when choose action for actor.
  22. # - Script now can work alone, without YEA - Battle Engine Ace.
  23. # 2012.02.16 - Finished Script.
  24. # 2012.02.07 - Started Script.
  25. #
  26. #==============================================================================
  27. # ▼ Introduction
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # Battle Type: Predicted CTB.
  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. # To get this work with YEA - Ace Battle Engine, set the default battle system
  38. # for your game to be :pctb by either going to the Ace Battle Engine script and
  39. # setting DEFAULT_BATTLE_SYSTEM as :pctb or by using the following script call:
  40. #
  41. # $game_system:set_battle_system(:pctb)
  42. #
  43. # -----------------------------------------------------------------------------
  44. # Skill and Item Database
  45. # -----------------------------------------------------------------------------
  46. # SPEED FIX
  47. # ~ When set SPEED FIX to a number larger than 0, battler's Speed will be reseted
  48. # by value, equal to SPEED_FIX * :speed_rate.
  49. # ~ When set SPEED FIX to a number smaller than 0, battler's Speed will be
  50. # reduced by value, equal to SPEED_FIX * :speed_rate. This Skill/Item will be
  51. # counted as a charging skill/item.
  52. #
  53. # -----------------------------------------------------------------------------
  54. # Skill and Item Notetags
  55. # -----------------------------------------------------------------------------
  56. # <charge rate: x%>
  57. # Change battler's speed rate when charging a skill or item.
  58. #
  59. # <ctb cost: x%> or <ctb cost: x>
  60. # Decide how much Speed will be reduced after an action.
  61. # If it's a percent, Battler's Speed will be reduced x percents of Max Threshold.
  62. # If it's a normal value, Battler's Speed will be reduced by x.
  63. # Default: CTB COST 100% in percent and 0 in value
  64. #
  65. # <ctb change: +x%> or <ctb change: +x>
  66. # <ctb change: -x%> or <ctb change: -x>
  67. # Change target's Speed when use this skill/item.
  68. # If it's a percent, Battler's Speed will be increase or decrease x percents of
  69. # Max Threshold.
  70. # If it's a normal value, Battler's Speed will be increase or decrease by x.
  71. #
  72. #==============================================================================
  73. # ▼ Compatibility
  74. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  75. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  76. # it will run with RPG Maker VX without adjusting.
  77. #
  78. # This script is compatible with Yanfly Engine Ace - Ace Battle Engine v1.15+
  79. # and the script must be placed under Ace Battle Engine in the script listing.
  80. #
  81. #==============================================================================
  82.  
  83. #==============================================================================
  84. # ▼ Configuration
  85. #==============================================================================
  86.  
  87. module YSA
  88. module PCTB
  89. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  90. # - Mechanic Configuration -
  91. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  92. CTB_MECHANIC = { # Start
  93. :dyn_threshold => true,
  94. # Threshold Offset. If Dynamic Threshold is set to false, this will be
  95. # threshold
  96. :threshold_offset => 400,
  97. # For Dynamic Threshold
  98. :threshold_min => 800,
  99. :threshold_rate => 4.0,
  100. # Ticks per turn
  101. :turn_ctr => 32,
  102. :wait_after_turn => 5, # Frames
  103. # Predict Type
  104. # Type 0: Show Battlers Order only.
  105. # Type 1: Show Battlers Order and Re-order when active battler chooses
  106. # an action.
  107. # Type 2: Show Battlers Order in X Turns (FFX Style).
  108. :predict => 2,
  109. :pre_turns => 22,
  110. } # Do not remove this.
  111.  
  112. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  113. # - Battler Configuration -
  114. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  115. BATTLER_RULES = { # Start
  116. # Speed offset when reset, multiply with Skill/Item speed
  117. :speed_rate => 16.0,
  118. :speed_limit => 0.75, # Set to 0 to disable limit.
  119. # Initialize speed
  120. :initial => 0.10,
  121. :surprise => 0.75,
  122. :random_rate => 8.0, # Multiply with AGI.
  123. # Charging Term
  124. :charge_text => "%s is charging %s!",
  125. :charge_text_dur => 4,
  126. # Can't take action Term
  127. :cant_text => "%s cannot take an action!",
  128. :cant_text_dur => 4,
  129. :show_cant_text => true,
  130. } # Do not remove this.
  131.  
  132. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  133. # - Event Configuration -
  134. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  135. CTB_COMMON_EVENT = { # Start
  136. # Set to 0 to disable this.
  137. :turn_update => 0, # Run common event whenever turn updates.
  138. :end_action => 0, # Run common event whenever an action finishes.
  139. } # Do not remove this.
  140.  
  141. end
  142. end
  143.  
  144. #==============================================================================
  145. # ▼ Editting anything past this point may potentially result in causing
  146. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  147. # halitosis so edit at your own risk.
  148. #==============================================================================
  149.  
  150. module YSA
  151. module REGEXP
  152. module USABLEITEM
  153.  
  154. CHARGE_RATE = /<(?:CHARGE_RATE|charge rate):[ ](\d+)?([%%])>/i
  155. CTB_COST_PER = /<(?:CTB_COST|ctb cost):[ ](\d+)?([%%])>/i
  156. CTB_COST_VAL = /<(?:CTB_COST|ctb cost):[ ](\d+)?>/i
  157.  
  158. CHANGE_CTB_PER = /<(?:CTB_CHANGE|ctb change):[ ]([\+\-]\d+)([%%])?>/i
  159. CHANGE_CTB_VAL = /<(?:CTB_CHANGE|ctb change):[ ]([\+\-]\d+)?>/i
  160.  
  161. end # USABLEITEM
  162. end # REGEXP
  163. end # YSA
  164.  
  165. #==============================================================================
  166. # ■ DataManager
  167. #==============================================================================
  168.  
  169. module DataManager
  170.  
  171. #--------------------------------------------------------------------------
  172. # alias method: load_database
  173. #--------------------------------------------------------------------------
  174. class <<self; alias load_database_pctb load_database; end
  175. def self.load_database
  176. load_database_pctb
  177. load_notetags_pctb
  178. end
  179.  
  180. #--------------------------------------------------------------------------
  181. # new method: load_notetags_pctb
  182. #--------------------------------------------------------------------------
  183. def self.load_notetags_pctb
  184. groups = [$data_skills, $data_items]
  185. for group in groups
  186. for obj in group
  187. next if obj.nil?
  188. obj.load_notetags_pctb
  189. end
  190. end
  191. end
  192.  
  193. end # DataManager
  194.  
  195. #==============================================================================
  196. # ■ RPG::UsableItem
  197. #==============================================================================
  198.  
  199. class RPG::UsableItem < RPG::BaseItem
  200.  
  201. #--------------------------------------------------------------------------
  202. # public instance variables
  203. #--------------------------------------------------------------------------
  204. attr_accessor :charge_rate
  205. attr_accessor :ctb_cost
  206. attr_accessor :ctb_cost_val
  207. attr_accessor :ctb_change
  208. attr_accessor :ctb_change_val
  209.  
  210. #--------------------------------------------------------------------------
  211. # common cache: load_notetags_pctb
  212. #--------------------------------------------------------------------------
  213. def load_notetags_pctb
  214. @charge_rate = 100
  215. @ctb_cost = 100
  216. @ctb_cost_val = 0
  217. @ctb_change = 0
  218. @ctb_change_val = 0
  219. #---
  220. self.note.split(/[\r\n]+/).each { |line|
  221. case line
  222. #---
  223. when YSA::REGEXP::USABLEITEM::CHARGE_RATE
  224. @charge_rate = $1.to_i
  225. when YSA::REGEXP::USABLEITEM::CTB_COST_PER
  226. @ctb_cost = $1.to_i
  227. when YSA::REGEXP::USABLEITEM::CTB_COST_VAL
  228. @ctb_cost_val = $1.to_i
  229. when YSA::REGEXP::USABLEITEM::CHANGE_CTB_PER
  230. @ctb_change = $1.to_i
  231. when YSA::REGEXP::USABLEITEM::CHANGE_CTB_VAL
  232. @ctb_change_val = $1.to_i
  233. #---
  234. end
  235. } # self.note.split
  236. #---
  237. @charge_rate = 100 if @charge_rate <= 0
  238. @ctb_cost = 100 if @ctb_cost > 100
  239. end
  240.  
  241. end # RPG::UsableItem
  242.  
  243. #==============================================================================
  244. # ■ BattleManager
  245. #==============================================================================
  246.  
  247. module BattleManager
  248.  
  249. #--------------------------------------------------------------------------
  250. # alias method:
  251. # - make_action_orders
  252. # - prior_command
  253. # - next_command
  254. # - in_turn?
  255. # - battle_start
  256. #--------------------------------------------------------------------------
  257. class <<self
  258. alias pctb_make_action_orders make_action_orders
  259. alias pctb_prior_command prior_command
  260. alias pctb_next_command next_command
  261. alias pctb_next_subject next_subject
  262. alias pctb_battle_start battle_start
  263. alias pctb_input_start input_start
  264. alias pctb_turn_start turn_start
  265. end
  266.  
  267. #--------------------------------------------------------------------------
  268. # battle_start
  269. #--------------------------------------------------------------------------
  270. def self.battle_start
  271. pctb_battle_start
  272. if btype?(:pctb)
  273. make_pctb_action_orders
  274. make_pctb_threshold
  275. make_pctb_first_speed
  276. end
  277. end
  278.  
  279. #--------------------------------------------------------------------------
  280. # make_action_orders
  281. #--------------------------------------------------------------------------
  282. def self.make_action_orders
  283. return if btype?(:pctb)
  284. pctb_make_action_orders unless btype?(:pctb)
  285. end
  286.  
  287. #--------------------------------------------------------------------------
  288. # next_command
  289. #--------------------------------------------------------------------------
  290. def self.next_command
  291. return false if btype?(:pctb)
  292. pctb_next_command
  293. end
  294.  
  295. #--------------------------------------------------------------------------
  296. # prior_command
  297. #--------------------------------------------------------------------------
  298. def self.prior_command
  299. return false if btype?(:pctb)
  300. pctb_prior_command
  301. end
  302.  
  303. #--------------------------------------------------------------------------
  304. # new method: make_pctb_action_orders
  305. #--------------------------------------------------------------------------
  306. def self.make_pctb_action_orders
  307. @action_battlers = []
  308. end
  309.  
  310. #--------------------------------------------------------------------------
  311. # new method: make_pctb_threshold
  312. #--------------------------------------------------------------------------
  313. def self.make_pctb_threshold
  314. @threshold = YSA::PCTB::CTB_MECHANIC[:threshold_offset]
  315. return unless YSA::PCTB::CTB_MECHANIC[:dyn_threshold]
  316. offset = 0
  317. battlers = $game_party.members + $game_troop.members
  318. battlers.each { |battler|
  319. offset += battler.agi
  320. }
  321. @threshold += offset * YSA::PCTB::CTB_MECHANIC[:threshold_rate]
  322. @threshold = @threshold >= YSA::PCTB::CTB_MECHANIC[:threshold_min] ? @threshold : YSA::PCTB::CTB_MECHANIC[:threshold_min]
  323. end
  324.  
  325. #--------------------------------------------------------------------------
  326. # new method: make_pctb_first_speed
  327. #--------------------------------------------------------------------------
  328. def self.make_pctb_first_speed
  329. init_value = YSA::PCTB::BATTLER_RULES[:initial] * pctb_threshold
  330. surprise_value = YSA::PCTB::BATTLER_RULES[:surprise] * pctb_threshold
  331. battlers = $game_party.members + $game_troop.members
  332. battlers.each { |battler|
  333. check = (battler.actor? && @preemptive) || (battler.enemy? && @surprise)
  334. battler.pctb_speed = init_value
  335. battler.pctb_speed = surprise_value if check
  336. random = YSA::PCTB::BATTLER_RULES[:random_rate] * battler.agi + 1
  337. battler.pctb_speed += rand(random)
  338. }
  339. end
  340.  
  341. #--------------------------------------------------------------------------
  342. # new method: pctb_threshold
  343. #--------------------------------------------------------------------------
  344. def self.pctb_threshold
  345. return @threshold
  346. end
  347.  
  348. #--------------------------------------------------------------------------
  349. # new method: set_actor
  350. #--------------------------------------------------------------------------
  351. def self.set_actor(actor_index)
  352. @actor_index = actor_index
  353. end
  354.  
  355. #--------------------------------------------------------------------------
  356. # new method: action_list_ctb
  357. #--------------------------------------------------------------------------
  358. def self.action_list_ctb
  359. return @action_battlers
  360. end
  361.  
  362. #--------------------------------------------------------------------------
  363. # alias method: next_subject
  364. #--------------------------------------------------------------------------
  365. def self.next_subject
  366. return pctb_next_subject unless btype?(:pctb)
  367. loop do
  368. battler = @action_battlers[0]
  369. return nil unless battler
  370. unless battler.index && battler.alive?
  371. @action_battlers.shift
  372. next
  373. end
  374. return battler
  375. end
  376. end
  377.  
  378. #--------------------------------------------------------------------------
  379. # alias method: input_start
  380. #--------------------------------------------------------------------------
  381. def self.input_start
  382. return pctb_input_start unless btype?(:pctb)
  383. @phase = :input
  384. return false
  385. end
  386.  
  387. #--------------------------------------------------------------------------
  388. # alias method: turn_start
  389. #--------------------------------------------------------------------------
  390. def self.turn_start
  391. return pctb_turn_start unless btype?(:pctb)
  392. @phase = :turn
  393. clear_actor
  394. end
  395.  
  396. #--------------------------------------------------------------------------
  397. # alias method: turn_start
  398. #--------------------------------------------------------------------------
  399. def self.sort_battlers(cache = false)
  400. if btype?(:pctb)
  401. battlers = []
  402. for battler in ($game_party.members + $game_troop.members)
  403. next if battler.dead?
  404. battlers.push(battler)
  405. end
  406. battlers.sort! { |a,b|
  407. if a.pctb_ctr(cache) != b.pctb_ctr(cache)
  408. a.pctb_ctr(cache) <=> b.pctb_ctr(cache)
  409. elsif a.pctb_prediction != b.pctb_prediction
  410. b.pctb_prediction <=> a.pctb_prediction
  411. elsif a.agi != b.agi
  412. b.agi <=> a.agi
  413. elsif a.screen_x != b.screen_x
  414. a.screen_x <=> b.screen_x
  415. else
  416. a.name <=> b.name
  417. end
  418. }
  419. return battlers
  420. end
  421. end
  422.  
  423. #--------------------------------------------------------------------------
  424. # new method: btype?
  425. #--------------------------------------------------------------------------
  426. unless $imported["YEA-BattleEngine"]
  427. def self.btype?(btype)
  428. return true if btype == :pctb
  429. end
  430. end
  431.  
  432. end # BattleManager
  433.  
  434. #==============================================================================
  435. # ■ Game_System
  436. #==============================================================================
  437.  
  438. class Game_System
  439.  
  440. if $imported["YEA-BattleEngine"]
  441. #--------------------------------------------------------------------------
  442. # alias method: set_battle_system
  443. #--------------------------------------------------------------------------
  444. alias pctb_set_battle_system set_battle_system
  445. def set_battle_system(type)
  446. case type
  447. when :pctb; @battle_system = :pctb
  448. else; pctb_set_battle_system(type)
  449. end
  450. end
  451.  
  452. #--------------------------------------------------------------------------
  453. # alias method: battle_system_corrected
  454. #--------------------------------------------------------------------------
  455. alias pctb_battle_system_corrected battle_system_corrected
  456. def battle_system_corrected(type)
  457. case type
  458. when :pctb; return :pctb
  459. else; return pctb_battle_system_corrected(type)
  460. end
  461. end
  462. end
  463.  
  464. end # Game_System
  465.  
  466. #==============================================================================
  467. # ■ Game_Battler
  468. #==============================================================================
  469.  
  470. class Game_Battler < Game_BattlerBase
  471.  
  472. #--------------------------------------------------------------------------
  473. # public instance variables
  474. #--------------------------------------------------------------------------
  475. attr_accessor :pctb_speed
  476. attr_accessor :pctb_prediction
  477. attr_accessor :last_obj
  478. attr_accessor :pctb_forced
  479. attr_accessor :pctb_speed_cache
  480.  
  481. #--------------------------------------------------------------------------
  482. # alias method: initialize
  483. #--------------------------------------------------------------------------
  484. alias pctb_initialize initialize
  485. def initialize
  486. pctb_initialize
  487. @pctb_speed = 0
  488. @pctb_prediction = 0
  489. @pctb_speed_cache = 0
  490. end
  491.  
  492. #--------------------------------------------------------------------------
  493. # new method: base_gain_pctb
  494. #--------------------------------------------------------------------------
  495. def base_gain_pctb
  496. return self.agi
  497. end
  498.  
  499. #--------------------------------------------------------------------------
  500. # new method: real_gain_pctb
  501. #--------------------------------------------------------------------------
  502. def real_gain_pctb
  503. obj = current_action.item if current_action
  504. value = base_gain_pctb
  505. value = value * obj.charge_rate / 100 if obj && @charging_pctb
  506. return value
  507. end
  508.  
  509. #--------------------------------------------------------------------------
  510. # new method: pctb_ctr
  511. #--------------------------------------------------------------------------
  512. def pctb_ctr(cache = false)
  513. @pctb_prediction = @pctb_speed unless cache
  514. @pctb_prediction = @pctb_speed_cache if cache
  515. return 0 if @pctb_prediction >= BattleManager.pctb_threshold
  516. value = (BattleManager.pctb_threshold.to_f - @pctb_prediction.to_f) / real_gain_pctb.to_f
  517. value = value.ceil
  518. @pctb_prediction += value * real_gain_pctb
  519. return value
  520. end
  521.  
  522. #--------------------------------------------------------------------------
  523. # new method: reset_pctb_speed
  524. #--------------------------------------------------------------------------
  525. def reset_pctb_speed(cache = false)
  526. return @pctb_forced = false if @pctb_forced
  527. if actor?
  528. obj = input ? input.item : @last_obj
  529. else
  530. obj = @last_obj
  531. end
  532. real_cache = @pctb_speed
  533. if obj
  534. limit_rate = YSA::PCTB::BATTLER_RULES[:speed_limit]
  535. limit = BattleManager.pctb_threshold * limit_rate
  536. real_cache -= obj.ctb_cost * BattleManager.pctb_threshold / 100
  537. real_cache -= obj.ctb_cost_val
  538. value = YSA::PCTB::BATTLER_RULES[:speed_rate] * obj.speed
  539. value = [value, 0].max
  540. value = [value, limit].min if limit > 0
  541. real_cache += value
  542. else
  543. real_cache -= BattleManager.pctb_threshold
  544. end
  545. real_cache = [real_cache, 0].max
  546. @pctb_speed = real_cache if cache == false
  547. @pctb_speed_cache = real_cache if cache
  548. @charging_pctb = false unless cache
  549. @last_obj = nil unless cache
  550. end
  551.  
  552. #--------------------------------------------------------------------------
  553. # new method: charging_start
  554. #--------------------------------------------------------------------------
  555. def charging_start
  556. return false unless BattleManager.btype?(:pctb)
  557. return false if @charging_pctb
  558. return false unless current_action
  559. obj = current_action.item
  560. return false unless obj
  561. return false if obj.speed >= 0
  562. value = obj.speed * YSA::PCTB::BATTLER_RULES[:speed_rate]
  563. @pctb_speed += value
  564. @pctb_speed = [@pctb_speed, 0].max
  565. BattleManager.action_list_ctb.shift
  566. @charging_pctb = true
  567. SceneManager.scene.charging_start(self)
  568. SceneManager.scene.update_pctb_speed
  569. return true
  570. end
  571.  
  572. #--------------------------------------------------------------------------
  573. # new method: pctb_active?
  574. #--------------------------------------------------------------------------
  575. def pctb_active?
  576. return @pctb_speed >= BattleManager.pctb_threshold && movable?
  577. end
  578.  
  579. #--------------------------------------------------------------------------
  580. # new method: storage_speed
  581. #--------------------------------------------------------------------------
  582. def storage_speed
  583. return if @cache_speed
  584. @cache_speed = @pctb_speed
  585. end
  586.  
  587. #--------------------------------------------------------------------------
  588. # new method: restore_speed
  589. #--------------------------------------------------------------------------
  590. def restore_speed
  591. return unless @cache_speed
  592. @pctb_speed = @cache_speed
  593. @cache_speed = nil
  594. end
  595.  
  596. #--------------------------------------------------------------------------
  597. # alias method: update_state_turns
  598. #--------------------------------------------------------------------------
  599. alias pctb_update_state_turns update_state_turns
  600. def update_state_turns
  601. if BattleManager.btype?(:pctb)
  602. states.each do |state|
  603. @state_turns[state.id] -= 1 if @state_turns[state.id] > 0 && state.auto_removal_timing == 2
  604. end
  605. else
  606. pctb_update_state_turns
  607. end
  608. end
  609.  
  610. #--------------------------------------------------------------------------
  611. # new method: update_state_actions
  612. #--------------------------------------------------------------------------
  613. def update_state_actions
  614. return unless BattleManager.btype?(:pctb)
  615. states.each do |state|
  616. @state_turns[state.id] -= 1 if @state_turns[state.id] > 0 && state.auto_removal_timing == 1
  617. end
  618. end
  619.  
  620. #--------------------------------------------------------------------------
  621. # alias method: on_action_end
  622. #--------------------------------------------------------------------------
  623. alias pctb_on_action_end on_action_end
  624. def on_action_end
  625. pctb_on_action_end
  626. update_state_actions
  627. end
  628.  
  629. #--------------------------------------------------------------------------
  630. # alias method: force_action
  631. #--------------------------------------------------------------------------
  632. alias pctb_force_action force_action
  633. def force_action(skill_id, target_index)
  634. if BattleManager.btype?(:pctb)
  635. action = Game_Action.new(self, true)
  636. action.set_skill(skill_id)
  637. if target_index == -2
  638. action.target_index = last_target_index
  639. elsif target_index == -1
  640. action.decide_random_target
  641. else
  642. action.target_index = target_index
  643. end
  644. @actions = [action] + @actions
  645. @pctb_forced = true
  646. end
  647. pctb_force_action(skill_id, target_index) unless BattleManager.btype?(:pctb)
  648. end
  649.  
  650. #--------------------------------------------------------------------------
  651. # alias method: make_action_times
  652. #--------------------------------------------------------------------------
  653. alias pctb_make_action_times make_action_times
  654. def make_action_times
  655. BattleManager.btype?(:pctb) ? 1 : pctb_make_action_times
  656. end
  657.  
  658. end # Game_Battler
  659.  
  660. #==============================================================================
  661. # ■ Game_Actor
  662. #==============================================================================
  663.  
  664. class Game_Actor < Game_Battler
  665.  
  666. #--------------------------------------------------------------------------
  667. # overwrite method: input
  668. #--------------------------------------------------------------------------
  669. if $imported["YEA-BattleEngine"]
  670. def input
  671. game_actor_input_abe
  672. end
  673. end
  674.  
  675. #--------------------------------------------------------------------------
  676. # new method: screen_x | screen_y
  677. #--------------------------------------------------------------------------
  678. unless $imported["YEA-BattleEngine"]
  679. def screen_x
  680. 0
  681. end
  682.  
  683. def screen_y
  684. 0
  685. end
  686. end
  687.  
  688. end # Game_Actor
  689.  
  690. #==============================================================================
  691. # ■ Scene_Battle
  692. #==============================================================================
  693.  
  694. class Scene_Battle < Scene_Base
  695.  
  696. #--------------------------------------------------------------------------
  697. # new method: battle_start
  698. #--------------------------------------------------------------------------
  699. alias pctb_battle_start battle_start
  700. def battle_start
  701. pctb_battle_start
  702. update_pctb_speed if BattleManager.btype?(:pctb)
  703. end
  704.  
  705. #--------------------------------------------------------------------------
  706. # new method: charging_start
  707. #--------------------------------------------------------------------------
  708. def charging_start(battler)
  709. @status_window.show
  710. @status_window.open
  711. if $imported["YEA-BattleEngine"]
  712. redraw_current_status
  713. @status_aid_window.hide
  714. else
  715. refresh_status
  716. end
  717. @actor_command_window.show
  718. string = YSA::PCTB::BATTLER_RULES[:charge_text]
  719. skill = battler.current_action.item
  720. skill_text = sprintf("\\i[%d]%s", skill.icon_index, skill.name)
  721. text = sprintf(string, battler.name, skill_text)
  722. @log_window.add_text(text)
  723. YSA::PCTB::BATTLER_RULES[:charge_text_dur].times do @log_window.wait end
  724. @log_window.back_one
  725. end
  726.  
  727. #--------------------------------------------------------------------------
  728. # new method: update_pctb_speed
  729. #--------------------------------------------------------------------------
  730. def update_pctb_speed
  731. return if scene_changing?
  732. @clocktick = 0 if @clocktick.nil?
  733. ctr = YSA::PCTB::CTB_MECHANIC[:turn_ctr]
  734. #---
  735. battlers = BattleManager.sort_battlers
  736. first_battler = battlers[0]
  737. tick = first_battler.pctb_ctr
  738. #---
  739. battlers.each { |battler|
  740. battler.pctb_speed += tick * battler.real_gain_pctb
  741. }
  742. #---
  743. @clocktick = @clocktick + tick
  744. pass_turn = @clocktick / ctr
  745. pass_turn = pass_turn.floor.to_i
  746. pass_turn.times {
  747. $game_temp.reserve_common_event(YSA::PCTB::CTB_COMMON_EVENT[:turn_update]) if YSA::PCTB::CTB_COMMON_EVENT[:turn_update] > 0 && $data_common_events[YSA::PCTB::CTB_COMMON_EVENT[:turn_update]]
  748. process_event
  749. $game_troop.increase_turn
  750. turn_end
  751. wait(YSA::PCTB::CTB_MECHANIC[:wait_after_turn])
  752. }
  753. @clocktick = @clocktick % ctr
  754. #---
  755. if first_battler.movable?
  756. BattleManager.action_list_ctb.push(first_battler)
  757. else
  758. string = YSA::PCTB::BATTLER_RULES[:cant_text]
  759. text = sprintf(string, first_battler.name)
  760. @log_window.add_text(text)
  761. YSA::PCTB::BATTLER_RULES[:cant_text_dur].times do @log_window.wait end
  762. @log_window.back_one
  763. first_battler.clear_actions
  764. first_battler.reset_pctb_speed
  765. return update_pctb_speed && update_order_gauge
  766. end
  767. #---
  768. update_order_gauge
  769. #---
  770. start_pctb_action
  771. end
  772.  
  773. #--------------------------------------------------------------------------
  774. # new method: start_pctb_action
  775. #--------------------------------------------------------------------------
  776. def start_pctb_action
  777. battler = BattleManager.action_list_ctb[0]
  778. battler.make_actions if battler.actions.size == 0
  779. return if battler.charging_start && battler.enemy?
  780. if battler.actor? && battler.input && battler.input.item.nil?
  781. BattleManager.input_start
  782. BattleManager.set_actor(battler.index)
  783. start_actor_command_selection
  784. if $imported["YEA-BattleEngine"]
  785. redraw_current_status
  786. @status_aid_window.hide
  787. else
  788. refresh_status
  789. end
  790. @status_window.show
  791. @status_window.open
  792. end
  793. turn_start if battler.enemy?
  794. turn_start if battler.actor? && battler.input && battler.input.item
  795. end
  796.  
  797. #--------------------------------------------------------------------------
  798. # new method: update_order_gauge
  799. #--------------------------------------------------------------------------
  800. def update_order_gauge
  801. battler = BattleManager.action_list_ctb[0]
  802. return unless $imported["YSA-OrderBattler"]
  803. BattleManager.make_ctb_battler_order
  804. @active_order_sprite.battler = battler if @active_order_sprite
  805. for order in @spriteset_order
  806. order.make_destination
  807. end
  808. end
  809.  
  810. #--------------------------------------------------------------------------
  811. # alias method: execute_action
  812. #--------------------------------------------------------------------------
  813. alias scene_battle_execute_action_pctb execute_action
  814. def execute_action
  815. scene_battle_execute_action_pctb
  816. unless BattleManager.action_forced?
  817. @subject.last_obj = @subject.current_action.item unless @subject.last_obj
  818. end
  819. end
  820.  
  821. #--------------------------------------------------------------------------
  822. # alias method: execute_action
  823. #--------------------------------------------------------------------------
  824. alias scene_battle_invoke_item_pctb invoke_item
  825. def invoke_item(target, item)
  826. scene_battle_invoke_item_pctb(target, item)
  827. #---
  828. change_per = item.ctb_change * BattleManager.pctb_threshold / 100
  829. change_val = item.ctb_change_val
  830. target.pctb_speed += change_per
  831. target.pctb_speed = 0 if target.pctb_speed < 0
  832. target.pctb_speed += change_val
  833. target.pctb_speed = 0 if target.pctb_speed < 0
  834. #---
  835. end
  836.  
  837. #--------------------------------------------------------------------------
  838. # alias method: process_action_end
  839. #--------------------------------------------------------------------------
  840. alias scene_battle_process_action_end_pctb process_action_end
  841. def process_action_end
  842. scene_battle_process_action_end_pctb
  843. unless BattleManager.action_forced?
  844. $game_temp.reserve_common_event(YSA::PCTB::CTB_COMMON_EVENT[:end_action]) if YSA::PCTB::CTB_COMMON_EVENT[:end_action] > 0 && $data_common_events[YSA::PCTB::CTB_COMMON_EVENT[:end_action]]
  845. process_event
  846. @subject.restore_speed
  847. @subject.reset_pctb_speed
  848. return start_pctb_action if @subject.pctb_active?
  849. BattleManager.action_list_ctb.shift
  850. update_pctb_speed
  851. end
  852. end
  853.  
  854. #--------------------------------------------------------------------------
  855. # alias method: next_command
  856. #--------------------------------------------------------------------------
  857. alias pctb_next_command next_command
  858. def next_command
  859. if BattleManager.actor
  860. if BattleManager.actor != BattleManager.action_list_ctb[0]
  861. BattleManager.action_list_ctb[0].make_actions
  862. start_pctb_action
  863. return
  864. end
  865. end
  866. return @subject = nil if BattleManager.actor && BattleManager.actor.charging_start
  867. pctb_next_command
  868. end
  869.  
  870. #--------------------------------------------------------------------------
  871. # alias method: create_actor_command_window
  872. #--------------------------------------------------------------------------
  873. alias yctb_create_actor_command_window create_actor_command_window
  874. def create_actor_command_window
  875. yctb_create_actor_command_window
  876. @actor_command_window.set_handler(:cancel, method(:ctb_prior_actor))
  877. @actor_command_window.set_handler(:dir4, method(:ctb_prior_actor))
  878. @actor_command_window.set_handler(:dir6, method(:ctb_next_command))
  879. end
  880.  
  881. #--------------------------------------------------------------------------
  882. # new method: ctb_prior_actor
  883. #--------------------------------------------------------------------------
  884. def ctb_prior_actor
  885. BattleManager.actor.make_actions
  886. last_index = BattleManager.actor.index
  887. prior_index = last_index - 1
  888. if prior_index < 0
  889. @actor_command_window.close
  890. @party_command_window.setup
  891. else
  892. return ctb_prior_actor if !$game_party.members[prior_index].movable?
  893. $game_party.members[prior_index].make_actions
  894. BattleManager.input_start
  895. BattleManager.set_actor(prior_index)
  896. start_actor_command_selection
  897. if $imported["YEA-BattleEngine"]
  898. redraw_current_status
  899. @status_aid_window.hide
  900. else
  901. refresh_status
  902. end
  903. @status_window.show
  904. @status_window.open
  905. end
  906. end
  907.  
  908. #--------------------------------------------------------------------------
  909. # new method: ctb_next_command
  910. #--------------------------------------------------------------------------
  911. def ctb_next_command
  912. BattleManager.actor.make_actions
  913. last_index = BattleManager.actor.index
  914. next_index = last_index + 1
  915. if next_index > ($game_party.members.size - 1)
  916. return start_confirm_command_selection if $imported["YEA-BattleCommandList"] && YEA::BATTLE_COMMANDS::USE_CONFIRM_WINDOW
  917. BattleManager.action_list_ctb[0].make_actions
  918. start_pctb_action
  919. else
  920. return ctb_next_command if !$game_party.members[next_index].movable?
  921. $game_party.members[next_index].make_actions
  922. BattleManager.input_start
  923. BattleManager.set_actor(next_index)
  924. start_actor_command_selection
  925. if $imported["YEA-BattleEngine"]
  926. redraw_current_status
  927. @status_aid_window.hide
  928. else
  929. refresh_status
  930. end
  931. @status_window.show
  932. @status_window.open
  933. end
  934. end
  935.  
  936. #--------------------------------------------------------------------------
  937. # alias method: command_fight
  938. #--------------------------------------------------------------------------
  939. alias command_fight_pctb command_fight
  940. def command_fight
  941. return command_fight_pctb unless BattleManager.btype?(:pctb)
  942. if BattleManager.action_list_ctb[0].nil?
  943. update_pctb_speed
  944. else
  945. BattleManager.action_list_ctb[0].make_actions
  946. start_pctb_action
  947. end
  948. end
  949.  
  950. #--------------------------------------------------------------------------
  951. # alias method: turn_start
  952. #--------------------------------------------------------------------------
  953. alias pctb_turn_start turn_start
  954. def turn_start
  955. last_subject = @subject if BattleManager.btype?(:pctb)
  956. pctb_turn_start
  957. @subject = last_subject if BattleManager.btype?(:pctb)
  958. end
  959.  
  960. end # Scene_Battle
  961.  
  962. #==============================================================================
  963. #
  964. # ▼ End of File
  965. #
  966. #==============================================================================
Add Comment
Please, Sign In to add comment