Guest User

Untitled

a guest
Apr 8th, 2017
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 61.43 KB | None | 0 0
  1. #===============================================================================
  2. # Elite Battle system
  3. # by Luka S.J.
  4. # ----------------
  5. # Animations Script
  6. # ----------------
  7. # system is based off the original Essentials battle system, made by
  8. # Poccil & Maruno
  9. # No additional features added to AI, mechanics
  10. # or functionality of the battle system.
  11. # This update is purely cosmetic, and includes a B/W like dynamic scene with a
  12. # custom interface.
  13. #
  14. # Enjoy the script, and make sure to give credit!
  15. # (DO NOT ALTER THE NAMES OF THE INDIVIDUAL SCRIPT SECTIONS OR YOU WILL BREAK
  16. # YOUR SYSTEM!)
  17. #-------------------------------------------------------------------------------
  18. # Core alterations to the animation player.
  19. # Additional functions added to help with sprite animations and their
  20. # positioning.
  21. #===============================================================================
  22. class PokeBattle_Scene
  23. attr_reader :vector
  24. def getWeatherAnim(weather)
  25. # v 15.x
  26. # 0: No weather, 1: Rain, 2: Storm, 3: Snow, 4: Sandstorm, 5: Sunny, 6: Heavy rain, 7: Blizzard
  27. # v 16.x
  28. # 0: No weather, 1: Rain, 2: Storm, 3: Snow, 4: Blizzard, 5: Sandstorm, 6: Heavy rain, 7: Sunny
  29. case weather
  30. when PBWeather::SUNNYDAY
  31. return isVersion15? ? 5 : 7
  32. when PBWeather::RAINDANCE
  33. return 1
  34. when PBWeather::SANDSTORM
  35. return isVersion15? ? 4 : 5
  36. when PBWeather::HAIL
  37. return 3
  38. else
  39. return isVersion15? ? 5 : 7 if PBWeather.const_defined?(:DESOLATELAND) && weather==PBWeather::DESOLATELAND
  40. return 6 if PBWeather.const_defined?(:PRIMORDIALSEA) && weather==PBWeather::PRIMORDIALSEA
  41. return 0
  42. end
  43. end
  44. #=============================================================================
  45. # Misc code to automize sprite animation and placement
  46. #=============================================================================
  47. def animateBattleSprites(align=false,smanim=false)
  48. updateSMSequence if $smAnim && !smanim
  49. ebSpecialSpecies_update if $specialSpecies && !smanim
  50. @vector.update
  51. alignBattleScene
  52. if !$smAnim && !$specialSpecies && !@safaribattle && (@animweather.nil? || @battle.weather!=@animweather) && EBUISTYLE > 0
  53. @sprites["weather"].type = getWeatherAnim(@battle.weather)
  54. @sprites["weather"].max = 36
  55. @sprites["weather"].ox = $game_map.display_x / 4
  56. @sprites["weather"].oy = $game_map.display_y / 4
  57. @animweather=@battle.weather
  58. end
  59. @sprites["weather"].update if @sprites["weather"] && !@sprites["weather"].disposed?
  60. @idleTimer+=1 if @idleTimer >= 0
  61. @lastMotion=nil if @idleTimer < 0
  62. @sprites["player"].x+=(40-@sprites["player"].x)/4 if @safaribattle && @sprites["player"] && @playerfix
  63. for i in 0...4
  64. if @sprites["pokemon#{i}"]
  65. if @sprites["pokemon#{i}"].loaded
  66. status=@battle.battlers[i].status
  67. case status
  68. when PBStatuses::SLEEP
  69. @sprites["pokemon#{i}"].actualBitmap.setSpeed(3)
  70. when PBStatuses::PARALYSIS
  71. @sprites["pokemon#{i}"].actualBitmap.setSpeed(2)
  72. @sprites["pokemon#{i}"].status=2
  73. when PBStatuses::FROZEN
  74. @sprites["pokemon#{i}"].actualBitmap.setSpeed(0)
  75. @sprites["pokemon#{i}"].status=3
  76. when PBStatuses::POISON
  77. @sprites["pokemon#{i}"].status=1
  78. when PBStatuses::BURN
  79. @sprites["pokemon#{i}"].status=4
  80. else
  81. @sprites["pokemon#{i}"].actualBitmap.setSpeed(1)
  82. @sprites["pokemon#{i}"].status=0
  83. end
  84. end
  85. @sprites["pokemon#{i}"].update(@vector.angle+49)
  86. @sprites["battlebox#{i}"].update if @sprites["battlebox#{i}"] && @sprites["pokemon#{i}"].loaded
  87. end
  88. if !@orgPos.nil? && @idleTimer > (@lastMotion.nil? ? BATTLEMOTIONTIMER*Graphics.frame_rate : BATTLEMOTIONTIMER*Graphics.frame_rate*0.5) && @vector.finished? && !@safaribattle
  89. @vector.inc = 0.005*(rand(4)+1)
  90. loop do
  91. n = rand(RANDOM_CAMERA.length)
  92. if !(n==@lastMotion)
  93. @lastMotion=n
  94. break
  95. end
  96. end
  97. setVector(RANDOM_CAMERA[@lastMotion])
  98. #@idleTimer=0
  99. end
  100. next if !align
  101. base=(i%2==0) ? "playerbase" : "enemybase"
  102. zoom = (i%2==0) ? 2 : 1 #BACKSPRITESCALE : 1
  103. if @sprites["pokemon#{i}"]
  104. @sprites["pokemon#{i}"].x=@sprites["#{base}"].x
  105. @sprites["pokemon#{i}"].y=@sprites["#{base}"].y
  106. @sprites["pokemon#{i}"].zoom_x=@sprites["#{base}"].zoom_x*zoom
  107. @sprites["pokemon#{i}"].zoom_y=@sprites["#{base}"].zoom_y*zoom/@vector.zoom2
  108. @sprites["pokemon#{i}"].angle=@sprites["#{base}"].angle
  109. if @battle.doublebattle && i/2==0
  110. @sprites["pokemon#{i}"].x-=50*@sprites["pokemon#{i}"].zoom_x
  111. elsif @battle.doublebattle && i/2==1
  112. @sprites["pokemon#{i}"].x+=50*@sprites["pokemon#{i}"].zoom_x
  113. end
  114. @sprites["pokemon1"].x-=25*@sprites["pokemon1"].zoom_x if @battle.doublebattle && !USEBATTLEBASES
  115. @sprites["pokemon2"].x+=10*@sprites["pokemon2"].zoom_x if @battle.doublebattle && !USEBATTLEBASES
  116. @sprites["pokemon2"].y+=10*@sprites["pokemon2"].zoom_x if @battle.doublebattle && !USEBATTLEBASES
  117. end
  118. for t in 0...2
  119. n=(t==0) ? "" : "2"
  120. if @sprites["trainer#{n}"]
  121. @sprites["trainer#{n}"].x=@sprites["enemybase"].x
  122. @sprites["trainer#{n}"].y=@sprites["enemybase"].y
  123. @sprites["trainer#{n}"].angle=@sprites["enemybase"].angle
  124. @sprites["trainer#{n}"].zoom_x=@sprites["enemybase"].zoom_x
  125. @sprites["trainer#{n}"].zoom_y=@sprites["enemybase"].zoom_y/@vector.zoom2
  126. end
  127. end
  128. end
  129. end
  130.  
  131. def moveEntireScene(x=0,y=0,lock=true,bypass=false,except=nil)
  132. unless bypass
  133. return if DISABLESCENEMOTION
  134. return if EBUISTYLE==0 && defined?(SCREENDUALHEIGHT)
  135. end
  136. for i in 0...4
  137. next if !i.nil? && i == except
  138. @sprites["pokemon#{i}"].x+=x if @sprites["pokemon#{i}"]
  139. @sprites["pokemon#{i}"].y+=y if @sprites["pokemon#{i}"]
  140. end
  141. @vector.x+=x
  142. @vector.y+=y
  143. return if !lock
  144. return if @orgPos.nil?
  145. @orgPos[0]+=x
  146. @orgPos[1]+=y
  147. end
  148.  
  149. def moveUpperRight(cw=nil)
  150. if !DISABLESCENEMOTION
  151. @vector.lock
  152. @vector.inc=0.2
  153. @vector.add("x",40)
  154. @vector.add("y",-20)
  155. @vector.add("scale",-30)
  156. @vector.add("angle",-0)
  157. @vector.add("zoom2",-0.1)
  158. if !@orgPos.nil?
  159. @orgPos[0]+=40
  160. @orgPos[1]+=-20
  161. @orgPos[3]+=-30
  162. @orgPos[2]+=-0
  163. end
  164. end
  165. 10.times do
  166. cw.show if !cw.nil?
  167. wait(1,true)
  168. end
  169. end
  170.  
  171. def moveLowerLeft(cw=nil)
  172. if !DISABLESCENEMOTION
  173. @vector.lock
  174. @vector.inc=0.2
  175. @vector.add("x",-40)
  176. @vector.add("y",20)
  177. @vector.add("scale",30)
  178. @vector.add("angle",0)
  179. @vector.add("zoom2",0.1)
  180. if !@orgPos.nil?
  181. @orgPos[0]+=-40
  182. @orgPos[1]+=20
  183. @orgPos[3]+=30
  184. @orgPos[2]+=0
  185. end
  186. end
  187. 10.times do
  188. cw.hide if !cw.nil?
  189. wait(1,true)
  190. end
  191. end
  192.  
  193. def moveRight(cw=nil)
  194. if !DISABLESCENEMOTION
  195. @vector.lock
  196. @vector.inc=0.2
  197. @vector.add("x",80)
  198. if !@orgPos.nil?
  199. @orgPos[0]+=80
  200. end
  201. end
  202. 10.times do
  203. cw.show if !cw.nil?
  204. wait(1,true)
  205. end
  206. end
  207.  
  208. def moveLeft(cw=nil)
  209. if !DISABLESCENEMOTION
  210. @vector.lock
  211. @vector.inc=0.2
  212. @vector.add("x",-80)
  213. if !@orgPos.nil?
  214. @orgPos[0]+=-80
  215. end
  216. end
  217. 10.times do
  218. cw.hide if !cw.nil?
  219. wait(1,true)
  220. end
  221. end
  222.  
  223. def wait(frames,align=false)
  224. frames.times do
  225. animateBattleSprites(align,$smAnim || $specialSpecies)
  226. Graphics.update if !$smAnim && !$specialSpecies
  227. end
  228. end
  229.  
  230. def setVector(*args)
  231. return if DISABLESCENEMOTION
  232. if args[0].is_a?(Array)
  233. x,y,angle,scale,zoom1,zoom2 = args[0]
  234. else
  235. x,y,angle,scale,zoom1,zoom2 = args
  236. end
  237. vector = @battle.doublebattle ? VECTOR2 : VECTOR1
  238. @vector.set(x+@orgPos[0]-vector[0],y+@orgPos[1]-vector[1],
  239. angle+@orgPos[2]-vector[2],scale+@orgPos[3]-vector[3],
  240. zoom1+@orgPos[4]-vector[4],zoom2)
  241. end
  242.  
  243. def alignBattleScene
  244. vector = @battle.doublebattle ? VECTOR2 : VECTOR1
  245. @sprites["battlebg"].update
  246. @sprites["enemybase"].x=(@vector.x2).to_i
  247. @sprites["enemybase"].y=(@vector.y2).to_i
  248. @sprites["enemybase"].zoom_x=(@vector.zoom1)
  249. @sprites["enemybase"].zoom_y=(@vector.zoom1)*(@vector.zoom2)
  250. @sprites["enemybase"].angle=(@vector.locked?) ? 0 : (@sprites["battlebg"].angle).to_i if self.sendingOut
  251. @sprites["playerbase"].x=(@vector.x).to_i
  252. @sprites["playerbase"].y=(@vector.y).to_i
  253. @sprites["playerbase"].zoom_x=(@vector.zoom1)
  254. @sprites["playerbase"].zoom_y=(@vector.zoom1)*(@vector.zoom2)
  255. @sprites["playerbase"].angle=(@vector.locked?) ? 0 : (@sprites["battlebg"].angle).to_i if self.sendingOut
  256. end
  257.  
  258. def revertMoveTransformations(index)
  259. if @sprites["pokemon#{index}"] && @sprites["pokemon#{index}"].hidden
  260. @sprites["pokemon#{index}"].hidden = false
  261. @sprites["pokemon#{index}"].visible = true
  262. end
  263. end
  264.  
  265. #=============================================================================
  266. # Common animations player
  267. #=============================================================================
  268. alias pbCommonAnimation_ebs pbCommonAnimation unless self.method_defined?(:pbCommonAnimation_ebs)
  269. def pbCommonAnimation(animname,user,target,hitnum=0)
  270. return false if ["Rain","Hail","Sandstorm","Sunny","ShadowSky","HealthDown"].include?(animname)
  271. return false if ["MegaEvolution","MegaEvolution2"].include?(animname) && !CUSTOMANIMATIONS
  272. anm = "pbCommonAnimation"+animname
  273. target = user if target.nil?
  274. # return pbCommonAnimationStatUp(user.index,target.index,hitnum)
  275. if eval("defined?(#{anm})")
  276. return eval("#{anm}(#{user.index},#{target.index},#{hitnum})") if !CUSTOMANIMATIONS
  277. end
  278. return pbCommonAnimation_ebs(animname,user,target,hitnum)
  279. end
  280.  
  281. # Burned
  282. def pbCommonAnimationBurn(userindex,targetindex,hitnum=0)
  283. wait(16,true) if self.afterAnim
  284. poke = @sprites["pokemon#{targetindex}"]
  285. player = (targetindex%2==0)
  286. fp = {}
  287. rndx = []
  288. rndy = []
  289. shake = 2
  290. k = -1
  291. factor = player ? 1 : 0.5
  292. cx, cy = getCenter(poke,true)
  293. for i in 0...3
  294. fp["#{i}"] = Sprite.new(poke.viewport)
  295. fp["#{i}"].bitmap = pbBitmap("Graphics/Animations/eb136")
  296. fp["#{i}"].src_rect.set(0,101*rand(3),53,101)
  297. fp["#{i}"].ox = 26
  298. fp["#{i}"].oy = 101
  299. fp["#{i}"].opacity = 0
  300. fp["#{i}"].z = (player ? 29 : 19)
  301. rndx.push(rand(64))
  302. rndy.push(rand(64))
  303. fp["#{i}"].x = cx - 32*factor + rndx[i]*factor
  304. fp["#{i}"].y = cy - 32*factor + rndy[i]*factor + 50*factor
  305. end
  306. pbSEPlay("eb_fire1",80)
  307. for i in 0...32
  308. k *= -1 if i%16==0
  309. for j in 0...3
  310. if fp["#{j}"].opacity == 0 && fp["#{j}"].tone.gray == 0
  311. fp["#{j}"].zoom_x = factor
  312. fp["#{j}"].zoom_y = factor
  313. fp["#{j}"].y -= 2*factor
  314. end
  315. next if j>(i/4)
  316. fp["#{j}"].src_rect.x += 53 if i%4==0
  317. fp["#{j}"].src_rect.x = 0 if fp["#{j}"].src_rect.x >= fp["#{j}"].bitmap.width
  318. if fp["#{j}"].opacity == 255 || fp["#{j}"].tone.gray > 0
  319. fp["#{j}"].opacity -= 16
  320. fp["#{j}"].tone.gray += 8
  321. fp["#{j}"].tone.red -= 2; fp["#{j}"].tone.green -= 2; fp["#{j}"].tone.blue -= 2
  322. fp["#{j}"].zoom_x -= 0.01
  323. fp["#{j}"].zoom_y += 0.02
  324. else
  325. fp["#{j}"].opacity += 51
  326. end
  327. end
  328. poke.tone.red += 2.4*k
  329. poke.tone.green -= 1.2*k
  330. poke.tone.blue -= 2.4*k
  331. poke.addOx(shake)
  332. shake = -2 if poke.ox > poke.bitmap.width/2 + 2
  333. shake = 2 if poke.ox < poke.bitmap.width/2 - 2
  334. poke.still
  335. wait(1,true)
  336. end
  337. poke.ox = poke.bitmap.width/2
  338. pbDisposeSpriteHash(fp)
  339. end
  340.  
  341. # Poisoned
  342. def pbCommonAnimationPoison(userindex,targetindex,hitnum=0)
  343. return if targetindex.nil?
  344. wait(16,true) if self.afterAnim
  345. poke = @sprites["pokemon#{targetindex}"]
  346. player = (targetindex%2==0)
  347. fp = {}
  348. shake = 1
  349. k = -0.1
  350. inc = 1
  351. factor = poke.zoom_x
  352. cx, cy = getCenter(poke,true)
  353. endy = []
  354. for j in 0...12
  355. fp["#{j}"] = Sprite.new(poke.viewport)
  356. fp["#{j}"].bitmap = pbBitmap("Graphics/Animations/ebPoison#{rand(3)+1}")
  357. fp["#{j}"].ox = fp["#{j}"].bitmap.width/2
  358. fp["#{j}"].oy = fp["#{j}"].bitmap.height/2
  359. fp["#{j}"].x = cx - 48*factor + rand(96)*factor
  360. fp["#{j}"].y = cy
  361. z = [1,0.9,0.8][rand(3)]
  362. fp["#{j}"].zoom_x = z*factor
  363. fp["#{j}"].zoom_y = z*factor
  364. fp["#{j}"].opacity = 0
  365. fp["#{j}"].z = player ? 29 : 19
  366. endy.push(cy - 64*factor - rand(32)*factor)
  367. end
  368. for i in 0...32
  369. pbSEPlay("eb_poison1",80) if i%8==0
  370. poke.addOx(shake)
  371. k *= -1 if i%16==0
  372. inc += k
  373. for j in 0...12
  374. next if j>(i/2)
  375. fp["#{j}"].y -= (fp["#{j}"].y - endy[j])*0.06
  376. fp["#{j}"].opacity += 51 if i < 16
  377. fp["#{j}"].opacity -= 16 if i >= 16
  378. fp["#{j}"].x -= 1*factor*(fp["#{j}"].x < cx ? 1 : -1)
  379. fp["#{j}"].angle += 4*(fp["#{j}"].x < cx ? 1 : -1)
  380. end
  381. shake = -1*inc.round if poke.ox > poke.bitmap.width/2# + 2*inc.round
  382. shake = 1*inc.round if poke.ox < poke.bitmap.width/2# - 2*inc.round
  383. poke.still
  384. poke.color.alpha += k*60
  385. poke.anim = true
  386. wait(1,true)
  387. end
  388. poke.ox = poke.bitmap.width/2
  389. pbDisposeSpriteHash(fp)
  390. end
  391.  
  392. # Frozen
  393. def pbCommonAnimationFrozen(userindex,targetindex,hitnum=0)
  394. return if targetindex.nil?
  395. wait(16,true) if self.afterAnim
  396. poke = @sprites["pokemon#{targetindex}"]
  397. player = (targetindex%2==0)
  398. fp = {}
  399. rndx = []
  400. rndy = []
  401. shake = 2
  402. k = -1
  403. factor = poke.zoom_x
  404. for i in 0...12
  405. fp["#{i}"] = Sprite.new(poke.viewport)
  406. fp["#{i}"].bitmap = pbBitmap("Graphics/Animations/eb248")
  407. fp["#{i}"].src_rect.set(rand(2)*26,0,26,42)
  408. fp["#{i}"].ox = 13
  409. fp["#{i}"].oy = 21
  410. fp["#{i}"].opacity = 0
  411. fp["#{i}"].z = (player ? 29 : 19)
  412. r = rand(101)
  413. fp["#{i}"].zoom_x = (factor - r*0.0075*factor)
  414. fp["#{i}"].zoom_y = (factor - r*0.0075*factor)
  415. rndx.push(rand(96))
  416. rndy.push(rand(96))
  417. end
  418. pbSEPlay("eb_ice1")
  419. for i in 0...32
  420. k *= -1 if i%8==0
  421. for j in 0...12
  422. next if j>(i/2)
  423. if fp["#{j}"].opacity == 0
  424. cx, cy = getCenter(poke,true)
  425. fp["#{j}"].x = cx - 48*factor + rndx[j]*factor
  426. fp["#{j}"].y = cy - 48*factor + rndy[j]*factor
  427. end
  428. fp["#{j}"].src_rect.x += 26 if i%4==0 && fp["#{j}"].opacity >= 255
  429. fp["#{j}"].src_rect.x = 78 if fp["#{j}"].src_rect.x > 78
  430. if fp["#{j}"].src_rect.x==78
  431. fp["#{j}"].opacity -= 24
  432. fp["#{j}"].zoom_x += 0.02
  433. fp["#{j}"].zoom_y += 0.02
  434. elsif fp["#{j}"].opacity >= 255
  435. fp["#{j}"].opacity -= 24
  436. else
  437. fp["#{j}"].opacity += 45 if (i)/2 > k
  438. end
  439. end
  440. poke.tone.red += 3.2*k
  441. poke.tone.green += 3.2*k
  442. poke.tone.blue += 3.2*k
  443. poke.still
  444. wait(1,true)
  445. end
  446. pbDisposeSpriteHash(fp)
  447. end
  448.  
  449. # Paralyzed
  450. def pbCommonAnimationParalysis(userindex,targetindex,hitnum=0)
  451. return if targetindex.nil?
  452. wait(16,true) if self.afterAnim
  453. poke = @sprites["pokemon#{targetindex}"]
  454. player = (targetindex%2==0)
  455. fp = {}
  456. k = -1
  457. factor = poke.zoom_x
  458. for i in 0...12
  459. fp["#{i}"] = Sprite.new(poke.viewport)
  460. fp["#{i}"].bitmap = pbBitmap("Graphics/Animations/eb064_3")
  461. fp["#{i}"].ox = fp["#{i}"].bitmap.width/2
  462. fp["#{i}"].oy = fp["#{i}"].bitmap.height/2
  463. fp["#{i}"].opacity = 0
  464. fp["#{i}"].z = player ? 29 : 19
  465. end
  466. pbSEPlay("eb_electric1")
  467. for i in 0...32
  468. k *= -1 if i%16==0
  469. for n in 0...12
  470. next if n>(i/2)
  471. if fp["#{n}"].opacity == 0 && fp["#{n}"].tone.gray == 0
  472. r = rand(2); r2 = rand(4)
  473. fp["#{n}"].zoom_x = [0.2,0.25,0.5,0.75][r2]
  474. fp["#{n}"].zoom_y = [0.2,0.25,0.5,0.75][r2]
  475. cx, cy = getCenter(poke,true)
  476. x, y = randCircleCord(32*factor)
  477. fp["#{n}"].x = cx - 32*factor*poke.zoom_x + x*poke.zoom_x
  478. fp["#{n}"].y = cy - 32*factor*poke.zoom_y + y*poke.zoom_y
  479. fp["#{n}"].angle = -Math.atan(1.0*(fp["#{n}"].y-cy)/(fp["#{n}"].x-cx))*(180.0/Math::PI) + rand(2)*180 + rand(90)
  480. end
  481. fp["#{n}"].opacity += 155 if i < 27
  482. fp["#{n}"].angle += 180 if i%2==0
  483. fp["#{n}"].opacity -= 51 if i >= 27
  484. end
  485. poke.tone.red -= 14*k
  486. poke.tone.green -= 14*k
  487. poke.tone.blue -= 14*k
  488. poke.still
  489. wait(1,true)
  490. end
  491. pbDisposeSpriteHash(fp)
  492. end
  493.  
  494. # Shiny
  495. def pbCommonAnimationShiny(userindex,targetindex,hitnum=0)
  496. return if targetindex.nil?
  497. wait(16,true) if self.afterAnim
  498. poke = @sprites["pokemon#{targetindex}"]
  499. player = (targetindex%2==0)
  500. fp = {}
  501. k = -1
  502. factor = poke.zoom_x
  503. for i in 0...16
  504. cx, cy = getCenter(poke,true)
  505. fp["#{i}"] = Sprite.new(poke.viewport)
  506. str = "Graphics/Animations/ebShiny1"
  507. str = "Graphics/Animations/ebShiny2" if i >= 8
  508. fp["#{i}"].bitmap = pbBitmap(str)
  509. fp["#{i}"].ox = fp["#{i}"].bitmap.width/2
  510. fp["#{i}"].oy = fp["#{i}"].bitmap.height/2
  511. fp["#{i}"].x = cx
  512. fp["#{i}"].y = cy
  513. fp["#{i}"].zoom_x = factor
  514. fp["#{i}"].zoom_y = factor
  515. fp["#{i}"].opacity = 0
  516. fp["#{i}"].z = player ? 29 : 19
  517. end
  518. for j in 0...8
  519. fp["s#{j}"] = Sprite.new(poke.viewport)
  520. fp["s#{j}"].bitmap = pbBitmap("Graphics/Animations/ebShiny3")
  521. fp["s#{j}"].ox = fp["s#{j}"].bitmap.width/2
  522. fp["s#{j}"].oy = fp["s#{j}"].bitmap.height/2
  523. fp["s#{j}"].opacity = 0
  524. z = [1,0.75,1.25,0.5][rand(4)]*factor
  525. fp["s#{j}"].zoom_x = z
  526. fp["s#{j}"].zoom_y = z
  527. cx, cy = getCenter(poke,true)
  528. fp["s#{j}"].x = cx - 32*factor + rand(64)*factor
  529. fp["s#{j}"].y = cy - 32*factor + rand(64)*factor
  530. fp["s#{j}"].opacity = 0
  531. fp["s#{j}"].z = player ? 29 : 19
  532. end
  533. pbSEPlay("shiny")
  534. for i in 0...48
  535. k *= -1 if i%24==0
  536. cx, cy = getCenter(poke,true)
  537. for j in 0...16
  538. next if (j >= 8 && i < 16)
  539. a = (j < 8 ? -30 : -15) + 45*(j%8) + i*2
  540. r = poke.bitmap.width*factor/2.5
  541. x = cx + r*Math.cos(a*(Math::PI/180))
  542. y = cy - r*Math.sin(a*(Math::PI/180))
  543. x = (x - fp["#{j}"].x)*0.1
  544. y = (y - fp["#{j}"].y)*0.1
  545. fp["#{j}"].x += x
  546. fp["#{j}"].y += y
  547. fp["#{j}"].angle += 8
  548. if j < 8
  549. fp["#{j}"].opacity += 51 if i < 16
  550. if i >= 16
  551. fp["#{j}"].opacity -= 16
  552. fp["#{j}"].zoom_x -= 0.04*factor
  553. fp["#{j}"].zoom_y -= 0.04*factor
  554. end
  555. else
  556. fp["#{j}"].opacity += 51 if i < 32
  557. if i >= 32
  558. fp["#{j}"].opacity -= 16
  559. fp["#{j}"].zoom_x -= 0.02*factor
  560. fp["#{j}"].zoom_y -= 0.02*factor
  561. end
  562. end
  563. end
  564. poke.tone.red += 3.2*k/2
  565. poke.tone.green += 3.2*k/2
  566. poke.tone.blue += 3.2*k/2
  567. wait(1,true)
  568. end
  569. pbSEPlay("eb_shine1",80)
  570. for i in 0...16
  571. for j in 0...8
  572. next if j>i
  573. fp["s#{j}"].opacity += 51
  574. fp["s#{j}"].zoom_x -= fp["s#{j}"].zoom_x*0.25 if fp["s#{j}"].opacity >= 255
  575. fp["s#{j}"].zoom_y -= fp["s#{j}"].zoom_y*0.25 if fp["s#{j}"].opacity >= 255
  576. end
  577. wait(1,true)
  578. end
  579. pbDisposeSpriteHash(fp)
  580. end
  581.  
  582. # Confused
  583. def pbCommonAnimationConfusion(userindex,targetindex,hitnum=0)
  584. return if targetindex.nil?
  585. wait(16,true) if self.afterAnim
  586. poke = @sprites["pokemon#{targetindex}"]
  587. player = (targetindex%2==0)
  588. fp = {}
  589. k = -1
  590. factor = poke.zoom_x
  591. reversed = []
  592. cx, cy = getCenter(poke,true)
  593. width = 128*factor
  594. for j in 0...8
  595. fp["#{j}"] = Sprite.new(poke.viewport)
  596. fp["#{j}"].bitmap = pbBitmap("Graphics/Animations/ebConfused")
  597. fp["#{j}"].ox = fp["#{j}"].bitmap.width/2
  598. fp["#{j}"].oy = fp["#{j}"].bitmap.height/2
  599. fp["#{j}"].zoom_x = factor
  600. fp["#{j}"].zoom_y = factor
  601. fp["#{j}"].opacity
  602. fp["#{j}"].y = cy - 32*factor
  603. fp["#{j}"].x = cx + 64*factor - (j%4)*32*factor
  604. reversed.push([false,true][j/4])
  605. end
  606. vol = 80
  607. for i in 0...64
  608. k = i if i < 16
  609. pbSEPlay("eb_confusion1",vol) if i%8==0
  610. vol -= 5 if i%8==0
  611. for j in 0...8
  612. reversed[j] = true if fp["#{j}"].x <= cx - 64*factor
  613. reversed[j] = false if fp["#{j}"].x >= cx + 64*factor
  614. fp["#{j}"].z = reversed[j] ? poke.z - 1 : poke.z + 1
  615. fp["#{j}"].y = cy - 48*factor - k*2*factor - (reversed[j] ? 4*factor : 0)
  616. fp["#{j}"].x -= reversed[j] ? -4*factor : 4*factor
  617. fp["#{j}"].opacity += 16 if i < 16
  618. fp["#{j}"].opacity -= 16 if i >= 48
  619. end
  620. wait(1,true)
  621. end
  622. pbDisposeSpriteHash(fp)
  623. end
  624.  
  625. # Sleeping
  626. def pbCommonAnimationSleep(userindex,targetindex,hitnum=0)
  627. return if targetindex.nil?
  628. wait(16,true) if self.afterAnim
  629. poke = @sprites["pokemon#{targetindex}"]
  630. player = (targetindex%2==0)
  631. fp = {}
  632. k = -1
  633. r = []
  634. factor = poke.zoom_x
  635. for i in 0...3
  636. fp["#{i}"] = Sprite.new(poke.viewport)
  637. fp["#{i}"].bitmap = pbBitmap("Graphics/Animations/ebSleep")
  638. fp["#{i}"].ox = fp["#{i}"].bitmap.width/2
  639. fp["#{i}"].oy = fp["#{i}"].bitmap.height/2
  640. fp["#{i}"].angle = player ? 55 : 125
  641. fp["#{i}"].zoom_x = 0
  642. fp["#{i}"].zoom_y = 0
  643. fp["#{i}"].z = player ? 29 : 19
  644. fp["#{i}"].tone = Tone.new(192,192,192)
  645. r.push(0)
  646. end
  647. pbSEPlay("eb_snore",80)
  648. for j in 0...48
  649. cx, cy = getCenter(poke,true)
  650. for i in 0...3
  651. next if i>(j/12)
  652. fp["#{i}"].zoom_x += ((1*factor) - fp["#{i}"].zoom_x)*0.1
  653. fp["#{i}"].zoom_y += ((1*factor) - fp["#{i}"].zoom_y)*0.1
  654. a = player ? 55 : 125
  655. r[i] += 4*factor
  656. x = cx + r[i]*Math.cos(a*(Math::PI/180)) + 16*factor*(player ? 1 : -1)
  657. y = cy - r[i]*Math.sin(a*(Math::PI/180)) - 32*factor
  658. fp["#{i}"].x = x
  659. fp["#{i}"].y = y
  660. fp["#{i}"].opacity -= 16 if r[i] >= 64
  661. fp["#{i}"].tone.red -= 16 if fp["#{i}"].tone.red > 0
  662. fp["#{i}"].tone.green -= 16 if fp["#{i}"].tone.green > 0
  663. fp["#{i}"].tone.blue -= 16 if fp["#{i}"].tone.blue > 0
  664. fp["#{i}"].angle += player ? - 1 : 1
  665. end
  666. wait(1,true)
  667. end
  668. pbDisposeSpriteHash(fp)
  669. end
  670.  
  671. # Stat Down
  672. def pbCommonAnimationStatDown(userindex,targetindex,hitnum=0)
  673. return if targetindex.nil?
  674. wait(16,true) if self.afterAnim
  675. poke = @sprites["pokemon#{targetindex}"]
  676. player = (targetindex%2==0)
  677. pt = {}
  678. rndx = []
  679. rndy = []
  680. tone = []
  681. timer = []
  682. speed = []
  683. endy = poke.y - poke.bitmap.height*(player ? 1.5 : 1)
  684. for i in 0...64
  685. s = rand(2)
  686. y = rand(poke.bitmap.height*0.25)+1
  687. c = [Color.new(128,183,238),Color.new(74,128,208),Color.new(54,141,228)][rand(3)]
  688. pt["#{i}"] = Sprite.new(poke.viewport)
  689. pt["#{i}"].bitmap = Bitmap.new(14,14)
  690. pt["#{i}"].bitmap.drawCircle(c)
  691. pt["#{i}"].ox = pt["#{i}"].bitmap.width/2
  692. pt["#{i}"].oy = pt["#{i}"].bitmap.height/2
  693. width = (96/poke.bitmap.width*0.5).to_i
  694. pt["#{i}"].x = poke.x + rand((64 + width)*poke.zoom_x - 16)*(s==0 ? 1 : -1)
  695. #pt["#{i}"].x = poke.x + (rand(poke.bitmap.width*poke.zoom_x*0.6)-8)*(s==0 ? 1 : -1)
  696. pt["#{i}"].y = endy - y*poke.zoom_y
  697. pt["#{i}"].z = poke.z + (rand(2)==0 ? 1 : -1)
  698. r = rand(4)
  699. pt["#{i}"].zoom_x = poke.zoom_x*[1,0.9,0.95,0.85][r]*0.84
  700. pt["#{i}"].zoom_y = poke.zoom_y*[1,0.9,0.95,0.85][r]*0.84
  701. pt["#{i}"].opacity = 0
  702. pt["#{i}"].tone = Tone.new(128,128,128)
  703. tone.push(128)
  704. rndx.push(pt["#{i}"].x + rand(32)*(s==0 ? 1 : -1))
  705. rndy.push(poke.y + poke.bitmap.height - poke.oy)
  706. timer.push(0)
  707. speed.push((rand(50)+1)*0.002)
  708. end
  709. pbSEPlay("stat_down")
  710. for i in 0...64
  711. for j in 0...64
  712. next if j>(i*2)
  713. timer[j] += 1
  714. pt["#{j}"].x += (rndx[j] - pt["#{j}"].x)*speed[j]
  715. pt["#{j}"].y -= (pt["#{j}"].y - rndy[j])*speed[j]
  716. tone[j] -= 8 if tone[j] > 0
  717. pt["#{j}"].tone = Tone.new(tone[j],tone[j],tone[j])
  718. pt["#{j}"].angle += 4
  719. if timer[j] > 8
  720. pt["#{j}"].opacity -= 8
  721. pt["#{j}"].zoom_x -= 0.02*poke.zoom_x if pt["#{j}"].zoom_x > 0
  722. pt["#{j}"].zoom_y -= 0.02*poke.zoom_y if pt["#{j}"].zoom_y > 0
  723. else
  724. pt["#{j}"].opacity += 25 if pt["#{j}"].opacity < 200
  725. pt["#{j}"].zoom_x += 0.025*poke.zoom_x
  726. pt["#{j}"].zoom_y += 0.025*poke.zoom_y
  727. end
  728. end
  729. wait(1,true)
  730. end
  731. pbDisposeSpriteHash(pt)
  732. end
  733.  
  734. # Stat Up
  735. def pbCommonAnimationStatUp(userindex,targetindex,hitnum=0)
  736. return if targetindex.nil?
  737. wait(16,true) if self.afterAnim
  738. poke = @sprites["pokemon#{targetindex}"]
  739. player = (targetindex%2==0)
  740. pt = {}
  741. rndx = []
  742. rndy = []
  743. tone = []
  744. timer = []
  745. speed = []
  746. endy = poke.y - poke.bitmap.height*(player ? 1.5 : 1)
  747. for i in 0...64
  748. s = rand(2)
  749. y = rand(64)+1
  750. c = [Color.new(238,83,17),Color.new(236,112,19),Color.new(242,134,36)][rand(3)]
  751. pt["#{i}"] = Sprite.new(poke.viewport)
  752. pt["#{i}"].bitmap = Bitmap.new(14,14)
  753. pt["#{i}"].bitmap.drawCircle(c)
  754. pt["#{i}"].ox = pt["#{i}"].bitmap.width/2
  755. pt["#{i}"].oy = pt["#{i}"].bitmap.height/2
  756. width = (96/poke.bitmap.width*0.5).to_i
  757. pt["#{i}"].x = poke.x + rand((64 + width)*poke.zoom_x - 16)*(s==0 ? 1 : -1)
  758. #pt["#{i}"].x = poke.x + (rand(poke.bitmap.width*poke.zoom_x*0.4)-8)*(s==0 ? 1 : -1)
  759. pt["#{i}"].y = poke.y
  760. pt["#{i}"].z = poke.z + (rand(2)==0 ? 1 : -1)
  761. r = rand(4)
  762. pt["#{i}"].zoom_x = poke.zoom_x*[1,0.9,0.95,0.85][r]*0.84
  763. pt["#{i}"].zoom_y = poke.zoom_y*[1,0.9,0.95,0.85][r]*0.84
  764. pt["#{i}"].opacity = 0
  765. pt["#{i}"].tone = Tone.new(128,128,128)
  766. tone.push(128)
  767. rndx.push(pt["#{i}"].x + rand(32)*(s==0 ? 1 : -1))
  768. rndy.push(endy - y*poke.zoom_y)
  769. timer.push(0)
  770. speed.push((rand(50)+1)*0.002)
  771. end
  772. pbSEPlay("stat_up")
  773. for i in 0...64
  774. for j in 0...64
  775. next if j>(i*2)
  776. timer[j] += 1
  777. pt["#{j}"].x += (rndx[j] - pt["#{j}"].x)*speed[j]
  778. pt["#{j}"].y -= (pt["#{j}"].y - rndy[j])*speed[j]
  779. tone[j] -= 8 if tone[j] > 0
  780. pt["#{j}"].tone = Tone.new(tone[j],tone[j],tone[j])
  781. pt["#{j}"].angle += 4
  782. if timer[j] > 8
  783. pt["#{j}"].opacity -= 8
  784. pt["#{j}"].zoom_x -= 0.02*poke.zoom_x if pt["#{j}"].zoom_x > 0
  785. pt["#{j}"].zoom_y -= 0.02*poke.zoom_y if pt["#{j}"].zoom_y > 0
  786. else
  787. pt["#{j}"].opacity += 25 if pt["#{j}"].opacity < 200
  788. pt["#{j}"].zoom_x += 0.025*poke.zoom_x
  789. pt["#{j}"].zoom_y += 0.025*poke.zoom_y
  790. end
  791. end
  792. wait(1,true)
  793. end
  794. pbDisposeSpriteHash(pt)
  795. end
  796.  
  797. # Healing
  798. def pbCommonAnimationHealthUp(userindex,targetindex,hitnum=0)
  799. return if targetindex.nil?
  800. wait(16,true) if self.afterAnim
  801. poke = @sprites["pokemon#{targetindex}"]
  802. player = (targetindex%2==0)
  803. pt = {}
  804. rndx = []
  805. rndy = []
  806. tone = []
  807. timer = []
  808. speed = []
  809. endy = poke.y - poke.bitmap.height*(player ? 1.5 : 1)
  810. for i in 0...32
  811. s = rand(2)
  812. y = rand(64)+1
  813. c = [Color.new(92,202,81),Color.new(68,215,105),Color.new(192,235,180)][rand(3)]
  814. pt["#{i}"] = Sprite.new(poke.viewport)
  815. pt["#{i}"].bitmap = Bitmap.new(14,14)
  816. pt["#{i}"].bitmap.drawCircle(c)
  817. pt["#{i}"].ox = pt["#{i}"].bitmap.width/2
  818. pt["#{i}"].oy = pt["#{i}"].bitmap.height/2
  819. width = (96/poke.bitmap.width*0.5).to_i
  820. pt["#{i}"].x = poke.x + rand((64 + width)*poke.zoom_x - 32)*(s==0 ? 1 : -1)
  821. #pt["#{i}"].x = poke.x + (rand(poke.bitmap.width*poke.zoom_x*0.4)-8)*(s==0 ? 1 : -1)
  822. pt["#{i}"].y = poke.y
  823. pt["#{i}"].z = poke.z + (rand(2)==0 ? 1 : -1)
  824. r = rand(4)
  825. pt["#{i}"].zoom_x = poke.zoom_x*[1,0.9,0.75,0.5][r]*0.84
  826. pt["#{i}"].zoom_y = poke.zoom_y*[1,0.9,0.75,0.5][r]*0.84
  827. pt["#{i}"].opacity = 0
  828. pt["#{i}"].tone = Tone.new(128,128,128)
  829. tone.push(128)
  830. rndx.push(pt["#{i}"].x + rand(32)*(s==0 ? 1 : -1))
  831. rndy.push(endy - y*poke.zoom_y)
  832. timer.push(0)
  833. speed.push((rand(50)+1)*0.002)
  834. end
  835. for j in 0...12
  836. pt["s#{j}"] = Sprite.new(poke.viewport)
  837. pt["s#{j}"].bitmap = pbBitmap("Graphics/Animations/ebHealing")
  838. pt["s#{j}"].ox = pt["s#{j}"].bitmap.width/2
  839. pt["s#{j}"].oy = pt["s#{j}"].bitmap.height/2
  840. pt["s#{j}"].opacity = 0
  841. z = [1,0.75,1.25,0.5][rand(4)]*poke.zoom_x
  842. pt["s#{j}"].zoom_x = z
  843. pt["s#{j}"].zoom_y = z
  844. cx, cy = getCenter(poke,true)
  845. pt["s#{j}"].x = cx - 32*poke.zoom_x + rand(64)*poke.zoom_x
  846. pt["s#{j}"].y = cy - 32*poke.zoom_x + rand(64)*poke.zoom_x
  847. pt["s#{j}"].opacity = 0
  848. pt["s#{j}"].z = player ? 29 : 19
  849. end
  850. pbSEPlay("Protect")
  851. for i in 0...64
  852. for j in 0...32
  853. next if j>(i)
  854. timer[j] += 1
  855. pt["#{j}"].x += (rndx[j] - pt["#{j}"].x)*speed[j]
  856. pt["#{j}"].y -= (pt["#{j}"].y - rndy[j])*speed[j]
  857. tone[j] -= 8 if tone[j] > 0
  858. pt["#{j}"].tone = Tone.new(tone[j],tone[j],tone[j])
  859. pt["#{j}"].angle += 4
  860. if timer[j] > 8
  861. pt["#{j}"].opacity -= 8
  862. pt["#{j}"].zoom_x -= 0.02*poke.zoom_x if pt["#{j}"].zoom_x > 0
  863. pt["#{j}"].zoom_y -= 0.02*poke.zoom_y if pt["#{j}"].zoom_y > 0
  864. else
  865. pt["#{j}"].opacity += 25 if pt["#{j}"].opacity < 200
  866. pt["#{j}"].zoom_x += 0.025*poke.zoom_x
  867. pt["#{j}"].zoom_y += 0.025*poke.zoom_y
  868. end
  869. end
  870. for k in 0...12
  871. next if k>i
  872. pt["s#{k}"].opacity += 51
  873. pt["s#{k}"].zoom_x -= pt["s#{k}"].zoom_x*0.25 if pt["s#{k}"].opacity >= 255 && pt["s#{k}"].zoom_x > 0
  874. pt["s#{k}"].zoom_y -= pt["s#{k}"].zoom_y*0.25 if pt["s#{k}"].opacity >= 255 && pt["s#{k}"].zoom_y > 0
  875. end
  876. wait(1,true)
  877. end
  878. pbDisposeSpriteHash(pt)
  879. end
  880. #=============================================================================
  881. # For in battle sprite changes
  882. #=============================================================================
  883. alias pbChangePokemon_ebs pbChangePokemon unless self.method_defined?(:pbChangePokemon_ebs)
  884. def pbChangePokemon(attacker,pokemon)
  885. return pbMegaAnimation(attacker,pokemon) if pokemon.isMega? && !CUSTOMANIMATIONS
  886. pbDisplayEffect(@battle.abilityChange) if EFFECTMESSAGES && !@battle.abilityChange.nil?
  887. @battle.abilityChange = nil
  888. pkmn=@sprites["pokemon#{attacker.index}"]
  889. back=!@battle.pbIsOpposing?(attacker.index)
  890. t=0
  891. 10.times do
  892. t+=51 if t < 255
  893. pkmn.tone=Tone.new(t,t,t)
  894. pkmn.zoom_x+=0.05
  895. pkmn.zoom_y+=0.05
  896. wait(1)
  897. end
  898. pkmn.setPokemonBitmap(pokemon,back)
  899. 10.times do
  900. t-=51 if t > 0
  901. pkmn.tone=Tone.new(t,t,t)
  902. pkmn.zoom_x-=0.05
  903. pkmn.zoom_y-=0.05
  904. wait(1)
  905. end
  906. end
  907.  
  908. def pbMegaAnimation(attacker,pokemon)
  909. for i in 0...4
  910. @sprites["battlebox#{i}"].visible=false if @sprites["battlebox#{i}"]
  911. end
  912. clearMessageWindow
  913.  
  914. fp = {}
  915. pkmn = @sprites["pokemon#{attacker.index}"]
  916.  
  917. vector = @battle.doublebattle ? VECTOR2 : VECTOR1
  918. back = !@battle.pbIsOpposing?(attacker.index)
  919. @vector.set(getRealVector(attacker.index,back))
  920. wait(16,true)
  921. factor = pkmn.zoom_x
  922.  
  923. fp["bg"] = ScrollingSprite.new(pkmn.viewport)
  924. fp["bg"].setBitmap("Graphics/Animations/ebMegaBg")
  925. fp["bg"].speed = 32
  926. fp["bg"].opacity = 0
  927.  
  928. # particle initialization
  929. for i in 0...16
  930. fp["c#{i}"] = Sprite.new(pkmn.viewport)
  931. fp["c#{i}"].z = pkmn.z + 10
  932. fp["c#{i}"].bitmap = pbBitmap(sprintf("Graphics/Animations/ebMega%03d",rand(4)+1))
  933. fp["c#{i}"].ox = fp["c#{i}"].bitmap.width/2
  934. fp["c#{i}"].oy = fp["c#{i}"].bitmap.height/2
  935. fp["c#{i}"].opacity = 0
  936. end
  937.  
  938. # ray initialization
  939. rangle = []
  940. cx, cy = getCenter(pkmn,true)
  941. for i in 0...8; rangle.push((360/8)*i + 15); end
  942. for j in 0...8
  943. fp["r#{j}"] = Sprite.new(viewport)
  944. fp["r#{j}"].bitmap = pbBitmap("Graphics/Animations/ebMega005")
  945. fp["r#{j}"].ox = 0
  946. fp["r#{j}"].oy = fp["r#{j}"].bitmap.height/2
  947. fp["r#{j}"].opacity = 0
  948. fp["r#{j}"].zoom_x = 0
  949. fp["r#{j}"].zoom_y = 0
  950. fp["r#{j}"].x = cx
  951. fp["r#{j}"].y = cy
  952. a = rand(rangle.length)
  953. fp["r#{j}"].angle = rangle[a]
  954. fp["r#{j}"].z = pkmn.z + 2
  955. rangle.delete_at(a)
  956. end
  957.  
  958. # ripple initialization
  959. for j in 0...3
  960. fp["v#{j}"] = Sprite.new(viewport)
  961. fp["v#{j}"].bitmap = pbBitmap("Graphics/Animations/ebMega006")
  962. fp["v#{j}"].ox = fp["v#{j}"].bitmap.width/2
  963. fp["v#{j}"].oy = fp["v#{j}"].bitmap.height/2
  964. fp["v#{j}"].x = cx
  965. fp["v#{j}"].y = cy
  966. fp["v#{j}"].opacity = 0
  967. fp["v#{j}"].zoom_x = 2
  968. fp["v#{j}"].zoom_y = 2
  969. end
  970.  
  971. fp["mega"] = Sprite.new(pkmn.viewport)
  972. fp["mega"].bitmap = pbBitmap("Graphics/Animations/ebMega007")
  973. fp["mega"].ox = fp["mega"].bitmap.width/2
  974. fp["mega"].oy = fp["mega"].bitmap.height/2
  975. fp["mega"].x = cx
  976. fp["mega"].y = cy
  977. fp["mega"].opacity = 0
  978. fp["mega"].z = pkmn.z + 20
  979. fp["mega"].tone = Tone.new(255,255,255)
  980.  
  981. fp["circle"] = Sprite.new(pkmn.viewport)
  982. fp["circle"].bitmap = Bitmap.new(pkmn.bitmap.width*1.25,pkmn.bitmap.height*1.25)
  983. fp["circle"].bitmap.drawCircle
  984. fp["circle"].ox = fp["circle"].bitmap.width/2
  985. fp["circle"].oy = fp["circle"].bitmap.height/2
  986. fp["circle"].x = cx
  987. fp["circle"].y = cy
  988. fp["circle"].z = pkmn.z + 10
  989. fp["circle"].zoom_x = 0
  990. fp["circle"].zoom_y = 0
  991.  
  992. t = 0
  993. z = 0.02
  994. pbSEPlay("Harden",120)
  995. for i in 0...128
  996. fp["bg"].opacity += 8
  997. fp["bg"].update
  998. t += 8 if t < 255
  999. pkmn.tone = Tone.new(t,t,t)
  1000. # particle animation
  1001. for j in 0...16
  1002. next if j > (i/8)
  1003. if fp["c#{j}"].opacity == 0 && i < 72
  1004. fp["c#{j}"].opacity = 255
  1005. x, y = randCircleCord(96*factor)
  1006. fp["c#{j}"].x = cx - 96*factor + x
  1007. fp["c#{j}"].y = cy - 96*factor + y
  1008. end
  1009. x2 = cx
  1010. y2 = cy
  1011. x0 = fp["c#{j}"].x
  1012. y0 = fp["c#{j}"].y
  1013. fp["c#{j}"].x += (x2 - x0)*0.1
  1014. fp["c#{j}"].y += (y2 - y0)*0.1
  1015. fp["c#{j}"].opacity -= 16
  1016. end
  1017.  
  1018. # ray animation
  1019. for j in 0...8
  1020. if fp["r#{j}"].opacity == 0 && j <= (i%128)/16 && i < 96
  1021. fp["r#{j}"].opacity = 255
  1022. fp["r#{j}"].zoom_x = 0
  1023. fp["r#{j}"].zoom_y = 0
  1024. end
  1025. fp["r#{j}"].opacity -= 4
  1026. fp["r#{j}"].zoom_x += 0.05
  1027. fp["r#{j}"].zoom_y += 0.05
  1028. end
  1029.  
  1030. # circle animation
  1031. if i < 48
  1032. elsif i < 64
  1033. fp["circle"].zoom_x += factor/16.0
  1034. fp["circle"].zoom_y += factor/16.0
  1035. elsif i >= 124
  1036. fp["circle"].zoom_x += factor
  1037. fp["circle"].zoom_y += factor
  1038. else
  1039. z *= -1 if (i-96)%4 == 0
  1040. fp["circle"].zoom_x += z
  1041. fp["circle"].zoom_y += z
  1042. end
  1043.  
  1044. pbSEPlay("Twine",80) if i == 40
  1045. pbSEPlay("Refresh") if i == 56
  1046.  
  1047. if i >= 24
  1048. # mega symbol animation
  1049. if i >= 64
  1050. fp["mega"].zoom_x += 0.04
  1051. fp["mega"].zoom_y += 0.04
  1052. #fp["mega"].opacity -= 8
  1053. elsif fp["mega"].zoom_y < factor
  1054. fp["mega"].zoom_x += (factor-1)/16.0
  1055. fp["mega"].zoom_y += (factor-1)/16.0
  1056. #fp["mega"].opacity += 16
  1057. else
  1058. fp["mega"].tone.red -= 16 if fp["mega"].tone.red > 0
  1059. fp["mega"].tone.green -= 16 if fp["mega"].tone.green > 0
  1060. fp["mega"].tone.blue -= 16 if fp["mega"].tone.blue > 0
  1061. end
  1062. # ripple animation
  1063. for j in 0...3
  1064. next if j > (i-32)/8
  1065. next if fp["v#{j}"].zoom_x <= 0
  1066. fp["v#{j}"].opacity += 16
  1067. fp["v#{j}"].zoom_x -= 0.05
  1068. fp["v#{j}"].zoom_y -= 0.05
  1069. end
  1070. end
  1071. wait(1,true)
  1072. end
  1073. pkmn.viewport.color = Color.new(255,255,255)
  1074. pkmn.tone = Tone.new(0,0,0)
  1075. pbDisposeSpriteHash(fp)
  1076. fp["impact"] = Sprite.new(pkmn.viewport)
  1077. fp["impact"].bitmap = pbBitmap("Graphics/Pictures/impact")
  1078. fp["impact"].ox = fp["impact"].bitmap.width/2
  1079. fp["impact"].oy = fp["impact"].bitmap.height/2
  1080. fp["impact"].x = pkmn.viewport.rect.width/2
  1081. fp["impact"].y = pkmn.viewport.rect.height/2
  1082. fp["impact"].z = 999
  1083. fp["impact"].opacity = 0
  1084. pkmn.setPokemonBitmap(pokemon,back)
  1085. pbPlayCry(pokemon)
  1086. k = -2
  1087. for i in 0...24
  1088. fp["impact"].opacity += 64
  1089. fp["impact"].angle += 180 if i%4 == 0
  1090. fp["impact"].mirror = !fp["impact"].mirror if i%4 == 2
  1091. k *= -1 if i%4 == 0
  1092. pkmn.viewport.color.alpha -= 16
  1093. moveEntireScene(0,k,true,true)
  1094. wait(1,false)
  1095. end
  1096. for i in 0...16
  1097. fp["impact"].opacity -= 64
  1098. fp["impact"].angle += 180 if i%4 == 0
  1099. fp["impact"].mirror = !fp["impact"].mirror if i%4 == 2
  1100. wait(1)
  1101. end
  1102. @vector.set(vector)
  1103. for i in 0...4
  1104. @sprites["battlebox#{i}"].visible = true if @sprites["battlebox#{i}"]
  1105. end
  1106. fp["impact"].dispose
  1107. end
  1108. #=============================================================================
  1109. # New animation core for move animations
  1110. #=============================================================================
  1111. alias pbAnimation_ebs pbAnimation unless self.method_defined?(:pbAnimation_ebs)
  1112. def pbAnimation(moveid,user,target,hitnum=0)
  1113. return pbAnimation_ebs(moveid,user,target,hitnum) if $INEDITOR
  1114. animid=pbFindAnimation(moveid,user.index,hitnum)
  1115. return if !animid
  1116. anim=animid[0]
  1117. animations=load_data("Data/PkmnAnimations.rxdata")
  1118. name=PBMoves.getName(moveid)
  1119. # Substitute animation
  1120. if @sprites["pokemon#{user.index}"] && @battle.battlescene && !self.respond_to?(:playGlobalMoveAnimation)
  1121. subbed = @sprites["pokemon#{user.index}"].isSub
  1122. self.setSubstitute(user.index,false) if subbed
  1123. end
  1124. pbSaveShadows {
  1125. if animid[1] # On opposing side and using OppMove animation
  1126. pbAnimationCore(animations[anim],target,user,true,name)
  1127. else # On player's side, and/or using Move animation
  1128. pbAnimationCore(animations[anim],user,target,false,name)
  1129. end
  1130. }
  1131. if PBMoveData.new(moveid).function==0x69 && user && target # Transform
  1132. # Change form to transformed version
  1133. pbChangePokemon(user,target.pokemon) if !self.respond_to?(:playGlobalMoveAnimation)
  1134. end
  1135. end
  1136.  
  1137. alias pbAnimationCore_ebs pbAnimationCore unless self.method_defined?(:pbAnimationCore_ebs)
  1138. def pbAnimationCore(animation,user,target,oppmove=false,movename="")
  1139. return pbAnimationCore_ebs(animation,user,target,oppmove,movename) if $INEDITOR
  1140. return if !animation
  1141. clearMessageWindow
  1142. isVisible=[false,false,false,false]
  1143. for i in 0...4
  1144. next if self.respond_to?(:playGlobalMoveAnimation)
  1145. if @sprites["battlebox#{i}"]
  1146. isVisible[i]=@sprites["battlebox#{i}"].visible
  1147. @sprites["battlebox#{i}"].visible=false
  1148. end
  1149. end
  1150. @briefmessage=false
  1151. usersprite=(user) ? @sprites["pokemon#{user.index}"] : nil
  1152. targetsprite=(target) ? @sprites["pokemon#{target.index}"] : nil
  1153. target=user if !targetsprite && !target
  1154. # Special animations
  1155. special=(
  1156. ["Quick Attack","Flamethrower","Tail Whip"].include?(movename)
  1157. )
  1158. # Vector movement
  1159. fakeplayer=PBAnimationPlayerX.new(animation,user,target,self,oppmove)
  1160. fakeplayer.start
  1161. vector = @battle.doublebattle ? VECTOR2 : VECTOR1
  1162. if !(target==user) && !user.nil?
  1163. focus=fakeplayer.getFocus
  1164. if focus==3 || special # both
  1165. @vector.set(DUALVECTOR)
  1166. elsif focus==1
  1167. if target.index%2==0 && user.index%2==1 # player
  1168. @vector.set(PLAYERVECTOR)
  1169. elsif target.index%2==1 && user.index%2==0 # opponent
  1170. @vector.set(ENEMYVECTOR)
  1171. end
  1172. end
  1173. end
  1174. fakeplayer.dispose
  1175. wait(20,true)
  1176. # end
  1177. olduserx=usersprite ? usersprite.x-usersprite.ox : 0
  1178. uy=usersprite ? (usersprite.bitmap.height*usersprite.zoom_y)/2 - ((usersprite.bitmap.height-usersprite.oy)*usersprite.zoom_y) : 0
  1179. oldusery=usersprite ? usersprite.y-uy : 0
  1180. oldtargetx=targetsprite ? targetsprite.x-targetsprite.ox : 0
  1181. ty=targetsprite ? (targetsprite.bitmap.height*targetsprite.zoom_y)/2 - ((targetsprite.bitmap.height-targetsprite.oy)*targetsprite.zoom_y) : 0
  1182. oldtargety=targetsprite ? targetsprite.y-ty : 0
  1183.  
  1184. useroy = usersprite.oy if usersprite
  1185. targetoy = targetsprite.oy if targetsprite
  1186.  
  1187. animplayer=PBAnimationPlayerX.new(animation,user,target,self,oppmove)
  1188. if !targetsprite
  1189. userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
  1190. userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
  1191. animplayer.setLineTransform(
  1192. PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
  1193. PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
  1194. olduserx+(userwidth/2),oldusery,
  1195. olduserx+(userwidth/2),oldusery)
  1196. else
  1197. userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
  1198. userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
  1199. targetwidth=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.width
  1200. targetheight=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.height
  1201. animplayer.setLineTransform(
  1202. PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
  1203. PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
  1204. olduserx+(userwidth/2),oldusery,
  1205. oldtargetx+(targetwidth/2),oldtargety)
  1206. end
  1207. animplayer.start
  1208. while animplayer.playing?
  1209. animplayer.update
  1210. animateBattleSprites
  1211. pbGraphicsUpdate
  1212. pbInputUpdate
  1213. end
  1214. animplayer.dispose
  1215. usersprite.oy = useroy if usersprite
  1216. targetsprite.oy = targetoy if targetsprite
  1217. vector = @battle.doublebattle ? VECTOR2 : VECTOR1
  1218. @vector.set(vector)
  1219. for i in 0...4
  1220. next if self.respond_to?(:playGlobalMoveAnimation)
  1221. if @sprites["battlebox#{i}"]
  1222. @sprites["battlebox#{i}"].visible=true if isVisible[i]
  1223. end
  1224. end
  1225. wait(20,true) if !(target==user) && !user.nil? && !self.respond_to?(:playGlobalMoveAnimation)
  1226. end
  1227. end
  1228.  
  1229. #===============================================================================
  1230. # New aliased methods for Sprite animations within the battle system
  1231. #===============================================================================
  1232. alias pbSpriteSetAnimFrame_ebs pbSpriteSetAnimFrame unless defined?(pbSpriteSetAnimFrame_ebs)
  1233. def pbSpriteSetAnimFrame(sprite,frame,user=nil,target=nil,ineditor=$INEDITOR)
  1234. return pbSpriteSetAnimFrame_ebs(sprite,frame,user,target) if ineditor
  1235. return if !sprite
  1236. if !frame
  1237. sprite.visible=false
  1238. sprite.src_rect=Rect.new(0,0,1,1)
  1239. return
  1240. end
  1241. sprite.blend_type=frame[AnimFrame::BLENDTYPE]
  1242. sprite.angle=frame[AnimFrame::ANGLE]
  1243. sprite.mirror=(frame[AnimFrame::MIRROR]>0)
  1244. sprite.opacity=frame[AnimFrame::OPACITY]
  1245. sprite.visible=true
  1246. if !frame[AnimFrame::VISIBLE]==1 && ineditor
  1247. sprite.opacity/=2
  1248. else
  1249. sprite.visible=(frame[AnimFrame::VISIBLE]==1)
  1250. end
  1251. pattern=frame[AnimFrame::PATTERN]
  1252. if pattern>=0
  1253. animwidth=192
  1254. sprite.src_rect.set((pattern%5)*animwidth,(pattern/5)*animwidth,
  1255. animwidth,animwidth)
  1256. else
  1257. if sprite.respond_to?(:battleIndex) && sprite.battleIndex
  1258. index = sprite.battleIndex
  1259. elsif user.respond_to?(:battleIndex) && user.battleIndex
  1260. index = user.battleIndex
  1261. else
  1262. index = 1
  1263. end
  1264. z = (index%2==1) ? 1 : 2#BACKSPRITESCALE
  1265. if @scene && @scene.respond_to?(:sprites) && @scene.sprites["enemybase"] && @scene.sprites["playerbase"]
  1266. zoom = (index%2==1) ? @scene.sprites["enemybase"].zoom_x : @scene.sprites["playerbase"].zoom_x
  1267. else
  1268. zoom = 1
  1269. end
  1270. sprite.zoom_x = (frame[AnimFrame::ZOOMX]*zoom*z)/100.0
  1271. sprite.zoom_y = (frame[AnimFrame::ZOOMY]*zoom*z)/100.0
  1272. end
  1273. sprite.zoom_x=frame[AnimFrame::ZOOMX]/100.0 if pattern>=0
  1274. sprite.zoom_y=frame[AnimFrame::ZOOMY]/100.0 if pattern>=0
  1275. sprite.color.set(
  1276. frame[AnimFrame::COLORRED],
  1277. frame[AnimFrame::COLORGREEN],
  1278. frame[AnimFrame::COLORBLUE],
  1279. frame[AnimFrame::COLORALPHA]
  1280. )
  1281. sprite.tone.set(
  1282. frame[AnimFrame::TONERED],
  1283. frame[AnimFrame::TONEGREEN],
  1284. frame[AnimFrame::TONEBLUE],
  1285. frame[AnimFrame::TONEGRAY]
  1286. )
  1287. sprite.ox=sprite.src_rect.width/2 if pattern>=0
  1288. sprite.oy=sprite.src_rect.height/2 if pattern>=0
  1289. sprite.x=frame[AnimFrame::X]
  1290. sprite.y=frame[AnimFrame::Y]
  1291. if sprite!=user && sprite!=target
  1292. case frame[AnimFrame::PRIORITY]
  1293. when 0 # Behind everything
  1294. sprite.z=5
  1295. when 1 # In front of everything
  1296. sprite.z=35
  1297. when 2 # Just behind focus
  1298. if frame[AnimFrame::FOCUS]==1 # Focused on target
  1299. sprite.z=(target) ? target.z-1 : 5
  1300. elsif frame[AnimFrame::FOCUS]==2 # Focused on user
  1301. sprite.z=(user) ? user.z-1 : 5
  1302. else # Focused on user and target, or screen
  1303. sprite.z=5
  1304. end
  1305. when 3 # Just in front of focus
  1306. if frame[AnimFrame::FOCUS]==1 # Focused on target
  1307. sprite.z=(target) ? target.z+1 : 35
  1308. elsif frame[AnimFrame::FOCUS]==2 # Focused on user
  1309. sprite.z=(user) ? user.z+1 : 35
  1310. else # Focused on user and target, or screen
  1311. sprite.z=35
  1312. end
  1313. else
  1314. sprite.z=35
  1315. end
  1316. end
  1317. end
  1318.  
  1319. class PBAnimationPlayerX
  1320.  
  1321. def getFocus
  1322. return 1 if @frame < 0
  1323. pattern=1
  1324. if (@frame&1)==0
  1325. thisframe=@animation[@frame>>1]
  1326. # Set each cel sprite acoordingly
  1327. for i in 0...thisframe.length
  1328. cel=thisframe[i]
  1329. next if !cel
  1330. sprite=@animsprites[i]
  1331. next if !sprite
  1332. focus=cel[AnimFrame::FOCUS]
  1333. end
  1334. return [pattern,focus].max
  1335. end
  1336. return 1
  1337. end
  1338.  
  1339. alias initialize_ebs initialize unless self.method_defined?(:initialize_ebs)
  1340. def initialize(animation,user,target,scene=nil,oppmove=false,ineditor=false)
  1341. initialize_ebs(animation,user,target,scene,oppmove,ineditor)
  1342. end
  1343.  
  1344. alias update_ebs update unless self.method_defined?(:update_ebs)
  1345. def update
  1346. return update_ebs if $INEDITOR
  1347. return if @frame<0
  1348. if (@frame>>1) >= @animation.length
  1349. @frame=(@looping) ? 0 : -1
  1350. if @frame<0
  1351. @animbitmap.dispose if @animbitmap
  1352. @animbitmap=nil
  1353. return
  1354. end
  1355. end
  1356. if !@animbitmap || @animbitmap.disposed?
  1357. @animbitmap=AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic,
  1358. @animation.hue).deanimate
  1359. for i in 0...MAXSPRITES
  1360. @animsprites[i].bitmap=@animbitmap if @animsprites[i]
  1361. end
  1362. end
  1363. @bgGraphic.update
  1364. @bgColor.update
  1365. @foGraphic.update
  1366. @foColor.update
  1367. if (@frame&1)==0
  1368. thisframe=@animation[@frame>>1]
  1369. # Make all cel sprites invisible
  1370. for i in 0...MAXSPRITES
  1371. @animsprites[i].visible=false if @animsprites[i]
  1372. end
  1373. # Set each cel sprite acoordingly
  1374. for i in 0...thisframe.length
  1375. cel=thisframe[i]
  1376. next if !cel
  1377. sprite=@animsprites[i]
  1378. next if !sprite
  1379. # Set cel sprite's graphic
  1380. if cel[AnimFrame::PATTERN]==-1
  1381. sprite.bitmap=@userbitmap
  1382. elsif cel[AnimFrame::PATTERN]==-2
  1383. sprite.bitmap=@targetbitmap
  1384. else
  1385. sprite.bitmap=@animbitmap
  1386. end
  1387. # Apply settings to the cel sprite
  1388. pbSpriteSetAnimFrame(sprite,cel,@usersprite,@targetsprite,false)
  1389. case cel[AnimFrame::FOCUS]
  1390. when 1 # Focused on target
  1391. sprite.x=cel[AnimFrame::X]+@targetOrig[0]-PokeBattle_SceneConstants::FOCUSTARGET_X
  1392. sprite.y=cel[AnimFrame::Y]+@targetOrig[1]-PokeBattle_SceneConstants::FOCUSTARGET_Y
  1393. sprite.y-=64 if defined?(SCREENDUALHEIGHT) && cel[AnimFrame::PATTERN]>=0 && !@ineditor
  1394. when 2 # Focused on user
  1395. sprite.x=cel[AnimFrame::X]+@userOrig[0]-PokeBattle_SceneConstants::FOCUSUSER_X
  1396. sprite.y=cel[AnimFrame::Y]+@userOrig[1]-PokeBattle_SceneConstants::FOCUSUSER_Y
  1397. sprite.y-=64 if defined?(SCREENDUALHEIGHT) && cel[AnimFrame::PATTERN]>=0 && !@ineditor
  1398. when 3 # Focused on user and target
  1399. if @srcLine && @dstLine
  1400. point=transformPoint(
  1401. @srcLine[0],@srcLine[1],@srcLine[2],@srcLine[3],
  1402. @dstLine[0],@dstLine[1],@dstLine[2],@dstLine[3],
  1403. sprite.x,sprite.y)
  1404. sprite.x=point[0]
  1405. sprite.y=point[1]
  1406. if isReversed(@srcLine[0],@srcLine[2],@dstLine[0],@dstLine[2]) &&
  1407. cel[AnimFrame::PATTERN]>=0
  1408. # Reverse direction
  1409. sprite.mirror=!sprite.mirror
  1410. end
  1411. end
  1412. end
  1413. # EB positioning addition
  1414. if cel[AnimFrame::PATTERN]<0 && !defined?(SCREENDUALHEIGHT) && !@ineditor
  1415. offset=( (sprite.oy*sprite.zoom_y)-(sprite.bitmap.height-sprite.oy)*sprite.zoom_y )/2
  1416. #offset+=(sprite.zoom_y*sprite.oy)/2 if sprite.isSub
  1417. sprite.y+=offset
  1418. end
  1419. end
  1420. # Play timings
  1421. @animation.playTiming(@frame>>1,@bgGraphic,@bgColor,@foGraphic,@foColor,@oldbg,@oldfo,@user)
  1422. end
  1423. @frame+=1
  1424. end
  1425.  
  1426. end
  1427.  
  1428. module RPG
  1429. class Weather
  1430. alias initialize_ebs initialize unless self.method_defined?(:initialize_ebs)
  1431. alias dispose_ebs dispose unless self.method_defined?(:dispose_ebs)
  1432. end
  1433. class BattleWeather < Weather
  1434. attr_accessor :visible
  1435.  
  1436. def initialize(viewport = nil)
  1437. @disposed = false
  1438. @visible = true
  1439. initialize_ebs(viewport)
  1440. @viewport.z = @origviewport.z
  1441. end
  1442.  
  1443. def dispose
  1444. dispose_ebs
  1445. @disposed = true
  1446. end
  1447.  
  1448. def disposed?
  1449. return @disposed
  1450. end
  1451. def color
  1452. return @viewport.color
  1453. end
  1454. def color=(val)
  1455. @viewport.color=val
  1456. end
  1457. end
  1458. end
  1459. #-------------------------------------------------------------------------------
  1460. # Handles the animation during the ball burst upon Pokemon entry
  1461. #-------------------------------------------------------------------------------
  1462. class EBBallBurst
  1463. def initialize(viewport,x=0,y=0,z=50,factor=1,balltype=0)
  1464. balltype = 0 if pbResolveBitmap("Graphics/Animations/Ballburst/shine#{balltype}").nil?
  1465. @balltype = balltype
  1466. @viewport = viewport
  1467. @factor = factor
  1468. @fp = {}
  1469. @index = 0
  1470. @tone = 255.0
  1471. @pzoom = []
  1472. @poy = []
  1473. @szoom = []
  1474. @rangl = []
  1475. @rad = []
  1476. @catching = false
  1477. @recall = false
  1478. for j in 0...8
  1479. @fp["s#{j}"] = Sprite.new(@viewport)
  1480. @fp["s#{j}"].bitmap = pbBitmap("Graphics/Animations/Ballburst/ray#{balltype}")
  1481. @fp["s#{j}"].oy = @fp["s#{j}"].bitmap.height/2
  1482. @fp["s#{j}"].zoom_x = 0
  1483. @fp["s#{j}"].zoom_y = 0
  1484. @fp["s#{j}"].tone = Tone.new(255,255,255)
  1485. @fp["s#{j}"].x = x
  1486. @fp["s#{j}"].y = y
  1487. @fp["s#{j}"].z = z
  1488. @fp["s#{j}"].angle = rand(360)
  1489. @szoom.push([1.0,1.25,0.75,0.5][rand(4)]*@factor)
  1490. end
  1491. @fp["cir"] = Sprite.new(@viewport)
  1492. @fp["cir"].bitmap = pbBitmap("Graphics/Animations/Ballburst/shine#{balltype}")
  1493. @fp["cir"].ox = @fp["cir"].bitmap.width/2
  1494. @fp["cir"].oy = @fp["cir"].bitmap.height/2
  1495. @fp["cir"].x = x
  1496. @fp["cir"].y = y
  1497. @fp["cir"].zoom_x = 0
  1498. @fp["cir"].zoom_y = 0
  1499. @fp["cir"].tone = Tone.new(255,255,255)
  1500. @fp["cir"].z = z
  1501. for k in 0...16
  1502. str = ["particle","eff"][rand(2)]
  1503. @fp["p#{k}"] = Sprite.new(@viewport)
  1504. @fp["p#{k}"].bitmap = pbBitmap("Graphics/Animations/Ballburst/#{str}#{balltype}")
  1505. @fp["p#{k}"].ox = @fp["p#{k}"].bitmap.width/2
  1506. @fp["p#{k}"].oy = @fp["p#{k}"].bitmap.height/2
  1507. @pzoom.push([1.0,0.3,0.75,0.5][rand(4)]*@factor)
  1508. @fp["p#{k}"].zoom_x = 1*@factor
  1509. @fp["p#{k}"].zoom_y = 1*@factor
  1510. @fp["p#{k}"].tone = Tone.new(255,255,255)
  1511. @fp["p#{k}"].x = x
  1512. @fp["p#{k}"].y = y
  1513. @fp["p#{k}"].z = z
  1514. @fp["p#{k}"].opacity = 0
  1515. @fp["p#{k}"].angle = rand(360)
  1516. @rangl.push(rand(360))
  1517. @poy.push(rand(4)+3)
  1518. @rad.push(0)
  1519. end
  1520. @x = x; @y = y; @z = z
  1521. end
  1522.  
  1523. def update
  1524. return self.reverse if @catching
  1525. i = @index # i
  1526. for j in 0...8
  1527. next if i < 4
  1528. next if j > (i-4)/2
  1529. @fp["s#{j}"].zoom_x += (@szoom[j]*0.1)
  1530. @fp["s#{j}"].zoom_y += (@szoom[j]*0.1)
  1531. @fp["s#{j}"].opacity -= 8 if @fp["s#{j}"].zoom_x >= 1
  1532. end
  1533. for k in 0...16
  1534. next if i < 4
  1535. next if k > (i-4)
  1536. @fp["p#{k}"].opacity += 25.5 if i < 22
  1537. @fp["p#{k}"].zoom_x -= (@fp["p#{k}"].zoom_x - @pzoom[k])*0.1
  1538. @fp["p#{k}"].zoom_y -= (@fp["p#{k}"].zoom_y - @pzoom[k])*0.1
  1539. a = @rangl[k]
  1540. @rad[k] += @poy[k]*@factor; r = @rad[k]
  1541. x = @x + r*Math.cos(a*(Math::PI/180))
  1542. y = @y - r*Math.sin(a*(Math::PI/180))
  1543. @fp["p#{k}"].x = x
  1544. @fp["p#{k}"].y = y
  1545. @fp["p#{k}"].angle += 4
  1546. end
  1547. if i >= 22
  1548. for j in 0...8
  1549. @fp["s#{j}"].opacity -= 26
  1550. end
  1551. for k in 0...16
  1552. @fp["p#{k}"].opacity -= 26
  1553. end
  1554. @fp["cir"].opacity -= 26
  1555. end
  1556. @tone -= 25.5 if i >= 4 && @tone > 0
  1557. for j in 0...8
  1558. @fp["s#{j}"].tone = Tone.new(@tone,@tone,@tone)
  1559. end
  1560. for k in 0...16
  1561. @fp["p#{k}"].tone = Tone.new(@tone,@tone,@tone)
  1562. end
  1563. @fp["cir"].tone = Tone.new(@tone,@tone,@tone)
  1564. @fp["cir"].zoom_x += (@factor*1.5 - @fp["cir"].zoom_x)*0.06
  1565. @fp["cir"].zoom_y += (@factor*1.5 - @fp["cir"].zoom_y)*0.06
  1566. @fp["cir"].angle -= 4 if $PokemonSystem.screensize < 2
  1567. @index += 1 # i
  1568. end
  1569.  
  1570. def reverse
  1571. i = @index # i
  1572. @tone -= 25.5 if i >= 4 && @tone > 0
  1573. for j in 0...8
  1574. next if i < 4
  1575. next if j > (i-4)/2
  1576. next if @recall
  1577. @fp["s#{j}"].zoom_x += (@szoom[j]*0.1)
  1578. @fp["s#{j}"].zoom_y += (@szoom[j]*0.1)
  1579. @fp["s#{j}"].opacity -= 8 if @fp["s#{j}"].zoom_x >= 1
  1580. end
  1581. if i >= 22
  1582. for j in 0...8
  1583. @fp["s#{j}"].opacity -= 26
  1584. end
  1585. end
  1586. for j in 0...8
  1587. @fp["s#{j}"].tone = Tone.new(@tone,@tone,@tone)
  1588. end
  1589. for k in 0...16
  1590. a = k*22.5 + 11.5 + i*4
  1591. r = 128*@factor - i*8*@factor
  1592. x = @x + r*Math.cos(a*(Math::PI/180))
  1593. y = @y - r*Math.sin(a*(Math::PI/180))
  1594. @fp["p#{k}"].x = x
  1595. @fp["p#{k}"].y = y
  1596. @fp["p#{k}"].angle += 8
  1597. @fp["p#{k}"].opacity += 32 if i < 8
  1598. @fp["p#{k}"].opacity -= 32 if i >= 8
  1599. end
  1600. @fp["cir"].tone = Tone.new(@tone,@tone,@tone)
  1601. @fp["cir"].zoom_x -= (@fp["cir"].zoom_x - 0.5*@factor)*0.06
  1602. @fp["cir"].zoom_y -= (@fp["cir"].zoom_y - 0.5*@factor)*0.06
  1603. @fp["cir"].opacity += 25.5 if i < 16
  1604. @fp["cir"].opacity -= 16 if i >= 16
  1605. @fp["cir"].angle -= 4 if $PokemonSystem.screensize < 2
  1606. @index += 1 # i
  1607. end
  1608.  
  1609. def dispose
  1610. pbDisposeSpriteHash(@fp)
  1611. end
  1612.  
  1613. def catching
  1614. @catching = true
  1615. for k in 0...16
  1616. a = k*22.5 + 11.5
  1617. r = 128*@factor
  1618. x = @x + r*Math.cos(a*(Math::PI/180))
  1619. y = @y - r*Math.sin(a*(Math::PI/180))
  1620. @fp["p#{k}"].x = x
  1621. @fp["p#{k}"].y = y
  1622. @fp["p#{k}"].tone = Tone.new(0,0,0)
  1623. @fp["p#{k}"].opacity = 0
  1624. str = ["particle","eff"][k%2]
  1625. @fp["p#{k}"].bitmap = pbBitmap("Graphics/Animations/Ballburst/#{str}#{@balltype}")
  1626. @fp["p#{k}"].ox = @fp["p#{k}"].bitmap.width/2
  1627. @fp["p#{k}"].oy = @fp["p#{k}"].bitmap.height/2
  1628. end
  1629. @fp["cir"].zoom_x = 2*@factor
  1630. @fp["cir"].zoom_y = 2*@factor
  1631. end
  1632.  
  1633. def recall
  1634. @recall = true
  1635. self.catching
  1636. end
  1637.  
  1638. end
  1639. #-------------------------------------------------------------------------------
  1640. # Handles the animation of dust particles when heavy Pokemon are sent out
  1641. #-------------------------------------------------------------------------------
  1642. class EBDustParticle
  1643.  
  1644. def initialize(viewport,sprite,factor=1)
  1645. @viewport = viewport
  1646. @x = sprite.x
  1647. @y = sprite.y
  1648. @z = sprite.z
  1649. @factor = sprite.zoom_x
  1650. @index = 0
  1651. @fp = {}
  1652. width = sprite.bitmap.width/2 - 16
  1653. @max = 16 + (width/16)
  1654. for j in 0...@max
  1655. @fp["#{j}"] = Sprite.new(@viewport)
  1656. @fp["#{j}"].bitmap = pbBitmap("Graphics/Animations/ebDustParticle")
  1657. @fp["#{j}"].ox = @fp["#{j}"].bitmap.width/2
  1658. @fp["#{j}"].oy = @fp["#{j}"].bitmap.height/2
  1659. @fp["#{j}"].opacity = 0
  1660. @fp["#{j}"].angle = rand(360)
  1661. @fp["#{j}"].x = @x - width*@factor + rand(width*2*@factor)
  1662. @fp["#{j}"].y = @y - 16*@factor + rand(32*@factor)
  1663. @fp["#{j}"].z = @z + (@fp["#{j}"].y < @y ? -1 : 1)
  1664. zoom = [1,0.8,0.9,0.7][rand(4)]
  1665. @fp["#{j}"].zoom_x = zoom*@factor
  1666. @fp["#{j}"].zoom_y = zoom*@factor
  1667. end
  1668. end
  1669.  
  1670. def update
  1671. i = @index
  1672. for j in 0...@max
  1673. @fp["#{j}"].opacity += 25.5 if i < 10
  1674. @fp["#{j}"].opacity -= 25.5 if i >= 14
  1675. if @fp["#{j}"].x >= @x
  1676. @fp["#{j}"].angle += 4
  1677. @fp["#{j}"].x += 2
  1678. else
  1679. @fp["#{j}"].angle -= 4
  1680. @fp["#{j}"].x -= 2
  1681. end
  1682. #@fp["#{j}"].y += 1
  1683. end
  1684. @index += 1
  1685. end
  1686.  
  1687. def dispose
  1688. pbDisposeSpriteHash(@fp)
  1689. end
  1690.  
  1691. end
  1692. #===============================================================================
  1693. # Additional classes and functions added to calcualte the positions of the
  1694. # scene elements in the battle system.
  1695. # Makes for smoother animation/movement and adds more depth to the system.
  1696. #===============================================================================
  1697. class Vector
  1698. attr_reader :x
  1699. attr_reader :y
  1700. attr_reader :angle
  1701. attr_reader :scale
  1702. attr_reader :x2
  1703. attr_reader :y2
  1704. attr_accessor :zoom1
  1705. attr_accessor :zoom2
  1706. attr_accessor :inc
  1707. attr_accessor :set
  1708.  
  1709. def initialize(x=0,y=0,angle=0,scale=1,zoom1=1,zoom2=1)
  1710. @x=x.to_f
  1711. @y=y.to_f
  1712. @angle=angle.to_f
  1713. @scale=scale.to_f
  1714. @zoom1=zoom1.to_f
  1715. @zoom2=zoom2.to_f
  1716. @inc=0.2
  1717. @set=[@x,@y,@scale,@angle,@zoom1,@zoom2]
  1718. @locked=false
  1719. @force=false
  1720. @constant=1
  1721. self.calculate
  1722. end
  1723.  
  1724. def calculate
  1725. angle=@angle*(Math::PI/180)
  1726. width=Math.cos(angle)*@scale
  1727. height=Math.sin(angle)*@scale
  1728. @x2=@x+width
  1729. @y2=@y-height
  1730. end
  1731.  
  1732. def spoof(*args)
  1733. if args[0].is_a?(Array)
  1734. x,y,angle,scale,zoom1,zoom2 = args[0]
  1735. else
  1736. x,y,angle,scale,zoom1,zoom2 = args
  1737. end
  1738. angle=angle*(Math::PI/180)
  1739. width=Math.cos(angle)*scale
  1740. height=Math.sin(angle)*scale
  1741. x2=x+width
  1742. y2=y-height
  1743. return x2, y2
  1744. end
  1745.  
  1746. def angle=(val)
  1747. @angle=val
  1748. self.calculate
  1749. end
  1750.  
  1751. def scale=(val)
  1752. @scale=val
  1753. self.calculate
  1754. end
  1755.  
  1756. def x=(val)
  1757. @x=val
  1758. @set[0]=val
  1759. self.calculate
  1760. end
  1761.  
  1762. def y=(val)
  1763. @y=val
  1764. @set[1]=val
  1765. self.calculate
  1766. end
  1767.  
  1768. def force
  1769. @force = true
  1770. end
  1771.  
  1772. def set(*args)
  1773. return if DISABLESCENEMOTION && !@force
  1774. @force = false
  1775. if args[0].is_a?(Array)
  1776. x,y,angle,scale,zoom1,zoom2 = args[0]
  1777. else
  1778. x,y,angle,scale,zoom1,zoom2 = args
  1779. end
  1780. @set=[x,y,angle,scale,zoom1,zoom2]
  1781. @constant=rand(4)+1
  1782. end
  1783.  
  1784. def add(field="",amount=0.0)
  1785. case field
  1786. when "x"
  1787. @set[0]=@x+amount
  1788. when "y"
  1789. @set[1]=@y+amount
  1790. when "angle"
  1791. @set[2]=@angle+amount
  1792. when "scale"
  1793. @set[3]=@scale+amount
  1794. when "zoom1"
  1795. @set[4]=@zoom1+amount
  1796. when "zoom2"
  1797. @set[5]=@zoom2+amount
  1798. end
  1799. end
  1800.  
  1801. def setXY(x,y)
  1802. @set[0]=x
  1803. @set[1]=y
  1804. end
  1805.  
  1806. def locked?
  1807. return @locked
  1808. end
  1809.  
  1810. def lock
  1811. @locked=!@locked
  1812. end
  1813.  
  1814. def update
  1815. @x+=(@set[0]-@x)*@inc
  1816. @y+=(@set[1]-@y)*@inc
  1817. @angle+=(@set[2]-@angle)*@inc
  1818. @scale+=(@set[3]-@scale)*@inc
  1819. @zoom1+=(@set[4]-@zoom1)*@inc
  1820. @zoom2+=(@set[5]-@zoom2)*@inc
  1821. self.calculate
  1822. end
  1823.  
  1824. def finished?
  1825. return ((@set[0]-@x)*@inc).abs <= 0.05*@constant
  1826. end
  1827.  
  1828. end
  1829.  
  1830. def calculateCurve(x1,y1,x2,y2,x3,y3,frames=10)
  1831. output=[]
  1832. curve=[x1,y1,x2,y2,x3,y3,x3,y3]
  1833. step=1.0/frames
  1834. t=0.0
  1835. frames.times do
  1836. point=getCubicPoint2(curve,t)
  1837. output.push([point[0],point[1]])
  1838. t+=step
  1839. end
  1840. return output
  1841. end
  1842.  
  1843. def singleDecInt?(number)
  1844. number*=10
  1845. return (number%10==0)
  1846. end
Add Comment
Please, Sign In to add comment