Guest User

elitebattle_UI

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