pigu_6

Yami | Visual effect

Mar 8th, 2013
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.73 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Symphony - Add-on: Visual Effect Tags
  4. # -- Last Updated: 2012.10.20
  5. # -- Level: Nothing
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["BattleSymphony-VisualEffect"] = true
  12.  
  13. #==============================================================================
  14. # ¥ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.10.20 - Finished Script.
  17. # 2012.07.01 - Started Script.
  18. #
  19. #==============================================================================
  20. # ¥ Compatibility
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  23. # it will run with RPG Maker VX without adjusting.
  24. # Remember to put this script under Battle Symphony.
  25. #
  26. #==============================================================================
  27.  
  28. #==============================================================================
  29. # ¡ Default Actions - Imported Symphony Configuration
  30. #==============================================================================
  31.  
  32. module SYMPHONY
  33.  
  34. VE_AUTO_SYMPHONY = {
  35.  
  36. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  37. # autosymphony: hide nonfocus
  38. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  39. # This hides whatever isn't the active battler and its targets. Great for
  40. # long action sequences or summoning sequences when the allied party
  41. # members, who aren't involved, will disappear. In addition to that, the
  42. # screen will also fade black and the battle waits 32 frames.
  43. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  44. "HIDE NONFOCUS" => [
  45. ["VANISH", ["NOT FOCUS", "TRUE"]],
  46. ["SCREEN", ["DARKEN"]],
  47. ["WAIT", [32]],
  48. ], # end HIDE NONFOCUS
  49.  
  50. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  51. # autosymphony: show nonfocus
  52. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  53. # This removes the hidden effect from the vanished units in the hidden
  54. # version of this AutoSymphony. Returns all of the hidden non-participating
  55. # party members back into view. The screen's fade will return back to
  56. # normal and the battle waits 16 frames.
  57. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  58. "SHOW NONFOCUS" => [
  59. ["VANISH", ["NOT FOCUS", "FALSE"]],
  60. ["SCREEN", ["LIGHTEN"]],
  61. ["WAIT", [16]],
  62. ], # end SHOW NONFOCUS
  63.  
  64. } # Do not remove this.
  65.  
  66. AUTO_SYMPHONY.merge!(VE_AUTO_SYMPHONY)
  67.  
  68. end # SYMPHONY
  69.  
  70. #==============================================================================
  71. # ¡ Scene_Battle - Imported Symphony Configuration
  72. #==============================================================================
  73.  
  74. class Scene_Battle < Scene_Base
  75.  
  76. #--------------------------------------------------------------------------
  77. # alias method: imported_symphony
  78. #--------------------------------------------------------------------------
  79. alias bes_ve_imported_symphony imported_symphony
  80. def imported_symphony
  81. case @action.upcase
  82.  
  83. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  84. # afterimage: tune1, tune2
  85. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  86. # tune1
  87. # - refer to target typing; See Symphony Manual for more info.
  88. # tune2
  89. # - refer to flag; true or false.
  90. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  91. # Switch the Afterimage effect for targets, which creates some
  92. # afterimage behind targets.
  93. # --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - -
  94. # afterimage: user, true
  95. # afterimage: targets, false
  96. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  97. when /AFTERIMAGE|MIRAGE/i
  98. action_afterimage
  99.  
  100. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  101. # effect: tune1, tune2
  102. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  103. # tune1
  104. # - refer to target typing; See Symphony Manual for more info.
  105. # tune2
  106. # - refer to effect; There are 2 default effects for sprites:
  107. # + whiten
  108. # + blink
  109. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  110. # Start effect on targets sprites for short duration.
  111. # --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - -
  112. # effect: user, whiten
  113. # effect: targets, blink
  114. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  115. when /EFFECT/i
  116. action_effect
  117.  
  118. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  119. # movie: tune1
  120. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  121. # tune1
  122. # - refer to movie filename.
  123. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  124. # Play a movie file when action is called. Movie has to be put in folder
  125. # Graphics/Movies.
  126. # --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - -
  127. # movie: thunder.ogg
  128. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  129. when /MOVIE/i
  130. action_movie
  131.  
  132. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  133. # screen: tune1
  134. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  135. # tune1
  136. # - fade out, x; This will fade the screen out in x frames.
  137. # - fade in, x; This will fade the screen in in x frames.
  138. # - shake, x, y, z; Shakes screen with y power, z speed, x frames.
  139. # - weather, x, y, z; Sets weather type y, z power, x frames.
  140. # - tone, x, r, g, b, gr; x frames, rgb, gr is gray.
  141. # - flash, x, r, g, b, a; x frames, rgb, a is alpha.
  142. # - darken; This darkens the battleback.
  143. # - lighten; This removes the darkened battleback.
  144. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  145. # This will produce unique effects using the screen. Each tuneset uses
  146. # a different set of rules so pay attention to the examples below on
  147. # how it's all used.
  148. # --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - -
  149. # screen: fade out, 30
  150. # screen: fade in, 30
  151. # screen: shake, 60, 5, 5
  152. # screen: weather, 30, rain, 5
  153. # screen: tone, 60, 5, 5, 5, 0
  154. # screen: flash, 30, 255, 255, 255, 96
  155. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  156. when /SCREEN/i
  157. action_screen
  158.  
  159. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  160. # vanish: tune1, tune2, tune3
  161. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  162. # tune1
  163. # - refer to target typing; See Symphony Manual for more info.
  164. # tune2
  165. # - refer to flag; true or false.
  166. # tune3 (optional)
  167. # - refer to instant flag; Put instant here.
  168. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  169. # Make targets appear or disappear. If tune3 is true, the targets will
  170. # be disappear or appear instantly.
  171. # --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - -
  172. # vanish: targets, true
  173. # vanish: user, false, instant
  174. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  175. when /VANISH/i
  176. action_vanish
  177.  
  178. else
  179. bes_ve_imported_symphony
  180. end
  181. end
  182.  
  183. end # Scene_Battle
  184.  
  185. #==============================================================================
  186. # ¡ Game_Battler
  187. #==============================================================================
  188.  
  189. class Game_Battler < Game_BattlerBase
  190.  
  191. #--------------------------------------------------------------------------
  192. # * Public Instance Variables
  193. #--------------------------------------------------------------------------
  194. attr_reader :afterimage
  195. attr_reader :vanishing
  196.  
  197. #--------------------------------------------------------------------------
  198. # new method: set_vanish
  199. #--------------------------------------------------------------------------
  200. def set_vanish(code)
  201. case code
  202. when 0
  203. @vanishing = false
  204. sprite.start_effect(:appear)
  205. when 1
  206. @vanishing = true
  207. sprite.start_effect(:disappear)
  208. when 2
  209. @vanishing = false
  210. sprite.start_effect(:appear)
  211. sprite.set_effect_instant
  212. when 3
  213. @vanishing = true
  214. sprite.start_effect(:disappear)
  215. sprite.set_effect_instant
  216. end
  217. end
  218.  
  219. #--------------------------------------------------------------------------
  220. # new method: set_afterimage
  221. #--------------------------------------------------------------------------
  222. def set_afterimage(flag)
  223. @afterimage = flag
  224. end
  225.  
  226. end # Game_Battler
  227.  
  228. #==============================================================================
  229. # ¡ Game_Screen
  230. #==============================================================================
  231.  
  232. class Game_Screen
  233.  
  234. #--------------------------------------------------------------------------
  235. # * Public Instance Variables
  236. #--------------------------------------------------------------------------
  237. attr_reader :alpha
  238.  
  239. #--------------------------------------------------------------------------
  240. # alias method: clear
  241. #--------------------------------------------------------------------------
  242. alias bes_ve_clear clear
  243. def clear
  244. bes_ve_clear
  245. clear_bes_ve
  246. end
  247.  
  248. #--------------------------------------------------------------------------
  249. # new method: clear_bes_ve
  250. #--------------------------------------------------------------------------
  251. def clear_bes_ve
  252. clear_alpha
  253. end
  254.  
  255. #--------------------------------------------------------------------------
  256. # new method: clear_alpha
  257. #--------------------------------------------------------------------------
  258. def clear_alpha
  259. @alpha = 0
  260. @darken_duration = 0
  261. @lighten_duration = 0
  262. end
  263.  
  264. #--------------------------------------------------------------------------
  265. # new method: start_darken_background
  266. #--------------------------------------------------------------------------
  267. def start_darken_background
  268. @darken_duration = 32
  269. end
  270.  
  271. #--------------------------------------------------------------------------
  272. # new method: start_lighten_background
  273. #--------------------------------------------------------------------------
  274. def start_lighten_background
  275. @lighten_duration = 16
  276. end
  277.  
  278. #--------------------------------------------------------------------------
  279. # alias method: update
  280. #--------------------------------------------------------------------------
  281. alias bes_ve_update update
  282. def update
  283. bes_ve_update
  284. update_darken
  285. update_lighten
  286. end
  287.  
  288. #--------------------------------------------------------------------------
  289. # new method: update_darken
  290. #--------------------------------------------------------------------------
  291. def update_darken
  292. return if @darken_duration <= 0
  293. @alpha = (32 - @darken_duration) * 4
  294. @darken_duration -= 1
  295. end
  296.  
  297. #--------------------------------------------------------------------------
  298. # new method: update_lighten
  299. #--------------------------------------------------------------------------
  300. def update_lighten
  301. return if @lighten_duration <= 0
  302. @alpha = @lighten_duration * 8
  303. @lighten_duration -= 1
  304. end
  305.  
  306. end # Game_Screen
  307.  
  308. #==============================================================================
  309. # ¡ Sprite_Battler
  310. #==============================================================================
  311.  
  312. class Sprite_Battler < Sprite_Base
  313.  
  314. #--------------------------------------------------------------------------
  315. # overwrite method: setup_new_effect
  316. #--------------------------------------------------------------------------
  317. def setup_new_effect
  318. if !@battler_visible && @battler.alive?
  319. start_effect(:appear) unless @battler.vanishing
  320. elsif @battler_visible && @battler.hidden?
  321. start_effect(:disappear)
  322. end
  323. if @battler_visible && @battler.sprite_effect_type
  324. start_effect(@battler.sprite_effect_type)
  325. @battler.sprite_effect_type = nil
  326. end
  327. setup_popups if $imported["YEA-BattleEngine"]
  328. end
  329.  
  330. #--------------------------------------------------------------------------
  331. # new method: set_effect_instant
  332. #--------------------------------------------------------------------------
  333. def set_effect_instant
  334. return if @effect_type.nil?
  335. @effect_duration = 1
  336. end
  337.  
  338. #--------------------------------------------------------------------------
  339. # alias method: update_position
  340. #--------------------------------------------------------------------------
  341. alias bes_ve_update_position update_position
  342. def update_position
  343. bes_ve_update_position
  344. update_afterimage
  345. end
  346.  
  347. #--------------------------------------------------------------------------
  348. # new method: update_afterimage
  349. #--------------------------------------------------------------------------
  350. def update_afterimage
  351. @afterimage_sprites ||= []
  352. @afterimage_sprites.each { |sprite|
  353. @afterimage_sprites.delete(sprite) if sprite.disposed?
  354. next if sprite.disposed?
  355. sprite.update
  356. }
  357. return unless @battler.afterimage
  358. if @afterimage_sprites.size < 3
  359. sprite = Sprite_AfterImage.new(self.viewport, self)
  360. @afterimage_sprites << sprite
  361. end
  362. end
  363.  
  364. end # Sprite_Battler
  365.  
  366. #==============================================================================
  367. # ¡ Sprite_AfterImage
  368. #==============================================================================
  369.  
  370. class Sprite_AfterImage < Sprite_Base
  371.  
  372. #--------------------------------------------------------------------------
  373. # initialize
  374. #--------------------------------------------------------------------------
  375. def initialize(viewport, sprite)
  376. super(viewport)
  377. @sprite = sprite
  378. @time = 12
  379. @fade_time_start = @time / 2
  380. @fade_time = (@time - @fade_time_start).to_f
  381. refresh
  382. end
  383.  
  384. #--------------------------------------------------------------------------
  385. # refresh
  386. #--------------------------------------------------------------------------
  387. def refresh
  388. self.x = @sprite.x; self.y = @sprite.y
  389. self.ox = @sprite.ox; self.oy = @sprite.oy
  390. self.bitmap = @sprite.bitmap
  391. self.opacity = @sprite.opacity - 95
  392. self.src_rect.set(@sprite.src_rect)
  393. self.mirror = @sprite.mirror
  394. self.visible = @sprite.visible
  395. @opacity_rate = self.opacity / @fade_time
  396. end
  397.  
  398. #--------------------------------------------------------------------------
  399. # update
  400. #--------------------------------------------------------------------------
  401. def update
  402. super
  403. @time -= 1
  404. if @time < @fade_time_start
  405. self.opacity -= @opacity_rate
  406. end
  407. self.dispose if self.opacity <= 0
  408. end
  409.  
  410. end # Sprite_AfterImage
  411.  
  412. #==============================================================================
  413. # ¡ Spriteset_Battle
  414. #==============================================================================
  415.  
  416. class Spriteset_Battle
  417.  
  418. #--------------------------------------------------------------------------
  419. # alias method: update_battleback1
  420. #--------------------------------------------------------------------------
  421. alias bes_ve_update_battleback1 update_battleback1
  422. def update_battleback1
  423. bes_ve_update_battleback1
  424. @back1_sprite.color.alpha = $game_troop.screen.alpha
  425. end
  426.  
  427. #--------------------------------------------------------------------------
  428. # alias method: update_battleback2
  429. #--------------------------------------------------------------------------
  430. alias bes_ve_update_battleback2 update_battleback2
  431. def update_battleback2
  432. bes_ve_update_battleback2
  433. @back2_sprite.color.alpha = $game_troop.screen.alpha
  434. end
  435.  
  436. end # Spriteset_Battle
  437.  
  438. #==============================================================================
  439. # ¡ Scene_Battle - Imported Symphony Actions
  440. #==============================================================================
  441.  
  442. class Scene_Battle < Scene_Base
  443.  
  444. #--------------------------------------------------------------------------
  445. # new method: action_afterimage
  446. #--------------------------------------------------------------------------
  447. def action_afterimage
  448. targets = get_action_targets.uniq
  449. return if targets.size == 0
  450. case @action_values[1].upcase
  451. when "ON", "TRUE", "ENABLE"
  452. flag = true
  453. when "OFF", "FALSE", "DISABLE"
  454. flag = false
  455. end
  456. targets.each { |target|
  457. next unless target.exist?
  458. target.set_afterimage(flag)
  459. }
  460. end
  461.  
  462. #--------------------------------------------------------------------------
  463. # new method: action_effect
  464. #--------------------------------------------------------------------------
  465. def action_effect
  466. targets = get_action_targets.uniq
  467. return if targets.size == 0
  468. symbol = @action_values[1].downcase.to_sym
  469. targets.each { |target|
  470. next unless target.exist?
  471. target.sprite.start_effect(symbol)
  472. }
  473. end
  474.  
  475. #--------------------------------------------------------------------------
  476. # new method: action_effect
  477. #--------------------------------------------------------------------------
  478. def action_movie
  479. return if @action_values[0].nil?
  480. return if @action_values[0].size == 0
  481. filename = "Graphics/Movies/#{@action_values[0]}"
  482. return unless FileTest.exist?(filename)
  483. Graphics.play_movie(filename)
  484. end
  485.  
  486. #--------------------------------------------------------------------------
  487. # new method: action_screen
  488. #--------------------------------------------------------------------------
  489. def action_screen
  490. case @action_values[0]
  491. when "FADEOUT", "FADE OUT"
  492. duration = @action_values[1].to_i
  493. duration = 30 if duration <= 0
  494. $game_troop.screen.start_fadeout(duration)
  495. when "FADEIN", "FADE IN"
  496. duration = @action_values[1].to_i
  497. duration = 30 if duration <= 0
  498. $game_troop.screen.start_fadein(duration)
  499. when "TONE"
  500. duration = @action_values[1].to_i
  501. duration = 30 if duration <= 0
  502. r = @action_values[2].to_i; g = @action_values[3].to_i; b = @action_values[4].to_i
  503. gr = @action_values[5].to_i
  504. tone = Tone.new(r, g, b, gr)
  505. $game_troop.screen.start_tone_change(tone, duration)
  506. when "FLASH"
  507. duration = @action_values[1].to_i
  508. duration = 30 if duration <= 0
  509. r = @action_values[2].to_i; g = @action_values[3].to_i; b = @action_values[4].to_i
  510. a = @action_values[5].to_i
  511. a = 255 if a <= 0
  512. color = Color.new(r, g, b, a)
  513. $game_troop.screen.start_flash(color, duration)
  514. when "SHAKE"
  515. duration = @action_values[1].to_i
  516. duration = 30 if duration <= 0
  517. power = @action_values[2].to_i
  518. power = 5 if power <= 0
  519. speed = @action_values[3].to_i
  520. speed = 5 if speed <= 0
  521. $game_troop.screen.start_shake(power, speed, duration)
  522. when "WEATHER"
  523. duration = @action_values[1].to_i
  524. duration = 30 if duration <= 0
  525. type = @action_values[2].to_sym
  526. power = @action_values[3].to_i
  527. $game_troop.screen.change_weather(type, power, duration)
  528. when "DARKEN"
  529. $game_troop.screen.start_darken_background
  530. when "LIGHTEN"
  531. $game_troop.screen.start_lighten_background
  532. end
  533. end
  534.  
  535. #--------------------------------------------------------------------------
  536. # new method: action_vanish
  537. #--------------------------------------------------------------------------
  538. def action_vanish
  539. targets = get_action_targets.uniq
  540. return if targets.size == 0
  541. case @action_values[1]
  542. when "ON", "TRUE", "ENABLE", "HIDE"
  543. vanish_code = 1
  544. when "OFF", "FALSE", "DISABLE", "SHOW"
  545. vanish_code = 0
  546. end
  547. vanish_code += 2 if @action_values.include?("INSTANT")
  548. targets.each { |target|
  549. next unless target.exist?
  550. target.set_vanish(vanish_code)
  551. }
  552. end
  553.  
  554. end # Scene_Battle
  555.  
  556. #===============================================================================
  557. #
  558. # END OF FILE
  559. #
  560. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment