Advertisement
Guest User

Untitled

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