Kid02

help again

Apr 20th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 160.45 KB | None | 0 0
  1. # Resultados de una batalla:
  2. # 0 - No decidido o cancelada
  3. # 1 - Gana el jugador
  4. # 2 - Pierde el jugador
  5. # 3 - El jugador o Pokémon salvaje huye de la batalla, o el jugador pierde la partida
  6. # 4 - El Pokémon salvaje fue atrapado
  7. # 5 - Empate
  8.  
  9. ################################################################################
  10. # Catching and storing Pokémon.
  11. ################################################################################
  12. module PokeBattle_BattleCommon
  13. def pbStorePokemon(pokemon)
  14. if !(pokemon.isShadow? rescue false)
  15. if pbDisplayConfirm(_INTL("¿Quieres ponerle un apodo a {1}?",pokemon.name))
  16. species=PBSpecies.getName(pokemon.species)
  17. nickname=@scene.pbNameEntry(_INTL("Apodo de {1}",species),pokemon)
  18. pokemon.name=nickname if nickname!=""
  19. end
  20. end
  21. oldcurbox=@peer.pbCurrentBox()
  22. storedbox=@peer.pbStorePokemon(self.pbPlayer,pokemon)
  23. creator=@peer.pbGetStorageCreator()
  24. return if storedbox<0
  25. curboxname=@peer.pbBoxName(oldcurbox)
  26. boxname=@peer.pbBoxName(storedbox)
  27. if storedbox!=oldcurbox
  28. if creator
  29. pbDisplayPaused(_INTL("La caja \"{1}\" de la PC de {2} está llena.",curboxname,creator))
  30. else
  31. pbDisplayPaused(_INTL("La caja \"{1}\" de la PC de Alguien está llena.",curboxname))
  32. end
  33. pbDisplayPaused(_INTL("{1} fue transferido a la caja \"{2}\".",pokemon.name,boxname))
  34. else
  35. if creator
  36. pbDisplayPaused(_INTL("{1} fue transferido a la PC de {2}.",pokemon.name,creator))
  37. else
  38. pbDisplayPaused(_INTL("{1} fue transferido a la PC de Alguien.",pokemon.name))
  39. end
  40. pbDisplayPaused(_INTL("Fue guardado en la caja \"{1}\".",boxname))
  41. end
  42. end
  43.  
  44. def pbThrowPokeBall(idxPokemon,ball,rareness=nil,showplayer=false)
  45. itemname=PBItems.getName(ball)
  46. battler=nil
  47. if pbIsOpposing?(idxPokemon)
  48. battler=self.battlers[idxPokemon]
  49. else
  50. battler=self.battlers[idxPokemon].pbOppositeOpposing
  51. end
  52. if battler.isFainted?
  53. battler=battler.pbPartner
  54. end
  55. pbDisplayBrief(_INTL("{1} usó una {2}.",self.pbPlayer.name,itemname))
  56. if battler.isFainted?
  57. pbDisplay(_INTL("Pero no hay objetivo..."))
  58. return
  59. end
  60. if @opponent && (!pbIsSnagBall?(ball) || !battler.isShadow?)
  61. @scene.pbThrowAndDeflect(ball,1)
  62. pbDisplay(_INTL("¡El Entrenador ha bloqueado la Poké Ball!\n¡No seas un ladrón!"))
  63. else
  64. if $game_switches[126]==true
  65. @scene.pbThrowAndDeflect(ball,1)
  66. pbDisplay(_INTL("¡No puedes atrapar a este pokémon!"))
  67. return
  68. end
  69. pokemon=battler.pokemon
  70. species=pokemon.species
  71. if $DEBUG && Input.press?(Input::CTRL)
  72. shakes=4
  73. else
  74. if !rareness
  75. dexdata=pbOpenDexData
  76. pbDexDataOffset(dexdata,species,16)
  77. rareness=dexdata.fgetb # Get rareness from dexdata file
  78. dexdata.close
  79. end
  80. a=battler.totalhp
  81. b=battler.hp
  82. rareness=BallHandlers.modifyCatchRate(ball,rareness,self,battler)
  83. x=(((a*3-b*2)*rareness)/(a*3)).floor
  84. if battler.status==PBStatuses::SLEEP || battler.status==PBStatuses::FROZEN
  85. x=(x*2.5).floor
  86. elsif battler.status!=0
  87. x=(x*1.5).floor
  88. end
  89. c=0
  90. if $Trainer
  91. if $Trainer.pokedexOwned>600
  92. c=(x*2.5/6).floor
  93. elsif $Trainer.pokedexOwned>450
  94. c=(x*2/6).floor
  95. elsif $Trainer.pokedexOwned>300
  96. c=(x*1.5/6).floor
  97. elsif $Trainer.pokedexOwned>150
  98. c=(x*1/6).floor
  99. elsif $Trainer.pokedexOwned>30
  100. c=(x*0.5/6).floor
  101. end
  102. end
  103. shakes=0; critical=false
  104. if x>255 || BallHandlers.isUnconditional?(ball,self,battler)
  105. shakes=4
  106. else
  107. x=1 if x<1
  108. y = ( 65536 / ((255.0/x)**0.1875) ).floor
  109. if USECRITICALCAPTURE && pbRandom(256)<c
  110. critical=true
  111. shakes=4 if pbRandom(65536)<y
  112. else
  113. shakes+=1 if pbRandom(65536)<y
  114. shakes+=1 if pbRandom(65536)<y && shakes==1
  115. shakes+=1 if pbRandom(65536)<y && shakes==2
  116. shakes+=1 if pbRandom(65536)<y && shakes==3
  117. end
  118. end
  119. end
  120. PBDebug.log("[Poké Ball lanzada] #{itemname}, #{shakes} sacudidas (4=captura)")
  121. @scene.pbThrow(ball,(critical) ? 1 : shakes,critical,battler.index,showplayer)
  122. case shakes
  123. when 0
  124. pbDisplay(_INTL("¡Oh no! ¡El Pokémon salió con facilidad!"))
  125. BallHandlers.onFailCatch(ball,self,battler)
  126. when 1
  127. pbDisplay(_INTL("Aww... ¡Parecía que ya estaba capturado!"))
  128. BallHandlers.onFailCatch(ball,self,battler)
  129. when 2
  130. pbDisplay(_INTL("¡Aargh! ¡Casi lo tenía!"))
  131. BallHandlers.onFailCatch(ball,self,battler)
  132. when 3
  133. pbDisplay(_INTL("¡Viejo! ¡Estuvo demasiado cerca!"))
  134. BallHandlers.onFailCatch(ball,self,battler)
  135. when 4
  136. pbDisplayBrief(_INTL("¡Si! ¡{1} ha sido capturado!",pokemon.name))
  137. @scene.pbThrowSuccess
  138. if pbIsSnagBall?(ball) && @opponent
  139. pbRemoveFromParty(battler.index,battler.pokemonIndex)
  140. battler.pbReset
  141. battler.participants=[]
  142. else
  143. @decision=4
  144. end
  145. if pbIsSnagBall?(ball)
  146. pokemon.ot=self.pbPlayer.name
  147. pokemon.trainerID=self.pbPlayer.id
  148. end
  149. BallHandlers.onCatch(ball,self,pokemon)
  150. pokemon.ballused=pbGetBallType(ball)
  151. pokemon.makeUnmega rescue nil
  152. pokemon.makeUnprimal rescue nil
  153. pokemon.pbRecordFirstMoves
  154. if GAINEXPFORCAPTURE
  155. battler.captured=true
  156. pbGainEXP
  157. battler.captured=false
  158. end
  159. if !self.pbPlayer.hasOwned?(species)
  160. self.pbPlayer.setOwned(species)
  161. if $Trainer.pokedex
  162. pbDisplayPaused(_INTL("Se agregaron los datos de {1} en la Pokédex.",pokemon.name))
  163. @scene.pbShowPokedex(species)
  164. end
  165. end
  166. @scene.pbHideCaptureBall
  167. if pbIsSnagBall?(ball) && @opponent
  168. pokemon.pbUpdateShadowMoves rescue nil
  169. @snaggedpokemon.push(pokemon)
  170. else
  171. pbStorePokemon(pokemon)
  172. end
  173. end
  174. end
  175. end
  176. end
  177.  
  178.  
  179.  
  180. ################################################################################
  181. # Main battle class.
  182. ################################################################################
  183. class PokeBattle_Battle
  184. attr_reader(:scene) # Scene object for this battle
  185. attr_accessor(:decision) # Decision: 0=undecided; 1=win; 2=loss; 3=escaped; 4=caught
  186. attr_accessor(:internalbattle) # Internal battle flag
  187. attr_accessor(:doublebattle) # Double battle flag
  188. attr_accessor(:cantescape) # True if player can't escape
  189. attr_accessor(:shiftStyle) # Shift/Set "battle style" option
  190. attr_accessor(:battlescene) # "Battle scene" option
  191. attr_accessor(:debug) # Debug flag
  192. attr_reader(:player) # Player trainer
  193. attr_reader(:opponent) # Opponent trainer
  194. attr_reader(:party1) # Player's Pokémon party
  195. attr_reader(:party2) # Foe's Pokémon party
  196. attr_reader(:party1order) # Order of Pokémon in the player's party
  197. attr_reader(:party2order) # Order of Pokémon in the opponent's party
  198. attr_accessor(:fullparty1) # True if player's party's max size is 6 instead of 3
  199. attr_accessor(:fullparty2) # True if opponent's party's max size is 6 instead of 3
  200. attr_reader(:battlers) # Currently active Pokémon
  201. attr_accessor(:items) # Items held by opponents
  202. attr_reader(:sides) # Effects common to each side of a battle
  203. attr_reader(:field) # Effects common to the whole of a battle
  204. attr_accessor(:environment) # Battle surroundings
  205. attr_accessor(:weather) # Current weather, custom methods should use pbWeather instead
  206. attr_accessor(:weatherduration) # Duration of current weather, or -1 if indefinite
  207. attr_reader(:switching) # True if during the switching phase of the round
  208. attr_reader(:futuresight) # True if Future Sight is hitting
  209. attr_reader(:struggle) # The Struggle move
  210. attr_accessor(:choices) # Choices made by each Pokémon this round
  211. attr_reader(:successStates) # Success states
  212. attr_accessor(:lastMoveUsed) # Last move used
  213. attr_accessor(:lastMoveUser) # Last move user
  214. attr_accessor(:megaEvolution) # Battle index of each trainer's Pokémon to Mega Evolve
  215. attr_accessor(:amuletcoin) # Whether Amulet Coin's effect applies
  216. attr_accessor(:extramoney) # Money gained in battle by using Pay Day
  217. attr_accessor(:doublemoney) # Whether Happy Hour's effect applies
  218. attr_accessor(:endspeech) # Speech by opponent when player wins
  219. attr_accessor(:endspeech2) # Speech by opponent when player wins
  220. attr_accessor(:endspeechwin) # Speech by opponent when opponent wins
  221. attr_accessor(:endspeechwin2) # Speech by opponent when opponent wins
  222. attr_accessor(:rules)
  223. attr_reader(:turncount)
  224. attr_accessor :controlPlayer
  225. include PokeBattle_BattleCommon
  226.  
  227. MAXPARTYSIZE = 6
  228. MEGARINGS=[:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM]
  229.  
  230. class BattleAbortedException < Exception; end
  231.  
  232. def pbAbort
  233. raise BattleAbortedException.new("Battle aborted")
  234. end
  235.  
  236. def pbDebugUpdate
  237. end
  238.  
  239. def pbRandom(x)
  240. return rand(x)
  241. end
  242.  
  243. def pbAIRandom(x)
  244. return rand(x)
  245. end
  246.  
  247. ################################################################################
  248. # Initialise battle class. / Inicializa la clase batalla
  249. ################################################################################
  250. def initialize(scene,p1,p2,player,opponent)
  251. if p1.length==0
  252. raise ArgumentError.new(_INTL("El equipo 1 no tiene Pokémon."))
  253. return
  254. end
  255. if p2.length==0
  256. raise ArgumentError.new(_INTL("El equipo 2 no tiene Pokémon."))
  257. return
  258. end
  259. if p2.length>2 && !opponent
  260. raise ArgumentError.new(_INTL("Las batallas con más de dos Pokémon salvajes no están permitidas."))
  261. return
  262. end
  263. @scene = scene
  264. @decision = 0
  265. @internalbattle = true
  266. @doublebattle = false
  267. @cantescape = false
  268. @shiftStyle = true
  269. @battlescene = true
  270. @debug = false
  271. @debugupdate = 0
  272. if opponent && player.is_a?(Array) && player.length==0
  273. player = player[0]
  274. end
  275. if opponent && opponent.is_a?(Array) && opponent.length==0
  276. opponent = opponent[0]
  277. end
  278. @player = player # PokeBattle_Trainer object
  279. @opponent = opponent # PokeBattle_Trainer object
  280. @party1 = p1
  281. @party2 = p2
  282. @party1order = []
  283. for i in 0...12; @party1order.push(i); end
  284. @party2order = []
  285. for i in 0...12; @party2order.push(i); end
  286. @fullparty1 = false
  287. @fullparty2 = false
  288. @battlers = []
  289. @items = nil
  290. @sides = [PokeBattle_ActiveSide.new, # Player's side
  291. PokeBattle_ActiveSide.new] # Foe's side
  292. @field = PokeBattle_ActiveField.new # Whole field (gravity/rooms)
  293. @environment = PBEnvironment::None # e.g. Tall grass, cave, still water
  294. @weather = 0
  295. @weatherduration = 0
  296. @switching = false
  297. @futuresight = false
  298. @choices = [ [0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1] ]
  299. @successStates = []
  300. for i in 0...4
  301. @successStates.push(PokeBattle_SuccessState.new)
  302. end
  303. @lastMoveUsed = -1
  304. @lastMoveUser = -1
  305. @nextPickupUse = 0
  306. @megaEvolution = []
  307. if @player.is_a?(Array)
  308. @megaEvolution[0]=[-1]*@player.length
  309. else
  310. @megaEvolution[0]=[-1]
  311. end
  312. if @opponent.is_a?(Array)
  313. @megaEvolution[1]=[-1]*@opponent.length
  314. else
  315. @megaEvolution[1]=[-1]
  316. end
  317. @amuletcoin = false
  318. @extramoney = 0
  319. @doublemoney = false
  320. @endspeech = ""
  321. @endspeech2 = ""
  322. @endspeechwin = ""
  323. @endspeechwin2 = ""
  324. @rules = {}
  325. @turncount = 0
  326. @peer = PokeBattle_BattlePeer.create()
  327. @priority = []
  328. @usepriority = false
  329. @snaggedpokemon = []
  330. @runCommand = 0
  331. if hasConst?(PBMoves,:STRUGGLE)
  332. @struggle = PokeBattle_Move.pbFromPBMove(self,PBMove.new(getConst(PBMoves,:STRUGGLE)))
  333. else
  334. @struggle = PokeBattle_Struggle.new(self,nil)
  335. end
  336. @struggle.pp = -1
  337. for i in 0...4
  338. battlers[i] = PokeBattle_Battler.new(self,i)
  339. end
  340. for i in @party1
  341. next if !i
  342. i.itemRecycle = 0
  343. i.itemInitial = i.item
  344. i.belch = false
  345. end
  346. for i in @party2
  347. next if !i
  348. i.itemRecycle = 0
  349. i.itemInitial = i.item
  350. i.belch = false
  351. end
  352. end
  353.  
  354. ################################################################################
  355. # Info about battle. / Información sobre la batalla
  356. ################################################################################
  357. def pbDoubleBattleAllowed?
  358. if !@fullparty1 && @party1.length>MAXPARTYSIZE
  359. return false
  360. end
  361. if !@fullparty2 && @party2.length>MAXPARTYSIZE
  362. return false
  363. end
  364. _opponent=@opponent
  365. _player=@player
  366. # Wild battle
  367. if !_opponent
  368. if @party2.length==1
  369. return false
  370. elsif @party2.length==2
  371. return true
  372. else
  373. return false
  374. end
  375. # Trainer battle
  376. else
  377. if _opponent.is_a?(Array)
  378. if _opponent.length==1
  379. _opponent=_opponent[0]
  380. elsif _opponent.length!=2
  381. return false
  382. end
  383. end
  384. _player=_player
  385. if _player.is_a?(Array)
  386. if _player.length==1
  387. _player=_player[0]
  388. elsif _player.length!=2
  389. return false
  390. end
  391. end
  392. if _opponent.is_a?(Array)
  393. sendout1=pbFindNextUnfainted(@party2,0,pbSecondPartyBegin(1))
  394. sendout2=pbFindNextUnfainted(@party2,pbSecondPartyBegin(1))
  395. return false if sendout1<0 || sendout2<0
  396. else
  397. sendout1=pbFindNextUnfainted(@party2,0)
  398. sendout2=pbFindNextUnfainted(@party2,sendout1+1)
  399. return false if sendout1<0 || sendout2<0
  400. end
  401. end
  402. if _player.is_a?(Array)
  403. sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0))
  404. sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0))
  405. return false if sendout1<0 || sendout2<0
  406. else
  407. sendout1=pbFindNextUnfainted(@party1,0)
  408. sendout2=pbFindNextUnfainted(@party1,sendout1+1)
  409. return false if sendout1<0 || sendout2<0
  410. end
  411. return true
  412. end
  413.  
  414. def pbWeather
  415. for i in 0...4
  416. if @battlers[i].hasWorkingAbility(:CLOUDNINE) ||
  417. @battlers[i].hasWorkingAbility(:AIRLOCK)
  418. return 0
  419. end
  420. end
  421. return @weather
  422. end
  423.  
  424. ################################################################################
  425. # Get battler info. / Obtiene información de la batalla
  426. ################################################################################
  427. def pbIsOpposing?(index)
  428. return (index%2)==1
  429. end
  430.  
  431. def pbOwnedByPlayer?(index)
  432. return false if pbIsOpposing?(index)
  433. return false if @player.is_a?(Array) && index==2
  434. return true
  435. end
  436.  
  437. def pbIsDoubleBattler?(index)
  438. return (index>=2)
  439. end
  440.  
  441. # Only used for Wish / Solo usado para Deseo
  442. def pbThisEx(battlerindex,pokemonindex)
  443. party=pbParty(battlerindex)
  444. if pbIsOpposing?(battlerindex)
  445. if @opponent
  446. return _INTL("El {1} rival",party[pokemonindex].name)
  447. else
  448. return _INTL("El {1} salvaje",party[pokemonindex].name)
  449. end
  450. else
  451. return _INTL("{1}",party[pokemonindex].name)
  452. end
  453. end
  454.  
  455. # Checks whether an item can be removed from a Pokémon.
  456. def pbIsUnlosableItem(pkmn,item)
  457. return true if pbIsMail?(item)
  458. return false if pkmn.effects[PBEffects::Transform]
  459. if isConst?(pkmn.ability,PBAbilities,:MULTITYPE)
  460. plates=[:FISTPLATE,:SKYPLATE,:TOXICPLATE,:EARTHPLATE,:STONEPLATE,
  461. :INSECTPLATE,:SPOOKYPLATE,:IRONPLATE,:FLAMEPLATE,:SPLASHPLATE,
  462. :MEADOWPLATE,:ZAPPLATE,:MINDPLATE,:ICICLEPLATE,:DRACOPLATE,
  463. :DREADPLATE,:PIXIEPLATE]
  464. for i in plates
  465. return true if isConst?(item,PBItems,i)
  466. end
  467. end
  468. combos=[[:GIRATINA,:GRISEOUSORB],
  469. [:GENESECT,:BURNDRIVE],
  470. [:GENESECT,:CHILLDRIVE],
  471. [:GENESECT,:DOUSEDRIVE],
  472. [:GENESECT,:SHOCKDRIVE],
  473. # Mega Stones
  474. [:ABOMASNOW,:ABOMASITE],
  475. [:ABSOL,:ABSOLITE],
  476. [:AERODACTYL,:AERODACTYLITE],
  477. [:AGGRON,:AGGRONITE],
  478. [:ALAKAZAM,:ALAKAZITE],
  479. [:ALTARIA,:ALTARIANITE],
  480. [:AMPHAROS,:AMPHAROSITE],
  481. [:AUDINO,:AUDINITE],
  482. [:BANETTE,:BANETTITE],
  483. [:BEEDRILL,:BEEDRILLITE],
  484. [:BLASTOISE,:BLASTOISINITE],
  485. [:BLAZIKEN,:BLAZIKENITE],
  486. [:CAMERUPT,:CAMERUPTITE],
  487. [:CHARIZARD,:CHARIZARDITEX],
  488. [:CHARIZARD,:CHARIZARDITEY],
  489. [:DIANCIE,:DIANCITE],
  490. [:GALLADE,:GALLADITE],
  491. [:GARCHOMP,:GARCHOMPITE],
  492. [:GARDEVOIR,:GARDEVOIRITE],
  493. [:GENGAR,:GENGARITE],
  494. [:GLALIE,:GLALITITE],
  495. [:GYARADOS,:GYARADOSITE],
  496. [:HERACROSS,:HERACRONITE],
  497. [:HOUNDOOM,:HOUNDOOMINITE],
  498. [:KANGASKHAN,:KANGASKHANITE],
  499. [:LATIAS,:LATIASITE],
  500. [:LATIOS,:LATIOSITE],
  501. [:LOPUNNY,:LOPUNNITE],
  502. [:LUCARIO,:LUCARIONITE],
  503. [:MANECTRIC,:MANECTITE],
  504. [:MAWILE,:MAWILITE],
  505. [:MEDICHAM,:MEDICHAMITE],
  506. [:METAGROSS,:METAGROSSITE],
  507. [:MEWTWO,:MEWTWONITEX],
  508. [:MEWTWO,:MEWTWONITEY],
  509. [:PIDGEOT,:PIDGEOTITE],
  510. [:PINSIR,:PINSIRITE],
  511. [:SABLEYE,:SABLENITE],
  512. [:SALAMENCE,:SALAMENCITE],
  513. [:SCEPTILE,:SCEPTILITE],
  514. [:SCIZOR,:SCIZORITE],
  515. [:SHARPEDO,:SHARPEDONITE],
  516. [:SLOWBRO,:SLOWBRONITE],
  517. [:STEELIX,:STEELIXITE],
  518. [:SWAMPERT,:SWAMPERTITE],
  519. [:TYRANITAR,:TYRANITARITE],
  520. [:VENUSAUR,:VENUSAURITE],
  521. # Primal Reversion stones
  522. [:KYOGRE,:BLUEORB],
  523. [:GROUDON,:REDORB]
  524. ]
  525. for i in combos
  526. if isConst?(pkmn.species,PBSpecies,i[0]) && isConst?(item,PBItems,i[1])
  527. return true
  528. end
  529. end
  530. return false
  531. end
  532.  
  533. def pbCheckGlobalAbility(a)
  534. for i in 0...4 # in order from own first, opposing first, own second, opposing second
  535. if @battlers[i].hasWorkingAbility(a)
  536. return @battlers[i]
  537. end
  538. end
  539. return nil
  540. end
  541.  
  542. def nextPickupUse
  543. @nextPickupUse+=1
  544. return @nextPickupUse
  545. end
  546.  
  547. ################################################################################
  548. # Player-related info.
  549. ################################################################################
  550. def pbPlayer
  551. if @player.is_a?(Array)
  552. return @player[0]
  553. else
  554. return @player
  555. end
  556. end
  557.  
  558. def pbGetOwnerItems(battlerIndex)
  559. return [] if !@items
  560. if pbIsOpposing?(battlerIndex)
  561. if @opponent.is_a?(Array)
  562. return (battlerIndex==1) ? @items[0] : @items[1]
  563. else
  564. return @items
  565. end
  566. else
  567. return []
  568. end
  569. end
  570.  
  571. def pbSetSeen(pokemon)
  572. if pokemon && @internalbattle
  573. self.pbPlayer.seen[pokemon.species]=true
  574. pbSeenForm(pokemon)
  575. end
  576. end
  577.  
  578. def pbGetMegaRingName(battlerIndex)
  579. if pbBelongsToPlayer?(battlerIndex)
  580. for i in MEGARINGS
  581. next if !hasConst?(PBItems,i)
  582. return PBItems.getName(getConst(PBItems,i)) if $PokemonBag.pbQuantity(i)>0
  583. end
  584. end
  585. # Add your own Mega objects for particular trainer types here
  586. # if isConst?(pbGetOwner(battlerIndex).trainertype,PBTrainers,:BUGCATCHER)
  587. # return _INTL("Mega Net")
  588. # end
  589. return _INTL("Mega Aro")
  590. end
  591.  
  592. def pbHasMegaRing(battlerIndex)
  593. return true if !pbBelongsToPlayer?(battlerIndex)
  594. for i in MEGARINGS
  595. next if !hasConst?(PBItems,i)
  596. return true if $PokemonBag.pbQuantity(i)>0
  597. end
  598. return false
  599. end
  600.  
  601. ################################################################################
  602. # Get party info, manipulate parties. / Obtiene información del equipo,
  603. ################################################################################
  604. def pbPokemonCount(party)
  605. count=0
  606. for i in party
  607. next if !i
  608. count+=1 if i.hp>0 && !i.isEgg?
  609. end
  610. return count
  611. end
  612.  
  613. def pbAllFainted?(party)
  614. pbPokemonCount(party)==0
  615. end
  616.  
  617. def pbMaxLevel(party)
  618. lv=0
  619. for i in party
  620. next if !i
  621. lv=i.level if lv<i.level
  622. end
  623. return lv
  624. end
  625.  
  626. def pbMaxLevelFromIndex(index)
  627. party=pbParty(index)
  628. owner=(pbIsOpposing?(index)) ? @opponent : @player
  629. maxlevel=0
  630. if owner.is_a?(Array)
  631. start=0
  632. limit=pbSecondPartyBegin(index)
  633. start=limit if pbIsDoubleBattler?(index)
  634. for i in start...start+limit
  635. next if !party[i]
  636. maxlevel=party[i].level if maxlevel<party[i].level
  637. end
  638. else
  639. for i in party
  640. next if !i
  641. maxlevel=i.level if maxlevel<i.level
  642. end
  643. end
  644. return maxlevel
  645. end
  646.  
  647. def pbParty(index)
  648. return pbIsOpposing?(index) ? party2 : party1
  649. end
  650.  
  651. def pbOpposingParty(index)
  652. return pbIsOpposing?(index) ? party1 : party2
  653. end
  654.  
  655. def pbSecondPartyBegin(battlerIndex)
  656. if pbIsOpposing?(battlerIndex)
  657. return @fullparty2 ? 6 : 3
  658. else
  659. return @fullparty1 ? 6 : 3
  660. end
  661. end
  662.  
  663. def pbPartyLength(battlerIndex)
  664. if pbIsOpposing?(battlerIndex)
  665. return (@opponent.is_a?(Array)) ? pbSecondPartyBegin(battlerIndex) : MAXPARTYSIZE
  666. else
  667. return @player.is_a?(Array) ? pbSecondPartyBegin(battlerIndex) : MAXPARTYSIZE
  668. end
  669. end
  670.  
  671. def pbFindNextUnfainted(party,start,finish=-1)
  672. finish=party.length if finish<0
  673. for i in start...finish
  674. next if !party[i]
  675. return i if party[i].hp>0 && !party[i].isEgg?
  676. end
  677. return -1
  678. end
  679.  
  680. def pbGetLastPokeInTeam(index)
  681. party=pbParty(index)
  682. partyorder=(!pbIsOpposing?(index)) ? @party1order : @party2order
  683. plength=pbPartyLength(index)
  684. pstart=pbGetOwnerIndex(index)*plength
  685. lastpoke=-1
  686. for i in pstart...pstart+plength
  687. p=party[partyorder[i]]
  688. next if !p || p.isEgg? || p.hp<=0
  689. lastpoke=partyorder[i]
  690. end
  691. return lastpoke
  692. end
  693.  
  694. def pbFindPlayerBattler(pkmnIndex)
  695. battler=nil
  696. for k in 0...4
  697. if !pbIsOpposing?(k) && @battlers[k].pokemonIndex==pkmnIndex
  698. battler=@battlers[k]
  699. break
  700. end
  701. end
  702. return battler
  703. end
  704.  
  705. def pbIsOwner?(battlerIndex,partyIndex)
  706. secondParty=pbSecondPartyBegin(battlerIndex)
  707. if !pbIsOpposing?(battlerIndex)
  708. return true if !@player || !@player.is_a?(Array)
  709. return (battlerIndex==0) ? partyIndex<secondParty : partyIndex>=secondParty
  710. else
  711. return true if !@opponent || !@opponent.is_a?(Array)
  712. return (battlerIndex==1) ? partyIndex<secondParty : partyIndex>=secondParty
  713. end
  714. end
  715.  
  716. def pbGetOwner(battlerIndex)
  717. if pbIsOpposing?(battlerIndex)
  718. if @opponent.is_a?(Array)
  719. return (battlerIndex==1) ? @opponent[0] : @opponent[1]
  720. else
  721. return @opponent
  722. end
  723. else
  724. if @player.is_a?(Array)
  725. return (battlerIndex==0) ? @player[0] : @player[1]
  726. else
  727. return @player
  728. end
  729. end
  730. end
  731.  
  732. def pbGetOwnerPartner(battlerIndex)
  733. if pbIsOpposing?(battlerIndex)
  734. if @opponent.is_a?(Array)
  735. return (battlerIndex==1) ? @opponent[1] : @opponent[0]
  736. else
  737. return @opponent
  738. end
  739. else
  740. if @player.is_a?(Array)
  741. return (battlerIndex==0) ? @player[1] : @player[0]
  742. else
  743. return @player
  744. end
  745. end
  746. end
  747.  
  748. def pbGetOwnerIndex(battlerIndex)
  749. if pbIsOpposing?(battlerIndex)
  750. return (@opponent.is_a?(Array)) ? ((battlerIndex==1) ? 0 : 1) : 0
  751. else
  752. return (@player.is_a?(Array)) ? ((battlerIndex==0) ? 0 : 1) : 0
  753. end
  754. end
  755.  
  756. def pbBelongsToPlayer?(battlerIndex)
  757. if @player.is_a?(Array) && @player.length>1
  758. return battlerIndex==0
  759. else
  760. return (battlerIndex%2)==0
  761. end
  762. return false
  763. end
  764.  
  765. def pbPartyGetOwner(battlerIndex,partyIndex)
  766. secondParty=pbSecondPartyBegin(battlerIndex)
  767. if !pbIsOpposing?(battlerIndex)
  768. return @player if !@player || !@player.is_a?(Array)
  769. return (partyIndex<secondParty) ? @player[0] : @player[1]
  770. else
  771. return @opponent if !@opponent || !@opponent.is_a?(Array)
  772. return (partyIndex<secondParty) ? @opponent[0] : @opponent[1]
  773. end
  774. end
  775.  
  776. def pbAddToPlayerParty(pokemon)
  777. party=pbParty(0)
  778. for i in 0...party.length
  779. party[i]=pokemon if pbIsOwner?(0,i) && !party[i]
  780. end
  781. end
  782.  
  783. def pbRemoveFromParty(battlerIndex,partyIndex)
  784. party=pbParty(battlerIndex)
  785. side=(pbIsOpposing?(battlerIndex)) ? @opponent : @player
  786. order=(pbIsOpposing?(battlerIndex)) ? @party2order : @party1order
  787. secondpartybegin=pbSecondPartyBegin(battlerIndex)
  788. party[partyIndex]=nil
  789. if !side || !side.is_a?(Array) # Oponente individual o salvaje
  790. party.compact!
  791. for i in partyIndex...party.length+1
  792. for j in 0...4
  793. next if !@battlers[j]
  794. if pbGetOwner(j)==side && @battlers[j].pokemonIndex==i
  795. @battlers[j].pokemonIndex-=1
  796. break
  797. end
  798. end
  799. end
  800. for i in 0...order.length
  801. order[i]=(i==partyIndex) ? order.length-1 : order[i]-1
  802. end
  803. else
  804. if partyIndex<secondpartybegin-1
  805. for i in partyIndex...secondpartybegin
  806. if i>=secondpartybegin-1
  807. party[i]=nil
  808. else
  809. party[i]=party[i+1]
  810. end
  811. end
  812. for i in 0...order.length
  813. next if order[i]>=secondpartybegin
  814. order[i]=(i==partyIndex) ? secondpartybegin-1 : order[i]-1
  815. end
  816. else
  817. for i in partyIndex...secondpartybegin+pbPartyLength(battlerIndex)
  818. if i>=party.length-1
  819. party[i]=nil
  820. else
  821. party[i]=party[i+1]
  822. end
  823. end
  824. for i in 0...order.length
  825. next if order[i]<secondpartybegin
  826. order[i]=(i==partyIndex) ? secondpartybegin+pbPartyLength(battlerIndex)-1 : order[i]-1
  827. end
  828. end
  829. end
  830. end
  831.  
  832. ################################################################################
  833. # Check whether actions can be taken. / Verifica cuando se pueden tomar acciones
  834. ################################################################################
  835. def pbCanShowCommands?(idxPokemon)
  836. thispkmn=@battlers[idxPokemon]
  837. return false if thispkmn.isFainted?
  838. return false if thispkmn.effects[PBEffects::TwoTurnAttack]>0
  839. return false if thispkmn.effects[PBEffects::HyperBeam]>0
  840. return false if thispkmn.effects[PBEffects::Rollout]>0
  841. return false if thispkmn.effects[PBEffects::Outrage]>0
  842. return false if thispkmn.effects[PBEffects::Uproar]>0
  843. return false if thispkmn.effects[PBEffects::Bide]>0
  844. return true
  845. end
  846.  
  847. ################################################################################
  848. # Attacking. / Atacando
  849. ################################################################################
  850. def pbCanShowFightMenu?(idxPokemon)
  851. thispkmn=@battlers[idxPokemon]
  852. if !pbCanShowCommands?(idxPokemon)
  853. return false
  854. end
  855. # No hay movimientos que se puedan elegir
  856. if !pbCanChooseMove?(idxPokemon,0,false) &&
  857. !pbCanChooseMove?(idxPokemon,1,false) &&
  858. !pbCanChooseMove?(idxPokemon,2,false) &&
  859. !pbCanChooseMove?(idxPokemon,3,false)
  860. return false
  861. end
  862. # Encore / Repetición
  863. return false if thispkmn.effects[PBEffects::Encore]>0
  864. return true
  865. end
  866.  
  867. def pbCanChooseMove?(idxPokemon,idxMove,showMessages,sleeptalk=false)
  868. thispkmn=@battlers[idxPokemon]
  869. thismove=thispkmn.moves[idxMove]
  870. opp1=thispkmn.pbOpposing1
  871. opp2=thispkmn.pbOpposing2
  872. if !thismove||thismove.id==0
  873. return false
  874. end
  875. if thismove.pp<=0 && thismove.totalpp>0 && !sleeptalk
  876. if showMessages
  877. pbDisplayPaused(_INTL("¡No quedan PP para este movimiento!"))
  878. end
  879. return false
  880. end
  881. if thispkmn.hasWorkingItem(:ASSAULTVEST) && thismove.pbIsStatus?
  882. if showMessages
  883. pbDisplayPaused(_INTL("¡Los efectos del {1} deshabilita el uso de movimientos de estado!",
  884. PBItems.getName(thispkmn.item)))
  885. end
  886. return false
  887. end
  888. if thispkmn.effects[PBEffects::ChoiceBand]>=0 &&
  889. (thispkmn.hasWorkingItem(:CHOICEBAND) ||
  890. thispkmn.hasWorkingItem(:CHOICESPECS) ||
  891. thispkmn.hasWorkingItem(:CHOICESCARF))
  892. hasmove=false
  893. for i in 0...4
  894. if thispkmn.moves[i].id==thispkmn.effects[PBEffects::ChoiceBand]
  895. hasmove=true; break
  896. end
  897. end
  898. if hasmove && thismove.id!=thispkmn.effects[PBEffects::ChoiceBand]
  899. if showMessages
  900. pbDisplayPaused(_INTL("¡La {1} solo permite el uso de {2}!",
  901. PBItems.getName(thispkmn.item),
  902. PBMoves.getName(thispkmn.effects[PBEffects::ChoiceBand])))
  903. end
  904. return false
  905. end
  906. end
  907. if opp1.effects[PBEffects::Imprison]
  908. if thismove.id==opp1.moves[0].id ||
  909. thismove.id==opp1.moves[1].id ||
  910. thismove.id==opp1.moves[2].id ||
  911. thismove.id==opp1.moves[3].id
  912. if showMessages
  913. pbDisplayPaused(_INTL("¡{1} no puede usar {2} por estar sellado!",thispkmn.pbThis,thismove.name))
  914. end
  915. #PBDebug.log("[CanChoose][#{opp1.pbThis} has: #{opp1.moves[0].name}, #{opp1.moves[1].name},#{opp1.moves[2].name},#{opp1.moves[3].name}]")
  916. return false
  917. end
  918. end
  919. if opp2.effects[PBEffects::Imprison] # Cerca
  920. if thismove.id==opp2.moves[0].id ||
  921. thismove.id==opp2.moves[1].id ||
  922. thismove.id==opp2.moves[2].id ||
  923. thismove.id==opp2.moves[3].id
  924. if showMessages
  925. pbDisplayPaused(_INTL("¡{1} no puede usar {2} por estar sellado!",thispkmn.pbThis,thismove.name))
  926. end
  927. #PBDebug.log("[CanChoose][#{opp2.pbThis} has: #{opp2.moves[0].name}, #{opp2.moves[1].name},#{opp2.moves[2].name},#{opp2.moves[3].name}]")
  928. return false
  929. end
  930. end
  931. if thispkmn.effects[PBEffects::Taunt]>0 && thismove.basedamage==0 # Mofa
  932. if showMessages
  933. pbDisplayPaused(_INTL("¡{1} no puede usar {2} por la mofa!",thispkmn.pbThis,thismove.name))
  934. end
  935. return false
  936. end
  937. if thispkmn.effects[PBEffects::Torment] # Tormento
  938. if thismove.id==thispkmn.lastMoveUsed
  939. if showMessages
  940. pbDisplayPaused(_INTL("¡{1} no puede utilizar el mismo movimiento dos veces seguidas debido al tormento!",thispkmn.pbThis))
  941. end
  942. return false
  943. end
  944. end
  945. if thismove.id==thispkmn.effects[PBEffects::DisableMove] && !sleeptalk # Movimiento deshabilitado
  946. if showMessages
  947. pbDisplayPaused(_INTL("¡{1} tiene deshabilitado {2}!",thispkmn.pbThis,thismove.name))
  948. end
  949. return false
  950. end
  951. if thismove.function==0x158 && # Belch
  952. (!thispkmn.pokemon || !thispkmn.pokemon.belch)
  953. if showMessages
  954. pbDisplayPaused(_INTL("¡{1} no ha comido ninguna baya, por lo que no se puede reciclar!",thispkmn.pbThis))
  955. end
  956. return false
  957. end
  958. if thispkmn.effects[PBEffects::Encore]>0 && idxMove!=thispkmn.effects[PBEffects::EncoreIndex]
  959. return false
  960. end
  961. return true
  962. end
  963.  
  964. def pbAutoChooseMove(idxPokemon,showMessages=true)
  965. thispkmn=@battlers[idxPokemon]
  966. if thispkmn.isFainted?
  967. @choices[idxPokemon][0]=0
  968. @choices[idxPokemon][1]=0
  969. @choices[idxPokemon][2]=nil
  970. return
  971. end
  972. if thispkmn.effects[PBEffects::Encore]>0 &&
  973. pbCanChooseMove?(idxPokemon,thispkmn.effects[PBEffects::EncoreIndex],false)
  974. PBDebug.log("[Auto choosing Encore move] #{thispkmn.moves[thispkmn.effects[PBEffects::EncoreIndex]].name}")
  975. @choices[idxPokemon][0]=1 # "Use move"
  976. @choices[idxPokemon][1]=thispkmn.effects[PBEffects::EncoreIndex] # Index of move
  977. @choices[idxPokemon][2]=thispkmn.moves[thispkmn.effects[PBEffects::EncoreIndex]]
  978. @choices[idxPokemon][3]=-1 # No target chosen yet
  979. if @doublebattle
  980. thismove=thispkmn.moves[thispkmn.effects[PBEffects::EncoreIndex]]
  981. target=thispkmn.pbTarget(thismove)
  982. if target==PBTargets::SingleNonUser
  983. target=@scene.pbChooseTarget(idxPokemon,target)
  984. pbRegisterTarget(idxPokemon,target) if target>=0
  985. elsif target==PBTargets::UserOrPartner
  986. target=@scene.pbChooseTarget(idxPokemon,target)
  987. pbRegisterTarget(idxPokemon,target) if target>=0 && (target&1)==(idxPokemon&1)
  988. end
  989. end
  990. else
  991. if !pbIsOpposing?(idxPokemon)
  992. pbDisplayPaused(_INTL("¡A {1} no le quedan movimientos!",thispkmn.name)) if showMessages
  993. end
  994. @choices[idxPokemon][0]=1 # "Usa movimiento"
  995. @choices[idxPokemon][1]=-1 # Índice del movimiento usado
  996. @choices[idxPokemon][2]=@struggle # Usa Combate
  997. @choices[idxPokemon][3]=-1 # Falta elegir objetivo
  998. end
  999. end
  1000.  
  1001. def pbRegisterMove(idxPokemon,idxMove,showMessages=true)
  1002. thispkmn=@battlers[idxPokemon]
  1003. thismove=thispkmn.moves[idxMove]
  1004. return false if !pbCanChooseMove?(idxPokemon,idxMove,showMessages)
  1005. @choices[idxPokemon][0]=1 # "Usa movimiento"
  1006. @choices[idxPokemon][1]=idxMove # Índice del movimiento usado
  1007. @choices[idxPokemon][2]=thismove # PokeBattle_Move object of the move
  1008. @choices[idxPokemon][3]=-1 # Falta elegir objetivo
  1009. return true
  1010. end
  1011.  
  1012. def pbChoseMove?(i,move)
  1013. return false if @battlers[i].isFainted?
  1014. if @choices[i][0]==1 && @choices[i][1]>=0
  1015. choice=@choices[i][1]
  1016. return isConst?(@battlers[i].moves[choice].id,PBMoves,move)
  1017. end
  1018. return false
  1019. end
  1020.  
  1021. def pbChoseMoveFunctionCode?(i,code)
  1022. return false if @battlers[i].isFainted?
  1023. if @choices[i][0]==1 && @choices[i][1]>=0
  1024. choice=@choices[i][1]
  1025. return @battlers[i].moves[choice].function==code
  1026. end
  1027. return false
  1028. end
  1029.  
  1030. def pbRegisterTarget(idxPokemon,idxTarget)
  1031. @choices[idxPokemon][3]=idxTarget # Set target of move
  1032. return true
  1033. end
  1034.  
  1035. def pbPriority(ignorequickclaw=false,log=false)
  1036. return @priority if @usepriority # use stored priority if round isn't over yet
  1037. @priority.clear
  1038. speeds=[]
  1039. priorities=[]
  1040. quickclaw=[]; lagging=[]
  1041. minpri=0; maxpri=0
  1042. temp=[]
  1043. # Calcula la velocidad de cada Pokémon
  1044. for i in 0...4
  1045. speeds[i]=@battlers[i].pbSpeed
  1046. quickclaw[i]=false
  1047. lagging[i]=false
  1048. if !ignorequickclaw && @choices[i][0]==1 # Chose to use a move
  1049. if !quickclaw[i] && @battlers[i].hasWorkingItem(:CUSTAPBERRY) &&
  1050. !@battlers[i].pbOpposing1.hasWorkingAbility(:UNNERVE) &&
  1051. !@battlers[i].pbOpposing2.hasWorkingAbility(:UNNERVE)
  1052. if (@battlers[i].hasWorkingAbility(:GLUTTONY) && @battlers[i].hp<=(@battlers[i].totalhp/2).floor) ||
  1053. @battlers[i].hp<=(@battlers[i].totalhp/4).floor
  1054. pbCommonAnimation("UseItem",@battlers[i],nil)
  1055. quickclaw[i]=true
  1056. pbDisplayBrief(_INTL("¡{1} se mueve primero gracias a la {2}!",
  1057. @battlers[i].pbThis,PBItems.getName(@battlers[i].item)))
  1058. @battlers[i].pbConsumeItem
  1059. end
  1060. end
  1061. if !quickclaw[i] && @battlers[i].hasWorkingItem(:QUICKCLAW)
  1062. if pbRandom(10)<2
  1063. pbCommonAnimation("UseItem",@battlers[i],nil)
  1064. quickclaw[i]=true
  1065. pbDisplayBrief(_INTL("¡{1} se mueve primero gracias a la {2}!",
  1066. @battlers[i].pbThis,PBItems.getName(@battlers[i].item)))
  1067. end
  1068. end
  1069. if !quickclaw[i] &&
  1070. (@battlers[i].hasWorkingAbility(:STALL) ||
  1071. @battlers[i].hasWorkingItem(:LAGGINGTAIL) ||
  1072. @battlers[i].hasWorkingItem(:FULLINCENSE))
  1073. lagging[i]=true
  1074. end
  1075. end
  1076. end
  1077. # Calculate each Pokémon's priority bracket, and get the min/max priorities
  1078. for i in 0...4
  1079. # Assume that doing something other than using a move is priority 0
  1080. pri=0
  1081. if @choices[i][0]==1 # Chose to use a move
  1082. pri=@choices[i][2].priority
  1083. pri+=1 if @battlers[i].hasWorkingAbility(:PRANKSTER) &&
  1084. @choices[i][2].pbIsStatus?
  1085. pri+=1 if @battlers[i].hasWorkingAbility(:GALEWINGS) &&
  1086. isConst?(@choices[i][2].type,PBTypes,:FLYING)
  1087. end
  1088. priorities[i]=pri
  1089. if i==0
  1090. minpri=pri
  1091. maxpri=pri
  1092. else
  1093. minpri=pri if minpri>pri
  1094. maxpri=pri if maxpri<pri
  1095. end
  1096. end
  1097. # Find and order all moves with the same priority
  1098. curpri=maxpri
  1099. loop do
  1100. temp.clear
  1101. for j in 0...4
  1102. temp.push(j) if priorities[j]==curpri
  1103. end
  1104. # Sort by speed
  1105. if temp.length==1
  1106. @priority[@priority.length]=@battlers[temp[0]]
  1107. elsif temp.length>1
  1108. n=temp.length
  1109. for m in 0...temp.length-1
  1110. for i in 1...temp.length
  1111. # For each pair of battlers, rank the second compared to the first
  1112. # -1 means rank higher, 0 means rank equal, 1 means rank lower
  1113. cmp=0
  1114. if quickclaw[temp[i]]
  1115. cmp=-1
  1116. if quickclaw[temp[i-1]]
  1117. if speeds[temp[i]]==speeds[temp[i-1]]
  1118. cmp=0
  1119. else
  1120. cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : 1
  1121. end
  1122. end
  1123. elsif quickclaw[temp[i-1]]
  1124. cmp=1
  1125. elsif lagging[temp[i]]
  1126. cmp=1
  1127. if lagging[temp[i-1]]
  1128. if speeds[temp[i]]==speeds[temp[i-1]]
  1129. cmp=0
  1130. else
  1131. cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? 1 : -1
  1132. end
  1133. end
  1134. elsif lagging[temp[i-1]]
  1135. cmp=-1
  1136. elsif speeds[temp[i]]!=speeds[temp[i-1]]
  1137. if @field.effects[PBEffects::TrickRoom]>0
  1138. cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? 1 : -1
  1139. else
  1140. cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : 1
  1141. end
  1142. end
  1143. if cmp<0 || # Swap the pair according to the second battler's rank
  1144. (cmp==0 && pbRandom(2)==0)
  1145. swaptmp=temp[i]
  1146. temp[i]=temp[i-1]
  1147. temp[i-1]=swaptmp
  1148. end
  1149. end
  1150. end
  1151. # Battlers in this bracket are properly sorted, so add them to @priority
  1152. for i in temp
  1153. @priority[@priority.length]=@battlers[i]
  1154. end
  1155. end
  1156. curpri-=1
  1157. break if curpri<minpri
  1158. end
  1159. # Write the priority order to the debug log
  1160. if log
  1161. d="[Priority] "; comma=false
  1162. for i in 0...4
  1163. if @priority[i] && !@priority[i].isFainted?
  1164. d+=", " if comma
  1165. d+="#{@priority[i].pbThis(comma)} (#{@priority[i].index})"; comma=true
  1166. end
  1167. end
  1168. PBDebug.log(d)
  1169. end
  1170. @usepriority=true
  1171. return @priority
  1172. end
  1173.  
  1174. ################################################################################
  1175. # Switching Pokémon.
  1176. ################################################################################
  1177. def pbCanSwitchLax?(idxPokemon,pkmnidxTo,showMessages)
  1178. if pkmnidxTo>=0
  1179. party=pbParty(idxPokemon)
  1180. if pkmnidxTo>=party.length
  1181. return false
  1182. end
  1183. if !party[pkmnidxTo]
  1184. return false
  1185. end
  1186. if party[pkmnidxTo].isEgg?
  1187. pbDisplayPaused(_INTL("¡Un Huevo no puede pelear!")) if showMessages
  1188. return false
  1189. end
  1190. if !pbIsOwner?(idxPokemon,pkmnidxTo)
  1191. owner=pbPartyGetOwner(idxPokemon,pkmnidxTo)
  1192. pbDisplayPaused(_INTL("¡No puedes cambiar un Pokémon de {1} por uno de los tuyos!",owner.name)) if showMessages
  1193. return false
  1194. end
  1195. if party[pkmnidxTo].hp<=0
  1196. pbDisplayPaused(_INTL("¡{1} no tiene más energías para pelear!",party[pkmnidxTo].name)) if showMessages
  1197. return false
  1198. end
  1199. if @battlers[idxPokemon].pokemonIndex==pkmnidxTo ||
  1200. @battlers[idxPokemon].pbPartner.pokemonIndex==pkmnidxTo
  1201. pbDisplayPaused(_INTL("¡{1} ya está en el campo de batalla!",party[pkmnidxTo].name)) if showMessages
  1202. return false
  1203. end
  1204. end
  1205. return true
  1206. end
  1207.  
  1208. def pbCanSwitch?(idxPokemon,pkmnidxTo,showMessages,ignoremeanlook=false)
  1209. thispkmn=@battlers[idxPokemon]
  1210. # Multi-Turn Attacks/Mean Look -- Ataques multiturnos / Mal de Ojo
  1211. if !pbCanSwitchLax?(idxPokemon,pkmnidxTo,showMessages)
  1212. return false
  1213. end
  1214. isOpposing=pbIsOpposing?(idxPokemon)
  1215. party=pbParty(idxPokemon)
  1216. for i in 0...4
  1217. next if isOpposing!=pbIsOpposing?(i)
  1218. if choices[i][0]==2 && choices[i][1]==pkmnidxTo
  1219. pbDisplayPaused(_INTL("{1} ya está seleccionado.",party[pkmnidxTo].name)) if showMessages
  1220. return false
  1221. end
  1222. end
  1223. if thispkmn.hasWorkingItem(:SHEDSHELL)
  1224. return true
  1225. end
  1226. if USENEWBATTLEMECHANICS && thispkmn.pbHasType?(:GHOST)
  1227. return true
  1228. end
  1229. if thispkmn.effects[PBEffects::MultiTurn]>0 ||
  1230. (!ignoremeanlook && thispkmn.effects[PBEffects::MeanLook]>=0)
  1231. pbDisplayPaused(_INTL("¡{1} no puede ser remplazado!",thispkmn.pbThis)) if showMessages
  1232. return false
  1233. end
  1234. if @field.effects[PBEffects::FairyLock]>0
  1235. pbDisplayPaused(_INTL("¡{1} no puede ser remplazado!",thispkmn.pbThis)) if showMessages
  1236. return false
  1237. end
  1238. if thispkmn.effects[PBEffects::Ingrain]
  1239. pbDisplayPaused(_INTL("¡{1} no puede ser remplazado!",thispkmn.pbThis)) if showMessages
  1240. return false
  1241. end
  1242. opp1=thispkmn.pbOpposing1
  1243. opp2=thispkmn.pbOpposing2
  1244. opp=nil
  1245. if thispkmn.pbHasType?(:STEEL)
  1246. opp=opp1 if opp1.hasWorkingAbility(:MAGNETPULL)
  1247. opp=opp2 if opp2.hasWorkingAbility(:MAGNETPULL)
  1248. end
  1249. if !thispkmn.isAirborne?
  1250. opp=opp1 if opp1.hasWorkingAbility(:ARENATRAP)
  1251. opp=opp2 if opp2.hasWorkingAbility(:ARENATRAP)
  1252. end
  1253. if !thispkmn.hasWorkingAbility(:SHADOWTAG)
  1254. opp=opp1 if opp1.hasWorkingAbility(:SHADOWTAG)
  1255. opp=opp2 if opp2.hasWorkingAbility(:SHADOWTAG)
  1256. end
  1257. if opp
  1258. abilityname=PBAbilities.getName(opp.ability)
  1259. pbDisplayPaused(_INTL("¡La habilidad {2} de {1} impide el cambio!",opp.pbThis,abilityname)) if showMessages
  1260. return false
  1261. end
  1262. return true
  1263. end
  1264.  
  1265. def pbRegisterSwitch(idxPokemon,idxOther)
  1266. return false if !pbCanSwitch?(idxPokemon,idxOther,false)
  1267. @choices[idxPokemon][0]=2 # "Cambiar Pokémon"
  1268. @choices[idxPokemon][1]=idxOther # Índice del Pokémon con el que se hará el cambio
  1269. @choices[idxPokemon][2]=nil
  1270. side=(pbIsOpposing?(idxPokemon)) ? 1 : 0
  1271. owner=pbGetOwnerIndex(idxPokemon)
  1272. if @megaEvolution[side][owner]==idxPokemon
  1273. @megaEvolution[side][owner]=-1
  1274. end
  1275. return true
  1276. end
  1277.  
  1278. def pbCanChooseNonActive?(index)
  1279. party=pbParty(index)
  1280. for i in 0...party.length
  1281. return true if pbCanSwitchLax?(index,i,false)
  1282. end
  1283. return false
  1284. end
  1285.  
  1286. def pbSwitch(favorDraws=false)
  1287. if !favorDraws
  1288. return if @decision>0
  1289. else
  1290. return if @decision==5
  1291. end
  1292. pbJudge()
  1293. return if @decision>0
  1294. firstbattlerhp=@battlers[0].hp
  1295. switched=[]
  1296. for index in 0...4
  1297. next if !@doublebattle && pbIsDoubleBattler?(index)
  1298. next if @battlers[index] && !@battlers[index].isFainted?
  1299. next if !pbCanChooseNonActive?(index)
  1300. if !pbOwnedByPlayer?(index)
  1301. if !pbIsOpposing?(index) || (@opponent && pbIsOpposing?(index))
  1302. newenemy=pbSwitchInBetween(index,false,false)
  1303. newenemyname=newenemy
  1304. if newenemy>=0 && isConst?(pbParty(index)[newenemy].ability,PBAbilities,:ILLUSION)
  1305. newenemyname=pbGetLastPokeInTeam(index)
  1306. end
  1307. opponent=pbGetOwner(index)
  1308. if !@doublebattle && firstbattlerhp>0 && @shiftStyle && @opponent &&
  1309. @internalbattle && pbCanChooseNonActive?(0) && pbIsOpposing?(index) &&
  1310. @battlers[0].effects[PBEffects::Outrage]==0
  1311. pbDisplayPaused(_INTL("{1} está por enviar a {2}.",opponent.fullname,pbParty(index)[newenemyname].name))
  1312. if pbDisplayConfirm(_INTL("{1}, ¿quieres cambiar de Pokémon?",self.pbPlayer.name))
  1313. newpoke=pbSwitchPlayer(0,true,true)
  1314. if newpoke>=0
  1315. newpokename=newpoke
  1316. if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
  1317. newpokename=pbGetLastPokeInTeam(0)
  1318. end
  1319. pbDisplayBrief(_INTL("¡{1}, es suficiente! ¡Regresa!",@battlers[0].name))
  1320. pbRecallAndReplace(0,newpoke,newpokename)
  1321. switched.push(0)
  1322. end
  1323. end
  1324. end
  1325. pbRecallAndReplace(index,newenemy,newenemyname,false,false)
  1326. switched.push(index)
  1327. end
  1328. elsif @opponent
  1329. newpoke=pbSwitchInBetween(index,true,false)
  1330. newpokename=newpoke
  1331. if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
  1332. newpokename=pbGetLastPokeInTeam(index)
  1333. end
  1334. pbRecallAndReplace(index,newpoke,newpokename)
  1335. switched.push(index)
  1336. else
  1337. switch=false
  1338. if !pbDisplayConfirm(_INTL("¿Quieres cambiar de Pokémon?"))
  1339. switch=(pbRun(index,true)<=0)
  1340. else
  1341. switch=true
  1342. end
  1343. if switch
  1344. newpoke=pbSwitchInBetween(index,true,false)
  1345. newpokename=newpoke
  1346. if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
  1347. newpokename=pbGetLastPokeInTeam(index)
  1348. end
  1349. pbRecallAndReplace(index,newpoke,newpokename)
  1350. switched.push(index)
  1351. end
  1352. end
  1353. end
  1354. if switched.length>0
  1355. priority=pbPriority
  1356. for i in priority
  1357. i.pbAbilitiesOnSwitchIn(true) if switched.include?(i.index)
  1358. end
  1359. end
  1360. end
  1361.  
  1362. def pbSendOut(index,pokemon)
  1363. pbSetSeen(pokemon)
  1364. @peer.pbOnEnteringBattle(self,pokemon)
  1365. if pbIsOpposing?(index)
  1366. @scene.pbTrainerSendOut(index,pokemon)
  1367. else
  1368. @scene.pbSendOut(index,pokemon)
  1369. end
  1370. @scene.pbResetMoveIndex(index)
  1371. end
  1372.  
  1373. def pbReplace(index,newpoke,batonpass=false)
  1374. party=pbParty(index)
  1375. oldpoke=@battlers[index].pokemonIndex
  1376. # Initialise the new Pokémon
  1377. @battlers[index].pbInitialize(party[newpoke],newpoke,batonpass)
  1378. # Reorder the party for this battle
  1379. partyorder=(!pbIsOpposing?(index)) ? @party1order : @party2order
  1380. bpo=-1; bpn=-1
  1381. for i in 0...partyorder.length
  1382. bpo=i if partyorder[i]==oldpoke
  1383. bpn=i if partyorder[i]==newpoke
  1384. end
  1385. p=partyorder[bpo]; partyorder[bpo]=partyorder[bpn]; partyorder[bpn]=p
  1386. # Send out the new Pokémon
  1387. pbSendOut(index,party[newpoke])
  1388. pbSetSeen(party[newpoke])
  1389. end
  1390.  
  1391. def pbRecallAndReplace(index,newpoke,newpokename=-1,batonpass=false,moldbreaker=false)
  1392. @battlers[index].pbResetForm
  1393. if !@battlers[index].isFainted?
  1394. @scene.pbRecall(index)
  1395. end
  1396. pbMessagesOnReplace(index,newpoke,newpokename)
  1397. pbReplace(index,newpoke,batonpass)
  1398. return pbOnActiveOne(@battlers[index],false,moldbreaker)
  1399. end
  1400.  
  1401. def pbMessagesOnReplace(index,newpoke,newpokename=-1)
  1402. newpokename=newpoke if newpokename<0
  1403. party=pbParty(index)
  1404. if pbOwnedByPlayer?(index)
  1405. # if !party[newpoke]
  1406. # p [index,newpoke,party[newpoke],pbAllFainted?(party)]
  1407. # PBDebug.log([index,newpoke,party[newpoke],"pbMOR"].inspect)
  1408. # for i in 0...party.length
  1409. # PBDebug.log([i,party[i].hp].inspect)
  1410. # end
  1411. # raise BattleAbortedException.new
  1412. # end
  1413. opposing=@battlers[index].pbOppositeOpposing
  1414. if opposing.isFainted? || opposing.hp==opposing.totalhp
  1415. pbDisplayBrief(_INTL("¡Adelante! ¡{1}!",party[newpokename].name))
  1416. elsif opposing.hp>=(opposing.totalhp/2)
  1417. pbDisplayBrief(_INTL("¡Tú puedes! ¡{1}!",party[newpokename].name))
  1418. elsif opposing.hp>=(opposing.totalhp/4)
  1419. pbDisplayBrief(_INTL("¡Ya lo tienes, {1}!",party[newpokename].name))
  1420. else
  1421. pbDisplayBrief(_INTL("¡Tu rival está débil!\n¡Termínalo, {1}!",party[newpokename].name))
  1422. end
  1423. PBDebug.log("[Sacar Pokémon] El jugador envió a #{party[newpokename].name} en posición #{index}")
  1424. else
  1425. # if !party[newpoke]
  1426. # p [index,newpoke,party[newpoke],pbAllFainted?(party)]
  1427. # PBDebug.log([index,newpoke,party[newpoke],"pbMOR"].inspect)
  1428. # for i in 0...party.length
  1429. # PBDebug.log([i,party[i].hp].inspect)
  1430. # end
  1431. # raise BattleAbortedException.new
  1432. # end
  1433. owner=pbGetOwner(index)
  1434. pbDisplayBrief(_INTL("¡{1} envió\r\na {2}!",owner.fullname,party[newpokename].name))
  1435. PBDebug.log("[Sacar Pokémon] Rival envió a #{party[newpokename].name} en posición #{index}")
  1436. end
  1437. end
  1438.  
  1439. def pbSwitchInBetween(index,lax,cancancel)
  1440. if !pbOwnedByPlayer?(index)
  1441. return @scene.pbChooseNewEnemy(index,pbParty(index))
  1442. else
  1443. return pbSwitchPlayer(index,lax,cancancel)
  1444. end
  1445. end
  1446.  
  1447. def pbSwitchPlayer(index,lax,cancancel)
  1448. if @debug
  1449. return @scene.pbChooseNewEnemy(index,pbParty(index))
  1450. else
  1451. return @scene.pbSwitch(index,lax,cancancel)
  1452. end
  1453. end
  1454.  
  1455. ################################################################################
  1456. # Using an item. / Usando un objeto
  1457. ################################################################################
  1458. # Uses an item on a Pokémon in the player's party.
  1459. def pbUseItemOnPokemon(item,pkmnIndex,userPkmn,scene)
  1460. pokemon=@party1[pkmnIndex]
  1461. battler=nil
  1462. name=pbGetOwner(userPkmn.index).fullname
  1463. name=pbGetOwner(userPkmn.index).name if pbBelongsToPlayer?(userPkmn.index)
  1464. pbDisplayBrief(_INTL("{1} ha usado\r\n{2}.",name,PBItems.getName(item)))
  1465. PBDebug.log("[Objeto usado] El jugador ha usado #{PBItems.getName(item)} en #{pokemon.name}")
  1466. ret=false
  1467. if pokemon.isEgg?
  1468. pbDisplay(_INTL("¡Pero no tuvo efecto!"))
  1469. else
  1470. for i in 0...4
  1471. if !pbIsOpposing?(i) && @battlers[i].pokemonIndex==pkmnIndex
  1472. battler=@battlers[i]
  1473. end
  1474. end
  1475. ret=ItemHandlers.triggerBattleUseOnPokemon(item,pokemon,battler,scene)
  1476. end
  1477. if !ret && pbBelongsToPlayer?(userPkmn.index)
  1478. if $PokemonBag.pbCanStore?(item)
  1479. $PokemonBag.pbStoreItem(item)
  1480. else
  1481. raise _INTL("De alguna forma no se pudo regresar el objeto sin usar a la mochila.")
  1482. end
  1483. end
  1484. return ret
  1485. end
  1486.  
  1487. # Uses an item on an active Pokémon.
  1488. def pbUseItemOnBattler(item,index,userPkmn,scene)
  1489. PBDebug.log("[Objeto usado] El jugador ha usado #{PBItems.getName(item)} en #{@battlers[index].pbThis(true)}")
  1490. ret=ItemHandlers.triggerBattleUseOnBattler(item,@battlers[index],scene)
  1491. if !ret && pbBelongsToPlayer?(userPkmn.index)
  1492. if $PokemonBag.pbCanStore?(item)
  1493. $PokemonBag.pbStoreItem(item)
  1494. else
  1495. raise _INTL("De alguna forma no se pudo regresar el objeto sin usar a la mochila.")
  1496. end
  1497. end
  1498. return ret
  1499. end
  1500.  
  1501. def pbRegisterItem(idxPokemon,idxItem,idxTarget=nil)
  1502. if idxTarget!=nil && idxTarget>=0
  1503. for i in 0...4
  1504. if !@battlers[i].pbIsOpposing?(idxPokemon) &&
  1505. @battlers[i].pokemonIndex==idxTarget &&
  1506. @battlers[i].effects[PBEffects::Embargo]>0
  1507. pbDisplay(_INTL("¡El efecto de Embargo impide usar el objeto en {1}!",@battlers[i].pbThis(true)))
  1508. if pbBelongsToPlayer?(@battlers[i].index)
  1509. if $PokemonBag.pbCanStore?(idxItem)
  1510. $PokemonBag.pbStoreItem(idxItem)
  1511. else
  1512. raise _INTL("Por alguna razón, no se pudo regresar el objeto a la mochila.")
  1513. end
  1514. end
  1515. return false
  1516. end
  1517. end
  1518. end
  1519. if ItemHandlers.hasUseInBattle(idxItem)
  1520. if idxPokemon==0 # Primer Pokémon del Jugador
  1521. if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
  1522. # Using Poké Balls or Poké Doll only
  1523. ItemHandlers.triggerUseInBattle(idxItem,@battlers[idxPokemon],self)
  1524. if @doublebattle
  1525. @battlers[idxPokemon+2].effects[PBEffects::SkipTurn]=true
  1526. end
  1527. else
  1528. if $PokemonBag.pbCanStore?(idxItem)
  1529. $PokemonBag.pbStoreItem(idxItem)
  1530. else
  1531. raise _INTL("De alguna forma no se pudo regresar el objeto sin usar a la mochila.")
  1532. end
  1533. return false
  1534. end
  1535. else
  1536. if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
  1537. pbDisplay(_INTL("¡Es imposible apuntar sin concentrarse!"))
  1538. end
  1539. return false
  1540. end
  1541. end
  1542. @choices[idxPokemon][0]=3 # "Usar un objeto"
  1543. @choices[idxPokemon][1]=idxItem # ID del objeto que se usará
  1544. @choices[idxPokemon][2]=idxTarget # Índice del Pokémon sobre el que se usará
  1545. side=(pbIsOpposing?(idxPokemon)) ? 1 : 0
  1546. owner=pbGetOwnerIndex(idxPokemon)
  1547. if @megaEvolution[side][owner]==idxPokemon
  1548. @megaEvolution[side][owner]=-1
  1549. end
  1550. return true
  1551. end
  1552.  
  1553. def pbEnemyUseItem(item,battler)
  1554. return 0 if !@internalbattle
  1555. items=pbGetOwnerItems(battler.index)
  1556. return if !items
  1557. opponent=pbGetOwner(battler.index)
  1558. for i in 0...items.length
  1559. if items[i]==item
  1560. items.delete_at(i)
  1561. break
  1562. end
  1563. end
  1564. itemname=PBItems.getName(item)
  1565. pbDisplayBrief(_INTL("¡{1} ha usado\r\n{2}!",opponent.fullname,itemname))
  1566. PBDebug.log("[Objeto usado] El rival ha usado #{itemname} en #{battler.pbThis(true)}")
  1567. if isConst?(item,PBItems,:POTION)
  1568. battler.pbRecoverHP(20,true)
  1569. pbDisplay(_INTL("Los PS de {1} fueron restaurados.",battler.pbThis))
  1570. elsif isConst?(item,PBItems,:SUPERPOTION)
  1571. battler.pbRecoverHP(50,true)
  1572. pbDisplay(_INTL("Los PS de {1} fueron restaurados.",battler.pbThis))
  1573. elsif isConst?(item,PBItems,:HYPERPOTION)
  1574. battler.pbRecoverHP(200,true)
  1575. pbDisplay(_INTL("Los PS de {1} fueron restaurados.",battler.pbThis))
  1576. elsif isConst?(item,PBItems,:MAXPOTION)
  1577. battler.pbRecoverHP(battler.totalhp-battler.hp,true)
  1578. pbDisplay(_INTL("Los PS de {1} fueron restaurados.",battler.pbThis))
  1579. elsif isConst?(item,PBItems,:FULLRESTORE)
  1580. fullhp=(battler.hp==battler.totalhp)
  1581. battler.pbRecoverHP(battler.totalhp-battler.hp,true)
  1582. battler.status=0; battler.statusCount=0
  1583. battler.effects[PBEffects::Confusion]=0
  1584. if fullhp
  1585. pbDisplay(_INTL("¡{1} se puso saludable!",battler.pbThis))
  1586. else
  1587. pbDisplay(_INTL("Los PS de {1} fueron restaurados.",battler.pbThis))
  1588. end
  1589. elsif isConst?(item,PBItems,:FULLHEAL)
  1590. battler.status=0; battler.statusCount=0
  1591. battler.effects[PBEffects::Confusion]=0
  1592. pbDisplay(_INTL("¡{1} se puso saludable!",battler.pbThis))
  1593. elsif isConst?(item,PBItems,:XATTACK)
  1594. if battler.pbCanIncreaseStatStage?(PBStats::ATTACK,battler)
  1595. battler.pbIncreaseStat(PBStats::ATTACK,1,battler,true)
  1596. end
  1597. elsif isConst?(item,PBItems,:XDEFEND)
  1598. if battler.pbCanIncreaseStatStage?(PBStats::DEFENSE,battler)
  1599. battler.pbIncreaseStat(PBStats::DEFENSE,1,battler,true)
  1600. end
  1601. elsif isConst?(item,PBItems,:XSPEED)
  1602. if battler.pbCanIncreaseStatStage?(PBStats::SPEED,battler)
  1603. battler.pbIncreaseStat(PBStats::SPEED,1,battler,true)
  1604. end
  1605. elsif isConst?(item,PBItems,:XSPECIAL)
  1606. if battler.pbCanIncreaseStatStage?(PBStats::SPATK,battler)
  1607. battler.pbIncreaseStat(PBStats::SPATK,1,battler,true)
  1608. end
  1609. elsif isConst?(item,PBItems,:XSPDEF)
  1610. if battler.pbCanIncreaseStatStage?(PBStats::SPDEF,battler)
  1611. battler.pbIncreaseStat(PBStats::SPDEF,1,battler,true)
  1612. end
  1613. elsif isConst?(item,PBItems,:XACCURACY)
  1614. if battler.pbCanIncreaseStatStage?(PBStats::ACCURACY,battler)
  1615. battler.pbIncreaseStat(PBStats::ACCURACY,1,battler,true)
  1616. end
  1617. end
  1618. end
  1619.  
  1620. ################################################################################
  1621. # Fleeing from battle. / Huyendo de la batalla
  1622. ################################################################################
  1623. def pbCanRun?(idxPokemon)
  1624. return false if @opponent
  1625. return false if @cantescape && !pbIsOpposing?(idsPokemon)
  1626. thispkmn=@battlers[idxPokemon]
  1627. return true if thispkmn.pbHasType?(:GHOST) && USENEWBATTLEMECHANICS
  1628. return true if thispkmn.hasWorkingItem(:SMOKEBALL)
  1629. return true if thispkmn.hasWorkingAbility(:RUNAWAY)
  1630. return pbCanSwitch?(idxPokemon,-1,false)
  1631. end
  1632.  
  1633. def pbRun(idxPokemon,duringBattle=false)
  1634. thispkmn=@battlers[idxPokemon]
  1635. if pbIsOpposing?(idxPokemon)
  1636. return 0 if @opponent
  1637. @choices[i][0]=5 # run
  1638. @choices[i][1]=0
  1639. @choices[i][2]=nil
  1640. return -1
  1641. end
  1642. if @opponent
  1643. if $DEBUG && Input.press?(Input::CTRL)
  1644. if pbDisplayConfirm(_INTL("¿Tratar esta batalla como una victoria?"))
  1645. @decision=1
  1646. return 1
  1647. elsif pbDisplayConfirm(_INTL("¿Tratar esta batalla como una derrota?"))
  1648. @decision=2
  1649. return 1
  1650. end
  1651. elsif @internalbattle
  1652. pbDisplayPaused(_INTL("¡No! ¡No se puede escapar de una batalla contra un entrenador!"))
  1653. elsif pbDisplayConfirm(_INTL("¿Quieres perder el duelo y salir ahora?"))
  1654. pbDisplay(_INTL("¡{1} perdió el duelo!",self.pbPlayer.name))
  1655. @decision=3
  1656. return 1
  1657. end
  1658. return 0
  1659. end
  1660. if $DEBUG && Input.press?(Input::CTRL)
  1661. pbDisplayPaused(_INTL("¡Escapaste sin problemas!"))
  1662. @decision=3
  1663. return 1
  1664. end
  1665. if @cantescape
  1666. pbDisplayPaused(_INTL("¡No conseguiste escapar!"))
  1667. return 0
  1668. end
  1669. if thispkmn.pbHasType?(:GHOST) && USENEWBATTLEMECHANICS
  1670. pbDisplayPaused(_INTL("¡Escapaste sin problemas!"))
  1671. @decision=3
  1672. return 1
  1673. end
  1674. if thispkmn.hasWorkingAbility(:RUNAWAY)
  1675. if duringBattle
  1676. pbDisplayPaused(_INTL("¡Escapaste sin problemas!"))
  1677. else
  1678. pbDisplayPaused(_INTL("¡{1} ha escapado usando Fuga!",thispkmn.pbThis))
  1679. end
  1680. @decision=3
  1681. return 1
  1682. end
  1683. if thispkmn.hasWorkingItem(:SMOKEBALL)
  1684. if duringBattle
  1685. pbDisplayPaused(_INTL("¡Escapaste sin problemas!"))
  1686. else
  1687. pbDisplayPaused(_INTL("¡{1} ha escapado usando la {2}!",thispkmn.pbThis,PBItems.getName(thispkmn.item)))
  1688. end
  1689. @decision=3
  1690. return 1
  1691. end
  1692. if $game_switches[90] && turncount >= 3
  1693. if duringBattle
  1694. pbDisplayPaused(_INTL("¡Arya ha escapado con presteza!"))
  1695. end
  1696. @decision=3
  1697. return 1
  1698. end
  1699. if !duringBattle && !pbCanSwitch?(idxPokemon,-1,false)
  1700. pbDisplayPaused(_INTL("¡No conseguiste escapar!"))
  1701. return 0
  1702. end
  1703. # Note: not pbSpeed, because using unmodified Speed
  1704. speedPlayer=@battlers[idxPokemon].speed
  1705. opposing=@battlers[idxPokemon].pbOppositeOpposing
  1706. opposing=opposing.pbPartner if opposing.isFainted?
  1707. if !opposing.isFainted?
  1708. speedEnemy=opposing.speed
  1709. if speedPlayer>speedEnemy
  1710. rate=256
  1711. else
  1712. speedEnemy=1 if speedEnemy<=0
  1713. rate=speedPlayer*128/speedEnemy
  1714. rate+=@runCommand*30
  1715. rate&=0xFF
  1716. end
  1717. else
  1718. rate=256
  1719. end
  1720. ret=1
  1721. if pbAIRandom(256)<rate
  1722. pbDisplayPaused(_INTL("¡Escapaste sin problemas!"))
  1723. @decision=3
  1724. else
  1725. pbDisplayPaused(_INTL("¡No conseguiste escapar!"))
  1726. ret=-1
  1727. end
  1728. @runCommand+=1 if !duringBattle
  1729. return ret
  1730. end
  1731.  
  1732. ################################################################################
  1733. # Mega Evolve battler. / Mega Evolución
  1734. ################################################################################
  1735. def pbCanMegaEvolve?(index)
  1736. return false if $game_switches[NO_MEGA_EVOLUTION]
  1737. return false if !@battlers[index].hasMega?
  1738. return false if pbIsOpposing?(index) && !@opponent
  1739. return true if $DEBUG && Input.press?(Input::CTRL)
  1740. return false if !pbHasMegaRing(index)
  1741. side=(pbIsOpposing?(index)) ? 1 : 0
  1742. owner=pbGetOwnerIndex(index)
  1743. return false if @megaEvolution[side][owner]!=-1
  1744. return false if @battlers[index].effects[PBEffects::SkyDrop]
  1745. return true
  1746. end
  1747.  
  1748. def pbRegisterMegaEvolution(index)
  1749. side=(pbIsOpposing?(index)) ? 1 : 0
  1750. owner=pbGetOwnerIndex(index)
  1751. @megaEvolution[side][owner]=index
  1752. end
  1753.  
  1754. def pbMegaEvolve(index)
  1755. return if !@battlers[index] || !@battlers[index].pokemon
  1756. return if !(@battlers[index].hasMega? rescue false)
  1757. return if (@battlers[index].isMega? rescue true)
  1758. ownername=pbGetOwner(index).fullname
  1759. ownername=pbGetOwner(index).name if pbBelongsToPlayer?(index)
  1760. case (@battlers[index].pokemon.megaMessage rescue 0)
  1761. when 1 # Rayquaza
  1762. pbDisplay(_INTL("¡El ruego vehemente de {1} alcanza a {2}!",ownername,@battlers[index].pbThis))
  1763. else
  1764. pbDisplay(_INTL("¡La {2} de {1} está reaccionando al {4} de {3}!",
  1765. @battlers[index].pbThis,PBItems.getName(@battlers[index].item),
  1766. ownername,pbGetMegaRingName(index)))
  1767. end
  1768. pbCommonAnimation("MegaEvolution",@battlers[index],nil)
  1769. @battlers[index].pokemon.makeMega
  1770. @battlers[index].form=@battlers[index].pokemon.form
  1771. @battlers[index].pbUpdate(true)
  1772. @scene.pbChangePokemon(@battlers[index],@battlers[index].pokemon)
  1773. pbCommonAnimation("MegaEvolution2",@battlers[index],nil)
  1774. meganame=(@battlers[index].pokemon.megaName rescue nil)
  1775. if !meganame || meganame==""
  1776. meganame=_INTL("Mega {1}",PBSpecies.getName(@battlers[index].pokemon.species))
  1777. end
  1778. pbDisplay(_INTL("¡{1} ha Mega Evolucionado en {2}!",@battlers[index].pbThis,meganame))
  1779. PBDebug.log("[Mega Evolución] #{@battlers[index].pbThis} ha Mega Evolucionado")
  1780. side=(pbIsOpposing?(index)) ? 1 : 0
  1781. owner=pbGetOwnerIndex(index)
  1782. @megaEvolution[side][owner]=-2
  1783. end
  1784.  
  1785. ################################################################################
  1786. # Primal Revert battler.
  1787. ################################################################################
  1788. def pbPrimalReversion(index)
  1789. return if !@battlers[index] || !@battlers[index].pokemon
  1790. return if !(@battlers[index].hasPrimal? rescue false)
  1791. return if (@battlers[index].isPrimal? rescue true)
  1792. if isConst?(@battlers[index].pokemon.species,PBSpecies,:KYOGRE)
  1793. pbCommonAnimation("PrimalKyogre",@battlers[index],nil)
  1794. elsif isConst?(@battlers[index].pokemon.species,PBSpecies,:GROUDON)
  1795. pbCommonAnimation("PrimalGroudon",@battlers[index],nil)
  1796. end
  1797. @battlers[index].pokemon.makePrimal
  1798. @battlers[index].form=@battlers[index].pokemon.form
  1799. @battlers[index].pbUpdate(true)
  1800. @scene.pbChangePokemon(@battlers[index],@battlers[index].pokemon)
  1801. if isConst?(@battlers[index].pokemon.species,PBSpecies,:KYOGRE)
  1802. pbCommonAnimation("PrimalKyogre2",@battlers[index],nil)
  1803. elsif isConst?(@battlers[index].pokemon.species,PBSpecies,:GROUDON)
  1804. pbCommonAnimation("PrimalGroudon2",@battlers[index],nil)
  1805. end
  1806. pbDisplay(_INTL("¡{1} ha esperimentado una Regresión Primigenia y ha recobrado su apariencia primitiva!",@battlers[index].pbThis))
  1807. PBDebug.log("[Regresión Primigenia] #{@battlers[index].pbThis} ha recobrado su apariencia primitiva")
  1808. end
  1809.  
  1810. ################################################################################
  1811. # Call battler.
  1812. ################################################################################
  1813. def pbCall(index)
  1814. owner=pbGetOwner(index)
  1815. pbDisplay(_INTL("¡{1} ha llamado a {2}!",owner.name,@battlers[index].name))
  1816. pbDisplay(_INTL("¡{1}!",@battlers[index].name))
  1817. PBDebug.log("[Llamado Pokémon] #{owner.name} ha llamado a #{@battlers[index].pbThis(true)}")
  1818. if @battlers[index].isShadow?
  1819. if @battlers[index].inHyperMode?
  1820. @battlers[index].pokemon.hypermode=false
  1821. @battlers[index].pokemon.adjustHeart(-300)
  1822. pbDisplay(_INTL("¡{1} recobró el sentido tras la llamada de su Entrenador!",@battlers[index].pbThis))
  1823. else
  1824. pbDisplay(_INTL("¡Pero no pasó nada!"))
  1825. end
  1826. elsif @battlers[index].status!=PBStatuses::SLEEP &&
  1827. @battlers[index].pbCanIncreaseStatStage?(PBStats::ACCURACY,@battlers[index])
  1828. @battlers[index].pbIncreaseStat(PBStats::ACCURACY,1,@battlers[index],true)
  1829. else
  1830. pbDisplay(_INTL("¡Pero no pasó nada!"))
  1831. end
  1832. end
  1833.  
  1834. ################################################################################
  1835. # Gaining Experience. / Ganando experiencia
  1836. ################################################################################
  1837. def pbGainEXP
  1838. return if !@internalbattle
  1839. successbegin=true
  1840. for i in 0...4 # Not ordered by priority
  1841. if !@doublebattle && pbIsDoubleBattler?(i)
  1842. @battlers[i].participants=[]
  1843. next
  1844. end
  1845. if pbIsOpposing?(i) && @battlers[i].participants.length>0 &&
  1846. (@battlers[i].isFainted? || @battlers[i].captured)
  1847. haveexpall=(hasConst?(PBItems,:EXPALL) && $PokemonBag.pbQuantity(:EXPALL)>0)
  1848. # First count the number of participants
  1849. partic=0
  1850. expshare=0
  1851. for j in @battlers[i].participants
  1852. next if !@party1[j] || !pbIsOwner?(0,j)
  1853. partic+=1 if @party1[j].hp>0 && !@party1[j].isEgg?
  1854. end
  1855. if !haveexpall
  1856. for j in 0...@party1.length
  1857. next if !@party1[j] || !pbIsOwner?(0,j)
  1858. expshare+=1 if @party1[j].hp>0 && !@party1[j].isEgg? &&
  1859. (isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
  1860. isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE))
  1861. end
  1862. end
  1863. # Now calculate EXP for the participants
  1864. if partic>0 || expshare>0 || haveexpall
  1865. if !@opponent && successbegin && pbAllFainted?(@party2)
  1866. @scene.pbWildBattleSuccess
  1867. successbegin=false
  1868. end
  1869. for j in 0...@party1.length
  1870. next if !@party1[j] || !pbIsOwner?(0,j)
  1871. next if @party1[j].hp<=0 || @party1[j].isEgg?
  1872. haveexpshare=(isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
  1873. isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE))
  1874. next if !haveexpshare && !@battlers[i].participants.include?(j)
  1875. pbGainExpOne(j,@battlers[i],partic,expshare,haveexpall)
  1876. end
  1877. if haveexpall
  1878. showmessage=true
  1879. for j in 0...@party1.length
  1880. next if !@party1[j] || !pbIsOwner?(0,j)
  1881. next if @party1[j].hp<=0 || @party1[j].isEgg?
  1882. next if isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
  1883. isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE)
  1884. next if @battlers[i].participants.include?(j)
  1885. pbDisplayPaused(_INTL("¡El resto del equipo también ha ganado Puntos de Experiencia gracias al {1}!",
  1886. PBItems.getName(getConst(PBItems,:EXPALL)))) if showmessage
  1887. showmessage=false
  1888. pbGainExpOne(j,@battlers[i],partic,expshare,haveexpall,false)
  1889. end
  1890. end
  1891. end
  1892. # Now clear the participants array
  1893.  
  1894. #Experiencia para Pokemon del pc
  1895. #Autor: Kyu. Recurso de https://newpokeliberty.blogspot.com/
  1896. for x in 0...$PokemonStorage.maxBoxes
  1897. for y in 0...$PokemonStorage.maxPokemon(x)
  1898. next if $PokemonStorage[x,y]==nil
  1899. next if $PokemonStorage[x,y].isEgg?
  1900. maxexp=PBExperience.pbGetMaxExperience($PokemonStorage[x,y].growthrate)
  1901. if $PokemonStorage[x,y].exp<maxexp
  1902. oldlevel=$PokemonStorage[x,y].level
  1903. baseexp=@battlers[i].pokemon.baseExp
  1904. exp=(@battlers[i].level*baseexp).floor
  1905. leveladjust=(2*@battlers[i].level+10.0)/(@battlers[i].level+$PokemonStorage[x,y].level+10.0)
  1906. leveladjust=leveladjust**5
  1907. leveladjust=Math.sqrt(leveladjust)
  1908. exp=(exp*leveladjust).floor
  1909. $PokemonStorage[x,y].exp+=exp*0.15 #cambiar número para modificar
  1910. if $PokemonStorage[x,y].level!=oldlevel
  1911. $PokemonStorage[x,y].calcStats
  1912. movelist= $PokemonStorage[x,y].getMoveList
  1913. for z in movelist
  1914. $PokemonStorage[x,y].pbLearnMove(z[1]) if z[0]==$PokemonStorage[x,y].level # Learned a new move
  1915. end
  1916. end
  1917. end
  1918. end
  1919. end
  1920.  
  1921. @battlers[i].participants=[]
  1922.  
  1923. end
  1924. end
  1925. end
  1926.  
  1927. def pbGainExpOne(index,defeated,partic,expshare,haveexpall,showmessages=true)
  1928. thispoke=@party1[index]
  1929. # Original species, not current species
  1930. level=defeated.level
  1931. baseexp=defeated.pokemon.baseExp
  1932. evyield=defeated.pokemon.evYield
  1933. # Gain effort value points, using RS effort values
  1934. totalev=0
  1935. for k in 0...6
  1936. totalev+=thispoke.ev[k]
  1937. end
  1938. for k in 0...6
  1939. evgain=evyield[k]
  1940. evgain*=2 if isConst?(thispoke.item,PBItems,:MACHOBRACE) ||
  1941. isConst?(thispoke.itemInitial,PBItems,:MACHOBRACE)
  1942. case k
  1943. when PBStats::HP
  1944. evgain+=4 if isConst?(thispoke.item,PBItems,:POWERWEIGHT) ||
  1945. isConst?(thispoke.itemInitial,PBItems,:POWERWEIGHT)
  1946. when PBStats::ATTACK
  1947. evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBRACER) ||
  1948. isConst?(thispoke.itemInitial,PBItems,:POWERBRACER)
  1949. when PBStats::DEFENSE
  1950. evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBELT) ||
  1951. isConst?(thispoke.itemInitial,PBItems,:POWERBELT)
  1952. when PBStats::SPATK
  1953. evgain+=4 if isConst?(thispoke.item,PBItems,:POWERLENS) ||
  1954. isConst?(thispoke.itemInitial,PBItems,:POWERLENS)
  1955. when PBStats::SPDEF
  1956. evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBAND) ||
  1957. isConst?(thispoke.itemInitial,PBItems,:POWERBAND)
  1958. when PBStats::SPEED
  1959. evgain+=4 if isConst?(thispoke.item,PBItems,:POWERANKLET) ||
  1960. isConst?(thispoke.itemInitial,PBItems,:POWERANKLET)
  1961. end
  1962. evgain*=2 if thispoke.pokerusStage>=1 # Infected or cured
  1963. if evgain>0
  1964. # Can't exceed overall limit
  1965. evgain-=totalev+evgain-PokeBattle_Pokemon::EVLIMIT if totalev+evgain>PokeBattle_Pokemon::EVLIMIT
  1966. # Can't exceed stat limit
  1967. evgain-=thispoke.ev[k]+evgain-PokeBattle_Pokemon::EVSTATLIMIT if thispoke.ev[k]+evgain>PokeBattle_Pokemon::EVSTATLIMIT
  1968. # Add EV gain
  1969. thispoke.ev[k]+=evgain
  1970. if thispoke.ev[k]>PokeBattle_Pokemon::EVSTATLIMIT
  1971. print "Single-stat EV limit #{PokeBattle_Pokemon::EVSTATLIMIT} exceeded.\r\nStat: #{k} EV gain: #{evgain} EVs: #{thispoke.ev.inspect}"
  1972. thispoke.ev[k]=PokeBattle_Pokemon::EVSTATLIMIT
  1973. end
  1974. totalev+=evgain
  1975. if totalev>PokeBattle_Pokemon::EVLIMIT
  1976. print "EV limit #{PokeBattle_Pokemon::EVLIMIT} exceeded.\r\nTotal EVs: #{totalev} EV gain: #{evgain} EVs: #{thispoke.ev.inspect}"
  1977. end
  1978. end
  1979. end
  1980. # Gain experience
  1981. ispartic=0
  1982. ispartic=1 if defeated.participants.include?(index)
  1983. haveexpshare=(isConst?(thispoke.item,PBItems,:EXPSHARE) ||
  1984. isConst?(thispoke.itemInitial,PBItems,:EXPSHARE)) ? 1 : 0
  1985. exp=0
  1986. if expshare>0
  1987. if partic==0 # No participants, all Exp goes to Exp Share holders
  1988. exp=(level*baseexp).floor
  1989. exp=(exp/(NOSPLITEXP ? 1 : expshare)).floor*haveexpshare
  1990. else
  1991. if NOSPLITEXP
  1992. exp=(level*baseexp).floor*ispartic
  1993. exp=(level*baseexp/2).floor*haveexpshare if ispartic==0
  1994. else
  1995. exp=(level*baseexp/2).floor
  1996. exp=(exp/partic).floor*ispartic + (exp/expshare).floor*haveexpshare
  1997. end
  1998. end
  1999. elsif ispartic==1
  2000. exp=(level*baseexp/(NOSPLITEXP ? 1 : partic)).floor
  2001. elsif haveexpall
  2002. exp=(level*baseexp/2).floor
  2003. end
  2004. return if exp<=0
  2005. exp=(exp*3/2).floor if @opponent
  2006. if USESCALEDEXPFORMULA
  2007. exp=(exp/5).floor
  2008. leveladjust=(2*level+10.0)/(level+thispoke.level+10.0)
  2009. leveladjust=leveladjust**5
  2010. leveladjust=Math.sqrt(leveladjust)
  2011. exp=(exp*leveladjust).floor
  2012. exp+=1 if ispartic>0 || haveexpshare>0
  2013. else
  2014. exp=(exp/7).floor
  2015. end
  2016. isOutsider=(thispoke.trainerID!=self.pbPlayer.id ||
  2017. (thispoke.language!=0 && thispoke.language!=self.pbPlayer.language))
  2018. if isOutsider
  2019. if thispoke.language!=0 && thispoke.language!=self.pbPlayer.language
  2020. exp=(exp*1.7).floor
  2021. else
  2022. exp=(exp*3/2).floor
  2023. end
  2024. end
  2025. exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG) ||
  2026. isConst?(thispoke.itemInitial,PBItems,:LUCKYEGG)
  2027. growthrate=thispoke.growthrate
  2028. newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
  2029. exp=newexp-thispoke.exp
  2030. if exp>0
  2031. if showmessages
  2032. if isOutsider
  2033. pbDisplayPaused(_INTL("¡{1} ha ganado un total de {2} Puntos de Experiencia!",thispoke.name,exp))
  2034. else
  2035. pbDisplayPaused(_INTL("¡{1} ha ganado {2} Puntos de Experiencia!",thispoke.name,exp))
  2036. end
  2037. end
  2038. newlevel=PBExperience.pbGetLevelFromExperience(newexp,growthrate)
  2039. tempexp=0
  2040. curlevel=thispoke.level
  2041. if newlevel<curlevel
  2042. debuginfo="#{thispoke.name}: #{thispoke.level}/#{newlevel} | #{thispoke.exp}/#{newexp} | gain: #{exp}"
  2043. raise RuntimeError.new(_INTL("El nivel nuevo ({1}) es menor que el nivel actual\r\ndel Pokémon ({2}), lo que no debería pasar.\r\n[Depurar: {3}]",
  2044. newlevel,curlevel,debuginfo))
  2045. return
  2046. end
  2047. if thispoke.respond_to?("isShadow?") && thispoke.isShadow?
  2048. thispoke.exp+=exp
  2049. else
  2050. tempexp1=thispoke.exp
  2051. tempexp2=0
  2052. # Find battler
  2053. battler=pbFindPlayerBattler(index)
  2054. loop do
  2055. # EXP Bar animation
  2056. startexp=PBExperience.pbGetStartExperience(curlevel,growthrate)
  2057. endexp=PBExperience.pbGetStartExperience(curlevel+1,growthrate)
  2058. tempexp2=(endexp<newexp) ? endexp : newexp
  2059. thispoke.exp=tempexp2
  2060. @scene.pbEXPBar(thispoke,battler,startexp,endexp,tempexp1,tempexp2)
  2061. tempexp1=tempexp2
  2062. curlevel+=1
  2063. if curlevel>newlevel
  2064. thispoke.calcStats
  2065. battler.pbUpdate(false) if battler
  2066. @scene.pbRefresh
  2067. break
  2068. end
  2069. oldtotalhp=thispoke.totalhp
  2070. oldattack=thispoke.attack
  2071. olddefense=thispoke.defense
  2072. oldspeed=thispoke.speed
  2073. oldspatk=thispoke.spatk
  2074. oldspdef=thispoke.spdef
  2075. if battler && battler.pokemon && @internalbattle
  2076. battler.pokemon.changeHappiness("level up")
  2077. end
  2078. thispoke.calcStats
  2079. battler.pbUpdate(false) if battler
  2080. @scene.pbRefresh
  2081. pbDisplayPaused(_INTL("¡{1} subió al nivel {2}!",thispoke.name,curlevel))
  2082. @scene.pbLevelUp(thispoke,battler,oldtotalhp,oldattack,
  2083. olddefense,oldspeed,oldspatk,oldspdef)
  2084. # Determina todos los movimientos aprendidos a este nivel
  2085. movelist=thispoke.getMoveList
  2086. for k in movelist
  2087. if k[0]==thispoke.level # Aprendió un movimiento nuevo
  2088. pbLearnMove(index,k[1])
  2089. end
  2090. end
  2091. end
  2092. end
  2093. end
  2094. end
  2095.  
  2096. ################################################################################
  2097. # Learning a move. / Aprendiendo un movimiento
  2098. ################################################################################
  2099. def pbLearnMove(pkmnIndex,move)
  2100. pokemon=@party1[pkmnIndex]
  2101. return if !pokemon
  2102. pkmnname=pokemon.name
  2103. battler=pbFindPlayerBattler(pkmnIndex)
  2104. movename=PBMoves.getName(move)
  2105. for i in 0...4
  2106. return if pokemon.moves[i].id==move
  2107. if pokemon.moves[i].id==0
  2108. pokemon.moves[i]=PBMove.new(move)
  2109. battler.moves[i]=PokeBattle_Move.pbFromPBMove(self,pokemon.moves[i]) if battler
  2110. pbDisplayPaused(_INTL("¡{1} ha aprendido {2}!",pkmnname,movename))
  2111. PBDebug.log("[Movimiento aprendido] #{pkmnname} ha aprendido #{movename}")
  2112. return
  2113. end
  2114. end
  2115. loop do
  2116. pbDisplayPaused(_INTL("{1} quiere aprender el movimiento {2}.",pkmnname,movename))
  2117. pbDisplayPaused(_INTL("Pero {1} ya conoce cuatro movimientos.",pkmnname))
  2118. if pbDisplayConfirm(_INTL("¿Quieres sustituir uno de esos movimientos por {1}?",movename))
  2119. pbDisplayPaused(_INTL("¿Qué movimiento quieres que olvide?"))
  2120. forgetmove=@scene.pbForgetMove(pokemon,move)
  2121. if forgetmove>=0
  2122. oldmovename=PBMoves.getName(pokemon.moves[forgetmove].id)
  2123. pokemon.moves[forgetmove]=PBMove.new(move) # Remplaza PP actuales/totales
  2124. battler.moves[forgetmove]=PokeBattle_Move.pbFromPBMove(self,pokemon.moves[forgetmove]) if battler
  2125. pbDisplayPaused(_INTL("1, 2 y..."))
  2126. pbDisplayPaused(_INTL("¡Puf!"))
  2127. pbDisplayPaused(_INTL("¡{1} ha olvidado cómo utilizar {2}!",pkmnname,oldmovename))
  2128. pbDisplayPaused(_INTL("Y..."))
  2129. pbDisplayPaused(_INTL("¡{1} ha aprendido {2}!",pkmnname,movename))
  2130. PBDebug.log("[Movimiento aprendido] #{pkmnname} ha olvidado #{oldmovename} y ha aprendido #{movename}")
  2131. return
  2132. elsif pbDisplayConfirm(_INTL("¿Prefieres que {1} no aprenda {2}?",pkmnname,movename))
  2133. pbDisplayPaused(_INTL("{1} no ha aprendido {2}.",pkmnname,movename))
  2134. return
  2135. end
  2136. elsif pbDisplayConfirm(_INTL("¿Prefieres que {1} no aprenda {2}?",pkmnname,movename))
  2137. pbDisplayPaused(_INTL("{1} no ha aprendido {2}.",pkmnname,movename))
  2138. return
  2139. end
  2140. end
  2141. end
  2142.  
  2143. ################################################################################
  2144. # Abilities. / Habilidades
  2145. ################################################################################
  2146. def pbOnActiveAll
  2147. for i in 0...4 # Currently unfainted participants will earn EXP even if they faint afterwards
  2148. @battlers[i].pbUpdateParticipants if pbIsOpposing?(i)
  2149. @amuletcoin=true if !pbIsOpposing?(i) &&
  2150. (isConst?(@battlers[i].item,PBItems,:AMULETCOIN) ||
  2151. isConst?(@battlers[i].item,PBItems,:LUCKINCENSE))
  2152. end
  2153. for i in 0...4
  2154. if !@battlers[i].isFainted?
  2155. if @battlers[i].isShadow? && pbIsOpposing?(i)
  2156. pbCommonAnimation("Shadow",@battlers[i],nil)
  2157. pbDisplay(_INTL("¡Alto!\n¡Un Pokémon Oscuro!"))
  2158. end
  2159. end
  2160. end
  2161. # Weather-inducing abilities, Trace, Imposter, etc.
  2162. @usepriority=false
  2163. priority=pbPriority
  2164. for i in priority
  2165. i.pbAbilitiesOnSwitchIn(true)
  2166. end
  2167. # Check forms are correct
  2168. for i in 0...4
  2169. next if @battlers[i].isFainted?
  2170. @battlers[i].pbCheckForm
  2171. end
  2172. end
  2173.  
  2174. def pbOnActiveOne(pkmn,onlyabilities=false,moldbreaker=false)
  2175. return false if pkmn.isFainted?
  2176. if !onlyabilities
  2177. for i in 0...4 # Los participantes actualmente no debilitados ganarán EXP incluso si estuvieron debilitados en el medio
  2178. @battlers[i].pbUpdateParticipants if pbIsOpposing?(i)
  2179. @amuletcoin=true if !pbIsOpposing?(i) &&
  2180. (isConst?(@battlers[i].item,PBItems,:AMULETCOIN) ||
  2181. isConst?(@battlers[i].item,PBItems,:LUCKINCENSE))
  2182. end
  2183. if pkmn.isShadow? && pbIsOpposing?(pkmn.index)
  2184. pbCommonAnimation("Shadow",pkmn,nil)
  2185. pbDisplay(_INTL("¡Alto!\n¡Un Pokémon Oscuro!"))
  2186. end
  2187. # Deseo Cura
  2188. if pkmn.effects[PBEffects::HealingWish]
  2189. PBDebug.log("[Efecto prolongado disparado] Deseo Cura de #{pkmn.pbThis}")
  2190. pbCommonAnimation("HealingWish",pkmn,nil)
  2191. pbDisplayPaused(_INTL("¡El deseo de {1} se hizo realidad!",pkmn.pbThis(true)))
  2192. pkmn.pbRecoverHP(pkmn.totalhp,true)
  2193. pkmn.pbCureStatus(false)
  2194. pkmn.effects[PBEffects::HealingWish]=false
  2195. end
  2196. # Danza Lunar
  2197. if pkmn.effects[PBEffects::LunarDance]
  2198. PBDebug.log("[Efecto prolongado disparado] Danza Lunar de #{pkmn.pbThis}")
  2199. pbCommonAnimation("LunarDance",pkmn,nil)
  2200. pbDisplayPaused(_INTL("¡{1} se rodeó de una luz lunar misteriosa!",pkmn.pbThis))
  2201. pkmn.pbRecoverHP(pkmn.totalhp,true)
  2202. pkmn.pbCureStatus(false)
  2203. for i in 0...4
  2204. pkmn.moves[i].pp=pkmn.moves[i].totalpp
  2205. end
  2206. pkmn.effects[PBEffects::LunarDance]=false
  2207. end
  2208. # Púas
  2209. if pkmn.pbOwnSide.effects[PBEffects::Spikes]>0 && !pkmn.isAirborne?(moldbreaker)
  2210. if !pkmn.hasWorkingAbility(:MAGICGUARD)
  2211. PBDebug.log("[Peligro de entrada] #{pkmn.pbThis} activó las Púas")
  2212. spikesdiv=[8,6,4][pkmn.pbOwnSide.effects[PBEffects::Spikes]-1]
  2213. @scene.pbDamageAnimation(pkmn,0)
  2214. pkmn.pbReduceHP((pkmn.totalhp/spikesdiv).floor)
  2215. pbDisplayPaused(_INTL("¡{1} ha sido herido por las púas!",pkmn.pbThis))
  2216. end
  2217. end
  2218. pkmn.pbFaint if pkmn.isFainted?
  2219. # Trampa Rocas
  2220. if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.isFainted?
  2221. if !pkmn.hasWorkingAbility(:MAGICGUARD)
  2222. atype=getConst(PBTypes,:ROCK) || 0
  2223. eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
  2224. if eff>0
  2225. PBDebug.log("[Peligro de entrada] #{pkmn.pbThis} activó la Trampa Rocas")
  2226. @scene.pbDamageAnimation(pkmn,0)
  2227. pkmn.pbReduceHP(((pkmn.totalhp*eff)/64).floor)
  2228. pbDisplayPaused(_INTL("¡{1} fue herido por las piedras puntiagudas!",pkmn.pbThis))
  2229. end
  2230. end
  2231. end
  2232. pkmn.pbFaint if pkmn.isFainted?
  2233. # Púas Tóxicas
  2234. if pkmn.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 && !pkmn.isFainted?
  2235. if !pkmn.isAirborne?(moldbreaker)
  2236. if pkmn.pbHasType?(:POISON)
  2237. PBDebug.log("[Peligro de entrada] #{pkmn.pbThis} absorbió las Púas Tóxicas")
  2238. pkmn.pbOwnSide.effects[PBEffects::ToxicSpikes]=0
  2239. pbDisplayPaused(_INTL("¡Las Púas Tóxicas lanzadas alrededor de {1} desaparecieron!",pkmn.pbThis))
  2240. elsif pkmn.pbCanPoisonSpikes?(moldbreaker)
  2241. PBDebug.log("[Peligro de entrada] #{pkmn.pbThis} activó las Púas Tóxicas")
  2242. if pkmn.pbOwnSide.effects[PBEffects::ToxicSpikes]==2
  2243. pkmn.pbPoison(nil,_INTL("¡{1} ha sido gravemente envenenado por las Púas Tóxicas!",pkmn.pbThis,true))
  2244. else
  2245. pkmn.pbPoison(nil,_INTL("¡{1} ha sido envenenado por las Púas Tóxicas!",pkmn.pbThis))
  2246. end
  2247. end
  2248. end
  2249. end
  2250. # Red Viscosa
  2251. if pkmn.pbOwnSide.effects[PBEffects::StickyWeb] && !pkmn.isFainted? &&
  2252. !pkmn.isAirborne?(moldbreaker)
  2253. if pkmn.pbCanReduceStatStage?(PBStats::SPEED,nil,false,nil,moldbreaker)
  2254. PBDebug.log("[Peligro de entrada] #{pkmn.pbThis} activó la Red Viscosa")
  2255. pbDisplayPaused(_INTL("¡{1} ha sido atrapado en la Red Viscosa!",pkmn.pbThis))
  2256. pkmn.pbReduceStat(PBStats::SPEED,1,nil,false,nil,true,moldbreaker)
  2257. end
  2258. end
  2259. end
  2260. pkmn.pbAbilityCureCheck
  2261. if pkmn.isFainted?
  2262. pbGainEXP
  2263. pbJudge # pbSwitch
  2264. return false
  2265. end
  2266. # pkmn.pbAbilitiesOnSwitchIn(true)
  2267. if !onlyabilities
  2268. pkmn.pbCheckForm
  2269. pkmn.pbBerryCureCheck
  2270. end
  2271. return true
  2272. end
  2273.  
  2274. def pbPrimordialWeather
  2275. # End Primordial Sea, Desolate Land, Delta Stream
  2276. hasabil=false
  2277. case @weather
  2278. when PBWeather::HEAVYRAIN
  2279. for i in 0...4
  2280. if isConst?(@battlers[i].ability,PBAbilities,:PRIMORDIALSEA) &&
  2281. !@battlers[i].isFainted?
  2282. hasabil=true; break
  2283. end
  2284. if !hasabil
  2285. @weather=0
  2286. pbDisplayBrief("¡El diluvio ha terminado!")
  2287. end
  2288. end
  2289. when PBWeather::HARSHSUN
  2290. for i in 0...4
  2291. if isConst?(@battlers[i].ability,PBAbilities,:DESOLATELAND) &&
  2292. !@battlers[i].isFainted?
  2293. hasabil=true; break
  2294. end
  2295. if !hasabil
  2296. @weather=0
  2297. pbDisplayBrief("¡El sol vuelve a brillar como siempre!")
  2298. end
  2299. end
  2300. when PBWeather::STRONGWINDS
  2301. for i in 0...4
  2302. if isConst?(@battlers[i].ability,PBAbilities,:DELTASTREAM) &&
  2303. !@battlers[i].isFainted?
  2304. hasabil=true; break
  2305. end
  2306. if !hasabil
  2307. @weather=0
  2308. pbDisplayBrief("¡Las misteriosas turbulencias han amainado!")
  2309. end
  2310. end
  2311. end
  2312. end
  2313.  
  2314. ################################################################################
  2315. # Judging.
  2316. ################################################################################
  2317. def pbJudgeCheckpoint(attacker,move=0)
  2318. end
  2319.  
  2320. def pbDecisionOnTime
  2321. count1=0
  2322. count2=0
  2323. hptotal1=0
  2324. hptotal2=0
  2325. for i in @party1
  2326. next if !i
  2327. if i.hp>0 && !i.isEgg?
  2328. count1+=1
  2329. hptotal1+=i.hp
  2330. end
  2331. end
  2332. for i in @party2
  2333. next if !i
  2334. if i.hp>0 && !i.isEgg?
  2335. count2+=1
  2336. hptotal2+=i.hp
  2337. end
  2338. end
  2339. return 1 if count1>count2 # win
  2340. return 2 if count1<count2 # loss
  2341. return 1 if hptotal1>hptotal2 # win
  2342. return 2 if hptotal1<hptotal2 # loss
  2343. return 5 # draw
  2344. end
  2345.  
  2346. def pbDecisionOnTime2
  2347. count1=0
  2348. count2=0
  2349. hptotal1=0
  2350. hptotal2=0
  2351. for i in @party1
  2352. next if !i
  2353. if i.hp>0 && !i.isEgg?
  2354. count1+=1
  2355. hptotal1+=(i.hp*100/i.totalhp)
  2356. end
  2357. end
  2358. hptotal1/=count1 if count1>0
  2359. for i in @party2
  2360. next if !i
  2361. if i.hp>0 && !i.isEgg?
  2362. count2+=1
  2363. hptotal2+=(i.hp*100/i.totalhp)
  2364. end
  2365. end
  2366. hptotal2/=count2 if count2>0
  2367. return 1 if count1>count2 # win
  2368. return 2 if count1<count2 # loss
  2369. return 1 if hptotal1>hptotal2 # win
  2370. return 2 if hptotal1<hptotal2 # loss
  2371. return 5 # draw
  2372. end
  2373.  
  2374. def pbDecisionOnDraw
  2375. return 5 # draw
  2376. end
  2377.  
  2378. def pbJudge
  2379. # PBDebug.log("[Counts: #{pbPokemonCount(@party1)}/#{pbPokemonCount(@party2)}]")
  2380. if pbAllFainted?(@party1) && pbAllFainted?(@party2)
  2381. @decision=pbDecisionOnDraw() # Draw
  2382. return
  2383. end
  2384. if pbAllFainted?(@party1)
  2385. @decision=2 # Loss
  2386. return
  2387. end
  2388. if pbAllFainted?(@party2)
  2389. @decision=1 # Win
  2390. return
  2391. end
  2392. end
  2393.  
  2394. ################################################################################
  2395. # Messages and animations.
  2396. ################################################################################
  2397. def pbDisplay(msg)
  2398. @scene.pbDisplayMessage(msg)
  2399. end
  2400.  
  2401. def pbDisplayPaused(msg)
  2402. @scene.pbDisplayPausedMessage(msg)
  2403. end
  2404.  
  2405. def pbDisplayBrief(msg)
  2406. @scene.pbDisplayMessage(msg,true)
  2407. end
  2408.  
  2409. def pbDisplayConfirm(msg)
  2410. @scene.pbDisplayConfirmMessage(msg)
  2411. end
  2412.  
  2413. def pbShowCommands(msg,commands,cancancel=true)
  2414. @scene.pbShowCommands(msg,commands,cancancel)
  2415. end
  2416.  
  2417. def pbAnimation(move,attacker,opponent,hitnum=0)
  2418. if @battlescene
  2419. @scene.pbAnimation(move,attacker,opponent,hitnum)
  2420. end
  2421. end
  2422.  
  2423. def pbCommonAnimation(name,attacker,opponent,hitnum=0)
  2424. if @battlescene
  2425. @scene.pbCommonAnimation(name,attacker,opponent,hitnum)
  2426. end
  2427. end
  2428.  
  2429. ################################################################################
  2430. # Núcleo del combate.
  2431. ################################################################################
  2432. def pbStartBattle(canlose=false)
  2433. Graphics.frame_rate = 80
  2434. PBDebug.log("")
  2435. PBDebug.log("******************************************")
  2436. begin
  2437. pbStartBattleCore(canlose)
  2438. rescue BattleAbortedException
  2439. @decision=0
  2440. @scene.pbEndBattle(@decision)
  2441. end
  2442. Graphics.frame_rate = 40
  2443. return @decision
  2444. end
  2445.  
  2446. def pbStartBattleCore(canlose)
  2447. if !@fullparty1 && @party1.length>MAXPARTYSIZE
  2448. raise ArgumentError.new(_INTL("Equipo 1 tiene más de {1} Pokémon.",MAXPARTYSIZE))
  2449. end
  2450. if !@fullparty2 && @party2.length>MAXPARTYSIZE
  2451. raise ArgumentError.new(_INTL("Equipo 2 tiene más de {1} Pokémon.",MAXPARTYSIZE))
  2452. end
  2453. #==================================================================
  2454. # Initialize wild Pokémon / Inicializa Pokémon salvaje
  2455. #==================================================================
  2456. if !@opponent
  2457. if @party2.length==1
  2458. if @doublebattle && !$game_switches[Boss]
  2459. raise _INTL("Sólo se permiten dos Pokémon salvajes en una batalla doble")
  2460. end
  2461. wildpoke=@party2[0]
  2462. @battlers[1].pbInitialize(wildpoke,0,false)
  2463. @peer.pbOnEnteringBattle(self,wildpoke)
  2464. pbSetSeen(wildpoke)
  2465. @scene.pbStartBattle(self)
  2466. pbDisplayPaused(_INTL("¡Un {1} salvaje te corta el paso!",wildpoke.name))
  2467. elsif @party2.length==2
  2468. if !@doublebattle
  2469. raise _INTL("Sólo se permite un Pokémon salvaje en batallas individuales")
  2470. end
  2471. @battlers[1].pbInitialize(@party2[0],0,false)
  2472. @battlers[3].pbInitialize(@party2[1],0,false)
  2473. @peer.pbOnEnteringBattle(self,@party2[0])
  2474. @peer.pbOnEnteringBattle(self,@party2[1])
  2475. pbSetSeen(@party2[0])
  2476. pbSetSeen(@party2[1])
  2477. @scene.pbStartBattle(self)
  2478. pbDisplayPaused(_INTL("¡Aparecieron {1} y\r\n{2} salvajes!",
  2479. @party2[0].name,@party2[1].name))
  2480. else
  2481. raise _INTL("Sólo se permite uno o dos Pokémon salvajes en batallas dobles")
  2482. end
  2483. #=====================================================================================
  2484. # Initialize opponents in double battles / Inicializa oponentes en batallas dobles
  2485. #=====================================================================================
  2486. elsif @doublebattle
  2487. if @opponent.is_a?(Array)
  2488. if @opponent.length==1
  2489. @opponent=@opponent[0]
  2490. elsif @opponent.length!=2
  2491. raise _INTL("Rivales con cero o más de dos personas no están permitidos")
  2492. end
  2493. end
  2494. if @player.is_a?(Array)
  2495. if @player.length==1
  2496. @player=@player[0]
  2497. elsif @player.length!=2
  2498. raise _INTL("Entrenadores jugadores con cero o más de dos personas no están permitidos")
  2499. end
  2500. end
  2501. @scene.pbStartBattle(self)
  2502. if @opponent.is_a?(Array)
  2503. pbDisplayPaused(_INTL("¡{1} y {2}\r\nte desafían!",@opponent[0].fullname,@opponent[1].fullname))
  2504. sendout1=pbFindNextUnfainted(@party2,0,pbSecondPartyBegin(1))
  2505. raise _INTL("El oponente 1 no tiene ningún Pokémon saludable") if sendout1<0
  2506. sendout2=pbFindNextUnfainted(@party2,pbSecondPartyBegin(1))
  2507. raise _INTL("El oponente 2 no tiene ningún Pokémon saludable") if sendout2<0
  2508. @battlers[1].pbInitialize(@party2[sendout1],sendout1,false)
  2509. pbDisplayBrief(_INTL("¡{1} envió\r\na {2}!",@opponent[0].fullname,@battlers[1].name))
  2510. pbSendOut(1,@party2[sendout1])
  2511. @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
  2512. pbDisplayBrief(_INTL("¡{1} envió\r\na {2}!",@opponent[1].fullname,@battlers[3].name))
  2513. pbSendOut(3,@party2[sendout2])
  2514. else
  2515. pbDisplayPaused(_INTL("¡{1}\r\nte desafía!",@opponent.fullname))
  2516. sendout1=pbFindNextUnfainted(@party2,0)
  2517. sendout2=pbFindNextUnfainted(@party2,sendout1+1)
  2518. if sendout1<0 || sendout2<0
  2519. raise _INTL("El oponente no tiene dos Pokémon saludables")
  2520. end
  2521. @battlers[1].pbInitialize(@party2[sendout1],sendout1,false)
  2522. @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
  2523. pbDisplayBrief(_INTL("¡{1} envió\r\na {2} y {3}!",
  2524. @opponent.fullname,@battlers[1].name,@battlers[3].name))
  2525. pbSendOut(1,@party2[sendout1])
  2526. pbSendOut(3,@party2[sendout2])
  2527. end
  2528. #================================================================================
  2529. # Initialize opponent in single battles / Inicializa oponente en batallas simples
  2530. #================================================================================
  2531. else
  2532. sendout=pbFindNextUnfainted(@party2,0)
  2533. raise _INTL("El Entrenador no tiene ningún Pokémon saludable") if sendout<0
  2534. if @opponent.is_a?(Array)
  2535. raise _INTL("El oponente debe tener un sólo participante en batallas individuales") if @opponent.length!=1
  2536. @opponent=@opponent[0]
  2537. end
  2538. if @player.is_a?(Array)
  2539. raise _INTL("El jugador debe tener un sólo participante en batallas individuales") if @player.length!=1
  2540. @player=@player[0]
  2541. end
  2542. trainerpoke=@party2[sendout]
  2543. @scene.pbStartBattle(self)
  2544. pbDisplayPaused(_INTL("¡{1}\r\nte desafía!",@opponent.fullname))
  2545. @battlers[1].pbInitialize(trainerpoke,sendout,false)
  2546. pbDisplayBrief(_INTL("¡{1} envió\r\na {2}!",@opponent.fullname,@battlers[1].name))
  2547. pbSendOut(1,trainerpoke)
  2548. end
  2549. #===================================================================================
  2550. # Initialize players in double battles / Inicializa jugadores en batallas dobles
  2551. #===================================================================================
  2552. if @doublebattle
  2553. if @player.is_a?(Array)
  2554. sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0))
  2555. raise _INTL("El jugador 1 no tiene ningún Pokémon saludable") if sendout1<0
  2556. sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0))
  2557. raise _INTL("El jugador 2 no tiene ningún Pokémon saludable") if sendout2<0
  2558. @battlers[0].pbInitialize(@party1[sendout1],sendout1,false)
  2559. @battlers[2].pbInitialize(@party1[sendout2],sendout2,false)
  2560. pbDisplayBrief(_INTL("¡{1} envió\r\na {2}! ¡Adelante, {3}!",
  2561. @player[1].fullname,@battlers[2].name,@battlers[0].name))
  2562. pbSetSeen(@party1[sendout1])
  2563. pbSetSeen(@party1[sendout2])
  2564. else
  2565. sendout1=pbFindNextUnfainted(@party1,0)
  2566. sendout2=pbFindNextUnfainted(@party1,sendout1+1)
  2567. if sendout1<0 || sendout2<0
  2568. raise _INTL("El jugador no tiene dos Pokémon saludables")
  2569. end
  2570. @battlers[0].pbInitialize(@party1[sendout1],sendout1,false)
  2571. @battlers[2].pbInitialize(@party1[sendout2],sendout2,false)
  2572. pbDisplayBrief(_INTL("¡Adelante, {1} y {2}!",@battlers[0].name,@battlers[2].name))
  2573. end
  2574. pbSendOut(0,@party1[sendout1])
  2575. pbSendOut(2,@party1[sendout2])
  2576. #====================================
  2577. # Initialize player in single battles
  2578. #====================================
  2579. else
  2580. sendout=pbFindNextUnfainted(@party1,0)
  2581. if sendout<0
  2582. raise _INTL("El jugador no tiene ningún Pokémon saludable")
  2583. end
  2584. @battlers[0].pbInitialize(@party1[sendout],sendout,false)
  2585. pbDisplayBrief(_INTL("¡Adelante {1}!",@battlers[0].name))
  2586. pbSendOut(0,@party1[sendout])
  2587. end
  2588. #==================
  2589. # Initialize battle
  2590. #==================
  2591. if @weather==PBWeather::SUNNYDAY
  2592. pbCommonAnimation("Sunny",nil,nil)
  2593. pbDisplay(_INTL("Hace mucho sol..."))
  2594. elsif @weather==PBWeather::RAINDANCE
  2595. pbCommonAnimation("Rain",nil,nil)
  2596. pbDisplay(_INTL("Sigue lloviendo..."))
  2597. elsif @weather==PBWeather::SANDSTORM
  2598. pbCommonAnimation("Sandstorm",nil,nil)
  2599. pbDisplay(_INTL("La tormenta de arena arrecia..."))
  2600. elsif @weather==PBWeather::HAIL
  2601. pbCommonAnimation("Hail",nil,nil)
  2602. pbDisplay(_INTL("Sigue granizando..."))
  2603. elsif @weather==PBWeather::HEAVYRAIN
  2604. pbCommonAnimation("HeavyRain",nil,nil)
  2605. pbDisplay(_INTL("Sigue diluviando..."))
  2606. elsif @weather==PBWeather::HARSHSUN
  2607. pbCommonAnimation("HarshSun",nil,nil)
  2608. pbDisplay(_INTL("El sol sigue realmente abrasador..."))
  2609. elsif @weather==PBWeather::STRONGWINDS
  2610. pbCommonAnimation("StrongWinds",nil,nil)
  2611. pbDisplay(_INTL("Las misteriosas turbulencias continúan con fuerza..."))
  2612. end
  2613. pbOnActiveAll # Habilidades
  2614. @turncount=0
  2615. loop do # Now begin the battle loop
  2616. PBDebug.log("")
  2617. PBDebug.log("***Round #{@turncount+1}***")
  2618. if @debug && @turncount>=100
  2619. @decision=pbDecisionOnTime()
  2620. PBDebug.log("")
  2621. PBDebug.log("***Undecided after 100 rounds, aborting***")
  2622. pbAbort
  2623. break
  2624. end
  2625. PBDebug.logonerr{
  2626. pbCommandPhase
  2627. }
  2628. break if @decision>0
  2629. PBDebug.logonerr{
  2630. pbAttackPhase
  2631. }
  2632. break if @decision>0
  2633. PBDebug.logonerr{
  2634. pbEndOfRoundPhase
  2635. }
  2636. break if @decision>0
  2637. @turncount+=1
  2638. if turncount==1 && $game_switches[90]
  2639. $game_switches[91]==true
  2640. s=Sprite.new; s.bitmap = Bitmap.new("Graphics/Pictures/Arya2 sad")
  2641. s.x=390
  2642. s.y=-12
  2643. s.z=99999
  2644. pbWait(1)
  2645. s.x=370
  2646. pbWait(1)
  2647. s.x=350
  2648. pbWait(1)
  2649. s.x=330
  2650. pbWait(1)
  2651. s.x=310
  2652. pbWait(1)
  2653. s.x=290
  2654. pbWait(1)
  2655. s.x=270
  2656. pbWait(1)
  2657. s.x=250
  2658. pbWait(1)
  2659. s.x=230
  2660. pbWait(10)
  2661. pbDisplayPaused("El enemigo es demasiado fuerte, debo resistir.")
  2662. s.x=260
  2663. pbWait(1)
  2664. s.x=290
  2665. pbWait(1)
  2666. s.x=320
  2667. pbWait(1)
  2668. s.x=350
  2669. pbWait(1)
  2670. s.x=380
  2671. pbWait(1)
  2672. s.x=410
  2673. pbWait(1)
  2674. s.x=440
  2675. pbWait(1)
  2676.  
  2677. s.dispose
  2678. elsif turncount==2 && $game_switches[90]
  2679. s=Sprite.new; s.bitmap = Bitmap.new("Graphics/Pictures/Arya2 surprise")
  2680. s.x=390
  2681. s.y=-12
  2682. s.z=99999
  2683. pbWait(1)
  2684. s.x=370
  2685. pbWait(1)
  2686. s.x=350
  2687. pbWait(1)
  2688. s.x=330
  2689. pbWait(1)
  2690. s.x=310
  2691. pbWait(1)
  2692. s.x=290
  2693. pbWait(1)
  2694. s.x=270
  2695. pbWait(1)
  2696. s.x=250
  2697. pbWait(1)
  2698. s.x=230
  2699. pbWait(10)
  2700. pbDisplayPaused("¿Qué estoy haciendo? ¡No estoy logrando nada en combate!")
  2701. s.x=260
  2702. pbWait(1)
  2703. s.x=290
  2704. pbWait(1)
  2705. s.x=320
  2706. pbWait(1)
  2707. s.x=350
  2708. pbWait(1)
  2709. s.x=380
  2710. pbWait(1)
  2711. s.x=410
  2712. pbWait(1)
  2713. s.x=440
  2714. s.dispose
  2715.  
  2716. elsif turncount==3 && $game_switches[90]
  2717. s=Sprite.new; s.bitmap = Bitmap.new("Graphics/Pictures/Arya2 angry")
  2718. s.x=390
  2719. s.y=-12
  2720. s.z=99999
  2721. pbWait(1)
  2722. s.x=370
  2723. pbWait(1)
  2724. s.x=350
  2725. pbWait(1)
  2726. s.x=330
  2727. pbWait(1)
  2728. s.x=310
  2729. pbWait(1)
  2730. s.x=290
  2731. pbWait(1)
  2732. s.x=270
  2733. pbWait(1)
  2734. s.x=250
  2735. pbWait(1)
  2736. s.x=230
  2737. pbWait(10)
  2738. pbDisplayPaused("¡Agh! ¡No podré aguantar mucho màs, es mejor ser prudente!")
  2739. s.x=260
  2740. pbWait(1)
  2741. s.x=290
  2742. pbWait(1)
  2743. s.x=320
  2744. pbWait(1)
  2745. s.x=350
  2746. pbWait(1)
  2747. s.x=380
  2748. pbWait(1)
  2749. s.x=410
  2750. pbWait(1)
  2751. s.x=440
  2752. s.dispose
  2753. return pbEndOfBattle(canlose)
  2754. end
  2755. end
  2756. return pbEndOfBattle(canlose)
  2757. end
  2758.  
  2759. ################################################################################
  2760. # Command phase.
  2761. ################################################################################
  2762. def pbCommandMenu(i)
  2763. return @scene.pbCommandMenu(i)
  2764. end
  2765.  
  2766. def pbItemMenu(i)
  2767. return @scene.pbItemMenu(i)
  2768. end
  2769.  
  2770. def pbAutoFightMenu(i)
  2771. return false
  2772. end
  2773.  
  2774. def pbCommandPhase
  2775. @scene.pbBeginCommandPhase
  2776. @scene.pbResetCommandIndices
  2777. for i in 0...4 # Reset choices if commands can be shown
  2778. @battlers[i].effects[PBEffects::SkipTurn]=false
  2779. if pbCanShowCommands?(i) || @battlers[i].isFainted?
  2780. @choices[i][0]=0
  2781. @choices[i][1]=0
  2782. @choices[i][2]=nil
  2783. @choices[i][3]=-1
  2784. else
  2785. unless !@doublebattle && pbIsDoubleBattler?(i)
  2786. PBDebug.log("[Reutilización de comandos] #{@battlers[i].pbThis(true)}")
  2787. end
  2788. end
  2789. end
  2790. # Reset choices to perform Mega Evolution if it wasn't done somehow
  2791. for i in 0...2
  2792. for j in 0...@megaEvolution[i].length
  2793. @megaEvolution[i][j]=-1 if @megaEvolution[i][j]>=0
  2794. end
  2795. end
  2796. for i in 0...4
  2797. break if @decision!=0
  2798. next if @choices[i][0]!=0
  2799. if !pbOwnedByPlayer?(i) || @controlPlayer
  2800. if !@battlers[i].isFainted? && pbCanShowCommands?(i)
  2801. @scene.pbChooseEnemyCommand(i)
  2802. end
  2803. else
  2804. commandDone=false
  2805. commandEnd=false
  2806. if pbCanShowCommands?(i)
  2807. loop do
  2808. cmd=pbCommandMenu(i)
  2809. if cmd==0 # Fight
  2810. if pbCanShowFightMenu?(i)
  2811. commandDone=true if pbAutoFightMenu(i)
  2812. until commandDone
  2813. index=@scene.pbFightMenu(i)
  2814. if index<0
  2815. side=(pbIsOpposing?(i)) ? 1 : 0
  2816. owner=pbGetOwnerIndex(i)
  2817. if @megaEvolution[side][owner]==i
  2818. @megaEvolution[side][owner]=-1
  2819. end
  2820. break
  2821. end
  2822. next if !pbRegisterMove(i,index)
  2823. if @doublebattle
  2824. thismove=@battlers[i].moves[index]
  2825. target=@battlers[i].pbTarget(thismove)
  2826. if target==PBTargets::SingleNonUser # single non-user
  2827. target=@scene.pbChooseTarget(i,target)
  2828. next if target<0
  2829. pbRegisterTarget(i,target)
  2830. elsif target==PBTargets::UserOrPartner # Acupressure
  2831. target=@scene.pbChooseTarget(i,target)
  2832. next if target<0 || (target&1)==1
  2833. pbRegisterTarget(i,target)
  2834. end
  2835. end
  2836. commandDone=true
  2837. end
  2838. else
  2839. pbAutoChooseMove(i)
  2840. commandDone=true
  2841. end
  2842. elsif cmd!=0 && @battlers[i].effects[PBEffects::SkyDrop] # Caída Libre
  2843. pbDisplay(_INTL("¡{1} no se puede liberar de la Caída Libre!",@battlers[i].pbThis(true)))
  2844. elsif cmd==1 # Bag
  2845. if !@internalbattle
  2846. if pbOwnedByPlayer?(i)
  2847. pbDisplay(_INTL("Los objetos no se pueden utilizar aquí."))
  2848. end
  2849. else
  2850. item=pbItemMenu(i)
  2851. if item[0]>0
  2852. if pbRegisterItem(i,item[0],item[1])
  2853. commandDone=true
  2854. end
  2855. end
  2856. end
  2857. elsif cmd==2 # Pokémon
  2858. pkmn=pbSwitchPlayer(i,false,true)
  2859. if pkmn>=0
  2860. commandDone=true if pbRegisterSwitch(i,pkmn)
  2861. end
  2862. elsif cmd==3 # Run
  2863. run=pbRun(i)
  2864. if run>0
  2865. commandDone=true
  2866. return
  2867. elsif run<0
  2868. commandDone=true
  2869. side=(pbIsOpposing?(i)) ? 1 : 0
  2870. owner=pbGetOwnerIndex(i)
  2871. if @megaEvolution[side][owner]==i
  2872. @megaEvolution[side][owner]=-1
  2873. end
  2874. end
  2875. elsif cmd==4 # Call
  2876. thispkmn=@battlers[i]
  2877. @choices[i][0]=4 # "Call Pokémon"
  2878. @choices[i][1]=0
  2879. @choices[i][2]=nil
  2880. side=(pbIsOpposing?(i)) ? 1 : 0
  2881. owner=pbGetOwnerIndex(i)
  2882. if @megaEvolution[side][owner]==i
  2883. @megaEvolution[side][owner]=-1
  2884. end
  2885. commandDone=true
  2886. elsif cmd==-1 # Go back to first battler's choice
  2887. @megaEvolution[0][0]=-1 if @megaEvolution[0][0]>=0
  2888. @megaEvolution[1][0]=-1 if @megaEvolution[1][0]>=0
  2889. # Restore the item the player's first Pokémon was due to use
  2890. if @choices[0][0]==3 && $PokemonBag && $PokemonBag.pbCanStore?(@choices[0][1])
  2891. $PokemonBag.pbStoreItem(@choices[0][1])
  2892. end
  2893. pbCommandPhase
  2894. return
  2895. end
  2896. break if commandDone
  2897. end
  2898. end
  2899. end
  2900. end
  2901. end
  2902.  
  2903. ################################################################################
  2904. # Attack phase.
  2905. ################################################################################
  2906. def pbAttackPhase
  2907. @scene.pbBeginAttackPhase
  2908. for i in 0...4
  2909. @successStates[i].clear
  2910. if @choices[i][0]!=1 && @choices[i][0]!=2
  2911. @battlers[i].effects[PBEffects::DestinyBond]=false
  2912. @battlers[i].effects[PBEffects::Grudge]=false
  2913. end
  2914. @battlers[i].turncount+=1 if !@battlers[i].isFainted?
  2915. @battlers[i].effects[PBEffects::Rage]=false if !pbChoseMove?(i,:RAGE)
  2916. end
  2917. # Calculate priority at this time
  2918. @usepriority=false
  2919. priority=pbPriority(false,true)
  2920. # Mega Evolution
  2921. megaevolved=[]
  2922. for i in priority
  2923. if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
  2924. side=(pbIsOpposing?(i.index)) ? 1 : 0
  2925. owner=pbGetOwnerIndex(i.index)
  2926. if @megaEvolution[side][owner]==i.index
  2927. pbMegaEvolve(i.index)
  2928. megaevolved.push(i.index)
  2929. end
  2930. end
  2931. end
  2932. if megaevolved.length>0
  2933. for i in priority
  2934. i.pbAbilitiesOnSwitchIn(true) if megaevolved.include?(i.index)
  2935. end
  2936. end
  2937. # Call at Pokémon
  2938. for i in priority
  2939. if @choices[i.index][0]==4 && !i.effects[PBEffects::SkipTurn]
  2940. pbCall(i.index)
  2941. end
  2942. end
  2943. # Switch out Pokémon
  2944. @switching=true
  2945. switched=[]
  2946. for i in priority
  2947. if @choices[i.index][0]==2 && !i.effects[PBEffects::SkipTurn]
  2948. index=@choices[i.index][1] # party position of Pokémon to switch to
  2949. newpokename=index
  2950. if isConst?(pbParty(i.index)[index].ability,PBAbilities,:ILLUSION)
  2951. newpokename=pbGetLastPokeInTeam(i.index)
  2952. end
  2953. self.lastMoveUser=i.index
  2954. if !pbOwnedByPlayer?(i.index)
  2955. owner=pbGetOwner(i.index)
  2956. pbDisplayBrief(_INTL("¡{1} saca a {2}!",owner.fullname,i.name))
  2957. PBDebug.log("[Sacar Pokémon] Oponente sacó #{i.pbThis(true)}")
  2958. else
  2959. pbDisplayBrief(_INTL("¡{1}, cambio!\r\n¡Vuelve aquí!",i.name))
  2960. PBDebug.log("[Sacar Pokémon] Jugador sacó #{i.pbThis(true)}")
  2961. end
  2962. for j in priority
  2963. next if !i.pbIsOpposing?(j.index)
  2964. # if Pursuit and this target ("i") was chosen
  2965. if pbChoseMoveFunctionCode?(j.index,0x88) && # Pursuit
  2966. !j.hasMovedThisRound?
  2967. if j.status!=PBStatuses::SLEEP && j.status!=PBStatuses::FROZEN &&
  2968. !j.effects[PBEffects::SkyDrop] &&
  2969. (!j.hasWorkingAbility(:TRUANT) || !j.effects[PBEffects::Truant])
  2970. @choices[j.index][3]=i.index # Make sure to target the switching Pokémon
  2971. j.pbUseMove(@choices[j.index]) # This calls pbGainEXP as appropriate
  2972. j.effects[PBEffects::Pursuit]=true
  2973. @switching=false
  2974. return if @decision>0
  2975. end
  2976. end
  2977. break if i.isFainted?
  2978. end
  2979. if !pbRecallAndReplace(i.index,index,newpokename)
  2980. # If a forced switch somehow occurs here in single battles
  2981. # the attack phase now ends
  2982. if !@doublebattle
  2983. @switching=false
  2984. return
  2985. end
  2986. else
  2987. switched.push(i.index)
  2988. end
  2989. end
  2990. end
  2991. if switched.length>0
  2992. for i in priority
  2993. i.pbAbilitiesOnSwitchIn(true) if switched.include?(i.index)
  2994. end
  2995. end
  2996. @switching=false
  2997. # Uso de objetos
  2998. for i in priority
  2999. if @choices[i.index][0]==3 && !i.effects[PBEffects::SkipTurn]
  3000. if pbIsOpposing?(i.index)
  3001. # Opponent use item
  3002. pbEnemyUseItem(@choices[i.index][1],i)
  3003. else
  3004. # Player use item
  3005. item=@choices[i.index][1]
  3006. if item>0
  3007. usetype=$ItemData[item][ITEMBATTLEUSE]
  3008. if usetype==1 || usetype==3
  3009. if @choices[i.index][2]>=0
  3010. pbUseItemOnPokemon(item,@choices[i.index][2],i,@scene)
  3011. end
  3012. elsif usetype==2 || usetype==4
  3013. if !ItemHandlers.hasUseInBattle(item) # Poké Ball/Poké Doll used already
  3014. pbUseItemOnBattler(item,@choices[i.index][2],i,@scene)
  3015. end
  3016. end
  3017. end
  3018. end
  3019. end
  3020. end
  3021. # Uso de ataques
  3022. for i in priority
  3023. next if i.effects[PBEffects::SkipTurn]
  3024. if pbChoseMoveFunctionCode?(i.index,0x115) # Focus Punch / Puño Certero
  3025. pbCommonAnimation("FocusPunch",i,nil)
  3026. pbDisplay(_INTL("¡{1} está reforzando su concentración!",i.pbThis))
  3027. end
  3028. end
  3029. 10.times do
  3030. # Forced to go next
  3031. advance=false
  3032. for i in priority
  3033. next if !i.effects[PBEffects::MoveNext]
  3034. next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  3035. advance=i.pbProcessTurn(@choices[i.index])
  3036. break if advance
  3037. end
  3038. return if @decision>0
  3039. next if advance
  3040. # Regular priority order
  3041. for i in priority
  3042. next if i.effects[PBEffects::Quash]
  3043. next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  3044. advance=i.pbProcessTurn(@choices[i.index])
  3045. break if advance
  3046. end
  3047. return if @decision>0
  3048. next if advance
  3049. # Quashed
  3050. for i in priority
  3051. next if !i.effects[PBEffects::Quash]
  3052. next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  3053. advance=i.pbProcessTurn(@choices[i.index])
  3054. break if advance
  3055. end
  3056. return if @decision>0
  3057. next if advance
  3058. # Check for all done
  3059. for i in priority
  3060. advance=true if @choices[i.index][0]==1 && !i.hasMovedThisRound? &&
  3061. !i.effects[PBEffects::SkipTurn]
  3062. break if advance
  3063. end
  3064. next if advance
  3065. break
  3066. end
  3067. pbWait(20)
  3068. end
  3069.  
  3070. ################################################################################
  3071. # Final de la ronda.
  3072. ################################################################################
  3073. def pbEndOfRoundPhase
  3074. PBDebug.log("[Final de la ronda]")
  3075. for i in 0...4
  3076. @battlers[i].effects[PBEffects::Electrify]=false
  3077. @battlers[i].effects[PBEffects::Endure]=false
  3078. @battlers[i].effects[PBEffects::FirstPledge]=0
  3079. @battlers[i].effects[PBEffects::HyperBeam]-=1 if @battlers[i].effects[PBEffects::HyperBeam]>0
  3080. @battlers[i].effects[PBEffects::KingsShield]=false
  3081. @battlers[i].effects[PBEffects::LifeOrb]=false
  3082. @battlers[i].effects[PBEffects::MoveNext]=false
  3083. @battlers[i].effects[PBEffects::Powder]=false
  3084. @battlers[i].effects[PBEffects::Protect]=false
  3085. @battlers[i].effects[PBEffects::ProtectNegation]=false
  3086. @battlers[i].effects[PBEffects::Quash]=false
  3087. @battlers[i].effects[PBEffects::Roost]=false
  3088. @battlers[i].effects[PBEffects::SpikyShield]=false
  3089. end
  3090. @usepriority=false # recalculate priority
  3091. priority=pbPriority(true) # Ignoring Quick Claw here
  3092. # Weather
  3093. case @weather
  3094. when PBWeather::SUNNYDAY
  3095. @weatherduration=@weatherduration-1 if @weatherduration>0
  3096. if @weatherduration==0
  3097. pbDisplay(_INTL("Se ha ido el sol."))
  3098. @weather=0
  3099. PBDebug.log("[Fin de efecto] El clima Día Soleado se terminó")
  3100. else
  3101. pbCommonAnimation("Sunny",nil,nil)
  3102. # pbDisplay(_INTL("Hace mucho sol..."))
  3103. if pbWeather==PBWeather::SUNNYDAY
  3104. for i in priority
  3105. if i.hasWorkingAbility(:SOLARPOWER) # Poder solar
  3106. PBDebug.log("[Habilidad disparada] Poder Solar de #{i.pbThis}")
  3107. @scene.pbDamageAnimation(i,0)
  3108. i.pbReduceHP((i.totalhp/8).floor)
  3109. pbDisplay(_INTL("¡{1} perdió algunos PS debido al Poder Solar!",i.pbThis))
  3110. if i.isFainted?
  3111. return if !i.pbFaint
  3112. end
  3113. end
  3114. end
  3115. end
  3116. end
  3117. when PBWeather::RAINDANCE
  3118. @weatherduration=@weatherduration-1 if @weatherduration>0
  3119. if @weatherduration==0
  3120. pbDisplay(_INTL("Ha dejado de llover."))
  3121. @weather=0
  3122. PBDebug.log("[Fin de efecto] El clima Lluvia se terminó")
  3123. else
  3124. pbCommonAnimation("Rain",nil,nil)
  3125. # pbDisplay(_INTL("Sigue lloviendo..."))
  3126. end
  3127. when PBWeather::SANDSTORM
  3128. @weatherduration=@weatherduration-1 if @weatherduration>0
  3129. if @weatherduration==0
  3130. pbDisplay(_INTL("La tormenta de arena amainó."))
  3131. @weather=0
  3132. PBDebug.log("[Fin de efecto] El clima Tormenta de Arena terminó")
  3133. else
  3134. pbCommonAnimation("Sandstorm",nil,nil)
  3135. # pbDisplay(_INTL("La tormenta de arena arrecia..."))
  3136. if pbWeather==PBWeather::SANDSTORM
  3137. PBDebug.log("[Efecto prolongado disparado] El clima Tormenta de Arena inflinge daño")
  3138. for i in priority
  3139. next if i.isFainted?
  3140. if !i.pbHasType?(:GROUND) && !i.pbHasType?(:ROCK) && !i.pbHasType?(:STEEL) &&
  3141. !i.hasWorkingAbility(:SANDVEIL) &&
  3142. !i.hasWorkingAbility(:SANDRUSH) &&
  3143. !i.hasWorkingAbility(:SANDFORCE) &&
  3144. !i.hasWorkingAbility(:MAGICGUARD) &&
  3145. !i.hasWorkingAbility(:OVERCOAT) &&
  3146. !i.hasWorkingItem(:SAFETYGOGGLES) &&
  3147. ![0xCA,0xCB].include?(PBMoveData.new(i.effects[PBEffects::TwoTurnAttack]).function) # Dig, Dive
  3148. @scene.pbDamageAnimation(i,0)
  3149. i.pbReduceHP((i.totalhp/16).floor)
  3150. pbDisplay(_INTL("¡La tormenta de arena zarandea a {1}!",i.pbThis))
  3151. if i.isFainted?
  3152. return if !i.pbFaint
  3153. end
  3154. end
  3155. end
  3156. end
  3157. end
  3158. when PBWeather::HAIL
  3159. @weatherduration=@weatherduration-1 if @weatherduration>0
  3160. if @weatherduration==0
  3161. pbDisplay(_INTL("Ha dejado de granizar."))
  3162. @weather=0
  3163. PBDebug.log("[Fin de efecto] El clima Granizo terminó")
  3164. else
  3165. pbCommonAnimation("Hail",nil,nil)
  3166. # pbDisplay(_INTL("Sigue granizando..."))
  3167. if pbWeather==PBWeather::HAIL
  3168. PBDebug.log("[Efecto prolongado disparado] El clima Granizo inflinge daño")
  3169. for i in priority
  3170. next if i.isFainted?
  3171. if !i.pbHasType?(:ICE) &&
  3172. !i.hasWorkingAbility(:ICEBODY) &&
  3173. !i.hasWorkingAbility(:SNOWCLOAK) &&
  3174. !i.hasWorkingAbility(:MAGICGUARD) &&
  3175. !i.hasWorkingAbility(:OVERCOAT) &&
  3176. !i.hasWorkingItem(:SAFETYGOGGLES) &&
  3177. ![0xCA,0xCB].include?(PBMoveData.new(i.effects[PBEffects::TwoTurnAttack]).function) # Dig, Dive
  3178. @scene.pbDamageAnimation(i,0)
  3179. i.pbReduceHP((i.totalhp/16).floor)
  3180. pbDisplay(_INTL("¡El granizo zarandea a {1}!",i.pbThis))
  3181. if i.isFainted?
  3182. return if !i.pbFaint
  3183. end
  3184. end
  3185. end
  3186. end
  3187. end
  3188. when PBWeather::HEAVYRAIN # Mar del Albor
  3189. hasabil=false
  3190. for i in 0...4
  3191. if isConst?(@battlers[i].ability,PBAbilities,:PRIMORDIALSEA) && !@battlers[i].isFainted?
  3192. hasabil=true; break
  3193. end
  3194. end
  3195. @weatherduration=0 if !hasabil
  3196. if @weatherduration==0
  3197. pbDisplay(_INTL("¡El diluvio ha terminado!"))
  3198. @weather=0
  3199. PBDebug.log("[Fin de efecto] El clima del Mar del Albor ha terminado")
  3200. else
  3201. pbCommonAnimation("HeavyRain",nil,nil)
  3202. end
  3203. when PBWeather::HARSHSUN # Tierra del Ocaso
  3204. hasabil=false
  3205. for i in 0...4
  3206. if isConst?(@battlers[i].ability,PBAbilities,:DESOLATELAND) && !@battlers[i].isFainted?
  3207. hasabil=true; break
  3208. end
  3209. end
  3210. @weatherduration=0 if !hasabil
  3211. if @weatherduration==0
  3212. pbDisplay(_INTL("¡El sol vuelve a brillar como siempre!"))
  3213. @weather=0
  3214. PBDebug.log("[Fin de efecto] El clima de la Tierra del Ocaso ha terminado")
  3215. else
  3216. pbCommonAnimation("HarshSun",nil,nil)
  3217. if pbWeather==PBWeather::HARSHSUN
  3218. for i in priority
  3219. if i.hasWorkingAbility(:SOLARPOWER) # Poder Solar
  3220. PBDebug.log("[Habilidad disparada] Poder Solar de #{i.pbThis}")
  3221. @scene.pbDamageAnimation(i,0)
  3222. i.pbReduceHP((i.totalhp/8).floor)
  3223. pbDisplay(_INTL("¡{1} ha sido dañado por la luz solar!",i.pbThis))
  3224. if i.isFainted?
  3225. return if !i.pbFaint
  3226. end
  3227. end
  3228. end
  3229. end
  3230. end
  3231. when PBWeather::STRONGWINDS # Ráfaga Delta
  3232. hasabil=false
  3233. for i in 0...4
  3234. if isConst?(@battlers[i].ability,PBAbilities,:DELTASTREAM) && !@battlers[i].isFainted?
  3235. hasabil=true; break
  3236. end
  3237. end
  3238. @weatherduration=0 if !hasabil
  3239. if @weatherduration==0
  3240. pbDisplay(_INTL("¡Las misteriosas turbulencias han amainado!"))
  3241. @weather=0
  3242. PBDebug.log("[Fin de efecto] El clima de Ráfaga Delta ha terminado")
  3243. else
  3244. pbCommonAnimation("StrongWinds",nil,nil)
  3245. end
  3246. end
  3247. # Shadow Sky weather / Clima Cielo Oscuro (de Pkm XD)
  3248. if isConst?(@weather,PBWeather,:SHADOWSKY)
  3249. @weatherduration=@weatherduration-1 if @weatherduration>0
  3250. if @weatherduration==0
  3251. pbDisplay(_INTL("El cielo oscuro se ha aclarado."))
  3252. @weather=0
  3253. PBDebug.log("[Fin de efecto] El clima Cielo Oscuro ha terminado")
  3254. else
  3255. pbCommonAnimation("ShadowSky",nil,nil)
  3256. # pbDisplay(_INTL("El cielo sigue oscuro..."));
  3257. if isConst?(pbWeather,PBWeather,:SHADOWSKY)
  3258. PBDebug.log("[Efecto prolongado disparado] El clima Cielo Oscuro inflinge daño")
  3259. for i in priority
  3260. next if i.isFainted?
  3261. if !i.isShadow?
  3262. @scene.pbDamageAnimation(i,0)
  3263. i.pbReduceHP((i.totalhp/16).floor)
  3264. pbDisplay(_INTL("¡{1} ha sido dañado por el cielo oscuro!",i.pbThis))
  3265. if i.isFainted?
  3266. return if !i.pbFaint
  3267. end
  3268. end
  3269. end
  3270. end
  3271. end
  3272. end
  3273. # Future Sight/Doom Desire - Premonición/Deseo Oculto
  3274. for i in battlers # not priority
  3275. next if i.isFainted?
  3276. if i.effects[PBEffects::FutureSight]>0
  3277. i.effects[PBEffects::FutureSight]-=1
  3278. if i.effects[PBEffects::FutureSight]==0
  3279. move=i.effects[PBEffects::FutureSightMove]
  3280. PBDebug.log("[Efecto prolongado disparado] #{PBMoves.getName(move)} ha golpeado a #{i.pbThis(true)}")
  3281. pbDisplay(_INTL("¡{1} ha sufrido el ataque {2}!",i.pbThis,PBMoves.getName(move)))
  3282. moveuser=nil
  3283. for j in battlers
  3284. next if j.pbIsOpposing?(i.effects[PBEffects::FutureSightUserPos])
  3285. if j.pokemonIndex==i.effects[PBEffects::FutureSightUser] && !j.isFainted?
  3286. moveuser=j; break
  3287. end
  3288. end
  3289. if !moveuser
  3290. party=pbParty(i.effects[PBEffects::FutureSightUserPos])
  3291. if party[i.effects[PBEffects::FutureSightUser]].hp>0
  3292. moveuser=PokeBattle_Battler.new(self,i.effects[PBEffects::FutureSightUserPos])
  3293. moveuser.pbInitDummyPokemon(party[i.effects[PBEffects::FutureSightUser]],
  3294. i.effects[PBEffects::FutureSightUser])
  3295. end
  3296. end
  3297. if !moveuser
  3298. pbDisplay(_INTL("¡Pero falló!"))
  3299. else
  3300. @futuresight=true
  3301. moveuser.pbUseMoveSimple(move,-1,i.index)
  3302. @futuresight=false
  3303. end
  3304. i.effects[PBEffects::FutureSight]=0
  3305. i.effects[PBEffects::FutureSightMove]=0
  3306. i.effects[PBEffects::FutureSightUser]=-1
  3307. i.effects[PBEffects::FutureSightUserPos]=-1
  3308. if i.isFainted?
  3309. return if !i.pbFaint
  3310. next
  3311. end
  3312. end
  3313. end
  3314. end
  3315. for i in priority
  3316. next if i.isFainted?
  3317. # Rain Dish / Cura Lluvia
  3318. if i.hasWorkingAbility(:RAINDISH) &&
  3319. (pbWeather==PBWeather::RAINDANCE ||
  3320. pbWeather==PBWeather::HEAVYRAIN)
  3321. PBDebug.log("[Habilidad disparada] Cura Lluvia de #{i.pbThis}")
  3322. hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
  3323. pbDisplay(_INTL("¡{1} ha restaurado algunos PS gracias a {2}!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
  3324. end
  3325. # Dry Skin / Piel Seca
  3326. if i.hasWorkingAbility(:DRYSKIN)
  3327. if pbWeather==PBWeather::RAINDANCE ||
  3328. pbWeather==PBWeather::HEAVYRAIN
  3329. PBDebug.log("[Habilidad disparada] Piel Seca de #{i.pbThis} (bajo lluvia)")
  3330. hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
  3331. pbDisplay(_INTL("¡{1} ha restaurado algunos PS por su {2}!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
  3332. elsif pbWeather==PBWeather::SUNNYDAY ||
  3333. pbWeather==PBWeather::HARSHSUN
  3334. PBDebug.log("[Habilidad disparada] Piel Seca de #{i.pbThis} (al sol)")
  3335. @scene.pbDamageAnimation(i,0)
  3336. hploss=i.pbReduceHP((i.totalhp/8).floor)
  3337. pbDisplay(_INTL("¡{1} ha sido dañado por la fuerte luz del sol sobre su {2}!",i.pbThis,PBAbilities.getName(i.ability))) if hploss>0
  3338. end
  3339. end
  3340. # Ice Body / Gélido
  3341. if i.hasWorkingAbility(:ICEBODY) && pbWeather==PBWeather::HAIL
  3342. PBDebug.log("[Habilidad disparada] Gélido de #{i.pbThis}")
  3343. hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
  3344. pbDisplay(_INTL("{1} ha restaurado algunos PS con {2}!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
  3345. end
  3346. if i.isFainted?
  3347. return if !i.pbFaint
  3348. end
  3349. end
  3350. # Wish / Deseo
  3351. for i in priority
  3352. next if i.isFainted?
  3353. if i.effects[PBEffects::Wish]>0
  3354. i.effects[PBEffects::Wish]-=1
  3355. if i.effects[PBEffects::Wish]==0
  3356. PBDebug.log("[Efecto prolongado disparado] Deseo de #{i.pbThis}")
  3357. hpgain=i.pbRecoverHP(i.effects[PBEffects::WishAmount],true)
  3358. if hpgain>0
  3359. wishmaker=pbThisEx(i.index,i.effects[PBEffects::WishMaker])
  3360. pbDisplay(_INTL("¡El deseo de {1} se hizo realidad!",wishmaker))
  3361. end
  3362. end
  3363. end
  3364. end
  3365. # Fire Pledge + Grass Pledge combination damage
  3366. for i in 0...2
  3367. if sides[i].effects[PBEffects::SeaOfFire]>0 &&
  3368. pbWeather!=PBWeather::RAINDANCE &&
  3369. pbWeather!=PBWeather::HEAVYRAIN
  3370. @battle.pbCommonAnimation("SeaOfFire",nil,nil) if i==0
  3371. @battle.pbCommonAnimation("SeaOfFireOpp",nil,nil) if i==1
  3372. for j in priority
  3373. next if (j.index&1)!=i
  3374. next if j.pbHasType?(:FIRE) || j.hasWorkingAbility(:MAGICGUARD)
  3375. @scene.pbDamageAnimation(j,0)
  3376. hploss=j.pbReduceHP((j.totalhp/8).floor)
  3377. pbDisplay(_INTL("¡{1} ha sido dañado por el mar de llamas!",j.pbThis)) if hploss>0
  3378. if j.isFainted?
  3379. return if !j.pbFaint
  3380. end
  3381. end
  3382. end
  3383. end
  3384. for i in priority
  3385. next if i.isFainted?
  3386. # Shed Skin, Hydration
  3387. if (i.hasWorkingAbility(:SHEDSKIN) && pbRandom(10)<3) ||
  3388. (i.hasWorkingAbility(:HYDRATION) && (pbWeather==PBWeather::RAINDANCE ||
  3389. pbWeather==PBWeather::HEAVYRAIN))
  3390. if i.status>0
  3391. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(i.ability)} de #{i.pbThis}")
  3392. s=i.status
  3393. i.pbCureStatus(false)
  3394. case s
  3395. when PBStatuses::SLEEP
  3396. pbDisplay(_INTL("¡{2} de {1} lo despertó!",i.pbThis,PBAbilities.getName(i.ability)))
  3397. when PBStatuses::POISON
  3398. pbDisplay(_INTL("¡{2} de {1} le curó el veneno!",i.pbThis,PBAbilities.getName(i.ability)))
  3399. when PBStatuses::BURN
  3400. pbDisplay(_INTL("¡{2} de {1} le curó la quemadura!",i.pbThis,PBAbilities.getName(i.ability)))
  3401. when PBStatuses::PARALYSIS
  3402. pbDisplay(_INTL("¡{2} de {1} le curó la parálisis!",i.pbThis,PBAbilities.getName(i.ability)))
  3403. when PBStatuses::FROZEN
  3404. pbDisplay(_INTL("¡{2} de {1} le permitió descongelarse!",i.pbThis,PBAbilities.getName(i.ability)))
  3405. end
  3406. end
  3407. end
  3408. # Healer
  3409. if i.hasWorkingAbility(:HEALER) && pbRandom(10)<3
  3410. partner=i.pbPartner
  3411. if partner && partner.status>0
  3412. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(i.ability)} de #{i.pbThis}")
  3413. s=partner.status
  3414. partner.pbCureStatus(false)
  3415. case s
  3416. when PBStatuses::SLEEP
  3417. pbDisplay(_INTL("¡{2} de {1} le quitó el sueño a su compañero!",i.pbThis,PBAbilities.getName(i.ability)))
  3418. when PBStatuses::POISON
  3419. pbDisplay(_INTL("¡{2} de {1} le curó el venenó a su compañero!",i.pbThis,PBAbilities.getName(i.ability)))
  3420. when PBStatuses::BURN
  3421. pbDisplay(_INTL("¡{2} de {1} le curó la quemadura a su compañero!",i.pbThis,PBAbilities.getName(i.ability)))
  3422. when PBStatuses::PARALYSIS
  3423. pbDisplay(_INTL("¡{2} de {1} liberó de la parálisis a su compañero!",i.pbThis,PBAbilities.getName(i.ability)))
  3424. when PBStatuses::FROZEN
  3425. pbDisplay(_INTL("¡{2} de {1} descongeló a su compañero!",i.pbThis,PBAbilities.getName(i.ability)))
  3426. end
  3427. end
  3428. end
  3429. end
  3430. for i in priority
  3431. next if i.isFainted?
  3432. # Grassy Terrain (healing)
  3433. if @field.effects[PBEffects::GrassyTerrain]>0 && !i.isAirborne?
  3434. hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
  3435. pbDisplay(_INTL("Los PS de {1} han sido recuperados.",i.pbThis)) if hpgain>0
  3436. end
  3437. # Held berries/Leftovers/Black Sludge
  3438. i.pbBerryCureCheck(true)
  3439. if i.isFainted?
  3440. return if !i.pbFaint
  3441. end
  3442. end
  3443. # Acua Aro / Aqua Ring
  3444. for i in priority
  3445. next if i.isFainted?
  3446. if i.effects[PBEffects::AquaRing]
  3447. PBDebug.log("[Efecto prolongado disparado] Acua Aro de #{i.pbThis}")
  3448. hpgain=(i.totalhp/16).floor
  3449. hpgain=(hpgain*1.3).floor if i.hasWorkingItem(:BIGROOT)
  3450. hpgain=i.pbRecoverHP(hpgain,true)
  3451. pbDisplay(_INTL("¡Acua Aro ha recuperado salud de {1}!",i.pbThis)) if hpgain>0
  3452. end
  3453. end
  3454. # Arraigo / Ingrain
  3455. for i in priority
  3456. next if i.isFainted?
  3457. if i.effects[PBEffects::Ingrain]
  3458. PBDebug.log("[Efecto prolongado disparado] Arraigo de #{i.pbThis}")
  3459. hpgain=(i.totalhp/16).floor
  3460. hpgain=(hpgain*1.3).floor if i.hasWorkingItem(:BIGROOT) # Raíz Grande
  3461. hpgain=i.pbRecoverHP(hpgain,true)
  3462. pbDisplay(_INTL("¡{1} ha absorbido nutrientes con las raíces!",i.pbThis)) if hpgain>0
  3463. end
  3464. end
  3465. # Drenadoras / Leech Seed
  3466. for i in priority
  3467. next if i.isFainted?
  3468. if i.effects[PBEffects::LeechSeed]>=0 && !i.hasWorkingAbility(:MAGICGUARD)
  3469. recipient=@battlers[i.effects[PBEffects::LeechSeed]]
  3470. if recipient && !recipient.isFainted? # si existe beneficiario
  3471. PBDebug.log("[Efecto prolongado disparado] Drenadoras de #{i.pbThis}")
  3472. pbCommonAnimation("LeechSeed",recipient,i)
  3473. hploss=i.pbReduceHP((i.totalhp/8).floor,true)
  3474. if i.hasWorkingAbility(:LIQUIDOOZE)
  3475. recipient.pbReduceHP(hploss,true)
  3476. pbDisplay(_INTL("¡{1} ha absorbido el Lodo Líquido!",recipient.pbThis))
  3477. else
  3478. if recipient.effects[PBEffects::HealBlock]==0
  3479. hploss=(hploss*1.3).floor if recipient.hasWorkingItem(:BIGROOT)
  3480. recipient.pbRecoverHP(hploss,true)
  3481. end
  3482. pbDisplay(_INTL("¡Las drenadoras restaron salud a {1}!",i.pbThis))
  3483. end
  3484. if i.isFainted?
  3485. return if !i.pbFaint
  3486. end
  3487. if recipient.isFainted?
  3488. return if !recipient.pbFaint
  3489. end
  3490. end
  3491. end
  3492. end
  3493. for i in priority
  3494. next if i.isFainted?
  3495. # Envenenado/Gravemente envenenado Poison/Bad poison
  3496. if i.status==PBStatuses::POISON
  3497. if i.statusCount>0
  3498. i.effects[PBEffects::Toxic]+=1
  3499. i.effects[PBEffects::Toxic]=[15,i.effects[PBEffects::Toxic]].min
  3500. end
  3501. if i.hasWorkingAbility(:POISONHEAL) # Antídoto
  3502. pbCommonAnimation("Poison",i,nil)
  3503. if i.effects[PBEffects::HealBlock]==0 && i.hp<i.totalhp
  3504. PBDebug.log("[Habilidad disparada] Antídoto de #{i.pbThis}")
  3505. i.pbRecoverHP((i.totalhp/8).floor,true)
  3506. pbDisplay(_INTL("¡{1} ha recuperado salud gracias al Antídoto!",i.pbThis))
  3507. end
  3508. else
  3509. if !i.hasWorkingAbility(:MAGICGUARD) # Muro Mágico
  3510. PBDebug.log("[Daño por estado] #{i.pbThis} recibió daño por el veneno/tóxico")
  3511. if i.statusCount==0
  3512. i.pbReduceHP((i.totalhp/8).floor)
  3513. else
  3514. i.pbReduceHP(((i.totalhp*i.effects[PBEffects::Toxic])/16).floor)
  3515. end
  3516. i.pbContinueStatus
  3517. end
  3518. end
  3519. end
  3520. # Quemadura / Burn
  3521. if i.status==PBStatuses::BURN
  3522. if !i.hasWorkingAbility(:MAGICGUARD) # Muro Mágico
  3523. PBDebug.log("[Daño por estado] #{i.pbThis} recibió daño por la quemadura")
  3524. if i.hasWorkingAbility(:HEATPROOF) # Ignífugo
  3525. PBDebug.log("[Habilidad disparada] Ignífugo de #{i.pbThis}")
  3526. i.pbReduceHP((i.totalhp/16).floor)
  3527. else
  3528. i.pbReduceHP((i.totalhp/8).floor)
  3529. end
  3530. end
  3531. i.pbContinueStatus
  3532. end
  3533. # Pesadilla / Nightmare
  3534. if i.effects[PBEffects::Nightmare]
  3535. if i.status==PBStatuses::SLEEP
  3536. if !i.hasWorkingAbility(:MAGICGUARD)
  3537. PBDebug.log("[Efecto prolongado disparado] Pesadilla de #{i.pbThis}")
  3538. i.pbReduceHP((i.totalhp/4).floor,true)
  3539. pbDisplay(_INTL("¡{1} está inmerso en una Pesadilla!",i.pbThis))
  3540. end
  3541. else
  3542. i.effects[PBEffects::Nightmare]=false
  3543. end
  3544. end
  3545. if i.isFainted?
  3546. return if !i.pbFaint
  3547. next
  3548. end
  3549. end
  3550. # Maldición / Curse
  3551. for i in priority
  3552. next if i.isFainted?
  3553. if i.effects[PBEffects::Curse] && !i.hasWorkingAbility(:MAGICGUARD)
  3554. PBDebug.log("[Efecto prolongado disparado] Maldición de #{i.pbThis}")
  3555. i.pbReduceHP((i.totalhp/4).floor,true)
  3556. pbDisplay(_INTL("¡{1} es víctima de una Maldición!",i.pbThis))
  3557. end
  3558. if i.isFainted?
  3559. return if !i.pbFaint
  3560. next
  3561. end
  3562. end
  3563. # Ataques Multi-turnos (Bind/Clamp/Fire Spin/Magma Storm/Sand Tomb/Whirlpool/Wrap)
  3564. for i in priority
  3565. next if i.isFainted?
  3566. if i.effects[PBEffects::MultiTurn]>0
  3567. i.effects[PBEffects::MultiTurn]-=1
  3568. movename=PBMoves.getName(i.effects[PBEffects::MultiTurnAttack])
  3569. if i.effects[PBEffects::MultiTurn]==0
  3570. PBDebug.log("[Fin de efecto] El movimiento de trampa #{movename} que afectaba a #{i.pbThis} terminó")
  3571. pbDisplay(_INTL("¡{1} se liberó de {2}!",i.pbThis,movename))
  3572. else
  3573. if isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:BIND)
  3574. pbCommonAnimation("Bind",i,nil)
  3575. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:CLAMP)
  3576. pbCommonAnimation("Clamp",i,nil)
  3577. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:FIRESPIN)
  3578. pbCommonAnimation("FireSpin",i,nil)
  3579. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:MAGMASTORM)
  3580. pbCommonAnimation("MagmaStorm",i,nil)
  3581. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:SANDTOMB)
  3582. pbCommonAnimation("SandTomb",i,nil)
  3583. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:WRAP)
  3584. pbCommonAnimation("Wrap",i,nil)
  3585. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:INFESTATION)
  3586. pbCommonAnimation("Infestation",i,nil)
  3587. else
  3588. pbCommonAnimation("Wrap",i,nil)
  3589. end
  3590. if !i.hasWorkingAbility(:MAGICGUARD)
  3591. PBDebug.log("[Efecto prolongado disparado] #{i.pbThis} ha sido dañado por el movimiento de trampa #{movename}")
  3592. @scene.pbDamageAnimation(i,0)
  3593. amt=(USENEWBATTLEMECHANICS) ? (i.totalhp/8).floor : (i.totalhp/16).floor
  3594. if @battlers[i.effects[PBEffects::MultiTurnUser]].hasWorkingItem(:BINDINGBAND)
  3595. amt=(USENEWBATTLEMECHANICS) ? (i.totalhp/6).floor : (i.totalhp/8).floor
  3596. end
  3597. i.pbReduceHP(amt)
  3598. pbDisplay(_INTL("¡{1} ha sido dañado por {2}!",i.pbThis,movename))
  3599. end
  3600. end
  3601. end
  3602. if i.isFainted?
  3603. return if !i.pbFaint
  3604. end
  3605. end
  3606. # Mofa / Taunt
  3607. for i in priority
  3608. next if i.isFainted?
  3609. if i.effects[PBEffects::Taunt]>0
  3610. i.effects[PBEffects::Taunt]-=1
  3611. if i.effects[PBEffects::Taunt]==0
  3612. pbDisplay(_INTL("¡El efecto de Mofa de {1} ha pasado!",i.pbThis))
  3613. PBDebug.log("[Fin de efecto] #{i.pbThis} ya no está afectado por Mofa")
  3614. end
  3615. end
  3616. end
  3617. # Otra Vez / Encore
  3618. for i in priority
  3619. next if i.isFainted?
  3620. if i.effects[PBEffects::Encore]>0
  3621. if i.moves[i.effects[PBEffects::EncoreIndex]].id!=i.effects[PBEffects::EncoreMove]
  3622. i.effects[PBEffects::Encore]=0
  3623. i.effects[PBEffects::EncoreIndex]=0
  3624. i.effects[PBEffects::EncoreMove]=0
  3625. PBDebug.log("[Fin de efecto] #{i.pbThis} is no longer encored (encored move was lost)")
  3626. else
  3627. i.effects[PBEffects::Encore]-=1
  3628. if i.effects[PBEffects::Encore]==0 || i.moves[i.effects[PBEffects::EncoreIndex]].pp==0
  3629. i.effects[PBEffects::Encore]=0
  3630. pbDisplay(_INTL("¡Otra Vez ya no hace efecto en {1}!",i.pbThis))
  3631. PBDebug.log("[Fin de efecto] #{i.pbThis} ya no es afectado por Otra Vez")
  3632. end
  3633. end
  3634. end
  3635. end
  3636. # Anulación/Cuerpo Maldito - Disable/Cursed Body
  3637. for i in priority
  3638. next if i.isFainted?
  3639. if i.effects[PBEffects::Disable]>0
  3640. i.effects[PBEffects::Disable]-=1
  3641. if i.effects[PBEffects::Disable]==0
  3642. i.effects[PBEffects::DisableMove]=0
  3643. pbDisplay(_INTL("¡{1} ya no está desactivado!",i.pbThis))
  3644. PBDebug.log("[Fin de efecto] #{i.pbThis} ya no está desactivado")
  3645. end
  3646. end
  3647. end
  3648. # Levitón / Magnet Rise
  3649. for i in priority
  3650. next if i.isFainted?
  3651. if i.effects[PBEffects::MagnetRise]>0
  3652. i.effects[PBEffects::MagnetRise]-=1
  3653. if i.effects[PBEffects::MagnetRise]==0
  3654. pbDisplay(_INTL("¡El electromagnetismo de {1} desapareció!",i.pbThis))
  3655. PBDebug.log("[Fin de efecto] #{i.pbThis} dejó de levitar con Levitón")
  3656. end
  3657. end
  3658. end
  3659. # Telequinesis / Telekinesis (Gen5)
  3660. for i in priority
  3661. next if i.isFainted?
  3662. if i.effects[PBEffects::Telekinesis]>0
  3663. i.effects[PBEffects::Telekinesis]-=1
  3664. if i.effects[PBEffects::Telekinesis]==0
  3665. pbDisplay(_INTL("¡{1} se liberó de la Telequinesis!",i.pbThis))
  3666. PBDebug.log("[Fin de efecto] #{i.pbThis} ya no está levitando por Telequinesis")
  3667. end
  3668. end
  3669. end
  3670. # Anticura / Heal Block
  3671. for i in priority
  3672. next if i.isFainted?
  3673. if i.effects[PBEffects::HealBlock]>0
  3674. i.effects[PBEffects::HealBlock]-=1
  3675. if i.effects[PBEffects::HealBlock]==0
  3676. pbDisplay(_INTL("¡Anticura ya no hace efecto en {1}!",i.pbThis))
  3677. PBDebug.log("[Fin de efecto] #{i.pbThis} ya no tiene Anticura")
  3678. end
  3679. end
  3680. end
  3681. # Embargo
  3682. for i in priority
  3683. next if i.isFainted?
  3684. if i.effects[PBEffects::Embargo]>0
  3685. i.effects[PBEffects::Embargo]-=1
  3686. if i.effects[PBEffects::Embargo]==0
  3687. pbDisplay(_INTL("¡{1} puede volver a usar objetos!",i.pbThis(true)))
  3688. PBDebug.log("[Fin de efecto] #{i.pbThis} ya no está afectado por Embargo")
  3689. end
  3690. end
  3691. end
  3692. # Bostezo / Yawn
  3693. for i in priority
  3694. next if i.isFainted?
  3695. if i.effects[PBEffects::Yawn]>0
  3696. i.effects[PBEffects::Yawn]-=1
  3697. if i.effects[PBEffects::Yawn]==0 && i.pbCanSleepYawn?
  3698. PBDebug.log("[Efecto prolongado disparado] Bostezo de #{i.pbThis}")
  3699. i.pbSleep
  3700. end
  3701. end
  3702. end
  3703. # Canto Mortal / Perish Song
  3704. perishSongUsers=[]
  3705. for i in priority
  3706. next if i.isFainted?
  3707. if i.effects[PBEffects::PerishSong]>0
  3708. i.effects[PBEffects::PerishSong]-=1
  3709. pbDisplay(_INTL("¡El contador de salud de {1} bajó a {2}!",i.pbThis,i.effects[PBEffects::PerishSong]))
  3710. PBDebug.log("[Efecto prolongado disparado] El contador de Canto Mortal de #{i.pbThis} bajó a #{i.effects[PBEffects::PerishSong]}")
  3711. if i.effects[PBEffects::PerishSong]==0
  3712. perishSongUsers.push(i.effects[PBEffects::PerishSongUser])
  3713. i.pbReduceHP(i.hp,true)
  3714. end
  3715. end
  3716. if i.isFainted?
  3717. return if !i.pbFaint
  3718. end
  3719. end
  3720. if perishSongUsers.length>0
  3721. # If all remaining Pokemon fainted by a Perish Song triggered by a single side
  3722. if (perishSongUsers.find_all{|item| pbIsOpposing?(item) }.length==perishSongUsers.length) ||
  3723. (perishSongUsers.find_all{|item| !pbIsOpposing?(item) }.length==perishSongUsers.length)
  3724. pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
  3725. end
  3726. end
  3727. if @decision>0
  3728. pbGainEXP
  3729. return
  3730. end
  3731. # Reflejo / Reflect
  3732. for i in 0...2
  3733. if sides[i].effects[PBEffects::Reflect]>0
  3734. sides[i].effects[PBEffects::Reflect]-=1
  3735. if sides[i].effects[PBEffects::Reflect]==0
  3736. pbDisplay(_INTL("¡Los efectos de Reflejo de tu equipo se disiparon!")) if i==0
  3737. pbDisplay(_INTL("¡Los efectos de Reflejo del equipo enemigo se disiparon!")) if i==1
  3738. PBDebug.log("[Fin de efecto] Reflejo del lado del jugador terminó") if i==0
  3739. PBDebug.log("[Fin de efecto] Reflejo del lado del oponente terminó") if i==1
  3740. end
  3741. end
  3742. end
  3743. # Pantalla Luz / Light Screen
  3744. for i in 0...2
  3745. if sides[i].effects[PBEffects::LightScreen]>0
  3746. sides[i].effects[PBEffects::LightScreen]-=1
  3747. if sides[i].effects[PBEffects::LightScreen]==0
  3748. pbDisplay(_INTL("¡Los efectos de Pantalla de Luz de tu equipo se disiparon!")) if i==0
  3749. pbDisplay(_INTL("¡Los efectos de Pantalla de Luz del equipo enemigo se disiparon!")) if i==1
  3750. PBDebug.log("[Fin de efecto] Pantalla de Luz del lado del jugador se terminó") if i==0
  3751. PBDebug.log("[Fin de efecto] Pantalla de Luz del lado del oponente se terminó") if i==1
  3752. end
  3753. end
  3754. end
  3755. # Velo Sagrado / Safeguard
  3756. for i in 0...2
  3757. if sides[i].effects[PBEffects::Safeguard]>0
  3758. sides[i].effects[PBEffects::Safeguard]-=1
  3759. if sides[i].effects[PBEffects::Safeguard]==0
  3760. pbDisplay(_INTL("¡Velo Sagrado de tu equipo dejó de hacer efecto!")) if i==0
  3761. pbDisplay(_INTL("¡Velo Sagrado del equipo enemigo dejó de hacer efecto!")) if i==1
  3762. PBDebug.log("[Fin de efecto] Velo Sagrado del lado del jugador terminó") if i==0
  3763. PBDebug.log("[Fin de efecto] Velo Sagrado del lado del oponente terminó") if i==1
  3764. end
  3765. end
  3766. end
  3767. # Neblina / Mist
  3768. for i in 0...2
  3769. if sides[i].effects[PBEffects::Mist]>0
  3770. sides[i].effects[PBEffects::Mist]-=1
  3771. if sides[i].effects[PBEffects::Mist]==0
  3772. pbDisplay(_INTL("¡Neblina de tu equipo dejó de hacer efecto!")) if i==0
  3773. pbDisplay(_INTL("¡Neblina del equipo enemigo dejó de hacer efecto!")) if i==1
  3774. PBDebug.log("[Fin de efecto] Neblina del lado del jugador terminó") if i==0
  3775. PBDebug.log("[Fin de efecto] Neblina del lado del oponente terminó") if i==1
  3776. end
  3777. end
  3778. end
  3779. # Viento Afín / Tailwind
  3780. for i in 0...2
  3781. if sides[i].effects[PBEffects::Tailwind]>0
  3782. sides[i].effects[PBEffects::Tailwind]-=1
  3783. if sides[i].effects[PBEffects::Tailwind]==0
  3784. pbDisplay(_INTL("¡Viento Afín de tu equipo dejó de hacer efecto!")) if i==0
  3785. pbDisplay(_INTL("¡Viento Afín del equipo enemigo dejó de hacer efecto!")) if i==1
  3786. PBDebug.log("[Fin de efecto] Viento Afín del lado del jugador terminó") if i==0
  3787. PBDebug.log("[Fin de efecto] Viento Afín del lado del oponente terminó") if i==1
  3788. end
  3789. end
  3790. end
  3791. # Conjuro / Lucky Chant
  3792. for i in 0...2
  3793. if sides[i].effects[PBEffects::LuckyChant]>0
  3794. sides[i].effects[PBEffects::LuckyChant]-=1
  3795. if sides[i].effects[PBEffects::LuckyChant]==0
  3796. pbDisplay(_INTL("¡Conjuro de tu equipo dejó de hacer efecto!")) if i==0
  3797. pbDisplay(_INTL("¡Conjuro del equipo enemigo dejó de hacer efecto!")) if i==1
  3798. PBDebug.log("[Fin de efecto] Conjuro del lado del jugador terminó") if i==0
  3799. PBDebug.log("[Fin de efecto] Conjuro del lado del oponente terminó") if i==1
  3800. end
  3801. end
  3802. end
  3803. # Final de los movimientos combiandos Voto
  3804. for i in 0...2
  3805. if sides[i].effects[PBEffects::Swamp]>0
  3806. sides[i].effects[PBEffects::Swamp]-=1
  3807. if sides[i].effects[PBEffects::Swamp]==0
  3808. pbDisplay(_INTL("The swamp around your team disappeared!")) if i==0
  3809. pbDisplay(_INTL("The swamp around the opposing team disappeared!")) if i==1
  3810. PBDebug.log("[Fin de efecto] Grass Pledge's swamp ended on the player's side") if i==0
  3811. PBDebug.log("[Fin de efecto] Grass Pledge's swamp ended on the opponent's side") if i==1
  3812. end
  3813. end
  3814. if sides[i].effects[PBEffects::SeaOfFire]>0
  3815. sides[i].effects[PBEffects::SeaOfFire]-=1
  3816. if sides[i].effects[PBEffects::SeaOfFire]==0
  3817. pbDisplay(_INTL("The sea of fire around your team disappeared!")) if i==0
  3818. pbDisplay(_INTL("The sea of fire around the opposing team disappeared!")) if i==1
  3819. PBDebug.log("[Fin de efecto] Fire Pledge's sea of fire ended on the player's side") if i==0
  3820. PBDebug.log("[Fin de efecto] Fire Pledge's sea of fire ended on the opponent's side") if i==1
  3821. end
  3822. end
  3823. if sides[i].effects[PBEffects::Rainbow]>0
  3824. sides[i].effects[PBEffects::Rainbow]-=1
  3825. if sides[i].effects[PBEffects::Rainbow]==0
  3826. pbDisplay(_INTL("The rainbow around your team disappeared!")) if i==0
  3827. pbDisplay(_INTL("The rainbow around the opposing team disappeared!")) if i==1
  3828. PBDebug.log("[Fin de efecto] Water Pledge's rainbow ended on the player's side") if i==0
  3829. PBDebug.log("[Fin de efecto] Water Pledge's rainbow ended on the opponent's side") if i==1
  3830. end
  3831. end
  3832. end
  3833. # Gravedad / Gravity
  3834. if @field.effects[PBEffects::Gravity]>0
  3835. @field.effects[PBEffects::Gravity]-=1
  3836. if @field.effects[PBEffects::Gravity]==0
  3837. pbDisplay(_INTL("¡La Gravedad volvió a la normalidad!"))
  3838. PBDebug.log("[Fin de efecto] Se terminó la gravedad intensa")
  3839. end
  3840. end
  3841. # Espacio Raro / Trick Room
  3842. if @field.effects[PBEffects::TrickRoom]>0
  3843. @field.effects[PBEffects::TrickRoom]-=1
  3844. if @field.effects[PBEffects::TrickRoom]==0
  3845. pbDisplay(_INTL("The twisted dimensions returned to normal."))
  3846. PBDebug.log("[Fin de efecto] Espacio Raro ha terminado")
  3847. end
  3848. end
  3849. # Zona Extraña / Wonder Room
  3850. if @field.effects[PBEffects::WonderRoom]>0
  3851. @field.effects[PBEffects::WonderRoom]-=1
  3852. if @field.effects[PBEffects::WonderRoom]==0
  3853. pbDisplay(_INTL("Wonder Room wore off, and the Defense and Sp. Def stats returned to normal!"))
  3854. PBDebug.log("[Fin de efecto] Zona Extraña ha terminado")
  3855. end
  3856. end
  3857. # Zona Mágica / Magic Room
  3858. if @field.effects[PBEffects::MagicRoom]>0
  3859. @field.effects[PBEffects::MagicRoom]-=1
  3860. if @field.effects[PBEffects::MagicRoom]==0
  3861. pbDisplay(_INTL("The area returned to normal."))
  3862. PBDebug.log("[Fin de efecto] Zona Mágica ha terminado")
  3863. end
  3864. end
  3865. # Mud Sport
  3866. if @field.effects[PBEffects::MudSportField]>0
  3867. @field.effects[PBEffects::MudSportField]-=1
  3868. if @field.effects[PBEffects::MudSportField]==0
  3869. pbDisplay(_INTL("The effects of Mud Sport have faded."))
  3870. PBDebug.log("[Fin de efecto] Mud Sport ended")
  3871. end
  3872. end
  3873. # Water Sport
  3874. if @field.effects[PBEffects::WaterSportField]>0
  3875. @field.effects[PBEffects::WaterSportField]-=1
  3876. if @field.effects[PBEffects::WaterSportField]==0
  3877. pbDisplay(_INTL("The effects of Water Sport have faded."))
  3878. PBDebug.log("[Fin de efecto] Water Sport ended")
  3879. end
  3880. end
  3881. # Electric Terrain
  3882. if @field.effects[PBEffects::ElectricTerrain]>0
  3883. @field.effects[PBEffects::ElectricTerrain]-=1
  3884. if @field.effects[PBEffects::ElectricTerrain]==0
  3885. pbDisplay(_INTL("The electric current disappeared from the battlefield."))
  3886. PBDebug.log("[Fin de efecto] Electric Terrain ended")
  3887. end
  3888. end
  3889. # Grassy Terrain (counting down)
  3890. if @field.effects[PBEffects::GrassyTerrain]>0
  3891. @field.effects[PBEffects::GrassyTerrain]-=1
  3892. if @field.effects[PBEffects::GrassyTerrain]==0
  3893. pbDisplay(_INTL("The grass disappeared from the battlefield."))
  3894. PBDebug.log("[Fin de efecto] Grassy Terrain ended")
  3895. end
  3896. end
  3897. # Misty Terrain
  3898. if @field.effects[PBEffects::MistyTerrain]>0
  3899. @field.effects[PBEffects::MistyTerrain]-=1
  3900. if @field.effects[PBEffects::MistyTerrain]==0
  3901. pbDisplay(_INTL("The mist disappeared from the battlefield."))
  3902. PBDebug.log("[Fin de efecto] Misty Terrain ended")
  3903. end
  3904. end
  3905. # Alboroto / Uproar
  3906. for i in priority
  3907. next if i.isFainted?
  3908. if i.effects[PBEffects::Uproar]>0
  3909. for j in priority
  3910. if !j.isFainted? && j.status==PBStatuses::SLEEP && !j.hasWorkingAbility(:SOUNDPROOF)
  3911. PBDebug.log("[Efecto prolongado disparado] Alboroto ha despertado a #{j.pbThis(true)}")
  3912. j.pbCureStatus(false)
  3913. pbDisplay(_INTL("¡{1} se despertó por el Alboroto!",j.pbThis))
  3914. end
  3915. end
  3916. i.effects[PBEffects::Uproar]-=1
  3917. if i.effects[PBEffects::Uproar]==0
  3918. pbDisplay(_INTL("{1} se tranquilizó.",i.pbThis))
  3919. PBDebug.log("[Fin de efecto] #{i.pbThis} ya no está haciendo alboroto")
  3920. else
  3921. pbDisplay(_INTL("¡{1} está montando un Alboroto!",i.pbThis))
  3922. end
  3923. end
  3924. end
  3925. for i in priority
  3926. next if i.isFainted?
  3927. # Impulso / Speed Boost
  3928. # A Pokémon's turncount is 0 if it became active after the beginning of a round
  3929. if i.turncount>0 && i.hasWorkingAbility(:SPEEDBOOST)
  3930. if i.pbIncreaseStatWithCause(PBStats::SPEED,1,i,PBAbilities.getName(i.ability))
  3931. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(i.ability)} de #{i.pbThis}")
  3932. end
  3933. end
  3934. # Bad Dreams
  3935. if i.status==PBStatuses::SLEEP && !i.hasWorkingAbility(:MAGICGUARD)
  3936. if i.pbOpposing1.hasWorkingAbility(:BADDREAMS) ||
  3937. i.pbOpposing2.hasWorkingAbility(:BADDREAMS)
  3938. PBDebug.log("[Habilidad disparada] Pesadilla de #{i.pbThis}")
  3939. hploss=i.pbReduceHP((i.totalhp/8).floor,true)
  3940. pbDisplay(_INTL("¡{1} sufre por el mal sueño!",i.pbThis)) if hploss>0
  3941. end
  3942. end
  3943. if i.isFainted?
  3944. return if !i.pbFaint
  3945. next
  3946. end
  3947. # Recogida / Pickup
  3948. if i.hasWorkingAbility(:PICKUP) && i.item<=0
  3949. item=0; index=-1; use=0
  3950. for j in 0...4
  3951. next if j==i.index
  3952. if @battlers[j].effects[PBEffects::PickupUse]>use
  3953. item=@battlers[j].effects[PBEffects::PickupItem]
  3954. index=j
  3955. use=@battlers[j].effects[PBEffects::PickupUse]
  3956. end
  3957. end
  3958. if item>0
  3959. i.item=item
  3960. @battlers[index].effects[PBEffects::PickupItem]=0
  3961. @battlers[index].effects[PBEffects::PickupUse]=0
  3962. @battlers[index].pokemon.itemRecycle=0 if @battlers[index].pokemon.itemRecycle==item
  3963. if !@opponent && # In a wild battle
  3964. i.pokemon.itemInitial==0 &&
  3965. @battlers[index].pokemon.itemInitial==item
  3966. i.pokemon.itemInitial=item
  3967. @battlers[index].pokemon.itemInitial=0
  3968. end
  3969. pbDisplay(_INTL("¡{1} ha encontrado una {2}!",i.pbThis,PBItems.getName(item)))
  3970. i.pbBerryCureCheck(true)
  3971. end
  3972. end
  3973. # Cosecha / Harvest
  3974. if i.hasWorkingAbility(:HARVEST) && i.item<=0 && i.pokemon.itemRecycle>0
  3975. if pbIsBerry?(i.pokemon.itemRecycle) &&
  3976. (pbWeather==PBWeather::SUNNYDAY ||
  3977. pbWeather==PBWeather::HARSHSUN || pbRandom(10)<5)
  3978. i.item=i.pokemon.itemRecycle
  3979. i.pokemon.itemRecycle=0
  3980. i.pokemon.itemInitial=item if i.pokemon.itemInitial==0
  3981. pbDisplay(_INTL("¡{1} ha cosechado una {2}!",i.pbThis,PBItems.getName(i.item)))
  3982. i.pbBerryCureCheck(true)
  3983. end
  3984. end
  3985. # Veleta / Moody
  3986. if i.hasWorkingAbility(:MOODY)
  3987. randomup=[]; randomdown=[]
  3988. for j in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,PBStats::SPATK,
  3989. PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
  3990. randomup.push(j) if i.pbCanIncreaseStatStage?(j,i)
  3991. randomdown.push(j) if i.pbCanReduceStatStage?(j,i)
  3992. end
  3993. if randomup.length>0
  3994. PBDebug.log("[Habilidad disparada] Veleta de #{i.pbThis} (suba caractarística)")
  3995. r=pbRandom(randomup.length)
  3996. i.pbIncreaseStatWithCause(randomup[r],2,i,PBAbilities.getName(i.ability))
  3997. for j in 0...randomdown.length
  3998. if randomdown[j]==randomup[r]
  3999. randomdown[j]=nil; randomdown.compact!
  4000. break
  4001. end
  4002. end
  4003. end
  4004. if randomdown.length>0
  4005. PBDebug.log("[Habilidad disparada] Veleta de #{i.pbThis} (baja caractarística)")
  4006. r=pbRandom(randomdown.length)
  4007. i.pbReduceStatWithCause(randomdown[r],1,i,PBAbilities.getName(i.ability))
  4008. end
  4009. end
  4010. end
  4011. for i in priority
  4012. next if i.isFainted?
  4013. # Toxisfera / Toxic Orb
  4014. if i.hasWorkingItem(:TOXICORB) && i.status==0 && i.pbCanPoison?(nil,false)
  4015. PBDebug.log("[Objeto disparado] Toxisfera de #{i.pbThis}")
  4016. i.pbPoison(nil,_INTL("¡{1} ha sido gravemente envenenado por la {2}!",i.pbThis,
  4017. PBItems.getName(i.item)),true)
  4018. end
  4019. # Llamasfera / Flame Orb
  4020. if i.hasWorkingItem(:FLAMEORB) && i.status==0 && i.pbCanBurn?(nil,false)
  4021. PBDebug.log("[Objeto disparado] Llamasfera de #{i.pbThis}")
  4022. i.pbBurn(nil,_INTL("¡{1} ha sido quemado por la {2}!",i.pbThis,PBItems.getName(i.item)))
  4023. end
  4024. # Toxiestrella / Sticky Barb
  4025. if i.hasWorkingItem(:STICKYBARB) && !i.hasWorkingAbility(:MAGICGUARD)
  4026. PBDebug.log("[Objeto disparado] Toxiestrella de #{i.pbThis}")
  4027. @scene.pbDamageAnimation(i,0)
  4028. i.pbReduceHP((i.totalhp/8).floor)
  4029. pbDisplay(_INTL("¡{1} ha sido dañado por la {2}!",i.pbThis,PBItems.getName(i.item)))
  4030. end
  4031. if i.isFainted?
  4032. return if !i.pbFaint
  4033. end
  4034. end
  4035. # Revisión de formas
  4036. for i in 0...4
  4037. next if @battlers[i].isFainted?
  4038. @battlers[i].pbCheckForm
  4039. end
  4040. pbGainEXP
  4041. pbSwitch
  4042. return if @decision>0
  4043. for i in priority
  4044. next if i.isFainted?
  4045. i.pbAbilitiesOnSwitchIn(false)
  4046. end
  4047. # Healing Wish/Lunar Dance - should go here
  4048. # Spikes/Toxic Spikes/Stealth Rock - should go here (in order of their 1st use)
  4049. for i in 0...4
  4050. if @battlers[i].turncount>0 && @battlers[i].hasWorkingAbility(:TRUANT)
  4051. @battlers[i].effects[PBEffects::Truant]=!@battlers[i].effects[PBEffects::Truant]
  4052. end
  4053. if @battlers[i].effects[PBEffects::LockOn]>0 # Also Mind Reader
  4054. @battlers[i].effects[PBEffects::LockOn]-=1
  4055. @battlers[i].effects[PBEffects::LockOnPos]=-1 if @battlers[i].effects[PBEffects::LockOn]==0
  4056. end
  4057. @battlers[i].effects[PBEffects::Flinch]=false
  4058. @battlers[i].effects[PBEffects::FollowMe]=0
  4059. @battlers[i].effects[PBEffects::HelpingHand]=false
  4060. @battlers[i].effects[PBEffects::MagicCoat]=false
  4061. @battlers[i].effects[PBEffects::Snatch]=false
  4062. @battlers[i].effects[PBEffects::Charge]-=1 if @battlers[i].effects[PBEffects::Charge]>0
  4063. @battlers[i].lastHPLost=0
  4064. @battlers[i].tookDamage=false
  4065. @battlers[i].lastAttacker.clear
  4066. @battlers[i].effects[PBEffects::Counter]=-1
  4067. @battlers[i].effects[PBEffects::CounterTarget]=-1
  4068. @battlers[i].effects[PBEffects::MirrorCoat]=-1
  4069. @battlers[i].effects[PBEffects::MirrorCoatTarget]=-1
  4070. end
  4071. for i in 0...2
  4072. if !@sides[i].effects[PBEffects::EchoedVoiceUsed]
  4073. @sides[i].effects[PBEffects::EchoedVoiceCounter]=0
  4074. end
  4075. @sides[i].effects[PBEffects::EchoedVoiceUsed]=false
  4076. @sides[i].effects[PBEffects::QuickGuard]=false
  4077. @sides[i].effects[PBEffects::WideGuard]=false
  4078. @sides[i].effects[PBEffects::CraftyShield]=false
  4079. @sides[i].effects[PBEffects::Round]=0
  4080. end
  4081. @field.effects[PBEffects::FusionBolt]=false
  4082. @field.effects[PBEffects::FusionFlare]=false
  4083. @field.effects[PBEffects::IonDeluge]=false
  4084. @field.effects[PBEffects::FairyLock]-=1 if @field.effects[PBEffects::FairyLock]>0
  4085. # invalidate stored priority
  4086. @usepriority=false
  4087. end
  4088.  
  4089. ################################################################################
  4090. # End of battle. / Final de la batalla
  4091. ################################################################################
  4092. def pbEndOfBattle(canlose=false)
  4093. case @decision
  4094. ##### VICTORIA #####
  4095. when 1
  4096. PBDebug.log("")
  4097. PBDebug.log("***Jugador ganó***")
  4098. if @opponent
  4099. @scene.pbTrainerBattleSuccess
  4100. if @opponent.is_a?(Array)
  4101. pbDisplayPaused(_INTL("¡{1} ha derrotado a {2} y {3}!",self.pbPlayer.name,@opponent[0].fullname,@opponent[1].fullname))
  4102. else
  4103. pbDisplayPaused(_INTL("¡{1} ha derrotado a\r\n{2}!",self.pbPlayer.name,@opponent.fullname))
  4104. end
  4105. @scene.pbShowOpponent(0)
  4106. pbDisplayPaused(@endspeech.gsub(/\\[Pp][Nn]/,self.pbPlayer.name))
  4107. if @opponent.is_a?(Array)
  4108. @scene.pbHideOpponent
  4109. @scene.pbShowOpponent(1)
  4110. pbDisplayPaused(@endspeech2.gsub(/\\[Pp][Nn]/,self.pbPlayer.name))
  4111. end
  4112. # Se calcula el dinero ganado por la victoria
  4113. if @internalbattle
  4114. tmoney=0
  4115. if @opponent.is_a?(Array) # Batallas dobles
  4116. maxlevel1=0; maxlevel2=0; limit=pbSecondPartyBegin(1)
  4117. for i in 0...limit
  4118. if @party2[i]
  4119. maxlevel1=@party2[i].level if maxlevel1<@party2[i].level
  4120. end
  4121. if @party2[i+limit]
  4122. maxlevel2=@party2[i+limit].level if maxlevel1<@party2[i+limit].level
  4123. end
  4124. end
  4125. tmoney+=maxlevel1*@opponent[0].moneyEarned
  4126. tmoney+=maxlevel2*@opponent[1].moneyEarned
  4127. else
  4128. maxlevel=0
  4129. for i in @party2
  4130. next if !i
  4131. maxlevel=i.level if maxlevel<i.level
  4132. end
  4133. tmoney+=maxlevel*@opponent.moneyEarned
  4134. end
  4135. # If Amulet Coin/Luck Incense's effect applies, double money earned
  4136. tmoney*=2 if @amuletcoin
  4137. # If Happy Hour's effect applies, double money earned
  4138. tmoney*=2 if @doublemoney
  4139. oldmoney=self.pbPlayer.money
  4140. self.pbPlayer.money+=tmoney
  4141. moneygained=self.pbPlayer.money-oldmoney
  4142. if moneygained>0
  4143. pbDisplayPaused(_INTL("¡{1} ha obtenido ${2}\r\npor la victoria!",self.pbPlayer.name,tmoney))
  4144. end
  4145. end
  4146. end
  4147. if @internalbattle && @extramoney>0
  4148. @extramoney*=2 if @amuletcoin
  4149. @extramoney*=2 if @doublemoney
  4150. oldmoney=self.pbPlayer.money
  4151. self.pbPlayer.money+=@extramoney
  4152. moneygained=self.pbPlayer.money-oldmoney
  4153. if moneygained>0
  4154. pbDisplayPaused(_INTL("¡{1} ha recogido ${2}!",self.pbPlayer.name,@extramoney))
  4155. end
  4156. end
  4157. for pkmn in @snaggedpokemon
  4158. pbStorePokemon(pkmn)
  4159. self.pbPlayer.shadowcaught=[] if !self.pbPlayer.shadowcaught
  4160. self.pbPlayer.shadowcaught[pkmn.species]=true
  4161. end
  4162. @snaggedpokemon.clear
  4163. ##### DERROTA, EMPATE #####
  4164. when 2, 5
  4165. PBDebug.log("")
  4166. PBDebug.log("***Jugador perdió***") if @decision==2
  4167. PBDebug.log("***Jugador empató con oponente***") if @decision==5
  4168. if @internalbattle
  4169. pbDisplayPaused(_INTL("¡{1} no tiene más Pokémon que puedan pelear!",self.pbPlayer.name))
  4170. moneylost=pbMaxLevelFromIndex(0) # Player's Pokémon only, not partner's
  4171. multiplier=[8,16,24,36,48,60,80,100,120]
  4172. moneylost*=multiplier[[multiplier.length-1,self.pbPlayer.numbadges].min]
  4173. moneylost=self.pbPlayer.money if moneylost>self.pbPlayer.money
  4174. moneylost=0 if $game_switches[NO_MONEY_LOSS]
  4175. oldmoney=self.pbPlayer.money
  4176. self.pbPlayer.money-=moneylost
  4177. lostmoney=oldmoney-self.pbPlayer.money
  4178. if @opponent
  4179. if @opponent.is_a?(Array)
  4180. pbDisplayPaused(_INTL("¡{1} ha perdido contra {2} y {3}!",self.pbPlayer.name,@opponent[0].fullname,@opponent[1].fullname))
  4181. else
  4182. pbDisplayPaused(_INTL("¡{1} ha perdido contra\r\n{2}!",self.pbPlayer.name,@opponent.fullname))
  4183. end
  4184. if moneylost>0
  4185. pbDisplayPaused(_INTL("{1} ha entregado ${2} al ganador...",self.pbPlayer.name,lostmoney))
  4186. pbDisplayPaused(_INTL("...")) if !canlose
  4187. end
  4188. else
  4189. if moneylost>0
  4190. pbDisplayPaused(_INTL("{1} entró en pánico y dejó caer\r\n${2}...",self.pbPlayer.name,lostmoney))
  4191. pbDisplayPaused(_INTL("...")) if !canlose
  4192. end
  4193. end
  4194. pbDisplayPaused(_INTL("¡{1} se desmayó!",self.pbPlayer.name)) if !canlose
  4195. elsif @decision==2
  4196. @scene.pbShowOpponent(0)
  4197. pbDisplayPaused(@endspeechwin.gsub(/\\[Pp][Nn]/,self.pbPlayer.name))
  4198. if @opponent.is_a?(Array)
  4199. @scene.pbHideOpponent
  4200. @scene.pbShowOpponent(1)
  4201. pbDisplayPaused(@endspeechwin2.gsub(/\\[Pp][Nn]/,self.pbPlayer.name))
  4202. end
  4203. end
  4204. end
  4205. # Pass on Pokérus within the party
  4206. infected=[]
  4207. for i in 0...$Trainer.party.length
  4208. if $Trainer.party[i].pokerusStage==1
  4209. infected.push(i)
  4210. end
  4211. end
  4212. if infected.length>=1
  4213. for i in infected
  4214. strain=$Trainer.party[i].pokerus/16
  4215. if i>0 && $Trainer.party[i-1].pokerusStage==0
  4216. $Trainer.party[i-1].givePokerus(strain) if rand(3)==0
  4217. end
  4218. if i<$Trainer.party.length-1 && $Trainer.party[i+1].pokerusStage==0
  4219. $Trainer.party[i+1].givePokerus(strain) if rand(3)==0
  4220. end
  4221. end
  4222. end
  4223. @scene.pbEndBattle(@decision)
  4224. for i in @battlers
  4225. i.pbResetForm
  4226. if i.hasWorkingAbility(:NATURALCURE)
  4227. i.status=0
  4228. end
  4229. end
  4230. for i in $Trainer.party
  4231. i.setItem(i.itemInitial)
  4232. i.itemInitial=i.itemRecycle=0
  4233. i.belch=false
  4234. end
  4235. return @decision
  4236. end
  4237. end
Add Comment
Please, Sign In to add comment