Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
113
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. do_pose(state_pose)
  268. elsif low_life?
  269. do_pose(2)
  270. else
  271. do_pose(0)
  272. end
  273. @freeze_pose = false unless GALV_BAT::ONE_ANIM.include?(@pose)
  274. end
  275.  
  276. def low_life?
  277. @hp < (mhp * GALV_BAT::HP_CRISIS)
  278. end
  279.  
  280. def state_pose
  281. prio = 0
  282. prio_state = 0
  283. @states.each { |sid|
  284. if $data_states[sid].priority > prio
  285. prio_state = sid
  286. prio = $data_states[sid].priority
  287. end
  288. }
  289. if prio_state <= 0 || !$data_states[prio_state].pose
  290. return 2
  291. else
  292. $data_states[prio_state].pose
  293. end
  294. end
  295.  
  296. alias galv_animb_gbgbb_add_state add_state
  297. def add_state(state_id)
  298. galv_animb_gbgbb_add_state(state_id)
  299. set_idle_pose
  300. end
  301.  
  302. alias galv_animb_gbgbb_remove_state remove_state
  303. def remove_state(state_id)
  304. dead = dead?
  305. galv_animb_gbgbb_remove_state(state_id)
  306. set_idle_pose if state_id != 1 && !dead? || dead
  307. end
  308.  
  309. alias galv_animb_gbgbb_execute_damage execute_damage
  310. def execute_damage(user)
  311. perform_get_hit if @result.hp_damage > 0
  312. galv_animb_gbgbb_execute_damage(user)
  313. if !$imported["YEA-BattleEngine"]
  314. SceneManager.scene.wait(15)
  315. set_idle_pose
  316. end
  317. end
  318.  
  319. def perform_get_hit
  320. if !dead? && !guard? && $game_party.in_battle && @animated_battler
  321. do_pose(3)
  322. @sprite_effect_type = :get_hit
  323. end
  324. end
  325.  
  326. def perform_counter_attack
  327. if !dead? && $game_party.in_battle && @animated_battler
  328. do_pose(GALV_BAT::COUNTER_ATTACK)
  329. @sprite_effect_type = :counter_attack
  330. end
  331. end
  332.  
  333. def perform_magic_reflect
  334. if !dead? && $game_party.in_battle && @animated_battler
  335. do_pose(GALV_BAT::MAGIC_REFLECT)
  336. @sprite_effect_type = :counter_attack
  337. end
  338. end
  339.  
  340. def perform_victory
  341. if !dead? && @animated_battler
  342. do_pose(10)
  343. end
  344. end
  345.  
  346. def perform_enter_battle
  347. @bactivated = true
  348. if !dead? && @animated_battler
  349. @pose = 11
  350. @sprite_effect_type = :enter_battle
  351. end
  352. end
  353.  
  354. def perform_dash(dash_type,target)
  355. if !dead? && @animated_battler
  356. @move_target = target
  357. pose = dash_type == :dash_forward ? 8 : 9
  358. do_pose(pose)
  359. @sprite_effect_type = dash_type
  360. end
  361. end
  362.  
  363. def perform_travel(dash_type,target,speed)
  364. @move_target = target
  365. @move_speed = speed
  366. do_pose(8)
  367. @sprite_effect_type = dash_type
  368. end
  369.  
  370. def moving?
  371. @move_speed > 0
  372. end
  373.  
  374. def perform_dodge
  375. if !dead? && @animated_battler
  376. do_pose(GALV_BAT::EVASION[0])
  377. @sprite_effect_type = :dodge
  378. end
  379. end
  380.  
  381. alias galv_animb_gbgbb_on_battle_start on_battle_start
  382. def on_battle_start
  383. perform_enter_battle
  384. galv_animb_gbgbb_on_battle_start
  385. end
  386.  
  387. def init_animated_battler(i)
  388. @sprite_effect_type = :appear
  389. @bactivated = false
  390. @pose = alive? ? 11 : 12
  391. if actor?
  392. #@screen_x = GALV_BAT::ACTOR_POSITIONS[i][0]
  393. #@orx = GALV_BAT::ACTOR_POSITIONS[i][0]
  394. #@screen_y = GALV_BAT::ACTOR_POSITIONS[i][1]
  395. #@ory = GALV_BAT::ACTOR_POSITIONS[i][1]
  396. @screen_x = $game_system.b_positions[i][0]
  397. @orx = $game_system.b_positions[i][0]
  398. @screen_y = $game_system.b_positions[i][1]
  399. @ory = $game_system.b_positions[i][1]
  400. else
  401. @orx = @screen_x
  402. @ory = @screen_y
  403. end
  404. end
  405.  
  406. def reinit_battler(i)
  407. if actor?
  408. #@screen_x = GALV_BAT::ACTOR_POSITIONS[i][0]
  409. #@orx = GALV_BAT::ACTOR_POSITIONS[i][0]
  410. #@screen_y = GALV_BAT::ACTOR_POSITIONS[i][1]
  411. #@ory = GALV_BAT::ACTOR_POSITIONS[i][1]
  412. @screen_x = $game_system.b_positions[i][0]
  413. @orx = $game_system.b_positions[i][0]
  414. @screen_y = $game_system.b_positions[i][1]
  415. @ory = $game_system.b_positions[i][1]
  416. else
  417. @orx = @screen_x
  418. @ory = @screen_y
  419. end
  420. @bactivated = true
  421. end
  422.  
  423. alias galv_animb_gbgbb_item_apply item_apply
  424. def item_apply(user, item)
  425. galv_animb_gbgbb_item_apply(user, item)
  426. if @result.evaded
  427. perform_dodge
  428. end
  429. end
  430. end # Game_Battler < Game_BattlerBase
  431.  
  432.  
  433. #----------------#
  434. #---| GAME_ACTOR |----------------------------------------------------------
  435. #----------------#
  436.  
  437. class Game_Actor < Game_Battler
  438. attr_accessor :screen_x
  439. attr_accessor :screen_y
  440.  
  441. def screen_x; screen_x = @screen_x; end
  442. def screen_y; screen_y = @screen_y; end
  443. def screen_z; 100; end
  444.  
  445. alias galv_animb_gagb_initialize initialize
  446. def initialize(actor_id)
  447. galv_animb_gagb_initialize(actor_id)
  448. setup_animated_battler
  449. @screen_x = 0
  450. @screen_y = 0
  451. end
  452.  
  453. def sub_pose(target)
  454. if !dead? && @animated_battler
  455. return if $data_actors[@actor_id].note =~ /<stationary_sub>/i
  456. @screen_x = target.screen_x - GALV_BAT::SXOFFSET
  457. @screen_y = target.screen_y - GALV_BAT::SYOFFSET
  458. @sprite_effect_type = :substitute
  459. end
  460. end
  461.  
  462. def return_to_position
  463. if !dead? && @animated_battler
  464. @screen_x = @orx
  465. @screen_y = @ory
  466. end
  467. end
  468. end # Game_Actor < Game_Battler
  469.  
  470.  
  471. #----------------#
  472. #---| GAME_ENEMY |----------------------------------------------------------
  473. #----------------#
  474.  
  475. class Game_Enemy < Game_Battler
  476. alias galv_animb_gegb_initialize initialize
  477. def initialize(index, enemy_id)
  478. galv_animb_gegb_initialize(index, enemy_id)
  479. setup_animated_battler
  480. end
  481.  
  482. def sub_pose(target)
  483. if !dead? && @animated_battler
  484. return if $data_enemies[@enemy_id].note =~ /<stationary_sub>/i
  485. @screen_x = target.screen_x + GALV_BAT::SXOFFSET
  486. @screen_y = target.screen_y + GALV_BAT::SYOFFSET
  487. @sprite_effect_type = :substitute
  488. end
  489. end
  490.  
  491. def return_to_position
  492. if !dead? && @animated_battler
  493. @screen_x = @orx
  494. @screen_y = @ory
  495. end
  496. end
  497. end # Game_Enemy < Game_Battler
  498.  
  499.  
  500. #-------------------#
  501. #---| BATTLEMANAGER |-------------------------------------------------------
  502. #-------------------#
  503.  
  504. module BattleManager
  505. class << self
  506. alias galv_animb_bm_process_victory process_victory
  507. end
  508.  
  509. def self.process_victory
  510. $game_party.battle_members.each { |actor| actor.perform_victory }
  511. galv_animb_bm_process_victory
  512. end
  513. end # BattleManager
  514.  
  515.  
  516. #------------------#
  517. #---| SCENE_BATTLE |--------------------------------------------------------
  518. #------------------#
  519.  
  520. class Scene_Battle < Scene_Base
  521. alias galv_animb_sbsb_start start
  522. def start
  523. position_battlers
  524. galv_animb_sbsb_start
  525. end
  526.  
  527. def position_actors
  528. $game_party.battle_members.each_with_index { |battler,i|
  529. battler.reinit_battler(i)
  530. }
  531. @spriteset.refresh_actors
  532. end
  533.  
  534. def position_battlers
  535. galv_all_battle_members.each_with_index { |battler,i|
  536. battler.init_animated_battler(i)
  537. }
  538. end
  539.  
  540. def galv_all_battle_members
  541. $game_party.battle_members + $game_troop.members
  542. end
  543.  
  544. alias galv_animb_sbsb_show_animation show_animation
  545. def show_animation(targets, animation_id)
  546. @move_target = targets[0]
  547. check_dash
  548. set_pose
  549. galv_animb_sbsb_show_animation(targets, animation_id)
  550. end
  551.  
  552. def check_dash
  553. move = move_to_target
  554. if move > 0
  555. @subject.perform_travel(:move_forward,@move_target,move)
  556. update_for_wait while @subject.moving?
  557. elsif move == 0
  558. @subject.perform_dash(:dash_forward,@move_target)
  559. wait(30)
  560. end
  561. end
  562.  
  563. def move_to_target
  564. return -1 if no_action && !@moveitem
  565. @moveitem ||= @subject.current_action.item
  566. return $1.to_i if @moveitem.note =~ /<melee: (.*)>/i
  567. if @moveitem.is_a?(RPG::Skill) && @moveitem.id == 1
  568. char = @subject.actor? ? $data_actors[@subject.id] :
  569. $data_enemies[@subject.enemy_id]
  570. return $1.to_i if char.note =~ /<melee: (.*)>/i
  571. end
  572. return -1
  573. end
  574.  
  575. def no_action
  576. !@subject || [email protected]_action || [email protected]_action.item
  577. end
  578.  
  579. alias galv_animb_sbsb_process_action_end process_action_end
  580. def process_action_end
  581. if @subject.screen_x != @subject.orx
  582. @subject.perform_dash(:dash_back,@subject)
  583. wait(25)
  584. end
  585. galv_animb_sbsb_process_action_end
  586. @moveitem = nil
  587. end
  588.  
  589. alias galv_animb_sbsb_invoke_counter_attack invoke_counter_attack
  590. def invoke_counter_attack(target,item)
  591. target.perform_counter_attack
  592. galv_animb_sbsb_invoke_counter_attack(target,item)
  593. end
  594.  
  595. alias galv_animb_sbsb_invoke_magic_reflection invoke_magic_reflection
  596. def invoke_magic_reflection(target, item)
  597. target.perform_magic_reflect
  598. galv_animb_sbsb_invoke_magic_reflection(target, item)
  599. end
  600.  
  601. def set_pose
  602. return if no_action
  603. item = @subject.current_action.item
  604. if item.is_a?(RPG::Skill)
  605. case item.id
  606. when 2 # guard
  607. @subject.do_pose(1)
  608. when 1 # attack
  609. @subject.do_pose(4)
  610. wait(20) if $imported["YEA-BattleEngine"]
  611. else
  612. unique = item.pose ? item.pose : 6
  613. @subject.do_pose(unique)
  614. end
  615. elsif item.is_a?(RPG::Item)
  616. unique = item.pose ? item.pose : 5
  617. @subject.do_pose(unique)
  618. wait(30) if $imported["YEA-BattleEngine"]
  619. end
  620. end
  621. end # Scene_Battle < Scene_Base
  622.  
  623.  
  624. #----------------------#
  625. #---| WINDOW_BATTLELOG |----------------------------------------------------
  626. #----------------------#
  627.  
  628. class Window_BattleLog < Window_Selectable
  629. alias galv_animb_wblws_display_substitute display_substitute
  630. def display_substitute(substitute, target)
  631. substitute.sub_pose(target)
  632. galv_animb_wblws_display_substitute(substitute, target)
  633. end
  634. end
  635.  
  636.  
  637. #----------------------#
  638. #---| SPRITESET_BATTLE |----------------------------------------------------
  639. #----------------------#
  640.  
  641. class Spriteset_Battle
  642. #OVERWRITE
  643. def create_enemies
  644. @enemy_sprites = $game_troop.members.reverse.collect do |enemy|
  645. if enemy.animated_battler
  646. Sprite_AnimBattler.new(@viewport1, enemy)
  647. else
  648. Sprite_Battler.new(@viewport1, enemy)
  649. end
  650. end
  651. end
  652.  
  653. # OVERWRITE
  654. def create_actors
  655. @actor_sprites = $game_party.battle_members.reverse.collect do |actor|
  656. Sprite_ActorBattler.new(@viewport1, actor)
  657. end
  658. end
  659.  
  660. # OVERWRITE
  661. def update_actors
  662. need_update = false
  663. @actor_sprites.each_with_index do |sprite, i|
  664. sprite.battler = $game_party.battle_members[i]
  665. if sprite.battler
  666. sprite.update
  667. else
  668. need_update = true
  669. end
  670. end
  671. need_update = true if @actor_sprites.count < $game_party.battle_members.count
  672. if need_update
  673. SceneManager.scene.position_actors
  674. end
  675. end
  676.  
  677. def refresh_actors
  678. dispose_actors
  679. create_actors
  680. end
  681. end # Spriteset_Battle
  682.  
  683.  
  684. #--------------------#
  685. #---| SPRITE_BATTLER |------------------------------------------------------
  686. #--------------------#
  687.  
  688. class Sprite_Battler < Sprite_Base
  689. alias galv_animb_spritebsb_update update
  690. def update
  691. if @battler && @battler.animated_battler && @galv_animb
  692. super
  693. else
  694. galv_animb_spritebsb_update
  695. end
  696. end
  697. end # Sprite_Battler < Sprite_Base
  698.  
  699.  
  700. #------------------------#
  701. #---| SPRITE_ANIMBATTLER |--------------------------------------------------
  702. #------------------------#
  703.  
  704. class Sprite_AnimBattler < Sprite_Battler
  705. def initialize(viewport, battler = nil)
  706. init_variables
  707. super(viewport,battler)
  708. end
  709.  
  710. def init_variables
  711. @pattern = 0
  712. @speed_timer = 0
  713. @pose = 0
  714. @galv_animb = true
  715. end
  716.  
  717. def update
  718. if @battler && @battler.animated_battler
  719. update_bitmap
  720. update_pose
  721. update_src_rect
  722. update_anim
  723. update_position
  724. setup_new_effect
  725. setup_new_animation
  726. update_effect
  727. end
  728. super
  729. end
  730.  
  731. def update_bitmap
  732. new_bitmap = Cache.battler(@battler.animated_battler,
  733. @battler.battler_hue)
  734. if bitmap != new_bitmap
  735. self.bitmap = new_bitmap
  736. spritesheet_normal
  737. init_visibility
  738. end
  739. end
  740.  
  741. def spritesheet_normal
  742. @cw = bitmap.width / GALV_BAT::COLS
  743. @ch = bitmap.height / GALV_BAT::ROWS
  744. self.ox = @cw / 2
  745. self.oy = @ch
  746. set_mirror
  747. end
  748.  
  749. def set_mirror
  750. self.mirror = GALV_BAT::ENEMY_FLIP
  751. end
  752.  
  753. def update_pose
  754. if @pose != @battler.pose
  755. @pattern = 0
  756. @pose = @battler.pose
  757. end
  758. if @battler.reset_pose
  759. @pose = 0
  760. @battler.reset_pose = false
  761. end
  762. end
  763.  
  764. def update_src_rect
  765. if @pattern >= GALV_BAT::COLS
  766. @pattern = 0 unless freeze_pose?
  767. end
  768. sx = @pattern * @cw
  769. sy = @battler.pose * @ch
  770. self.src_rect.set(sx, sy, @cw, @ch)
  771. end
  772.  
  773. def freeze_pose?
  774. @battler.freeze_pose && @pattern == GALV_BAT::COLS - 1
  775. end
  776.  
  777. def update_anim
  778. return if [email protected]
  779. @speed_timer += 1
  780. if @speed_timer > 8
  781. @pattern += 1 unless freeze_pose?
  782. @speed_timer = 0
  783. end
  784. end
  785.  
  786. def update_position
  787. self.x = @battler.screen_x
  788. self.y = @battler.screen_y
  789. self.z = @battler.screen_z
  790. end
  791.  
  792. def start_effect(effect_type)
  793. @effect_type = effect_type
  794. case @effect_type
  795. when :counter_attack,:magic_reflect,:get_hit
  796. @effect_duration = 40
  797. @battler_visible = true
  798. when :enter_battle
  799. @effect_duration = 35
  800. @battler_visible = true
  801. when :dash_forward,:dash_back
  802. @effect_duration = 15
  803. @battler_visible = true
  804. when :move_forward
  805. @effect_duration = 500
  806. @move_duration = @effect_duration
  807. @battler_visible = true
  808. when :dodge
  809. @effect_duration = 20
  810. @battler_visible = true
  811. when :substitute
  812. @effect_duration = 20
  813. @battler_visible = true
  814. end
  815. super
  816. end
  817.  
  818. def update_effect
  819. if @effect_duration > 0
  820. case @effect_type
  821. when :get_hit, :substitute
  822. update_generic_pose
  823. when :counter_attack,:magic_reflect
  824. update_counter
  825. when :enter_battle
  826. update_enter_battle
  827. when :dash_forward
  828. update_dash_forward
  829. when :move_forward
  830. update_move_forward
  831. when :dash_back
  832. update_dash_back
  833. when :dodge
  834. update_dodge
  835. end
  836. end
  837. super
  838. end
  839.  
  840. def revert_to_normal
  841. return if do_revert?
  842. super
  843. spritesheet_normal
  844. end
  845.  
  846. def do_revert?
  847. @effect_type == :whiten || @battler.dead?
  848. end
  849.  
  850. def update_generic_pose
  851. if @effect_duration == 1
  852. @battler.return_to_position
  853. @battler.set_idle_pose
  854. end
  855. end
  856.  
  857. def xoff; @battler.actor? ? GALV_BAT::XOFFSET : -GALV_BAT::XOFFSET; end
  858. def yoff; @battler.actor? ? GALV_BAT::YOFFSET : -GALV_BAT::YOFFSET; end
  859.  
  860. def update_dash_forward
  861. if @battler.actor? && @battler.screen_x > Graphics.width / 2
  862. @battler.screen_x -= 3
  863. elsif @battler.enemy? && @battler.screen_x < Graphics.width / 2
  864. @battler.screen_x += 3
  865. end
  866. update_disappear
  867. if @effect_duration == 1
  868. @battler.screen_x = @battler.move_target.screen_x + xoff
  869. @battler.screen_y = @battler.move_target.screen_y + yoff
  870. start_effect(:appear)
  871. end
  872. end
  873.  
  874. def update_dash_back
  875. if @battler.actor? && @battler.screen_x < Graphics.width / 2
  876. @battler.screen_x += 3
  877. elsif @battler.enemy? && @battler.screen_x > Graphics.width / 2
  878. @battler.screen_x -= 3
  879. end
  880. update_disappear
  881. if @effect_duration == 1
  882. @battler.screen_x = @battler.move_target.orx
  883. @battler.screen_y = @battler.move_target.ory
  884. start_effect(:appear)
  885. end
  886. end
  887.  
  888. def update_move_forward
  889. if @battler.actor?
  890. @battler.screen_x -= x_difference(@battler,@battler.move_target)
  891. elsif @battler.enemy?
  892. @battler.screen_x += x_difference(@battler,@battler.move_target)
  893. end
  894. @battler.screen_y += y_difference(@battler,@battler.move_target)
  895. end
  896.  
  897. def y_difference(bat,tar)
  898. yof = bat.actor? ? yoff : -yoff
  899. y_diff = bat.ory - (tar.screen_y + yof)
  900. x_diff = bat.orx - (tar.screen_x + xoff)
  901. y_move = y_diff.to_f / (x_diff.to_f / [@battler.move_speed,1].max).to_f
  902. return bat.actor? ? -y_move : y_move
  903. end
  904.  
  905. def x_difference(bat,tar)
  906. if bat.actor? && bat.screen_x <= (tar.screen_x + xoff) ||
  907. bat.enemy? && bat.screen_x >= (tar.screen_x + xoff)
  908. @battler.move_speed = 0
  909. @effect_duration = 1
  910. return 0
  911. end
  912. return @battler.move_speed
  913. end
  914.  
  915. def update_dodge
  916. if @effect_duration == 1
  917. @battler.screen_x = @battler.orx
  918. @battler.screen_y = @battler.ory
  919. @battler.set_idle_pose
  920. elsif @effect_duration >= 10
  921. @battler.actor? ? @battler.screen_x += 3 : @battler.screen_x -= 3
  922. else
  923. @battler.pose = GALV_BAT::EVASION[1]
  924. @battler.actor? ? @battler.screen_x -= 3 : @battler.screen_x += 3
  925. end
  926. end
  927.  
  928. def update_enter_battle
  929. if @effect_duration == 1
  930. @battler.bactivated = true
  931. @battler.set_idle_pose
  932. end
  933. end
  934.  
  935. def update_counter
  936. self.color.set(255, 255, 255, 0)
  937. self.color.alpha = 128 - (26 - @effect_duration) * 10
  938. @battler.set_idle_pose if @effect_duration == 1
  939. end
  940.  
  941. def update_collapse; end
  942. end # Sprite_AnimBattler < Sprite_Base
  943.  
  944.  
  945. #-------------------------#
  946. #---| SPRITE_ACTORBATTLER |-------------------------------------------------
  947. #-------------------------#
  948.  
  949. class Sprite_ActorBattler < Sprite_AnimBattler
  950. def initialize(viewport, battler = nil)
  951. super(viewport,battler)
  952. end
  953.  
  954. def dispose; super; end
  955. def update; super; end
  956.  
  957. def set_mirror
  958. self.mirror = GALV_BAT::ACTOR_FLIP
  959. end
  960.  
  961. def update_position
  962. self.x = @battler.screen_x
  963. self.y = @battler.screen_y
  964. self.z = @battler.screen_z
  965. end
  966.  
  967. def init_visibility
  968. self.opacity = 255
  969. end
  970. end # Sprite_ActorBattler < Sprite_AnimBattler
  971.  
  972.  
  973. #------------------------#
  974. #---| WINDOW_BATTLEENEMY |--------------------------------------------------
  975. #------------------------#
  976.  
  977. class Window_BattleEnemy < Window_Selectable
  978. if $imported["YEA-BattleEngine"]
  979. def create_flags
  980. set_select_flag(:any)
  981. select(-1)
  982. return if $game_temp.battle_aid.nil?
  983. if $game_temp.battle_aid.need_selection?
  984. select(-1)
  985. elsif $game_temp.battle_aid.for_all?
  986. select(-1)
  987. set_select_flag(:all)
  988. elsif $game_temp.battle_aid.for_random?
  989. select(-1)
  990. set_select_flag(:random)
  991. end
  992. end
  993. end
  994. end # Window_BattleEnemy < Window_Selectable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement