Guest User

Untitled

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