Advertisement
Dekita

Untitled

Apr 19th, 2014
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.94 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Particles
  5. # -- Author : Dekita
  6. # -- Version : 1.0
  7. # -- Level : Easy / Normal
  8. # -- Requires : $D13x Core Script v2.5+
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Particles]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 15/o4/2o14 - Finished,
  21. # ??/o3/2o14 - Started
  22. #
  23. #===============================================================================
  24. # ☆ Introduction
  25. #-------------------------------------------------------------------------------
  26. # This script creates 'particles' that are shown in any scene you want.
  27. # A particle is basically an image that is shown. The image will have a certain
  28. # movement and can be used for a number of visual effects.
  29. # This script is required by any other particle type script of mine.
  30. #
  31. #===============================================================================
  32. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  33. #===============================================================================
  34. # 1. You MUST give credit to "Dekita" !!
  35. # 2. You are NOT allowed to repost this script.(or modified versions)
  36. # 3. You are NOT allowed to convert this script.
  37. # 4. You are NOT allowed to use this script for Commercial games.
  38. # 5. ENJOY!
  39. #
  40. # "FINE PRINT"
  41. # By using this script you hereby agree to the above terms and conditions,
  42. # if any violation of the above terms occurs "legal action" may be taken.
  43. # Not understanding the above terms and conditions does NOT mean that
  44. # they do not apply to you.
  45. # If you wish to discuss the terms and conditions in further detail you can
  46. # contact me at http://dekitarpg.wordpress.com/
  47. #
  48. #===============================================================================
  49. # ☆ Instructions
  50. #-------------------------------------------------------------------------------
  51. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  52. #
  53. #===============================================================================
  54. # ☆ Script Calls
  55. #-------------------------------------------------------------------------------
  56. # N/A
  57. #
  58. #===============================================================================
  59. # ☆ Notetags ( default )
  60. #-------------------------------------------------------------------------------
  61. # N/A
  62. #
  63. #===============================================================================
  64. # ☆ HELP
  65. #-------------------------------------------------------------------------------
  66. # N/A
  67. #
  68. #===============================================================================
  69. module DekitaParticles
  70. #===============================================================================
  71. #-----------------------------------------------------------------------------
  72. # Graphics Folder
  73. #-----------------------------------------------------------------------------
  74. Folder = "Graphics/$D13x/Particles/"
  75. #-----------------------------------------------------------------------------
  76. # Additional space to give images outwith the screen size... (size in pixels)
  77. #-----------------------------------------------------------------------------
  78. Screen_Buffer = 60
  79. #-----------------------------------------------------------------------------
  80. #
  81. #-----------------------------------------------------------------------------
  82. Transition_Speed = 10
  83. #-----------------------------------------------------------------------------
  84. # Particle Type Settings
  85. #-----------------------------------------------------------------------------
  86. Type = {
  87. #---------------------------------------------------------------------------
  88. #:name => {
  89. # 'imag'=> [ 'Image_Name' , hue],
  90. # 'spwn'=> { x: [min, max] , y: [min, max] },
  91. # 'move'=> { x: [min, max] , y: [min, max] },
  92. # 'zoom'=> { x: [min, max] , y: [min, max] },
  93. # 'angl'=> [ base, rand, add_base, add_rand],
  94. # 'opac'=> [ base, add, [fade?, -add]],
  95. # 'wave'=> [ amp, length, speed, phase],
  96. # 'bush'=> [ depth, opac ]
  97. # 'dlay'=> [ use delay?, min, max]
  98. # 'inst'=> instantly visible?,
  99. # 'grow'=> zoom each frame,
  100. # 'amnt'=> amount shown on screen,
  101. # 'blnd'=> blend type,
  102. # 'zval'=> z value (importance),
  103. # 'scrl'=> scroll with map? (only works with my weather script),
  104. # },
  105. #---------------------------------------------------------------------------
  106. # :Meteor - Used in Title by default
  107. #---------------------------------------------------------------------------
  108. :Meteor => {
  109. 'imag'=> ["Fire/MeteorMedium", 0 , 0],
  110. 'spwn'=> { x: [0, 640] , y: [0, 416] },
  111. 'move'=> { x: [-3, 0] , y: [4, 3] },
  112. 'zoom'=> { x: [0.4, 1.0] , y: [0.4, 1.0] },
  113. 'angl'=> [326, 0, 0, 0],
  114. 'opac'=> [0, 2, [false,0]],
  115. 'wave'=> [0,10,180,360],
  116. 'bush'=> [0,255],
  117. 'dlay'=> [true,180,360],
  118. 'inst'=> false,
  119. 'grow'=> 0.01,
  120. 'amnt'=> 1,
  121. 'zval'=> 1,
  122. 'blnd'=> 0,
  123. 'zpop'=> [false, 0.0, 2.0, 50], # [on?, min, max, opac fade],
  124. 'apop'=> [false, 45, 50], # [on?, angle, opac fade],
  125. },
  126. #---------------------------------------------------------------------------
  127. # :Spark - Used in Title by default && by $D13x Particle Weather
  128. #---------------------------------------------------------------------------
  129. :Spark => {
  130. 'imag'=> ["Red_Sparkle", 0 , 361],
  131. 'spwn'=> { x: [-20, 660] , y: [-20, 436] },
  132. 'move'=> { x: [-1, -2] , y: [1, 5] },
  133. 'zoom'=> { x: [1.0, 1.0] , y: [1.0, 1.0] },
  134. 'angl'=> [0,360, -2, 5],
  135. 'opac'=> [0,10, [false,0]],
  136. 'wave'=> [0,10,180,360],
  137. 'bush'=> [0,255],
  138. 'dlay'=> [false,0,0],
  139. 'inst'=> false,
  140. 'grow'=> -0.01,
  141. 'amnt'=> 10,
  142. 'zval'=> 2,
  143. 'blnd'=> 1,
  144. 'zpop'=> [true, 0.0, 2.0, 50],
  145. 'apop'=> [false, 45, 50],
  146. },
  147. #---------------------------------------------------------------------------
  148. # :FireBall - Used in menus by default
  149. #---------------------------------------------------------------------------
  150. :FireBall => {
  151. 'imag'=> ["Fire/Medium",0, 361],
  152. 'spwn'=> { x: [0, 640] , y: [0, 416] },
  153. 'move'=> { x: [-1, 3] , y: [-1, 3] },
  154. 'zoom'=> { x: [0.4, 1.0] , y: [0.4, 1.0] },
  155. 'angl'=> [0, 30, 15, 45],
  156. 'opac'=> [0, 1, [true,-1]],
  157. 'wave'=> [0,10,120,360],
  158. 'bush'=> [0,255],
  159. 'dlay'=> [false, 0, 0],
  160. 'inst'=> false,
  161. 'grow'=> 0.01,
  162. 'amnt'=> 4,
  163. 'zval'=> 1,
  164. 'blnd'=> 0,
  165. 'zpop'=> [true, 0.0, 1.6, 10], # [on?, min, max, opac fade],
  166. 'apop'=> [false, 45, 50], # [on?, angle, opac fade],
  167. },
  168. #---------------------------------------------------------------------------
  169. # :Rain - Used as weather by 'Particle Weather' add-on
  170. #---------------------------------------------------------------------------
  171. :Rain => {
  172. 'imag'=> ["Water/DropExtraSmall", 0 , 0],
  173. 'spwn'=> { x: [-40, 680] , y: [-40, 416] },
  174. 'move'=> { x: [0, 0] , y: [10, 10] },
  175. 'zoom'=> { x: [1.0, 0.25] , y: [1.0, 0.25] },
  176. 'angl'=> [0,0,0,0],
  177. 'opac'=> [100,5,[false,0]],
  178. 'wave'=> [0,10,180,360],
  179. 'bush'=> [0,255],
  180. 'dlay'=> [false,0,0],
  181. 'inst'=> false,
  182. 'grow'=> 0,#.01,
  183. 'amnt'=> 20,
  184. 'zval'=> 2,
  185. 'blnd'=> 0,
  186. 'zpop'=> [false, 0.0, 2.0, 50],
  187. 'apop'=> [false, 45, 50],
  188. },
  189. #---------------------------------------------------------------------------
  190. # :FireRain - Used as weather by 'Particle Weather' add-on
  191. #---------------------------------------------------------------------------
  192. :FireRain => {
  193. 'imag'=> ["Fire/BrimstoneExtraSmall", 0 , 0],
  194. 'spwn'=> { x: [-40, 680] , y: [-40, 416] },
  195. 'move'=> { x: [0, 0] , y: [10, 10] },
  196. 'zoom'=> { x: [1.0, 0.25] , y: [1.0, 0.5] },
  197. 'angl'=> [0,0,0,0],
  198. 'opac'=> [80,20,[true,40]],
  199. 'wave'=> [0,10,180,360],
  200. 'bush'=> [0,255],
  201. 'dlay'=> [false,0,0],
  202. 'inst'=> false,
  203. 'grow'=> -0.01,
  204. 'amnt'=> 10,
  205. 'zval'=> 2,
  206. 'blnd'=> 0,
  207. 'zpop'=> [false, 0.0, 2.0, 50],
  208. 'apop'=> [false, 45, 50],
  209. },
  210. #---------------------------------------------------------------------------
  211. # :Glow - Used as weather by 'Particle Weather' add-on
  212. #---------------------------------------------------------------------------
  213. :Glow => {
  214. 'imag'=> ["Red_Sparkle", 0 , 0],
  215. 'spwn'=> { x: [-40, 680] , y: [-40, 456] },
  216. 'move'=> { x: [-1, 3] , y: [-1, 3] },
  217. 'zoom'=> { x: [1.0, 0.25] , y: [1.0, 0.25] },
  218. 'angl'=> [0,360, -4, 8],
  219. 'opac'=> [0,10, [false,10]],
  220. 'wave'=> [0,10,180,360],
  221. 'bush'=> [0,255],
  222. 'dlay'=> [false,0,0],
  223. 'inst'=> false,
  224. 'grow'=> -0.01,
  225. 'amnt'=> 10,
  226. 'zval'=> 2,
  227. 'blnd'=> 1,
  228. 'zpop'=> [true, 0.0, 2.0, 50],
  229. 'apop'=> [false, 45, 50],
  230. },
  231. #---------------------------------------------------------------------------
  232. # :Meteor - Used as weather by 'Particle Weather' add-on
  233. #---------------------------------------------------------------------------
  234. :MeteorRain => {
  235. 'imag'=> ["Fire/MeteorSmall", 0 , 0],
  236. 'spwn'=> { x: [-40, 680] , y: [-40, 416] },
  237. 'move'=> { x: [-3, 0] , y: [6, 5] },
  238. 'zoom'=> { x: [1.0, 0.25] , y: [1.0, 0.5] },
  239. 'angl'=> [340,0,0,0],
  240. 'opac'=> [80,10,[false,0]],
  241. 'wave'=> [0,10,180,360],
  242. 'bush'=> [0,255],
  243. 'dlay'=> [false,0,0],
  244. 'inst'=> false,
  245. 'grow'=> -0.01,
  246. 'amnt'=> 10,
  247. 'zval'=> 2,
  248. 'blnd'=> 0,
  249. 'zpop'=> [false, 0.0, 2.0, 50],
  250. 'apop'=> [false, 45, 50],
  251. },
  252. }#<<Type
  253.  
  254. #-----------------------------------------------------------------------------
  255. # Scene's Particles Settings
  256. #-----------------------------------------------------------------------------
  257. def self.particles(scene_class_name,scene_particles=nil)
  258. case scene_class_name.to_s
  259. when "Scene_Title" then scene_particles = [:Meteor , :Spark]
  260. when "Scene_Menu" then scene_particles = [:FireBall, :Spark]
  261. when "Scene_Item" then scene_particles = [:FireBall, :Spark]
  262. when "Scene_Skill" then scene_particles = [:FireBall, :Spark]
  263. when "Scene_Equip" then scene_particles = [:FireBall, :Spark]
  264. when "Scene_Status" then scene_particles = [:FireBall, :Spark]
  265. when "Scene_Save" then scene_particles = [:FireBall, :Spark]
  266. when "Scene_Load" then scene_particles = [:FireBall, :Spark]
  267. when "Scene_End" then scene_particles = [:FireBall, :Spark]
  268. when "Scene_Shop" then scene_particles = [:FireBall, :Spark]
  269. when "Scene_Name" then scene_particles = [:FireBall, :Spark]
  270. when "Scene_Gameover" then scene_particles = [:FireBall, :Spark]
  271. # //
  272. when "Scene_SPDS" then scene_particles = [:FireBall, :Spark]
  273. when "SUG_Scene" then scene_particles = [:FireBall, :Spark]
  274. when "Scene_Teleport" then scene_particles = [:FireBall, :Spark]
  275. when "Scene_BANK" then scene_particles = [:FireBall, :Spark]
  276. end
  277. return scene_particles #####################
  278. end # CUSTOMISATION END #
  279. end #####################
  280. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  281. # #
  282. # http://dekitarpg.wordpress.com/ #
  283. # #
  284. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  285. #===============================================================================#
  286. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  287. # YES?\.\. #
  288. # OMG, REALLY? \| #
  289. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  290. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  291. #===============================================================================#
  292. module Cache
  293. #===============================================================================
  294. #-----------------------------------------------------------------------------
  295. #
  296. #-----------------------------------------------------------------------------
  297. def self.particle(filename = "", hue = 0)
  298. load_bitmap(Particle_Core::Folder, filename, hue)
  299. end
  300. end
  301. #===============================================================================
  302. class Particle_Core < Sprite
  303. #===============================================================================
  304. #-----------------------------------------------------------------------------
  305. #
  306. #-----------------------------------------------------------------------------
  307. include DekitaParticles
  308. #-----------------------------------------------------------------------------
  309. #
  310. #-----------------------------------------------------------------------------
  311. attr_accessor :particle_type
  312. attr_accessor :spwn
  313. attr_accessor :move
  314. attr_accessor :zval
  315. attr_accessor :imag
  316. attr_accessor :amnt
  317. attr_accessor :blnd
  318. attr_accessor :angl
  319. attr_accessor :zoom
  320. attr_accessor :grow
  321. attr_accessor :opac
  322. attr_accessor :inst
  323. attr_accessor :wave
  324. attr_accessor :bush
  325. attr_accessor :dlay
  326. attr_accessor :zpop
  327. attr_accessor :apop
  328. #-----------------------------------------------------------------------------
  329. #
  330. #-----------------------------------------------------------------------------
  331. def initialize(data,viewport=nil,type=nil)
  332. @particle_type = type
  333. @view = viewport
  334. @data = data
  335. super(@view)
  336. init_variabz
  337. init_bitmap
  338. init_particle
  339. self.opacity = 255 if @inst #|| outwith_screen?
  340. end
  341. #-----------------------------------------------------------------------------
  342. #
  343. #-----------------------------------------------------------------------------
  344. def init_variabz
  345. @spwn = @data['spwn']
  346. @move = @data['move']
  347. @zval = @data['zval']
  348. @imag = @data['imag']
  349. @amnt = @data['amnt']
  350. @blnd = @data['blnd']
  351. @angl = @data['angl']
  352. @zoom = @data['zoom']
  353. @grow = @data['grow']
  354. @opac = @data['opac']
  355. @inst = @data['inst']
  356. @wave = @data['wave']
  357. @bush = @data['bush']
  358. @dlay = @data['dlay']
  359. @zpop = @data['zpop']
  360. @apop = @data['apop']
  361. end
  362. #-----------------------------------------------------------------------------
  363. #
  364. #-----------------------------------------------------------------------------
  365. def init_bitmap
  366. i = @data['imag'][0]
  367. h = @data['imag'][1]+rand(@data['imag'][2])
  368. self.bitmap = Cache.particle(i,h)
  369. end
  370. #-----------------------------------------------------------------------------
  371. #
  372. #-----------------------------------------------------------------------------
  373. def init_particle
  374. @mx = Graphics.width
  375. @my = Graphics.height
  376. @iw = self.bitmap.width
  377. @ih = self.bitmap.height
  378. init_posi
  379. init_opac
  380. init_wave
  381. init_blnd
  382. init_angl
  383. init_bush
  384. init_zoom
  385. init_zval
  386. init_move
  387. init_dlay
  388. @fading = false
  389. end
  390. #-----------------------------------------------------------------------------
  391. #
  392. #-----------------------------------------------------------------------------
  393. def init_posi
  394. x_pos = @spwn[:x][0] + rand(@spwn[:x][1]-@spwn[:x][0])
  395. y_pos = @spwn[:y][0] + rand(@spwn[:y][1]-@spwn[:y][0])
  396. self.x = x_pos
  397. self.y = rand(y_pos)
  398. @imagwi = self.bitmap.width
  399. @imaghe = self.bitmap.height
  400. self.ox = (@imagwi/2)
  401. self.oy = (@imaghe/2)
  402. end
  403. #-----------------------------------------------------------------------------
  404. #
  405. #-----------------------------------------------------------------------------
  406. def init_opac
  407. self.opacity = @opac[0]
  408. self.opacity = 255 if self.y < 0 || self.y > Graphics.height #||
  409. # self.y < 0 || self.y > Graphics.height
  410. end
  411. #-----------------------------------------------------------------------------
  412. #
  413. #-----------------------------------------------------------------------------
  414. def init_wave
  415. self.wave_amp = @wave[0]
  416. self.wave_length = @wave[1]
  417. self.wave_speed = @wave[2]
  418. self.wave_phase = @wave[3]
  419. end
  420. #-----------------------------------------------------------------------------
  421. #
  422. #-----------------------------------------------------------------------------
  423. def init_blnd
  424. self.blend_type = @blnd
  425. end
  426. #-----------------------------------------------------------------------------
  427. #
  428. #-----------------------------------------------------------------------------
  429. def init_angl
  430. @base_angl = @angl[0]+rand(@angl[1]).to_i
  431. @angl_addd = @angl[2]+rand(@angl[3]).to_i
  432. self.angle = @base_angl
  433. @anglepopping = false
  434. end
  435. #-----------------------------------------------------------------------------
  436. #
  437. #-----------------------------------------------------------------------------
  438. def init_bush
  439. self.bush_depth = @bush[0]
  440. self.bush_opacity = @bush[1]
  441. end
  442. #-----------------------------------------------------------------------------
  443. #
  444. #-----------------------------------------------------------------------------
  445. def init_zoom
  446. @x_zoom = @zoom[:x][0] + (rand(@zoom[:x][1]*100)/100)
  447. @y_zoom = @zoom[:y][0] + (rand(@zoom[:y][1]*100)/100)
  448. self.zoom_x = @x_zoom
  449. self.zoom_y = @y_zoom
  450. @zoompopping = false
  451. end
  452. #-----------------------------------------------------------------------------
  453. #
  454. #-----------------------------------------------------------------------------
  455. def init_zval
  456. self.z = @zval
  457. end
  458. #-----------------------------------------------------------------------------
  459. #
  460. #-----------------------------------------------------------------------------
  461. def init_move
  462. xmoveee = @move[:x][0] + rand(@move[:x][1])
  463. ymoveee = @move[:y][0] + rand(@move[:y][1])
  464. @x_move = xmoveee == 0 ? @move[:x][0] : xmoveee
  465. @y_move = ymoveee == 0 ? @move[:y][0] : ymoveee
  466. end
  467. #-----------------------------------------------------------------------------
  468. #
  469. #-----------------------------------------------------------------------------
  470. def init_dlay
  471. delay_time = @dlay[1]+rand(@dlay[2]-@dlay[1])
  472. @spawn_delay = @dlay[0] ? delay_time : 0
  473. end
  474. #-----------------------------------------------------------------------------
  475. #
  476. #-----------------------------------------------------------------------------
  477. def dispose
  478. super
  479. self.bitmap.dispose
  480. end
  481. #-----------------------------------------------------------------------------
  482. #
  483. #-----------------------------------------------------------------------------
  484. def update
  485. super
  486. update_spawn
  487. updt_particle
  488. init_particle if respawn_time?
  489. end
  490. #-----------------------------------------------------------------------------
  491. #
  492. #-----------------------------------------------------------------------------
  493. def respawn_time?
  494. return true if @spawn_delay < 0 && outwith_screen?
  495. return false
  496. end
  497. #-----------------------------------------------------------------------------
  498. #
  499. #-----------------------------------------------------------------------------
  500. def update_spawn
  501. @spawn_delay -= 1
  502. end
  503. #-----------------------------------------------------------------------------
  504. #
  505. #-----------------------------------------------------------------------------
  506. def updt_particle
  507. update_move
  508. update_opac
  509. update_fadd
  510. update_angl
  511. update_zoom
  512. end
  513. #-----------------------------------------------------------------------------
  514. #
  515. #-----------------------------------------------------------------------------
  516. def update_move
  517. self.x += @x_move
  518. self.y += @y_move
  519. end
  520. #-----------------------------------------------------------------------------
  521. #
  522. #-----------------------------------------------------------------------------
  523. def update_opac
  524. return update_fade if @fading && @opac[2][0]
  525. self.opacity += @opac[1]
  526. end
  527. #-----------------------------------------------------------------------------
  528. #
  529. #-----------------------------------------------------------------------------
  530. def update_fade
  531. self.opacity += @opac[2][1]
  532. end
  533. #-----------------------------------------------------------------------------
  534. #
  535. #-----------------------------------------------------------------------------
  536. def update_fadd
  537. @fading = true if self.opacity >= 255 && @opac[2][0]
  538. end
  539. #-----------------------------------------------------------------------------
  540. #
  541. #-----------------------------------------------------------------------------
  542. def update_angl
  543. self.angle += @angl_addd
  544. update_apop
  545. end
  546. #-----------------------------------------------------------------------------
  547. #
  548. #-----------------------------------------------------------------------------
  549. def update_zoom
  550. @x_zoom += @grow
  551. @y_zoom += @grow
  552. self.zoom_x = @x_zoom
  553. self.zoom_y = @y_zoom
  554. update_zpop
  555. end
  556. #-----------------------------------------------------------------------------
  557. #
  558. #-----------------------------------------------------------------------------
  559. def update_apop
  560. if @anglepopping
  561. self.opacity -= @apop[1]
  562. end
  563. return unless @apop[0]
  564. @anglepopping = true if self.angle <= -@apop[0]
  565. @anglepopping = true if self.angle >= @apop[0]
  566. end
  567. #-----------------------------------------------------------------------------
  568. #
  569. #-----------------------------------------------------------------------------
  570. def update_zpop
  571. if @zoompopping
  572. self.opacity -= @zpop[3]
  573. end
  574. return unless @zpop[0]
  575. @zoompopping = true if self.zoom_x <= @zpop[1]
  576. @zoompopping = true if self.zoom_x >= @zpop[2]
  577. @zoompopping = true if self.zoom_y <= @zpop[1]
  578. @zoompopping = true if self.zoom_y >= @zpop[2]
  579. end
  580. #-----------------------------------------------------------------------------
  581. #
  582. #-----------------------------------------------------------------------------
  583. def outwith_screen?
  584. buff = DekitaParticles::Screen_Buffer
  585. return true if ( (self.x) < -buff || (self.x) > (@mx+buff) )
  586. return true if ( (self.y) < -buff || (self.y) > (@my+buff) )
  587. return false
  588. end
  589. end
  590. #===============================================================================
  591. class Particle_Spriteset
  592. #===============================================================================
  593. #-----------------------------------------------------------------------------
  594. #
  595. #-----------------------------------------------------------------------------
  596. attr_accessor :particle_vp
  597. attr_accessor :particles
  598. #-----------------------------------------------------------------------------
  599. #
  600. #-----------------------------------------------------------------------------
  601. def initialize
  602. init_module
  603. init_partvp
  604. init_particles
  605. end
  606. #-----------------------------------------------------------------------------
  607. #
  608. #-----------------------------------------------------------------------------
  609. def dispose
  610. disp_particles
  611. end
  612. #-----------------------------------------------------------------------------
  613. #
  614. #-----------------------------------------------------------------------------
  615. def update
  616. updt_particles
  617. end
  618. #-----------------------------------------------------------------------------
  619. #
  620. #-----------------------------------------------------------------------------
  621. def init_module
  622. @module = DekitaParticles
  623. end
  624. #-----------------------------------------------------------------------------
  625. #
  626. #-----------------------------------------------------------------------------
  627. def init_partvp
  628. @particlevp = nil
  629. end
  630. #-----------------------------------------------------------------------------
  631. #
  632. #-----------------------------------------------------------------------------
  633. def init_particles
  634. disp_particles
  635. paarticles = scene_particles
  636. return unless paarticles
  637. @particles = []
  638. paarticles.each do |particle|
  639. make_particle(particle)
  640. end
  641. updt_particles
  642. end
  643. #-----------------------------------------------------------------------------
  644. #
  645. #-----------------------------------------------------------------------------
  646. def scene_particles
  647. @module.particles(SceneManager.scene.class.name) || []
  648. end
  649. #-----------------------------------------------------------------------------
  650. #
  651. #-----------------------------------------------------------------------------
  652. def particle_count(particle)
  653. @module::Type[particle]['amnt']
  654. end
  655. #-----------------------------------------------------------------------------
  656. #
  657. #-----------------------------------------------------------------------------
  658. def make_particle(particle)
  659. return unless particle
  660. particle_count(particle).to_i.times do
  661. add_particle_to_arr(particle)
  662. end
  663. end
  664. #-----------------------------------------------------------------------------
  665. #
  666. #-----------------------------------------------------------------------------
  667. def add_particle_to_arr(particle)
  668. return unless @particles
  669. @particles << Particle_Core.new(@module::Type[particle],@particlevp,particle)
  670. end
  671. #-----------------------------------------------------------------------------
  672. #
  673. #-----------------------------------------------------------------------------
  674. def disp_particles
  675. return unless @particles
  676. @particles.each do |particle|
  677. particle.dispose
  678. end
  679. @particles = []
  680. end
  681. #-----------------------------------------------------------------------------
  682. #
  683. #-----------------------------------------------------------------------------
  684. def updt_particles
  685. return unless @particles
  686. @particles.each do |particle|
  687. particle.update
  688. end
  689. end
  690. end
  691. #===============================================================================
  692. class Game_Map
  693. #===============================================================================
  694. #-----------------------------------------------------------------------------
  695. #
  696. #-----------------------------------------------------------------------------
  697. alias :setup_particle_fog :setup
  698. alias :sdp_for_fog :set_display_pos
  699. alias :s_d_for_fog :scroll_down
  700. alias :s_l_for_fog :scroll_left
  701. alias :s_r_for_fog :scroll_right
  702. alias :s_u_for_fog :scroll_up
  703. alias :update_for_fog :update_parallax
  704. #-----------------------------------------------------------------------------
  705. #
  706. #-----------------------------------------------------------------------------
  707. attr_reader :particle_x
  708. attr_reader :particle_y
  709. attr_reader :particle_sx
  710. attr_reader :particle_sy
  711. attr_reader :particle_loopx
  712. attr_reader :particle_loopy
  713. #-----------------------------------------------------------------------------
  714. #
  715. #-----------------------------------------------------------------------------
  716. def setup(map_id)
  717. setup_particle_fog(map_id)
  718. setup_particle
  719. end
  720. #-----------------------------------------------------------------------------
  721. #
  722. #-----------------------------------------------------------------------------
  723. def setup_particle
  724. @particle_x = 0
  725. @particle_y = 0
  726. @particle_sx = 0
  727. @particle_sy = 0
  728. @particle_loopx = @particle_sx != 0 ? @particle_sx : 0
  729. @particle_loopy = @particle_sy != 0 ? @particle_sy : 0
  730. end
  731. #-----------------------------------------------------------------------------
  732. #
  733. #-----------------------------------------------------------------------------
  734. def set_display_pos(x, y)
  735. sdp_for_fog(x, y)
  736. @particle_x = x
  737. @particle_y = y
  738. end
  739. #-----------------------------------------------------------------------------
  740. #
  741. #-----------------------------------------------------------------------------
  742. def scroll_up(distance)
  743. last_y = @display_y
  744. s_u_for_fog(distance)
  745. fog_scroll_up(distance, last_y)
  746. end
  747. #-----------------------------------------------------------------------------
  748. #
  749. #-----------------------------------------------------------------------------
  750. def scroll_down(distance)
  751. last_y = @display_y
  752. s_d_for_fog(distance)
  753. fog_scroll_down(distance, last_y)
  754. end
  755. #-----------------------------------------------------------------------------
  756. #
  757. #-----------------------------------------------------------------------------
  758. def scroll_left(distance)
  759. last_x = @display_x
  760. s_l_for_fog(distance)
  761. fog_scroll_left(distance, last_x)
  762. end
  763. #-----------------------------------------------------------------------------
  764. #
  765. #-----------------------------------------------------------------------------
  766. def scroll_right(distance)
  767. last_x = @display_x
  768. s_r_for_fog(distance)
  769. fog_scroll_right(distance, last_x)
  770. end
  771. #-----------------------------------------------------------------------------
  772. #
  773. #-----------------------------------------------------------------------------
  774. def fog_scroll_up(distance, last_y)
  775. value = loop_vertical? ? -distance : @display_y - last_y
  776. @particle_y += value
  777. end
  778. #-----------------------------------------------------------------------------
  779. #
  780. #-----------------------------------------------------------------------------
  781. def fog_scroll_down(distance, last_y)
  782. value = loop_vertical? ? distance : @display_y - last_y
  783. @particle_y += value
  784. end
  785. #-----------------------------------------------------------------------------
  786. #
  787. #-----------------------------------------------------------------------------
  788. def fog_scroll_left(distance, last_x)
  789. value = loop_horizontal? ? -distance : @display_x - last_x
  790. @particle_x += value
  791. end
  792. #-----------------------------------------------------------------------------
  793. #
  794. #-----------------------------------------------------------------------------
  795. def fog_scroll_right(distance, last_x)
  796. value = loop_horizontal? ? distance : @display_x - last_x
  797. @particle_x += value
  798. end
  799. #-----------------------------------------------------------------------------
  800. #
  801. #-----------------------------------------------------------------------------
  802. def update_parallax
  803. update_for_fog
  804. update_fog
  805. end
  806. #-----------------------------------------------------------------------------
  807. #
  808. #-----------------------------------------------------------------------------
  809. def update_fog
  810. @particle_x += @particle_sx / 128.0 if @particle_loopx
  811. @particle_y += @particle_sy / 128.0 if @particle_loopy
  812. end
  813. end
  814. #===============================================================================
  815. class Scene_Base
  816. #===============================================================================
  817. #-----------------------------------------------------------------------------
  818. #
  819. #-----------------------------------------------------------------------------
  820. attr_accessor :particle_spriteset
  821. #-----------------------------------------------------------------------------
  822. #
  823. #-----------------------------------------------------------------------------
  824. alias :sd13x_particle_start :start
  825. alias :dispo_particle_sd13x :terminate
  826. alias :updat_particle_sd13x :update
  827. #-----------------------------------------------------------------------------
  828. #
  829. #-----------------------------------------------------------------------------
  830. def start
  831. sd13x_particle_start
  832. create_scene_particles
  833. end
  834. #-----------------------------------------------------------------------------
  835. #
  836. #-----------------------------------------------------------------------------
  837. def terminate
  838. dispo_particle_sd13x
  839. dispose_scene_particles
  840. end
  841. #-----------------------------------------------------------------------------
  842. #
  843. #-----------------------------------------------------------------------------
  844. def update
  845. updat_particle_sd13x
  846. update_scene_particles
  847. end
  848. #-----------------------------------------------------------------------------
  849. #
  850. #-----------------------------------------------------------------------------
  851. def create_scene_particles
  852. dispose_scene_particles
  853. @particle_spriteset = Particle_Spriteset.new
  854. end
  855. #-----------------------------------------------------------------------------
  856. #
  857. #-----------------------------------------------------------------------------
  858. def dispose_scene_particles
  859. return unless @particle_spriteset
  860. @particle_spriteset.dispose
  861. @particle_spriteset = nil
  862. end
  863. #-----------------------------------------------------------------------------
  864. #
  865. #-----------------------------------------------------------------------------
  866. def update_scene_particles
  867. return unless @particle_spriteset
  868. @particle_spriteset.update
  869. end
  870. #-----------------------------------------------------------------------------
  871. #
  872. #-----------------------------------------------------------------------------
  873. def transition_speed
  874. return DekitaParticles::Transition_Speed
  875. end
  876. end
  877. #===============================================================================#
  878. # http://dekitarpg.wordpress.com/ #
  879. #===============================================================================#
  880. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement