Advertisement
OGButtjuice

EliteBattle_3 (EBS v17.2)

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