Guest User

Untitled

a guest
May 28th, 2014
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 120.60 KB | None | 0 0
  1. #==============================================================================
  2. # Sideview Battle System Version 2.2xp
  3. #==============================================================================
  4. #==============================================================================
  5. # ■ Atoa Module
  6. #==============================================================================
  7. $atoa_script = {} if $atoa_script.nil?
  8. $atoa_script["SBS Tankentai"] = true
  9.  
  10. #==============================================================================
  11. # ■ Scene_Battle
  12. #==============================================================================
  13. class Scene_Battle
  14. #--------------------------------------------------------------------------
  15. include N01
  16. #--------------------------------------------------------------------------
  17. attr_accessor :spriteset
  18. #--------------------------------------------------------------------------
  19. def main
  20. fix_weapon_init
  21. start
  22. create_viewport
  23. process_transition
  24. update_battle
  25. terminate
  26. fix_weapon_end
  27. end
  28. #--------------------------------------------------------------------------
  29. def start
  30. @battle_start = true
  31. $game_temp.in_battle = true
  32. $game_temp.battle_turn = 0
  33. $game_temp.battle_event_flags.clear
  34. $game_temp.battle_abort = false
  35. $game_temp.battle_main_phase = false
  36. $game_temp.battleback_name = $game_map.battleback_name
  37. $game_temp.forcing_battler = nil
  38. $game_system.battle_interpreter.setup(nil, 0)
  39. @troop_id = $game_temp.battle_troop_id
  40. $game_troop.setup(@troop_id)
  41. for enemy in $game_troop.enemies
  42. enemy.true_immortal = enemy.immortal
  43. end
  44. end
  45. #--------------------------------------------------------------------------
  46. def create_viewport
  47. s1 = $data_system.words.attack
  48. s2 = $data_system.words.skill
  49. s3 = $data_system.words.guard
  50. s4 = $data_system.words.item
  51. @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  52. @actor_command_window.y = 160
  53. @actor_command_window.back_opacity = 160
  54. @actor_command_window.active = false
  55. @actor_command_window.visible = false
  56. @party_command_window = Window_PartyCommand.new
  57. @help_window = Window_Help.new
  58. @help_window.back_opacity = 160
  59. @help_window.visible = false
  60. @active_battler_window = Window_NameCommand.new(@active_battler, 240, 64)
  61. @active_battler_window.visible = false
  62. @status_window = Window_BattleStatus.new
  63. @message_window = Window_Message.new
  64. @spriteset = Spriteset_Battle.new
  65. @wait_count, @escape_ratio = 0, 50
  66. end
  67. #--------------------------------------------------------------------------
  68. def process_transition
  69. if $data_system.battle_transition == ""
  70. Graphics.transition(20)
  71. else
  72. Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition)
  73. end
  74. start_phase1
  75. end
  76. #--------------------------------------------------------------------------
  77. def update_battle
  78. loop do
  79. Graphics.update
  80. Input.update
  81. update
  82. break if $scene != self
  83. end
  84. end
  85. #--------------------------------------------------------------------------
  86. def terminate
  87. $game_map.refresh
  88. Graphics.freeze
  89. @actor_command_window.dispose
  90. @party_command_window.dispose
  91. @help_window.dispose
  92. @status_window.dispose
  93. @message_window.dispose
  94. @skill_window.dispose if @skill_window != nil
  95. @item_window.dispose if @item_window != nil
  96. @result_window.dispose if @result_window != nil
  97. @spriteset.dispose
  98. if $scene.is_a?(Scene_Title)
  99. Graphics.transition
  100. Graphics.freeze
  101. end
  102. $scene = nil if $BTEST and not $scene.is_a?(Scene_Gameover)
  103. end
  104. #--------------------------------------------------------------------------
  105. def fix_weapon_init
  106. for member in $game_party.actors
  107. if member.weapons[0] == nil and member.weapons[1] != nil
  108. weapon_to_equip = member.armor1_id
  109. member.equip(1, 0)
  110. member.equip(0, weapon_to_equip)
  111. member.two_swords_change = true
  112. end
  113. end
  114. end
  115. #--------------------------------------------------------------------------
  116. def fix_weapon_end
  117. for member in $game_party.actors
  118. if member.two_swords_change
  119. weapon_to_re_equip = member.weapon_id
  120. member.equip(0, 0)
  121. member.equip(1, weapon_to_re_equip)
  122. member.two_swords_change = false
  123. end
  124. end
  125. end
  126. #--------------------------------------------------------------------------
  127. def update_basic
  128. Graphics.update
  129. Input.update
  130. $game_system.update
  131. $game_screen.update
  132. @spriteset.update
  133. end
  134. #--------------------------------------------------------------------------
  135. def update_effects
  136. for battler in $game_party.actors + $game_troop.enemies
  137. if battler.exist?
  138. battler_sprite = @spriteset.actor_sprites[battler.index] if battler.actor?
  139. battler_sprite = @spriteset.enemy_sprites[battler.index] if battler.is_a?(Game_Enemy)
  140. battler_sprite.effects_update
  141. end
  142. end
  143. end
  144. #--------------------------------------------------------------------------
  145. def wait(duration)
  146. for i in 0...duration
  147. update_basic
  148. end
  149. end
  150. #--------------------------------------------------------------------------
  151. def pop_help(obj)
  152. @help_window.set_text(obj, 1)
  153. loop do
  154. update_basic
  155. break @help_window.visible = false if Input.trigger?(Input::C)
  156. end
  157. end
  158. #--------------------------------------------------------------------------
  159. alias start_phase1_n01 start_phase1
  160. def start_phase1
  161. for member in $game_party.actors + $game_troop.enemies
  162. member.dead_anim = member.dead? ? true : false
  163. @spriteset.set_stand_by_action(member.actor?, member.index) unless member.dead_anim
  164. end
  165. start_phase1_n01
  166. $clear_enemies_actions = false
  167. if $preemptive
  168. pop_help(PREEMPTIVE_ALERT)
  169. $clear_enemies_actions = true
  170. end
  171. @battle_start = false unless $back_attack
  172. return unless $back_attack
  173. pop_help(BACK_ATTACK_ALERT)
  174. @battle_start = false
  175. $game_party.clear_actions
  176. start_phase4
  177. end
  178. #--------------------------------------------------------------------------
  179. alias start_phase4_n01 start_phase4
  180. def start_phase4
  181. start_phase4_n01
  182. @active_battler_window.visible = false
  183. if $clear_enemies_actions
  184. $clear_enemies_actions = false
  185. $game_troop.clear_actions
  186. end
  187. end
  188. #--------------------------------------------------------------------------
  189. def judge
  190. if $game_party.all_dead? or $game_party.actors.size == 0
  191. if $game_temp.battle_can_lose
  192. $game_system.bgm_play($game_temp.map_bgm)
  193. battle_end(2)
  194. return true
  195. end
  196. $game_temp.gameover = true
  197. return true
  198. end
  199. for enemy in $game_troop.enemies
  200. return false if enemy.exist?
  201. end
  202. process_victory
  203. return true
  204. end
  205. #--------------------------------------------------------------------------
  206. def update_phase2_escape
  207. enemies_agi = enemies_number = 0
  208. for enemy in $game_troop.enemies
  209. if enemy.exist?
  210. enemies_agi += enemy.agi
  211. enemies_number += 1
  212. end
  213. end
  214. enemies_agi /= [enemies_number, 1].max
  215. actors_agi = actors_number = 0
  216. for actor in $game_party.actors
  217. if actor.exist?
  218. actors_agi += actor.agi
  219. actors_number += 1
  220. end
  221. end
  222. actors_agi /= [actors_number, 1].max
  223. @success = rand(100) < @escape_ratio * actors_agi / enemies_agi
  224. @party_command_window.visible = false
  225. @party_command_window.active = false
  226. wait(2)
  227. if @success
  228. $game_system.se_play($data_system.escape_se)
  229. for actor in $game_party.actors
  230. unless actor.dead?
  231. @spriteset.set_action(true, actor.index, actor.run_success)
  232. end
  233. end
  234. pop_help(ESCAPE_SUCCESS)
  235. $game_system.bgm_play($game_temp.map_bgm)
  236. battle_end(1)
  237. else
  238. @escape_ratio += 5
  239. $game_party.clear_actions
  240. $game_system.se_play($data_system.escape_se)
  241. for actor in $game_party.actors
  242. unless actor.dead?
  243. @spriteset.set_action(true, actor.index,actor.run_ng)
  244. end
  245. end
  246. pop_help(ESCAPE_FAIL)
  247. start_phase4
  248. end
  249. end
  250. #--------------------------------------------------------------------------
  251. def process_victory
  252. for enemy in $game_troop.enemies
  253. break boss_wait = true if enemy.collapse_type == 3
  254. end
  255. wait(440) if boss_wait
  256. wait(WIN_WAIT) unless boss_wait
  257. for actor in $game_party.actors
  258. unless actor.restriction == 4
  259. @spriteset.set_action(true, actor.index,actor.win)
  260. end
  261. end
  262. start_phase5
  263. end
  264. #--------------------------------------------------------------------------
  265. def start_phase5
  266. @phase = 5
  267. $game_system.me_play($game_system.battle_end_me)
  268. $game_system.bgm_play($game_temp.map_bgm)
  269. treasures = []
  270. for enemy in $game_troop.enemies
  271. gold = gold.nil? ? enemy.gold : gold + enemy.gold
  272. treasures << treasure_drop(enemy) unless enemy.hidden
  273. end
  274. exp = gain_exp
  275. treasures = treasures.compact
  276. $game_party.gain_gold(gold)
  277. for item in treasures
  278. case item
  279. when RPG::Item
  280. $game_party.gain_item(item.id, 1)
  281. when RPG::Weapon
  282. $game_party.gain_weapon(item.id, 1)
  283. when RPG::Armor
  284. $game_party.gain_armor(item.id, 1)
  285. end
  286. end
  287. @result_window = Window_BattleResult.new(exp, gold, treasures)
  288. @result_window.add_multi_drops if $atoa_script['Multi Drop']
  289. @phase5_wait_count = 100
  290. end
  291. #--------------------------------------------------------------------------
  292. def treasure_drop(enemy)
  293. if rand(100) < enemy.treasure_prob
  294. treasure = $data_items[enemy.item_id] if enemy.item_id > 0
  295. treasure = $data_weapons[enemy.weapon_id] if enemy.weapon_id > 0
  296. treasure = $data_armors[enemy.armor_id] if enemy.armor_id > 0
  297. end
  298. return treasure
  299. end
  300. #--------------------------------------------------------------------------
  301. def gain_exp
  302. exp = exp_gained
  303. for i in 0...$game_party.actors.size
  304. actor = $game_party.actors[i]
  305. if actor.cant_get_exp? == false
  306. last_level = actor.level
  307. actor.exp += exp
  308. if actor.level > last_level
  309. @status_window.level_up(i)
  310. end
  311. end
  312. end
  313. return exp
  314. end
  315. #--------------------------------------------------------------------------
  316. def exp_gained
  317. for enemy in $game_troop.enemies
  318. exp = exp.nil? ? enemy.exp : exp + enemy.exp
  319. end
  320. if EXP_SHARE
  321. actor_number = 0
  322. for actor in $game_party.actors
  323. actor_number += 1 unless actor.cant_get_exp?
  324. end
  325. exp = exp / [actor_number, 1].max
  326. end
  327. return exp
  328. end
  329. #--------------------------------------------------------------------------
  330. alias acbs_update_phase5 update_phase5
  331. def update_phase5
  332. @result_window.update
  333. acbs_update_phase5
  334. end
  335. #--------------------------------------------------------------------------
  336. alias phase3_next_actor_n01 phase3_next_actor
  337. def phase3_next_actor
  338. if @active_battler != nil && @active_battler.inputable?
  339. @spriteset.set_action(true, @actor_index, @active_battler.command_a)
  340. end
  341. @wait_count = 32 if @actor_index == $game_party.actors.size-1
  342. phase3_next_actor_n01
  343. if @active_battler != nil && @active_battler.inputable?
  344. @spriteset.set_action(true, @actor_index,@active_battler.command_b)
  345. end
  346. end
  347. #--------------------------------------------------------------------------
  348. alias phase3_prior_actor_n01 phase3_prior_actor
  349. def phase3_prior_actor
  350. if @active_battler != nil && @active_battler.inputable?
  351. @active_battler.current_action.clear
  352. @spriteset.set_action(true, @actor_index,@active_battler.command_a)
  353. end
  354. phase3_prior_actor_n01
  355. if @active_battler != nil && @active_battler.inputable?
  356. @active_battler.current_action.clear
  357. @spriteset.set_action(true, @actor_index,@active_battler.command_b)
  358. end
  359. end
  360. #--------------------------------------------------------------------------
  361. alias start_phase2_n01 start_phase2
  362. def start_phase2
  363. @active_battler_window.visible = false
  364. start_phase2_n01
  365. end
  366. #--------------------------------------------------------------------------
  367. alias phase3_setup_command_window_n01 phase3_setup_command_window
  368. def phase3_setup_command_window
  369. phase3_setup_command_window_n01
  370. @actor_command_window.x = COMMAND_WINDOW_POSITION[0]
  371. @actor_command_window.y = COMMAND_WINDOW_POSITION[1]
  372. @actor_command_window.z = 2000
  373. @actor_command_window.index = 0
  374. @actor_command_window.back_opacity = COMMAND_OPACITY
  375. @active_battler_window.refresh(@active_battler)
  376. @active_battler_window.visible = true if BATTLER_NAME_WINDOW
  377. end
  378. #--------------------------------------------------------------------------
  379. alias acbs_update_phase3_basic_command_scenebattle update_phase3_basic_command
  380. def update_phase3_basic_command
  381. if Input.trigger?(Input::C)
  382. case @actor_command_window.commands[@actor_command_window.index]
  383. when $data_system.words.attack
  384. $game_system.se_play($data_system.decision_se)
  385. @active_battler.current_action.kind = 0
  386. @active_battler.current_action.basic = 0
  387. @actor_command_window.active = false
  388. @actor_command_window.visible = false
  389. start_enemy_select
  390. return
  391. when $data_system.words.item
  392. $game_system.se_play($data_system.decision_se)
  393. @active_battler.current_action.kind = 2
  394. start_item_select
  395. return
  396. when $data_system.words.guard
  397. $game_system.se_play($data_system.decision_se)
  398. @active_battler.current_action.kind = 0
  399. @active_battler.current_action.basic = 1
  400. phase3_next_actor
  401. return
  402. end
  403. end
  404. acbs_update_phase3_basic_command_scenebattle
  405. end
  406. #--------------------------------------------------------------------------
  407. def now_action(battler = @active_battler)
  408. return if battler.nil?
  409. @now_action = nil
  410. case battler.current_action.kind
  411. when 0
  412. @now_action = $data_weapons[battler.weapon_id] if battler.current_action.basic == 0
  413. when 1
  414. @now_action = $data_skills[battler.current_action.skill_id]
  415. when 2
  416. @now_action = $data_items[battler.current_action.item_id]
  417. end
  418. end
  419. #--------------------------------------------------------------------------
  420. def start_enemy_select
  421. now_action
  422. @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
  423. @enemy_arrow.help_window = @help_window
  424. @actor_command_window.active = false
  425. @actor_command_window.visible = false
  426. @active_battler_window.visible = false
  427. @status_window.visible = true
  428. end
  429. #--------------------------------------------------------------------------
  430. alias start_actor_select_n01 start_actor_select
  431. def start_actor_select
  432. now_action
  433. start_actor_select_n01
  434. @status_window.visible = true
  435. @active_battler_window.visible = false
  436. @actor_arrow.input_right if @now_action.extension.include?("OTHERS")
  437. end
  438. #--------------------------------------------------------------------------
  439. alias update_phase3_actor_select_n01 update_phase3_actor_select
  440. def update_phase3_actor_select
  441. @actor_arrow.input_update_target if @now_action.extension.include?("OTHERS") and @actor_arrow.index == @active_battler.index
  442. update_phase3_actor_select_n01
  443. end
  444. #--------------------------------------------------------------------------
  445. alias update_phase3_n01 update_phase3
  446. def update_phase3
  447. if @enemy_arrow_all != nil
  448. update_phase3_select_all_enemies
  449. return
  450. elsif @actor_arrow_all != nil
  451. update_phase3_select_all_actors
  452. return
  453. elsif @battler_arrow_all != nil
  454. update_phase3_select_all_battlers
  455. return
  456. end
  457. update_phase3_n01
  458. end
  459. #--------------------------------------------------------------------------
  460. alias update_phase3_skill_select_n01 update_phase3_skill_select
  461. def update_phase3_skill_select
  462. @status_window.visible = false if HIDE_WINDOW
  463. if Input.trigger?(Input::C)
  464. @skill = @skill_window.skill
  465. if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
  466. $game_system.se_play($data_system.buzzer_se)
  467. return
  468. end
  469. @active_battler.current_action.skill_id = @skill.id
  470. @skill_window.visible = false
  471. if @skill.extension.include?("TARGETALL")
  472. $game_system.se_play($data_system.decision_se)
  473. start_select_all_battlers
  474. return
  475. end
  476. if (@skill.extension.include?("RANDOMTARGET") and @skill.scope <= 2) or @skill.scope == 2
  477. $game_system.se_play($data_system.decision_se)
  478. start_select_all_enemies
  479. return
  480. end
  481. if (@skill.extension.include?("RANDOMTARGET") and @skill.scope > 2) or @skill.scope == 4
  482. $game_system.se_play($data_system.decision_se)
  483. start_select_all_actors
  484. return
  485. end
  486. end
  487. update_phase3_skill_select_n01
  488. end
  489. #--------------------------------------------------------------------------
  490. alias update_phase3_item_select_n01 update_phase3_item_select
  491. def update_phase3_item_select
  492. @status_window.visible = false if HIDE_WINDOW
  493. if Input.trigger?(Input::C)
  494. @item = @item_window.item
  495. if @item == nil or not $game_party.item_can_use?(@item.id)
  496. $game_system.se_play($data_system.buzzer_se)
  497. return
  498. end
  499. @active_battler.current_action.item_id = @item.id
  500. @item_window.visible = false
  501. if @item.extension.include?("TARGETALL")
  502. $game_system.se_play($data_system.decision_se)
  503. start_select_all_battlers
  504. return
  505. end
  506. if @item.extension.include?("RANDOMTARGET") and @item.scope <= 2 or @item.scope == 2
  507. $game_system.se_play($data_system.decision_se)
  508. start_select_all_enemies
  509. return
  510. end
  511. if (@item.extension.include?("RANDOMTARGET") and @item.scope > 2) or @item.scope == 4
  512. $game_system.se_play($data_system.decision_se)
  513. start_select_all_actors
  514. return
  515. end
  516. end
  517. update_phase3_item_select_n01
  518. end
  519. #--------------------------------------------------------------------------
  520. def update_phase3_select_all_enemies
  521. @enemy_arrow_all.update_multi_arrow
  522. if Input.trigger?(Input::B)
  523. $game_system.se_play($data_system.cancel_se)
  524. end_select_all_enemies
  525. return
  526. end
  527. if Input.trigger?(Input::C)
  528. $game_system.se_play($data_system.decision_se)
  529. if @skill_window != nil
  530. end_skill_select
  531. end
  532. if @item_window != nil
  533. end_item_select
  534. end
  535. end_select_all_enemies
  536. phase3_next_actor
  537. return
  538. end
  539. end
  540. #--------------------------------------------------------------------------
  541. def update_phase3_select_all_actors
  542. @actor_arrow_all.update_multi_arrow
  543. if Input.trigger?(Input::B)
  544. $game_system.se_play($data_system.cancel_se)
  545. end_select_all_actors
  546. return
  547. end
  548. if Input.trigger?(Input::C)
  549. $game_system.se_play($data_system.decision_se)
  550. if @skill_window != nil
  551. end_skill_select
  552. end
  553. if @item_window != nil
  554. end_item_select
  555. end
  556. end_select_all_actors
  557. phase3_next_actor
  558. return
  559. end
  560. end
  561. #--------------------------------------------------------------------------
  562. def update_phase3_select_all_battlers
  563. @battler_arrow_all.update_multi_arrow
  564. if Input.trigger?(Input::B)
  565. $game_system.se_play($data_system.cancel_se)
  566. end_select_all_battlers
  567. return
  568. end
  569. if Input.trigger?(Input::C)
  570. $game_system.se_play($data_system.decision_se)
  571. if @skill_window != nil
  572. end_skill_select
  573. end
  574. if @item_window != nil
  575. end_item_select
  576. end
  577. end_select_all_battlers
  578. phase3_next_actor
  579. return
  580. end
  581. end
  582. #--------------------------------------------------------------------------
  583. def start_select_all_enemies
  584. now_action
  585. @status_window.visible = true
  586. @active_battler_window.visible = false
  587. @enemy_arrow_all = Arrow_Enemy_All.new(@spriteset.viewport2)
  588. end
  589. #--------------------------------------------------------------------------
  590. def start_select_all_actors
  591. now_action
  592. @status_window.visible = true
  593. @active_battler_window.visible = false
  594. @actor_arrow_all = Arrow_Actor_All.new(@spriteset.viewport2)
  595. end
  596. #--------------------------------------------------------------------------
  597. def start_select_all_battlers
  598. now_action
  599. @status_window.visible = true
  600. @active_battler_window.visible = false
  601. @battler_arrow_all = Arrow_Battler_All.new(@spriteset.viewport2)
  602. end
  603. #--------------------------------------------------------------------------
  604. def end_select_all_actors
  605. @actor_arrow_all.dispose_multi_arrow
  606. @actor_arrow_all = nil
  607. @active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
  608. end
  609. #--------------------------------------------------------------------------
  610. def end_select_all_enemies
  611. @enemy_arrow_all.dispose_multi_arrow
  612. @enemy_arrow_all = nil
  613. @active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
  614. end
  615. #--------------------------------------------------------------------------
  616. def end_select_all_battlers
  617. @battler_arrow_all.dispose_multi_arrow
  618. @battler_arrow_all = nil
  619. @active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
  620. end
  621. #--------------------------------------------------------------------------
  622. alias end_enemy_select_n01 end_enemy_select
  623. def end_enemy_select
  624. end_enemy_select_n01
  625. @active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
  626. end
  627. #--------------------------------------------------------------------------
  628. alias start_skill_select_n01 start_skill_select
  629. def start_skill_select
  630. start_skill_select_n01
  631. @status_window.visible = false if HIDE_WINDOW
  632. @active_battler_window.visible = false
  633. end
  634. #--------------------------------------------------------------------------
  635. alias end_skill_select_n01 end_skill_select
  636. def end_skill_select
  637. end_skill_select_n01
  638. @status_window.visible = true
  639. @active_battler_window.visible = true if BATTLER_NAME_WINDOW
  640. end
  641. #--------------------------------------------------------------------------
  642. alias start_item_select_n01 start_item_select
  643. def start_item_select
  644. start_item_select_n01
  645. @status_window.visible = false if HIDE_WINDOW
  646. @active_battler_window.visible = false
  647. end
  648. #--------------------------------------------------------------------------
  649. alias end_item_select_n01 end_item_select
  650. def end_item_select
  651. end_item_select_n01
  652. @status_window.visible = true
  653. @active_battler_window.visible = true if BATTLER_NAME_WINDOW
  654. end
  655. #--------------------------------------------------------------------------
  656. alias make_action_orders_n01 make_action_orders
  657. def make_action_orders
  658. make_action_orders_n01
  659. for battler in @action_battlers
  660. skill_id = battler.current_action.skill_id
  661. item_id = battler.current_action.item_id
  662. next if battler.current_action.kind == 0
  663. extension = $data_skills[skill_id].extension if skill_id != 0
  664. extension = $data_items[item_id].extension if item_id != 0
  665. battler.current_action.speed = 9999 if extension.include?("FAST")
  666. battler.current_action.speed = -1 if extension.include?("SLOW")
  667. end
  668. @action_battlers.sort! {|a,b|
  669. b.current_action.speed - a.current_action.speed }
  670. for enemy in $game_troop.enemies
  671. if enemy.action_time[0] != 1
  672. action_time = 0
  673. for i in 1...enemy.action_time[0]
  674. action_time += 1 if rand(100) < enemy.action_time[1]
  675. end
  676. enemy.act_time = action_time
  677. action_time.times do
  678. enemy_order_time(enemy)
  679. action_time -= 1
  680. break if action_time == 0
  681. end
  682. enemy.adj_speed = nil
  683. end
  684. end
  685. end
  686. #--------------------------------------------------------------------------
  687. def enemy_order_time(enemy)
  688. enemy.make_action_speed2(enemy.action_time[2])
  689. select_time = 0
  690. for member in @action_battlers
  691. select_time += 1
  692. break @action_battlers.push(enemy) if member.current_action.speed < enemy.adj_speed
  693. break @action_battlers.push(enemy) if select_time == @action_battlers.size
  694. end
  695. end
  696. #--------------------------------------------------------------------------
  697. def update_phase4_step1
  698. return if @spriteset.effect?
  699. return @wait_count -= 1 if @wait_count > 0
  700. @help_window.visible = false
  701. return if judge
  702. if $game_temp.forcing_battler == nil
  703. setup_battle_event
  704. return if $game_system.battle_interpreter.running?
  705. end
  706. if $game_temp.forcing_battler != nil
  707. @action_battlers.delete($game_temp.forcing_battler)
  708. @action_battlers.unshift($game_temp.forcing_battler)
  709. end
  710. if @action_battlers.size == 0
  711. turn_ending
  712. start_phase2
  713. return
  714. end
  715. @animation1_id = 0
  716. @animation2_id = 0
  717. @common_event_id = 0
  718. @active_battler = @action_battlers.shift
  719. return if @active_battler.index == nil
  720. @active_battler.remove_states_auto
  721. @status_window.refresh
  722. @phase4_step = 2
  723. end
  724. #--------------------------------------------------------------------------
  725. def turn_ending
  726. for member in $game_party.actors + $game_troop.enemies
  727. member.current_action.clear
  728. next unless member.exist?
  729. member.slip_damage = false
  730. actor = member.actor?
  731. for state in member.battler_states
  732. member.remove_state(state.id) if state.extension.include?("ZEROTURNLIFT")
  733. end
  734. damage = 0
  735. for state in member.battler_states
  736. next unless state.extension.include?("SLIPDAMAGE")
  737. for ext in state.slip_extension
  738. if ext[0] == "hp"
  739. base_damage = ext[1] + member.maxhp * ext[2] / 100
  740. damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
  741. slip_pop = ext[3]
  742. slip_dead = ext[4]
  743. slip_damage_flug = true
  744. member.slip_damage = true
  745. end
  746. end
  747. end
  748. if member.slip_damage && member.exist? && !slip_damage_flug
  749. damage += member.apply_variance(member.maxhp / 10, 10)
  750. slip_dead = false
  751. slip_pop = true
  752. slip_damage_flug = true
  753. member.slip_damage = true
  754. end
  755. damage = member.hp - 1 if damage >= member.hp && slip_dead = false
  756. member.hp -= damage
  757. member.damage = damage if damage > 0
  758. member.perform_collapse if member.dead? && member.slip_damage
  759. @spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
  760. @spriteset.set_stand_by_action(actor, member.index) if member.hp <= 0 and not member.dead_anim
  761. member.dead_anim = member.dead? ? true : false
  762. end
  763. @status_window.refresh
  764. wait(DMG_DURATION / 2) if slip_damage_flug
  765. slip_damage_flug = false
  766. for member in $game_party.actors + $game_troop.enemies
  767. next unless member.exist?
  768. actor = member.actor?
  769. damage = 0
  770. for state in member.battler_states
  771. next unless state.extension.include?("SLIPDAMAGE")
  772. for ext in state.slip_extension
  773. if ext[0] == "mp"
  774. base_damage = ext[1] + member.maxsp * ext[2] / 100
  775. damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
  776. slip_pop = ext[3]
  777. slip_damage_flug = true
  778. end
  779. end
  780. member.sp_damage = true
  781. member.sp -= damage
  782. member.damage = damage if damage > 0
  783. @spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
  784. end
  785. end
  786. @status_window.refresh
  787. wait(DMG_DURATION / 2) if slip_damage_flug
  788. for member in $game_party.actors + $game_troop.enemies
  789. next unless member.exist?
  790. actor = member.actor?
  791. damage = 0
  792. for state in member.battler_states
  793. next unless state.extension.include?("REGENERATION")
  794. for ext in state.slip_extension
  795. if ext[0] == "hp"
  796. base_damage = ext[1] + member.maxhp * ext[2] / 100
  797. damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
  798. slip_pop = ext[3]
  799. slip_damage_flug = true
  800. end
  801. end
  802. member.hp -= damage
  803. member.damage = damage if damage < 0
  804. @spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
  805. end
  806. end
  807. @status_window.refresh
  808. wait(DMG_DURATION / 2) if slip_damage_flug
  809. for member in $game_party.actors + $game_troop.enemies
  810. next unless member.exist?
  811. actor = member.actor?
  812. damage = 0
  813. for state in member.battler_states
  814. next unless state.extension.include?("REGENERATION")
  815. for ext in state.slip_extension
  816. if ext[0] == "mp"
  817. base_damage = ext[1] + member.maxhp * ext[2] / 100
  818. damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
  819. slip_pop = ext[3]
  820. slip_damage_flug = true
  821. end
  822. end
  823. member.sp_damage = true
  824. member.sp -= damage
  825. member.damage = damage if damage < 0
  826. @spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
  827. end
  828. end
  829. @status_window.refresh
  830. wait(DMG_DURATION / 2) if slip_damage_flug
  831. end
  832. #--------------------------------------------------------------------------
  833. alias update_phase4_step2_n01 update_phase4_step2
  834. def update_phase4_step2
  835. for member in $game_party.actors + $game_troop.enemies
  836. member.dead_anim = member.dead? ? true : false
  837. end
  838. if @active_battler.current_action.kind != 0
  839. obj = $data_skills[@active_battler.current_action.skill_id] if @active_battler.current_action.kind == 1
  840. obj = $data_items[@active_battler.current_action.item_id] if @active_battler.current_action.kind == 2
  841. @active_battler.white_flash = false if obj != nil &&obj.extension.include?("NOFLASH")
  842. end
  843. @active_battler.active = true
  844. update_phase4_step2_n01
  845. if @active_battler != nil && @active_battler.derivation != 0
  846. @active_battler.current_action.kind = 1
  847. @active_battler.current_action.skill_id = @active_battler.derivation
  848. @action_battlers.unshift(@active_battler)
  849. end
  850. if @active_battler != nil && !@active_battler.actor? && @active_battler.act_time != 0
  851. @active_battler.make_action
  852. @active_battler.act_time -= 1
  853. end
  854. update_phase4_step6
  855. end
  856. #--------------------------------------------------------------------------
  857. alias update_phase4_step6_n01 update_phase4_step6
  858. def update_phase4_step6
  859. update_phase4_step6_n01
  860. @active_battler.active = false if @active_battler != nil
  861. end
  862. #--------------------------------------------------------------------------
  863. def make_basic_action_result
  864. if @active_battler.current_action.basic == 0
  865. execute_action_attack
  866. return
  867. end
  868. if @active_battler.current_action.basic == 1
  869. @help_window.set_text("#{@active_battler.name} defends", 1)
  870. @help_window.visible = true
  871. @active_battler.active = false
  872. @active_battler.defense_pose = true
  873. @spriteset.set_stand_by_action(@active_battler.actor?, @active_battler.index)
  874. wait(45)
  875. @help_window.visible = false
  876. return
  877. end
  878. if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2
  879. @spriteset.set_action(false, @active_battler.index, @active_battler.run_success)
  880. $game_system.se_play($data_system.escape_se)
  881. @active_battler.escape
  882. pop_help("#{@active_battler.name} escaped...")
  883. return
  884. end
  885. if @active_battler.current_action.basic == 3
  886. @active_battler.active = false
  887. $game_temp.forcing_battler = nil
  888. @phase4_step = 1
  889. return
  890. end
  891. end
  892. #--------------------------------------------------------------------------
  893. def execute_action_attack
  894. if @active_battler.actor?
  895. if @active_battler.weapon_id == 0
  896. action = @active_battler.non_weapon
  897. immortaling
  898. else
  899. action = $data_weapons[@active_battler.weapon_id].base_action
  900. if $data_weapons[@active_battler.weapon_id].plus_state_set.include?(1)
  901. for member in $game_party.actors + $game_troop.enemies
  902. next if member.immortal
  903. next if member.dead?
  904. member.dying = true
  905. end
  906. else
  907. immortaling
  908. end
  909. end
  910. else
  911. if @active_battler.weapon == 0
  912. action = @active_battler.base_action
  913. immortaling
  914. else
  915. action = $data_weapons[@active_battler.weapon].base_action
  916. if $data_weapons[@active_battler.weapon].plus_state_set.include?(1)
  917. for member in $game_party.actors + $game_troop.enemies
  918. next if member.immortal
  919. next if member.dead?
  920. member.dying = true
  921. end
  922. else
  923. immortaling
  924. end
  925. end
  926. end
  927. target_decision
  928. @spriteset.set_action(@active_battler.actor?, @active_battler.index, action)
  929. playing_action
  930. end
  931. #--------------------------------------------------------------------------
  932. def make_attack_targets
  933. @target_battlers = []
  934. if @active_battler.is_a?(Game_Enemy)
  935. if @active_battler.restriction == 3
  936. target = $game_troop.random_target_enemy
  937. elsif @active_battler.restriction == 2
  938. target = $game_party.random_target_actor
  939. else
  940. index = @active_battler.current_action.target_index
  941. target = $game_party.smooth_target_actor(index)
  942. end
  943. end
  944. if @active_battler.actor?
  945. if @active_battler.restriction == 3
  946. target = $game_party.random_target_actor
  947. elsif @active_battler.restriction == 2
  948. target = $game_troop.random_target_enemy
  949. else
  950. index = @active_battler.current_action.target_index
  951. target = $game_troop.smooth_target_enemy(index)
  952. end
  953. end
  954. @target_battlers = [target]
  955. return @target_battlers
  956. end
  957. #--------------------------------------------------------------------------
  958. def make_skill_action_result
  959. skill = $data_skills[@active_battler.current_action.skill_id]
  960. if skill.plus_state_set.include?(1)
  961. for member in $game_party.actors + $game_troop.enemies
  962. next if member.immortal
  963. next if member.dead?
  964. member.dying = true
  965. end
  966. else
  967. immortaling
  968. end
  969. return unless @active_battler.skill_can_use?(skill.id)
  970. target_decision(skill)
  971. @active_battler.consum_skill_cost(skill)
  972. @status_window.refresh
  973. @spriteset.set_action(@active_battler.actor?, @active_battler.index, skill.base_action)
  974. @help_window.set_text(skill.name, 1) unless skill.extension.include?("HELPHIDE")
  975. playing_action
  976. @common_event_id = skill.common_event_id
  977. end
  978. #--------------------------------------------------------------------------
  979. def make_item_action_result
  980. item = $data_items[@active_battler.current_action.item_id]
  981. unless $game_party.item_can_use?(item.id)
  982. @phase4_step = 1
  983. return
  984. end
  985. if @item.consumable
  986. $game_party.lose_item(item.id, 1)
  987. end
  988. immortaling
  989. target_decision(item)
  990. @spriteset.set_action(@active_battler.actor?, @active_battler.index, item.base_action)
  991. @help_window.set_text(item.name, 1) unless item.extension.include?("HELPHIDE")
  992. playing_action
  993. @common_event_id = item.common_event_id
  994. end
  995. #--------------------------------------------------------------------------
  996. def target_decision(obj = nil)
  997. if obj != nil
  998. set_target_battlers(obj.scope)
  999. if obj.extension.include?("TARGETALL")
  1000. @target_battlers = []
  1001. if obj.scope != 5 or obj.scope != 6
  1002. for target in $game_troop.enemies + $game_party.actors
  1003. @target_battlers.push(target) if target.exist?
  1004. end
  1005. else
  1006. for target in $game_troop.enemies + $game_party.actors
  1007. @target_battlers.push(target) if target != nil && target.hp0?
  1008. end
  1009. end
  1010. end
  1011. @target_battlers.delete(@active_battler) if obj.extension.include?("OTHERS")
  1012. if obj.extension.include?("RANDOMTARGET")
  1013. randum_targets = @target_battlers.dup
  1014. @target_battlers = [randum_targets[rand(randum_targets.size)]]
  1015. end
  1016. else
  1017. @target_battlers = make_attack_targets
  1018. end
  1019. if @target_battlers.size == 0
  1020. action = @active_battler.recover_action
  1021. @spriteset.set_action(@active_battler.actor?, @active_battler.index, action)
  1022. end
  1023. @spriteset.set_target(@active_battler.actor?, @active_battler.index, @target_battlers)
  1024. end
  1025. #--------------------------------------------------------------------------
  1026. def playing_action
  1027. loop do
  1028. update_basic
  1029. update_effects
  1030. action = @active_battler.play
  1031. next if action == 0
  1032. @active_battler.play = 0
  1033. if action[0] == "Individual"
  1034. individual
  1035. elsif action == "Can Collapse"
  1036. unimmortaling
  1037. elsif action == "Cancel Action"
  1038. break action_end
  1039. elsif action == "End"
  1040. break action_end
  1041. elsif action[0] == "OBJ_ANIM"
  1042. damage_action(action[1])
  1043. end
  1044. end
  1045. end
  1046. #--------------------------------------------------------------------------
  1047. def individual
  1048. @individual_target = @target_battlers
  1049. @stand_by_target = @target_battlers.dup
  1050. end
  1051. #--------------------------------------------------------------------------
  1052. def immortaling
  1053. for member in $game_party.actors + $game_troop.enemies
  1054. member.immortal = true unless member.dead?
  1055. end
  1056. end
  1057. #--------------------------------------------------------------------------
  1058. def unimmortaling
  1059. return if @active_battler.individual
  1060. for member in $game_party.actors + $game_troop.enemies
  1061. member.immortal = false
  1062. member.add_state(1) if member.dead?
  1063. if member.dead? and not member.dead_anim
  1064. member.perform_collapse
  1065. @spriteset.set_stand_by_action(member.actor?, member.index)
  1066. end
  1067. member.dead_anim = member.dead? ? true : false
  1068. next unless member.dead?
  1069. resurrection(member)
  1070. end
  1071. update_basic
  1072. @status_window.refresh
  1073. end
  1074. #--------------------------------------------------------------------------
  1075. def resurrection(target)
  1076. for state in target.battler_states
  1077. for ext in state.extension
  1078. name = ext.split('')
  1079. next unless name[0] == "A"
  1080. wait(25)
  1081. name = name.join
  1082. name.slice!("AUTOLIFE/")
  1083. target.hp = target.maxhp * name.to_i / 100
  1084. target.remove_state(1)
  1085. target.remove_state(state.id)
  1086. target.animation_id = RESURRECTION
  1087. target.animation_hit = true
  1088. target.anime_mirror = true if $back_attack
  1089. @status_window.refresh
  1090. wait($data_animations[RESURRECTION].frame_max * 2)
  1091. end
  1092. end
  1093. end
  1094. #--------------------------------------------------------------------------
  1095. def magic_reflection(target, obj)
  1096. return if obj != nil and $data_skills[@active_battler.current_action.skill_id].int_f == 0
  1097. for state in target.battler_states
  1098. for ext in state.extension
  1099. name = ext.split('')
  1100. next unless name[0] == "M"
  1101. if name[3] == "R"
  1102. name = name.join
  1103. name.slice!("MAGREFLECT/")
  1104. target.animation_id = name.to_i
  1105. target.animation_hit = true
  1106. target.anime_mirror = true if $back_attack
  1107. @reflection = true
  1108. else
  1109. name = name.join
  1110. name.slice!("MAGNULL/")
  1111. target.animation_id = name.to_i
  1112. target.animation_hit = true
  1113. target.anime_mirror = true if $back_attack
  1114. @invalid = true
  1115. end
  1116. end
  1117. end
  1118. end
  1119. #--------------------------------------------------------------------------
  1120. def physics_reflection(target, obj)
  1121. return if obj != nil && $data_skills[@active_battler.current_action.skill_id].str_f == 0
  1122. for state in target.battler_states
  1123. for ext in state.extension
  1124. name = ext.split('')
  1125. next unless name[0] == "P"
  1126. if name[3] == "R"
  1127. name = name.join
  1128. name.slice!("PHYREFLECT/")
  1129. target.animation_id = name.to_i
  1130. target.animation_hit = true
  1131. target.anime_mirror = true if $back_attack
  1132. @reflection = true
  1133. else
  1134. name = name.join
  1135. name.slice!("PHYNULL/")
  1136. target.animation_id = name.to_i
  1137. target.animation_hit = true
  1138. target.anime_mirror = true if $back_attack
  1139. @invalid = true
  1140. end
  1141. end
  1142. end
  1143. end
  1144. #--------------------------------------------------------------------------
  1145. def absorb_cost(target, obj)
  1146. for state in target.battler_states
  1147. if state.extension.include?("COSTABSORB")
  1148. cost = @active_battler.calc_sp_cost(@active_battler, obj)
  1149. return target.hp += cost if obj.extension.include?("HPCONSUME")
  1150. return target.mp += cost
  1151. end
  1152. end
  1153. end
  1154. #--------------------------------------------------------------------------
  1155. def absorb_attack(obj, target, index, actor)
  1156. for ext in obj.extension
  1157. return if target.evaded or target.missed or target.damage == 0 or target.damage == nil
  1158. name = ext.split('')
  1159. next unless name[3] == "G" and name[1] == "D"
  1160. name = name.join
  1161. name.slice!("%DMGABSORB/")
  1162. kind = "hp" unless target.sp_damage
  1163. kind = "sp" if target.sp_damage
  1164. absorb = target.damage * name.to_i / 100
  1165. @wide_attack = true if obj.scope == 2 or obj.scope == 4 or obj.scope == 6 or obj.extension.include?("TARGETALL")
  1166. if @wide_attack && @absorb == nil && @target_battlers.size != 1
  1167. @absorb = absorb
  1168. @absorb_target_size = @target_battlers.size - 2
  1169. elsif @absorb != nil && @absorb_target_size > 0
  1170. @absorb += absorb
  1171. @absorb_target_size -= 1
  1172. elsif @absorb != nil
  1173. @absorb += absorb
  1174. absorb_action = ["absorb", nil, kind, @absorb]
  1175. @spriteset.set_damage_action(actor, index, absorb_action)
  1176. @absorb = nil
  1177. @absorb_target_size = nil
  1178. @active_battler.perform_collapse
  1179. else
  1180. absorb_action = ["absorb", nil, kind, absorb]
  1181. @spriteset.set_damage_action(actor, index, absorb_action)
  1182. @active_battler.perform_collapse
  1183. end
  1184. end
  1185. end
  1186. #--------------------------------------------------------------------------
  1187. def action_end
  1188. @individual_target = nil
  1189. @help_window.visible = false if @help_window != nil && @help_window.visible
  1190. @active_battler.active = false
  1191. unimmortaling
  1192. for member in $game_troop.enemies
  1193. member.non_dead = false if member.non_dead
  1194. end
  1195. if @active_battler.reflex != nil
  1196. if @active_battler.current_action.kind == 1
  1197. obj = $data_skills[@active_battler.current_action.skill_id]
  1198. @active_battler.perfect_skill_effect(@active_battler, obj)
  1199. elsif @active_battler.current_action.kind == 2
  1200. obj = $data_items[@active_battler.current_action.item_id]
  1201. @active_battler.item_effect(@active_battler, obj)
  1202. else
  1203. @active_battler.perfect_attack_effect(@active_battler)
  1204. end
  1205. pop_damage(@active_battler, obj, @active_battler.reflex)
  1206. @active_battler.perform_collapse
  1207. @active_battler.reflex = nil
  1208. wait(COLLAPSE_WAIT)
  1209. end
  1210. if @active_battler.derivation != 0
  1211. @active_battler.current_action.skill_id = @active_battler.derivation
  1212. @active_battler.current_action.kind = 1
  1213. @active_battler.derivation = 0
  1214. @action_battlers.unshift(@active_battler)
  1215. else
  1216. @spriteset.set_stand_by_action(@active_battler.actor?, @active_battler.index)
  1217. wait(ACTION_WAIT + 20)
  1218. end
  1219. end
  1220. #--------------------------------------------------------------------------
  1221. def damage_action(action)
  1222. @target_battlers = [@individual_target.shift] if @active_battler.individual
  1223. if @active_battler.current_action.kind == 1
  1224. obj = $data_skills[@active_battler.current_action.skill_id]
  1225. for target in @target_battlers
  1226. return if target == nil
  1227. if obj.scope == 5 or obj.scope == 6
  1228. return unless target.dead?
  1229. else
  1230. return if target.dead?
  1231. end
  1232. if target.hp == 0 && obj.scope != 5 && obj.scope != 6
  1233. target.perfect_skill_effect(@active_battler, obj)
  1234. elsif obj.extension.include?("NOEVADE")
  1235. target.perfect_skill_effect(@active_battler, obj)
  1236. else
  1237. magic_reflection(target, obj) unless obj.extension.include?("IGNOREREFLECT")
  1238. physics_reflection(target, obj) unless obj.extension.include?("IGNOREREFLECT")
  1239. target.skill_effect(@active_battler, obj) unless @reflection or @invalid
  1240. end
  1241. pop_damage(target, obj, action) unless @reflection or @invalid
  1242. absorb_cost(target, obj)
  1243. @active_battler.reflex = action if @reflection
  1244. @reflection = false
  1245. @invalid = false
  1246. end
  1247. elsif @active_battler.current_action.kind == 2
  1248. obj = $data_items[@active_battler.current_action.item_id]
  1249. for target in @target_battlers
  1250. return if target == nil
  1251. if obj.scope == 5 or obj.scope == 6
  1252. return unless target.dead?
  1253. else
  1254. return if target.dead?
  1255. end
  1256. target.revival = true if obj.scope == 5 or obj.scope == 6
  1257. target.item_effect(obj)
  1258. pop_damage(target, obj, action)
  1259. end
  1260. else
  1261. for target in @target_battlers
  1262. return if target == nil or target.dead?
  1263. physics_reflection(target, nil)
  1264. target.perfect_attack_effect(@active_battler) if target.hp <= 0
  1265. target.attack_effect(@active_battler) unless target.hp <= 0 unless @reflection or @invalid
  1266. pop_damage(target, obj, action) unless @reflection or @invalid
  1267. @active_battler.reflex = action if @reflection
  1268. @reflection = false
  1269. @invalid = false
  1270. end
  1271. end
  1272. return if obj == nil
  1273. target_decision(obj) if obj.extension.include?("RANDOMTARGET")
  1274. end
  1275. #--------------------------------------------------------------------------
  1276. def pop_damage(target, obj, action)
  1277. index = @active_battler.index
  1278. actor = @active_battler.actor?
  1279. if obj != nil && obj.extension.size != 0
  1280. absorb_attack(obj, target, index, actor)
  1281. action[2] = false if obj.extension.include?("NOOVERKILL")
  1282. end
  1283. @spriteset.set_damage_action(target.actor?, target.index, action)
  1284. @status_window.refresh
  1285. end
  1286. end
  1287.  
  1288. #==============================================================================
  1289. # ■ Scene_Map
  1290. #==============================================================================
  1291. class Scene_Map
  1292. #--------------------------------------------------------------------------
  1293. include N01
  1294. #--------------------------------------------------------------------------
  1295. alias call_battle_n01 call_battle
  1296. #--------------------------------------------------------------------------
  1297. def call_battle
  1298. $back_attack = $preemptive = false
  1299. preemptive_or_back_attack
  1300. call_battle_n01
  1301. end
  1302. #--------------------------------------------------------------------------
  1303. def preemptive_or_back_attack
  1304. enemies_agi = 0
  1305. for enemy in $game_troop.enemies
  1306. enemies_agi += enemy.agi
  1307. end
  1308. enemies_agi /= [$game_troop.enemies.size, 1].max
  1309. actors_agi = 0
  1310. for actor in $game_party.actors
  1311. actors_agi += actor.agi
  1312. end
  1313. actors_agi /= [$game_party.actors.size, 1].max
  1314. preemptive_plus
  1315. if actors_agi >= enemies_agi
  1316. percent_preemptive = PREEMPTIVE_RATE * ($preemptive_plus ? 3 : 1)
  1317. percent_back_attack = BACK_ATTACK_RATE / 2
  1318. else
  1319. percent_preemptive = (PREEMPTIVE_RATE / 2) * ($preemptive_plus ? 3 : 1)
  1320. percent_back_attack = BACK_ATTACK_RATE
  1321. end
  1322. if rand(100) < percent_preemptive
  1323. $preemptive = true
  1324. elsif rand(100) < percent_back_attack
  1325. $back_attack = true
  1326. end
  1327. special_back_attack_conditions
  1328. special_preemptive_conditions
  1329. $preemptive = false if $back_attack or !PREEMPTIVE
  1330. $back_attack = false if !BACK_ATTACK
  1331. end
  1332. #--------------------------------------------------------------------------
  1333. def special_back_attack_conditions
  1334. for i in 0...BACK_ATTACK_SWITCH.size
  1335. return $back_attack = true if $game_switches[BACK_ATTACK_SWITCH[i]]
  1336. end
  1337. for i in 0...NO_BACK_ATTACK_SWITCH.size
  1338. return $back_attack = false if $game_switches[NON_BACK_ATTACK_SWITCH[i]]
  1339. end
  1340. for actor in $game_party.actors
  1341. return $back_attack = false if NON_BACK_ATTACK_WEAPONS.include?(actor.weapon_id)
  1342. return $back_attack = false if NON_BACK_ATTACK_ARMOR1.include?(actor.armor1_id)
  1343. return $back_attack = false if NON_BACK_ATTACK_ARMOR2.include?(actor.armor2_id)
  1344. return $back_attack = false if NON_BACK_ATTACK_ARMOR3.include?(actor.armor3_id)
  1345. return $back_attack = false if NON_BACK_ATTACK_ARMOR4.include?(actor.armor4_id)
  1346. for i in 0...NON_BACK_ATTACK_SKILLS.size
  1347. return $back_attack = false if actor.skill_id_learn?(NON_BACK_ATTACK_SKILLS[i])
  1348. end
  1349. end
  1350. end
  1351. #--------------------------------------------------------------------------
  1352. def special_preemptive_conditions
  1353. for i in 0...PREEMPTIVE_SWITCH.size
  1354. return $preemptive = true if $game_switches[PREEMPTIVE_SWITCH[i]]
  1355. end
  1356. for i in 0...NO_PREEMPTIVE_SWITCH.size
  1357. return $preemptive = false if $game_switches[NON_PREEMPTIVE_SWITCH[i]]
  1358. end
  1359. end
  1360. #--------------------------------------------------------------------------
  1361. def preemptive_plus
  1362. $preemptive_plus = false
  1363. for actor in $game_party.actors
  1364. return $preemptive_plus = true if PREEMPTIVE_WEAPONS.include?(actor.weapon_id)
  1365. return $preemptive_plus = true if PREEMPTIVE_ARMOR1.include?(actor.armor1_id)
  1366. return $preemptive_plus = true if PREEMPTIVE_ARMOR2.include?(actor.armor2_id)
  1367. return $preemptive_plus = true if PREEMPTIVE_ARMOR3.include?(actor.armor3_id)
  1368. return $preemptive_plus = true if PREEMPTIVE_ARMOR4.include?(actor.armor4_id)
  1369. for i in 0...PREEMPTIVE_SKILLS.size
  1370. return $preemptive_plus = true if actor.skill_id_learn?(PREEMPTIVE_SKILLS[i])
  1371. end
  1372. end
  1373. end
  1374. end
  1375.  
  1376. #==============================================================================
  1377. # ■ Spriteset_Battle
  1378. #==============================================================================
  1379. class Spriteset_Battle
  1380. #--------------------------------------------------------------------------
  1381. attr_reader :viewport1
  1382. attr_reader :viewport2
  1383. attr_accessor :actor_sprites
  1384. attr_accessor :enemy_sprites
  1385. #--------------------------------------------------------------------------
  1386. include N01
  1387. #--------------------------------------------------------------------------
  1388. def initialize
  1389. @viewport1 = Viewport.new(0, 0, 640, 480)
  1390. @viewport2 = Viewport.new(0, 0, 640, 480)
  1391. @viewport3 = Viewport.new(0, 0, 640, 480)
  1392. @viewport4 = Viewport.new(0, 0, 640, 480)
  1393. @viewport2.z = 101
  1394. @viewport3.z = 200
  1395. @viewport4.z = 5000
  1396. @battleback_sprite = Sprite.new(@viewport1)
  1397. @battleback_sprite.mirror = true if $back_attack && BACK_ATTACK_BATTLE_BACK_MIRROR
  1398. @enemy_sprites = []
  1399. for enemy in $game_troop.enemies
  1400. @enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy))
  1401. end
  1402. @actor_sprites = []
  1403. for i in 0...$game_party.actors.size
  1404. @actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
  1405. end
  1406. @weather = RPG::Weather.new(@viewport1)
  1407. @picture_sprites = []
  1408. for i in 51..100
  1409. @picture_sprites.push(Sprite_Picture.new(@viewport3, $game_screen.pictures[i]))
  1410. end
  1411. @timer_sprite = Sprite_Timer.new
  1412. update
  1413. end
  1414. #--------------------------------------------------------------------------
  1415. def update
  1416. if $game_party.actors.size > @actor_sprites.size
  1417. for i in @actor_sprites.size...$game_party.actors.size
  1418. @actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
  1419. end
  1420. elsif @actor_sprites.size > $game_party.actors.size
  1421. for i in 0...@actor_sprites.size
  1422. @actor_sprites[i].dispose
  1423. end
  1424. @actor_sprites = []
  1425. for i in 0...$game_party.actors.size
  1426. @actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
  1427. end
  1428. end
  1429. for i in 0...$game_party.actors.size
  1430. @actor_sprites[i].battler = $game_party.actors[i]
  1431. end
  1432. if @battleback_name != $game_temp.battleback_name
  1433. @battleback_name = $game_temp.battleback_name
  1434. if @battleback_sprite.bitmap != nil
  1435. @battleback_sprite.bitmap.dispose
  1436. end
  1437. @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  1438. @battleback_sprite.src_rect.set(0, 0, 640, 480)
  1439. end
  1440. for sprite in @enemy_sprites + @actor_sprites
  1441. sprite.update
  1442. end
  1443. @weather.type = $game_screen.weather_type
  1444. @weather.max = $game_screen.weather_max
  1445. @weather.update
  1446. for sprite in @picture_sprites
  1447. sprite.update
  1448. end
  1449. @timer_sprite.update
  1450. @viewport1.tone = $game_screen.tone
  1451. @viewport1.ox = $game_screen.shake
  1452. @viewport2.tone = $game_screen.tone
  1453. @viewport2.ox = $game_screen.shake
  1454. @viewport4.color = $game_screen.flash_color
  1455. @viewport1.update
  1456. @viewport2.update
  1457. @viewport4.update
  1458. end
  1459. #--------------------------------------------------------------------------
  1460. def set_damage_action(actor, index, action)
  1461. return if index.nil?
  1462. @actor_sprites[index].damage_action(action) if actor
  1463. @enemy_sprites[index].damage_action(action) unless actor
  1464. end
  1465. #--------------------------------------------------------------------------
  1466. def set_damage_pop(actor, index, damage)
  1467. return if index.nil?
  1468. @actor_sprites[index].damage_pop if actor
  1469. @enemy_sprites[index].damage_pop unless actor
  1470. end
  1471. #--------------------------------------------------------------------------
  1472. def set_target(actor, index, target)
  1473. return if index.nil?
  1474. @actor_sprites[index].get_target(target) if actor
  1475. @enemy_sprites[index].get_target(target) unless actor
  1476. end
  1477. #--------------------------------------------------------------------------
  1478. def set_action(actor, index, kind)
  1479. return if index.nil?
  1480. @actor_sprites[index].start_action(kind) if actor
  1481. @enemy_sprites[index].start_action(kind) unless actor
  1482. end
  1483. #--------------------------------------------------------------------------
  1484. def set_stand_by_action(actor, index)
  1485. return if index.nil?
  1486. @actor_sprites[index].push_stand_by if actor
  1487. @enemy_sprites[index].push_stand_by unless actor
  1488. end
  1489. end
  1490.  
  1491. #==============================================================================
  1492. # ■ Sprite_MoveAnime
  1493. #==============================================================================
  1494. class Sprite_MoveAnime < RPG::Sprite
  1495. #--------------------------------------------------------------------------
  1496. attr_accessor :battler
  1497. attr_accessor :base_x
  1498. attr_accessor :base_y
  1499. #--------------------------------------------------------------------------
  1500. def initialize(viewport,battler = nil)
  1501. super(viewport)
  1502. @battler = battler
  1503. self.visible = false
  1504. @base_x = 0
  1505. @base_y = 0
  1506. @move_x = 0
  1507. @move_y = 0
  1508. @moving_x = 0
  1509. @moving_y = 0
  1510. @orbit = 0
  1511. @orbit_plus = 0
  1512. @orbit_time = 0
  1513. @through = false
  1514. @finish = false
  1515. @time = 0
  1516. @angle = 0
  1517. @angling = 0
  1518. end
  1519. #--------------------------------------------------------------------------
  1520. def anime_action(id,mirror,distanse_x,distanse_y,type,speed,orbit,weapon,icon_index,icon_weapon)
  1521. @time = speed
  1522. @moving_x = distanse_x / speed
  1523. @moving_y = distanse_y / speed
  1524. @through = true if type == 1
  1525. @orbit_plus = orbit
  1526. @orbit_time = @time
  1527. if weapon != ""
  1528. action = ANIME[weapon].dup
  1529. @angle = action[0]
  1530. end_angle = action[1]
  1531. time = action[2]
  1532. @angling = (end_angle - @angle)/ time
  1533. self.angle = @angle
  1534. self.mirror = mirror
  1535. if icon_weapon
  1536. self.bitmap = RPG::Cache.icon(icon_index)
  1537. self.ox = 12
  1538. self.oy = 12
  1539. else
  1540. self.bitmap = RPG::Cache.character(icon_index, 0)
  1541. self.ox = self.bitmap.width / 2
  1542. self.oy = self.bitmap.height / 2
  1543. end
  1544. self.visible = true
  1545. self.z = 1000
  1546. end
  1547. self.x = @base_x + @move_x
  1548. self.y = @base_y + @move_y + @orbit
  1549. if id != 0 && !icon_weapon
  1550. animation($data_animations[id],true)
  1551. elsif id != 0 && icon_weapon
  1552. loop_animation($data_animations[id])
  1553. end
  1554. end
  1555. #--------------------------------------------------------------------------
  1556. def action_reset
  1557. @moving_x = @moving_y = @move_x = @move_y = @base_x = @base_y = @orbit = 0
  1558. @orbit_time = @angling = @angle = 0
  1559. @through = self.visible = @finish = false
  1560. dispose_animation
  1561. end
  1562. #--------------------------------------------------------------------------
  1563. def finish?
  1564. return @finish
  1565. end
  1566. #--------------------------------------------------------------------------
  1567. def update
  1568. super
  1569. @time -= 1
  1570. if @time >= 0
  1571. @move_x += @moving_x
  1572. @move_y += @moving_y
  1573. if @time < @orbit_time / 2
  1574. @orbit_plus = @orbit_plus * 5 / 4
  1575. elsif @time == @orbit_time / 2
  1576. @orbit_plus *= -1
  1577. else
  1578. @orbit_plus = @orbit_plus * 2 / 3
  1579. end
  1580. @orbit += @orbit_plus
  1581. end
  1582. @time = 100 if @time < 0 && @through
  1583. @finish = true if @time < 0 && !@through
  1584. self.x = @base_x + @move_x
  1585. self.y = @base_y + @move_y + @orbit
  1586. if self.x < -200 or self.x > 840 or self.y < -200 or self.y > 680
  1587. @finish = true
  1588. end
  1589. if self.visible
  1590. @angle += @angling
  1591. self.angle = @angle
  1592. end
  1593. end
  1594. end
  1595.  
  1596. #==============================================================================
  1597. # ■ Sprite_Weapon
  1598. #==============================================================================
  1599. class Sprite_Weapon < RPG::Sprite
  1600. #--------------------------------------------------------------------------
  1601. include N01
  1602. #--------------------------------------------------------------------------
  1603. attr_accessor :battler
  1604. #--------------------------------------------------------------------------
  1605. def initialize(viewport,battler = nil)
  1606. super(viewport)
  1607. @battler = battler
  1608. @action = []
  1609. @move_x = 0
  1610. @move_y = 0
  1611. @move_z = 0
  1612. @plus_x = 0
  1613. @plus_y = 0
  1614. @angle = 0
  1615. @zoom_x = 1
  1616. @zoom_y = 1
  1617. @moving_x = 0
  1618. @moving_y = 0
  1619. @angling = 0
  1620. @zooming_x = 1
  1621. @zooming_y = 1
  1622. @freeze = -1
  1623. @mirroring = false
  1624. @time = ANIME_PATTERN + 1
  1625. weapon_graphics
  1626. end
  1627. #--------------------------------------------------------------------------
  1628. def dispose
  1629. self.bitmap.dispose if self.bitmap != nil
  1630. super
  1631. end
  1632. #--------------------------------------------------------------------------
  1633. def weapon_graphics(left = false)
  1634. if @battler.actor?
  1635. weapon = @battler.weapons[0] unless left
  1636. weapon = @battler.weapons[1] if left
  1637. else
  1638. weapon = $data_weapons[@battler.weapon]
  1639. @mirroring = true if @battler.action_mirror
  1640. end
  1641. return if weapon == nil
  1642. if weapon.graphic == ""
  1643. self.bitmap = RPG::Cache.icon(weapon.icon_name)
  1644. @weapon_width = @weapon_height = 24
  1645. else
  1646. self.bitmap = RPG::Cache.icon(weapon.graphic)
  1647. @weapon_width = self.bitmap.width
  1648. @weapon_height = self.bitmap.height
  1649. end
  1650. end
  1651. #--------------------------------------------------------------------------
  1652. def freeze(action)
  1653. @freeze = action
  1654. end
  1655. #--------------------------------------------------------------------------
  1656. def weapon_action(action,loop)
  1657. if action == ""
  1658. self.visible = false
  1659. elsif @weapon_id == 0
  1660. self.visible = false
  1661. else
  1662. @action = ANIME[action]
  1663. act0 = @action[0]
  1664. act1 = @action[1]
  1665. act2 = @action[2]
  1666. act3 = @action[3]
  1667. act4 = @action[4]
  1668. act5 = @action[5]
  1669. act6 = @action[6]
  1670. act7 = @action[7]
  1671. act8 = @action[8]
  1672. act9 = @action[9]
  1673. act10 = @action[10]
  1674. if @mirroring
  1675. act0 *= -1
  1676. act3 *= -1
  1677. act4 *= -1
  1678. act9 *= -1
  1679. end
  1680. if $back_attack && BACK_ATTACK
  1681. act0 *= -1
  1682. act3 *= -1
  1683. act4 *= -1
  1684. act9 *= -1
  1685. end
  1686. time = ANIME_PATTERN
  1687. if act2
  1688. self.z = @battler.position_z + 1
  1689. else
  1690. self.z = @battler.position_z - 1
  1691. end
  1692. if act6
  1693. if self.mirror
  1694. self.mirror = false
  1695. else
  1696. self.mirror = true
  1697. end
  1698. end
  1699. if @mirroring
  1700. if self.mirror
  1701. self.mirror = false
  1702. else
  1703. self.mirror = true
  1704. end
  1705. end
  1706. if $back_attack && BACK_ATTACK
  1707. if self.mirror
  1708. self.mirror = false
  1709. else
  1710. self.mirror = true
  1711. end
  1712. end
  1713. @moving_x = act0 / time
  1714. @moving_y = act1 / time
  1715. @angle = act3
  1716. self.angle = @angle
  1717. @angling = (act4 - act3)/ time
  1718. @angle += (act4 - act3) % time
  1719. @zooming_x = (1 - act7) / time
  1720. @zooming_y = (1 - act8) / time
  1721. if self.mirror
  1722. case act5
  1723. when 1
  1724. act5 = 2
  1725. when 2
  1726. act5 = 1
  1727. when 3
  1728. act5 = 4
  1729. when 4
  1730. act5 = 3
  1731. end
  1732. end
  1733. case act5
  1734. when 0
  1735. self.ox = @weapon_width / 2
  1736. self.oy = @weapon_height / 2
  1737. when 1
  1738. self.ox = 0
  1739. self.oy = 0
  1740. when 2
  1741. self.ox = @weapon_width
  1742. self.oy = 0
  1743. when 3
  1744. self.ox = 0
  1745. self.oy = @weapon_height
  1746. when 4
  1747. self.ox = @weapon_width
  1748. self.oy = @weapon_height
  1749. end
  1750. @plus_x = act9
  1751. @plus_y = act10
  1752. @loop = true if loop == 0
  1753. @angle -= @angling
  1754. @zoom_x -= @zooming_x
  1755. @zoom_y -= @zooming_y
  1756. @move_x -= @moving_x
  1757. @move_y -= @moving_y
  1758. @move_z = 1000 if act2
  1759. if @freeze != -1
  1760. for i in 0..@freeze + 1
  1761. @angle += @angling
  1762. @zoom_x += @zooming_x
  1763. @zoom_y += @zooming_y
  1764. @move_x += @moving_x
  1765. @move_y += @moving_y
  1766. end
  1767. @angling = 0
  1768. @zooming_x = 0
  1769. @zooming_y = 0
  1770. @moving_x = 0
  1771. @moving_y = 0
  1772. end
  1773. self.visible = true
  1774. end
  1775. end
  1776. #--------------------------------------------------------------------------
  1777. def action_reset
  1778. @moving_x = @moving_y = @move_x = @move_y = @plus_x = @plus_y = 0
  1779. @angling = @zooming_x = @zooming_y = @angle = self.angle = @move_z = 0
  1780. @zoom_x = @zoom_y = self.zoom_x = self.zoom_y = 1
  1781. self.mirror = self.visible = @loop = false
  1782. @freeze = -1
  1783. @action = []
  1784. @time = ANIME_PATTERN + 1
  1785. end
  1786. #--------------------------------------------------------------------------
  1787. def action_loop
  1788. @angling *= -1
  1789. @zooming_x *= -1
  1790. @zooming_y *= -1
  1791. @moving_x *= -1
  1792. @moving_y *= -1
  1793. end
  1794. #--------------------------------------------------------------------------
  1795. def mirroring
  1796. return @mirroring = false if @mirroring
  1797. @mirroring = true
  1798. end
  1799. #--------------------------------------------------------------------------
  1800. def action
  1801. return if @time <= 0
  1802. @time -= 1
  1803. @angle += @angling
  1804. @zoom_x += @zooming_x
  1805. @zoom_y += @zooming_y
  1806. @move_x += @moving_x
  1807. @move_y += @moving_y
  1808. if @loop && @time == 0
  1809. @time = ANIME_PATTERN + 1
  1810. action_loop
  1811. end
  1812. end
  1813. #--------------------------------------------------------------------------
  1814. def update
  1815. super
  1816. self.angle = @angle
  1817. self.zoom_x = @zoom_x
  1818. self.zoom_y = @zoom_y
  1819. self.x = @battler.position_x + @move_x + @plus_x
  1820. self.y = @battler.position_y + @move_y + @plus_y
  1821. self.z = @battler.position_z + @move_z - 1
  1822. end
  1823. end
  1824.  
  1825. #==============================================================================
  1826. # Game_Party
  1827. #==============================================================================
  1828. class Game_Party
  1829. #--------------------------------------------------------------------------
  1830. include N01
  1831. #--------------------------------------------------------------------------
  1832. def add_actor(actor_id)
  1833. actor = $game_actors[actor_id]
  1834. if @actors.size < MAX_MEMBER and not @actors.include?(actor)
  1835. @actors.push(actor)
  1836. $game_player.refresh
  1837. end
  1838. end
  1839. end
  1840.  
  1841. #==============================================================================
  1842. # ■ RPG::Weapon
  1843. #==============================================================================
  1844. class RPG::Weapon
  1845. #--------------------------------------------------------------------------
  1846. def magic?
  1847. return false
  1848. end
  1849. end
  1850.  
  1851. #==============================================================================
  1852. # ■ RPG::Skill
  1853. #==============================================================================
  1854. class RPG::Skill
  1855. #--------------------------------------------------------------------------
  1856. def magic?
  1857. return @atk_f == 0 ? true : false
  1858. end
  1859. end
  1860.  
  1861. #==============================================================================
  1862. # ■ RPG::Item
  1863. #==============================================================================
  1864. class RPG::Item
  1865. #--------------------------------------------------------------------------
  1866. def magic?
  1867. return false
  1868. end
  1869. end
  1870.  
  1871. #==============================================================================
  1872. # ■ RPG::Cache
  1873. #==============================================================================
  1874. module RPG::Cache
  1875. def self.faces(filename, hue = 0)
  1876. self.load_bitmap('Graphics/Faces/', filename, hue)
  1877. end
  1878. end
  1879.  
  1880. #==============================================================================
  1881. # ■ Game_Battler
  1882. #==============================================================================
  1883. class Game_Battler
  1884. #--------------------------------------------------------------------------
  1885. include N01
  1886. #--------------------------------------------------------------------------
  1887. attr_accessor :sp_damage
  1888. attr_accessor :collapse
  1889. attr_accessor :move_x
  1890. attr_accessor :move_y
  1891. attr_accessor :move_z
  1892. attr_accessor :jump
  1893. attr_accessor :active
  1894. attr_accessor :non_dead
  1895. attr_accessor :slip_damage
  1896. attr_accessor :derivation
  1897. attr_accessor :individual
  1898. attr_accessor :play
  1899. attr_accessor :force_action
  1900. attr_accessor :force_target
  1901. attr_accessor :revival
  1902. attr_accessor :reflex
  1903. attr_accessor :absorb
  1904. attr_accessor :anime_mirror
  1905. attr_accessor :dying
  1906. attr_accessor :state_animation_id
  1907. attr_accessor :dead_anim
  1908. attr_accessor :missed
  1909. attr_accessor :evaded
  1910. attr_accessor :true_immortal
  1911. attr_accessor :defense_pose
  1912. attr_reader :base_position_x
  1913. attr_reader :base_position_y
  1914. attr_reader :base_height
  1915. #--------------------------------------------------------------------------
  1916. alias initialize_n01 initialize
  1917. def initialize
  1918. initialize_n01
  1919. @move_x = @move_y = @move_z = @plus_y = @jump = @derivation = @act_time = 0
  1920. @force_action = @force_target = @base_position_x = @base_position_y = 0
  1921. @absorb = @play = @now_state = @state_frame = @state_animation_id = 0
  1922. @active = @non_dead = @individual = @slip_damage = @revival = false
  1923. @collapse = @sp_damage = @anime_mirror = @dying = false
  1924. @evaded = @missed = false
  1925. @anim_states = []
  1926. end
  1927. #--------------------------------------------------------------------------
  1928. def state_id
  1929. return @states[@states.size - 1]
  1930. end
  1931. #--------------------------------------------------------------------------
  1932. def in_danger
  1933. return @hp <= self.maxhp / 4
  1934. end
  1935. #--------------------------------------------------------------------------
  1936. def battler_states
  1937. bat_states = []
  1938. for i in self.states
  1939. bat_states.push($data_states[i])
  1940. end
  1941. return bat_states
  1942. end
  1943. #--------------------------------------------------------------------------
  1944. def apply_variance(damage, variance)
  1945. if damage != 0
  1946. amp = [damage.abs * variance / 100, 0].max
  1947. damage += rand(amp+1) + rand(amp+1) - amp
  1948. end
  1949. return damage
  1950. end
  1951. #--------------------------------------------------------------------------
  1952. def state_animation_id
  1953. return 0 if @states.empty?
  1954. return 0 if @states.include?(1)
  1955. @state_frame -= 1 if @state_frame > 0
  1956. return @state_animation_id if @state_frame > 0
  1957. if @anim_states.empty?
  1958. for state in @states
  1959. @anim_states << state if $data_states[state].animation_id > 0
  1960. end
  1961. end
  1962. now_state = @anim_states.shift
  1963. return 0 if now_state.nil?
  1964. @state_animation_id = $data_states[now_state].animation_id
  1965. return 0 if $data_animations[@state_animation_id].nil?
  1966. @state_frame = $data_animations[@state_animation_id].frame_max * STATE_CYCLE_TIME * 2
  1967. return @state_animation_id
  1968. end
  1969. #--------------------------------------------------------------------------
  1970. def skill_can_use?(skill_id)
  1971. skill = $data_skills[skill_id]
  1972. if skill.extension.include?("CONSUMEHP")
  1973. return false if calc_sp_cost(self, skill) >= self.hp
  1974. else
  1975. return false if calc_sp_cost(self, skill) > self.sp
  1976. end
  1977. return false if dead?
  1978. return false if skill.atk_f == 0 and self.restriction == 1
  1979. occasion = skill.occasion
  1980. return (occasion == 0 or occasion == 1) if $game_temp.in_battle
  1981. return (occasion == 0 or occasion == 2)
  1982. end
  1983. #--------------------------------------------------------------------------
  1984. def calc_sp_cost(user, skill)
  1985. cost = skill.sp_cost
  1986. if skill.extension.include?("%COSTMAX")
  1987. return user.maxhp * cost / 100 if skill.extension.include?("CONSUMEHP")
  1988. return user.maxsp * cost / 100
  1989. elsif skill.extension.include?("%COSTNOW")
  1990. return user.hp * cost / 100 if skill.extension.include?("CONSUMEHP")
  1991. return user.sp * cost / 100
  1992. end
  1993. return cost
  1994. end
  1995. #--------------------------------------------------------------------------
  1996. def consum_skill_cost(skill)
  1997. return false unless skill_can_use?(skill.id)
  1998. cost = calc_sp_cost(self, skill)
  1999. return self.hp -= cost if skill.extension.include?("CONSUMEHP")
  2000. return self.sp -= cost
  2001. end
  2002. #--------------------------------------------------------------------------
  2003. def attack_effect(attacker)
  2004. self.critical = @evaded = @missed = false
  2005. hit_result = (rand(100) < attacker.hit)
  2006. puts "hit result"
  2007. puts hit_result
  2008. set_attack_result(attacker) if hit_result
  2009. weapon = attacker.actor? ? $data_weapons[attacker.weapon_id] : nil
  2010. if hit_result
  2011. set_attack_state_change(attacker)
  2012. else
  2013. self.critical = false
  2014. @missed = true
  2015. end
  2016. self.damage = POP_EVA if @evaded
  2017. self.damage = POP_MISS if @missed
  2018. return true
  2019. end
  2020. #--------------------------------------------------------------------------
  2021. def perfect_attack_effect(attacker)
  2022. self.critical = @evaded = @missed = false
  2023. set_attack_result(attacker)
  2024. weapon = attacker.actor? ? $data_weapons[attacker.weapon_id] : nil
  2025. set_attack_state_change(attacker)
  2026. return true
  2027. end
  2028. #--------------------------------------------------------------------------
  2029. def set_attack_result(attacker)
  2030. set_attack_damage_value(attacker)
  2031. if self.damage > 0
  2032. self.damage /= 2 if self.guarding?
  2033. set_attack_critical(attacker)
  2034. set_critical_damage(attacker) if self.critical
  2035. end
  2036. apply_variance(15) if self.damage.abs > 0
  2037. set_attack_hit_value(attacker)
  2038. end
  2039. #--------------------------------------------------------------------------
  2040. #--------------------------------------------------------------------------
  2041. def set_attack_damage_value(attacker)
  2042. if attacker.atk > 0
  2043. atk = [(attacker.str * 2) + (attacker.atk * 3), 0].max
  2044. atk2 = atk - self.pdef
  2045. elsif attacker.atk == 0
  2046. atk = [(attacker.str * 2) + (attacker.atk * 3), 0].max
  2047. atk2 = (atk - self.pdef) / 2
  2048. end
  2049. if atk2 < 0 and elements_correct(attacker.element_set) != -100
  2050. atk2 = 0
  2051. end
  2052. self.damage = atk2
  2053. self.damage *= elements_correct(attacker.element_set)
  2054. self.damage /= 100
  2055. end
  2056. #--------------------------------------------------------------------------
  2057. def apply_variance(variance)
  2058. amp = [self.damage.abs * variance / 100, 1].max
  2059. self.damage += rand(amp + 1) + rand(amp + 1) - amp
  2060. end
  2061. #--------------------------------------------------------------------------
  2062. def set_attack_hit_value(attacker)
  2063. puts "EVA"
  2064. puts self.eva
  2065. puts "HIT"
  2066. puts attacker.dex
  2067. evade_chance = 8 * self.eva / attacker.dex
  2068. puts "evade chance"
  2069. puts evade_chance
  2070. if self.damage < 0
  2071. hit_chance = 100
  2072. else
  2073. hit_chance = 100 - evade_chance
  2074. end
  2075. puts "hit chance"
  2076. puts hit_chance
  2077. if self.cant_evade?
  2078. hit_chance = 100
  2079. end
  2080. puts "hit chance"
  2081. puts hit_chance
  2082. hit_result = (rand(100) < hit_chance)
  2083. puts hit_result
  2084. @evaded = true unless hit_result
  2085. end
  2086. #--------------------------------------------------------------------------
  2087. def set_attack_critical(attacker)
  2088. self.critical = rand(100) < attacker.luk - (self.luk / 2)
  2089. end
  2090. #--------------------------------------------------------------------------
  2091. #--------------------------------------------------------------------------
  2092. def set_critical_damage(attacker)
  2093. self.damage += self.damage
  2094. end
  2095. #--------------------------------------------------------------------------
  2096. def set_attack_state_change(attacker)
  2097. remove_states_shock
  2098. effective = apply_damage(attacker)
  2099. @state_changed = false
  2100. states_plus(attacker.plus_state_set)
  2101. states_minus(attacker.minus_state_set)
  2102. return effective
  2103. end
  2104. #--------------------------------------------------------------------------
  2105. def skill_effect(user, skill)
  2106. self.critical = @evaded = @missed = false
  2107. if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2108. ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2109. return false
  2110. end
  2111. effective = false
  2112. effective |= skill.common_event_id > 0
  2113. hit = skill.hit
  2114. hit *= set_skill_hit(user, skill)
  2115. hit_result = (rand(100) < hit)
  2116. effective |= hit < 100
  2117. effective |= set_skill_result(user, skill, effective) if hit_result
  2118. if hit_result
  2119. effective |= set_skill_state_change(user, skill, effective)
  2120. else
  2121. @missed = true unless @evaded
  2122. end
  2123. self.damage = nil unless $game_temp.in_battle
  2124. self.damage = POP_EVA if @evaded
  2125. self.damage = POP_MISS if @missed
  2126. return effective
  2127. end
  2128. #--------------------------------------------------------------------------
  2129. def perfect_skill_effect(user, skill)
  2130. self.critical = @evaded = @missed = false
  2131. if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2132. ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2133. return false
  2134. end
  2135. effective = false
  2136. effective |= skill.common_event_id > 0
  2137. effective |= set_skill_result(user, skill, effective)
  2138. effective |= set_skill_state_change(user, skill, effective)
  2139. self.damage = nil unless $game_temp.in_battle
  2140. return effective
  2141. end
  2142. #--------------------------------------------------------------------------
  2143. def set_skill_hit(user, skill)
  2144. if skill.magic?
  2145. return 1
  2146. else
  2147. return user.hit / 100
  2148. end
  2149. end
  2150. #--------------------------------------------------------------------------
  2151. def set_skill_result(user, skill, effective)
  2152. set_skill_damage_value(user, skill)
  2153. if self.damage > 0
  2154. self.damage /= 2 if self.guarding?
  2155. end
  2156. apply_variance(skill.variance) if skill.variance > 0 and self.damage.abs > 0
  2157. effective |= set_skill_hit_value(user, skill, effective)
  2158. return effective
  2159. end
  2160. #--------------------------------------------------------------------------
  2161. def set_skill_damage_value(user, skill)
  2162. power = set_skill_power(user, skill)
  2163. if power > 0
  2164. power -= (self.pdef * skill.pdef_f) / 200
  2165. power -= (self.mdef * skill.mdef_f) / 200
  2166. power = [power, 0].max
  2167. end
  2168. rate = set_skill_rate(user, skill)
  2169. rate = [rate, 0].max
  2170. self.damage = power * rate / 20
  2171. self.damage *= elements_correct(skill.element_set)
  2172. self.damage /= 100
  2173. end
  2174. #--------------------------------------------------------------------------
  2175. def set_skill_power(user, skill)
  2176. power = skill.power + ((user.atk * skill.atk_f) / 100)
  2177. end
  2178. #--------------------------------------------------------------------------
  2179. def set_skill_rate(user, skill)
  2180. rate = 20
  2181. rate += (user.str * skill.str_f / 100)
  2182. rate += (user.dex * skill.dex_f / 100)
  2183. rate += (user.agi * skill.agi_f / 100)
  2184. rate += (user.int * skill.int_f / 100)
  2185. return rate
  2186. end
  2187. #--------------------------------------------------------------------------
  2188. def set_skill_hit_value(user, skill, effective)
  2189. atk_hit = user.dex
  2190. eva = 8 * self.agi / atk_hit + self.eva
  2191. hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
  2192. hit = self.cant_evade? ? 100 : hit
  2193. hit_result = (rand(100) < hit)
  2194. @evaded = true unless hit_result
  2195. effective |= hit < 100
  2196. return effective
  2197. end
  2198. #--------------------------------------------------------------------------
  2199. def set_skill_state_change(user, skill, effective = false)
  2200. if skill.power != 0 and not skill.magic?
  2201. remove_states_shock
  2202. effective = true
  2203. end
  2204. effective |= apply_damage(user)
  2205. @state_changed = false
  2206. effective |= states_plus(skill.plus_state_set)
  2207. effective |= states_minus(skill.minus_state_set)
  2208. if skill.power == 0
  2209. self.damage = ""
  2210. @missed = true unless @state_changed
  2211. end
  2212. return effective
  2213. end
  2214. #--------------------------------------------------------------------------
  2215. def apply_damage(user)
  2216. return true if @evaded or @missed or not self.damage.is_a?(Numeric)
  2217. if self.sp_damage
  2218. last_sp = self.sp
  2219. self.sp -= self.damage
  2220. effective = self.sp != last_sp
  2221. else
  2222. last_hp = self.hp
  2223. self.hp -= self.damage
  2224. effective = self.hp != last_hp
  2225. end
  2226. return effective
  2227. end
  2228. #--------------------------------------------------------------------------
  2229. def item_effect(item, actor=nil)
  2230. self.critical = @evaded = @missed = false
  2231. if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  2232. ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  2233. return false
  2234. end
  2235. effective = false
  2236. effective |= item.common_event_id > 0
  2237. hit_result = (rand(100) < item.hit)
  2238. @missed = true unless hit_result
  2239. effective |= item.hit < 100
  2240. if hit_result == true
  2241. effective |= make_item_damage_value(item)
  2242. else
  2243. @missed = true
  2244. end
  2245. self.damage = nil unless $game_temp.in_battle
  2246. self.damage = POP_MISS if @missed
  2247. return effective
  2248. end
  2249. #--------------------------------------------------------------------------
  2250. def perfect_item_effect(item)
  2251. self.critical = @evaded = @missed = false
  2252. if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  2253. ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  2254. return false
  2255. end
  2256. effective = false
  2257. effective |= item.common_event_id > 0
  2258. effective |= item.hit < 100
  2259. effective |= make_item_damage_value(item)
  2260. self.damage = nil unless $game_temp.in_battle
  2261. self.damage = POP_MISS if @missed
  2262. return effective
  2263. end
  2264. #--------------------------------------------------------------------------
  2265. def make_item_damage_value(item)
  2266. recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  2267. recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  2268.  
  2269. if item.mdef_f == 100
  2270. recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  2271. recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  2272. puts "power"
  2273. puts recover_hp
  2274. defendrate = 0
  2275. defendrate += (user.pdef * skill.pdef_f / 100)
  2276. defendrate += (user.mdef * skill.mdef_f / 100)
  2277. puts "defend rate"
  2278. puts defendrate
  2279. damage = actor.base_int * 3
  2280. puts "damage"
  2281. puts damage
  2282. damage *= (recover_hp / 100)
  2283. puts "damage * power"
  2284. puts damage
  2285. damage -= defendrate
  2286. puts "minus defense"
  2287. puts damage
  2288. finaldamage = damage
  2289. puts ".to_i"
  2290. puts finaldamage
  2291. damage = finaldamage.to_i
  2292. puts damage
  2293. damage *= elements_correct(skill.element_set)
  2294. puts damage
  2295. damage /= 100
  2296. puts "elements"
  2297. puts damage
  2298. recover_hp = damage
  2299. else
  2300.  
  2301. if recover_hp < 0
  2302. recover_hp += self.pdef * item.pdef_f / 20
  2303. recover_hp += self.mdef * item.mdef_f / 20
  2304. recover_hp = [recover_hp, 0].min
  2305. end
  2306. recover_hp *= elements_correct(item.element_set)
  2307. recover_hp /= 100
  2308. recover_sp *= elements_correct(item.element_set)
  2309. recover_sp /= 100
  2310. if item.variance > 0 and recover_hp.abs > 0
  2311. amp = [recover_hp.abs * item.variance / 100, 1].max
  2312. recover_hp += rand(amp+1) + rand(amp+1) - amp
  2313. end
  2314. if item.variance > 0 and recover_sp.abs > 0
  2315. amp = [recover_sp.abs * item.variance / 100, 1].max
  2316. recover_sp += rand(amp+1) + rand(amp+1) - amp
  2317. end
  2318. recover_hp /= 2 if recover_hp < 0 and self.guarding?
  2319. self.damage = -recover_hp
  2320. last_hp = self.hp
  2321. last_sp = self.sp
  2322. self.hp += recover_hp
  2323. self.sp += recover_sp
  2324. effective |= self.hp != last_hp
  2325. effective |= self.sp != last_sp
  2326. @state_changed = false
  2327. effective |= states_plus(item.plus_state_set)
  2328. effective |= states_minus(item.minus_state_set)
  2329. if item.parameter_type > 0 and item.parameter_points != 0
  2330. case item.parameter_type
  2331. when 1
  2332. @maxhp_plus += item.parameter_points
  2333. when 2
  2334. @maxsp_plus += item.parameter_points
  2335. when 3
  2336. @str_plus += item.parameter_points
  2337. when 4
  2338. @dex_plus += item.parameter_points
  2339. when 5
  2340. @agi_plus += item.parameter_points
  2341. when 6
  2342. @int_plus += item.parameter_points
  2343. end
  2344. effective = true
  2345. end
  2346. if item.recover_hp_rate == 0 and item.recover_hp == 0
  2347. self.damage = ""
  2348. if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  2349. (item.parameter_type == 0 or item.parameter_points == 0)
  2350. unless @state_changed
  2351. @missed = true
  2352. end
  2353. end
  2354. end
  2355. end
  2356. return effective
  2357. end
  2358. #--------------------------------------------------------------------------
  2359. alias skill_effect_n01 skill_effect
  2360. def skill_effect(user, skill)
  2361. now_hp = self.hp
  2362. if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2363. ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2364. return false
  2365. end
  2366. effective = skill_effect_n01(user, skill)
  2367. return if effective == false
  2368. check_extension(skill)
  2369. if @ratio_maxdamage != nil
  2370. self.damage = self.maxhp * @ratio_maxdamage / 100 unless @sp_damage
  2371. self.damage = self.maxsp * @ratio_maxdamage / 100 if @sp_damage
  2372. end
  2373. if @ratio_nowdamage != nil
  2374. self.damage = self.hp * @ratio_nowdamage / 100 unless @sp_damage
  2375. self.damage = self.sp * @ratio_nowdamage / 100 if @sp_damage
  2376. end
  2377. if @cost_damage
  2378. cost = calc_sp_cost(user, skill)
  2379. if skill.extension.include?("CONSUMEHP")
  2380. self.damage = self.damage * cost / user.maxhp
  2381. else
  2382. self.damage = self.damage * cost / user.maxsp
  2383. end
  2384. end
  2385. self.damage = self.damage * user.hp / user.maxhp if @nowhp_damage
  2386. self.damage = self.damage * user.sp / user.maxsp if @nowsp_damage
  2387. if @sp_damage
  2388. self.hp = now_hp
  2389. self.sp -= self.damage
  2390. elsif @extension
  2391. self.hp = now_hp
  2392. self.hp -= self.damage
  2393. end
  2394. return true
  2395. end
  2396. #--------------------------------------------------------------------------
  2397. alias perfect_skill_effect_n01 perfect_skill_effect
  2398. def perfect_skill_effect(user, skill)
  2399. now_hp = self.hp
  2400. if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2401. ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2402. return false
  2403. end
  2404. effective = perfect_skill_effect_n01(user, skill)
  2405. return if effective == false
  2406. check_extension(skill)
  2407. if @ratio_maxdamage != nil
  2408. self.damage = self.maxhp * @ratio_maxdamage / 100 unless @sp_damage
  2409. self.damage = self.maxsp * @ratio_maxdamage / 100 if @sp_damage
  2410. end
  2411. if @ratio_nowdamage != nil
  2412. self.damage = self.hp * @ratio_nowdamage / 100 unless @sp_damage
  2413. self.damage = self.sp * @ratio_nowdamage / 100 if @sp_damage
  2414. end
  2415. if @cost_damage
  2416. cost = calc_sp_cost(user, skill)
  2417. if skill.extension.include?("CONSUMEHP")
  2418. self.damage = self.damage * cost / user.maxhp
  2419. else
  2420. self.damage = self.damage * cost / user.maxsp
  2421. end
  2422. end
  2423. self.damage = self.damage * user.hp / user.maxhp if @nowhp_damage
  2424. self.damage = self.damage * user.sp / user.maxsp if @nowsp_damage
  2425. if @sp_damage
  2426. self.hp = now_hp
  2427. self.sp -= self.damage
  2428. elsif @extension
  2429. self.hp = now_hp
  2430. self.hp -= self.damage
  2431. end
  2432. return true
  2433. end
  2434. #--------------------------------------------------------------------------
  2435. def check_extension(skill)
  2436. @extension = false
  2437. @sp_damage = false
  2438. @cost_damage = false
  2439. @nowhp_damage = false
  2440. @nowsp_damage = false
  2441. @ratio_maxdamage = nil
  2442. @ratio_nowdamage = nil
  2443. for ext in skill.extension
  2444. break if self.damage == "Errou!" or self.damage == "" or self.damage == 0
  2445. if ext == "SPDAMAGE"
  2446. next @sp_damage = true
  2447. elsif ext == "COSTPOWER"
  2448. @extension = true
  2449. next @cost_damage = true
  2450. elsif ext == "HPNOWPOWER"
  2451. @extension = true
  2452. next @nowhp_damage = true
  2453. elsif ext == "MPNOWPOWER"
  2454. @extension = true
  2455. next @nowsp_damage = true
  2456. else
  2457. name = ext.split('')
  2458. if name[7] == "M"
  2459. name = name.join
  2460. name.slice!("%DAMAGEMAX/")
  2461. @extension = true
  2462. next @ratio_maxdamage = name.to_i
  2463. elsif name[7] == "N"
  2464. name = name.join
  2465. name.slice!("%DAMAGENOW/")
  2466. @extension = true
  2467. next @ratio_nowdamage = name.to_i
  2468. end
  2469. end
  2470. end
  2471. end
  2472. #--------------------------------------------------------------------------
  2473. def change_base_position(x, y)
  2474. @base_position_x = x
  2475. @base_position_y = y
  2476. end
  2477. #--------------------------------------------------------------------------
  2478. def reset_coordinate
  2479. @move_x = @move_y = @move_z = @jump = @derivation = 0
  2480. @active = @non_dead = @individual = false
  2481. end
  2482. end
  2483.  
  2484. #==============================================================================
  2485. # ■ Game_Actor
  2486. #==============================================================================
  2487. class Game_Actor < Game_Battler
  2488. #--------------------------------------------------------------------------
  2489. attr_reader :armor5_id
  2490. attr_reader :armor6_id
  2491. attr_reader :armor7_id
  2492. attr_accessor :actor_height
  2493. attr_accessor :two_swords_change
  2494. #--------------------------------------------------------------------------
  2495. include N01
  2496. #--------------------------------------------------------------------------
  2497. def actor?
  2498. return true
  2499. end
  2500. #--------------------------------------------------------------------------
  2501. def weapons
  2502. return [$data_weapons[@weapon_id]]
  2503. end
  2504. #--------------------------------------------------------------------------
  2505. def armors
  2506. result = []
  2507. result << $data_armors[@armor1_id]
  2508. result << $data_armors[@armor2_id]
  2509. result << $data_armors[@armor3_id]
  2510. result << $data_armors[@armor4_id]
  2511. return result
  2512. end
  2513. #--------------------------------------------------------------------------
  2514. def equips
  2515. return weapons + armors
  2516. end
  2517. #--------------------------------------------------------------------------
  2518. def skill_id_learn?(skill_id)
  2519. return @skills.include?(skill_id)
  2520. end
  2521. #--------------------------------------------------------------------------
  2522. def exp=(exp)
  2523. @exp = [exp, 0].max
  2524. while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
  2525. @level += 1
  2526. for j in $data_classes[@class_id].learnings
  2527. if j.level == @level
  2528. learn_skill(j.skill_id)
  2529. end
  2530. end
  2531. end
  2532. while @exp < @exp_list[@level]
  2533. @level -= 1
  2534. end
  2535. @hp = [@hp, self.maxhp].min
  2536. @sp = [@sp, self.maxsp].min
  2537. end
  2538. #--------------------------------------------------------------------------
  2539. def base_atk
  2540. n = 0
  2541. for item in weapons.compact do n += item.atk end
  2542. n = UNARMED_ATTACK if weapons[0] == nil and weapons[1] == nil
  2543. return n
  2544. end
  2545. #--------------------------------------------------------------------------
  2546. def base_pdef
  2547. n = 0
  2548. for item in equips.compact do n += item.pdef end
  2549. return n
  2550. end
  2551. #--------------------------------------------------------------------------
  2552. def base_mdef
  2553. n = 0
  2554. for item in equips.compact do n += item.mdef end
  2555. return n
  2556. end
  2557. #--------------------------------------------------------------------------
  2558. def base_eva
  2559. n = 0
  2560. for item in armors.compact do n += item.eva end
  2561. return n
  2562. end
  2563. #--------------------------------------------------------------------------
  2564. def graphic_change(character_name)
  2565. @character_name = character_name
  2566. end
  2567. #--------------------------------------------------------------------------
  2568. def perform_collapse
  2569. $game_system.se_play($data_system.actor_collapse_se) if $game_temp.in_battle and dead?
  2570. end
  2571. #--------------------------------------------------------------------------
  2572. def base_position
  2573. base = ACTOR_POSITION[self.index]
  2574. @base_position_x = base[0]
  2575. @base_position_y = base[1]
  2576. @base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
  2577. end
  2578. #--------------------------------------------------------------------------
  2579. def actor_height
  2580. @base_height = 0 if CURSOR_TYPE != 1
  2581. @base_height = 72 if CURSOR_TYPE == 1
  2582. return @base_height
  2583. end
  2584. #--------------------------------------------------------------------------
  2585. def position_x
  2586. return 0 if self.index == nil
  2587. return @base_position_x + @move_x
  2588. end
  2589. #--------------------------------------------------------------------------
  2590. def position_y
  2591. return 0 if self.index == nil
  2592. return @base_position_y + @move_y + @jump
  2593. end
  2594. #--------------------------------------------------------------------------
  2595. def position_z
  2596. return 0 if self.index == nil
  2597. return position_y + @move_z - @jump + 200
  2598. end
  2599. end
  2600.  
  2601. #==============================================================================
  2602. # ■ Game_Enemy
  2603. #==============================================================================
  2604. class Game_Enemy < Game_Battler
  2605. #--------------------------------------------------------------------------
  2606. include N01
  2607. #--------------------------------------------------------------------------
  2608. attr_accessor :adj_speed
  2609. attr_accessor :act_time
  2610. #--------------------------------------------------------------------------
  2611. def actor?
  2612. return false
  2613. end
  2614. #--------------------------------------------------------------------------
  2615. def make_action_speed2(adj)
  2616. @adj_speed = @current_action.speed if @adj_speed == nil
  2617. @adj_speed = @adj_speed * adj / 100
  2618. end
  2619. #--------------------------------------------------------------------------
  2620. def perform_collapse
  2621. @force_action = ["N01collapse"] if $game_temp.in_battle and dead?
  2622. end
  2623. #--------------------------------------------------------------------------
  2624. def element_set2
  2625. return []
  2626. end
  2627. #--------------------------------------------------------------------------
  2628. def base_position
  2629. return if self.index == nil
  2630. bitmap = Bitmap.new("Graphics/Battlers/" + @battler_name) if !self.anime_on
  2631. bitmap = Bitmap.new("Graphics/Characters/" + @battler_name) if self.anime_on && WALK_ANIME
  2632. bitmap = Bitmap.new("Graphics/Characters/" + @battler_name + "_1") if self.anime_on && !WALK_ANIME
  2633. height = bitmap.height
  2634. @base_position_x = self.screen_x + self.position_plus[0]
  2635. @base_position_y = self.screen_y + self.position_plus[1] - height / 3 + 32
  2636. @base_position_x = 640 - self.screen_x - self.position_plus[0] if $back_attack and BACK_ATTACK_MIRROR
  2637. @base_height = 0 if CURSOR_TYPE == 0
  2638. @base_height = height / 3 + 64 if CURSOR_TYPE == 1 if !self.anime_on
  2639. @base_height = height /12 + 64 if CURSOR_TYPE == 1 if self.anime_on
  2640. @base_height = -(height / 3) if CURSOR_TYPE == 2 if !self.anime_on
  2641. @base_height = -(height /12) if CURSOR_TYPE == 2 if self.anime_on
  2642. bitmap.dispose
  2643. end
  2644. #--------------------------------------------------------------------------
  2645. def enemy_height
  2646. return @base_height
  2647. end
  2648. #--------------------------------------------------------------------------
  2649. def position_x
  2650. return @base_position_x - @move_x
  2651. end
  2652. #--------------------------------------------------------------------------
  2653. def position_y
  2654. return @base_position_y + @move_y + @jump
  2655. end
  2656. #--------------------------------------------------------------------------
  2657. def position_z
  2658. return position_y + @move_z - @jump + 200
  2659. end
  2660. end
  2661.  
  2662. #==============================================================================
  2663. # Arrow_Base
  2664. #==============================================================================
  2665. class Arrow_Base < Sprite
  2666. #--------------------------------------------------------------------------
  2667. include N01
  2668. #--------------------------------------------------------------------------
  2669. def update_multi_arrow
  2670. return if @arrows == nil or @arrows == []
  2671. @blink_count = (@blink_count + 1) % 40
  2672. if @blink_count < 20
  2673. @arrows[i].src_rect.set(128, 96, 32, 32) if @arrows[i] != nil
  2674. else
  2675. @arrows[i].src_rect.set(160, 96, 32, 32) if @arrows[i] != nil
  2676. end
  2677. end
  2678. end
  2679. #--------------------------------------------------------------------------
  2680. def dispose_multi_arrow
  2681. @arrows[i].dispose if @arrows[i] != nil
  2682. end
  2683. end
  2684. end
  2685.  
  2686. #==============================================================================
  2687. # Arrow_Enemy_All
  2688. #==============================================================================
  2689. class Arrow_Enemy_All < Arrow_Base
  2690. #--------------------------------------------------------------------------
  2691. def initialize(viewport)
  2692. super(viewport)
  2693. @arrows = []
  2694. for battler in $game_troop.enemies
  2695. if battler.exist?
  2696. @arrows[battler.index] = Arrow_Enemy.new(viewport)
  2697. @arrows[battler.index].index = battler.index
  2698. end
  2699. end
  2700. end
  2701. #--------------------------------------------------------------------------
  2702. def update_multi_arrow
  2703. super
  2704. enemy = $game_troop.enemies[i]
  2705. if enemy != nil && @arrows[i] != nil && @arrows[i].enemy != nil
  2706. @arrows[i].x = @arrows[i].enemy.position_x + CURSOR_POSITION[0]
  2707. @arrows[i].y = @arrows[i].enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
  2708. end
  2709. end
  2710. end
  2711. end
  2712.  
  2713. #==============================================================================
  2714. # Arrow_Actor_All
  2715. #==============================================================================
  2716. class Arrow_Actor_All < Arrow_Base
  2717. #--------------------------------------------------------------------------
  2718. def initialize(viewport)
  2719. super(viewport)
  2720. @arrows = []
  2721. for battler in $game_party.actors
  2722. if battler.exist?
  2723. @arrows[battler.index] = Arrow_Actor.new(viewport)
  2724. @arrows[battler.index].index = battler.index
  2725. end
  2726. end
  2727. end
  2728. #--------------------------------------------------------------------------
  2729. def update_multi_arrow
  2730. super
  2731. actor = $game_party.actors[i]
  2732. if actor != nil && @arrows[i] != nil && @arrows[i].actor != nil
  2733. @arrows[i].x = @arrows[i].actor.position_x + CURSOR_POSITION[0]
  2734. @arrows[i].y = @arrows[i].actor.position_y + CURSOR_POSITION[1] + actor.actor_height
  2735. end
  2736. end
  2737. end
  2738. end
  2739.  
  2740. #==============================================================================
  2741. # Arrow_Battler_All
  2742. #==============================================================================
  2743. class Arrow_Battler_All < Arrow_Base
  2744. #--------------------------------------------------------------------------
  2745. def initialize(viewport)
  2746. super(viewport)
  2747. @arrows = []
  2748. s = 0
  2749. for battler in $game_party.actors + $game_troop.enemies
  2750. @arrows[s] = Arrow_Actor.new(viewport) if battler.actor?
  2751. @arrows[s] = Arrow_Enemy.new(viewport) if battler.is_a?(Game_Enemy)
  2752. @arrows[s].index = battler.index
  2753. s += 1
  2754. end
  2755. end
  2756. #--------------------------------------------------------------------------
  2757. def update_multi_arrow
  2758. super
  2759. s = 0
  2760. if @arrows[i].is_a?(Arrow_Actor)
  2761. actor = $game_party.actors[i]
  2762. if @arrows[i].actor != nil
  2763. @arrows[i].x = @arrows[i].actor.position_x + CURSOR_POSITION[0]
  2764. @arrows[i].y = @arrows[i].actor.position_y + CURSOR_POSITION[1] + actor.actor_height
  2765. s += 1
  2766. end
  2767. elsif @arrows[i].is_a?(Arrow_Enemy)
  2768. enemy = $game_troop.enemies[i - s]
  2769. if @arrows[i].enemy != nil or @arrows[i] != nil
  2770. @arrows[i].x = @arrows[i].enemy.position_x + CURSOR_POSITION[0]
  2771. @arrows[i].y = @arrows[i].enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
  2772. end
  2773. end
  2774. end
  2775. end
  2776. end
  2777.  
  2778. #==============================================================================
  2779. # ■ Arrow_Enemy
  2780. #==============================================================================
  2781. class Arrow_Enemy < Arrow_Base
  2782. #--------------------------------------------------------------------------
  2783. def update
  2784. super
  2785. $game_troop.enemies.size.times do
  2786. break if self.enemy.exist?
  2787. @index += 1
  2788. @index %= $game_troop.enemies.size
  2789. end
  2790. if Input.repeat?(Input::RIGHT)
  2791. cursor_up if $back_attack
  2792. cursor_down unless $back_attack
  2793. end
  2794. if Input.repeat?(Input::LEFT)
  2795. cursor_up unless $back_attack
  2796. cursor_down if $back_attack
  2797. end
  2798. if Input.repeat?(Input::UP)
  2799. cursor_down
  2800. end
  2801. if Input.repeat?(Input::DOWN)
  2802. cursor_up
  2803. end
  2804. if self.enemy != nil
  2805. self.x = self.enemy.position_x + CURSOR_POSITION[0]
  2806. self.y = self.enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
  2807. end
  2808. end
  2809. #--------------------------------------------------------------------------
  2810. def cursor_up
  2811. $game_system.se_play($data_system.cursor_se)
  2812. $game_troop.enemies.size.times do
  2813. @index += $game_troop.enemies.size - 1
  2814. @index %= $game_troop.enemies.size
  2815. break if self.enemy.exist?
  2816. end
  2817. end
  2818. #--------------------------------------------------------------------------
  2819. def cursor_down
  2820. $game_system.se_play($data_system.cursor_se)
  2821. $game_troop.enemies.size.times do
  2822. @index += 1
  2823. @index %= $game_troop.enemies.size
  2824. break if self.enemy.exist?
  2825. end
  2826. end
  2827. end
  2828.  
  2829. #==============================================================================
  2830. # ■ Arrow_Actor
  2831. #==============================================================================
  2832. class Arrow_Actor < Arrow_Base
  2833. #--------------------------------------------------------------------------
  2834. def update
  2835. super
  2836. if Input.repeat?(Input::RIGHT)
  2837. cursor_up if $back_attack
  2838. cursor_down unless $back_attack
  2839. end
  2840. if Input.repeat?(Input::LEFT)
  2841. cursor_up unless $back_attack
  2842. cursor_down if $back_attack
  2843. end
  2844. if Input.repeat?(Input::UP)
  2845. cursor_up
  2846. end
  2847. if Input.repeat?(Input::DOWN)
  2848. cursor_down
  2849. end
  2850. if self.actor != nil
  2851. self.x = self.actor.position_x + CURSOR_POSITION[0]
  2852. self.y = self.actor.position_y + CURSOR_POSITION[1] + actor.actor_height
  2853. end
  2854. end
  2855. #--------------------------------------------------------------------------
  2856. def cursor_up
  2857. $game_system.se_play($data_system.cursor_se)
  2858. @index += $game_party.actors.size - 1
  2859. @index %= $game_party.actors.size
  2860. end
  2861. #--------------------------------------------------------------------------
  2862. def cursor_down
  2863. $game_system.se_play($data_system.cursor_se)
  2864. @index += 1
  2865. @index %= $game_party.actors.size
  2866. end
  2867. #--------------------------------------------------------------------------
  2868. def input_right
  2869. @index += 1
  2870. @index %= $game_party.actors.size
  2871. end
  2872. #--------------------------------------------------------------------------
  2873. def input_update_target
  2874. if Input.repeat?(Input::RIGHT)
  2875. if @index == self.actor.index
  2876. cursor_up if $back_attack
  2877. cursor_down unless $back_attack
  2878. end
  2879. end
  2880. if Input.repeat?(Input::LEFT)
  2881. if @index == self.actor.index
  2882. cursor_up unless $back_attack
  2883. cursor_down if $back_attack
  2884. end
  2885. end
  2886. if Input.repeat?(Input::UP)
  2887. cursor_up if @index == self.actor.index
  2888. end
  2889. if Input.repeat?(Input::DOWN)
  2890. cursor_down if @index == self.actor.index
  2891. end
  2892. if self.actor != nil
  2893. self.x = self.actor.screen_x
  2894. self.y = self.actor.screen_y
  2895. end
  2896. end
  2897. end
  2898.  
  2899. #==============================================================================
  2900. # ■ Game_Troop
  2901. #==============================================================================
  2902. class Game_Troop
  2903. def clear_actions
  2904. for enemies in @enemies
  2905. enemies.current_action.clear
  2906. end
  2907. end
  2908. end
  2909.  
  2910. #==============================================================================
  2911. # ■ Window_Command
  2912. #==============================================================================
  2913. class Window_Command < Window_Selectable
  2914. #--------------------------------------------------------------------------
  2915. attr_accessor :commands
  2916. end
  2917.  
  2918. #==============================================================================
  2919. # ■ Window_Base
  2920. #==============================================================================
  2921. class Window_Base < Window
  2922. #--------------------------------------------------------------------------
  2923. include N01
  2924. #--------------------------------------------------------------------------
  2925. def draw_actor_state(actor, x, y, width = 0)
  2926. status_icon = []
  2927. for i in actor.states
  2928. if $data_states[i].rating >= 1
  2929. begin
  2930. status_icon.push(RPG::Cache.icon($data_states[i].name + "_st"))
  2931. break if status_icon.size > (Icon_max - 1)
  2932. rescue
  2933. end
  2934. end
  2935. end
  2936. for icon in status_icon
  2937. self.contents.blt(x + X_Adjust, y + Y_Adjust + 4, icon, Rect.new(0, 0, Icon_X, Icon_Y), 255)
  2938. x += Icon_X + 2
  2939. end
  2940. end
  2941. #--------------------------------------------------------------------------
  2942. def draw_actor_parameter(actor, x, y, type)
  2943. case type
  2944. when 0
  2945. parameter_name = $data_system.words.atk
  2946. parameter_value = actor.atk
  2947. when 1
  2948. parameter_name = $data_system.words.pdef
  2949. parameter_value = actor.pdef
  2950. when 2
  2951. parameter_name = $data_system.words.mdef
  2952. parameter_value = actor.mdef
  2953. when 3
  2954. parameter_name = $data_system.words.str
  2955. parameter_value = actor.str
  2956. when 4
  2957. parameter_name = (DAMAGE_ALGORITHM_TYPE == 0 ? STAT_VIT : $data_system.words.dex)
  2958. parameter_value = actor.dex
  2959. when 5
  2960. parameter_name = $data_system.words.agi
  2961. parameter_value = actor.agi
  2962. when 6
  2963. parameter_name = $data_system.words.int
  2964. parameter_value = actor.int
  2965. when 7
  2966. parameter_name = STAT_EVA
  2967. parameter_value = actor.eva
  2968. end
  2969. self.contents.font.color = system_color
  2970. self.contents.draw_text(x, y, 120, 32, parameter_name)
  2971. self.contents.font.color = normal_color
  2972. self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
  2973. end
  2974. end
  2975.  
  2976. #==============================================================================
  2977. # ■ Window_Help
  2978. #==============================================================================
  2979. class Window_Help < Window_Base
  2980. #--------------------------------------------------------------------------
  2981. def initialize
  2982. super(0, 0, 640, 64)
  2983. self.contents = Bitmap.new(width - 32, height - 32)
  2984. self.z = 2000 if $game_temp.in_battle
  2985. self.back_opacity = HELP_OPACITY if $game_temp.in_battle
  2986. end
  2987. #--------------------------------------------------------------------------
  2988. def set_text_update(text, align = 0)
  2989. self.contents.clear
  2990. self.contents.font.color = normal_color
  2991. self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
  2992. @text = text
  2993. @align = align
  2994. @actor = nil
  2995. self.visible = true
  2996. end
  2997. #--------------------------------------------------------------------------
  2998. def set_enemy(enemy)
  2999. text = enemy.name
  3000. set_text_update(text, 1)
  3001. text_width = self.contents.text_size(text).width
  3002. x = (text_width + self.width)/2
  3003. status_icon = []
  3004. for i in enemy.states
  3005. if $data_states[i].rating >= 1
  3006. begin
  3007. status_icon.push(RPG::Cache.icon($data_states[i].name + "_st"))
  3008. break if status_icon.size > (Icon_max - 1)
  3009. rescue
  3010. end
  3011. end
  3012. end
  3013. for icon in status_icon
  3014. self.contents.blt(x + X_Adjust, y + Y_Adjust + 4, icon, Rect.new(0, 0, Icon_X, Icon_Y), 255)
  3015. x += Icon_X + 2
  3016. end
  3017. end
  3018. end
  3019.  
  3020. #==============================================================================
  3021. # ■ Window_Skill
  3022. #==============================================================================
  3023. class Window_Skill < Window_Selectable
  3024. #--------------------------------------------------------------------------
  3025. def initialize(actor)
  3026. super(0, 128, 640, 352)
  3027. @actor = actor
  3028. @column_max = 2
  3029. refresh
  3030. self.index = 0
  3031. if $game_temp.in_battle
  3032. self.y = 320
  3033. self.height = 160
  3034. self.z = 2100
  3035. self.back_opacity = MENU_OPACITY
  3036. end
  3037. end
  3038. #--------------------------------------------------------------------------
  3039. def draw_item(index)
  3040. skill = @data[index]
  3041. if @actor.skill_can_use?(skill.id)
  3042. self.contents.font.color = normal_color
  3043. else
  3044. self.contents.font.color = disabled_color
  3045. end
  3046. x = 4 + index % 2 * (288 + 32)
  3047. y = index / 2 * 32
  3048. rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  3049. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  3050. bitmap = RPG::Cache.icon(skill.icon_name)
  3051. opacity = self.contents.font.color == normal_color ? 255 : 128
  3052. self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  3053. self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  3054. cost = @actor.calc_sp_cost(@actor, skill)
  3055. self.contents.draw_text(x + 232, y, 48, 32, cost.to_s, 2)
  3056. end
  3057. end
  3058.  
  3059. #==============================================================================
  3060. # ■ Window_Item
  3061. #==============================================================================
  3062. class Window_Item < Window_Selectable
  3063. #--------------------------------------------------------------------------
  3064. def initialize
  3065. super(0, 64, 640, 416)
  3066. @column_max = 2
  3067. refresh
  3068. self.index = 0
  3069. if $game_temp.in_battle
  3070. self.y = 320
  3071. self.height = 160
  3072. self.z = 2100
  3073. self.back_opacity = MENU_OPACITY
  3074. end
  3075. end
  3076. end
  3077.  
  3078. #==============================================================================
  3079. # ■ Window_PartyCommand
  3080. #==============================================================================
  3081. class Window_PartyCommand < Window_Selectable
  3082. #--------------------------------------------------------------------------
  3083. alias initialize_n01 initialize
  3084. #--------------------------------------------------------------------------
  3085. def initialize
  3086. initialize_n01
  3087. self.z = 2000
  3088. end
  3089. end
  3090.  
  3091. #==============================================================================
  3092. # ■ Window_BattleStatus
  3093. #==============================================================================
  3094. class Window_BattleStatus < Window_Base
  3095. #--------------------------------------------------------------------------
  3096. def initialize
  3097. super(0, 320, 640, 160)
  3098. self.contents = Bitmap.new(width - 32, height - 32)
  3099. @level_up_flags = []
  3100. for i in 0...$game_party.actors.size
  3101. @level_up_flags.push(false)
  3102. end
  3103. self.z = 2000
  3104. self.opacity = STATUS_OPACITY
  3105. refresh
  3106. end
  3107. #--------------------------------------------------------------------------
  3108. def update
  3109. super
  3110. end
  3111. end
  3112.  
  3113. #==============================================================================
  3114. # ■ Window_NameCommand
  3115. #==============================================================================
  3116. class Window_BattleResult < Window_Base
  3117. #--------------------------------------------------------------------------
  3118. def initialize(exp, gold, treasures)
  3119. @exp = exp
  3120. @gold = gold
  3121. @treasures = treasures
  3122. super(160, 0, 320, @treasures.size * 32 + 64)
  3123. self.contents = Bitmap.new(width - 32, height - 32)
  3124. self.y = 160 - height / 2
  3125. self.back_opacity = 160
  3126. self.z = 2000
  3127. self.visible = false
  3128. refresh
  3129. end
  3130. end
  3131.  
  3132. #==============================================================================
  3133. # ■ Window_NameCommand
  3134. #==============================================================================
  3135. class Window_NameCommand < Window_Base
  3136. #--------------------------------------------------------------------------
  3137. def initialize(actor, x, y)
  3138. super(x, y, 160, 64)
  3139. self.contents = Bitmap.new(width - 32, height - 32)
  3140. self.contents.font.name = Font.default_name
  3141. self.z = 2000
  3142. self.back_opacity = COMMAND_OPACITY
  3143. refresh(actor)
  3144. end
  3145. #--------------------------------------------------------------------------
  3146. def refresh(actor)
  3147. self.contents.clear
  3148. self.contents.font.color = normal_color
  3149. self.contents.draw_text(0, 0, 128, 32, actor.name, 1) if actor != nil
  3150. end
  3151. end
  3152.  
  3153. #==============================================================================
  3154. # ■ RPG::Sprite
  3155. #==============================================================================
  3156. class RPG::Sprite < ::Sprite
  3157. #--------------------------------------------------------------------------
  3158. include N01
  3159. #--------------------------------------------------------------------------
  3160. def initialize(viewport = nil)
  3161. super(viewport)
  3162. @_whiten_duration = 0
  3163. @_appear_duration = 0
  3164. @_escape_duration = 0
  3165. @_collapse_duration = 0
  3166. @_damage_duration = 0
  3167. @_animation_duration = 0
  3168. @_blink = false
  3169. @_damage_durations = []
  3170. @time = 0
  3171. end
  3172. #--------------------------------------------------------------------------
  3173. def appear
  3174. end
  3175. #--------------------------------------------------------------------------
  3176. def escape
  3177. end
  3178. #--------------------------------------------------------------------------
  3179. def collapse
  3180. end
  3181. #--------------------------------------------------------------------------
  3182. def damage(value, critical, sp_damage = nil)
  3183. dispose_damage(0...@_damage_durations.size)
  3184. @_damage_sprites = []
  3185. if value.is_a?(Numeric)
  3186. damage_string = value.abs.to_s
  3187. else
  3188. damage_string = value.to_s
  3189. end
  3190. @damage_size = 1 if !MULTI_POP
  3191. @damage_size = damage_string.size if MULTI_POP
  3192. for i in 0...@damage_size
  3193. letter = damage_string[i..i] if MULTI_POP
  3194. letter = damage_string if !MULTI_POP
  3195. bitmap = Bitmap.new(160, 48)
  3196. bitmap.font.name = DAMAGE_FONT
  3197. bitmap.font.size = DMG_F_SIZE
  3198. bitmap.font.color.set(0, 0, 0)
  3199. bitmap.draw_text(-1, 12-1,160, 36, letter, 1)
  3200. bitmap.draw_text(+1, 12-1,160, 36, letter, 1)
  3201. bitmap.draw_text(-1, 12+1,160, 36, letter, 1)
  3202. bitmap.draw_text(+1, 12+1,160, 36, letter, 1)
  3203. if value.is_a?(Numeric) and value < 0
  3204. bitmap.font.color.set(HP_REC_COLOR[0],HP_REC_COLOR[1],HP_REC_COLOR[2]) if !sp_damage
  3205. bitmap.font.color.set(SP_REC_COLOR[0],SP_REC_COLOR[1],SP_REC_COLOR[2]) if sp_damage
  3206. else
  3207. bitmap.font.color.set(HP_DMG_COLOR[0],HP_DMG_COLOR[1],HP_DMG_COLOR[2]) if !sp_damage
  3208. bitmap.font.color.set(SP_DMG_COLOR[0],SP_DMG_COLOR[1],SP_DMG_COLOR[2]) if sp_damage
  3209. bitmap.font.color.set(CRT_DMG_COLOR[0],CRT_DMG_COLOR[1],CRT_DMG_COLOR[2]) if critical
  3210. end
  3211. bitmap.draw_text(0, 12,160, 36, letter, 1)
  3212. if critical and CRITIC_TEXT and i == 0
  3213. x_pop = (MULTI_POP ? (damage_string.size - 1) * (DMG_SPACE / 2) : 0)
  3214. bitmap.font.size = ((DMG_F_SIZE * 2) / 3).to_i
  3215. bitmap.font.color.set(0, 0, 0)
  3216. bitmap.draw_text(-1 + x_pop, -1, 160, 20, POP_CRI, 1)
  3217. bitmap.draw_text(+1 + x_pop, -1, 160, 20, POP_CRI, 1)
  3218. bitmap.draw_text(-1 + x_pop, +1, 160, 20, POP_CRI, 1)
  3219. bitmap.draw_text(+1 + x_pop, +1, 160, 20, POP_CRI, 1)
  3220. bitmap.font.color.set(CRT_TXT_COLOR[0],CRT_TXT_COLOR[1],CRT_TXT_COLOR[2]) if critical
  3221. bitmap.draw_text(0 + x_pop, 0, 160, 20, POP_CRI, 1)
  3222. end
  3223. if critical and CRITIC_FLASH
  3224. $game_screen.start_flash(Color.new(255, 255, 255, 255),10)
  3225. end
  3226. @_damage_sprites[i] = ::Sprite.new(self.viewport)
  3227. @_damage_sprites[i].bitmap = bitmap
  3228. @_damage_sprites[i].ox = 80
  3229. @_damage_sprites[i].oy = 20
  3230. @_damage_sprites[i].x = self.x + i * DMG_SPACE
  3231. @_damage_sprites[i].y = self.y - self.oy / 2
  3232. @_damage_sprites[i].z = DMG_DURATION + 3000 + i * 2
  3233. end
  3234. end
  3235. #--------------------------------------------------------------------------
  3236. def dispose
  3237. dispose_damage(0...@_damage_durations.size)
  3238. dispose_animation
  3239. dispose_loop_animation
  3240. if @damage_sprites != nil
  3241. for damage_sprite in @damage_sprites
  3242. damage_sprite.dispose
  3243. end
  3244. end
  3245. super
  3246. end
  3247. #--------------------------------------------------------------------------
  3248. def update
  3249. super
  3250. @damage_sprites = [] if @damage_sprites.nil?
  3251. @damage_durations = [] if @damage_durations.nil?
  3252. if @_damage_sprites != nil
  3253. for sprite in @_damage_sprites
  3254. if sprite != nil and sprite.visible
  3255. x = DMG_X_MOVE
  3256. y = DMG_Y_MOVE
  3257. d = sprite.z - 3000
  3258. m = self.mirror
  3259. @damage_sprites.push(Sprite_Damage.new(sprite, x, y, d, m))
  3260. sprite.visible = false
  3261. end
  3262. end
  3263. end
  3264. for damage_sprite in @damage_sprites
  3265. damage_sprite.update
  3266. end
  3267. for i in 0...@damage_sprites.size
  3268. @damage_sprites[i] = nil if @damage_sprites[i].disposed?
  3269. end
  3270. @damage_sprites.compact!
  3271. if @_whiten_duration > 0
  3272. @_whiten_duration -= 1
  3273. self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  3274. end
  3275. if @_animation != nil and (Graphics.frame_count % 2 == 0)
  3276. @_animation_duration -= 1
  3277. update_animation
  3278. end
  3279. if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  3280. update_loop_animation
  3281. @_loop_animation_index += 1
  3282. @_loop_animation_index %= @_loop_animation.frame_max
  3283. end
  3284. if @_blink
  3285. @_blink_count = (@_blink_count + 1) % 32
  3286. if @_blink_count < 16
  3287. alpha = (16 - @_blink_count) * 6
  3288. else
  3289. alpha = (@_blink_count - 16) * 6
  3290. end
  3291. self.color.set(255, 255, 255, alpha)
  3292. end
  3293. @@_animations.clear
  3294. end
  3295. #--------------------------------------------------------------------------
  3296. def dispose_damage(index)
  3297. return if @_damage_sprites == nil
  3298. if @_damage_sprites[index].is_a?(::Sprite) and @_damage_sprites[index].bitmap != nil
  3299. @_damage_sprites[index].bitmap.dispose
  3300. @_damage_sprites[index].dispose
  3301. @_damage_durations[index] = 0
  3302. end
  3303. end
  3304. #--------------------------------------------------------------------------
  3305. def dispose_animation
  3306. if @_animation_sprites != nil
  3307. sprite = @_animation_sprites[0]
  3308. if sprite != nil
  3309. @@_reference_count[sprite.bitmap] -= 1
  3310. if @@_reference_count[sprite.bitmap] == 0
  3311. sprite.bitmap.dispose
  3312. end
  3313. end
  3314. for sprite in @_animation_sprites
  3315. sprite.dispose
  3316. end
  3317. @_animation_sprites = nil
  3318. @_animation = nil
  3319. end
  3320. @mirror = false
  3321. end
  3322. #--------------------------------------------------------------------------
  3323. def animation_mirror(mirror_effect)
  3324. @mirror = mirror_effect
  3325. end
  3326. #--------------------------------------------------------------------------
  3327. def animation_set_sprites(sprites, cell_data, position)
  3328. for i in 0..15
  3329. sprite = sprites[i]
  3330. pattern = cell_data[i, 0]
  3331. if sprite == nil or pattern == nil or pattern == -1
  3332. sprite.visible = false if sprite != nil
  3333. next
  3334. end
  3335. sprite.visible = true
  3336. sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  3337. if position == 3
  3338. if self.viewport != nil
  3339. sprite.x = self.viewport.rect.width / 2
  3340. sprite.y = self.viewport.rect.height - 160
  3341. else
  3342. sprite.x = 320
  3343. sprite.y = 240
  3344. end
  3345. else
  3346. sprite.x = self.x - self.ox + self.src_rect.width / 2
  3347. sprite.y = self.y - self.oy + self.src_rect.height / 2
  3348. sprite.y -= self.src_rect.height / 4 if position == 0
  3349. sprite.y += self.src_rect.height / 4 if position == 2
  3350. end
  3351. sprite.x += cell_data[i, 1]
  3352. sprite.y += cell_data[i, 2]
  3353. sprite.z = 2000
  3354. if @mirror
  3355. sprite.ox = 88
  3356. else
  3357. sprite.ox = 104
  3358. end
  3359. sprite.oy = 96
  3360. sprite.zoom_x = cell_data[i, 3] / 100.0
  3361. sprite.zoom_y = cell_data[i, 3] / 100.0
  3362. sprite.angle = cell_data[i, 4]
  3363. sprite.mirror = (cell_data[i, 5] == 1)
  3364. if @mirror
  3365. if sprite.mirror
  3366. sprite.mirror = false
  3367. else
  3368. sprite.mirror = true
  3369. end
  3370. end
  3371. sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  3372. sprite.blend_type = cell_data[i, 7]
  3373. end
  3374. end
  3375. end
  3376.  
  3377. #==============================================================================
  3378. # ■ Sprite_Damage
  3379. #==============================================================================
  3380. class Sprite_Damage < Sprite
  3381. #--------------------------------------------------------------------------
  3382. include N01
  3383. #--------------------------------------------------------------------------
  3384. def initialize(sprite, init_x_speed, init_y_speed, duration, mirror)
  3385. super(nil)
  3386. self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
  3387. self.opacity = 255
  3388. self.x = sprite.x
  3389. self.y = sprite.y
  3390. self.z = 3000
  3391. self.ox = sprite.ox
  3392. self.oy = sprite.oy
  3393. @damage_mirror = mirror
  3394. @now_x_speed = init_x_speed
  3395. @now_y_speed = init_y_speed
  3396. @potential_x_energy = 0.0
  3397. @potential_y_energy = 0.0
  3398. @duration = duration
  3399. end
  3400. #--------------------------------------------------------------------------
  3401. def update
  3402. @duration -= 1
  3403. return unless @duration <= DMG_DURATION
  3404. super
  3405. n = self.oy + @now_y_speed
  3406. if n <= 0
  3407. @now_y_speed *= -1
  3408. @now_y_speed /= 2
  3409. @now_x_speed /= 2
  3410. end
  3411. self.oy = [n, 0].max
  3412. @potential_y_energy += DMG_GRAVITY
  3413. speed = @potential_y_energy.floor
  3414. @now_y_speed -= speed
  3415. @potential_y_energy -= speed
  3416. @potential_x_energy += @now_x_speed if @damage_mirror if POP_MOVE
  3417. @potential_x_energy -= @now_x_speed if !@damage_mirror if POP_MOVE
  3418. speed = @potential_x_energy.floor
  3419. self.ox += speed
  3420. @potential_x_energy -= speed
  3421. case @duration
  3422. when 1..10
  3423. self.opacity -= 25
  3424. when 0
  3425. self.dispose
  3426. end
  3427. end
  3428. end
Advertisement
Add Comment
Please, Sign In to add comment