Advertisement
Guest User

Ar tonelico script xp

a guest
Oct 26th, 2011
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 162.67 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # Ar Tonelico Custom Battle System
  3. # Author: Kread-EX
  4. # Version 1.1
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  6.  
  7. # TERMS OF USAGE
  8. # #------------------------------------------------------------------------------------------------------------------
  9. # # You are free to adapt this work to suit your needs.
  10. # #
  11. # # You cannot use this work for commercial purposes.
  12. # #
  13. # # This work can only be distributed by the following websites:
  14. # # http://www.creationasylum.net/
  15. # # http://www.rpgrevolution.com/ --> Standalone Scripts ONLY (not the demo !)
  16. # # http://www.rmvxp.com/
  17. # # If you want to distribute it elsewhere, contact me first. I'll most likely accept (unless I have
  18. # # some kind of grudge against a certain place), but I want to keep track of the places.
  19. # # Note that I will support and update this script on the above places ONLY.
  20. # #------------------------------------------------------------------------------------------------------------------
  21.  
  22.  
  23. #===========================================================
  24. # INTRODUCTION
  25. #
  26. # This script is a custom battle system (CBS) destined to replicate more or less the system used
  27. # in the game "Ar Tonelico - Sekai no Owari de Shi Tsudukeru Shoujo". I say more or less because
  28. # I changed some things.
  29. #
  30. #
  31. # HOW TO USE
  32. # This script is designed to be used with Minkoff/DerVVulfman's Animated Battlers. It won't work
  33. # with the default layout neither will it with Xiderowg's FullMotion script.
  34. # If you downloaded the script from RRR, you'll have to get the Animated Battlers script.
  35. # You can find it there: http://www.creationasylum.net/forum/index.php?showtopic=11827
  36. # Put the main script above the Animated Battlers, and the patch below.
  37. # Read carefully the configuration steps in the KreadCFG section and if the Animated Battlers if
  38. # necessary.
  39. #
  40. # COMPATIBILITY ISSUES
  41. #
  42. # Will clash with the SDK, but not with the MACL.
  43. # In order to avoid lag, I have overwritten most methods insteads of aliasing them, which means
  44. # most battle add-ons will clash with this script.
  45. # If will write add-ons for the next releases depending of user feedback.
  46. #
  47. # CREDITS
  48. #
  49. # Gust Entertainment and Banpresto for making Ar Tonelico in the first place.
  50. # Minkoff and DerVVulfman for their Animated Battlers script.
  51. # MoyasiWhite for the icons.
  52. # Dollmage, Nakka and Grin for the battler graphics.
  53. # Gozaru for the face graphics.
  54. #===========================================================
  55.  
  56. #===========================================================
  57. # ** KreadCFG
  58. #------------------------------------------------------------------------------
  59. # Configuration module.
  60. #===========================================================
  61.  
  62. module KreadCFG
  63.  
  64. # Name of Reyvateil class.
  65. ReyvateilClass = 'Reyvateil'
  66.  
  67. # Name of Song Magic.
  68. SongMagicName = 'Song Magic'
  69.  
  70. # Name of Song Activation.
  71. SongActivate = 'Activate Song'
  72.  
  73. # Name of Song Cancellation.
  74. SongCancel = 'Cancel Song'
  75.  
  76. # Animation ID for Song Activation
  77. SongActivateAnimID = 105
  78.  
  79. # Animation ID for Song Cancellation
  80. SongCancelAnimID = 104
  81.  
  82. # Name of Red Magic and Blue Magic
  83. SongRed = 'Red Magic'
  84. SongBlue = 'Blue Magic'
  85.  
  86. # List of charging animation for Song Magic (Red type only).
  87. # Format: {Skill ID => Animation ID}
  88. SongMagicChargeAnim = {82 => 102, 83 => 107}
  89.  
  90. # Max Burst value before Song Magic evolution.
  91. # Format: {Skill ID => value}
  92. SongMagicMaxBurst = {82 => 700, 83 => 3000, 89 => 6000}
  93.  
  94. # Skill Evolution Pattern. Determine in which skill a previous skill will evolve when the
  95. # Max Burst value has been reached.
  96. # Format: {Old Skill ID => New Skill ID}
  97. SongMagicEvolve = {82 => 83}
  98.  
  99. # Harmo Overdrive Skills ID (skills available using Harmonics gauge)
  100. # Format: [Skill ID, Skill ID, ...]
  101. HarmoOverdriveSkills = [85, 86]
  102.  
  103. # Set here the IDs for Fire, Ice and Wind elements.
  104. FireElement = 1
  105. IceElement = 2
  106. WindElement = 6
  107.  
  108. # Hit number for skills.
  109. # Format: when Skill ID then #nb of hits. Default is 1.
  110. def self.skill_hits(skill_id)
  111. case skill_id
  112. when 57 then 2
  113. when 60, 82, 83 then 5
  114. when 68 then 3
  115. else
  116. 1
  117. end
  118. end
  119.  
  120. # Hit timings. Goes with Hit numbers.
  121. # Enter here the Frame number that triggers the hit.
  122. # If the skill has 1 hit, then you don't have to configure this.
  123. # Format: {Skill ID => [frame, frame, frame...]}
  124. HitTimings = {
  125. 57 => [3, 6],
  126. 60 => [2, 5, 8, 11, 14],
  127. 68 => [2, 7, 12],
  128. 82 => [54, 56, 58, 60, 62],
  129. 83 => [54, 56, 58, 60, 62]
  130. }
  131.  
  132. # Skill speed multiplier.
  133. # Format: when Skill ID then Float number. Default is 0.8.
  134. def self.skill_speed(skill_id)
  135. case skill_id
  136. when 58, 59, 66, 67, 70, 71 then 0.6
  137. when 30, 60, 68, 72 then 0.3
  138. when 85 then 0.2
  139. when 86 then 0.1
  140. else
  141. 0.8
  142. end
  143. end
  144.  
  145. # Item speed multiplier.
  146. ItemSpeed = 1.5
  147.  
  148. # Battle speed. The higher, the faster. Minimum is 2 and maximum is 100.
  149. BattleSpeed = 10
  150.  
  151. #--------------------------------------------------------------------------
  152. # * Checks if the given actor is a Reyvateil
  153. #--------------------------------------------------------------------------
  154. def self.is_reyvateil?(actor)
  155. return false if !actor.is_a?(Game_Actor)
  156. return $data_classes[actor.class_id].name == ReyvateilClass
  157. end
  158. #--------------------------------------------------------------------------
  159. # * Checks if there is a Reyvateil in the party at all
  160. #--------------------------------------------------------------------------
  161. def self.reyvateil_party?
  162. $game_party.actors.each {|actor|
  163. return true if self.is_reyvateil?(actor)
  164. }
  165. return false
  166. end
  167. #--------------------------------------------------------------------------
  168. # * Returns the Reyvateil in the party
  169. #--------------------------------------------------------------------------
  170. def self.return_reyvateil
  171. $game_party.actors.each {|actor|
  172. return actor if self.is_reyvateil?(actor)
  173. }
  174. return nil
  175. end
  176. #--------------------------------------------------------------------------
  177. # * Checks if there are two Reyvateils
  178. #--------------------------------------------------------------------------
  179. def self.too_many_reyvateils?
  180. rev_count = 0
  181. $game_party.actors.each {|actor|
  182. rev_count += 1 if self.is_reyvateil?(actor)
  183. }
  184. return rev_count >= 2
  185. end
  186. #--------------------------------------------------------------------------
  187. end
  188.  
  189. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  190. # Ar Tonelico Custom Battle System
  191. # Author: Kread-EX
  192. # Version 1.1
  193. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  194.  
  195. #===========================================================
  196. # ** Scene_Battle
  197. #------------------------------------------------------------------------------
  198. # This class performs battle screen processing.
  199. #===========================================================
  200.  
  201. class Scene_Battle
  202. #--------------------------------------------------------------------------
  203. # * Public instance variables
  204. #--------------------------------------------------------------------------
  205. attr_reader :skill
  206. attr_accessor :vanguards_harmonics
  207. attr_accessor :reyvateil_harmonics
  208. #--------------------------------------------------------------------------
  209. # * Main Processing
  210. #--------------------------------------------------------------------------
  211. def main
  212. # Checks if too many reyvateils
  213. if KreadCFG.too_many_reyvateils?
  214. print("You cannot have more than 1 Reyvateil in your party !\n" +
  215. "Please take this into account when designing your game.")
  216. exit
  217. end
  218. # Checks for alone reyvateil
  219. if $game_party.actors.size == 1 && KreadCFG.reyvateil_party?
  220. print("You cannot have a lone Reyvateil in your party !")
  221. exit
  222. end
  223. set_global_variables
  224. set_troop_data
  225. set_initial_action_meters
  226. create_sprites_and_windows
  227. # Initialize wait count
  228. @wait_count = 0
  229. # Assign Reyvateil
  230. @reyvateil = KreadCFG.return_reyvateil
  231. if @reyvateil != nil
  232. @reyvateil.song_chant = false
  233. @reyvateil.song_blue = false
  234. @reyvateil.harmonics = 0
  235. @reyvateil.burst_value = 0
  236. end
  237. # Prepare Vanguards Harmonics
  238. @vanguards_harmonics = 0
  239. # Prepare Reyvateil Harmonics
  240. @reyvateil_harmonics = 0
  241. # Initialize delayed command
  242. @delayed_command = false
  243. # Start pre-battle phase
  244. start_phase1
  245. # But switch to Reyvateil command menu if there is a Reyvateil
  246. start_phase6 if KreadCFG.reyvateil_party?
  247. execute_transition
  248. execute_basic_loop
  249. terminate_scene
  250. end
  251. #--------------------------------------------------------------------------
  252. # * Fake judge
  253. #--------------------------------------------------------------------------
  254. def fake_judge
  255. # If all dead determinant is true, or number of members in party is 0
  256. if $game_party.all_dead? or $game_party.actors.size == 0
  257. # If possible to lose
  258. if $game_temp.battle_can_lose
  259. # Desactive Reyvateil Menu
  260. @reyvateil_menu = 'desactivated'
  261. @delayed_command = false
  262. # Return true
  263. return true
  264. end
  265. # Desactive Reyvateil Menu
  266. @reyvateil_menu = 'desactivated'
  267. @delayed_command = false
  268. # Return true
  269. return true
  270. end
  271. # Return false if even 1 enemy exists
  272. for enemy in $game_troop.enemies
  273. if enemy.exist?
  274. return false
  275. end
  276. end
  277. # Desactive Reyvateil Menu
  278. @reyvateil_menu = 'desactivated'
  279. @delayed_command = false
  280. # Return true
  281. return true
  282. end
  283. #--------------------------------------------------------------------------
  284. # * Initialize all globals
  285. #--------------------------------------------------------------------------
  286. def set_global_variables
  287. # Initialize each kind of temporary battle data
  288. $game_temp.in_battle = true
  289. $game_temp.battle_turn = 0
  290. $game_temp.battle_event_flags.clear
  291. $game_temp.battle_abort = false
  292. $game_temp.battle_main_phase = false
  293. $game_temp.battleback_name = $game_map.battleback_name
  294. $game_temp.forcing_battler = nil
  295. $game_temp.max_harmonics = 1000
  296. # Initialize battle event interpreter
  297. $game_system.battle_interpreter.setup(nil, 0)
  298. $game_party.harmonics = 0
  299. end
  300. #--------------------------------------------------------------------------
  301. # * Prepare troop
  302. #--------------------------------------------------------------------------
  303. def set_troop_data
  304. @troop_id = $game_temp.battle_troop_id
  305. $game_troop.setup(@troop_id)
  306. end
  307. #--------------------------------------------------------------------------
  308. # * Computes the initial Action Meters for all battlers
  309. #--------------------------------------------------------------------------
  310. def set_initial_action_meters
  311. ($game_party.actors + $game_troop.enemies).each {|battler|
  312. battler.action_meter = battler.agi + rand(battler.agi / 50)
  313. }
  314. end
  315. #--------------------------------------------------------------------------
  316. # * Create the permanently used sprites and windows
  317. #--------------------------------------------------------------------------
  318. def create_sprites_and_windows
  319. # Make sprite set
  320. @spriteset = Spriteset_Battle.new
  321. # Status windows for each actor
  322. @status_windows = []
  323. i = 0
  324. old_y = 350
  325. (0...$game_party.actors.size).each {|j|
  326. i = (($game_party.actors.size - 1) - j)
  327. @status_windows[i] = Battle_Status.new(i)
  328. @status_windows[i].y = old_y
  329. old_y -= 58
  330. }
  331. # Reyvateil command sprite (if there is a Reyvateil in the party)
  332. if KreadCFG.reyvateil_party?
  333. @reyvateil_command = Reyvateil_Command.new(@spriteset.viewport5)
  334. end
  335. # Action system graphic interface
  336. @action_system = Action_System.new(@spriteset.viewport5)
  337. # Create message window
  338. @message_window = Window_Message.new
  339. # Create the Harmonics gauge
  340. @harmonics_gauge = Harmonics_Gauge.new(@spriteset.viewport5, KreadCFG.return_reyvateil)
  341. end
  342. #--------------------------------------------------------------------------
  343. # * Perform the start-battle transition
  344. #--------------------------------------------------------------------------
  345. def execute_transition
  346. if $data_system.battle_transition == ''
  347. Graphics.transition(20)
  348. else
  349. Graphics.transition(40, 'Graphics/Transitions/' + $data_system.battle_transition)
  350. end
  351. end
  352. #--------------------------------------------------------------------------
  353. # * Basic scene loop
  354. #--------------------------------------------------------------------------
  355. def execute_basic_loop
  356. # Main loop
  357. loop {
  358. # Update game screen
  359. Graphics.update
  360. # Update input information
  361. Input.update
  362. # Frame update
  363. update
  364. # Abort loop if screen is changed
  365. break if $scene != self
  366. }
  367. end
  368. #--------------------------------------------------------------------------
  369. # * Destroy all objects
  370. #--------------------------------------------------------------------------
  371. def dispose_objects
  372. @message_window.dispose
  373. @spriteset.dispose
  374. @status_windows.each {|spr| spr.dispose}
  375. if @reyvateil_command != nil
  376. @reyvateil_command.bitmap.dispose
  377. @reyvateil_command.dispose
  378. end
  379. if @levelup_sprites != nil
  380. @levelup_sprites.each {|spr| spr.dispose}
  381. end
  382. @reyvateil_ring.dispose if @reyvateil_ring != nil
  383. @result_window.dispose if @result_window != nil
  384. @action_system.dispose
  385. end
  386. #--------------------------------------------------------------------------
  387. # * Link to next scene
  388. #--------------------------------------------------------------------------
  389. def terminate_scene
  390. # Refresh map
  391. $game_map.refresh
  392. # Prepare for transition
  393. Graphics.freeze
  394. # Dispose of all objects
  395. dispose_objects
  396. # Clear cache
  397. RPG::Cache.clear
  398. # If switching to title screen
  399. if $scene.is_a?(Scene_Title)
  400. # Fade out screen
  401. Graphics.transition
  402. Graphics.freeze
  403. end
  404. # If switching from battle test to any screen other than game over screen
  405. if $BTEST and not $scene.is_a?(Scene_Gameover)
  406. $scene = nil
  407. end
  408. end
  409. #--------------------------------------------------------------------------
  410. # * Frame Update
  411. #--------------------------------------------------------------------------
  412. def update
  413. update_battle_interpreter
  414. update_globals
  415. update_harmonics
  416. update_sprites_and_windows
  417. update_transition
  418. update_reyvateil_command
  419. if @reyvateil != nil && @blue_launch
  420. update_phase6_blue_magic unless (@reyvateil.dead? || !@reyvateil.song_blue)
  421. @blue_launch = false
  422. end
  423. # If message window is showing, then stops
  424. return if $game_temp.message_window_showing
  425. # If effect is showing, then stops
  426. return if @spriteset.effect?
  427. # If game over
  428. if $game_temp.gameover
  429. # Switch to game over screen
  430. $scene = Scene_Gameover.new
  431. return
  432. end
  433. # If returning to title screen
  434. if $game_temp.to_title
  435. # Switch to title screen
  436. $scene = Scene_Title.new
  437. return
  438. end
  439. # If battle is aborted
  440. if $game_temp.battle_abort
  441. # Return to BGM used before battle started
  442. $game_system.bgm_play($game_temp.map_bgm)
  443. # Battle ends
  444. battle_end(1)
  445. return
  446. end
  447. # If waiting
  448. if @wait_count > 0
  449. # Decrease wait count
  450. @wait_count -= 1
  451. return
  452. end
  453. # If battler forcing an action doesn't exist, and battle event is running, then stops
  454. return if $game_temp.forcing_battler == nil && $game_system.battle_interpreter.running?
  455. update_phases
  456. end
  457. #--------------------------------------------------------------------------
  458. # * Update the battle interpreter
  459. #--------------------------------------------------------------------------
  460. def update_battle_interpreter
  461. # If battle event is running
  462. if $game_system.battle_interpreter.running?
  463. # Update interpreter
  464. $game_system.battle_interpreter.update
  465. # If a battler which is forcing actions doesn't exist
  466. if $game_temp.forcing_battler == nil
  467. # If battle event has finished running
  468. unless $game_system.battle_interpreter.running?
  469. # Rerun battle event set up if battle continues
  470. setup_battle_event unless judge
  471. end
  472. end
  473. end
  474. end
  475. #--------------------------------------------------------------------------
  476. # * Update the global variables
  477. #--------------------------------------------------------------------------
  478. def update_globals
  479. # Update system (timer) and screen
  480. $game_system.update
  481. $game_screen.update
  482. # If timer has reached 0
  483. if $game_system.timer_working && $game_system.timer == 0
  484. # Abort battle
  485. $game_temp.battle_abort = true
  486. end
  487. end
  488. #--------------------------------------------------------------------------
  489. # * Update Harmonics
  490. #--------------------------------------------------------------------------
  491. def update_harmonics
  492. return if @phase == 4 && @phase4_step.between?(2, 4)
  493. # If there is a change, perform it.
  494. if @vanguards_harmonics > 0
  495. if @reyvateil != nil
  496. $game_party.harmonics = [($game_party.harmonics + 2),
  497. ($game_temp.max_harmonics - @reyvateil.harmonics)].min
  498. else
  499. $game_party.harmonics = [($game_party.harmonics + 2),
  500. ($game_temp.max_harmonics)].min
  501. end
  502. @vanguards_harmonics -= 2
  503. elsif @vanguards_harmonics < 0
  504. $game_party.harmonics = [($game_party.harmonics - 5), 0].max
  505. @vanguards_harmonics += 5
  506. end
  507. if @reyvateil_harmonics < 0
  508. @reyvateil.harmonics = [(@reyvateil.harmonics - 5), 0].max
  509. @reyvateil_harmonics += 5
  510. end
  511. end
  512. #--------------------------------------------------------------------------
  513. # * Simply updates all permanent sprites and windows
  514. #--------------------------------------------------------------------------
  515. def update_sprites_and_windows
  516. @message_window.update
  517. @spriteset.update
  518. @status_windows.each {|spr| spr.update}
  519. @action_system.update
  520. @help_window.update if @help_window != nil
  521. @burst_gauge.update if @burst_gauge != nil
  522. @harmonics_gauge.update
  523. end
  524. #--------------------------------------------------------------------------
  525. # * Update the transition effects
  526. #--------------------------------------------------------------------------
  527. def update_transition
  528. # If transition is processing
  529. if $game_temp.transition_processing
  530. # Clear transition processing flag
  531. $game_temp.transition_processing = false
  532. # Execute transition
  533. execute_transition
  534. end
  535. end
  536. #--------------------------------------------------------------------------
  537. # * Update the activation of Reyvateil menu
  538. #--------------------------------------------------------------------------
  539. def update_reyvateil_command
  540. # Quit if there isn't any reyvateil or already active
  541. return if !KreadCFG.reyvateil_party? || !@reyvateil_command.visible || @reyvateil.dead?
  542. # Activates by pressing B
  543. if Input.trigger?(Input::B)
  544. # Effect depends of the current situation
  545. case @reyvateil_menu
  546. when 'immediate'
  547. # Stores previous phase
  548. @previous_phase = @phase
  549. # Switch to phase 6
  550. start_phase6
  551. when 'delayed'
  552. @delayed_command = true
  553. @reyvateil_command.visible = false
  554. when 'desactivated'
  555. $game_system.se_play($data_system.buzzer_se)
  556. end
  557. end
  558. end
  559. #--------------------------------------------------------------------------
  560. # * Update the various battle phases
  561. #--------------------------------------------------------------------------
  562. def update_phases
  563. # Branch according to phase
  564. case @phase
  565. when 1 # pre-battle phase
  566. update_phase1
  567. when 2 # party command phase
  568. update_phase2
  569. when 3 # actor command phase
  570. update_phase3
  571. when 4 # main phase
  572. update_phase4
  573. when 5 # after battle phase
  574. update_phase5
  575. when 6 # Reyvateil command phase
  576. update_phase6
  577. end
  578. end
  579. #--------------------------------------------------------------------------
  580. # * Start Pre-Battle Phase
  581. #--------------------------------------------------------------------------
  582. def start_phase1
  583. # Shift to phase 1
  584. @phase = 1
  585. # Clear active battler
  586. @active_battler = nil
  587. # Reyvateil command is immediate
  588. @reyvateil_menu = 'immediate'
  589. # Set up battle event
  590. setup_battle_event
  591. end
  592. #--------------------------------------------------------------------------
  593. # * Frame Update (pre-battle phase)
  594. #--------------------------------------------------------------------------
  595. def update_phase1
  596. # Determine win/loss situation
  597. if judge
  598. # If won or lost: end method
  599. return
  600. end
  601. # Switch to phase 4 in case of forcing battler
  602. if $game_temp.forcing_battler != nil
  603. @active_battler = $game_temp.forcing_battler
  604. @reyvateil_menu = 'desactivated'
  605. start_phase4
  606. return
  607. end
  608. # Update Burst value SP consumption and Reyvateil Harmonics
  609. update_phase1_reyvateil_system
  610. # Update Action Meters
  611. update_phase1_action_meters
  612. # Try to select an active battler
  613. update_phase1_battler_selection
  614. # Switch to next phase if there is an active battler
  615. if @active_battler != nil
  616. # If it's an enemy
  617. if @active_battler.is_a?(Game_Enemy)
  618. # Decrease Ambiance Field of all enemies, and set this one to 0.
  619. $game_troop.enemies.each {|enemy|
  620. enemy.ambiance_field = [(enemy.ambiance_field - 1), 0].max
  621. }
  622. @active_battler.ambiance_field = 0
  623. # Clear skill
  624. @skill = nil
  625. # Program action
  626. @active_battler.make_action
  627. # Switch to phase 4
  628. start_phase4
  629. # Else, it's a standard actor
  630. else
  631. if !@active_battler.inputable?
  632. @active_battler.action_meter = @active_battler.agi
  633. start_phase4
  634. return
  635. end
  636. # Switch to phase 3
  637. start_phase3
  638. end
  639. end
  640. end
  641. #--------------------------------------------------------------------------
  642. # * Frame Update (phase 1: Burst value, SP and R. Harmo update)
  643. #--------------------------------------------------------------------------
  644. def update_phase1_reyvateil_system
  645. # Quit if there's no Reyvateil in party.
  646. return unless KreadCFG.reyvateil_party?
  647. # Update Reyvateil death
  648. if @reyvateil.dead?
  649. @reyvateil.harmonics = 0
  650. @reyvateil.burst_value = 0
  651. @reyvateil.song_chant = false
  652. @reyvateil.song_blue = false
  653. @reyvateil.current_action.clear
  654. if @burst_gauge != nil
  655. @burst_gauge.dispose
  656. @burst_gauge = nil
  657. end
  658. return
  659. end
  660. # Update Harmonics
  661. @reyvateil.harmonics = [(@reyvateil.harmonics + 1),
  662. ($game_temp.max_harmonics - $game_party.harmonics)].min
  663. # Restores SP if not chanting
  664. if !@reyvateil.song_chant
  665. @reyvateil.sp += (10 * (1 + $game_party.global_harmonics / 1000.00)).round
  666. @status_windows[@reyvateil.index].refresh_sp_only
  667. return
  668. end
  669. # Updates SP consumption
  670. @reyvateil.sp -= ($data_skills[@reyvateil.current_action.skill_id].sp_cost *
  671. (1 - $game_party.global_harmonics / 900.00)).round
  672. # Cancels the song if ran out of SP
  673. if @reyvateil.sp <= 0
  674. @reyvateil.sp = 0
  675. # Play animation
  676. @reyvateil.animation_id = KreadCFG::SongCancelAnimID
  677. # Destroy Burst
  678. @burst_gauge.dispose
  679. @burst_gauge = nil
  680. # Clear action
  681. @reyvateil.song_chant = false
  682. @reyvateil.song_blue = false
  683. @reyvateil.loop_animation_id = 0
  684. @reyvateil.current_action.clear
  685. end
  686. @status_windows[@reyvateil.index].refresh_sp_only
  687. # Updates value
  688. @reyvateil.burst_value += (5 + $game_party.global_harmonics / 100)
  689. # If the burst match the Evolve stage, then the spell evolve
  690. current_song = @reyvateil.current_action.skill_id
  691. if KreadCFG::SongMagicEvolve[current_song] != nil
  692. if KreadCFG::SongMagicMaxBurst[current_song] <= @reyvateil.burst_value
  693. @reyvateil.current_action.skill_id = KreadCFG::SongMagicEvolve[current_song]
  694. @reyvateil.loop_animation_id = KreadCFG::SongMagicChargeAnim[@reyvateil.current_action.skill_id]
  695. @reyvateil.animation_id = KreadCFG::SongActivateAnimID
  696. end
  697. end
  698. end
  699. #--------------------------------------------------------------------------
  700. # * Frame Update (phase 1: Action Meters update)
  701. #--------------------------------------------------------------------------
  702. def update_phase1_action_meters
  703. # Adds the BattleSpeed value to AMs. Corrects if under 2 or over 100.
  704. inc = [[KreadCFG::BattleSpeed, 2].max, 100].min
  705. ($game_party.actors + $game_troop.enemies).each {|battler|
  706. next unless battler.exist?
  707. battler.action_meter += inc
  708. }
  709. end
  710. #--------------------------------------------------------------------------
  711. # * Frame Update (phase 1: active battler selection)
  712. #--------------------------------------------------------------------------
  713. def update_phase1_battler_selection
  714. # Iterate both parties searching for a battler with full AM
  715. ($game_party.actors + $game_troop.enemies).each {|battler|
  716. next unless battler.exist?
  717. if battler.action_meter >= 1000 && battler == @action_system.queue.first.battler
  718. @active_battler = battler
  719. return
  720. end
  721. }
  722. end
  723. #--------------------------------------------------------------------------
  724. # * Frame Update (party command phase: escape)
  725. #--------------------------------------------------------------------------
  726. def update_phase2_escape
  727. # Calculate enemy agility average
  728. enemies_agi = 0
  729. enemies_number = 0
  730. for enemy in $game_troop.enemies
  731. if enemy.exist?
  732. enemies_agi += enemy.agi
  733. enemies_number += 1
  734. end
  735. end
  736. if enemies_number > 0
  737. enemies_agi /= enemies_number
  738. end
  739. # Calculate actor agility average
  740. actors_agi = 0
  741. actors_number = 0
  742. for actor in $game_party.actors
  743. if actor.exist?
  744. actors_agi += actor.agi
  745. actors_number += 1
  746. end
  747. end
  748. if actors_number > 0
  749. actors_agi /= actors_number
  750. end
  751. # Determine if escape is successful
  752. success = rand(100) < 50 * actors_agi / enemies_agi
  753. # If escape is successful
  754. if success
  755. # Play escape SE
  756. $game_system.se_play($data_system.escape_se)
  757. # Return to BGM before battle started
  758. $game_system.bgm_play($game_temp.map_bgm)
  759. # Battle ends
  760. battle_end(1)
  761. # If escape is failure
  762. else
  763. # Update Action Meters
  764. @active_battler.action_meter = @active_battler.agi
  765. @active_battler.blink = false
  766. @action_system.update_order
  767. @action_system.update_coordinates
  768. @active_battler = nil
  769. @wait_count = 12
  770. # Switch to phase 4
  771. start_phase4
  772. end
  773. end
  774. #--------------------------------------------------------------------------
  775. # * Start Actor Command Phase
  776. #--------------------------------------------------------------------------
  777. def start_phase3
  778. # Shift to phase 3
  779. @phase = 3
  780. # Blink
  781. @active_battler.blink = true
  782. # Shifts to right action order
  783. @action_system.right_shift
  784. # Create the command ring
  785. @command_ring = Command_Ring.new(@active_battler)
  786. # Reyvateil command is desactivated
  787. @reyvateil_menu = 'desactivated'
  788. end
  789. #--------------------------------------------------------------------------
  790. # * Frame Update (actor command phase)
  791. #--------------------------------------------------------------------------
  792. def update_phase3
  793. # Update enemy arrow
  794. if @enemy_arrow != nil
  795. update_phase3_enemy_select
  796. # Update actor arrow
  797. elsif @actor_arrow != nil
  798. update_phase3_actor_select
  799. # If skill window is enabled
  800. elsif @skill_window != nil
  801. update_phase3_skill_select
  802. # If item window is enabled
  803. elsif @item_window != nil
  804. update_phase3_item_select
  805. # Update command ring if active
  806. elsif @command_ring.active
  807. update_phase3_command_ring
  808. end
  809. end
  810. #--------------------------------------------------------------------------
  811. # * Frame Update (phase 3: actor command selection)
  812. #--------------------------------------------------------------------------
  813. def update_phase3_command_ring
  814. # Update object
  815. @command_ring.update
  816. # C: Validate command
  817. if Input.trigger?(Input::C)
  818. # Play SE
  819. $game_system.se_play($data_system.decision_se)
  820. # Hide command ring
  821. @command_ring.toggle_visibility
  822. @command_ring.toggle_activity
  823. # Branch by command
  824. case @command_ring.command
  825. when 'Attack'
  826. # Play decision SE
  827. $game_system.se_play($data_system.decision_se)
  828. # Set action
  829. @active_battler.current_action.kind = 0
  830. @active_battler.current_action.basic = 0
  831. # Store current action meter
  832. @current_am = @active_battler.action_meter
  833. # And set the next action meter value
  834. @active_battler.action_meter = @active_battler.agi
  835. # Enemy selection
  836. start_enemy_select
  837. when 'Skill'
  838. # Play decision SE
  839. $game_system.se_play($data_system.decision_se)
  840. # Skill selection
  841. start_skill_select
  842. when 'Item'
  843. # Play decision SE
  844. $game_system.se_play($data_system.decision_se)
  845. # Item selection
  846. start_item_select
  847. when 'Guard'
  848. # Play decision SE
  849. $game_system.se_play($data_system.decision_se)
  850. # Set action
  851. @active_battler.current_action.kind = 0
  852. @active_battler.current_action.basic = 1
  853. # And set the next action meter value
  854. @active_battler.action_meter = @active_battler.agi * 2
  855. # Switch to phase 4
  856. start_phase4
  857. when 'Flee'
  858. update_phase2_escape
  859. end
  860. end
  861. end
  862. #--------------------------------------------------------------------------
  863. # * Start Skill Selection
  864. #--------------------------------------------------------------------------
  865. def start_skill_select
  866. # Make skill help window
  867. @skill_help = Window_SkillHelp.new
  868. # Make skill window
  869. @skill_window = Window_BattleSkill.new(@active_battler)
  870. # Associate the two
  871. @skill_window.help_window = @skill_help
  872. # Stores last skill and current AM value
  873. @last_skill = nil
  874. @current_am = @active_battler.action_meter
  875. end
  876. #--------------------------------------------------------------------------
  877. # * Frame Update (actor command phase : skill selection)
  878. #--------------------------------------------------------------------------
  879. def update_phase3_skill_select
  880. # Update skill window
  881. @skill_window.update
  882. # Virtualize next action turn
  883. @skill = @skill_window.skill
  884. if @last_skill != @skill
  885. @last_skill = @skill
  886. @active_battler.action_meter = @active_battler.agi * KreadCFG.skill_speed(@skill.id)
  887. @action_system.update_order
  888. @action_system.update_coordinates
  889. end
  890. # If B button was pressed
  891. if Input.trigger?(Input::B)
  892. # Play cancel SE
  893. $game_system.se_play($data_system.cancel_se)
  894. # End skill selection
  895. end_skill_select
  896. # Restores AM
  897. @active_battler.action_meter = @current_am
  898. # End virtualization
  899. @action_system.update_order
  900. @action_system.update_coordinates(true)
  901. return
  902. end
  903. # If C button was pressed
  904. if Input.trigger?(Input::C)
  905. # Get currently selected data on the skill window
  906. @skill = @skill_window.skill
  907. # If it can't be used
  908. if @skill == nil || !@active_battler.skill_can_use?(@skill.id)
  909. # Play buzzer SE
  910. $game_system.se_play($data_system.buzzer_se)
  911. return
  912. end
  913. # Play decision SE
  914. $game_system.se_play($data_system.decision_se)
  915. # Set action
  916. @active_battler.current_action.kind = 1
  917. @active_battler.current_action.skill_id = @skill.id
  918. # Make skill window and skill help window invisible
  919. @skill_window.visible = @skill_help.visible = false
  920. # If effect scope is single enemy
  921. if @skill.scope == 1
  922. # Start enemy selection
  923. start_enemy_select
  924. # If effect scope is single ally
  925. elsif @skill.scope == 3 or @skill.scope == 5
  926. # Start actor selection
  927. start_actor_select
  928. # If effect scope is not single
  929. else
  930. # End skill selection
  931. end_skill_select
  932. # Start phase 4
  933. start_phase4
  934. end
  935. return
  936. end
  937. end
  938. #--------------------------------------------------------------------------
  939. # * End Skill Selection
  940. #--------------------------------------------------------------------------
  941. def end_skill_select
  942. # Dispose of skill window
  943. @skill_window.dispose
  944. @skill_window = nil
  945. # Dispose of help windiw
  946. @skill_help.dispose
  947. @skill_help = nil
  948. # Retrieve command ring
  949. @command_ring.toggle_visibility
  950. @command_ring.toggle_activity
  951. end
  952. #--------------------------------------------------------------------------
  953. # * Start Item Selection
  954. #--------------------------------------------------------------------------
  955. def start_item_select
  956. # Make item help window
  957. @item_help = Window_SkillHelp.new
  958. # Make item window
  959. @item_window = Window_BattleItem.new
  960. # Associate the two
  961. @item_window.help_window = @item_help
  962. # Stores current AM value
  963. @current_am = @active_battler.action_meter
  964. # Update AM
  965. @active_battler.action_meter = @active_battler.agi * KreadCFG::ItemSpeed
  966. end
  967. #--------------------------------------------------------------------------
  968. # * Frame Update (actor command phase : item selection)
  969. #--------------------------------------------------------------------------
  970. def update_phase3_item_select
  971. # Update item window
  972. @item_window.update
  973. # If B button was pressed
  974. if Input.trigger?(Input::B)
  975. # Play cancel SE
  976. $game_system.se_play($data_system.cancel_se)
  977. # End item selection
  978. end_item_select
  979. # Restores AM
  980. @active_battler.action_meter = @current_am
  981. # End virtualization
  982. @action_system.update_order
  983. @action_system.update_coordinates(true)
  984. return
  985. end
  986. # If C button was pressed
  987. if Input.trigger?(Input::C)
  988. # Get currently selected data on the item window
  989. @item = @item_window.item
  990. # If it can't be used
  991. if @item == nil
  992. # Play buzzer SE
  993. $game_system.se_play($data_system.buzzer_se)
  994. return
  995. end
  996. # Play decision SE
  997. $game_system.se_play($data_system.decision_se)
  998. # Set action
  999. @active_battler.current_action.kind = 2
  1000. @active_battler.current_action.item_id = @item.id
  1001. # Make item window and item help window invisible
  1002. @item_window.visible = @item_help.visible = false
  1003. # If effect scope is single enemy
  1004. if @item.scope == 1
  1005. # Start enemy selection
  1006. start_enemy_select
  1007. # If effect scope is single ally
  1008. elsif @item.scope == 3 or @item.scope == 5
  1009. # Start actor selection
  1010. start_actor_select
  1011. # If effect scope is not single
  1012. else
  1013. # End item selection
  1014. end_item_select
  1015. # Start phase 4
  1016. start_phase4
  1017. end
  1018. return
  1019. end
  1020. end
  1021. #--------------------------------------------------------------------------
  1022. # * End Item Selection
  1023. #--------------------------------------------------------------------------
  1024. def end_item_select
  1025. # Dispose of item window
  1026. @item_window.dispose
  1027. @item_window = nil
  1028. # Dispose of help window
  1029. @item_help.dispose
  1030. @item_help = nil
  1031. # Retrieve command ring
  1032. @command_ring.toggle_visibility
  1033. @command_ring.toggle_activity
  1034. end
  1035. #--------------------------------------------------------------------------
  1036. # * Start Enemy Selection
  1037. #--------------------------------------------------------------------------
  1038. def start_enemy_select
  1039. # Make Ambiance Field the help window
  1040. @help_window = Ambiance_Field.new
  1041. # Make enemy arrow
  1042. @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
  1043. # Associate help window
  1044. @enemy_arrow.help_window = @help_window
  1045. @enemy_arrow.update
  1046. # Virtualize next action turn
  1047. @action_system.update_order
  1048. @action_system.update_coordinates
  1049. end
  1050. #--------------------------------------------------------------------------
  1051. # * Frame Update (actor command phase : enemy selection)
  1052. #--------------------------------------------------------------------------
  1053. def update_phase3_enemy_select
  1054. # Update enemy arrow
  1055. @enemy_arrow.update
  1056. # If B button was pressed
  1057. if Input.trigger?(Input::B)
  1058. # Play cancel SE
  1059. $game_system.se_play($data_system.cancel_se)
  1060. # Restore old Action Meter
  1061. @active_battler.action_meter = @current_am if @command_ring.command == 'Attack'
  1062. # End enemy selection
  1063. end_enemy_select
  1064. # End virtualization
  1065. if @command_ring.command == 'Attack'
  1066. @action_system.update_order
  1067. @action_system.update_coordinates(true)
  1068. end
  1069. # Retrieve skill window
  1070. if @skill_window != nil
  1071. @skill_window.visible = @skill_help.visible = true
  1072. # Retrieve item window
  1073. elsif @item_window != nil
  1074. @item_window.visible = @item_help.visible = true
  1075. end
  1076. return
  1077. end
  1078. # If C button was pressed
  1079. if Input.trigger?(Input::C)
  1080. # Play decision SE
  1081. $game_system.se_play($data_system.decision_se)
  1082. # Set action
  1083. @active_battler.current_action.target_index = @enemy_arrow.index
  1084. # End enemy selection
  1085. end_enemy_select
  1086. # If skill window is showing
  1087. if @skill_window != nil
  1088. # End skill selection
  1089. end_skill_select
  1090. end
  1091. # If item window is showing
  1092. if @item_window != nil
  1093. # End item selection
  1094. end_item_select
  1095. end
  1096. # Switch to action phase
  1097. start_phase4
  1098. end
  1099. end
  1100. #--------------------------------------------------------------------------
  1101. # * End Enemy Selection
  1102. #--------------------------------------------------------------------------
  1103. def end_enemy_select
  1104. # Dispose of enemy arrow
  1105. @enemy_arrow.dispose
  1106. @enemy_arrow = nil
  1107. # Dispose of Ambiance Field
  1108. @help_window.dispose
  1109. @help_window = nil
  1110. # If command is [fight]
  1111. if @command_ring.command == 'Attack'
  1112. # Enable command ring
  1113. @command_ring.toggle_visibility
  1114. @command_ring.toggle_activity
  1115. end
  1116. end
  1117. #--------------------------------------------------------------------------
  1118. # * Start Actor Selection
  1119. #--------------------------------------------------------------------------
  1120. def start_actor_select
  1121. # Make Ambiance Field the help window
  1122. @help_window = Ambiance_Field.new
  1123. # Make actor arrow
  1124. @actor_arrow = Arrow_Actor.new(@spriteset.viewport1)
  1125. # Associate help window
  1126. @actor_arrow.help_window = @help_window
  1127. @actor_arrow.update
  1128. # Virtualize next action turn
  1129. @action_system.update_order
  1130. @action_system.update_coordinates
  1131. end
  1132. #--------------------------------------------------------------------------
  1133. # * Frame Update (actor command phase : actor selection)
  1134. #--------------------------------------------------------------------------
  1135. def update_phase3_actor_select
  1136. # Update actor arrow
  1137. @actor_arrow.update
  1138. # If B button was pressed
  1139. if Input.trigger?(Input::B)
  1140. # Play cancel SE
  1141. $game_system.se_play($data_system.cancel_se)
  1142. # Restore old Action Meter
  1143. @active_battler.action_meter = @current_am
  1144. # End actor selection
  1145. end_actor_select
  1146. # End virtualization
  1147. @action_system.update_order
  1148. @action_system.update_coordinates(true)
  1149. # Retrieve skill window
  1150. if @skill_window != nil
  1151. @skill_window.visible = @skill_help.visible = true
  1152. # Retrieve item window
  1153. elsif @item_window != nil
  1154. @item_window.visible = @item_help.visible = true
  1155. end
  1156. return
  1157. end
  1158. # If C button was pressed
  1159. if Input.trigger?(Input::C)
  1160. # Play decision SE
  1161. $game_system.se_play($data_system.decision_se)
  1162. # Set action
  1163. @active_battler.current_action.target_index = @actor_arrow.index
  1164. # End actor selection
  1165. end_actor_select
  1166. # If skill window is showing
  1167. if @skill_window != nil
  1168. # End skill selection
  1169. end_skill_select
  1170. end
  1171. # If item window is showing
  1172. if @item_window != nil
  1173. # End item selection
  1174. end_item_select
  1175. end
  1176. # Switch to action phase
  1177. start_phase4
  1178. end
  1179. end
  1180. #--------------------------------------------------------------------------
  1181. # * End Actor Selection
  1182. #--------------------------------------------------------------------------
  1183. def end_actor_select
  1184. # Dispose of actor arrow
  1185. @actor_arrow.dispose
  1186. @actor_arrow = nil
  1187. # Dispose of Ambiance Field
  1188. @help_window.dispose
  1189. @help_window = nil
  1190. end
  1191. #--------------------------------------------------------------------------
  1192. # * Start Main Phase
  1193. #--------------------------------------------------------------------------
  1194. def start_phase4
  1195. # Shift to phase 4
  1196. @phase = 4
  1197. # Switch Reyvateil ring mode
  1198. @reyvateil_menu = 'delayed' unless $game_temp.forcing_battler != nil
  1199. # Destroy Command Ring
  1200. if @command_ring != nil
  1201. @command_ring.dispose
  1202. @command_ring = nil
  1203. end
  1204. # Clear skill and item
  1205. @skill = @item = nil
  1206. # Turn count
  1207. $game_temp.battle_turn += 1
  1208. # Switch to phase 1 if @active_battler is nil
  1209. if @active_battler == nil
  1210. start_phase1
  1211. return
  1212. end
  1213. # Right shift when enemy attack
  1214. @action_system.right_shift if @active_battler.is_a?(Game_Enemy)
  1215. # Blink
  1216. @active_battler.blink = false
  1217. # Create help window
  1218. @help_window = Action_Help.new(@spriteset.viewport5, @active_battler.current_action)
  1219. # Set main phase flag
  1220. $game_temp.battle_main_phase = true
  1221. # Shift to step 1
  1222. @phase4_step = 1
  1223. end
  1224. #--------------------------------------------------------------------------
  1225. # * Frame Update (main phase)
  1226. #--------------------------------------------------------------------------
  1227. def update_phase4
  1228. case @phase4_step
  1229. when 1
  1230. update_phase4_step1
  1231. when 2
  1232. update_phase4_step2
  1233. when 3
  1234. update_phase4_step3
  1235. when 4
  1236. update_phase4_step4
  1237. when 5
  1238. update_phase4_step5
  1239. when 6
  1240. update_phase4_step6
  1241. end
  1242. end
  1243. #--------------------------------------------------------------------------
  1244. # * Frame Update (main phase step 1 : action preparation)
  1245. #--------------------------------------------------------------------------
  1246. def update_phase4_step1
  1247. # Determine win/loss
  1248. if judge
  1249. # If won, or if lost : end method
  1250. return
  1251. end
  1252. # Initialize animation ID and common event ID
  1253. @animation1_id = 0
  1254. @animation2_id = 0
  1255. @common_event_id = 0
  1256. # Slip damage
  1257. if @active_battler.hp > 0 and @active_battler.slip_damage?
  1258. @active_battler.slip_damage_effect
  1259. @active_battler.damage_pop = true
  1260. end
  1261. # Natural removal of states
  1262. @active_battler.remove_states_auto
  1263. # Refresh status window (active battler only)
  1264. @status_windows[@active_battler.index].refresh if @active_battler.is_a?(Game_Actor)
  1265. # Shift to step 2
  1266. @phase4_step = 2
  1267. end
  1268. #--------------------------------------------------------------------------
  1269. # * Frame Update (main phase step 2 : start action)
  1270. #--------------------------------------------------------------------------
  1271. def update_phase4_step2
  1272. # If not a forcing action
  1273. unless @active_battler.current_action.forcing
  1274. # If restriction is [normal attack enemy] or [normal attack ally]
  1275. if @active_battler.restriction == 2 or @active_battler.restriction == 3
  1276. # Set attack as an action
  1277. @active_battler.current_action.kind = 0
  1278. @active_battler.current_action.basic = 0
  1279. end
  1280. # If restriction is [cannot perform action]
  1281. if @active_battler.restriction == 4
  1282. # Clear battler being forced into action
  1283. $game_temp.forcing_battler = nil
  1284. # Shift to step 1
  1285. @phase4_step = 1
  1286. return
  1287. end
  1288. end
  1289. # Clear target battlers
  1290. @target_battlers = []
  1291. # Branch according to each action
  1292. case @active_battler.current_action.kind
  1293. when 0 # basic
  1294. make_basic_action_result
  1295. when 1 # skill
  1296. make_skill_action_result
  1297. when 2 # item
  1298. make_item_action_result
  1299. end
  1300. # Shift to step 3
  1301. @phase4_step = 3
  1302. end
  1303. #--------------------------------------------------------------------------
  1304. # * Make Basic Action Results
  1305. #--------------------------------------------------------------------------
  1306. def make_basic_action_result
  1307. # If attack
  1308. if @active_battler.current_action.basic == 0
  1309. # Set animation ID
  1310. @animation1_id = @active_battler.animation1_id
  1311. @animation2_id = @active_battler.animation2_id
  1312. # If action battler is enemy
  1313. if @active_battler.is_a?(Game_Enemy)
  1314. if @active_battler.restriction == 3
  1315. target = $game_troop.random_target_enemy
  1316. elsif @active_battler.restriction == 2
  1317. target = $game_party.random_target_actor
  1318. else
  1319. index = @active_battler.current_action.target_index
  1320. target = $game_party.smooth_target_actor(index)
  1321. end
  1322. end
  1323. # If action battler is actor
  1324. if @active_battler.is_a?(Game_Actor)
  1325. if @active_battler.restriction == 3
  1326. target = $game_party.random_target_actor
  1327. elsif @active_battler.restriction == 2
  1328. target = $game_troop.random_target_enemy
  1329. else
  1330. index = @active_battler.current_action.target_index
  1331. target = $game_troop.smooth_target_enemy(index)
  1332. end
  1333. end
  1334. # Set array of targeted battlers
  1335. @target_battlers = [target]
  1336. # Apply normal attack results
  1337. @target_battlers.each {|target| target.attack_effect(@active_battler)}
  1338. return
  1339. end
  1340. # If escape
  1341. if @active_battler.is_a?(Game_Enemy) and
  1342. @active_battler.current_action.basic == 2
  1343. # Escape
  1344. @active_battler.escape
  1345. return
  1346. end
  1347. # If doing nothing
  1348. if @active_battler.current_action.basic == 3
  1349. # Clear battler being forced into action
  1350. $game_temp.forcing_battler = nil
  1351. # Shift to step 1
  1352. @phase4_step = 5
  1353. return
  1354. end
  1355. end
  1356. #--------------------------------------------------------------------------
  1357. # * Make Skill Action Results
  1358. #--------------------------------------------------------------------------
  1359. def make_skill_action_result
  1360. # Get skill
  1361. @skill = $data_skills[@active_battler.current_action.skill_id]
  1362. # Set animation ID
  1363. @animation1_id = @skill.animation1_id
  1364. @animation2_id = @skill.animation2_id
  1365. # Removes HP, SP or Harmonics
  1366. if KreadCFG::HarmoOverdriveSkills.include?(@skill.id) && @active_battler.is_a?(Game_Actor)
  1367. @reyvateil.harmonics = 0
  1368. $game_party.harmonics = 0
  1369. end
  1370. if $game_system.vanguards_sp || @active_battler.is_a?(Game_Enemy)
  1371. @active_battler.sp -= @skill.sp_cost
  1372. else
  1373. @active_battler.hp =
  1374. [(@active_battler.hp - (@skill.sp_cost * @active_battler.maxhp) / 100), 0].max
  1375. end
  1376. # Set command event ID
  1377. @common_event_id = @skill.common_event_id
  1378. # Set target battlers
  1379. set_target_battlers(@skill.scope)
  1380. # Check skill hit number
  1381. hit_nb = KreadCFG.skill_hits(skill.id)
  1382. # If number is 1, apply the effect once
  1383. if hit_nb == 1
  1384. @target_battlers.each {|target| target.skill_effect(@active_battler, @skill)}
  1385. # Else, apply the effect for each hit
  1386. else
  1387. for i in (1..hit_nb)
  1388. for target in @target_battlers
  1389. target.skill_effect(@active_battler, @skill, (i - 1))
  1390. end
  1391. end
  1392. end
  1393. end
  1394. #--------------------------------------------------------------------------
  1395. # * Make Item Action Results
  1396. #--------------------------------------------------------------------------
  1397. def make_item_action_result
  1398. # Get item
  1399. @item = $data_items[@active_battler.current_action.item_id]
  1400. # If unable to use due to items running out
  1401. unless $game_party.item_can_use?(@item.id)
  1402. # Shift to step 1
  1403. @phase4_step = 1
  1404. return
  1405. end
  1406. # If consumable
  1407. if @item.consumable
  1408. # Decrease used item by 1
  1409. $game_party.lose_item(@item.id, 1)
  1410. end
  1411. # Set animation ID
  1412. @animation1_id = @item.animation1_id
  1413. @animation2_id = @item.animation2_id
  1414. # Set common event ID
  1415. @common_event_id = @item.common_event_id
  1416. # Decide on target
  1417. index = @active_battler.current_action.target_index
  1418. target = $game_party.smooth_target_actor(index)
  1419. # Set targeted battlers
  1420. set_target_battlers(@item.scope)
  1421. # Apply item effect
  1422. for target in @target_battlers
  1423. target.item_effect(@item)
  1424. end
  1425. end
  1426. #--------------------------------------------------------------------------
  1427. # * Make Song Magic Action Results
  1428. #--------------------------------------------------------------------------
  1429. def make_song_action_result
  1430. # Get skill
  1431. @skill = $data_skills[@reyvateil.current_action.skill_id]
  1432. # Set animation ID
  1433. @animation1_id = @skill.animation1_id
  1434. @animation2_id = @skill.animation2_id
  1435. # Refresh status window
  1436. @status_windows[@reyvateil.index].refresh
  1437. # Set command event ID
  1438. @common_event_id = @skill.common_event_id
  1439. # Set target battlers
  1440. set_target_battlers(@skill.scope)
  1441. # Check skill hit number
  1442. hit_nb = KreadCFG.skill_hits(skill.id)
  1443. # If number is 1, apply the effect once
  1444. if hit_nb == 1
  1445. @target_battlers.each {|target|
  1446. target.song_effect(@reyvateil, @skill)
  1447. target.damage_pop = true if @reyvateil.song_blue
  1448. }
  1449. # Else, apply the effect for each hit
  1450. else
  1451. for i in (1..hit_nb)
  1452. for target in @target_battlers
  1453. target.song_effect(@reyvateil, @skill, (i - 1))
  1454. target.damage_pop = true if @reyvateil.song_blue
  1455. end
  1456. end
  1457. end
  1458. end
  1459. #--------------------------------------------------------------------------
  1460. # * Frame Update (main phase step 3 : animation for action performer)
  1461. #--------------------------------------------------------------------------
  1462. def update_phase4_step3
  1463. # Animation for action performer (if ID is 0, then white flash)
  1464. if @animation1_id == 0
  1465. @active_battler.white_flash = true
  1466. else
  1467. @active_battler.animation_id = @animation1_id
  1468. @active_battler.animation_hit = true
  1469. end
  1470. # Refresh status window (active battler only)
  1471. @status_windows[@active_battler.index].refresh if @active_battler.is_a?(Game_Actor)
  1472. # Shift to step 4
  1473. @phase4_step = 4
  1474. end
  1475. #--------------------------------------------------------------------------
  1476. # * Frame Update (main phase step 4 : animation for target)
  1477. #--------------------------------------------------------------------------
  1478. def update_phase4_step4
  1479. # Animation for target
  1480. @target_battlers.each {|target|
  1481. target.animation_id = @animation2_id
  1482. target.animation_hit = (target.damage[0] != 'Miss')
  1483. }
  1484. # Shift to step 5
  1485. @phase4_step = 5
  1486. end
  1487. #--------------------------------------------------------------------------
  1488. # * Frame Update (main phase step 5 : damage display)
  1489. #--------------------------------------------------------------------------
  1490. def update_phase4_step5
  1491. # Destroy help window
  1492. @help_window.dispose
  1493. @help_window = nil
  1494. # Display damage
  1495. @target_battlers.each {|target|
  1496. if target.damage.size > 0
  1497. target.damage_pop = true
  1498. end
  1499. }
  1500. # Refresh status windows
  1501. @status_windows.each {|win| win.refresh}
  1502. # Refreshes Action Meters
  1503. @action_system.update_order
  1504. @action_system.update_coordinates
  1505. if $game_temp.battle_turn % ($game_party.actors.size + $game_troop.enemies.size - 1) == 0
  1506. @blue_launch = true if @reyvateil != nil && @reyvateil.song_blue
  1507. end
  1508. # Wait 12 frames
  1509. @wait_count = 12
  1510. # Clear the forcing battler
  1511. $game_temp.forcing_battler = nil
  1512. # Shift to phase 1
  1513. start_phase1
  1514. # Switch to phase 6
  1515. if @delayed_command
  1516. start_phase6 unless fake_judge
  1517. @delayed_command = false
  1518. end
  1519. end
  1520. #--------------------------------------------------------------------------
  1521. # * Start After Battle Phase
  1522. #--------------------------------------------------------------------------
  1523. def start_phase5
  1524. # Shift to phase 5
  1525. @phase = 5
  1526. # Play battle end ME
  1527. $game_system.me_play($game_system.battle_end_me)
  1528. # Return to BGM before battle started
  1529. $game_system.bgm_play($game_temp.map_bgm)
  1530. # Initialize EXP, amount of gold, and treasure
  1531. exp = 0
  1532. gold = 0
  1533. treasures = []
  1534. # Loop
  1535. for enemy in $game_troop.enemies
  1536. # If enemy is not hidden
  1537. unless enemy.hidden
  1538. # Add EXP and amount of gold obtained
  1539. exp += enemy.exp
  1540. gold += enemy.gold
  1541. # Determine if treasure appears
  1542. if rand(100) < enemy.treasure_prob
  1543. if enemy.item_id > 0
  1544. treasures.push($data_items[enemy.item_id])
  1545. end
  1546. if enemy.weapon_id > 0
  1547. treasures.push($data_weapons[enemy.weapon_id])
  1548. end
  1549. if enemy.armor_id > 0
  1550. treasures.push($data_armors[enemy.armor_id])
  1551. end
  1552. end
  1553. end
  1554. end
  1555. # Treasure is limited to a maximum of 6 items
  1556. treasures = treasures[0..5]
  1557. # Obtaining EXP
  1558. @levelup_sprites = []
  1559. for i in 0...$game_party.actors.size
  1560. actor = $game_party.actors[i]
  1561. @levelup_sprites.push(Sprite_LevelUP.new(@spriteset.viewport5, actor))
  1562. if actor.cant_get_exp? == false
  1563. last_level = actor.level
  1564. actor.exp += exp
  1565. if actor.level > last_level
  1566. @levelup_sprites[actor.index].visible = true
  1567. end
  1568. end
  1569. end
  1570. # Obtaining gold
  1571. $game_party.gain_gold(gold)
  1572. # Obtaining treasure
  1573. for item in treasures
  1574. case item
  1575. when RPG::Item
  1576. $game_party.gain_item(item.id, 1)
  1577. when RPG::Weapon
  1578. $game_party.gain_weapon(item.id, 1)
  1579. when RPG::Armor
  1580. $game_party.gain_armor(item.id, 1)
  1581. end
  1582. end
  1583. # Make battle result window
  1584. @result_window = Window_BattleResult.new(exp, gold, treasures)
  1585. # Set wait count
  1586. @phase5_wait_count = 100
  1587. end
  1588. #--------------------------------------------------------------------------
  1589. # * Frame Update (after battle phase)
  1590. #--------------------------------------------------------------------------
  1591. def update_phase5
  1592. # If wait count is larger than 0
  1593. if @phase5_wait_count > 0
  1594. # Decrease wait count
  1595. @phase5_wait_count -= 1
  1596. # If wait count reaches 0
  1597. if @phase5_wait_count == 0
  1598. # Show result window
  1599. @result_window.visible = true
  1600. # Clear main phase flag
  1601. $game_temp.battle_main_phase = false
  1602. end
  1603. return
  1604. end
  1605. # If C button was pressed
  1606. if Input.trigger?(Input::C)
  1607. # Battle ends
  1608. battle_end(0)
  1609. end
  1610. end
  1611. #--------------------------------------------------------------------------
  1612. # * Start Reyvateil Command Phase
  1613. #--------------------------------------------------------------------------
  1614. def start_phase6
  1615. # Shift to phase 6
  1616. @phase = 6
  1617. # Blink
  1618. @reyvateil.blink = true
  1619. # Set action meter to max
  1620. @reyvateil.action_meter = 1000
  1621. # Create battler icon
  1622. @action_system.insert_reyvateil
  1623. # Make Reyvateil Command sprite invisible
  1624. @reyvateil_command.visible = false
  1625. # Prepare action
  1626. @song_activate = false
  1627. @wait_count = 10
  1628. end
  1629. #--------------------------------------------------------------------------
  1630. # * Frame Update (Reyvateil command phase)
  1631. #--------------------------------------------------------------------------
  1632. def update_phase6
  1633. # Create Reyvateil Command Ring
  1634. if @reyvateil_ring == nil
  1635. @reyvateil_ring = Command_Ring.new(@reyvateil)
  1636. end
  1637. # Update Song activation
  1638. if @song_activate
  1639. update_phase6_song_activation
  1640. # Update Song selection
  1641. elsif @song_window != nil
  1642. update_phase6_song_select
  1643. # Update Reyvateil ring
  1644. elsif @reyvateil_ring != nil
  1645. update_phase6_reyvateil_ring
  1646. end
  1647. end
  1648. #--------------------------------------------------------------------------
  1649. # * Frame Update (phase 6: Song Magic activation)
  1650. #--------------------------------------------------------------------------
  1651. def update_phase6_song_activation
  1652. # Supress animations
  1653. @reyvateil.loop_animation_id = 0
  1654. @reyvateil.song_chant = false
  1655. # Make skill result
  1656. @target_battlers = []
  1657. @active_battler = @reyvateil
  1658. @skill = $data_skills[@active_battler.current_action.skill_id]
  1659. set_target_battlers(@skill.scope)
  1660. make_song_action_result
  1661. @target_battlers.each {|target|
  1662. target.animation_id = @animation2_id
  1663. target.animation_hit = (target.damage[0] != 'Miss')
  1664. }
  1665. @reyvateil.animation_id = KreadCFG::SongActivateAnimID
  1666. @active_battler = nil
  1667. # Destroy Burst
  1668. @burst_gauge.dispose
  1669. @burst_gauge = nil
  1670. @reyvateil.burst_value = 0
  1671. end_reyvateil_command
  1672. end
  1673. #--------------------------------------------------------------------------
  1674. # * Frame Update (phase 6: Song Magic activation - Blue)
  1675. #--------------------------------------------------------------------------
  1676. def update_phase6_blue_magic
  1677. # Make skill result
  1678. prev_ab = @active_battler
  1679. @target_battlers = []
  1680. @active_battler = @reyvateil
  1681. @skill = $data_skills[@active_battler.current_action.skill_id]
  1682. set_target_battlers(@skill.scope)
  1683. make_song_action_result
  1684. @target_battlers.each {|target|
  1685. target.animation_id = @animation2_id
  1686. target.animation_hit = (target.damage[0] != 'Miss')
  1687. }
  1688. @status_windows.each {|win| win.refresh}
  1689. @active_battler = prev_ab
  1690. end
  1691. #--------------------------------------------------------------------------
  1692. # * Frame Update (phase 6: Song Magic selection)
  1693. #--------------------------------------------------------------------------
  1694. def update_phase6_song_select
  1695. # Update window
  1696. @song_window.update
  1697. # B: Return to Ring
  1698. if Input.trigger?(Input::B)
  1699. # Play SE
  1700. $game_system.se_play($data_system.cancel_se)
  1701. # Retrieve command ring
  1702. @reyvateil_ring.toggle_visibility
  1703. @reyvateil_ring.toggle_activity
  1704. # Destroy song window
  1705. @song_window.dispose
  1706. @song_window = nil
  1707. # Destroy help window
  1708. @help_window.dispose
  1709. @help_window = nil
  1710. return
  1711. end
  1712. # C: Validate Song Magic
  1713. if Input.trigger?(Input::C)
  1714. # Play SE
  1715. $game_system.se_play($data_system.decision_se)
  1716. # Set battler action
  1717. @reyvateil.song_chant = true
  1718. @reyvateil.song_blue = [3, 4, 5, 6].include?(@song_window.skill.scope)
  1719. @reyvateil.burst_value = 0
  1720. @reyvateil.current_action.kind = 1
  1721. @reyvateil.current_action.skill_id = @song_window.skill.id
  1722. # Set animation and loop animation
  1723. @reyvateil.animation_id = @song_window.skill.animation1_id
  1724. @reyvateil.loop_animation_id = KreadCFG::SongMagicChargeAnim[@song_window.skill.id]
  1725. @reyvateil.loop_animation_id = 0 if @reyvateil.loop_animation_id == nil
  1726. # Create Burst Gauge
  1727. if @burst_gauge == nil
  1728. @burst_gauge = Burst_Gauge.new(@spriteset.viewport5, @reyvateil)
  1729. end
  1730. @blue_launch = @reyvateil.song_blue
  1731. # Return to previous phase
  1732. end_reyvateil_command
  1733. return
  1734. end
  1735. end
  1736. #--------------------------------------------------------------------------
  1737. # * Frame Update (phase 6: Reyvateil Command selection)
  1738. #--------------------------------------------------------------------------
  1739. def update_phase6_reyvateil_ring
  1740. # Update ring
  1741. @reyvateil_ring.update
  1742. # B: Cancels command
  1743. if Input.trigger?(Input::B)
  1744. # Play SE
  1745. $game_system.se_play($data_system.cancel_se)
  1746. # Return to previous phase
  1747. end_reyvateil_command
  1748. end
  1749. # C: Validate command
  1750. if Input.trigger?(Input::C)
  1751. # Branch by command
  1752. case @reyvateil_ring.command
  1753. when KreadCFG::SongMagicName
  1754. # Play decision SE
  1755. $game_system.se_play($data_system.decision_se)
  1756. # Hide command ring
  1757. @reyvateil_ring.toggle_visibility
  1758. @reyvateil_ring.toggle_activity
  1759. # Create Song Magic window and help window
  1760. @help_window = Window_SongHelp.new
  1761. @song_window = Window_BattleSkill.new(@reyvateil)
  1762. @song_window.help_window = @help_window
  1763. when KreadCFG::SongActivate
  1764. # Do nothing if no song is chanted
  1765. unless (@reyvateil.song_chant && !@reyvateil.song_blue)
  1766. $game_system.se_play($data_system.buzzer_se)
  1767. return
  1768. end
  1769. # Activates the song
  1770. @song_activate = true
  1771. when KreadCFG::SongCancel
  1772. # Do nothing if no song is chanted
  1773. unless @reyvateil.song_chant
  1774. $game_system.se_play($data_system.buzzer_se)
  1775. return
  1776. end
  1777. # Play animation
  1778. @reyvateil.animation_id = KreadCFG::SongCancelAnimID
  1779. # Destroy Burst
  1780. @burst_gauge.dispose
  1781. @burst_gauge = nil
  1782. # Clear action
  1783. @reyvateil.song_chant = false
  1784. @reyvateil.song_blue = false
  1785. @reyvateil.loop_animation_id = 0
  1786. @reyvateil.current_action.clear
  1787. end_reyvateil_command
  1788. when 'Flee'
  1789. # Play escape SE
  1790. $game_system.se_play($data_system.escape_se)
  1791. # Return to BGM before battle started
  1792. $game_system.bgm_play($game_temp.map_bgm)
  1793. # Battle ends
  1794. battle_end(1)
  1795. end
  1796. end
  1797. end
  1798. #--------------------------------------------------------------------------
  1799. # * End Reyvateil Command
  1800. #--------------------------------------------------------------------------
  1801. def end_reyvateil_command
  1802. @reyvateil_command.visible = true
  1803. @reyvateil.blink = false
  1804. # Destroy all
  1805. @reyvateil_ring.dispose
  1806. @reyvateil_ring = nil
  1807. if @song_window != nil
  1808. @song_window.dispose
  1809. @song_window = nil
  1810. end
  1811. if @help_window != nil
  1812. @help_window.dispose
  1813. @help_window = nil
  1814. end
  1815. @action_system.remove_reyvateil
  1816. if @previous_phase == nil
  1817. start_phase1
  1818. else
  1819. @phase = @previous_phase
  1820. end
  1821. end
  1822. #--------------------------------------------------------------------------
  1823. end
  1824.  
  1825. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1826. # Ar Tonelico Custom Battle System
  1827. # Author: Kread-EX
  1828. # Version 1.1
  1829. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1830.  
  1831. #===========================================================
  1832. # ** Sprite
  1833. #------------------------------------------------------------------------------
  1834. # Basic sprite class, enhanced with moving capabilities
  1835. #===========================================================
  1836.  
  1837. class Sprite
  1838. #--------------------------------------------------------------------------
  1839. # * Public Instance Variables
  1840. #--------------------------------------------------------------------------
  1841. attr_reader :x_destination
  1842. #--------------------------------------------------------------------------
  1843. # * Object Initialization
  1844. #--------------------------------------------------------------------------
  1845. alias_method :krx_move_sprite_init, :initialize
  1846. def initialize(viewport = nil)
  1847. krx_move_sprite_init(viewport) # Original call
  1848. # When these two variables are different than the coordinates, the sprite moves.
  1849. @x_destination = nil
  1850. @y_destination = nil
  1851. # Coordinates incrementation.
  1852. @increment = 0
  1853. end
  1854. #--------------------------------------------------------------------------
  1855. # * Horizontal move
  1856. #--------------------------------------------------------------------------
  1857. def x_slide(x_dest, inc)
  1858. @x_destination = x_dest
  1859. @increment= inc
  1860. end
  1861. #--------------------------------------------------------------------------
  1862. # * Vertical move
  1863. #--------------------------------------------------------------------------
  1864. def y_slide(y_dest, inc)
  1865. @y_destination = y_dest
  1866. @increment = inc
  1867. end
  1868. #--------------------------------------------------------------------------
  1869. # * Frame Update
  1870. #--------------------------------------------------------------------------
  1871. alias_method :krx_move_sprite_update, :update
  1872. def update
  1873. update_x_slide
  1874. update_y_slide
  1875. return if self.is_sliding?
  1876. krx_move_sprite_update # Original call
  1877. end
  1878. #--------------------------------------------------------------------------
  1879. # * Update horizontal motion
  1880. #--------------------------------------------------------------------------
  1881. def update_x_slide
  1882. return if @x_destination == nil
  1883. if @x_destination > self.x
  1884. self.x = [self.x + @increment, @x_destination].min
  1885. else
  1886. self.x = [self.x - @increment, @x_destination].max
  1887. end
  1888. @x_destination = nil if @x_destination == self.x
  1889. end
  1890. #--------------------------------------------------------------------------
  1891. # * Update vertical motion
  1892. #--------------------------------------------------------------------------
  1893. def update_y_slide
  1894. return if @y_destination == nil
  1895. if @y_destination > self.y
  1896. self.y = [self.y + @increment, @y_destination].min
  1897. else
  1898. self.y = [self.y - @increment, @y_destination].max
  1899. end
  1900. @y_destination = nil if @y_destination == self.y
  1901. end
  1902. #--------------------------------------------------------------------------
  1903. # * Checks if moving
  1904. #--------------------------------------------------------------------------
  1905. def is_sliding?
  1906. return (@x_destination != nil || @y_destination != nil)
  1907. end
  1908. #--------------------------------------------------------------------------
  1909. end
  1910.  
  1911. #===========================================================
  1912. # ** RPG::Sprite
  1913. #------------------------------------------------------------------------------
  1914. # Basic RGSS class, enhanced to display damage with image files and processing multi-hit skills.
  1915. #===========================================================
  1916.  
  1917. class RPG::Sprite
  1918. #--------------------------------------------------------------------------
  1919. # * Object Initialization
  1920. #--------------------------------------------------------------------------
  1921. def initialize(viewport = nil)
  1922. super(viewport)
  1923. @_whiten_duration = 0
  1924. @_appear_duration = 0
  1925. @_escape_duration = 0
  1926. @_collapse_duration = 0
  1927. @_damage_sprites = []
  1928. @_damage_durations = []
  1929. @_animation_duration = 0
  1930. @_blink = false
  1931. end
  1932. #--------------------------------------------------------------------------
  1933. # * Dispose all
  1934. #--------------------------------------------------------------------------
  1935. def dispose
  1936. @_damage_sprites.each {|spr| dispose_damage(spr)}
  1937. dispose_animation
  1938. dispose_loop_animation
  1939. super
  1940. end
  1941. #--------------------------------------------------------------------------
  1942. # * Determine if effects are displayed
  1943. #--------------------------------------------------------------------------
  1944. def effect?
  1945. @_whiten_duration > 0 ||
  1946. @_appear_duration > 0 ||
  1947. @_escape_duration > 0 ||
  1948. @_collapse_duration > 0 ||
  1949. @_animation_duration > 0
  1950. end
  1951. #--------------------------------------------------------------------------
  1952. # * Dispose the damage sprites
  1953. #--------------------------------------------------------------------------
  1954. def dispose_damage(sprite)
  1955. if sprite != nil
  1956. sprite.dispose
  1957. @_damage_durations.delete_at(@_damage_sprites.index(sprite))
  1958. @_damage_durations.compact!
  1959. @_damage_sprites.delete(sprite)
  1960. @_damage_sprites.compact!
  1961. end
  1962. end
  1963. #--------------------------------------------------------------------------
  1964. # * Display damage
  1965. #--------------------------------------------------------------------------
  1966. def damage(value)
  1967. # Creates the bitmap
  1968. bitmap = Bitmap.new(519, 124)
  1969. bitmap.draw_damage(value) unless value == ''
  1970. # And draw it on the sprite
  1971. @_damage_sprites.push(::Sprite.new(self.viewport))
  1972. @_damage_sprites[-1].bitmap = bitmap
  1973. @_damage_sprites[-1].ox = 47 + self.viewport.ox
  1974. @_damage_sprites[-1].oy = 32
  1975. @_damage_sprites[-1].x = self.x + self.viewport.rect.x
  1976. @_damage_sprites[-1].y = self.y - self.oy / 2 + self.viewport.rect.y
  1977. @_damage_sprites[-1].z = 3000
  1978. # Setup damage durations
  1979. @_damage_durations[@_damage_sprites.index(@_damage_sprites[-1])] = 40
  1980. end
  1981. #--------------------------------------------------------------------------
  1982. # * Frame Update
  1983. #--------------------------------------------------------------------------
  1984. def update
  1985. super
  1986. # Update white flash
  1987. if @_whiten_duration > 0
  1988. @_whiten_duration -= 1
  1989. self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  1990. end
  1991. # Update enemy appearance
  1992. if @_appear_duration > 0
  1993. @_appear_duration -= 1
  1994. self.opacity = (16 - @_appear_duration) * 16
  1995. end
  1996. # Update escape
  1997. if @_escape_duration > 0
  1998. @_escape_duration -= 1
  1999. self.opacity = 256 - (32 - @_escape_duration) * 10
  2000. end
  2001. # Update collapse animation
  2002. if @_collapse_duration > 0
  2003. @_collapse_duration -= 1
  2004. self.opacity = 256 - (48 - @_collapse_duration) * 6
  2005. end
  2006. # Update damage sprites
  2007. @_damage_sprites.each {|sprite|
  2008. if @_damage_durations[@_damage_sprites.index(sprite)] > 0
  2009. @_damage_durations[@_damage_sprites.index(sprite)] -= 1
  2010. sprite.y -= 3
  2011. sprite.opacity -= 8
  2012. if @_damage_durations[@_damage_sprites.index(sprite)] == 0
  2013. dispose_damage(sprite)
  2014. end
  2015. end
  2016. }
  2017. # Update animation
  2018. if @_animation != nil && (Graphics.frame_count % 2 == 0)
  2019. @_animation_duration -= 1
  2020. update_animation
  2021. end
  2022. # Update state animation
  2023. if @_loop_animation != nil && (Graphics.frame_count % 2 == 0)
  2024. update_loop_animation
  2025. @_loop_animation_index += 1
  2026. @_loop_animation_index %= @_loop_animation.frame_max
  2027. end
  2028. # Update blink for actor command
  2029. if @_blink
  2030. @_blink_count = (@_blink_count + 1) % 32
  2031. if @_blink_count < 16
  2032. alpha = (16 - @_blink_count) * 6
  2033. else
  2034. alpha = (@_blink_count - 16) * 6
  2035. end
  2036. self.color.set(255, 255, 255, alpha)
  2037. end
  2038. # Clear the animation data
  2039. @@_animations.clear
  2040. end
  2041. #--------------------------------------------------------------------------
  2042. end
  2043.  
  2044. #===========================================================
  2045. # ** Sprite_Battler
  2046. #------------------------------------------------------------------------------
  2047. # This sprite is used to display the battler.It observes the Game_Character
  2048. # class and automatically changes sprite conditions.
  2049. #===========================================================
  2050.  
  2051. class Sprite_Battler < RPG::Sprite
  2052. #--------------------------------------------------------------------------
  2053. # * Object Initialization
  2054. # viewport : viewport
  2055. # battler : battler (Game_Battler)
  2056. #--------------------------------------------------------------------------
  2057. alias_method :krx_atcbs_sprite_battler_initialize, :initialize
  2058. def initialize(viewport, battler = nil)
  2059. krx_atcbs_sprite_battler_initialize(viewport, battler)
  2060. @loop_anim_id = 0
  2061. end
  2062. #--------------------------------------------------------------------------
  2063. # * Frame Update
  2064. #--------------------------------------------------------------------------
  2065. def update
  2066. super
  2067. # Quit if battler is nil
  2068. if @battler == nil
  2069. self.bitmap = nil
  2070. loop_animation(nil)
  2071. return
  2072. end
  2073. # If file name or hue are different than current ones
  2074. if @battler.battler_name != @battler_name || @battler.battler_hue != @battler_hue
  2075. # Get and set bitmap
  2076. @battler_name = @battler.battler_name
  2077. @battler_hue = @battler.battler_hue
  2078. self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  2079. @width = bitmap.width
  2080. @height = bitmap.height
  2081. self.ox = @width / 2
  2082. self.oy = @height
  2083. # Change opacity level to 0 when dead or hidden
  2084. self.opacity = 0 if @battler.dead? or @battler.hidden
  2085. end
  2086. # If battler dies when chanting
  2087. if @battler.dead?
  2088. @battler.burst_value = 0
  2089. @battler.song_chant = false
  2090. @battler.loop_animation_id = 0
  2091. end
  2092. # If animation ID is different than current one
  2093. if @battler.damage.size == 0 && @battler.state_animation_id != @state_animation_id
  2094. @state_animation_id = @battler.state_animation_id
  2095. loop_animation($data_animations[@state_animation_id])
  2096. end
  2097. # Song Magic loop animation
  2098. if KreadCFG.is_reyvateil?(@battler) && @battler.loop_animation_id != @loop_anim_id
  2099. @loop_anim_id = @battler.loop_animation_id
  2100. if @battler.loop_animation_id == 0
  2101. loop_animation(nil)
  2102. return
  2103. end
  2104. skill_id = @battler.current_action.skill_id
  2105. if skill_id != 0
  2106. loop_animation($data_animations[KreadCFG::SongMagicChargeAnim[skill_id]])
  2107. else
  2108. loop_animation(nil)
  2109. end
  2110. end
  2111. # Blink
  2112. if @battler.blink
  2113. blink_on
  2114. else
  2115. blink_off
  2116. end
  2117. # If invisible
  2118. unless @battler_visible
  2119. # Appear
  2120. if !@battler.hidden && !@battler.dead? && (@battler.damage.size == 0 || @battler.damage_pop)
  2121. appear
  2122. @battler_visible = true
  2123. end
  2124. end
  2125. # If visible
  2126. if @battler_visible
  2127. # Escape
  2128. if @battler.hidden
  2129. $game_system.se_play($data_system.escape_se)
  2130. escape
  2131. @battler_visible = false
  2132. end
  2133. # White flash
  2134. if @battler.white_flash
  2135. whiten
  2136. @battler.white_flash = false
  2137. end
  2138. # Animation
  2139. if @battler.animation_id != 0
  2140. animation = $data_animations[@battler.animation_id]
  2141. animation(animation, @battler.animation_hit)
  2142. @battler.animation_id = 0
  2143. end
  2144. # Damage
  2145. if @battler.damage_pop
  2146. damage(@battler.damage.shift)
  2147. @battler.critical = false
  2148. @battler.damage_pop = false
  2149. end
  2150. # Collapse
  2151. if @battler.damage.size == 0 && @battler.dead?
  2152. if @battler.is_a?(Game_Enemy)
  2153. $game_system.se_play($data_system.enemy_collapse_se)
  2154. else
  2155. $game_system.se_play($data_system.actor_collapse_se)
  2156. end
  2157. collapse
  2158. @battler_visible = false
  2159. end
  2160. end
  2161. # Set sprite coordinates
  2162. self.x = @battler.screen_x
  2163. self.y = @battler.screen_y
  2164. self.z = @battler.screen_z
  2165. end
  2166. #--------------------------------------------------------------------------
  2167. # * Frame Update: Animation
  2168. #--------------------------------------------------------------------------
  2169. def update_animation
  2170. # Get animation data
  2171. if @_animation_duration > 0
  2172. frame_index = @_animation.frame_max - @_animation_duration
  2173. cell_data = @_animation.frames[frame_index].cell_data
  2174. position = @_animation.position
  2175. animation_set_sprites(@_animation_sprites, cell_data, position)
  2176. # Checks if there is a skill and the skill has multiple hits
  2177. skill = $scene.skill
  2178. if skill != nil && KreadCFG.skill_hits(skill.id) > 1
  2179. # If the frame index match one of the skill timings
  2180. KreadCFG::HitTimings[skill.id].each {|i|
  2181. if frame_index == i
  2182. # Display damage if there is any
  2183. @battler.damage_pop = true if @battler.damage.size > 0
  2184. end
  2185. }
  2186. end
  2187. # Process timings
  2188. @_animation.timings.each {|timing|
  2189. if timing.frame == frame_index
  2190. animation_process_timing(timing, @_animation_hit)
  2191. end
  2192. }
  2193. else
  2194. dispose_animation
  2195. end
  2196. end
  2197. #--------------------------------------------------------------------------
  2198. end
  2199.  
  2200. #===========================================================
  2201. # ** Bitmap
  2202. #------------------------------------------------------------------------------
  2203. # Basic bitmap class, enhanced with various drawing methods.
  2204. #===========================================================
  2205.  
  2206. class Bitmap
  2207. #--------------------------------------------------------------------------
  2208. # * Draws text, but with outline
  2209. #--------------------------------------------------------------------------
  2210. def draw_outlined_text(x, y, width, height, string, align = 0, outline_color = Color.new(0, 0, 0))
  2211. old_color = self.font.color.dup
  2212. self.font.color = outline_color
  2213. self.draw_text(x - 1, y - 1, width + 1, height + 1, string, align)
  2214. self.draw_text(x - 1, y + 1, width + 1, height + 1, string, align)
  2215. self.draw_text(x + 1, y - 1, width + 1, height + 1, string, align)
  2216. self.draw_text(x + 1, y + 1, width + 1, height + 1, string, align)
  2217. self.font.color = old_color
  2218. self.draw_text(x, y, width, height, string, align)
  2219. end
  2220. #--------------------------------------------------------------------------
  2221. # * Draws the damage values
  2222. #--------------------------------------------------------------------------
  2223. def draw_damage(value, element_set = $scene.skill != nil ? $scene.skill.element_set : [])
  2224. # Process numeric values
  2225. if value.is_a?(Numeric)
  2226. # Computes the first digit
  2227. if value != 0
  2228. digit = Math.log10(value.abs).to_i
  2229. # Automatically 0 if the value if 0
  2230. else
  2231. digit = 0
  2232. end
  2233. # Checks if the value if negative
  2234. if value < 0
  2235. filename = 'Damage_Recovery'
  2236. # Checks the element_set to know which file to load
  2237. elsif element_set.include?(KreadCFG::FireElement)
  2238. filename = 'Damage_Fire'
  2239. elsif element_set.include?(KreadCFG::IceElement)
  2240. filename = 'Damage_Ice'
  2241. elsif element_set.include?(KreadCFG::WindElement)
  2242. filename = 'Damage_Wind'
  2243. else
  2244. filename = 'Damage'
  2245. end
  2246. value = value.abs
  2247. # Loads the bitmap
  2248. bmp = RPG::Cache.picture(filename)
  2249. # Transfer one digit after the other until none remains
  2250. x = 0
  2251. while digit >= 0
  2252. self.blt(x, 0, bmp, Rect.new((value / (10 ** digit)) * 47, 0, 47, 62))
  2253. x += 14
  2254. value %= 10 ** digit
  2255. digit -= 1
  2256. end
  2257. # Process string damage
  2258. else
  2259. # Loads the bitmap
  2260. bmp = RPG::Cache.picture("Damage_#{value}")
  2261. self.blt(0, 0, bmp, bmp.rect)
  2262. end
  2263. end
  2264. #--------------------------------------------------------------------------
  2265. end
  2266.  
  2267. #===========================================================
  2268. # ** Spriteset_Battle
  2269. #------------------------------------------------------------------------------
  2270. # This class brings together battle screen sprites. It's used within
  2271. # the Scene_Battle class.
  2272. #===========================================================
  2273.  
  2274. class Spriteset_Battle
  2275. #--------------------------------------------------------------------------
  2276. # * Public Instance Variables
  2277. #--------------------------------------------------------------------------
  2278. attr_reader :viewport5 # interface sprites viewport
  2279. #--------------------------------------------------------------------------
  2280. # * Object Initialization
  2281. #--------------------------------------------------------------------------
  2282. def initialize
  2283. # Make viewports
  2284. @viewport1 = Viewport.new(0, 0, 640, 480)
  2285. @viewport2 = Viewport.new(0, 0, 640, 480)
  2286. @viewport3 = Viewport.new(0, 0, 640, 480)
  2287. @viewport4 = Viewport.new(0, 0, 640, 480)
  2288. @viewport5 = Viewport.new(0, 0, 640, 480)
  2289. @viewport2.z = 101
  2290. @viewport3.z = 200
  2291. @viewport4.z = 5000
  2292. @viewport5.z = 6000
  2293. # Make battleback sprite
  2294. @battleback_sprite = Sprite.new(@viewport1)
  2295. # Make enemy sprites
  2296. @enemy_sprites = []
  2297. $game_troop.enemies.reverse.each {|enemy|
  2298. @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  2299. }
  2300. # Make actor sprites
  2301. @actor_sprites = []
  2302. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2303. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2304. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2305. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2306. # Make weather
  2307. @weather = RPG::Weather.new(@viewport1)
  2308. # Make picture sprites
  2309. @picture_sprites = []
  2310. (51..100).each {|i|
  2311. @picture_sprites.push(Sprite_Picture.new(@viewport3,$game_screen.pictures[i]))
  2312. }
  2313. # Make timer sprite
  2314. @timer_sprite = Sprite_Timer.new
  2315. # Frame update
  2316. update
  2317. end
  2318. #--------------------------------------------------------------------------
  2319. # * Dispose
  2320. #--------------------------------------------------------------------------
  2321. alias_method :krx_atcbs_dispose, :dispose
  2322. def dispose
  2323. krx_atcbs_dispose
  2324. @viewport5.dispose
  2325. end
  2326. #--------------------------------------------------------------------------
  2327. # * Frame Update
  2328. #--------------------------------------------------------------------------
  2329. def update
  2330. # Update actor sprite bitmap (corresponds with actor switching)
  2331. @actor_sprites[0].battler = $game_party.actors[0]
  2332. @actor_sprites[1].battler = $game_party.actors[1]
  2333. @actor_sprites[2].battler = $game_party.actors[2]
  2334. @actor_sprites[3].battler = $game_party.actors[3]
  2335. # If battleback file name is different from current one
  2336. if @battleback_name != $game_temp.battleback_name
  2337. @battleback_name = $game_temp.battleback_name
  2338. if @battleback_sprite.bitmap != nil
  2339. @battleback_sprite.bitmap.dispose
  2340. end
  2341. # Stretches the battleback if necessary
  2342. bmp = RPG::Cache.battleback(@battleback_name)
  2343. @battleback_sprite.bitmap = Bitmap.new(640, 480)
  2344. @battleback_sprite.bitmap.stretch_blt(@battleback_sprite.bitmap.rect, bmp, bmp.rect)
  2345. end
  2346. # Update battler sprites
  2347. (@enemy_sprites + @actor_sprites).each {|sprite| sprite.update}
  2348. # Update weather graphic
  2349. @weather.type = $game_screen.weather_type
  2350. @weather.max = $game_screen.weather_max
  2351. @weather.update
  2352. # Update picture sprites
  2353. @picture_sprites.each {|sprite| sprite.update}
  2354. # Update timer sprite
  2355. @timer_sprite.update
  2356. # Set screen color tone and shake position
  2357. @viewport1.tone = $game_screen.tone
  2358. @viewport1.ox = $game_screen.shake
  2359. # Set screen flash color
  2360. @viewport4.color = $game_screen.flash_color
  2361. # Update viewports
  2362. @viewport1.update
  2363. @viewport2.update
  2364. @viewport4.update
  2365. @viewport5.update
  2366. end
  2367. #--------------------------------------------------------------------------
  2368. end
  2369.  
  2370. #===========================================================
  2371. # ** Action_System
  2372. #------------------------------------------------------------------------------
  2373. # Displays the turn order in battle
  2374. #===========================================================
  2375.  
  2376. class Action_System < Sprite
  2377. #--------------------------------------------------------------------------
  2378. # * Public instance variables
  2379. #--------------------------------------------------------------------------
  2380. attr_reader :queue
  2381. #--------------------------------------------------------------------------
  2382. # * Object Initialization
  2383. #--------------------------------------------------------------------------
  2384. def initialize(viewport)
  2385. super(viewport)
  2386. create_bitmap
  2387. create_battler_icons
  2388. update_order
  2389. update_coordinates_immediate
  2390. end
  2391. #--------------------------------------------------------------------------
  2392. # * Create the bitmap
  2393. #--------------------------------------------------------------------------
  2394. def create_bitmap
  2395. self.bitmap = RPG::Cache.picture('Action_Turns')
  2396. end
  2397. #--------------------------------------------------------------------------
  2398. # * Create the icons representing the battlers
  2399. #--------------------------------------------------------------------------
  2400. def create_battler_icons
  2401. @queue = []
  2402. ($game_party.actors + $game_troop.enemies).each {|battler|
  2403. next if KreadCFG.is_reyvateil?(battler)
  2404. @queue.push(Battler_Icon.new(self.viewport, battler))
  2405. }
  2406. end
  2407. #--------------------------------------------------------------------------
  2408. # * Frame Update
  2409. #--------------------------------------------------------------------------
  2410. def update
  2411. super
  2412. @queue.each {|spr| spr.update}
  2413. end
  2414. #--------------------------------------------------------------------------
  2415. # * Update icons order by action meter
  2416. #--------------------------------------------------------------------------
  2417. def update_order
  2418. max_nb = $game_party.actors.size + $game_troop.enemies.size
  2419. sel_bat = nil
  2420. if @queue.size != max_nb
  2421. ($game_party.actors + $game_troop.enemies).each {|bat|
  2422. sel_bat = bat
  2423. already_in_queue = false
  2424. next if !bat.exist? || bat == KreadCFG.return_reyvateil
  2425. @queue.each {|ico|
  2426. if ico.battler == sel_bat
  2427. already_in_queue = true
  2428. break
  2429. end
  2430. }
  2431. next if already_in_queue
  2432. @queue.push(Battler_Icon.new(self.viewport, bat))
  2433. }
  2434. end
  2435. inds = []
  2436. @queue.each_index {|i|
  2437. if !@queue[i].battler.exist?
  2438. @queue[i].dispose
  2439. inds.push(i)
  2440. end
  2441. }
  2442. inds.each {|j| @queue[j] = nil}
  2443. @queue.compact!
  2444. @queue.sort! {|a, b| b.battler.action_meter <=> a.battler.action_meter}
  2445. end
  2446. #--------------------------------------------------------------------------
  2447. # * Update icons coordinates by order
  2448. #--------------------------------------------------------------------------
  2449. def update_coordinates(with_right_shift = false)
  2450. @queue.each_index {|i| @queue[i].x_slide((self.bitmap.width - 130) - 53 * i, 24)}
  2451. if with_right_shift
  2452. @queue.each_index {|i|
  2453. @queue[i].x_slide(@queue[i].x_destination + (i == 0 ? 60 : 53), 12)
  2454. }
  2455. end
  2456. end
  2457. #--------------------------------------------------------------------------
  2458. # * Update icons coordinates by order immediately
  2459. #--------------------------------------------------------------------------
  2460. def update_coordinates_immediate
  2461. @queue.each_index {|i| @queue[i].x = (self.bitmap.width - 130) - 53 * i}
  2462. end
  2463. #--------------------------------------------------------------------------
  2464. # * Shift the icons to the right
  2465. #--------------------------------------------------------------------------
  2466. def right_shift
  2467. @queue.each_index {|i|
  2468. @queue[i].x_slide(@queue[i].x + (i == 0 ? 60 : 53), 12)
  2469. }
  2470. end
  2471. #--------------------------------------------------------------------------
  2472. # * Insert the Reyvateil icon
  2473. #--------------------------------------------------------------------------
  2474. def insert_reyvateil
  2475. @queue.push(Battler_Icon.new(self.viewport, $game_party.actors[-1]))
  2476. @queue[-1].x = @queue[0].x + 60
  2477. end
  2478. #--------------------------------------------------------------------------
  2479. # * Remove the Reyvateil icon
  2480. #--------------------------------------------------------------------------
  2481. def remove_reyvateil
  2482. @queue[-1].dispose
  2483. @queue[-1] = nil
  2484. @queue.compact!
  2485. end
  2486. #--------------------------------------------------------------------------
  2487. end
  2488.  
  2489. #===========================================================
  2490. # ** Battler_Icon
  2491. #------------------------------------------------------------------------------
  2492. # Displays the battler's graphic for turns in battle
  2493. #===========================================================
  2494.  
  2495. class Battler_Icon < Sprite
  2496. #--------------------------------------------------------------------------
  2497. # * Public instance variables
  2498. #--------------------------------------------------------------------------
  2499. attr_reader :battler
  2500. #--------------------------------------------------------------------------
  2501. # * Object Initialization
  2502. #--------------------------------------------------------------------------
  2503. def initialize(viewport, battler)
  2504. super(viewport)
  2505. @battler = battler
  2506. @am = 0
  2507. create_bitmap
  2508. setup_initial_coordinates
  2509. update
  2510. end
  2511. #--------------------------------------------------------------------------
  2512. # * Create the bitmap
  2513. #--------------------------------------------------------------------------
  2514. def create_bitmap
  2515. # If enemies don't have custom icons, use the default one
  2516. bmp = RPG::Cache.picture("BattleFace_#{@battler.name}") rescue NIL
  2517. if bmp != nil
  2518. self.bitmap = bmp
  2519. else
  2520. if @battler.is_a?(Game_Enemy)
  2521. self.bitmap = RPG::Cache.picture('BattleFace_Enemy').clone
  2522. end
  2523. end
  2524. # Loads action meter bitmap
  2525. @am_bmp = RPG::Cache.picture('ActionBar_Full')
  2526. end
  2527. #--------------------------------------------------------------------------
  2528. # * Setups the coordinates for the battle entry
  2529. #--------------------------------------------------------------------------
  2530. def setup_initial_coordinates
  2531. self.y, self.z = 7, 1
  2532. end
  2533. #--------------------------------------------------------------------------
  2534. # * Frame Update
  2535. #--------------------------------------------------------------------------
  2536. def update
  2537. super
  2538. # Updates Action Meter if necessary
  2539. if @am != @battler.action_meter
  2540. # Computes AM / Max AM ratio
  2541. ratio = [(@battler.action_meter / 1000.0), 1000].min
  2542. am_rect = Rect.new(0, 0, @am_bmp.width, @am_bmp.height * ratio)
  2543. self.bitmap.fill_rect(48, 0, 5, 48, Color.new(0, 0, 0))
  2544. self.bitmap.blt(49, 1, @am_bmp, am_rect)
  2545. @am = @battler.action_meter
  2546. end
  2547. end
  2548. #--------------------------------------------------------------------------
  2549. end
  2550.  
  2551. #===========================================================
  2552. # ** Arrow_Actor
  2553. #------------------------------------------------------------------------------
  2554. # This arrow cursor is used to choose an actor. This class inherits from the
  2555. # Arrow_Base class.
  2556. #===========================================================
  2557.  
  2558. class Arrow_Actor < Arrow_Base
  2559. #--------------------------------------------------------------------------
  2560. # * Frame Update
  2561. #--------------------------------------------------------------------------
  2562. alias_method :krx_atcbs_update, :update
  2563. def update
  2564. krx_atcbs_update
  2565. # Set help window coordinates
  2566. if @help_window != nil
  2567. @help_window.x = self.x - 64
  2568. @help_window.y = self.y - 8
  2569. end
  2570. end
  2571. #--------------------------------------------------------------------------
  2572. end
  2573.  
  2574. #===========================================================
  2575. # ** Arrow_Enemy
  2576. #------------------------------------------------------------------------------
  2577. # This arrow cursor is used to choose enemies. This class inherits from the
  2578. # Arrow_Base class.
  2579. #===========================================================
  2580.  
  2581. class Arrow_Enemy < Arrow_Base
  2582. #--------------------------------------------------------------------------
  2583. # * Frame Update
  2584. #--------------------------------------------------------------------------
  2585. alias_method :krx_atcbs_update, :update
  2586. def update
  2587. krx_atcbs_update
  2588. # Set help window coordinates
  2589. if @help_window != nil
  2590. @help_window.x = self.x - 64
  2591. @help_window.y = self.y - 8
  2592. end
  2593. end
  2594. #--------------------------------------------------------------------------
  2595. end
  2596.  
  2597. #===========================================================
  2598. # ** Action_Help
  2599. #------------------------------------------------------------------------------
  2600. # Displays action name in battle
  2601. #===========================================================
  2602.  
  2603. class Action_Help < Sprite
  2604. #--------------------------------------------------------------------------
  2605. # * Object Initialization
  2606. #--------------------------------------------------------------------------
  2607. def initialize(viewport, action)
  2608. super(viewport)
  2609. @action = action
  2610. set_bitmap
  2611. set_coordinates
  2612. refresh
  2613. end
  2614. #--------------------------------------------------------------------------
  2615. # * Setup the bitmap
  2616. #--------------------------------------------------------------------------
  2617. def set_bitmap
  2618. # Dispose bitmap if already existing
  2619. if self.bitmap != nil
  2620. self.bitmap.dispose
  2621. self.bitmap = nil
  2622. end
  2623. # Branch by action kind
  2624. if @action.kind == 0 # Basics
  2625. self.bitmap = Bitmap.new(8, 8) # Blank Bitmap
  2626. else # Skills and Items
  2627. self.bitmap = Bitmap.new('Graphics/Pictures/Help')
  2628. end
  2629. end
  2630. #--------------------------------------------------------------------------
  2631. # * Setup the coordinates
  2632. #--------------------------------------------------------------------------
  2633. def set_coordinates
  2634. self.ox = self.bitmap.width / 2
  2635. self.oy = self.bitmap.height / 2
  2636. self.x = 320
  2637. self.y = 96
  2638. end
  2639. #--------------------------------------------------------------------------
  2640. # * Refresh
  2641. #--------------------------------------------------------------------------
  2642. def refresh
  2643. # Sets font
  2644. self.bitmap.font.name = 'Arial'
  2645. self.bitmap.font.size = 32
  2646. self.bitmap.font.italic = true
  2647. # Branch by kind
  2648. case @action.kind
  2649. when 1 # Skill
  2650. text = $data_skills[@action.skill_id].name
  2651. self.bitmap.draw_text(0, 12, self.bitmap.width, 32, text, 1)
  2652. when 2 # Item
  2653. text = $data_items[@action.item_id].name
  2654. self.bitmap.draw_text(0, 12, self.bitmap.width, 32, text, 1)
  2655. end
  2656. end
  2657. #--------------------------------------------------------------------------
  2658. end
  2659.  
  2660. #===========================================================
  2661. # ** Reyvateil_Command
  2662. #------------------------------------------------------------------------------
  2663. # Displays the Reyvateil special command
  2664. #===========================================================
  2665.  
  2666. class Reyvateil_Command < Sprite
  2667. #--------------------------------------------------------------------------
  2668. # * Object Initialization
  2669. #--------------------------------------------------------------------------
  2670. def initialize(viewport)
  2671. super(viewport)
  2672. self.bitmap = Bitmap.new(190, 40)
  2673. self.bitmap.font.name = ['Sylfaen', 'Arial']
  2674. self.bitmap.font.bold = self.bitmap.font.italic = true
  2675. refresh
  2676. end
  2677. #--------------------------------------------------------------------------
  2678. # * Refresh
  2679. #--------------------------------------------------------------------------
  2680. def refresh
  2681. ico = RPG::Cache.icon('button_13')
  2682. self.x = 640 - self.bitmap.width
  2683. self.y = 480 - self.bitmap.height
  2684. self.bitmap.blt(0, 6, ico, ico.rect)
  2685. self.bitmap.draw_outlined_text(28, 0, self.bitmap.width, 32,
  2686. KreadCFG::ReyvateilClass + ' Command')
  2687. end
  2688. #--------------------------------------------------------------------------
  2689. end
  2690.  
  2691. #===========================================================
  2692. # ** Burst_Gauge
  2693. #------------------------------------------------------------------------------
  2694. # Displays the Burst Gauge
  2695. #===========================================================
  2696.  
  2697. class Burst_Gauge < Sprite
  2698. #--------------------------------------------------------------------------
  2699. # * Object Initialization
  2700. #--------------------------------------------------------------------------
  2701. def initialize(viewport, reyvateil)
  2702. super(viewport)
  2703. @reyvateil = reyvateil
  2704. @last_value = 0
  2705. @value_sprite = Burst_Value.new(viewport, reyvateil)
  2706. set_bitmap
  2707. set_coordinates
  2708. end
  2709. #--------------------------------------------------------------------------
  2710. # * Dispose all
  2711. #--------------------------------------------------------------------------
  2712. def dispose
  2713. super
  2714. @value_sprite.dispose
  2715. end
  2716. #--------------------------------------------------------------------------
  2717. # * Create the bitmap
  2718. #--------------------------------------------------------------------------
  2719. def set_bitmap
  2720. @back = RPG::Cache.picture('BurstGauge_Back')
  2721. self.bitmap = Bitmap.new(@back.width, @back.height)
  2722. self.bitmap.blt(0, 0, @back, @back.rect)
  2723. end
  2724. #--------------------------------------------------------------------------
  2725. # * Setup initial coordinates
  2726. #--------------------------------------------------------------------------
  2727. def set_coordinates
  2728. self.x, self.y, self.z = 8, 416, -5
  2729. end
  2730. #--------------------------------------------------------------------------
  2731. # * Frame Update
  2732. #--------------------------------------------------------------------------
  2733. def update
  2734. super
  2735. # Quit unless stored burst value is different than current burst value
  2736. return unless @last_value != @reyvateil.burst_value
  2737. return if @reyvateil.dead?
  2738. # Refreshes the gauge
  2739. filler = RPG::Cache.picture('BurstGauge_Fill')
  2740. ratio = (@reyvateil.burst_value * 1.00) /
  2741. (KreadCFG::SongMagicMaxBurst[@reyvateil.current_action.skill_id] * 1.00)
  2742. rect = Rect.new(0, 0, [(filler.width * ratio).round, filler.width].min, filler.height)
  2743. self.bitmap.clear
  2744. self.bitmap.blt(0, 0, @back, @back.rect)
  2745. self.bitmap.blt(2, 2, filler, rect)
  2746. @value_sprite.refresh(@reyvateil.burst_value)
  2747. @last_value = @reyvateil.burst_value
  2748. end
  2749. #--------------------------------------------------------------------------
  2750. end
  2751.  
  2752.  
  2753. #===========================================================
  2754. # ** Burst_Value
  2755. #------------------------------------------------------------------------------
  2756. # Displays the Burst value
  2757. #===========================================================
  2758.  
  2759. class Burst_Value < Sprite
  2760. #--------------------------------------------------------------------------
  2761. # * Object Initialization
  2762. #--------------------------------------------------------------------------
  2763. def initialize(viewport, reyvateil)
  2764. super(viewport)
  2765. set_bitmap
  2766. set_coordinates
  2767. end
  2768. #--------------------------------------------------------------------------
  2769. # * Create the bitmap
  2770. #--------------------------------------------------------------------------
  2771. def set_bitmap
  2772. self.bitmap = Bitmap.new(320, 96)
  2773. self.bitmap.font.name = ['Abduction II', 'Arial']
  2774. self.bitmap.font.size = 32
  2775. self.bitmap.draw_outlined_text(2, 2, 320, 96, '0%')
  2776. end
  2777. #--------------------------------------------------------------------------
  2778. # * Setup initial coordinates
  2779. #--------------------------------------------------------------------------
  2780. def set_coordinates
  2781. self.x, self.y, self.z = 332, 375, -4
  2782. end
  2783. #--------------------------------------------------------------------------
  2784. # * Refresh
  2785. #--------------------------------------------------------------------------
  2786. def refresh(new_value)
  2787. self.bitmap.clear
  2788. self.bitmap.draw_outlined_text(2, 2, 320, 96, new_value.to_s + '%')
  2789. end
  2790. #--------------------------------------------------------------------------
  2791. end
  2792.  
  2793. #===========================================================
  2794. # ** Harmonics_Gauge
  2795. #------------------------------------------------------------------------------
  2796. # Displays the Harmonics gauge.
  2797. #===========================================================
  2798.  
  2799. class Harmonics_Gauge < Sprite
  2800. #--------------------------------------------------------------------------
  2801. # * Object Initialization
  2802. #--------------------------------------------------------------------------
  2803. def initialize(viewport, reyvateil)
  2804. super(viewport)
  2805. self.x, self.y = 6, 440
  2806. self.bitmap = RPG::Cache.picture('Harmonics_Back')
  2807. @reyvateil = reyvateil
  2808. @last_harmo = nil
  2809. create_vanguards_bar
  2810. create_reyvateil_bar if @reyvateil != nil
  2811. end
  2812. #--------------------------------------------------------------------------
  2813. # * Dispose all
  2814. #--------------------------------------------------------------------------
  2815. def dispose
  2816. super
  2817. if @v_bar != nil
  2818. @vanguards_fill.dispose
  2819. @v_bar.bitmap.dispose
  2820. @v_bar.dispose
  2821. end
  2822. if @r_bar != nil
  2823. @reyvateil_fill.dispose
  2824. @r_bar.bitmap.dispose
  2825. @r_bar.dispose
  2826. end
  2827. end
  2828. #--------------------------------------------------------------------------
  2829. # * Create the gauge bar (Vanguards)
  2830. #--------------------------------------------------------------------------
  2831. def create_vanguards_bar
  2832. @vanguards_fill = RPG::Cache.picture('Harmonics_Vanguards')
  2833. @v_bar = Sprite.new(self.viewport)
  2834. @v_bar.bitmap = Bitmap.new(@vanguards_fill.width, @vanguards_fill.height)
  2835. @v_bar.x, @v_bar.y, @v_bar.z = self.x + 7, self.y + 7, self.z + 1
  2836. end
  2837. #--------------------------------------------------------------------------
  2838. # * Create the gauge bar (Reyvateil)
  2839. #--------------------------------------------------------------------------
  2840. def create_reyvateil_bar
  2841. @reyvateil_fill = RPG::Cache.picture('Harmonics_Reyvateil')
  2842. @r_bar = Sprite.new(self.viewport)
  2843. @r_bar.mirror = true
  2844. @r_bar.bitmap = Bitmap.new(@reyvateil_fill.width, @reyvateil_fill.height)
  2845. @r_bar.x, @r_bar.y, @r_bar.z = self.x + 7, self.y + 7, self.z + 1
  2846. end
  2847. #--------------------------------------------------------------------------
  2848. # * Frame Update
  2849. #--------------------------------------------------------------------------
  2850. def update
  2851. super
  2852. # Quit if Harmonics value didn't change
  2853. return unless $game_party.global_harmonics != @last_harmo
  2854. # If the global harmonics are maxed, then show special bar
  2855. if $game_party.global_harmonics == $game_temp.max_harmonics
  2856. bmp = RPG::Cache.picture('Harmonics_Maxed')
  2857. rect = bmp.rect
  2858. @r_bar.bitmap.clear if @r_bar != nil
  2859. @v_bar.bitmap.clear
  2860. @v_bar.bitmap.blt(0, 0, bmp, rect)
  2861. @last_harmo = $game_party.global_harmonics
  2862. return
  2863. end
  2864. # Update Vanguards bar
  2865. if @v_bar != nil
  2866. # Computes the amount of global harmonics due to Vanguards
  2867. ratio = $game_party.harmonics.to_f / $game_temp.max_harmonics.to_f
  2868. # And adjust the rect coordinate
  2869. rect = Rect.new(0, 0, (@vanguards_fill.width * ratio).round, @vanguards_fill.height)
  2870. @v_bar.bitmap.clear
  2871. @v_bar.bitmap.blt(0, 0, @vanguards_fill, rect)
  2872. end
  2873. # Update Reyvateil bar
  2874. if @r_bar != nil
  2875. # Computes the amount of global harmonics due to Reyvateil
  2876. ratio = @reyvateil.harmonics.to_f / $game_temp.max_harmonics.to_f
  2877. # And adjust the rect coordinate
  2878. rect = Rect.new(0, 0, (@reyvateil_fill.width * ratio).round, @reyvateil_fill.height)
  2879. @r_bar.bitmap.clear
  2880. @r_bar.bitmap.blt(0, 0, @reyvateil_fill, rect)
  2881. end
  2882. @last_harmo = $game_party.global_harmonics
  2883. end
  2884. #--------------------------------------------------------------------------
  2885. end
  2886.  
  2887. #===========================================================
  2888. # ** Sprite_LevelUp
  2889. #------------------------------------------------------------------------------
  2890. # Displays levelling up
  2891. #===========================================================
  2892.  
  2893. class Sprite_LevelUP < Sprite
  2894. #--------------------------------------------------------------------------
  2895. # * Object Initialization
  2896. #--------------------------------------------------------------------------
  2897. def initialize(viewport, actor)
  2898. super(viewport)
  2899. self.bitmap = Bitmap.new(120, 64)
  2900. self.bitmap.font.color = Color.new(0, 0, 0)
  2901. self.bitmap.draw_text(1, 1, 80, 32, 'Level Up')
  2902. self.bitmap.draw_text(1, 3, 80, 32, 'Level Up')
  2903. self.bitmap.draw_text(3, 1, 80, 32, 'Level Up')
  2904. self.bitmap.draw_text(3, 3, 80, 32, 'Level Up')
  2905. self.bitmap.font.color = Color.new(255, 255, 255)
  2906. self.bitmap.draw_text(2, 2, 80, 32, 'Level Up')
  2907. self.visible = false
  2908. self.x = 560
  2909. self.y = 176 + (actor.index * 58)
  2910. end
  2911. #--------------------------------------------------------------------------
  2912. end
  2913.  
  2914. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2915. # Ar Tonelico Custom Battle System
  2916. # Author: Kread-EX
  2917. # Version 1.1
  2918. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2919.  
  2920. #===========================================================
  2921. # ** Window
  2922. #------------------------------------------------------------------------------
  2923. # Basic window class, enhanced with moving capabilities
  2924. #===========================================================
  2925.  
  2926. class Window
  2927. #--------------------------------------------------------------------------
  2928. # * Object Initialization
  2929. #--------------------------------------------------------------------------
  2930. alias_method :krx_move_window_init, :initialize
  2931. def initialize(viewport = nil)
  2932. krx_move_window_init(viewport) # Original call
  2933. # When these two variables are different than the coordinates, the window moves.
  2934. @x_destination = nil
  2935. @y_destination = nil
  2936. # Coordinates incrementation.
  2937. @increment = 0
  2938. end
  2939. #--------------------------------------------------------------------------
  2940. # * Horizontal move
  2941. #--------------------------------------------------------------------------
  2942. def x_slide(x_dest, inc)
  2943. @x_destination = x_dest
  2944. @increment= inc
  2945. end
  2946. #--------------------------------------------------------------------------
  2947. # * Vertical move
  2948. #--------------------------------------------------------------------------
  2949. def y_slide(y_dest, inc)
  2950. @y_destination = y_dest
  2951. @increment = inc
  2952. end
  2953. #--------------------------------------------------------------------------
  2954. # * Frame Update
  2955. #--------------------------------------------------------------------------
  2956. alias_method :krx_move_window_update, :update
  2957. def update
  2958. update_x_slide
  2959. update_y_slide
  2960. return if self.is_sliding?
  2961. krx_move_window_update # Original call
  2962. end
  2963. #--------------------------------------------------------------------------
  2964. # * Update horizontal motion
  2965. #--------------------------------------------------------------------------
  2966. def update_x_slide
  2967. return if @x_destination == nil
  2968. if @x_destination > self.x
  2969. self.x = [self.x + @increment, @x_destination].min
  2970. else
  2971. self.x = [self.x - @increment, @x_destination].max
  2972. end
  2973. @x_destination = nil if @x_destination == self.x
  2974. end
  2975. #--------------------------------------------------------------------------
  2976. # * Update vertical motion
  2977. #--------------------------------------------------------------------------
  2978. def update_y_slide
  2979. return if @y_destination == nil
  2980. if @y_destination > self.y
  2981. self.y = [self.y + @increment, @y_destination].min
  2982. else
  2983. self.y = [self.y - @increment, @y_destination].max
  2984. end
  2985. @y_destination = nil if @y_destination == self.y
  2986. end
  2987. #--------------------------------------------------------------------------
  2988. # * Checks if moving
  2989. #--------------------------------------------------------------------------
  2990. def is_sliding?
  2991. return (@x_destination != nil || @y_destination != nil)
  2992. end
  2993. #--------------------------------------------------------------------------
  2994. end
  2995.  
  2996. #===========================================================
  2997. # ** Command_Ring
  2998. #------------------------------------------------------------------------------
  2999. # Ring menu for selecting commands in battle.
  3000. #===========================================================
  3001.  
  3002. class Command_Ring < Window_Base
  3003. #--------------------------------------------------------------------------
  3004. # * Object Initialization
  3005. #--------------------------------------------------------------------------
  3006. def initialize(actor)
  3007. super(500, 350, 320, 320)
  3008. self.contents = Bitmap.new(width - 32, height - 32)
  3009. self.opacity = 0
  3010. @actor = actor
  3011. @center_x = [actor.screen_x, 500].min
  3012. @center_y = actor.screen_y - 32
  3013. @last_x, @last_y = @center_x, @center_y
  3014. @index = 0
  3015. @active = true
  3016. create_commands
  3017. create_icons
  3018. setup_icons_coordinates
  3019. make_self_coordinates
  3020. refresh
  3021. end
  3022. #--------------------------------------------------------------------------
  3023. # * Get Index
  3024. #--------------------------------------------------------------------------
  3025. def index
  3026. return @index
  3027. end
  3028. #--------------------------------------------------------------------------
  3029. # * Get selected command
  3030. #--------------------------------------------------------------------------
  3031. def command
  3032. return @commands[@index]
  3033. end
  3034. #--------------------------------------------------------------------------
  3035. # * Dispose objects
  3036. #--------------------------------------------------------------------------
  3037. def dispose
  3038. super
  3039. @icons.each {|ico| ico.bitmap.dispose ; ico.dispose}
  3040. end
  3041. #--------------------------------------------------------------------------
  3042. # * Frame Update
  3043. #--------------------------------------------------------------------------
  3044. def update
  3045. super
  3046. make_self_coordinates
  3047. correct_coordinates
  3048. # Quit here is the ring isn't active
  3049. return if !@active
  3050. process_rotation
  3051. @icons.each {|ico| ico.update}
  3052. end
  3053. #--------------------------------------------------------------------------
  3054. # * Rotates the ring upon keyboard input
  3055. #--------------------------------------------------------------------------
  3056. def process_rotation
  3057. return if self.is_sliding?
  3058. # Clockwise
  3059. if Input.trigger?(Input::RIGHT)
  3060. rotate
  3061. @icons[@index].zoom_x = @icons[@index].zoom_y = 2.0
  3062. # Counterclockwise
  3063. elsif Input.trigger?(Input::LEFT)
  3064. rotate(true)
  3065. @icons[@index].zoom_x = @icons[@index].zoom_y = 2.0
  3066. end
  3067. end
  3068. #--------------------------------------------------------------------------
  3069. # * Refresh
  3070. #--------------------------------------------------------------------------
  3071. def refresh
  3072. command = @commands[@index]
  3073. self.contents.clear
  3074. self.contents.font.color = Color.new(70, 100, 235, 255)
  3075. self.contents.font.name = 'Verdana'
  3076. self.contents.font.size = 22
  3077. self.contents.font.bold = self.contents.font.italic = true
  3078. self.contents.draw_text(0, 0, 320, 36, command)
  3079. self.contents.draw_text(0, 2, 320, 36, command)
  3080. self.contents.draw_text(2, 0, 320, 36, command)
  3081. self.contents.draw_text(2, 2, 320, 36, command)
  3082. self.contents.font.color = Color.new(255, 255, 255, 255)
  3083. self.contents.draw_text(1, 1, 320, 36, command)
  3084. end
  3085. #--------------------------------------------------------------------------
  3086. # * Makes the ring visible or invisible
  3087. #--------------------------------------------------------------------------
  3088. def toggle_visibility
  3089. self.visible = !self.visible
  3090. @icons.each {|ico| ico.visible = !ico.visible}
  3091. end
  3092. #--------------------------------------------------------------------------
  3093. # * Makes the ring active or inactive
  3094. #--------------------------------------------------------------------------
  3095. def toggle_activity
  3096. @active = !@active
  3097. end
  3098. #--------------------------------------------------------------------------
  3099. # * Rotate the ring
  3100. #--------------------------------------------------------------------------
  3101. def rotate(counterclockwise = false)
  3102. make_new_index(counterclockwise)
  3103. reset_zoom
  3104. d1 = 2.0 * Math::PI / @commands.size
  3105. (0...@commands.size).each {|i|
  3106. j = i - @index
  3107. d = d1 * j + d1
  3108. @icons[i].x_slide(@center_x + (96 * Math.sin(d)).to_i, 15) rescue nil
  3109. @icons[i].y_slide(@center_y - (96 * Math.cos(d)).to_i, 15)
  3110. }
  3111. end
  3112. #--------------------------------------------------------------------------
  3113. # * Correct the coordinates
  3114. #--------------------------------------------------------------------------
  3115. def correct_coordinates
  3116. @center_x, @center_y = [@actor.screen_x, 500].min, @actor.screen_y - 32
  3117. if @last_x != @center_x || @last_y != @center_y
  3118. self.x_slide(@center_x, 64)
  3119. self.y_slide(@center_y, 64)
  3120. (0...@icons.size).each {|i|
  3121. d1 = 2.0 * Math::PI / @commands.size
  3122. j = i - @index
  3123. d = d1 * j + d1
  3124. @icons[i].x_slide(@center_x + (96 * Math.sin(d)).to_i, 64) rescue nil
  3125. @icons[i].y_slide(@center_y - (96 * Math.cos(d)).to_i, 64)
  3126. }
  3127. @last_x, @last_y = @center_x, @center_y
  3128. end
  3129. end
  3130. #--------------------------------------------------------------------------
  3131. # * Determine if the ring is moving
  3132. #--------------------------------------------------------------------------
  3133. def moving?
  3134. @icons.each {|ico| return true if ico.moving?}
  3135. return false
  3136. end
  3137. #--------------------------------------------------------------------------
  3138. # * Initialize the icons coordinates
  3139. #--------------------------------------------------------------------------
  3140. def setup_icons_coordinates
  3141. d1 = 2.0 * Math::PI / @commands.size
  3142. (0...@commands.size).each {|i|
  3143. j = i - @index
  3144. d = d1 * j + d1
  3145. @icons[i].x = @center_x + (96 * Math.sin(d)).to_i
  3146. @icons[i].y = @center_y - (96 * Math.cos(d)).to_i
  3147. @icons[i].z += 1000
  3148. @icons[i].ox = @icons[i].oy = 12
  3149. }
  3150. end
  3151. #--------------------------------------------------------------------------
  3152. # * Calculate the new index
  3153. #--------------------------------------------------------------------------
  3154. def make_new_index(minus)
  3155. @index = minus ? @index - 1 : @index + 1
  3156. @index %= @commands.size
  3157. refresh
  3158. end
  3159. #--------------------------------------------------------------------------
  3160. # * Calculate the new coordinates
  3161. #--------------------------------------------------------------------------
  3162. def make_self_coordinates
  3163. command = @commands[@index].is_a?(Array) ? @commands[@index][0] : @commands[@index]
  3164. self.x = @icons[@index].x - (58 + self.contents.text_size(command).width)
  3165. self.y = @icons[@index].y - 32
  3166. self.z += 1000
  3167. end
  3168. #--------------------------------------------------------------------------
  3169. # * Reset zoom
  3170. #--------------------------------------------------------------------------
  3171. def reset_zoom
  3172. @counter = 0
  3173. @icons.each {|ico|
  3174. ico.zoom_x = 1.0
  3175. ico.zoom_y = 1.0
  3176. }
  3177. end
  3178. #--------------------------------------------------------------------------
  3179. # * Create commands
  3180. #--------------------------------------------------------------------------
  3181. def create_commands
  3182. # Switch to Reyvateil Command if necessary
  3183. if KreadCFG.is_reyvateil?(@actor)
  3184. create_reyvateil_commands
  3185. return
  3186. end
  3187. @commands = ['Attack']
  3188. # Adds Skill if character knows at least one skill
  3189. @commands.push('Skill') if @actor.skills.size > 0
  3190. # Adds Guard
  3191. @commands.push('Guard')
  3192. # Adds Item
  3193. @commands.push('Item')
  3194. # Adds Flee if escape is enabled for this battle
  3195. @commands.push('Flee') if $game_temp.battle_can_escape
  3196. end
  3197. #--------------------------------------------------------------------------
  3198. # * Create icons
  3199. #--------------------------------------------------------------------------
  3200. def create_icons
  3201. # Quit if the actor is a Reyvateil
  3202. return if KreadCFG.is_reyvateil?(@actor)
  3203. @icons = []
  3204. # Check commands and add icons corresponding to them
  3205. @commands.each {|str|
  3206. @icons.push(Sprite.new(self.viewport))
  3207. @icons[-1].bitmap = RPG::Cache.icon("RingIcon_#{str.downcase}")
  3208. }
  3209. end
  3210. #--------------------------------------------------------------------------
  3211. # * Create commands and icons (Reyvateil Only)
  3212. #--------------------------------------------------------------------------
  3213. def create_reyvateil_commands
  3214. @commands = [KreadCFG::SongMagicName, KreadCFG::SongActivate, KreadCFG::SongCancel]
  3215. @icons = [] ; 3.times {@icons.push(Sprite.new(self.viewport))}
  3216. @icons[0].bitmap = RPG::Cache.icon('RingIcon_SongMagic')
  3217. @icons[1].bitmap = RPG::Cache.icon('RingIcon_SongActivate')
  3218. @icons[2].bitmap = RPG::Cache.icon('RingIcon_SongCancel')
  3219. # Adds Flee is possible...
  3220. return unless $game_temp.battle_can_escape
  3221. @commands.push('Flee')
  3222. @icons.push(Sprite.new(self.viewport))
  3223. @icons[-1].bitmap = RPG::Cache.icon('RingIcon_flee')
  3224. end
  3225. #--------------------------------------------------------------------------
  3226. end
  3227.  
  3228. #===========================================================
  3229. # ** Ambiance_Field
  3230. #------------------------------------------------------------------------------
  3231. # Displays ambiance field, as well as enemy name and status effects
  3232. #===========================================================
  3233.  
  3234. class Ambiance_Field < Window_Base
  3235. #--------------------------------------------------------------------------
  3236. # * Object Initialization
  3237. #--------------------------------------------------------------------------
  3238. def initialize
  3239. super(0, 0, 260, 96)
  3240. self.contents = Bitmap.new(width - 32, height - 32)
  3241. self.opacity = 0
  3242. self.z = 5000
  3243. @battler = nil
  3244. end
  3245. #--------------------------------------------------------------------------
  3246. # * Displays actor information
  3247. #--------------------------------------------------------------------------
  3248. def set_actor(actor)
  3249. set_battler(actor)
  3250. end
  3251. #--------------------------------------------------------------------------
  3252. # * Displays enemy information
  3253. #--------------------------------------------------------------------------
  3254. def set_enemy(enemy)
  3255. set_battler(enemy)
  3256. display_ambiance_field_value(enemy) if $game_system.ambiance_field
  3257. end
  3258. #--------------------------------------------------------------------------
  3259. # * Displays battler information
  3260. #--------------------------------------------------------------------------
  3261. def set_battler(battler)
  3262. return if @battler == battler
  3263. self.contents.clear
  3264. display_name(battler)
  3265. display_hp(battler)
  3266. @battler = battler
  3267. end
  3268. #--------------------------------------------------------------------------
  3269. # * Displays the name
  3270. #--------------------------------------------------------------------------
  3271. def display_name(battler)
  3272. self.contents.font.color = Color.new(70, 100, 235, 255)
  3273. self.contents.font.name = 'Verdana'
  3274. self.contents.font.size = 22
  3275. self.contents.font.bold = self.contents.font.italic = true
  3276. self.contents.draw_text(0, 0, 102, 36, battler.name, 1)
  3277. self.contents.draw_text(0, 2, 102, 36, battler.name, 1)
  3278. self.contents.draw_text(2, 0, 102, 36, battler.name, 1)
  3279. self.contents.draw_text(2, 2, 102, 36, battler.name, 1)
  3280. self.contents.font.color = Color.new(255, 255, 255, 255)
  3281. self.contents.draw_text(1, 1, 102, 36, battler.name, 1)
  3282. end
  3283. #--------------------------------------------------------------------------
  3284. # * Displays the hp bar
  3285. #--------------------------------------------------------------------------
  3286. def display_hp(battler)
  3287. # Draws Bar back
  3288. self.contents.fill_rect(0, 32, 96, 5, Color.new(0, 0, 0))
  3289. # Computes HP / Max HP ratio
  3290. ratio = battler.hp.to_f / battler.maxhp.to_f
  3291. # Draws Bar
  3292. full = RPG::Cache.picture('HpBar_Full')
  3293. rect = Rect.new(0, 0, (ratio * full.width).round, full.height)
  3294. self.contents.blt(1, 33, full, rect)
  3295. end
  3296. #--------------------------------------------------------------------------
  3297. # * Displays the value of the Ambiance Field
  3298. #--------------------------------------------------------------------------
  3299. def display_ambiance_field_value(enemy)
  3300. self.contents.font.size = 52
  3301. self.contents.font.color = Color.new(230, 100, 100, 255)
  3302. self.contents.draw_text(110, 2, 320, 64, enemy.ambiance_field.to_s)
  3303. self.contents.draw_text(110, 4, 320, 64, enemy.ambiance_field.to_s)
  3304. self.contents.draw_text(112, 2, 320, 64, enemy.ambiance_field.to_s)
  3305. self.contents.draw_text(112, 4, 320, 64, enemy.ambiance_field.to_s)
  3306. self.contents.font.color = Color.new(255, 255, 255, 255)
  3307. self.contents.draw_text(111, 3, 320, 64, enemy.ambiance_field.to_s)
  3308. end
  3309. #--------------------------------------------------------------------------
  3310. end
  3311.  
  3312. #===========================================================
  3313. # ** Window_BattleSkill
  3314. #------------------------------------------------------------------------------
  3315. # This window displays usable skills on the battle screens.
  3316. #===========================================================
  3317.  
  3318. class Window_BattleSkill < Window_Selectable
  3319. #--------------------------------------------------------------------------
  3320. # * Object Initialization
  3321. # actor : actor
  3322. #--------------------------------------------------------------------------
  3323. def initialize(actor)
  3324. super(0, 128, 240, 256)
  3325. self.index = 0
  3326. self.back_opacity = 160
  3327. self.z = 7000
  3328. @actor = actor
  3329. @column_max = 1
  3330. refresh
  3331. end
  3332. #--------------------------------------------------------------------------
  3333. # * Acquiring Skill
  3334. #--------------------------------------------------------------------------
  3335. def skill
  3336. return @data[self.index]
  3337. end
  3338. #--------------------------------------------------------------------------
  3339. # * Refresh
  3340. #--------------------------------------------------------------------------
  3341. def refresh
  3342. if self.contents != nil
  3343. self.contents.dispose
  3344. self.contents = nil
  3345. end
  3346. @data = []
  3347. (0...@actor.skills.size).each {|i|
  3348. skill = $data_skills[@actor.skills[i]]
  3349. @data.push(skill) if skill != nil
  3350. }
  3351. # If item count is not 0, make a bit map and draw all items
  3352. @item_max = @data.size
  3353. if @item_max > 0
  3354. self.contents = Bitmap.new(width - 32, row_max * 32)
  3355. (0...@item_max).each {|i| draw_item(i)}
  3356. end
  3357. end
  3358. #--------------------------------------------------------------------------
  3359. # * Draw Item
  3360. # index : item number
  3361. #--------------------------------------------------------------------------
  3362. def draw_item(index)
  3363. skill = @data[index]
  3364. if @actor.skill_can_use?(skill.id)
  3365. self.contents.font.color = normal_color
  3366. else
  3367. self.contents.font.color = disabled_color
  3368. end
  3369. x = 4 + index % 1 * (288 + 32)
  3370. y = index * 32
  3371. rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  3372. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  3373. bitmap = RPG::Cache.icon(skill.icon_name)
  3374. opacity = self.contents.font.color == normal_color ? 255 : 128
  3375. self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  3376. self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  3377. end
  3378. #--------------------------------------------------------------------------
  3379. # * Help Text Update
  3380. #--------------------------------------------------------------------------
  3381. def update_help
  3382. if @help_window.class == Window_SkillHelp
  3383. @help_window.set_skill(self.skill, @actor)
  3384. else
  3385. @help_window.set_skill(self.skill)
  3386. end
  3387. end
  3388. #--------------------------------------------------------------------------
  3389. end
  3390.  
  3391. #===========================================================
  3392. # ** Window_BattleItem
  3393. #------------------------------------------------------------------------------
  3394. # This window displays usable items on the battle screens.
  3395. #===========================================================
  3396.  
  3397. class Window_BattleItem < Window_Selectable
  3398. #--------------------------------------------------------------------------
  3399. # * Object Initialization
  3400. #--------------------------------------------------------------------------
  3401. def initialize
  3402. super(0, 128, 240, 256)
  3403. self.index = 0
  3404. self.back_opacity = 160
  3405. self.z = 7000
  3406. @column_max = 1
  3407. refresh
  3408. end
  3409. #--------------------------------------------------------------------------
  3410. # * Acquiring Item
  3411. #--------------------------------------------------------------------------
  3412. def item
  3413. return @data[self.index]
  3414. end
  3415. #--------------------------------------------------------------------------
  3416. # * Refresh
  3417. #--------------------------------------------------------------------------
  3418. def refresh
  3419. if self.contents != nil
  3420. self.contents.dispose
  3421. self.contents = nil
  3422. end
  3423. @data = []
  3424. (1...$data_items.size).each {|i|
  3425. item = $data_items[i]
  3426. @data.push(item) if [0, 1].include?(item.occasion) && $game_party.item_number(item.id) > 0
  3427. }
  3428. # If item count is not 0, make a bit map and draw all items
  3429. @item_max = @data.size
  3430. if @item_max > 0
  3431. self.contents = Bitmap.new(width - 32, row_max * 32)
  3432. (0...@item_max).each {|i| draw_item(i)}
  3433. end
  3434. end
  3435. #--------------------------------------------------------------------------
  3436. # * Draw Item
  3437. # index : item number
  3438. #--------------------------------------------------------------------------
  3439. def draw_item(index)
  3440. item = @data[index]
  3441. x = 4 + index % 1 * (288 + 32)
  3442. y = index * 32
  3443. rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  3444. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  3445. bitmap = RPG::Cache.icon(item.icon_name)
  3446. self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  3447. self.contents.draw_text(x + 28, y, 204, 32, item.name, 0)
  3448. end
  3449. #--------------------------------------------------------------------------
  3450. # * Help Text Update
  3451. #--------------------------------------------------------------------------
  3452. def update_help
  3453. @help_window.set_item(self.item)
  3454. end
  3455. #--------------------------------------------------------------------------
  3456. end
  3457.  
  3458. #===========================================================
  3459. # ** Window_SkillHelp
  3460. #------------------------------------------------------------------------------
  3461. # This window displays skill effect on the battle screen. Also works for items.
  3462. #===========================================================
  3463.  
  3464. class Window_SkillHelp < Window_Base
  3465. #--------------------------------------------------------------------------
  3466. # * Object Initialization
  3467. #--------------------------------------------------------------------------
  3468. def initialize
  3469. super(240, 128, 240, 256)
  3470. self.back_opacity = 160
  3471. self.contents = Bitmap.new(width - 32, height - 32)
  3472. self.z = 7000
  3473. end
  3474. #--------------------------------------------------------------------------
  3475. # * Set skill
  3476. #--------------------------------------------------------------------------
  3477. def set_skill(skill, actor)
  3478. if @skill != skill || @actor != actor
  3479. @skill = skill
  3480. @actor = actor
  3481. self.contents.clear
  3482. draw_skill_hp_cost if !$game_system.vanguards_sp
  3483. draw_skill_sp_cost if $game_system.vanguards_sp
  3484. draw_skill_description
  3485. end
  3486. end
  3487. #--------------------------------------------------------------------------
  3488. # * Set item
  3489. #--------------------------------------------------------------------------
  3490. def set_item(item)
  3491. if @skill != item
  3492. @skill = item
  3493. self.contents.clear
  3494. draw_item_number
  3495. draw_skill_description
  3496. end
  3497. end
  3498. #--------------------------------------------------------------------------
  3499. # * Draw the hp cost of the skill
  3500. #--------------------------------------------------------------------------
  3501. def draw_skill_hp_cost
  3502. self.contents.font.color = system_color
  3503. self.contents.font.italic = true
  3504. self.contents.draw_text(0, 0, 96, 32, 'HP Cost')
  3505. self.contents.font.color = normal_color
  3506. self.contents.draw_text(87, 0, 96, 32, ((@actor.maxhp * @skill.sp_cost) / 100).to_s)
  3507. self.contents.font.italic = false
  3508. end
  3509. #--------------------------------------------------------------------------
  3510. # * Draw the sp cost of the skill
  3511. #--------------------------------------------------------------------------
  3512. def draw_skill_sp_cost
  3513. self.contents.font.color = system_color
  3514. self.contents.font.italic = true
  3515. self.contents.draw_text(0, 0, 96, 32, 'SP Cost')
  3516. self.contents.font.color = normal_color
  3517. self.contents.draw_text(87, 0, 96, 32, @skill.sp_cost.to_s)
  3518. self.contents.font.italic = false
  3519. end
  3520. #--------------------------------------------------------------------------
  3521. # * Draw skill description
  3522. #--------------------------------------------------------------------------
  3523. def draw_skill_description
  3524. # Break the text in lines
  3525. lines, last_word, current_text = [], 0, ''
  3526. text = @skill.description.clone
  3527. (0..text.size).each do |i|
  3528. if text[i, 1] == ' ' || i == text.size || text[i, 2] == "\n"
  3529. word = text[last_word, i-last_word]
  3530. if self.contents.text_size("#{current_text} #{word}").width > (self.width - 32) ||
  3531. word.include?("\n")
  3532. lines.push(current_text)
  3533. current_text = word
  3534. else
  3535. current_text += (current_text == '' ? word : " #{word}")
  3536. end
  3537. last_word = i+1
  3538. end
  3539. end
  3540. lines.push("#{current_text} #{text[last_word, text.size-last_word]}")
  3541. # Draw the text
  3542. self.contents.font.color = normal_color
  3543. lines.each_index {|i| self.contents.draw_text(0, 32 + 32 * i, self.width - 32, 32, lines[i])}
  3544. end
  3545. #--------------------------------------------------------------------------
  3546. # * Draw the number possessed of an item
  3547. #--------------------------------------------------------------------------
  3548. def draw_item_number
  3549. self.contents.font.color = system_color
  3550. self.contents.font.italic = true
  3551. self.contents.draw_text(0, 0, 96, 32, 'Possessed')
  3552. self.contents.font.color = normal_color
  3553. self.contents.draw_text(103, 0, 96, 32, $game_party.item_number(@skill.id).to_s)
  3554. self.contents.font.italic = false
  3555. end
  3556. #--------------------------------------------------------------------------
  3557. end
  3558.  
  3559. #===========================================================
  3560. # ** Window_SongHelp
  3561. #------------------------------------------------------------------------------
  3562. # This window displays Song Magic effect on the battle screen
  3563. #===========================================================
  3564.  
  3565. class Window_SongHelp < Window_Base
  3566. #--------------------------------------------------------------------------
  3567. # * Object Initialization
  3568. #--------------------------------------------------------------------------
  3569. def initialize
  3570. super(240, 128, 320, 256)
  3571. self.back_opacity = 160
  3572. self.contents = Bitmap.new(width - 32, height - 32)
  3573. self.z = 7000
  3574. end
  3575. #--------------------------------------------------------------------------
  3576. # * Set skill
  3577. #--------------------------------------------------------------------------
  3578. def set_skill(skill)
  3579. if @skill != skill
  3580. @skill = skill
  3581. self.contents.clear
  3582. draw_skill_category
  3583. draw_ruler
  3584. draw_skill_sp_cost
  3585. draw_skill_description
  3586. draw_burst_evolutions
  3587. end
  3588. end
  3589. #--------------------------------------------------------------------------
  3590. # * Draw Song Magic category (Red or Blue)
  3591. #--------------------------------------------------------------------------
  3592. def draw_skill_category
  3593. category = @skill.scope == 2 ? KreadCFG::SongRed : KreadCFG::SongBlue
  3594. self.contents.font.color = system_color
  3595. self.contents.draw_text(0, 0, 240, 32, category)
  3596. end
  3597. #--------------------------------------------------------------------------
  3598. # * Draw ruler
  3599. #--------------------------------------------------------------------------
  3600. def draw_ruler
  3601. self.contents.font.name = 'Arial'
  3602. self.contents.font.size = 16
  3603. char_size = self.contents.text_size('_').width
  3604. self.contents.draw_text(0, 8, self.width - 40, 32, '_' * ((self.width - 40) / char_size), 1)
  3605. self.contents.font.name = Font.default_name
  3606. self.contents.font.size = Font.default_size
  3607. end
  3608. #--------------------------------------------------------------------------
  3609. # * Draw the sp cost of the skill
  3610. #--------------------------------------------------------------------------
  3611. def draw_skill_sp_cost
  3612. self.contents.font.italic = true
  3613. self.contents.draw_text(0, 192, 96, 32, 'SP Rate')
  3614. self.contents.font.color = normal_color
  3615. self.contents.draw_text(72, 192, 96, 32, @skill.sp_cost.to_s)
  3616. self.contents.font.italic = false
  3617. end
  3618. #--------------------------------------------------------------------------
  3619. # * Draw skill description
  3620. #--------------------------------------------------------------------------
  3621. def draw_skill_description
  3622. # Break the text in lines
  3623. @lines, last_word, current_text = [], 0, ''
  3624. text = @skill.description.clone
  3625. (0..text.size).each do |i|
  3626. if text[i, 1] == ' ' || i == text.size || text[i, 2] == "\n"
  3627. word = text[last_word, i-last_word]
  3628. if self.contents.text_size("#{current_text} #{word}").width > (self.width - 32) ||
  3629. word.include?("\n")
  3630. @lines.push(current_text)
  3631. current_text = word
  3632. else
  3633. current_text += (current_text == '' ? word : " #{word}")
  3634. end
  3635. last_word = i+1
  3636. end
  3637. end
  3638. @lines.push("#{current_text} #{text[last_word, text.size-last_word]}")
  3639. # Draw the text
  3640. self.contents.font.color = normal_color
  3641. @lines.each_index {|i| self.contents.draw_text(0, 32 + 32 * i, self.width - 32, 32, @lines[i])}
  3642. end
  3643. #--------------------------------------------------------------------------
  3644. # * Draw burst evolutions
  3645. #--------------------------------------------------------------------------
  3646. def draw_burst_evolutions
  3647. # Checks evolution pattern
  3648. pattern = []
  3649. bursts = []
  3650. new_skill = @skill.id
  3651. while new_skill != nil
  3652. unless new_skill == @skill.id
  3653. pattern.push($data_skills[new_skill])
  3654. bursts.push(KreadCFG::SongMagicMaxBurst[new_skill])
  3655. end
  3656. new_skill = KreadCFG::SongMagicEvolve[new_skill]
  3657. end
  3658. # Draws the pattern on the window
  3659. return if pattern.size == 0
  3660. y = 32 + 32 * @lines.size
  3661. self.contents.font.color = system_color
  3662. self.contents.font.italic = true
  3663. (0...pattern.size).each {|i|
  3664. self.contents.draw_text(0, y + i * 32, 320, 32,
  3665. "Becomes #{pattern[i].name} at #{bursts[i]}%.")
  3666. }
  3667. end
  3668. #--------------------------------------------------------------------------
  3669. end
  3670.  
  3671. #===========================================================
  3672. # ** Battle_Status
  3673. #------------------------------------------------------------------------------
  3674. # Displays the status of a party member on the battle screen.
  3675. #===========================================================
  3676.  
  3677. class Battle_Status < Window_Base
  3678. #--------------------------------------------------------------------------
  3679. # * Object Initialization
  3680. #--------------------------------------------------------------------------
  3681. def initialize(actor_index)
  3682. super(432, 0, 240, 96)
  3683. self.contents = Bitmap.new(width - 32, height - 32)
  3684. self.contents.font.name = ['Staccato222 BT', 'Arial']
  3685. self.contents.font.size = 20
  3686. self.z = 900
  3687. self.opacity = 0
  3688. # Get actor
  3689. @actor = $game_party.actors[actor_index]
  3690. refresh
  3691. end
  3692. #--------------------------------------------------------------------------
  3693. # * Refresh
  3694. #--------------------------------------------------------------------------
  3695. def refresh
  3696. self.contents.clear
  3697. # Create the background
  3698. if !KreadCFG.is_reyvateil?(@actor) && !$game_system.vanguards_sp
  3699. back = RPG::Cache.picture('Status_Window2')
  3700. else
  3701. back = RPG::Cache.picture('Status_Window')
  3702. end
  3703. self.contents.blt(0, 0, back, back.rect)
  3704. # Create the face
  3705. face = RPG::Cache.picture("Status_Window_#{@actor.name}")
  3706. self.contents.blt(144, 4, face, face.rect)
  3707. # Display HP and SP
  3708. refresh_hp
  3709. refresh_sp
  3710. end
  3711. #--------------------------------------------------------------------------
  3712. # * Draws current and max HP
  3713. #--------------------------------------------------------------------------
  3714. def refresh_hp
  3715. # Computes HP / Max HP ratio
  3716. ratio = @actor.hp.to_f / @actor.maxhp.to_f
  3717. # Draws Bar
  3718. bar = RPG::Cache.picture('HpBar_Full')
  3719. rect = Rect.new(0, 0, (ratio * bar.width).round, bar.height)
  3720. self.contents.blt(49, 22, bar, rect)
  3721. first_text_size = self.contents.text_size(@actor.hp.to_s).width
  3722. second_text_size = self.contents.text_size("/#{@actor.maxhp}").width
  3723. # Draws the values
  3724. self.contents.font.color = @actor.hp == 0 ? Color.new(255, 64, 0) :
  3725. (@actor.hp <= @actor.maxhp / 4) ? Color.new(255, 255, 64) : Color.new(255, 255, 255)
  3726. self.contents.draw_outlined_text(48, 0, bar.width - second_text_size, 32, @actor.hp.to_s, 1)
  3727. self.contents.font.color = Color.new(255, 255, 255)
  3728. self.contents.draw_outlined_text(48 + first_text_size, 0, bar.width - first_text_size, 32,
  3729. "/#{@actor.maxhp}", 1)
  3730. end
  3731. #--------------------------------------------------------------------------
  3732. # * Draws current and max SP
  3733. #--------------------------------------------------------------------------
  3734. def refresh_sp
  3735. # Quit in the actor is a vanguard and SP usage disabled
  3736. return if !KreadCFG.is_reyvateil?(@actor) && !$game_system.vanguards_sp
  3737. # Computes SP / Max SP ratio
  3738. ratio = @actor.sp.to_f / @actor.maxsp.to_f
  3739. # Draws Bar
  3740. bar = RPG::Cache.picture('SpBar_Full')
  3741. rect = Rect.new(0, 0, (ratio * bar.width).round, bar.height)
  3742. self.contents.blt(49, 42, bar, rect)
  3743. first_text_size = self.contents.text_size(@actor.sp.to_s).width
  3744. second_text_size = self.contents.text_size("/#{@actor.maxsp}").width
  3745. # Draws the values
  3746. self.contents.font.color = @actor.sp == 0 ? Color.new(255, 64, 0) :
  3747. (@actor.sp <= @actor.maxsp / 4) ? Color.new(255, 255, 64) : Color.new(255, 255, 255)
  3748. self.contents.draw_outlined_text(48, 20, bar.width - second_text_size, 32, @actor.sp.to_s, 1)
  3749. self.contents.font.color = Color.new(255, 255, 255)
  3750. self.contents.draw_outlined_text(48 + first_text_size, 20, bar.width - first_text_size, 32,
  3751. "/#{@actor.maxsp}", 1)
  3752. end
  3753. #--------------------------------------------------------------------------
  3754. # * Draws current and max SP (Reyvateil chanting only)
  3755. #--------------------------------------------------------------------------
  3756. def refresh_sp_only
  3757. # Clears the SP part of the bitmap
  3758. crop = RPG::Cache.picture('Status_Window_Crop')
  3759. self.contents.fill_rect(4, 28, 140, 20, Color.new(0, 0, 0, 0))
  3760. self.contents.blt(4, 28, crop, crop.rect)
  3761. # Computes SP / Max SP ratio
  3762. ratio = @actor.sp.to_f / @actor.maxsp.to_f
  3763. # Draw bar
  3764. bar = RPG::Cache.picture('SpBar_Full')
  3765. rect = Rect.new(0, 0, (ratio * bar.width).round, bar.height)
  3766. self.contents.blt(49, 42, bar, rect)
  3767. first_text_size = self.contents.text_size(@actor.sp.to_s).width
  3768. second_text_size = self.contents.text_size("/#{@actor.maxsp}").width
  3769. # Draws the values
  3770. self.contents.font.color = @actor.sp == 0 ? Color.new(255, 64, 0) :
  3771. (@actor.sp <= @actor.maxsp / 4) ? Color.new(255, 255, 64) : Color.new(255, 255, 255)
  3772. self.contents.draw_outlined_text(48, 20, bar.width - second_text_size, 32, @actor.sp.to_s, 1)
  3773. self.contents.font.color = Color.new(255, 255, 255)
  3774. self.contents.draw_outlined_text(48 + first_text_size, 20, bar.width - first_text_size, 32,
  3775. "/#{@actor.maxsp}", 1)
  3776. end
  3777. #--------------------------------------------------------------------------
  3778. end
  3779.  
  3780. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  3781. # Ar Tonelico Custom Battle System
  3782. # Author: Kread-EX
  3783. # Version 1.1
  3784. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  3785.  
  3786. #===========================================================
  3787. # ** Game_System
  3788. #------------------------------------------------------------------------------
  3789. # This class handles data surrounding the system. Backround music, etc.
  3790. # is managed here as well. Refer to "$game_system" for the instance of
  3791. # this class.
  3792. #===========================================================
  3793.  
  3794. class Game_System
  3795. #--------------------------------------------------------------------------
  3796. # * Public Instance Variables
  3797. #--------------------------------------------------------------------------
  3798. attr_accessor :ambiance_field # If true, the ambiance field is activated
  3799. attr_accessor :vanguards_sp # If true, the front liners use SP for their skills
  3800. #--------------------------------------------------------------------------
  3801. # * Object Initialization
  3802. #--------------------------------------------------------------------------
  3803. alias_method :krx_atcbs_initialize, :initialize
  3804. def initialize
  3805. krx_atcbs_initialize
  3806. @ambiance_field = true
  3807. @vanguards_sp = false
  3808. end
  3809. #--------------------------------------------------------------------------
  3810. end
  3811.  
  3812. #===========================================================
  3813. # ** Game_Battler
  3814. #------------------------------------------------------------------------------
  3815. # This class deals with battlers. It's used as a superclass for the Game_Actor
  3816. # and Game_Enemy classes.
  3817. #===========================================================
  3818.  
  3819. class Game_Battler
  3820. #--------------------------------------------------------------------------
  3821. # * Public Instance Variables
  3822. #--------------------------------------------------------------------------
  3823. attr_accessor :action_meter # Sort of ATB counter - roughly
  3824. attr_accessor :song_chant # If true, the a song is currently active
  3825. attr_accessor :song_blue # If true, the current song is Blue Magic
  3826. attr_accessor :burst_value # Actual burst value for the song
  3827. attr_accessor :harmonics # Actual harmonics value (Reyvateil only)
  3828. attr_accessor :loop_animation_id # ID of the looping animation
  3829. #--------------------------------------------------------------------------
  3830. # * Object Initialization
  3831. #--------------------------------------------------------------------------
  3832. alias_method :krx_atcbs_initialize, :initialize
  3833. def initialize
  3834. krx_atcbs_initialize
  3835. @action_meter = 0
  3836. @song_chant = false
  3837. @song_blue = false
  3838. @burst_value = 0
  3839. @harmonics = 0
  3840. @loop_animation_id = 0
  3841. @damage = []
  3842. end
  3843. #--------------------------------------------------------------------------
  3844. # * Determine Usable Skills
  3845. # skill_id : skill ID
  3846. #--------------------------------------------------------------------------
  3847. def skill_can_use?(skill_id)
  3848. # Check HP requirements.
  3849. if !$game_system.vanguards_sp
  3850. if self.is_a?(Game_Actor) && !KreadCFG.is_reyvateil?(self)
  3851. return false if self.hp <= (self.maxhp * $data_skills[skill_id].sp_cost) / 100
  3852. end
  3853. end
  3854. # In case of Harmo Overdrive, need the correct amount of Harmonics
  3855. if KreadCFG::HarmoOverdriveSkills.include?(skill_id) && self.is_a?(Game_Actor)
  3856. if $game_party.global_harmonics < $game_temp.max_harmonics
  3857. return false
  3858. end
  3859. end
  3860. # If there's not enough SP, the skill cannot be used.
  3861. if $data_skills[skill_id].sp_cost > self.sp
  3862. return false
  3863. end
  3864. # Unusable if incapacitated
  3865. if dead?
  3866. return false
  3867. end
  3868. # If silent, only physical skills can be used
  3869. if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
  3870. return false
  3871. end
  3872. # Get usable time
  3873. occasion = $data_skills[skill_id].occasion
  3874. # If in battle
  3875. if $game_temp.in_battle
  3876. # Usable with [Normal] and [Only Battle]
  3877. return (occasion == 0 or occasion == 1)
  3878. # If not in battle
  3879. else
  3880. # Usable with [Normal] and [Only Menu]
  3881. return (occasion == 0 or occasion == 2)
  3882. end
  3883. end
  3884. #--------------------------------------------------------------------------
  3885. # * Applying Normal Attack Effects
  3886. # attacker : battler
  3887. #--------------------------------------------------------------------------
  3888. def attack_effect(attacker)
  3889. # Clear critical flag
  3890. self.critical = false
  3891. # First hit detection
  3892. hit_result = (rand(100) < attacker.hit)
  3893. # If hit occurs
  3894. if hit_result == true
  3895. # Calculate basic damage
  3896. atk = [attacker.atk - self.pdef / 2, 0].max
  3897. self.damage[0] = atk * (20 + attacker.str) / 20
  3898. # Element correction
  3899. self.damage[0] *= elements_correct(attacker.element_set)
  3900. self.damage[0] /= 100
  3901. # If damage value is strictly positive
  3902. if self.damage[0] > 0
  3903. # Critical correction
  3904. if rand(100) < 4 * attacker.dex / self.agi
  3905. self.damage[0] *= 2
  3906. self.critical = true
  3907. end
  3908. # Guard correction
  3909. self.damage[0] /= 2 if self.guarding?
  3910. end
  3911. # Dispersion
  3912. if self.damage[0].abs > 0
  3913. amp = [self.damage[0].abs * 15 / 100, 1].max
  3914. self.damage[0] += rand(amp+1) + rand(amp+1) - amp
  3915. end
  3916. # Second hit detection
  3917. eva = 8 * self.agi / attacker.dex + self.eva
  3918. hit = self.damage[0] < 0 ? 100 : 100 - eva
  3919. hit = self.cant_evade? ? 100 : hit
  3920. hit_result = (rand(100) < hit)
  3921. end
  3922. # If hit occurs
  3923. if hit_result == true
  3924. # State Removed by Shock
  3925. remove_states_shock
  3926. # Substract damage from HP
  3927. self.hp -= self.damage[0]
  3928. # Raise Ambiance Field
  3929. if $game_system.ambiance_field
  3930. @ambiance_field = [(@ambiance_field + 1), 3].min if self.is_a?(Game_Enemy)
  3931. end
  3932. # State change
  3933. @state_changed = false
  3934. states_plus(attacker.plus_state_set)
  3935. states_minus(attacker.minus_state_set)
  3936. # Update harmonics
  3937. if attacker.is_a?(Game_Actor)
  3938. $scene.vanguards_harmonics += 50
  3939. else
  3940. if KreadCFG.return_reyvateil == self
  3941. $scene.reyvateil_harmonics -= 50
  3942. else
  3943. $scene.vanguards_harmonics -= 50
  3944. end
  3945. end
  3946. # When missing
  3947. else
  3948. # Set damage to "Miss"
  3949. self.damage[0] = 'Miss'
  3950. # Clear critical flag
  3951. self.critical = false
  3952. end
  3953. # End Method
  3954. return true
  3955. end
  3956. #--------------------------------------------------------------------------
  3957. # * Apply Skill Effects
  3958. # user : the one using skills (battler)
  3959. # skill : skill
  3960. #--------------------------------------------------------------------------
  3961. def skill_effect(user, skill, hit_number = 0)
  3962. # Clear critical flag
  3963. self.critical = false
  3964. # If skill scope is for ally with 1 or more HP, and your own HP = 0,
  3965. # or skill scope is for ally with 0, and your own HP = 1 or more
  3966. if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  3967. ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  3968. # End Method
  3969. return false
  3970. end
  3971. # Clear effective flag
  3972. effective = false
  3973. # Set effective flag if common ID is effective
  3974. effective |= skill.common_event_id > 0
  3975. # First hit detection
  3976. hit = skill.hit
  3977. if skill.atk_f > 0
  3978. hit *= user.hit / 100
  3979. end
  3980. hit_result = (rand(100) < hit)
  3981. # Set effective flag if skill is uncertain
  3982. effective |= hit < 100
  3983. # If hit occurs
  3984. if hit_result == true
  3985. # Calculate power
  3986. power = skill.power + user.atk * skill.atk_f / 100
  3987. if power > 0
  3988. power -= self.pdef * skill.pdef_f / 200
  3989. power -= self.mdef * skill.mdef_f / 200
  3990. power = [power, 0].max
  3991. end
  3992. # Calculate rate
  3993. rate = 20
  3994. rate += (user.str * skill.str_f / 100)
  3995. rate += (user.dex * skill.dex_f / 100)
  3996. rate += (user.agi * skill.agi_f / 100)
  3997. rate += (user.int * skill.int_f / 100)
  3998. # Calculate basic damage
  3999. self.damage[hit_number] = power * rate / 20
  4000. # Element correction
  4001. self.damage[hit_number] *= elements_correct(skill.element_set)
  4002. self.damage[hit_number] /= 100
  4003. # If damage value is strictly positive
  4004. if self.damage[hit_number] > 0
  4005. # Raise Ambiance Field
  4006. @ambiance_field = [(@ambiance_field + 1), 3].min if self.is_a?(Game_Enemy)
  4007. # Guard correction
  4008. if self.guarding?
  4009. self.damage[hit_number] /= 2
  4010. end
  4011. end
  4012. # Dispersion
  4013. if skill.variance > 0 and self.damage[-1].abs > 0
  4014. amp = [self.damage[hit_number].abs * skill.variance / 100, 1].max
  4015. self.damage[hit_number] += rand(amp+1) + rand(amp+1) - amp
  4016. end
  4017. # Second hit detection
  4018. eva = 8 * self.agi / user.dex + self.eva
  4019. hit = self.damage[hit_number] < 0 ? 100 : 100 - eva * skill.eva_f / 100
  4020. hit = self.cant_evade? ? 100 : hit
  4021. hit_result = (rand(100) < hit)
  4022. # Set effective flag if skill is uncertain
  4023. effective |= hit < 100
  4024. end
  4025. # If hit occurs
  4026. if hit_result == true
  4027. # Update harmonics
  4028. if hit_number == 0 && !KreadCFG::HarmoOverdriveSkills.include?(skill.id) && skill.scope < 3
  4029. if user.is_a?(Game_Actor)
  4030. $scene.vanguards_harmonics += skill.scope == 1 ? 80 : 20
  4031. else
  4032. if KreadCFG.return_reyvateil == self
  4033. $scene.reyvateil_harmonics -= 80
  4034. else
  4035. $scene.vanguards_harmonics -= skill.scope == 1 ? 80 : 20
  4036. end
  4037. end
  4038. end
  4039. # If physical attack has power other than 0
  4040. if skill.power != 0 and skill.atk_f > 0
  4041. # State Removed by Shock
  4042. remove_states_shock
  4043. # Set to effective flag
  4044. effective = true
  4045. end
  4046. # Substract damage from HP
  4047. last_hp = self.hp
  4048. self.hp -= self.damage[hit_number]
  4049. effective |= self.hp != last_hp
  4050. # State change
  4051. @state_changed = false
  4052. effective |= states_plus(skill.plus_state_set)
  4053. effective |= states_minus(skill.minus_state_set)
  4054. # If power is 0
  4055. if skill.power == 0
  4056. # Set damage to an empty string
  4057. self.damage[hit_number] = ''
  4058. # If state is unchanged
  4059. unless @state_changed
  4060. # Set damage to "Miss"
  4061. self.damage[hit_number] = 'Miss'
  4062. end
  4063. end
  4064. # If miss occurs
  4065. else
  4066. # Set damage to "Miss"
  4067. self.damage[hit_number] = 'Miss'
  4068. end
  4069. # If not in battle
  4070. unless $game_temp.in_battle
  4071. # Set damage to an empty array
  4072. self.damage = []
  4073. end
  4074. # End Method
  4075. return effective
  4076. end
  4077. #--------------------------------------------------------------------------
  4078. # * Apply Song Magic effects
  4079. # user : the Reyvateil
  4080. # skill : skill
  4081. #--------------------------------------------------------------------------
  4082. def song_effect(user, skill, hit_number = 0)
  4083. # If skill scope is for ally with 1 or more HP, and your own HP = 0,
  4084. # or skill scope is for ally with 0, and your own HP = 1 or more
  4085. if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  4086. ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  4087. # End Method
  4088. return false
  4089. end
  4090. # Song Magic never miss, so no hit detection is performed
  4091. # Power calculation method (for Red Magic only):
  4092. if skill.scope == 2
  4093. power = (([(user.int - self.mdef), 0].max + user.burst_value) * (skill.power / 100.00)).round
  4094. else
  4095. # For Blue Magic, skill base power only
  4096. power = skill.power
  4097. power -= user.int if power != 0
  4098. end
  4099. self.damage[hit_number] = power
  4100. # Ambiance Field correction
  4101. self.damage[hit_number] += (@ambiance_field / 3) * power if self.damage[hit_number] > 0
  4102. # Element correction
  4103. self.damage[hit_number] *= elements_correct(skill.element_set)
  4104. self.damage[hit_number] /= 100
  4105. # Dispersion
  4106. if skill.variance > 0 and self.damage[hit_number].abs > 0
  4107. amp = [self.damage[hit_number].abs * skill.variance / 100, 1].max
  4108. self.damage[hit_number] += rand(amp+1) + rand(amp+1) - amp
  4109. end
  4110. # Substract damage from HP
  4111. last_hp = self.hp
  4112. self.hp -= self.damage[hit_number]
  4113. return true
  4114. end
  4115. #--------------------------------------------------------------------------
  4116. # * Application of Item Effects
  4117. # item : item
  4118. #--------------------------------------------------------------------------
  4119. def item_effect(item)
  4120. # Clear critical flag
  4121. self.critical = false
  4122. # If item scope is for ally with 1 or more HP, and your own HP = 0,
  4123. # or item scope is for ally with 0 HP, and your own HP = 1 or more
  4124. if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  4125. ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  4126. # End Method
  4127. return false
  4128. end
  4129. # Clear effective flag
  4130. effective = false
  4131. # Set effective flag if common ID is effective
  4132. effective |= item.common_event_id > 0
  4133. # Determine hit
  4134. hit_result = (rand(100) < item.hit)
  4135. # Set effective flag is skill is uncertain
  4136. effective |= item.hit < 100
  4137. # If hit occurs
  4138. if hit_result == true
  4139. # Calculate amount of recovery
  4140. recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  4141. recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  4142. if recover_hp < 0
  4143. recover_hp += self.pdef * item.pdef_f / 20
  4144. recover_hp += self.mdef * item.mdef_f / 20
  4145. recover_hp = [recover_hp, 0].min
  4146. end
  4147. # Element correction
  4148. recover_hp *= elements_correct(item.element_set)
  4149. recover_hp /= 100
  4150. recover_sp *= elements_correct(item.element_set)
  4151. recover_sp /= 100
  4152. # Dispersion
  4153. if item.variance > 0 and recover_hp.abs > 0
  4154. amp = [recover_hp.abs * item.variance / 100, 1].max
  4155. recover_hp += rand(amp+1) + rand(amp+1) - amp
  4156. end
  4157. if item.variance > 0 and recover_sp.abs > 0
  4158. amp = [recover_sp.abs * item.variance / 100, 1].max
  4159. recover_sp += rand(amp+1) + rand(amp+1) - amp
  4160. end
  4161. # If recovery code is negative
  4162. if recover_hp < 0
  4163. # Guard correction
  4164. if self.guarding?
  4165. recover_hp /= 2
  4166. end
  4167. end
  4168. # Set damage value and reverse HP recovery amount
  4169. self.damage << -recover_hp
  4170. # HP and SP recovery
  4171. last_hp = self.hp
  4172. last_sp = self.sp
  4173. self.hp += recover_hp
  4174. self.sp += recover_sp
  4175. effective |= self.hp != last_hp
  4176. effective |= self.sp != last_sp
  4177. # State change
  4178. @state_changed = false
  4179. effective |= states_plus(item.plus_state_set)
  4180. effective |= states_minus(item.minus_state_set)
  4181. # If parameter value increase is effective
  4182. if item.parameter_type > 0 and item.parameter_points != 0
  4183. # Branch by parameter
  4184. case item.parameter_type
  4185. when 1 # Max HP
  4186. @maxhp_plus += item.parameter_points
  4187. when 2 # Max SP
  4188. @maxsp_plus += item.parameter_points
  4189. when 3 # Strength
  4190. @str_plus += item.parameter_points
  4191. when 4 # Dexterity
  4192. @dex_plus += item.parameter_points
  4193. when 5 # Agility
  4194. @agi_plus += item.parameter_points
  4195. when 6 # Intelligence
  4196. @int_plus += item.parameter_points
  4197. end
  4198. # Set to effective flag
  4199. effective = true
  4200. end
  4201. # If HP recovery rate and recovery amount are 0
  4202. if item.recover_hp_rate == 0 and item.recover_hp == 0
  4203. # Set damage to empty string
  4204. self.damage << ''
  4205. # If SP recovery rate / recovery amount are 0, and parameter increase
  4206. # value is ineffective.
  4207. if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  4208. (item.parameter_type == 0 or item.parameter_points == 0)
  4209. # If state is unchanged
  4210. unless @state_changed
  4211. # Set damage to "Miss"
  4212. self.damage << 'Miss'
  4213. end
  4214. end
  4215. end
  4216. # If miss occurs
  4217. else
  4218. # Set damage to "Miss"
  4219. self.damage << 'Miss'
  4220. end
  4221. # If not in battle
  4222. unless $game_temp.in_battle
  4223. # Set damage to an empty array
  4224. self.damage = []
  4225. end
  4226. # End Method
  4227. return effective
  4228. end
  4229. #--------------------------------------------------------------------------
  4230. # * Application of Slip Damage Effects
  4231. #--------------------------------------------------------------------------
  4232. def slip_damage_effect
  4233. # Set damage
  4234. self.damage << self.maxhp / 10
  4235. # Dispersion
  4236. if self.damage[-1].abs > 0
  4237. amp = [self.damage[-1].abs * 15 / 100, 1].max
  4238. self.damage[-1] += rand(amp+1) + rand(amp+1) - amp
  4239. end
  4240. # Subtract damage from HP
  4241. self.hp -= self.damage[-1]
  4242. # End Method
  4243. return true
  4244. end
  4245. #--------------------------------------------------------------------------
  4246. end
  4247.  
  4248. #===========================================================
  4249. # ** Game_Enemy
  4250. #------------------------------------------------------------------------------
  4251. # This class handles enemies. It's used within the Game_Troop class
  4252. # ($game_troop).
  4253. #===========================================================
  4254.  
  4255. class Game_Enemy < Game_Battler
  4256. #--------------------------------------------------------------------------
  4257. # * Public Instance Variables
  4258. #--------------------------------------------------------------------------
  4259. attr_accessor :ambiance_field
  4260. #--------------------------------------------------------------------------
  4261. # * Object Initialization
  4262. #--------------------------------------------------------------------------
  4263. alias_method :krx_atcbs_game_enemy_initialize, :initialize
  4264. def initialize(troop_id, member_index)
  4265. @ambiance_field = 0
  4266. krx_atcbs_game_enemy_initialize(troop_id, member_index)
  4267. end
  4268. #--------------------------------------------------------------------------
  4269. # * Make Action
  4270. #--------------------------------------------------------------------------
  4271. def make_action
  4272. # Clear current action
  4273. self.current_action.clear
  4274. # If unable to move
  4275. unless self.movable?
  4276. # End Method
  4277. return
  4278. end
  4279. # Extract current effective actions
  4280. available_actions = []
  4281. rating_max = 0
  4282. for action in self.actions
  4283. # Confirm turn conditions
  4284. n = $game_temp.battle_turn
  4285. a = action.condition_turn_a
  4286. b = action.condition_turn_b
  4287. if (b == 0 and n != a) or
  4288. (b > 0 and (n < 1 or n < a or n % b != a % b))
  4289. next
  4290. end
  4291. # Confirm HP conditions
  4292. if self.hp * 100.0 / self.maxhp > action.condition_hp
  4293. next
  4294. end
  4295. # Confirm level conditions
  4296. if $game_party.max_level < action.condition_level
  4297. next
  4298. end
  4299. # Confirm switch conditions
  4300. switch_id = action.condition_switch_id
  4301. if switch_id > 0 and $game_switches[switch_id] == false
  4302. next
  4303. end
  4304. # Add this action to applicable conditions
  4305. available_actions.push(action)
  4306. if action.rating > rating_max
  4307. rating_max = action.rating
  4308. end
  4309. end
  4310. # Calculate total with max rating value at 3 (exclude 0 or less)
  4311. ratings_total = 0
  4312. for action in available_actions
  4313. if action.rating > rating_max - 3
  4314. ratings_total += action.rating - (rating_max - 3)
  4315. end
  4316. end
  4317. # If ratings total isn't 0
  4318. if ratings_total > 0
  4319. # Create random numbers
  4320. value = rand(ratings_total)
  4321. # Set things that correspond to created random numbers as current action
  4322. for action in available_actions
  4323. if action.rating > rating_max - 3
  4324. if value < action.rating - (rating_max - 3)
  4325. self.current_action.kind = action.kind
  4326. self.current_action.basic = action.basic
  4327. self.current_action.skill_id = action.skill_id
  4328. self.current_action.decide_random_target_for_enemy
  4329. case action.kind
  4330. when 0
  4331. self.action_meter = self.agi
  4332. when 1
  4333. self.action_meter = self.agi * KreadCFG.skill_speed(action.skill_id)
  4334. end
  4335. return
  4336. else
  4337. value -= action.rating - (rating_max - 3)
  4338. end
  4339. end
  4340. end
  4341. end
  4342. end
  4343. #--------------------------------------------------------------------------
  4344. end
  4345.  
  4346. #===========================================================
  4347. # ** Game_Party
  4348. #------------------------------------------------------------------------------
  4349. # This class handles the party. It includes information on amount of gold
  4350. # and items. Refer to "$game_party" for the instance of this class.
  4351. #===========================================================
  4352.  
  4353. class Game_Party
  4354. #--------------------------------------------------------------------------
  4355. # * Public Instance Variables
  4356. #--------------------------------------------------------------------------
  4357. attr_reader :harmonics # Vanguards Harmonics, without Reyvateil value
  4358. #--------------------------------------------------------------------------
  4359. # * Object Initialization
  4360. #--------------------------------------------------------------------------
  4361. alias_method :krx_atcbs_initialize, :initialize
  4362. def initialize
  4363. krx_atcbs_initialize # Original call
  4364. @harmonics = 0
  4365. end
  4366. #--------------------------------------------------------------------------
  4367. # * Change Harmonic value
  4368. #--------------------------------------------------------------------------
  4369. def harmonics=(harmonics)
  4370. @harmonics = harmonics
  4371. if self.global_harmonics > $game_temp.max_harmonics
  4372. substract = KreadCFG.return_reyvateil == nil ? 0 : KreadCFG.return_reyvateil.harmonics
  4373. @harmonics = $game_temp.max_harmonics - substract
  4374. end
  4375. end
  4376. #--------------------------------------------------------------------------
  4377. # * Returns Global Harmonics value
  4378. #--------------------------------------------------------------------------
  4379. def global_harmonics
  4380. return @harmonics if KreadCFG.return_reyvateil == nil
  4381. return (@harmonics + KreadCFG.return_reyvateil.harmonics)
  4382. end
  4383. #--------------------------------------------------------------------------
  4384. end
  4385.  
  4386. #===========================================================
  4387. # ** Game_Temp
  4388. #------------------------------------------------------------------------------
  4389. # This class handles temporary data that is not included with save data.
  4390. # Refer to "$game_temp" for the instance of this class.
  4391. #===========================================================
  4392.  
  4393. class Game_Temp
  4394. #--------------------------------------------------------------------------
  4395. # * Public Instance Variables
  4396. #--------------------------------------------------------------------------
  4397. attr_accessor :max_harmonics
  4398. #--------------------------------------------------------------------------
  4399. # * Object Initialization
  4400. #--------------------------------------------------------------------------
  4401. alias_method :krx_atcbs_initialize, :initialize
  4402. def initialize
  4403. krx_atcbs_initialize
  4404. @max_harmonics = 1000
  4405. end
  4406. #--------------------------------------------------------------------------
  4407. end
  4408.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement