Guest User

Untitled

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