Nyaruko69

Untitled

May 1st, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 121.50 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Config for battle system visuals
  3. # set this to false to remove battle bases
  4. USEBATTLEBASES = false
  5. # applies a blur to the background
  6. # toggle between true and false, or set as numeric value
  7. # higher values will increase battle loading times (recommended = 3)
  8. BLURBATTLEBACKGROUND = 0
  9. # resize factor of the background (default = 3.5)
  10. BACKGROUNDSCALAR = 3.5
  11. #-------------------------------------------------------------------------------
  12.  
  13. # List of Pokemon that are going to trigger the "Minor Legendary" battle entry
  14. # animation
  15.  
  16. MINOR_LEGENDARIES = [
  17. :MOLTRES,
  18. :ARTICUNO,
  19. :ZAPDOS,
  20. :GIRATINA,
  21. :DEOXYS
  22. ]
  23.  
  24. # Array handling the automatic queuing of battle BGM
  25.  
  26. BATTLE_BGM_SPECIES = [
  27. [:DEOXYS,"BT-Deoxys Theme.ogg"],
  28. [:GIRATINA,"giratinabattle.ogg"],
  29. [[:MOLTRES,:ZAPDOS,:ARTICUNO],"dpplegendary.ogg"],
  30. [[:REGISTEEL,:REGIROCK,:REGICE,:REGIGIGAS],"regibattle.ogg"],
  31. ]
  32.  
  33. # List of trainertypes triggering the "evil" team animation
  34. EVIL_TEAM_LIST = [
  35. :SOLDADO_M,
  36. :SOLDADO_F,
  37. ]
  38.  
  39. #===============================================================================
  40. # Don't touch these
  41. # Used to configure the system for potential DS styles (leftovers)
  42. #-----------------------------------------------------
  43. VIEWPORT_HEIGHT = DEFAULTSCREENHEIGHT
  44. VIEWPORT_OFFSET = 0
  45. #-------------------------------------------------------------------------------
  46. # Extensions for classes
  47. #-------------------------------------------------------------------------------
  48. # additional String functionality
  49. class ::String
  50. def starts_with?(char)
  51. proc = self.scan(/./)
  52. return (proc[0] == char) ? true : false
  53. end
  54. end
  55. # additional Sprite functionality
  56. class Sprite
  57. attr_reader :storedBitmap
  58. attr_accessor :speed
  59. attr_accessor :toggle
  60. attr_accessor :end_x
  61. attr_accessor :end_y
  62. attr_accessor :param
  63. attr_accessor :ex
  64. attr_accessor :ey
  65.  
  66. def drawRect(width,height,color)
  67. self.bitmap = Bitmap.new(width,height)
  68. self.bitmap.fill_rect(0,0,width,height,color)
  69. end
  70.  
  71. def center
  72. self.ox = self.src_rect.width/2
  73. self.oy = self.src_rect.height/2
  74. end
  75.  
  76. def snapScreen
  77. bmp = Graphics.snap_to_bitmap
  78. width = self.viewport ? viewport.rect.width : Graphics.width
  79. height = self.viewport ? viewport.rect.height : Graphics.height
  80. x = self.viewport ? viewport.rect.x : 0
  81. y = self.viewport ? viewport.rect.y : 0
  82. self.bitmap = Bitmap.new(width,height)
  83. self.bitmap.blt(0,0,bmp,Rect.new(x,y,width,height))
  84. end
  85.  
  86. def skew(angle=90)
  87. return false if !self.bitmap
  88. angle=angle*(Math::PI/180)
  89. bitmap=self.bitmap
  90. rect=Rect.new(0,0,bitmap.width,bitmap.height)
  91. width=rect.width+((rect.height-1)/Math.tan(angle))
  92. self.bitmap=Bitmap.new(width,rect.height)
  93. for i in 0...rect.height
  94. y=rect.height-i
  95. x=i/Math.tan(angle)
  96. self.bitmap.blt(x+rect.x,y+rect.y,bitmap,Rect.new(0,y,rect.width,1))
  97. end
  98. end
  99.  
  100. def blur_sprite(blur_val=2,opacity=35)
  101. bitmap = self.bitmap
  102. self.bitmap = Bitmap.new(bitmap.width,bitmap.height)
  103. self.bitmap.blt(0,0,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
  104. x=0
  105. y=0
  106. for i in 1...(8 * blur_val)
  107. dir = i % 8
  108. x += (1 + (i / 8))*([0,6,7].include?(dir) ? -1 : 1)*([1,5].include?(dir) ? 0 : 1)
  109. y += (1 + (i / 8))*([1,4,5,6].include?(dir) ? -1 : 1)*([3,7].include?(dir) ? 0 : 1)
  110. self.bitmap.blt(x-blur_val,y+(blur_val*2),bitmap,Rect.new(0,0,bitmap.width,bitmap.height),opacity)
  111. end
  112. end
  113.  
  114. def getAvgColor(freq=2)
  115. return Color.new(0,0,0,0) if !self.bitmap
  116. bmp = self.bitmap
  117. width = self.bitmap.width/freq
  118. height = self.bitmap.height/freq
  119. red = 0
  120. green = 0
  121. blue = 0
  122. n = width*height
  123. for x in 0...width
  124. for y in 0...height
  125. color = bmp.get_pixel(x*freq,y*freq)
  126. if color.alpha > 0
  127. red += color.red
  128. green += color.green
  129. blue += color.blue
  130. end
  131. end
  132. end
  133. avg = Color.new(red/n,green/n,blue/n)
  134. return avg
  135. end
  136.  
  137. def create_outline(color,thickness=2,hard=false)
  138. return false if !self.bitmap
  139. bmp = self.bitmap.clone
  140. self.bitmap = Bitmap.new(bmp.width,bmp.height)
  141. for x in 0...bmp.width-thickness
  142. for y in 0...bmp.height
  143. pixel = bmp.get_pixel(x,y)
  144. if pixel.alpha > 0
  145. for i in 1..thickness
  146. c1 = bmp.get_pixel(x,y-i)
  147. c2 = bmp.get_pixel(x,y+i)
  148. c3 = bmp.get_pixel(x-i,y)
  149. c4 = bmp.get_pixel(x+i,y)
  150. self.bitmap.set_pixel(x,y-i,color) if c1.alpha <= 0
  151. self.bitmap.set_pixel(x,y+i,color) if c2.alpha <= 0
  152. self.bitmap.set_pixel(x-i,y,color) if c3.alpha <= 0
  153. self.bitmap.set_pixel(x+i,y,color) if c4.alpha <= 0
  154. end
  155. end
  156. end
  157. end
  158. self.bitmap.blt(0,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
  159. end
  160.  
  161. def colorize(color)
  162. return false if !self.bitmap
  163. bmp = self.bitmap.clone
  164. self.bitmap = Bitmap.new(bmp.width,bmp.height)
  165. for x in 0...bmp.width
  166. for y in 0...bmp.height
  167. pixel = bmp.get_pixel(x,y)
  168. self.bitmap.set_pixel(x,y,color) if pixel.alpha > 0
  169. end
  170. end
  171. end
  172.  
  173. def glow(color,opacity=35,keep=true)
  174. return false if !self.bitmap
  175. temp_bmp = self.bitmap.clone
  176. self.colorize(color)
  177. self.blur_sprite(3,opacity)
  178. src = self.bitmap.clone
  179. self.bitmap.clear
  180. self.bitmap.stretch_blt(Rect.new(-0.005*src.width,-0.015*src.height,src.width*1.01,1.02*src.height),src,Rect.new(0,0,src.width,src.height))
  181. self.bitmap.blt(0,0,temp_bmp,Rect.new(0,0,temp_bmp.width,temp_bmp.height)) if keep
  182. end
  183.  
  184. def fuzz(color,opacity=35)
  185. return false if !self.bitmap
  186. self.colorize(color)
  187. self.blur_sprite(3,opacity)
  188. src = self.bitmap.clone
  189. self.bitmap.clear
  190. self.bitmap.stretch_blt(Rect.new(-0.005*src.width,-0.015*src.height,src.width*1.01,1.02*src.height),src,Rect.new(0,0,src.width,src.height))
  191. end
  192.  
  193. def memorize_bitmap(bitmap = nil)
  194. @storedBitmap = bitmap if !bitmap.nil?
  195. @storedBitmap = self.bitmap.clone if bitmap.nil?
  196. end
  197. def restore_bitmap
  198. self.bitmap = @storedBitmap.clone
  199. end
  200.  
  201. def toneAll(val)
  202. self.tone.red += val
  203. self.tone.green += val
  204. self.tone.blue += val
  205. end
  206.  
  207. def onlineBitmap(url)
  208. pbDownloadToFile(url,"_temp.png")
  209. return if !FileTest.exist?("_temp.png")
  210. self.bitmap = pbBitmap("_temp")
  211. File.delete("_temp.png")
  212. end
  213. end
  214. # additional Bitmap functionality
  215. class Bitmap
  216. def drawCircle(color=Color.new(255,255,255),r=(self.width/2),tx=(self.width/2),ty=(self.height/2),hollow=false)
  217. # basic circle formula
  218. # (x - tx)**2 + (y - ty)**2 = r**2
  219. for x in 0...self.width
  220. f = (r**2 - (x - tx)**2)
  221. next if f < 0
  222. y1 = -Math.sqrt(f).to_i + ty
  223. y2 = Math.sqrt(f).to_i + ty
  224. if hollow
  225. self.set_pixel(x,y1,color)
  226. self.set_pixel(x,y2,color)
  227. else
  228. for y in y1..y2
  229. self.set_pixel(x,y,color)
  230. end
  231. end
  232. end
  233. end
  234. end
  235. #-------------------------------------------------------------------------------
  236. # Class used for generating scrolling backgrounds (move animations)
  237. #-------------------------------------------------------------------------------
  238. class ScrollingSprite < Sprite
  239. attr_accessor :speed
  240. attr_accessor :direction
  241. attr_accessor :vertical
  242.  
  243. def setBitmap(val,vertical=false,pulse=false)
  244. @vertical = vertical
  245. @pulse = pulse
  246. @direction = 1 if @direction.nil?
  247. @gopac = 1
  248. @speed = 32 if @speed.nil?
  249. val = pbBitmap(val) if val.is_a?(String)
  250. if @vertical
  251. bmp = Bitmap.new(val.width,val.height*2)
  252. for i in 0...2
  253. bmp.blt(0,val.height*i,val,Rect.new(0,0,val.width,val.height))
  254. end
  255. self.bitmap = bmp.clone
  256. y = @direction > 0 ? 0 : val.height
  257. self.src_rect.set(0,y,val.width,val.height)
  258. else
  259. bmp = Bitmap.new(val.width*2,val.height)
  260. for i in 0...2
  261. bmp.blt(val.width*i,0,val,Rect.new(0,0,val.width,val.height))
  262. end
  263. self.bitmap = bmp.clone
  264. x = @direction > 0 ? 0 : val.width
  265. self.src_rect.set(x,0,val.width,val.height)
  266. end
  267. end
  268.  
  269. def update
  270. if @vertical
  271. self.src_rect.y += @speed*@direction
  272. self.src_rect.y = 0 if @direction > 0 && self.src_rect.y >= self.src_rect.height
  273. self.src_rect.y = self.src_rect.height if @direction < 0 && self.src_rect.y <= 0
  274. else
  275. self.src_rect.x += @speed*@direction
  276. self.src_rect.x = 0 if @direction > 0 && self.src_rect.x >= self.src_rect.width
  277. self.src_rect.x = self.src_rect.width if @direction < 0 && self.src_rect.x <= 0
  278. end
  279. if @pulse
  280. self.opacity -= @gopac*@speed
  281. @gopac *= -1 if self.opacity == 255 || self.opacity == 0
  282. end
  283. end
  284.  
  285. end
  286. #-------------------------------------------------------------------------------
  287. # Class used for generating sprites with a trail
  288. #-------------------------------------------------------------------------------
  289. class TrailingSprite
  290. attr_accessor :x
  291. attr_accessor :y
  292. attr_accessor :z
  293. attr_accessor :color
  294. attr_accessor :keyFrame
  295. attr_accessor :zoom_x
  296. attr_accessor :zoom_y
  297. attr_accessor :opacity
  298.  
  299. def initialize(viewport,bmp)
  300. @viewport = viewport
  301. @bmp = bmp
  302. @sprites = {}
  303. @x = 0
  304. @y = 0
  305. @z = 0
  306. @i = 0
  307. @frame = 128
  308. @keyFrame = 0
  309. @color = Color.new(0,0,0,0)
  310. @zoom_x = 1
  311. @zoom_y = 1
  312. @opacity = 255
  313. end
  314.  
  315. def update
  316. @frame += 1
  317. if @frame > @keyFrame
  318. @sprites["#{@i}"] = Sprite.new(@viewport)
  319. @sprites["#{@i}"].bitmap = @bmp
  320. @sprites["#{@i}"].center
  321. @sprites["#{@i}"].x = x
  322. @sprites["#{@i}"].y = y
  323. @sprites["#{@i}"].z = z
  324. @sprites["#{@i}"].zoom_x = @zoom_x
  325. @sprites["#{@i}"].zoom_y = @zoom_y
  326. @sprites["#{@i}"].opacity = @opacity
  327. @i += 1
  328. @frame = 0
  329. end
  330. for key in @sprites.keys
  331. if @sprites[key].opacity > @keyFrame
  332. @sprites[key].opacity -= 24
  333. @sprites[key].zoom_x -= 0.035
  334. @sprites[key].zoom_y -= 0.035
  335. @sprites[key].color = @color
  336. end
  337. end
  338. end
  339.  
  340. def visible=(val)
  341. for key in @sprites.keys
  342. @sprites[key].visible = val
  343. end
  344. end
  345.  
  346. def dispose
  347. for key in @sprites.keys
  348. @sprites[key].dispose
  349. end
  350. @sprites.clear
  351. end
  352.  
  353. def disposed?
  354. @sprites.keys.length < 1
  355. end
  356. end
  357. #-------------------------------------------------------------------------------
  358. # Class used to render the background for the special S&M trainer battle
  359. # animation
  360. #-------------------------------------------------------------------------------
  361. class RainbowSprite < Sprite
  362. attr_accessor :speed
  363. def setBitmap(val,speed = 1)
  364. @val = val
  365. @val = pbBitmap(val) if val.is_a?(String)
  366. @speed = speed
  367. self.bitmap = Bitmap.new(@val.width,@val.height)
  368. self.bitmap.blt(0,0,@val,Rect.new(0,0,@val.width,@val.height))
  369. @current_hue = 0
  370. end
  371.  
  372. def update
  373. self.bitmap.clear
  374. self.bitmap.blt(0,0,@val,Rect.new(0,0,@val.width,@val.height))
  375. self.bitmap.hue_change(@current_hue)
  376. @current_hue += @speed
  377. @current_hue = 0 if @current_hue >= 360
  378. end
  379. end
  380. #-------------------------------------------------------------------------------
  381. # Common UI handlers
  382. #-------------------------------------------------------------------------------
  383. class CommonButton < Sprite
  384. attr_accessor :selected
  385. def setButton(size="M",var=1,text="")
  386. bmp = pbBitmap("Graphics/Pictures/Common/btn#{size}_#{var}")
  387. pbSetSmallFont(bmp)
  388. case size
  389. when "M"
  390. x, y, w, h = 46, 22, 92, 38
  391. when "N"
  392. x, y, w, h = 54, 16, 108, 30
  393. when "L"
  394. x, y, w, h = 61, 22, 122, 38
  395. end
  396. color = self.darkenColor(bmp.get_pixel(x, y))
  397. self.bitmap = Bitmap.new(bmp.width - 22, bmp.height)
  398. pbSetSmallFont(self.bitmap)
  399. self.bitmap.blt(0, 0, bmp, Rect.new(0, 0, bmp.width - 22, bmp.height))
  400. pbDrawOutlineText(self.bitmap,2,2,w,h,text,Color.new(255,255,255),color,1)
  401. end
  402.  
  403. def darkenColor(color=nil,amt=0.6)
  404. return getDarkerColor(color,amt)
  405. end
  406. end
  407.  
  408. def getDarkerColor(color=nil,amt=0.6)
  409. return nil if color.nil?
  410. red = color.red - color.red*amt
  411. green = color.green - color.green*amt
  412. blue = color.blue - color.blue*amt
  413. return Color.new(red,green,blue)
  414. end
  415. #-------------------------------------------------------------------------------
  416. # Misc scripting utilities
  417. #-------------------------------------------------------------------------------
  418. class Bitmap
  419. attr_accessor :storedPath
  420. end
  421.  
  422. def pbBitmap(name)
  423. if !pbResolveBitmap(name).nil?
  424. bmp = BitmapCache.load_bitmap(name)
  425. bmp.storedPath = name
  426. else
  427. p "Image located at '#{name}' was not found!" if $DEBUG
  428. bmp = Bitmap.new(1,1)
  429. end
  430. return bmp
  431. end
  432. #-------------------------------------------------------------------------------
  433. # F12 Soft-resetting fix
  434. #-------------------------------------------------------------------------------
  435. if defined?(SOFTRESETFIX) && SOFTRESETFIX
  436. unless $f12_fix.nil?
  437. game_name = "Game"
  438. if $DEBUG
  439. Thread.new{system(game_name+" debug")}
  440. else
  441. Thread.new{system(game_name)}
  442. end
  443. exit
  444. end
  445. $f12_fix = true
  446. end
  447. #===============================================================================
  448. # New methods used to inject new code into Scripts.rxdata
  449. #-------------------------------------------------------------------------------
  450. # Backs up your current scripts to prevent any permanent damage
  451. #-------------------------------------------------------------------------------
  452. def backupScriptData(file_name = nil)
  453. if file_name.nil?
  454. ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
  455. scripts_filename = "\0" * 256
  456. ini.call('Game', 'Scripts', '', scripts_filename, 256, '.\\Game.ini')
  457. scripts_filename.delete!("\0")
  458. else
  459. scripts_filename = file_name
  460. end
  461. File.copy(scripts_filename, scripts_filename+".bak",false)
  462. end
  463. #-------------------------------------------------------------------------------
  464. # Returns all possible data read from the game's scripts
  465. #-------------------------------------------------------------------------------
  466. def getScriptData(file_name = nil)
  467. # Backs up the Scripts
  468. backupScriptData(file_name)
  469. # Gets Scripts filename from the .ini file
  470. if file_name.nil?
  471. ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
  472. scripts_filename = "\0" * 256
  473. ini.call('Game', 'Scripts', '', scripts_filename, 256, '.\\Game.ini')
  474. scripts_filename.delete!("\0")
  475. else
  476. scripts_filename = file_name
  477. end
  478.  
  479. scripts = load_data(scripts_filename)
  480. names = []
  481. codes = []
  482. # Reads all the currently existing scripts, and stores them for later manipulation
  483. for script in scripts
  484. id, name, code = script
  485. next if id.nil?
  486. code = Zlib::Inflate.inflate(code)
  487. code.gsub!(/\t/) {' '}
  488. names.push(name)
  489. codes.push(code)
  490. end
  491. return names, codes, scripts_filename
  492. end
  493. #-------------------------------------------------------------------------------
  494. # Returns one specific script from the game's scripts
  495. #-------------------------------------------------------------------------------
  496. def getSpecificScript(name = "Main")
  497. # Fetches all the necessary Scripts data
  498. names, codes, scripts_filename = getScriptData
  499. # Gets the location index of script from name
  500. if name.is_a?(String)
  501. index = names.index(name)
  502. elsif name.is_a?(Numeric)
  503. index = name
  504. else
  505. return # failsafe
  506. end
  507. # Returns selected script
  508. return codes[index]
  509. end
  510. #-------------------------------------------------------------------------------
  511. #===============================================================================
  512. # Elite Battle system
  513. # by Luka S.J.
  514. # ----------------
  515. # Sprites Script
  516. # ----------------
  517. # system is based off the original Essentials battle system, made by
  518. # Poccil & Maruno
  519. # No additional features added to AI, mechanics
  520. # or functionality of the battle system.
  521. # This update is purely cosmetic, and includes a B/W like dynamic scene with a
  522. # custom interface.
  523. #
  524. # Enjoy the script, and make sure to give credit!
  525. # (DO NOT ALTER THE NAMES OF THE INDIVIDUAL SCRIPT SECTIONS OR YOU WILL BREAK
  526. # YOUR SYSTEM!)
  527. #-------------------------------------------------------------------------------
  528. # New methods for creating in-battle Pokemon sprites.
  529. # * creates fixed shadows in the sprite itself
  530. # * calculates correct positions according to metric data in here
  531. # * sprites have a different focal point for more precise base placement
  532. #===============================================================================
  533. class DynamicPokemonSprite
  534. attr_accessor :shadow
  535. attr_accessor :sprite
  536. attr_accessor :showshadow
  537. attr_accessor :status
  538. attr_accessor :hidden
  539. attr_accessor :fainted
  540. attr_accessor :anim
  541. attr_accessor :charged
  542. attr_accessor :isShadow
  543. attr_reader :loaded
  544. attr_reader :selected
  545. attr_reader :isSub
  546. attr_reader :viewport
  547. attr_reader :pulse
  548.  
  549. def initialize(doublebattle,index,viewport=nil)
  550. @viewport=viewport
  551. @metrics=load_data("Data/metrics.dat")
  552. @selected=0
  553. @frame=0
  554. @frame2=0
  555. @frame3=0
  556.  
  557. @status=0
  558. @loaded=false
  559. @charged=false
  560. @index=index
  561. @doublebattle=doublebattle
  562. @showshadow=true
  563. @altitude=0
  564. @yposition=0
  565. @shadow=Sprite.new(@viewport)
  566. @sprite=Sprite.new(@viewport)
  567. back=(@index%2==0)
  568. @substitute=AnimatedBitmapWrapper.new("Graphics/Battlers/"+(back ? "substitute_back" : "substitute"),POKEMONSPRITESCALE)
  569. @overlay=Sprite.new(@viewport)
  570. @isSub=false
  571. @lock=false
  572. @pokemon=nil
  573. @still=false
  574. @hidden=false
  575. @fainted=false
  576. @anim=false
  577. @isShadow=false
  578.  
  579. @fp = {}
  580. for i in 0...16
  581. @fp["#{i}"] = Sprite.new(@viewport)
  582. @fp["#{i}"].bitmap = pbBitmap("Graphics/Animations/ebShadow")
  583. @fp["#{i}"].ox = @fp["#{i}"].bitmap.width/4
  584. @fp["#{i}"].oy = @fp["#{i}"].bitmap.height/2
  585. @fp["#{i}"].src_rect.set(0,0,@fp["#{i}"].bitmap.width/2,@fp["#{i}"].bitmap.height)
  586. @fp["#{i}"].opacity = 0
  587. end
  588.  
  589. for i in 0...16
  590. @fp["c#{i}"] = Sprite.new(@viewport)
  591. @fp["c#{i}"].bitmap = pbBitmap("Graphics/Animations/ebCharged")
  592. @fp["c#{i}"].ox = @fp["c#{i}"].bitmap.width/8
  593. @fp["c#{i}"].oy = @fp["c#{i}"].bitmap.height
  594. @fp["c#{i}"].src_rect.set(0,0,@fp["c#{i}"].bitmap.width/4,@fp["c#{i}"].bitmap.height)
  595. @fp["c#{i}"].opacity = 0
  596. end
  597.  
  598. for j in 0...4
  599. @fp["r#{j}"] = Sprite.new(viewport)
  600. @fp["r#{j}"].bitmap = pbBitmap("Graphics/Animations/ebRipple")
  601. @fp["r#{j}"].ox = @fp["r#{j}"].bitmap.width/2
  602. @fp["r#{j}"].oy = @fp["r#{j}"].bitmap.height/2
  603. @fp["r#{j}"].zoom_x = 0
  604. @fp["r#{j}"].zoom_y = 0
  605. @fp["r#{j}"].param = 0
  606. end
  607.  
  608. @pulse = 8
  609. @k = 1
  610. end
  611.  
  612. def battleIndex; return @index; end
  613. def x; @sprite.x; end
  614. def y; @sprite.y; end
  615. def z; @sprite.z; end
  616. def ox; @sprite.ox; end
  617. def oy; @sprite.oy; end
  618. def zoom_x; @sprite.zoom_x; end
  619. def zoom_y; @sprite.zoom_y; end
  620. def visible; @sprite.visible; end
  621. def opacity; @sprite.opacity; end
  622. def width; @bitmap.width; end
  623. def height; @bitmap.height; end
  624. def tone; @sprite.tone; end
  625. def bitmap; @bitmap.bitmap; end
  626. def actualBitmap; @bitmap; end
  627. def disposed?; @sprite.disposed?; end
  628. def color; @sprite.color; end
  629. def src_rect; @sprite.src_rect; end
  630. def blend_type; @sprite.blend_type; end
  631. def angle; @sprite.angle; end
  632. def mirror; @sprite.mirror; end
  633. def src_rect; return @sprite.src_rect; end
  634. def src_rect=(val)
  635. @sprite.src_rect=val
  636. end
  637. def lock
  638. @lock=true
  639. end
  640. def bitmap=(val)
  641. @bitmap.bitmap=val
  642. end
  643. def x=(val)
  644. @sprite.x=val
  645. @shadow.x=val
  646. end
  647. def ox=(val)
  648. @sprite.ox=val
  649. self.formatShadow
  650. end
  651. def addOx(val)
  652. @sprite.ox+=val
  653. self.formatShadow
  654. end
  655. def oy=(val)
  656. @sprite.oy=val
  657. self.formatShadow
  658. end
  659. def addOy(val)
  660. @sprite.oy+=val
  661. self.formatShadow
  662. end
  663. def y=(val)
  664. @sprite.y=val
  665. @shadow.y=val
  666. end
  667. def z=(val)
  668. @shadow.z=(val==32) ? 31 : 10
  669. @sprite.z=val
  670. end
  671. def zoom_x=(val)
  672. @sprite.zoom_x=val
  673. self.formatShadow
  674. end
  675. def zoom_y=(val)
  676. @sprite.zoom_y=val
  677. self.formatShadow
  678. end
  679. def visible=(val)
  680. return if @hidden
  681. @sprite.visible=val
  682. if @fp
  683. for key in @fp.keys
  684. @fp[key].visible=val
  685. end
  686. end
  687. self.formatShadow
  688. end
  689. def opacity=(val)
  690. @sprite.opacity=val
  691. self.formatShadow
  692. end
  693. def tone=(val)
  694. @sprite.tone=val
  695. end
  696. def color=(val)
  697. @sprite.color=val
  698. if @fp
  699. for key in @fp.keys
  700. @fp[key].color=val
  701. end
  702. end
  703. end
  704. def blend_type=(val)
  705. @sprite.blend_type=val
  706. self.formatShadow
  707. end
  708. def angle=(val)
  709. @sprite.angle=(val)
  710. self.formatShadow
  711. end
  712. def mirror=(val)
  713. @sprite.mirror=(val)
  714. self.formatShadow
  715. end
  716. def dispose
  717. @sprite.dispose
  718. @shadow.dispose
  719. pbDisposeSpriteHash(@fp)
  720. end
  721. def selected=(val)
  722. @selected=val
  723. @sprite.visible=true if !@hidden
  724. end
  725. def toneAll(val)
  726. @sprite.tone.red+=val
  727. @sprite.tone.green+=val
  728. @sprite.tone.blue+=val
  729. end
  730.  
  731. def setBitmap(file,shadow=false)
  732. self.resetParticles
  733. @showshadow = shadow
  734. @bitmap = AnimatedBitmapWrapper.new(file)
  735. @sprite.bitmap = @bitmap.bitmap.clone
  736. @shadow.bitmap = @bitmap.bitmap.clone
  737. @loaded = true
  738. self.formatShadow
  739. end
  740.  
  741. def setPokemonBitmap(pokemon,back=false,species=nil)
  742. self.resetParticles
  743. return if !pokemon || pokemon.nil?
  744. @pokemon = pokemon
  745. @isShadow = true if @pokemon.isShadow?
  746. @altitude = @metrics[2][pokemon.species]
  747. if back
  748. @yposition = @metrics[0][pokemon.species]
  749. @altitude *= 0.5
  750. else
  751. @yposition = @metrics[1][pokemon.species]
  752. end
  753. scale = back ? BACKSPRITESCALE : POKEMONSPRITESCALE
  754. if !species.nil?
  755. @bitmap = pbLoadPokemonBitmapSpecies(pokemon,species,back,scale)
  756. else
  757. @bitmap = pbLoadPokemonBitmap(pokemon,back,scale)
  758. end
  759. @sprite.bitmap = @bitmap.bitmap.clone
  760. @shadow.bitmap = @bitmap.bitmap.clone
  761. @sprite.ox = @bitmap.width/2
  762. @sprite.oy = @bitmap.height
  763. @sprite.oy += @altitude
  764. @sprite.oy -= @yposition
  765. @sprite.oy -= pokemon.formOffsetY if pokemon.respond_to?(:formOffsetY)
  766.  
  767. @fainted = false
  768. @loaded = true
  769. @hidden = false
  770. self.visible = true
  771. @pulse = 8
  772. @k = 1
  773. self.formatShadow
  774. end
  775.  
  776. def resetParticles
  777. if @fp
  778. for key in @fp.keys
  779. @fp[key].visible = false
  780. end
  781. end
  782. @isShadow = false
  783. @charged = false
  784. end
  785.  
  786. def refreshMetrics(metrics)
  787. @metrics = metrics
  788. @altitude = @metrics[2][@pokemon.species]
  789. if (@index%2==0)
  790. @yposition = @metrics[0][@pokemon.species]
  791. @altitude *= 0.5
  792. else
  793. @yposition = @metrics[1][@pokemon.species]
  794. end
  795.  
  796. @sprite.ox = @bitmap.width/2
  797. @sprite.oy = @bitmap.height
  798. @sprite.oy += @altitude
  799. @sprite.oy -= @yposition
  800. @sprite.oy -= @pokemon.formOffsetY if @pokemon.respond_to?(:formOffsetY)
  801. end
  802.  
  803. def setSubstitute
  804. @isSub = true
  805. @sprite.bitmap = @substitute.bitmap.clone
  806. @shadow.bitmap = @substitute.bitmap.clone
  807. @sprite.ox = @substitute.width/2
  808. @sprite.oy = @substitute.height
  809. self.formatShadow
  810. end
  811.  
  812. def removeSubstitute
  813. @isSub = false
  814. @sprite.bitmap = @bitmap.bitmap.clone
  815. @shadow.bitmap = @bitmap.bitmap.clone
  816. @sprite.ox = @bitmap.width/2
  817. @sprite.oy = @bitmap.height
  818. @sprite.oy += @altitude
  819. @sprite.oy -= @yposition
  820. @sprite.oy -= @pokemon.formOffsetY if @pokemon && @pokemon.respond_to?(:formOffsetY)
  821. self.formatShadow
  822. end
  823.  
  824. def still
  825. @still = true
  826. end
  827.  
  828. def clear
  829. @sprite.bitmap.clear
  830. @bitmap.dispose
  831. end
  832.  
  833. def formatShadow
  834. @shadow.zoom_x = @sprite.zoom_x*0.90
  835. @shadow.zoom_y = @sprite.zoom_y*0.30
  836. @shadow.ox = @sprite.ox - 6
  837. @shadow.oy = @sprite.oy - 6
  838. @shadow.opacity = @sprite.opacity*0.3
  839. @shadow.tone = Tone.new(-255,-255,-255,255)
  840. @shadow.visible = @sprite.visible
  841. @shadow.mirror = @sprite.mirror
  842. @shadow.angle = @sprite.angle
  843.  
  844. @shadow.visible = false if !@showshadow
  845. end
  846.  
  847. def update(angle=74)
  848. if @still
  849. @still = false
  850. return
  851. end
  852. return if @lock
  853. return if !@bitmap || @bitmap.disposed?
  854. if @isSub
  855. @substitute.update
  856. else
  857. @bitmap.update
  858. end
  859. @shadow.skew(angle)
  860. if !@anim && [email protected]?
  861. @pulse += @k
  862. @k *= -1 if @pulse == 128 || @pulse == 8
  863. case @status
  864. when 0
  865. @sprite.color = Color.new(0,0,0,0)
  866. when 1 #PSN
  867. @sprite.color = Color.new(109,55,130,@pulse)
  868. when 2 #PAR
  869. @sprite.color = Color.new(204,152,44,@pulse)
  870. when 3 #FRZ
  871. @sprite.color = Color.new(56,160,193,@pulse)
  872. when 4 #BRN
  873. @sprite.color = Color.new(206,73,43,@pulse)
  874. end
  875. end
  876. @anim = false
  877. # Pokémon sprite blinking when targeted or damaged
  878. @frame += 1
  879. @frame = 0 if @frame > 256
  880. if @selected==2 # When targeted or damaged
  881. @sprite.visible = (@frame%10<7) && !@hidden
  882. end
  883. self.formatShadow
  884. end
  885.  
  886. def shadowUpdate
  887. return if !@loaded
  888. return if self.disposed? || @bitmap.disposed?
  889. for i in 0...16
  890. next if i > @frame2/4
  891. @fp["#{i}"].visible = @showshadow
  892. @fp["#{i}"].visible = false if @hidden
  893. @fp["#{i}"].visible = false if !@isShadow
  894. next if !@isShadow
  895. if @fp["#{i}"].opacity <= 0
  896. @fp["#{i}"].toggle = 2
  897. z = [0.5,0.6,0.7,0.8,0.9,1.0][rand(6)]
  898. @fp["#{i}"].param = z
  899. @fp["#{i}"].x = self.x - self.bitmap.width*self.zoom_x/2 + rand(self.bitmap.width)*self.zoom_x
  900. @fp["#{i}"].y = self.y - 64*self.zoom_y + rand(64)*self.zoom_y
  901. @fp["#{i}"].z = (rand(2)==0) ? self.z - 1 : self.z + 1
  902. @fp["#{i}"].speed = (rand(2)==0) ? +1 : -1
  903. @fp["#{i}"].src_rect.x = rand(2)*@fp["#{i}"].bitmap.width/2
  904. end
  905. @fp["#{i}"].zoom_x = @fp["#{i}"].param*self.zoom_x
  906. @fp["#{i}"].zoom_y = @fp["#{i}"].param*self.zoom_y
  907. @fp["#{i}"].param -= 0.01
  908. @fp["#{i}"].y -= 1
  909. @fp["#{i}"].opacity += 8*@fp["#{i}"].toggle
  910. @fp["#{i}"].toggle = -1 if @fp["#{i}"].opacity >= 255
  911. end
  912. @frame2 += 1 if @frame2 < 128
  913. end
  914.  
  915. def chargedUpdate
  916. return if !@loaded
  917. return if self.disposed? || @bitmap.disposed?
  918. for i in 0...16
  919. next if i > @frame3/16
  920. @fp["c#{i}"].visible = @showshadow
  921. @fp["c#{i}"].visible = false if @hidden
  922. @fp["c#{i}"].visible = false if !@charged
  923. next if !@charged
  924. if @fp["c#{i}"].opacity <= 0
  925. x = @sprite.x - @sprite.ox + rand(@sprite.bitmap.width)
  926. y = @sprite.y - @sprite.oy*0.7 + rand(@sprite.bitmap.height*0.8)
  927. @fp["c#{i}"].x = x
  928. @fp["c#{i}"].y = y
  929. @fp["c#{i}"].z = (rand(2)==0) ? self.z - 1 : self.z + 1
  930. @fp["c#{i}"].src_rect.x = rand(4)*@fp["c#{i}"].bitmap.width/4
  931. @fp["c#{i}"].zoom_y = 0.6
  932. @fp["c#{i}"].opacity = 166 + rand(90)
  933. @fp["c#{i}"].mirror = (x < @sprite.x) ? false : true
  934. end
  935. @fp["c#{i}"].zoom_y += 0.1
  936. @fp["c#{i}"].opacity -= 16
  937. end
  938. for j in 0...4
  939. next if j > @frame3/32
  940. @fp["r#{j}"].visible = @showshadow
  941. @fp["r#{j}"].visible = false if @hidden
  942. @fp["r#{j}"].visible = false if !@charged
  943. if @fp["r#{j}"].opacity <= 0
  944. @fp["r#{j}"].opacity = 255
  945. @fp["r#{j}"].zoom_x = 0
  946. @fp["r#{j}"].zoom_y = 0
  947. @fp["r#{j}"].param = 0
  948. end
  949. @fp["r#{j}"].param += 0.01
  950. @fp["r#{j}"].zoom_x = @fp["r#{j}"].param*self.zoom_x
  951. @fp["r#{j}"].zoom_y = @fp["r#{j}"].param*self.zoom_x
  952. @fp["r#{j}"].x = self.x
  953. @fp["r#{j}"].y = self.y
  954. @fp["r#{j}"].opacity -= 2
  955. end
  956. @frame3 += 1 if @frame3 < 256
  957. end
  958. end
  959. #-------------------------------------------------------------------------------
  960. # Animated trainer sprites
  961. #-------------------------------------------------------------------------------
  962. class DynamicTrainerSprite < DynamicPokemonSprite
  963.  
  964. def initialize(doublebattle,index,viewport=nil,trarray=false)
  965. @viewport=viewport
  966. @trarray=trarray
  967. @selected=0
  968. @frame=0
  969. @frame2=0
  970.  
  971. @status=0
  972. @loaded=false
  973. @index=index
  974. @doublebattle=doublebattle
  975. @showshadow=true
  976. @altitude=0
  977. @yposition=0
  978. @shadow=Sprite.new(@viewport)
  979. @sprite=Sprite.new(@viewport)
  980. @overlay=Sprite.new(@viewport)
  981. @lock=false
  982. end
  983.  
  984. def totalFrames; @bitmap.animationFrames; end
  985. def toLastFrame
  986. @bitmap.toFrame(@bitmap.totalFrames-1)
  987. self.update
  988. end
  989. def selected; end
  990.  
  991. def setTrainerBitmap(file)
  992. @bitmap=AnimatedBitmapWrapper.new(file,TRAINERSPRITESCALE)
  993. if @doublebattle && @trarray
  994. if @index==-2
  995. @sprite.ox-=50
  996. elsif @index==-1
  997. @sprite.ox+=50
  998. end
  999. end
  1000.  
  1001. self.formatShadow
  1002. @shadow.skew(74)
  1003. end
  1004.  
  1005. end
  1006. #-------------------------------------------------------------------------------
  1007. # New class used to configure and animate battle backgrounds
  1008. #-------------------------------------------------------------------------------
  1009. class AnimatedBattleBackground < Sprite
  1010.  
  1011. def setBitmap(backdrop,scene)
  1012. blur = 4; blur = BLURBATTLEBACKGROUND if BLURBATTLEBACKGROUND.is_a?(Numeric)
  1013. @eff = {}
  1014. @scene = scene
  1015. if $INEDITOR
  1016. @defaultvector = VECTOR1
  1017. else
  1018. @defaultvector = (@scene.battle.doublebattle ? VECTOR2 : VECTOR1)
  1019. end
  1020. @canAnimate = !pbResolveBitmap("Graphics/BattleBacks/Animation/eff1"+backdrop).nil?
  1021. bg = pbBitmap("Graphics/BattleBacks/battlebg/"+backdrop)
  1022. @bmp = Bitmap.new(bg.width*BACKGROUNDSCALAR,bg.width*BACKGROUNDSCALAR)
  1023. @bmp.stretch_blt(Rect.new(0,0,@bmp.width,@bmp.height),bg,Rect.new(0,0,bg.width,bg.height))
  1024. self.bitmap = @bmp.clone
  1025. self.blur_sprite(blur) if BLURBATTLEBACKGROUND
  1026. sx, sy = @scene.vector.spoof(@defaultvector)
  1027. self.ox = 256 + sx
  1028. self.oy = 192 + sy
  1029. for i in 1..3
  1030. next if !@canAnimate
  1031. @eff["#{i}"] = Sprite.new(self.viewport)
  1032. bmp = pbBitmap("Graphics/BattleBacks/Animation/eff#{i}"+backdrop)
  1033. @eff["#{i}"].bitmap = Bitmap.new(@bmp.width*2,@bmp.height)
  1034. @eff["#{i}"].bitmap.stretch_blt(Rect.new(0,0,@bmp.width*2,@bmp.height),bmp,Rect.new(0,0,bmp.width,bmp.height))
  1035. @eff["#{i}"].src_rect.set([0,128,0,-128][i]*BACKGROUNDSCALAR,0,bmp.width*BACKGROUNDSCALAR/2,bmp.height*BACKGROUNDSCALAR)
  1036. @eff["#{i}"].ox = self.ox
  1037. @eff["#{i}"].oy = self.oy
  1038. @eff["#{i}"].blur_sprite(blur) if BLURBATTLEBACKGROUND
  1039. end
  1040. self.update
  1041. end
  1042.  
  1043. def update
  1044. if @canAnimate
  1045. @eff["1"].src_rect.x -= 1
  1046. @eff["1"].src_rect.x = 512*BACKGROUNDSCALAR if @eff["1"].src_rect.x <= -256*BACKGROUNDSCALAR
  1047. @eff["2"].src_rect.x += 1
  1048. @eff["2"].src_rect.x = -256*BACKGROUNDSCALAR if @eff["2"].src_rect.x >= 512*BACKGROUNDSCALAR
  1049. @eff["3"].src_rect.x -= 2
  1050. @eff["3"].src_rect.x = 512*BACKGROUNDSCALAR if @eff["3"].src_rect.x <= -256*BACKGROUNDSCALAR
  1051. end
  1052. # coordinates
  1053. self.x = @scene.vector.x2
  1054. self.y = @scene.vector.y2
  1055. self.angle = ((@scene.vector.angle - @defaultvector[2])*0.5).to_i if $PokemonSystem.screensize < 2 && @scene.sendingOut
  1056. sx, sy = @scene.vector.spoof(@defaultvector)
  1057. self.zoom_x = ((@scene.vector.x2 - @scene.vector.x)*1.0/(sx - @defaultvector[0])*1.0)**0.6
  1058. self.zoom_y = ((@scene.vector.y2 - @scene.vector.y)*1.0/(sy - @defaultvector[1])*1.0)**0.6
  1059. for i in 1..3
  1060. next if !@canAnimate
  1061. @eff["#{i}"].x = self.x
  1062. @eff["#{i}"].y = self.y
  1063. @eff["#{i}"].zoom_x = self.zoom_x
  1064. @eff["#{i}"].zoom_y = self.zoom_y
  1065. @eff["#{i}"].visible = true
  1066. @eff["#{i}"].tone = self.tone
  1067. if self.angle!=0
  1068. @eff["#{i}"].opacity -= 51
  1069. else
  1070. @eff["#{i}"].opacity += 51
  1071. end
  1072. end
  1073. end
  1074.  
  1075. alias dispose_bg_ebs dispose unless self.method_defined?(:dispose_bg_ebs)
  1076. def dispose
  1077. pbDisposeSpriteHash(@eff)
  1078. dispose_bg_ebs
  1079. end
  1080.  
  1081. alias :color_bg= :color= unless self.method_defined?(:color_bg=)
  1082. def color=(val)
  1083. for i in 1..3
  1084. next if !@canAnimate
  1085. @eff["#{i}"].color = val
  1086. end
  1087. self.color_bg = val
  1088. end
  1089. end
  1090. #-------------------------------------------------------------------------------
  1091. # New class used to render the Mother Beast Lusamine styled VS background
  1092. #-------------------------------------------------------------------------------
  1093. class CrazyRainbowBackground
  1094.  
  1095. def initialize(viewport)
  1096. @viewport = viewport
  1097. @sprites = {}
  1098.  
  1099. @sprites["bg"] = Sprite.new(@viewport)
  1100. @sprites["bg"].drawRect(@viewport.rect.width,@viewport.rect.height,Color.new(0,0,0))
  1101. @sprites["bg"].z = 200
  1102. for j in 0...3
  1103. @sprites["b#{j}"] = RainbowSprite.new(@viewport)
  1104. @sprites["b#{j}"].setBitmap("Graphics/Transitions/smC#{j}",8)
  1105. @sprites["b#{j}"].ox = @sprites["b#{j}"].bitmap.width/2
  1106. @sprites["b#{j}"].oy = @sprites["b#{j}"].bitmap.height/2
  1107. @sprites["b#{j}"].x = @viewport.rect.width/2
  1108. @sprites["b#{j}"].y = @viewport.rect.height/2
  1109. @sprites["b#{j}"].zoom_x = 0.6 + 0.6*j
  1110. @sprites["b#{j}"].zoom_y = 0.6 + 0.6*j
  1111. @sprites["b#{j}"].opacity = 64 + 64*(1+j)
  1112. @sprites["b#{j}"].z = 250
  1113. end
  1114. for j in 0...64
  1115. @sprites["p#{j}"] = Sprite.new(@viewport)
  1116. @sprites["p#{j}"].z = 300
  1117. width = 16 + rand(48)
  1118. height = 16 + rand(16)
  1119. @sprites["p#{j}"].bitmap = Bitmap.new(width,height)
  1120. bmp = pbBitmap("Graphics/Transitions/smCParticle")
  1121. @sprites["p#{j}"].bitmap.stretch_blt(Rect.new(0,0,width,height),bmp,Rect.new(0,0,bmp.width,bmp.height))
  1122. @sprites["p#{j}"].bitmap.hue_change(rand(360))
  1123. @sprites["p#{j}"].ox = width/2
  1124. @sprites["p#{j}"].oy = height + 192 + rand(32)
  1125. @sprites["p#{j}"].angle = rand(360)
  1126. @sprites["p#{j}"].speed = 1 + rand(4)
  1127. @sprites["p#{j}"].x = @viewport.rect.width/2
  1128. @sprites["p#{j}"].y = @viewport.rect.height/2
  1129. @sprites["p#{j}"].zoom_x = (@sprites["p#{j}"].oy/192.0)*1.5
  1130. @sprites["p#{j}"].zoom_y = (@sprites["p#{j}"].oy/192.0)*1.5
  1131. end
  1132. @frame = 0
  1133. end
  1134.  
  1135. def update
  1136. for j in 0...3
  1137. @sprites["b#{j}"].zoom_x -= 0.025
  1138. @sprites["b#{j}"].zoom_y -= 0.025
  1139. @sprites["b#{j}"].opacity -= 4
  1140. if @sprites["b#{j}"].zoom_x <= 0 || @sprites["b#{j}"].opacity <= 0
  1141. @sprites["b#{j}"].zoom_x = 2.25
  1142. @sprites["b#{j}"].zoom_y = 2.25
  1143. @sprites["b#{j}"].opacity = 255
  1144. end
  1145. @sprites["b#{j}"].update if @frame%8==0
  1146. end
  1147. for j in 0...64
  1148. @sprites["p#{j}"].angle -= @sprites["p#{j}"].speed
  1149. @sprites["p#{j}"].opacity -= @sprites["p#{j}"].speed
  1150. @sprites["p#{j}"].oy -= @sprites["p#{j}"].speed/2 if @sprites["p#{j}"].oy > @sprites["p#{j}"].bitmap.height
  1151. @sprites["p#{j}"].zoom_x = (@sprites["p#{j}"].oy/192.0)*1.5
  1152. @sprites["p#{j}"].zoom_y = (@sprites["p#{j}"].oy/192.0)*1.5
  1153. if @sprites["p#{j}"].zoom_x <= 0 || @sprites["p#{j}"].oy <= 0 || @sprites["p#{j}"].opacity <= 0
  1154. @sprites["p#{j}"].angle = rand(360)
  1155. @sprites["p#{j}"].oy = @sprites["p#{j}"].bitmap.height + 192 + rand(32)
  1156. @sprites["p#{j}"].zoom_x = (@sprites["p#{j}"].oy/192.0)*1.5
  1157. @sprites["p#{j}"].zoom_y = (@sprites["p#{j}"].oy/192.0)*1.5
  1158. @sprites["p#{j}"].opacity = 255
  1159. @sprites["p#{j}"].speed = 1 + rand(4)
  1160. end
  1161. end
  1162. @frame += 1
  1163. @frame = 0 if @frame > 128
  1164. end
  1165.  
  1166. def dispose
  1167. pbDisposeSpriteHash(@sprites)
  1168. end
  1169.  
  1170. end
  1171. #===============================================================================
  1172. # New functions for the Sprite class
  1173. # adds new bitmap transformations
  1174. #===============================================================================
  1175. def setPictureSpriteEB(sprite,picture)
  1176. sprite.visible = picture.visible
  1177. # Set sprite coordinates
  1178. sprite.y = picture.y
  1179. sprite.z = picture.number
  1180. # Set zoom rate, opacity level, and blend method
  1181. sprite.zoom_x = picture.zoom_x / 100.0
  1182. sprite.zoom_y = picture.zoom_y / 100.0
  1183. sprite.opacity = picture.opacity
  1184. sprite.blend_type = picture.blend_type
  1185. # Set rotation angle and color tone
  1186. angle = picture.angle
  1187. sprite.tone = picture.tone
  1188. sprite.color = picture.color
  1189. while angle < 0
  1190. angle += 360
  1191. end
  1192. angle %= 360
  1193. sprite.angle=angle
  1194. end
  1195. #-------------------------------------------------------------------------------
  1196. # Utilities used for move animations
  1197. #-------------------------------------------------------------------------------
  1198. class PokeBattle_Scene
  1199. def getCenter(sprite,zoom=false)
  1200. zoom = zoom ? sprite.zoom_y : 1
  1201. x = sprite.x
  1202. y = sprite.y + (sprite.bitmap.height-sprite.oy)*zoom - sprite.bitmap.height*zoom/2
  1203. return x, y
  1204. end
  1205.  
  1206. def alignSprites(sprite,target)
  1207. sprite.ox = sprite.src_rect.width/2
  1208. sprite.oy = sprite.src_rect.height/2
  1209. sprite.x, sprite.y = getCenter(target)
  1210. sprite.zoom_x, sprite.zoom_y = target.zoom_x/2, target.zoom_y/2
  1211. end
  1212.  
  1213. def getRealVector(targetindex,player)
  1214. vector = (player ? PLAYERVECTOR : ENEMYVECTOR).clone
  1215. if @battle.doublebattle && !USEBATTLEBASES
  1216. case targetindex
  1217. when 0
  1218. vector[0] = vector[0] + 80
  1219. when 1
  1220. vector[0] = vector[0] + 192
  1221. when 2
  1222. vector[0] = vector[0] - 64
  1223. when 3
  1224. vector[0] = vector[0] - 36
  1225. end
  1226. end
  1227. return vector
  1228. end
  1229.  
  1230. def applySpriteProperties(sprite1,sprite2)
  1231. sprite2.x = sprite1.x
  1232. sprite2.y = sprite1.y
  1233. sprite2.z = sprite1.z
  1234. sprite2.zoom_x = sprite1.zoom_x
  1235. sprite2.zoom_y = sprite1.zoom_y
  1236. sprite2.opacity = sprite1.opacity
  1237. sprite2.angle = sprite1.angle
  1238. sprite2.tone = sprite1.tone
  1239. sprite2.color = sprite1.color
  1240. sprite2.visible = sprite1.visible
  1241. end
  1242. end
  1243. #===============================================================================
  1244. # Misc. scripting tools
  1245. #===============================================================================
  1246. def checkEBFolderPath
  1247. if !pbResolveBitmap("Graphics/Pictures/EBS/pokeballs").nil?
  1248. return "Graphics/Pictures/EBS"
  1249. else
  1250. return "Graphics/Pictures"
  1251. end
  1252. end
  1253.  
  1254. def checkEBFolderPathDS
  1255. if !pbResolveBitmap("Graphics/Pictures/EBS/DS/background").nil?
  1256. return "Graphics/Pictures/EBS/DS"
  1257. else
  1258. return "Graphics/Pictures"
  1259. end
  1260. end
  1261.  
  1262. #===============================================================================
  1263. # Elite Battle system
  1264. # by Luka S.J.
  1265. # ----------------
  1266. # EntryAnimations Script
  1267. # ----------------
  1268. # system is based off the original Essentials battle system, made by
  1269. # Poccil & Maruno
  1270. # No additional features added to AI, mechanics
  1271. # or functionality of the battle system.
  1272. # This update is purely cosmetic, and includes a B/W like dynamic scene with a
  1273. # custom interface.
  1274. #
  1275. # Enjoy the script, and make sure to give credit!
  1276. # (DO NOT ALTER THE NAMES OF THE INDIVIDUAL SCRIPT SECTIONS OR YOU WILL BREAK
  1277. # YOUR SYSTEM!)
  1278. #-------------------------------------------------------------------------------
  1279. # Replaces the stock battle start animations for trainer (non-VS) and wild
  1280. # battles.
  1281. #
  1282. # If you'd like to use just the new transitions from EBS for your project,
  1283. # you'll also need to copy over the EliteBattle_Sprites section of the scripts
  1284. # to your project, as well as the configurations for the following constants:
  1285. # - VIEWPORT_HEIGHT
  1286. # - VIEWPORT_OFFSET
  1287. #
  1288. # In order to use the New VS sequence you need the following images in your
  1289. # Graphics/Transitions/ folder:
  1290. # - vsTrainer#{trainer_id}
  1291. # - vsBarNew#{trainer_id}
  1292. #
  1293. # In order to use the Elite Four VS sequence you need the following images in your
  1294. # Graphics/Transitions/ folder:
  1295. # - vsTrainer#{trainer_id}
  1296. # - vsBarElite#{trainer_id}
  1297. #
  1298. # In order to use the Special VS sequence you need the following images in your
  1299. # Graphics/Transitions/ folder:
  1300. # - vsTrainerSpecial#{trainer_id}
  1301. # - vsBarSpecial#{trainer_id}
  1302. #
  1303. # In order to use the new Sun/Moon styled trainer battles you need the following
  1304. # in your Graphics/Transitions/ folder:
  1305. # - smTrainer#{trainer_id}
  1306. # Other styles for S&M transitions:
  1307. # - smSpecial#{trainer_id} <-- Plays a special version
  1308. # - smElite#{trainer_id} <-- Plays an Elite4 version
  1309. # - smCrazy#{trainer_id} <-- Plays a crazy bg version
  1310. #
  1311. # Having just the trainersprite will play the animation with the default background
  1312. # found in the Graphics/Transitions/ folder. You can use unique backgrounds for
  1313. # your trainertypes by having the following in your folder:
  1314. # - smBg#{trainer_id}
  1315. # - smBgNext#{trainer_id}
  1316. # - smBgLast#{trainer_id}
  1317. # - smEffBg#{trainer_id} (for Elite4 variant)
  1318. #
  1319. # If you have the smSpecial#{trainer_id} image file in your Graphics/Transitions
  1320. # folder, the game will play a special variant of the SM VS animation.
  1321. #
  1322. # New graphics for default VS backgrounds of any trainertypes registered in the
  1323. # EVIL_TEAM_LIST array are in Graphics/Transitions/ folder:
  1324. # - smBgEvil
  1325. # - smBgNextEvil
  1326. # - smBgLastEvil
  1327. #
  1328. # You can add special transitions for your species by having the following
  1329. # Graphics in your Graphics/Transitions/ folder:
  1330. # - species#{species_id}
  1331. # - speciesBg#{species_id} (optional)
  1332. # - speciesEffA#{species_id} (optional)
  1333. # - speciesEffB#{species_id} (optional)
  1334. # - speciesEffC#{species_id} (optional)
  1335. #
  1336. # This style is only compatible with the Next Gen UI
  1337. #===============================================================================
  1338. alias pbBattleAnimation_ebs pbBattleAnimation unless defined?(pbBattleAnimation_ebs)
  1339. def pbBattleAnimation(bgm=nil,trainerid=-1,trainername="")
  1340. handled = false
  1341. playingBGS = nil
  1342. playingBGM = nil
  1343. if $game_system && $game_system.is_a?(Game_System)
  1344. playingBGS = $game_system.getPlayingBGS
  1345. playingBGM = $game_system.getPlayingBGM
  1346. $game_system.bgm_pause
  1347. $game_system.bgs_pause
  1348. end
  1349. $smAnim = false
  1350. $specialSpecies = false
  1351. pbMEFade(0.25)
  1352. pbWait(10)
  1353. pbMEStop
  1354. for value in BATTLE_BGM_SPECIES
  1355. if value[0].is_a?(Array)
  1356. for species in value[0]
  1357. num = species if species.is_a?(Numeric)
  1358. num = getConst(PBSpecies,species) if species.is_a?(Symbol)
  1359. bgm = value[1] if !num.nil? && trainerid < 0 && num == $wildSpecies
  1360. end
  1361. else
  1362. num = value[0] if value[0].is_a?(Numeric)
  1363. num = getConst(PBSpecies,value[0]) if value[0].is_a?(Symbol)
  1364. bgm = value[1] if !num.nil? && trainerid < 0 && num == $wildSpecies
  1365. end
  1366. end
  1367. if bgm
  1368. pbBGMPlay(bgm,80)
  1369. else
  1370. pbBGMPlay(pbGetWildBattleBGM(0),80)
  1371. end
  1372. viewport = Viewport.new(0,0,Graphics.width,VIEWPORT_HEIGHT)
  1373. viewport.z = 99999
  1374. # Fade to gray a few times.
  1375. viewport.color = Color.new(17*8,17*8,17*8)
  1376. 3.times do
  1377. viewport.color.alpha = 0
  1378. 6.times do
  1379. viewport.color.alpha += 30
  1380. Graphics.update
  1381. Input.update
  1382. pbUpdateSceneMap
  1383. end
  1384. 6.times do
  1385. viewport.color.alpha -= 30
  1386. Graphics.update
  1387. Input.update
  1388. pbUpdateSceneMap
  1389. end
  1390. end
  1391.  
  1392. if trainerid >= 0 && !handled
  1393. tgraphic = sprintf("Graphics/Transitions/smTrainer%d",trainerid)
  1394. tgraphic2 = sprintf("Graphics/Transitions/smSpecial%d",trainerid)
  1395. tgraphic3 = sprintf("Graphics/Transitions/smElite%d",trainerid)
  1396. tgraphic4 = sprintf("Graphics/Transitions/smCrazy%d",trainerid)
  1397. e_team = false
  1398. for val in EVIL_TEAM_LIST
  1399. if val.is_a?(Numeric)
  1400. id = val
  1401. elsif val.is_a?(Symbol)
  1402. id = getConst(PBTrainers,val)
  1403. end
  1404. e_team = true if !id.nil? && trainerid == id
  1405. end
  1406. handled = vsEvilTeam(viewport) if e_team
  1407. if (pbResolveBitmap(tgraphic) || pbResolveBitmap(tgraphic2) || pbResolveBitmap(tgraphic3) || pbResolveBitmap(tgraphic4)) && defined?(EBUISTYLE)
  1408. viewport.color = Color.new(255,255,255,0)
  1409. smPreBattle(viewport) if !handled
  1410. handled = true
  1411. $smAnim = true
  1412. end
  1413. tbargraphic = sprintf("Graphics/Transitions/vsBarSpecial%s",getConstantName(PBTrainers,trainerid)) rescue nil
  1414. tbargraphic = sprintf("Graphics/Transitions/vsBarSpecial%d",trainerid) if !pbResolveBitmap(tbargraphic)
  1415. tgraphic = sprintf("Graphics/Transitions/vsTrainerSpecial%s",getConstantName(PBTrainers,trainerid)) rescue nil
  1416. tgraphic = sprintf("Graphics/Transitions/vsTrainerSpecial%d",trainerid) if !pbResolveBitmap(tgraphic)
  1417. if pbResolveBitmap(tgraphic) && !handled
  1418. handled = vsSequenceSpecial(viewport,trainername,trainerid,tbargraphic,tgraphic)
  1419. end
  1420. tbargraphic = sprintf("Graphics/Transitions/vsBarElite%s",getConstantName(PBTrainers,trainerid)) rescue nil
  1421. tbargraphic = sprintf("Graphics/Transitions/vsBarElite%d",trainerid) if !pbResolveBitmap(tbargraphic)
  1422. tgraphic = sprintf("Graphics/Transitions/vsTrainer%s",getConstantName(PBTrainers,trainerid)) rescue nil
  1423. tgraphic = sprintf("Graphics/Transitions/vsTrainer%d",trainerid) if !pbResolveBitmap(tgraphic)
  1424. if pbResolveBitmap(tbargraphic) && pbResolveBitmap(tgraphic) && !handled
  1425. handled = vsSequenceElite(viewport,trainername,trainerid,tbargraphic,tgraphic)
  1426. end
  1427. tbargraphic = sprintf("Graphics/Transitions/vsBarNew%s",getConstantName(PBTrainers,trainerid)) rescue nil
  1428. tbargraphic = sprintf("Graphics/Transitions/vsBarNew%d",trainerid) if !pbResolveBitmap(tbargraphic)
  1429. if pbResolveBitmap(tbargraphic) && pbResolveBitmap(tgraphic) && !handled
  1430. handled = vsSequenceNew(viewport,trainername,trainerid,tbargraphic,tgraphic)
  1431. end
  1432. tbargraphic = sprintf("Graphics/Transitions/vsBar%s",getConstantName(PBTrainers,trainerid)) rescue nil
  1433. tbargraphic = sprintf("Graphics/Transitions/vsBar%d",trainerid) if !pbResolveBitmap(tbargraphic)
  1434. if pbResolveBitmap(tbargraphic) && pbResolveBitmap(tgraphic) && !handled
  1435. handled = vsSequenceEssentials(viewport,trainername,trainerid,tbargraphic,tgraphic)
  1436. end
  1437. end
  1438. if !handled && trainerid >= 0
  1439. case rand(3)
  1440. when 0
  1441. ebTrainerAnimation1(viewport)
  1442. when 1
  1443. ebTrainerAnimation2(viewport)
  1444. when 2
  1445. ebTrainerAnimation3(viewport)
  1446. end
  1447. handled = true
  1448. end
  1449. if !handled
  1450. minor = false
  1451. if !$wildSpecies.nil?
  1452. for species in MINOR_LEGENDARIES
  1453. num = species if species.is_a?(Numeric)
  1454. num = getConst(PBSpecies,species) if species.is_a?(Symbol)
  1455. minor = true if $wildSpecies == num
  1456. end
  1457. special = pbResolveBitmap("Graphics/Transitions/species#{$wildSpecies}")
  1458. end
  1459. if !$wildSpecies.nil? && queuedIsRegi?
  1460. ebWildAnimationRegi(viewport)
  1461. elsif !$wildSpecies.nil? && special
  1462. ebWildAnimationMinor(viewport,true)
  1463. $specialSpecies = true
  1464. elsif !$wildSpecies.nil? && minor
  1465. ebWildAnimationMinor(viewport)
  1466. elsif !$wildLevel.nil? && $wildLevel > $Trainer.party[0].level
  1467. ebWildAnimationOverlevel(viewport)
  1468. elsif $PokemonGlobal && ($PokemonGlobal.surfing || $PokemonGlobal.diving || $PokemonGlobal.fishing)
  1469. ebWildAnimationWater(viewport)
  1470. elsif $PokemonEncounters && $PokemonEncounters.isCave?
  1471. ebWildAnimationCave(viewport)
  1472. elsif pbGetMetadata($game_map.map_id,MetadataOutdoor)
  1473. ebWildAnimationOutdoor(viewport)
  1474. else
  1475. ebWildAnimationIndoor(viewport)
  1476. end
  1477. handled = true
  1478. end
  1479. pbPushFade
  1480. yield if block_given?
  1481. pbPopFade
  1482. if $game_system && $game_system.is_a?(Game_System)
  1483. $game_system.bgm_resume(playingBGM)
  1484. $game_system.bgs_resume(playingBGS)
  1485. end
  1486. $PokemonGlobal.nextBattleBGM = nil
  1487. $PokemonGlobal.nextBattleME = nil
  1488. $PokemonGlobal.nextBattleBack = nil
  1489. $PokemonEncounters.clearStepCount
  1490. for j in 0..17
  1491. viewport.color = Color.new(0,0,0,(17-j)*15)
  1492. Graphics.update
  1493. Input.update
  1494. pbUpdateSceneMap
  1495. end
  1496. viewport.dispose
  1497. $smAnim = false
  1498. end
  1499.  
  1500. alias pbWildBattle_ebs pbWildBattle unless defined?(pbWildBattle_ebs)
  1501. def pbWildBattle(*args)
  1502. species = args[0]
  1503. if species.is_a?(String) || species.is_a?(Symbol)
  1504. $wildSpecies = getConst(PBSpecies,species)
  1505. else
  1506. $wildSpecies = species
  1507. end
  1508. $wildLevel = args[1]
  1509. return pbWildBattle_ebs(*args)
  1510. $wildSpecies = nil
  1511. $wildLevel = nil
  1512. end
  1513. #-------------------------------------------------------------------------------
  1514. # Custom animations for trainer battles
  1515. #-------------------------------------------------------------------------------
  1516. def ebTrainerAnimation1(viewport)
  1517. ball=Sprite.new(viewport)
  1518. ball.bitmap=pbBitmap("Graphics/Transitions/vsBall")
  1519. ball.ox=ball.bitmap.width/2
  1520. ball.oy=ball.bitmap.height/2
  1521. ball.x=viewport.rect.width/2
  1522. ball.y=viewport.rect.height/2
  1523. ball.zoom_x=0
  1524. ball.zoom_y=0
  1525. 16.times do
  1526. ball.angle+=22.5
  1527. ball.zoom_x+=0.0625
  1528. ball.zoom_y+=0.0625
  1529. pbWait(1)
  1530. end
  1531. bmp=Graphics.snap_to_bitmap
  1532. pbWait(8)
  1533. ball.dispose
  1534. black=Sprite.new(viewport)
  1535. black.bitmap=Bitmap.new(viewport.rect.width,viewport.rect.height)
  1536. black.bitmap.fill_rect(0,0,viewport.rect.width,viewport.rect.height,Color.new(0,0,0))
  1537. field1=Sprite.new(viewport)
  1538. field1.bitmap=bmp
  1539. field1.src_rect.height=VIEWPORT_HEIGHT/2
  1540. field2=Sprite.new(viewport)
  1541. field2.bitmap=bmp
  1542. field2.y=VIEWPORT_HEIGHT/2
  1543. field2.src_rect.height=VIEWPORT_HEIGHT/2
  1544. field2.src_rect.y=(VIEWPORT_HEIGHT+VIEWPORT_OFFSET)/2
  1545. 16.times do
  1546. field1.x-=viewport.rect.width/16
  1547. field2.x+=viewport.rect.width/16
  1548. pbWait(1)
  1549. end
  1550. viewport.color=Color.new(0,0,0,255)
  1551. black.dispose
  1552. field1.dispose
  1553. field2.dispose
  1554. end
  1555.  
  1556. def ebTrainerAnimation2(viewport)
  1557. bmp=Graphics.snap_to_bitmap
  1558. black=Sprite.new(viewport)
  1559. black.bitmap=Bitmap.new(viewport.rect.width,viewport.rect.height)
  1560. black.bitmap.fill_rect(0,0,viewport.rect.width,viewport.rect.height,Color.new(0,0,0))
  1561. field1=Sprite.new(viewport)
  1562. field1.bitmap=bmp
  1563. field1.src_rect.height=VIEWPORT_HEIGHT/2
  1564. field2=Sprite.new(viewport)
  1565. field2.bitmap=bmp
  1566. field2.y=VIEWPORT_HEIGHT/2
  1567. field2.src_rect.height=VIEWPORT_HEIGHT/2
  1568. field2.src_rect.y=(VIEWPORT_HEIGHT+VIEWPORT_OFFSET)/2
  1569. ball1=Sprite.new(viewport)
  1570. ball1.bitmap=pbBitmap("Graphics/Transitions/vsBall")
  1571. ball1.ox=ball1.bitmap.width/2
  1572. ball1.oy=ball1.bitmap.height/2
  1573. ball1.x=viewport.rect.width+ball1.ox
  1574. ball1.y=viewport.rect.height/4
  1575. ball1.zoom_x=0.5
  1576. ball1.zoom_y=0.5
  1577. ball2=Sprite.new(viewport)
  1578. ball2.bitmap=pbBitmap("Graphics/Transitions/vsBall")
  1579. ball2.ox=ball2.bitmap.width/2
  1580. ball2.oy=ball2.bitmap.height/2
  1581. ball2.y=(viewport.rect.height/4)*3
  1582. ball2.x=-ball2.ox
  1583. ball2.zoom_x=0.5
  1584. ball2.zoom_y=0.5
  1585. 16.times do
  1586. ball1.x-=(viewport.rect.width/8)
  1587. ball2.x+=(viewport.rect.width/8)
  1588. pbWait(1)
  1589. end
  1590. 32.times do
  1591. field1.x-=(viewport.rect.width/16)
  1592. field1.y-=(viewport.rect.height/32)
  1593. field2.x+=(viewport.rect.width/16)
  1594. field2.y+=(viewport.rect.height/32)
  1595. pbWait(1)
  1596. end
  1597. viewport.color=Color.new(0,0,0,255)
  1598. black.dispose
  1599. ball1.dispose
  1600. ball2.dispose
  1601. field1.dispose
  1602. field2.dispose
  1603. end
  1604.  
  1605. def ebTrainerAnimation3(viewport)
  1606. balls = {}
  1607. rects = {}
  1608. ball = Bitmap.new(viewport.rect.height/6,viewport.rect.height/6)
  1609. bmp = pbBitmap("Graphics/Transitions/vsBall")
  1610. ball.stretch_blt(Rect.new(0,0,ball.width,ball.height),bmp,Rect.new(0,0,bmp.width,bmp.height))
  1611. for i in 0...6
  1612. rects["#{i}"] = Sprite.new(viewport)
  1613. rects["#{i}"].bitmap = Bitmap.new(1,viewport.rect.height/6)
  1614. rects["#{i}"].bitmap.fill_rect(0,0,1,viewport.rect.height/6,Color.new(0,0,0))
  1615. rects["#{i}"].x = (i%2==0) ? -32 : viewport.rect.width+32
  1616. rects["#{i}"].ox = (i%2==0) ? 0 : 1
  1617. rects["#{i}"].y = (viewport.rect.height/6)*i
  1618.  
  1619. balls["#{i}"] = Sprite.new(viewport)
  1620. balls["#{i}"].bitmap = ball
  1621. balls["#{i}"].ox = ball.width/2
  1622. balls["#{i}"].oy = ball.height/2
  1623. balls["#{i}"].x = rects["#{i}"].x
  1624. balls["#{i}"].y = rects["#{i}"].y + rects["#{i}"].bitmap.height/2
  1625. end
  1626. for j in 0...28
  1627. for i in 0...6
  1628. balls["#{i}"].x+=(i%2==0) ? 24 : -24
  1629. balls["#{i}"].angle-=(i%2==0) ? 42 : -42
  1630. rects["#{i}"].zoom_x+=24
  1631. end
  1632. pbWait(1)
  1633. end
  1634. viewport.color = Color.new(0,0,0,255)
  1635. pbDisposeSpriteHash(balls)
  1636. pbDisposeSpriteHash(rects)
  1637. end
  1638.  
  1639. def vsEvilTeam(viewport)
  1640. fp = {}
  1641. viewport.color = Color.new(0,0,0,0)
  1642. 8.times do
  1643. viewport.color.alpha += 32
  1644. pbWait(1)
  1645. end
  1646.  
  1647. fp["bg"] = Sprite.new(viewport)
  1648. fp["bg"].bitmap = pbBitmap("Graphics/Transitions/evilTeamBg")
  1649. fp["bg"].color = Color.new(0,0,0)
  1650.  
  1651. fp["bg2"] = Sprite.new(viewport)
  1652. fp["bg2"].bitmap = pbBitmap("Graphics/Transitions/evilTeamEff5")
  1653. fp["bg2"].ox = fp["bg2"].bitmap.width/2
  1654. fp["bg2"].oy = fp["bg2"].bitmap.height/2
  1655. fp["bg2"].x = viewport.rect.width/2
  1656. fp["bg2"].y = viewport.rect.height/2
  1657. fp["bg2"].visible = false
  1658.  
  1659. speed = []
  1660. for j in 0...16
  1661. fp["e1_#{j}"] = Sprite.new(viewport)
  1662. bmp = pbBitmap("Graphics/Transitions/evilTeamEff1")
  1663. fp["e1_#{j}"].bitmap = Bitmap.new(bmp.width,bmp.height)
  1664. w = bmp.width/(1 + rand(3))
  1665. fp["e1_#{j}"].bitmap.stretch_blt(Rect.new(0,0,w,bmp.height),bmp,Rect.new(0,0,bmp.width,bmp.height))
  1666. fp["e1_#{j}"].oy = fp["e1_#{j}"].bitmap.height/2
  1667. fp["e1_#{j}"].angle = rand(360)
  1668. fp["e1_#{j}"].opacity = 0
  1669. fp["e1_#{j}"].x = viewport.rect.width/2
  1670. fp["e1_#{j}"].y = viewport.rect.height/2
  1671. speed.push(4 + rand(5))
  1672. end
  1673.  
  1674. fp["logo"] = Sprite.new(viewport)
  1675. fp["logo"].bitmap = pbBitmap("Graphics/Transitions/evilTeamLogo")
  1676. fp["logo"].ox = fp["logo"].bitmap.width/2
  1677. fp["logo"].oy = fp["logo"].bitmap.height/2
  1678. fp["logo"].x = viewport.rect.width/2
  1679. fp["logo"].y = viewport.rect.height/2
  1680. fp["logo"].memorize_bitmap
  1681. fp["logo"].bitmap = pbBitmap("Graphics/Transitions/evilTeamLogo2")
  1682. fp["logo"].zoom_x = 2
  1683. fp["logo"].zoom_y = 2
  1684. fp["logo"].z = 50
  1685.  
  1686. fp["ring"] = Sprite.new(viewport)
  1687. fp["ring"].bitmap = pbBitmap("Graphics/Transitions/evilTeamEff2")
  1688. fp["ring"].ox = fp["ring"].bitmap.width/2
  1689. fp["ring"].oy = fp["ring"].bitmap.height/2
  1690. fp["ring"].x = viewport.rect.width/2
  1691. fp["ring"].y = viewport.rect.height/2
  1692. fp["ring"].zoom_x = 0
  1693. fp["ring"].zoom_y = 0
  1694. fp["ring"].z = 100
  1695.  
  1696. for j in 0...32
  1697. fp["e2_#{j}"] = Sprite.new(viewport)
  1698. bmp = pbBitmap("Graphics/Transitions/evilTeamEff4")
  1699. fp["e2_#{j}"].bitmap = pbBitmap("Graphics/Transitions/evilTeamEff4")
  1700. fp["e2_#{j}"].oy = fp["e2_#{j}"].bitmap.height/2
  1701. fp["e2_#{j}"].angle = rand(360)
  1702. fp["e2_#{j}"].opacity = 0
  1703. fp["e2_#{j}"].x = viewport.rect.width/2
  1704. fp["e2_#{j}"].y = viewport.rect.height/2
  1705. fp["e2_#{j}"].z = 100
  1706. end
  1707.  
  1708. fp["ring2"] = Sprite.new(viewport)
  1709. fp["ring2"].bitmap = pbBitmap("Graphics/Transitions/evilTeamEff3")
  1710. fp["ring2"].ox = fp["ring2"].bitmap.width/2
  1711. fp["ring2"].oy = fp["ring2"].bitmap.height/2
  1712. fp["ring2"].x = viewport.rect.width/2
  1713. fp["ring2"].y = viewport.rect.height/2
  1714. fp["ring2"].visible = false
  1715. fp["ring2"].zoom_x = 0
  1716. fp["ring2"].zoom_y = 0
  1717. fp["ring2"].z = 100
  1718.  
  1719. for i in 0...32
  1720. viewport.color.alpha -= 8 if viewport.color.alpha > 0
  1721. fp["logo"].zoom_x -= 1/32.0
  1722. fp["logo"].zoom_y -= 1/32.0
  1723. for j in 0...16
  1724. next if j > i/4
  1725. if fp["e1_#{j}"].ox < -(viewport.rect.width/2)
  1726. speed[j] = 4 + rand(5)
  1727. fp["e1_#{j}"].opacity = 0
  1728. fp["e1_#{j}"].ox = 0
  1729. fp["e1_#{j}"].angle = rand(360)
  1730. bmp = pbBitmap("Graphics/Transitions/evilTeamEff1")
  1731. fp["e1_#{j}"].bitmap.clear
  1732. w = bmp.width/(1 + rand(3))
  1733. fp["e1_#{j}"].bitmap.stretch_blt(Rect.new(0,0,w,bmp.height),bmp,Rect.new(0,0,bmp.width,bmp.height))
  1734. end
  1735. fp["e1_#{j}"].opacity += speed[j]
  1736. fp["e1_#{j}"].ox -= speed[j]
  1737. end
  1738. pbWait(1)
  1739. end
  1740. fp["logo"].color = Color.new(255,255,255)
  1741. fp["logo"].restore_bitmap
  1742. fp["ring2"].visible = true
  1743. fp["bg2"].visible = true
  1744. viewport.color = Color.new(255,255,255)
  1745. for i in 0...144
  1746. if i >= 128
  1747. viewport.color.alpha += 16
  1748. else
  1749. viewport.color.alpha -= 16 if viewport.color.alpha > 0
  1750. end
  1751. fp["logo"].color.alpha -= 16 if fp["logo"].color.alpha > 0
  1752. fp["bg"].color.alpha -= 8 if fp["bg"].color.alpha > 0
  1753. for j in 0...16
  1754. if fp["e1_#{j}"].ox < -(viewport.rect.width/2)
  1755. speed[j] = 4 + rand(5)
  1756. fp["e1_#{j}"].opacity = 0
  1757. fp["e1_#{j}"].ox = 0
  1758. fp["e1_#{j}"].angle = rand(360)
  1759. bmp = pbBitmap("Graphics/Transitions/evilTeamEff1")
  1760. fp["e1_#{j}"].bitmap.clear
  1761. w = bmp.width/(1 + rand(3))
  1762. fp["e1_#{j}"].bitmap.stretch_blt(Rect.new(0,0,w,bmp.height),bmp,Rect.new(0,0,bmp.width,bmp.height))
  1763. end
  1764. fp["e1_#{j}"].opacity += speed[j]
  1765. fp["e1_#{j}"].ox -= speed[j]
  1766. end
  1767. for j in 0...32
  1768. next if j > i*2
  1769. fp["e2_#{j}"].ox -= 16
  1770. fp["e2_#{j}"].opacity += 16
  1771. end
  1772. fp["ring"].zoom_x += 0.1
  1773. fp["ring"].zoom_y += 0.1
  1774. fp["ring"].opacity -= 8
  1775. fp["ring2"].zoom_x += 0.2 if fp["ring2"].zoom_x < 3
  1776. fp["ring2"].zoom_y += 0.2 if fp["ring2"].zoom_y < 3
  1777. fp["ring2"].opacity -= 16
  1778. fp["bg2"].angle += 2 if $PokemonSystem.screensize < 2
  1779. pbWait(1)
  1780. end
  1781. pbDisposeSpriteHash(fp)
  1782. 8.times do
  1783. viewport.color.red -= 255/8.0
  1784. viewport.color.green -= 255/8.0
  1785. viewport.color.blue -= 255/8.0
  1786. pbWait(1)
  1787. end
  1788. end
  1789. #-------------------------------------------------------------------------------
  1790. # Custom animations for wild battles
  1791. #-------------------------------------------------------------------------------
  1792. def queuedIsRegi?
  1793. ret = false
  1794. for poke in [:REGIROCK,:REGISTEEL,:REGICE,:REGIGIGAS]
  1795. num = getConst(PBSpecies,poke)
  1796. next if num.nil? || ret
  1797. if $wildSpecies == num
  1798. ret = true
  1799. end
  1800. end
  1801. return ret
  1802. end
  1803.  
  1804. def ebWildAnimationRegi(viewport)
  1805. fp = {}
  1806. index = [PBSpecies::REGIROCK,PBSpecies::REGISTEEL,PBSpecies::REGICE,PBSpecies::REGIGIGAS].index($wildSpecies)
  1807. width = viewport.rect.width
  1808. height = viewport.rect.height
  1809. viewport.color = Color.new(0,0,0,0)
  1810. fp["back"] = Sprite.new(viewport)
  1811. fp["back"].bitmap = Graphics.snap_to_bitmap
  1812. fp["back"].blur_sprite
  1813. c = index < 3 ? 0 : 255
  1814. fp["back"].color = Color.new(c,c,c,128*(index < 3 ? 1 : 2))
  1815. fp["back"].z = 99999
  1816. fp["back"].opacity = 0
  1817. x = [
  1818. [width*0.5,width*0.25,width*0.75,width*0.25,width*0.75,width*0.25,width*0.75],
  1819. [width*0.5,width*0.3,width*0.7,width*0.15,width*0.85,width*0.3,width*0.7],
  1820. [width*0.5,width*0.325,width*0.675,width*0.5,width*0.5,width*0.15,width*0.85],
  1821. [width*0.5,width*0.5,width*0.5,width*0.5,width*0.35,width*0.65,width*0.5]
  1822. ]
  1823. y = [
  1824. [height*0.5,height*0.5,height*0.5,height*0.25,height*0.75,height*0.75,height*0.25],
  1825. [height*0.5,height*0.25,height*0.75,height*0.5,height*0.5,height*0.75,height*0.25],
  1826. [height*0.5,height*0.5,height*0.5,height*0.25,height*0.75,height*0.5,height*0.5],
  1827. [height*0.9,height*0.74,height*0.58,height*0.4,height*0.25,height*0.25,height*0.1]
  1828. ]
  1829. for j in 0...14
  1830. fp["#{j}"] = Sprite.new(viewport)
  1831. fp["#{j}"].bitmap = pbBitmap("Graphics/Transitions/regi")
  1832. fp["#{j}"].src_rect.set(96*(j/7),100*index,96,100)
  1833. fp["#{j}"].ox = fp["#{j}"].src_rect.width/2
  1834. fp["#{j}"].oy = fp["#{j}"].src_rect.height/2
  1835. fp["#{j}"].x = x[index][j%7]
  1836. fp["#{j}"].y = y[index][j%7]
  1837. fp["#{j}"].opacity = 0
  1838. fp["#{j}"].z = 99999
  1839. end
  1840. 8.times do
  1841. fp["back"].opacity += 32
  1842. pbWait(1)
  1843. end
  1844. k = -2
  1845. for i in 0...72
  1846. if index < 3
  1847. k += 2 if i%8==0
  1848. else
  1849. k += (k==3 ? 2 : 1) if i%4==0
  1850. end
  1851. k = 6 if k > 6
  1852. for j in 0..k
  1853. fp["#{j}"].opacity += 32
  1854. fp["#{j+7}"].opacity += 26 if fp["#{j}"].opacity >= 255
  1855. fp["#{j}"].visible = fp["#{j+7}"].opacity < 255
  1856. end
  1857. fp["back"].color.alpha += 2 if fp["back"].color.alpha < 255
  1858. pbWait(1)
  1859. end
  1860. 8.times do
  1861. viewport.color.alpha += 32
  1862. pbWait(1)
  1863. end
  1864. pbDisposeSpriteHash(fp)
  1865. end
  1866.  
  1867. def ebWildAnimationOutdoor(viewport)
  1868. screen=Sprite.new(viewport)
  1869. screen.bitmap=Bitmap.new(viewport.rect.width,viewport.rect.height)
  1870. black=Color.new(0,0,0)
  1871. width=viewport.rect.width/16
  1872. height=viewport.rect.height/4
  1873. for i in 0...16
  1874. if i < 8
  1875. x1=width+(i%8)*(width*2)
  1876. x2=viewport.rect.width-width-(i%8)*(width*2)
  1877. else
  1878. x2=width+(i%8)*(width*2)
  1879. x1=viewport.rect.width-width-(i%8)*(width*2)
  1880. end
  1881. y1=(i/8)*height
  1882. y2=viewport.rect.height-height-y1
  1883. for j in 1...3
  1884. ext=j*(width/2)
  1885. screen.bitmap.fill_rect(x1,y1,ext,height,black)
  1886. screen.bitmap.fill_rect(x1-ext,y1,ext,height,black)
  1887. screen.bitmap.fill_rect(x2,y2,ext,height,black)
  1888. screen.bitmap.fill_rect(x2-ext,y2,ext,height,black)
  1889. pbWait(1)
  1890. end
  1891. end
  1892. viewport.color=Color.new(0,0,0,255)
  1893. screen.dispose
  1894. end
  1895.  
  1896. def ebWildAnimationIndoor(viewport)
  1897. screen=Sprite.new(viewport)
  1898. screen.bitmap=Bitmap.new(viewport.rect.width,viewport.rect.height)
  1899. black=Color.new(0,0,0)
  1900. width=viewport.rect.width
  1901. height=viewport.rect.height/16
  1902. for i in 1...17
  1903. for j in 0...16
  1904. x=(j%2==0) ? 0 : viewport.rect.width-i*(width/16)
  1905. screen.bitmap.fill_rect(x,j*height,i*(width/16),height,black)
  1906. end
  1907. pbWait(1)
  1908. end
  1909. viewport.color=Color.new(0,0,0,255)
  1910. pbWait(10)
  1911. screen.dispose
  1912. end
  1913.  
  1914. def ebWildAnimationCave(viewport)
  1915. screen=Sprite.new(viewport)
  1916. screen.bitmap=Bitmap.new(viewport.rect.width,viewport.rect.height)
  1917. black=Color.new(0,0,0)
  1918. width=viewport.rect.width/4
  1919. height=viewport.rect.height/4
  1920. sprites={}
  1921. for i in 0...16
  1922. sprites["#{i}"]=Sprite.new(viewport)
  1923. sprites["#{i}"].bitmap=Bitmap.new(width,height)
  1924. sprites["#{i}"].bitmap.fill_rect(0,0,width,height,black)
  1925. sprites["#{i}"].ox=width/2
  1926. sprites["#{i}"].oy=height/2
  1927. sprites["#{i}"].x=width/2+width*(i%4)
  1928. sprites["#{i}"].y=viewport.rect.height-height/2-height*(i/4)
  1929. sprites["#{i}"].zoom_x=0
  1930. sprites["#{i}"].zoom_y=0
  1931. end
  1932. seq=[[0],[4,1],[8,5,2],[12,9,6,3],[13,10,7],[14,11],[15]]
  1933. for i in 0...seq.length
  1934. 5.times do
  1935. for j in 0...seq[i].length
  1936. n=seq[i][j]
  1937. sprites["#{n}"].zoom_x+=0.2
  1938. sprites["#{n}"].zoom_y+=0.2
  1939. end
  1940. pbWait(1)
  1941. end
  1942. end
  1943. viewport.color=Color.new(0,0,0,255)
  1944. pbWait(1)
  1945. pbDisposeSpriteHash(sprites)
  1946. screen.dispose
  1947. end
  1948.  
  1949. def ebWildAnimationMinor(viewport,special=false)
  1950. bmp = Graphics.snap_to_bitmap
  1951. max = 50
  1952. amax = 4
  1953. frames = {}
  1954. zoom = 1
  1955. viewport.color = special ? Color.new(64,64,64,0) : Color.new(255,255,155,0)
  1956. 20.times do
  1957. viewport.color.alpha+=2
  1958. pbWait(1)
  1959. end
  1960. for i in 0...(max+20)
  1961. if !(i%2==0)
  1962. if i > max*0.75
  1963. zoom+=0.3
  1964. else
  1965. zoom-=0.01
  1966. end
  1967. angle = 0 if angle.nil?
  1968. angle = (i%3==0) ? rand(amax*2) - amax : angle
  1969. frames["#{i}"] = Sprite.new(viewport)
  1970. frames["#{i}"].bitmap = bmp
  1971. frames["#{i}"].src_rect.set(0,0,viewport.rect.width,viewport.rect.height)
  1972. frames["#{i}"].ox = viewport.rect.width/2
  1973. frames["#{i}"].oy = viewport.rect.height/2
  1974. frames["#{i}"].x = viewport.rect.width/2
  1975. frames["#{i}"].y = viewport.rect.height/2
  1976. frames["#{i}"].angle = angle
  1977. frames["#{i}"].zoom_x = zoom
  1978. frames["#{i}"].zoom_y = zoom
  1979. frames["#{i}"].tone = Tone.new(i/4,i/4,i/4)
  1980. frames["#{i}"].opacity = 30
  1981. end
  1982. if i >= max
  1983. viewport.color.alpha += 12
  1984. if special
  1985. viewport.color.red -= 64/20.0
  1986. viewport.color.green -= 64/20.0
  1987. viewport.color.blue -= 64/20.0
  1988. else
  1989. viewport.color.blue += 5
  1990. end
  1991. end
  1992. pbWait(1)
  1993. end
  1994. frames["#{max+19}"].tone = Tone.new(255,255,255)
  1995. pbWait(10)
  1996. 10.times do
  1997. next if special
  1998. viewport.color.red-=25.5
  1999. viewport.color.green-=25.5
  2000. viewport.color.blue-=25.5
  2001. pbWait(1)
  2002. end
  2003. pbDisposeSpriteHash(frames)
  2004. end
  2005.  
  2006. def ebWildAnimationOverlevel(viewport)
  2007. height = viewport.rect.height/4
  2008. width = viewport.rect.width/10
  2009. backdrop = Sprite.new(viewport)
  2010. backdrop.bitmap = Graphics.snap_to_bitmap
  2011. sprite = Sprite.new(viewport)
  2012. sprite.bitmap = Bitmap.new(viewport.rect.width,viewport.rect.height)
  2013. for j in 0...4
  2014. y = [0,2,1,3]
  2015. for i in 1..10
  2016. sprite.bitmap.fill_rect(0,height*y[j],width*i,height,Color.new(255,255,255))
  2017. backdrop.tone.red += 3
  2018. backdrop.tone.green += 3
  2019. backdrop.tone.blue += 3
  2020. pbWait(1)
  2021. end
  2022. end
  2023. viewport.color = Color.new(0,0,0,0)
  2024. 10.times do
  2025. viewport.color.alpha += 25.5
  2026. pbWait(1)
  2027. end
  2028. backdrop.dispose
  2029. sprite.dispose
  2030. end
  2031.  
  2032. def ebWildAnimationWater(viewport)
  2033. bmp = Graphics.snap_to_bitmap
  2034. split = 12
  2035. n = viewport.rect.height/split
  2036. sprites = {}
  2037. black = Sprite.new(viewport)
  2038. black.bitmap = Bitmap.new(viewport.rect.width,viewport.rect.height)
  2039. black.bitmap.fill_rect(0,0,black.bitmap.width,black.bitmap.height,Color.new(0,0,0))
  2040. for i in 0...n
  2041. sprites["#{i}"] = Sprite.new(viewport)
  2042. sprites["#{i}"].bitmap = bmp
  2043. sprites["#{i}"].ox = bmp.width/2
  2044. sprites["#{i}"].x = viewport.rect.width/2
  2045. sprites["#{i}"].y = i*split
  2046. sprites["#{i}"].src_rect.set(0,i*split,bmp.width,split)
  2047. sprites["#{i}"].color = Color.new(0,0,0,0)
  2048. end
  2049. for f in 0...64
  2050. for i in 0...n
  2051. o = Math.sin(f - i*0.5)
  2052. sprites["#{i}"].x = viewport.rect.width/2 + 16*o if f >= i
  2053. sprites["#{i}"].color.alpha += 25.5 if sprites["#{i}"].color.alpha < 255 && f >= (64 - (48-i))
  2054. end
  2055. pbWait(1)
  2056. end
  2057. viewport.color = Color.new(0,0,0,255)
  2058. pbDisposeSpriteHash(sprites)
  2059. end
  2060. #-------------------------------------------------------------------------------
  2061. # VS. animation, by Luka S.J.
  2062. # Tweaked by Maruno.
  2063. # (official Essentials one)
  2064. #-------------------------------------------------------------------------------
  2065. SE_EXTRA_PATH = " "
  2066. def vsSequenceEssentials(viewport,trainername,trainerid,tbargraphic,tgraphic)
  2067. outfit=$Trainer ? $Trainer.outfit : 0
  2068. # Set up
  2069. viewplayer=Viewport.new(0,viewport.rect.height/3,viewport.rect.width/2,128)
  2070. viewplayer.z=viewport.z
  2071. viewopp=Viewport.new(viewport.rect.width/2,viewport.rect.height/3,viewport.rect.width/2,128)
  2072. viewopp.z=viewport.z
  2073. viewvs=Viewport.new(0,0,viewport.rect.width,viewport.rect.height)
  2074. viewvs.z=viewport.z
  2075. xoffset=(viewport.rect.width/2)/10
  2076. xoffset=xoffset.round
  2077. xoffset=xoffset*10
  2078. fade=Sprite.new(viewport)
  2079. fade.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsFlash")
  2080. fade.tone=Tone.new(-255,-255,-255)
  2081. fade.opacity=100
  2082. overlay=Sprite.new(viewport)
  2083. overlay.bitmap=Bitmap.new(viewport.rect.width,viewport.rect.height)
  2084. pbSetSystemFont(overlay.bitmap)
  2085. bar1=Sprite.new(viewplayer)
  2086. pbargraphic=sprintf("Graphics/Transitions/vsBar%s_%d",getConstantName(PBTrainers,$Trainer.trainertype),outfit) rescue nil
  2087. pbargraphic=sprintf("Graphics/Transitions/vsBar%d_%d",$Trainer.trainertype,outfit) if !pbResolveBitmap(pbargraphic)
  2088. if !pbResolveBitmap(pbargraphic)
  2089. pbargraphic=sprintf("Graphics/Transitions/vsBar%s",getConstantName(PBTrainers,$Trainer.trainertype)) rescue nil
  2090. end
  2091. pbargraphic=sprintf("Graphics/Transitions/vsBar%d",$Trainer.trainertype) if !pbResolveBitmap(pbargraphic)
  2092. bar1.bitmap=BitmapCache.load_bitmap(pbargraphic)
  2093. bar1.x=-xoffset
  2094. bar2=Sprite.new(viewopp)
  2095. bar2.bitmap=BitmapCache.load_bitmap(tbargraphic)
  2096. bar2.x=xoffset
  2097. vs=Sprite.new(viewvs)
  2098. vs.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vs")
  2099. vs.ox=vs.bitmap.width/2
  2100. vs.oy=vs.bitmap.height/2
  2101. vs.x=viewport.rect.width/2
  2102. vs.y=viewport.rect.height/1.5
  2103. vs.visible=false
  2104. flash=Sprite.new(viewvs)
  2105. flash.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsFlash")
  2106. flash.opacity=0
  2107. # Animation
  2108. 10.times do
  2109. bar1.x+=xoffset/10
  2110. bar2.x-=xoffset/10
  2111. pbWait(1)
  2112. end
  2113. pbSEPlay("#{SE_EXTRA_PATH}Flash2")
  2114. pbSEPlay("#{SE_EXTRA_PATH}Sword2")
  2115. flash.opacity=255
  2116. bar1.dispose
  2117. bar2.dispose
  2118. bar1=AnimatedPlane.new(viewplayer)
  2119. bar1.bitmap=BitmapCache.load_bitmap(pbargraphic)
  2120. player=Sprite.new(viewplayer)
  2121. pgraphic=sprintf("Graphics/Transitions/vsTrainer%s_%d",getConstantName(PBTrainers,$Trainer.trainertype),outfit) rescue nil
  2122. pgraphic=sprintf("Graphics/Transitions/vsTrainer%d_%d",$Trainer.trainertype,outfit) if !pbResolveBitmap(pgraphic)
  2123. if !pbResolveBitmap(pgraphic)
  2124. pgraphic=sprintf("Graphics/Transitions/vsTrainer%s",getConstantName(PBTrainers,$Trainer.trainertype)) rescue nil
  2125. end
  2126. pgraphic=sprintf("Graphics/Transitions/vsTrainer%d",$Trainer.trainertype) if !pbResolveBitmap(pgraphic)
  2127. player.bitmap=BitmapCache.load_bitmap(pgraphic)
  2128. player.x=-xoffset
  2129. bar2=AnimatedPlane.new(viewopp)
  2130. bar2.bitmap=BitmapCache.load_bitmap(tbargraphic)
  2131. trainer=Sprite.new(viewopp)
  2132. trainer.bitmap=BitmapCache.load_bitmap(tgraphic)
  2133. trainer.x=xoffset
  2134. trainer.tone=Tone.new(-255,-255,-255)
  2135. 25.times do
  2136. flash.opacity-=51 if flash.opacity>0
  2137. bar1.ox-=16
  2138. bar2.ox+=16
  2139. pbWait(1)
  2140. end
  2141. 11.times do
  2142. bar1.ox-=16
  2143. bar2.ox+=16
  2144. player.x+=xoffset/10
  2145. trainer.x-=xoffset/10
  2146. pbWait(1)
  2147. end
  2148. 2.times do
  2149. bar1.ox-=16
  2150. bar2.ox+=16
  2151. player.x-=xoffset/20
  2152. trainer.x+=xoffset/20
  2153. pbWait(1)
  2154. end
  2155. 10.times do
  2156. bar1.ox-=16
  2157. bar2.ox+=16
  2158. pbWait(1)
  2159. end
  2160. val=2
  2161. flash.opacity=255
  2162. vs.visible=true
  2163. trainer.tone=Tone.new(0,0,0)
  2164. textpos=[
  2165. [_INTL("{1}",$Trainer.name),viewport.rect.width/4,(viewport.rect.height/1.5)+10,2,
  2166. Color.new(248,248,248),Color.new(12*6,12*6,12*6)],
  2167. [_INTL("{1}",trainername),(viewport.rect.width/4)+(viewport.rect.width/2),(viewport.rect.height/1.5)+10,2,
  2168. Color.new(248,248,248),Color.new(12*6,12*6,12*6)]
  2169. ]
  2170. pbDrawTextPositions(overlay.bitmap,textpos)
  2171. pbSEPlay("#{SE_EXTRA_PATH}Sword2")
  2172. 70.times do
  2173. bar1.ox-=16
  2174. bar2.ox+=16
  2175. flash.opacity-=25.5 if flash.opacity>0
  2176. vs.x+=val
  2177. vs.y-=val
  2178. val=2 if vs.x<=(viewport.rect.width/2)-2
  2179. val=-2 if vs.x>=(viewport.rect.width/2)+2
  2180. pbWait(1)
  2181. end
  2182. 30.times do
  2183. bar1.ox-=16
  2184. bar2.ox+=16
  2185. vs.zoom_x+=0.2
  2186. vs.zoom_y+=0.2
  2187. pbWait(1)
  2188. end
  2189. flash.tone=Tone.new(-255,-255,-255)
  2190. 10.times do
  2191. bar1.ox-=16
  2192. bar2.ox+=16
  2193. flash.opacity+=25.5
  2194. pbWait(1)
  2195. end
  2196. # End
  2197. player.dispose
  2198. trainer.dispose
  2199. flash.dispose
  2200. vs.dispose
  2201. bar1.dispose
  2202. bar2.dispose
  2203. overlay.dispose
  2204. fade.dispose
  2205. viewvs.dispose
  2206. viewopp.dispose
  2207. viewplayer.dispose
  2208. viewport.color=Color.new(0,0,0,255)
  2209. return true
  2210. end
  2211. #-------------------------------------------------------------------------------
  2212. # New EBS VS. animation
  2213. #-------------------------------------------------------------------------------
  2214. def vsSequenceNew(viewport,trainername,trainerid,tbargraphic,tgraphic)
  2215. #------------------
  2216. # sets the face2 graphic to be the shadow instead of larger mug
  2217. showShadow = false
  2218. # decides whether or not to colour the vsLight(s) according to the vsBar
  2219. colorLight = false
  2220. # decides whether or not to return to default white colour
  2221. colorReset = false
  2222. #------------------
  2223. ow = Sprite.new(viewport)
  2224. ow.bitmap = Graphics.snap_to_bitmap
  2225. ow.blur_sprite
  2226. ow.opacity = 0
  2227. ow.tone = Tone.new(-92,-92,-92)
  2228.  
  2229. bmp = pbBitmap("Graphics/Transitions/vsLight3")
  2230. globaly = viewport.rect.height*0.4
  2231.  
  2232. bar = Sprite.new(viewport)
  2233. bar.bitmap = pbBitmap(tbargraphic)
  2234. bar.ox = bar.bitmap.width
  2235. bar.oy = bar.bitmap.height/2
  2236. bar.x = viewport.rect.width*2 + 64
  2237. bar.y = globaly
  2238.  
  2239. color = bar.bitmap.get_pixel(bar.bitmap.width/2,1)
  2240.  
  2241. bbar1 = Sprite.new(viewport)
  2242. bbar1.bitmap = Bitmap.new(viewport.rect.width,2)
  2243. bbar1.bitmap.fill_rect(0,0,viewport.rect.width,2,Color.new(0,0,0))
  2244. bbar1.y = bar.y - bar.oy
  2245. bbar1.zoom_y = 0
  2246. bbar1.z = 99
  2247.  
  2248. bbar2 = Sprite.new(viewport)
  2249. bbar2.bitmap = Bitmap.new(viewport.rect.width,2)
  2250. bbar2.bitmap.fill_rect(0,0,viewport.rect.width,2,Color.new(0,0,0))
  2251. bbar2.oy = 2
  2252. bbar2.y = bar.y + bar.oy + 8
  2253. bbar2.zoom_y = 0
  2254. bbar2.z = 99
  2255.  
  2256. face2 = Sprite.new(viewport)
  2257. face2.bitmap = pbBitmap(tgraphic)
  2258. face2.src_rect.set(0,face2.bitmap.height/4,face2.bitmap.width,face2.bitmap.height/2) if !showShadow
  2259. face2.oy = face2.src_rect.height/2
  2260. face2.y = globaly
  2261. face2.zoom_x = 2 if !showShadow
  2262. face2.zoom_y = 2 if !showShadow
  2263. face2.opacity = showShadow ? 255 : 92
  2264. face2.visible = false
  2265. face2.x = showShadow ? (viewport.rect.width - face2.bitmap.width + 16) : (viewport.rect.width - face2.bitmap.width*2 + 64)
  2266. face2.color = Color.new(0,0,0,255) if showShadow
  2267.  
  2268. light3 = Sprite.new(viewport)
  2269. light3.bitmap = Bitmap.new(bmp.width*2,bmp.height)
  2270. for i in 0...2
  2271. light3.bitmap.blt(bmp.width*i,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
  2272. end
  2273. light3.x = viewport.rect.width
  2274. light3.oy = bmp.height/2
  2275. light3.y = globaly
  2276. light3.color = color if colorLight
  2277.  
  2278. light1 = Sprite.new(viewport)
  2279. light1.bitmap = pbBitmap("Graphics/Transitions/vsLight1")
  2280. light1.ox = light1.bitmap.width/2
  2281. light1.oy = light1.bitmap.height/2
  2282. light1.x = viewport.rect.width*0.25
  2283. light1.y = globaly
  2284. light1.zoom_x = 0
  2285. light1.zoom_y = 0
  2286. light1.color = color if colorLight
  2287.  
  2288. light2 = Sprite.new(viewport)
  2289. light2.bitmap = pbBitmap("Graphics/Transitions/vsLight2")
  2290. light2.ox = light2.bitmap.width/2
  2291. light2.oy = light2.bitmap.height/2
  2292. light2.x = viewport.rect.width*0.25
  2293. light2.y = globaly
  2294. light2.zoom_x = 0
  2295. light2.zoom_y = 0
  2296. light2.color = color if colorLight
  2297.  
  2298. vs = Sprite.new(viewport)
  2299. vs.bitmap = pbBitmap("Graphics/Transitions/vs")
  2300. vs.ox = vs.bitmap.width/2
  2301. vs.oy = vs.bitmap.height/2
  2302. vs.x = viewport.rect.width*0.25
  2303. vs.y = globaly
  2304. vs.opacity = 0
  2305. vs.zoom_x = 4
  2306. vs.zoom_y = 4
  2307.  
  2308. face1 = Sprite.new(viewport)
  2309. face1.bitmap = pbBitmap(tgraphic)
  2310. face1.oy = face1.bitmap.height/2
  2311. face1.y = globaly
  2312. face1.x = viewport.rect.width
  2313. face1.color = Color.new(0,0,0,255)
  2314.  
  2315. name = Sprite.new(viewport)
  2316. name.bitmap = Bitmap.new(viewport.rect.width/2,96)
  2317. pbSetSystemFont(name.bitmap)
  2318. name.ox = name.bitmap.width/2
  2319. name.x = viewport.rect.width*0.75
  2320. name.y = bar.y + bar.oy
  2321. pbDrawTextPositions(name.bitmap,[[trainername,name.bitmap.width/2,4,2,Color.new(255,255,255),nil]])
  2322. name.visible = false
  2323.  
  2324. ripples = Sprite.new(viewport)
  2325. ripples.bitmap = pbBitmap("Graphics/Transitions/ripples")
  2326. ripples.ox = ripples.bitmap.width/2
  2327. ripples.oy = ripples.bitmap.height/2
  2328. ripples.x = vs.x
  2329. ripples.y = globaly
  2330. ripples.opacity = 0
  2331. ripples.z = 99
  2332. ripples.zoom_x = 0.0
  2333. ripples.zoom_y = 0.0
  2334.  
  2335. 8.times do
  2336. light1.zoom_x+=1.0/16
  2337. light1.zoom_y+=1.0/16
  2338. light2.zoom_x+=1.0/8
  2339. light2.zoom_y+=1.0/8
  2340. light1.angle-=32
  2341. light2.angle+=64
  2342. light3.x-=64
  2343. ow.opacity+=12.8
  2344. pbWait(1)
  2345. end
  2346. n = false
  2347. k = false
  2348. max = 224
  2349. for i in 0...max
  2350. n = !n if i%8==0
  2351. k = !k if i%4==0
  2352. ow.opacity+=12.8 if ow.opacity < 255
  2353. light1.zoom_x+=(n ? 1.0/16 : -1.0/16)
  2354. light1.zoom_y+=(n ? 1.0/16 : -1.0/16)
  2355. light1.angle-=16
  2356. light2.angle+=32
  2357. light3.x-=32
  2358. light3.x = 0 if light3.x <= -light3.bitmap.width/2
  2359. if i >= 32 && i < 41
  2360. bar.x-=64
  2361. pbSEPlay("#{SE_EXTRA_PATH}Ice8",80) if i==32
  2362. end
  2363. if i >= 32
  2364. face1.x-=(face1.x-viewport.rect.width/2)*0.1
  2365. end
  2366. viewport.color.alpha-=255/20.0 if viewport.color.alpha > 0
  2367. face2.x -= (showShadow ? -1 : 1) if i%(showShadow ? 4 : 2)==0 && face2.visible
  2368. vs.x+=(k ? 2 : -2)/2 if i >= 72
  2369. vs.y-=(k ? 2 : -2)/2 if i >= 72
  2370. ripples.opacity-=12.8 if ripples.opacity > 0
  2371. ripples.zoom_x+=0.2 if ripples.opacity > 0
  2372. ripples.zoom_y+=0.2 if ripples.opacity > 0
  2373. if i > 62
  2374. vs.opacity+=25.5 if vs.opacity < 255
  2375. vs.zoom_x-=0.2 if vs.zoom_x > 1
  2376. vs.zoom_y-=0.2 if vs.zoom_y > 1
  2377. end
  2378. if i==72
  2379. viewport.color = Color.new(255,255,255,255)
  2380. ow.color = Color.new(0,0,0,255)
  2381. face2.visible = true
  2382. face1.color = Color.new(0,0,0,0)
  2383. name.visible = true
  2384. ripples.opacity = 255
  2385. pbSEPlay("#{SE_EXTRA_PATH}Saint9",50)
  2386. pbSEPlay("#{SE_EXTRA_PATH}Flash2",50)
  2387. if colorReset
  2388. light1.color = Color.new(0,0,0,0)
  2389. light2.color = Color.new(0,0,0,0)
  2390. light3.color = Color.new(0,0,0,0)
  2391. end
  2392. end
  2393. if i >= max-8
  2394. bbar1.zoom_y+=8
  2395. bbar2.zoom_y+=8
  2396. name.opacity-=255/4.0
  2397. end
  2398. pbWait(1)
  2399. end
  2400. viewport.color = Color.new(0,0,0,255)
  2401. ow.dispose
  2402. bar.dispose
  2403. bbar1.dispose
  2404. bbar2.dispose
  2405. face1.dispose
  2406. face2.dispose
  2407. light1.dispose
  2408. light2.dispose
  2409. light3.dispose
  2410. ripples.dispose
  2411. vs.dispose
  2412. return true
  2413. end
  2414. #-------------------------------------------------------------------------------
  2415. # Elite Four EBS VS. animation
  2416. #-------------------------------------------------------------------------------
  2417. def vsSequenceElite(viewport,trainername,trainerid,tbargraphic,tgraphic)
  2418. ow = Sprite.new(viewport)
  2419. ow.bitmap = Graphics.snap_to_bitmap
  2420. ow.blur_sprite
  2421. ow.opacity = 0
  2422. ow.tone = Tone.new(-92,-92,-92)
  2423.  
  2424. effect1 = Sprite.new(viewport)
  2425. effect1.bitmap = pbBitmap("Graphics/Transitions/vsBg")
  2426. effect1.ox = effect1.bitmap.width/2
  2427. effect1.x = viewport.rect.width/2
  2428. effect1.oy = effect1.bitmap.height/2
  2429. effect1.y = viewport.rect.height/2
  2430. effect1.visible = false
  2431.  
  2432. names = Sprite.new(viewport)
  2433. names.bitmap = Bitmap.new(viewport.rect.width,viewport.rect.height)
  2434. names.z = 999
  2435. pbSetSystemFont(names.bitmap)
  2436. txt = [
  2437. [trainername,viewport.rect.width*0.25,viewport.rect.height*0.25+32,2,Color.new(255,255,255),Color.new(32,32,32)],
  2438. [$Trainer.name,viewport.rect.width*0.75,viewport.rect.height*0.75+32,2,Color.new(255,255,255),Color.new(32,32,32)]
  2439. ]
  2440. pbDrawTextPositions(names.bitmap,txt)
  2441. names.visible = false
  2442.  
  2443. bmp = pbBitmap("Graphics/Transitions/vsLight3")
  2444.  
  2445. bar1 = Sprite.new(viewport)
  2446. bar1.bitmap = pbBitmap(tbargraphic)
  2447. bar1.oy = bar1.bitmap.height/2
  2448. bar1.y = viewport.rect.height*0.25
  2449. bar1.x = viewport.rect.width
  2450.  
  2451. light1 = Sprite.new(viewport)
  2452. light1.bitmap = Bitmap.new(bmp.width*2,bmp.height)
  2453. for i in 0...2
  2454. light1.bitmap.blt(bmp.width*i,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
  2455. end
  2456. light1.x = viewport.rect.width
  2457. light1.oy = bmp.height/2
  2458. light1.y = viewport.rect.height*0.25
  2459.  
  2460. shadow1 = Sprite.new(viewport)
  2461. shadow1.bitmap = pbBitmap(tgraphic)
  2462. shadow1.oy = shadow1.bitmap.height/2
  2463. shadow1.y = viewport.rect.height*0.25
  2464. shadow1.x = viewport.rect.width/2 - 16
  2465. shadow1.color = Color.new(0,0,0,255)
  2466. shadow1.opacity = 96
  2467. shadow1.visible = false
  2468.  
  2469. face1 = Sprite.new(viewport)
  2470. face1.bitmap = pbBitmap(tgraphic)
  2471. face1.oy = face1.bitmap.height/2
  2472. face1.y = viewport.rect.height*0.25
  2473. face1.x = viewport.rect.width
  2474. face1.color = Color.new(0,0,0,255)
  2475.  
  2476. #-------------------
  2477. outfit=$Trainer ? $Trainer.outfit : 0
  2478. pbargraphic=sprintf("Graphics/Transitions/vsBarElite%s_%d",getConstantName(PBTrainers,$Trainer.trainertype),outfit) rescue nil
  2479. pbargraphic=sprintf("Graphics/Transitions/vsBarElite%d_%d",$Trainer.trainertype,outfit) if !pbResolveBitmap(pbargraphic)
  2480. if !pbResolveBitmap(pbargraphic)
  2481. pbargraphic=sprintf("Graphics/Transitions/vsBarElite%s",getConstantName(PBTrainers,$Trainer.trainertype)) rescue nil
  2482. end
  2483. pbargraphic=sprintf("Graphics/Transitions/vsBarElite%d",$Trainer.trainertype) if !pbResolveBitmap(pbargraphic)
  2484. pgraphic=sprintf("Graphics/Transitions/vsTrainer%s_%d",getConstantName(PBTrainers,$Trainer.trainertype),outfit) rescue nil
  2485. pgraphic=sprintf("Graphics/Transitions/vsTrainer%d_%d",$Trainer.trainertype,outfit) if !pbResolveBitmap(pgraphic)
  2486. if !pbResolveBitmap(pgraphic)
  2487. pgraphic=sprintf("Graphics/Transitions/vsTrainer%s",getConstantName(PBTrainers,$Trainer.trainertype)) rescue nil
  2488. end
  2489. pgraphic=sprintf("Graphics/Transitions/vsTrainer%d",$Trainer.trainertype) if !pbResolveBitmap(pgraphic)
  2490. #-------------------
  2491.  
  2492. bar2 = Sprite.new(viewport)
  2493. bar2.bitmap = pbBitmap(pbargraphic)
  2494. bar2.oy = bar2.bitmap.height/2
  2495. bar2.y = viewport.rect.height*0.75
  2496. bar2.x = -bar2.bitmap.width
  2497.  
  2498. light2 = Sprite.new(viewport)
  2499. light2.bitmap = light1.bitmap.clone
  2500. light2.mirror = true
  2501. light2.x = -light2.bitmap.width
  2502. light2.oy = bmp.height/2
  2503. light2.y = viewport.rect.height*0.75
  2504.  
  2505. shadow2 = Sprite.new(viewport)
  2506. shadow2.bitmap = pbBitmap(pgraphic)
  2507. shadow2.oy = shadow2.bitmap.height/2
  2508. shadow2.y = viewport.rect.height*0.75
  2509. shadow2.x = 16
  2510. shadow2.color = Color.new(0,0,0,255)
  2511. shadow2.opacity = 96
  2512. shadow2.visible = false
  2513.  
  2514. face2 = Sprite.new(viewport)
  2515. face2.bitmap = pbBitmap(pgraphic)
  2516. face2.oy = face2.bitmap.height/2
  2517. face2.y = viewport.rect.height*0.75
  2518. face2.x = -face2.bitmap.width
  2519. face2.color = Color.new(0,0,0,255)
  2520.  
  2521. ripples = Sprite.new(viewport)
  2522. ripples.bitmap = pbBitmap("Graphics/Transitions/ripples")
  2523. ripples.ox = ripples.bitmap.width/2
  2524. ripples.oy = ripples.bitmap.height/2
  2525. ripples.x = viewport.rect.width/2
  2526. ripples.y = viewport.rect.height/2
  2527. ripples.opacity = 0
  2528. ripples.zoom_x = 0.0
  2529. ripples.zoom_y = 0.0
  2530. ripples.z = 999
  2531.  
  2532. vs = Sprite.new(viewport)
  2533. vs.bitmap = pbBitmap("Graphics/Transitions/vs")
  2534. vs.ox = vs.bitmap.width/2
  2535. vs.oy = vs.bitmap.height/2
  2536. vs.x = viewport.rect.width/2
  2537. vs.y = viewport.rect.height/2
  2538. vs.opacity = 0
  2539. vs.zoom_x = 4
  2540. vs.zoom_y = 4
  2541. vs.z = 999
  2542.  
  2543. max = 224
  2544. k = false
  2545. for i in 0...max
  2546. k = !k if i%4==0
  2547. viewport.color.alpha-=255/16.0 if viewport.color.alpha > 0
  2548. ow.opacity+=12.8 if ow.opacity < 255
  2549. light1.x-=(light1.x > 0) ? 64 : 32
  2550. light1.x = 0 if light1.x <= -light1.bitmap.width/2
  2551. bar1.x-=(bar1.x)*0.2 if i >= 32
  2552.  
  2553. face1.x-=(face1.x-viewport.rect.width/2)*0.1 if i >= 16
  2554. face2.x+=(0-face2.x)*0.1 if i >= 16
  2555.  
  2556. light2.x+=(light2.x < -light2.bitmap.width/2) ? 64 : 32
  2557. light2.x = -light2.bitmap.width/2 if light2.x >= 0
  2558. bar2.x+=(0-bar2.x)*0.2 if i >= 32
  2559.  
  2560. effect1.angle+=2 if $PokemonSystem.screensize < 2
  2561. vs.x+=(k ? 2 : -2)/2 if i >= 72
  2562. vs.y-=(k ? 2 : -2)/2 if i >= 72
  2563. ripples.opacity-=12.8 if ripples.opacity > 0
  2564. ripples.zoom_x+=0.2 if ripples.opacity > 0
  2565. ripples.zoom_y+=0.2 if ripples.opacity > 0
  2566. if i%4 == 0
  2567. shadow1.x-=1
  2568. shadow2.x+=1
  2569. end
  2570. if i > 62 && i < max-16
  2571. vs.opacity+=25.5 if vs.opacity < 255
  2572. vs.zoom_x-=0.2 if vs.zoom_x > 1
  2573. vs.zoom_y-=0.2 if vs.zoom_y > 1
  2574. end
  2575. if i == 72
  2576. face1.color = Color.new(0,0,0,0)
  2577. face2.color = Color.new(0,0,0,0)
  2578. viewport.color = Color.new(255,255,255,255)
  2579. ow.color = Color.new(0,0,0,255)
  2580. effect1.visible = true
  2581. ripples.opacity = 255
  2582. names.visible = true
  2583. shadow1.visible = true
  2584. shadow2.visible = true
  2585. pbSEPlay("#{SE_EXTRA_PATH}Saint9",50)
  2586. pbSEPlay("#{SE_EXTRA_PATH}Flash2",50)
  2587. end
  2588. viewport.color = Color.new(0,0,0,0) if i == max-17
  2589. if i >= max-16
  2590. vs.zoom_x+=0.2
  2591. vs.zoom_y+=0.2
  2592. viewport.color.alpha+=255/8.0
  2593. end
  2594.  
  2595. pbWait(1)
  2596. end
  2597. viewport.color = Color.new(0,0,0,255)
  2598. ow.dispose
  2599. effect1.dispose
  2600. bar1.dispose
  2601. bar2.dispose
  2602. light1.dispose
  2603. light2.dispose
  2604. face1.dispose
  2605. face2.dispose
  2606. shadow1.dispose
  2607. shadow2.dispose
  2608. names.dispose
  2609. vs.dispose
  2610. ripples.dispose
  2611. return true
  2612. end
  2613. #-------------------------------------------------------------------------------
  2614. # Special EBS VS. animation
  2615. #-------------------------------------------------------------------------------
  2616. def vsSequenceSpecial(viewport,trainername,trainerid,tbargraphic,tgraphic)
  2617. ow = Sprite.new(viewport)
  2618. ow.bitmap = Graphics.snap_to_bitmap
  2619. ow.blur_sprite
  2620. ow.opacity = 0
  2621.  
  2622. bg = Sprite.new(viewport)
  2623. bg.visible = false
  2624.  
  2625. light = AnimatedPlane.new(viewport)
  2626. light.bitmap = pbBitmap("Graphics/Transitions/vsSpecialLight")
  2627. light.opacity = 0
  2628.  
  2629. vss = Sprite.new(viewport)
  2630. vss.bitmap = pbBitmap("Graphics/Transitions/vs")
  2631. vss.color = Color.new(0,0,0,255)
  2632. vss.ox = vss.bitmap.width/2
  2633. vss.oy = vss.bitmap.height/2
  2634. vss.x = 110 + 16
  2635. vss.y = 132 + 16
  2636. vss.opacity = 128
  2637. vss.visible = false
  2638.  
  2639. vs = Sprite.new(viewport)
  2640. vs.bitmap = pbBitmap("Graphics/Transitions/vs")
  2641. vs.ox = vs.bitmap.width/2
  2642. vs.oy = vs.bitmap.height/2
  2643. vs.x = 110
  2644. vs.y = 132
  2645. vs.visible = false
  2646.  
  2647. names = Sprite.new(viewport)
  2648. names.x = 6
  2649. names.y = 4
  2650. names.opacity = 128
  2651. names.color = Color.new(0,0,0,255)
  2652. names.visible = false
  2653.  
  2654. name = Sprite.new(viewport)
  2655. name.bitmap = Bitmap.new(viewport.rect.width,viewport.rect.height)
  2656. name.bitmap.font.name = "Arial"
  2657. name.bitmap.font.size = 48
  2658. name.visible = false
  2659. pbDrawOutlineText(name.bitmap,64,viewport.rect.height-160,-1,-1,"#{trainername}",Color.new(255,255,255),Color.new(0,0,0),2)
  2660. names.bitmap = name.bitmap.clone
  2661.  
  2662. border1 = Sprite.new(viewport)
  2663. border1.bitmap = pbBitmap("Graphics/Transitions/vsBorder")
  2664. border1.zoom_x = 1.2
  2665. border1.y = -border1.bitmap.height
  2666. border1.z = 99
  2667.  
  2668. border2 = Sprite.new(viewport)
  2669. border2.bitmap = pbBitmap("Graphics/Transitions/vsBorder")
  2670. border2.zoom_x = 1.2
  2671. border2.x = viewport.rect.width
  2672. border2.angle = 180
  2673. border2.y = viewport.rect.height+border2.bitmap.height
  2674. border2.z = 99
  2675.  
  2676. trainer = Sprite.new(viewport)
  2677. trainer.bitmap = pbBitmap(tgraphic)
  2678. trainer.x = 0
  2679. trainer.ox = trainer.bitmap.width
  2680. trainer.z = 100
  2681. trainer.color = Color.new(0,0,0,255)
  2682.  
  2683. shadow = Sprite.new(viewport)
  2684. shadow.bitmap = pbBitmap(tgraphic)
  2685. shadow.x = viewport.rect.width + 22
  2686. shadow.ox = shadow.bitmap.width
  2687. shadow.y = 22
  2688. shadow.color = Color.new(0,0,0,255)
  2689. shadow.opacity = 128
  2690. shadow.visible = false
  2691.  
  2692. if pbResolveBitmap(tbargraphic)
  2693. bg.bitmap = pbBitmap(tbargraphic)
  2694. else
  2695. bg.bitmap = Bitmap.new(viewport.rect.width,viewport.rect.height)
  2696. color = trainer.getAvgColor
  2697. avg = ((color.red+color.green+color.blue)/3)-120
  2698. color = Color.new(color.red-avg,color.green-avg,color.blue-avg)
  2699. bg.bitmap.fill_rect(0,0,viewport.rect.width,viewport.rect.height,color)
  2700. end
  2701.  
  2702. y1 = border1.y.to_f
  2703. y2 = border2.y.to_f
  2704. 30.times do
  2705. ow.opacity += 12.8
  2706. y1 += ((70-border1.bitmap.height)-y1)*0.2
  2707. border1.y = y1
  2708. y2 -= (y2-(viewport.rect.height+border2.bitmap.height-70))*0.2
  2709. border2.y = y2
  2710. light.opacity+=12.8
  2711. light.ox += 24
  2712. pbWait(1)
  2713. end
  2714. 40.times do
  2715. trainer.x += ((viewport.rect.width)-trainer.x)*0.2
  2716. light.ox += 24
  2717. pbWait(1)
  2718. end
  2719.  
  2720. viewport.tone = Tone.new(255,255,255)
  2721. bg.visible = true
  2722. shadow.visible = true
  2723. vs.visible = true
  2724. vss.visible = true
  2725. name.visible = true
  2726. names.visible = true
  2727. trainer.color = Color.new(0,0,0,0)
  2728.  
  2729. p = 1
  2730. 20.times do
  2731. viewport.tone.red -= 255/20.0
  2732. viewport.tone.green -= 255/20.0
  2733. viewport.tone.blue -= 255/20.0
  2734. light.ox += 24
  2735. vs.x += p; vs.y -= p
  2736. p = -1 if vs.x >= 112
  2737. p = +1 if vs.x <= 108
  2738. vss.x = vs.x + 16; vss.y = vs.y + 16
  2739. pbWait(1)
  2740. end
  2741. 120.times do
  2742. light.ox += 24
  2743. vs.x += p; vs.y -= p
  2744. p = -1 if vs.x >= 112
  2745. p = +1 if vs.x <= 108
  2746. vss.x = vs.x + 16; vss.y = vs.y + 16
  2747. pbWait(1)
  2748. end
  2749. y1 = border1.y.to_f
  2750. y2 = border2.y.to_f
  2751. 6.times do
  2752. trainer.x -= 1
  2753. shadow.x = trainer.x + 22
  2754. light.ox += 24
  2755. vs.x += p; vs.y -= p
  2756. p = -1 if vs.x >= 112
  2757. p = +1 if vs.x <= 108
  2758. vss.x = vs.x + 16; vss.y = vs.y + 16
  2759. pbWait(1)
  2760. end
  2761. 30.times do
  2762. trainer.x += ((viewport.rect.width*2)-trainer.x)*0.2
  2763. shadow.x = trainer.x + 22
  2764. y1 += ((0)-y1)*0.2
  2765. border1.y = y1
  2766. y2 -= (y2-(viewport.rect.height))*0.2
  2767. border2.y = y2
  2768. light.ox += 24
  2769. vs.x += p; vs.y -= p
  2770. p = -1 if vs.x >= 112
  2771. p = +1 if vs.x <= 108
  2772. vss.x = vs.x + 16; vss.y = vs.y + 16
  2773. pbWait(1)
  2774. end
  2775. ow.dispose
  2776. bg.dispose
  2777. vs.dispose
  2778. vss.dispose
  2779. name.dispose
  2780. names.dispose
  2781. trainer.dispose
  2782. shadow.dispose
  2783. light.dispose
  2784. viewport.color=Color.new(0,0,0,255)
  2785. return true
  2786. end
  2787. #-------------------------------------------------------------------------------
  2788. # Sun & Moon VS animation logic
  2789. #-------------------------------------------------------------------------------
  2790. # used to play that little "rainbow" zoom before the battle starts
  2791. def smPreBattle(viewport)
  2792. bmp = Graphics.snap_to_bitmap
  2793. fp = {}
  2794. fp["bg1"] = Sprite.new(viewport)
  2795. fp["bg1"].bitmap = bmp
  2796. fp["bg1"].ox = bmp.width/2
  2797. fp["bg1"].oy = bmp.height/2
  2798. fp["bg1"].x = viewport.rect.width/2
  2799. fp["bg1"].y = viewport.rect.height/2
  2800. fp["bg2"] = Sprite.new(viewport)
  2801. fp["bg2"].bitmap = bmp
  2802. fp["bg2"].blur_sprite(3)
  2803. fp["bg2"].ox = bmp.width/2
  2804. fp["bg2"].oy = bmp.height/2
  2805. fp["bg2"].x = viewport.rect.width/2
  2806. fp["bg2"].y = viewport.rect.height/2
  2807. fp["bg2"].opacity = 0
  2808.  
  2809. fp["glow1"] = Sprite.new(viewport)
  2810. fp["glow1"].bitmap = pbBitmap("Graphics/Transitions/smGlow1")
  2811. fp["glow1"].ox = fp["glow1"].bitmap.width/2
  2812. fp["glow1"].oy = fp["glow1"].bitmap.height/2
  2813. fp["glow1"].x = viewport.rect.width/2
  2814. fp["glow1"].y = viewport.rect.height/2
  2815. fp["glow1"].zoom_x = 0.35
  2816. fp["glow1"].zoom_y = 0.35
  2817. fp["glow1"].opacity = 0
  2818. fp["glow2"] = Sprite.new(viewport)
  2819. fp["glow2"].bitmap = pbBitmap("Graphics/Transitions/smGlow1")
  2820. fp["glow2"].ox = fp["glow1"].bitmap.width/2
  2821. fp["glow2"].oy = fp["glow1"].bitmap.height/2
  2822. fp["glow2"].x = viewport.rect.width/2
  2823. fp["glow2"].y = viewport.rect.height/2
  2824. fp["glow2"].zoom_x = 0.1
  2825. fp["glow2"].zoom_y = 0.1
  2826. fp["glow2"].opacity = 0
  2827. for i in 0...32
  2828. fp["bg1"].zoom_x += 0.02
  2829. fp["bg1"].zoom_y += 0.02
  2830. fp["bg2"].zoom_x += 0.02
  2831. fp["bg2"].zoom_y += 0.02
  2832. fp["bg2"].opacity += 12
  2833. if i >= 16
  2834. fp["bg2"].tone.red += 16
  2835. fp["bg2"].tone.green += 16
  2836. fp["bg2"].tone.blue += 16
  2837. end
  2838. if i >= 28
  2839. fp["glow1"].opacity += 64
  2840. fp["glow1"].zoom_x += 0.02
  2841. fp["glow1"].zoom_y += 0.02
  2842. end
  2843. Graphics.update
  2844. end
  2845. for i in 0...52
  2846. fp["glow1"].zoom_x += 0.02
  2847. fp["glow1"].zoom_y += 0.02
  2848. if i >= 8
  2849. fp["glow2"].opacity += 64
  2850. fp["glow2"].zoom_x += 0.02
  2851. fp["glow2"].zoom_y += 0.02
  2852. end
  2853. if i >= 36
  2854. viewport.color.alpha += 16
  2855. end
  2856. Graphics.update
  2857. end
  2858. pbDisposeSpriteHash(fp)
  2859. end
  2860. # handler for the different Sun/Moon transitions
  2861. class PokeBattle_Scene
  2862. attr_accessor :sequenceType
  2863. def startSMSequence(viewport,trainerid)
  2864. @vs = {}
  2865. return crazySequence_start(viewport,trainerid) if pbResolveBitmap(sprintf("Graphics/Transitions/smCrazy%d",trainerid))
  2866. return vsSequenceSM_start(viewport,trainerid)
  2867. end
  2868.  
  2869. def updateSMSequence
  2870. return crazySequence_update if sequenceType == 1
  2871. return vsSequenceSM_update
  2872. end
  2873.  
  2874. def endSMSequence
  2875. return crazySequence_end if sequenceType == 1
  2876. return vsSequenceSM_end
  2877. end
  2878.  
  2879. def sendoutSMSequence
  2880. $smAnim = false
  2881. return crazySequence_sendout if sequenceType == 1
  2882. return vsSequenceSM_sendout
  2883. end
  2884. end
  2885. #-------------------------------------------------------------------------------
  2886. # Classic Sun Moon VS sequences
  2887. #-------------------------------------------------------------------------------
  2888. class PokeBattle_Scene
  2889. # actual Sun/Moon intro sequence gets handled here
  2890. def vsSequenceSM_start(viewport,trainerid)
  2891. # checks for variants of the sequel
  2892. @smSpecial = pbResolveBitmap(sprintf("Graphics/Transitions/smSpecial%d",trainerid))
  2893. @smElite = pbResolveBitmap(sprintf("Graphics/Transitions/smElite%d",trainerid))
  2894. @smSpecial = false if @smElite
  2895. # checks if trainer belongs to the evil team
  2896. evil = false
  2897. for val in EVIL_TEAM_LIST
  2898. if val.is_a?(Numeric)
  2899. id = val
  2900. elsif val.is_a?(Symbol)
  2901. id = getConst(PBTrainers,val)
  2902. end
  2903. evil = true if !id.nil? && trainerid == id
  2904. end
  2905. # sets the color to white
  2906. viewport.color = Color.new(255,255,255) if !evil
  2907.  
  2908. bgstring = "Graphics/Transitions/smBg#{trainerid}"
  2909. bgstring2 = "Graphics/Transitions/smBgNext#{trainerid}"
  2910. bgstring3 = "Graphics/Transitions/smBgLast#{trainerid}"
  2911.  
  2912. if @smElite
  2913. # Elite4 variant
  2914. @vs["bg"] = Sprite.new(viewport)
  2915. str = sprintf("Graphics/Transitions/smEffBg%d",trainerid)
  2916. str = "Graphics/Transitions/smEffBg" if !pbResolveBitmap(str)
  2917. @vs["bg"].bitmap = pbBitmap(str)
  2918. else
  2919. # Regular and special animations
  2920. @vs["bg"] = @smSpecial ? RainbowSprite.new(viewport) : ScrollingSprite.new(viewport)
  2921. @vs["bg"].setBitmap("Graphics/Transitions/smBgDefault")
  2922. @vs["bg"].setBitmap("Graphics/Transitions/smBgEvil") if evil
  2923. @vs["bg"].setBitmap(bgstring) if pbResolveBitmap(bgstring)
  2924. @vs["bg"].setBitmap("Graphics/Transitions/smBgSpecial") if @smSpecial
  2925. end
  2926. @vs["bg"].color = Color.new(0,0,0,255)
  2927. @vs["bg"].speed = @smSpecial ? 4 : 32 if !@smElite
  2928. @vs["bg"].ox = @vs["bg"].src_rect.width/2
  2929. @vs["bg"].oy = @vs["bg"].src_rect.height/2
  2930. @vs["bg"].x = viewport.rect.width/2
  2931. @vs["bg"].y = viewport.rect.height/2
  2932. @vs["bg"].angle = - 8 if !@smSpecial && !@smElite && $PokemonSystem.screensize < 2
  2933. @vs["bg"].z = 200
  2934. if !@smSpecial && !@smElite
  2935. # loads the rest of the scrolling panorama
  2936. @vs["bg2"] = ScrollingSprite.new(viewport)
  2937. @vs["bg2"].setBitmap("Graphics/Transitions/smBgLastDefault",false,true)
  2938. @vs["bg2"].setBitmap("Graphics/Transitions/smBgLastEvil",false,true) if evil
  2939. @vs["bg2"].setBitmap(bgstring3,false,true) if pbResolveBitmap(bgstring3)
  2940. @vs["bg2"].color = Color.new(0,0,0,255)
  2941. @vs["bg2"].speed = 64
  2942. @vs["bg2"].ox = @vs["bg2"].src_rect.width/2
  2943. @vs["bg2"].oy = @vs["bg2"].src_rect.height/2
  2944. @vs["bg2"].x = viewport.rect.width/2
  2945. @vs["bg2"].y = viewport.rect.height/2
  2946. @vs["bg2"].angle = - 8 if $PokemonSystem.screensize < 2
  2947. @vs["bg2"].z = 200
  2948. @vs["bg3"] = ScrollingSprite.new(viewport)
  2949. @vs["bg3"].setBitmap("Graphics/Transitions/smBgNextDefault",false,true)
  2950. @vs["bg3"].setBitmap("Graphics/Transitions/smBgNextEvil",false,true) if evil
  2951. @vs["bg3"].setBitmap(bgstring2,false,true) if pbResolveBitmap(bgstring2)
  2952. @vs["bg3"].color = Color.new(0,0,0,255)
  2953. @vs["bg3"].speed = 80
  2954. @vs["bg3"].ox = @vs["bg3"].src_rect.width/2
  2955. @vs["bg3"].oy = @vs["bg3"].src_rect.height/2
  2956. @vs["bg3"].x = viewport.rect.width/2
  2957. @vs["bg3"].y = viewport.rect.height/2
  2958. @vs["bg3"].angle = - 8 if $PokemonSystem.screensize < 2
  2959. @vs["bg3"].z = 200
  2960. end
  2961.  
  2962. @vsFp = {}
  2963. @fpDx = []
  2964. @fpDy = []
  2965. @fpIndex = 0
  2966. if @smSpecial
  2967. # loads particles for special variant
  2968. @vsFp["ring"] = Sprite.new(viewport)
  2969. @vsFp["ring"].bitmap = pbBitmap("Graphics/Transitions/smRing")
  2970. @vsFp["ring"].ox = @vsFp["ring"].bitmap.width/2
  2971. @vsFp["ring"].oy = @vsFp["ring"].bitmap.height/2
  2972. @vsFp["ring"].x = viewport.rect.width/2
  2973. @vsFp["ring"].y = viewport.rect.height
  2974. @vsFp["ring"].zoom_x = 0
  2975. @vsFp["ring"].zoom_y = 0
  2976. @vsFp["ring"].z = 500
  2977.  
  2978. for j in 0...32
  2979. @vsFp["s#{j}"] = Sprite.new(viewport)
  2980. @vsFp["s#{j}"].bitmap = pbBitmap("Graphics/Transitions/smSpec")
  2981. @vsFp["s#{j}"].ox = @vsFp["s#{j}"].bitmap.width/2
  2982. @vsFp["s#{j}"].oy = @vsFp["s#{j}"].bitmap.height/2
  2983. @vsFp["s#{j}"].opacity = 0
  2984. @vsFp["s#{j}"].z = 220
  2985. @fpDx.push(0)
  2986. @fpDy.push(0)
  2987. end
  2988.  
  2989. @fpSpeed = []
  2990. @fpOpac = []
  2991. for j in 0...3
  2992. k = j+1
  2993. speed = 2 + rand(5)
  2994. @vsFp["p#{j}"] = ScrollingSprite.new(viewport)
  2995. @vsFp["p#{j}"].setBitmap("Graphics/Transitions/smSpecEff#{k}")
  2996. @vsFp["p#{j}"].speed = speed*4
  2997. @vsFp["p#{j}"].direction = -1
  2998. @vsFp["p#{j}"].opacity = 0
  2999. @vsFp["p#{j}"].z = 400
  3000. @vsFp["p#{j}"].zoom_y = 1 + rand(10)*0.005
  3001. @fpSpeed.push(speed)
  3002. @fpOpac.push(4) if j > 0
  3003. end
  3004. end
  3005.  
  3006. if @smElite
  3007. # loads particles for Elite4 variant
  3008. for j in 0...16
  3009. @vsFp["e#{j}"] = Sprite.new(viewport)
  3010. bmp = pbBitmap("Graphics/Transitions/smEff1")
  3011. @vsFp["e#{j}"].bitmap = Bitmap.new(bmp.width,bmp.height)
  3012. w = bmp.width/(1 + rand(3))
  3013. @vsFp["e#{j}"].bitmap.stretch_blt(Rect.new(0,0,w,bmp.height),bmp,Rect.new(0,0,bmp.width,bmp.height))
  3014. @vsFp["e#{j}"].oy = @vsFp["e#{j}"].bitmap.height/2
  3015. @vsFp["e#{j}"].angle = rand(360)
  3016. @vsFp["e#{j}"].opacity = 0
  3017. @vsFp["e#{j}"].x = viewport.rect.width/2
  3018. @vsFp["e#{j}"].y = viewport.rect.height/2
  3019. @vsFp["e#{j}"].speed = (4 + rand(5))
  3020. @vsFp["e#{j}"].z = 220
  3021. end
  3022. for j in 0...3
  3023. @vsFp["ec#{j}"] = Sprite.new(viewport)
  3024. @vsFp["ec#{j}"].bitmap = pbBitmap("Graphics/Transitions/smEff2")
  3025. @vsFp["ec#{j}"].ox = @vsFp["ec#{j}"].bitmap.width/2
  3026. @vsFp["ec#{j}"].oy = @vsFp["ec#{j}"].bitmap.height/2
  3027. @vsFp["ec#{j}"].x = viewport.rect.width/2
  3028. @vsFp["ec#{j}"].y = viewport.rect.height/2
  3029. @vsFp["ec#{j}"].zoom_x = 1.5
  3030. @vsFp["ec#{j}"].zoom_y = 1.5
  3031. @vsFp["ec#{j}"].opacity = 0
  3032. @vsFp["ec#{j}"].z = 220
  3033. end
  3034. @vs["bg2"] = Sprite.new(viewport)
  3035. @vs["bg2"].bitmap = pbBitmap("Graphics/Transitions/smEff3")
  3036. @vs["bg2"].ox = @vs["bg2"].src_rect.width/2
  3037. @vs["bg2"].oy = @vs["bg2"].src_rect.height/2
  3038. @vs["bg2"].x = viewport.rect.width/2
  3039. @vs["bg2"].y = viewport.rect.height/2
  3040. @vs["bg2"].opacity = 0
  3041. @vs["bg2"].z = 200
  3042. end
  3043.  
  3044. # trainer and trainer effect graphics
  3045. @vs["shade"] = Sprite.new(viewport)
  3046. @vs["shade"].z = 250
  3047. @vs["glow"] = Sprite.new(viewport)
  3048. @vs["glow"].y = viewport.rect.height
  3049. @vs["glow"].z = 250
  3050. @vs["glow2"] = Sprite.new(viewport)
  3051. @vs["glow2"].x = viewport.rect.width/2
  3052. @vs["glow2"].z = 250
  3053.  
  3054. @vs["trainer"] = Sprite.new(viewport)
  3055. @vs["trainer"].z = 350
  3056. @vs["trainer"].bitmap = Bitmap.new(viewport.rect.width,viewport.rect.height)
  3057. @vs["trainer"].ox = @vs["trainer"].bitmap.width/2
  3058. @vs["trainer"].oy = @vs["trainer"].bitmap.height/2
  3059. @vs["trainer"].x = @vs["trainer"].ox
  3060. @vs["trainer"].y = @vs["trainer"].oy
  3061. @vs["trainer"].tone = Tone.new(255,255,255)
  3062. @vs["trainer"].zoom_x = 1.32
  3063. @vs["trainer"].zoom_y = 1.32
  3064. @vs["trainer"].opacity = 0
  3065.  
  3066. t_ext = @smSpecial ? "Special" : "Trainer"
  3067. t_ext = "Elite" if @smElite
  3068. bmp = pbBitmap("Graphics/Transitions/sm#{t_ext}#{trainerid}")
  3069. ox = (@vs["trainer"].bitmap.width - bmp.width)/2
  3070. oy = (@vs["trainer"].bitmap.height - bmp.height)/2
  3071. @vs["trainer"].bitmap.blt(ox,oy,bmp,Rect.new(0,0,bmp.width,bmp.height))
  3072. bmp = @vs["trainer"].bitmap.clone
  3073.  
  3074. @vs["shade"].bitmap = bmp.clone
  3075. @vs["shade"].color = @smElite ? Color.new(150,115,255,204) : Color.new(10,169,245,204)
  3076. @vs["shade"].opacity = 0
  3077.  
  3078. @vs["glow"].bitmap = bmp.clone
  3079. @vs["glow"].glow(Color.new(0,0,0),35,false)
  3080. @vs["glow"].src_rect.set(0,viewport.rect.height,viewport.rect.width/2,0)
  3081. @vs["glow2"].bitmap = @vs["glow"].bitmap.clone
  3082. @vs["glow2"].src_rect.set(viewport.rect.width/2,0,viewport.rect.width/2,0)
  3083.  
  3084. @vs["overlay"] = Sprite.new(viewport)
  3085. @vs["overlay"].z = 999
  3086. obmp = pbBitmap("Graphics/Transitions/ballTransition")
  3087. @vs["overlay"].bitmap = Bitmap.new(viewport.rect.width,viewport.rect.height)
  3088. @vs["overlay"].opacity = 0
  3089. # starts playing the intro of the animation
  3090. 16.times do
  3091. viewport.color.alpha -= 16 if viewport.color.alpha > 0
  3092. @vs["trainer"].zoom_x -= 0.02
  3093. @vs["trainer"].zoom_y -= 0.02
  3094. @vs["trainer"].opacity += 32
  3095. Graphics.update
  3096. end
  3097. @vs["trainer"].zoom_x = 1; @vs["trainer"].zoom_y = 1
  3098. @commandWindow.drawLineup
  3099. @commandWindow.lineupY(-32)
  3100. for i in 0...16
  3101. @commandWindow.showArrows if i < 10
  3102. @vs["trainer"].tone.red -= 16
  3103. @vs["trainer"].tone.green -= 16
  3104. @vs["trainer"].tone.blue -= 16
  3105. @vs["bg"].color.alpha -= 16
  3106. if !@smSpecial && !@smElite
  3107. @vs["bg2"].color.alpha -= 16
  3108. @vs["bg3"].color.alpha -= 16
  3109. end
  3110. if @smSpecial
  3111. @vsFp["ring"].zoom_x += 0.2
  3112. @vsFp["ring"].zoom_y += 0.2
  3113. @vsFp["ring"].opacity -= 16
  3114. end
  3115. self.vsSequenceSM_update
  3116. Graphics.update
  3117. end
  3118. 16.times do
  3119. self.vsSequenceSM_update
  3120. Graphics.update
  3121. end
  3122. for i in 0...16
  3123. @vs["trainer"].tone.red -= 32*(i < 8 ? -1 : 1)
  3124. @vs["trainer"].tone.green -= 32*(i < 8 ? -1 : 1)
  3125. @vs["trainer"].tone.blue -= 32*(i < 8 ? -1 : 1)
  3126. @vs["bg"].speed = (@smSpecial ? 2 : 16) if i == 8 && !@smElite
  3127. if !@smSpecial && !@smElite
  3128. @vs["bg2"].speed = 2 if i == 8
  3129. @vs["bg3"].speed = 6 if i == 8
  3130. end
  3131. for j in 0...3
  3132. next if !@smSpecial
  3133. next if i != 8
  3134. @vsFp["p#{j}"].speed /= 4
  3135. end
  3136. self.vsSequenceSM_update
  3137. Graphics.update
  3138. end
  3139. 16.times do
  3140. @vs["glow"].src_rect.height += 24
  3141. @vs["glow"].src_rect.y -= 24
  3142. @vs["glow"].y -= 24
  3143. @vs["glow2"].src_rect.height += 24
  3144. self.vsSequenceSM_update
  3145. Graphics.update
  3146. end
  3147. viewport.color = Color.new(255,255,255,0) if @smElite
  3148. 8.times do
  3149. viewport.color.alpha += 32 if @smElite
  3150. @vs["glow"].tone.red += 32
  3151. @vs["glow"].tone.green += 32
  3152. @vs["glow"].tone.blue += 32
  3153. @vs["glow2"].tone.red += 32
  3154. @vs["glow2"].tone.green += 32
  3155. @vs["glow2"].tone.blue += 32
  3156. self.vsSequenceSM_update
  3157. Graphics.update
  3158. end
  3159. @vs["bg2"].opacity = 255 if @smElite
  3160. for i in 0...4
  3161. @vs["trainer"].tone.red += 64
  3162. @vs["trainer"].tone.green += 64
  3163. @vs["trainer"].tone.blue += 64
  3164. if !@smSpecial && !@smElite
  3165. @vs["bg"].x += 2
  3166. @vs["bg2"].x += 2
  3167. @vs["bg3"].x += 2
  3168. end
  3169. viewport.color.alpha -= 16 if @smElite
  3170. self.vsSequenceSM_update
  3171. Graphics.update
  3172. end
  3173. for j in 0...3
  3174. viewport.color.alpha -= 16 if @smElite
  3175. next if !@smSpecial
  3176. @vsFp["p#{j}"].z = 300
  3177. end
  3178. for i in 0...8
  3179. viewport.color.alpha -= 16 if @smElite
  3180. @vs["trainer"].tone.red -= 32
  3181. @vs["trainer"].tone.green -= 32
  3182. @vs["trainer"].tone.blue -= 32
  3183. @vs["shade"].opacity += 32
  3184. @vs["shade"].x -= 4
  3185. if i < 4 && !@smSpecial && !@smElite
  3186. @vs["bg"].x -= 2
  3187. @vs["bg2"].x -= 2
  3188. @vs["bg3"].x -= 2
  3189. end
  3190. self.vsSequenceSM_update
  3191. Graphics.update
  3192. end
  3193. # end of intro animation
  3194. end
  3195.  
  3196. def vsSequenceSM_update
  3197. # updates the background effects
  3198. @vs["bg"].update if @vs["bg"] && !@vs["bg"].disposed?
  3199. @vs["bg2"].update if @vs["bg2"] && !@vs["bg2"].disposed?
  3200. @vs["bg3"].update if @vs["bg3"] && !@vs["bg3"].disposed?
  3201. for j in 0...32
  3202. # updates the particles for the special variant
  3203. next if !@smSpecial
  3204. next if !@vsFp["s#{j}"] || @vsFp["s#{j}"].disposed?
  3205. next if j > @fpIndex/4
  3206. if @vsFp["s#{j}"].opacity <= 1
  3207. width = @vs["bg"].viewport.rect.width
  3208. height = @vs["bg"].viewport.rect.height
  3209. x = rand(width*0.75) + width*0.125
  3210. y = rand(height*0.50) + height*0.25
  3211. @fpDx[j] = x + rand(width*0.125)*(x < width/2 ? -1 : 1)
  3212. @fpDy[j] = y - rand(height*0.25)
  3213. z = [1,0.75,0.5,0.25][rand(4)]
  3214. @vsFp["s#{j}"].zoom_x = z
  3215. @vsFp["s#{j}"].zoom_y = z
  3216. @vsFp["s#{j}"].x = x
  3217. @vsFp["s#{j}"].y = y
  3218. @vsFp["s#{j}"].opacity = 255
  3219. @vsFp["s#{j}"].angle = rand(360)
  3220. end
  3221. @vsFp["s#{j}"].x -= (@vsFp["s#{j}"].x - @fpDx[j])*0.05
  3222. @vsFp["s#{j}"].y -= (@vsFp["s#{j}"].y - @fpDy[j])*0.05
  3223. @vsFp["s#{j}"].opacity -= @vsFp["s#{j}"].opacity*0.05
  3224. @vsFp["s#{j}"].zoom_x -= @vsFp["s#{j}"].zoom_x*0.05
  3225. @vsFp["s#{j}"].zoom_y -= @vsFp["s#{j}"].zoom_y*0.05
  3226. end
  3227. for j in 0...3
  3228. # updates the particles for the special variant
  3229. next if !@smSpecial
  3230. next if !@vsFp["p#{j}"] || @vsFp["p#{j}"].disposed?
  3231. @vsFp["p#{j}"].update
  3232. if j == 0
  3233. @vsFp["p#{j}"].opacity += 5 if @vsFp["p#{j}"].opacity < 155
  3234. else
  3235. @vsFp["p#{j}"].opacity += @fpOpac[j-1]*(@fpSpeed[j]/2)
  3236. end
  3237. next if @fpIndex < 24
  3238. @fpOpac[j-1] *= -1 if (@vsFp["p#{j}"].opacity >= 255 || @vsFp["p#{j}"].opacity < 65)
  3239. end
  3240. if @smElite && @vs["bg"] && !@vs["bg"].disposed?
  3241. # updates the particles for the Elite4 variant
  3242. @vs["bg"].angle += 1 if $PokemonSystem.screensize < 2
  3243. @vs["bg2"].angle -= 1 if $PokemonSystem.screensize < 2
  3244. for j in 0...16
  3245. next if @vs["bg2"].opacity < 255
  3246. if @vsFp["e#{j}"].ox < -(@vsFp["e#{j}"].viewport.rect.width/2)
  3247. @vsFp["e#{j}"].speed = 4 + rand(5)
  3248. @vsFp["e#{j}"].opacity = 0
  3249. @vsFp["e#{j}"].ox = 0
  3250. @vsFp["e#{j}"].angle = rand(360)
  3251. bmp = pbBitmap("Graphics/Transitions/smEff1")
  3252. @vsFp["e#{j}"].bitmap.clear
  3253. w = bmp.width/(1 + rand(3))
  3254. @vsFp["e#{j}"].bitmap.stretch_blt(Rect.new(0,0,w,bmp.height),bmp,Rect.new(0,0,bmp.width,bmp.height))
  3255. end
  3256. @vsFp["e#{j}"].opacity += @vsFp["e#{j}"].speed
  3257. @vsFp["e#{j}"].ox -= @vsFp["e#{j}"].speed
  3258. end
  3259. for j in 0...3
  3260. next if j > @fpIndex/50
  3261. if @vsFp["ec#{j}"].zoom_x <= 0
  3262. @vsFp["ec#{j}"].zoom_x = 1.5
  3263. @vsFp["ec#{j}"].zoom_y = 1.5
  3264. @vsFp["ec#{j}"].opacity = 0
  3265. end
  3266. @vsFp["ec#{j}"].opacity += 8
  3267. @vsFp["ec#{j}"].zoom_x -= 0.01
  3268. @vsFp["ec#{j}"].zoom_y -= 0.01
  3269. end
  3270.  
  3271. end
  3272. @fpIndex += 1 if @fpIndex < 150
  3273. end
  3274.  
  3275. def vsSequenceSM_end
  3276. # final transition
  3277. viewport = @viewport
  3278. zoom = 4.0
  3279. obmp = pbBitmap("Graphics/Transitions/ballTransition")
  3280. @vs["bg"].speed = @smSpecial ? 4 : 32 if !@smElite
  3281. if !@smSpecial && !@smElite
  3282. @vs["bg2"].speed = 64
  3283. @vs["bg3"].speed = 8
  3284. end
  3285. for j in 0...3
  3286. next if !@smSpecial
  3287. @vsFp["p#{j}"].speed *= 4
  3288. end
  3289. for i in 0..20
  3290. @vs["trainer"].x += 6*(i/5 + 1)
  3291. @vs["glow"].x += 6*(i/5 + 1)
  3292. @vs["glow2"].x += 6*(i/5 + 1)
  3293. @commandWindow.hideArrows if i < 10
  3294. @vs["overlay"].bitmap.clear
  3295. ox = (1 - zoom)*viewport.rect.width*0.5
  3296. oy = (1 - zoom)*viewport.rect.height*0.5
  3297. width = (ox < 0 ? 0 : ox).ceil
  3298. height = (oy < 0 ? 0 : oy).ceil
  3299. @vs["overlay"].bitmap.fill_rect(0,0,width,viewport.rect.height,Color.new(0,0,0))
  3300. @vs["overlay"].bitmap.fill_rect(viewport.rect.width-width,0,width,viewport.rect.height,Color.new(0,0,0))
  3301. @vs["overlay"].bitmap.fill_rect(0,0,viewport.rect.width,height,Color.new(0,0,0))
  3302. @vs["overlay"].bitmap.fill_rect(0,viewport.rect.height-height,viewport.rect.width,height,Color.new(0,0,0))
  3303. @vs["overlay"].bitmap.stretch_blt(Rect.new(ox,oy,(obmp.width*zoom).ceil,(obmp.height*zoom).ceil),obmp,Rect.new(0,0,obmp.width,obmp.height))
  3304. @vs["overlay"].opacity += 64
  3305. zoom -= 4.0/20
  3306. self.vsSequenceSM_update
  3307. @vs["shade"].opacity -= 16
  3308. Graphics.update
  3309. end
  3310. @commandWindow.lineupY(+32)
  3311. # disposes of current sprites
  3312. pbDisposeSpriteHash(@vs)
  3313. pbDisposeSpriteHash(@vsFp)
  3314. @vs["overlay"] = Sprite.new(@msgview)
  3315. @vs["overlay"].z = 9999999
  3316. @vs["overlay"].bitmap = Bitmap.new(@msgview.rect.width,@msgview.rect.height)
  3317. @vs["overlay"].bitmap.fill_rect(0,0,@msgview.rect.width,@msgview.rect.height,Color.new(0,0,0))
  3318. end
  3319.  
  3320. def vsSequenceSM_sendout
  3321. # transitions from VS sequence to the battle scene
  3322. viewport = @msgview
  3323. zoom = 0
  3324. obmp = pbBitmap("Graphics/Transitions/ballTransition")
  3325. 21.times do
  3326. @vs["overlay"].bitmap.clear
  3327. ox = (1 - zoom)*viewport.rect.width*0.5
  3328. oy = (1 - zoom)*viewport.rect.height*0.5
  3329. width = (ox < 0 ? 0 : ox).ceil
  3330. height = (oy < 0 ? 0 : oy).ceil
  3331. @vs["overlay"].bitmap.fill_rect(0,0,width,viewport.rect.height,Color.new(0,0,0))
  3332. @vs["overlay"].bitmap.fill_rect(viewport.rect.width-width,0,width,viewport.rect.height,Color.new(0,0,0))
  3333. @vs["overlay"].bitmap.fill_rect(0,0,viewport.rect.width,height,Color.new(0,0,0))
  3334. @vs["overlay"].bitmap.fill_rect(0,viewport.rect.height-height,viewport.rect.width,height,Color.new(0,0,0))
  3335. @vs["overlay"].bitmap.stretch_blt(Rect.new(ox,oy,(obmp.width*zoom).ceil,(obmp.height*zoom).ceil),obmp,Rect.new(0,0,obmp.width,obmp.height))
  3336. @vs["overlay"].opacity -= 12.8
  3337. zoom += 4.0/20
  3338. wait(1,true)
  3339. end
  3340. @vs["overlay"].dispose
  3341. end
  3342. end
  3343. #-------------------------------------------------------------------------------
  3344. # New S&M "Mother Beast Lusamine" styled sequence
  3345. #-------------------------------------------------------------------------------
  3346. class PokeBattle_Scene
  3347. def crazySequence_start(viewport,trainerid)
  3348. @sequenceType = 1
  3349. @vs["bg"] = CrazyRainbowBackground.new(viewport)
  3350. @vs["rect"] = Sprite.new(@viewport)
  3351. @vs["rect"].z = 400
  3352. @vs["rect"].drawRect(viewport.rect.width,viewport.rect.height,Color.new(0,0,0))
  3353. @vs["rect"].color = Color.new(255,255,255)
  3354.  
  3355. @vs["trainer"] = Sprite.new(viewport)
  3356. @vs["trainer"].bitmap = pbBitmap(sprintf("Graphics/Transitions/smCrazy%d",trainerid))
  3357. @vs["trainer"].ox = @vs["trainer"].bitmap.width/2
  3358. @vs["trainer"].oy = @vs["trainer"].bitmap.height/2
  3359. @vs["trainer"].x = 3*viewport.rect.width/2
  3360. @vs["trainer"].y = viewport.rect.height/2
  3361. @vs["trainer"].color = Color.new(255,255,255)
  3362. @vs["trainer"].z = 450
  3363.  
  3364. @vs["trainer3"] = Sprite.new(viewport)
  3365. @vs["trainer3"].bitmap = Bitmap.new(viewport.rect.width,viewport.rect.height)
  3366. bmp = @vs["trainer"].bitmap.clone
  3367. @vs["trainer3"].bitmap.blt((viewport.rect.width-bmp.width)/2,(viewport.rect.height-bmp.height)/2,bmp,Rect.new(0,0,bmp.width,bmp.height))
  3368. @vs["trainer3"].y = viewport.rect.height
  3369. @vs["trainer3"].color = Color.new(255,255,255)
  3370. @vs["trainer3"].z = 400
  3371. @vs["trainer3"].glow(Color.new(255,255,255))
  3372. @vs["trainer3"].src_rect.set(0,viewport.rect.height,viewport.rect.width,0)
  3373.  
  3374. @commandWindow.drawLineup
  3375. @commandWindow.lineupY(-32)
  3376. 64.times do
  3377. @vs["bg"].update
  3378. end
  3379. 16.times do
  3380. @vs["rect"].color.alpha -= 16
  3381. Graphics.update
  3382. end
  3383. for i in 0...24
  3384. @commandWindow.showArrows if i < 10
  3385. @vs["trainer"].x += ((-16 + viewport.rect.width/2) - @vs["trainer"].x)*0.2
  3386. Graphics.update
  3387. end
  3388. 4.times do
  3389. @vs["trainer"].x += 4
  3390. Graphics.update
  3391. end
  3392. 8.times do
  3393. @vs["trainer"].color.alpha -= 32
  3394. Graphics.update
  3395. end
  3396. 16.times do
  3397. @vs["trainer3"].src_rect.y -= 24
  3398. @vs["trainer3"].src_rect.height += 24
  3399. @vs["trainer3"].y -= 24
  3400. Graphics.update
  3401. end
  3402. @vs["rect"].color = Color.new(255,255,255,0)
  3403. for i in 0...2
  3404. 8.times do
  3405. @vs["trainer"].color.alpha += 32*(i==0 ? 1 : -1)
  3406. @vs["rect"].color.alpha += 16
  3407. @vs["rect"].opacity -= 16 if i == 1
  3408. @vs["bg"].update if i == 1
  3409. Graphics.update
  3410. end
  3411. end
  3412. 16.times do
  3413. @vs["bg"].update
  3414. @vs["rect"].opacity -= 16
  3415. Graphics.update
  3416. end
  3417. end
  3418.  
  3419. def crazySequence_end
  3420. view = @vs["trainer"].viewport
  3421. @vs["bg"].dispose
  3422. @vs["rect"].dispose
  3423. @vs["trainer"].dispose
  3424. @vs["trainer3"].dispose
  3425.  
  3426. bmp = Graphics.snap_to_bitmap
  3427. @vs["ov1"] = Sprite.new(view)
  3428. @vs["ov1"].bitmap = bmp
  3429. @vs["ov1"].ox = bmp.width/2
  3430. @vs["ov1"].oy = bmp.height/2
  3431. @vs["ov1"].x = viewport.rect.width/2
  3432. @vs["ov1"].y = viewport.rect.height/2
  3433. @vs["ov1"].z = 500
  3434. @vs["ov2"] = Sprite.new(view)
  3435. @vs["ov2"].bitmap = bmp
  3436. @vs["ov2"].blur_sprite(3)
  3437. @vs["ov2"].ox = bmp.width/2
  3438. @vs["ov2"].oy = bmp.height/2
  3439. @vs["ov2"].x = viewport.rect.width/2
  3440. @vs["ov2"].y = viewport.rect.height/2
  3441. @vs["ov2"].opacity = 0
  3442. @vs["ov2"].z = 500
  3443. # final zooming transition
  3444. for i in 0...32
  3445. @commandWindow.hideArrows if i < 10
  3446. @vs["ov1"].zoom_x += 0.02
  3447. @vs["ov1"].zoom_y += 0.02
  3448. @vs["ov2"].zoom_x += 0.02
  3449. @vs["ov2"].zoom_y += 0.02
  3450. @vs["ov2"].opacity += 12
  3451. if i >= 16
  3452. @vs["ov2"].tone.red += 16
  3453. @vs["ov2"].tone.green += 16
  3454. @vs["ov2"].tone.blue += 16
  3455. end
  3456. Graphics.update
  3457. end
  3458. 8.times do; Graphics.update; end
  3459. $smAnim = false
  3460. @vs["ov1"].opacity = 0
  3461. for i in 0...16
  3462. @vs["ov2"].opacity -= 16
  3463. wait(1,true)
  3464. end
  3465. @commandWindow.lineupY(+32)
  3466. @vs["ov1"].dispose
  3467. @vs["ov2"].dispose
  3468. end
  3469.  
  3470. def crazySequence_sendout
  3471. end
  3472.  
  3473. def crazySequence_update
  3474. return if @vs["trainer"].disposed?
  3475. @vs["bg"].update
  3476. end
  3477. end#-------------------------------------------------------------------------------
  3478. # Special Pokemon VS animation
  3479. #-------------------------------------------------------------------------------
  3480. class PokeBattle_Scene
  3481. # called within the scene to update animation
  3482. def ebSpecialSpecies_update
  3483. for j in 0...3
  3484. if @vsFp["ec#{j}"].zoom_x <= 0
  3485. @vsFp["ec#{j}"].zoom_x = 2
  3486. @vsFp["ec#{j}"].zoom_y = 2
  3487. @vsFp["ec#{j}"].opacity = 255
  3488. end
  3489. @vsFp["ec#{j}"].opacity -= 3
  3490. @vsFp["ec#{j}"].zoom_x -= 0.02
  3491. @vsFp["ec#{j}"].zoom_y -= 0.02
  3492. end
  3493. @vsFp["poke1"].src_rect.height += 40 if @vsFp["poke1"].src_rect.height < 640
  3494. @vsFp["poke1"].opacity -= 2*@vsFp["poke1"].toggle
  3495. @vsFp["poke1"].toggle *= -1 if @vsFp["poke1"].opacity <= 0 || @vsFp["poke1"].opacity >= 255
  3496. @vsFp["bg"].angle += 1 if $PokemonSystem.screensize < 2
  3497. end
  3498. # called within the scene to initialize and start the animation
  3499. def ebSpecialSpecies_start(viewport)
  3500. species = $wildSpecies
  3501. viewport.color = Color.new(255,255,255,0)
  3502.  
  3503. @vsFp = {}
  3504. # graphics for bars covering the viewport
  3505. @vsFp["bar1"] = Sprite.new(viewport)
  3506. @vsFp["bar1"].drawRect(viewport.rect.width,viewport.rect.height/2,Color.new(0,0,0))
  3507. @vsFp["bar1"].z = 999
  3508. @vsFp["bar2"] = Sprite.new(viewport)
  3509. @vsFp["bar2"].drawRect(viewport.rect.width,viewport.rect.height/2 + 2,Color.new(0,0,0))
  3510. @vsFp["bar2"].oy = @vsFp["bar2"].bitmap.height
  3511. @vsFp["bar2"].y = viewport.rect.height + 2
  3512. @vsFp["bar2"].z = 999
  3513. # background graphic
  3514. @vsFp["bg"] = Sprite.new(viewport)
  3515. str = "Graphics/Transitions/speciesBg#{species}"
  3516. str = "Graphics/Transitions/speciesBg" if !pbResolveBitmap(str)
  3517. @vsFp["bg"].bitmap = pbBitmap(str)
  3518. @vsFp["bg"].ox = @vsFp["bg"].src_rect.width/2
  3519. @vsFp["bg"].oy = @vsFp["bg"].src_rect.height/2
  3520. @vsFp["bg"].x = viewport.rect.width/2
  3521. @vsFp["bg"].y = viewport.rect.height/2
  3522. # "electricity" effect that scrolls horizontally behind the Pokemon
  3523. @vsFp["streak"] = ScrollingSprite.new(viewport)
  3524. @vsFp["streak"].setBitmap("Graphics/Transitions/vsLight3")
  3525. @vsFp["streak"].x = viewport.rect.width
  3526. @vsFp["streak"].y = viewport.rect.height/2
  3527. @vsFp["streak"].speed = 64
  3528. @vsFp["streak"].oy = @vsFp["streak"].bitmap.height/2
  3529. # initial particles
  3530. for j in 0...24
  3531. n = ["B","C"][rand(2)]
  3532. @vsFp["p#{j}"] = Sprite.new(viewport)
  3533. str = "Graphics/Transitions/speciesEff#{n}#{species}"
  3534. str = "Graphics/Transitions/speciesEff#{n}" if !pbResolveBitmap(str)
  3535. @vsFp["p#{j}"].bitmap = pbBitmap(str)
  3536. @vsFp["p#{j}"].ox = @vsFp["p#{j}"].bitmap.width/2
  3537. @vsFp["p#{j}"].oy = @vsFp["p#{j}"].bitmap.height/2
  3538. @vsFp["p#{j}"].x = viewport.rect.width + 48
  3539. y = viewport.rect.height*0.5*0.72 + rand(0.28*viewport.rect.height)
  3540. @vsFp["p#{j}"].y = y
  3541. @vsFp["p#{j}"].speed = rand(4) + 1
  3542. @vsFp["p#{j}"].z = 1 if rand(2)==0
  3543. end
  3544. # main Pokemon graphic
  3545. @vsFp["poke1"] = Sprite.new(viewport)
  3546. @vsFp["poke1"].bitmap = pbBitmap("Graphics/Transitions/species#{species}")
  3547. @vsFp["poke1"].ox = @vsFp["poke1"].bitmap.width/2
  3548. @vsFp["poke1"].oy = @vsFp["poke1"].bitmap.height*0.25
  3549. @vsFp["poke1"].x = viewport.rect.width/2
  3550. @vsFp["poke1"].y = viewport.rect.height/2
  3551. @vsFp["poke1"].glow(Color.new(101,136,194),35,false)
  3552. @vsFp["poke1"].src_rect.height = 0
  3553. @vsFp["poke1"].toggle = -1
  3554. @vsFp["poke2"] = Sprite.new(viewport)
  3555. @vsFp["poke2"].bitmap = pbBitmap("Graphics/Transitions/species#{species}")
  3556. @vsFp["poke2"].ox = @vsFp["poke2"].bitmap.width/2
  3557. @vsFp["poke2"].oy = @vsFp["poke2"].bitmap.height*0.25
  3558. @vsFp["poke2"].x = viewport.rect.width
  3559. @vsFp["poke2"].y = viewport.rect.height/2
  3560. @vsFp["poke2"].opacity = 0
  3561. # ring particles which zoom towards the center of viewport
  3562. for j in 0...3
  3563. @vsFp["ec#{j}"] = Sprite.new(viewport)
  3564. str = "Graphics/Transitions/speciesEffA#{species}"
  3565. str = "Graphics/Transitions/speciesEffA" if !pbResolveBitmap(str)
  3566. @vsFp["ec#{j}"].bitmap = pbBitmap(str)
  3567. @vsFp["ec#{j}"].ox = @vsFp["ec#{j}"].bitmap.width/2
  3568. @vsFp["ec#{j}"].oy = @vsFp["ec#{j}"].bitmap.height/2
  3569. @vsFp["ec#{j}"].x = viewport.rect.width/2
  3570. @vsFp["ec#{j}"].y = viewport.rect.height/2
  3571. @vsFp["ec#{j}"].zoom_x = 2
  3572. @vsFp["ec#{j}"].zoom_y = 2
  3573. @vsFp["ec#{j}"].opacity = 255
  3574. end
  3575. # starts the animation
  3576. for i in 0...64
  3577. @vsFp["streak"].x -= 64 if @vsFp["streak"].x > 0
  3578. @vsFp["streak"].update if @vsFp["streak"].x <= 0
  3579. @vsFp["streak"].opacity -= 16 if i >= 48
  3580. @vsFp["bar1"].zoom_y -= 0.02 if @vsFp["bar1"].zoom_y > 0.72
  3581. @vsFp["bar2"].zoom_y -= 0.02 if @vsFp["bar2"].zoom_y > 0.72
  3582. @vsFp["poke2"].opacity += 16
  3583. @vsFp["poke2"].x -= (@vsFp["poke2"].x - viewport.rect.width/2)*0.1
  3584. for j in 0...3
  3585. next if j > i/50
  3586. if @vsFp["ec#{j}"].zoom_x <= 0
  3587. @vsFp["ec#{j}"].zoom_x = 2
  3588. @vsFp["ec#{j}"].zoom_y = 2
  3589. @vsFp["ec#{j}"].opacity = 255
  3590. end
  3591. @vsFp["ec#{j}"].opacity -= 3
  3592. @vsFp["ec#{j}"].zoom_x -= 0.02
  3593. @vsFp["ec#{j}"].zoom_y -= 0.02
  3594. end
  3595. for j in 0...24
  3596. next if j > i/2
  3597. @vsFp["p#{j}"].x -= 32*@vsFp["p#{j}"].speed
  3598. end
  3599. @vsFp["bg"].angle += 1 if $PokemonSystem.screensize < 2
  3600. Graphics.update
  3601. end
  3602. # changes focus to Pokemon graphic
  3603. for i in 0...8
  3604. @vsFp["bar1"].zoom_y -= 0.72/8
  3605. @vsFp["bar2"].zoom_y -= 0.72/8
  3606. @vsFp["poke1"].y -= 8
  3607. @vsFp["poke2"].y -= 8
  3608. if i >= 4
  3609. viewport.color.alpha += 64
  3610. end
  3611. ebSpecialSpecies_update
  3612. Graphics.update
  3613. end
  3614. # flash and impact of screen
  3615. @vsFp["poke1"].oy = @vsFp["poke1"].bitmap.height/2
  3616. @vsFp["poke1"].y = viewport.rect.height/2
  3617. @vsFp["poke2"].oy = @vsFp["poke2"].bitmap.height/2
  3618. @vsFp["poke2"].y = viewport.rect.height/2
  3619. @vsFp["impact"] = Sprite.new(viewport)
  3620. @vsFp["impact"].bitmap = pbBitmap("Graphics/Pictures/impact")
  3621. @vsFp["impact"].ox = @vsFp["impact"].bitmap.width/2
  3622. @vsFp["impact"].oy = @vsFp["impact"].bitmap.height/2
  3623. @vsFp["impact"].x = viewport.rect.width/2
  3624. @vsFp["impact"].y = viewport.rect.height/2
  3625. @vsFp["impact"].z = 999
  3626. @vsFp["impact"].opacity = 0
  3627. pbPlayCry(species)
  3628. k = -1
  3629. # fades flash
  3630. for i in 0...32
  3631. viewport.color.alpha -= 16 if viewport.color.alpha > 0
  3632. @vsFp["bg"].y += k*4 if i < 16
  3633. @vsFp["poke2"].y += k*4 if i < 16
  3634. k *= -1 if i%2==0
  3635. @vsFp["impact"].opacity += (i < 24) ? 64 : -32
  3636. @vsFp["impact"].angle += 180 if i%4 == 0
  3637. @vsFp["impact"].mirror = !@vsFp["impact"].mirror if i%4 == 2
  3638. ebSpecialSpecies_update
  3639. Graphics.update
  3640. end
  3641. end
  3642. # called to end the sequence and dispose of sprites
  3643. def ebSpecialSpecies_end
  3644. bmp = Graphics.snap_to_bitmap
  3645. view = @vsFp["poke1"].viewport
  3646. pbDisposeSpriteHash(@vsFp)
  3647. @vsFp["ov1"] = Sprite.new(view)
  3648. @vsFp["ov1"].bitmap = bmp
  3649. @vsFp["ov1"].ox = bmp.width/2
  3650. @vsFp["ov1"].oy = bmp.height/2
  3651. @vsFp["ov1"].x = viewport.rect.width/2
  3652. @vsFp["ov1"].y = viewport.rect.height/2
  3653. @vsFp["ov2"] = Sprite.new(view)
  3654. @vsFp["ov2"].bitmap = bmp
  3655. @vsFp["ov2"].blur_sprite(3)
  3656. @vsFp["ov2"].ox = bmp.width/2
  3657. @vsFp["ov2"].oy = bmp.height/2
  3658. @vsFp["ov2"].x = viewport.rect.width/2
  3659. @vsFp["ov2"].y = viewport.rect.height/2
  3660. @vsFp["ov2"].opacity = 0
  3661. # final zooming transition
  3662. for i in 0...32
  3663. @vsFp["ov1"].zoom_x += 0.02
  3664. @vsFp["ov1"].zoom_y += 0.02
  3665. @vsFp["ov2"].zoom_x += 0.02
  3666. @vsFp["ov2"].zoom_y += 0.02
  3667. @vsFp["ov2"].opacity += 12
  3668. if i >= 16
  3669. @vsFp["ov2"].tone.red += 16
  3670. @vsFp["ov2"].tone.green += 16
  3671. @vsFp["ov2"].tone.blue += 16
  3672. end
  3673. Graphics.update
  3674. end
  3675. 8.times do; Graphics.update; end
  3676. @vsFp["ov1"].opacity = 0
  3677. $specialSpecies = false
  3678. @sprites["battlebox1"].appear
  3679. for i in 0...16
  3680. @vsFp["ov2"].opacity -= 16
  3681. if i < 10
  3682. if EBUISTYLE==2
  3683. @sprites["battlebox1"].show
  3684. elsif EBUISTYLE==0
  3685. @sprites["battlebox1"].update
  3686. else
  3687. @sprites["battlebox1"].x+=26
  3688. end
  3689. end
  3690. animateBattleSprites
  3691. Graphics.update
  3692. end
  3693. pbDisposeSpriteHash(@vsFp)
  3694. end
  3695.  
  3696. end
Advertisement
Add Comment
Please, Sign In to add comment