Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.18 KB | None | 0 0
  1. #------------------------------------------------------------------------------#
  2. # Galv's Animated Battlers
  3. #------------------------------------------------------------------------------#
  4. # For: RPGMAKER VX ACE
  5. # Version 1.3
  6. #------------------------------------------------------------------------------#
  7. # 2014-06-20 - Version 1.3 - added ability to change actor battle x,y positions
  8. # 2014-01-17 - Version 1.2 - compatibility fix when using with Actor Duel Game
  9. # 2013-05-06 - Version 1.1 - added move speed for melee attacks
  10. # 2013-05-04 - Version 1.0 - release
  11. #------------------------------------------------------------------------------#
  12. # Holder's animated battler spritesheets can be found here:
  13. # http://animatedbattlers.wordpress.com/
  14. #------------------------------------------------------------------------------#
  15. # This is just another animated battler script that uses holder-style animated
  16. # battler sheets. There are better ones out there, this one is just my basic
  17. # implementation in an attempt to continue improving my scripting.
  18. #
  19. # This script works in the default battle system but is optimised for use with
  20. # Yanfly's battle script. Not tested with other battle scripts. Put this script
  21. # below any battle scripts you try it with.
  22. #------------------------------------------------------------------------------#
  23.  
  24. #------------------------------------------------------------------------------#
  25. # Note tag for ENEMIES and ACTORS
  26. #------------------------------------------------------------------------------#
  27. #
  28. # <battler: filename> # filename is the animated spritesheet located in
  29. # # /Graphics/Battlers/
  30. # # Required for actors, optional for enemies.
  31. #
  32. # <stationary_sub> # will not re-position themselves in front of an ally
  33. # # they are covering/substituting for.
  34. #
  35. #------------------------------------------------------------------------------#
  36.  
  37. #------------------------------------------------------------------------------#
  38. # Note tags for SKILLS, ITEMS and STATES
  39. #------------------------------------------------------------------------------#
  40. #
  41. # <pose: x> # The skill, item or state will use x pose row.
  42. # # If a skill does not have this tag, it will use row 6.
  43. # # If an item does not have this tag, it will use row 5.
  44. # # If a state does not have this tag, it will use row 2. If a
  45. # # battler has multiple states, it uses the highest priority.
  46. #
  47. #------------------------------------------------------------------------------#
  48.  
  49. #------------------------------------------------------------------------------#
  50. # Note tag for SKILLS, ITEMS and ACTORS
  51. #------------------------------------------------------------------------------#
  52. #
  53. # <melee: x> # Normal attacks for Actors, items being used or skills being
  54. # # used that have this tag will make the actor dash into close
  55. # # range before doing the action. x is the dash speed.
  56. # # 0 = instant. 1 is slow, higher numbers is faster
  57. #
  58. #------------------------------------------------------------------------------#
  59.  
  60. #------------------------------------------------------------------------------#
  61. # SCRIPT CALLS
  62. #------------------------------------------------------------------------------#
  63. #
  64. # change_battler(id,"filename") # Changes actor's animated battler sheet.
  65. #
  66. #------------------------------------------------------------------------------#
  67.  
  68. ($imported ||= {})["Galv_Animated_Battlers"] = true
  69. module GALV_BAT
  70.  
  71. #-------------------------------------------------------------------------------
  72. #
  73. # * SETTINGS
  74. #
  75. #-------------------------------------------------------------------------------
  76.  
  77. COLS = 4 # How many columns your animated spritesheet uses
  78. ROWS = 14 # How many rows your animated spritesheet uses
  79.  
  80. ENEMY_FLIP = true # true = flip enemy battler image horizontally
  81. ACTOR_FLIP = false # true = flip actor battler image horizonatally
  82.  
  83. HP_CRISIS = 0.25 # Remaining hp before poor status pose (0.25 = 25%)
  84.  
  85. ONE_ANIM = [3,4,5,6,7,11,12] # Poses that will NOT keep repeating their frames
  86.  
  87.  
  88. XOFFSET = 80 # horizonatal distance from opponent when using <melee: x>
  89. YOFFSET = 0 # vertical distance from opponent when using <melee: x>
  90.  
  91. SXOFFSET = 40 # horizontal distance from ally when substituting
  92. SYOFFSET = 0 # vertical distance from ally when substituting
  93.  
  94. #------------------------------------------------------------------------------#
  95. ACTOR_POSITIONS = [ # don't touch
  96. #------------------------------------------------------------------------------#
  97. # Default x,y locations of your actors on the battle screen
  98. #------------------------------------------------------------------------------#
  99.  
  100. [440,350], # Party member 1 [x,y] z = 0
  101. [460,180], # Party member 2 [x,y] z = 1
  102. [480,210], # Party member 3 [x,y] z = 2
  103. [500,260], # Party member 4 [x,y] z = 3
  104.  
  105. # You can change these in game by using the z value above for each position.
  106. # script call:
  107. # $game_system.b_positions[z] = [x,y]
  108. #
  109. # eg. To change position of party member 3 to x 500 and y 300
  110. # $game_system.b_positions[2] = [500,300]
  111.  
  112. #------------------------------------------------------------------------------#
  113. ] #don't touch
  114. #------------------------------------------------------------------------------#
  115.  
  116. #-------------------------------------------------------------------------------
  117. # POSES USED FOR SPECIAL ACTIONS:
  118. #-------------------------------------------------------------------------------
  119.  
  120. COUNTER_ATTACK = 4 # Pose when counter attacking
  121. MAGIC_REFLECT = 7 # Pose when reflecting magic
  122. EVASION = [9,8] # Move back then move forward poses to evade.
  123.  
  124. #-------------------------------------------------------------------------------
  125. # POSE INFORMATION:
  126. #------------------------------------------------------------------------------#
  127. # DEFAULT SPRITESHEET POSES (HOLDER SETUP)
  128. #------------------------------------------------------------------------------#
  129. # ROW POSE
  130. #
  131. # 0 Idle
  132. # 1 Guard
  133. # 2 Poor Status
  134. # 3 Get hit
  135. # 4 Normal Attack
  136. # 5 Use Item
  137. # 6 Use Skill
  138. # 7 Use Magic
  139. # 8 Move toward
  140. # 9 Move back
  141. # 10 Victory
  142. # 11 Battle Start
  143. # 12 Dead
  144. # 13 Spritesheet Info
  145. #------------------------------------------------------------------------------#
  146.  
  147. #-------------------------------------------------------------------------------
  148. #
  149. # * END SETTINGS
  150. #
  151. #-------------------------------------------------------------------------------
  152.  
  153. end
  154.  
  155. #------------------------------------------------------------------------------#
  156. # OVERWRITTEN METHODS
  157. #------------------------------------------------------------------------------#
  158. # class Spriteset_Battle
  159. # - create_enemies
  160. # - create_actors
  161. # - update_actors
  162. #------------------------------------------------------------------------------#
  163.  
  164. #-----------------#
  165. #---| GAME_SYSTEM |---------------------------------------------------------
  166. #-----------------#
  167.  
  168.  
  169. class Game_System
  170. attr_accessor :b_positions
  171.  
  172. alias galv_animb_gs_initialize initialize
  173. def initialize
  174. galv_animb_gs_initialize
  175. @b_positions = Array.new(GALV_BAT::ACTOR_POSITIONS)
  176. end
  177. end
  178.  
  179. #----------------------#
  180. #---| GAME_INTERPRETER |----------------------------------------------------
  181. #----------------------#
  182.  
  183. class Game_Interpreter
  184. def change_battler(id,name)
  185. $game_actors[id].animated_battler = name
  186. end
  187. end # Game_Interpreter
  188.  
  189.  
  190. #-------------------#
  191. #---| RPG::BASEITEM |-------------------------------------------------------
  192. #-------------------#
  193.  
  194. class RPG::BaseItem
  195. def pose
  196. if @pose.nil?
  197. if @note =~ /<pose: (.*)>/i
  198. @pose = $1.to_i
  199. else
  200. @pose = nil
  201. end
  202. end
  203. @pose
  204. end
  205. end # RPG::BaseItem
  206.  
  207.  
  208. #----------------------#
  209. #---| GAME_BATTLERBASE |----------------------------------------------------
  210. #----------------------#
  211.  
  212. class Game_BattlerBase
  213. alias galv_animb_gbb_appear appear
  214. def appear
  215. return if SceneManager.scene_is?(Scene_Map)
  216. galv_animb_gbb_appear
  217. end
  218. end # Game_BattlerBase
  219.  
  220.  
  221. #------------------#
  222. #---| GAME_BATTLER |--------------------------------------------------------
  223. #------------------#
  224.  
  225. class Game_Battler < Game_BattlerBase
  226. attr_accessor :animated_battler
  227. attr_accessor :pose
  228. attr_accessor :freeze_pose
  229. attr_accessor :bactivated
  230. attr_accessor :move_target
  231. attr_accessor :orx
  232. attr_accessor :ory
  233. attr_accessor :reset_pose
  234. attr_accessor :move_speed
  235.  
  236. def setup_animated_battler
  237. @pose = 0
  238. @move_speed = 0
  239. char = actor? ? actor : enemy
  240. @animated_battler = $1 if char.note =~ /<battler:[ ](.*)>/i
  241. end
  242.  
  243. def do_pose(col)
  244. @reset_pose = true
  245. @pose = col
  246. @freeze_pose = true if GALV_BAT::ONE_ANIM.include?(@pose)
  247. end
  248.  
  249. alias galv_animb_gbgbb_on_turn_end on_turn_end
  250. def on_turn_end
  251. galv_animb_gbgbb_on_turn_end
  252. set_idle_pose
  253. end
  254.  
  255. alias galv_animb_gbgbb_on_action_end on_action_end
  256. def on_action_end
  257. galv_animb_gbgbb_on_action_end
  258. set_idle_pose
  259. end
  260.  
  261. def set_idle_pose
  262. return if !@bactivated
  263. if death_state?
  264. do_pose(12)
  265. elsif guard?
  266. do_pose(1)
  267. elsif !@states.empty?
  268. do_pose(state_pose)
  269. elsif low_life?
  270. do_pose(2)
  271. else
  272. do_pose(0)
  273. end
  274. @freeze_pose = false unless GALV_BAT::ONE_ANIM.include?(@pose)
  275. end
  276.  
  277. def low_life?
  278. @hp < (mhp * GALV_BAT::HP_CRISIS)
  279. end
  280.  
  281. def state_pose
  282. prio = 0
  283. prio_state = 0
  284. @states.each { |sid|
  285. if $data_states[sid].priority > prio
  286. prio_state = sid
  287. prio = $data_states[sid].priority
  288. end
  289. }
  290. if prio_state <= 0 || !$data_states[prio_state].pose
  291. return 2
  292. else
  293. $data_states[prio_state].pose
  294. end
  295. end
  296.  
  297. alias galv_animb_gbgbb_add_state add_state
  298. def add_state(state_id)
  299. galv_animb_gbgbb_add_state(state_id)
  300. set_idle_pose
  301. end
  302.  
  303. alias galv_animb_gbgbb_remove_state remove_state
  304. def remove_state(state_id)
  305. dead = dead?
  306. galv_animb_gbgbb_remove_state(state_id)
  307. set_idle_pose if state_id != 1 && !dead? || dead
  308. end
  309.  
  310. alias galv_animb_gbgbb_execute_damage execute_damage
  311. def execute_damage(user)
  312. perform_get_hit if @result.hp_damage > 0
  313. galv_animb_gbgbb_execute_damage(user)
  314. if !$imported["YEA-BattleEngine"]
  315. SceneManager.scene.wait(15)
  316. set_idle_pose
  317. end
  318. end
  319.  
  320. def perform_get_hit
  321. if !dead? && !guard? && $game_party.in_battle && @animated_battler
  322. do_pose(3)
  323. @sprite_effect_type = :get_hit
  324. end
  325. end
  326.  
  327. def perform_counter_attack
  328. if !dead? && $game_party.in_battle && @animated_battler
  329. do_pose(GALV_BAT::COUNTER_ATTACK)
  330. @sprite_effect_type = :counter_attack
  331. end
  332. end
  333.  
  334. def perform_magic_reflect
  335. if !dead? && $game_party.in_battle && @animated_battler
  336. do_pose(GALV_BAT::MAGIC_REFLECT)
  337. @sprite_effect_type = :counter_attack
  338. end
  339. end
  340.  
  341. def perform_victory
  342. if !dead? && @animated_battler
  343. do_pose(10)
  344. end
  345. end
  346.  
  347. def perform_enter_battle
  348. @bactivated = true
  349. if !dead? && @animated_battler
  350. @pose = 11
  351. @sprite_effect_type = :enter_battle
  352. end
  353. end
  354.  
  355. def perform_dash(dash_type,target)
  356. if !dead? && @animated_battler
  357. @move_target = target
  358. pose = dash_type == :dash_forward ? 8 : 9
  359. do_pose(pose)
  360. @sprite_effect_type = dash_type
  361. end
  362. end
  363.  
  364. def perform_travel(dash_type,target,speed)
  365. @move_target = target
  366. @move_speed = speed
  367. do_pose(8)
  368. @sprite_effect_type = dash_type
  369. end
  370.  
  371. def moving?
  372. @move_speed > 0
  373. end
  374.  
  375. def perform_dodge
  376. if !dead? && @animated_battler
  377. do_pose(GALV_BAT::EVASION[0])
  378. @sprite_effect_type = :dodge
  379. end
  380. end
  381.  
  382. alias galv_animb_gbgbb_on_battle_start on_battle_start
  383. def on_battle_start
  384. perform_enter_battle
  385. galv_animb_gbgbb_on_battle_start
  386. end
  387.  
  388. def init_animated_battler(i)
  389. @sprite_effect_type = :appear
  390. @bactivated = false
  391. @pose = alive? ? 11 : 12
  392. if actor?
  393. #@screen_x = GALV_BAT::ACTOR_POSITIONS[i][0]
  394. #@orx = GALV_BAT::ACTOR_POSITIONS[i][0]
  395. #@screen_y = GALV_BAT::ACTOR_POSITIONS[i][1]
  396. #@ory = GALV_BAT::ACTOR_POSITIONS[i][1]
  397. @screen_x = $game_system.b_positions[i][0]
  398. @orx = $game_system.b_positions[i][0]
  399. @screen_y = $game_system.b_positions[i][1]
  400. @ory = $game_system.b_positions[i][1]
  401. else
  402. @orx = @screen_x
  403. @ory = @screen_y
  404. end
  405. end
  406.  
  407. def reinit_battler(i)
  408. if actor?
  409. #@screen_x = GALV_BAT::ACTOR_POSITIONS[i][0]
  410. #@orx = GALV_BAT::ACTOR_POSITIONS[i][0]
  411. #@screen_y = GALV_BAT::ACTOR_POSITIONS[i][1]
  412. #@ory = GALV_BAT::ACTOR_POSITIONS[i][1]
  413. @screen_x = $game_system.b_positions[i][0]
  414. @orx = $game_system.b_positions[i][0]
  415. @screen_y = $game_system.b_positions[i][1]
  416. @ory = $game_system.b_positions[i][1]
  417. else
  418. @orx = @screen_x
  419. @ory = @screen_y
  420. end
  421. @bactivated = true
  422. end
  423.  
  424. alias galv_animb_gbgbb_item_apply item_apply
  425. def item_apply(user, item)
  426. galv_animb_gbgbb_item_apply(user, item)
  427. if @result.evaded
  428. perform_dodge
  429. end
  430. end
  431. end # Game_Battler < Game_BattlerBase
  432.  
  433.  
  434. #----------------#
  435. #---| GAME_ACTOR |----------------------------------------------------------
  436. #----------------#
  437.  
  438. class Game_Actor < Game_Battler
  439. attr_accessor :screen_x
  440. attr_accessor :screen_y
  441.  
  442. def screen_x; screen_x = @screen_x; end
  443. def screen_y; screen_y = @screen_y; end
  444. def screen_z; 100; end
  445.  
  446. alias galv_animb_gagb_initialize initialize
  447. def initialize(actor_id)
  448. galv_animb_gagb_initialize(actor_id)
  449. setup_animated_battler
  450. @screen_x = 0
  451. @screen_y = 0
  452. end
  453.  
  454. def sub_pose(target)
  455. if !dead? && @animated_battler
  456. return if $data_actors[@actor_id].note =~ /<stationary_sub>/i
  457. @screen_x = target.screen_x - GALV_BAT::SXOFFSET
  458. @screen_y = target.screen_y - GALV_BAT::SYOFFSET
  459. @sprite_effect_type = :substitute
  460. end
  461. end
  462.  
  463. def return_to_position
  464. if !dead? && @animated_battler
  465. @screen_x = @orx
  466. @screen_y = @ory
  467. end
  468. end
  469. end # Game_Actor < Game_Battler
  470.  
  471.  
  472. #----------------#
  473. #---| GAME_ENEMY |----------------------------------------------------------
  474. #----------------#
  475.  
  476. class Game_Enemy < Game_Battler
  477. alias galv_animb_gegb_initialize initialize
  478. def initialize(index, enemy_id)
  479. galv_animb_gegb_initialize(index, enemy_id)
  480. setup_animated_battler
  481. end
  482.  
  483. def sub_pose(target)
  484. if !dead? && @animated_battler
  485. return if $data_enemies[@enemy_id].note =~ /<stationary_sub>/i
  486. @screen_x = target.screen_x + GALV_BAT::SXOFFSET
  487. @screen_y = target.screen_y + GALV_BAT::SYOFFSET
  488. @sprite_effect_type = :substitute
  489. end
  490. end
  491.  
  492. def return_to_position
  493. if !dead? && @animated_battler
  494. @screen_x = @orx
  495. @screen_y = @ory
  496. end
  497. end
  498. end # Game_Enemy < Game_Battler
  499.  
  500.  
  501. #-------------------#
  502. #---| BATTLEMANAGER |-------------------------------------------------------
  503. #-------------------#
  504.  
  505. module BattleManager
  506. class << self
  507. alias galv_animb_bm_process_victory process_victory
  508. end
  509.  
  510. def self.process_victory
  511. $game_party.battle_members.each { |actor| actor.perform_victory }
  512. galv_animb_bm_process_victory
  513. end
  514. end # BattleManager
  515.  
  516.  
  517. #------------------#
  518. #---| SCENE_BATTLE |--------------------------------------------------------
  519. #------------------#
  520.  
  521. class Scene_Battle < Scene_Base
  522. alias galv_animb_sbsb_start start
  523. def start
  524. position_battlers
  525. galv_animb_sbsb_start
  526. end
  527.  
  528. def position_actors
  529. $game_party.battle_members.each_with_index { |battler,i|
  530. battler.reinit_battler(i)
  531. }
  532. @spriteset.refresh_actors
  533. end
  534.  
  535. def position_battlers
  536. galv_all_battle_members.each_with_index { |battler,i|
  537. battler.init_animated_battler(i)
  538. }
  539. end
  540.  
  541. def galv_all_battle_members
  542. $game_party.battle_members + $game_troop.members
  543. end
  544.  
  545. alias galv_animb_sbsb_show_animation show_animation
  546. def show_animation(targets, animation_id)
  547. @move_target = targets[0]
  548. check_dash
  549. set_pose
  550. galv_animb_sbsb_show_animation(targets, animation_id)
  551. end
  552.  
  553. def check_dash
  554. move = move_to_target
  555. if move > 0
  556. @subject.perform_travel(:move_forward,@move_target,move)
  557. update_for_wait while @subject.moving?
  558. elsif move == 0
  559. @subject.perform_dash(:dash_forward,@move_target)
  560. wait(30)
  561. end
  562. end
  563.  
  564. def move_to_target
  565. return -1 if no_action && !@moveitem
  566. @moveitem ||= @subject.current_action.item
  567. return $1.to_i if @moveitem.note =~ /<melee: (.*)>/i
  568. if @moveitem.is_a?(RPG::Skill) && @moveitem.id == 1
  569. char = @subject.actor? ? $data_actors[@subject.id] :
  570. $data_enemies[@subject.enemy_id]
  571. return $1.to_i if char.note =~ /<melee: (.*)>/i
  572. end
  573. return -1
  574. end
  575.  
  576. def no_action
  577. !@subject || !@subject.current_action || !@subject.current_action.item
  578. end
  579.  
  580. alias galv_animb_sbsb_process_action_end process_action_end
  581. def process_action_end
  582. if @subject.screen_x != @subject.orx
  583. @subject.perform_dash(:dash_back,@subject)
  584. wait(25)
  585. end
  586. galv_animb_sbsb_process_action_end
  587. @moveitem = nil
  588. end
  589.  
  590. alias galv_animb_sbsb_invoke_counter_attack invoke_counter_attack
  591. def invoke_counter_attack(target,item)
  592. target.perform_counter_attack
  593. galv_animb_sbsb_invoke_counter_attack(target,item)
  594. end
  595.  
  596. alias galv_animb_sbsb_invoke_magic_reflection invoke_magic_reflection
  597. def invoke_magic_reflection(target, item)
  598. target.perform_magic_reflect
  599. galv_animb_sbsb_invoke_magic_reflection(target, item)
  600. end
  601.  
  602. def set_pose
  603. return if no_action
  604. item = @subject.current_action.item
  605. if item.is_a?(RPG::Skill)
  606. case item.id
  607. when 2 # guard
  608. @subject.do_pose(1)
  609. when 1 # attack
  610. @subject.do_pose(4)
  611. wait(20) if $imported["YEA-BattleEngine"]
  612. else
  613. unique = item.pose ? item.pose : 6
  614. @subject.do_pose(unique)
  615. end
  616. elsif item.is_a?(RPG::Item)
  617. unique = item.pose ? item.pose : 5
  618. @subject.do_pose(unique)
  619. wait(30) if $imported["YEA-BattleEngine"]
  620. end
  621. end
  622. end # Scene_Battle < Scene_Base
  623.  
  624.  
  625. #----------------------#
  626. #---| WINDOW_BATTLELOG |----------------------------------------------------
  627. #----------------------#
  628.  
  629. class Window_BattleLog < Window_Selectable
  630. alias galv_animb_wblws_display_substitute display_substitute
  631. def display_substitute(substitute, target)
  632. substitute.sub_pose(target)
  633. galv_animb_wblws_display_substitute(substitute, target)
  634. end
  635. end
  636.  
  637.  
  638. #----------------------#
  639. #---| SPRITESET_BATTLE |----------------------------------------------------
  640. #----------------------#
  641.  
  642. class Spriteset_Battle
  643. #OVERWRITE
  644. def create_enemies
  645. @enemy_sprites = $game_troop.members.reverse.collect do |enemy|
  646. if enemy.animated_battler
  647. Sprite_AnimBattler.new(@viewport1, enemy)
  648. else
  649. Sprite_Battler.new(@viewport1, enemy)
  650. end
  651. end
  652. end
  653.  
  654. # OVERWRITE
  655. def create_actors
  656. @actor_sprites = $game_party.battle_members.reverse.collect do |actor|
  657. Sprite_ActorBattler.new(@viewport1, actor)
  658. end
  659. end
  660.  
  661. # OVERWRITE
  662. def update_actors
  663. need_update = false
  664. @actor_sprites.each_with_index do |sprite, i|
  665. sprite.battler = $game_party.battle_members[i]
  666. if sprite.battler
  667. sprite.update
  668. else
  669. need_update = true
  670. end
  671. end
  672. need_update = true if @actor_sprites.count < $game_party.battle_members.count
  673. if need_update
  674. SceneManager.scene.position_actors
  675. end
  676. end
  677.  
  678. def refresh_actors
  679. dispose_actors
  680. create_actors
  681. end
  682. end # Spriteset_Battle
  683.  
  684.  
  685. #--------------------#
  686. #---| SPRITE_BATTLER |------------------------------------------------------
  687. #--------------------#
  688.  
  689. class Sprite_Battler < Sprite_Base
  690. alias galv_animb_spritebsb_update update
  691. def update
  692. if @battler && @battler.animated_battler && @galv_animb
  693. super
  694. else
  695. galv_animb_spritebsb_update
  696. end
  697. end
  698. end # Sprite_Battler < Sprite_Base
  699.  
  700.  
  701. #------------------------#
  702. #---| SPRITE_ANIMBATTLER |--------------------------------------------------
  703. #------------------------#
  704.  
  705. class Sprite_AnimBattler < Sprite_Battler
  706. def initialize(viewport, battler = nil)
  707. init_variables
  708. super(viewport,battler)
  709. end
  710.  
  711. def init_variables
  712. @pattern = 0
  713. @speed_timer = 0
  714. @pose = 0
  715. @galv_animb = true
  716. end
  717.  
  718. def update
  719. if @battler && @battler.animated_battler
  720. update_bitmap
  721. update_pose
  722. update_src_rect
  723. update_anim
  724. update_position
  725. setup_new_effect
  726. setup_new_animation
  727. update_effect
  728. end
  729. super
  730. end
  731.  
  732. def update_bitmap
  733. new_bitmap = Cache.battler(@battler.animated_battler,
  734. @battler.battler_hue)
  735. if bitmap != new_bitmap
  736. self.bitmap = new_bitmap
  737. spritesheet_normal
  738. init_visibility
  739. end
  740. end
  741.  
  742. def spritesheet_normal
  743. @cw = bitmap.width / GALV_BAT::COLS
  744. @ch = bitmap.height / GALV_BAT::ROWS
  745. self.ox = @cw / 2
  746. self.oy = @ch
  747. set_mirror
  748. end
  749.  
  750. def set_mirror
  751. self.mirror = GALV_BAT::ENEMY_FLIP
  752. end
  753.  
  754. def update_pose
  755. if @pose != @battler.pose
  756. @pattern = 0
  757. @pose = @battler.pose
  758. end
  759. if @battler.reset_pose
  760. @pose = 0
  761. @battler.reset_pose = false
  762. end
  763. end
  764.  
  765. def update_src_rect
  766. if @pattern >= GALV_BAT::COLS
  767. @pattern = 0 unless freeze_pose?
  768. end
  769. sx = @pattern * @cw
  770. sy = @battler.pose * @ch
  771. self.src_rect.set(sx, sy, @cw, @ch)
  772. end
  773.  
  774. def freeze_pose?
  775. @battler.freeze_pose && @pattern == GALV_BAT::COLS - 1
  776. end
  777.  
  778. def update_anim
  779. return if !@battler.bactivated
  780. @speed_timer += 1
  781. if @speed_timer > 8
  782. @pattern += 1 unless freeze_pose?
  783. @speed_timer = 0
  784. end
  785. end
  786.  
  787. def update_position
  788. self.x = @battler.screen_x
  789. self.y = @battler.screen_y
  790. self.z = @battler.screen_z
  791. end
  792.  
  793. def start_effect(effect_type)
  794. @effect_type = effect_type
  795. case @effect_type
  796. when :counter_attack,:magic_reflect,:get_hit
  797. @effect_duration = 40
  798. @battler_visible = true
  799. when :enter_battle
  800. @effect_duration = 35
  801. @battler_visible = true
  802. when :dash_forward,:dash_back
  803. @effect_duration = 15
  804. @battler_visible = true
  805. when :move_forward
  806. @effect_duration = 500
  807. @move_duration = @effect_duration
  808. @battler_visible = true
  809. when :dodge
  810. @effect_duration = 20
  811. @battler_visible = true
  812. when :substitute
  813. @effect_duration = 20
  814. @battler_visible = true
  815. end
  816. super
  817. end
  818.  
  819. def update_effect
  820. if @effect_duration > 0
  821. case @effect_type
  822. when :get_hit, :substitute
  823. update_generic_pose
  824. when :counter_attack,:magic_reflect
  825. update_counter
  826. when :enter_battle
  827. update_enter_battle
  828. when :dash_forward
  829. update_dash_forward
  830. when :move_forward
  831. update_move_forward
  832. when :dash_back
  833. update_dash_back
  834. when :dodge
  835. update_dodge
  836. end
  837. end
  838. super
  839. end
  840.  
  841. def revert_to_normal
  842. return if do_revert?
  843. super
  844. spritesheet_normal
  845. end
  846.  
  847. def do_revert?
  848. @effect_type == :whiten || @battler.dead?
  849. end
  850.  
  851. def update_generic_pose
  852. if @effect_duration == 1
  853. @battler.return_to_position
  854. @battler.set_idle_pose
  855. end
  856. end
  857.  
  858. def xoff; @battler.actor? ? GALV_BAT::XOFFSET : -GALV_BAT::XOFFSET; end
  859. def yoff; @battler.actor? ? GALV_BAT::YOFFSET : -GALV_BAT::YOFFSET; end
  860.  
  861. def update_dash_forward
  862. if @battler.actor? && @battler.screen_x > Graphics.width / 2
  863. @battler.screen_x -= 3
  864. elsif @battler.enemy? && @battler.screen_x < Graphics.width / 2
  865. @battler.screen_x += 3
  866. end
  867. update_disappear
  868. if @effect_duration == 1
  869. @battler.screen_x = @battler.move_target.screen_x + xoff
  870. @battler.screen_y = @battler.move_target.screen_y + yoff
  871. start_effect(:appear)
  872. end
  873. end
  874.  
  875. def update_dash_back
  876. if @battler.actor? && @battler.screen_x < Graphics.width / 2
  877. @battler.screen_x += 3
  878. elsif @battler.enemy? && @battler.screen_x > Graphics.width / 2
  879. @battler.screen_x -= 3
  880. end
  881. update_disappear
  882. if @effect_duration == 1
  883. @battler.screen_x = @battler.move_target.orx
  884. @battler.screen_y = @battler.move_target.ory
  885. start_effect(:appear)
  886. end
  887. end
  888.  
  889. def update_move_forward
  890. if @battler.actor?
  891. @battler.screen_x -= x_difference(@battler,@battler.move_target)
  892. elsif @battler.enemy?
  893. @battler.screen_x += x_difference(@battler,@battler.move_target)
  894. end
  895. @battler.screen_y += y_difference(@battler,@battler.move_target)
  896. end
  897.  
  898. def y_difference(bat,tar)
  899. yof = bat.actor? ? yoff : -yoff
  900. y_diff = bat.ory - (tar.screen_y + yof)
  901. x_diff = bat.orx - (tar.screen_x + xoff)
  902. y_move = y_diff.to_f / (x_diff.to_f / [@battler.move_speed,1].max).to_f
  903. return bat.actor? ? -y_move : y_move
  904. end
  905.  
  906. def x_difference(bat,tar)
  907. if bat.actor? && bat.screen_x <= (tar.screen_x + xoff) ||
  908. bat.enemy? && bat.screen_x >= (tar.screen_x + xoff)
  909. @battler.move_speed = 0
  910. @effect_duration = 1
  911. return 0
  912. end
  913. return @battler.move_speed
  914. end
  915.  
  916. def update_dodge
  917. if @effect_duration == 1
  918. @battler.screen_x = @battler.orx
  919. @battler.screen_y = @battler.ory
  920. @battler.set_idle_pose
  921. elsif @effect_duration >= 10
  922. @battler.actor? ? @battler.screen_x += 3 : @battler.screen_x -= 3
  923. else
  924. @battler.pose = GALV_BAT::EVASION[1]
  925. @battler.actor? ? @battler.screen_x -= 3 : @battler.screen_x += 3
  926. end
  927. end
  928.  
  929. def update_enter_battle
  930. if @effect_duration == 1
  931. @battler.bactivated = true
  932. @battler.set_idle_pose
  933. end
  934. end
  935.  
  936. def update_counter
  937. self.color.set(255, 255, 255, 0)
  938. self.color.alpha = 128 - (26 - @effect_duration) * 10
  939. @battler.set_idle_pose if @effect_duration == 1
  940. end
  941.  
  942. def update_collapse; end
  943. end # Sprite_AnimBattler < Sprite_Base
  944.  
  945.  
  946. #-------------------------#
  947. #---| SPRITE_ACTORBATTLER |-------------------------------------------------
  948. #-------------------------#
  949.  
  950. class Sprite_ActorBattler < Sprite_AnimBattler
  951. def initialize(viewport, battler = nil)
  952. super(viewport,battler)
  953. end
  954.  
  955. def dispose; super; end
  956. def update; super; end
  957.  
  958. def set_mirror
  959. self.mirror = GALV_BAT::ACTOR_FLIP
  960. end
  961.  
  962. def update_position
  963. self.x = @battler.screen_x
  964. self.y = @battler.screen_y
  965. self.z = @battler.screen_z
  966. end
  967.  
  968. def init_visibility
  969. self.opacity = 255
  970. end
  971. end # Sprite_ActorBattler < Sprite_AnimBattler
  972.  
  973.  
  974. #------------------------#
  975. #---| WINDOW_BATTLEENEMY |--------------------------------------------------
  976. #------------------------#
  977.  
  978. class Window_BattleEnemy < Window_Selectable
  979. if $imported["YEA-BattleEngine"]
  980. def create_flags
  981. set_select_flag(:any)
  982. select(-1)
  983. return if $game_temp.battle_aid.nil?
  984. if $game_temp.battle_aid.need_selection?
  985. select(-1)
  986. elsif $game_temp.battle_aid.for_all?
  987. select(-1)
  988. set_select_flag(:all)
  989. elsif $game_temp.battle_aid.for_random?
  990. select(-1)
  991. set_select_flag(:random)
  992. end
  993. end
  994. end
  995. end # Window_BattleEnemy < Window_Selectable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement