Guest User

Untitled

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