Advertisement
Guest User

elitebattle_UI

a guest
Sep 5th, 2017
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 96.96 KB | None | 0 0
  1. #===============================================================================
  2. # Elite Battle system
  3. # by Luka S.J.
  4. # ----------------
  5. # UI Script
  6. # ----------------
  7. # system is based off the original Essentials battle system, made by
  8. # Poccil & Maruno
  9. # No additional features added to AI, mechanics
  10. # or functionality of the battle system.
  11. # This update is purely cosmetic, and includes a B/W like dynamic scene with a
  12. # custom interface.
  13. #
  14. # Enjoy the script, and make sure to give credit!
  15. # (DO NOT ALTER THE NAMES OF THE INDIVIDUAL SCRIPT SECTIONS OR YOU WILL BREAK
  16. # YOUR SYSTEM!)
  17. #-------------------------------------------------------------------------------
  18. # A brand new interface for Pokemon Essentials, to be used with the dynamic
  19. # battle system. Command and Fight windows are not based upon the previous
  20. # versions. Keep that in mind if you did (or plan to do) any alterations to the
  21. # interfaces.
  22. #===============================================================================
  23. module PokeBattle_SceneConstants
  24. if EBUISTYLE > 0
  25. MESSAGEBASECOLOR = Color.new(255,255,255)
  26. MESSAGESHADOWCOLOR = Color.new(32,32,32)
  27. MENUBASECOLOR = MESSAGEBASECOLOR
  28. MENUSHADOWCOLOR = MESSAGESHADOWCOLOR
  29. BOXTEXTBASECOLOR = MESSAGEBASECOLOR
  30. BOXTEXTSHADOWCOLOR = MESSAGESHADOWCOLOR
  31. HPGAUGESIZE = 168
  32. EXPGAUGESIZE = 260
  33. end
  34. end
  35. #===============================================================================
  36. # Pokemon data battle boxes
  37. # UI overhaul
  38. #===============================================================================
  39. class PokemonNewDataBox < SpriteWrapper
  40. attr_reader :battler
  41. attr_accessor :selected
  42. attr_accessor :appearing
  43. attr_reader :animatingHP
  44. attr_reader :animatingEXP
  45.  
  46. def initialize(battler,doublebattle,viewport=nil,player=nil,scene=nil)
  47. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  48. view.z = viewport.z + 1
  49. viewport = view
  50. super(viewport)
  51. @scene=scene
  52. @explevel=0
  53. @player=player
  54. @battler=battler
  55. @doublebattle=doublebattle
  56. @selected=0
  57. @frame=0
  58. @showhp=false
  59. @showexp=false
  60. @appearing=false
  61. @animatingHP=false
  62. @starthp=0
  63. @currenthp=0
  64. @endhp=0
  65. @expflash=0
  66. if (@battler.index&1)==0 # if player's Pokémon
  67. @spritebaseX=34
  68. @playerpoke=true
  69. else
  70. @spritebaseX=16
  71. @playerpoke=false
  72. end
  73. if !doublebattle && @battler.index==0
  74. @showhp=true
  75. @showexp=true
  76. end
  77. @statuses=pbBitmap("#{checkEBFolderPath}/newStatuses")
  78. @contents=BitmapWrapper.new(264,78)
  79. self.bitmap=@contents
  80. self.visible=false
  81. self.z=50
  82. refreshExpLevel
  83. refresh
  84. end
  85.  
  86. def dispose
  87. @statuses.dispose
  88. @contents.dispose
  89. super
  90. end
  91.  
  92. def refreshExpLevel
  93. if !@battler.pokemon
  94. @explevel=0
  95. else
  96. growthrate=@battler.pokemon.growthrate
  97. startexp=PBExperience.pbGetStartExperience(@battler.pokemon.level,growthrate)
  98. endexp=PBExperience.pbGetStartExperience(@battler.pokemon.level+1,growthrate)
  99. if startexp==endexp
  100. @explevel=0
  101. else
  102. @explevel=(@battler.pokemon.exp-startexp)*PokeBattle_SceneConstants::EXPGAUGESIZE/(endexp-startexp)
  103. end
  104. end
  105. end
  106.  
  107. def exp
  108. return @animatingEXP ? @currentexp : @explevel
  109. end
  110.  
  111. def hp
  112. return @animatingHP ? @currenthp : @battler.hp
  113. end
  114.  
  115. def animateHP(oldhp,newhp)
  116. @starthp=oldhp
  117. @currenthp=oldhp
  118. @endhp=newhp
  119. @animatingHP=true
  120. end
  121.  
  122. def animateEXP(oldexp,newexp)
  123. @currentexp=oldexp
  124. @endexp=newexp
  125. @animatingEXP=true
  126. end
  127.  
  128. def appear
  129. refreshExpLevel
  130. refresh
  131. self.visible=true
  132. self.opacity=255
  133. end
  134.  
  135. def getBattler(battler)
  136. return battler.effects[PBEffects::Illusion] if PBEffects.const_defined?(:Illusion) && battler.respond_to?('effects') && !battler.effects[PBEffects::Illusion].nil?
  137. return battler
  138. end
  139.  
  140. def refresh
  141. self.bitmap.clear
  142. return if !@battler.pokemon
  143. if @playerpoke # Player Pokemon box
  144. isOutsider=(@battler.pokemon.trainerID!=@player.id || (@battler.pokemon.language!=0 && @battler.pokemon.language!=@player.language))
  145. y=0; y=1 if isOutsider;
  146. self.bitmap.blt(22,0,pbBitmap("#{checkEBFolderPath}/bbtrans"),Rect.new(0,0,242,54))
  147. y=0; y=32 if @doublebattle;
  148. self.bitmap.blt(0,36,pbBitmap("#{checkEBFolderPath}/exparea"),Rect.new(0,y,262,32))
  149. self.bitmap.blt(2,32,pbBitmap("#{checkEBFolderPath}/expbar"),Rect.new(0,y*34,self.exp,34)) if !@doublebattle
  150. self.bitmap.blt(54,40,pbBitmap("#{checkEBFolderPath}/hparea"),Rect.new(0,0,180,16))
  151.  
  152. hpGaugeSize=PokeBattle_SceneConstants::HPGAUGESIZE
  153. hpgauge=@battler.totalhp==0 ? 0 : (self.hp*hpGaugeSize/@battler.totalhp)
  154. hpgauge=2 if hpgauge==0 && self.hp > 0
  155. hpzone=0
  156. hpzone=1 if self.hp <=(@battler.totalhp/2).floor
  157. hpzone=2 if self.hp <=(@battler.totalhp/3.5).floor
  158. self.bitmap.blt(54,40,pbBitmap("#{checkEBFolderPath}/hpbars"),Rect.new(0,20*hpzone,6,20)) if self.hp > 0
  159. self.bitmap.blt(60,40,pbBitmap("#{checkEBFolderPath}/hpbars"),Rect.new(6,20*hpzone,hpgauge,20))
  160. self.bitmap.blt(60+hpgauge,40,pbBitmap("#{checkEBFolderPath}/hpbars"),Rect.new(174,20*hpzone,6,20)) if self.hp > 0
  161. y=58; y-=26 if @doublebattle;
  162. self.bitmap.blt(44,y,@statuses,Rect.new(0,17*(@battler.status-1),52,17)) if @battler.status > 0
  163. self.bitmap.blt(22,34,pbBitmap("#{checkEBFolderPath}/mega_sym"),Rect.new(0,0,30,30)) if @battler.isMega?
  164. if @battler.respond_to?(:isPrimal?) && @battler.isPrimal?
  165. path=nil
  166. path="Graphics/Pictures/battlePrimalKyogreBox.png" if @battler.species == getConst(PBSpecies,:KYOGRE)
  167. path="Graphics/Pictures/battlePrimalGroudonBox.png" if @battler.species == getConst(PBSpecies,:GROUDON)
  168. #define any custom Primal graphics here
  169. self.bitmap.blt(22,34,pbBitmap(path),Rect.new(0,0,30,30))
  170. end
  171. self.bitmap.blt(148,52,pbBitmap("#{checkEBFolderPath}/hpind"),Rect.new(0,0,76,22)) if !@doublebattle
  172. pbSetSmallFont(self.bitmap)
  173. textpos=[
  174. ["#{self.hp}/#{@battler.totalhp}",152+34,50,2,Color.new(23,28,31),Color.new(185,185,185)]
  175. ]
  176. pbDrawTextPositions(self.bitmap,textpos) if !@doublebattle
  177. pbSetSystemFont(self.bitmap)
  178. pokename=getBattler(@battler).name
  179. textpos=[
  180. [pokename,8+44,5,false,Color.new(255,255,255),Color.new(32,32,32)]
  181. ]
  182. genderX=self.bitmap.text_size(pokename).width
  183. genderX+=14+44
  184. if getBattler(@battler).gender==0 # Male
  185. textpos.push([_INTL("♂"),genderX,5,false,Color.new(48+30,96+30,216),Color.new(32,32,32)])
  186. elsif getBattler(@battler).gender==1 # Female
  187. textpos.push([_INTL("♀"),genderX,5,false,Color.new(248,88+30,40+30),Color.new(32,32,32)])
  188. end
  189. textpos.push([_INTL("Lv{1}",@battler.level),242,5,true,Color.new(255,255,255),Color.new(32,32,32)])
  190. pbDrawTextPositions(self.bitmap,textpos)
  191.  
  192. else # Enemy Pokemon box
  193.  
  194. self.bitmap.blt(0,0,pbBitmap("#{checkEBFolderPath}/bbtrans_opp"),Rect.new(0,0,242,54))
  195. y=0; y=32 if @doublebattle;
  196. self.bitmap.blt(2,36,pbBitmap("#{checkEBFolderPath}/exparea_opp"),Rect.new(0,y,262,32))
  197. self.bitmap.blt(30,40,pbBitmap("#{checkEBFolderPath}/hparea"),Rect.new(0,0,180,16))
  198.  
  199. hpGaugeSize=PokeBattle_SceneConstants::HPGAUGESIZE
  200. hpgauge=@battler.totalhp==0 ? 0 : (self.hp*hpGaugeSize/@battler.totalhp)
  201. hpgauge=2 if hpgauge==0 && self.hp > 0
  202. hpzone=0
  203. hpzone=1 if self.hp <=(@battler.totalhp/2).floor
  204. hpzone=2 if self.hp <=(@battler.totalhp/3.5).floor
  205. self.bitmap.blt(30,40,pbBitmap("#{checkEBFolderPath}/hpbars"),Rect.new(0,20*hpzone,6,20)) if self.hp > 0
  206. self.bitmap.blt(36,40,pbBitmap("#{checkEBFolderPath}/hpbars"),Rect.new(6,20*hpzone,hpgauge,20))
  207. self.bitmap.blt(36+hpgauge,40,pbBitmap("#{checkEBFolderPath}/hpbars"),Rect.new(174,20*hpzone,6,20)) if self.hp > 0
  208. self.bitmap.blt(214,34,pbBitmap("#{checkEBFolderPath}/battleBoxOwned.png"),Rect.new(0,0,14,14)) if @battler.owned
  209. self.bitmap.blt(212,34,pbBitmap("#{checkEBFolderPath}/mega_sym"),Rect.new(0,0,30,30)) if @battler.isMega?
  210. if @battler.respond_to?(:isPrimal?) && @battler.isPrimal?
  211. path=nil
  212. path="Graphics/Pictures/battlePrimalKyogreBox.png" if @battler.species == getConst(PBSpecies,:KYOGRE)
  213. path="Graphics/Pictures/battlePrimalGroudonBox.png" if @battler.species == getConst(PBSpecies,:GROUDON)
  214. #define any custom Primal graphics here
  215. self.bitmap.blt(212,34,pbBitmap(path),Rect.new(0,0,30,30))
  216. end
  217. y=58; y-=26 if @doublebattle;
  218. self.bitmap.blt(20,y,@statuses,Rect.new(0,17*(@battler.status-1),52,17)) if @battler.status > 0
  219. pbSetSystemFont(self.bitmap)
  220. pokename=getBattler(@battler).name
  221. textpos=[
  222. [pokename,8+20,5,false,Color.new(255,255,255),Color.new(32,32,32)]
  223. ]
  224. genderX=self.bitmap.text_size(pokename).width
  225. genderX+=14+20
  226. if getBattler(@battler).gender==0 # Male
  227. textpos.push([_INTL("♂"),genderX,5,false,Color.new(48+30,96+30,216),Color.new(32,32,32)])
  228. elsif getBattler(@battler).gender==1 # Female
  229. textpos.push([_INTL("♀"),genderX,5,false,Color.new(248,88+30,40+30),Color.new(32,32,32)])
  230. end
  231. textpos.push([_INTL("Lv{1}",@battler.level),218,5,true,Color.new(255,255,255),Color.new(32,32,32)])
  232. pbDrawTextPositions(self.bitmap,textpos)
  233. end
  234. end
  235.  
  236. def update
  237. super
  238. @frame+=1
  239. if @animatingHP
  240. if @currenthp < @endhp
  241. @currenthp += (@endhp - @currenthp)/10.0
  242. @currenthp = @currenthp.ceil
  243. @currenthp = @endhp if @currenthp > @endhp
  244. elsif @currenthp > @endhp
  245. @currenthp -= (@currenthp - @endhp)/10.0
  246. @currenthp = @currenthp.floor
  247. @currenthp = @endhp if @currenthp < @endhp
  248. end
  249. refresh
  250. @animatingHP=false if @currenthp==@endhp
  251. end
  252. if @animatingEXP
  253. if !@showexp
  254. @currentexp=@endexp
  255. elsif @currentexp < @endexp # Gaining Exp
  256. if @endexp >=PokeBattle_SceneConstants::EXPGAUGESIZE ||
  257. @endexp-@currentexp >=PokeBattle_SceneConstants::EXPGAUGESIZE/4
  258. @currentexp+=4
  259. else
  260. @currentexp+=2
  261. end
  262. @currentexp=@endexp if @currentexp > @endexp
  263. elsif @currentexp > @endexp # Losing Exp
  264. if @endexp==0 ||
  265. @currentexp-@endexp >=PokeBattle_SceneConstants::EXPGAUGESIZE/4
  266. @currentexp-=4
  267. elsif @currentexp > @endexp
  268. @currentexp-=2
  269. end
  270. @currentexp=@endexp if @currentexp < @endexp
  271. end
  272. refresh
  273. if @currentexp==@endexp
  274. if @currentexp==PokeBattle_SceneConstants::EXPGAUGESIZE
  275. if @expflash==0
  276. pbSEPlay(isVersion17? ? "Pkmn exp full" : "expfull")
  277. self.flash(Color.new(64,200,248),8)
  278. @expflash=8
  279. else
  280. @expflash-=1
  281. if @expflash==0
  282. @animatingEXP=false
  283. refreshExpLevel
  284. end
  285. end
  286. else
  287. @animatingEXP=false
  288. end
  289. end
  290. end
  291. end
  292. end
  293.  
  294. class NewSafariDataBox < SpriteWrapper
  295. attr_accessor :selected
  296. attr_reader :appearing
  297.  
  298. def initialize(battle,viewport=nil)
  299. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  300. view.z = viewport.z + 1
  301. viewport = view
  302. super(viewport)
  303. @selected=0
  304. @battle=battle
  305. @spriteX=PokeBattle_SceneConstants::SAFARIBOX_X
  306. @spriteY=PokeBattle_SceneConstants::SAFARIBOX_Y
  307. @appearing=false
  308. @contents=BitmapWrapper.new(264,78)
  309. self.bitmap=@contents
  310. pbSetSystemFont(self.bitmap)
  311. self.visible=false
  312. self.z=50
  313. refresh
  314. end
  315.  
  316. def appear
  317. refresh
  318. self.visible=true
  319. self.opacity=255
  320. end
  321.  
  322. def refresh
  323. self.bitmap.clear
  324. if EBUISTYLE==2
  325. bmp = pbBitmap("#{checkEBFolderPath}/nextGen/safariBar")
  326. self.bitmap.blt((self.bitmap.width-bmp.width)/2,self.bitmap.height-bmp.height,bmp,Rect.new(0,0,bmp.width,bmp.height))
  327. str = _INTL("Safari Balls: {1}",@battle.ballcount)
  328. pbDrawOutlineText(self.bitmap,0,0,self.bitmap.width,self.bitmap.height,str,Color.new(255,255,255),Color.new(0,0,0),1)
  329. else
  330. self.bitmap.blt(22,0,pbBitmap("#{checkEBFolderPath}/bbtrans"),Rect.new(0,0,242,54))
  331. self.bitmap.blt(0,36,pbBitmap("#{checkEBFolderPath}/exparea"),Rect.new(0,32,262,32))
  332. textpos=[]
  333. base=PokeBattle_SceneConstants::BOXTEXTBASECOLOR
  334. shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
  335. textpos.push([_INTL("Safari Balls: {1}",@battle.ballcount),54,8,false,base,shadow])
  336. pbDrawTextPositions(self.bitmap,textpos)
  337. end
  338. end
  339.  
  340. def update
  341. end
  342. end
  343. #===============================================================================
  344. # Party arrow
  345. # creates an arrow indicating the amount of Pokemon a trainer has
  346. #===============================================================================
  347. class NewPartyArrow
  348.  
  349. def initialize(viewport,party,player=false,doublebattle=false,secondparty=nil)
  350. @viewport = viewport
  351. @party = party
  352. @player = player
  353. @index = 0
  354.  
  355. self.draw(party,player,doublebattle,secondparty)
  356. self.x = @player ? Graphics.width+@arrow.ox : -@arrow.bitmap.width
  357. self.y = @player ? 232 : 64
  358.  
  359. @disposed = false
  360. end
  361.  
  362. def x
  363. return @arrow.x
  364. end
  365.  
  366. def y
  367. return @arrow.y - 28
  368. end
  369.  
  370. def x=(val)
  371. @arrow.x = val
  372. for i in 0...6
  373. @ball["#{i}"].x = val - @arrow.ox + 12 + (i*(@ball["#{i}"].bitmap.width+2)) + @ball["#{i}"].ox
  374. @ball["#{i}"].x += 24 if @player
  375. end
  376. end
  377.  
  378. def y=(val)
  379. @arrow.y = val + 28
  380. for i in 0...6
  381. @ball["#{i}"].y = @arrow.y - (@ball["#{i}"].bitmap.height-4) + @ball["#{i}"].oy
  382. end
  383. end
  384.  
  385. def dispose
  386. @arrow.dispose
  387. for i in 0...6
  388. @ball["#{i}"].dispose
  389. end
  390. @disposed = true
  391. end
  392.  
  393. def disposed?
  394. return @disposed
  395. end
  396.  
  397. def color; return @arrow.color; end
  398. def color=(val); @arrow.color=val; end
  399. def tone; return @arrow.tone; end
  400. def tone=(val); @arrow.tone=val; end
  401. def visible; return @arrow.visible; end
  402. def visible=(val); @arrow.visible=val; end
  403.  
  404. def draw(party,player=false,doublebattle=false,secondparty=nil)
  405. @arrow = Sprite.new(@viewport)
  406. @arrow.bitmap = pbBitmap("#{checkEBFolderPath}/partyArrow")
  407. @arrow.ox = @player ? 240 : 0
  408. @arrow.mirror = @player
  409. @ball = {}
  410. for i in 0...6
  411. k = i
  412. if !player && doublebattle && i >= 3 && !secondparty.nil?
  413. k = (i%3) + secondparty
  414. end
  415. @ball["#{i}"] = Sprite.new(@viewport)
  416. if k < party.length && party[k]
  417. if party[k].hp <=0 || party[k].isEgg?
  418. @ball["#{i}"].bitmap = pbBitmap("Graphics/Pictures/ballfainted")
  419. elsif party[k].status > 0
  420. @ball["#{i}"].bitmap = pbBitmap("Graphics/Pictures/ballstatus")
  421. else
  422. @ball["#{i}"].bitmap = pbBitmap("Graphics/Pictures/ballnormal")
  423. end
  424. else
  425. @ball["#{i}"].bitmap = pbBitmap("Graphics/Pictures/ballempty")
  426. end
  427. @ball["#{i}"].ox = @ball["#{i}"].bitmap.width/2
  428. @ball["#{i}"].oy = @ball["#{i}"].bitmap.height/2
  429. @ball["#{i}"].angle = @player ? -360 : 360
  430. end
  431. end
  432.  
  433. def show
  434. pbSEPlay("SE_Party",75) if @index%3==0 && @index < 18
  435. self.x += @player ? -15 : 15
  436. for i in 0...6
  437. @ball["#{i}"].angle -= @player ? -22.5 : 22.5
  438. end
  439. @index += 1
  440. end
  441.  
  442. def hide
  443. @arrow.zoom_x += 0.032
  444. @arrow.opacity -= 16
  445. for i in 0...6
  446. @ball["#{i}"].angle -= @player ? -22.5 : 22.5
  447. @ball["#{i}"].opacity -= 16
  448. @ball["#{i}"].x += @player ? -(5-i) : i
  449. end
  450. end
  451.  
  452. end
  453. #===============================================================================
  454. # Command Menu
  455. # UI ovarhaul
  456. #===============================================================================
  457. KleinCommandWindow = NewCommandWindow.clone if defined?(NewCommandWindow)=='constant'
  458. class NewCommandWindow
  459. attr_accessor :index
  460. attr_accessor :overlay
  461. attr_accessor :backdrop
  462. attr_accessor :coolDown
  463.  
  464. def initialize(viewport=nil,battle=nil,safari=false,viewport_top=nil)
  465. if !viewport.nil?
  466. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  467. view.z = viewport.z
  468. view2 = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  469. view2.z = viewport.z + 2
  470. viewport = view
  471. end
  472. @battle=battle
  473. @safaribattle=safari
  474. @viewport=viewport
  475. @viewport2=(viewport.nil?) ? viewport : view2
  476. @viewport3 = viewport_top
  477. @index=0
  478. @coolDown=0
  479. @over=false
  480.  
  481. @buttonBitmap=pbBitmap("#{checkEBFolderPath}/commandMenuButtons")
  482.  
  483. @texts=[
  484. [_INTL("Fight"),_INTL("Bag"),_INTL("Pokemon"),_INTL("Run")],
  485. [_INTL("Ball"),_INTL("Bait"),_INTL("Rock"),_INTL("Call")]
  486. ]
  487.  
  488. @helpText=Sprite.new(@viewport)
  489. @helpText.bitmap=Bitmap.new(Graphics.width,36)
  490. @helpText.y=VIEWPORT_HEIGHT-(104)
  491. @helpText.x=Graphics.width+8
  492. @helpText.z=100
  493. pbSetSystemFont(@helpText.bitmap)
  494.  
  495. @backdrop=Sprite.new(@viewport)
  496. @backdrop.bitmap=Bitmap.new(@viewport.rect.width,@viewport.rect.height)
  497. pbSetSystemFont(@backdrop.bitmap)
  498.  
  499. @background=Sprite.new(@viewport)
  500. @background.bitmap=pbBitmap("#{checkEBFolderPath}/newCommandBox")
  501. @background.y=VIEWPORT_HEIGHT-68
  502. @background.z=100
  503.  
  504. @bgText=Sprite.new(@viewport)
  505. @bgText.bitmap=Bitmap.new(512,98)
  506. @bgText.y=VIEWPORT_HEIGHT-68
  507. @bgText.z=110
  508. pbSetSystemFont(@bgText.bitmap)
  509. text=[]
  510.  
  511. @selHand=Sprite.new(@viewport2)
  512. @selHand.bitmap=pbBitmap("#{checkEBFolderPath}/selHand")
  513. @selHand.oy=@selHand.bitmap.height
  514. @selHand.ox=@selHand.bitmap.width/2
  515. @selHand.z=150
  516. @selHand.visible=false
  517. @animdata=[0.1,0]
  518.  
  519. @overlay=Sprite.new(@viewport2)
  520. @overlay.bitmap = Bitmap.new(@viewport2.rect.width,@viewport2.rect.height)
  521. @overlay.bitmap.blt(0,0,@backdrop.bitmap,Rect.new(0,0,@backdrop.bitmap.width,@backdrop.bitmap.height))
  522. bmp=pbBitmap("#{checkEBFolderPath}/shadeFull")
  523. @overlay.blur_sprite(3)
  524. @overlay.z = 200
  525.  
  526. @button={}
  527. ds_x=[100,38,200,362]
  528. ds_y=[92,284,296,284]
  529. for i in 0...4
  530. @button["#{i}"]=Sprite.new(@viewport)
  531. @button["#{i}"].bitmap=@buttonBitmap
  532. row=(@safaribattle) ? 1 : 0
  533. row=0 if i==3
  534.  
  535. @button["#{i}"].src_rect.set(i*116,row*48,116,48)
  536. @button["#{i}"].z=120
  537. @button["#{i}"].x=16+(i*122)
  538. @button["#{i}"].y=@background.y+12
  539. y=(i<1) ? 110 : 42
  540. x=(i<1) ? 158 : 58
  541. text.push(["#{@texts[row][i]}",78+(i*122),40,2,PokeBattle_SceneConstants::MESSAGEBASECOLOR,Color.new(41,71,77)])
  542. end
  543. pbDrawTextPositions(@bgText.bitmap,text)
  544. @bgText.x=@button["#{@index}"].x
  545. @bgText.src_rect.set((@index*122)+16,0,116,98)
  546. end
  547.  
  548. def refreshCommands(index)
  549. poke=@battle.battlers[index]
  550. for i in 0...4
  551. @button["#{i}"].dispose if @button["#{i}"] && !@button["#{i}"].disposed?
  552. end
  553. @bgText.bitmap.clear
  554. text=[]
  555. ds_x=[100,38,200,362]
  556. ds_y=[92,284,296,284]
  557. for i in 0...4
  558. @button["#{i}"]=Sprite.new(@viewport)
  559. @button["#{i}"].bitmap=@buttonBitmap
  560. row=(@safaribattle) ? 1 : 0
  561. if i==3
  562. if poke.isShadow? && poke.inHyperMode?
  563. row=1
  564. else
  565. row=0
  566. end
  567. end
  568. @button["#{i}"].src_rect.set(i*116,row*48,116,48)
  569. @button["#{i}"].z=120
  570. @button["#{i}"].x=16+(i*122)
  571. @button["#{i}"].y=@background.y+12
  572. y=(i<1) ? 110 : 42
  573. x=(i<1) ? 158 : 58
  574. text.push(["#{@texts[row][i]}",78+(i*122),40,2,PokeBattle_SceneConstants::MESSAGEBASECOLOR,Color.new(41,71,77)])
  575. end
  576. pbDrawTextPositions(@bgText.bitmap,text)
  577. end
  578.  
  579. def visible; end; def visible=(val); end
  580. def disposed?; end
  581. def dispose
  582. @viewport.dispose
  583. @viewport2.dispose
  584. @viewport3.dispose
  585. @helpText.dispose
  586. @backdrop.dispose
  587. @background.dispose
  588. @bgText.dispose
  589. @selHand.dispose
  590. pbDisposeSpriteHash(@button)
  591. end
  592. def color; end; def color=(val); end
  593.  
  594. def showText
  595. return if @helpText.x <= 0
  596. @helpText.opacity=255
  597. @helpText.x-=52
  598. end
  599.  
  600. def text=(msg)
  601. bitmap=pbBitmap("#{checkEBFolderPath}/newBattleMessageSmall")
  602. balls=pbBitmap("#{checkEBFolderPath}/newPartyBalls")
  603. @helpText.bitmap.clear
  604. @helpText.bitmap.blt(0,0,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
  605. x = EBUISTYLE==2 ? bitmap.width - 12 : bitmap.width/2
  606. a = EBUISTYLE==2 ? 1 : 2
  607. text=[["#{msg}",x,2,a,PokeBattle_SceneConstants::MESSAGEBASECOLOR,PokeBattle_SceneConstants::MESSAGESHADOWCOLOR]]
  608. pbDrawTextPositions(@helpText.bitmap,text)
  609. for i in 0...6
  610. next if @safaribattle
  611. o=3
  612. if i < @battle.party1.length && @battle.party1[i]
  613. if @battle.party1[i].hp <=0 || @battle.party1[i].isEgg?
  614. o=2
  615. elsif @battle.party1[i].status > 0
  616. o=1
  617. else
  618. o=0
  619. end
  620. end
  621. @helpText.bitmap.blt(404+(i*18),18,balls,Rect.new(o*18,0,18,18))
  622. next if !@battle.opponent
  623. enemyindex=i
  624. if @battle.doublebattle && i >=3
  625. enemyindex=(i%3)+@battle.pbSecondPartyBegin(1)
  626. end
  627. o=3
  628. if enemyindex < @battle.party2.length && @battle.party2[enemyindex]
  629. if @battle.party2[enemyindex].hp <=0 || @battle.party2[enemyindex].isEgg?
  630. o=2
  631. elsif @battle.party2[enemyindex].status > 0
  632. o=1
  633. else
  634. o=0
  635. end
  636. end
  637. @helpText.bitmap.blt(i*18,0,balls,Rect.new(o*18,0,18,18))
  638. end
  639. end
  640.  
  641. def show
  642. @overlay.opacity -= 25.5
  643. return if @background.y <= VIEWPORT_HEIGHT-68
  644. @selHand.visible=false
  645. @background.y-=7
  646. @bgText.y-=7
  647. @helpText.y-=7
  648. for i in 0...4
  649. @button["#{i}"].y=@background.y+12
  650. end
  651. end
  652.  
  653. def hide(skip=false)
  654. @selHand.visible=false
  655. @helpText.opacity-=25.5
  656. @helpText.y+=7
  657. @helpText.x=Graphics.width+8 if @helpText.opacity <=0
  658. return if skip
  659. @background.y+=7
  660. @bgText.y+=7
  661. for i in 0...4
  662. @button["#{i}"].y=@background.y+12
  663. end
  664. end
  665.  
  666. def hide_ds(initialize=false)
  667. if initialize
  668. bmp = pbBitmap("#{checkEBFolderPath}/DS/background")
  669. @overlay.bitmap.clear
  670. @overlay.bitmap.blt(0,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
  671. bmp=pbBitmap("#{checkEBFolderPath}/shadeFull")
  672. @overlay.blur_sprite(3)
  673. @overlay.bitmap.blt(0,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
  674. else
  675. @overlay.opacity+=25.5
  676. end
  677. end
  678.  
  679. def update
  680. @coolDown=0
  681. @selHand.x=@button["#{@index}"].x+@button["#{@index}"].src_rect.width/2
  682. @selHand.y=@button["#{@index}"].y
  683. @selHand.zoom_y-=@animdata[0]
  684. @selHand.visible=true
  685. @bgText.x=@button["#{@index}"].x
  686. @bgText.src_rect.set((@index*122)+16,0,116,98)
  687. @animdata[0]=-0.1 if @selHand.zoom_y <=0.5
  688. if @selHand.zoom_y >=1
  689. @animdata[0]=0
  690. @animdata[1]+=1
  691. if @animdata[1] > 14
  692. @animdata[0]=0.1
  693. @animdata[1]=0
  694. end
  695. end
  696. @over=false
  697. for i in 0...4
  698. if defined?($mouse)
  699. if $mouse.over?(@button["#{i}"])
  700. @over=true
  701. @index = i
  702. end
  703. end
  704. if @index==i
  705. @button["#{i}"].y-=1 if @button["#{i}"].y > @background.y+2
  706. else
  707. @button["#{i}"].y+=1 if @button["#{i}"].y < @background.y+12
  708. end
  709. end
  710. end
  711.  
  712. def mouseOver?
  713. return false if !defined?($mouse)
  714. return @over
  715. end
  716.  
  717. end
  718.  
  719. class PokeBattle_Scene
  720.  
  721. alias pbCommandMenu_ebs pbCommandMenu unless self.method_defined?(:pbCommandMenu_ebs)
  722. def pbCommandMenu(index)
  723. @orgPos=[@vector.x,@vector.y,@vector.angle,@vector.scale,@vector.zoom1] if @orgPos.nil?
  724. @idleTimer=0 if @idleTimer < 0
  725. return pbCommandMenu_ebs(index)
  726. end
  727.  
  728. alias pbCommandMenuEx_ebs pbCommandMenuEx unless self.method_defined?(:pbCommandMenuEx_ebs)
  729. def pbCommandMenuEx(index,texts,mode=0)
  730. return pbCommandMenuEx_ebs(index,texts,mode) if EBUISTYLE==0
  731. @ret=0
  732. clearMessageWindow
  733. if EBUISTYLE==2 && @battle.doublebattle
  734. @sprites["battlebox0"].visible = (index==0) ? true : false
  735. @sprites["battlebox2"].visible = (index==2) ? true : false
  736. @sprites["battlebox0"].positionX = (index==0) ? 0 : Graphics.width
  737. @sprites["battlebox2"].positionX = (index==2) ? 0 : Graphics.width
  738. end
  739. @sprites["battlebox0"].visible = true if !@battle.doublebattle
  740. if @battle.doublebattle && !USEBATTLEBASES && !@inCMx
  741. moveRight if index==0
  742. moveLeft if index==2
  743. end
  744. @inCMx=true
  745. cw=@commandWindow
  746. cw.refreshCommands(index)
  747. name=(@safaribattle) ? $Trainer.name : @battle.battlers[index].name
  748. cw.text=_INTL("What will {1} do?",name)
  749. pbSEPlay("SE_Zoom2",50)
  750. 10.times do
  751. cw.showText
  752. animateBattleSprites(true)
  753. pbGraphicsUpdate
  754. end
  755. pbSEPlay("SE_Zoom4",50)
  756. 10.times do
  757. cw.show
  758. animateBattleSprites(true)
  759. pbGraphicsUpdate
  760. end
  761. pbRefresh
  762. loop do
  763. pbGraphicsUpdate
  764. pbInputUpdate
  765. animateBattleSprites(true)
  766. cw.update
  767. # Update selected command
  768. if (defined?($mouse) && $mouse.active? && cw.mouseOver?)
  769. elsif Input.trigger?(Input::LEFT) && cw.coolDown <= 0
  770. if cw.index > 0
  771. pbSEPlay("SE_Select1")
  772. cw.index-=1
  773. elsif cw.index <=0
  774. pbSEPlay("SE_Select1")
  775. cw.index=3
  776. end
  777. cw.triggerLeft if EBUISTYLE==2
  778. cw.coolDown=1
  779. elsif Input.trigger?(Input::RIGHT) && cw.coolDown <= 0
  780. if cw.index < 3
  781. pbSEPlay("SE_Select1")
  782. cw.index+=1
  783. elsif cw.index >=3
  784. pbSEPlay("SE_Select1")
  785. cw.index=0
  786. end
  787. cw.triggerRight if EBUISTYLE==2
  788. cw.coolDown=1
  789. end
  790. if Input.press?(Input::CTRL) && Input.trigger?(Input::B) && $DEBUG
  791. self.moveAnimationsSelector if PokeBattle_Scene.method_defined?(:moveAnimationsSelector)
  792. end
  793. if Input.trigger?(Input::C) || (defined?($mouse) && cw.mouseOver? && $mouse.leftClick?) # Confirm choice
  794. pbSEPlay("SE_Select2")
  795. @ret=cw.index
  796. @inCMx=false if @battle.doublebattle && !USEBATTLEBASES && @ret > 0
  797. @lastcmd[index]=@ret
  798. break
  799. elsif (Input.trigger?(Input::B) || (defined?($mouse) && $mouse.rightClick?)) && index==2 && @lastcmd[0]!=2 # Cancel
  800. pbSEPlay("SE_Select2")
  801. if @battle.doublebattle && !USEBATTLEBASES
  802. moveRight if index==2
  803. moveLeft if index==0
  804. @inCMx=false
  805. end
  806. @ret=-1
  807. break
  808. end
  809. end
  810. 10.times do
  811. cw.hide(false)
  812. animateBattleSprites(true)
  813. pbGraphicsUpdate
  814. end
  815. if @ret > 0
  816. vector = @battle.doublebattle ? VECTOR2 : VECTOR1
  817. @vector.set(vector)
  818. @vector.inc=0.2
  819. if EBUISTYLE==2 && @battle.doublebattle
  820. @sprites["battlebox0"].positionX = 0
  821. @sprites["battlebox0"].visible = false
  822. @sprites["battlebox2"].positionX = Graphics.width
  823. @sprites["battlebox2"].visible = false
  824. end
  825. end
  826. return @ret
  827. end
  828.  
  829. def movePlayerBoxes(amt=6)
  830. @commandWindow.hide_ds(true) if amt < 0
  831. 10.times do
  832. @sprites["battlebox0"].y += amt if @sprites["battlebox0"]
  833. @sprites["battlebox2"].y += amt if @sprites["battlebox2"]
  834. @commandWindow.hide_ds(false) if amt < 0
  835. animateBattleSprites(true)
  836. pbGraphicsUpdate
  837. end
  838. if amt < 0
  839. 10.times do; @commandWindow.hide(false); end
  840. @commandWindow.backdrop.visible = false
  841. end
  842. end
  843. end
  844. #===============================================================================
  845. # Fight Menu
  846. # UI ovarhaul
  847. #===============================================================================
  848. KleinFightWindow = NewFightWindow.clone if defined?(NewFightWindow)=='constant'
  849. class NewFightWindow
  850. attr_accessor :index
  851. attr_accessor :battler
  852. attr_accessor :refreshpos
  853. attr_reader :nummoves
  854.  
  855. def initialize(viewport=nil)
  856. if !viewport.nil?
  857. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  858. view.z = viewport.z
  859. view2 = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  860. view2.z = viewport.z + 2
  861. viewport = view
  862. end
  863. @viewport=viewport
  864. @viewport2=(viewport.nil?) ? viewport : view2
  865. @index=0
  866. @over=false
  867. @refreshpos=false
  868. @battler=nil
  869. @nummoves=0
  870.  
  871. if EBUISTYLE==2
  872. @buttonBitmap=pbBitmap("#{checkEBFolderPath}/nextGen/moveSelButtons")
  873. else
  874. @buttonBitmap=pbBitmap("#{checkEBFolderPath}/moveSelButtons")
  875. end
  876. @categoryBitmap=pbBitmap("Graphics/Pictures/category")
  877.  
  878. @backdrop=Sprite.new(@viewport)
  879. @backdrop.bitmap=Bitmap.new(@viewport.rect.width,@viewport.rect.height)
  880. @backdrop.opacity=0
  881. @backdrop.tone=Tone.new(64,64,64)
  882.  
  883. @background=Sprite.new(@viewport)
  884. if EBUISTYLE==2
  885. @background.bitmap=pbBitmap("#{checkEBFolderPath}/nextGen/newBattleMessageBox")
  886. else
  887. @background.bitmap=pbBitmap("#{checkEBFolderPath}/newCommandBox")
  888. end
  889. @background.y=VIEWPORT_HEIGHT-98+(EBUISTYLE==2 ? 2 : 0)
  890. @background.z=100
  891.  
  892.  
  893. @selHand=Sprite.new(@viewport2)
  894. @selHand.bitmap=pbBitmap("#{checkEBFolderPath}/selHand")
  895. @selHand.oy=@selHand.bitmap.height
  896. @selHand.ox=@selHand.bitmap.width/2
  897. @selHand.z=150
  898. @selHand.visible=false
  899. @animdata=[0.1,0]
  900.  
  901. @arrow1=Sprite.new(@viewport)
  902. @arrow1.bitmap=pbBitmap("#{checkEBFolderPath}/dirArrow")
  903. @arrow1.y=@background.y+2
  904. @arrow1.z=140
  905. @arrow1.mirror=true
  906. @arrow1.opacity=0
  907.  
  908. @arrow2=Sprite.new(@viewport)
  909. @arrow2.bitmap=pbBitmap("#{checkEBFolderPath}/dirArrow")
  910. @arrow2.y=@background.y+2
  911. @arrow2.z=140
  912. @arrow2.x=Graphics.width-20
  913. @arrow2.opacity=0
  914.  
  915. @megaButton=Sprite.new(@viewport)
  916. path = (EBUISTYLE==2) ? "nextGen/" : ""
  917. @megaButton.bitmap=pbBitmap("#{checkEBFolderPath}/#{path}megaEvoButton")
  918. @megaButton.y=252
  919. @megaButton.x=-16
  920. @megaButton.z=145
  921. @megaButton.src_rect.set(0,0,116,48)
  922.  
  923. @button={}
  924. @moved=false
  925. @showMega=false
  926. @position=[]
  927. @alternate=[0,0]
  928.  
  929. end
  930.  
  931. def generateButtons
  932. @moves=@battler.moves
  933. @nummoves=0
  934. @position.clear
  935. for i in 0...4
  936. @button["#{i}"].dispose if @button["#{i}"]
  937. @button["#{i}_2"].dispose if @button["#{i}_2"]
  938. @nummoves+=1 if @moves[i] && @moves[i].id > 0
  939. end
  940. @button={}
  941. for i in 0...@moves.length
  942. @position.push(30+(i*220)-(@index*220))
  943. end
  944. if @index==3
  945. for j in 0...@position.length
  946. @position[j]+=220
  947. end
  948. end
  949. pos_y=[80,80,212,212]
  950. for i in 0...@nummoves
  951. movedata=PBMoveData.new(@moves[i].id)
  952. @button["#{i}"]=Sprite.new(@viewport)
  953. @button["#{i}"].bitmap=Bitmap.new(214,88)
  954. pbSetSystemFont(@button["#{i}"].bitmap)
  955. @button["#{i}"].z=120
  956. @button["#{i}"].x=@position[i]
  957. @button["#{i}"].y=@background.y+10
  958. baseColor=@buttonBitmap.get_pixel(4,32+(@moves[i].type*88))
  959. shadowColor=@buttonBitmap.get_pixel(20,4+(@moves[i].type*88))
  960. @button["#{i}"].bitmap.blt(0,0,@buttonBitmap,Rect.new(0,@moves[i].type*88,214,88))
  961. text=[
  962. ["#{@moves[i].name}",103,10,2,baseColor,shadowColor],
  963. ["PP: #{@moves[i].pp}/#{@moves[i].totalpp}",103-18,38,2,baseColor,shadowColor]
  964. ]
  965. pbDrawTextPositions(@button["#{i}"].bitmap,text)
  966.  
  967. @button["#{i}_2"]=Sprite.new(@viewport)
  968. @button["#{i}_2"].bitmap=Bitmap.new(214,88)
  969. @button["#{i}_2"].z=120
  970. @button["#{i}_2"].x=@position[i]
  971. @button["#{i}_2"].y=@background.y+10
  972. @button["#{i}_2"].visible=false
  973. @button["#{i}_2"].visible=true if @index==i
  974. @button["#{i}_2"].bitmap.blt(148,58,@categoryBitmap,Rect.new(0,movedata.category*28,64,28))
  975. end
  976. end
  977.  
  978. def formatBackdrop
  979. @backdrop.bitmap.clear
  980. bmp = Graphics.snap_to_bitmap
  981. @backdrop.bitmap.blt(0,0,bmp,Rect.new(0,VIEWPORT_HEIGHT+VIEWPORT_OFFSET,bmp.width,bmp.height))
  982. bmp=pbBitmap("#{checkEBFolderPath}/shadeFull")
  983. @backdrop.blur_sprite(3)
  984. @backdrop.bitmap.blt(0,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
  985. end
  986.  
  987. def show
  988. @backdrop.opacity+=25.5
  989. @selHand.visible=false
  990. @background.y-=10
  991. @arrow1.y-=10
  992. @arrow2.y-=10
  993. for i in 0...5
  994. next if !@button["#{i}"]
  995. @button["#{i}"].y=@background.y+10 if @button["#{i}"] && !@button["#{i}"].disposed?
  996. @button["#{i}_2"].y=@background.y+10 if @button["#{i}_2"] && !@button["#{i}_2"].disposed?
  997. end
  998. end
  999.  
  1000. def hide
  1001. @backdrop.opacity-=25.5
  1002. @selHand.visible=false
  1003. @background.y+=10
  1004. @megaButton.x-=10
  1005. @arrow1.y+=10
  1006. @arrow2.y+=10
  1007. @showMega=false
  1008. for i in 0...5
  1009. next if !@button["#{i}"]
  1010. @button["#{i}"].y=@background.y+10 if @button["#{i}"] && !@button["#{i}"].disposed?
  1011. @button["#{i}_2"].y=@background.y+10 if @button["#{i}_2"] && !@button["#{i}_2"].disposed?
  1012. end
  1013. end
  1014.  
  1015. def megaButton
  1016. @showMega=true
  1017. end
  1018.  
  1019. def megaButtonTrigger
  1020. @megaButton.src_rect.y+=48
  1021. @megaButton.src_rect.y=0 if @megaButton.src_rect.y >=96
  1022. end
  1023.  
  1024. def update
  1025. if @index==0 or @index==1
  1026. @arrow2.opacity+=25.5 if @arrow2.opacity < 255
  1027. elsif @index==2 or @index==3
  1028. @arrow2.opacity-=25.5 if @arrow2.opacity > 0
  1029. end
  1030. if @index==1 or @index==2 or @index==3
  1031. @arrow1.opacity+=25.5 if @arrow1.opacity < 255
  1032. elsif @index==0
  1033. @arrow1.opacity-=25.5 if @arrow1.opacity > 0
  1034. end
  1035. for i in 0...@position.length
  1036. @position[i]=30+(i*220)-(@index*220) if @index < 3 or @refreshpos
  1037. end
  1038. @refreshpos=false
  1039. for i in 0...@nummoves
  1040. @button["#{i}_2"].visible=false
  1041. @button["#{i}_2"].visible=true if @index==i
  1042. if @index==i
  1043. @button["#{i}"].y-=1 if @button["#{i}"].y > @background.y+2
  1044. else
  1045. @button["#{i}"].y+=1 if @button["#{i}"].y < @background.y+10
  1046. end
  1047. distance=@button["#{i}"].x-@position[i]
  1048. @button["#{i}"].x-=distance/10
  1049. @button["#{i}_2"].x=@button["#{i}"].x
  1050. @button["#{i}_2"].y=@button["#{i}"].y
  1051. end
  1052. if @showMega
  1053. @megaButton.x+=10 if @megaButton.x < -16
  1054. end
  1055. @selHand.x=@button["#{@index}"].x+@button["#{@index}"].src_rect.width/2
  1056. @selHand.y=@button["#{@index}"].y
  1057. @selHand.zoom_y-=@animdata[0]
  1058. @selHand.visible=true
  1059. @animdata[0]=-0.1 if @selHand.zoom_y <=0.5
  1060. if @selHand.zoom_y >=1
  1061. @animdata[0]=0
  1062. @animdata[1]+=1
  1063. if @animdata[1] > 14
  1064. @animdata[0]=0.1
  1065. @animdata[1]=0
  1066. end
  1067. end
  1068. if defined?($mouse)
  1069. @over = false
  1070. for i in 0...5
  1071. next if !@button["#{i}"]
  1072. if $mouse.over?(@button["#{i}"])
  1073. @over = true
  1074. @index = i
  1075. end
  1076. end
  1077. end
  1078.  
  1079. end
  1080.  
  1081. def dispose
  1082. @viewport.dispose
  1083. @viewport2.dispose
  1084. @selHand.dispose
  1085. @backdrop.dispose
  1086. @background.dispose
  1087. @arrow1.dispose
  1088. @arrow2.dispose
  1089. @megaButton.dispose
  1090. pbDisposeSpriteHash(@button)
  1091. end
  1092.  
  1093. def overMega?
  1094. return false if !defined?($mouse)
  1095. return $mouse.over?(@megaButton)
  1096. end
  1097.  
  1098. def mouseOver?
  1099. return false if !defined?($mouse)
  1100. return @over
  1101. end
  1102. end
  1103.  
  1104. class PokeBattle_Scene
  1105.  
  1106. alias pbFightMenu_ebs pbFightMenu unless self.method_defined?(:pbFightMenu_ebs)
  1107. def pbFightMenu(index)
  1108. return pbFightMenu_ebs(index) if EBUISTYLE==0
  1109. clearMessageWindow
  1110. if EBUISTYLE==2
  1111. @sprites["battlebox0"].visible = false if @sprites["battlebox0"]
  1112. @sprites["battlebox2"].visible = false if @sprites["battlebox2"]
  1113. end
  1114. cw = @fightWindow
  1115. mega = false
  1116. battler=@battle.battlers[index]
  1117. cw.megaButton if @battle.pbCanMegaEvolve?(index)
  1118. cw.battler=battler
  1119. lastIndex=@lastmove[index]
  1120. if battler.moves[lastIndex].id!=0
  1121. cw.index=lastIndex
  1122. else
  1123. cw.index=0
  1124. end
  1125. cw.generateButtons
  1126. pbSelectBattler(index)
  1127. pbSEPlay("SE_Zoom4",50)
  1128. moveUpperRight(cw)
  1129. pbRefresh
  1130. loop do
  1131. pbGraphicsUpdate
  1132. pbInputUpdate
  1133. animateBattleSprites(true)
  1134. cw.update
  1135. # Update selected command
  1136. if (defined?($mouse) && $mouse.active? && cw.mouseOver?)
  1137. elsif (Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)) && (EBUISTYLE==2)
  1138. pbSEPlay("SE_Select1")
  1139. cw.index=[0,1,2,3][[1,0,3,2].index(cw.index)]
  1140. cw.index=(cw.nummoves-1) if cw.index < 0
  1141. cw.index=0 if cw.index > (cw.nummoves-1)
  1142. elsif (Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN)) && (EBUISTYLE==2)
  1143. pbSEPlay("SE_Select1")
  1144. cw.index=[0,1,2,3][[2,3,0,1].index(cw.index)]
  1145. cw.index=0 if cw.index < 0
  1146. cw.index=(cw.nummoves-1) if cw.index > (cw.nummoves-1)
  1147. elsif Input.trigger?(Input::LEFT) && cw.index < 4
  1148. if cw.index > 0
  1149. pbSEPlay("SE_Select1")
  1150. cw.index-=1
  1151. else
  1152. pbSEPlay("SE_Select1")
  1153. cw.index=cw.nummoves-1
  1154. cw.refreshpos=true
  1155. end
  1156. elsif Input.trigger?(Input::RIGHT) && cw.index < 4
  1157. if cw.index < (cw.nummoves-1)
  1158. pbSEPlay("SE_Select1")
  1159. cw.index+=1
  1160. else
  1161. pbSEPlay("SE_Select1")
  1162. cw.index=0
  1163. end
  1164. end
  1165. if Input.trigger?(Input::C) || (defined?($mouse) && cw.mouseOver? && $mouse.leftClick?) # Confirm choice
  1166. if cw.index < 4
  1167. @ret=cw.index
  1168. @battle.pbRegisterMegaEvolution(index) if mega
  1169. pbSEPlay("SE_Select2")
  1170. @lastmove[index]=@ret
  1171. @idleTimer=-1
  1172. @inCMx=false
  1173. break
  1174. else
  1175. @lastmove[index]=cw.index
  1176. pbPlayCancelSE()
  1177. @ret=-1
  1178. break
  1179. end
  1180. elsif Input.trigger?(Input::A) || (defined?($mouse) && cw.overMega? && $mouse.leftClick?) # Use Mega Evolution
  1181. if @battle.pbCanMegaEvolve?(index)
  1182. if mega
  1183. mega = false
  1184. else
  1185. mega = true
  1186. end
  1187. cw.megaButtonTrigger
  1188. pbSEPlay("SE_Select3")
  1189. end
  1190. elsif Input.trigger?(Input::B) || (defined?($mouse) && $mouse.rightClick?) # Cancel fight menu
  1191. @lastmove[index]=cw.index
  1192. pbPlayCancelSE()
  1193. @ret=-1
  1194. break
  1195. end
  1196. end
  1197. if @ret > -1
  1198. vector = @battle.doublebattle ? VECTOR2 : VECTOR1
  1199. @vector.set(vector)
  1200. @orgPos=nil
  1201. @vector.inc=0.2
  1202. @vector.lock
  1203. 10.times do
  1204. cw.hide
  1205. wait(1,true)
  1206. end
  1207. else
  1208. moveLowerLeft(cw)
  1209. end
  1210. if EBUISTYLE==2 && !@battle.doublebattle
  1211. @sprites["battlebox0"].visible = true if @sprites["battlebox0"]
  1212. @sprites["battlebox2"].visible = true if @sprites["battlebox2"]
  1213. end
  1214. @sprites["battlebox#{index}"].visible = true if EBUISTYLE==2 && @doublebattle
  1215. if EBUISTYLE==2 && @battle.doublebattle
  1216. @sprites["battlebox0"].positionX = 0
  1217. @sprites["battlebox2"].positionX = Graphics.width
  1218. end
  1219. return @ret
  1220. end
  1221.  
  1222. alias pbChooseTarget_ebs pbChooseTarget unless self.method_defined?(:pbChooseTarget_ebs)
  1223. def pbChooseTarget(*args)
  1224. if EBUISTYLE==0
  1225. return pbChooseTarget_ebs(*args)
  1226. end
  1227. index, targettype = args
  1228. curwindow=pbFirstTarget(*args)
  1229. if curwindow==-1
  1230. raise RuntimeError.new(_INTL("No targets somehow..."))
  1231. end
  1232. loop do
  1233. pbGraphicsUpdate
  1234. pbInputUpdate
  1235. pbUpdateSelected(curwindow)
  1236. if Input.trigger?(Input::C)
  1237. pbUpdateSelected(-1)
  1238. @ret=curwindow
  1239. break
  1240. end
  1241. if Input.trigger?(Input::B)
  1242. pbUpdateSelected(-1)
  1243. @ret=-1
  1244. break
  1245. end
  1246. if Input.trigger?(Input::RIGHT) && !(curwindow==3 or curwindow==2)
  1247. pbPlayCursorSE()
  1248. newcurwindow=3 if curwindow==1
  1249. newcurwindow=2 if curwindow==0
  1250. curwindow=newcurwindow if ((newcurwindow!=index) || (targettype==PBTargets::UserOrPartner)) && !@battle.battlers[newcurwindow].isFainted?
  1251. elsif Input.trigger?(Input::DOWN) && !(curwindow==0 or curwindow==2)
  1252. pbPlayCursorSE()
  1253. newcurwindow=0 if curwindow==1
  1254. newcurwindow=2 if curwindow==3
  1255. curwindow=newcurwindow if ((newcurwindow!=index) || (targettype==PBTargets::UserOrPartner)) && !@battle.battlers[newcurwindow].isFainted?
  1256. elsif Input.trigger?(Input::LEFT) && !(curwindow==1 or curwindow==0)
  1257. pbPlayCursorSE()
  1258. newcurwindow=1 if curwindow==3
  1259. newcurwindow=0 if curwindow==2
  1260. curwindow=newcurwindow if ((newcurwindow!=index) || (targettype==PBTargets::UserOrPartner)) && !@battle.battlers[newcurwindow].isFainted?
  1261. elsif Input.trigger?(Input::UP) && !(curwindow==3 or curwindow==1)
  1262. pbPlayCursorSE()
  1263. newcurwindow=3 if curwindow==2
  1264. newcurwindow=1 if curwindow==0
  1265. curwindow=newcurwindow if ((newcurwindow!=index) || (targettype==PBTargets::UserOrPartner)) && !@battle.battlers[newcurwindow].isFainted?
  1266. end
  1267. #
  1268. @sprites["shades"].opacity+=15 if @sprites["shades"].opacity < 150
  1269. for i in 0...4
  1270. if @sprites["pokemon#{i}"]
  1271. if index==i or curwindow==i
  1272. increaseTone(@sprites["pokemon#{i}"],-10) if @sprites["pokemon#{i}"].tone.red > 0
  1273. else
  1274. increaseTone(@sprites["pokemon#{i}"],10) if @sprites["pokemon#{i}"].tone.red < 80
  1275. end
  1276. end
  1277. end
  1278. #
  1279. end
  1280. 10.times do
  1281. @sprites["shades"].opacity-=15 if @sprites["shades"].opacity > 0
  1282. for i in 0...4
  1283. increaseTone(@sprites["pokemon#{i}"],-10) if @sprites["pokemon#{i}"] && @sprites["pokemon#{i}"].tone.red > 0
  1284. end
  1285. animateBattleSprites(true)
  1286. pbGraphicsUpdate
  1287. end
  1288. if EBUISTYLE==2 && @battle.doublebattle
  1289. @sprites["battlebox0"].positionX = 0
  1290. @sprites["battlebox2"].positionX = Graphics.width
  1291. end
  1292. return @ret
  1293. end
  1294.  
  1295. end
  1296.  
  1297. def increaseTone(sprite,amount)
  1298. sprite.tone.red+=amount
  1299. sprite.tone.green+=amount
  1300. sprite.tone.blue+=amount
  1301. end
  1302. #===============================================================================
  1303. # Command Choices
  1304. # UI ovarhaul
  1305. #===============================================================================
  1306. class NewChoiceSel
  1307. attr_accessor :index
  1308. attr_reader :over
  1309.  
  1310. def initialize(viewport,commands)
  1311. @commands=commands
  1312. @index=0
  1313. @over=false
  1314. offset = 0
  1315. @viewport=Viewport.new(0,offset,Graphics.width,VIEWPORT_HEIGHT)
  1316. @viewport.z=viewport.z+5
  1317. @sprites={}
  1318. @sprites["back"]=Sprite.new(@viewport)
  1319. @sprites["back"].bitmap=pbBitmap(EBUISTYLE==2 ? "#{checkEBFolderPath}/nextGen/shadeRest" : "#{checkEBFolderPath}/shadeRest")
  1320. @sprites["back"].opacity=0
  1321. bitmap=pbBitmap("#{checkEBFolderPath}/choiceSel")
  1322. baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
  1323. shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
  1324. @sprites["sel"]=Sprite.new(@viewport)
  1325. @sprites["sel"].bitmap=bitmap
  1326. @sprites["sel"].src_rect.set(160,0,160,62)
  1327. @sprites["sel"].y=220
  1328. @sprites["sel"].x=-150
  1329. for i in 0...@commands.length
  1330. @sprites["choice#{i}"]=Sprite.new(@viewport)
  1331. @sprites["choice#{i}"].x=80+(i*192)
  1332. @sprites["choice#{i}"].y=VIEWPORT_HEIGHT
  1333. @sprites["choice#{i}"].bitmap=Bitmap.new(160,62)
  1334. choice=@sprites["choice#{i}"].bitmap
  1335. pbSetSystemFont(choice)
  1336. choice.blt(0,0,bitmap,Rect.new(0,0,160,62))
  1337. pbDrawOutlineText(choice,0,0,160,62,@commands[i],baseColor,shadowColor,1)
  1338. end
  1339. end
  1340.  
  1341. def dispose(scene)
  1342. 5.times do
  1343. @sprites["back"].opacity-=51
  1344. @sprites["sel"].opacity-=51
  1345. for i in 0...@commands.length
  1346. @sprites["choice#{i}"].opacity-=51
  1347. end
  1348. @sprites["choice#{@index}"].y+=2
  1349. scene.animateBattleSprites(true)
  1350. scene.pbGraphicsUpdate
  1351. end
  1352. pbDisposeSpriteHash(@sprites)
  1353. @viewport.dispose
  1354. end
  1355.  
  1356. def update
  1357. @sprites["sel"].x=@sprites["choice#{@index}"].x
  1358. @sprites["back"].opacity+=25.5 if @sprites["back"].opacity < 255
  1359. if (defined?($mouse) && $mouse.active? && @over)
  1360. elsif Input.trigger?(Input::LEFT)
  1361. pbSEPlay("SE_Select1")
  1362. @index-=1
  1363. @index=@commands.length-1 if @index < 0
  1364. @sprites["choice#{@index}"].src_rect.y+=6
  1365. elsif Input.trigger?(Input::RIGHT)
  1366. pbSEPlay("SE_Select1")
  1367. @index+=1
  1368. @index=0 if @index >=@commands.length
  1369. @sprites["choice#{@index}"].src_rect.y+=6
  1370. end
  1371. @over=false
  1372. if defined?($mouse)
  1373. for i in 0...2
  1374. if $mouse.over?(@sprites["choice#{i}"])
  1375. @index = i
  1376. @over=true
  1377. end
  1378. end
  1379. end
  1380. for i in 0...@commands.length
  1381. @sprites["choice#{i}"].src_rect.y-=1 if @sprites["choice#{i}"].src_rect.y > 0
  1382. @sprites["choice#{i}"].y-=(@sprites["choice#{i}"].y-220)*0.4
  1383. end
  1384. end
  1385.  
  1386. end
  1387. #===============================================================================
  1388. # Battle Bag interface
  1389. # UI ovarhaul
  1390. #===============================================================================
  1391. def pbIsMedicine?(item)
  1392. return $ItemData[item] && !($ItemData[item][ITEMTYPE]==5) &&($ItemData[item][ITEMBATTLEUSE]==1)
  1393. end
  1394.  
  1395. def pbIsBattleItem?(item)
  1396. return $ItemData[item] && !($ItemData[item][ITEMTYPE]==3 || $ItemData[item][ITEMTYPE]==4) && ($ItemData[item][ITEMBATTLEUSE]==2)
  1397. end
  1398.  
  1399. class NewBattleBag
  1400. attr_reader :index
  1401. attr_reader :ret
  1402.  
  1403. def pbDisplayMessage(msg)
  1404. @scene.changeMessageViewport(@viewport)
  1405. @scene.pbDisplayMessage(msg)
  1406. @scene.clearMessageWindow
  1407. @scene.changeMessageViewport
  1408. end
  1409.  
  1410. def initialize(scene,viewport)
  1411. @scene=scene
  1412. $lastUsed=0 if $lastUsed.nil?
  1413. offset=0
  1414. @background=Viewport.new(0,offset,Graphics.width,VIEWPORT_HEIGHT)
  1415. @background.z=viewport.z+5
  1416. @viewport=Viewport.new(0,offset,Graphics.width,VIEWPORT_HEIGHT)
  1417. @viewport.z=viewport.z+5
  1418. @lastUsed=$lastUsed
  1419. @index=0
  1420. @item=0
  1421. @page=-1
  1422. @selPocket=0
  1423. @ret=nil
  1424. @over=false
  1425. @baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
  1426. @shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
  1427.  
  1428. @sprites={}
  1429. @items={}
  1430. path = (EBUISTYLE==2) ? "nextGen/" : ""
  1431. @bitmaps=[pbBitmap("#{checkEBFolderPath}/battleBagChoices"),pbBitmap("#{checkEBFolderPath}/battleBagLast"),pbBitmap("#{checkEBFolderPath}/#{path}battleBackButtons")]
  1432. @sprites["back"]=Sprite.new(@background)
  1433. @sprites["back"].bitmap=pbBitmap("#{checkEBFolderPath}/shadeFull")
  1434. @sprites["back"].opacity=0
  1435. @sprites["sel"]=Sprite.new(@viewport)
  1436. @sprites["sel"].x=-216
  1437. @sprites["sel"].y=34
  1438. @sprites["name"]=Sprite.new(@viewport)
  1439. @sprites["name"].bitmap=Bitmap.new(380,44)
  1440. pbSetSystemFont(@sprites["name"].bitmap)
  1441. @sprites["name"].x=-380
  1442. @sprites["name"].y=328
  1443. for i in 0...4
  1444. @sprites["pocket#{i}"]=Sprite.new(@viewport)
  1445. @sprites["pocket#{i}"].bitmap=@bitmaps[0]
  1446. @sprites["pocket#{i}"].src_rect.set(216*i,0,216,92)
  1447. @sprites["pocket#{i}"].x=24+(i%2)*244+((i%2==0) ? -260 : 260)
  1448. @sprites["pocket#{i}"].y=34+(i/2)*118+(i%2)*42
  1449. end
  1450. @sprites["pocket4"]=Sprite.new(@viewport)
  1451. @sprites["pocket4"].bitmap=Bitmap.new(356,60)
  1452. pbSetSystemFont(@sprites["pocket4"].bitmap)
  1453. @sprites["pocket4"].x=24
  1454. @sprites["pocket4"].y=316+80
  1455. self.refresh
  1456. @sprites["pocket5"]=Sprite.new(@viewport)
  1457. @sprites["pocket5"].bitmap=@bitmaps[2]
  1458. @sprites["pocket5"].src_rect.set(0,0,120,52)
  1459. @sprites["pocket5"].x=384
  1460. @sprites["pocket5"].y=320+80
  1461. @sprites["pocket5"].z=5
  1462.  
  1463. @sprites["confirm"]=Sprite.new(@viewport)
  1464. @sprites["confirm"].bitmap=Bitmap.new(466,156)
  1465. pbSetSmallFont(@sprites["confirm"].bitmap)
  1466. @sprites["confirm"].x=26-520
  1467. @sprites["confirm"].y=80
  1468. @sprites["cancel"]=Sprite.new(@viewport)
  1469. @sprites["cancel"].bitmap=pbBitmap("#{checkEBFolderPath}/battleItemConfirm")
  1470. @sprites["cancel"].src_rect.set(466,0,466,72)
  1471. @sprites["cancel"].x=26-520
  1472. @sprites["cancel"].y=234
  1473. end
  1474.  
  1475. def checkPockets
  1476. @mergedPockets = []
  1477. for i in 0...$PokemonBag.pockets.length
  1478. @mergedPockets+=$PokemonBag.pockets[i]
  1479. end
  1480. end
  1481.  
  1482. def drawPocket(pocket,index)
  1483. @pocket=[]
  1484. @pgtrigger=false
  1485. self.checkPockets
  1486. for item in @mergedPockets
  1487. next if item.nil?
  1488. next if !(ItemHandlers.hasUseInBattle(item[0]) || ItemHandlers.hasBattleUseOnPokemon(item[0]) || ItemHandlers.hasBattleUseOnBattler(item[0]))
  1489. case index
  1490. when 0 # Medicine
  1491. @pocket.push([item[0],item[1]]) if pbIsMedicine?(item[0])
  1492. when 1 # Pokeballs
  1493. @pocket.push([item[0],item[1]]) if pbIsPokeBall?(item[0])
  1494. when 2 # Berries
  1495. @pocket.push([item[0],item[1]]) if pbIsBerry?(item[0])
  1496. when 3 # Battle Items
  1497. @pocket.push([item[0],item[1]]) if pbIsBattleItem?(item[0])
  1498. end
  1499. end
  1500. if @pocket.length < 1
  1501. pbDisplayMessage(_INTL("You have no usable items in this pocket."))
  1502. return
  1503. end
  1504. @xpos=[]
  1505. @pages=@pocket.length/6
  1506. @pages+=1 if @pocket.length%6 > 0
  1507. @page=0
  1508. @item=0
  1509. @back=false
  1510. @selPocket=pocket
  1511. pbDisposeSpriteHash(@items)
  1512. @pname=pbPocketNames[pocket]
  1513. x=0
  1514. y=0
  1515. for j in 0...@pocket.length
  1516. i=j
  1517. @items["#{j}"]=Sprite.new(@viewport)
  1518. @items["#{j}"].bitmap=Bitmap.new(216,92)
  1519. pbSetSystemFont(@items["#{j}"].bitmap)
  1520. @items["#{j}"].bitmap.blt(0,0,@bitmaps[0],Rect.new(216*5,0,216,92))
  1521. @items["#{j}"].bitmap.blt(156,32,pbBitmap(sprintf("Graphics/Icons/item%03d",@pocket[i][0])),Rect.new(0,0,48,48))
  1522. pbDrawOutlineText(@items["#{j}"].bitmap,8,8,200,38,"#{PBItems.getName(@pocket[i][0])}",@baseColor,@shadowColor,1)
  1523. pbDrawOutlineText(@items["#{j}"].bitmap,8,46,200,38,"x#{@pocket[i][1]}",@baseColor,@shadowColor,1)
  1524.  
  1525. @items["#{j}"].x=28+x*246+(i/6)*512+512
  1526. @xpos.push(@items["#{j}"].x-512)
  1527. @items["#{j}"].y=28+y*90
  1528. @items["#{j}"].opacity=255
  1529. x+=1
  1530. y+=1 if x > 1
  1531. x=0 if x > 1
  1532. y=0 if y > 2
  1533. end
  1534. end
  1535.  
  1536. def name
  1537. bitmap=@sprites["name"].bitmap
  1538. bitmap.clear
  1539. bitmap.blt(0,0,pbBitmap("#{checkEBFolderPath}/battleLastItem"),Rect.new(0,0,320,44))
  1540. pbDrawOutlineText(bitmap,0,0,320,36,@pname,@baseColor,@shadowColor,1)
  1541. pbDrawOutlineText(bitmap,300,0,80,36,"#{@page+1}/#{@pages}",@baseColor,@shadowColor,1)
  1542. @sprites["name"].x+=38 if @sprites["name"].x < 0
  1543. end
  1544.  
  1545. def updatePocket
  1546. @page=@item/6
  1547. self.name
  1548. for i in 0...@pocket.length
  1549. @items["#{i}"].x-=(@items["#{i}"].x-(@xpos[i]-@page*512))*0.2
  1550. @items["#{i}"].src_rect.y-=1 if @items["#{i}"].src_rect.y > 0
  1551. end
  1552. if @back
  1553. @sprites["sel"].bitmap=@bitmaps[2]
  1554. @sprites["sel"].src_rect.set(120*2,0,120,52)
  1555. @sprites["sel"].x=@sprites["pocket5"].x
  1556. @sprites["sel"].y=@sprites["pocket5"].y
  1557. else
  1558. @sprites["sel"].bitmap=@bitmaps[0]
  1559. @sprites["sel"].src_rect.set(216*4,0,216,92)
  1560. @sprites["sel"].x=@items["#{@item}"].x
  1561. @sprites["sel"].y=@items["#{@item}"].y
  1562. end
  1563. @sprites["pocket5"].src_rect.y-=1 if @sprites["pocket5"].src_rect.y > 0
  1564. if (defined?($mouse) && $mouse.active? && @over)
  1565. elsif Input.trigger?(Input::LEFT) && !@back
  1566. pbSEPlay("SE_Select1")
  1567. if ![0,2,4].include?(@item)
  1568. if @item%2==0
  1569. @item-=5
  1570. else
  1571. @item-=1
  1572. end
  1573. else
  1574. @item-=1 if @item < 0
  1575. end
  1576. @item=0 if @item < 0
  1577. @items["#{@item}"].src_rect.y+=6
  1578. elsif Input.trigger?(Input::RIGHT) && !@back
  1579. pbSEPlay("SE_Select1")
  1580. if @page < (@pocket.length)/6
  1581. if @item%2==1
  1582. @item+=5
  1583. else
  1584. @item+=1
  1585. end
  1586. else
  1587. @item+=1 if @item < @pocket.length-1
  1588. end
  1589. @item=@pocket.length-1 if @item > @pocket.length-1
  1590. @items["#{@item}"].src_rect.y+=6
  1591. elsif Input.trigger?(Input::UP)
  1592. pbSEPlay("SE_Select1")
  1593. if @back
  1594. @item+=4 if (@item%6) < 2
  1595. @back=false
  1596. else
  1597. @item-=2
  1598. if (@item%6) > 3
  1599. @item+=6
  1600. @back=true
  1601. end
  1602. end
  1603. @item=0 if @item < 0
  1604. @item=@pocket.length-1 if @item > @pocket.length-1
  1605. @items["#{@item}"].src_rect.y+=6 if !@back
  1606. @sprites["pocket5"].src_rect.y+=6 if @back
  1607. elsif Input.trigger?(Input::DOWN)
  1608. pbSEPlay("SE_Select1")
  1609. if @back
  1610. @item-=4 if (@item%6) > 3
  1611. @back=false
  1612. else
  1613. @item+=2
  1614. if (@item%6) < 2
  1615. @item-=6
  1616. @back=true
  1617. end
  1618. @back=true if @item > @pocket.length-1
  1619. end
  1620. @item=@pocket.length-1 if @item > @pocket.length-1
  1621. @item=0 if @item < 0
  1622. @items["#{@item}"].src_rect.y+=6 if !@back
  1623. @sprites["pocket5"].src_rect.y+=6 if @back
  1624. end
  1625. @over=false
  1626. if defined?($mouse)
  1627. for i in 0...@pocket.length
  1628. if $mouse.over?(@items["#{i}"])
  1629. @item = i
  1630. @back=false
  1631. @over=true
  1632. end
  1633. end
  1634. if $mouse.inArea?(Graphics.width-32,@viewport.rect.y,32,@viewport.rect.height) && @page < (@pocket.length)/6
  1635. if !@pgtrigger
  1636. @item+=5 if !(@item+5 > @pocket.length-1)
  1637. @item=@pocket.length-1 if @item > @pocket.length-1
  1638. end
  1639. @pgtrigger=true
  1640. end
  1641. if $mouse.inArea?(0,@viewport.rect.y,32,@viewport.rect.height) && @page > 0
  1642. if !@pgtrigger
  1643. @item-=5 if !(@item-5 < 0)
  1644. @item=0 if @item < 0
  1645. end
  1646. @pgtrigger=true
  1647. end
  1648. @pgtrigger=false if !$mouse.inArea?(Graphics.width-32,@viewport.rect.y,32,@viewport.rect.height) && !$mouse.inArea?(0,@viewport.rect.y,32,@viewport.rect.height)
  1649. if $mouse.over?(@sprites["pocket5"])
  1650. @back=true
  1651. @over=true
  1652. end
  1653. end
  1654. if (@back && (Input.trigger?(Input::C) || (defined?($mouse) && @over && $mouse.leftClick?))) || Input.trigger?(Input::B)
  1655. pbSEPlay("SE_Select3")
  1656. @selPocket=0
  1657. @page=-1
  1658. @back=false
  1659. @doubleback=true
  1660. end
  1661. end
  1662.  
  1663. def closeCurrent
  1664. @selPocket=0
  1665. @page=-1
  1666. @back=false
  1667. @ret=nil
  1668. self.refresh
  1669. end
  1670.  
  1671. def show
  1672. @ret=nil
  1673. self.refresh
  1674. for i in 0...6
  1675. @sprites["pocket#{i}"].opacity=255
  1676. end
  1677. @sprites["pocket4"].y=316+80
  1678. @sprites["pocket5"].y=320+80
  1679. pbSEPlay("SE_Zoom4",60)
  1680. 10.times do
  1681. for i in 0...4
  1682. @sprites["pocket#{i}"].x+=((i%2==0) ? 26 : -26)
  1683. end
  1684. for i in 4...6
  1685. @sprites["pocket#{i}"].y-=8
  1686. end
  1687. @sprites["back"].opacity+=25.5
  1688. @scene.animateBattleSprites(true)
  1689. @scene.pbGraphicsUpdate
  1690. end
  1691. end
  1692.  
  1693. def hide
  1694. @sprites["sel"].x=Graphics.width
  1695. 10.times do
  1696. for i in 0...4
  1697. @sprites["pocket#{i}"].x-=((i%2==0) ? 26 : -26)
  1698. end
  1699. for i in 4...6
  1700. @sprites["pocket#{i}"].y+=8
  1701. end
  1702. if @pocket
  1703. for i in 0...@pocket.length
  1704. @items["#{i}"].opacity-=25.5
  1705. end
  1706. end
  1707. @sprites["name"].x-=38 if @sprites["name"].x > -380
  1708. @sprites["back"].opacity-=25.5
  1709. @scene.animateBattleSprites(true)
  1710. @scene.pbGraphicsUpdate
  1711. end
  1712. end
  1713.  
  1714. def useItem?
  1715. Input.update
  1716. bitmap=@sprites["confirm"].bitmap
  1717. bitmap.clear
  1718. bitmap.blt(0,0,pbBitmap("#{checkEBFolderPath}/battleItemConfirm"),Rect.new(0,0,466,156))
  1719. bitmap.blt(20,30,pbBitmap(sprintf("Graphics/Icons/item%03d",@ret)),Rect.new(0,0,48,48))
  1720. drawTextEx(bitmap,80,12,364,3,pbGetMessage(MessageTypes::ItemDescriptions,@ret),@shadowColor,Color.new(200,200,200))
  1721. @sprites["sel"].bitmap=pbBitmap("#{checkEBFolderPath}/battleItemConfirm")
  1722. @sprites["sel"].x=Graphics.width
  1723. @sprites["sel"].src_rect.width=466
  1724. 10.times do
  1725. @sprites["confirm"].x+=52
  1726. @sprites["cancel"].x+=52
  1727. if @pocket
  1728. for i in 0...@pocket.length
  1729. @items["#{i}"].opacity-=25.5
  1730. end
  1731. end
  1732. for i in 0...4
  1733. @sprites["pocket#{i}"].opacity-=51 if @sprites["pocket#{i}"].opacity > 0
  1734. end
  1735. @sprites["pocket4"].y+=8 if @sprites["pocket4"].y < 316+80
  1736. @sprites["pocket5"].y+=8 if @sprites["pocket5"].y < 400
  1737. @sprites["name"].x-=38
  1738. @scene.animateBattleSprites
  1739. @scene.pbGraphicsUpdate
  1740. end
  1741. @sprites["name"].x=-380
  1742. index=0
  1743. choice=(index==0) ? "confirm" : "cancel"
  1744. loop do
  1745. @sprites["sel"].x=@sprites["#{choice}"].x
  1746. @sprites["sel"].y=@sprites["#{choice}"].y
  1747. @sprites["sel"].src_rect.x=(466*(index+2))
  1748. @sprites["#{choice}"].src_rect.y-=1 if @sprites["#{choice}"].src_rect.y > 0
  1749. if (defined?($mouse) && $mouse.active? && @over)
  1750. elsif Input.trigger?(Input::UP)
  1751. pbSEPlay("SE_Select1")
  1752. index-=1
  1753. index=1 if index < 0
  1754. choice=(index==0) ? "confirm" : "cancel"
  1755. @sprites["#{choice}"].src_rect.y+=6
  1756. elsif Input.trigger?(Input::DOWN)
  1757. pbSEPlay("SE_Select1")
  1758. index+=1
  1759. index=0 if index > 1
  1760. choice=(index==0) ? "confirm" : "cancel"
  1761. @sprites["#{choice}"].src_rect.y+=6
  1762. end
  1763. @over=false
  1764. for i in 0...2
  1765. if defined?($mouse)
  1766. c=(i==0) ? "confirm" : "cancel"
  1767. if $mouse.over?(@sprites["#{c}"])
  1768. choice=(i==0) ? "confirm" : "cancel"
  1769. index = i
  1770. @over=true
  1771. end
  1772. end
  1773. end
  1774. if Input.trigger?(Input::C) || (defined?($mouse) && @over && $mouse.leftClick?)
  1775. pbSEPlay("SE_Select2")
  1776. break
  1777. end
  1778. Input.update
  1779. @scene.animateBattleSprites
  1780. @scene.pbGraphicsUpdate
  1781. end
  1782. @sprites["sel"].x=Graphics.width
  1783. self.refresh
  1784. 10.times do
  1785. @sprites["confirm"].x-=52
  1786. @sprites["cancel"].x-=52
  1787. @sprites["pocket5"].y-=8 if index > 0
  1788. @scene.animateBattleSprites
  1789. @scene.pbGraphicsUpdate
  1790. end
  1791. if index > 0
  1792. @ret=nil
  1793. return false
  1794. else
  1795. @index=0 if @index==4 && @lastUsed==0
  1796. return true
  1797. end
  1798. end
  1799.  
  1800. def finish
  1801. if (Input.trigger?(Input::B) || ((Input.trigger?(Input::C) || (defined?($mouse) && @over && $mouse.leftClick?)) && @index==5)) && @selPocket==0 && !@doubleback
  1802. pbSEPlay("SE_Select3")
  1803. return true
  1804. end
  1805. @doubleback=false
  1806. return false
  1807. end
  1808.  
  1809. def refresh
  1810. bitmap=@sprites["pocket4"].bitmap
  1811. bitmap.clear
  1812. i=(@lastUsed > 0 ? 1 : 0)
  1813. text=["","#{PBItems.getName(@lastUsed)}"]
  1814. bitmap.blt(0,0,@bitmaps[1],Rect.new(i*356,0,356,60))
  1815. bitmap.blt(28,6,pbBitmap(sprintf("Graphics/Icons/item%03d",@lastUsed)),Rect.new(0,0,48,48)) if @lastUsed>0
  1816. pbDrawOutlineText(bitmap,0,0,356,60,text[i],@baseColor,@shadowColor,1)
  1817. end
  1818.  
  1819. def update
  1820. if @selPocket==0
  1821. updateMain
  1822. for i in 0...4
  1823. @sprites["pocket#{i}"].opacity+=51 if @sprites["pocket#{i}"].opacity < 255
  1824. end
  1825. @sprites["pocket4"].y-=8 if @sprites["pocket4"].y > 316
  1826. if @pocket
  1827. for i in 0...@pocket.length
  1828. @items["#{i}"].opacity-=51 if @items["#{i}"] && @items["#{i}"].opacity > 0
  1829. end
  1830. end
  1831. @sprites["name"].x-=38 if @sprites["name"].x > -380
  1832. else
  1833. if (Input.trigger?(Input::C) || (defined?($mouse) && @over && $mouse.leftClick?)) && !@back
  1834. pbSEPlay("SE_Select2")
  1835. @selPocket=0
  1836. @page=-1
  1837. @lastUsed=0
  1838. @lastUsed=@pocket[@item][0] if @pocket[@item][1] > 1
  1839. $lastUsed=@lastUsed
  1840. @ret=@pocket[@item][0]
  1841. end
  1842. updatePocket
  1843. for i in 0...4
  1844. @sprites["pocket#{i}"].opacity-=51 if @sprites["pocket#{i}"].opacity > 0
  1845. end
  1846. @sprites["pocket4"].y+=8 if @sprites["pocket4"].y < 316+80
  1847. for i in 0...@pocket.length
  1848. @items["#{i}"].opacity+=51 if @items["#{i}"] && @items["#{i}"].opacity < 255
  1849. end
  1850. end
  1851. end
  1852.  
  1853. def updateMain
  1854. if @index < 4
  1855. @sprites["sel"].bitmap=@bitmaps[0]
  1856. @sprites["sel"].src_rect.set(216*4,0,216,92)
  1857. elsif @index==4
  1858. @sprites["sel"].bitmap=@bitmaps[1]
  1859. @sprites["sel"].src_rect.set(356*2,0,356,60)
  1860. else
  1861. @sprites["sel"].bitmap=@bitmaps[2]
  1862. @sprites["sel"].src_rect.set(120*2,0,120,52)
  1863. end
  1864. @sprites["sel"].x=@sprites["pocket#{@index}"].x
  1865. @sprites["sel"].y=@sprites["pocket#{@index}"].y
  1866. if (defined?($mouse) && $mouse.active? && @over)
  1867. elsif Input.trigger?(Input::LEFT)
  1868. pbSEPlay("SE_Select1")
  1869. @index-=1
  1870. @index+=2 if @index%2==1
  1871. @index=3 if @index==4 && !(@lastUsed > 0)
  1872. @sprites["pocket#{@index}"].src_rect.y+=6
  1873. elsif Input.trigger?(Input::RIGHT)
  1874. pbSEPlay("SE_Select1")
  1875. @index+=1
  1876. @index-=2 if @index%2==0
  1877. @index=2 if @index==4 && !(@lastUsed > 0)
  1878. @sprites["pocket#{@index}"].src_rect.y+=6
  1879. elsif Input.trigger?(Input::UP)
  1880. pbSEPlay("SE_Select1")
  1881. @index-=2
  1882. @index+=6 if @index < 0
  1883. @index=5 if @index==4 && !(@lastUsed > 0)
  1884. @sprites["pocket#{@index}"].src_rect.y+=6
  1885. elsif Input.trigger?(Input::DOWN)
  1886. pbSEPlay("SE_Select1")
  1887. @index+=2
  1888. @index-=6 if @index > 5
  1889. @index=5 if @index==4 && !(@lastUsed > 0)
  1890. @sprites["pocket#{@index}"].src_rect.y+=6
  1891. end
  1892. @over = false
  1893. for i in 0...6
  1894. if defined?($mouse)
  1895. if $mouse.over?(@sprites["pocket#{i}"])
  1896. @index = i if i!=4 || (i==4 && @lastUsed > 0)
  1897. @over = true
  1898. end
  1899. end
  1900. @sprites["pocket#{i}"].src_rect.y-=1 if @sprites["pocket#{i}"].src_rect.y > 0
  1901. end
  1902. if (Input.trigger?(Input::C) || (defined?($mouse) && @over && $mouse.leftClick?)) && !@doubleback && @index < 5
  1903. pbSEPlay("SE_Select2")
  1904. if @index < 4
  1905. cmd=[2,3,5,7]
  1906. cmd=[2,1,4,5] if pbPocketNames.length==6
  1907. self.drawPocket(cmd[@index],@index)
  1908. else
  1909. @selPocket=0
  1910. @page=-1
  1911. @ret=@lastUsed
  1912. @lastUsed=0 if !($PokemonBag.pbQuantity(@lastUsed) > 1)
  1913. end
  1914. end
  1915. end
  1916.  
  1917. end
  1918.  
  1919. class PokeBattle_Scene
  1920. alias pbItemMenu_ebs pbItemMenu unless self.method_defined?(:pbItemMenu_ebs)
  1921. def pbItemMenu(index)
  1922. @idleTimer=-1
  1923. vector = @battle.doublebattle ? VECTOR2 : VECTOR1
  1924. @vector.set(vector)
  1925. @vector.inc=0.2
  1926. Input.update
  1927. return pbItemMenu_ebs(index) if EBUISTYLE==0
  1928. ret=0
  1929. retindex=-1
  1930. pkmnid=-1
  1931. @bagWindow.show
  1932. loop do
  1933. break if @bagWindow.finish
  1934. Input.update
  1935. @bagWindow.update
  1936. if !@bagWindow.ret.nil? && @bagWindow.useItem?
  1937. item=@bagWindow.ret
  1938. usetype=$ItemData[item][ITEMBATTLEUSE]
  1939. if usetype==1 || usetype==3
  1940. modparty=[]
  1941. for i in 0...6
  1942. partyorder = @battle.respond_to?(:partyorder) ? @battle.partyorder[i] : @battle.party1order[i]
  1943. modparty.push(@battle.party1[partyorder])
  1944. end
  1945. pkmnlist=PokemonScreen_Scene.new
  1946. pkmnlist.addPriority=true
  1947. pkmnscreen=PokemonScreen.new(pkmnlist,modparty)
  1948. pbFadeOutIn(999999) {
  1949. pkmnscreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.doublebattle)
  1950. }
  1951. activecmd=pkmnscreen.pbChoosePokemon
  1952. partyorder = @battle.respond_to?(:partyorder) ? @battle.partyorder : @battle.party1order
  1953. pkmnid=partyorder[activecmd]
  1954. if activecmd>=0 && pkmnid>=0 && ItemHandlers.hasBattleUseOnPokemon(item)
  1955. pkmnlist.pbEndScene
  1956. ret=item
  1957. retindex=pkmnid
  1958. break
  1959. end
  1960. pkmnlist.pbEndScene
  1961. @bagWindow.closeCurrent
  1962. #itemscene.pbStartScene($PokemonBag)
  1963. elsif usetype==2 || usetype==4
  1964. if ItemHandlers.hasBattleUseOnBattler(item)
  1965. ret=item
  1966. retindex=index
  1967. break
  1968. end
  1969. end
  1970. end
  1971. animateBattleSprites
  1972. pbGraphicsUpdate
  1973. end
  1974. @bagWindow.hide
  1975. pbConsumeItemInBattle($PokemonBag,ret) if ret > 0
  1976. return [ret,retindex]
  1977. end
  1978. end
  1979.  
  1980. class_name = isVersion17? ? "PokemonParty_Scene" : "PokemonScreen_Scene"
  1981. class_string = <<_END_
  1982. class #{class_name}
  1983. attr_accessor :addPriority
  1984. alias pbStartScene_ebs pbStartScene unless self.method_defined?(:pbStartScene_ebs)
  1985. def pbStartScene(*args)
  1986. pbStartScene_ebs(*args)
  1987. @viewport.z += 6 if @addPriority
  1988. end
  1989. end
  1990. _END_
  1991. eval(class_string)
  1992. #===============================================================================
  1993. # Pokemon data battle boxes (Next Generation)
  1994. # UI overhaul
  1995. #===============================================================================
  1996. class NextGenDataBox < SpriteWrapper
  1997. attr_reader :battler
  1998. attr_accessor :selected
  1999. attr_accessor :appearing
  2000. attr_accessor :charged
  2001. attr_reader :animatingHP
  2002. attr_reader :animatingEXP
  2003.  
  2004. def initialize(battler,doublebattle,viewport=nil,player=nil,scene=nil)
  2005. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  2006. view.z = viewport.z# + 1
  2007. @viewport = view
  2008. @scene = scene
  2009. @player = player
  2010. @battler = battler
  2011. @doublebattle = doublebattle
  2012. @playerpoke = (@battler.index&1)==0
  2013. @vector = (@battler.index&1)==0 ? @scene.vector.x : @scene.vector.x2
  2014. @sprites = {}
  2015. @path = "#{checkEBFolderPath}/nextGen/"
  2016. @showhp = (@battler.index&1)==0
  2017. @showexp = (@battler.index&1)==0
  2018. @explevel=0
  2019. @selected=0
  2020. @frame=0
  2021. @appearing=false
  2022. @animatingHP=false
  2023. @starthp=0.0
  2024. @currenthp=0.0
  2025. @endhp=0.0
  2026. @expflash=0
  2027. @loaded = false
  2028. @showing = false
  2029. @second = false
  2030. @charged = false
  2031. @Mbreathe = 1
  2032. @Mlock = false
  2033. end
  2034.  
  2035. def disposed?
  2036. return @sprites["layer1"].disposed? if @sprites["layer1"]
  2037. return true
  2038. end
  2039.  
  2040. def dispose
  2041. pbDisposeSpriteHash(@sprites)
  2042. end
  2043.  
  2044. def refreshExpLevel
  2045. if !@battler.pokemon
  2046. @explevel=0
  2047. else
  2048. growthrate=@battler.pokemon.growthrate
  2049. startexp=PBExperience.pbGetStartExperience(@battler.pokemon.level,growthrate)
  2050. endexp=PBExperience.pbGetStartExperience(@battler.pokemon.level+1,growthrate)
  2051. if startexp==endexp
  2052. @explevel=0
  2053. else
  2054. @explevel=(@battler.pokemon.exp-startexp)*@sprites["exp"].bitmap.width/(endexp-startexp)
  2055. end
  2056. end
  2057. end
  2058.  
  2059. def exp
  2060. return @animatingEXP ? @currentexp : @explevel
  2061. end
  2062.  
  2063. def hp
  2064. return @animatingHP ? @currenthp : @battler.hp
  2065. end
  2066.  
  2067. def animateHP(oldhp,newhp)
  2068. @starthp=oldhp.to_f
  2069. @currenthp=oldhp.to_f
  2070. @endhp=newhp.to_f
  2071. @animatingHP=true
  2072. end
  2073.  
  2074. def animateEXP(oldexp,newexp)
  2075. @currentexp=oldexp
  2076. @endexp=newexp
  2077. @animatingEXP=true
  2078. end
  2079.  
  2080. def show; @showing = true; end
  2081.  
  2082. def appear
  2083. # used to call the set-up procedure from the battle scene
  2084. self.setUp
  2085. @loaded = true
  2086. refreshExpLevel
  2087. if @playerpoke
  2088. @sprites["layer1"].x = -@sprites["layer1"].bitmap.width - 32
  2089. @sprites["layer1"].y = @viewport.rect.height + @sprites["layer1"].bitmap.height + 32
  2090. else
  2091. @sprites["layer1"].x = @viewport.rect.width + @sprites["layer1"].bitmap.width + 32
  2092. @sprites["layer1"].y = -@sprites["layer1"].bitmap.height - 32
  2093. end
  2094. self.x = @sprites["layer1"].x
  2095. self.y = @sprites["layer1"].y
  2096. self.refresh
  2097. end
  2098.  
  2099. def getBattler(battler)
  2100. return battler.effects[PBEffects::Illusion] if PBEffects.const_defined?(:Illusion) && battler.respond_to?('effects') && !battler.effects[PBEffects::Illusion].nil?
  2101. return battler
  2102. end
  2103.  
  2104. def setUp
  2105. # reset of the set-up procedure
  2106. @loaded = false
  2107. @showing = false
  2108. @second = false
  2109. pbDisposeSpriteHash(@sprites)
  2110. @sprites.clear
  2111. # initializes all the necessary components
  2112. @sprites["mega"] = Sprite.new(@viewport)
  2113. @sprites["mega"].opacity = 0
  2114.  
  2115. @sprites["layer1"] = Sprite.new(@viewport)
  2116. @sprites["layer1"].bitmap = pbBitmap(@path+"layer1")
  2117. @sprites["layer1"].src_rect.height = 64 if !@showexp
  2118. @sprites["layer1"].mirror = !@playerpoke
  2119.  
  2120. @sprites["shadow"] = Sprite.new(@viewport)
  2121. @sprites["shadow"].bitmap = Bitmap.new(@sprites["layer1"].bitmap.width,@sprites["layer1"].bitmap.height)
  2122. @sprites["shadow"].z = -1
  2123. @sprites["shadow"].opacity = 255*0.25
  2124. @sprites["shadow"].color = Color.new(0,0,0,255)
  2125.  
  2126. @sprites["hp"] = Sprite.new(@viewport)
  2127. @hpBarBmp = pbBitmap(@path+"hpBar")
  2128. @hpBarChr = pbBitmap(@path+"hpBarCharged")
  2129. c = @hpBarChr.get_pixel(2,0)
  2130. @sprites["hp"].bitmap = Bitmap.new(@hpBarBmp.width,@hpBarBmp.height)
  2131. @sprites["hp"].mirror = !@playerpoke
  2132.  
  2133. for i in 0...46
  2134. step = rand(129)/4.0
  2135. @sprites["chr#{i}"] = Sprite.new(@viewport)
  2136. @sprites["chr#{i}"].bitmap = Bitmap.new(4,14)
  2137. @sprites["chr#{i}"].bitmap.fill_rect(0,0,4,14,c)
  2138. @sprites["chr#{i}"].oy = @sprites["chr#{i}"].bitmap.height
  2139. @sprites["chr#{i}"].opacity = 256*step/12.0
  2140. @sprites["chr#{i}"].zoom_y = 1.0*step/24.0
  2141. @sprites["chr#{i}"].z = 8
  2142. end
  2143.  
  2144. @sprites["exp"] = Sprite.new(@viewport)
  2145. @sprites["exp"].bitmap = pbBitmap(@path+"expBar")
  2146. @sprites["exp"].src_rect.y = @sprites["exp"].bitmap.height*-1 if !@showexp
  2147.  
  2148. @sprites["text"] = Sprite.new(@viewport)
  2149. @sprites["text"].bitmap = Bitmap.new(@sprites["layer1"].bitmap.width,@sprites["layer1"].bitmap.height)
  2150. @sprites["text"].z = 9
  2151. pbSetSystemFont(@sprites["text"].bitmap)
  2152. end
  2153.  
  2154. def x; return @sprites["layer1"].x; end
  2155. def y; return @sprites["layer1"].y; end
  2156. def z; return @sprites["layer1"].z; end
  2157. def visible; return @sprites["layer1"] ? @sprites["layer1"].visible : false; end
  2158. def opacity; return @sprites["layer1"].opacity; end
  2159. def color; return @sprites["layer1"].color; end
  2160. def x=(val)
  2161. return if !@loaded
  2162. # calculates the relative X positions of all elements
  2163. @sprites["layer1"].x = val
  2164. @sprites["text"].x = @sprites["layer1"].x
  2165. @sprites["hp"].x = @sprites["layer1"].x + 28 + (!@playerpoke ? 4 : 0)
  2166. @sprites["exp"].x = @sprites["layer1"].x + 40
  2167. @sprites["mega"].x = @sprites["layer1"].x + (!@playerpoke ? -8 : 222)
  2168. @sprites["shadow"].x = @sprites["layer1"].x + 2
  2169. end
  2170. def y=(val)
  2171. return if !@loaded
  2172. # calculates the relative Y positions of all elements
  2173. @sprites["layer1"].y = val
  2174. @sprites["text"].y = @sprites["layer1"].y
  2175. @sprites["hp"].y = @sprites["layer1"].y + 46
  2176. @sprites["exp"].y = @sprites["layer1"].y + 68
  2177. @sprites["mega"].y = @sprites["layer1"].y + 38
  2178. @sprites["shadow"].y = @sprites["layer1"].y + 2
  2179. end
  2180. def visible=(val)
  2181. for key in @sprites.keys
  2182. next if key=="layer0"
  2183. next if !@sprites[key]
  2184. if key.include?("chr")
  2185. @sprites[key].visible = val if @charged
  2186. else
  2187. @sprites[key].visible = val
  2188. end
  2189. end
  2190. end
  2191. def opacity=(val)
  2192. for key in @sprites.keys
  2193. next if key=="layer0"
  2194. next if key=="mega" && !@battler.isMega?
  2195. next if !@sprites[key]
  2196. @sprites[key].opacity = val
  2197. @sprites[key].opacity *= 0.25 if key=="shadow"
  2198. end
  2199. end
  2200. def color=(val)
  2201. for sprite in @sprites.values
  2202. sprite.color = val
  2203. end
  2204. end
  2205. def positionX=(val)
  2206. val = 4 if val < 4
  2207. val = (@viewport.rect.width - @sprites["layer1"].bitmap.width) if val > (@viewport.rect.width - @sprites["layer1"].bitmap.width)
  2208. self.x = val
  2209. end
  2210.  
  2211. def updateChargeAnimation
  2212. return if !@charged || !self.visible
  2213. for i in 0...46
  2214. if @sprites["chr#{i}"].zoom_y >= 1.0
  2215. @sprites["chr#{i}"].zoom_y = 0
  2216. @sprites["chr#{i}"].opacity = 255
  2217. end
  2218. @sprites["chr#{i}"].opacity -= 256/48.0
  2219. @sprites["chr#{i}"].zoom_y += 1.0/24.0
  2220. @sprites["chr#{i}"].x = @sprites["hp"].x + 2 + i*4
  2221. @sprites["chr#{i}"].y = @sprites["hp"].y + 2
  2222. @sprites["chr#{i}"].color.alpha -= 16 if @sprites["chr#{i}"].color.alpha > 0
  2223. end
  2224. end
  2225.  
  2226. def charge
  2227. @charged = true
  2228. @sprites["hp"].color = Color.new(255,255,255)
  2229. for i in 0...46
  2230. @sprites["chr#{i}"].color = Color.new(255,255,255)
  2231. end
  2232. self.updateHpBar
  2233. self.visible = self.visible
  2234. end
  2235.  
  2236. def stopCharge
  2237. @charged = false
  2238. @sprites["hp"].color = Color.new(255,255,255)
  2239. self.updateHpBar
  2240. self.visible = self.visible
  2241. end
  2242.  
  2243. def updateHpBar
  2244. # updates the current state of the HP bar
  2245. # the bar's colour hue gets dynamically adjusted (i.e. not through sprites)
  2246. # HP bar is mirrored for opposing Pokemon
  2247. hpbar = @battler.totalhp==0 ? 0 : (1.0*self.hp*@sprites["hp"].bitmap.width/@battler.totalhp).ceil
  2248. @sprites["hp"].src_rect.x = @sprites["hp"].bitmap.width - hpbar if !@playerpoke
  2249. @sprites["hp"].src_rect.width = hpbar
  2250. hue = (0-120)*(1-(self.hp.to_f/@battler.totalhp))
  2251. @sprites["hp"].bitmap.clear
  2252. bmp = @charged ? @hpBarChr : @hpBarBmp
  2253. @sprites["hp"].bitmap.blt(0,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
  2254. @sprites["hp"].bitmap.hue_change(hue) if !@charged
  2255. for i in 0...46
  2256. @sprites["chr#{i}"].zoom_x = (i >= (46*(self.hp.to_f/@battler.totalhp)).floor) ? 0 : 1
  2257. @sprites["chr#{i}"].zoom_x = 0 if !@charged
  2258. end
  2259. end
  2260.  
  2261. def refresh
  2262. # exits the refresh if the databox isn't fully set up yet
  2263. return if !@loaded
  2264. # update for HP/EXP bars
  2265. self.updateHpBar
  2266. @sprites["exp"].src_rect.width = self.exp
  2267. # clears the current bitmap containing text and adjusts its font
  2268. @sprites["text"].bitmap.clear
  2269. pbSetSystemFont(@sprites["text"].bitmap)
  2270. # used to calculate the potential offset of elements should they exceed the
  2271. # width of the HP bar
  2272. str = ""
  2273. str = _INTL("♂") if getBattler(@battler).gender==0
  2274. str = _INTL("♀") if getBattler(@battler).gender==1
  2275. w = @sprites["text"].bitmap.text_size("#{getBattler(@battler).name}#{str}Lv.#{getBattler(@battler).level}").width
  2276. o = (w > @sprites["hp"].bitmap.width+4) ? (w-(@sprites["hp"].bitmap.width+4))/2.0 : 0; o = o.ceil
  2277. o += 2 if getBattler(@battler).level == 100
  2278. # additional layer to draw extra things onto the databox (unused by default)
  2279. bmp = pbBitmap(@path+"layer2")
  2280. @sprites["text"].bitmap.blt(@playerpoke ? 0 : 4,@playerpoke ? 0 : 4,bmp,Rect.new(0,0,bmp.width,@showexp ? bmp.height : 62))
  2281. # writes the Pokemon's name
  2282. str = getBattler(@battler).name
  2283. str += " "
  2284. x = @playerpoke ? 28 : 32
  2285. pkmn = getBattler(@battler); pkmn = pkmn.pokemon if pkmn.respond_to?(:pokemon)
  2286. color = pkmn.isShiny? ? Color.new(222,197,95) : Color.new(255,255,255) if !pkmn.nil?
  2287. pbDrawOutlineText(@sprites["text"].bitmap,x-o,-20,@sprites["text"].bitmap.width,@sprites["text"].bitmap.height,str,color,Color.new(0,0,0),0)
  2288. # writes the Pokemon's gender
  2289. x = @sprites["text"].bitmap.text_size(str).width + (@playerpoke ? 28 : 32)
  2290. str = ""
  2291. str = _INTL("♂") if getBattler(@battler).gender==0
  2292. str = _INTL("♀") if getBattler(@battler).gender==1
  2293. color = (getBattler(@battler).gender==0) ? Color.new(53,107,208) : Color.new(180,37,77)
  2294. pbDrawOutlineText(@sprites["text"].bitmap,x-o,-20,@sprites["text"].bitmap.width,@sprites["text"].bitmap.height,str,color,Color.new(0,0,0),0)
  2295. # writes the Pokemon's level
  2296. str = "#{getBattler(@battler).level}"
  2297. x = @playerpoke ? -30 : -26
  2298. pbDrawOutlineText(@sprites["text"].bitmap,x+o,-20,@sprites["text"].bitmap.width,@sprites["text"].bitmap.height,str,Color.new(255,255,255),Color.new(0,0,0),2)
  2299. x -= @sprites["text"].bitmap.text_size(str).width+(@playerpoke ? 3 : 2)
  2300. pbSetSmallFont(@sprites["text"].bitmap)
  2301. str = _INTL("Lv.")
  2302. pbDrawOutlineText(@sprites["text"].bitmap,x+o+2,-19,@sprites["text"].bitmap.width,@sprites["text"].bitmap.height,str,Color.new(222,197,95),Color.new(0,0,0),2)
  2303. # writes the number of the Pokemon's current/total HP
  2304. str = "#{self.hp}/#{@battler.totalhp}"
  2305. pbDrawOutlineText(@sprites["text"].bitmap,-40,13,@sprites["text"].bitmap.width,@sprites["text"].bitmap.height,str,Color.new(255,255,255),Color.new(0,0,0),1) if @showhp
  2306. # draws Pokeball if Pokemon is caught
  2307. @sprites["text"].bitmap.blt(12,46,pbBitmap(@path+"battleBoxOwned.png"),Rect.new(0,0,14,14)) if !@playerpoke && @battler.owned && !@scene.battle.opponent
  2308. # draws the status conditions
  2309. @sprites["text"].bitmap.blt(160,54,pbBitmap(@path+"statuses"),Rect.new(0,18*(@battler.status-1),52,18)) if @battler.status > 0
  2310. # re-draws the databox shadow
  2311. @sprites["shadow"].bitmap.clear
  2312. bmp = @sprites["layer1"].bitmap.clone
  2313. @sprites["shadow"].bitmap.blt(@playerpoke ? 0 : 4,0,bmp,Rect.new(0,0,bmp.width,@showexp ? bmp.height : 64))
  2314. bmp = @sprites["text"].bitmap.clone
  2315. @sprites["shadow"].bitmap.blt(0,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
  2316. # changes the Mega symbol graphics (depending on Mega or Primal)
  2317. if @battler.isMega?
  2318. @sprites["mega"].bitmap = pbBitmap("#{checkEBFolderPath}/mega_sym")
  2319. elsif @battler.respond_to?(:isPrimal?) && @battler.isPrimal?
  2320. path=nil
  2321. path="Graphics/Pictures/battlePrimalKyogreBox.png" if @battler.species == getConst(PBSpecies,:KYOGRE)
  2322. path="Graphics/Pictures/battlePrimalGroudonBox.png" if @battler.species == getConst(PBSpecies,:GROUDON)
  2323. @sprites["mega"].bitmap = pbBitmap(path)
  2324. end
  2325. @sprites["mega"].x = @sprites["layer1"].x + (!@playerpoke ? -8 : 222)
  2326. end
  2327.  
  2328. def update
  2329. # updates the HP increase/decrease animation
  2330. if @animatingHP
  2331. if @currenthp < @endhp
  2332. @currenthp += (@endhp - @currenthp)/10.0
  2333. @currenthp = @currenthp.ceil
  2334. @currenthp = @endhp if @currenthp > @endhp
  2335. elsif @currenthp > @endhp
  2336. @currenthp -= (@currenthp - @endhp)/10.0
  2337. @currenthp = @currenthp.floor
  2338. @currenthp = @endhp if @currenthp < @endhp
  2339. end
  2340. self.refresh
  2341. @animatingHP = false if @currenthp==@endhp
  2342. end
  2343. # updates the EXP increase/decrease animation
  2344. if @animatingEXP
  2345. if !@showexp
  2346. @currentexp = @endexp
  2347. elsif @currentexp < @endexp
  2348. @currentexp += (@endexp - @currentexp)/10.0
  2349. @currentexp = @currentexp.ceil
  2350. @currentexp = @endexp if @currentexp > @endexp
  2351. elsif @currentexp > @endexp
  2352. @currentexp -= (@currentexp - @endexp)/10.0
  2353. @currentexp = @currentexp.floor
  2354. @currentexp = @endexp if @currentexp < @endexp
  2355. end
  2356. self.refresh
  2357. if @currentexp == @endexp
  2358. # tints the databox blue and plays a sound when EXP is full
  2359. if @currentexp >= @sprites["exp"].bitmap.width
  2360. pbSEPlay(isVersion17? ? "Pkmn exp full" : "expfull")
  2361. @sprites["layer1"].tone = Tone.new(0,80,210)
  2362. @sprites["text"].tone = Tone.new(0,80,210)
  2363. @animatingEXP = false
  2364. refreshExpLevel
  2365. else
  2366. @animatingEXP = false
  2367. end
  2368. end
  2369. end
  2370. return if !@loaded
  2371. # animates the movement of the databox to its screen position
  2372. # this position is dependant on the battle scene vector
  2373. if @showing && !@second
  2374. y = @playerpoke ? @viewport.rect.height - @sprites["layer1"].bitmap.height - 2 : 6
  2375. x = @vector + @sprites["layer1"].bitmap.width/2
  2376. if @scene.battle.doublebattle
  2377. x = 0 if @battler.index==1
  2378. x = @viewport.rect.width if @battler.index==2
  2379. end
  2380. x = 4 if x < 4
  2381. x = (@viewport.rect.width - @sprites["layer1"].bitmap.width) if x > (@viewport.rect.width - @sprites["layer1"].bitmap.width)
  2382. self.x -= (self.x - x)/4
  2383. self.y += (y - self.y)/4
  2384. @second = true if self.x <= x+2 && self.x >= x-2
  2385. end
  2386. # shows the Mega/Primal symbols when activated
  2387. if (@battler.isMega? || (@battler.respond_to?(:isPrimal?) && @battler.isPrimal?)) && !@Mlock
  2388. @sprites["mega"].opacity = 255
  2389. @Mlock = true
  2390. end
  2391. # charged bar animation
  2392. self.updateChargeAnimation
  2393. @sprites["hp"].color.alpha -= 16 if @sprites["hp"].color.alpha > 0
  2394. # animates a glow for the Mega/Primal symbols
  2395. if @battler.isMega? || (@battler.respond_to?(:isPrimal?) && @battler.isPrimal?)
  2396. @sprites["mega"].tone.red += @Mbreathe
  2397. @sprites["mega"].tone.green += @Mbreathe
  2398. @sprites["mega"].tone.blue += @Mbreathe
  2399. @Mbreathe = -1 if @sprites["mega"].tone.red >= 100
  2400. @Mbreathe = 1 if @sprites["mega"].tone.red <= 0
  2401. end
  2402. # gets rid of the level up tone
  2403. @sprites["layer1"].tone.green -= 4 if @sprites["layer1"].tone.green > 0
  2404. @sprites["layer1"].tone.blue -= 21 if @sprites["layer1"].tone.blue > 0
  2405. @sprites["text"].tone.green -= 4 if @sprites["text"].tone.green > 0
  2406. @sprites["text"].tone.blue -= 21 if @sprites["text"].tone.blue > 0
  2407. end
  2408. end
  2409. #===============================================================================
  2410. # Command Menu (Next Generation)
  2411. # UI ovarhaul
  2412. #===============================================================================
  2413. class NextGenCommandWindow
  2414. attr_accessor :index
  2415. attr_accessor :overlay
  2416. attr_accessor :backdrop
  2417. attr_accessor :coolDown
  2418.  
  2419. def initialize(viewport=nil,battle=nil,safari=false,viewport_top=nil)
  2420. if !viewport.nil?
  2421. @viewport = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  2422. @viewport.z = viewport.z# + 1
  2423. end
  2424. @battle=battle
  2425. @safaribattle=safari
  2426. @index=0
  2427. @oldindex=0
  2428. @coolDown=0
  2429. @over=false
  2430. @path="#{checkEBFolderPath}/nextGen/"
  2431.  
  2432. @background=Sprite.new(@viewport)
  2433. @background.bitmap=pbBitmap(@path+"commandMenu")
  2434. @background.x=@viewport.rect.width-@background.bitmap.width
  2435. @background.y=@viewport.rect.height-@background.bitmap.height
  2436. @yO=(@background.bitmap.height/10.0).round*10
  2437.  
  2438. @helpText=Sprite.new(@viewport)
  2439. @helpText.bitmap=Bitmap.new(@background.bitmap.width,@background.bitmap.height)
  2440. @helpText.y=@background.y
  2441. @helpText.x=@background.x
  2442. @helpText.z=9
  2443. pbSetSmallFont(@helpText.bitmap)
  2444.  
  2445. @buttons=Sprite.new(@viewport)
  2446. @buttons.x=@background.x+(@background.bitmap.width-222)
  2447. @buttons.y=@background.y
  2448.  
  2449. @arrowLeft=Sprite.new(@viewport)
  2450. @arrowLeft.bitmap=pbBitmap(@path+"arrowLeft")
  2451. @arrowLeft.x=@background.x-2
  2452. @arrowLeft.y=@background.y+4
  2453.  
  2454. @arrowRight=Sprite.new(@viewport)
  2455. @arrowRight.bitmap=pbBitmap(@path+"arrowRight")
  2456. @arrowRight.x=@background.x+@background.bitmap.width-@arrowRight.bitmap.width-5
  2457. @arrowRight.y=@background.y+4
  2458.  
  2459. @barGraphic = pbBitmap(@path+"partyBar")
  2460. @ballGraphic = pbBitmap(@path+"partyIndicators")
  2461.  
  2462. @partyLine1 = Sprite.new(@viewport)
  2463. @partyLine1.bitmap = Bitmap.new(@barGraphic.width,14)
  2464. @partyLine1.x = -6
  2465. @partyLine1.end_x = @partyLine1.x
  2466. @partyLine1.y = 274
  2467. @partyLine1.opacity = 255*0.8
  2468. @partyLine2 = Sprite.new(@viewport)
  2469. @partyLine2.bitmap = Bitmap.new(@barGraphic.width,14)
  2470. @partyLine2.x = @viewport.rect.width - 140
  2471. @partyLine2.end_x = @partyLine2.x
  2472. @partyLine2.y = 80
  2473. @partyLine2.opacity = 255*0.8
  2474.  
  2475. @arrowsShow = true
  2476.  
  2477. @aL=@arrowLeft.x
  2478. @aR=@arrowRight.x
  2479. @orgx=@buttons.x
  2480. self.update
  2481. end
  2482.  
  2483. def refreshCommands(index)
  2484. poke = @battle.battlers[index]
  2485. cmds = []
  2486. cmds.push(@safaribattle ? _INTL("BALL") : _INTL("FIGHT"))
  2487. cmds.push(@safaribattle ? _INTL("BAIT") : _INTL("BAG"))
  2488. cmds.push(@safaribattle ? _INTL("ROCK") : _INTL("PARTY"))
  2489. cmds.push((poke.isShadow? && poke.inHyperMode?) ? _INTL("CALL") : _INTL("RUN"))
  2490. bmp = pbBitmap(@path+"cmdButtons")
  2491. bitmap = Bitmap.new(188,176)
  2492. pbSetSmallFont(bitmap)
  2493. for i in 0...4
  2494. bitmap.blt(30*i,44*i,bmp,Rect.new(0,44*i,98,44))
  2495. outline = self.darkenColor(bmp.get_pixel(52,22+(44*i)),0.6)
  2496. pbDrawOutlineText(bitmap,30*i,(44*i)-1,98,44,cmds[i],Color.new(255,255,255),outline,1)
  2497. for j in 0...4
  2498. next if i==j
  2499. x = (j > i) ? ((30*i) + 74 + (30*(j-i))) : (30*j)
  2500. bitmap.blt(x,44*i,bmp,Rect.new(98,44*j,22,44))
  2501. end
  2502. end
  2503. @buttons.bitmap = bitmap.clone
  2504. @buttons.src_rect.height = bitmap.height/4
  2505. @buttons.src_rect.y = 44*@index
  2506. end
  2507.  
  2508. def visible; end; def visible=(val); end
  2509. def disposed?; end
  2510. def dispose
  2511. @viewport.dispose
  2512. @helpText.dispose
  2513. @background.dispose
  2514. @buttons.dispose
  2515. @arrowLeft.dispose
  2516. @arrowRight.dispose
  2517. @partyLine1.dispose
  2518. @partyLine2.dispose
  2519. end
  2520. def color; end; def color=(val); end
  2521.  
  2522. def showText
  2523. @helpText.y-=@yO/10
  2524. self.showArrows
  2525. end
  2526.  
  2527. def lineupY(y)
  2528. @partyLine1.y += y
  2529. #@partyLine2.y += y
  2530. end
  2531.  
  2532. def drawLineup
  2533. return if @safaribattle || !SHOWPARTYARROWS
  2534. @partyLine1.bitmap.clear
  2535. @partyLine2.bitmap.clear
  2536. # start drawing the player party preview
  2537. @partyLine1.bitmap.blt(0,2,@barGraphic,Rect.new(0,0,@barGraphic.width,@barGraphic.height))
  2538. for i in 0...6
  2539. o=3
  2540. if i < @battle.party1.length && @battle.party1[i]
  2541. if @battle.party1[i].hp <=0 || @battle.party1[i].isEgg?
  2542. o=2
  2543. elsif @battle.party1[i].status > 0
  2544. o=1
  2545. else
  2546. o=0
  2547. end
  2548. end
  2549. @partyLine1.bitmap.blt(18+i*18,0,@ballGraphic,Rect.new(14*o,0,14,14))
  2550. end
  2551. # start drawing the opponent party preview
  2552. return if !@battle.opponent
  2553. @partyLine2.bitmap.blt(0,2,@barGraphic,Rect.new(0,0,@barGraphic.width,@barGraphic.height))
  2554. for i in 0...6
  2555. enemyindex=i
  2556. if @battle.doublebattle && i >=3
  2557. enemyindex=(i%3)+@battle.pbSecondPartyBegin(1)
  2558. end
  2559. o=3
  2560. if enemyindex < @battle.party2.length && @battle.party2[enemyindex]
  2561. if @battle.party2[enemyindex].hp <=0 || @battle.party2[enemyindex].isEgg?
  2562. o=2
  2563. elsif @battle.party2[enemyindex].status > 0
  2564. o=1
  2565. else
  2566. o=0
  2567. end
  2568. end
  2569. @partyLine2.bitmap.blt(18+i*18,0,@ballGraphic,Rect.new(14*o,0,14,14))
  2570. end
  2571. end
  2572.  
  2573. def darkenColor(color=nil,amt=0.2)
  2574. return nil if color.nil?
  2575. red = color.red - color.red*amt
  2576. green = color.green - color.green*amt
  2577. blue = color.blue - color.blue*amt
  2578. return Color.new(red,green,blue)
  2579. end
  2580.  
  2581. def text=(msg)
  2582. self.drawLineup
  2583. @helpText.bitmap.clear
  2584. pbDrawOutlineText(@helpText.bitmap,-2,20,@helpText.bitmap.width,@helpText.bitmap.height,msg,Color.new(255,255,255),Color.new(0,0,0),1)
  2585. end
  2586.  
  2587. def show
  2588. @background.y-=@yO/10
  2589. @buttons.y-=@yO/10
  2590. @arrowLeft.y-=@yO/10
  2591. @arrowRight.y-=@yO/10
  2592. end
  2593.  
  2594. def showArrows
  2595. @partyLine1.end_x = -6
  2596. @partyLine2.end_x = @viewport.rect.width - 140
  2597. @partyLine1.x += (@partyLine1.end_x - @partyLine1.x)*0.4
  2598. @partyLine2.x -= (@partyLine2.x - @partyLine2.end_x)*0.4
  2599. end
  2600.  
  2601. def hideArrows
  2602. @partyLine1.end_x = -6 - @partyLine1.bitmap.width
  2603. @partyLine2.end_x = @viewport.rect.width - 140 + @partyLine2.bitmap.width
  2604. @partyLine1.x += (@partyLine1.end_x - @partyLine1.x)*0.4
  2605. @partyLine2.x -= (@partyLine2.x - @partyLine2.end_x)*0.4
  2606. end
  2607.  
  2608. def hide(skip=false)
  2609. @background.y+=@yO/10
  2610. @buttons.y+=@yO/10
  2611. @helpText.y+=@yO/10
  2612. @arrowLeft.y+=@yO/10
  2613. @arrowRight.y+=@yO/10
  2614. self.hideArrows
  2615. end
  2616.  
  2617. def update
  2618. @over=$mouse.over?(@buttons) if defined?($mouse)
  2619. # animation for when the index changes
  2620. if @oldindex!=@index
  2621. @buttons.x+=2
  2622. if @buttons.x==@orgx+6
  2623. @buttons.src_rect.y = (@buttons.bitmap.height/4)*@index
  2624. @oldindex=@index
  2625. end
  2626. else
  2627. @buttons.x-=2 if @buttons.x > @orgx
  2628. @coolDown=0 if @buttons.x==@orgx
  2629. end
  2630. @arrowRight.x-=2 if @arrowRight.x > @aR
  2631. @arrowLeft.x+=2 if @arrowLeft.x < @aL
  2632. # mouse functions for compatibility with the Easy Mouse System
  2633. if defined?($mouse) && $mouse.leftClick?(@arrowLeft) && @coolDown < 1
  2634. self.triggerLeft
  2635. if @index > 0
  2636. pbSEPlay("SE_Select1")
  2637. @index-=1
  2638. elsif @index <=0
  2639. pbSEPlay("SE_Select1")
  2640. @index=3
  2641. end
  2642. @coolDown=1
  2643. elsif defined?($mouse) && $mouse.leftClick?(@arrowRight) && @coolDown < 1
  2644. self.triggerRight
  2645. if @index < 3
  2646. pbSEPlay("SE_Select1")
  2647. @index+=1
  2648. elsif @index >=3
  2649. pbSEPlay("SE_Select1")
  2650. @index=0
  2651. end
  2652. @coolDown=1
  2653. end
  2654. end
  2655.  
  2656. def triggerLeft; @arrowLeft.x=@aL-8; end
  2657. def triggerRight; @arrowRight.x=@aR+8; end
  2658.  
  2659. def mouseOver?
  2660. return false if !defined?($mouse)
  2661. return @over
  2662. end
  2663.  
  2664. end
  2665. #===============================================================================
  2666. # Fight Menu (Next Generation)
  2667. # UI ovarhaul
  2668. #===============================================================================
  2669. class NextGenFightWindow
  2670. attr_accessor :index
  2671. attr_accessor :battler
  2672. attr_accessor :refreshpos
  2673. attr_reader :nummoves
  2674.  
  2675. def initialize(viewport=nil,battle=nil)
  2676. if !viewport.nil?
  2677. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  2678. view.z = viewport.z
  2679. view2 = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  2680. view2.z = viewport.z# + 2
  2681. viewport = view
  2682. end
  2683. @viewport=viewport
  2684. @viewport2=(viewport.nil?) ? viewport : view2
  2685. @battle=battle
  2686. @index=0
  2687. @oldindex=-1
  2688. @over=false
  2689. @refreshpos=false
  2690. @battler=nil
  2691. @nummoves=0
  2692.  
  2693. @opponent=nil
  2694. @player=nil
  2695. @opponent=@battle.battlers[1] if !@battle.doublebattle
  2696. @player=@battle.battlers[0] if !@battle.doublebattle
  2697.  
  2698. @buttonBitmap=pbBitmap("#{checkEBFolderPath}/nextGen/moveSelButtons")
  2699.  
  2700. @background=Sprite.new(@viewport)
  2701. @background.bitmap=pbBitmap("#{checkEBFolderPath}/nextGen/newBattleMessageBox")
  2702. @background.y=VIEWPORT_HEIGHT-96
  2703. @background.z=100
  2704.  
  2705. @megaButton=Sprite.new(@viewport)
  2706. @megaButton.bitmap=pbBitmap("#{checkEBFolderPath}/nextGen/megaEvoButton")
  2707. @megaButton.z=101
  2708. @megaButton.x=10
  2709. @megaButton.y=316 + 100
  2710. @megaButton.src_rect.set(0,0,44,44)
  2711.  
  2712. @backButton=Sprite.new(@viewport)
  2713. @backButton.bitmap=pbBitmap("#{checkEBFolderPath}/nextGen/backButton")
  2714. @backButton.z=101
  2715. @backButton.x=462
  2716. @backButton.y=316
  2717.  
  2718. @button={}
  2719. @moved=false
  2720. @showMega=false
  2721. @ox=[60,258,60,258]
  2722. @oy=[294,294,338,338]
  2723. # If you're coming from Thundaga's tutorial to add your custom type's
  2724. # text to the @types array, this step is no longer necessary, and EBS
  2725. # will take care of that for you automatically
  2726. @category=[_INTL("PHYS"),_INTL("SPEC"),_INTL("STAT")]
  2727.  
  2728. eff=[_INTL("Normal damage"),_INTL("Not very effective"),_INTL("Super effective")]
  2729. @typeInd=Sprite.new(@viewport)
  2730. @typeInd.bitmap=Bitmap.new(192,24*3)
  2731. pbSetSmallFont(@typeInd.bitmap)
  2732. for i in 0...3
  2733. pbDrawOutlineText(@typeInd.bitmap,0,24*i,192,24,eff[i],Color.new(255,255,255),Color.new(0,0,0),1)
  2734. end
  2735. @typeInd.src_rect.set(0,0,192,24)
  2736. @typeInd.ox=96
  2737. @typeInd.oy=16
  2738. @typeInd.z=103
  2739. @typeInd.visible=false
  2740.  
  2741. end
  2742.  
  2743. def generateButtons
  2744. @moves=@battler.moves
  2745. @nummoves=0
  2746. @oldindex=-1
  2747. for i in 0...4
  2748. @button["#{i}"].dispose if @button["#{i}"]
  2749. @nummoves+=1 if @moves[i] && @moves[i].id > 0
  2750. end
  2751. @x = @ox.clone
  2752. @y = @oy.clone
  2753. for i in 0...4
  2754. @y[i] += 22 if @nummoves < 3
  2755. end
  2756. @button={}
  2757. for i in 0...@nummoves
  2758. movedata = PBMoveData.new(@moves[i].id)
  2759. move = @moves[i]
  2760. @button["#{i}"] = Sprite.new(@viewport)
  2761. @button["#{i}"].z = 102
  2762. @button["#{i}"].bitmap = Bitmap.new(198*2,78)
  2763. @button["#{i}"].bitmap.blt(0,0,@buttonBitmap,Rect.new(0,move.type*78,198,78))
  2764. @button["#{i}"].bitmap.blt(198,0,@buttonBitmap,Rect.new(198,move.type*78,198,78))
  2765. baseColor=self.darkenColor(@buttonBitmap.get_pixel(16,8+(@moves[i].type*78)))
  2766. baseColor2=@buttonBitmap.get_pixel(16,8+(@moves[i].type*78))
  2767. shadowColor=self.darkenColor(@buttonBitmap.get_pixel(18,10+(@moves[i].type*78)))
  2768. pbSetSmallFont(@button["#{i}"].bitmap)
  2769. pbDrawOutlineText(@button["#{i}"].bitmap,198,0,196,42,"#{move.name}",Color.new(255,255,255),baseColor,1)
  2770. pbDrawOutlineText(@button["#{i}"].bitmap,6,52,186,22,self.typename(move.type),Color.new(255,255,255),baseColor2,0)
  2771. pbDrawOutlineText(@button["#{i}"].bitmap,6,52,186,22,@category[movedata.category],Color.new(255,255,255),baseColor2,2)
  2772. pp = "#{move.pp}/#{move.totalpp}"
  2773. text=[
  2774. [pp,98,40,2,baseColor,shadowColor]
  2775. ]
  2776. pbDrawTextPositions(@button["#{i}"].bitmap,text)
  2777. pbSetSystemFont(@button["#{i}"].bitmap)
  2778. text=[
  2779. ["#{move.name}",98,12,2,baseColor,shadowColor]
  2780. ]
  2781. pbDrawTextPositions(@button["#{i}"].bitmap,text)
  2782. @button["#{i}"].src_rect.set(198,0,198,78)
  2783. @button["#{i}"].x = @x[i] - ((i%2==0) ? 260 : -260)
  2784. @button["#{i}"].y = @y[i]
  2785. end
  2786.  
  2787. end
  2788.  
  2789. def typename(type)
  2790. name = PBTypes.getName(type).upcase
  2791. return _INTL("ELECTR") if name == "ELECTRIC"
  2792. return _INTL("PSYCH") if name == "PSYCHIC"
  2793. return _INTL("GRASS") if name == "GRASS"
  2794. return _INTL("FIRE") if name == "FIRE"
  2795. return _INTL("WATER") if name == "WATER"
  2796. return _INTL("NORMAL") if name == "NORMAL"
  2797. return _INTL("DARK") if name == "DARK"
  2798. return _INTL("GHOST") if name == "GHOST"
  2799. return _INTL("GROUND") if name == "GROUND"
  2800. return _INTL("ROCK") if name == "ROCK"
  2801. return _INTL("FAIRY") if name == "FAIRY"
  2802. return _INTL("STEEL") if name == "STEEL"
  2803. return _INTL("FLYING") if name == "FLYING"
  2804. return _INTL("FIGHTING") if name == "FIGHTING"
  2805. return _INTL("POISON") if name == "POISON"
  2806. return _INTL("BUG") if name == "BUG"
  2807. return _INTL("DRAGON") if name == "DRAGON"
  2808. return _INTL("ICE") if name == "ICE"
  2809. return _INTL("SHADOW") if name == "SHADOW"
  2810. arr = name.scan(/./)
  2811. return name if arr.length < 7
  2812. n = ""
  2813. for i in 0...6
  2814. n += arr[i]
  2815. end
  2816. return n
  2817. end
  2818.  
  2819. def formatBackdrop
  2820. end
  2821.  
  2822. def darkenColor(color=nil,amt=0.2)
  2823. return nil if color.nil?
  2824. red = color.red - color.red*amt
  2825. green = color.green - color.green*amt
  2826. blue = color.blue - color.blue*amt
  2827. return Color.new(red,green,blue)
  2828. end
  2829.  
  2830. def show
  2831. @typeInd.visible=false
  2832. @background.y -= 10
  2833. @backButton.y -= 10
  2834. for i in 0...@nummoves
  2835. @button["#{i}"].x += ((i%2==0) ? 26 : -26)
  2836. end
  2837. end
  2838.  
  2839. def hide
  2840. @typeInd.visible=false
  2841. @background.y += 10
  2842. @megaButton.y += 10
  2843. @backButton.y += 10
  2844. for i in 0...@nummoves
  2845. @button["#{i}"].x -= ((i%2==0) ? 26 : -26)
  2846. end
  2847. @showMega=false
  2848. end
  2849.  
  2850. def megaButton
  2851. @showMega=true
  2852. end
  2853.  
  2854. def megaButtonTrigger
  2855. @megaButton.src_rect.x+=44
  2856. @megaButton.src_rect.x=0 if @megaButton.src_rect.x > 44
  2857. @megaButton.src_rect.y = -4
  2858. end
  2859.  
  2860. def update
  2861. if @showMega
  2862. @megaButton.y -= 10 if @megaButton.y > 316
  2863. @megaButton.src_rect.y += 1 if @megaButton.src_rect.y < 0
  2864. end
  2865. if @oldindex!=@index
  2866. @button["#{@index}"].src_rect.y = -4
  2867. if SHOWTYPEADVANTAGE && !@battle.doublebattle
  2868. move = @battler.moves[@index]
  2869. @modifier = move.pbTypeModifier(move.type,@player,@opponent)
  2870. end
  2871. @oldindex = @index
  2872. end
  2873. for i in 0...@nummoves
  2874. @button["#{i}"].src_rect.x = 198*(@index == i ? 0 : 1)
  2875. @button["#{i}"].y = @y[i]
  2876. @button["#{i}"].src_rect.y += 1 if @button["#{i}"].src_rect.y < 0
  2877. next if i!=@index
  2878. if [0,1].include?(i)
  2879. @button["#{i}"].y = @y[i] - ((@nummoves < 3) ? 18 : 34)
  2880. elsif [2,3].include?(i)
  2881. @button["#{i}"].y = @y[i] - 34
  2882. @button["#{i-2}"].y = @y[i-2] - 34
  2883. end
  2884. end
  2885. if SHOWTYPEADVANTAGE && !@battle.doublebattle
  2886. @typeInd.visible = true
  2887. @typeInd.y = @button["#{@index}"].y
  2888. @typeInd.x = @button["#{@index}"].x + @button["#{@index}"].src_rect.width/2
  2889. eff=0
  2890. if @modifier<8
  2891. eff=1 # "Not very effective"
  2892. elsif @modifier>8
  2893. eff=2 # "Super effective"
  2894. end
  2895. @typeInd.src_rect.y = 24*eff
  2896. end
  2897. if defined?($mouse)
  2898. @over = false
  2899. for i in 0...@nummoves
  2900. if $mouse.overPixel?(@button["#{i}"])
  2901. @index = i
  2902. @over = true
  2903. end
  2904. end
  2905. end
  2906. end
  2907.  
  2908. def dispose
  2909. @viewport.dispose
  2910. @viewport2.dispose
  2911. @background.dispose
  2912. @megaButton.dispose
  2913. @backButton.dispose
  2914. @typeInd.dispose
  2915. pbDisposeSpriteHash(@button)
  2916. end
  2917.  
  2918. def overMega?
  2919. return false if !defined?($mouse)
  2920. return $mouse.over?(@megaButton)
  2921. end
  2922.  
  2923. def mouseOver?
  2924. return false if !defined?($mouse)
  2925. return @over
  2926. end
  2927. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement