Nyaruko69

Untitled

Jul 3rd, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 114.18 KB | None | 0 0
  1. =begin
  2. - def pbChooseNewEnemy(index,party)
  3. Use this method to choose a new Pokémon for the enemy
  4. The enemy's party is guaranteed to have at least one
  5. choosable member.
  6. index - Index to the battler to be replaced (use e.g. @battle.battlers[index] to
  7. access the battler)
  8. party - Enemy's party
  9.  
  10. - def pbWildBattleSuccess
  11. This method is called when the player wins a wild Pokémon battle.
  12. This method can change the battle's music for example.
  13.  
  14. - def pbTrainerBattleSuccess
  15. This method is called when the player wins a Trainer battle.
  16. This method can change the battle's music for example.
  17.  
  18. - def pbFainted(pkmn)
  19. This method is called whenever a Pokémon faints.
  20. pkmn - PokeBattle_Battler object indicating the Pokémon that fainted
  21.  
  22. - def pbChooseEnemyCommand(index)
  23. Use this method to choose a command for the enemy.
  24. index - Index of enemy battler (use e.g. @battle.battlers[index] to
  25. access the battler)
  26.  
  27. - def pbCommandMenu(index)
  28. Use this method to display the list of commands and choose
  29. a command for the player.
  30. index - Index of battler (use e.g. @battle.battlers[index] to
  31. access the battler)
  32. Return values:
  33. 0 - Fight
  34. 1 - Pokémon
  35. 2 - Bag
  36. 3 - Run
  37. =end
  38.  
  39. #===============================================================================
  40. # Command menu (Fight/Pokémon/Bag/Run)
  41. #===============================================================================
  42. class CommandMenuDisplay
  43. attr_accessor :mode
  44.  
  45. def initialize(viewport=nil)
  46. @display=nil
  47. if PokeBattle_SceneConstants::USECOMMANDBOX
  48. @display=IconSprite.new(4,Graphics.height-88,viewport)
  49. @display.setBitmap("Graphics/Pictures/Battle/overlay_command")
  50. end
  51. @window=Window_CommandPokemon.newWithSize([],
  52. Graphics.width-240,Graphics.height-96,240,96,viewport)
  53. @window.columns=2
  54. @window.columnSpacing=1
  55. @window.ignore_input=true
  56. @msgbox=Window_UnformattedTextPokemon.newWithSize(
  57. "",16,Graphics.height-96+2,220,96,viewport)
  58. @msgbox.baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
  59. @msgbox.shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
  60. @msgbox.windowskin=nil
  61. @title=""
  62. @buttons=nil
  63. if PokeBattle_SceneConstants::USECOMMANDBOX
  64. @window.opacity=0
  65. @window.x=Graphics.width
  66. @buttons=CommandMenuButtons.new(self.index,self.mode,viewport)
  67. end
  68. end
  69.  
  70. def x; @window.x; end
  71. def x=(value)
  72. @window.x=value
  73. @msgbox.x=value
  74. @display.x=value if @display
  75. @buttons.x=value if @buttons
  76. end
  77.  
  78. def y; @window.y; end
  79. def y=(value)
  80. @window.y=value
  81. @msgbox.y=value
  82. @display.y=value if @display
  83. @buttons.y=value if @buttons
  84. end
  85.  
  86. def z; @window.z; end
  87. def z=(value)
  88. @window.z=value
  89. @msgbox.z=value
  90. @display.z=value if @display
  91. @buttons.z=value+1 if @buttons
  92. end
  93.  
  94. def ox; @window.ox; end
  95. def ox=(value)
  96. @window.ox=value
  97. @msgbox.ox=value
  98. @display.ox=value if @display
  99. @buttons.ox=value if @buttons
  100. end
  101.  
  102. def oy; @window.oy; end
  103. def oy=(value)
  104. @window.oy=value
  105. @msgbox.oy=value
  106. @display.oy=value if @display
  107. @buttons.oy=value if @buttons
  108. end
  109.  
  110. def visible; @window.visible; end
  111. def visible=(value)
  112. @window.visible=value
  113. @msgbox.visible=value
  114. @display.visible=value if @display
  115. @buttons.visible=value if @buttons
  116. end
  117.  
  118. def color; @window.color; end
  119. def color=(value)
  120. @window.color=value
  121. @msgbox.color=value
  122. @display.color=value if @display
  123. @buttons.color=value if @buttons
  124. end
  125.  
  126. def disposed?
  127. return @msgbox.disposed? || @window.disposed?
  128. end
  129.  
  130. def dispose
  131. return if disposed?
  132. @msgbox.dispose
  133. @window.dispose
  134. @display.dispose if @display
  135. @buttons.dispose if @buttons
  136. end
  137.  
  138. def index; @window.index; end
  139. def index=(value); @window.index=value; end
  140.  
  141. def setTexts(value)
  142. @msgbox.text=value[0]
  143. commands=[]
  144. for i in 1..4
  145. commands.push(value[i]) if value[i] && value[i]!=nil
  146. end
  147. @window.commands=commands
  148. end
  149.  
  150. def refresh
  151. @msgbox.refresh
  152. @window.refresh
  153. @buttons.refresh(self.index,self.mode) if @buttons
  154. end
  155.  
  156. def update
  157. @msgbox.update
  158. @window.update
  159. @display.update if @display
  160. @buttons.update(self.index,self.mode) if @buttons
  161. end
  162. end
  163.  
  164.  
  165.  
  166. class CommandMenuButtons < BitmapSprite
  167. def initialize(index=0,mode=0,viewport=nil)
  168. super(20,14,viewport)
  169. self.x=Graphics.width-164
  170. self.y=Graphics.height-70
  171. @mode=mode
  172. @buttonbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_command"))
  173. refresh(index,mode)
  174. end
  175.  
  176. def dispose
  177. @buttonbitmap.dispose
  178. super
  179. end
  180.  
  181. def update(index=0,mode=0)
  182. refresh(index,mode)
  183. end
  184.  
  185. def refresh(index,mode=0)
  186. self.bitmap.clear
  187. @mode=mode
  188. cmdarray=[0,2,1,3]
  189. case @mode
  190. when 1
  191. cmdarray=[0,2,1,4] # Use "Call"
  192. when 2
  193. cmdarray=[5,7,6,3] # Safari Zone battle
  194. when 3
  195. cmdarray=[0,8,1,3] # Bug Catching Contest
  196. end
  197. for i in 0...4
  198. next if i==index
  199. x=((i%2)==0) ? 0 : 20
  200. y=((i/2)==0) ? 0: 0
  201. self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(0,cmdarray[i]*14,10,14))
  202. end
  203. for i in 0...4
  204. next if i!=index
  205. x=((i%2)==0) ? 0 : 20
  206. y=((i/2)==0) ? 0 : 0
  207. self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(10,cmdarray[i]*14,10,14))
  208. end
  209. end
  210. end
  211.  
  212.  
  213.  
  214. #===============================================================================
  215. # Fight menu (choose a move)
  216. #===============================================================================
  217. class FightMenuDisplay
  218. attr_reader :battler
  219. attr_reader :index
  220. attr_accessor :megaButton
  221.  
  222. def initialize(battler,viewport=nil)
  223. @display=nil
  224. if PokeBattle_SceneConstants::USEFIGHTBOX
  225. @display=IconSprite.new(4,Graphics.height-152,viewport)
  226. @display.setBitmap("Graphics/Pictures/Battle/overlay_fight")
  227. end
  228. @window=Window_CommandPokemon.newWithSize([],0,Graphics.height-152,310,172,viewport)
  229.  
  230. @window.columns=1
  231. @window.columnSpacing=2
  232. @window.ignore_input=true
  233. pbSetNarrowFont(@window.contents)
  234. @info=Window_AdvancedTextPokemon.newWithSize(
  235. "",310,Graphics.height-152,Graphics.width-310,172,viewport)
  236. pbSetNarrowFont(@info.contents)
  237. @ctag=shadowctag(PokeBattle_SceneConstants::MENUBASECOLOR,
  238. PokeBattle_SceneConstants::MENUSHADOWCOLOR)
  239. @buttons=nil
  240. @battler=battler
  241. @index=0
  242. @megaButton=0 # 0=don't show, 1=show, 2=pressed
  243. if PokeBattle_SceneConstants::USEFIGHTBOX
  244. @window.opacity=0
  245. @window.x=Graphics.width
  246. @info.opacity=0
  247. @info.x=Graphics.width+Graphics.width-96
  248. @buttons=FightMenuButtons.new(self.index,nil,viewport)
  249. end
  250. refresh
  251. end
  252.  
  253. def x; @window.x; end
  254. def x=(value)
  255. @window.x=value
  256. @info.x=value
  257. @display.x=value if @display
  258. @buttons.x=value if @buttons
  259. end
  260.  
  261. def y; @window.y; end
  262. def y=(value)
  263. @window.y=value
  264. @info.y=value
  265. @display.y=value if @display
  266. @buttons.y=value if @buttons
  267. end
  268.  
  269. def z; @window.z; end
  270. def z=(value)
  271. @window.z=value
  272. @info.z=value
  273. @display.z=value if @display
  274. @buttons.z=value+1 if @buttons
  275. end
  276.  
  277. def ox; @window.ox; end
  278. def ox=(value)
  279. @window.ox=value
  280. @info.ox=value
  281. @display.ox=value if @display
  282. @buttons.ox=value if @buttons
  283. end
  284.  
  285. def oy; @window.oy; end
  286. def oy=(value)
  287. @window.oy=value
  288. @info.oy=value
  289. @display.oy=value if @display
  290. @buttons.oy=value if @buttons
  291. end
  292.  
  293. def visible; @window.visible; end
  294. def visible=(value)
  295. @window.visible=value
  296. @info.visible=value
  297. @display.visible=value if @display
  298. @buttons.visible=value if @buttons
  299. end
  300.  
  301. def color; @window.color; end
  302. def color=(value)
  303. @window.color=value
  304. @info.color=value
  305. @display.color=value if @display
  306. @buttons.color=value if @buttons
  307. end
  308.  
  309. def disposed?
  310. return @info.disposed? || @window.disposed?
  311. end
  312.  
  313. def dispose
  314. return if disposed?
  315. @info.dispose
  316. @display.dispose if @display
  317. @buttons.dispose if @buttons
  318. @window.dispose
  319. end
  320.  
  321. def battler=(value)
  322. @battler=value
  323. refresh
  324. end
  325.  
  326. def setIndex(value)
  327. if @battler && @battler.moves[value].id!=0
  328. @index=value
  329. @window.index=value
  330. refresh
  331. return true
  332. end
  333. return false
  334. end
  335.  
  336. def refresh
  337. return if !@battler
  338. commands=[]
  339. for i in 0...4
  340. break if @battler.moves[i].id==0
  341. commands.push(@battler.moves[i].name)
  342. end
  343. @window.commands=commands
  344. selmove=@battler.moves[@index]
  345. movetype=PBTypes.getName(selmove.type)
  346. if selmove.totalpp==0
  347. @info.text=_INTL("{1}PP: ---<br>TYPE/{2}",@ctag,movetype)
  348. else
  349. @info.text=_ISPRINTF("{1:s}PP: {2: 2d}/{3: 2d}<br>TYPE/{4:s}",
  350. @ctag,selmove.pp,selmove.totalpp,movetype)
  351. end
  352. @buttons.refresh(self.index,@battler ? @battler.moves : nil,@megaButton) if @buttons
  353. end
  354.  
  355. def update
  356. @info.update
  357. @window.update
  358. @display.update if @display
  359. if @buttons
  360. moves=@battler ? @battler.moves : nil
  361. @buttons.update(self.index,moves,@megaButton)
  362. end
  363. end
  364. end
  365.  
  366.  
  367.  
  368. class FightMenuButtons < BitmapSprite
  369. UPPERGAP=152
  370.  
  371. def initialize(index=0,moves=nil,viewport=nil)
  372. super(Graphics.width,172,viewport)
  373. @viewport2=Viewport.new(0,0,Graphics.width,Graphics.height)
  374. @viewport2.z=200005
  375. @bitpage=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2)
  376. self.x=30
  377. self.y=Graphics.height-14-UPPERGAP
  378. pbSetSmallFont(self.bitmap)
  379. pbSetSmallFont(@bitpage.bitmap)
  380.  
  381. @buttonbitmap=AnimatedBitmap.new("Graphics/Pictures/Battle/cursor_fight")
  382. @categorybitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/category"))
  383. @typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
  384. @megaevobitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_mega"))
  385. refresh(index,moves,0)
  386. end
  387.  
  388. def dispose
  389. @buttonbitmap.dispose
  390. @categorybitmap.dispose
  391. @typebitmap.dispose
  392. @megaevobitmap.dispose
  393. super
  394. end
  395.  
  396. def update(index=0,moves=nil,megaButton=0)
  397. refresh(index,moves,megaButton)
  398. end
  399.  
  400. def refresh(index,moves,megaButton)
  401. return if !moves
  402. self.bitmap.clear
  403. @bitpage.bitmap.clear
  404. textpos=[]
  405. textposi=[]
  406. for i in 0...4
  407. next if i==index
  408. next if moves[i].id==0
  409. x=20
  410. if i==0
  411. y= 18
  412. elsif i==1
  413. y= 36
  414. elsif i==2
  415. y= 54
  416. elsif i==3
  417. y= 72
  418. end
  419. y+=UPPERGAP
  420. self.bitmap.blt(x,y+2,@buttonbitmap.bitmap,Rect.new(0,moves[i].type*14,208,14))
  421. textpos.push([moves[i].name,x+28,y-88,0,
  422. PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
  423. end
  424. ppcolors=[
  425. PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
  426. PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
  427. PokeBattle_SceneConstants::PPTEXTBASECOLORYELLOW,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORYELLOW,
  428. PokeBattle_SceneConstants::PPTEXTBASECOLORORANGE,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORORANGE,
  429. PokeBattle_SceneConstants::PPTEXTBASECOLORRED,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORRED
  430. ]
  431. for i in 0...4
  432. next if i!=index
  433. next if moves[i].id==0
  434. x= 30
  435. if i==0
  436. y= 18
  437. elsif i==1
  438. y= 36
  439. elsif i==2
  440. y= 54
  441. elsif i==3
  442. y= 72
  443. end
  444. y+=UPPERGAP
  445. self.bitmap.blt(x+16,y-82,@buttonbitmap.bitmap,Rect.new(208,moves[i].type*14,208,14))
  446. self.bitmap.blt(0,38,@categorybitmap.bitmap,Rect.new(0,moves[i].category*16,48,16))
  447. self.bitmap.blt(60,38,@typebitmap.bitmap,Rect.new(0,moves[i].type*16,54,16))
  448. textpos.push([moves[i].name,x+28,y-88,0,
  449. PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
  450. if moves[i].totalpp>0
  451. ppfraction=(4.0*moves[i].pp/moves[i].totalpp).ceil
  452. textpos.push([_INTL("PP: {1}/{2}",moves[i].pp,moves[i].totalpp),
  453. 50,52,0,ppcolors[(4-ppfraction)*2],ppcolors[(4-ppfraction)*2+1]])
  454. end
  455. end
  456. pbDrawTextPositions(self.bitmap,textpos)
  457. #pbDrawTextPositions(@bitpage.bitmap,textposi)
  458. if megaButton>0
  459. self.bitmap.blt(146,0,@megaevobitmap.bitmap,Rect.new(0,(megaButton-1)*46,96,46))
  460. end
  461. end
  462. end
  463.  
  464.  
  465.  
  466. #===============================================================================
  467. # Data box for safari battles
  468. #===============================================================================
  469. class SafariDataBox < SpriteWrapper
  470. attr_accessor :selected
  471. attr_reader :appearing
  472.  
  473. def initialize(battle,viewport=nil)
  474. super(viewport)
  475. @selected = 0
  476. @battle = battle
  477. @databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_safari")
  478. @spriteX = PokeBattle_SceneConstants::SAFARIBOX_X
  479. @spriteY = PokeBattle_SceneConstants::SAFARIBOX_Y
  480. @appearing = false
  481. @contents = BitmapWrapper.new(@databox.width,@databox.height)
  482. self.bitmap = @contents
  483. self.visible = false
  484. self.z = 50
  485. pbSetSystemFont(self.bitmap)
  486. refresh
  487. end
  488.  
  489. def appear
  490. refresh
  491. self.visible = true
  492. self.opacity = 255
  493. self.x = @spriteX+240
  494. self.y = @spriteY
  495. @appearing = true
  496. end
  497.  
  498. def refresh
  499. self.bitmap.clear
  500. self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
  501. base = Color.new(72,72,72)
  502. shadow = Color.new(184,184,184)
  503. textpos = []
  504. textpos.push([_INTL("Safari Balls"),30,8,false,base,shadow])
  505. textpos.push([_INTL("Left: {1}",@battle.ballcount),30,38,false,base,shadow])
  506. pbDrawTextPositions(self.bitmap,textpos)
  507. self.bitmap.font.name="Pokémon GB Font [Extended]"
  508. self.bitmap.font.size=26
  509. end
  510.  
  511. def update
  512. super
  513. if @appearing
  514. self.x -= 12
  515. self.x = @spriteX if self.x<@spriteX
  516. @appearing = false if self.x<=@spriteX
  517. self.y = @spriteY
  518. return
  519. end
  520. self.x = @spriteX
  521. self.y = @spriteY
  522. end
  523. end
  524.  
  525.  
  526.  
  527. #===============================================================================
  528. # Data box for regular battles (both single and double)
  529. #===============================================================================
  530. class PokemonDataBox < SpriteWrapper
  531. attr_reader :battler
  532. attr_accessor :selected
  533. attr_accessor :appearing
  534. attr_reader :animatingHP
  535. attr_reader :animatingEXP
  536.  
  537. def initialize(battler,doublebattle,viewport=nil)
  538. super(viewport)
  539. @explevel = 0
  540. @battler = battler
  541. @selected = 0
  542. @frame = 0
  543. @showhp = false
  544. @showexp = false
  545. @appearing = false
  546. @animatingHP = false
  547. @starthp = 0
  548. @currenthp = 0
  549. @endhp = 0
  550. @expflash = 0
  551. @spritebaseX = ((@battler.index&1)==0) ? 34 : 16 # Player's/foe's
  552. if doublebattle
  553. case @battler.index
  554. when 0
  555. @databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_thin")
  556. @spriteX = PokeBattle_SceneConstants::PLAYERBOXD1_X
  557. @spriteY = PokeBattle_SceneConstants::PLAYERBOXD1_Y
  558. when 1
  559. @databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_thin_foe")
  560. @spriteX = PokeBattle_SceneConstants::FOEBOXD1_X
  561. @spriteY = PokeBattle_SceneConstants::FOEBOXD1_Y
  562. when 2
  563. @databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_thin")
  564. @spriteX = PokeBattle_SceneConstants::PLAYERBOXD2_X
  565. @spriteY = PokeBattle_SceneConstants::PLAYERBOXD2_Y
  566. when 3
  567. @databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_thin_foe")
  568. @spriteX = PokeBattle_SceneConstants::FOEBOXD2_X
  569. @spriteY = PokeBattle_SceneConstants::FOEBOXD2_Y
  570. end
  571. else
  572. case @battler.index
  573. when 0
  574. @databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_normal")
  575. @spriteX = PokeBattle_SceneConstants::PLAYERBOX_X
  576. @spriteY = PokeBattle_SceneConstants::PLAYERBOX_Y
  577. @showhp = true
  578. @showexp = true
  579. when 1
  580. @databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_normal_foe")
  581. @spriteX = PokeBattle_SceneConstants::FOEBOX_X
  582. @spriteY = PokeBattle_SceneConstants::FOEBOX_Y
  583. end
  584. end
  585. @statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/icon_statuses"))
  586. @hpbar = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_hp"))
  587. @expbar = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_exp"))
  588. @contents = BitmapWrapper.new(@databox.width,@databox.height)
  589. self.bitmap = @contents
  590. self.visible = false
  591. self.z = 50
  592. refreshExpLevel
  593. refresh
  594. end
  595.  
  596. def dispose
  597. @statuses.dispose
  598. @hpbar.dispose
  599. @expbar.dispose
  600. @databox.dispose
  601. @contents.dispose
  602. super
  603. end
  604.  
  605. def hp
  606. return (@animatingHP) ? @currenthp : @battler.hp
  607. end
  608.  
  609. def exp
  610. return (@animatingEXP) ? @currentexp : @explevel
  611. end
  612.  
  613. def animateHP(oldhp,newhp)
  614. @starthp = oldhp
  615. @currenthp = oldhp
  616. @endhp = newhp
  617. @animatingHP = true
  618. end
  619.  
  620. def animateEXP(oldexp,newexp)
  621. @currentexp = oldexp
  622. @endexp = newexp
  623. @animatingEXP = true
  624. end
  625.  
  626. def appear
  627. refreshExpLevel
  628. refresh
  629. self.visible = true
  630. self.opacity = 255
  631. self.x = ((@battler.index&1)==0) ? @spriteX+320 : @spriteX-320 # Player's/foe's
  632. self.y = @spriteY
  633. @appearing = true
  634. end
  635.  
  636. def refreshExpLevel
  637. if !@battler.pokemon
  638. @explevel = 0
  639. else
  640. growthrate = @battler.pokemon.growthrate
  641. startexp = PBExperience.pbGetStartExperience(@battler.pokemon.level,growthrate)
  642. endexp = PBExperience.pbGetStartExperience(@battler.pokemon.level+1,growthrate)
  643. if startexp==endexp
  644. @explevel = 0
  645. else
  646. @explevel = (@battler.pokemon.exp-startexp)*@expbar.bitmap.width/(endexp-startexp) #expbar.bitmap.width
  647. end
  648. end
  649. end
  650.  
  651. def refresh
  652. self.bitmap.clear
  653. return if !@battler.pokemon
  654. self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
  655. base = Color.new(0,0,0)
  656. shadow = Color.new(255,255,255)
  657. pbSetSystemFont(self.bitmap)
  658. textpos = []
  659. imagepos = []
  660. # Draw Pokémon's name
  661. textpos.push([@battler.name,@spritebaseX-16,-8,false,Color.new(0,0,0)]) #+5,-5
  662. # Draw Pokémon's gender symbol
  663. genderX = self.bitmap.text_size(@battler.name).height
  664. genderX += @spritebaseX+102
  665. case @battler.displayGender
  666. when 0 # Male
  667. textpos.push([_INTL("{"),genderX+0,10,false,Color.new(0,0,255)])
  668. when 1 # Female
  669. textpos.push([_INTL("}"),genderX+0,10,false,Color.new(255,0,0)])
  670. end
  671. pbDrawTextPositions(self.bitmap,textpos)
  672. self.bitmap.font.name="Pokémon GB Font [Extended]"
  673. self.bitmap.font.size=26
  674. # Draw Pokémon's level
  675. pbSetSmallFont(self.bitmap)
  676. #imagepos.push(["Graphics/Pictures/Battle/overlay_lv",
  677. # @spritebaseX+70-self.bitmap.text_size(@battler.level.to_s).width,18,0,0,-1,-1])
  678. textpos = [
  679. [_INTL(":L{1}",@battler.level),@spritebaseX+120,10,true,Color.new(0,0,0)]
  680. #[@battler.level.to_s,@spritebaseX+120,10,true,Color.new(0,0,0)]
  681. ]
  682. # Draw Pokémon's HP numbers
  683. if @showhp
  684. hpstring = _ISPRINTF("{1: 2d}/{2: 2d}",self.hp,@battler.totalhp)
  685. textpos.push([hpstring,@spritebaseX+100,43,true,Color.new(0,0,0)])
  686. end
  687. pbDrawTextPositions(self.bitmap,textpos)
  688. self.bitmap.font.name="Pokémon GB Font [Extended]"
  689. self.bitmap.font.size=26
  690. # Draw shiny icon
  691. if @battler.isShiny?
  692. shinyX = ((@battler.index&1)==0) ? -6 : 206 # Player's/foe's
  693. imagepos.push(["Graphics/Pictures/shiny",@spritebaseX+shinyX,36,0,0,-1,-1])
  694. end
  695. # Draw Mega Evolution/Primal Reversion icon
  696. if @battler.isMega?
  697. imagepos.push(["Graphics/Pictures/Battle/icon_mega",@spritebaseX+8,34,0,0,-1,-1])
  698. elsif @battler.isPrimal?
  699. if isConst?(@battler.pokemon.species,PBSpecies,:KYOGRE)
  700. imagepos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre",@spritebaseX+140,4,0,0,-1,-1])
  701. elsif isConst?(@battler.pokemon.species,PBSpecies,:GROUDON)
  702. imagepos.push(["Graphics/Pictures/Battle/icon_primal_Groudon",@spritebaseX+140,4,0,0,-1,-1])
  703. end
  704. end
  705. # Draw owned icon (foe Pokémon only)
  706. if @battler.owned && (@battler.index&1)==1
  707. imagepos.push(["Graphics/Pictures/Battle/icon_own",@spritebaseX+140,33,0,0,-1,-1])
  708. end
  709. # Draw status icon
  710. if @battler.status>0
  711. iconheight = 16
  712. self.bitmap.blt(@spritebaseX-3,16,@statuses.bitmap,
  713. Rect.new(0,(@battler.status-1)*iconheight,@statuses.bitmap.width,iconheight))
  714. end
  715. # Draw HP bar
  716. hpgauge = (@battler.totalhp==0) ? 0 : self.hp*@hpbar.bitmap.width/@battler.totalhp
  717. hpgauge = 2 if hpgauge<2 && self.hp>0
  718. hpzone = 0
  719. hpzone = 1 if self.hp<=(@battler.totalhp/2).floor
  720. hpzone = 2 if self.hp<=(@battler.totalhp/4).floor
  721. if @animatingHP && self.hp>0 # fill with black (shows what the HP used to be)
  722. self.bitmap.fill_rect(@spritebaseX+30,35,
  723. @starthp*@hpbar.bitmap.width/@battler.totalhp,@hpbar.bitmap.height/3,Color.new(0,0,0))
  724. end
  725. self.bitmap.blt(@spritebaseX+30,35,@hpbar.bitmap,
  726. Rect.new(0,hpzone*@hpbar.bitmap.height/3,hpgauge,@hpbar.bitmap.height/3))
  727. # Draw Exp bar
  728. if @showexp
  729. self.bitmap.blt(@spritebaseX-18,70,@expbar.bitmap,
  730. Rect.new(0,0,self.exp,@expbar.bitmap.height))
  731. end
  732. pbDrawImagePositions(self.bitmap,imagepos)
  733. end
  734.  
  735. def update
  736. super
  737. @frame += 1
  738. # Animate HP bar
  739. if @animatingHP
  740. if @currenthp<@endhp
  741. @currenthp += [0.3,(@battler.totalhp/96).floor].max
  742. @currenthp = @endhp if @currenthp>@endhp
  743. elsif @currenthp>@endhp
  744. @currenthp -= [0.3,(@battler.totalhp/96).floor].max
  745. @currenthp = @endhp if @currenthp<@endhp
  746. end
  747. @animatingHP = false if @currenthp==@endhp
  748. refresh
  749. end
  750. # Animate Exp bar
  751. if @animatingEXP
  752. if !@showexp
  753. @currentexp = @endexp
  754. elsif @currentexp<@endexp # Gaining Exp
  755. if @endexp>=144 ||
  756. @endexp-@currentexp>=144/4
  757. @currentexp += 0.8
  758. else
  759. @currentexp += 0.8
  760. end
  761. @currentexp = @endexp if @currentexp>@endexp
  762. elsif @currentexp>@endexp # Losing Exp
  763. if @endexp==0 ||
  764. @currentexp-@endexp>=144/4
  765. @currentexp -= 0.8
  766. elsif @currentexp>@endexp
  767. @currentexp -= 0.8
  768. end
  769. @currentexp = @endexp if @currentexp<@endexp
  770. end
  771. refresh
  772. if @currentexp==@endexp
  773. if @currentexp==144
  774. if @expflash==0
  775. pbSEPlay("expfull")
  776. self.flash(Color.new(64,200,248),8)
  777. @expflash = 8
  778. else
  779. @expflash -= 1
  780. if @expflash==0
  781. @animatingEXP = false
  782. refreshExpLevel
  783. end
  784. end
  785. else
  786. @animatingEXP = false
  787. end
  788. end
  789. end
  790. # Move data box onto the screen
  791. if @appearing
  792. if (@battler.index&1)==0 # if player's Pokémon
  793. self.x -= 12
  794. self.x = @spriteX if self.x<@spriteX
  795. @appearing = false if self.x<=@spriteX
  796. else
  797. self.x += 12
  798. self.x = @spriteX if self.x>@spriteX
  799. @appearing = false if self.x>=@spriteX
  800. end
  801. self.y = @spriteY
  802. return
  803. end
  804. self.x = @spriteX
  805. self.y = @spriteY
  806. # Data box bobbing while Pokémon is selected
  807. #if @selected==1 || @selected==2 # Choosing commands/targeted or damaged
  808. # if (@frame/6).floor==1
  809. # self.y = @spriteY-2
  810. #elsif (@frame/6).floor==3
  811. # self.y = @spriteY+2
  812. #end
  813. #end
  814. end
  815. end
  816.  
  817.  
  818. #===============================================================================
  819. # Shows the enemy trainer(s)'s Pokémon being thrown out. It appears at coords
  820. # (@spritex,@spritey), and moves in y to @endspritey where it stays for the rest
  821. # of the battle, i.e. the latter is the more important value.
  822. # Doesn't show the ball itself being thrown.
  823. #===============================================================================
  824. class PokeballSendOutAnimation
  825. SPRITESTEPS=10
  826. STARTZOOM=0.125
  827.  
  828. def initialize(sprite,spritehash,pkmn,illusionpoke,doublebattle)
  829. @illusionpoke=illusionpoke
  830. @disposed=false
  831. @ballused=pkmn.pokemon ? pkmn.pokemon.ballused : 0
  832. if @illusionpoke
  833. @ballused=@illusionpoke.ballused || 0
  834. end
  835. @PokemonBattlerSprite=sprite
  836. @PokemonBattlerSprite.visible=false
  837. @PokemonBattlerSprite.tone=Tone.new(248,248,248,248)
  838. @pokeballsprite=IconSprite.new(0,0,sprite.viewport)
  839. @pokeballsprite.setBitmap(sprintf("Graphics/Pictures/Battle/ball_%02d",@ballused))
  840. if doublebattle
  841. @spritex=PokeBattle_SceneConstants::FOEBATTLERD1_X if pkmn.index==1
  842. @spritex=PokeBattle_SceneConstants::FOEBATTLERD2_X if pkmn.index==3
  843. else
  844. @spritex=PokeBattle_SceneConstants::FOEBATTLER_X
  845. end
  846. @spritey=0
  847. if @illusionpoke
  848. @endspritey=adjustBattleSpriteY(sprite,@illusionpoke.species,pkmn.index)
  849. else
  850. @endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)
  851. end
  852. if doublebattle
  853. @spritey=PokeBattle_SceneConstants::FOEBATTLERD1_Y if pkmn.index==1
  854. @spritey=PokeBattle_SceneConstants::FOEBATTLERD2_Y if pkmn.index==3
  855. @endspritey+=PokeBattle_SceneConstants::FOEBATTLERD1_Y if pkmn.index==1
  856. @endspritey+=PokeBattle_SceneConstants::FOEBATTLERD2_Y if pkmn.index==3
  857. else
  858. @spritey=PokeBattle_SceneConstants::FOEBATTLER_Y
  859. @endspritey+=PokeBattle_SceneConstants::FOEBATTLER_Y
  860. end
  861. @spritehash=spritehash
  862. @pokeballsprite.x=@spritex-@pokeballsprite.bitmap.width/2
  863. @pokeballsprite.y=@spritey-@pokeballsprite.bitmap.height/2-4
  864. @pokeballsprite.z=@PokemonBattlerSprite.z+1
  865. @pkmn=pkmn
  866. @shadowX=@spritex
  867. @shadowY=@spritey
  868. if @spritehash["shadow#{@pkmn.index}"] && @spritehash["shadow#{@pkmn.index}"].bitmap!=nil
  869. @shadowX-=@spritehash["shadow#{@pkmn.index}"].bitmap.width/2
  870. @shadowY-=@spritehash["shadow#{@pkmn.index}"].bitmap.height/2
  871. end
  872. @shadowVisible=showShadow?(pkmn.species)
  873. if @illusionpoke
  874. @shadowVisible=showShadow?(@illusionpoke.species)
  875. end
  876. @stepspritey=(@spritey-@endspritey)
  877. @zoomstep=(1.0-STARTZOOM)/SPRITESTEPS
  878. @animdone=false
  879. @frame=0
  880. end
  881.  
  882. def disposed?
  883. return @disposed
  884. end
  885.  
  886. def animdone?
  887. return @animdone
  888. end
  889.  
  890. def dispose
  891. return if disposed?
  892. @pokeballsprite.dispose
  893. @disposed=true
  894. end
  895.  
  896. def update
  897. return if disposed?
  898. @pokeballsprite.update
  899. @frame+=1
  900. if @frame==2
  901. pbSEPlay("Battle recall")
  902. end
  903. if @frame==4
  904. @PokemonBattlerSprite.visible=true
  905. @PokemonBattlerSprite.zoom_x=STARTZOOM
  906. @PokemonBattlerSprite.zoom_y=STARTZOOM
  907. pbSpriteSetCenter(@PokemonBattlerSprite,@spritex,@spritey)
  908. if @illusionpoke
  909. pbPlayCry(@illusionpoke)
  910. else
  911. if @pkmn.pokemon
  912. pbPlayCry(@pkmn.pokemon)
  913. else
  914. pbPlayCrySpecies(@pkmn.species,@pkmn.form)
  915. end
  916. end
  917. @pokeballsprite.setBitmap(sprintf("Graphics/Pictures/Battle/ball_%02d_open",@ballused))
  918. end
  919. if @frame==8
  920. @pokeballsprite.visible=false
  921. end
  922. if @frame>8 && @frame<=16
  923. color=Color.new(248,248,248,256-(16-@frame)*32)
  924. @spritehash["enemybase"].color=color
  925. @spritehash["playerbase"].color=color
  926. @spritehash["battlebg"].color=color
  927. for i in 0...4
  928. @spritehash["shadow#{i}"].color=color if @spritehash["shadow#{i}"]
  929. end
  930. end
  931. if @frame>16 && @frame<=24
  932. color=Color.new(248,248,248,(24-@frame)*32)
  933. tone=(24-@frame)*32
  934. @PokemonBattlerSprite.tone=Tone.new(tone,tone,tone,tone)
  935. @spritehash["enemybase"].color=color
  936. @spritehash["playerbase"].color=color
  937. @spritehash["battlebg"].color=color
  938. for i in 0...4
  939. @spritehash["shadow#{i}"].color=color if @spritehash["shadow#{i}"]
  940. end
  941. end
  942. if @frame>5 && @PokemonBattlerSprite.zoom_x<1.0
  943. @PokemonBattlerSprite.zoom_x+=@zoomstep
  944. @PokemonBattlerSprite.zoom_y+=@zoomstep
  945. @PokemonBattlerSprite.zoom_x=1.0 if @PokemonBattlerSprite.zoom_x > 1.0
  946. @PokemonBattlerSprite.zoom_y=1.0 if @PokemonBattlerSprite.zoom_y > 1.0
  947. currentY=@spritey-(@stepspritey*@PokemonBattlerSprite.zoom_y)
  948. pbSpriteSetCenter(@PokemonBattlerSprite,@spritex,currentY)
  949. @PokemonBattlerSprite.y=currentY
  950. end
  951. if @PokemonBattlerSprite.tone.gray<=0 && @PokemonBattlerSprite.zoom_x>=1.0
  952. @animdone=true
  953. if @spritehash["shadow#{@pkmn.index}"]
  954. @spritehash["shadow#{@pkmn.index}"].x=@shadowX
  955. @spritehash["shadow#{@pkmn.index}"].y=@shadowY
  956. @spritehash["shadow#{@pkmn.index}"].visible=@shadowVisible
  957. end
  958. end
  959. end
  960. end
  961.  
  962.  
  963.  
  964. #===============================================================================
  965. # Shows the player's (or partner's) Pokémon being thrown out. It appears at
  966. # (@spritex,@spritey), and moves in y to @endspritey where it stays for the rest
  967. # of the battle, i.e. the latter is the more important value.
  968. # Doesn't show the ball itself being thrown.
  969. #===============================================================================
  970. class PokeballPlayerSendOutAnimation
  971. # Ball curve: 8,52; 22,44; 52, 96
  972. # Player: Color.new(16*8,23*8,30*8)
  973. SPRITESTEPS=10
  974. STARTZOOM=0.125
  975.  
  976. def initialize(sprite,spritehash,pkmn,illusionpoke,doublebattle)
  977. @illusionpoke=illusionpoke
  978. @disposed=false
  979. @PokemonBattlerSprite=sprite
  980. @pkmn=pkmn
  981. @PokemonBattlerSprite.visible=false
  982. @PokemonBattlerSprite.tone=Tone.new(248,248,248,248)
  983. @spritehash=spritehash
  984. if doublebattle
  985. @spritex=PokeBattle_SceneConstants::PLAYERBATTLERD1_X if pkmn.index==0
  986. @spritex=PokeBattle_SceneConstants::PLAYERBATTLERD2_X if pkmn.index==2
  987. else
  988. @spritex=PokeBattle_SceneConstants::PLAYERBATTLER_X
  989. end
  990. @spritey=0
  991. if @illusionpoke
  992. @endspritey=adjustBattleSpriteY(sprite,@illusionpoke.species,pkmn.index)
  993. else
  994. @endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)
  995. end
  996. if doublebattle
  997. @spritey+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if pkmn.index==0
  998. @spritey+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if pkmn.index==2
  999. @endspritey+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if pkmn.index==0
  1000. @endspritey+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if pkmn.index==2
  1001. else
  1002. @spritey+=PokeBattle_SceneConstants::PLAYERBATTLER_Y
  1003. @endspritey+=PokeBattle_SceneConstants::PLAYERBATTLER_Y
  1004. end
  1005. @animdone=false
  1006. @frame=0
  1007. end
  1008.  
  1009. def disposed?
  1010. return @disposed
  1011. end
  1012.  
  1013. def animdone?
  1014. return @animdone
  1015. end
  1016.  
  1017. def dispose
  1018. return if disposed?
  1019. @disposed=true
  1020. end
  1021.  
  1022. def update
  1023. return if disposed?
  1024. @frame+=1
  1025. if @frame==4
  1026. @PokemonBattlerSprite.visible=true
  1027. @PokemonBattlerSprite.zoom_x=STARTZOOM
  1028. @PokemonBattlerSprite.zoom_y=STARTZOOM
  1029. pbSEPlay("Battle recall")
  1030. pbSpriteSetCenter(@PokemonBattlerSprite,@spritex,@spritey)
  1031. if @illusionpoke
  1032. pbPlayCry(@illusionpoke)
  1033. else
  1034. if @pkmn.pokemon
  1035. pbPlayCry(@pkmn.pokemon)
  1036. else
  1037. pbPlayCrySpecies(@pkmn.species,@pkmn.form)
  1038. end
  1039. end
  1040. end
  1041. if @frame>8 && @frame<=16
  1042. color=Color.new(248,248,248,256-(16-@frame)*32)
  1043. @spritehash["enemybase"].color=color
  1044. @spritehash["playerbase"].color=color
  1045. @spritehash["battlebg"].color=color
  1046. for i in 0...4
  1047. @spritehash["shadow#{i}"].color=color if @spritehash["shadow#{i}"]
  1048. end
  1049. end
  1050. if @frame>16 && @frame<=24
  1051. color=Color.new(248,248,248,(24-@frame)*32)
  1052. tone=(24-@frame)*32
  1053. @PokemonBattlerSprite.tone=Tone.new(tone,tone,tone,tone)
  1054. @spritehash["enemybase"].color=color
  1055. @spritehash["playerbase"].color=color
  1056. @spritehash["battlebg"].color=color
  1057. for i in 0...4
  1058. @spritehash["shadow#{i}"].color=color if @spritehash["shadow#{i}"]
  1059. end
  1060. end
  1061. if @frame>5 && @PokemonBattlerSprite.zoom_x<1.0
  1062. @PokemonBattlerSprite.zoom_x+=0.1
  1063. @PokemonBattlerSprite.zoom_y+=0.1
  1064. @PokemonBattlerSprite.zoom_x=1.0 if @PokemonBattlerSprite.zoom_x > 1.0
  1065. @PokemonBattlerSprite.zoom_y=1.0 if @PokemonBattlerSprite.zoom_y > 1.0
  1066. pbSpriteSetCenter(@PokemonBattlerSprite,@spritex,0)
  1067. @PokemonBattlerSprite.y=@spritey+(@endspritey-@spritey)*@PokemonBattlerSprite.zoom_y
  1068. end
  1069. if @PokemonBattlerSprite.tone.gray<=0 && @PokemonBattlerSprite.zoom_x>=1.0
  1070. @animdone=true
  1071. end
  1072. end
  1073. end
  1074.  
  1075.  
  1076.  
  1077. #===============================================================================
  1078. # Shows the enemy trainer(s) and the enemy party lineup sliding off screen.
  1079. # Doesn't show the ball thrown or the Pokémon.
  1080. #===============================================================================
  1081. class TrainerFadeAnimation
  1082. def initialize(sprites)
  1083. @frame=0
  1084. @sprites=sprites
  1085. @animdone=false
  1086. end
  1087.  
  1088. def animdone?
  1089. return @animdone
  1090. end
  1091.  
  1092. def update
  1093. return if @animdone
  1094. @frame+=1
  1095. @sprites["trainer"].x+=8
  1096. @sprites["trainer2"].x+=8 if @sprites["trainer2"]
  1097. @sprites["partybarfoe"].x+=8
  1098. @sprites["partybarfoe"].opacity-=12
  1099. for i in 0...6
  1100. @sprites["enemy#{i}"].opacity-=12
  1101. @sprites["enemy#{i}"].x+=8 if @frame>=i*4
  1102. end
  1103. @animdone=true if @sprites["trainer"].x>=Graphics.width &&
  1104. (!@sprites["trainer2"] || @sprites["trainer2"].x>=Graphics.width)
  1105. end
  1106. end
  1107.  
  1108.  
  1109.  
  1110. #===============================================================================
  1111. # Shows the player (and partner) and the player party lineup sliding off screen.
  1112. # Shows the player's/partner's throwing animation (if they have one).
  1113. # Doesn't show the ball thrown or the Pokémon.
  1114. #===============================================================================
  1115. class PlayerFadeAnimation
  1116. def initialize(sprites)
  1117. @frame=0
  1118. @sprites=sprites
  1119. @animdone=false
  1120. end
  1121.  
  1122. def animdone?
  1123. return @animdone
  1124. end
  1125.  
  1126. def update
  1127. return if @animdone
  1128. @frame+=1
  1129. @sprites["player"].x-=8
  1130. @sprites["playerB"].x-=8 if @sprites["playerB"]
  1131. @sprites["partybarplayer"].x-=8
  1132. @sprites["partybarplayer"].opacity-=12
  1133. for i in 0...6
  1134. if @sprites["player#{i}"]
  1135. @sprites["player#{i}"].opacity-=12
  1136. @sprites["player#{i}"].x-=8 if @frame>=i*4
  1137. end
  1138. end
  1139. pa=@sprites["player"]
  1140. pb=@sprites["playerB"]
  1141. pawidth=128
  1142. pbwidth=128
  1143. if (pa && pa.bitmap && !pa.bitmap.disposed?)
  1144. if pa.bitmap.height<pa.bitmap.width
  1145. numframes=pa.bitmap.width/pa.bitmap.height # Number of frames
  1146. pawidth=pa.bitmap.width/numframes # Width per frame
  1147. @sprites["player"].src_rect.x=pawidth*1 if @frame>0
  1148. @sprites["player"].src_rect.x=pawidth*2 if @frame>8
  1149. @sprites["player"].src_rect.x=pawidth*3 if @frame>12
  1150. @sprites["player"].src_rect.x=pawidth*4 if @frame>16
  1151. @sprites["player"].src_rect.width=pawidth
  1152. else
  1153. pawidth=pa.bitmap.width
  1154. @sprites["player"].src_rect.x=0
  1155. @sprites["player"].src_rect.width=pawidth
  1156. end
  1157. end
  1158. if (pb && pb.bitmap && !pb.bitmap.disposed?)
  1159. if pb.bitmap.height<pb.bitmap.width
  1160. numframes=pb.bitmap.width/pb.bitmap.height # Number of frames
  1161. pbwidth=pb.bitmap.width/numframes # Width per frame
  1162. @sprites["playerB"].src_rect.x=pbwidth*1 if @frame>0
  1163. @sprites["playerB"].src_rect.x=pbwidth*2 if @frame>8
  1164. @sprites["playerB"].src_rect.x=pbwidth*3 if @frame>12
  1165. @sprites["playerB"].src_rect.x=pbwidth*4 if @frame>16
  1166. @sprites["playerB"].src_rect.width=pbwidth
  1167. else
  1168. pbwidth=pb.bitmap.width
  1169. @sprites["playerB"].src_rect.x=0
  1170. @sprites["playerB"].src_rect.width=pbwidth
  1171. end
  1172. end
  1173. if pb
  1174. @animdone=true if pb.x<=-pbwidth
  1175. else
  1176. @animdone=true if pa.x<=-pawidth
  1177. end
  1178. end
  1179. end
  1180.  
  1181.  
  1182.  
  1183. #===============================================================================
  1184. # Shows the player's Poké Ball being thrown to capture a Pokémon.
  1185. #===============================================================================
  1186. def pokeballThrow(ball,shakes,critical,targetBattler,scene,battler,burst=-1,showplayer=false)
  1187. balltype=pbGetBallType(ball)
  1188. animtrainer=false
  1189. if showplayer && @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
  1190. animtrainer=true
  1191. end
  1192. oldvisible=@sprites["shadow#{targetBattler}"].visible
  1193. @sprites["shadow#{targetBattler}"].visible=false
  1194. ball=sprintf("Graphics/Pictures/Battle/ball_%02d",balltype)
  1195. ballopen=sprintf("Graphics/Pictures/Battle/ball_%02d_open",balltype)
  1196. # sprites
  1197. spritePoke=@sprites["pokemon#{targetBattler}"]
  1198. spriteBall=IconSprite.new(0,0,@viewport)
  1199. spriteBall.visible=false
  1200. spritePlayer=@sprites["player"] if animtrainer
  1201. # pictures
  1202. pictureBall=PictureEx.new(spritePoke.z+1)
  1203. picturePoke=PictureEx.new(spritePoke.z)
  1204. dims=[spritePoke.x,spritePoke.y]
  1205. center=getSpriteCenter(@sprites["pokemon#{targetBattler}"])
  1206. if @battle.doublebattle
  1207. ballendy=PokeBattle_SceneConstants::FOEBATTLERD1_Y-4 if targetBattler==1
  1208. ballendy=PokeBattle_SceneConstants::FOEBATTLERD2_Y-4 if targetBattler==3
  1209. else
  1210. ballendy=PokeBattle_SceneConstants::FOEBATTLER_Y-4
  1211. end
  1212. if animtrainer
  1213. picturePlayer=PictureEx.new(spritePoke.z+2)
  1214. playerpos=[@sprites["player"].x,@sprites["player"].y]
  1215. end
  1216. # starting positions
  1217. pictureBall.moveVisible(1,true)
  1218. pictureBall.moveName(1,ball)
  1219. pictureBall.moveOrigin(1,PictureOrigin::Center)
  1220. if animtrainer
  1221. pictureBall.moveXY(0,1,64,256)
  1222. else
  1223. pictureBall.moveXY(0,1,10,180)
  1224. end
  1225. picturePoke.moveVisible(1,true)
  1226. picturePoke.moveOrigin(1,PictureOrigin::Center)
  1227. picturePoke.moveXY(0,1,center[0],center[1])
  1228. if animtrainer
  1229. picturePlayer.moveVisible(1,true)
  1230. picturePlayer.moveName(1,spritePlayer.name)
  1231. picturePlayer.moveOrigin(1,PictureOrigin::TopLeft)
  1232. picturePlayer.moveXY(0,1,playerpos[0],playerpos[1])
  1233. end
  1234. # directives
  1235. picturePoke.moveSE(1,"Audio/SE/Battle throw")
  1236. if animtrainer
  1237. pictureBall.moveCurve(30,1,64,256,30+Graphics.width/2,10,center[0],center[1])
  1238. pictureBall.moveAngle(30,1,-720)
  1239. else
  1240. pictureBall.moveCurve(30,1,150,70,30+Graphics.width/2,10,center[0],center[1])
  1241. pictureBall.moveAngle(30,1,-1080)
  1242. end
  1243. pictureBall.moveAngle(0,pictureBall.totalDuration,0)
  1244. delay=pictureBall.totalDuration+4
  1245. picturePoke.moveTone(10,delay,Tone.new(0,-224,-224,0))
  1246. delay=picturePoke.totalDuration
  1247. picturePoke.moveSE(delay,"Audio/SE/Battle recall")
  1248. pictureBall.moveName(delay+4,ballopen)
  1249. if animtrainer
  1250. picturePlayer.moveSrc(1,@sprites["player"].bitmap.height,0)
  1251. picturePlayer.moveXY(0,1,playerpos[0]-14,playerpos[1])
  1252. picturePlayer.moveSrc(4,@sprites["player"].bitmap.height*2,0)
  1253. picturePlayer.moveXY(0,4,playerpos[0]-12,playerpos[1])
  1254. picturePlayer.moveSrc(8,@sprites["player"].bitmap.height*3,0)
  1255. picturePlayer.moveXY(0,8,playerpos[0]+20,playerpos[1])
  1256. picturePlayer.moveSrc(16,@sprites["player"].bitmap.height*4,0)
  1257. picturePlayer.moveXY(0,16,playerpos[0]+16,playerpos[1])
  1258. picturePlayer.moveSrc(40,0,0)
  1259. picturePlayer.moveXY(0,40,playerpos[0],playerpos[1])
  1260. end
  1261. loop do
  1262. pictureBall.update
  1263. picturePoke.update
  1264. picturePlayer.update if animtrainer
  1265. setPictureIconSprite(spriteBall,pictureBall)
  1266. setPictureSprite(spritePoke,picturePoke)
  1267. setPictureIconSprite(spritePlayer,picturePlayer) if animtrainer
  1268. pbGraphicsUpdate
  1269. pbInputUpdate
  1270. pbFrameUpdate
  1271. break if !pictureBall.running? && !picturePoke.running?
  1272. end
  1273. # Burst animation here
  1274. if burst>=0 && scene.battle.battlescene
  1275. scene.pbCommonAnimation("BallBurst#{burst}",battler,nil)
  1276. end
  1277. pictureBall.clearProcesses
  1278. picturePoke.clearProcesses
  1279. delay=0
  1280. picturePoke.moveZoom(15,delay,0)
  1281. picturePoke.moveXY(15,delay,center[0],center[1])
  1282. picturePoke.moveSE(delay+10,"Audio/SE/Battle jump to ball")
  1283. picturePoke.moveVisible(delay+15,false)
  1284. pictureBall.moveName(picturePoke.totalDuration+2,ball)
  1285. delay=pictureBall.totalDuration+6
  1286. if critical
  1287. pictureBall.moveSE(delay,"Audio/SE/Battle ball shake")
  1288. pictureBall.moveXY(2,delay,center[0]+4,center[1])
  1289. pictureBall.moveXY(4,pictureBall.totalDuration,center[0]-4,center[1])
  1290. pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/Battle ball shake")
  1291. pictureBall.moveXY(4,pictureBall.totalDuration,center[0]+4,center[1])
  1292. pictureBall.moveXY(4,pictureBall.totalDuration,center[0]-4,center[1])
  1293. pictureBall.moveXY(2,pictureBall.totalDuration,center[0],center[1])
  1294. delay=pictureBall.totalDuration+4
  1295. end
  1296. pictureBall.moveXY(10,delay,center[0],ballendy)
  1297. pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/Battle ball drop")
  1298. pictureBall.moveXY(5,pictureBall.totalDuration+2,center[0],ballendy-((ballendy-center[1])/2))
  1299. pictureBall.moveXY(5,pictureBall.totalDuration+2,center[0],ballendy)
  1300. pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/Battle ball drop")
  1301. pictureBall.moveXY(3,pictureBall.totalDuration+2,center[0],ballendy-((ballendy-center[1])/4))
  1302. pictureBall.moveXY(3,pictureBall.totalDuration+2,center[0],ballendy)
  1303. pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/Battle ball drop")
  1304. pictureBall.moveXY(1,pictureBall.totalDuration+2,center[0],ballendy-((ballendy-center[1])/8))
  1305. pictureBall.moveXY(1,pictureBall.totalDuration+2,center[0],ballendy)
  1306. pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/Battle ball drop")
  1307. picturePoke.moveXY(0,pictureBall.totalDuration,center[0],ballendy)
  1308. delay=pictureBall.totalDuration+18# if shakes==0
  1309. numshakes = (critical) ? 1 : [shakes,3].min
  1310. numshakes.times do
  1311. pictureBall.moveSE(delay,"Audio/SE/Battle ball shake")
  1312. pictureBall.moveXY(3,delay,center[0]-8,ballendy)
  1313. pictureBall.moveAngle(3,delay,20) # positive means counterclockwise
  1314. delay=pictureBall.totalDuration
  1315. pictureBall.moveXY(6,delay,center[0]+8,ballendy)
  1316. pictureBall.moveAngle(6,delay,-20) # negative means clockwise
  1317. delay=pictureBall.totalDuration
  1318. pictureBall.moveXY(3,delay,center[0],ballendy)
  1319. pictureBall.moveAngle(3,delay,0)
  1320. delay=pictureBall.totalDuration+18
  1321. end
  1322. if shakes<4
  1323. picturePoke.moveSE(delay,"Audio/SE/Battle recall")
  1324. pictureBall.moveName(delay,ballopen)
  1325. pictureBall.moveVisible(delay+10,false)
  1326. picturePoke.moveVisible(delay,true)
  1327. picturePoke.moveZoom(15,delay,100)
  1328. picturePoke.moveXY(15,delay,center[0],center[1])
  1329. picturePoke.moveTone(0,delay,Tone.new(248,248,248,248))
  1330. picturePoke.moveTone(24,delay,Tone.new(0,0,0,0))
  1331. delay=picturePoke.totalDuration
  1332. end
  1333. pictureBall.moveXY(0,delay,center[0],ballendy)
  1334. picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
  1335. picturePoke.moveXY(0,picturePoke.totalDuration,dims[0],dims[1])
  1336. loop do
  1337. pictureBall.update
  1338. picturePoke.update
  1339. setPictureIconSprite(spriteBall,pictureBall)
  1340. setPictureSprite(spritePoke,picturePoke)
  1341. pbGraphicsUpdate
  1342. pbInputUpdate
  1343. pbFrameUpdate
  1344. break if !pictureBall.running? && !picturePoke.running?
  1345. end
  1346. if shakes<4
  1347. @sprites["shadow#{targetBattler}"].visible=oldvisible
  1348. spriteBall.dispose
  1349. else
  1350. spriteBall.tone=Tone.new(-64,-64,-64,128)
  1351. pbSEPlay("Battle ball drop",100,150)
  1352. @sprites["capture"]=spriteBall
  1353. spritePoke.visible=false
  1354. end
  1355. end
  1356.  
  1357.  
  1358.  
  1359. #===============================================================================
  1360. # Battle scene (the visuals of the battle)
  1361. #===============================================================================
  1362. class PokeBattle_Scene
  1363. attr_accessor :abortable
  1364. attr_reader :viewport
  1365. attr_reader :sprites
  1366. BLANK = 0
  1367. MESSAGEBOX = 1
  1368. COMMANDBOX = 2
  1369. FIGHTBOX = 3
  1370.  
  1371. def initialize
  1372. @battle=nil
  1373. @lastcmd=[0,0,0,0]
  1374. @lastmove=[0,0,0,0]
  1375. @pkmnwindows=[nil,nil,nil,nil]
  1376. @sprites={}
  1377. @battlestart=true
  1378. @messagemode=false
  1379. @abortable=false
  1380. @aborted=false
  1381. end
  1382.  
  1383. def pbUpdate
  1384. partyAnimationUpdate
  1385. @sprites["battlebg"].update if @sprites["battlebg"].respond_to?("update")
  1386. end
  1387.  
  1388. def pbGraphicsUpdate
  1389. partyAnimationUpdate
  1390. @sprites["battlebg"].update if @sprites["battlebg"].respond_to?("update")
  1391. Graphics.update
  1392. end
  1393.  
  1394. def pbInputUpdate
  1395. Input.update
  1396. if Input.trigger?(Input::B) && @abortable && !@aborted
  1397. @aborted=true
  1398. @battle.pbAbort
  1399. end
  1400. end
  1401.  
  1402. def pbShowWindow(windowtype)
  1403. @sprites["messagebox"].visible = (windowtype==MESSAGEBOX ||
  1404. windowtype==COMMANDBOX ||
  1405. windowtype==FIGHTBOX ||
  1406. windowtype==BLANK )
  1407. @sprites["messagewindow"].visible = (windowtype==MESSAGEBOX)
  1408. @sprites["commandwindow"].visible = (windowtype==COMMANDBOX)
  1409. @sprites["fightwindow"].visible = (windowtype==FIGHTBOX)
  1410. end
  1411.  
  1412. def pbSetMessageMode(mode)
  1413. @messagemode=mode
  1414. msgwindow=@sprites["messagewindow"]
  1415. if mode # Within Pokémon command
  1416. msgwindow.baseColor=PokeBattle_SceneConstants::MENUBASECOLOR
  1417. msgwindow.shadowColor=PokeBattle_SceneConstants::MENUSHADOWCOLOR
  1418. msgwindow.opacity=255
  1419. msgwindow.x=16
  1420. msgwindow.width=Graphics.width
  1421. msgwindow.height=96
  1422. msgwindow.y=Graphics.height-msgwindow.height+2
  1423. else
  1424. msgwindow.baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
  1425. msgwindow.shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
  1426. msgwindow.opacity=0
  1427. msgwindow.x=16
  1428. msgwindow.width=Graphics.width-32
  1429. msgwindow.height=96
  1430. msgwindow.y=Graphics.height-msgwindow.height+2
  1431. end
  1432. end
  1433.  
  1434. def pbWaitMessage
  1435. if @briefmessage
  1436. pbShowWindow(MESSAGEBOX)
  1437. cw=@sprites["messagewindow"]
  1438. 40.times do
  1439. pbGraphicsUpdate
  1440. pbInputUpdate
  1441. pbFrameUpdate(cw)
  1442. end
  1443. cw.text=""
  1444. cw.visible=false
  1445. @briefmessage=false
  1446. end
  1447. end
  1448.  
  1449. def pbDisplay(msg,brief=false)
  1450. pbDisplayMessage(msg,brief)
  1451. end
  1452.  
  1453. def pbDisplayMessage(msg,brief=false)
  1454. pbWaitMessage
  1455. pbRefresh
  1456. pbShowWindow(MESSAGEBOX)
  1457. cw=@sprites["messagewindow"]
  1458. cw.text=msg
  1459. i=0
  1460. loop do
  1461. pbGraphicsUpdate
  1462. pbInputUpdate
  1463. pbFrameUpdate(cw)
  1464. if i==40
  1465. cw.text=""
  1466. cw.visible=false
  1467. return
  1468. end
  1469. if Input.trigger?(Input::C) || @abortable
  1470. if cw.pausing?
  1471. pbPlayDecisionSE() if !@abortable
  1472. cw.resume
  1473. end
  1474. end
  1475. if !cw.busy?
  1476. if brief
  1477. @briefmessage=true
  1478. return
  1479. end
  1480. i+=1
  1481. end
  1482. end
  1483. end
  1484.  
  1485. def pbDisplayPausedMessage(msg)
  1486. pbWaitMessage
  1487. pbRefresh
  1488. pbShowWindow(MESSAGEBOX)
  1489. if @messagemode
  1490. @switchscreen.pbDisplay(msg)
  1491. return
  1492. end
  1493. cw=@sprites["messagewindow"]
  1494. cw.text=_INTL("{1}\1",msg)
  1495. loop do
  1496. pbGraphicsUpdate
  1497. pbInputUpdate
  1498. pbFrameUpdate(cw)
  1499. if Input.trigger?(Input::C) || @abortable
  1500. if cw.busy?
  1501. pbPlayDecisionSE() if cw.pausing? && !@abortable
  1502. cw.resume
  1503. elsif !inPartyAnimation?
  1504. cw.text=""
  1505. pbPlayDecisionSE()
  1506. cw.visible=false if @messagemode
  1507. return
  1508. end
  1509. end
  1510. cw.update
  1511. end
  1512. end
  1513.  
  1514. def pbDisplayConfirmMessage(msg)
  1515. return pbShowCommands(msg,[_INTL("YES"),_INTL("NO")],1)==0
  1516. end
  1517.  
  1518. def pbShowCommands(msg,commands,defaultValue)
  1519. pbWaitMessage
  1520. pbRefresh
  1521. pbShowWindow(MESSAGEBOX)
  1522. dw=@sprites["messagewindow"]
  1523. dw.text=msg
  1524. cw = Window_CommandPokemon.new(commands)
  1525. cw.x=Graphics.width-cw.width
  1526. cw.y=Graphics.height-cw.height-dw.height
  1527. cw.index=0
  1528. cw.viewport=@viewport
  1529. pbRefresh
  1530. loop do
  1531. cw.visible=!dw.busy?
  1532. pbGraphicsUpdate
  1533. pbInputUpdate
  1534. pbFrameUpdate(cw)
  1535. dw.update
  1536. if Input.trigger?(Input::B) && defaultValue>=0
  1537. if dw.busy?
  1538. pbPlayDecisionSE() if dw.pausing?
  1539. dw.resume
  1540. else
  1541. cw.dispose
  1542. dw.text=""
  1543. return defaultValue
  1544. end
  1545. end
  1546. if Input.trigger?(Input::C)
  1547. if dw.busy?
  1548. pbPlayDecisionSE() if dw.pausing?
  1549. dw.resume
  1550. else
  1551. cw.dispose
  1552. dw.text=""
  1553. return cw.index
  1554. end
  1555. end
  1556. end
  1557. end
  1558.  
  1559. def pbFrameUpdate(cw=nil)
  1560. cw.update if cw
  1561. for i in 0...4
  1562. if @sprites["battlebox#{i}"]
  1563. @sprites["battlebox#{i}"].update
  1564. end
  1565. if @sprites["pokemon#{i}"]
  1566. @sprites["pokemon#{i}"].update
  1567. end
  1568. end
  1569. end
  1570.  
  1571. def pbRefresh
  1572. for i in 0...4
  1573. if @sprites["battlebox#{i}"]
  1574. @sprites["battlebox#{i}"].refresh
  1575. end
  1576. end
  1577. end
  1578.  
  1579. def pbAddSprite(id,x,y,filename,viewport)
  1580. sprite=IconSprite.new(x,y,viewport)
  1581. if filename
  1582. sprite.setBitmap(filename) rescue nil
  1583. end
  1584. @sprites[id]=sprite
  1585. return sprite
  1586. end
  1587.  
  1588. def pbAddPlane(id,filename,viewport)
  1589. sprite=AnimatedPlane.new(viewport)
  1590. if filename
  1591. sprite.setBitmap(filename)
  1592. end
  1593. @sprites[id]=sprite
  1594. return sprite
  1595. end
  1596.  
  1597. def pbDisposeSprites
  1598. pbDisposeSpriteHash(@sprites)
  1599. end
  1600.  
  1601. def pbBeginCommandPhase
  1602. # Called whenever a new round begins.
  1603. @battlestart=false
  1604. end
  1605.  
  1606. def pbShowOpponent(index)
  1607. if @battle.opponent
  1608. if @battle.opponent.is_a?(Array)
  1609. trainerfile=pbTrainerSpriteFile(@battle.opponent[index].trainertype)
  1610. else
  1611. trainerfile=pbTrainerSpriteFile(@battle.opponent.trainertype)
  1612. end
  1613. else
  1614. trainerfile="Graphics/Characters/trfront"
  1615. end
  1616. pbAddSprite("trainer",Graphics.width,PokeBattle_SceneConstants::FOETRAINER_Y,
  1617. trainerfile,@viewport)
  1618. if @sprites["trainer"].bitmap
  1619. @sprites["trainer"].y-=@sprites["trainer"].bitmap.height
  1620. @sprites["trainer"].z=8
  1621. end
  1622. 20.times do
  1623. pbGraphicsUpdate
  1624. pbInputUpdate
  1625. pbFrameUpdate
  1626. @sprites["trainer"].x-=6
  1627. end
  1628. end
  1629.  
  1630. def pbHideOpponent
  1631. 20.times do
  1632. pbGraphicsUpdate
  1633. pbInputUpdate
  1634. pbFrameUpdate
  1635. @sprites["trainer"].x+=6
  1636. end
  1637. end
  1638.  
  1639. def pbShowHelp(text)
  1640. @sprites["helpwindow"].resizeToFit(text,Graphics.width)
  1641. @sprites["helpwindow"].y=0
  1642. @sprites["helpwindow"].x=0
  1643. @sprites["helpwindow"].text=text
  1644. @sprites["helpwindow"].visible=true
  1645. end
  1646.  
  1647. def pbHideHelp
  1648. @sprites["helpwindow"].visible=false
  1649. end
  1650.  
  1651. def pbBackdrop
  1652. environ=@battle.environment
  1653. # Choose backdrop
  1654. backdrop="Field"
  1655. if environ==PBEnvironment::Cave
  1656. backdrop="Cave"
  1657. elsif environ==PBEnvironment::MovingWater || environ==PBEnvironment::StillWater
  1658. backdrop="Water"
  1659. elsif environ==PBEnvironment::Underwater
  1660. backdrop="Underwater"
  1661. elsif environ==PBEnvironment::Rock
  1662. backdrop="Mountain"
  1663. else
  1664. if !$game_map || !pbGetMetadata($game_map.map_id,MetadataOutdoor)
  1665. backdrop="IndoorA"
  1666. end
  1667. end
  1668. if $game_map
  1669. back=pbGetMetadata($game_map.map_id,MetadataBattleBack)
  1670. if back && back!=""
  1671. backdrop=back
  1672. end
  1673. end
  1674. if $PokemonGlobal && $PokemonGlobal.nextBattleBack
  1675. backdrop=$PokemonGlobal.nextBattleBack
  1676. end
  1677. # Choose bases
  1678. base=""
  1679. trialname=""
  1680. if environ==PBEnvironment::Grass || environ==PBEnvironment::TallGrass
  1681. trialname="Grass"
  1682. elsif environ==PBEnvironment::Sand
  1683. trialname="Sand"
  1684. elsif $PokemonGlobal.surfing
  1685. trialname="Water"
  1686. end
  1687. if pbResolveBitmap(sprintf("Graphics/Battlebacks/playerbase"+backdrop+trialname))
  1688. base=trialname
  1689. end
  1690. # Choose time of day
  1691. time=""
  1692. if ENABLESHADING
  1693. trialname=""
  1694. timenow=pbGetTimeNow
  1695. if PBDayNight.isNight?(timenow)
  1696. trialname="Night"
  1697. elsif PBDayNight.isEvening?(timenow)
  1698. trialname="Eve"
  1699. end
  1700. if pbResolveBitmap(sprintf("Graphics/Battlebacks/battlebg"+backdrop+trialname))
  1701. time=trialname
  1702. end
  1703. end
  1704. # Apply graphics
  1705. battlebg="Graphics/Battlebacks/battlebg"+backdrop+time
  1706. enemybase="Graphics/Battlebacks/enemybase"+backdrop+base+time
  1707. playerbase="Graphics/Battlebacks/playerbase"+backdrop+base+time
  1708. pbAddPlane("battlebg",battlebg,@viewport)
  1709. pbAddSprite("playerbase",
  1710. PokeBattle_SceneConstants::PLAYERBASEX,
  1711. PokeBattle_SceneConstants::PLAYERBASEY,playerbase,@viewport)
  1712. @sprites["playerbase"].x-=@sprites["playerbase"].bitmap.width/2 if @sprites["playerbase"].bitmap!=nil
  1713. @sprites["playerbase"].y-=@sprites["playerbase"].bitmap.height if @sprites["playerbase"].bitmap!=nil
  1714. pbAddSprite("enemybase",
  1715. PokeBattle_SceneConstants::FOEBASEX,
  1716. PokeBattle_SceneConstants::FOEBASEY,enemybase,@viewport)
  1717. @sprites["enemybase"].x-=@sprites["enemybase"].bitmap.width/2 if @sprites["enemybase"].bitmap!=nil
  1718. @sprites["enemybase"].y-=@sprites["enemybase"].bitmap.height/2 if @sprites["enemybase"].bitmap!=nil
  1719. @sprites["battlebg"].z=0
  1720. @sprites["playerbase"].z=1
  1721. @sprites["enemybase"].z=1
  1722. end
  1723.  
  1724. # Returns whether the party line-ups are currently appearing on-screen
  1725. def inPartyAnimation?
  1726. return @enablePartyAnim && @partyAnimPhase<3
  1727. end
  1728.  
  1729. # Shows the party line-ups appearing on-screen
  1730. def partyAnimationUpdate
  1731. return if !inPartyAnimation?
  1732. ballmovedist=16 # How far a ball moves each frame
  1733. # Bar slides on
  1734. if @partyAnimPhase==0
  1735. @sprites["partybarfoe"].x+=16
  1736. @sprites["partybarplayer"].x-=16
  1737. if @sprites["partybarfoe"].x+@sprites["partybarfoe"].bitmap.width>=PokeBattle_SceneConstants::FOEPARTYBAR_X
  1738. @sprites["partybarfoe"].x=PokeBattle_SceneConstants::FOEPARTYBAR_X-@sprites["partybarfoe"].bitmap.width
  1739. @sprites["partybarplayer"].x=PokeBattle_SceneConstants::PLAYERPARTYBAR_X
  1740. @partyAnimPhase=1
  1741. end
  1742. return
  1743. end
  1744. # Set up all balls ready to slide on
  1745. if @partyAnimPhase==1
  1746. @xposplayer=PokeBattle_SceneConstants::PLAYERPARTYBALL1_X
  1747. counter=0
  1748. # Make sure the ball starts off-screen
  1749. while @xposplayer<Graphics.width
  1750. counter+=1; @xposplayer+=ballmovedist
  1751. end
  1752. @xposenemy=PokeBattle_SceneConstants::FOEPARTYBALL1_X-counter*ballmovedist
  1753. for i in 0...6
  1754. # Choose the ball's graphic (player's side)
  1755. ballgraphic="Graphics/Pictures/Battle/icon_ball_empty"
  1756. if i<@battle.party1.length && @battle.party1[i]
  1757. if @battle.party1[i].hp<=0 || @battle.party1[i].egg?
  1758. ballgraphic="Graphics/Pictures/Battle/icon_ball_faint"
  1759. elsif @battle.party1[i].status>0
  1760. ballgraphic="Graphics/Pictures/Battle/icon_ball_status"
  1761. else
  1762. ballgraphic="Graphics/Pictures/Battle/icon_ball"
  1763. end
  1764. end
  1765. pbAddSprite("player#{i}",
  1766. @xposplayer+i*ballmovedist*6,PokeBattle_SceneConstants::PLAYERPARTYBALL1_Y,
  1767. ballgraphic,@viewport)
  1768. @sprites["player#{i}"].z=41
  1769. # Choose the ball's graphic (opponent's side)
  1770. ballgraphic="Graphics/Pictures/Battle/icon_ball_empty"
  1771. enemyindex=i
  1772. if @battle.doublebattle && i>=3
  1773. enemyindex=(i%3)+@battle.pbSecondPartyBegin(1)
  1774. end
  1775. if enemyindex<@battle.party2.length && @battle.party2[enemyindex]
  1776. if @battle.party2[enemyindex].hp<=0 || @battle.party2[enemyindex].egg?
  1777. ballgraphic="Graphics/Pictures/Battle/icon_ball_faint"
  1778. elsif @battle.party2[enemyindex].status>0
  1779. ballgraphic="Graphics/Pictures/Battle/icon_ball_status"
  1780. else
  1781. ballgraphic="Graphics/Pictures/Battle/icon_ball"
  1782. end
  1783. end
  1784. pbAddSprite("enemy#{i}",
  1785. @xposenemy-i*ballmovedist*6,PokeBattle_SceneConstants::FOEPARTYBALL1_Y,
  1786. ballgraphic,@viewport)
  1787. @sprites["enemy#{i}"].z=41
  1788. end
  1789. @partyAnimPhase=2
  1790. end
  1791. # Balls slide on
  1792. if @partyAnimPhase==2
  1793. for i in 0...6
  1794. if @sprites["enemy#{i}"].x<PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
  1795. @sprites["enemy#{i}"].x+=ballmovedist
  1796. @sprites["player#{i}"].x-=ballmovedist
  1797. if @sprites["enemy#{i}"].x>=PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
  1798. @sprites["enemy#{i}"].x=PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
  1799. @sprites["player#{i}"].x=PokeBattle_SceneConstants::PLAYERPARTYBALL1_X+i*PokeBattle_SceneConstants::PLAYERPARTYBALL_GAP
  1800. if i==5
  1801. @partyAnimPhase=3
  1802. end
  1803. end
  1804. end
  1805. end
  1806. end
  1807. end
  1808.  
  1809. def pbStartBattle(battle)
  1810. # Called whenever the battle begins
  1811. @battle=battle
  1812. @lastcmd=[0,0,0,0]
  1813. @lastmove=[0,0,0,0]
  1814. @showingplayer=true
  1815. @showingenemy=true
  1816. @sprites.clear
  1817. @viewport=Viewport.new(0,Graphics.height/2,Graphics.width,0)
  1818. @viewport.z=99999
  1819. @traineryoffset=(Graphics.height-320) # Adjust player's side for screen size
  1820. @foeyoffset=(@traineryoffset*3/4).floor # Adjust foe's side for screen size
  1821. pbBackdrop
  1822. pbAddSprite("partybarfoe",
  1823. PokeBattle_SceneConstants::FOEPARTYBAR_X,
  1824. PokeBattle_SceneConstants::FOEPARTYBAR_Y,
  1825. "Graphics/Pictures/Battle/overlay_lineup",@viewport)
  1826. pbAddSprite("partybarplayer",
  1827. PokeBattle_SceneConstants::PLAYERPARTYBAR_X,
  1828. PokeBattle_SceneConstants::PLAYERPARTYBAR_Y,
  1829. "Graphics/Pictures/Battle/overlay_lineup",@viewport)
  1830. @sprites["partybarfoe"].x-=@sprites["partybarfoe"].bitmap.width
  1831. @sprites["partybarplayer"].mirror=true
  1832. @sprites["partybarfoe"].z=40
  1833. @sprites["partybarplayer"].z=40
  1834. @sprites["partybarfoe"].visible=false
  1835. @sprites["partybarplayer"].visible=false
  1836. if @battle.player.is_a?(Array)
  1837. trainerfile=pbPlayerSpriteBackFile(@battle.player[0].trainertype)
  1838. pbAddSprite("player",
  1839. PokeBattle_SceneConstants::PLAYERTRAINERD1_X,
  1840. PokeBattle_SceneConstants::PLAYERTRAINERD1_Y,trainerfile,@viewport)
  1841. trainerfile=pbTrainerSpriteBackFile(@battle.player[1].trainertype)
  1842. pbAddSprite("playerB",
  1843. PokeBattle_SceneConstants::PLAYERTRAINERD2_X,
  1844. PokeBattle_SceneConstants::PLAYERTRAINERD2_Y,trainerfile,@viewport)
  1845. if @sprites["player"].bitmap
  1846. if @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
  1847. @sprites["player"].src_rect.x=0
  1848. @sprites["player"].src_rect.width=@sprites["player"].bitmap.width/5
  1849. end
  1850. @sprites["player"].x-=(@sprites["player"].src_rect.width/2)
  1851. @sprites["player"].y-=@sprites["player"].bitmap.height
  1852. @sprites["player"].z=30
  1853. end
  1854. if @sprites["playerB"].bitmap
  1855. if @sprites["playerB"].bitmap.width>@sprites["playerB"].bitmap.height
  1856. @sprites["playerB"].src_rect.x=0
  1857. @sprites["playerB"].src_rect.width=@sprites["playerB"].bitmap.width/5
  1858. end
  1859. @sprites["playerB"].x-=(@sprites["playerB"].src_rect.width/2)
  1860. @sprites["playerB"].y-=@sprites["playerB"].bitmap.height
  1861. @sprites["playerB"].z=31
  1862. end
  1863. else
  1864. trainerfile=pbPlayerSpriteBackFile(@battle.player.trainertype)
  1865. pbAddSprite("player",
  1866. PokeBattle_SceneConstants::PLAYERTRAINER_X,
  1867. PokeBattle_SceneConstants::PLAYERTRAINER_Y,trainerfile,@viewport)
  1868. if @sprites["player"].bitmap
  1869. if @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
  1870. @sprites["player"].src_rect.x=0
  1871. @sprites["player"].src_rect.width=@sprites["player"].bitmap.width/5
  1872. end
  1873. @sprites["player"].x-=(@sprites["player"].src_rect.width/2)
  1874. @sprites["player"].y-=@sprites["player"].bitmap.height
  1875. @sprites["player"].z=30
  1876. end
  1877. end
  1878. if @battle.opponent
  1879. if @battle.opponent.is_a?(Array)
  1880. trainerfile=pbTrainerSpriteFile(@battle.opponent[1].trainertype)
  1881. pbAddSprite("trainer2",
  1882. PokeBattle_SceneConstants::FOETRAINERD2_X,
  1883. PokeBattle_SceneConstants::FOETRAINERD2_Y,trainerfile,@viewport)
  1884. trainerfile=pbTrainerSpriteFile(@battle.opponent[0].trainertype)
  1885. pbAddSprite("trainer",
  1886. PokeBattle_SceneConstants::FOETRAINERD1_X,
  1887. PokeBattle_SceneConstants::FOETRAINERD1_Y,trainerfile,@viewport)
  1888. else
  1889. trainerfile=pbTrainerSpriteFile(@battle.opponent.trainertype)
  1890. pbAddSprite("trainer",
  1891. PokeBattle_SceneConstants::FOETRAINER_X,
  1892. PokeBattle_SceneConstants::FOETRAINER_Y,trainerfile,@viewport)
  1893. end
  1894. else
  1895. trainerfile="Graphics/Characters/trfront"
  1896. pbAddSprite("trainer",
  1897. PokeBattle_SceneConstants::FOETRAINER_X,
  1898. PokeBattle_SceneConstants::FOETRAINER_Y,trainerfile,@viewport)
  1899. end
  1900. if @sprites["trainer"].bitmap
  1901. @sprites["trainer"].x-=(@sprites["trainer"].bitmap.width/2)
  1902. @sprites["trainer"].y-=@sprites["trainer"].bitmap.height
  1903. @sprites["trainer"].z=8
  1904. end
  1905. if @sprites["trainer2"] && @sprites["trainer2"].bitmap
  1906. @sprites["trainer2"].x-=(@sprites["trainer2"].bitmap.width/2)
  1907. @sprites["trainer2"].y-=@sprites["trainer2"].bitmap.height
  1908. @sprites["trainer2"].z=7
  1909. end
  1910. @sprites["shadow0"]=IconSprite.new(0,0,@viewport)
  1911. @sprites["shadow0"].z=3
  1912. pbAddSprite("shadow1",0,0,"Graphics/Pictures/Battle/object_shadow",@viewport)
  1913. @sprites["shadow1"].z=3
  1914. @sprites["shadow1"].visible=false
  1915. @sprites["pokemon0"]=PokemonBattlerSprite.new(battle.doublebattle,0,@viewport)
  1916. @sprites["pokemon0"].z=21
  1917. @sprites["pokemon1"]=PokemonBattlerSprite.new(battle.doublebattle,1,@viewport)
  1918. @sprites["pokemon1"].z=16
  1919. if battle.doublebattle
  1920. @sprites["shadow2"]=IconSprite.new(0,0,@viewport)
  1921. @sprites["shadow2"].z=3
  1922. pbAddSprite("shadow3",0,0,"Graphics/Pictures/Battle/object_shadow",@viewport)
  1923. @sprites["shadow3"].z=3
  1924. @sprites["shadow3"].visible=false
  1925. @sprites["pokemon2"]=PokemonBattlerSprite.new(battle.doublebattle,2,@viewport)
  1926. @sprites["pokemon2"].z=26
  1927. @sprites["pokemon3"]=PokemonBattlerSprite.new(battle.doublebattle,3,@viewport)
  1928. @sprites["pokemon3"].z=11
  1929. end
  1930. @sprites["battlebox0"]=PokemonDataBox.new(battle.battlers[0],battle.doublebattle,@viewport)
  1931. @sprites["battlebox1"]=PokemonDataBox.new(battle.battlers[1],battle.doublebattle,@viewport)
  1932. if battle.doublebattle
  1933. @sprites["battlebox2"]=PokemonDataBox.new(battle.battlers[2],battle.doublebattle,@viewport)
  1934. @sprites["battlebox3"]=PokemonDataBox.new(battle.battlers[3],battle.doublebattle,@viewport)
  1935. end
  1936. pbAddSprite("messagebox",4,Graphics.height-88,"Graphics/Pictures/Battle/overlay_message",@viewport)
  1937. @sprites["messagebox"].z=90
  1938. @sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
  1939. @sprites["helpwindow"].visible=false
  1940. @sprites["helpwindow"].z=90
  1941. @sprites["messagewindow"]=Window_AdvancedTextPokemon.new("")
  1942. @sprites["messagewindow"].letterbyletter=true
  1943. @sprites["messagewindow"].viewport=@viewport
  1944. @sprites["messagewindow"].z=100
  1945. @sprites["commandwindow"]=CommandMenuDisplay.new(@viewport)
  1946. @sprites["commandwindow"].z=100
  1947. @sprites["fightwindow"]=FightMenuDisplay.new(nil,@viewport)
  1948. @sprites["fightwindow"].z=100
  1949. pbShowWindow(MESSAGEBOX)
  1950. pbSetMessageMode(false)
  1951. trainersprite1=@sprites["trainer"]
  1952. trainersprite2=@sprites["trainer2"]
  1953. if !@battle.opponent
  1954. @sprites["trainer"].visible=false
  1955. if @battle.party2.length>=1
  1956. if @battle.party2.length==1
  1957. species=@battle.party2[0].species
  1958. @sprites["pokemon1"].setPokemonBitmap(@battle.party2[0],false)
  1959. @sprites["pokemon1"].tone=Tone.new(-128,-128,-128,-128)
  1960. @sprites["pokemon1"].x=PokeBattle_SceneConstants::FOEBATTLER_X
  1961. @sprites["pokemon1"].x-=@sprites["pokemon1"].width/2
  1962. @sprites["pokemon1"].y=PokeBattle_SceneConstants::FOEBATTLER_Y
  1963. @sprites["pokemon1"].y+=adjustBattleSpriteY(@sprites["pokemon1"],species,1)
  1964. @sprites["pokemon1"].visible=true
  1965. @sprites["shadow1"].x=PokeBattle_SceneConstants::FOEBATTLER_X
  1966. @sprites["shadow1"].y=PokeBattle_SceneConstants::FOEBATTLER_Y
  1967. @sprites["shadow1"].x-=@sprites["shadow1"].bitmap.width/2 if @sprites["shadow1"].bitmap!=nil
  1968. @sprites["shadow1"].y-=@sprites["shadow1"].bitmap.height/2 if @sprites["shadow1"].bitmap!=nil
  1969. @sprites["shadow1"].visible=showShadow?(species)
  1970. trainersprite1=@sprites["pokemon1"]
  1971. elsif @battle.party2.length==2
  1972. species=@battle.party2[0].species
  1973. @sprites["pokemon1"].setPokemonBitmap(@battle.party2[0],false)
  1974. @sprites["pokemon1"].tone=Tone.new(-128,-128,-128,-128)
  1975. @sprites["pokemon1"].x=PokeBattle_SceneConstants::FOEBATTLERD1_X
  1976. @sprites["pokemon1"].x-=@sprites["pokemon1"].width/2
  1977. @sprites["pokemon1"].y=PokeBattle_SceneConstants::FOEBATTLERD1_Y
  1978. @sprites["pokemon1"].y+=adjustBattleSpriteY(@sprites["pokemon1"],species,1)
  1979. @sprites["pokemon1"].visible=true
  1980. @sprites["shadow1"].x=PokeBattle_SceneConstants::FOEBATTLERD1_X
  1981. @sprites["shadow1"].y=PokeBattle_SceneConstants::FOEBATTLERD1_Y
  1982. @sprites["shadow1"].x-=@sprites["shadow1"].bitmap.width/2 if @sprites["shadow1"].bitmap!=nil
  1983. @sprites["shadow1"].y-=@sprites["shadow1"].bitmap.height/2 if @sprites["shadow1"].bitmap!=nil
  1984. @sprites["shadow1"].visible=showShadow?(species)
  1985. trainersprite1=@sprites["pokemon1"]
  1986. species=@battle.party2[1].species
  1987. @sprites["pokemon3"].setPokemonBitmap(@battle.party2[1],false)
  1988. @sprites["pokemon3"].tone=Tone.new(-128,-128,-128,-128)
  1989. @sprites["pokemon3"].x=PokeBattle_SceneConstants::FOEBATTLERD2_X
  1990. @sprites["pokemon3"].x-=@sprites["pokemon3"].width/2
  1991. @sprites["pokemon3"].y=PokeBattle_SceneConstants::FOEBATTLERD2_Y
  1992. @sprites["pokemon3"].y+=adjustBattleSpriteY(@sprites["pokemon3"],species,3)
  1993. @sprites["pokemon3"].visible=true
  1994. @sprites["shadow3"].x=PokeBattle_SceneConstants::FOEBATTLERD2_X
  1995. @sprites["shadow3"].y=PokeBattle_SceneConstants::FOEBATTLERD2_Y
  1996. @sprites["shadow3"].x-=@sprites["shadow3"].bitmap.width/2 if @sprites["shadow3"].bitmap!=nil
  1997. @sprites["shadow3"].y-=@sprites["shadow3"].bitmap.height/2 if @sprites["shadow3"].bitmap!=nil
  1998. @sprites["shadow3"].visible=showShadow?(species)
  1999. trainersprite2=@sprites["pokemon3"]
  2000. end
  2001. end
  2002. end
  2003. #################
  2004. # Move trainers/bases/etc. off-screen
  2005. oldx=[]
  2006. oldx[0]=@sprites["playerbase"].x; @sprites["playerbase"].x+=Graphics.width
  2007. oldx[1]=@sprites["player"].x; @sprites["player"].x+=Graphics.width
  2008. if @sprites["playerB"]
  2009. oldx[2]=@sprites["playerB"].x; @sprites["playerB"].x+=Graphics.width
  2010. end
  2011. oldx[3]=@sprites["enemybase"].x; @sprites["enemybase"].x-=Graphics.width
  2012. oldx[4]=trainersprite1.x; trainersprite1.x-=Graphics.width
  2013. if trainersprite2
  2014. oldx[5]=trainersprite2.x; trainersprite2.x-=Graphics.width
  2015. end
  2016. oldx[6]=@sprites["shadow1"].x; @sprites["shadow1"].x-=Graphics.width
  2017. if @sprites["shadow3"]
  2018. oldx[7]=@sprites["shadow3"].x; @sprites["shadow3"].x-=Graphics.width
  2019. end
  2020. @sprites["partybarfoe"].x-=PokeBattle_SceneConstants::FOEPARTYBAR_X
  2021. @sprites["partybarplayer"].x+=Graphics.width-PokeBattle_SceneConstants::PLAYERPARTYBAR_X
  2022. #################
  2023. appearspeed=12
  2024. (1+Graphics.width/appearspeed).times do
  2025. tobreak=true
  2026. if @viewport.rect.y>0
  2027. @viewport.rect.y-=appearspeed/2
  2028. @viewport.rect.y=0 if @viewport.rect.y<0
  2029. @viewport.rect.height+=appearspeed
  2030. @viewport.rect.height=Graphics.height if @viewport.rect.height>Graphics.height
  2031. tobreak=false
  2032. end
  2033. if !tobreak
  2034. for i in @sprites
  2035. i[1].ox=@viewport.rect.x
  2036. i[1].oy=@viewport.rect.y
  2037. end
  2038. end
  2039. if @sprites["playerbase"].x>oldx[0]
  2040. @sprites["playerbase"].x-=appearspeed; tobreak=false
  2041. @sprites["playerbase"].x=oldx[0] if @sprites["playerbase"].x<oldx[0]
  2042. end
  2043. if @sprites["player"].x>oldx[1]
  2044. @sprites["player"].x-=appearspeed; tobreak=false
  2045. @sprites["player"].x=oldx[1] if @sprites["player"].x<oldx[1]
  2046. end
  2047. if @sprites["playerB"] && @sprites["playerB"].x>oldx[2]
  2048. @sprites["playerB"].x-=appearspeed; tobreak=false
  2049. @sprites["playerB"].x=oldx[2] if @sprites["playerB"].x<oldx[2]
  2050. end
  2051. if @sprites["enemybase"].x<oldx[3]
  2052. @sprites["enemybase"].x+=appearspeed; tobreak=false
  2053. @sprites["enemybase"].x=oldx[3] if @sprites["enemybase"].x>oldx[3]
  2054. end
  2055. if trainersprite1.x<oldx[4]
  2056. trainersprite1.x+=appearspeed; tobreak=false
  2057. trainersprite1.x=oldx[4] if trainersprite1.x>oldx[4]
  2058. end
  2059. if trainersprite2 && trainersprite2.x<oldx[5]
  2060. trainersprite2.x+=appearspeed; tobreak=false
  2061. trainersprite2.x=oldx[5] if trainersprite2.x>oldx[5]
  2062. end
  2063. if @sprites["shadow1"].x<oldx[6]
  2064. @sprites["shadow1"].x+=appearspeed; tobreak=false
  2065. @sprites["shadow1"].x=oldx[6] if @sprites["shadow1"].x>oldx[6]
  2066. end
  2067. if @sprites["shadow3"] && @sprites["shadow3"].x<oldx[7]
  2068. @sprites["shadow3"].x+=appearspeed; tobreak=false
  2069. @sprites["shadow3"].x=oldx[7] if @sprites["shadow3"].x>oldx[7]
  2070. end
  2071. pbGraphicsUpdate
  2072. pbInputUpdate
  2073. pbFrameUpdate
  2074. break if tobreak
  2075. end
  2076. #################
  2077. if @battle.opponent
  2078. @enablePartyAnim=true
  2079. @partyAnimPhase=0
  2080. @sprites["partybarfoe"].visible=true
  2081. @sprites["partybarplayer"].visible=true
  2082. else
  2083. pbPlayCry(@battle.party2[0]) # Play cry for wild Pokémon
  2084. @sprites["battlebox1"].appear
  2085. @sprites["battlebox3"].appear if @battle.party2.length==2
  2086. appearing=true
  2087. begin
  2088. pbGraphicsUpdate
  2089. pbInputUpdate
  2090. pbFrameUpdate
  2091. @sprites["pokemon1"].tone.red+=8 if @sprites["pokemon1"].tone.red<0
  2092. @sprites["pokemon1"].tone.blue+=8 if @sprites["pokemon1"].tone.blue<0
  2093. @sprites["pokemon1"].tone.green+=8 if @sprites["pokemon1"].tone.green<0
  2094. @sprites["pokemon1"].tone.gray+=8 if @sprites["pokemon1"].tone.gray<0
  2095. appearing=@sprites["battlebox1"].appearing
  2096. if @battle.party2.length==2
  2097. @sprites["pokemon3"].tone.red+=8 if @sprites["pokemon3"].tone.red<0
  2098. @sprites["pokemon3"].tone.blue+=8 if @sprites["pokemon3"].tone.blue<0
  2099. @sprites["pokemon3"].tone.green+=8 if @sprites["pokemon3"].tone.green<0
  2100. @sprites["pokemon3"].tone.gray+=8 if @sprites["pokemon3"].tone.gray<0
  2101. appearing=(appearing || @sprites["battlebox3"].appearing)
  2102. end
  2103. end while appearing
  2104. # Show shiny animation for wild Pokémon
  2105. if @battle.battlers[1].isShiny? && @battle.battlescene
  2106. pbCommonAnimation("Shiny",@battle.battlers[1],nil)
  2107. end
  2108. if @battle.party2.length==2
  2109. if @battle.battlers[3].isShiny? && @battle.battlescene
  2110. pbCommonAnimation("Shiny",@battle.battlers[3],nil)
  2111. end
  2112. end
  2113. end
  2114. end
  2115.  
  2116. def pbEndBattle(result)
  2117. @abortable=false
  2118. pbShowWindow(BLANK)
  2119. # Fade out all sprites
  2120. pbBGMFade(1.0)
  2121. pbFadeOutAndHide(@sprites)
  2122. pbDisposeSprites
  2123. end
  2124.  
  2125. def pbRecall(battlerindex)
  2126. @briefmessage=false
  2127. if @battle.pbIsOpposing?(battlerindex)
  2128. origin=PokeBattle_SceneConstants::FOEBATTLER_Y
  2129. if @battle.doublebattle
  2130. origin=PokeBattle_SceneConstants::FOEBATTLERD1_Y if battlerindex==1
  2131. origin=PokeBattle_SceneConstants::FOEBATTLERD2_Y if battlerindex==3
  2132. end
  2133. @sprites["shadow#{battlerindex}"].visible=false
  2134. else
  2135. origin=PokeBattle_SceneConstants::PLAYERBATTLER_Y
  2136. if @battle.doublebattle
  2137. origin=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if battlerindex==0
  2138. origin=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if battlerindex==2
  2139. end
  2140. end
  2141. spritePoke=@sprites["pokemon#{battlerindex}"]
  2142. picturePoke=PictureEx.new(spritePoke.z)
  2143. dims=[spritePoke.x,spritePoke.y]
  2144. center=getSpriteCenter(spritePoke)
  2145. # starting positions
  2146. picturePoke.moveVisible(1,true)
  2147. picturePoke.moveOrigin(1,PictureOrigin::Center)
  2148. picturePoke.moveXY(0,1,center[0],center[1])
  2149. # directives
  2150. picturePoke.moveTone(10,1,Tone.new(248,248,248,248))
  2151. delay=picturePoke.totalDuration
  2152. picturePoke.moveSE(delay,"Audio/SE/Battle recall")
  2153. picturePoke.moveZoom(15,delay,0)
  2154. picturePoke.moveXY(15,delay,center[0],origin)
  2155. picturePoke.moveVisible(picturePoke.totalDuration,false)
  2156. picturePoke.moveTone(0,picturePoke.totalDuration,Tone.new(0,0,0,0))
  2157. picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
  2158. loop do
  2159. picturePoke.update
  2160. setPictureSprite(spritePoke,picturePoke)
  2161. pbGraphicsUpdate
  2162. pbInputUpdate
  2163. pbFrameUpdate
  2164. break if !picturePoke.running?
  2165. end
  2166. end
  2167.  
  2168. def pbTrainerSendOut(battlerindex,pkmn)
  2169. illusionpoke=@battle.battlers[battlerindex].effects[PBEffects::Illusion]
  2170. @briefmessage=false
  2171. fadeanim=nil
  2172. while inPartyAnimation?; end
  2173. if @showingenemy
  2174. fadeanim=TrainerFadeAnimation.new(@sprites)
  2175. end
  2176. frame=0
  2177. @sprites["pokemon#{battlerindex}"].setPokemonBitmap(pkmn,false)
  2178. if illusionpoke
  2179. @sprites["pokemon#{battlerindex}"].setPokemonBitmap(illusionpoke,false)
  2180. end
  2181. sendout=PokeballSendOutAnimation.new(@sprites["pokemon#{battlerindex}"],
  2182. @sprites,@battle.battlers[battlerindex],illusionpoke,@battle.doublebattle)
  2183. loop do
  2184. fadeanim.update if fadeanim
  2185. frame+=1
  2186. if frame==1
  2187. @sprites["battlebox#{battlerindex}"].appear
  2188. end
  2189. if frame>=10
  2190. sendout.update
  2191. end
  2192. pbGraphicsUpdate
  2193. pbInputUpdate
  2194. pbFrameUpdate
  2195. break if (!fadeanim || fadeanim.animdone?) && sendout.animdone? &&
  2196. !@sprites["battlebox#{battlerindex}"].appearing
  2197. end
  2198. if @battle.battlers[battlerindex].isShiny? && @battle.battlescene
  2199. pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
  2200. end
  2201. sendout.dispose
  2202. if @showingenemy
  2203. @showingenemy=false
  2204. pbDisposeSprite(@sprites,"trainer")
  2205. pbDisposeSprite(@sprites,"partybarfoe")
  2206. for i in 0...6
  2207. pbDisposeSprite(@sprites,"enemy#{i}")
  2208. end
  2209. end
  2210. pbRefresh
  2211. end
  2212.  
  2213. def pbSendOut(battlerindex,pkmn) # Player sending out Pokémon
  2214. while inPartyAnimation?; end
  2215. illusionpoke=@battle.battlers[battlerindex].effects[PBEffects::Illusion]
  2216. balltype=pkmn.ballused
  2217. balltype=illusionpoke.ballused if illusionpoke
  2218. ballbitmap=sprintf("Graphics/Pictures/Battle/ball_%02d",balltype)
  2219. pictureBall=PictureEx.new(32)
  2220. delay=1
  2221. pictureBall.moveVisible(delay,true)
  2222. pictureBall.moveName(delay,ballbitmap)
  2223. pictureBall.moveOrigin(delay,PictureOrigin::Center)
  2224. # Setting the ball's movement path
  2225. path=[[0, 146], [10, 134], [21, 122], [30, 112],
  2226. [39, 104], [46, 99], [53, 95], [61, 93],
  2227. [68, 93], [75, 96], [82, 102], [89, 111],
  2228. [94, 121], [100, 134], [106, 150], [111, 166],
  2229. [116, 183], [120, 199], [124, 216], [127, 238]]
  2230. spriteBall=IconSprite.new(0,0,@viewport)
  2231. spriteBall.visible=false
  2232. angle=0
  2233. multiplier=1.0
  2234. if @battle.doublebattle
  2235. multiplier=(battlerindex==0) ? 0.7 : 1.3
  2236. end
  2237. for coord in path
  2238. delay=pictureBall.totalDuration
  2239. pictureBall.moveAngle(0,delay,angle)
  2240. pictureBall.moveXY(1,delay,coord[0]*multiplier,coord[1])
  2241. angle+=40
  2242. angle%=360
  2243. end
  2244. pictureBall.adjustPosition(0,@traineryoffset)
  2245. @sprites["battlebox#{battlerindex}"].visible=false
  2246. @briefmessage=false
  2247. fadeanim=nil
  2248. if @showingplayer
  2249. fadeanim=PlayerFadeAnimation.new(@sprites)
  2250. end
  2251. frame=0
  2252. @sprites["pokemon#{battlerindex}"].setPokemonBitmap(pkmn,true)
  2253. if illusionpoke
  2254. @sprites["pokemon#{battlerindex}"].setPokemonBitmap(illusionpoke,true)
  2255. end
  2256. sendout=PokeballPlayerSendOutAnimation.new(@sprites["pokemon#{battlerindex}"],
  2257. @sprites,@battle.battlers[battlerindex],illusionpoke,@battle.doublebattle)
  2258. loop do
  2259. fadeanim.update if fadeanim
  2260. frame+=1
  2261. if frame>1 && !pictureBall.running? && !@sprites["battlebox#{battlerindex}"].appearing
  2262. @sprites["battlebox#{battlerindex}"].appear
  2263. end
  2264. if frame>=3 && !pictureBall.running?
  2265. sendout.update
  2266. end
  2267. if (frame>=10 || !fadeanim) && pictureBall.running?
  2268. pictureBall.update
  2269. setPictureIconSprite(spriteBall,pictureBall)
  2270. end
  2271. pbGraphicsUpdate
  2272. pbInputUpdate
  2273. pbFrameUpdate
  2274. break if (!fadeanim || fadeanim.animdone?) && sendout.animdone? &&
  2275. !@sprites["battlebox#{battlerindex}"].appearing
  2276. end
  2277. spriteBall.dispose
  2278. sendout.dispose
  2279. if @battle.battlers[battlerindex].isShiny? && @battle.battlescene
  2280. pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
  2281. end
  2282. if @showingplayer
  2283. @showingplayer=false
  2284. pbDisposeSprite(@sprites,"player")
  2285. pbDisposeSprite(@sprites,"partybarplayer")
  2286. for i in 0...6
  2287. pbDisposeSprite(@sprites,"player#{i}")
  2288. end
  2289. end
  2290. pbRefresh
  2291. end
  2292.  
  2293. def pbTrainerWithdraw(battle,pkmn)
  2294. pbRefresh
  2295. end
  2296.  
  2297. def pbWithdraw(battle,pkmn)
  2298. pbRefresh
  2299. end
  2300.  
  2301. def pbMoveString(move)
  2302. ret=move.name
  2303. typename=PBTypes.getName(move.type)
  2304. if move.id>0
  2305. ret+=_INTL(" ({1}) PP: {2}/{3}",typename,move.pp,move.totalpp)
  2306. end
  2307. return ret
  2308. end
  2309.  
  2310. def pbBeginAttackPhase
  2311. pbSelectBattler(-1)
  2312. pbGraphicsUpdate
  2313. end
  2314.  
  2315. def pbSafariStart
  2316. @briefmessage=false
  2317. @sprites["battlebox0"]=SafariDataBox.new(@battle,@viewport)
  2318. @sprites["battlebox0"].appear
  2319. loop do
  2320. @sprites["battlebox0"].update
  2321. pbGraphicsUpdate
  2322. pbInputUpdate
  2323. pbFrameUpdate
  2324. break if !@sprites["battlebox0"].appearing
  2325. end
  2326. pbRefresh
  2327. end
  2328.  
  2329. def pbResetCommandIndices
  2330. @lastcmd=[0,0,0,0]
  2331. end
  2332.  
  2333. def pbResetMoveIndex(index)
  2334. @lastmove[index]=0
  2335. end
  2336.  
  2337. def pbSafariCommandMenu(index)
  2338. pbCommandMenuEx(index,[
  2339. _INTL("What will {1} throw?",@battle.pbPlayer.name),
  2340. _INTL("BALL"),
  2341. _INTL("BAIT"),
  2342. _INTL("ROCK"),
  2343. _INTL("RUN")
  2344. ],2)
  2345. end
  2346.  
  2347. # Use this method to display the list of commands.
  2348. # Return values: 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call
  2349. def pbCommandMenu(index)
  2350. shadowTrainer=false #(hasConst?(PBTypes,:SHADOW) && @battle.opponent)
  2351. ret=pbCommandMenuEx(index,[
  2352. _INTL("",@battle.battlers[index].name),
  2353. _INTL("FIGHT"),
  2354. _INTL("BAG"),
  2355. _INTL("@*"),
  2356. shadowTrainer ? _INTL("CALL") : _INTL("RUN")
  2357. ],(shadowTrainer ? 1 : 0))
  2358. ret=4 if ret==3 && shadowTrainer # Convert "Run" to "Call"
  2359. return ret
  2360. end
  2361.  
  2362. def pbCommandMenuEx(index,texts,mode=0) # Mode: 0 - regular battle
  2363. pbShowWindow(COMMANDBOX) # 1 - Shadow Pokémon battle
  2364. cw=@sprites["commandwindow"] # 2 - Safari Zone
  2365. cw.setTexts(texts) # 3 - Bug Catching Contest
  2366. cw.index=@lastcmd[index]
  2367. cw.mode=mode
  2368. pbSelectBattler(index)
  2369. pbRefresh
  2370. loop do
  2371. pbGraphicsUpdate
  2372. pbInputUpdate
  2373. pbFrameUpdate(cw)
  2374. # Update selected command
  2375. if Input.trigger?(Input::LEFT) && (cw.index&1)==1
  2376. pbPlayCursorSE
  2377. cw.index-=1
  2378. elsif Input.trigger?(Input::RIGHT) && (cw.index&1)==0
  2379. pbPlayCursorSE
  2380. cw.index+=1
  2381. elsif Input.trigger?(Input::UP) && (cw.index&2)==2
  2382. pbPlayCursorSE
  2383. cw.index-=2
  2384. elsif Input.trigger?(Input::DOWN) && (cw.index&2)==0
  2385. pbPlayCursorSE
  2386. cw.index+=2
  2387. end
  2388. if Input.trigger?(Input::C) # Confirm choice
  2389. pbPlayDecisionSE
  2390. ret=cw.index
  2391. @lastcmd[index]=ret
  2392. return ret
  2393. elsif Input.trigger?(Input::B) && index==2 && @lastcmd[0]!=2 # Cancel
  2394. pbPlayDecisionSE
  2395. return -1
  2396. end
  2397. end
  2398. end
  2399.  
  2400. # Use this method to display the list of moves for a Pokémon
  2401. def pbFightMenu(index)
  2402. pbShowWindow(FIGHTBOX)
  2403. cw = @sprites["fightwindow"]
  2404. battler=@battle.battlers[index]
  2405. cw.battler=battler
  2406. lastIndex=@lastmove[index]
  2407. if battler.moves[lastIndex].id!=0
  2408. cw.setIndex(lastIndex)
  2409. else
  2410. cw.setIndex(0)
  2411. end
  2412. cw.megaButton=0
  2413. cw.megaButton=1 if @battle.pbCanMegaEvolve?(index)
  2414. pbSelectBattler(index)
  2415. pbRefresh
  2416. loop do
  2417. pbGraphicsUpdate
  2418. pbInputUpdate
  2419. pbFrameUpdate(cw)
  2420. # Update selected command
  2421. if Input.trigger?(Input::UP) && (cw.index)>0
  2422. pbPlayCursorSE if cw.setIndex(cw.index-1)
  2423. elsif Input.trigger?(Input::DOWN) && (cw.index)==0
  2424. pbPlayCursorSE if cw.setIndex(cw.index+1)
  2425. elsif Input.trigger?(Input::DOWN) && (cw.index)==1
  2426. pbPlayCursorSE if cw.setIndex(cw.index+1)
  2427. elsif Input.trigger?(Input::DOWN) && (cw.index)==2
  2428. pbPlayCursorSE if cw.setIndex(cw.index+1)
  2429. end
  2430. if Input.trigger?(Input::C) # Confirm choice
  2431. ret=cw.index
  2432. pbPlayDecisionSE
  2433. @lastmove[index]=ret
  2434. return ret
  2435. elsif Input.trigger?(Input::A) # Use Mega Evolution
  2436. if @battle.pbCanMegaEvolve?(index)
  2437. @battle.pbRegisterMegaEvolution(index)
  2438. cw.megaButton=2
  2439. pbPlayDecisionSE
  2440. end
  2441. elsif Input.trigger?(Input::B) # Cancel fight menu
  2442. @lastmove[index]=cw.index
  2443. pbPlayCancelSE
  2444. return -1
  2445. end
  2446. end
  2447. end
  2448.  
  2449. # Use this method to display the inventory
  2450. # The return value is the item chosen, or 0 if the choice was canceled.
  2451. def pbItemMenu(index)
  2452. ret=0
  2453. retindex=-1
  2454. pkmnid=-1
  2455. endscene=true
  2456. oldsprites=pbFadeOutAndHide(@sprites)
  2457. oldlastpocket = $PokemonBag.lastpocket
  2458. oldchoices = $PokemonBag.getAllChoices
  2459. $PokemonBag.lastpocket = @baglastpocket if @baglastpocket!=nil
  2460. $PokemonBag.setAllChoices(@bagchoices) if @bagchoices!=nil
  2461. itemscene=PokemonBag_Scene.new
  2462. itemscene.pbStartScene($PokemonBag,true,Proc.new{|item|
  2463. $ItemData[item][ITEMBATTLEUSE]>0 || pbIsPokeBall?(item)
  2464. },false)
  2465. loop do
  2466. item=itemscene.pbChooseItem
  2467. break if item==0
  2468. usetype=$ItemData[item][ITEMBATTLEUSE]
  2469. cmdUse=-1
  2470. commands=[]
  2471. if usetype==0
  2472. commands[commands.length]=_INTL("Cancel")
  2473. else
  2474. commands[cmdUse=commands.length]=_INTL("Use")
  2475. commands[commands.length]=_INTL("Cancel")
  2476. end
  2477. itemname=PBItems.getName(item)
  2478. command=itemscene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
  2479. if cmdUse>=0 && command==cmdUse
  2480. if usetype==1 || usetype==3
  2481. modparty=[]
  2482. for i in 0...6
  2483. modparty.push(@battle.party1[@battle.party1order[i]])
  2484. end
  2485. pkmnlist=PokemonParty_Scene.new
  2486. pkmnscreen=PokemonPartyScreen.new(pkmnlist,modparty)
  2487. itemscene.pbEndScene
  2488. pkmnscreen.pbStartScene(_INTL("Use on which @*?"),@battle.doublebattle)
  2489. activecmd=pkmnscreen.pbChoosePokemon
  2490. pkmnid=@battle.party1order[activecmd]
  2491. if activecmd>=0 && pkmnid>=0 && ItemHandlers.hasBattleUseOnPokemon(item)
  2492. pkmnlist.pbEndScene
  2493. ret=item
  2494. retindex=pkmnid
  2495. endscene=false
  2496. break
  2497. end
  2498. pkmnlist.pbEndScene
  2499. itemscene.pbStartScene($PokemonBag)
  2500. elsif usetype==2 || usetype==4
  2501. if ItemHandlers.hasBattleUseOnBattler(item)
  2502. ret=item
  2503. retindex=index
  2504. break
  2505. end
  2506. end
  2507. end
  2508. end
  2509. pbConsumeItemInBattle($PokemonBag,ret) if ret>0
  2510. itemscene.pbEndScene if endscene
  2511. @baglastpocket = $PokemonBag.lastpocket
  2512. @bagchoices = $PokemonBag.getAllChoices
  2513. $PokemonBag.lastpocket = oldlastpocket
  2514. $PokemonBag.setAllChoices(oldchoices)
  2515. pbFadeInAndShow(@sprites,oldsprites)
  2516. return [ret,retindex]
  2517. end
  2518.  
  2519. # Called whenever a Pokémon should forget a move. It should return -1 if the
  2520. # selection is canceled, or 0 to 3 to indicate the move to forget. The function
  2521. # should not allow HM moves to be forgotten.
  2522. def pbForgetMove(pokemon,moveToLearn)
  2523. ret=-1
  2524. pbFadeOutIn(99999){
  2525. scene=PokemonSummary_Scene.new
  2526. screen=PokemonSummaryScreen.new(scene)
  2527. ret=screen.pbStartForgetScreen([pokemon],0,moveToLearn)
  2528. }
  2529. return ret
  2530. end
  2531.  
  2532. # Called whenever a Pokémon needs one of its moves chosen. Used for Ether.
  2533. def pbChooseMove(pokemon,message)
  2534. ret=-1
  2535. pbFadeOutIn(99999){
  2536. scene=PokemonSummary_Scene.new
  2537. screen=PokemonSummaryScreen.new(scene)
  2538. ret=screen.pbStartChooseMoveScreen([pokemon],0,message)
  2539. }
  2540. return ret
  2541. end
  2542.  
  2543. def pbNameEntry(helptext,pokemon)
  2544. return pbEnterPokemonName(helptext,0,PokeBattle_Pokemon::NAMELIMIT,"",pokemon)
  2545. end
  2546.  
  2547. def pbSelectBattler(index,selectmode=1)
  2548. numwindows=@battle.doublebattle ? 4 : 2
  2549. for i in 0...numwindows
  2550. sprite=@sprites["battlebox#{i}"]
  2551. sprite.selected=(i==index) ? selectmode : 0
  2552. sprite=@sprites["pokemon#{i}"]
  2553. sprite.selected=(i==index) ? selectmode : 0
  2554. end
  2555. end
  2556.  
  2557. def pbFirstTarget(index,targettype)
  2558. case targettype
  2559. when PBTargets::SingleNonUser
  2560. for i in 0...4
  2561. if i!=index && !@battle.battlers[i].fainted? &&
  2562. @battle.battlers[index].pbIsOpposing?(i)
  2563. return i
  2564. end
  2565. end
  2566. when PBTargets::UserOrPartner
  2567. return index
  2568. end
  2569. return -1
  2570. end
  2571.  
  2572. def pbUpdateSelected(index)
  2573. numwindows=@battle.doublebattle ? 4 : 2
  2574. for i in 0...numwindows
  2575. if i==index
  2576. @sprites["battlebox#{i}"].selected=2
  2577. @sprites["pokemon#{i}"].selected=2
  2578. else
  2579. @sprites["battlebox#{i}"].selected=0
  2580. @sprites["pokemon#{i}"].selected=0
  2581. end
  2582. end
  2583. pbFrameUpdate
  2584. end
  2585.  
  2586. def pbChooseTarget(index,targettype)
  2587. pbShowWindow(FIGHTBOX)
  2588. cw = @sprites["fightwindow"]
  2589. battler=@battle.battlers[index]
  2590. cw.battler=battler
  2591. lastIndex=@lastmove[index]
  2592. if battler.moves[lastIndex].id!=0
  2593. cw.setIndex(lastIndex)
  2594. else
  2595. cw.setIndex(0)
  2596. end
  2597. curwindow=pbFirstTarget(index,targettype)
  2598. if curwindow==-1
  2599. raise RuntimeError.new(_INTL("No targets somehow..."))
  2600. end
  2601. loop do
  2602. pbGraphicsUpdate
  2603. pbInputUpdate
  2604. pbUpdateSelected(curwindow)
  2605. if Input.trigger?(Input::B)
  2606. pbUpdateSelected(-1)
  2607. return -1
  2608. elsif Input.trigger?(Input::C)
  2609. pbUpdateSelected(-1)
  2610. return curwindow
  2611. end
  2612. if curwindow>=0
  2613. if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::DOWN)
  2614. loop do
  2615. case targettype
  2616. when PBTargets::SingleNonUser
  2617. case curwindow
  2618. when 0; newcurwindow=2
  2619. when 1; newcurwindow=0
  2620. when 2; newcurwindow=3
  2621. when 3; newcurwindow=1
  2622. end
  2623. when PBTargets::UserOrPartner
  2624. newcurwindow=(curwindow+2)%4
  2625. end
  2626. curwindow=newcurwindow
  2627. next if targettype==PBTargets::SingleNonUser && curwindow==index
  2628. next if targettype==PBTargets::SingleNonUser && curwindow==(index+2)%4 &&
  2629. @battle.battlers[curwindow].effects[PBEffects::HealBlock]>0 &&
  2630. battler.moves[lastIndex].function==0x16F # Pollen Puff
  2631. break if !@battle.battlers[curwindow].fainted?
  2632. end
  2633. elsif Input.trigger?(Input::LEFT) || Input.trigger?(Input::UP)
  2634. loop do
  2635. case targettype
  2636. when PBTargets::SingleNonUser
  2637. case curwindow
  2638. when 0; newcurwindow=1
  2639. when 1; newcurwindow=3
  2640. when 2; newcurwindow=0
  2641. when 3; newcurwindow=2
  2642. end
  2643. when PBTargets::UserOrPartner
  2644. newcurwindow=(curwindow+2)%4
  2645. end
  2646. curwindow=newcurwindow
  2647. next if targettype==PBTargets::SingleNonUser && curwindow==index
  2648. next if targettype==PBTargets::SingleNonUser && curwindow==(index+2)%4 &&
  2649. @battle.battlers[curwindow].effects[PBEffects::HealBlock]>0 &&
  2650. battler.moves[lastIndex].function==0x16B # Pollen Puff
  2651. break if !@battle.battlers[curwindow].fainted?
  2652. end
  2653. end
  2654. end
  2655. end
  2656. end
  2657.  
  2658. def pbSwitch(index,lax,cancancel)
  2659. party=@battle.pbParty(index)
  2660. partypos=@battle.party1order
  2661. ret=-1
  2662. # Fade out and hide all sprites
  2663. visiblesprites=pbFadeOutAndHide(@sprites)
  2664. pbShowWindow(BLANK)
  2665. pbSetMessageMode(true)
  2666. modparty=[]
  2667. for i in 0...6
  2668. modparty.push(party[partypos[i]])
  2669. end
  2670. scene=PokemonParty_Scene.new
  2671. @switchscreen=PokemonPartyScreen.new(scene,modparty)
  2672. @switchscreen.pbStartScene(_INTL("Choose a Pokémon."),
  2673. @battle.doublebattle && !@battle.fullparty1)
  2674. loop do
  2675. scene.pbSetHelpText(_INTL("Choose a Pokémon."))
  2676. activecmd=@switchscreen.pbChoosePokemon
  2677. if cancancel && activecmd==-1
  2678. ret=-1
  2679. break
  2680. end
  2681. if activecmd>=0
  2682. commands=[]
  2683. cmdShift=-1
  2684. cmdSummary=-1
  2685. pkmnindex=partypos[activecmd]
  2686. commands[cmdShift=commands.length]=_INTL("Switch In") if !party[pkmnindex].egg?
  2687. commands[cmdSummary=commands.length]=_INTL("Summary")
  2688. commands[commands.length]=_INTL("Cancel")
  2689. command=scene.pbShowCommands(_INTL("Do what with {1}?",party[pkmnindex].name),commands)
  2690. if cmdShift>=0 && command==cmdShift
  2691. canswitch=lax ? @battle.pbCanSwitchLax?(index,pkmnindex,true) :
  2692. @battle.pbCanSwitch?(index,pkmnindex,true)
  2693. if canswitch
  2694. ret=pkmnindex
  2695. break
  2696. end
  2697. elsif cmdSummary>=0 && command==cmdSummary
  2698. scene.pbSummary(activecmd)
  2699. end
  2700. end
  2701. end
  2702. @switchscreen.pbEndScene
  2703. @switchscreen=nil
  2704. pbShowWindow(BLANK)
  2705. pbSetMessageMode(false)
  2706. # back to main battle screen
  2707. pbFadeInAndShow(@sprites,visiblesprites)
  2708. return ret
  2709. end
  2710.  
  2711. def pbDamageAnimation(pkmn,effectiveness)
  2712. pkmnsprite=@sprites["pokemon#{pkmn.index}"]
  2713. shadowsprite=@sprites["shadow#{pkmn.index}"]
  2714. sprite=@sprites["battlebox#{pkmn.index}"]
  2715. oldshadowvisible=shadowsprite.visible
  2716. oldvisible=sprite.visible
  2717. sprite.selected=3
  2718. @briefmessage=false
  2719. 6.times do
  2720. pbGraphicsUpdate
  2721. pbInputUpdate
  2722. pbFrameUpdate
  2723. end
  2724. case effectiveness
  2725. when 0
  2726. pbSEPlay("Battle damage normal")
  2727. when 1
  2728. pbSEPlay("Battle damage weak")
  2729. when 2
  2730. pbSEPlay("Battle damage super")
  2731. end
  2732. 8.times do
  2733. pkmnsprite.visible=!pkmnsprite.visible
  2734. if oldshadowvisible
  2735. shadowsprite.visible=!shadowsprite.visible
  2736. end
  2737. 4.times do
  2738. pbGraphicsUpdate
  2739. pbInputUpdate
  2740. pbFrameUpdate
  2741. sprite.update
  2742. end
  2743. end
  2744. sprite.selected=0
  2745. sprite.visible=oldvisible
  2746. end
  2747.  
  2748. # This method is called whenever a Pokémon's HP changes.
  2749. # Used to animate the HP bar.
  2750. def pbHPChanged(pkmn,oldhp,anim=false)
  2751. @briefmessage=false
  2752. hpchange=pkmn.hp-oldhp
  2753. if hpchange<0
  2754. hpchange=-hpchange
  2755. PBDebug.log("[HP change] #{pkmn.pbThis} lost #{hpchange} HP (#{oldhp}=>#{pkmn.hp})")
  2756. else
  2757. PBDebug.log("[HP change] #{pkmn.pbThis} gained #{hpchange} HP (#{oldhp}=>#{pkmn.hp})")
  2758. end
  2759. if anim && @battle.battlescene
  2760. if pkmn.hp>oldhp
  2761. pbCommonAnimation("HealthUp",pkmn,nil)
  2762. elsif pkmn.hp<oldhp
  2763. pbCommonAnimation("HealthDown",pkmn,nil)
  2764. end
  2765. end
  2766. sprite=@sprites["battlebox#{pkmn.index}"]
  2767. sprite.animateHP(oldhp,pkmn.hp)
  2768. while sprite.animatingHP
  2769. pbGraphicsUpdate
  2770. pbInputUpdate
  2771. pbFrameUpdate
  2772. sprite.update
  2773. end
  2774. end
  2775.  
  2776. # This method is called whenever a Pokémon faints.
  2777. def pbFainted(pkmn)
  2778. frames=pbCryFrameLength(pkmn.pokemon)
  2779. pbPlayCry(pkmn.pokemon)
  2780. frames.times do
  2781. pbGraphicsUpdate
  2782. pbInputUpdate
  2783. pbFrameUpdate
  2784. end
  2785. @sprites["shadow#{pkmn.index}"].visible=false
  2786. pkmnsprite=@sprites["pokemon#{pkmn.index}"]
  2787. ycoord=0
  2788. if @battle.doublebattle
  2789. ycoord=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if pkmn.index==0
  2790. ycoord=PokeBattle_SceneConstants::FOEBATTLERD1_Y if pkmn.index==1
  2791. ycoord=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if pkmn.index==2
  2792. ycoord=PokeBattle_SceneConstants::FOEBATTLERD2_Y if pkmn.index==3
  2793. else
  2794. if @battle.pbIsOpposing?(pkmn.index)
  2795. ycoord=PokeBattle_SceneConstants::FOEBATTLER_Y
  2796. else
  2797. ycoord=PokeBattle_SceneConstants::PLAYERBATTLER_Y
  2798. end
  2799. end
  2800. pbSEPlay("Pkmn faint")
  2801. loop do
  2802. pkmnsprite.y+=8
  2803. if pkmnsprite.y-pkmnsprite.oy+pkmnsprite.src_rect.height>=ycoord
  2804. pkmnsprite.src_rect.height=ycoord-pkmnsprite.y+pkmnsprite.oy
  2805. end
  2806. pbGraphicsUpdate
  2807. pbInputUpdate
  2808. pbFrameUpdate
  2809. break if pkmnsprite.y>=ycoord
  2810. end
  2811. pkmnsprite.visible=false
  2812. 8.times do
  2813. @sprites["battlebox#{pkmn.index}"].opacity-=32
  2814. pbGraphicsUpdate
  2815. pbInputUpdate
  2816. pbFrameUpdate
  2817. end
  2818. @sprites["battlebox#{pkmn.index}"].visible=false
  2819. pkmn.pbResetForm
  2820. end
  2821.  
  2822. # Use this method to choose a command for the enemy.
  2823. def pbChooseEnemyCommand(index)
  2824. @battle.pbDefaultChooseEnemyCommand(index)
  2825. end
  2826.  
  2827. # Use this method to choose a new Pokémon for the enemy
  2828. # The enemy's party is guaranteed to have at least one choosable member.
  2829. def pbChooseNewEnemy(index,party)
  2830. @battle.pbDefaultChooseNewEnemy(index,party)
  2831. end
  2832.  
  2833. # This method is called when the player wins a wild Pokémon battle.
  2834. # This method can change the battle's music for example.
  2835. def pbWildBattleSuccess
  2836. pbBGMPlay(pbGetWildVictoryME())
  2837. end
  2838.  
  2839. # This method is called when the player wins a Trainer battle.
  2840. # This method can change the battle's music for example.
  2841. def pbTrainerBattleSuccess
  2842. pbBGMPlay(pbGetTrainerVictoryME(@battle.opponent))
  2843. end
  2844.  
  2845. def pbEXPBar(pokemon,battler,startexp,endexp,tempexp1,tempexp2)
  2846. if battler
  2847. @sprites["battlebox#{battler.index}"].refreshExpLevel
  2848. exprange=(endexp-startexp)
  2849. startexplevel=0
  2850. endexplevel=0
  2851. if exprange!=0
  2852. startexplevel=(tempexp1-startexp)*144/exprange
  2853. endexplevel=(tempexp2-startexp)*144/exprange
  2854. end
  2855. @sprites["battlebox#{battler.index}"].animateEXP(startexplevel,endexplevel)
  2856. while @sprites["battlebox#{battler.index}"].animatingEXP
  2857. pbGraphicsUpdate
  2858. pbInputUpdate
  2859. pbFrameUpdate
  2860. @sprites["battlebox#{battler.index}"].update
  2861. end
  2862. end
  2863. end
  2864.  
  2865. def pbShowPokedex(species)
  2866. pbFadeOutIn(99999){
  2867. scene = PokemonPokedexInfo_Scene.new
  2868. screen = PokemonPokedexInfoScreen.new(scene)
  2869. screen.pbDexEntry(species)
  2870. }
  2871. end
  2872.  
  2873. def pbChangeSpecies(attacker,species)
  2874. pkmn=@sprites["pokemon#{attacker.index}"]
  2875. shadow=@sprites["shadow#{attacker.index}"]
  2876. back=!@battle.pbIsOpposing?(attacker.index)
  2877. pkmn.setPokemonBitmapSpecies(attacker.pokemon,species,back)
  2878. pkmn.x=-pkmn.bitmap.width/2
  2879. pkmn.y=adjustBattleSpriteY(pkmn,species,attacker.index)
  2880. if @battle.doublebattle
  2881. case attacker.index
  2882. when 0
  2883. pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
  2884. pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
  2885. when 1
  2886. pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
  2887. pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
  2888. when 2
  2889. pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD2_X
  2890. pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y
  2891. when 3
  2892. pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD2_X
  2893. pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD2_Y
  2894. end
  2895. else
  2896. pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLER_X if attacker.index==0
  2897. pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLER_Y if attacker.index==0
  2898. pkmn.x+=PokeBattle_SceneConstants::FOEBATTLER_X if attacker.index==1
  2899. pkmn.y+=PokeBattle_SceneConstants::FOEBATTLER_Y if attacker.index==1
  2900. end
  2901. if shadow && !back
  2902. shadow.visible=showShadow?(species)
  2903. end
  2904. end
  2905.  
  2906. def pbChangePokemon(attacker,pokemon)
  2907. pkmn=@sprites["pokemon#{attacker.index}"]
  2908. shadow=@sprites["shadow#{attacker.index}"]
  2909. back=!@battle.pbIsOpposing?(attacker.index)
  2910. pkmn.setPokemonBitmap(pokemon,back)
  2911. pkmn.x=-pkmn.bitmap.width/2
  2912. pkmn.y=adjustBattleSpriteY(pkmn,pokemon.species,attacker.index)
  2913. if @battle.doublebattle
  2914. case attacker.index
  2915. when 0
  2916. pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
  2917. pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
  2918. when 1
  2919. pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
  2920. pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
  2921. when 2
  2922. pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD2_X
  2923. pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y
  2924. when 3
  2925. pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD2_X
  2926. pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD2_Y
  2927. end
  2928. else
  2929. pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLER_X if attacker.index==0
  2930. pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLER_Y if attacker.index==0
  2931. pkmn.x+=PokeBattle_SceneConstants::FOEBATTLER_X if attacker.index==1
  2932. pkmn.y+=PokeBattle_SceneConstants::FOEBATTLER_Y if attacker.index==1
  2933. end
  2934. if shadow && !back
  2935. shadow.visible=showShadow?(pokemon.species)
  2936. end
  2937. end
  2938.  
  2939. def pbSaveShadows
  2940. shadows=[]
  2941. for i in 0...4
  2942. s=@sprites["shadow#{i}"]
  2943. shadows[i]=s ? s.visible : false
  2944. s.visible=false if s
  2945. end
  2946. yield
  2947. for i in 0...4
  2948. s=@sprites["shadow#{i}"]
  2949. s.visible=shadows[i] if s
  2950. end
  2951. end
  2952.  
  2953. def pbFindAnimation(moveid,userIndex,hitnum)
  2954. begin
  2955. move2anim=load_data("Data/move2anim.dat")
  2956. noflip=false
  2957. if (userIndex&1)==0 # On player's side
  2958. anim=move2anim[0][moveid]
  2959. else # On opposing side
  2960. anim=move2anim[1][moveid]
  2961. noflip=true if anim
  2962. anim=move2anim[0][moveid] if !anim
  2963. end
  2964. return [anim+hitnum,noflip] if anim
  2965. # Actual animation not found, get the default animation for the move's type
  2966. move=PBMoveData.new(moveid)
  2967. type=move.type
  2968. typedefaultanim=[[:NORMAL,:TACKLE],
  2969. [:FIGHTING,:COMETPUNCH],
  2970. [:FLYING,:GUST],
  2971. [:POISON,:SLUDGE],
  2972. [:GROUND,:MUDSLAP],
  2973. [:ROCK,:ROCKTHROW],
  2974. [:BUG,:TWINEEDLE],
  2975. [:GHOST,:NIGHTSHADE],
  2976. [:STEEL,:GYROBALL],
  2977. [:FIRE,:EMBER],
  2978. [:WATER,:WATERGUN],
  2979. [:GRASS,:RAZORLEAF],
  2980. [:ELECTRIC,:THUNDERSHOCK],
  2981. [:PSYCHIC,:CONFUSION],
  2982. [:ICE,:ICEBALL],
  2983. [:DRAGON,:DRAGONRAGE],
  2984. [:DARK,:PURSUIT],
  2985. [:FAIRY,:FAIRYWIND]]
  2986. for i in typedefaultanim
  2987. if isConst?(type,PBTypes,i[0]) && hasConst?(PBMoves,i[1])
  2988. noflip=false
  2989. if (userIndex&1)==0 # On player's side
  2990. anim=move2anim[0][getConst(PBMoves,i[1])]
  2991. else # On opposing side
  2992. anim=move2anim[1][getConst(PBMoves,i[1])]
  2993. noflip=true if anim
  2994. anim=move2anim[0][getConst(PBMoves,i[1])] if !anim
  2995. end
  2996. return [anim,noflip] if anim
  2997. break
  2998. end
  2999. end
  3000. # Default animation for the move's type not found, use Tackle's animation
  3001. if hasConst?(PBMoves,:TACKLE)
  3002. anim=move2anim[0][getConst(PBMoves,:TACKLE)]
  3003. return [anim,false] if anim
  3004. end
  3005. rescue
  3006. return nil
  3007. end
  3008. return nil
  3009. end
  3010.  
  3011. def pbCommonAnimation(animname,user,target,hitnum=0)
  3012. animations=load_data("Data/PkmnAnimations.rxdata")
  3013. for i in 0...animations.length
  3014. if animations[i] && animations[i].name=="Common:"+animname
  3015. pbAnimationCore(animations[i],user,(target!=nil) ? target : user)
  3016. return
  3017. end
  3018. end
  3019. end
  3020.  
  3021. def pbAnimation(moveid,user,target,hitnum=0)
  3022. animid=pbFindAnimation(moveid,user.index,hitnum)
  3023. return if !animid
  3024. anim=animid[0]
  3025. animations=load_data("Data/PkmnAnimations.rxdata")
  3026. pbSaveShadows {
  3027. if animid[1] # On opposing side and using OppMove animation
  3028. pbAnimationCore(animations[anim],target,user,true)
  3029. else # On player's side, and/or using Move animation
  3030. pbAnimationCore(animations[anim],user,target)
  3031. end
  3032. }
  3033. if PBMoveData.new(moveid).function==0x69 && user && target # Transform
  3034. # Change form to transformed version
  3035. pbChangePokemon(user,target.pokemon)
  3036. end
  3037. end
  3038.  
  3039. def pbAnimationCore(animation,user,target,oppmove=false)
  3040. return if !animation
  3041. @briefmessage=false
  3042. usersprite=(user) ? @sprites["pokemon#{user.index}"] : nil
  3043. targetsprite=(target) ? @sprites["pokemon#{target.index}"] : nil
  3044. olduserx=usersprite ? usersprite.x : 0
  3045. oldusery=usersprite ? usersprite.y : 0
  3046. oldtargetx=targetsprite ? targetsprite.x : 0
  3047. oldtargety=targetsprite ? targetsprite.y : 0
  3048. if !targetsprite
  3049. target=user if !target
  3050. animplayer=PBAnimationPlayerX.new(animation,user,target,self,oppmove)
  3051. userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
  3052. userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
  3053. animplayer.setLineTransform(
  3054. PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
  3055. PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
  3056. olduserx+(userwidth/2),oldusery+(userheight/2),
  3057. olduserx+(userwidth/2),oldusery+(userheight/2))
  3058. else
  3059. animplayer=PBAnimationPlayerX.new(animation,user,target,self,oppmove)
  3060. userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
  3061. userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
  3062. targetwidth=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.width
  3063. targetheight=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.height
  3064. animplayer.setLineTransform(
  3065. PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
  3066. PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
  3067. olduserx+(userwidth/2),oldusery+(userheight/2),
  3068. oldtargetx+(targetwidth/2),oldtargety+(targetheight/2))
  3069. end
  3070. animplayer.start
  3071. while animplayer.playing?
  3072. animplayer.update
  3073. pbGraphicsUpdate
  3074. pbInputUpdate
  3075. pbFrameUpdate
  3076. end
  3077. usersprite.ox=0 if usersprite
  3078. usersprite.oy=0 if usersprite
  3079. usersprite.x=olduserx if usersprite
  3080. usersprite.y=oldusery if usersprite
  3081. targetsprite.ox=0 if targetsprite
  3082. targetsprite.oy=0 if targetsprite
  3083. targetsprite.x=oldtargetx if targetsprite
  3084. targetsprite.y=oldtargety if targetsprite
  3085. animplayer.dispose
  3086. end
  3087.  
  3088. def pbLevelUp(pokemon,battler,oldtotalhp,oldattack,olddefense,oldspeed,
  3089. oldspatk,oldspdef)
  3090. pbTopRightWindow(_INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}",
  3091. pokemon.totalhp-oldtotalhp,
  3092. pokemon.attack-oldattack,
  3093. pokemon.defense-olddefense,
  3094. pokemon.spatk-oldspatk,
  3095. pokemon.spdef-oldspdef,
  3096. pokemon.speed-oldspeed))
  3097. pbTopRightWindow(_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}",
  3098. pokemon.totalhp,pokemon.attack,pokemon.defense,pokemon.spatk,pokemon.spdef,pokemon.speed))
  3099. end
  3100.  
  3101. def pbThrowAndDeflect(ball,targetBattler)
  3102. @briefmessage=false
  3103. balltype=pbGetBallType(ball)
  3104. ball=sprintf("Graphics/Pictures/Battle/ball_%02d",balltype)
  3105. # sprite
  3106. spriteBall=IconSprite.new(0,0,@viewport)
  3107. spriteBall.visible=false
  3108. # picture
  3109. pictureBall=PictureEx.new(@sprites["pokemon#{targetBattler}"].z+1)
  3110. center=getSpriteCenter(@sprites["pokemon#{targetBattler}"])
  3111. # starting positions
  3112. pictureBall.moveVisible(1,true)
  3113. pictureBall.moveName(1,ball)
  3114. pictureBall.moveOrigin(1,PictureOrigin::Center)
  3115. pictureBall.moveXY(0,1,10,180)
  3116. # directives
  3117. pictureBall.moveSE(1,"Audio/SE/Battle throw")
  3118. pictureBall.moveCurve(30,1,150,70,30+Graphics.width/2,10,center[0],center[1])
  3119. pictureBall.moveAngle(30,1,-1080)
  3120. pictureBall.moveAngle(0,pictureBall.totalDuration,0)
  3121. delay=pictureBall.totalDuration
  3122. pictureBall.moveSE(delay,"Audio/SE/Battle ball drop")
  3123. pictureBall.moveXY(20,delay,0,Graphics.height)
  3124. loop do
  3125. pictureBall.update
  3126. setPictureIconSprite(spriteBall,pictureBall)
  3127. pbGraphicsUpdate
  3128. pbInputUpdate
  3129. pbFrameUpdate
  3130. break if !pictureBall.running?
  3131. end
  3132. spriteBall.dispose
  3133. end
  3134.  
  3135. def pbThrow(ball,shakes,critical,targetBattler,showplayer=false)
  3136. @briefmessage=false
  3137. burst=-1
  3138. animations=load_data("Data/PkmnAnimations.rxdata")
  3139. for i in 0...2
  3140. t=(i==0) ? ball : 0
  3141. for j in 0...animations.length
  3142. if animations[j]
  3143. if animations[j].name=="Common:BallBurst#{t}"
  3144. burst=t if burst<0
  3145. break
  3146. end
  3147. end
  3148. end
  3149. break if burst>=0
  3150. end
  3151. pokeballThrow(ball,shakes,critical,targetBattler,self,@battle.battlers[targetBattler],burst,showplayer)
  3152. end
  3153.  
  3154. def pbThrowSuccess
  3155. if !@battle.opponent
  3156. @briefmessage=false
  3157. pbMEPlay("catch")
  3158. frames=(3.5*Graphics.frame_rate).to_i
  3159. frames.times do
  3160. pbGraphicsUpdate
  3161. pbInputUpdate
  3162. pbFrameUpdate
  3163. end
  3164. end
  3165. end
  3166.  
  3167. def pbHideCaptureBall
  3168. if @sprites["capture"]
  3169. loop do
  3170. break if @sprites["capture"].opacity<=0
  3171. @sprites["capture"].opacity-=12
  3172. pbGraphicsUpdate
  3173. pbInputUpdate
  3174. pbFrameUpdate
  3175. end
  3176. end
  3177. end
  3178.  
  3179. def pbThrowBait
  3180. @briefmessage=false
  3181. ball=sprintf("Graphics/Pictures/Battle/object_bait")
  3182. armanim=false
  3183. if @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
  3184. armanim=true
  3185. end
  3186. # sprites
  3187. spritePoke=@sprites["pokemon1"]
  3188. spritePlayer=@sprites["player"]
  3189. spriteBall=IconSprite.new(0,0,@viewport)
  3190. spriteBall.visible=false
  3191. # pictures
  3192. pictureBall=PictureEx.new(spritePoke.z+1)
  3193. picturePoke=PictureEx.new(spritePoke.z)
  3194. picturePlayer=PictureEx.new(spritePoke.z+2)
  3195. dims=[spritePoke.x,spritePoke.y]
  3196. pokecenter=getSpriteCenter(@sprites["pokemon1"])
  3197. playerpos=[@sprites["player"].x,@sprites["player"].y]
  3198. ballendy=PokeBattle_SceneConstants::FOEBATTLER_Y-4
  3199. # starting positions
  3200. pictureBall.moveVisible(1,true)
  3201. pictureBall.moveName(1,ball)
  3202. pictureBall.moveOrigin(1,PictureOrigin::Center)
  3203. pictureBall.moveXY(0,1,64,256)
  3204. picturePoke.moveVisible(1,true)
  3205. picturePoke.moveOrigin(1,PictureOrigin::Center)
  3206. picturePoke.moveXY(0,1,pokecenter[0],pokecenter[1])
  3207. picturePlayer.moveVisible(1,true)
  3208. picturePlayer.moveName(1,@sprites["player"].name)
  3209. picturePlayer.moveOrigin(1,PictureOrigin::TopLeft)
  3210. picturePlayer.moveXY(0,1,playerpos[0],playerpos[1])
  3211. # directives
  3212. picturePoke.moveSE(1,"Audio/SE/Battle throw")
  3213. pictureBall.moveCurve(30,1,64,256,Graphics.width/2,48,
  3214. PokeBattle_SceneConstants::FOEBATTLER_X-48,
  3215. PokeBattle_SceneConstants::FOEBATTLER_Y)
  3216. pictureBall.moveAngle(30,1,-720)
  3217. pictureBall.moveAngle(0,pictureBall.totalDuration,0)
  3218. if armanim
  3219. picturePlayer.moveSrc(1,@sprites["player"].bitmap.height,0)
  3220. picturePlayer.moveXY(0,1,playerpos[0]-14,playerpos[1])
  3221. picturePlayer.moveSrc(4,@sprites["player"].bitmap.height*2,0)
  3222. picturePlayer.moveXY(0,4,playerpos[0]-12,playerpos[1])
  3223. picturePlayer.moveSrc(8,@sprites["player"].bitmap.height*3,0)
  3224. picturePlayer.moveXY(0,8,playerpos[0]+20,playerpos[1])
  3225. picturePlayer.moveSrc(16,@sprites["player"].bitmap.height*4,0)
  3226. picturePlayer.moveXY(0,16,playerpos[0]+16,playerpos[1])
  3227. picturePlayer.moveSrc(40,0,0)
  3228. picturePlayer.moveXY(0,40,playerpos[0],playerpos[1])
  3229. end
  3230. # Show Pokémon jumping before eating the bait
  3231. picturePoke.moveSE(50,"Audio/SE/Player jump")
  3232. picturePoke.moveXY(8,50,pokecenter[0],pokecenter[1]-8)
  3233. picturePoke.moveXY(8,58,pokecenter[0],pokecenter[1])
  3234. pictureBall.moveVisible(66,false)
  3235. picturePoke.moveSE(66,"Audio/SE/Player jump")
  3236. picturePoke.moveXY(8,66,pokecenter[0],pokecenter[1]-8)
  3237. picturePoke.moveXY(8,74,pokecenter[0],pokecenter[1])
  3238. # TODO: Show Pokémon eating the bait (pivots at the bottom right corner)
  3239. picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
  3240. picturePoke.moveXY(0,picturePoke.totalDuration,dims[0],dims[1])
  3241. loop do
  3242. pictureBall.update
  3243. picturePoke.update
  3244. picturePlayer.update
  3245. setPictureIconSprite(spriteBall,pictureBall)
  3246. setPictureSprite(spritePoke,picturePoke)
  3247. setPictureIconSprite(spritePlayer,picturePlayer)
  3248. pbGraphicsUpdate
  3249. pbInputUpdate
  3250. pbFrameUpdate
  3251. break if !pictureBall.running? && !picturePoke.running? && !picturePlayer.running?
  3252. end
  3253. spriteBall.dispose
  3254. end
  3255.  
  3256. def pbThrowRock
  3257. @briefmessage=false
  3258. ball=sprintf("Graphics/Pictures/Battle/object_rock")
  3259. anger=sprintf("Graphics/Pictures/Battle/object_anger")
  3260. armanim=false
  3261. if @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
  3262. armanim=true
  3263. end
  3264. # sprites
  3265. spritePoke=@sprites["pokemon1"]
  3266. spritePlayer=@sprites["player"]
  3267. spriteBall=IconSprite.new(0,0,@viewport)
  3268. spriteBall.visible=false
  3269. spriteAnger=IconSprite.new(0,0,@viewport)
  3270. spriteAnger.visible=false
  3271. # pictures
  3272. pictureBall=PictureEx.new(spritePoke.z+1)
  3273. picturePoke=PictureEx.new(spritePoke.z)
  3274. picturePlayer=PictureEx.new(spritePoke.z+2)
  3275. pictureAnger=PictureEx.new(spritePoke.z+1)
  3276. dims=[spritePoke.x,spritePoke.y]
  3277. pokecenter=getSpriteCenter(@sprites["pokemon1"])
  3278. playerpos=[@sprites["player"].x,@sprites["player"].y]
  3279. ballendy=PokeBattle_SceneConstants::FOEBATTLER_Y-4
  3280. # starting positions
  3281. pictureBall.moveVisible(1,true)
  3282. pictureBall.moveName(1,ball)
  3283. pictureBall.moveOrigin(1,PictureOrigin::Center)
  3284. pictureBall.moveXY(0,1,64,256)
  3285. picturePoke.moveVisible(1,true)
  3286. picturePoke.moveOrigin(1,PictureOrigin::Center)
  3287. picturePoke.moveXY(0,1,pokecenter[0],pokecenter[1])
  3288. picturePlayer.moveVisible(1,true)
  3289. picturePlayer.moveName(1,@sprites["player"].name)
  3290. picturePlayer.moveOrigin(1,PictureOrigin::TopLeft)
  3291. picturePlayer.moveXY(0,1,playerpos[0],playerpos[1])
  3292. pictureAnger.moveVisible(1,false)
  3293. pictureAnger.moveName(1,anger)
  3294. pictureAnger.moveXY(0,1,pokecenter[0]-56,pokecenter[1]-48)
  3295. pictureAnger.moveOrigin(1,PictureOrigin::Center)
  3296. pictureAnger.moveZoom(0,1,100)
  3297. # directives
  3298. picturePoke.moveSE(1,"Audio/SE/Battle throw")
  3299. pictureBall.moveCurve(30,1,64,256,Graphics.width/2,48,pokecenter[0],pokecenter[1])
  3300. pictureBall.moveAngle(30,1,-720)
  3301. pictureBall.moveAngle(0,pictureBall.totalDuration,0)
  3302. pictureBall.moveSE(30,"Audio/SE/Battle damage weak")
  3303. if armanim
  3304. picturePlayer.moveSrc(1,@sprites["player"].bitmap.height,0)
  3305. picturePlayer.moveXY(0,1,playerpos[0]-14,playerpos[1])
  3306. picturePlayer.moveSrc(4,@sprites["player"].bitmap.height*2,0)
  3307. picturePlayer.moveXY(0,4,playerpos[0]-12,playerpos[1])
  3308. picturePlayer.moveSrc(8,@sprites["player"].bitmap.height*3,0)
  3309. picturePlayer.moveXY(0,8,playerpos[0]+20,playerpos[1])
  3310. picturePlayer.moveSrc(16,@sprites["player"].bitmap.height*4,0)
  3311. picturePlayer.moveXY(0,16,playerpos[0]+16,playerpos[1])
  3312. picturePlayer.moveSrc(40,0,0)
  3313. picturePlayer.moveXY(0,40,playerpos[0],playerpos[1])
  3314. end
  3315. pictureBall.moveVisible(40,false)
  3316. # Show Pokémon being angry
  3317. pictureAnger.moveSE(48,"Audio/SE/Player jump")
  3318. pictureAnger.moveVisible(48,true)
  3319. pictureAnger.moveZoom(8,48,130)
  3320. pictureAnger.moveZoom(8,56,100)
  3321. pictureAnger.moveXY(0,64,pokecenter[0]+56,pokecenter[1]-64)
  3322. pictureAnger.moveSE(64,"Audio/SE/Player jump")
  3323. pictureAnger.moveZoom(8,64,130)
  3324. pictureAnger.moveZoom(8,72,100)
  3325. pictureAnger.moveVisible(80,false)
  3326. picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
  3327. picturePoke.moveXY(0,picturePoke.totalDuration,dims[0],dims[1])
  3328. loop do
  3329. pictureBall.update
  3330. picturePoke.update
  3331. picturePlayer.update
  3332. pictureAnger.update
  3333. setPictureIconSprite(spriteBall,pictureBall)
  3334. setPictureSprite(spritePoke,picturePoke)
  3335. setPictureIconSprite(spritePlayer,picturePlayer)
  3336. setPictureIconSprite(spriteAnger,pictureAnger)
  3337. pbGraphicsUpdate
  3338. pbInputUpdate
  3339. pbFrameUpdate
  3340. break if !pictureBall.running? && !picturePoke.running? &&
  3341. !picturePlayer.running? && !pictureAnger.running?
  3342. end
  3343. spriteBall.dispose
  3344. end
  3345. end
Add Comment
Please, Sign In to add comment