Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 136.50 KB | None | 0 0
  1. class Scene_Battle
  2.  
  3. #--------------------------------------------------------------------------
  4. # * Open instance variable
  5. #--------------------------------------------------------------------------
  6. attr_reader :status_window # Status Window
  7. attr_reader :spriteset # Battle sprite
  8. attr_reader :scroll_time # Screen portable basic time
  9. attr_reader :zoom_rate # Enemy battler basic position
  10. attr_reader :drive # Camera drive
  11. attr_accessor :force # Degree of action forcing
  12. attr_accessor :camera # Present camera possession person
  13.  
  14. #--------------------------------------------------------------------------
  15. # * ATB fundamental setup
  16. #--------------------------------------------------------------------------
  17. def atb_setup
  18. # ATB initialization
  19. #
  20. # speed : Battle speed decision. The lower the value, the faster the system
  21. #
  22. # @active : Degree of active setting
  23. # 3 : Always active state
  24. # 2 : ATB pauses when selecting skill/item
  25. # 1 : Same as 2, but pauses during target selection
  26. # 0 : Same as 1, but pauses during command window selection.
  27. #
  28. # @action : Others while acting is the fact that by their causes conduct permitted?
  29. # 3 : If by his is not incapacitation, limited to you permit
  30. # 2 : If by his has not received the damage, you permit
  31. # 1 : In addition to the state of 2, if the target has not acted, you permit
  32. # 0 : Conduct is not permitted. Until it finishes to act in order, it waits
  33. #
  34. # @anime_wait : When it makes true, during battle animation damage indicating wait catches
  35. # @damage_wait : Damage indicatory waiting (as for unit frame)
  36. #
  37. # @after_wait : At the time of ally enemy total loss, until moves to next processing, waiting
  38. # [a, b] a) At the time of party total loss, b) At time of enemy total loss (unit frame)
  39. #
  40. # @enemy_speed : Thought speed of enemy. If 1 immediately conduct.
  41. # In every frame, conduct is caused with the probability of 1/@enemy_speed
  42. #
  43. # @force : With forced action forced condition at time of skill use
  44. # 2: As for skill everything not to reside permanently, by all means immediately execution
  45. # 1: As for independent skill to reside permanently, only cooperation skill immediately execution
  46. # 0: All the skill permanent residence just are done
  47. #
  48. # ($scene.force = Usually by making x, from the script of the event modification possibility)
  49. #
  50. # CAMERA DRIVE SYSTEM: This system moves the Camera POV to the currently moving battler
  51. # @drive : Camera drive system ON/OFF. When true, drive ON, when false drive OFF
  52. # @scroll_time : Time it takes to scroll/move the camera POV during battle
  53. #
  54. # @zoom_rate = [i, j] : Zoom ratio of enemy
  55. # i) When arranging in the picture first section, enlargement ratio
  56. # j) When arranging in the picture lowest section, enlargement ratio
  57. # 1 When liking to make time, 1.0 be sure to set with decimal
  58. speed = 100 #200 # IN FRAMES / FOR ATB SYSTEM
  59. @active = 2 # Active Setting (Range of 0 - 3)
  60. @action = 0 # Action Setting (Range of 0 - 3)
  61. @anime_wait = false #
  62. @damage_wait = 10 #
  63. @after_wait = [80, 0] #
  64. @enemy_speed = 30 #
  65. @force = 2 #
  66. @drive = true # Turns camera system on/off
  67. @scroll_time = 5 # Speed of camera system
  68. @zoom_rate = [0.2, 1.0] # Controls perspective of battlers on screen
  69. @help_time = 40 #
  70. @escape == false #
  71. @camera = nil # Used by system: Determines camera
  72. @max = 0 #
  73. @turn_cnt = 0 # Turns
  74. @help_wait = 0 #
  75. @action_battlers = [] # Used by system to hold battlers
  76. @synthe = [] # Used by system: For Cooperative Skills & such
  77. @spell_p = {} #
  78. @spell_e = {} #
  79. @command_a = false #
  80. @command = [] #
  81. @party = false #
  82.  
  83. for battler in $game_party.actors + $game_troop.enemies
  84. spell_reset(battler)
  85. battler.at = battler.agi * rand(speed / 2)
  86. battler.damage_pop = {}
  87. battler.damage = {}
  88. battler.damage_sp = {}
  89. battler.critical = {}
  90. battler.recover_hp = {}
  91. battler.recover_sp = {}
  92. battler.state_p = {}
  93. battler.state_m = {}
  94. battler.animation = []
  95. if battler.is_a?(Game_Actor)
  96. @max += battler.agi
  97. end
  98. end
  99.  
  100. @max *= speed
  101. @max /= $game_party.actors.size
  102.  
  103. for battler in $game_party.actors + $game_troop.enemies
  104. battler.atp = 100 * battler.at / @max
  105. end
  106. end
  107.  
  108. #--------------------------------------------------------------------------
  109. # * Full AT Gauge SE
  110. #--------------------------------------------------------------------------
  111. def fullat_se
  112. Audio.se_play("Audio/SE/005-system05", 80, 100)
  113. end
  114.  
  115. #--------------------------------------------------------------------------
  116. # * Leveling Up SE
  117. #--------------------------------------------------------------------------
  118. def levelup_se
  119. Audio.se_play("Audio/SE/056-Right02", 80, 100)
  120. end
  121.  
  122. #--------------------------------------------------------------------------
  123. # * Skill Acquisition SE
  124. #--------------------------------------------------------------------------
  125. def skill_se
  126. Audio.se_play("Audio/SE/056-Right02", 80, 150)
  127. end
  128. end
  129.  
  130. class Window_Base < Window
  131. #--------------------------------------------------------------------------
  132. # * Draw Actor ATG
  133. # actor : Actor
  134. # x : draw spot x-coordinate
  135. # y : draw spot y-coordinate
  136. # width : draw spot width
  137. #--------------------------------------------------------------------------
  138. def draw_actor_atg(actor, x, y, width = 144)
  139. if @at_gauge == nil
  140. # plus_x: revised x-coordinate
  141. # rate_x: revised X-coordinate as (%)
  142. # plus_y: revised y-coordinate
  143. # plus_width: revised width
  144. # rate_width: revised width as (%)
  145. # height: Vertical width
  146. # align1: Type 1 ( 0: left justify 1: center justify 2: right justify )
  147. # align2: Type 2 ( 0: Upper stuffing 1: Central arranging 2:Lower stuffing )
  148. # align3: Gauge type 0:Left justify 1: Right justify
  149. @plus_x = 0
  150. @rate_x = 0
  151. @plus_y = 16
  152. @plus_width = 0
  153. @rate_width = 100
  154. @width = @plus_width + width * @rate_width / 100
  155. @height = 16
  156. @align1 = 0
  157. @align2 = 1
  158. @align3 = 0
  159. # Gradation settings: grade1: Empty gauge grade2:Actual gauge
  160. # (0:On side gradation 1:Vertically gradation 2: Slantedly gradation)
  161. grade1 = 1
  162. grade2 = 0
  163. # Color setting. color1: Outermost framework, color2: Medium framework
  164. # color3: Empty framework dark color, color4: Empty framework light/write color
  165. color1 = Color.new(0, 0, 0)
  166. color2 = Color.new(255, 255, 192)
  167. color3 = Color.new(0, 0, 0, 192)
  168. color4 = Color.new(0, 0, 64, 192)
  169. # Color setting of gauge
  170. # Usually color setting of the time
  171. color5 = Color.new(0, 64, 80)
  172. color6 = Color.new(0, 128, 160)
  173. # When gauge is MAX, color setting
  174. color7 = Color.new(80, 0, 0)
  175. color8 = Color.new(240, 0, 0)
  176. # Color setting at time of cooperation skill use
  177. color9 = Color.new(80, 64, 32)
  178. color10 = Color.new(240, 192, 96)
  179. # Color setting at time of skill permanent residence
  180. color11 = Color.new(80, 0, 64)
  181. color12 = Color.new(240, 0, 192)
  182. # Drawing of gauge
  183. gauge_rect_at(@width, @height, @align3, color1, color2,
  184. color3, color4, color5, color6, color7, color8,
  185. color9, color10, color11, color12, grade1, grade2)
  186. end
  187. # Variable at substituting the width of the gauge which is drawn
  188. if actor.rtp == 0
  189. at = (width + @plus_width) * actor.atp * @rate_width / 10000
  190. else
  191. at = (width + @plus_width) * actor.rt * @rate_width / actor.rtp / 100
  192. end
  193. if at > width
  194. at = width
  195. end
  196. # Revision such as the left stuffing central posture of gauge
  197. case @align1
  198. when 1
  199. x += (@rect_width - width) / 2
  200. when 2
  201. x += @rect_width - width
  202. end
  203. case @align2
  204. when 1
  205. y -= @height / 2
  206. when 2
  207. y -= @height
  208. end
  209. self.contents.blt(x + @plus_x + width * @rate_x / 100, y + @plus_y,
  210. @at_gauge, Rect.new(0, 0, @width, @height))
  211. if @align3 == 0
  212. rect_x = 0
  213. else
  214. x += @width - at - 1
  215. rect_x = @width - at - 1
  216. end
  217. # Color setting of gauge
  218. if at == width
  219. # Gauge drawing at the time of MAX
  220. self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  221. @at_gauge, Rect.new(rect_x, @height * 2, at, @height))
  222. else
  223. if actor.rtp == 0
  224. # Usually gauge drawing of the time
  225. self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  226. @at_gauge, Rect.new(rect_x, @height, at, @height))
  227. else
  228. if actor.spell == true
  229. #Gauge drawing at time of cooperation skill use
  230. self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  231. @at_gauge, Rect.new(rect_x, @height * 3, at, @height))
  232. else
  233. # Gauge drawing at time of skill permanent residence
  234. self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  235. @at_gauge, Rect.new(rect_x, @height * 4, at, @height))
  236. end
  237. end
  238. end
  239. end
  240. end
  241.  
  242. #==============================================================================
  243. # ** Scene_Battle (part 1)
  244. #------------------------------------------------------------------------------
  245. # This class performs battle screen processing.
  246. #==============================================================================
  247.  
  248. class Scene_Battle
  249. #--------------------------------------------------------------------------
  250. # * Main Processing
  251. #--------------------------------------------------------------------------
  252. def main
  253. # Initialize each kind of temporary battle data
  254. $game_temp.in_battle = true
  255. $game_temp.battle_turn = 0
  256. $game_temp.battle_event_flags.clear
  257. $game_temp.battle_abort = false
  258. $game_temp.battle_main_phase = false
  259. $game_temp.battleback_name = $game_map.battleback_name
  260. $game_temp.forcing_battler = nil
  261. # Initialize battle event interpreter
  262. $game_system.battle_interpreter.setup(nil, 0)
  263. # Prepare troop
  264. @troop_id = $game_temp.battle_troop_id
  265. $game_troop.setup(@troop_id)
  266. atb_setup
  267. # Make actor command window
  268. s1 = $data_system.words.attack
  269. s2 = $data_system.words.skill
  270. s3 = $data_system.words.guard
  271. s4 = $data_system.words.item
  272. @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  273. @actor_command_window.y = 160
  274. @actor_command_window.back_opacity = 160
  275. @actor_command_window.active = false
  276. @actor_command_window.visible = false
  277. # Make other windows
  278. @party_command_window = Window_PartyCommand.new
  279. @help_window = Window_Help.new
  280. @help_window.back_opacity = 160
  281. @help_window.visible = false
  282. @status_window = Window_BattleStatus.new
  283. @message_window = Window_Message.new
  284. # Make sprite set
  285. @spriteset = Spriteset_Battle.new
  286. # Initialize wait count
  287. @wait_count = 0
  288. # Execute transition
  289. if $data_system.battle_transition == ""
  290. Graphics.transition(20)
  291. else
  292. Graphics.transition(40, "Graphics/Transitions/" +
  293. $data_system.battle_transition)
  294. end
  295. # Start pre-battle phase
  296. start_phase1
  297. # Main loop
  298. loop do
  299. # Update game screen
  300. Graphics.update
  301. # Update input information
  302. Input.update
  303. # Frame update
  304. update
  305. # Abort loop if screen is changed
  306. if $scene != self
  307. break
  308. end
  309. end
  310. # Refresh map
  311. $game_map.refresh
  312. # Prepare for transition
  313. Graphics.freeze
  314. # Dispose of windows
  315. @actor_command_window.dispose
  316. @party_command_window.dispose
  317. @help_window.dispose
  318. @status_window.dispose
  319. @message_window.dispose
  320. if @skill_window != nil
  321. @skill_window.dispose
  322. end
  323. if @item_window != nil
  324. @item_window.dispose
  325. end
  326. if @result_window != nil
  327. @result_window.dispose
  328. end
  329. # Dispose of spriteset
  330. @spriteset.dispose
  331. # If switching to title screen
  332. if $scene.is_a?(Scene_Title)
  333. # Fade out screen
  334. Graphics.transition
  335. Graphics.freeze
  336. end
  337. # If switching from battle test to any screen other than game over screen
  338. if $BTEST and not $scene.is_a?(Scene_Gameover)
  339. $scene = nil
  340. end
  341. end
  342. #--------------------------------------------------------------------------
  343. # * Determine Battle Win/Loss Results
  344. #--------------------------------------------------------------------------
  345. def judge
  346. # If all dead determinant is true, or number of members in party is 0
  347. if $game_party.all_dead? or $game_party.actors.size == 0
  348. # If possible to lose
  349. if $game_temp.battle_can_lose
  350. # Return to BGM before battle starts
  351. $game_system.bgm_play($game_temp.map_bgm)
  352. # Battle end
  353. battle_end(2)
  354. # Return true
  355. return true
  356. end
  357. # Setting the game over flag
  358. $game_temp.gameover = true
  359. # Return true
  360. return true
  361. end
  362. # Return false if even 1 enemy exists
  363. for enemy in $game_troop.enemies
  364. if enemy.exist?
  365. return false
  366. end
  367. end
  368. # Start after battle phase (win)
  369. start_phase5
  370. # Return true
  371. return true
  372. end
  373. #--------------------------------------------------------------------------
  374. # * Frame renewal
  375. #--------------------------------------------------------------------------
  376. def update
  377. # If battle event is running
  378. if $game_system.battle_interpreter.running?
  379. if @command.size > 0
  380. @command_a = false
  381. @command = []
  382. command_delete
  383. end
  384. @status_window.at_refresh
  385. # Update interpreter
  386. $game_system.battle_interpreter.update
  387. # If a battler which is forcing actions doesn't exist
  388. if $game_temp.forcing_battler == nil
  389. # If battle event has finished running
  390. unless $game_system.battle_interpreter.running?
  391. # Refresh status window
  392. @status_window.refresh
  393. setup_battle_event
  394. end
  395. end
  396. end
  397. # Update system (timer) and screen
  398. $game_system.update
  399. $game_screen.update
  400. # If timer has reached 0
  401. if $game_system.timer_working and $game_system.timer == 0
  402. # Abort battle
  403. $game_temp.battle_abort = true
  404. end
  405. # Update windows
  406. @help_window.update
  407. @party_command_window.update
  408. @actor_command_window.update
  409. @status_window.update
  410. @message_window.update
  411. # Update sprite set
  412. @spriteset.update
  413. # If transition is processing
  414. if $game_temp.transition_processing
  415. # Clear transition processing flag
  416. $game_temp.transition_processing = false
  417. # Execute transition
  418. if $game_temp.transition_name == ""
  419. Graphics.transition(20)
  420. else
  421. Graphics.transition(40, "Graphics/Transitions/" +
  422. $game_temp.transition_name)
  423. end
  424. end
  425. # If message window is showing
  426. if $game_temp.message_window_showing
  427. return
  428. end
  429. # If game over
  430. if $game_temp.gameover
  431. # Switch to game over screen
  432. $scene = Scene_Gameover.new
  433. return
  434. end
  435. # If returning to title screen
  436. if $game_temp.to_title
  437. # Switch to title screen
  438. $scene = Scene_Title.new
  439. return
  440. end
  441. # If battle is aborted
  442. if $game_temp.battle_abort
  443. # Return to BGM used before battle started
  444. $game_system.bgm_play($game_temp.map_bgm)
  445. # Battle ends
  446. battle_end(1)
  447. return
  448. end
  449. # If help window is waiting
  450. if @help_wait > 0
  451. @help_wait -= 1
  452. if @help_wait == 0
  453. # Hide help window
  454. @help_window.visible = false
  455. end
  456. end
  457. # When the battler forced into action doesn't exist
  458. # while the battle event is in the midst of executing
  459. if $game_temp.forcing_battler == nil and
  460. $game_system.battle_interpreter.running?
  461. return
  462. end
  463. # Branch according to phase
  464. case @phase
  465. when 0 # AT gauge renewal phase
  466. if anime_wait_return
  467. update_phase0
  468. end
  469. when 1 # pre-battle phase
  470. update_phase1
  471. return
  472. when 2 # party command phase
  473. update_phase2
  474. return
  475. when 5 # after battle phase
  476. update_phase5
  477. return
  478. end
  479. if $scene != self
  480. return
  481. end
  482. if @phase == 0
  483. if @command.size != 0 # Actor command phase
  484. if @command_a == false
  485. start_phase3
  486. end
  487. update_phase3
  488. end
  489. # If waiting
  490. if @wait_count > 0
  491. # Decrease wait count
  492. @wait_count -= 1
  493. return
  494. end
  495. update_phase4
  496. end
  497. end
  498.  
  499.  
  500. #==============================================================================
  501. # ** Scene_Battle (part 2)
  502. #------------------------------------------------------------------------------
  503. # This class performs battle screen processing.
  504. #==============================================================================
  505.  
  506. #--------------------------------------------------------------------------
  507. # * Frame renewal (AT gauge renewal phase)
  508. #--------------------------------------------------------------------------
  509. def update_phase0
  510. if $game_temp.battle_turn == 0
  511. $game_temp.battle_turn = 1
  512. end
  513. # If B button was pressed
  514. if @command_a == false and @party == false
  515. if Input.trigger?(Input::B)
  516. # Play cancel SE
  517. $game_system.se_play($data_system.cancel_se)
  518. @party = true
  519. end
  520. end
  521. if @party == true and
  522. ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  523. (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  524. # Start party command phase
  525. start_phase2
  526. return
  527. end
  528. # AT gauge increase processing
  529. cnt = 0
  530. for battler in $game_party.actors + $game_troop.enemies
  531. active?(battler)
  532. if battler.rtp == 0
  533. if battler.at >= @max
  534. if battler.is_a?(Game_Actor)
  535. if battler.inputable?
  536. unless @action_battlers.include?(battler) or
  537. @command.include?(battler) or @escape == true
  538. if battler.current_action.forcing
  539. fullat_se
  540. force_action(battler)
  541. action_start(battler)
  542. else
  543. fullat_se
  544. @command.push(battler)
  545. end
  546. end
  547. else
  548. unless @action_battlers.include?(battler) or
  549. battler == @command[0]
  550. battler.current_action.clear
  551. if @command.include?(battler)
  552. @command.delete(battler)
  553. else
  554. if battler.movable?
  555. fullat_se
  556. end
  557. end
  558. action_start(battler)
  559. end
  560. end
  561. else
  562. unless @action_battlers.include?(battler)
  563. if battler.current_action.forcing
  564. force_action(battler)
  565. action_start(battler)
  566. else
  567. if @enemy_speed != 0
  568. if rand(@enemy_speed) == 0
  569. number = cnt - $game_party.actors.size
  570. enemy_action(number)
  571. end
  572. else
  573. number = cnt - $game_party.actors.size
  574. enemy_action(number)
  575. end
  576. end
  577. end
  578. end
  579. else
  580. battler.at += battler.agi
  581. if battler.guarding?
  582. battler.at += battler.agi
  583. end
  584. if battler.movable?
  585. battler.atp = 100 * battler.at / @max
  586. end
  587. end
  588. else
  589. if battler.rt >= battler.rtp
  590. speller = synthe?(battler)
  591. if speller != nil
  592. battler = speller[0]
  593. end
  594. unless @action_battlers.include?(battler)
  595. if battler.is_a?(Game_Actor)
  596. fullat_se
  597. end
  598. battler.rt = battler.rtp
  599. action_start(battler)
  600. end
  601. else
  602. battler.rt += battler.agi
  603. speller = synthe?(battler)
  604. if speller != nil
  605. for spell in speller
  606. if spell != battler
  607. spell.rt += battler.agi
  608. end
  609. end
  610. end
  611. end
  612. end
  613. cnt += 1
  614. end
  615. # Refresh AT gauge
  616. @status_window.at_refresh
  617. # Escape processing
  618. if @escape == true and
  619. ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  620. (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  621. temp = false
  622. for battler in $game_party.actors
  623. if battler.inputable?
  624. temp = true
  625. end
  626. end
  627. if temp == true
  628. for battler in $game_party.actors
  629. if battler.at < @max and battler.inputable?
  630. temp = false
  631. break
  632. end
  633. end
  634. if temp == true
  635. @escape = false
  636. for battler in $game_party.actors
  637. battler.at %= @max
  638. end
  639. $game_temp.battle_main_phase = false
  640. update_phase2_escape
  641. end
  642. end
  643. end
  644. end
  645. #--------------------------------------------------------------------------
  646. # * Start Party Command Phase
  647. #--------------------------------------------------------------------------
  648. def start_phase2
  649. # Shift to phase 2
  650. @phase = 2
  651. @party = false
  652. # Enable party command window
  653. @party_command_window.active = true
  654. @party_command_window.visible = true
  655. # Set actor to non-selecting
  656. @actor_index = -1
  657. # Disable actor command window
  658. @actor_command_window.active = false
  659. @actor_command_window.visible = false
  660. if @command.size != 0
  661. # Actor blink effect OFF
  662. if @active_actor != nil
  663. @active_actor.blink = false
  664. end
  665. end
  666. # Camera set
  667. @camera == "party"
  668. @spriteset.screen_target(0, 0, 1)
  669. # Clear main phase flag
  670. $game_temp.battle_main_phase = false
  671. end
  672. #--------------------------------------------------------------------------
  673. # * Frame renewal (party command phase)
  674. #--------------------------------------------------------------------------
  675. def update_phase2
  676. # When C button is pushed
  677. if Input.trigger?(Input::C)
  678. # It diverges at cursor position of the party command window
  679. case @party_command_window.index
  680. when 0 # It fights
  681. # Nullifying the party command window
  682. @party_command_window.active = false
  683. @party_command_window.visible = false
  684. # Performing decision SE
  685. $game_system.se_play($data_system.decision_se)
  686. @escape = false
  687. @phase = 0
  688. if $game_temp.battle_turn == 0
  689. $game_temp.battle_turn = 1
  690. end
  691. if @command_a == true
  692. # Actor command phase start
  693. start_phase3
  694. else
  695. $game_temp.battle_main_phase = true
  696. end
  697. when 1 # It escapes
  698. # When it is not flight possible,
  699. if $game_temp.battle_can_escape == false
  700. # Performing buzzer SE
  701. $game_system.se_play($data_system.buzzer_se)
  702. return
  703. end
  704. # Performing decision SE
  705. $game_system.se_play($data_system.decision_se)
  706. @phase = 0
  707. # Nullifying the party command window
  708. @party_command_window.active = false
  709. @party_command_window.visible = false
  710. $game_temp.battle_main_phase = true
  711. if $game_temp.battle_turn == 0
  712. update_phase2_escape
  713. $game_temp.battle_turn = 1
  714. for battler in $game_party.actors
  715. battler.at -= @max / 2
  716. end
  717. return
  718. end
  719. # Performing decision SE
  720. $game_system.se_play($data_system.decision_se)
  721. @escape = true
  722. for battler in $game_party.actors
  723. @command_a = false
  724. @command.delete(battler)
  725. @action_battlers.delete(battler)
  726. skill_reset(battler)
  727. end
  728. end
  729. return
  730. end
  731. end
  732. #--------------------------------------------------------------------------
  733. # * Frame renewal (party command phase: It escapes)
  734. #--------------------------------------------------------------------------
  735. def update_phase2_escape
  736. # The enemy it is fast, calculating mean value
  737. enemies_agi = 0
  738. enemies_number = 0
  739. for enemy in $game_troop.enemies
  740. if enemy.exist?
  741. enemies_agi += enemy.agi
  742. enemies_number += 1
  743. end
  744. end
  745. if enemies_number > 0
  746. enemies_agi /= enemies_number
  747. end
  748. # The actor it is fast, calculating mean value
  749. actors_agi = 0
  750. actors_number = 0
  751. for actor in $game_party.actors
  752. if actor.exist?
  753. actors_agi += actor.agi
  754. actors_number += 1
  755. end
  756. end
  757. if actors_number > 0
  758. actors_agi /= actors_number
  759. end
  760. # Flight success decision
  761. success = rand(100) < 50 * actors_agi / enemies_agi
  762. # In case of flight success
  763. if success
  764. # Performing flight SE
  765. $game_system.se_play($data_system.escape_se)
  766. # You reset to BGM before the battle starting
  767. $game_system.bgm_play($game_temp.map_bgm)
  768. # Battle end
  769. battle_end(1)
  770. # In case of failure of flight
  771. else
  772. @help_window.set_text("Cannot escape", 1)
  773. @help_wait = @help_time
  774. # Clearing the action of party everyone
  775. $game_party.clear_actions
  776. # Main phase start
  777. start_phase4
  778. end
  779. end
  780. #--------------------------------------------------------------------------
  781. # * After battle phase start
  782. #--------------------------------------------------------------------------
  783. def start_phase5
  784. # It moves to phase 5
  785. @phase = 5
  786. # Performing battle end ME
  787. $game_system.me_play($game_system.battle_end_me)
  788. # You reset to BGM before the battle starting
  789. $game_system.bgm_play($game_temp.map_bgm)
  790. # Initializing EXP, the gold and the treasure
  791. exp = 0
  792. gold = 0
  793. treasures = []
  794. if @active_actor != nil
  795. @active_actor.blink = false
  796. end
  797. # Setting the main phase flag
  798. $game_temp.battle_main_phase = true
  799. # Nullifying the party command window
  800. @party_command_window.active = false
  801. @party_command_window.visible = false
  802. # Nullifying the actor command window
  803. @actor_command_window.active = false
  804. @actor_command_window.visible = false
  805. if @skill_window != nil
  806. # Releasing the skill window
  807. @skill_window.dispose
  808. @skill_window = nil
  809. end
  810. if @item_window != nil
  811. # Releasing the item window
  812. @item_window.dispose
  813. @item_window = nil
  814. end
  815. # The help window is hidden
  816. @help_window.visible = false
  817. # Loop
  818. for enemy in $game_troop.enemies
  819. # When the enemy hides and it is not state,
  820. unless enemy.hidden
  821. # Adding acquisition EXP and the gold
  822. exp += enemy.exp
  823. gold += enemy.gold
  824. # Treasure appearance decision
  825. if rand(100) < enemy.treasure_prob
  826. if enemy.item_id > 0
  827. treasures.push($data_items[enemy.item_id])
  828. end
  829. if enemy.weapon_id > 0
  830. treasures.push($data_weapons[enemy.weapon_id])
  831. end
  832. if enemy.armor_id > 0
  833. treasures.push($data_armors[enemy.armor_id])
  834. end
  835. end
  836. end
  837. end
  838. # It limits the number of treasures up to 6
  839. treasures = treasures[0..5]
  840. # EXP acquisition
  841. for i in 0...$game_party.actors.size
  842. actor = $game_party.actors[i]
  843. if actor.cant_get_exp? == false
  844. last_level = actor.level
  845. actor.exp += exp
  846. if actor.level > last_level
  847. @status_window.level_up(i)
  848. actor.damage[[actor, -1]] = "Level up!"
  849. actor.up_level = actor.level - last_level
  850. end
  851. end
  852. end
  853. # Gold acquisition
  854. $game_party.gain_gold(gold)
  855. # Treasure acquisition
  856. for item in treasures
  857. case item
  858. when RPG::Item
  859. $game_party.gain_item(item.id, 1)
  860. when RPG::Weapon
  861. $game_party.gain_weapon(item.id, 1)
  862. when RPG::Armor
  863. $game_party.gain_armor(item.id, 1)
  864. end
  865. end
  866. # Drawing up the battle result window
  867. @result_window = Window_BattleResult.new(exp, gold, treasures)
  868. # Setting wait count
  869. @phase5_wait_count = 100
  870. end
  871. #--------------------------------------------------------------------------
  872. # * Frame renewal (after battle phase)
  873. #--------------------------------------------------------------------------
  874. def update_phase5
  875. # When wait count is larger than 0,
  876. if @phase5_wait_count > 0
  877. # Wait count is decreased
  878. @phase5_wait_count -= 1
  879. # When wait count becomes 0,
  880. if @phase5_wait_count == 0
  881. # Indicating the result window
  882. @result_window.visible = true
  883. # Clearing the main phase flag
  884. $game_temp.battle_main_phase = false
  885. # Refreshing the status window
  886. @status_window.refresh
  887. for actor in $game_party.actors
  888. if actor.damage.include?([actor, 0])
  889. @phase5_wait_count = 20
  890. actor.damage_pop[[actor, 0]] = true
  891. end
  892. if actor.damage.include?([actor, -1])
  893. @phase5_wait_count = 20
  894. actor.damage_pop[[actor, -1]] = true
  895. for level in actor.level - actor.up_level + 1..actor.level
  896. for skill in $data_classes[actor.class_id].learnings
  897. if level == skill.level and not actor.skill_learn?(skill.id)
  898. actor.damage[[actor, 0]] = "New Skill!"
  899. break
  900. end
  901. end
  902. end
  903. end
  904. end
  905. end
  906. return
  907. end
  908. # When C button is pushed,
  909. if Input.trigger?(Input::C)
  910. # Battle end
  911. battle_end(0)
  912. end
  913. end
  914.  
  915. #==============================================================================
  916. # ** Scene_Battle (Part 3)
  917. #------------------------------------------------------------------------------
  918. # It is the class which processes the battle picture.
  919. #==============================================================================
  920.  
  921. #--------------------------------------------------------------------------
  922. # * Actor command phase start
  923. #--------------------------------------------------------------------------
  924. def start_phase3
  925. if victory?
  926. return
  927. end
  928. # Clearing the main phase flag
  929. $game_temp.battle_main_phase = false
  930. @command_a = true
  931. @active_actor = @command[0]
  932. cnt = 0
  933. for actor in $game_party.actors
  934. if actor == @active_actor
  935. @actor_index = cnt
  936. end
  937. cnt += 1
  938. end
  939. @active_actor.blink = true
  940. unless @active_actor.inputable?
  941. @active_actor.current_action.clear
  942. phase3_next_actor
  943. return
  944. end
  945. phase3_setup_command_window
  946. # Setting of camera
  947. @camera = "command"
  948. plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
  949. y = [(plus.abs - 1.5) * 10 , 0].min
  950. @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  951. end
  952. #--------------------------------------------------------------------------
  953. # * Command input end of actor
  954. #--------------------------------------------------------------------------
  955. def phase3_next_actor
  956. @command.shift
  957. @command_a = false
  958. # Setting the main phase flag
  959. $game_temp.battle_main_phase = true
  960. # Nullifying the actor command window
  961. @actor_command_window.active = false
  962. @actor_command_window.visible = false
  963. # Blinking effect OFF of actor
  964. if @active_actor != nil
  965. @active_actor.blink = false
  966. end
  967. action_start(@active_actor)
  968. # You reset on the basis of the camera
  969. if @camera == "command"
  970. @spriteset.screen_target(0, 0, 1)
  971. end
  972. return
  973. end
  974. #--------------------------------------------------------------------------
  975. # * Setup of actor command window
  976. #--------------------------------------------------------------------------
  977. def phase3_setup_command_window
  978. # Nullifying the party command window
  979. @party_command_window.active = false
  980. @party_command_window.visible = false
  981. # Enabling the actor command window
  982. @actor_command_window.active = true
  983. @actor_command_window.visible = true
  984. # Setting the position of the actor command window
  985. @actor_command_window.x = @actor_index * 160 +
  986. (4 - $game_party.actors.size) * 80
  987. # Setting the index to 0
  988. @actor_command_window.index = 0
  989. end
  990. #--------------------------------------------------------------------------
  991. # * Enemy action compilation
  992. #--------------------------------------------------------------------------
  993. def enemy_action(number)
  994. enemy = $game_troop.enemies[number]
  995. unless enemy.current_action.forcing
  996. enemy.make_action
  997. end
  998. action_start(enemy)
  999. end
  1000. #--------------------------------------------------------------------------
  1001. # * Frame renewal (actor command phase)
  1002. #--------------------------------------------------------------------------
  1003. def update_phase3
  1004. if victory? and @command_a
  1005. command_delete
  1006. @command.push(@active_actor)
  1007. return
  1008. end
  1009. # When the enemy arrow is effective,
  1010. if @enemy_arrow != nil
  1011. update_phase3_enemy_select
  1012. # When the actor arrow is effective,
  1013. elsif @actor_arrow != nil
  1014. update_phase3_actor_select
  1015. # When the skill window is effective,
  1016. elsif @skill_window != nil
  1017. update_phase3_skill_select
  1018. # When the item window is effective
  1019. elsif @item_window != nil
  1020. update_phase3_item_select
  1021. # When the actor command window is effective,
  1022. elsif @actor_command_window.active
  1023. update_phase3_basic_command
  1024. end
  1025. end
  1026. #--------------------------------------------------------------------------
  1027. # * Frame renewal (actor command phase: Basic command)
  1028. #--------------------------------------------------------------------------
  1029. def update_phase3_basic_command
  1030. unless @active_actor.inputable?
  1031. @active_actor.current_action.clear
  1032. phase3_next_actor
  1033. return
  1034. end
  1035. # The B when button is pushed,
  1036. if Input.trigger?(Input::B) and @party == false
  1037. # Performing cancellation SE
  1038. $game_system.se_play($data_system.cancel_se)
  1039. @party = true
  1040. end
  1041. if @party == true and
  1042. ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  1043. (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  1044. # To party command phase
  1045. start_phase2
  1046. return
  1047. end
  1048. # When C button is pushed,
  1049. if Input.trigger?(Input::C)
  1050. @party = false
  1051. # It diverges at cursor position of the actor command window
  1052. case @actor_command_window.index
  1053. when 0 # Attack
  1054. # Performing decision SE
  1055. $game_system.se_play($data_system.decision_se)
  1056. # Starting the selection of the enemy
  1057. start_enemy_select
  1058. when 1 # Skill
  1059. # Performing decision SE
  1060. $game_system.se_play($data_system.decision_se)
  1061. # Starting the selection of skill
  1062. start_skill_select
  1063. when 2 # Defense
  1064. # Performing decision SE
  1065. $game_system.se_play($data_system.decision_se)
  1066. # Setting action
  1067. @active_actor.current_action.kind = 0
  1068. @active_actor.current_action.basic = 1
  1069. # To command input of the following actor
  1070. phase3_next_actor
  1071. when 3 # Item
  1072. # Performing decision SE
  1073. $game_system.se_play($data_system.decision_se)
  1074. # Starting the selection of the item
  1075. start_item_select
  1076. end
  1077. return
  1078. end
  1079. # Change Character
  1080. if @command.size > 1
  1081. # When the R when button is pushed,
  1082. if Input.trigger?(Input::R)
  1083. $game_system.se_play($data_system.cursor_se)
  1084. @party = false
  1085. # Blinking effect OFF of actor
  1086. if @active_actor != nil
  1087. @active_actor.blink = false
  1088. end
  1089. @command.push(@command[0])
  1090. @command.shift
  1091. @command_a = false
  1092. # Start-up of new command window
  1093. start_phase3
  1094. end
  1095. # When the L when button is pushed,
  1096. if Input.trigger?(Input::L)
  1097. $game_system.se_play($data_system.cursor_se)
  1098. @party = false
  1099. # Blinking effect OFF of actor
  1100. if @active_actor != nil
  1101. @active_actor.blink = false
  1102. end
  1103. @command.unshift(@command[@command.size - 1])
  1104. @command.delete_at(@command.size - 1)
  1105. @command_a = false
  1106. # Start-up of new command window
  1107. start_phase3
  1108. end
  1109. # When the right button is pushed,
  1110. if Input.trigger?(Input::RIGHT)
  1111. $game_system.se_play($data_system.cursor_se)
  1112. @party = false
  1113. # Blinking effect OFF of actor
  1114. if @active_actor != nil
  1115. @active_actor.blink = false
  1116. end
  1117. actor = $game_party.actors[@actor_index]
  1118. while actor == @command[0] or (not @command.include?(actor))
  1119. @actor_index += 1
  1120. @actor_index %= $game_party.actors.size
  1121. actor = $game_party.actors[@actor_index]
  1122. if actor == @command[0]
  1123. break
  1124. end
  1125. end
  1126. while actor != @command[0]
  1127. @command.push(@command.shift)
  1128. end
  1129. @command_a = false
  1130. # Start-up of new command window
  1131. start_phase3
  1132. end
  1133. # When the left button is pushed,
  1134. if Input.trigger?(Input::LEFT)
  1135. $game_system.se_play($data_system.cursor_se)
  1136. @party = false
  1137. # Blinking effect OFF of actor
  1138. if @active_actor != nil
  1139. @active_actor.blink = false
  1140. end
  1141. actor = $game_party.actors[@actor_index]
  1142. while actor == @command[0] or (not @command.include?(actor))
  1143. @actor_index -= 1
  1144. @actor_index %= $game_party.actors.size
  1145. actor = $game_party.actors[@actor_index]
  1146. if actor == @command[0]
  1147. break
  1148. end
  1149. end
  1150. while actor != @command[0]
  1151. @command.push(@command.shift)
  1152. end
  1153. @command_a = false
  1154. # Start-up of new command window
  1155. start_phase3
  1156. end
  1157. end
  1158. end
  1159. #--------------------------------------------------------------------------
  1160. # * Frame renewal (actor command phase: Skill selection)
  1161. #--------------------------------------------------------------------------
  1162. def update_phase3_skill_select
  1163. # During command selecting when it becomes incapacitation,
  1164. unless @active_actor.inputable?
  1165. @active_actor.current_action.clear
  1166. command_delete
  1167. # To command input of the following actor
  1168. phase3_next_actor
  1169. return
  1170. end
  1171. # The skill window is put in visible state
  1172. @skill_window.visible = true
  1173. # Renewing the skill window
  1174. @skill_window.update
  1175. # The B when button is pushed,
  1176. if Input.trigger?(Input::B)
  1177. # Performing cancellation SE
  1178. $game_system.se_play($data_system.cancel_se)
  1179. # End selection of skill
  1180. end_skill_select
  1181. return
  1182. end
  1183. # When C button is pushed,
  1184. if Input.trigger?(Input::C)
  1185. # Acquiring the data which presently is selected in the skill window
  1186. @skill = @skill_window.skill
  1187. # When you cannot use,
  1188. if @skill == nil or not @active_actor.skill_can_use?(@skill.id)
  1189. # Performing buzzer SE
  1190. $game_system.se_play($data_system.buzzer_se)
  1191. return
  1192. end
  1193. # Performing decision SE
  1194. $game_system.se_play($data_system.decision_se)
  1195. # Setting action
  1196. @active_actor.current_action.skill_id = @skill.id
  1197. # The skill window is put in invisibility state
  1198. @skill_window.visible = false
  1199. # When the effective range is the enemy single unit,
  1200. if @skill.scope == 1
  1201. # Starting the selection of the enemy
  1202. start_enemy_select
  1203. # When the effective range is the friend single unit,
  1204. elsif @skill.scope == 3 or @skill.scope == 5
  1205. # Starting the selection of the actor
  1206. start_actor_select
  1207. # When the effective range is not the single unit,
  1208. else
  1209. # Setting action
  1210. @active_actor.current_action.kind = 1
  1211. # End selection of skill
  1212. end_skill_select
  1213. # To command input of the following actor
  1214. phase3_next_actor
  1215. end
  1216. return
  1217. end
  1218. end
  1219. #--------------------------------------------------------------------------
  1220. # * Frame renewal (actor command phase: Item selection)
  1221. #--------------------------------------------------------------------------
  1222. def update_phase3_item_select
  1223. # During command selecting when it becomes incapacitation,
  1224. unless @active_actor.inputable?
  1225. @active_actor.current_action.clear
  1226. command_delete
  1227. # To command input of the following actor
  1228. phase3_next_actor
  1229. return
  1230. end
  1231. # The item window is put in visible state
  1232. @item_window.visible = true
  1233. # Renewing the item window
  1234. @item_window.update
  1235. # The B when button is pushed,
  1236. if Input.trigger?(Input::B)
  1237. # Performing cancellation SE
  1238. $game_system.se_play($data_system.cancel_se)
  1239. # End selection of item
  1240. end_item_select
  1241. return
  1242. end
  1243. #When C button is pushed,
  1244. if Input.trigger?(Input::C)
  1245. # Acquiring the data which presently is selected in the item window
  1246. @item = @item_window.item
  1247. # When you cannot use,
  1248. unless $game_party.item_can_use?(@item.id)
  1249. # Performing buzzer SE
  1250. $game_system.se_play($data_system.buzzer_se)
  1251. return
  1252. end
  1253. # Performing decision SE
  1254. $game_system.se_play($data_system.decision_se)
  1255. # Setting action
  1256. @active_actor.current_action.item_id = @item.id
  1257. # The item window is put in invisibility state
  1258. @item_window.visible = false
  1259. # When the effective range is the enemy single unit,
  1260. if @item.scope == 1
  1261. # Starting the selection of the enemy
  1262. start_enemy_select
  1263. # When the effective range is the friend single unit,
  1264. elsif @item.scope == 3 or @item.scope == 5
  1265. # Starting the selection of the actor
  1266. start_actor_select
  1267. # When the effective range is not the single unit,
  1268. else
  1269. # Setting action
  1270. @active_actor.current_action.kind = 2
  1271. # End selection of item
  1272. end_item_select
  1273. # To command input of the following actor
  1274. phase3_next_actor
  1275. end
  1276. return
  1277. end
  1278. end
  1279. #--------------------------------------------------------------------------
  1280. # * Frame renewal (actor command phase: Enemy selection)
  1281. #--------------------------------------------------------------------------
  1282. def update_phase3_enemy_select
  1283. # During command selecting when it becomes incapacitation,
  1284. unless @active_actor.inputable?
  1285. # You reset on the basis of the camera
  1286. if @camera == "select"
  1287. @spriteset.screen_target(0, 0, 1)
  1288. end
  1289. @active_actor.current_action.clear
  1290. command_delete
  1291. # To command input of the following actor
  1292. phase3_next_actor
  1293. return
  1294. end
  1295. # Renewing the enemy arrow
  1296. @enemy_arrow.update
  1297. # The B when button is pushed,
  1298. if Input.trigger?(Input::B)
  1299. # Performing cancellation SE
  1300. $game_system.se_play($data_system.cancel_se)
  1301. # You reset on the basis of the camera
  1302. if @camera == "select"
  1303. # Setting of camera
  1304. @camera = "command"
  1305. plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
  1306. y = [(plus.abs - 1.5) * 10 , 0].min
  1307. @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  1308. end
  1309. # End selection of enemy
  1310. end_enemy_select
  1311. return
  1312. end
  1313. # When C button is pushed,
  1314. if Input.trigger?(Input::C)
  1315. # Performing decision SE
  1316. $game_system.se_play($data_system.decision_se)
  1317. # Performing decision SE
  1318. @active_actor.current_action.kind = 0
  1319. @active_actor.current_action.basic = 0
  1320. @active_actor.current_action.target_index = @enemy_arrow.index
  1321. # When it is in the midst of skill window indicating,
  1322. if @skill_window != nil
  1323. # Resetting action
  1324. @active_actor.current_action.kind = 1
  1325. # End selection of skill
  1326. end_skill_select
  1327. end
  1328. # When it is in the midst of item window indicating,
  1329. if @item_window != nil
  1330. # Resetting action
  1331. @active_actor.current_action.kind = 2
  1332. # End selection of item
  1333. end_item_select
  1334. end
  1335. # End selection of enemy
  1336. end_enemy_select
  1337. # To command input of the following actor
  1338. phase3_next_actor
  1339. end
  1340. end
  1341. #--------------------------------------------------------------------------
  1342. # * Frame renewal (actor command phase: Actor selection)
  1343. #--------------------------------------------------------------------------
  1344. def update_phase3_actor_select
  1345. # During command selecting when it becomes incapacitation,
  1346. unless @active_actor.inputable?
  1347. @active_actor.current_action.clear
  1348. command_delete
  1349. # To command input of the following actor
  1350. phase3_next_actor
  1351. return
  1352. end
  1353. # Renewing the actor arrow
  1354. @actor_arrow.update
  1355. # The B when button is pushed,
  1356. if Input.trigger?(Input::B)
  1357. # Performing cancellation SE
  1358. $game_system.se_play($data_system.cancel_se)
  1359. # End selection of actor
  1360. end_actor_select
  1361. return
  1362. end
  1363. # When C button is pushed,
  1364. if Input.trigger?(Input::C)
  1365. # Performing decision SE
  1366. $game_system.se_play($data_system.decision_se)
  1367. # Setting action
  1368. @active_actor.current_action.kind = 0
  1369. @active_actor.current_action.basic = 0
  1370. @active_actor.current_action.target_index = @actor_arrow.index
  1371. # End selection of actor
  1372. end_actor_select
  1373. # When it is in the midst of skill window indicating,
  1374. if @skill_window != nil
  1375. # Resetting action
  1376. @active_actor.current_action.kind = 1
  1377. # End selection of skill
  1378. end_skill_select
  1379. end
  1380. # When it is in the midst of item window indicating,
  1381. if @item_window != nil
  1382. # Resetting action
  1383. @active_actor.current_action.kind = 2
  1384. # End selection of item
  1385. end_item_select
  1386. end
  1387. # To command input of the following actor
  1388. phase3_next_actor
  1389. end
  1390. end
  1391. #--------------------------------------------------------------------------
  1392. # * Start of enemy selection
  1393. #--------------------------------------------------------------------------
  1394. alias :start_enemy_select_rtab :start_enemy_select
  1395. def start_enemy_select
  1396. @camera = "select"
  1397. for enemy in $game_troop.enemies
  1398. if enemy.exist?
  1399. zoom = 1 / enemy.zoom
  1400. @spriteset.screen_target(enemy.attack_x(zoom) * 0.75,
  1401. enemy.attack_y(zoom) * 0.75, zoom)
  1402. break
  1403. end
  1404. end
  1405. # Original processing
  1406. start_enemy_select_rtab
  1407. end
  1408. #--------------------------------------------------------------------------
  1409. # * Enemy selection end
  1410. #--------------------------------------------------------------------------
  1411. alias :end_enemy_select_rtab :end_enemy_select
  1412. def end_enemy_select
  1413. # Original processing
  1414. end_enemy_select_rtab
  1415. if (@action == 0 and not @action_battlers.empty?) or
  1416. (@camera == "select" and (@active_actor.current_action.kind != 0 or
  1417. @active_actor.animation1_id != 0))
  1418. @spriteset.screen_target(0, 0, 1)
  1419. end
  1420. end
  1421. #--------------------------------------------------------------------------
  1422. # * Start of skill selection
  1423. #--------------------------------------------------------------------------
  1424. def start_skill_select
  1425. # Drawing up the skill window
  1426. @skill_window = Window_Skill.new(@active_actor)
  1427. # Help window association
  1428. @skill_window.help_window = @help_window
  1429. # Nullifying the actor command window
  1430. @actor_command_window.active = false
  1431. @actor_command_window.visible = false
  1432. end
  1433.  
  1434. #==============================================================================
  1435. # ** Scene_Battle (Part 4)
  1436. #------------------------------------------------------------------------------
  1437. # It is the class which processes the battle picture.
  1438. #==============================================================================
  1439.  
  1440. #--------------------------------------------------------------------------
  1441. # * Main phase start
  1442. #--------------------------------------------------------------------------
  1443. def start_phase4
  1444. $game_temp.battle_main_phase = true
  1445. end
  1446. #--------------------------------------------------------------------------
  1447. # * Frame renewal (main phase)
  1448. #--------------------------------------------------------------------------
  1449. def update_phase4
  1450. # When the battler who is forced action exists
  1451. if $game_temp.forcing_battler != nil
  1452. battler = $game_temp.forcing_battler
  1453. if battler.current_action.forcing == false
  1454. if @action_battlers.include?(battler)
  1455. if @action > 0 or @action_battlers[0].phase == 1
  1456. @action_battlers.delete(battler)
  1457. @action_battlers.push(battler)
  1458. end
  1459. if battler.phase == 1
  1460. battler.current_action.forcing = true
  1461. force_action(battler)
  1462. end
  1463. else
  1464. battler.current_action.forcing = true
  1465. force_action(battler)
  1466. action_start(battler)
  1467. @action_battlers.delete(battler)
  1468. @action_battlers.push(battler)
  1469. end
  1470. battler.at = @max
  1471. battler.atp = 100 * battler.at / @max
  1472. end
  1473. end
  1474. # When action is 1 or more, conduct is caused simultaneously
  1475. for battler in @action_battlers.reverse
  1476. # When it is in wait,
  1477. if battler.wait > 0
  1478. # Wait count is decreased
  1479. battler.wait -= 1
  1480. break if @action == 0
  1481. next
  1482. end
  1483. unless fin? and battler.phase < 3 and
  1484. not $game_system.battle_interpreter.running?
  1485. action_phase(battler)
  1486. end
  1487. break if @action == 0
  1488. end
  1489. # When the battler who is forced action does not exist
  1490. if $game_temp.forcing_battler == nil
  1491. # Setting up the battle event
  1492. setup_battle_event
  1493. # When it is in the midst of battle event executing,
  1494. if $game_system.battle_interpreter.running?
  1495. return
  1496. end
  1497. end
  1498. # The case where victory or defeat is decided processing
  1499. if fin?
  1500. # When being defeated, designated time wait
  1501. if $game_party.all_dead? and @after_wait[0] > 0
  1502. @after_wait[0] -= 1
  1503. return
  1504. end
  1505. # At the time of victory, designated time wait
  1506. if victory? and @after_wait[1] > 0
  1507. @after_wait[1] -= 1
  1508. return
  1509. end
  1510. # When battle ends, at the same time the actor is immediately before the acting, eliminating the conduct of the actor
  1511. for battler in @action_battlers.reverse
  1512. if battler.phase < 3 and not $game_system.battle_interpreter.running?
  1513. @action_battlers.delete(battler)
  1514. end
  1515. end
  1516. # Victory or defeat decision
  1517. if @action_battlers.empty? and
  1518. not $game_system.battle_interpreter.running?
  1519. judge
  1520. end
  1521. end
  1522. end
  1523. #--------------------------------------------------------------------------
  1524. # * Action renewal (main phase)
  1525. #--------------------------------------------------------------------------
  1526. def action_phase(battler)
  1527. # When action 1 is, verification whether or not the battler while acting
  1528. if @action == 1 and battler.phase <= 3
  1529. for target in battler.target
  1530. speller = synthe?(target)
  1531. if speller == nil
  1532. # When the target is in the midst of usual acting,
  1533. if @action_battlers.include?(target)
  1534. if target.phase > 2
  1535. return
  1536. end
  1537. end
  1538. else
  1539. # When the target is in the midst of cooperation skill moving,
  1540. for spell in speller
  1541. if @action_battlers.include?(spell)
  1542. if spell.phase > 2
  1543. return
  1544. end
  1545. end
  1546. end
  1547. end
  1548. end
  1549. end
  1550. case battler.phase
  1551. when 1
  1552. update_phase4_step1(battler)
  1553. when 2
  1554. update_phase4_step2(battler)
  1555. when 3
  1556. update_phase4_step3(battler)
  1557. when 4
  1558. update_phase4_step4(battler)
  1559. when 5
  1560. update_phase4_step5(battler)
  1561. when 6
  1562. update_phase4_step6(battler)
  1563. end
  1564. end
  1565. #--------------------------------------------------------------------------
  1566. # ? ?????? (??????? ???? 1 : ???????)
  1567. #--------------------------------------------------------------------------
  1568. def update_phase4_step1(battler)
  1569. # Already, when it is removed from battle
  1570. if battler.index == nil
  1571. @action_battlers.delete(battler)
  1572. anime_wait_return
  1573. return
  1574. end
  1575. speller = synthe?(battler)
  1576. if speller == nil
  1577. # When it is while the damage receiving
  1578. unless battler.damage.empty? or @action > 2
  1579. return
  1580. end
  1581. # Whether or not conduct possibility decision
  1582. unless battler.movable?
  1583. battler.phase = 6
  1584. return
  1585. end
  1586. else
  1587. # When it is while the damage receiving,
  1588. for spell in speller
  1589. unless spell.damage.empty? or @action > 2
  1590. return
  1591. end
  1592. # Whether or not conduct possibility decision
  1593. unless spell.movable?
  1594. battler.phase = 6
  1595. return
  1596. end
  1597. end
  1598. end
  1599. # At the time of skill use, permanent residence time setting
  1600. # When forced action and @force 2 being, skill immediately motion
  1601. if battler.current_action.kind == 1 and
  1602. (not battler.current_action.forcing or @force != 2)
  1603. if battler.rtp == 0
  1604. # If it is in the midst of skill residing permanently, cancellation
  1605. skill_reset(battler)
  1606. # Skill permanent residence time setting
  1607. recite_time(battler)
  1608. # Cooperation skill setting
  1609. synthe_spell(battler)
  1610. # When skill you reside permanently,
  1611. if battler.rtp > 0
  1612. # When forced action and @force 1 being, only cooperation skill immediately motion
  1613. speller = synthe?(battler)
  1614. if battler.current_action.forcing and @force > 0 and speller != nil
  1615. for spell in speller
  1616. spell.rt = spell.rtp
  1617. end
  1618. else
  1619. battler.blink = true
  1620. if battler.current_action.forcing
  1621. $game_temp.forcing_battler = nil
  1622. battler.current_action.forcing = false
  1623. end
  1624. @action_battlers.delete(battler)
  1625. return
  1626. end
  1627. end
  1628. end
  1629. end
  1630. # Blinking effect OFF of actor
  1631. if battler != nil
  1632. battler.blink = false
  1633. end
  1634. speller = synthe?(battler)
  1635. if speller == nil
  1636. @spell_p.delete(battler)
  1637. @spell_e.delete(battler)
  1638. else
  1639. for spell in speller
  1640. spell.blink = false
  1641. @spell_p.delete(spell)
  1642. @spell_e.delete(spell)
  1643. end
  1644. end
  1645. # It moves to step 2
  1646. battler.phase = 2
  1647. end
  1648. #--------------------------------------------------------------------------
  1649. # * Frame renewal (main phase step 2: Action start)
  1650. #--------------------------------------------------------------------------
  1651. def update_phase4_step2(battler)
  1652. # If it is not forced action
  1653. unless battler.current_action.forcing
  1654. # When restriction [ the enemy is attacked ] [ friend attacks ] usually usually
  1655. if battler.restriction == 2 or battler.restriction == 3
  1656. # Setting attack to action
  1657. battler.current_action.kind = 0
  1658. battler.current_action.basic = 0
  1659. end
  1660. end
  1661. # It diverges with classification of action
  1662. case battler.current_action.kind
  1663. when 0 # Basis
  1664. if fin?
  1665. battler.phase = 6
  1666. return
  1667. end
  1668. make_basic_action_result(battler)
  1669. when 1 # Skill
  1670. if fin? and $data_skills[battler.current_action.skill_id].scope == 1..2
  1671. battler.phase = 6
  1672. return
  1673. end
  1674. make_skill_action_result(battler)
  1675. when 2 # Item
  1676. if fin? and $data_items[battler.current_action.item_id].scope == 1..2
  1677. battler.phase = 6
  1678. return
  1679. end
  1680. make_item_action_result(battler)
  1681. end
  1682. if battler.phase == 2
  1683. # It moves to step 3
  1684. battler.phase = 3
  1685. end
  1686. end
  1687. #--------------------------------------------------------------------------
  1688. # * Basic action result compilation
  1689. #--------------------------------------------------------------------------
  1690. def make_basic_action_result(battler)
  1691. # In case of attack
  1692. if battler.current_action.basic == 0
  1693. # Setting animation ID
  1694. battler.anime1 = battler.animation1_id
  1695. battler.anime2 = battler.animation2_id
  1696. # When the conduct side battler is the enemy
  1697. if battler.is_a?(Game_Enemy)
  1698. if battler.restriction == 3
  1699. target = $game_troop.random_target_enemy
  1700. elsif battler.restriction == 2
  1701. target = $game_party.random_target_actor
  1702. else
  1703. index = battler.current_action.target_index
  1704. target = $game_party.smooth_target_actor(index)
  1705. end
  1706. end
  1707. # When the conduct side battler is the actor
  1708. if battler.is_a?(Game_Actor)
  1709. if battler.restriction == 3
  1710. target = $game_party.random_target_actor
  1711. elsif battler.restriction == 2
  1712. target = $game_troop.random_target_enemy
  1713. else
  1714. index = battler.current_action.target_index
  1715. target = $game_troop.smooth_target_enemy(index)
  1716. end
  1717. end
  1718. # Setting the arrangement of the object side battler
  1719. battler.target = [target]
  1720. # Applying the effect of normality attack
  1721. for target in battler.target
  1722. target.attack_effect(battler)
  1723. end
  1724. return
  1725. end
  1726. # In case of defense
  1727. if battler.current_action.basic == 1
  1728. return
  1729. end
  1730. # When escapes and is
  1731. if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2
  1732. # It escapes
  1733. @help_window.set_text("Escape", 1)
  1734. @help_wait = @help_time
  1735. battler.escape
  1736. return
  1737. end
  1738. # When what is not and is
  1739. if battler.current_action.basic == 3
  1740. # It moves to step 6
  1741. battler.phase = 6
  1742. return
  1743. end
  1744. end
  1745. #--------------------------------------------------------------------------
  1746. # * Object side battler setting of skill or item
  1747. # scope : Effective range of skill or item
  1748. #--------------------------------------------------------------------------
  1749. def set_target_battlers(scope, battler)
  1750. # When the conduct side battler is the enemy,
  1751. if battler.is_a?(Game_Enemy)
  1752. # It diverges in the effective range
  1753. case scope
  1754. when 1 # Enemy single unit
  1755. index =battler.current_action.target_index
  1756. battler.target.push($game_party.smooth_target_actor(index))
  1757. when 2 # Whole enemy
  1758. for actor in $game_party.actors
  1759. if actor.exist?
  1760. battler.target.push(actor)
  1761. end
  1762. end
  1763. when 3 # Friend single unit
  1764. index = battler.current_action.target_index
  1765. battler.target.push($game_troop.smooth_target_enemy(index))
  1766. when 4 # Whole friend
  1767. for enemy in $game_troop.enemies
  1768. if enemy.exist?
  1769. battler.target.push(enemy)
  1770. end
  1771. end
  1772. when 5 # Friend single unit (HP 0)
  1773. index = battler.current_action.target_index
  1774. enemy = $game_troop.enemies[index]
  1775. if enemy != nil and enemy.hp0?
  1776. battler.target.push(enemy)
  1777. end
  1778. when 6 # Whole friend (HP 0)
  1779. for enemy in $game_troop.enemies
  1780. if enemy != nil and enemy.hp0?
  1781. battler.target.push(enemy)
  1782. end
  1783. end
  1784. when 7 # User
  1785. battler.target.push(battler)
  1786. end
  1787. end
  1788. # When the conduct side battler is the actor,
  1789. if battler.is_a?(Game_Actor)
  1790. # It diverges in the effective range
  1791. case scope
  1792. when 1 # Enemy single unit
  1793. index = battler.current_action.target_index
  1794. battler.target.push($game_troop.smooth_target_enemy(index))
  1795. when 2 # Whole enemy
  1796. for enemy in $game_troop.enemies
  1797. if enemy.exist?
  1798. battler.target.push(enemy)
  1799. end
  1800. end
  1801. when 3 # Friend single unit
  1802. index = battler.current_action.target_index
  1803. battler.target.push($game_party.smooth_target_actor(index))
  1804. when 4 # Whole friend
  1805. for actor in $game_party.actors
  1806. if actor.exist?
  1807. battler.target.push(actor)
  1808. end
  1809. end
  1810. when 5 # Friend single unit (HP 0)
  1811. index = battler.current_action.target_index
  1812. actor = $game_party.actors[index]
  1813. if actor != nil and actor.hp0?
  1814. battler.target.push(actor)
  1815. end
  1816. when 6 # Whole friend (HP 0)
  1817. for actor in $game_party.actors
  1818. if actor != nil and actor.hp0?
  1819. battler.target.push(actor)
  1820. end
  1821. end
  1822. when 7 # User
  1823. battler.target.push(battler)
  1824. end
  1825. end
  1826. end
  1827. #--------------------------------------------------------------------------
  1828. # * Skill action result compilation
  1829. #--------------------------------------------------------------------------
  1830. def make_skill_action_result(battler)
  1831. # Acquiring skill
  1832. @skill = $data_skills[battler.current_action.skill_id]
  1833. # Verification whether or not it is cooperation skill,
  1834. speller = synthe?(battler)
  1835. # If it is not forced action
  1836. unless battler.current_action.forcing
  1837. # When with SP and so on is cut off and it becomes not be able to use
  1838. if speller == nil
  1839. unless battler.skill_can_use?(@skill.id)
  1840. # It moves to step 6
  1841. battler.phase = 6
  1842. return
  1843. end
  1844. end
  1845. end
  1846. # SP consumption
  1847. temp = false
  1848. if speller != nil
  1849. for spell in speller
  1850. if spell.current_action.spell_id == 0
  1851. spell.sp -= @skill.sp_cost
  1852. else
  1853. spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost
  1854. end
  1855. # Refreshing the status window
  1856. status_refresh(spell)
  1857. end
  1858. else
  1859. battler.sp -= @skill.sp_cost
  1860. # Refreshing the status window
  1861. status_refresh(battler)
  1862. end
  1863. # Setting animation ID
  1864. battler.anime1 = @skill.animation1_id
  1865. battler.anime2 = @skill.animation2_id
  1866. # Setting common event ID
  1867. battler.event = @skill.common_event_id
  1868. # Setting the object side battler
  1869. set_target_battlers(@skill.scope, battler)
  1870. # Applying the effect of skill
  1871. for target in battler.target
  1872. if speller != nil
  1873. damage = 0
  1874. d_result = false
  1875. effective = false
  1876. state_p = []
  1877. state_m = []
  1878. for spell in speller
  1879. if spell.current_action.spell_id != 0
  1880. @skill = $data_skills[spell.current_action.spell_id]
  1881. end
  1882. effective |= target.skill_effect(spell, @skill)
  1883. if target.damage[spell].class != String
  1884. d_result = true
  1885. damage += target.damage[spell]
  1886. elsif effective
  1887. effect = target.damage[spell]
  1888. end
  1889. state_p += target.state_p[spell]
  1890. state_m += target.state_m[spell]
  1891. target.damage.delete(spell)
  1892. target.state_p.delete(spell)
  1893. target.state_m.delete(spell)
  1894. end
  1895. if d_result
  1896. target.damage[battler] = damage
  1897. elsif effective
  1898. target.damage[battler] = effect
  1899. else
  1900. target.damage[battler] = 0
  1901. end
  1902. target.state_p[battler] = state_p
  1903. target.state_m[battler] = state_m
  1904. else
  1905. target.skill_effect(battler, @skill)
  1906. end
  1907. end
  1908. end
  1909. #--------------------------------------------------------------------------
  1910. # * Item action result compilation
  1911. #--------------------------------------------------------------------------
  1912. def make_item_action_result(battler)
  1913. # Acquiring the item
  1914. @item = $data_items[battler.current_action.item_id]
  1915. # When with the item and so on is cut off and it becomes not be able to use
  1916. unless $game_party.item_can_use?(@item.id)
  1917. # It moves to step 6
  1918. battler.phase = 6
  1919. return
  1920. end
  1921. # In case of consumable
  1922. if @item.consumable
  1923. # The item which you use is decreased 1
  1924. $game_party.lose_item(@item.id, 1)
  1925. end
  1926. # Setting animation ID
  1927. battler.anime1 = @item.animation1_id
  1928. battler.anime2 = @item.animation2_id
  1929. # Setting common event ID
  1930. battler.event = @item.common_event_id
  1931. # Deciding the object
  1932. index = battler.current_action.target_index
  1933. target = $game_party.smooth_target_actor(index)
  1934. # Setting the object side battler
  1935. set_target_battlers(@item.scope, battler)
  1936. # Applying the effect of the item
  1937. for target in battler.target
  1938. target.item_effect(@item, battler)
  1939. end
  1940. end
  1941. #--------------------------------------------------------------------------
  1942. # * Frame renewal (main phase step 3: Conduct side animation)
  1943. #--------------------------------------------------------------------------
  1944. def update_phase4_step3(battler)
  1945. # Renewal of help window. It diverges with classification of action
  1946. case battler.current_action.kind
  1947. when 0 # Basis
  1948. if battler.current_action.basic == 1
  1949. @help_window.set_text($data_system.words.guard, 1)
  1950. @help_wait = @help_time
  1951. end
  1952. when 1 # Skill
  1953. skill = $data_skills[battler.current_action.skill_id]
  1954. @help_window.set_text(skill.name, 1)
  1955. @help_wait = @help_time
  1956. when 2 # Item
  1957. item = $data_items[battler.current_action.item_id]
  1958. @help_window.set_text(item.name, 1)
  1959. @help_wait = @help_time
  1960. end
  1961. # When conduct side animation (ID 0 is, the white flash)
  1962. if battler.anime1 == 0
  1963. battler.white_flash = true
  1964. battler.wait = 5
  1965. # Camera setting
  1966. if battler.target[0].is_a?(Game_Enemy)
  1967. camera_set(battler)
  1968. end
  1969. else
  1970. battler.animation.push([battler.anime1, true])
  1971. speller = synthe?(battler)
  1972. if speller != nil
  1973. for spell in speller
  1974. if spell != battler
  1975. if spell.current_action.spell_id == 0
  1976. spell.animation.push([battler.anime1, true])
  1977. else
  1978. skill = spell.current_action.spell_id
  1979. spell.animation.push([$data_skills[skill].animation1_id, true])
  1980. spell.current_action.spell_id = 0
  1981. end
  1982. end
  1983. end
  1984. end
  1985. battler.wait = 2 * $data_animations[battler.anime1].frame_max - 10
  1986. end
  1987. # It moves to step 4
  1988. battler.phase = 4
  1989. end
  1990. #--------------------------------------------------------------------------
  1991. # * Frame renewal (main phase step 4: Object side animation)
  1992. #--------------------------------------------------------------------------
  1993. def update_phase4_step4(battler)
  1994. # Camera setting
  1995. if battler.target[0].is_a?(Game_Enemy) and battler.anime1 != 0
  1996. camera_set(battler)
  1997. end
  1998. # Object side animation
  1999. for target in battler.target
  2000. target.animation.push([battler.anime2,
  2001. (target.damage[battler] != "Miss")])
  2002. unless battler.anime2 == 0
  2003. battler.wait = 2 * $data_animations[battler.anime2].frame_max - 10
  2004. end
  2005. end
  2006. # It moves to step 5
  2007. battler.phase = 5
  2008. end
  2009. #--------------------------------------------------------------------------
  2010. # * Frame renewal (main phase step 5: Damage indication)
  2011. #--------------------------------------------------------------------------
  2012. def update_phase4_step5(battler)
  2013. # Damage indication
  2014. for target in battler.target
  2015. if target.damage[battler] != nil
  2016. target.damage_pop[battler] = true
  2017. target.damage_effect(battler, battler.current_action.kind)
  2018. battler.wait = @damage_wait
  2019. # Refreshing the status window
  2020. status_refresh(target)
  2021. end
  2022. end
  2023. # It moves to step 6
  2024. battler.phase = 6
  2025. end
  2026. #--------------------------------------------------------------------------
  2027. # * Frame renewal (main phase step 6: Refreshment)
  2028. #--------------------------------------------------------------------------
  2029. def update_phase4_step6(battler)
  2030. # The camera is reset
  2031. if battler.target[0].is_a?(Game_Enemy) and @camera == battler
  2032. @spriteset.screen_target(0, 0, 1)
  2033. end
  2034. # Skill learning
  2035. if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
  2036. for target in battler.target
  2037. skill_learning(target, target.class_id,
  2038. battler.current_action.skill_id)
  2039. end
  2040. end
  2041. # Clearing the battler of the action forced object
  2042. if battler.current_action.forcing == true and
  2043. battler.current_action.force_kind == 0 and
  2044. battler.current_action.force_basic == 0 and
  2045. battler.current_action.force_skill_id == 0
  2046. $game_temp.forcing_battler = nil
  2047. battler.current_action.forcing = false
  2048. end
  2049. refresh_phase(battler)
  2050. speller = synthe?(battler)
  2051. if speller != nil
  2052. for spell in speller
  2053. if spell != battler
  2054. refresh_phase(spell)
  2055. end
  2056. end
  2057. synthe_delete(speller)
  2058. end
  2059. # When common event ID is valid
  2060. if battler.event > 0
  2061. # Setting up the event
  2062. common_event = $data_common_events[battler.event]
  2063. $game_system.battle_interpreter.setup(common_event.list, 0)
  2064. end
  2065. act = 0
  2066. for actor in $game_party.actors + $game_troop.enemies
  2067. if actor.movable?
  2068. act += 1
  2069. end
  2070. end
  2071. if @turn_cnt >= act and act > 0
  2072. @turn_cnt %= act
  2073. $game_temp.battle_turn += 1
  2074. # Searching the full page of the battle event
  2075. for index in 0...$data_troops[@troop_id].pages.size
  2076. # Acquiring the event page
  2077. page = $data_troops[@troop_id].pages[index]
  2078. # When the span of this page [ turn ] is
  2079. if page.span == 1
  2080. # Clearing the execution being completed flag
  2081. $game_temp.battle_event_flags[index] = false
  2082. end
  2083. end
  2084. end
  2085. battler.phase = 1
  2086. @action_battlers.delete(battler)
  2087. end
  2088. #--------------------------------------------------------------------------
  2089. # * Refresh
  2090. #--------------------------------------------------------------------------
  2091. def refresh_phase(battler)
  2092. battler.at -= @max
  2093. if battler.movable?
  2094. battler.atp = 100 * battler.at / @max
  2095. end
  2096. spell_reset(battler)
  2097. # Slip damage
  2098. if battler.hp > 0 and battler.slip_damage?
  2099. battler.slip_damage_effect
  2100. battler.damage_pop["slip"] = true
  2101. end
  2102. # State natural cancellation
  2103. battler.remove_states_auto
  2104. # Refreshing the status window
  2105. status_refresh(battler, true)
  2106. unless battler.movable?
  2107. return
  2108. end
  2109. # Turn several counts
  2110. @turn_cnt += 1
  2111. end
  2112. #--------------------------------------------------------------------------
  2113. # * Battler action start
  2114. #--------------------------------------------------------------------------
  2115. def action_start(battler)
  2116. battler.phase = 1
  2117. battler.anime1 = 0
  2118. battler.anime2 = 0
  2119. battler.target = []
  2120. battler.event = 0
  2121. @action_battlers.unshift(battler)
  2122. end
  2123. #--------------------------------------------------------------------------
  2124. # * Refreshing the status window
  2125. #--------------------------------------------------------------------------
  2126. def status_refresh(battler, at = false)
  2127. if battler.is_a?(Game_Actor)
  2128. for i in 0...$game_party.actors.size
  2129. if battler == $game_party.actors[i]
  2130. number = i + 1
  2131. end
  2132. end
  2133. @status_window.refresh(number)
  2134. if at == true
  2135. @status_window.at_refresh(number)
  2136. end
  2137. end
  2138. end
  2139. #--------------------------------------------------------------------------
  2140. # * Animation wait judgement processing
  2141. #--------------------------------------------------------------------------
  2142. def anime_wait_return
  2143. if (@action_battlers.empty? or @anime_wait == false) and
  2144. not $game_system.battle_interpreter.running?
  2145. # When the enemy arrow is valid
  2146. if @enemy_arrow != nil
  2147. return [@active - 2, 0].min == 0
  2148. # When the actor arrow is valid
  2149. elsif @actor_arrow != nil
  2150. return [@active - 2, 0].min == 0
  2151. # When the skill window is valid
  2152. elsif @skill_window != nil
  2153. return [@active - 3, 0].min == 0
  2154. # When the item window is valid
  2155. elsif @item_window != nil
  2156. return [@active - 3, 0].min == 0
  2157. # When the actor command window is valid
  2158. elsif @actor_command_window.active
  2159. return [@active - 1, 0].min == 0
  2160. else
  2161. return true
  2162. end
  2163. else
  2164. return false
  2165. end
  2166. end
  2167. #--------------------------------------------------------------------------
  2168. # * Actor command elimination judgement
  2169. #--------------------------------------------------------------------------
  2170. def command_delete
  2171. # When the enemy arrow is valid
  2172. if @enemy_arrow != nil
  2173. end_enemy_select
  2174. # When the actor is valid
  2175. elsif @actor_arrow != nil
  2176. end_actor_select
  2177. end
  2178. # When the skill window is valid
  2179. if @skill_window != nil
  2180. end_skill_select
  2181. # When the item window is valid
  2182. elsif @item_window != nil
  2183. end_item_select
  2184. end
  2185. # When the actor command window is valid
  2186. if @actor_command_window.active
  2187. @command.shift
  2188. @command_a = false
  2189. # Setting the main phase flag
  2190. $game_temp.battle_main_phase = true
  2191. # Hides the actor command window when it is invalid
  2192. @actor_command_window.active = false
  2193. @actor_command_window.visible = false
  2194. # Blinking effect OFF of actor
  2195. if @active_actor != nil
  2196. @active_actor.blink = false
  2197. end
  2198. end
  2199. end
  2200. #--------------------------------------------------------------------------
  2201. # * Forcing action setting
  2202. #--------------------------------------------------------------------------
  2203. def force_action(battler)
  2204. battler.current_action.kind = battler.current_action.force_kind
  2205. battler.current_action.basic = battler.current_action.force_basic
  2206. battler.current_action.skill_id = battler.current_action.force_skill_id
  2207. battler.current_action.force_kind = 0
  2208. battler.current_action.force_basic = 0
  2209. battler.current_action.force_skill_id = 0
  2210. end
  2211. #--------------------------------------------------------------------------
  2212. # * Camera set
  2213. #--------------------------------------------------------------------------
  2214. def camera_set(battler)
  2215. @camera = battler
  2216. if battler.target.size == 1
  2217. if battler.current_action.kind == 0
  2218. zoom = 1.2 / battler.target[0].zoom
  2219. elsif synthe?(battler) == nil
  2220. zoom = 1.5 / battler.target[0].zoom
  2221. else
  2222. zoom = 2.0 / battler.target[0].zoom
  2223. end
  2224. @spriteset.screen_target(battler.target[0].attack_x(zoom),
  2225. battler.target[0].attack_y(zoom), zoom)
  2226. else
  2227. @spriteset.screen_target(0, 0, 0.75)
  2228. end
  2229. end
  2230. #--------------------------------------------------------------------------
  2231. # * Skill permanent residence time compilation
  2232. #--------------------------------------------------------------------------
  2233. def recite_time(battler)
  2234. end
  2235. #--------------------------------------------------------------------------
  2236. # * Cooperation skill distinction
  2237. #--------------------------------------------------------------------------
  2238. def synthe_spell(battler)
  2239. end
  2240. #--------------------------------------------------------------------------
  2241. # * Skill learning system
  2242. #--------------------------------------------------------------------------
  2243. def skill_learning(actor, class_id, skill_id)
  2244. end
  2245. #--------------------------------------------------------------------------
  2246. # * Conduct possible decision
  2247. #--------------------------------------------------------------------------
  2248. def active?(battler)
  2249. speller = synthe?(battler)
  2250. if speller != nil
  2251. if synthe_delete?(speller)
  2252. return false
  2253. end
  2254. else
  2255. unless battler.inputable?
  2256. spell_reset(battler)
  2257. unless battler.movable?
  2258. battler.atp = 0
  2259. return false
  2260. end
  2261. end
  2262. if battler.current_action.forcing
  2263. spell_reset(battler)
  2264. end
  2265. end
  2266. return true
  2267. end
  2268. #--------------------------------------------------------------------------
  2269. # * During synthesis skill residing permanently?
  2270. #--------------------------------------------------------------------------
  2271. def synthe?(battler)
  2272. for speller in @synthe
  2273. if speller.include?(battler)
  2274. return speller
  2275. end
  2276. end
  2277. return nil
  2278. end
  2279. #--------------------------------------------------------------------------
  2280. # * Synthesis skill elimination judgement
  2281. #--------------------------------------------------------------------------
  2282. def synthe_delete?(speller)
  2283. for battler in speller
  2284. if not battler.inputable? and dead_ok?(battler)
  2285. synthe_delete(speller)
  2286. return true
  2287. end
  2288. end
  2289. return false
  2290. end
  2291. #--------------------------------------------------------------------------
  2292. # * Synthesis skill elimination
  2293. #--------------------------------------------------------------------------
  2294. def synthe_delete(speller)
  2295. for battler in speller
  2296. spell_reset(battler)
  2297. if dead_ok?(battler)
  2298. @action_battlers.delete(battler)
  2299. end
  2300. end
  2301. @synthe.delete(speller)
  2302. end
  2303. #--------------------------------------------------------------------------
  2304. # * Cooperation the skill permanent residence cancellation which is included
  2305. #--------------------------------------------------------------------------
  2306. def skill_reset(battler)
  2307. speller = synthe?(battler)
  2308. if speller != nil
  2309. synthe_delete(speller)
  2310. else
  2311. spell_reset(battler)
  2312. end
  2313. end
  2314. #--------------------------------------------------------------------------
  2315. # * Skill permanent residence cancellation
  2316. #--------------------------------------------------------------------------
  2317. def spell_reset(battler)
  2318. battler.rt = 0
  2319. battler.rtp = 0
  2320. battler.blink = false
  2321. battler.spell = false
  2322. battler.current_action.spell_id = 0
  2323. @spell_p.delete(battler)
  2324. @spell_e.delete(battler)
  2325. end
  2326. #--------------------------------------------------------------------------
  2327. # * Battle end decision
  2328. #--------------------------------------------------------------------------
  2329. def fin?
  2330. return (victory? or $game_party.all_dead? or $game_party.actors.size == 0)
  2331. end
  2332. #--------------------------------------------------------------------------
  2333. # * Enemy total destruction decision
  2334. #--------------------------------------------------------------------------
  2335. def victory?
  2336. for battler in $game_troop.enemies
  2337. if not battler.hidden and (battler.rest_hp > 0 or
  2338. battler.immortal or battler.damage_pop.size > 0)
  2339. return false
  2340. end
  2341. end
  2342. return true
  2343. end
  2344. #--------------------------------------------------------------------------
  2345. # * Death permission decision
  2346. #--------------------------------------------------------------------------
  2347. def dead_ok?(battler)
  2348. speller = synthe?(battler)
  2349. if speller == nil
  2350. if @action_battlers.include?(battler)
  2351. if battler.phase > 2
  2352. return false
  2353. end
  2354. end
  2355. else
  2356. for battler in speller
  2357. if @action_battlers.include?(battler)
  2358. if battler.phase > 2
  2359. return false
  2360. end
  2361. end
  2362. end
  2363. end
  2364. return true
  2365. end
  2366. end
  2367.  
  2368. #==============================================================================
  2369. # ** Game_Actor
  2370. #------------------------------------------------------------------------------
  2371. # It is the class which handles the actor. This class Game_Actors class
  2372. # ($game_actors) is used in inside, Game_Party class ($game_party) from is
  2373. # referred to.
  2374. #==============================================================================
  2375.  
  2376. class Game_Actor < Game_Battler
  2377. #--------------------------------------------------------------------------
  2378. # * Acquisition in battle picture X coordinate
  2379. #--------------------------------------------------------------------------
  2380. def screen_x
  2381. # Calculating X coordinate from line order inside the party, it returns
  2382. if self.index != nil
  2383. return self.index * 160 + (4 - $game_party.actors.size) * 80 + 80
  2384. else
  2385. return 0
  2386. end
  2387. end
  2388. end
  2389.  
  2390. #==============================================================================
  2391. # ** Spriteset_Battle
  2392. #------------------------------------------------------------------------------
  2393. # It is the class which collected the sprite of the battle picture. This class
  2394. # is used inside Scene_Battle ?? ?.
  2395. #==============================================================================
  2396.  
  2397. class Spriteset_Battle
  2398. #--------------------------------------------------------------------------
  2399. # * Public Instance Variables
  2400. #--------------------------------------------------------------------------
  2401. attr_reader :real_x # X coordinate revision (presently value)
  2402. attr_reader :real_y # Y coordinate revision (presently value)
  2403. attr_reader :real_zoom # Enlargement ratio (presently value)
  2404. #--------------------------------------------------------------------------
  2405. # * Object initialization
  2406. #--------------------------------------------------------------------------
  2407. def initialize
  2408. # Drawing up the viewport
  2409. @viewport1 = Viewport.new(0, 0, 640, 480)
  2410. @viewport2 = Viewport.new(0, 0, 640, 480)
  2411. @viewport3 = Viewport.new(0, 0, 640, 480)
  2412. @viewport4 = Viewport.new(0, 0, 640, 480)
  2413. @viewport2.z = 101
  2414. @viewport3.z = 200
  2415. @viewport4.z = 5000
  2416. @wait = 0
  2417. @real_x = 0
  2418. @real_y = 0
  2419. @real_zoom = 1.0
  2420. @target_x = 0
  2421. @target_y = 0
  2422. @target_zoom = 1.0
  2423. @gap_x = 0
  2424. @gap_y = 0
  2425. @gap_zoom = 0.0
  2426. # Make battleback sprite
  2427. @battleback_sprite = Sprite.new(@viewport1)
  2428. # Drawing up enemy sprite
  2429. @enemy_sprites = []
  2430. for enemy in $game_troop.enemies.reverse
  2431. @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  2432. end
  2433. # Drawing up actor sprite
  2434. @actor_sprites = []
  2435. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2436. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2437. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2438. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2439. # Drawing up the weather
  2440. @weather = RPG::Weather.new(@viewport1)
  2441. # Drawing up picture sprite
  2442. @picture_sprites = []
  2443. for i in 51..100
  2444. @picture_sprites.push(Sprite_Picture.new(@viewport3,
  2445. $game_screen.pictures[i]))
  2446. end
  2447. # Drawing up timer sprite
  2448. @timer_sprite = Sprite_Timer.new
  2449. # Frame renewal
  2450. update
  2451. end
  2452. #--------------------------------------------------------------------------
  2453. # * Frame renewal
  2454. #--------------------------------------------------------------------------
  2455. def update
  2456. # Contents of actor sprite renewal (in replacement of actor correspondence)
  2457. @actor_sprites[0].battler = $game_party.actors[0]
  2458. @actor_sprites[1].battler = $game_party.actors[1]
  2459. @actor_sprites[2].battler = $game_party.actors[2]
  2460. @actor_sprites[3].battler = $game_party.actors[3]
  2461. # When file name of the battle back is different from present ones,
  2462. if @battleback_name != $game_temp.battleback_name
  2463. make_battleback
  2464. end
  2465. # Scroll of picture
  2466. screen_scroll
  2467. # Position revision of monster
  2468. for enemy in $game_troop.enemies
  2469. enemy.real_x = @real_x
  2470. enemy.real_y = @real_y
  2471. enemy.real_zoom = @real_zoom
  2472. end
  2473. # Renewing battler sprite
  2474. for sprite in @enemy_sprites + @actor_sprites
  2475. sprite.update
  2476. end
  2477. # Renewing weather graphics
  2478. @weather.type = $game_screen.weather_type
  2479. @weather.max = $game_screen.weather_max
  2480. @weather.update
  2481. # Renewing picture sprite
  2482. for sprite in @picture_sprites
  2483. sprite.update
  2484. end
  2485. # Renewing timer sprite
  2486. @timer_sprite.update
  2487. # Setting the color tone and shake position of the picture
  2488. @viewport1.tone = $game_screen.tone
  2489. @viewport1.ox = $game_screen.shake
  2490. # Setting the flash color of the picture
  2491. @viewport4.color = $game_screen.flash_color
  2492. # Renewing the viewport
  2493. @viewport1.update
  2494. @viewport2.update
  2495. @viewport4.update
  2496. end
  2497. #--------------------------------------------------------------------------
  2498. # * Setting of battle background
  2499. #--------------------------------------------------------------------------
  2500. def make_battleback
  2501. @battleback_name = $game_temp.battleback_name
  2502. if @battleback_sprite.bitmap != nil
  2503. @battleback_sprite.bitmap.dispose
  2504. end
  2505. @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  2506. if @battleback_sprite.bitmap.width == 640 and
  2507. @battleback_sprite.bitmap.height == 320
  2508. @battleback_sprite.src_rect.set(0, 0, 1280, 640)
  2509. @base_zoom = 2.0
  2510. @battleback_sprite.zoom_x = @base_zoom
  2511. @battleback_sprite.zoom_y = @base_zoom
  2512. @real_y = 4
  2513. @battleback_sprite.x = 320
  2514. @battleback_sprite.y = @real_y
  2515. @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2516. @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2517. elsif @battleback_sprite.bitmap.width == 640 and
  2518. @battleback_sprite.bitmap.height == 480
  2519. @battleback_sprite.src_rect.set(0, 0, 960, 720)
  2520. @base_zoom = 1.5
  2521. @battleback_sprite.zoom_x = @base_zoom
  2522. @battleback_sprite.zoom_y = @base_zoom
  2523. @battleback_sprite.x = 320
  2524. @battleback_sprite.y = 0
  2525. @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2526. @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2527. else
  2528. @battleback_sprite.src_rect.set(0, 0, @battleback_sprite.bitmap.width,
  2529. @battleback_sprite.bitmap.height)
  2530. @base_zoom = 1.0
  2531. @battleback_sprite.zoom_x = @base_zoom
  2532. @battleback_sprite.zoom_y = @base_zoom
  2533. @battleback_sprite.x = 320
  2534. @battleback_sprite.y = 0
  2535. @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2536. @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2537. end
  2538. end
  2539. #--------------------------------------------------------------------------
  2540. # * Position enlargement ratio setting of scroll goal of picture
  2541. #--------------------------------------------------------------------------
  2542. def screen_target(x, y, zoom)
  2543. return unless $scene.drive
  2544. @wait = $scene.scroll_time
  2545. @target_x = x
  2546. @target_y = y
  2547. @target_zoom = zoom
  2548. screen_over
  2549. @gap_x = @target_x - @real_x
  2550. @gap_y = @target_y - @real_y
  2551. @gap_zoom = @target_zoom - @real_zoom
  2552. end
  2553. #--------------------------------------------------------------------------
  2554. # * Scroll of picture
  2555. #--------------------------------------------------------------------------
  2556. def screen_scroll
  2557. if @wait > 0
  2558. @real_x = @target_x - @gap_x * (@wait ** 2) / ($scene.scroll_time ** 2)
  2559. @real_y = @target_y - @gap_y * (@wait ** 2) / ($scene.scroll_time ** 2)
  2560. @real_zoom = @target_zoom -
  2561. @gap_zoom * (@wait ** 2) / ($scene.scroll_time ** 2)
  2562. @battleback_sprite.x = 320 + @real_x
  2563. @battleback_sprite.y = @real_y
  2564. @battleback_sprite.zoom_x = @base_zoom * @real_zoom
  2565. @battleback_sprite.zoom_y = @base_zoom * @real_zoom
  2566. @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2567. @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2568. @wait -= 1
  2569. end
  2570. end
  2571. #--------------------------------------------------------------------------
  2572. # * When the screen goes outside the picture, revision processing
  2573. #--------------------------------------------------------------------------
  2574. def screen_over
  2575. width = @battleback_sprite.bitmap.width * @base_zoom * @target_zoom / 2
  2576. unless 324 + @target_x > width and 324 - @target_x > width
  2577. if 324 + @target_x > width
  2578. @target_x = width - 324
  2579. elsif 324 - @target_x > width
  2580. @target_x = 324 - width
  2581. end
  2582. end
  2583. height = @battleback_sprite.bitmap.height * @base_zoom * @target_zoom / 4
  2584. unless @target_y > height - 4 and 484 - @target_y > 3 * height
  2585. if @target_y > height - 4
  2586. @target_y = height - 4
  2587. elsif 484 - @target_y > 3 * height
  2588. @target_y = 484 - 3 * height
  2589. end
  2590. end
  2591. end
  2592. end
  2593.  
  2594. #==============================================================================
  2595. # ** Game_Battler (Part 1)
  2596. #------------------------------------------------------------------------------
  2597. # It is the class which handles the battler. This class is used as superclass
  2598. # of Game_Actor class and Game_Enemy ?? ?.
  2599. #==============================================================================
  2600.  
  2601. class Game_Battler
  2602. #--------------------------------------------------------------------------
  2603. # * Release instance variable addition
  2604. #--------------------------------------------------------------------------
  2605. attr_accessor :up_level # The frequency of levelling up
  2606. attr_accessor :at # AT (time gauge)
  2607. attr_accessor :atp # AT (for indication)
  2608. attr_accessor :rt # RP (permanent residence gauge)
  2609. attr_accessor :rtp # RP (permanent residence necessary quantity)
  2610. attr_accessor :spell # In the midst of synthesis skill motion
  2611. attr_accessor :recover_hp # HP recovery quantity
  2612. attr_accessor :recover_sp # SP recovery quantity
  2613. attr_accessor :state_p # Status abnormal arrangement
  2614. attr_accessor :state_m # Status abnormal arrangement
  2615. attr_accessor :damage_sp # SP damage indicatory flag
  2616. attr_accessor :animation # Arrangement of animation ID and Hit
  2617. attr_accessor :phase
  2618. attr_accessor :wait
  2619. attr_accessor :target
  2620. attr_accessor :anime1
  2621. attr_accessor :anime2
  2622. attr_accessor :event
  2623. #--------------------------------------------------------------------------
  2624. # * Object initialization
  2625. #--------------------------------------------------------------------------
  2626. alias :initialize_rtab :initialize
  2627. def initialize
  2628. initialize_rtab
  2629. @damage_pop = {}
  2630. @damage = {}
  2631. @damage_sp = {}
  2632. @critical = {}
  2633. @recover_hp = {}
  2634. @recover_sp = {}
  2635. @state_p = {}
  2636. @state_m = {}
  2637. @animation = []
  2638. @phase = 1
  2639. @wait = 0
  2640. @target = []
  2641. @anime1 = 0
  2642. @anime2 = 0
  2643. @event = 0
  2644. end
  2645. #--------------------------------------------------------------------------
  2646. # * Existence decision
  2647. #--------------------------------------------------------------------------
  2648. def exist?
  2649. return (not @hidden and (@hp > 0 or @immortal or @damage.size > 0))
  2650. end
  2651. #--------------------------------------------------------------------------
  2652. # * Remaining HP estimate
  2653. #--------------------------------------------------------------------------
  2654. def rest_hp
  2655. # Substituting reality HP to rest_hp
  2656. rest_hp = @hp
  2657. # All damage which the battler receives is made to reflect on rest_hp
  2658. for pre_damage in @damage
  2659. if pre_damage[1].is_a?(Numeric)
  2660. rest_hp -= pre_damage[1]
  2661. end
  2662. end
  2663. return rest_hp
  2664. end
  2665. #--------------------------------------------------------------------------
  2666. # * Cancellation of state
  2667. # state_id : State ID
  2668. # force : Forced cancellation flag (with processing of automatic state use)
  2669. #--------------------------------------------------------------------------
  2670. def remove_state(state_id, force = false)
  2671. # When this state is added,
  2672. if state?(state_id)
  2673. # When with the state which it is forced is added, at the same time cancellation is not forcing
  2674. if @states_turn[state_id] == -1 and not force
  2675. # Method end
  2676. return
  2677. end
  2678. # When present HP 0 and option [ the state of HP 0 you regard ] it is valid
  2679. if @hp == 0 and $data_states[state_id].zero_hp
  2680. # Whether or not [ you regard the state of HP 0 ] there is a state in other things, decision
  2681. zero_hp = false
  2682. for i in @states
  2683. if i != state_id and $data_states[i].zero_hp
  2684. zero_hp = true
  2685. end
  2686. end
  2687. # If you are possible to cancel aggressive failure, HP in 1 modification
  2688. if zero_hp == false
  2689. @hp = 1
  2690. end
  2691. end
  2692. unless self.movable?
  2693. # Deleting state ID from @states arrangement and @states_turn hash
  2694. @states.delete(state_id)
  2695. @states_turn.delete(state_id)
  2696. if self.movable?
  2697. self.at = 0
  2698. end
  2699. else
  2700. # Deleting state ID from @states arrangement and @states_turn hash
  2701. @states.delete(state_id)
  2702. @states_turn.delete(state_id)
  2703. end
  2704. end
  2705. # The maximum check of HP and SP
  2706. @hp = [@hp, self.maxhp].min
  2707. @sp = [@sp, self.maxsp].min
  2708. end
  2709. #--------------------------------------------------------------------------
  2710. # * Effective application of normality attack
  2711. # attacker : Attack person (battler)
  2712. #--------------------------------------------------------------------------
  2713. def attack_effect(attacker)
  2714. # Clearing the critical flag
  2715. self.critical[attacker] = false
  2716. state_p[attacker] = []
  2717. state_m[attacker] = []
  2718. # First on-target hit decision
  2719. hit_result = (rand(100) < attacker.hit)
  2720. # In case of on-target hit
  2721. if hit_result == true
  2722. # Calculating the basic damage
  2723. atk = [attacker.atk - self.pdef / 2, 0].max
  2724. self.damage[attacker] = atk * (20 + attacker.str) / 20
  2725. # Attribute correction
  2726. self.damage[attacker] *= elements_correct(attacker.element_set)
  2727. self.damage[attacker] /= 100
  2728. # When the mark of the damage is correct,
  2729. if self.damage[attacker] > 0
  2730. # Critical correction
  2731. if rand(100) < 4 * attacker.dex / self.agi
  2732. self.damage[attacker] *= 2
  2733. self.critical[attacker] = true
  2734. end
  2735. # Defense correction
  2736. if self.guarding?
  2737. self.damage[attacker] /= 2
  2738. end
  2739. end
  2740. # Dispersion
  2741. if self.damage[attacker].abs > 0
  2742. amp = [self.damage[attacker].abs * 15 / 100, 1].max
  2743. self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp
  2744. end
  2745. # Second on-target hit decision
  2746. eva = 8 * self.agi / attacker.dex + self.eva
  2747. hit = self.damage[attacker] < 0 ? 100 : 100 - eva
  2748. hit = self.cant_evade? ? 100 : hit
  2749. hit_result = (rand(100) < hit)
  2750. end
  2751. # In case of on-target hit
  2752. if hit_result == true
  2753. # State shocking cancellation
  2754. remove_states_shock
  2755. # From HP damage subtraction
  2756. # State change
  2757. @state_changed = false
  2758. states_plus(attacker, attacker.plus_state_set)
  2759. states_minus(attacker, attacker.minus_state_set)
  2760. # In case of miss
  2761. else
  2762. # Setting "Miss" to the damage
  2763. self.damage[attacker] = "Miss"
  2764. # Clearing the critical flag
  2765. self.critical[attacker] = false
  2766. end
  2767. # Method end
  2768. return true
  2769. end
  2770. #--------------------------------------------------------------------------
  2771. # * Effective application of skill
  2772. # user : User of skill (battler)
  2773. # skill : Skill
  2774. #--------------------------------------------------------------------------
  2775. def skill_effect(user, skill)
  2776. # Clearing the critical flag
  2777. self.critical[user] = false
  2778. state_p[user] = []
  2779. state_m[user] = []
  2780. # Effective range of skill with friend of HP 1 or more, your own HP 0,
  2781. # Or when the effective range of skill with the friend of HP 0, your own HP are 1 or more
  2782. if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2783. ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2784. # Method end
  2785. return false
  2786. end
  2787. # Clearing the effective flag
  2788. effective = false
  2789. # When common event ID is valid setting the effective flag
  2790. effective |= skill.common_event_id > 0
  2791. # First on-target hit decision
  2792. hit = skill.hit
  2793. if skill.atk_f > 0
  2794. hit *= user.hit / 100
  2795. end
  2796. hit_result = (rand(100) < hit)
  2797. # In case of uncertain skill setting the effective flag
  2798. effective |= hit < 100
  2799. # In case of on-target hit
  2800. if hit_result == true
  2801. # Calculating power
  2802. power = skill.power + user.atk * skill.atk_f / 100
  2803. if power > 0
  2804. power -= self.pdef * skill.pdef_f / 200
  2805. power -= self.mdef * skill.mdef_f / 200
  2806. power = [power, 0].max
  2807. end
  2808. # Calculating magnification ratio
  2809. rate = 20
  2810. rate += (user.str * skill.str_f / 100)
  2811. rate += (user.dex * skill.dex_f / 100)
  2812. rate += (user.agi * skill.agi_f / 100)
  2813. rate += (user.int * skill.int_f / 100)
  2814. # Calculating the basic damage
  2815. self.damage[user] = power * rate / 20
  2816. # Attribute correction
  2817. self.damage[user] *= elements_correct(skill.element_set)
  2818. self.damage[user] /= 100
  2819. # When the mark of the damage is correct
  2820. if self.damage[user] > 0
  2821. # Defense correction
  2822. if self.guarding?
  2823. self.damage[user] /= 2
  2824. end
  2825. end
  2826. # Dispersion
  2827. if skill.variance > 0 and self.damage[user].abs > 0
  2828. amp = [self.damage[user].abs * skill.variance / 100, 1].max
  2829. self.damage[user] += rand(amp+1) + rand(amp+1) - amp
  2830. end
  2831. # Second on-target hit decision
  2832. eva = 8 * self.agi / user.dex + self.eva
  2833. hit = self.damage[user] < 0 ? 100 : 100 - eva * skill.eva_f / 100
  2834. hit = self.cant_evade? ? 100 : hit
  2835. hit_result = (rand(100) < hit)
  2836. # In case of uncertain skill setting the effective flag
  2837. effective |= hit < 100
  2838. end
  2839. # In case of on-target hit
  2840. if hit_result == true
  2841. # In case of physical attack other than power 0
  2842. if skill.power != 0 and skill.atk_f > 0
  2843. # State shocking cancellation
  2844. remove_states_shock
  2845. # Setting the effective flag
  2846. effective = true
  2847. end
  2848. # The fluctuation decision of HP
  2849. last_hp = [[self.hp - self.damage[user], self.maxhp].min, 0].max # Effective decision
  2850. effective |= self.hp != last_hp
  2851. # State change
  2852. @state_changed = false
  2853. effective |= states_plus(user, skill.plus_state_set)
  2854. effective |= states_minus(user, skill.minus_state_set)
  2855. unless $game_temp.in_battle
  2856. self.damage_effect(user, 1)
  2857. end
  2858. # When power 0 is,
  2859. if skill.power == 0
  2860. # Setting the null line to the damage
  2861. self.damage[user] = ""
  2862. # When there is no change in the state,
  2863. unless @state_changed
  2864. # Setting "Miss" to the damage
  2865. self.damage[user] = "Miss"
  2866. end
  2867. end
  2868. # In case of miss
  2869. else
  2870. # Setting "Miss" to the damage
  2871. self.damage[user] = "Miss"
  2872. end
  2873. # When it is not in the midst of fighting,
  2874. unless $game_temp.in_battle
  2875. # Setting nil to the damage
  2876. self.damage[user] = nil
  2877. end
  2878. # Method end
  2879. return effective
  2880. end
  2881. #--------------------------------------------------------------------------
  2882. # * Effective application of item
  2883. # item : Item
  2884. #--------------------------------------------------------------------------
  2885. def item_effect(item, user = $game_party.actors[0])
  2886. # Clearing the critical flag
  2887. self.critical[user] = false
  2888. state_p[user] = []
  2889. state_m[user] = []
  2890. self.recover_hp[user] = 0
  2891. self.recover_sp[user] = 0
  2892. # Effective range of item with friend of HP 1 or more, your own HP 0,
  2893. # Or when the effective range of the item with the friend of HP 0, your own HP are 1 or more,
  2894. if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  2895. ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  2896. # Method end
  2897. return false
  2898. end
  2899. # Clearing the effective flag
  2900. effective = false
  2901. # When common event ID is valid setting the effective flag
  2902. effective |= item.common_event_id > 0
  2903. # On-target hit decision
  2904. hit_result = (rand(100) < item.hit)
  2905. # In case of uncertain skill setting the effective flag
  2906. effective |= item.hit < 100
  2907. # In case of on-target hit
  2908. if hit_result == true
  2909. # Calculating the recovery quantity
  2910. self.recover_hp[user] = maxhp * item.recover_hp_rate / 100 +
  2911. item.recover_hp
  2912. self.recover_sp[user] = maxsp * item.recover_sp_rate / 100 +
  2913. item.recover_sp
  2914. if self.recover_hp[user] < 0
  2915. self.recover_hp[user] += self.pdef * item.pdef_f / 20
  2916. self.recover_hp[user] += self.mdef * item.mdef_f / 20
  2917. self.recover_hp[user] = [self.recover_hp[user], 0].min
  2918. end
  2919. # Attribute correction
  2920. self.recover_hp[user] *= elements_correct(item.element_set)
  2921. self.recover_hp[user] /= 100
  2922. self.recover_sp[user] *= elements_correct(item.element_set)
  2923. self.recover_sp[user] /= 100
  2924. # Dispersion
  2925. if item.variance > 0 and self.recover_hp[user].abs > 0
  2926. amp = [self.recover_hp[user].abs * item.variance / 100, 1].max
  2927. self.recover_hp[user] += rand(amp+1) + rand(amp+1) - amp
  2928. end
  2929. if item.variance > 0 and self.recover_sp[user].abs > 0
  2930. amp = [self.recover_sp[user].abs * item.variance / 100, 1].max
  2931. self.recover_sp[user] += rand(amp+1) + rand(amp+1) - amp
  2932. end
  2933. # When the mark of the recovery quantity is negative number
  2934. if self.recover_hp[user] < 0
  2935. # Defense correction
  2936. if self.guarding?
  2937. self.recover_hp[user] /= 2
  2938. end
  2939. end
  2940. # The mark of the HP recovery quantity it reverses, sets to the value of the damage
  2941. self.damage[user] = -self.recover_hp[user]
  2942. # The fluctuation decision of HP and SP
  2943. last_hp = [[self.hp + self.recover_hp[user], self.maxhp].min, 0].max
  2944. last_sp = [[self.sp + self.recover_sp[user], self.maxsp].min, 0].max
  2945. effective |= self.hp != last_hp
  2946. effective |= self.sp != last_sp
  2947. # State change
  2948. @state_changed = false
  2949. effective |= states_plus(user, item.plus_state_set)
  2950. effective |= states_minus(user, item.minus_state_set)
  2951. unless $game_temp.in_battle
  2952. self.damage_effect(user, 2)
  2953. end
  2954. # When parameter rise value is valid
  2955. if item.parameter_type > 0 and item.parameter_points != 0
  2956. # It diverges with parameter
  2957. case item.parameter_type
  2958. when 1 # MaxHP
  2959. @maxhp_plus += item.parameter_points
  2960. when 2 # MaxSP
  2961. @maxsp_plus += item.parameter_points
  2962. when 3 #Strength
  2963. @str_plus += item.parameter_points
  2964. when 4 # Dexterity
  2965. @dex_plus += item.parameter_points
  2966. when 5 # Agility
  2967. @agi_plus += item.parameter_points
  2968. when 6 # Intelligence
  2969. @int_plus += item.parameter_points
  2970. end
  2971. # Setting the effective flag
  2972. effective = true
  2973. end
  2974. # When HP recovery factor and the recovery quantity 0 is
  2975. if item.recover_hp_rate == 0 and item.recover_hp == 0
  2976. # Setting the null line to the damage
  2977. self.damage[user] = ""
  2978. # When SP recovery factor and the recovery quantity 0, parameter rise value is invalid,
  2979. if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  2980. (item.parameter_type == 0 or item.parameter_points == 0)
  2981. # When there is no change in the state,
  2982. unless @state_changed
  2983. # Setting "Miss" to the damage
  2984. self.damage[user] = "Miss"
  2985. end
  2986. end
  2987. end
  2988. # In case of miss
  2989. else
  2990. # Setting "Miss" to the damage
  2991. self.damage[user] = "Miss"
  2992. end
  2993. # When it is not in the midst of fighting,
  2994. unless $game_temp.in_battle
  2995. # Setting nil to the damage
  2996. self.damage[user] = nil
  2997. end
  2998. # Method end
  2999. return effective
  3000. end
  3001. #--------------------------------------------------------------------------
  3002. # * State change (+) application
  3003. # plus_state_set : State change (+)
  3004. #--------------------------------------------------------------------------
  3005. def states_plus(battler, plus_state_set)
  3006. # Clearing the effective flag
  3007. effective = false
  3008. # The loop (the state which is added)
  3009. for i in plus_state_set
  3010. # When this state is not defended,
  3011. unless self.state_guard?(i)
  3012. # If this state is not full, setting the effective flag
  3013. effective |= self.state_full?(i) == false
  3014. # When the state [ it does not resist ] is,
  3015. if $data_states[i].nonresistance
  3016. # Setting the state change flag
  3017. @state_changed = true
  3018. # Adding the state
  3019. self.state_p[battler].push(i)
  3020. # When this state is not full,
  3021. elsif self.state_full?(i) == false
  3022. # It converts degree of state validity to probability, compares with random number
  3023. if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]]
  3024. # Setting the state change flag
  3025. @state_changed = true
  3026. # Adding the state
  3027. self.state_p[battler].push(i)
  3028. end
  3029. end
  3030. end
  3031. end
  3032. # Method end
  3033. return effective
  3034. end
  3035. #--------------------------------------------------------------------------
  3036. # * State change (-) application
  3037. # minus_state_set : State change (-)
  3038. #--------------------------------------------------------------------------
  3039. def states_minus(battler, minus_state_set)
  3040. # Clearing the effective flag
  3041. effective = false
  3042. # The loop (the state which is cancelled)
  3043. for i in minus_state_set
  3044. # If this state is added, setting the effective flag
  3045. effective |= self.state?(i)
  3046. # Setting the state change flag
  3047. @state_changed = true
  3048. # Cancelling the state
  3049. self.state_m[battler].push(i)
  3050. end
  3051. # Method end
  3052. return effective
  3053. end
  3054. #--------------------------------------------------------------------------
  3055. # * Damage operation
  3056. #--------------------------------------------------------------------------
  3057. def damage_effect(battler, item)
  3058. if item == 2
  3059. self.hp += self.recover_hp[battler]
  3060. self.sp += self.recover_sp[battler]
  3061. if self.recover_sp[battler] != 0
  3062. self.damage_sp[battler] = -self.recover_sp[battler]
  3063. end
  3064. self.recover_hp.delete(battler)
  3065. self.recover_sp.delete(battler)
  3066. else
  3067. if self.damage[battler].class != String
  3068. self.hp -= self.damage[battler]
  3069. end
  3070. end
  3071. for i in self.state_p[battler]
  3072. add_state(i)
  3073. end
  3074. for i in self.state_m[battler]
  3075. remove_state(i)
  3076. end
  3077. end
  3078. #--------------------------------------------------------------------------
  3079. # * Effective application of slip damage
  3080. #--------------------------------------------------------------------------
  3081. def slip_damage_effect
  3082. # Setting the damage
  3083. self.damage["slip"] = self.maxhp / 10
  3084. # Dispersion
  3085. if self.damage["slip"].abs > 0
  3086. amp = [self.damage["slip"].abs * 15 / 100, 1].max
  3087. self.damage["slip"] += rand(amp+1) + rand(amp+1) - amp
  3088. end
  3089. # From HP damage subtraction
  3090. self.hp -= self.damage["slip"]
  3091. # Method end
  3092. return true
  3093. end
  3094. end
  3095.  
  3096. #==============================================================================
  3097. # ** Game_BattleAction
  3098. #------------------------------------------------------------------------------
  3099. # Action (the conduct which is in the midst of fighting) it is the class which
  3100. # is handled. This class is used inside Game_Battler ?? ?.
  3101. #==============================================================================
  3102.  
  3103. class Game_BattleAction
  3104. #--------------------------------------------------------------------------
  3105. # * Public Instance Variables
  3106. #--------------------------------------------------------------------------
  3107. attr_accessor :spell_id # Skill ID for union magic
  3108. attr_accessor :force_kind # Classification (basis/skill/item)
  3109. attr_accessor :force_basic # basis (attack/defend/escape)
  3110. attr_accessor :force_skill_id # Skill ID
  3111. #--------------------------------------------------------------------------
  3112. # * Validity decision
  3113. #--------------------------------------------------------------------------
  3114. def valid?
  3115. return (not (@force_kind == 0 and @force_basic == 3))
  3116. end
  3117. end
  3118.  
  3119. #==============================================================================
  3120. # ** Game_Actor
  3121. #------------------------------------------------------------------------------
  3122. # It is the class which handles the actor. This class Game_Actors class
  3123. # ($game_actors) is used in inside, Game_Party class ($game_party) from is
  3124. # referred to.
  3125. #==============================================================================
  3126.  
  3127. class Game_Actor < Game_Battler
  3128. def skill_can_use?(skill_id)
  3129. return super
  3130. end
  3131. end
  3132.  
  3133. #==============================================================================
  3134. # ** Game_Enemy
  3135. #------------------------------------------------------------------------------
  3136. # It is the class which handles the enemy. This class Game_Troop class
  3137. # ($game_troop) is used in inside.
  3138. #==============================================================================
  3139.  
  3140. class Game_Enemy < Game_Battler
  3141. #--------------------------------------------------------------------------
  3142. # * Public Instance Variables
  3143. #--------------------------------------------------------------------------
  3144. attr_accessor :height # Height of picture
  3145. attr_accessor :real_x # X-coordinate revision
  3146. attr_accessor :real_y # Y-coordinate revision
  3147. attr_accessor :real_zoom # Enlargement ratio
  3148. #--------------------------------------------------------------------------
  3149. # * Object initialization
  3150. # troop_id :Troop ID
  3151. # member_index : Index of troop member
  3152. #--------------------------------------------------------------------------
  3153. def initialize(troop_id, member_index)
  3154. super()
  3155. @troop_id = troop_id
  3156. @member_index = member_index
  3157. troop = $data_troops[@troop_id]
  3158. @enemy_id = troop.members[@member_index].enemy_id
  3159. enemy = $data_enemies[@enemy_id]
  3160. @battler_name = enemy.battler_name
  3161. @battler_hue = enemy.battler_hue
  3162. @hp = maxhp
  3163. @sp = maxsp
  3164. @real_x = 0
  3165. @real_y = 0
  3166. @real_zoom = 1.0
  3167. @fly = 0
  3168. enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {@fly = $1.to_i}
  3169. @hidden = troop.members[@member_index].hidden
  3170. @immortal = troop.members[@member_index].immortal
  3171. end
  3172. alias :true_x :screen_x
  3173. alias :true_y :screen_y
  3174. #--------------------------------------------------------------------------
  3175. # * Acquisition in battle picture X coordinate
  3176. #--------------------------------------------------------------------------
  3177. def screen_x
  3178. return 320 + (true_x - 320) * @real_zoom + @real_x
  3179. end
  3180. #--------------------------------------------------------------------------
  3181. # * Acquisition in battle picture Y coordinate
  3182. #--------------------------------------------------------------------------
  3183. def screen_y
  3184. return true_y * @real_zoom + @real_y
  3185. end
  3186. #--------------------------------------------------------------------------
  3187. # * Acquisition in battle picture Z coordinate
  3188. #--------------------------------------------------------------------------
  3189. def screen_z
  3190. return true_y + @fly
  3191. end
  3192. #--------------------------------------------------------------------------
  3193. # * Acquisition of battle picture enlargement ratio
  3194. #--------------------------------------------------------------------------
  3195. def zoom
  3196. return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
  3197. (true_y + @fly) / 320 + $scene.zoom_rate[0]
  3198. end
  3199. #--------------------------------------------------------------------------
  3200. # * For attack and acquisition in battle picture X coordinate
  3201. #--------------------------------------------------------------------------
  3202. def attack_x(z)
  3203. return (320 - true_x) * z * 0.75
  3204. end
  3205. #--------------------------------------------------------------------------
  3206. # * For attack and acquisition of battle picture Y-coordinate
  3207. #--------------------------------------------------------------------------
  3208. def attack_y(z)
  3209. return (160 - (true_y + @fly / 4) * z + @height * zoom * z / 2) * 0.75
  3210. end
  3211. #--------------------------------------------------------------------------
  3212. # * Action compilation
  3213. #--------------------------------------------------------------------------
  3214. def make_action
  3215. # Clearing current action
  3216. self.current_action.clear
  3217. # When it cannot move,
  3218. unless self.inputable?
  3219. # Method end
  3220. return
  3221. end
  3222. # Presently extracting effective action
  3223. available_actions = []
  3224. rating_max = 0
  3225. for action in self.actions
  3226. # Turn conditional verification
  3227. n = $game_temp.battle_turn
  3228. a = action.condition_turn_a
  3229. b = action.condition_turn_b
  3230. if (b == 0 and n != a) or
  3231. (b > 0 and (n < 1 or n < a or n % b != a % b))
  3232. next
  3233. end
  3234. # HP conditional verification
  3235. if self.hp * 100.0 / self.maxhp > action.condition_hp
  3236. next
  3237. end
  3238. # Level conditional verification
  3239. if $game_party.max_level < action.condition_level
  3240. next
  3241. end
  3242. # Switch conditional verification
  3243. switch_id = action.condition_switch_id
  3244. if switch_id > 0 and $game_switches[switch_id] == false
  3245. next
  3246. end
  3247. # Skill active conditional verification
  3248. if action.kind == 1
  3249. unless self.skill_can_use?(action.skill_id)
  3250. next
  3251. end
  3252. end
  3253. # It corresponds to condition : Adding this action
  3254. available_actions.push(action)
  3255. if action.rating > rating_max
  3256. rating_max = action.rating
  3257. end
  3258. end
  3259. # Maximum rating value as 3 total calculation (as for 0 or less exclusion)
  3260. ratings_total = 0
  3261. for action in available_actions
  3262. if action.rating > rating_max - 3
  3263. ratings_total += action.rating - (rating_max - 3)
  3264. end
  3265. end
  3266. # When total of rating 0 is not,
  3267. if ratings_total > 0
  3268. # Drawing up random number
  3269. value = rand(ratings_total)
  3270. # Setting those which correspond to the random number which it drew up to current action
  3271. for action in available_actions
  3272. if action.rating > rating_max - 3
  3273. if value < action.rating - (rating_max - 3)
  3274. self.current_action.kind = action.kind
  3275. self.current_action.basic = action.basic
  3276. self.current_action.skill_id = action.skill_id
  3277. self.current_action.decide_random_target_for_enemy
  3278. return
  3279. else
  3280. value -= action.rating - (rating_max - 3)
  3281. end
  3282. end
  3283. end
  3284. end
  3285. end
  3286. end
  3287.  
  3288. #==============================================================================
  3289. # ** Game_Party
  3290. #------------------------------------------------------------------------------
  3291. # It is the class which handles the party. Information of the gold and the
  3292. # item etc. is included. Instance of this ? lath is referred to being
  3293. # $game_party.
  3294. #==============================================================================
  3295.  
  3296. class Game_Party
  3297. #--------------------------------------------------------------------------
  3298. # * Total destruction decision
  3299. #--------------------------------------------------------------------------
  3300. def all_dead?
  3301. # When party number of people 0 is
  3302. if $game_party.actors.size == 0
  3303. return false
  3304. end
  3305. # When the actor of HP 0 or more is in the party,
  3306. for actor in @actors
  3307. if actor.rest_hp > 0
  3308. return false
  3309. end
  3310. end
  3311. # Total destruction
  3312. return true
  3313. end
  3314. #--------------------------------------------------------------------------
  3315. # * Random of object actor decision
  3316. # hp0 : Limits to the actor of HP 0
  3317. #--------------------------------------------------------------------------
  3318. # Original target decisive routine smooth_target_actor_rtab and name modification
  3319. alias :random_target_actor_rtab :random_target_actor
  3320. def random_target_actor(hp0 = false)
  3321. # Initializing the roulette
  3322. roulette = []
  3323. # Loop
  3324. for actor in @actors
  3325. # When it corresponds to condition
  3326. if (not hp0 and actor.exist? and actor.rest_hp > 0) or
  3327. (hp0 and actor.hp0?)
  3328. # Acquiring the [ position ] of class of actor
  3329. position = $data_classes[actor.class_id].position
  3330. # At the time of avant-garde n = 4?At the time of medium defense n = 3?At the time rear guard n = 2
  3331. n = 4 - position
  3332. # In roulette actor n time addition
  3333. n.times do
  3334. roulette.push(actor)
  3335. end
  3336. end
  3337. end
  3338. # When size of the roulette 0 is
  3339. if roulette.size == 0
  3340. return random_target_actor_rtab(hp0)
  3341. end
  3342. # It turns the roulette, deciding the actor
  3343. return roulette[rand(roulette.size)]
  3344. end
  3345. #--------------------------------------------------------------------------
  3346. # * Smooth decision of object actor
  3347. # actor_index : actor index
  3348. #--------------------------------------------------------------------------
  3349. # Original target decisive routine smooth_target_actor_rtab and name modification
  3350. alias :smooth_target_actor_rtab :smooth_target_actor
  3351. def smooth_target_actor(actor_index)
  3352. # Acquiring the actor
  3353. actor = @actors[actor_index]
  3354. # When the actor exists
  3355. if actor != nil and actor.exist? and actor.rest_hp > 0
  3356. return actor
  3357. end
  3358. # Loop
  3359. for actor in @actors
  3360. # When the actor exists
  3361. if actor.exist? and actor.rest_hp > 0
  3362. return actor
  3363. end
  3364. end
  3365. # When friend has destroyed, original target decisive routine is executed
  3366. return smooth_target_actor_rtab(actor_index)
  3367. end
  3368. end
  3369.  
  3370. #==============================================================================
  3371. # ** Game_Troop
  3372. #------------------------------------------------------------------------------
  3373. # It is the class which handles the troop. As for instance of this class with
  3374. # $game_troop reference the ? it increases.
  3375. #==============================================================================
  3376.  
  3377. class Game_Troop
  3378. #--------------------------------------------------------------------------
  3379. # * Random of object enemy decision
  3380. # hp0 : It limits to the enemy of HP 0
  3381. #--------------------------------------------------------------------------
  3382. # Original target decisive routine random_target_enemy_rtab and name modification
  3383. alias :random_target_enemy_rtab :random_target_enemy
  3384. def random_target_enemy(hp0 = false)
  3385. # Initializing the roulette
  3386. roulette = []
  3387. # Loop
  3388. for enemy in @enemies
  3389. # When it corresponds to condition,
  3390. if (not hp0 and enemy.exist? and enemy.rest_hp > 0) or
  3391. (hp0 and enemy.hp0?)
  3392. # Adding the enemy to the roulette
  3393. roulette.push(enemy)
  3394. end
  3395. end
  3396. # When size of the roulette 0 is,
  3397. if roulette.size == 0
  3398. return random_target_enemy_rtab(hp0)
  3399. end
  3400. # It turns the roulette, deciding the enemy
  3401. return roulette[rand(roulette.size)]
  3402. end
  3403. #--------------------------------------------------------------------------
  3404. # * Smooth decision of object enemy
  3405. # enemy_index : enemy index
  3406. #--------------------------------------------------------------------------
  3407. # Original target decisive routine smooth_target_enemy_rtab and name modification
  3408. alias :smooth_target_enemy_rtab :smooth_target_enemy
  3409. def smooth_target_enemy(enemy_index)
  3410. # Acquiring the enemy
  3411. enemy = @enemies[enemy_index]
  3412. # When the enemy exists,
  3413. if enemy != nil and enemy.exist? and enemy.rest_hp > 0
  3414. return enemy
  3415. end
  3416. # Loop
  3417. for enemy in @enemies
  3418. # When the enemy exists,
  3419. if enemy.exist? and enemy.rest_hp > 0
  3420. return enemy
  3421. end
  3422. end
  3423. # When the enemy has destroyed, it searches the enemy for the second time
  3424. return smooth_target_enemy_rtab(enemy_index)
  3425. end
  3426. end
  3427.  
  3428. #==============================================================================
  3429. # ** Sprite_Battler
  3430. #------------------------------------------------------------------------------
  3431. # It is sprite for battler indication. Instance of Game_Battler class is watched,
  3432. # state of sprite changes automatically.
  3433. #==============================================================================
  3434.  
  3435. class Sprite_Battler < RPG::Sprite
  3436. #--------------------------------------------------------------------------
  3437. # * Frame Renewal
  3438. #--------------------------------------------------------------------------
  3439. def update
  3440. super
  3441. # When the battler is nil
  3442. if @battler == nil
  3443. self.bitmap = nil
  3444. loop_animation(nil)
  3445. return
  3446. end
  3447. # When file name or hue differs from present ones
  3448. if @battler.battler_name != @battler_name or
  3449. @battler.battler_hue != @battler_hue
  3450. # To acquire bitmap, setting
  3451. @battler_name = @battler.battler_name
  3452. @battler_hue = @battler.battler_hue
  3453. self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  3454. @width = bitmap.width
  3455. @height = bitmap.height
  3456. self.ox = @width / 2
  3457. self.oy = @height
  3458. if @battler.is_a?(Game_Enemy)
  3459. @battler.height = @height
  3460. end
  3461. # Aggressive failure or it hides and if state it designates opacity as 0
  3462. if @battler.dead? or @battler.hidden
  3463. self.opacity = 0
  3464. end
  3465. end
  3466. # When animation ID differs from present ones
  3467. if @battler.state_animation_id != @state_animation_id
  3468. @state_animation_id = @battler.state_animation_id
  3469. loop_animation($data_animations[@state_animation_id])
  3470. end
  3471. # In case of the actor whom it should indicate
  3472. if @battler.is_a?(Game_Actor) and @battler_visible
  3473. # When being main phase, opacity is lowered a little
  3474. if $game_temp.battle_main_phase
  3475. self.opacity += 3 if self.opacity < 255
  3476. else
  3477. self.opacity -= 3 if self.opacity > 207
  3478. end
  3479. end
  3480. # Blinking
  3481. if @battler.blink
  3482. blink_on
  3483. else
  3484. blink_off
  3485. end
  3486. # In case of invisibility
  3487. unless @battler_visible
  3488. # Appearance
  3489. if not @battler.hidden and not @battler.dead? and
  3490. (@battler.damage.size < 2 or @battler.damage_pop.size < 2)
  3491. appear
  3492. @battler_visible = true
  3493. end
  3494. end
  3495. # Damage
  3496. for battler in @battler.damage_pop
  3497. if battler[0].class == Array
  3498. if battler[0][1] >= 0
  3499. $scene.skill_se
  3500. else
  3501. $scene.levelup_se
  3502. end
  3503. damage(@battler.damage[battler[0]], false, 2)
  3504. else
  3505. damage(@battler.damage[battler[0]], @battler.critical[battler[0]])
  3506. end
  3507. if @battler.damage_sp.include?(battler[0])
  3508. damage(@battler.damage_sp[battler[0]],
  3509. @battler.critical[battler[0]], 1)
  3510. @battler.damage_sp.delete(battler[0])
  3511. end
  3512. @battler.damage_pop.delete(battler[0])
  3513. @battler.damage.delete(battler[0])
  3514. @battler.critical.delete(battler[0])
  3515. end
  3516. # When it is visible
  3517. if @battler_visible
  3518. # Flight
  3519. if @battler.hidden
  3520. $game_system.se_play($data_system.escape_se)
  3521. escape
  3522. @battler_visible = false
  3523. end
  3524. # White Flash
  3525. if @battler.white_flash
  3526. whiten
  3527. @battler.white_flash = false
  3528. end
  3529. # Animation
  3530. unless @battler.animation.empty?
  3531. for animation in @battler.animation.reverse
  3532. animation($data_animations[animation[0]], animation[1])
  3533. @battler.animation.delete(animation)
  3534. end
  3535. end
  3536. # Collapse
  3537. if @battler.damage.empty? and @battler.dead?
  3538. if $scene.dead_ok?(@battler)
  3539. if @battler.is_a?(Game_Enemy)
  3540. $game_system.se_play($data_system.enemy_collapse_se)
  3541. else
  3542. $game_system.se_play($data_system.actor_collapse_se)
  3543. end
  3544. collapse
  3545. @battler_visible = false
  3546. end
  3547. end
  3548. end
  3549. # Setting the coordinate of sprite
  3550. self.x = @battler.screen_x
  3551. self.y = @battler.screen_y
  3552. self.z = @battler.screen_z
  3553. if @battler.is_a?(Game_Enemy)
  3554. self.zoom_x = @battler.real_zoom * @battler.zoom
  3555. self.zoom_y = @battler.real_zoom * @battler.zoom
  3556. end
  3557. end
  3558. end
  3559.  
  3560. #==============================================================================
  3561. # ** Window_Base
  3562. #------------------------------------------------------------------------------
  3563. # It is superclass of all windows in the game.
  3564. #==============================================================================
  3565.  
  3566. class Window_Base < Window
  3567. #--------------------------------------------------------------------------
  3568. # * Drawing of gauge
  3569. #--------------------------------------------------------------------------
  3570. def gauge_rect_at(width, height, align3,
  3571. color1, color2, color3, color4, color5, color6, color7,
  3572. color8, color9, color10, color11, color12, grade1, grade2)
  3573. # Framework drawing
  3574. @at_gauge = Bitmap.new(width, height * 5)
  3575. @at_gauge.fill_rect(0, 0, width, height, color1)
  3576. @at_gauge.fill_rect(1, 1, width - 2, height - 2, color2)
  3577. if (align3 == 1 and grade1 == 0) or grade1 > 0
  3578. color = color3
  3579. color3 = color4
  3580. color4 = color
  3581. end
  3582. if (align3 == 1 and grade2 == 0) or grade2 > 0
  3583. color = color5
  3584. color5 = color6
  3585. color6 = color
  3586. color = color7
  3587. color7 = color8
  3588. color8 = color
  3589. color = color9
  3590. color9 = color10
  3591. color10 = color
  3592. color = color11
  3593. color11 = color12
  3594. color12 = color
  3595. end
  3596. if align3 == 0
  3597. if grade1 == 2
  3598. grade1 = 3
  3599. end
  3600. if grade2 == 2
  3601. grade2 = 3
  3602. end
  3603. end
  3604. # Drawing vertically of empty gauge gradation indication
  3605. @at_gauge.gradation_rect(2, 2, width - 4, height - 4,
  3606. color3, color4, grade1)
  3607. # Drawing of actual gauge
  3608. @at_gauge.gradation_rect(2, height + 2, width- 4, height - 4,
  3609. color5, color6, grade2)
  3610. @at_gauge.gradation_rect(2, height * 2 + 2, width- 4, height - 4,
  3611. color7, color8, grade2)
  3612. @at_gauge.gradation_rect(2, height * 3 + 2, width- 4, height - 4,
  3613. color9, color10, grade2)
  3614. @at_gauge.gradation_rect(2, height * 4 + 2, width- 4, height - 4,
  3615. color11, color12, grade2)
  3616. end
  3617. end
  3618.  
  3619. #==============================================================================
  3620. # ** Window_Help
  3621. #------------------------------------------------------------------------------
  3622. # It is the window which indicates the item description the skill and the
  3623. # status etc. of the actor.
  3624. #==============================================================================
  3625.  
  3626. class Window_Help < Window_Base
  3627. #--------------------------------------------------------------------------
  3628. # * Enemy Setting
  3629. # enemy : The enemy which indicates name and the state
  3630. #--------------------------------------------------------------------------
  3631. def set_enemy(enemy)
  3632. text = enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {""}
  3633. state_text = make_battler_state_text(enemy, 112, false)
  3634. if state_text != ""
  3635. text += " " + state_text
  3636. end
  3637. set_text(text, 1)
  3638. end
  3639. end
  3640.  
  3641. #==============================================================================
  3642. # ** Window_BattleStatus
  3643. #------------------------------------------------------------------------------
  3644. # It is the window which indicates the status of the party member in the
  3645. # battle picture.
  3646. #==============================================================================
  3647.  
  3648. class Window_BattleStatus < Window_Base
  3649. #--------------------------------------------------------------------------
  3650. # * Object Initialization
  3651. #--------------------------------------------------------------------------
  3652. def initialize
  3653. x = (4 - $game_party.actors.size) * 80
  3654. width = $game_party.actors.size * 160
  3655. super(x, 320, width, 160)
  3656. self.back_opacity = 160
  3657. @actor_window = []
  3658. for i in 0...$game_party.actors.size
  3659. @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
  3660. end
  3661. @level_up_flags = [false, false, false, false]
  3662. refresh
  3663. end
  3664. #--------------------------------------------------------------------------
  3665. # * Dispose
  3666. #--------------------------------------------------------------------------
  3667. def dispose
  3668. for window in @actor_window
  3669. window.dispose
  3670. end
  3671. super
  3672. end
  3673. #--------------------------------------------------------------------------
  3674. # * Refresh
  3675. #--------------------------------------------------------------------------
  3676. def refresh(number = 0) if number == 0
  3677. cnt = 0
  3678. for window in @actor_window
  3679. window.refresh(@level_up_flags[cnt])
  3680. cnt += 1
  3681. end
  3682. else
  3683. @actor_window[number - 1].refresh(@level_up_flags[number - 1])
  3684. end
  3685. end
  3686. #--------------------------------------------------------------------------
  3687. # * AT gauge refreshment
  3688. #--------------------------------------------------------------------------
  3689. def at_refresh(number = 0)
  3690. if number == 0
  3691. for window in @actor_window
  3692. window.at_refresh
  3693. end
  3694. else
  3695. @actor_window[number - 1].at_refresh
  3696. end
  3697. end
  3698. #--------------------------------------------------------------------------
  3699. # * Frame Renewal
  3700. #--------------------------------------------------------------------------
  3701. def update
  3702. super
  3703. if self.x != (4 - $game_party.actors.size) * 80
  3704. self.x = (4 - $game_party.actors.size) * 80
  3705. self.width = $game_party.actors.size * 160
  3706. for window in @actor_window
  3707. window.dispose
  3708. end
  3709. @actor_window = []
  3710. for i in 0...$game_party.actors.size
  3711. @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
  3712. end
  3713. refresh
  3714. end
  3715. for window in @actor_window
  3716. window.update
  3717. end
  3718. end
  3719. end
  3720.  
  3721. #==============================================================================
  3722. # ** Window_ActorStatus
  3723. #------------------------------------------------------------------------------
  3724. # It is the window which indicates the status of the party member respectively
  3725. # in the battle picture.
  3726. #==============================================================================
  3727.  
  3728. class Window_ActorStatus < Window_Base
  3729. #--------------------------------------------------------------------------
  3730. # * Object Initialization
  3731. #--------------------------------------------------------------------------
  3732. def initialize(id, x)
  3733. @actor_num = id
  3734. super(x, 320, 160, 160)
  3735. self.contents = Bitmap.new(width - 32, height - 32)
  3736. self.opacity = 0
  3737. self.back_opacity = 0
  3738. actor = $game_party.actors[@actor_num]
  3739. @actor_nm = actor.name
  3740. @actor_mhp = actor.maxhp
  3741. @actor_msp = actor.maxsp
  3742. @actor_hp = actor.hp
  3743. @actor_sp = actor.sp
  3744. @actor_st = make_battler_state_text(actor, 120, true)
  3745. @status_window = []
  3746. for i in 0...5
  3747. @status_window.push(Window_DetailsStatus.new(actor, i, x))
  3748. end
  3749. refresh(false)
  3750. end
  3751. #--------------------------------------------------------------------------
  3752. # * Dispose
  3753. #--------------------------------------------------------------------------
  3754. def dispose
  3755. for i in 0...5
  3756. @status_window[i].dispose
  3757. end
  3758. super
  3759. end
  3760. #--------------------------------------------------------------------------
  3761. # * Refresh
  3762. #--------------------------------------------------------------------------
  3763. def refresh(level_up_flags)
  3764. self.contents.clear
  3765. actor = $game_party.actors[@actor_num]
  3766. @status_window[0].refresh(actor) if @actor_nm != actor.name
  3767. @status_window[1].refresh(actor) if
  3768. @actor_mhp != actor.maxhp or @actor_hp != actor.hp
  3769. @status_window[2].refresh(actor) if
  3770. @actor_msp != actor.maxsp or @actor_sp != actor.sp
  3771. @status_window[3].refresh(actor, level_up_flags) if
  3772. @actor_st != make_battler_state_text(actor, 120, true) or level_up_flags
  3773. @actor_nm = actor.name
  3774. @actor_mhp = actor.maxhp
  3775. @actor_msp = actor.maxsp
  3776. @actor_hp = actor.hp
  3777. @actor_sp = actor.sp
  3778. @actor_st = make_battler_state_text(actor, 120, true)
  3779. end
  3780. #--------------------------------------------------------------------------
  3781. # * AT gauge refreshment
  3782. #--------------------------------------------------------------------------
  3783. def at_refresh
  3784. @status_window[4].refresh($game_party.actors[@actor_num])
  3785. end
  3786. #--------------------------------------------------------------------------
  3787. # * Frame Renewal
  3788. #--------------------------------------------------------------------------
  3789. def update
  3790. for window in @status_window
  3791. window.update
  3792. end
  3793. end
  3794. end
  3795.  
  3796. #==============================================================================
  3797. # ** Window_DetailsStatus
  3798. #------------------------------------------------------------------------------
  3799. # It is the window which indicates the status of the actor in individually in the battle picture.
  3800. #==============================================================================
  3801.  
  3802. class Window_DetailsStatus < Window_Base
  3803. #--------------------------------------------------------------------------
  3804. # * Object Initialization
  3805. #--------------------------------------------------------------------------
  3806. def initialize(actor, id, x)
  3807. @status_id = id
  3808. super(x, 320 + id * 26, 160, 64)
  3809. self.contents = Bitmap.new(width - 32, height - 32)
  3810. self.opacity = 0
  3811. self.back_opacity = 0
  3812. refresh(actor, false)
  3813. end
  3814. #--------------------------------------------------------------------------
  3815. # * Dispose
  3816. #--------------------------------------------------------------------------
  3817. def dispose
  3818. super
  3819. end
  3820. #--------------------------------------------------------------------------
  3821. # * Refresh
  3822. #--------------------------------------------------------------------------
  3823. def refresh(actor, level_up_flags = false)
  3824. self.contents.clear
  3825. case @status_id
  3826. when 0
  3827. draw_actor_name(actor, 4, 0)
  3828. when 1
  3829. draw_actor_hp(actor, 4, 0, 120)
  3830. when 2
  3831. draw_actor_sp(actor, 4, 0, 120)
  3832. when 3
  3833. if level_up_flags
  3834. self.contents.font.color = normal_color
  3835. self.contents.draw_text(4, 0, 120, 32, "LEVEL UP!")
  3836. else
  3837. draw_actor_state(actor, 4, 0)
  3838. end
  3839. when 4
  3840. draw_actor_atg(actor, 4, 0, 120)
  3841. end
  3842. end
  3843. #--------------------------------------------------------------------------
  3844. # * Frame renewal
  3845. #--------------------------------------------------------------------------
  3846. def update
  3847. #At the time of main phase opacity is lowered a little
  3848. if $game_temp.battle_main_phase
  3849. self.contents_opacity -= 4 if self.contents_opacity > 191
  3850. else
  3851. self.contents_opacity += 4 if self.contents_opacity < 255
  3852. end
  3853. end
  3854. end
  3855.  
  3856. #==============================================================================
  3857. # ** Arrow_Base
  3858. #------------------------------------------------------------------------------
  3859. # It is sprite for the arrow cursor indication which is used in the battle picture.
  3860. # This class is used as superclass of Arrow_Enemy class and Arrow_Actor class.
  3861. #==============================================================================
  3862.  
  3863. class Arrow_Base < Sprite
  3864. #--------------------------------------------------------------------------
  3865. # * Object Initialization
  3866. # viewport :viewport
  3867. #--------------------------------------------------------------------------
  3868. def initialize(viewport)
  3869. super(viewport)
  3870. self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
  3871. self.ox = 16
  3872. self.oy = 32
  3873. self.z = 2500
  3874. @blink_count = 0
  3875. @index = 0
  3876. @help_window = nil
  3877. update
  3878. end
  3879. end
  3880.  
  3881. #==============================================================================
  3882. # ** Arrow_Enemy
  3883. #------------------------------------------------------------------------------
  3884. # It is arrow cursor in order to make the enemy select.
  3885. # This class succeeds Arrow_Base.
  3886. #==============================================================================
  3887.  
  3888. class Arrow_Enemy < Arrow_Base
  3889. #--------------------------------------------------------------------------
  3890. # * Frame renewal
  3891. #--------------------------------------------------------------------------
  3892. def update
  3893. super
  3894. # When it points to the enemy which does not exist, it throws
  3895. $game_troop.enemies.size.times do
  3896. break if self.enemy.exist?
  3897. @index += 1
  3898. @index %= $game_troop.enemies.size
  3899. end
  3900. # The cursor right
  3901. if Input.repeat?(Input::RIGHT)
  3902. $game_system.se_play($data_system.cursor_se)
  3903. $game_troop.enemies.size.times do
  3904. @index += 1
  3905. @index %= $game_troop.enemies.size
  3906. break if self.enemy.exist?
  3907. end
  3908. $scene.camera = "select"
  3909. zoom = 1 / self.enemy.zoom
  3910. $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
  3911. self.enemy.attack_y(zoom) * 0.75, zoom)
  3912. end
  3913. # The cursor left
  3914. if Input.repeat?(Input::LEFT)
  3915. $game_system.se_play($data_system.cursor_se)
  3916. $game_troop.enemies.size.times do
  3917. @index += $game_troop.enemies.size - 1
  3918. @index %= $game_troop.enemies.size
  3919. break if self.enemy.exist?
  3920. end
  3921. $scene.camera = "select"
  3922. zoom = 1 / self.enemy.zoom
  3923. $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
  3924. self.enemy.attack_y(zoom) * 0.75, zoom)
  3925. end
  3926. # Setting the coordinate of sprite
  3927. if self.enemy != nil
  3928. self.x = self.enemy.screen_x
  3929. self.y = self.enemy.screen_y
  3930. end
  3931. end
  3932. end
  3933.  
  3934. #==============================================================================
  3935. # ** Interpreter
  3936. #------------------------------------------------------------------------------
  3937. # It is the interpreter which executes event command. This class is used inside
  3938. # the Game_System class and Game_Event class.
  3939. #==============================================================================
  3940.  
  3941. class Interpreter
  3942. #--------------------------------------------------------------------------
  3943. # ? ?????????
  3944. #--------------------------------------------------------------------------
  3945. def command_129
  3946. # Acquiring the actor
  3947. actor = $game_actors[@parameters[0]]
  3948. # When the actor is valid
  3949. if actor != nil
  3950. # It diverges with operation
  3951. if @parameters[1] == 0
  3952. if @parameters[2] == 1
  3953. $game_actors[@parameters[0]].setup(@parameters[0])
  3954. end
  3955. $game_party.add_actor(@parameters[0])
  3956. if $game_temp.in_battle
  3957. $game_actors[@parameters[0]].at = 0
  3958. $game_actors[@parameters[0]].atp = 0
  3959. $scene.spell_reset($game_actors[@parameters[0]])
  3960. $game_actors[@parameters[0]].damage_pop = {}
  3961. $game_actors[@parameters[0]].damage = {}
  3962. $game_actors[@parameters[0]].damage_sp = {}
  3963. $game_actors[@parameters[0]].critical = {}
  3964. $game_actors[@parameters[0]].recover_hp = {}
  3965. $game_actors[@parameters[0]].recover_sp = {}
  3966. $game_actors[@parameters[0]].state_p = {}
  3967. $game_actors[@parameters[0]].state_m = {}
  3968. $game_actors[@parameters[0]].animation = []
  3969. end
  3970. else
  3971. $game_party.remove_actor(@parameters[0])
  3972. end
  3973. end
  3974. if $game_temp.in_battle
  3975. $scene.status_window.update
  3976. end
  3977. # Continuation
  3978. return true
  3979. end
  3980. #--------------------------------------------------------------------------
  3981. # * The increase and decrease of HP
  3982. #--------------------------------------------------------------------------
  3983. alias :command_311_rtab :command_311
  3984. def command_311
  3985. command_311_rtab
  3986. if $game_temp.in_battle
  3987. $scene.status_window.refresh
  3988. end
  3989. end
  3990. #--------------------------------------------------------------------------
  3991. # *The increase and decrease of SP
  3992. #--------------------------------------------------------------------------
  3993. alias :command_312_rtab :command_312
  3994. def command_312
  3995. command_312_rtab
  3996. if $game_temp.in_battle
  3997. $scene.status_window.refresh
  3998. end
  3999. end
  4000. #--------------------------------------------------------------------------
  4001. # * Modification of state
  4002. #--------------------------------------------------------------------------
  4003. alias :command_313_rtab :command_313
  4004. def command_313
  4005. command_313_rtab
  4006. if $game_temp.in_battle
  4007. $scene.status_window.refresh
  4008. end
  4009. end
  4010. #--------------------------------------------------------------------------
  4011. # * All recovery
  4012. #--------------------------------------------------------------------------
  4013. alias :command_314_rtab :command_314
  4014. def command_314
  4015. command_314_rtab
  4016. if $game_temp.in_battle
  4017. $scene.status_window.refresh
  4018. end
  4019. end
  4020. #--------------------------------------------------------------------------
  4021. # * The increase and decrease of EXP
  4022. #--------------------------------------------------------------------------
  4023. alias :command_315_rtab :command_315
  4024. def command_315
  4025. command_315_rtab
  4026. if $game_temp.in_battle
  4027. $scene.status_window.refresh
  4028. end
  4029. end
  4030. #--------------------------------------------------------------------------
  4031. # * Increase and decrease of level
  4032. #--------------------------------------------------------------------------
  4033. alias :command_316_rtab :command_316
  4034. def command_316
  4035. command_316_rtab
  4036. if $game_temp.in_battle
  4037. $scene.status_window.refresh
  4038. end
  4039. end
  4040. #--------------------------------------------------------------------------
  4041. # * Increase and decrease of parameter
  4042. #--------------------------------------------------------------------------
  4043. alias :command_317_rtab :command_317
  4044. def command_317
  4045. command_317_rtab
  4046. if $game_temp.in_battle
  4047. $scene.status_window.refresh
  4048. end
  4049. end
  4050. #--------------------------------------------------------------------------
  4051. # * Modification of equipment
  4052. #--------------------------------------------------------------------------
  4053. alias :command_319_rtab :command_319
  4054. def command_319
  4055. command_319_rtab
  4056. if $game_temp.in_battle
  4057. $scene.status_window.refresh
  4058. end
  4059. end
  4060. #--------------------------------------------------------------------------
  4061. # * Name modification of actor
  4062. #--------------------------------------------------------------------------
  4063. alias :command_320_rtab :command_320
  4064. def command_320
  4065. command_320_rtab
  4066. if $game_temp.in_battle
  4067. $scene.status_window.refresh
  4068. end
  4069. end
  4070. #--------------------------------------------------------------------------
  4071. # * Class modification of actor
  4072. #--------------------------------------------------------------------------
  4073. alias :command_321_rtab :command_321
  4074. def command_321
  4075. command_321_rtab
  4076. if $game_temp.in_battle
  4077. $scene.status_window.refresh
  4078. end
  4079. end
  4080. #--------------------------------------------------------------------------
  4081. # * Indication of animation
  4082. #--------------------------------------------------------------------------
  4083. def command_337
  4084. # Process iteration
  4085. iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4086. # When the battler exists
  4087. if battler.exist?
  4088. # Setting animation ID
  4089. battler.animation.push([@parameters[2], true])
  4090. end
  4091. end
  4092. # continuous
  4093. return true
  4094. end
  4095. #--------------------------------------------------------------------------
  4096. # * Deal Damage
  4097. #--------------------------------------------------------------------------
  4098. def command_338
  4099. # of the damage the value which is operated acquisition
  4100. value = operate_value(0, @parameters[2], @parameters[3])
  4101. # Process iteration
  4102. iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4103. # battler exists with
  4104. if battler.exist?
  4105. # HP modification
  4106. battler.hp -= value
  4107. # fighting
  4108. if $game_temp.in_battle
  4109. # damage setting
  4110. battler.damage["event"] = value
  4111. battler.damage_pop["event"] = true
  4112. end
  4113. end
  4114. end
  4115. if $game_temp.in_battle
  4116. $scene.status_window.refresh
  4117. end
  4118. # continuation
  4119. return true
  4120. end
  4121. #--------------------------------------------------------------------------
  4122. # * Forcing the action
  4123. #--------------------------------------------------------------------------
  4124. def command_339
  4125. # If it is not in the midst of fighting, disregard
  4126. unless $game_temp.in_battle
  4127. return true
  4128. end
  4129. # If the number of turns 0 disregard
  4130. if $game_temp.battle_turn == 0
  4131. return true
  4132. end
  4133. # Processing (With convenient ones, there are no times when it becomes plural)
  4134. iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4135. # When the battler exists,
  4136. if battler.exist?
  4137. # Setting action
  4138. battler.current_action.force_kind = @parameters[2]
  4139. if battler.current_action.force_kind == 0
  4140. battler.current_action.force_basic = @parameters[3]
  4141. else
  4142. battler.current_action.force_skill_id = @parameters[3]
  4143. end
  4144. # Setting the conduct object
  4145. if @parameters[4] == -2
  4146. if battler.is_a?(Game_Enemy)
  4147. battler.current_action.decide_last_target_for_enemy
  4148. else
  4149. battler.current_action.decide_last_target_for_actor
  4150. end
  4151. elsif @parameters[4] == -1
  4152. if battler.is_a?(Game_Enemy)
  4153. battler.current_action.decide_random_target_for_enemy
  4154. else
  4155. battler.current_action.decide_random_target_for_actor
  4156. end
  4157. elsif @parameters[4] >= 0
  4158. battler.current_action.target_index = @parameters[4]
  4159. end
  4160. # When action validity and [ directly execution ] is,
  4161. if battler.current_action.valid? and @parameters[5] == 1
  4162. # Setting the battler of the forced object
  4163. $game_temp.forcing_battler = battler
  4164. # The index is advanced
  4165. @index += 1
  4166. # end
  4167. return false
  4168. elsif battler.current_action.valid? and @parameters[5] == 0
  4169. battler.current_action.forcing = true
  4170. end
  4171. end
  4172. end
  4173. # continuation
  4174. return true
  4175. end
  4176. end
  4177.  
  4178. #==============================================================================
  4179. # * Sprite module
  4180. #------------------------------------------------------------------------------
  4181. # This module manages and controls animation.
  4182. #==============================================================================
  4183.  
  4184. module RPG
  4185.  
  4186. class Sprite < ::Sprite
  4187. def initialize(viewport = nil)
  4188. super(viewport)
  4189. @_whiten_duration = 0
  4190. @_appear_duration = 0
  4191. @_escape_duration = 0
  4192. @_collapse_duration = 0
  4193. @_damage = []
  4194. @_animation = []
  4195. @_animation_duration = 0
  4196. @_blink = false
  4197. end
  4198. def damage(value, critical, type = 0)
  4199. if value.is_a?(Numeric)
  4200. damage_string = value.abs.to_s
  4201. else
  4202. damage_string = value.to_s
  4203. end
  4204. bitmap = Bitmap.new(160, 48)
  4205. bitmap.font.name = "Arial Black"
  4206. bitmap.font.size = 32
  4207. bitmap.font.color.set(0, 0, 0)
  4208. bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  4209. bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  4210. bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  4211. bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  4212. if value.is_a?(Numeric) and value < 0
  4213. if type == 0
  4214. bitmap.font.color.set(176, 255, 144)
  4215. else
  4216. bitmap.font.color.set(176, 144, 255)
  4217. end
  4218. else
  4219. if type == 0
  4220. bitmap.font.color.set(255, 255, 255)
  4221. else
  4222. bitmap.font.color.set(255, 176, 144)
  4223. end
  4224. end
  4225. if type == 2
  4226. bitmap.font.color.set(255, 224, 128)
  4227. end
  4228. bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  4229. if critical
  4230. string = "CRITICAL!"
  4231. bitmap.font.size = 20
  4232. bitmap.font.color.set(0, 0, 0)
  4233. bitmap.draw_text(-1, -1, 160, 20, string, 1)
  4234. bitmap.draw_text(+1, -1, 160, 20, string, 1)
  4235. bitmap.draw_text(-1, +1, 160, 20, string, 1)
  4236. bitmap.draw_text(+1, +1, 160, 20, string, 1)
  4237. bitmap.font.color.set(255, 255, 255)
  4238. bitmap.draw_text(0, 0, 160, 20, string, 1)
  4239. end
  4240. num = @_damage.size
  4241. if type != 2
  4242. @_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50])
  4243. else
  4244. @_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60])
  4245. end
  4246. @_damage[num][0].bitmap = bitmap
  4247. @_damage[num][0].ox = 80 + self.viewport.ox
  4248. @_damage[num][0].oy = 20 + self.viewport.oy
  4249. if self.battler.is_a?(Game_Actor)
  4250. @_damage[num][0].x = self.x
  4251. @_damage[num][0].y = self.y - self.oy / 2
  4252. else
  4253. @_damage[num][0].x = self.x + self.viewport.rect.x -
  4254. self.ox + self.src_rect.width / 2
  4255. @_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
  4256. self.viewport.rect.y
  4257. @_damage[num][0].zoom_x = self.zoom_x
  4258. @_damage[num][0].zoom_y = self.zoom_y
  4259. @_damage[num][0].z = 3000
  4260. end
  4261. end
  4262. def animation(animation, hit)
  4263. return if animation == nil
  4264. num = @_animation.size
  4265. @_animation.push([animation, hit, animation.frame_max, []])
  4266. bitmap = RPG::Cache.animation(animation.animation_name,
  4267. animation.animation_hue)
  4268. if @@_reference_count.include?(bitmap)
  4269. @@_reference_count[bitmap] += 1
  4270. else
  4271. @@_reference_count[bitmap] = 1
  4272. end
  4273. if @_animation[num][0].position != 3 or
  4274. not @@_animations.include?(animation)
  4275. for i in 0..15
  4276. sprite = ::Sprite.new
  4277. sprite.bitmap = bitmap
  4278. sprite.visible = false
  4279. @_animation[num][3].push(sprite)
  4280. end
  4281. unless @@_animations.include?(animation)
  4282. @@_animations.push(animation)
  4283. end
  4284. end
  4285. update_animation(@_animation[num])
  4286. end
  4287. def loop_animation(animation)
  4288. return if animation == @_loop_animation
  4289. dispose_loop_animation
  4290. @_loop_animation = animation
  4291. return if @_loop_animation == nil
  4292. @_loop_animation_index = 0
  4293. animation_name = @_loop_animation.animation_name
  4294. animation_hue = @_loop_animation.animation_hue
  4295. bitmap = RPG::Cache.animation(animation_name, animation_hue)
  4296. if @@_reference_count.include?(bitmap)
  4297. @@_reference_count[bitmap] += 1
  4298. else
  4299. @@_reference_count[bitmap] = 1
  4300. end
  4301. @_loop_animation_sprites = []
  4302. for i in 0..15
  4303. sprite = ::Sprite.new
  4304. sprite.bitmap = bitmap
  4305. sprite.visible = false
  4306. @_loop_animation_sprites.push(sprite)
  4307. end
  4308. # update_loop_animation
  4309. end
  4310. def dispose_damage
  4311. for damage in @_damage.reverse
  4312. damage[0].bitmap.dispose
  4313. damage[0].dispose
  4314. @_damage.delete(damage)
  4315. end
  4316. end
  4317. def dispose_animation
  4318. for anime in @_animation.reverse
  4319. sprite = anime[3][0]
  4320. if sprite != nil
  4321. @@_reference_count[sprite.bitmap] -= 1
  4322. if @@_reference_count[sprite.bitmap] == 0
  4323. sprite.bitmap.dispose
  4324. end
  4325. end
  4326. for sprite in anime[3]
  4327. sprite.dispose
  4328. end
  4329. @_animation.delete(anime)
  4330. end
  4331. end
  4332. def effect?
  4333. @_whiten_duration > 0 or
  4334. @_appear_duration > 0 or
  4335. @_escape_duration > 0 or
  4336. @_collapse_duration > 0 or
  4337. @_damage.size == 0 or
  4338. @_animation.size == 0
  4339. end
  4340. def update
  4341. super
  4342. if @_whiten_duration > 0
  4343. @_whiten_duration -= 1
  4344. self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  4345. end
  4346. if @_appear_duration > 0
  4347. @_appear_duration -= 1
  4348. self.opacity = (16 - @_appear_duration) * 16
  4349. end
  4350. if @_escape_duration > 0
  4351. @_escape_duration -= 1
  4352. self.opacity = 256 - (32 - @_escape_duration) * 10
  4353. end
  4354. if @_collapse_duration > 0
  4355. @_collapse_duration -= 1
  4356. self.opacity = 256 - (48 - @_collapse_duration) * 6
  4357. end
  4358. for damage in @_damage
  4359. if damage[1] > 0
  4360. damage[1] -= 1
  4361. damage[4] -= 3
  4362. damage[2] -= damage[4]
  4363. if self.battler.is_a?(Game_Actor)
  4364. damage[0].x = self.x + (40 - damage[1]) * damage[3] / 10
  4365. damage[0].y = self.y - self.oy / 2 + damage[2] / 10
  4366. else
  4367. damage[0].x = self.x + self.viewport.rect.x -
  4368. self.ox + self.src_rect.width / 2 +
  4369. (40 - damage[1]) * damage[3] / 10
  4370. damage[0].y = self.y - self.oy * self.zoom_y / 2 +
  4371. self.viewport.rect.y + damage[2] / 10
  4372. damage[0].zoom_x = self.zoom_x
  4373. damage[0].zoom_y = self.zoom_y
  4374. end
  4375. damage[0].z = 2960 + damage[1]
  4376. damage[0].opacity = 256 - (12 - damage[1]) * 32
  4377. if damage[1] == 0
  4378. damage[0].bitmap.dispose
  4379. damage[0].dispose
  4380. @_damage.delete(damage)
  4381. end
  4382. end
  4383. end
  4384. for anime in @_animation
  4385. if (Graphics.frame_count % 2 == 0)
  4386. anime[2] -= 1
  4387. update_animation(anime)
  4388. end
  4389. end
  4390. if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  4391. update_loop_animation
  4392. @_loop_animation_index += 1
  4393. @_loop_animation_index %= @_loop_animation.frame_max
  4394. end
  4395. if @_blink
  4396. @_blink_count = (@_blink_count + 1) % 32
  4397. if @_blink_count < 16
  4398. alpha = (16 - @_blink_count) * 6
  4399. else
  4400. alpha = (@_blink_count - 16) * 6
  4401. end
  4402. self.color.set(255, 255, 255, alpha)
  4403. end
  4404. @@_animations.clear
  4405. end
  4406. def update_animation(anime)
  4407. if anime[2] > 0
  4408. frame_index = anime[0].frame_max - anime[2]
  4409. cell_data = anime[0].frames[frame_index].cell_data
  4410. position = anime[0].position
  4411. animation_set_sprites(anime[3], cell_data, position)
  4412. for timing in anime[0].timings
  4413. if timing.frame == frame_index
  4414. animation_process_timing(timing, anime[1])
  4415. end
  4416. end
  4417. else
  4418. @@_reference_count[anime[3][0].bitmap] -= 1
  4419. if @@_reference_count[anime[3][0].bitmap] == 0
  4420. anime[3][0].bitmap.dispose
  4421. end
  4422. for sprite in anime[3]
  4423. sprite.dispose
  4424. end
  4425. @_animation.delete(anime)
  4426. end
  4427. end
  4428. def animation_set_sprites(sprites, cell_data, position)
  4429. for i in 0..15
  4430. sprite = sprites[i]
  4431. pattern = cell_data[i, 0]
  4432. if sprite == nil or pattern == nil or pattern == -1
  4433. sprite.visible = false if sprite != nil
  4434. next
  4435. end
  4436. sprite.visible = true
  4437. sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  4438. if position == 3
  4439. if self.viewport != nil
  4440. sprite.x = self.viewport.rect.width / 2
  4441. if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  4442. sprite.y = self.viewport.rect.height - 320
  4443. else
  4444. sprite.y = self.viewport.rect.height - 160
  4445. end
  4446. else
  4447. sprite.x = 320
  4448. sprite.y = 240
  4449. end
  4450. else
  4451. sprite.x = self.x + self.viewport.rect.x -
  4452. self.ox + self.src_rect.width / 2
  4453. if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  4454. sprite.y = self.y - self.oy * self.zoom_y / 2 +
  4455. self.viewport.rect.y
  4456. if position == 0
  4457. sprite.y -= self.src_rect.height * self.zoom_y / 4
  4458. elsif position == 2
  4459. sprite.y += self.src_rect.height * self.zoom_y / 4
  4460. end
  4461. else
  4462. sprite.y = self.y + self.viewport.rect.y -
  4463. self.oy + self.src_rect.height / 2
  4464. sprite.y -= self.src_rect.height / 4 if position == 0
  4465. sprite.y += self.src_rect.height / 4 if position == 2
  4466. end
  4467. end
  4468. sprite.x += cell_data[i, 1]
  4469. sprite.y += cell_data[i, 2]
  4470. sprite.z = 2000
  4471. sprite.ox = 96
  4472. sprite.oy = 96
  4473. sprite.zoom_x = cell_data[i, 3] / 100.0
  4474. sprite.zoom_y = cell_data[i, 3] / 100.0
  4475. if position != 3
  4476. sprite.zoom_x *= self.zoom_x
  4477. sprite.zoom_y *= self.zoom_y
  4478. end
  4479. sprite.angle = cell_data[i, 4]
  4480. sprite.mirror = (cell_data[i, 5] == 1)
  4481. sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  4482. sprite.blend_type = cell_data[i, 7]
  4483. end
  4484. end
  4485. def x=(x)
  4486. sx = x - self.x
  4487. if sx != 0
  4488. for anime in @_animation
  4489. if anime[3] != nil
  4490. for i in 0..15
  4491. anime[3][i].x += sx
  4492. end
  4493. end
  4494. end
  4495. if @_loop_animation_sprites != nil
  4496. for i in 0..15
  4497. @_loop_animation_sprites[i].x += sx
  4498. end
  4499. end
  4500. end
  4501. super
  4502. end
  4503. def y=(y)
  4504. sy = y - self.y
  4505. if sy != 0
  4506. for anime in @_animation
  4507. if anime[3] != nil
  4508. for i in 0..15
  4509. anime[3][i].y += sy
  4510. end
  4511. end
  4512. end
  4513. if @_loop_animation_sprites != nil
  4514. for i in 0..15
  4515. @_loop_animation_sprites[i].y += sy
  4516. end
  4517. end
  4518. end
  4519. super
  4520. end
  4521. end
  4522. end
  4523.  
  4524. #------------------------------------------------------------------------------
  4525. # New routine added to the Bitmap class.
  4526. #==============================================================================
  4527.  
  4528. class Bitmap
  4529. #--------------------------------------------------------------------------
  4530. # * Rectangle Gradation Indicator
  4531. # color1: Start color
  4532. # color2: Ending color
  4533. # align: 0: On side gradation
  4534. # 1: Vertically gradation
  4535. # 2: The gradation (intense concerning slantedly heavily note)
  4536. #--------------------------------------------------------------------------
  4537. def gradation_rect(x, y, width, height, color1, color2, align = 0)
  4538. if align == 0
  4539. for i in x...x + width
  4540. red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
  4541. green = color1.green +
  4542. (color2.green - color1.green) * (i - x) / (width - 1)
  4543. blue = color1.blue +
  4544. (color2.blue - color1.blue) * (i - x) / (width - 1)
  4545. alpha = color1.alpha +
  4546. (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  4547. color = Color.new(red, green, blue, alpha)
  4548. fill_rect(i, y, 1, height, color)
  4549. end
  4550. elsif align == 1
  4551. for i in y...y + height
  4552. red = color1.red +
  4553. (color2.red - color1.red) * (i - y) / (height - 1)
  4554. green = color1.green +
  4555. (color2.green - color1.green) * (i - y) / (height - 1)
  4556. blue = color1.blue +
  4557. (color2.blue - color1.blue) * (i - y) / (height - 1)
  4558. alpha = color1.alpha +
  4559. (color2.alpha - color1.alpha) * (i - y) / (height - 1)
  4560. color = Color.new(red, green, blue, alpha)
  4561. fill_rect(x, i, width, 1, color)
  4562. end
  4563. elsif align == 2
  4564. for i in x...x + width
  4565. for j in y...y + height
  4566. red = color1.red + (color2.red - color1.red) *
  4567. ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4568. green = color1.green + (color2.green - color1.green) *
  4569. ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4570. blue = color1.blue + (color2.blue - color1.blue) *
  4571. ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4572. alpha = color1.alpha + (color2.alpha - color1.alpha) *
  4573. ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4574. color = Color.new(red, green, blue, alpha)
  4575. set_pixel(i, j, color)
  4576. end
  4577. end
  4578. elsif align == 3
  4579. for i in x...x + width
  4580. for j in y...y + height
  4581. red = color1.red + (color2.red - color1.red) *
  4582. ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4583. green = color1.green + (color2.green - color1.green) *
  4584. ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4585. blue = color1.blue + (color2.blue - color1.blue) *
  4586. ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4587. alpha = color1.alpha + (color2.alpha - color1.alpha) *
  4588. ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4589. color = Color.new(red, green, blue, alpha)
  4590. set_pixel(i, j, color)
  4591. end
  4592. end
  4593. end
  4594. end
  4595. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement