Kid02

help

Apr 20th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 143.75 KB | None | 0 0
  1. class PokeBattle_Battler
  2. attr_reader :battle
  3. attr_reader :pokemon
  4. attr_reader :name
  5. attr_reader :index
  6. attr_accessor :pokemonIndex
  7. attr_reader :totalhp
  8. attr_reader :fainted
  9. attr_accessor :lastAttacker
  10. attr_accessor :turncount
  11. attr_accessor :effects
  12. attr_accessor :species
  13. attr_accessor :type1
  14. attr_accessor :type2
  15. attr_accessor :ability
  16. attr_accessor :gender
  17. attr_accessor :attack
  18. attr_writer :defense
  19. attr_accessor :spatk
  20. attr_writer :spdef
  21. attr_accessor :speed
  22. attr_accessor :stages
  23. attr_accessor :iv
  24. attr_accessor :moves
  25. attr_accessor :participants
  26. attr_accessor :tookDamage
  27. attr_accessor :lastHPLost
  28. attr_accessor :lastMoveUsed
  29. attr_accessor :lastMoveUsedType
  30. attr_accessor :lastMoveUsedSketch
  31. attr_accessor :lastRegularMoveUsed
  32. attr_accessor :lastRoundMoved
  33. attr_accessor :movesUsed
  34. attr_accessor :currentMove
  35. attr_accessor :damagestate
  36. attr_accessor :captured
  37.  
  38. def inHyperMode?; return false; end
  39. def isShadow?; return false; end
  40.  
  41. ################################################################################
  42. # Complex accessors
  43. ################################################################################
  44. def defense
  45. return @battle.field.effects[PBEffects::WonderRoom]>0 ? @spdef : @defense
  46. end
  47.  
  48. def spdef
  49. return @battle.field.effects[PBEffects::WonderRoom]>0 ? @defense : @spdef
  50. end
  51.  
  52. def nature
  53. return (@pokemon) ? @pokemon.nature : 0
  54. end
  55.  
  56. def happiness
  57. return (@pokemon) ? @pokemon.happiness : 0
  58. end
  59.  
  60. def pokerusStage
  61. return (@pokemon) ? @pokemon.pokerusStage : 0
  62. end
  63.  
  64. attr_reader :form
  65.  
  66. def form=(value)
  67. @form=value
  68. @pokemon.form=value if @pokemon
  69. end
  70.  
  71. def hasMega?
  72. return false if @effects[PBEffects::Transform]
  73. if @pokemon
  74. return (@pokemon.hasMegaForm? rescue false)
  75. end
  76. return false
  77. end
  78.  
  79. def isMega?
  80. if @pokemon
  81. return (@pokemon.isMega? rescue false)
  82. end
  83. return false
  84. end
  85.  
  86. def hasPrimal?
  87. return false if @effects[PBEffects::Transform]
  88. if @pokemon
  89. return (@pokemon.hasPrimalForm? rescue false)
  90. end
  91. return false
  92. end
  93.  
  94. def isPrimal?
  95. if @pokemon
  96. return (@pokemon.isPrimal? rescue false)
  97. end
  98. return false
  99. end
  100.  
  101. attr_reader :level
  102.  
  103. def level=(value)
  104. @level=value
  105. @pokemon.level=(value) if @pokemon
  106. end
  107.  
  108. attr_reader :status
  109.  
  110. def status=(value)
  111. if @status==PBStatuses::SLEEP && value==0
  112. @effects[PBEffects::Truant]=false
  113. end
  114. @status=value
  115. @pokemon.status=value if @pokemon
  116. if value!=PBStatuses::POISON
  117. @effects[PBEffects::Toxic]=0
  118. end
  119. if value!=PBStatuses::POISON && value!=PBStatuses::SLEEP
  120. @statusCount=0
  121. @pokemon.statusCount=0 if @pokemon
  122. end
  123. end
  124.  
  125. attr_reader :statusCount
  126.  
  127. def statusCount=(value)
  128. @statusCount=value
  129. @pokemon.statusCount=value if @pokemon
  130. end
  131.  
  132. attr_reader :hp
  133.  
  134. def hp=(value)
  135. @hp=value.to_i
  136. @pokemon.hp=value.to_i if @pokemon
  137. end
  138.  
  139. attr_reader :item
  140.  
  141. def item=(value)
  142. @item=value
  143. @pokemon.setItem(value) if @pokemon
  144. end
  145.  
  146. def weight(attacker=nil)
  147. w=(@pokemon) ? @pokemon.weight : 500
  148. if !attacker || !attacker.hasMoldBreaker
  149. w*=2 if self.hasWorkingAbility(:HEAVYMETAL)
  150. w/=2 if self.hasWorkingAbility(:LIGHTMETAL)
  151. end
  152. w/=2 if self.hasWorkingItem(:FLOATSTONE)
  153. w+=@effects[PBEffects::WeightChange]
  154. w=w.floor
  155. w=1 if w<1
  156. return w
  157. end
  158.  
  159. def name
  160. if @effects[PBEffects::Illusion]
  161. return @effects[PBEffects::Illusion].name
  162. end
  163. return @name
  164. end
  165.  
  166. def displayGender
  167. if @effects[PBEffects::Illusion]
  168. return @effects[PBEffects::Illusion].gender
  169. end
  170. return self.gender
  171. end
  172.  
  173. def isShiny?
  174. if @effects[PBEffects::Illusion]
  175. return @effects[PBEffects::Illusion].isShiny?
  176. end
  177. return @pokemon.isShiny? if @pokemon
  178. return false
  179. end
  180.  
  181. def owned
  182. return (@pokemon) ? $Trainer.owned[@pokemon.species] && [email protected] : false
  183. end
  184.  
  185. ################################################################################
  186. # Creating a battler
  187. ################################################################################
  188. def initialize(btl,index)
  189. @battle = btl
  190. @index = index
  191. @hp = 0
  192. @totalhp = 0
  193. @fainted = true
  194. @captured = false
  195. @stages = []
  196. @effects = []
  197. @damagestate = PokeBattle_DamageState.new
  198. pbInitBlank
  199. pbInitEffects(false)
  200. pbInitPermanentEffects
  201. end
  202.  
  203. def pbInitPokemon(pkmn,pkmnIndex)
  204. if pkmn.isEgg?
  205. raise _INTL("Un huevo no puede ser un Pokémon activo")
  206. end
  207. @name = pkmn.name
  208. @species = pkmn.species
  209. @level = pkmn.level
  210. @hp = pkmn.hp
  211. @totalhp = pkmn.totalhp
  212. @gender = pkmn.gender
  213. @ability = pkmn.ability
  214. @item = pkmn.item
  215. @type1 = pkmn.type1
  216. @type2 = pkmn.type2
  217. @form = pkmn.form
  218. @attack = pkmn.attack
  219. @defense = pkmn.defense
  220. @speed = pkmn.speed
  221. @spatk = pkmn.spatk
  222. @spdef = pkmn.spdef
  223. @status = pkmn.status
  224. @statusCount = pkmn.statusCount
  225. @pokemon = pkmn
  226. @pokemonIndex = pkmnIndex
  227. @participants = [] # Participants will earn Exp. Points if this battler is defeated
  228. @moves = [
  229. PokeBattle_Move.pbFromPBMove(@battle,pkmn.moves[0]),
  230. PokeBattle_Move.pbFromPBMove(@battle,pkmn.moves[1]),
  231. PokeBattle_Move.pbFromPBMove(@battle,pkmn.moves[2]),
  232. PokeBattle_Move.pbFromPBMove(@battle,pkmn.moves[3])
  233. ]
  234. @iv = []
  235. @iv[0] = pkmn.iv[0]
  236. @iv[1] = pkmn.iv[1]
  237. @iv[2] = pkmn.iv[2]
  238. @iv[3] = pkmn.iv[3]
  239. @iv[4] = pkmn.iv[4]
  240. @iv[5] = pkmn.iv[5]
  241. end
  242.  
  243. def pbInitDummyPokemon(pkmn,pkmnIndex)
  244. if pkmn.isEgg?
  245. raise _INTL("Un huevo no puede ser un Pokémon activo")
  246. end
  247. @name = pkmn.name
  248. @species = pkmn.species
  249. @level = pkmn.level
  250. @hp = pkmn.hp
  251. @totalhp = pkmn.totalhp
  252. @gender = pkmn.gender
  253. @type1 = pkmn.type1
  254. @type2 = pkmn.type2
  255. @form = pkmn.form
  256. @attack = pkmn.attack
  257. @defense = pkmn.defense
  258. @speed = pkmn.speed
  259. @spatk = pkmn.spatk
  260. @spdef = pkmn.spdef
  261. @status = pkmn.status
  262. @statusCount = pkmn.statusCount
  263. @pokemon = pkmn
  264. @pokemonIndex = pkmnIndex
  265. @participants = []
  266. @iv = []
  267. @iv[0] = pkmn.iv[0]
  268. @iv[1] = pkmn.iv[1]
  269. @iv[2] = pkmn.iv[2]
  270. @iv[3] = pkmn.iv[3]
  271. @iv[4] = pkmn.iv[4]
  272. @iv[5] = pkmn.iv[5]
  273. end
  274.  
  275. def pbInitBlank
  276. @name = ""
  277. @species = 0
  278. @level = 0
  279. @hp = 0
  280. @totalhp = 0
  281. @gender = 0
  282. @ability = 0
  283. @type1 = 0
  284. @type2 = 0
  285. @form = 0
  286. @attack = 0
  287. @defense = 0
  288. @speed = 0
  289. @spatk = 0
  290. @spdef = 0
  291. @status = 0
  292. @statusCount = 0
  293. @pokemon = nil
  294. @pokemonIndex = -1
  295. @participants = []
  296. @moves = [nil,nil,nil,nil]
  297. @iv = [0,0,0,0,0,0]
  298. @item = 0
  299. @weight = nil
  300. end
  301.  
  302. def pbInitPermanentEffects
  303. # These effects are always retained even if a Pokémon is replaced
  304. @effects[PBEffects::FutureSight] = 0
  305. @effects[PBEffects::FutureSightMove] = 0
  306. @effects[PBEffects::FutureSightUser] = -1
  307. @effects[PBEffects::FutureSightUserPos] = -1
  308. @effects[PBEffects::HealingWish] = false
  309. @effects[PBEffects::LunarDance] = false
  310. @effects[PBEffects::Wish] = 0
  311. @effects[PBEffects::WishAmount] = 0
  312. @effects[PBEffects::WishMaker] = -1
  313. end
  314.  
  315. def pbInitEffects(batonpass)
  316. if !batonpass
  317. # These effects are retained if Baton Pass is used
  318. @stages[PBStats::ATTACK] = 0
  319. @stages[PBStats::DEFENSE] = 0
  320. @stages[PBStats::SPEED] = 0
  321. @stages[PBStats::SPATK] = 0
  322. @stages[PBStats::SPDEF] = 0
  323. @stages[PBStats::EVASION] = 0
  324. @stages[PBStats::ACCURACY] = 0
  325. @lastMoveUsedSketch = -1
  326. @effects[PBEffects::AquaRing] = false
  327. @effects[PBEffects::Confusion] = 0
  328. @effects[PBEffects::Curse] = false
  329. @effects[PBEffects::Embargo] = 0
  330. @effects[PBEffects::FocusEnergy] = 0
  331. @effects[PBEffects::GastroAcid] = false
  332. @effects[PBEffects::HealBlock] = 0
  333. @effects[PBEffects::Ingrain] = false
  334. @effects[PBEffects::LeechSeed] = -1
  335. @effects[PBEffects::LockOn] = 0
  336. @effects[PBEffects::LockOnPos] = -1
  337. for i in 0...4
  338. next if [email protected][i]
  339. if @battle.battlers[i].effects[PBEffects::LockOnPos]==@index &&
  340. @battle.battlers[i].effects[PBEffects::LockOn]>0
  341. @battle.battlers[i].effects[PBEffects::LockOn]=0
  342. @battle.battlers[i].effects[PBEffects::LockOnPos]=-1
  343. end
  344. end
  345. @effects[PBEffects::MagnetRise] = 0
  346. @effects[PBEffects::PerishSong] = 0
  347. @effects[PBEffects::PerishSongUser] = -1
  348. @effects[PBEffects::PowerTrick] = false
  349. @effects[PBEffects::Substitute] = 0
  350. @effects[PBEffects::Telekinesis] = 0
  351. else
  352. if @effects[PBEffects::LockOn]>0
  353. @effects[PBEffects::LockOn]=2
  354. else
  355. @effects[PBEffects::LockOn]=0
  356. end
  357. if @effects[PBEffects::PowerTrick]
  358. @attack,@defense=@defense,@attack
  359. end
  360. end
  361. @damagestate.reset
  362. @fainted = false
  363. @lastAttacker = []
  364. @lastHPLost = 0
  365. @tookDamage = false
  366. @lastMoveUsed = -1
  367. @lastMoveUsedType = -1
  368. @lastRoundMoved = -1
  369. @movesUsed = []
  370. @turncount = 0
  371. @effects[PBEffects::Attract] = -1
  372. for i in 0...4
  373. next if [email protected][i]
  374. if @battle.battlers[i].effects[PBEffects::Attract]==@index
  375. @battle.battlers[i].effects[PBEffects::Attract]=-1
  376. end
  377. end
  378. @effects[PBEffects::BatonPass] = false
  379. @effects[PBEffects::Bide] = 0
  380. @effects[PBEffects::BideDamage] = 0
  381. @effects[PBEffects::BideTarget] = -1
  382. @effects[PBEffects::Charge] = 0
  383. @effects[PBEffects::ChoiceBand] = -1
  384. @effects[PBEffects::Counter] = -1
  385. @effects[PBEffects::CounterTarget] = -1
  386. @effects[PBEffects::DefenseCurl] = false
  387. @effects[PBEffects::DestinyBond] = false
  388. @effects[PBEffects::Disable] = 0
  389. @effects[PBEffects::DisableMove] = 0
  390. @effects[PBEffects::Electrify] = false
  391. @effects[PBEffects::Encore] = 0
  392. @effects[PBEffects::EncoreIndex] = 0
  393. @effects[PBEffects::EncoreMove] = 0
  394. @effects[PBEffects::Endure] = false
  395. @effects[PBEffects::FirstPledge] = 0
  396. @effects[PBEffects::FlashFire] = false
  397. @effects[PBEffects::Flinch] = false
  398. @effects[PBEffects::FollowMe] = 0
  399. @effects[PBEffects::Foresight] = false
  400. @effects[PBEffects::FuryCutter] = 0
  401. @effects[PBEffects::Grudge] = false
  402. @effects[PBEffects::HelpingHand] = false
  403. @effects[PBEffects::HyperBeam] = 0
  404. @effects[PBEffects::Illusion] = nil
  405. if self.hasWorkingAbility(:ILLUSION)
  406. if lastpoke!=@pokemonIndex
  407. @effects[PBEffects::Illusion] = @battle.pbParty(@index)[lastpoke]
  408. end
  409. end
  410. @effects[PBEffects::Imprison] = false
  411. @effects[PBEffects::KingsShield] = false
  412. @effects[PBEffects::LifeOrb] = false
  413. @effects[PBEffects::MagicCoat] = false
  414. @effects[PBEffects::MeanLook] = -1
  415. for i in 0...4
  416. next if [email protected][i]
  417. if @battle.battlers[i].effects[PBEffects::MeanLook]==@index
  418. @battle.battlers[i].effects[PBEffects::MeanLook]=-1
  419. end
  420. end
  421. @effects[PBEffects::MeFirst] = false
  422. @effects[PBEffects::Metronome] = 0
  423. @effects[PBEffects::MicleBerry] = false
  424. @effects[PBEffects::Minimize] = false
  425. @effects[PBEffects::MiracleEye] = false
  426. @effects[PBEffects::MirrorCoat] = -1
  427. @effects[PBEffects::MirrorCoatTarget] = -1
  428. @effects[PBEffects::MoveNext] = false
  429. @effects[PBEffects::MudSport] = false
  430. @effects[PBEffects::MultiTurn] = 0
  431. @effects[PBEffects::MultiTurnAttack] = 0
  432. @effects[PBEffects::MultiTurnUser] = -1
  433. for i in 0...4
  434. next if [email protected][i]
  435. if @battle.battlers[i].effects[PBEffects::MultiTurnUser]==@index
  436. @battle.battlers[i].effects[PBEffects::MultiTurn]=0
  437. @battle.battlers[i].effects[PBEffects::MultiTurnUser]=-1
  438. end
  439. end
  440. @effects[PBEffects::Nightmare] = false
  441. @effects[PBEffects::Outrage] = 0
  442. @effects[PBEffects::ParentalBond] = 0
  443. @effects[PBEffects::PickupItem] = 0
  444. @effects[PBEffects::PickupUse] = 0
  445. @effects[PBEffects::Pinch] = false
  446. @effects[PBEffects::Powder] = false
  447. @effects[PBEffects::Protect] = false
  448. @effects[PBEffects::ProtectNegation] = false
  449. @effects[PBEffects::ProtectRate] = 1
  450. @effects[PBEffects::Pursuit] = false
  451. @effects[PBEffects::Quash] = false
  452. @effects[PBEffects::Rage] = false
  453. @effects[PBEffects::Revenge] = 0
  454. @effects[PBEffects::Roar] = false
  455. @effects[PBEffects::Rollout] = 0
  456. @effects[PBEffects::Roost] = false
  457. @effects[PBEffects::SkipTurn] = false
  458. @effects[PBEffects::SkyDrop] = false
  459. @effects[PBEffects::SmackDown] = false
  460. @effects[PBEffects::Snatch] = false
  461. @effects[PBEffects::SpikyShield] = false
  462. @effects[PBEffects::Stockpile] = 0
  463. @effects[PBEffects::StockpileDef] = 0
  464. @effects[PBEffects::StockpileSpDef] = 0
  465. @effects[PBEffects::Taunt] = 0
  466. @effects[PBEffects::Torment] = false
  467. @effects[PBEffects::Toxic] = 0
  468. @effects[PBEffects::Transform] = false
  469. @effects[PBEffects::Truant] = false
  470. @effects[PBEffects::TwoTurnAttack] = 0
  471. @effects[PBEffects::Type3] = -1
  472. @effects[PBEffects::Unburden] = false
  473. @effects[PBEffects::Uproar] = 0
  474. @effects[PBEffects::Uturn] = false
  475. @effects[PBEffects::WaterSport] = false
  476. @effects[PBEffects::WeightChange] = 0
  477. @effects[PBEffects::Yawn] = 0
  478. end
  479.  
  480. def pbUpdate(fullchange=false)
  481. if @pokemon
  482. @pokemon.calcStats
  483. @level = @pokemon.level
  484. @hp = @pokemon.hp
  485. @totalhp = @pokemon.totalhp
  486. if !@effects[PBEffects::Transform]
  487. @attack = @pokemon.attack
  488. @defense = @pokemon.defense
  489. @speed = @pokemon.speed
  490. @spatk = @pokemon.spatk
  491. @spdef = @pokemon.spdef
  492. if fullchange
  493. @ability = @pokemon.ability
  494. @type1 = @pokemon.type1
  495. @type2 = @pokemon.type2
  496. end
  497. end
  498. end
  499. end
  500.  
  501. def pbInitialize(pkmn,index,batonpass)
  502. # Cure status of previous Pokemon with Natural Cure
  503. if self.hasWorkingAbility(:NATURALCURE)
  504. self.status=0
  505. end
  506. if self.hasWorkingAbility(:REGENERATOR)
  507. self.pbRecoverHP((totalhp/3).floor)
  508. end
  509. pbInitPokemon(pkmn,index)
  510. pbInitEffects(batonpass)
  511. end
  512.  
  513. # Used only to erase the battler of a Shadow Pokémon that has been snagged.
  514. def pbReset
  515. @pokemon = nil
  516. @pokemonIndex = -1
  517. self.hp = 0
  518. pbInitEffects(false)
  519. # reset status
  520. self.status = 0
  521. self.statusCount = 0
  522. @fainted = true
  523. # reset choice
  524. @battle.choices[@index] = [0,0,nil,-1]
  525. return true
  526. end
  527.  
  528. # Update Pokémon who will gain EXP if this battler is defeated
  529. def pbUpdateParticipants
  530. return if self.isFainted? # can't update if already fainted
  531. if @battle.pbIsOpposing?(@index)
  532. found1=false
  533. found2=false
  534. for i in @participants
  535. found1=true if i==pbOpposing1.pokemonIndex
  536. found2=true if i==pbOpposing2.pokemonIndex
  537. end
  538. if !found1 && !pbOpposing1.isFainted?
  539. @participants[@participants.length]=pbOpposing1.pokemonIndex
  540. end
  541. if !found2 && !pbOpposing2.isFainted?
  542. @participants[@participants.length]=pbOpposing2.pokemonIndex
  543. end
  544. end
  545. end
  546.  
  547. ################################################################################
  548. # About this battler
  549. ################################################################################
  550. def pbThis(lowercase=false)
  551. if @battle.pbIsOpposing?(@index)
  552. if @battle.opponent
  553. return lowercase ? _INTL("{1} rival",self.name) : _INTL("{1} rival",self.name) # Le quité 'el' y 'El' a estas 3 líneas
  554. else
  555. return lowercase ? _INTL("{1} salvaje",self.name) : _INTL("{1} salvaje",self.name)
  556. end
  557. elsif @battle.pbOwnedByPlayer?(@index)
  558. return _INTL("{1}",self.name)
  559. else
  560. return lowercase ? _INTL("{1} aliado",self.name) : _INTL("{1} aliado",self.name)
  561. end
  562. end
  563.  
  564. def pbHasType?(type)
  565. ret=false
  566. if type.is_a?(Symbol) || type.is_a?(String)
  567. ret=isConst?(self.type1,PBTypes,type.to_sym) ||
  568. isConst?(self.type2,PBTypes,type.to_sym)
  569. if @effects[PBEffects::Type3]>=0
  570. ret|=isConst?(@effects[PBEffects::Type3],PBTypes,type.to_sym)
  571. end
  572. else
  573. ret=(self.type1==type || self.type2==type)
  574. if @effects[PBEffects::Type3]>=0
  575. ret|=(@effects[PBEffects::Type3]==type)
  576. end
  577. end
  578. return ret
  579. end
  580.  
  581. def pbHasMove?(id)
  582. if id.is_a?(String) || id.is_a?(Symbol)
  583. id=getID(PBMoves,id)
  584. end
  585. return false if !id || id==0
  586. for i in @moves
  587. return true if i.id==id
  588. end
  589. return false
  590. end
  591.  
  592. def pbHasMoveType?(type)
  593. if type.is_a?(String) || type.is_a?(Symbol)
  594. type=getID(PBTypes,type)
  595. end
  596. return false if !type || type<0
  597. for i in @moves
  598. return true if i.type==type
  599. end
  600. return false
  601. end
  602.  
  603. def pbHasMoveFunction?(code)
  604. return false if !code
  605. for i in @moves
  606. return true if i.function==code
  607. end
  608. return false
  609. end
  610.  
  611. def hasMovedThisRound?
  612. return false if !@lastRoundMoved
  613. end
  614.  
  615. def isFainted?
  616. return @hp<=0
  617. end
  618.  
  619. def hasMoldBreaker
  620. return true if hasWorkingAbility(:MOLDBREAKER) ||
  621. hasWorkingAbility(:TERAVOLT) ||
  622. hasWorkingAbility(:TURBOBLAZE)
  623. return false
  624. end
  625.  
  626. def hasWorkingAbility(ability,ignorefainted=false)
  627. return false if self.isFainted? && !ignorefainted
  628. return false if @effects[PBEffects::GastroAcid]
  629. return isConst?(@ability,PBAbilities,ability)
  630. end
  631.  
  632. def hasWorkingItem(item,ignorefainted=false)
  633. return false if self.isFainted? && !ignorefainted
  634. return false if @effects[PBEffects::Embargo]>0
  635. return false if @battle.field.effects[PBEffects::MagicRoom]>0
  636. return false if self.hasWorkingAbility(:KLUTZ,ignorefainted)
  637. return isConst?(@item,PBItems,item)
  638. end
  639.  
  640. def isAirborne?(ignoreability=false)
  641. return false if self.hasWorkingItem(:IRONBALL)
  642. return false if @effects[PBEffects::Ingrain]
  643. return false if @effects[PBEffects::SmackDown]
  644. return false if @battle.field.effects[PBEffects::Gravity]>0
  645. return true if self.pbHasType?(:FLYING) && !@effects[PBEffects::Roost]
  646. return true if self.hasWorkingAbility(:LEVITATE) && !ignoreability
  647. return true if self.hasWorkingItem(:AIRBALLOON)
  648. return true if @effects[PBEffects::MagnetRise]>0
  649. return true if @effects[PBEffects::Telekinesis]>0
  650. return false
  651. end
  652.  
  653. def pbSpeed()
  654. stagemul=[10,10,10,10,10,10,10,15,20,25,30,35,40]
  655. stagediv=[40,35,30,25,20,15,10,10,10,10,10,10,10]
  656. speed=@speed
  657. stage=@stages[PBStats::SPEED]+6
  658. speed=(speed*stagemul[stage]/stagediv[stage]).floor
  659. speedmult=0x1000
  660. case @battle.pbWeather
  661. when PBWeather::RAINDANCE, PBWeather::HEAVYRAIN
  662. speedmult=speedmult*2 if self.hasWorkingAbility(:SWIFTSWIM)
  663. when PBWeather::SUNNYDAY, PBWeather::HARSHSUN
  664. speedmult=speedmult*2 if self.hasWorkingAbility(:CHLOROPHYLL)
  665. when PBWeather::SANDSTORM
  666. speedmult=speedmult*2 if self.hasWorkingAbility(:SANDRUSH)
  667. end
  668. if self.hasWorkingAbility(:QUICKFEET) && self.status>0
  669. speedmult=(speedmult*1.5).round
  670. end
  671. if self.hasWorkingAbility(:UNBURDEN) && @effects[PBEffects::Unburden] &&
  672. self.item==0
  673. speedmult=speedmult*2
  674. end
  675. if self.hasWorkingAbility(:SLOWSTART) && self.turncount<=5
  676. speedmult=(speedmult/2).round
  677. end
  678. if self.hasWorkingItem(:MACHOBRACE) ||
  679. self.hasWorkingItem(:POWERWEIGHT) ||
  680. self.hasWorkingItem(:POWERBRACER) ||
  681. self.hasWorkingItem(:POWERBELT) ||
  682. self.hasWorkingItem(:POWERANKLET) ||
  683. self.hasWorkingItem(:POWERLENS) ||
  684. self.hasWorkingItem(:POWERBAND)
  685. speedmult=(speedmult/2).round
  686. end
  687. if self.hasWorkingItem(:CHOICESCARF)
  688. speedmult=(speedmult*1.5).round
  689. end
  690. if isConst?(self.item,PBItems,:IRONBALL)
  691. speedmult=(speedmult/2).round
  692. end
  693. if self.hasWorkingItem(:QUICKPOWDER) && isConst?(self.species,PBSpecies,:DITTO) &&
  694. !@effects[PBEffects::Transform]
  695. speedmult=speedmult*2
  696. end
  697. if self.pbOwnSide.effects[PBEffects::Tailwind]>0
  698. speedmult=speedmult*2
  699. end
  700. if self.pbOwnSide.effects[PBEffects::Swamp]>0
  701. speedmult=(speedmult/2).round
  702. end
  703. if self.status==PBStatuses::PARALYSIS && !self.hasWorkingAbility(:QUICKFEET)
  704. speedmult=(speedmult/4).round
  705. end
  706. if @battle.internalbattle && @battle.pbOwnedByPlayer?(@index) &&
  707. @battle.pbPlayer.numbadges>=BADGESBOOSTSPEED
  708. speedmult=(speedmult*1.1).round
  709. end
  710. speed=(speed*speedmult*1.0/0x1000).round
  711. return [speed,1].max
  712. end
  713.  
  714. ################################################################################
  715. # Change HP
  716. ################################################################################
  717. def pbReduceHP(amt,anim=false,registerDamage=true)
  718. if amt>=self.hp
  719. amt=self.hp
  720. elsif amt<1 && !self.isFainted?
  721. amt=1
  722. end
  723. oldhp=self.hp
  724. self.hp-=amt
  725. raise _INTL("PS menor a 0") if self.hp<0
  726. raise _INTL("PS mayor a los PS totales") if self.hp>@totalhp
  727. @battle.scene.pbHPChanged(self,oldhp,anim) if amt>0
  728. @tookDamage=true if amt>0 && registerDamage
  729. return amt
  730. end
  731.  
  732. def pbRecoverHP(amt,anim=false)
  733. if self.hp+amt>@totalhp
  734. elsif amt<1 && self.hp!=@totalhp
  735. amt=1
  736. end
  737. oldhp=self.hp
  738. self.hp+=amt
  739. raise _INTL("PS menor a 0") if self.hp<0
  740. raise _INTL("PS mayor a los PS totales") if self.hp>@totalhp
  741. @battle.scene.pbHPChanged(self,oldhp,anim) if amt>0
  742. return amt
  743. end
  744.  
  745. def pbFaint(showMessage=true)
  746. if !self.isFainted?
  747. PBDebug.log("!!!***No se puede debilitar con PS mayor a 0")
  748. return true
  749. end
  750. if @fainted
  751. # PBDebug.log("!!!***No se puede debilitar si ya está debilitado")
  752. return true
  753. end
  754. @battle.scene.pbFainted(self)
  755. pbInitEffects(false)
  756. # Reset status
  757. self.status=0
  758. self.statusCount=0
  759. if @pokemon && @battle.internalbattle
  760. @pokemon.changeHappiness("faint")
  761. end
  762. if self.isMega?
  763. @pokemon.makeUnmega
  764. end
  765. if self.isPrimal?
  766. @pokemon.makeUnprimal
  767. end
  768. @fainted=true
  769. # reset choice
  770. @battle.choices[@index]=[0,0,nil,-1]
  771. pbOwnSide.effects[PBEffects::LastRoundFainted][email protected]
  772. @battle.pbDisplayPaused(_INTL("¡{1} se ha debilitado!",pbThis)) if showMessage
  773. PBDebug.log("[Pokémon debilitado] #{pbThis}")
  774. return true
  775. end
  776. ################################################################################
  777. # Find other battlers/sides in relation to this battler
  778. ################################################################################
  779. # Returns the data structure for this battler's side
  780. def pbOwnSide
  781. return @battle.sides[@index&1] # Player: 0 and 2; Foe: 1 and 3
  782. end
  783.  
  784. # Returns the data structure for the opposing Pokémon's side
  785. def pbOpposingSide
  786. return @battle.sides[(@index&1)^1] # Player: 1 and 3; Foe: 0 and 2
  787. end
  788.  
  789. # Returns whether the position belongs to the opposing Pokémon's side
  790. def pbIsOpposing?(i)
  791. return (@index&1)!=(i&1)
  792. end
  793.  
  794. # Returns the battler's partner
  795. def pbPartner
  796. return @battle.battlers[(@index&1)|((@index&2)^2)]
  797. end
  798.  
  799. # Returns the battler's first opposing Pokémon
  800. def pbOpposing1
  801. return @battle.battlers[((@index&1)^1)]
  802. end
  803.  
  804. # Returns the battler's second opposing Pokémon
  805. def pbOpposing2
  806. return @battle.battlers[((@index&1)^1)+2]
  807. end
  808.  
  809. def pbOppositeOpposing
  810. return @battle.battlers[(@index^1)]
  811. end
  812.  
  813. def pbOppositeOpposing2
  814. return @battle.battlers[(@index^1)|((@index&2)^2)]
  815. end
  816.  
  817. def pbNonActivePokemonCount()
  818. count=0
  819. [email protected](self.index)
  820. for i in 0...party.length
  821. if (self.isFainted? || i!=self.pokemonIndex) &&
  822. (pbPartner.isFainted? || i!=self.pbPartner.pokemonIndex) &&
  823. party[i] && !party[i].isEgg? && party[i].hp>0
  824. count+=1
  825. end
  826. end
  827. return count
  828. end
  829.  
  830. ################################################################################
  831. # Forms
  832. ################################################################################
  833. def pbCheckForm
  834. return if @effects[PBEffects::Transform]
  835. return if self.isFainted?
  836. transformed=false
  837. # Forecast
  838. if isConst?(self.species,PBSpecies,:CASTFORM)
  839. if self.hasWorkingAbility(:FORECAST)
  840. case @battle.pbWeather
  841. when PBWeather::SUNNYDAY, PBWeather::HARSHSUN
  842. if self.form!=1
  843. self.form=1; transformed=true
  844. end
  845. when PBWeather::RAINDANCE, PBWeather::HEAVYRAIN
  846. if self.form!=2
  847. self.form=2; transformed=true
  848. end
  849. when PBWeather::HAIL
  850. if self.form!=3
  851. self.form=3; transformed=true
  852. end
  853. else
  854. if self.form!=0
  855. self.form=0; transformed=true
  856. end
  857. end
  858. else
  859. if self.form!=0
  860. self.form=0; transformed=true
  861. end
  862. end
  863. end
  864. # Cherrim
  865. if isConst?(self.species,PBSpecies,:CHERRIM)
  866. if self.hasWorkingAbility(:FLOWERGIFT) &&
  867. (@battle.pbWeather==PBWeather::SUNNYDAY ||
  868. @battle.pbWeather==PBWeather::HARSHSUN)
  869. if self.form!=1
  870. self.form=1; transformed=true
  871. end
  872. else
  873. if self.form!=0
  874. self.form=0; transformed=true
  875. end
  876. end
  877. end
  878. # Shaymin
  879. if isConst?(self.species,PBSpecies,:SHAYMIN)
  880. transformed=true
  881. end
  882. end
  883. # Giratina
  884. if isConst?(self.species,PBSpecies,:GIRATINA)
  885. transformed=true
  886. end
  887. end
  888. # Arceus
  889. if isConst?(self.ability,PBAbilities,:MULTITYPE) &&
  890. isConst?(self.species,PBSpecies,:ARCEUS)
  891. transformed=true
  892. end
  893. end
  894. # Zen Mode
  895. if isConst?(self.species,PBSpecies,:DARMANITAN)
  896. if self.hasWorkingAbility(:ZENMODE) && @hp<=((@totalhp/2).floor)
  897. if self.form!=1
  898. self.form=1; transformed=true
  899. end
  900. else
  901. if self.form!=0
  902. self.form=0; transformed=true
  903. end
  904. end
  905. end
  906. # Keldeo
  907. if isConst?(self.species,PBSpecies,:KELDEO)
  908. transformed=true
  909. end
  910. end
  911. # Genesect
  912. if isConst?(self.species,PBSpecies,:GENESECT)
  913. transformed=true
  914. end
  915. end
  916. if transformed
  917. pbUpdate(true)
  918. @battle.scene.pbChangePokemon(self,@pokemon)
  919. @battle.pbDisplay(_INTL("¡{1} se ha transformado!",pbThis))
  920. PBDebug.log("[Cambio de forma] #{pbThis} cambió a forma #{self.form}")
  921. end
  922. end
  923.  
  924. def pbResetForm
  925. if !@effects[PBEffects::Transform]
  926. if isConst?(self.species,PBSpecies,:CASTFORM) ||
  927. isConst?(self.species,PBSpecies,:CHERRIM) ||
  928. isConst?(self.species,PBSpecies,:DARMANITAN) ||
  929. isConst?(self.species,PBSpecies,:MELOETTA) ||
  930. isConst?(self.species,PBSpecies,:AEGISLASH) ||
  931. isConst?(self.species,PBSpecies,:XERNEAS)
  932. self.form=0
  933. end
  934. end
  935. pbUpdate(true)
  936. end
  937.  
  938. ################################################################################
  939. # Efectos de las habilidades
  940. ################################################################################
  941. def pbAbilitiesOnSwitchIn(onactive)
  942. return if self.isFainted?
  943. if onactive
  944. @battle.pbPrimalReversion(self.index)
  945. end
  946. # Clima
  947. if onactive
  948. # Mar del Albor
  949. if self.hasWorkingAbility(:PRIMORDIALSEA) && @battle.weather!=PBWeather::HEAVYRAIN
  950. @battle.weather=PBWeather::HEAVYRAIN # Diluvio
  951. @battle.weatherduration=-1
  952. @battle.pbCommonAnimation("HeavyRain",nil,nil)
  953. @battle.pbDisplay(_INTL("¡{2} de {1} hizo diluviar!",pbThis,PBAbilities.getName(self.ability)))
  954. PBDebug.log("[Habilidad disparada] Mar del Albor de #{pbThis} hizo diluviar")
  955. end
  956. # Tierra del Ocaso
  957. if self.hasWorkingAbility(:DESOLATELAND) && @battle.weather!=PBWeather::HARSHSUN
  958. @battle.weather=PBWeather::HARSHSUN # Sol realmente abrazador
  959. @battle.weatherduration=-1
  960. @battle.pbCommonAnimation("HarshSun",nil,nil)
  961. @battle.pbDisplay(_INTL("¡{2} de {1} volvió al sol realmente abrasador!",pbThis,PBAbilities.getName(self.ability)))
  962. PBDebug.log("[Habilidad disparada] Tierra del Ocaso de #{pbThis} volvió al sol realmente abrasador")
  963. end
  964. # Ráfaga Delta
  965. if self.hasWorkingAbility(:DELTASTREAM) && @battle.weather!=PBWeather::STRONGWINDS
  966. @battle.weather=PBWeather::STRONGWINDS # Turbulencias misteriosas
  967. @battle.weatherduration=-1
  968. @battle.pbCommonAnimation("StrongWinds",nil,nil)
  969. @battle.pbDisplay(_INTL("¡{2} de {1} causó unas misteriosas turbulencias que protegen a los Pokémon de tipo Volador!",pbThis,PBAbilities.getName(self.ability)))
  970. PBDebug.log("[Habilidad disparada] Ráfaga Delta de #{pbThis} causó unas misteriosas turbulencias")
  971. end
  972. if @battle.weather!=PBWeather::HEAVYRAIN &&
  973. @battle.weather!=PBWeather::HARSHSUN &&
  974. @battle.weather!=PBWeather::STRONGWINDS
  975. # Habilidad: Llovizna - Tiempo: Danza Lluvia (Lluvia)
  976. if self.hasWorkingAbility(:DRIZZLE) && (@battle.weather!=PBWeather::RAINDANCE || @battle.weatherduration!=-1)
  977. @battle.weather=PBWeather::RAINDANCE
  978. if USENEWBATTLEMECHANICS
  979. @battle.weatherduration=5
  980. @battle.weatherduration=8 if hasWorkingItem(:DAMPROCK)
  981. else
  982. @battle.weatherduration=-1
  983. end
  984. @battle.pbCommonAnimation("Rain",nil,nil)
  985. @battle.pbDisplay(_INTL("¡{2} de {1} hizo llover!",pbThis,PBAbilities.getName(self.ability)))
  986. PBDebug.log("[Habilidad disparada] Llovizna de #{pbThis} hizo llover")
  987. end
  988. # Habilidad: Sequía - Tiempo: Día Soleado (Sol pega fuerte)
  989. if self.hasWorkingAbility(:DROUGHT) && (@battle.weather!=PBWeather::SUNNYDAY || @battle.weatherduration!=-1)
  990. @battle.weather=PBWeather::SUNNYDAY
  991. if USENEWBATTLEMECHANICS
  992. @battle.weatherduration=5
  993. @battle.weatherduration=8 if hasWorkingItem(:HEATROCK)
  994. else
  995. @battle.weatherduration=-1
  996. end
  997. @battle.pbCommonAnimation("Sunny",nil,nil)
  998. @battle.pbDisplay(_INTL("¡{2} de {1} intensificó los rayos del sol!",pbThis,PBAbilities.getName(self.ability)))
  999. PBDebug.log("[Habilidad disparada] Sequía de #{pbThis} aumentó la intensidad del sol")
  1000. end
  1001. # Habilidad: Chorro Arena - Tiempo: Tormenta de Arena
  1002. if self.hasWorkingAbility(:SANDSTREAM) && (@battle.weather!=PBWeather::SANDSTORM || @battle.weatherduration!=-1)
  1003. @battle.weather=PBWeather::SANDSTORM
  1004. if USENEWBATTLEMECHANICS
  1005. @battle.weatherduration=5
  1006. @battle.weatherduration=8 if hasWorkingItem(:SMOOTHROCK)
  1007. else
  1008. @battle.weatherduration=-1
  1009. end
  1010. @battle.pbCommonAnimation("Sandstorm",nil,nil)
  1011. @battle.pbDisplay(_INTL("¡{2} de {1} levantó una tormenta de arena!",pbThis,PBAbilities.getName(self.ability)))
  1012. PBDebug.log("[Habilidad disparada] Chorro Arena de #{pbThis} levantó una tormenta de arena")
  1013. end
  1014. # Habilidad Nevada: - Tiempo: Granizo
  1015. if self.hasWorkingAbility(:SNOWWARNING) && (@battle.weather!=PBWeather::HAIL || @battle.weatherduration!=-1)
  1016. @battle.weather=PBWeather::HAIL
  1017. if USENEWBATTLEMECHANICS
  1018. @battle.weatherduration=5
  1019. @battle.weatherduration=8 if hasWorkingItem(:ICYROCK)
  1020. else
  1021. @battle.weatherduration=-1
  1022. end
  1023. @battle.pbCommonAnimation("Hail",nil,nil)
  1024. @battle.pbDisplay(_INTL("¡{2} de {1} provocó granizo!",pbThis,PBAbilities.getName(self.ability)))
  1025. PBDebug.log("[Habilidad disparada] Nevada de #{pbThis} provocó granizo")
  1026. end
  1027. end
  1028. # Bucle Aire y Aclimatación
  1029. if self.hasWorkingAbility(:AIRLOCK) ||
  1030. self.hasWorkingAbility(:CLOUDNINE)
  1031. @battle.pbDisplay(_INTL("¡{1} tiene {2}!",pbThis,PBAbilities.getName(self.ability)))
  1032. @battle.pbDisplay(_INTL("El tiempo atmosférico ya no ejerce ninguna influencia."))
  1033. end
  1034. end
  1035. @battle.pbPrimordialWeather
  1036. # Trace / Rastro
  1037. if self.hasWorkingAbility(:TRACE)
  1038. choices=[]
  1039. for i in 0...4
  1040. if pbIsOpposing?(i) && !foe.isFainted?
  1041. abil=foe.ability
  1042. if abil>0 &&
  1043. !isConst?(abil,PBAbilities,:TRACE) &&
  1044. !isConst?(abil,PBAbilities,:MULTITYPE) &&
  1045. !isConst?(abil,PBAbilities,:ILLUSION) &&
  1046. !isConst?(abil,PBAbilities,:FLOWERGIFT) &&
  1047. !isConst?(abil,PBAbilities,:IMPOSTER) &&
  1048. !isConst?(abil,PBAbilities,:STANCECHANGE)
  1049. choices.push(i)
  1050. end
  1051. end
  1052. end
  1053. if choices.length>0
  1054. choice=choices[@battle.pbRandom(choices.length)]
  1055. [email protected][choice].pbThis(true)
  1056. [email protected][choice].ability
  1057. @ability=battlerability
  1058. abilityname=PBAbilities.getName(battlerability)
  1059. @battle.pbDisplay(_INTL("¡{1} ha copiado la habilidad {3} de {2}!",pbThis,battlername,abilityname))
  1060. PBDebug.log("[Habilidad disparada] Rastro de #{pbThis} se convirtió en #{abilityname} de #{battlername}")
  1061. end
  1062. end
  1063. # Intimidate / Intimidación
  1064. if self.hasWorkingAbility(:INTIMIDATE) && onactive
  1065. PBDebug.log("[Habilidad disparada] Intimidación de #{pbThis}")
  1066. for i in 0...4
  1067. if pbIsOpposing?(i) && [email protected][i].isFainted?
  1068. @battle.battlers[i].pbReduceAttackStatIntimidate(self)
  1069. end
  1070. end
  1071. end
  1072. # Download / Descarga
  1073. if self.hasWorkingAbility(:DOWNLOAD) && onactive
  1074. odef=ospdef=0
  1075. if pbOpposing1 && !pbOpposing1.isFainted?
  1076. odef+=pbOpposing1.defense
  1077. ospdef+=pbOpposing1.spdef
  1078. end
  1079. if pbOpposing2 && !pbOpposing2.isFainted?
  1080. odef+=pbOpposing2.defense
  1081. ospdef+=pbOpposing1.spdef
  1082. end
  1083. if ospdef>odef
  1084. if pbIncreaseStatWithCause(PBStats::ATTACK,1,self,PBAbilities.getName(ability))
  1085. PBDebug.log("[Habilidad disparada] Descarga de #{pbThis} (sube el Ataque)")
  1086. end
  1087. else
  1088. if pbIncreaseStatWithCause(PBStats::SPATK,1,self,PBAbilities.getName(ability))
  1089. PBDebug.log("[Habilidad disparada] Descarga de #{pbThis} (sube el Ataque Especial)")
  1090. end
  1091. end
  1092. end
  1093. # Frisk / Cacheo
  1094. if self.hasWorkingAbility(:FRISK) && @battle.pbOwnedByPlayer?(@index) && onactive
  1095. foes=[]
  1096. foes.push(pbOpposing1) if pbOpposing1.item>0 && !pbOpposing1.isFainted?
  1097. foes.push(pbOpposing2) if pbOpposing2.item>0 && !pbOpposing2.isFainted?
  1098. if USENEWBATTLEMECHANICS
  1099. PBDebug.log("[Habilidad disparada] Cacheo de #{pbThis}") if foes.length>0
  1100. for i in foes
  1101. itemname=PBItems.getName(i.item)
  1102. @battle.pbDisplay(_INTL("¡{1} cacheó a {2} y encontró {3}!",pbThis,i.pbThis(true),itemname))
  1103. end
  1104. elsif foes.length>0
  1105. PBDebug.log("[Habilidad disparada] Cacheo de #{pbThis}")
  1106. foe=foes[@battle.pbRandom(foes.length)]
  1107. itemname=PBItems.getName(foe.item)
  1108. @battle.pbDisplay(_INTL("¡{1} cacheó a su rival y encontró {2}!",pbThis,itemname))
  1109. end
  1110. end
  1111. # Anticipation / Anticipación
  1112. if self.hasWorkingAbility(:ANTICIPATION) && @battle.pbOwnedByPlayer?(@index) && onactive
  1113. PBDebug.log("[Habilidad disparada] #{pbThis} tiene Anticipación")
  1114. found=false
  1115. for foe in [pbOpposing1,pbOpposing2]
  1116. next if foe.isFainted?
  1117. for j in foe.moves
  1118. movedata=PBMoveData.new(j.id)
  1119. eff=PBTypes.getCombinedEffectiveness(movedata.type,type1,type2,@effects[PBEffects::Type3])
  1120. if (movedata.basedamage>0 && eff>8) ||
  1121. (movedata.function==0x70 && eff>0) # OHKO
  1122. found=true
  1123. break
  1124. end
  1125. end
  1126. break if found
  1127. end
  1128. @battle.pbDisplay(_INTL("¡Anticipación de {1} le hizo estremecerse!",pbThis)) if found
  1129. end
  1130. # Forewarn / Alerta
  1131. if self.hasWorkingAbility(:FOREWARN) && @battle.pbOwnedByPlayer?(@index) && onactive
  1132. PBDebug.log("[Habilidad disparada] #{pbThis} tiene Alerta")
  1133. highpower=0
  1134. fwmoves=[]
  1135. for foe in [pbOpposing1,pbOpposing2]
  1136. next if foe.isFainted?
  1137. for j in foe.moves
  1138. movedata=PBMoveData.new(j.id)
  1139. power=movedata.basedamage
  1140. power=160 if movedata.function==0x70 # OHKO
  1141. power=150 if movedata.function==0x8B # Eruption
  1142. power=120 if movedata.function==0x71 || # Counter
  1143. movedata.function==0x72 || # Mirror Coat
  1144. movedata.function==0x73 || # Metal Burst
  1145. power=80 if movedata.function==0x6A || # SonicBoom
  1146. movedata.function==0x6B || # Dragon Rage
  1147. movedata.function==0x6D || # Night Shade
  1148. movedata.function==0x6E || # Endeavor
  1149. movedata.function==0x6F || # Psywave
  1150. movedata.function==0x89 || # Return
  1151. movedata.function==0x8A || # Frustration
  1152. movedata.function==0x8C || # Crush Grip
  1153. movedata.function==0x8D || # Gyro Ball
  1154. movedata.function==0x90 || # Hidden Power
  1155. movedata.function==0x96 || # Natural Gift
  1156. movedata.function==0x97 || # Trump Card
  1157. movedata.function==0x98 || # Flail
  1158. movedata.function==0x9A # Grass Knot
  1159. if power>highpower
  1160. fwmoves=[j.id]; highpower=power
  1161. elsif power==highpower
  1162. fwmoves.push(j.id)
  1163. end
  1164. end
  1165. end
  1166. if fwmoves.length>0
  1167. fwmove=fwmoves[@battle.pbRandom(fwmoves.length)]
  1168. movename=PBMoves.getName(fwmove)
  1169. @battle.pbDisplay(_INTL("¡Alerta de {1} detectó {2}!",pbThis,movename))
  1170. end
  1171. end
  1172. # Mensaje de Presión
  1173. if self.hasWorkingAbility(:PRESSURE) && onactive
  1174. @battle.pbDisplay(_INTL("¡{1} ejerce su Presión!",pbThis))
  1175. end
  1176. # Mensaje de Rompemoldes
  1177. if self.hasWorkingAbility(:MOLDBREAKER) && onactive
  1178. @battle.pbDisplay(_INTL("¡{1} ha usado rompemoldes!",pbThis))
  1179. end
  1180. # Mensaje de Turbollama
  1181. if self.hasWorkingAbility(:TURBOBLAZE) && onactive
  1182. @battle.pbDisplay(_INTL("¡{1} desprende un aura llameante!",pbThis))
  1183. end
  1184. # Mensaje de Terravoltaje
  1185. if self.hasWorkingAbility(:TERAVOLT) && onactive
  1186. @battle.pbDisplay(_INTL("¡{1} desprende un aura electrizante!",pbThis))
  1187. end
  1188. # Mensaje de Aura Oscura
  1189. if self.hasWorkingAbility(:DARKAURA) && onactive
  1190. @battle.pbDisplay(_INTL("¡{1} iradia un aura oscura!",pbThis))
  1191. end
  1192. # Mensaje de Aura Feérica
  1193. if self.hasWorkingAbility(:FAIRYAURA) && onactive
  1194. @battle.pbDisplay(_INTL("¡{1} iradia un aura feérica!",pbThis))
  1195. end
  1196. # Mensaje de Rompeaura
  1197. if self.hasWorkingAbility(:AURABREAK) && onactive
  1198. @battle.pbDisplay(_INTL("¡{1} revierte las auras de todos los demás Pokémon!",pbThis))
  1199. end
  1200. # Imposter / Impostor
  1201. if self.hasWorkingAbility(:IMPOSTER) && !@effects[PBEffects::Transform] && onactive
  1202. choice=pbOppositeOpposing
  1203. blacklist=[
  1204. 0xC9, # Fly
  1205. 0xCA, # Dig
  1206. 0xCB, # Dive
  1207. 0xCC, # Bounce
  1208. 0xCD, # Shadow Force
  1209. 0xCE, # Sky Drop
  1210. 0x14D # Phantom Force
  1211. ]
  1212. if choice.effects[PBEffects::Transform] ||
  1213. choice.effects[PBEffects::Illusion] ||
  1214. choice.effects[PBEffects::Substitute]>0 ||
  1215. choice.effects[PBEffects::SkyDrop] ||
  1216. blacklist.include?(PBMoveData.new(choice.effects[PBEffects::TwoTurnAttack]).function)
  1217. PBDebug.log("[Habilidad disparada] Impostor de #{pbThis} no logró la transformación")
  1218. else
  1219. PBDebug.log("[Habilidad disparada] Impostor de #{pbThis}")
  1220. @battle.pbAnimation(getConst(PBMoves,:TRANSFORM),self,choice)
  1221. @effects[PBEffects::Transform]=true
  1222. @type1=choice.type1
  1223. @type2=choice.type2
  1224. @effects[PBEffects::Type3]=-1
  1225. @ability=choice.ability
  1226. @attack=choice.attack
  1227. @defense=choice.defense
  1228. @speed=choice.speed
  1229. @spatk=choice.spatk
  1230. @spdef=choice.spdef
  1231. for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,
  1232. PBStats::SPATK,PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
  1233. @stages[i]=choice.stages[i]
  1234. end
  1235. for i in 0...4
  1236. @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(choice.moves[i].id))
  1237. @moves[i].pp=5
  1238. @moves[i].totalpp=5
  1239. end
  1240. @effects[PBEffects::Disable]=0
  1241. @effects[PBEffects::DisableMove]=0
  1242. @battle.pbDisplay(_INTL("¡{1} se transformó en {2}!",pbThis,choice.pbThis(true)))
  1243. PBDebug.log("[Pokémon transformado] #{pbThis} se transformó en #{choice.pbThis(true)}")
  1244. end
  1245. end
  1246. # Mensaje del Globo Helio
  1247. if self.hasWorkingItem(:AIRBALLOON) && onactive
  1248. @battle.pbDisplay(_INTL("¡{1} está flotando en el aire gracias a su {2}!",pbThis,PBItems.getName(self.item)))
  1249. end
  1250. end
  1251.  
  1252. def pbEffectsOnDealingDamage(move,user,target,damage)
  1253. movetype=move.pbType(move.type,user,target)
  1254. if damage>0 && move.isContactMove?
  1255. if !target.damagestate.substitute
  1256. if target.hasWorkingItem(:STICKYBARB,true) && user.item==0 && !user.isFainted? # Toxiestrella
  1257. user.item=target.item
  1258. target.item=0
  1259. target.effects[PBEffects::Unburden]=true
  1260. if user.pokemon.itemInitial==0 && target.pokemon.itemInitial==user.item
  1261. user.pokemon.itemInitial=user.item
  1262. target.pokemon.itemInitial=0
  1263. end
  1264. end
  1265. @battle.pbDisplay(_INTL("¡{2} de {1} fue transferida a {3}!",
  1266. target.pbThis,PBItems.getName(user.item),user.pbThis(true)))
  1267. PBDebug.log("[Objeto disparado] Toxiestrella de #{target.pbThis} fue pasada a #{user.pbThis(true)}")
  1268. end
  1269. if target.hasWorkingItem(:ROCKYHELMET,true) && !user.isFainted? # Casco Dentado
  1270. if !user.hasWorkingAbility(:MAGICGUARD)
  1271. PBDebug.log("[Objeto disparado] Casco Dentado de #{target.pbThis}")
  1272. @battle.scene.pbDamageAnimation(user,0)
  1273. user.pbReduceHP((user.totalhp/6).floor)
  1274. @battle.pbDisplay(_INTL("¡{1} fue dañado por {2}!",user.pbThis,
  1275. PBItems.getName(target.item)))
  1276. end
  1277. end
  1278. if target.hasWorkingAbility(:AFTERMATH,true) && target.isFainted? && # Resquicio
  1279. !user.isFainted?
  1280. if [email protected](:DAMP) &&
  1281. !user.hasMoldBreaker && !user.hasWorkingAbility(:MAGICGUARD)
  1282. PBDebug.log("[Habilidad disparada] Resquicio de #{target.pbThis}")
  1283. @battle.scene.pbDamageAnimation(user,0)
  1284. user.pbReduceHP((user.totalhp/4).floor)
  1285. @battle.pbDisplay(_INTL("¡{1} fue dañado por Resquicio del rival!",user.pbThis))
  1286. end
  1287. end
  1288. if target.hasWorkingAbility(:CUTECHARM) && @battle.pbRandom(10)<3 # Gran Encanto
  1289. if !user.isFainted? && user.pbCanAttract?(target,false)
  1290. PBDebug.log("[Habilidad disparada] # Gran Encanto de #{target.pbThis}")
  1291. user.pbAttract(target,_INTL("¡{2} de {1} enamoró a {3}!",target.pbThis,
  1292. PBAbilities.getName(target.ability),user.pbThis(true)))
  1293. end
  1294. end
  1295. if target.hasWorkingAbility(:EFFECTSPORE,true) && @battle.pbRandom(10)<3 # Efecto Espora
  1296. if USENEWBATTLEMECHANICS &&
  1297. (user.pbHasType?(:GRASS) ||
  1298. user.hasWorkingAbility(:OVERCOAT) ||
  1299. user.hasWorkingItem(:SAFETYGOGGLES))
  1300. else
  1301. PBDebug.log("[Habilidad disparada] Efecto Espora de #{target.pbThis}")
  1302. case @battle.pbRandom(3)
  1303. when 0
  1304. if user.pbCanPoison?(nil,false)
  1305. user.pbPoison(target,_INTL("¡{2} de {1} envenenó a {3}!",target.pbThis,
  1306. PBAbilities.getName(target.ability),user.pbThis(true)))
  1307. end
  1308. when 1
  1309. if user.pbCanSleep?(nil,false)
  1310. user.pbSleep(_INTL("¡{2} de {1} durmió a {3}!",target.pbThis,
  1311. PBAbilities.getName(target.ability),user.pbThis(true)))
  1312. end
  1313. when 2
  1314. if user.pbCanParalyze?(nil,false)
  1315. user.pbParalyze(target,_INTL("¡{2} de {1} paralizó a {3}! ¡Quizás no pueda moverse!",
  1316. target.pbThis,PBAbilities.getName(target.ability),user.pbThis(true)))
  1317. end
  1318. end
  1319. end
  1320. end
  1321. if target.hasWorkingAbility(:FLAMEBODY,true) && @battle.pbRandom(10)<3 && # Cuerpo Llama
  1322. user.pbCanBurn?(nil,false)
  1323. PBDebug.log("[Habilidad disparada] Cuerpo Llama fr #{target.pbThis}")
  1324. user.pbBurn(target,_INTL("¡{2} de {1} quemó a {3}!",target.pbThis,
  1325. PBAbilities.getName(target.ability),user.pbThis(true)))
  1326. end
  1327. if target.hasWorkingAbility(:MUMMY,true) && !user.isFainted? # Momia
  1328. if !isConst?(user.ability,PBAbilities,:MULTITYPE) &&
  1329. !isConst?(user.ability,PBAbilities,:STANCECHANGE) &&
  1330. !isConst?(user.ability,PBAbilities,:MUMMY)
  1331. PBDebug.log("[Habilidad disparada] La habilidad Momia de #{target.pbThis} ha sido copiada en #{user.pbThis(true)}")
  1332. user.ability=getConst(PBAbilities,:MUMMY) || 0
  1333. @battle.pbDisplay(_INTL("¡{1} ha sido momificado por {2}!",
  1334. user.pbThis,target.pbThis(true)))
  1335. end
  1336. end
  1337. if target.hasWorkingAbility(:POISONPOINT,true) && @battle.pbRandom(10)<3 && # Punto Tóxico
  1338. user.pbCanPoison?(nil,false)
  1339. PBDebug.log("[Habilidad disparada] Punto Tóxico de #{target.pbThis}")
  1340. user.pbPoison(target,_INTL("¡{2} de {1} envenenó a {3}!",target.pbThis,
  1341. PBAbilities.getName(target.ability),user.pbThis(true)))
  1342. end
  1343. if (target.hasWorkingAbility(:ROUGHSKIN,true) || # Piel Tosca
  1344. target.hasWorkingAbility(:IRONBARBS,true)) && !user.isFainted?
  1345. if !user.hasWorkingAbility(:MAGICGUARD)
  1346. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(target.ability)} de #{target.pbThis}")
  1347. @battle.scene.pbDamageAnimation(user,0)
  1348. user.pbReduceHP((user.totalhp/8).floor)
  1349. @battle.pbDisplay(_INTL("¡{2} de {1} hirió a {3}!",target.pbThis,
  1350. PBAbilities.getName(target.ability),user.pbThis(true)))
  1351. end
  1352. end
  1353. if target.hasWorkingAbility(:STATIC,true) && @battle.pbRandom(10)<3 && # Electricidad Estática
  1354. user.pbCanParalyze?(nil,false)
  1355. PBDebug.log("[Habilidad disparada] Electricidad Estática de #{target.pbThis}")
  1356. user.pbParalyze(target,_INTL("¡{2} de {1} paralizó a {3}! ¡Quizás no pueda moverse!",
  1357. target.pbThis,PBAbilities.getName(target.ability),user.pbThis(true)))
  1358. end
  1359. if target.hasWorkingAbility(:GOOEY,true) # Baba
  1360. if user.pbReduceStatWithCause(PBStats::SPEED,1,target,PBAbilities.getName(target.ability))
  1361. PBDebug.log("[Habilidad disparada] Baba de #{target.pbThis}")
  1362. end
  1363. end
  1364. if user.hasWorkingAbility(:POISONTOUCH,true) && # Toque Tóxico
  1365. target.pbCanPoison?(nil,false) && @battle.pbRandom(10)<3
  1366. PBDebug.log("[Habilidad disparada] Toque Tóxico de #{user.pbThis}")
  1367. target.pbPoison(user,_INTL("¡{2} de {1} envenenó a {3}!",user.pbThis,
  1368. PBAbilities.getName(user.ability),target.pbThis(true)))
  1369. end
  1370. end
  1371. end
  1372. if damage>0
  1373. if !target.damagestate.substitute
  1374.  
  1375. if target.hasWorkingAbility(:CURSEDBODY,true) && @battle.pbRandom(10)<3 # Cuerpo Maldito
  1376. if user.effects[PBEffects::Disable]<=0 && move.pp>0 && !user.isFainted?
  1377. user.effects[PBEffects::Disable]=3
  1378. user.effects[PBEffects::DisableMove]=move.id
  1379. @battle.pbDisplay(_INTL("¡{2} de {1} ha desactivado el movimiento de {3}!",target.pbThis,
  1380. PBAbilities.getName(target.ability),user.pbThis(true)))
  1381. PBDebug.log("[Habilidad disparada] Cuerpo Maldito de #{target.pbThis} ha desactivado el movimiento de #{user.pbThis(true)}")
  1382. end
  1383. end
  1384. if target.hasWorkingAbility(:JUSTIFIED) && isConst?(movetype,PBTypes,:DARK) # Justiciero
  1385. if target.pbIncreaseStatWithCause(PBStats::ATTACK,1,target,PBAbilities.getName(target.ability))
  1386. PBDebug.log("[Habilidad disparada] Justiciero de #{target.pbThis}")
  1387. end
  1388. end
  1389. if target.hasWorkingAbility(:RATTLED) && # Cobardía
  1390. (isConst?(movetype,PBTypes,:BUG) ||
  1391. isConst?(movetype,PBTypes,:DARK) ||
  1392. isConst?(movetype,PBTypes,:GHOST))
  1393. if target.pbIncreaseStatWithCause(PBStats::SPEED,1,target,PBAbilities.getName(target.ability))
  1394. PBDebug.log("[Habilidad disparada] Cobardía de #{target.pbThis}")
  1395. end
  1396. end
  1397. if target.hasWorkingAbility(:WEAKARMOR) && move.pbIsPhysical?(movetype) # Armadura Frágil
  1398. if target.pbReduceStatWithCause(PBStats::DEFENSE,1,target,PBAbilities.getName(target.ability))
  1399. PBDebug.log("[Habilidad disparada] Armadura Frágil de #{target.pbThis} (baja Defensa)")
  1400. end
  1401. if target.pbIncreaseStatWithCause(PBStats::SPEED,1,target,PBAbilities.getName(target.ability))
  1402. PBDebug.log("[Habilidad disparada] Armadura Frágil de #{target.pbThis} (sube Velocidad)")
  1403. end
  1404. end
  1405. if target.hasWorkingItem(:AIRBALLOON,true) # Globo Helio
  1406. PBDebug.log("[Objeto disparado] Globo Helio de #{target.pbThis} ha reventado")
  1407. @battle.pbDisplay(_INTL("¡Ha explotado el Globo Helio de {1}!",target.pbThis))
  1408. target.pbConsumeItem(true,false)
  1409. elsif target.hasWorkingItem(:ABSORBBULB) && isConst?(movetype,PBTypes,:WATER) # Tubérculo
  1410. if target.pbIncreaseStatWithCause(PBStats::SPATK,1,target,PBItems.getName(target.item))
  1411. PBDebug.log("[Objeto disparado] #{PBItems.getName(target.item)} de #{target.pbThis}")
  1412. target.pbConsumeItem
  1413. end
  1414. elsif target.hasWorkingItem(:LUMINOUSMOSS) && isConst?(movetype,PBTypes,:WATER) # Musgo Brillante
  1415. if target.pbIncreaseStatWithCause(PBStats::SPDEF,1,target,PBItems.getName(target.item))
  1416. PBDebug.log("[Objeto disparado] #{PBItems.getName(target.item)} de #{target.pbThis}")
  1417. target.pbConsumeItem
  1418. end
  1419. elsif target.hasWorkingItem(:CELLBATTERY) && isConst?(movetype,PBTypes,:ELECTRIC) # Pila
  1420. if target.pbIncreaseStatWithCause(PBStats::ATTACK,1,target,PBItems.getName(target.item))
  1421. PBDebug.log("[Objeto disparado] #{PBItems.getName(target.item)} de #{target.pbThis}")
  1422. target.pbConsumeItem
  1423. end
  1424. elsif target.hasWorkingItem(:SNOWBALL) && isConst?(movetype,PBTypes,:ICE) # Bola de Nieve
  1425. if target.pbIncreaseStatWithCause(PBStats::ATTACK,1,target,PBItems.getName(target.item))
  1426. PBDebug.log("[Objeto disparado] #{PBItems.getName(target.item)} de #{target.pbThis}")
  1427. target.pbConsumeItem
  1428. end
  1429. elsif target.hasWorkingItem(:WEAKNESSPOLICY) && target.damagestate.typemod>8 # Seguro Debilidad
  1430. showanim=true
  1431. if target.pbIncreaseStatWithCause(PBStats::ATTACK,2,target,PBItems.getName(target.item),showanim)
  1432. PBDebug.log("[Objeto disparado] Seguro Debilidad de #{target.pbThis} (Ataque)")
  1433. showanim=false
  1434. end
  1435. if target.pbIncreaseStatWithCause(PBStats::SPATK,2,target,PBItems.getName(target.item),showanim)
  1436. PBDebug.log("[Objeto disparado] Seguro Debilidad de #{target.pbThis} (Ataque Especial)")
  1437. showanim=false
  1438. end
  1439. target.pbConsumeItem if !showanim
  1440. elsif target.hasWorkingItem(:ENIGMABERRY) && target.damagestate.typemod>8 # Baya Enigma
  1441. target.pbActivateBerryEffect
  1442. elsif (target.hasWorkingItem(:JABOCABERRY) && move.pbIsPhysical?(movetype)) || # Baya Jaboca
  1443. (target.hasWorkingItem(:ROWAPBERRY) && move.pbIsSpecial?(movetype)) # Baya Magua
  1444. if !user.hasWorkingAbility(:MAGICGUARD) && !user.isFainted? # Muro Mágico
  1445. PBDebug.log("[Objeto disparado] #{PBItems.getName(target.item)} de #{target.pbThis}")
  1446. @battle.scene.pbDamageAnimation(user,0)
  1447. user.pbReduceHP((user.totalhp/8).floor)
  1448. @battle.pbDisplay(_INTL("¡{1} usó su {2} y dañó a {3}!",target.pbThis,
  1449. PBItems.getName(target.item),user.pbThis(true)))
  1450. target.pbConsumeItem
  1451. end
  1452. elsif target.hasWorkingItem(:KEEBERRY) && move.pbIsPhysical?(movetype)
  1453. target.pbActivateBerryEffect
  1454. elsif target.hasWorkingItem(:MARANGABERRY) && move.pbIsSpecial?(movetype)
  1455. target.pbActivateBerryEffect
  1456. end
  1457. end
  1458. if target.hasWorkingAbility(:ANGERPOINT) # Irascible
  1459. if target.damagestate.critical && !target.damagestate.substitute &&
  1460. target.pbCanIncreaseStatStage?(PBStats::ATTACK,target)
  1461. PBDebug.log("[Habilidad disparada] Irascible de #{target.pbThis}")
  1462. target.stages[PBStats::ATTACK]=6
  1463. @battle.pbCommonAnimation("StatUp",target,nil)
  1464. @battle.pbDisplay(_INTL("¡{2} de {1} subió al máximo su {3}!",
  1465. target.pbThis,PBAbilities.getName(target.ability),PBStats.getName(PBStats::ATTACK)))
  1466. end
  1467. end
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473. #Arion final
  1474. if target.isConst?(target.species,PBSpecies,:ARION2) && target.isFainted? && target.form !=1
  1475. pbBGMPlay("Arya final theme",85,100)
  1476. @battle.pbDisplayPaused(_INTL("¡Arion ha perdido su barrera!"))
  1477. target.form = 1
  1478. target.pbUpdate(true) #la wea de genesect para cambiar de forma
  1479. @battle.scene.pbChangePokemon(target,target.pokemon) #la wea de zorua
  1480. target.pbRecoverHP(target.totalhp,true) #campana concha editado
  1481. target.pbCureStatus(false) #la wea de imunidad
  1482. @battle.pbLearnMove(:LAMENTACION)
  1483. @battle.pbLearnMove(:GRITOSDD)
  1484. @battle.pbLearnMove(:ARREPENTIMIENTO)
  1485. @battle.pbLearnMove(:PURGA)
  1486. pbWait(4)
  1487. @battle.pbDisplay(_INTL("¡Arión usa sus últimas fuerzas para menguar daños!"))
  1488. end
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498. end
  1499. user.pbAbilityCureCheck
  1500. target.pbAbilityCureCheck
  1501. end
  1502.  
  1503. def pbEffectsAfterHit(user,target,thismove,turneffects)
  1504. return if turneffects[PBEffects::TotalDamage]==0
  1505. if !(user.hasWorkingAbility(:SHEERFORCE) && thismove.addlEffect>0) # Potencia Bruta
  1506. # Objetos de objetivos:
  1507. # Tarjeta Roja
  1508. if target.hasWorkingItem(:REDCARD) && @battle.pbCanSwitch?(user.index,-1,false)
  1509. user.effects[PBEffects::Roar]=true
  1510. @battle.pbDisplay(_INTL("¡{1} ha sacado una {2} a {3}!",
  1511. target.pbThis,PBItems.getName(target.item),user.pbThis(true)))
  1512. target.pbConsumeItem
  1513. # Botón Escape
  1514. elsif target.hasWorkingItem(:EJECTBUTTON) && @battle.pbCanChooseNonActive?(target.index)
  1515. target.effects[PBEffects::Uturn]=true
  1516. @battle.pbDisplay(_INTL("¡{1} regresa gracias al {2}!",
  1517. target.pbThis,PBItems.getName(target.item)))
  1518. target.pbConsumeItem
  1519. end
  1520. # Objetos de usuario:
  1521. # Campana Concha
  1522. if user.hasWorkingItem(:SHELLBELL) && user.effects[PBEffects::HealBlock]==0
  1523. PBDebug.log("[Objeto disparado] #{user.pbThis}'s Shell Bell (total damage=#{turneffects[PBEffects::TotalDamage]})")
  1524. hpgain=user.pbRecoverHP((turneffects[PBEffects::TotalDamage]/8).floor,true)
  1525. if hpgain>0
  1526. @battle.pbDisplay(_INTL("¡{1} ha recuperado unos pocos PS con {2}!",
  1527. user.pbThis,PBItems.getName(user.item)))
  1528. end
  1529. end
  1530. # Vidasfera
  1531. if user.effects[PBEffects::LifeOrb] && !user.hasWorkingAbility(:MAGICGUARD)
  1532. PBDebug.log("[Objeto disparado] #{user.pbThis}'s Life Orb (recoil)")
  1533. hploss=user.pbReduceHP((user.totalhp/10).floor,true)
  1534. if hploss>0
  1535. @battle.pbDisplay(_INTL("¡{1} ha perdido algunos de sus PS!",user.pbThis))
  1536. end
  1537. end
  1538. user.pbFaint if user.isFainted? # no return
  1539. # Cambio Color
  1540. movetype=thismove.pbType(thismove.type,user,target)
  1541. if target.hasWorkingAbility(:COLORCHANGE) &&
  1542. !PBTypes.isPseudoType?(movetype) && !target.pbHasType?(movetype)
  1543. PBDebug.log("[Habilidad disparada] Cambio Color de #{target.pbThis} cambió al tipo #{PBTypes.getName(movetype)}")
  1544. target.type1=movetype
  1545. target.type2=movetype
  1546. target.effects[PBEffects::Type3]=-1
  1547. @battle.pbDisplay(_INTL("¡{2} de {1} ha cambiado su tipo a {3}!",target.pbThis,
  1548. PBAbilities.getName(target.ability),PBTypes.getName(movetype)))
  1549. end
  1550. end
  1551. # Autoestima
  1552. if user.hasWorkingAbility(:MOXIE) && target.isFainted?
  1553. if user.pbIncreaseStatWithCause(PBStats::ATTACK,1,user,PBAbilities.getName(user.ability))
  1554. PBDebug.log("[Habilidad disparada] Autoestima de #{user.pbThis}")
  1555. end
  1556. end
  1557.  
  1558.  
  1559. # Prestidigitador
  1560. if user.hasWorkingAbility(:MAGICIAN)
  1561. if target.item>0 && user.item==0 &&
  1562. user.effects[PBEffects::Substitute]==0 &&
  1563. target.effects[PBEffects::Substitute]==0 &&
  1564. !target.hasWorkingAbility(:STICKYHOLD) &&
  1565. [email protected](target,target.item) &&
  1566. [email protected](user,target.item) &&
  1567. (@battle.opponent || [email protected]?(user.index))
  1568. user.item=target.item
  1569. target.item=0
  1570. target.effects[PBEffects::Unburden]=true
  1571. if [email protected] && # In a wild battle
  1572. user.pokemon.itemInitial==0 &&
  1573. target.pokemon.itemInitial==user.item
  1574. user.pokemon.itemInitial=user.item
  1575. target.pokemon.itemInitial=0
  1576. end
  1577. @battle.pbDisplay(_INTL("¡{1} le ha robado un {3} a {2} usando {4}!",user.pbThis,
  1578. target.pbThis(true),PBItems.getName(user.item),PBAbilities.getName(user.ability)))
  1579. PBDebug.log("[Habilidad disparada] Prestidigitador de #{user.pbThis} ha robado #{PBItems.getName(user.item)} de #{target.pbThis(true)}")
  1580. end
  1581. end
  1582. # Hurto
  1583. if target.hasWorkingAbility(:PICKPOCKET)
  1584. if target.item==0 && user.item>0 &&
  1585. user.effects[PBEffects::Substitute]==0 &&
  1586. target.effects[PBEffects::Substitute]==0 &&
  1587. !user.hasWorkingAbility(:STICKYHOLD) &&
  1588. [email protected](user,user.item) &&
  1589. [email protected](target,user.item) &&
  1590. (@battle.opponent || [email protected]?(target.index))
  1591. target.item=user.item
  1592. user.item=0
  1593. user.effects[PBEffects::Unburden]=true
  1594. if [email protected] && # In a wild battle
  1595. target.pokemon.itemInitial==0 &&
  1596. user.pokemon.itemInitial==target.item
  1597. target.pokemon.itemInitial=target.item
  1598. user.pokemon.itemInitial=0
  1599. end
  1600. @battle.pbDisplay(_INTL("¡{1} le ha robado un {3} a {2}!",target.pbThis,
  1601. user.pbThis(true),PBItems.getName(target.item)))
  1602. PBDebug.log("[Habilidad disparada] Hurto de #{target.pbThis} ha robado #{PBItems.getName(target.item)} de #{user.pbThis(true)}")
  1603. end
  1604. end
  1605. end
  1606.  
  1607. def pbAbilityCureCheck
  1608. return if self.isFainted?
  1609. case self.status
  1610. when PBStatuses::SLEEP
  1611. if self.hasWorkingAbility(:VITALSPIRIT) || self.hasWorkingAbility(:INSOMNIA)
  1612. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(@ability)} de #{pbThis}")
  1613. pbCureStatus(false)
  1614. @battle.pbDisplay(_INTL("¡{2} de {1} lo despertó!",pbThis,PBAbilities.getName(@ability)))
  1615. end
  1616. when PBStatuses::POISON
  1617. if self.hasWorkingAbility(:IMMUNITY)
  1618. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(@ability)} de #{pbThis}")
  1619. pbCureStatus(false)
  1620. @battle.pbDisplay(_INTL("¡{2} de {1} le curó el veneno!",pbThis,PBAbilities.getName(@ability)))
  1621. end
  1622. when PBStatuses::BURN
  1623. if self.hasWorkingAbility(:WATERVEIL)
  1624. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(@ability)} de #{pbThis}")
  1625. pbCureStatus(false)
  1626. @battle.pbDisplay(_INTL("¡{2} de {1} le curó la quemadura!",pbThis,PBAbilities.getName(@ability)))
  1627. end
  1628. when PBStatuses::PARALYSIS
  1629. if self.hasWorkingAbility(:LIMBER)
  1630. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(@ability)} de #{pbThis}")
  1631. pbCureStatus(false)
  1632. @battle.pbDisplay(_INTL("¡{2} de {1} le curó la parálisis!",pbThis,PBAbilities.getName(@ability)))
  1633. end
  1634. when PBStatuses::FROZEN
  1635. if self.hasWorkingAbility(:MAGMAARMOR)
  1636. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(@ability)} de #{pbThis}")
  1637. pbCureStatus(false)
  1638. @battle.pbDisplay(_INTL("¡{2} de {1} le permitió descongelarse!",pbThis,PBAbilities.getName(@ability)))
  1639. end
  1640. end
  1641. if @effects[PBEffects::Confusion]>0 && self.hasWorkingAbility(:OWNTEMPO)
  1642. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(@ability)} de #{pbThis} (attract)")
  1643. pbCureConfusion(false)
  1644. @battle.pbDisplay(_INTL("¡{2} de {1} le quitó su problema de confusión!",pbThis,PBAbilities.getName(@ability)))
  1645. end
  1646. if @effects[PBEffects::Attract]>=0 && self.hasWorkingAbility(:OBLIVIOUS)
  1647. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(@ability)} de #{pbThis}")
  1648. pbCureAttract
  1649. @battle.pbDisplay(_INTL("¡{2} de {1} le quitó el enamoramiento!",pbThis,PBAbilities.getName(@ability)))
  1650. end
  1651. if USENEWBATTLEMECHANICS && @effects[PBEffects::Taunt]>0 && self.hasWorkingAbility(:OBLIVIOUS)
  1652. PBDebug.log("[Habilidad disparada] #{PBAbilities.getName(@ability)} de #{pbThis} (taunt)")
  1653. @effects[PBEffects::Taunt]=0
  1654. @battle.pbDisplay(_INTL("¡{2} de {1} le quitó el enamoramiento!",pbThis,PBAbilities.getName(@ability)))
  1655. end
  1656. end
  1657.  
  1658. ################################################################################
  1659. # Held item effects / Efectos de objetos llevados
  1660. ################################################################################
  1661. def pbConsumeItem(recycle=true,pickup=true)
  1662. itemname=PBItems.getName(self.item)
  1663. @pokemon.itemRecycle=self.item if recycle
  1664. @pokemon.itemInitial=0 if @pokemon.itemInitial==self.item
  1665. if pickup
  1666. @effects[PBEffects::PickupItem]=self.item
  1667. @effects[PBEffects::PickupUse][email protected]
  1668. end
  1669. self.item=0
  1670. self.effects[PBEffects::Unburden]=true
  1671. # Simbiosis
  1672. if pbPartner && pbPartner.hasWorkingAbility(:SYMBIOSIS) && recycle
  1673. if pbPartner.item>0 &&
  1674. [email protected](pbPartner,pbPartner.item) &&
  1675. [email protected](self,pbPartner.item)
  1676. @battle.pbDisplay(_INTL("¡{2} de {1} permite compartir su {3} con {4}!",
  1677. pbPartner.pbThis,PBAbilities.getName(pbPartner.ability),
  1678. PBItems.getName(pbPartner.item),pbThis(true)))
  1679. self.item=pbPartner.item
  1680. pbPartner.item=0
  1681. pbPartner.effects[PBEffects::Unburden]=true
  1682. pbBerryCureCheck
  1683. end
  1684. end
  1685. end
  1686.  
  1687. def pbConfusionBerry(flavor,message1,message2)
  1688. amt=self.pbRecoverHP((self.totalhp/8).floor,true)
  1689. if amt>0
  1690. @battle.pbDisplay(message1)
  1691. if (self.nature%5)==flavor && (self.nature/5).floor!=(self.nature%5)
  1692. @battle.pbDisplay(message2)
  1693. pbConfuseSelf
  1694. end
  1695. return true
  1696. end
  1697. return false
  1698. end
  1699.  
  1700. def pbStatIncreasingBerry(stat,berryname)
  1701. return pbIncreaseStatWithCause(stat,1,self,berryname)
  1702. end
  1703.  
  1704. def pbActivateBerryEffect(berry=0,consume=true)
  1705. berry=self.item if berry==0
  1706. berryname=(berry==0) ? "" : PBItems.getName(berry)
  1707. PBDebug.log("[Objeto disparado] #{berryname} de #{pbThis}")
  1708. consumed=false
  1709. if isConst?(berry,PBItems,:ORANBERRY) # Baya Aranja
  1710. amt=self.pbRecoverHP(10,true)
  1711. if amt>0
  1712. @battle.pbDisplay(_INTL("¡{1} recuperó su salud usando una {2}!",pbThis,berryname))
  1713. consumed=true
  1714. end
  1715. elsif isConst?(berry,PBItems,:SITRUSBERRY) || # Baya Zidra
  1716. isConst?(berry,PBItems,:ENIGMABERRY) # Baya Enigma
  1717. amt=self.pbRecoverHP((self.totalhp/4).floor,true)
  1718. if amt>0
  1719. @battle.pbDisplay(_INTL("¡{1} recuperó su salud usando una {2}!",pbThis,berryname))
  1720. consumed=true
  1721. end
  1722. elsif isConst?(berry,PBItems,:CHESTOBERRY) # Baya Atania
  1723. if self.status==PBStatuses::SLEEP
  1724. pbCureStatus(false)
  1725. @battle.pbDisplay(_INTL("¡{1} se ha despertado gracias a la {2}!",pbThis,berryname))
  1726. consumed=true
  1727. end
  1728. elsif isConst?(berry,PBItems,:PECHABERRY) # Baya Meloc
  1729. if self.status==PBStatuses::POISON
  1730. pbCureStatus(false)
  1731. @battle.pbDisplay(_INTL("¡{1} se ha curado del envenenamiento gracias a la {2}!",pbThis,berryname))
  1732. consumed=true
  1733. end
  1734. elsif isConst?(berry,PBItems,:RAWSTBERRY) # Baya Safre
  1735. if self.status==PBStatuses::BURN
  1736. pbCureStatus(false)
  1737. @battle.pbDisplay(_INTL("¡{1} se ha curado la quemadura gracias a la {2}!",pbThis,berryname))
  1738. consumed=true
  1739. end
  1740. elsif isConst?(berry,PBItems,:CHERIBERRY) # Baya Zreza
  1741. if self.status==PBStatuses::PARALYSIS
  1742. pbCureStatus(false)
  1743. @battle.pbDisplay(_INTL("¡{1} se ha recuperado de la parálisis gracias a la {2}!",pbThis,berryname))
  1744. consumed=true
  1745. end
  1746. elsif isConst?(berry,PBItems,:ASPEARBERRY) # Baya Perasi
  1747. if self.status==PBStatuses::FROZEN
  1748. pbCureStatus(false)
  1749. @battle.pbDisplay(_INTL("¡{1} se ha descongelado gracias a la {2}!",pbThis,berryname))
  1750. consumed=true
  1751. end
  1752. elsif isConst?(berry,PBItems,:LEPPABERRY) # Baya Zanama
  1753. found=[]
  1754. if @pokemon.moves[i].id!=0
  1755. if (consume && @pokemon.moves[i].pp==0) ||
  1756. (!consume && @pokemon.moves[i].pp<@pokemon.moves[i].totalpp)
  1757. found.push(i)
  1758. end
  1759. end
  1760. end
  1761. if found.length>0
  1762. choice=(consume) ? found[0] : found[@battle.pbRandom(found.length)]
  1763. pokemove.pp+=10
  1764. pokemove.pp=pokemove.totalpp if pokemove.pp>pokemove.totalpp
  1765. self.moves[choice].pp=pokemove.pp
  1766. movename=PBMoves.getName(pokemove.id)
  1767. @battle.pbDisplay(_INTL("¡{1} ha restaurado los PP de {3} con {2}!",pbThis,berryname,movename))
  1768. consumed=true
  1769. end
  1770. elsif isConst?(berry,PBItems,:PERSIMBERRY) # Baya Caquic
  1771. if @effects[PBEffects::Confusion]>0
  1772. pbCureConfusion(false)
  1773. @battle.pbDisplay(_INTL("¡{1} se ha librado de la confusión gracias a la {2}!",pbThis,berryname))
  1774. consumed=true
  1775. end
  1776. elsif isConst?(berry,PBItems,:LUMBERRY) # Baya Ziuela
  1777. if self.status>0 || @effects[PBEffects::Confusion]>0
  1778. st=self.status; conf=(@effects[PBEffects::Confusion]>0)
  1779. pbCureStatus(false)
  1780. pbCureConfusion(false)
  1781. case st
  1782. when PBStatuses::SLEEP
  1783. @battle.pbDisplay(_INTL("¡{1} se ha despertado gracias a la {2}!",pbThis,berryname))
  1784. when PBStatuses::POISON
  1785. @battle.pbDisplay(_INTL("¡{1} se ha curado del envenenamiento gracias a la {2}!",pbThis,berryname))
  1786. when PBStatuses::BURN
  1787. @battle.pbDisplay(_INTL("¡{1} se ha curado la quemadura gracias a la {2}!",pbThis,berryname))
  1788. when PBStatuses::PARALYSIS
  1789. @battle.pbDisplay(_INTL("¡{1} se ha recuperado de la parálisis gracias a la {2}!",pbThis,berryname))
  1790. when PBStatuses::FROZEN
  1791. @battle.pbDisplay(_INTL("¡{1} se ha descongelado gracias a la {2}!",pbThis,berryname))
  1792. end
  1793. if conf
  1794. @battle.pbDisplay(_INTL("¡{1} se ha librado de la confusión gracias a la {2}!",pbThis,berryname))
  1795. end
  1796. consumed=true
  1797. end
  1798. elsif isConst?(berry,PBItems,:FIGYBERRY) # Baya Higog
  1799. consumed=pbConfusionBerry(0,
  1800. _INTL("¡{1} ha restaurado su salud con una {2}!",pbThis,berryname),
  1801. _INTL("¡La {2} estaba muy picante para {1}!",pbThis(true),berryname))
  1802. elsif isConst?(berry,PBItems,:WIKIBERRY) # Baya Wiki
  1803. consumed=pbConfusionBerry(3,
  1804. _INTL("¡{1} ha restaurado su salud con una {2}!",pbThis,berryname),
  1805. _INTL("¡La {2} estaba muy seca para {1}!",pbThis(true),berryname))
  1806. elsif isConst?(berry,PBItems,:MAGOBERRY) # Baya Ango
  1807. consumed=pbConfusionBerry(2,
  1808. _INTL("¡{1} ha restaurado su salud con una {2}!",pbThis,berryname),
  1809. _INTL("¡La {2} estaba muy dulce para {1}!",pbThis(true),berryname))
  1810. elsif isConst?(berry,PBItems,:AGUAVBERRY) # Baya Guaya
  1811. consumed=pbConfusionBerry(4,
  1812. _INTL("¡{1} ha restaurado su salud con una {2}!",pbThis,berryname),
  1813. _INTL("¡La {2} estaba muy amarga para {1}!",pbThis(true),berryname))
  1814. elsif isConst?(berry,PBItems,:IAPAPABERRY) # Baya Pabaya
  1815. consumed=pbConfusionBerry(1,
  1816. _INTL("¡{1} ha restaurado su salud con una {2}!",pbThis,berryname),
  1817. _INTL("¡La {2} estaba muy ácida para {1}!",pbThis(true),berryname))
  1818. elsif isConst?(berry,PBItems,:LIECHIBERRY) # Baya Lichi
  1819. consumed=pbStatIncreasingBerry(PBStats::ATTACK,berryname)
  1820. elsif isConst?(berry,PBItems,:GANLONBERRY) || # Baya Gonlan
  1821. isConst?(berry,PBItems,:KEEBERRY) # Baya Biglia
  1822. consumed=pbStatIncreasingBerry(PBStats::DEFENSE,berryname)
  1823. elsif isConst?(berry,PBItems,:SALACBERRY) # Baya Aslac
  1824. consumed=pbStatIncreasingBerry(PBStats::SPEED,berryname)
  1825. elsif isConst?(berry,PBItems,:PETAYABERRY) # Baya Yapati
  1826. consumed=pbStatIncreasingBerry(PBStats::SPATK,berryname)
  1827. elsif isConst?(berry,PBItems,:APICOTBERRY) || # Baya Aricoc
  1828. isConst?(berry,PBItems,:MARANGABERRY) # Baya Maranga
  1829. consumed=pbStatIncreasingBerry(PBStats::SPDEF,berryname)
  1830. elsif isConst?(berry,PBItems,:LANSATBERRY) # Baya Zonlan
  1831. if @effects[PBEffects::FocusEnergy]<2
  1832. @effects[PBEffects::FocusEnergy]=2
  1833. @battle.pbDisplay(_INTL("¡{1} se está preparando para luchar gracias a la {2}!",pbThis,berryname))
  1834. consumed=true
  1835. end
  1836. elsif isConst?(berry,PBItems,:MICLEBERRY) # Baya Lagro
  1837. if !@effects[PBEffects::MicleBerry]
  1838. @effects[PBEffects::MicleBerry]=true
  1839. @battle.pbDisplay(_INTL("¡{1} usará con mayor precisión del siguiente movimiento gracias a la {2}!",
  1840. pbThis,berryname))
  1841. consumed=true
  1842. end
  1843. elsif isConst?(berry,PBItems,:STARFBERRY)
  1844. stats=[]
  1845. for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPATK,PBStats::SPDEF,PBStats::SPEED]
  1846. stats.push(i) if pbCanIncreaseStatStage?(i,self)
  1847. end
  1848. if stats.length>0
  1849. stat=stats[@battle.pbRandom(stats.length)]
  1850. consumed=pbIncreaseStatWithCause(stat,2,self,berryname)
  1851. end
  1852. end
  1853. if consumed
  1854. # Carrillo
  1855. if hasWorkingAbility(:CHEEKPOUCH)
  1856. amt=self.pbRecoverHP((@totalhp/3).floor,true)
  1857. if amt>0
  1858. @battle.pbDisplay(_INTL("¡{2} de {1} ha restaurado algunos PS!",
  1859. pbThis,PBAbilities.getName(ability)))
  1860. end
  1861. end
  1862. pbConsumeItem if consume
  1863. self.pokemon.belch=true if self.pokemon
  1864. end
  1865. end
  1866.  
  1867. def pbBerryCureCheck(hpcure=false)
  1868. return if self.isFainted?
  1869. unnerver=(pbOpposing1.hasWorkingAbility(:UNNERVE) ||
  1870. pbOpposing2.hasWorkingAbility(:UNNERVE))
  1871. itemname=(self.item==0) ? "" : PBItems.getName(self.item)
  1872. if hpcure
  1873. if self.hasWorkingItem(:BERRYJUICE) && self.hp<=(self.totalhp/2).floor # Zumo de Baya
  1874. amt=self.pbRecoverHP(20,true)
  1875. if amt>0
  1876. @battle.pbCommonAnimation("UseItem",self,nil)
  1877. @battle.pbDisplay(_INTL("¡{1} ha restaurado su salud gracias a la {2}!",pbThis,itemname))
  1878. pbConsumeItem
  1879. return
  1880. end
  1881. end
  1882. end
  1883. if !unnerver
  1884. if hpcure
  1885. if self.hp<=(self.totalhp/2).floor
  1886. if self.hasWorkingItem(:ORANBERRY) ||
  1887. self.hasWorkingItem(:SITRUSBERRY)
  1888. pbActivateBerryEffect
  1889. return
  1890. end
  1891. if self.hasWorkingItem(:FIGYBERRY) ||
  1892. self.hasWorkingItem(:WIKIBERRY) ||
  1893. self.hasWorkingItem(:MAGOBERRY) ||
  1894. self.hasWorkingItem(:AGUAVBERRY) ||
  1895. self.hasWorkingItem(:IAPAPABERRY)
  1896. pbActivateBerryEffect
  1897. return
  1898. end
  1899. end
  1900. end
  1901. if (self.hasWorkingAbility(:GLUTTONY) && self.hp<=(self.totalhp/2).floor) ||
  1902. self.hp<=(self.totalhp/4).floor
  1903. if self.hasWorkingItem(:LIECHIBERRY) ||
  1904. self.hasWorkingItem(:GANLONBERRY) ||
  1905. self.hasWorkingItem(:SALACBERRY) ||
  1906. self.hasWorkingItem(:PETAYABERRY) ||
  1907. self.hasWorkingItem(:APICOTBERRY)
  1908. pbActivateBerryEffect
  1909. return
  1910. end
  1911. if self.hasWorkingItem(:LANSATBERRY) ||
  1912. self.hasWorkingItem(:STARFBERRY)
  1913. pbActivateBerryEffect
  1914. return
  1915. end
  1916. if self.hasWorkingItem(:MICLEBERRY)
  1917. pbActivateBerryEffect
  1918. return
  1919. end
  1920. end
  1921. if self.hasWorkingItem(:LEPPABERRY)
  1922. pbActivateBerryEffect
  1923. return
  1924. end
  1925. if self.hasWorkingItem(:CHESTOBERRY) ||
  1926. self.hasWorkingItem(:PECHABERRY) ||
  1927. self.hasWorkingItem(:RAWSTBERRY) ||
  1928. self.hasWorkingItem(:CHERIBERRY) ||
  1929. self.hasWorkingItem(:ASPEARBERRY) ||
  1930. self.hasWorkingItem(:PERSIMBERRY) ||
  1931. self.hasWorkingItem(:LUMBERRY)
  1932. pbActivateBerryEffect
  1933. return
  1934. end
  1935. end
  1936. if self.hasWorkingItem(:WHITEHERB)
  1937. reducedstats=false
  1938. for i in [PBStats::ATTACK,PBStats::DEFENSE,
  1939. PBStats::SPEED,PBStats::SPATK,PBStats::SPDEF,
  1940. PBStats::ACCURACY,PBStats::EVASION]
  1941. if @stages[i]<0
  1942. @stages[i]=0; reducedstats=true
  1943. end
  1944. end
  1945. if reducedstats
  1946. PBDebug.log("[Objeto disparado] #{itemname} de #{pbThis}")
  1947. @battle.pbCommonAnimation("UseItem",self,nil)
  1948. @battle.pbDisplay(_INTL("¡{1} ha restaurado su estado gracias a la {2}!",pbThis,itemname))
  1949. pbConsumeItem
  1950. return
  1951. end
  1952. end
  1953. if self.hasWorkingItem(:MENTALHERB) && # Hierba Mental
  1954. (@effects[PBEffects::Attract]>=0 ||
  1955. @effects[PBEffects::Taunt]>0 ||
  1956. @effects[PBEffects::Encore]>0 ||
  1957. @effects[PBEffects::Torment] ||
  1958. @effects[PBEffects::Disable]>0 ||
  1959. @effects[PBEffects::HealBlock]>0)
  1960. PBDebug.log("[Objeto disparado] #{itemname} de #{pbThis}")
  1961. @battle.pbCommonAnimation("UseItem",self,nil)
  1962. @battle.pbDisplay(_INTL("¡{1} se le pasó el enamoramiento usando {2}!",pbThis,itemname)) if @effects[PBEffects::Attract]>=0 # Enamoramiento
  1963. @battle.pbDisplay(_INTL("¡El efecto de Mofa de {1} ha pasado!",pbThis)) if @effects[PBEffects::Taunt]>0 # Mofa
  1964. @battle.pbDisplay(_INTL("¡{1} se liberó de Repetición!",pbThis)) if @effects[PBEffects::Encore]>0 # Repetición
  1965. @battle.pbDisplay(_INTL("¡El efecto de Tormento de {1} ha pasado!",pbThis)) if @effects[PBEffects::Torment] # Tormento
  1966. @battle.pbDisplay(_INTL("¡{1} se ha liberado de la anulación!",pbThis)) if @effects[PBEffects::Disable]>0 # Anulación
  1967. @battle.pbDisplay(_INTL("¡Anticura de {1} se agotó!",pbThis)) if @effects[PBEffects::HealBlock]>0 # Anticura
  1968. self.pbCureAttract
  1969. @effects[PBEffects::Taunt]=0
  1970. @effects[PBEffects::Encore]=0
  1971. @effects[PBEffects::EncoreMove]=0
  1972. @effects[PBEffects::EncoreIndex]=0
  1973. @effects[PBEffects::Torment]=false
  1974. @effects[PBEffects::Disable]=0
  1975. @effects[PBEffects::HealBlock]=0
  1976. pbConsumeItem
  1977. return
  1978. end
  1979. if hpcure && self.hasWorkingItem(:LEFTOVERS) && self.hp!=self.totalhp && # Restos
  1980. @effects[PBEffects::HealBlock]==0
  1981. PBDebug.log("[Objeto disparado] Restos de #{pbThis}")
  1982. @battle.pbCommonAnimation("UseItem",self,nil)
  1983. pbRecoverHP((self.totalhp/16).floor,true)
  1984. @battle.pbDisplay(_INTL("¡{1} ha restaurado un poco sus PS con {2}!",pbThis,itemname))
  1985. end
  1986. if hpcure && self.hasWorkingItem(:BLACKSLUDGE) # Lodo Negro
  1987. if pbHasType?(:POISON)
  1988. if self.hp!=self.totalhp &&
  1989. (!USENEWBATTLEMECHANICS || @effects[PBEffects::HealBlock]==0)
  1990. PBDebug.log("[Objeto disparado] Lodo Negro de #{pbThis} (cura)") # Lodo Negro
  1991. @battle.pbCommonAnimation("UseItem",self,nil)
  1992. pbRecoverHP((self.totalhp/16).floor,true)
  1993. @battle.pbDisplay(_INTL("¡{1} ha restaurado un poco sus PS con {2}!",pbThis,itemname))
  1994. end
  1995. elsif !self.hasWorkingAbility(:MAGICGUARD)
  1996. PBDebug.log("[Objeto disparado] Lodo Negro de #{pbThis} (daño)") # Lodo Negro
  1997. @battle.pbCommonAnimation("UseItem",self,nil)
  1998. pbReduceHP((self.totalhp/8).floor,true)
  1999. @battle.pbDisplay(_INTL("¡{1} ha sido herido por {2}!",pbThis,itemname))
  2000. end
  2001. pbFaint if self.isFainted?
  2002. end
  2003. end
  2004.  
  2005. ################################################################################
  2006. # Move user and targets
  2007. ################################################################################
  2008. def pbFindUser(choice,targets)
  2009. move=choice[2]
  2010. target=choice[3]
  2011. user=self # Normally, the user is self
  2012. # Targets in normal cases
  2013. case pbTarget(move)
  2014. when PBTargets::SingleNonUser
  2015. if target>=0
  2016. if !pbIsOpposing?(targetBattler.index)
  2017. if !pbAddTarget(targets,targetBattler)
  2018. pbAddTarget(targets,pbOpposing2) if !pbAddTarget(targets,pbOpposing1)
  2019. end
  2020. else
  2021. pbAddTarget(targets,targetBattler.pbPartner) if !pbAddTarget(targets,targetBattler)
  2022. end
  2023. else
  2024. pbRandomTarget(targets)
  2025. end
  2026. when PBTargets::SingleOpposing
  2027. if target>=0
  2028. if !pbIsOpposing?(targetBattler.index)
  2029. if !pbAddTarget(targets,targetBattler)
  2030. pbAddTarget(targets,pbOpposing2) if !pbAddTarget(targets,pbOpposing1)
  2031. end
  2032. else
  2033. pbAddTarget(targets,targetBattler.pbPartner) if !pbAddTarget(targets,targetBattler)
  2034. end
  2035. else
  2036. pbRandomTarget(targets)
  2037. end
  2038. when PBTargets::OppositeOpposing
  2039. pbAddTarget(targets,pbOppositeOpposing) if !pbAddTarget(targets,pbOppositeOpposing2)
  2040. when PBTargets::RandomOpposing
  2041. pbRandomTarget(targets)
  2042. when PBTargets::AllOpposing
  2043. # Just pbOpposing1 because partner is determined late
  2044. pbAddTarget(targets,pbOpposing2) if !pbAddTarget(targets,pbOpposing1)
  2045. when PBTargets::AllNonUsers
  2046. for i in 0...4 # not ordered by priority
  2047. pbAddTarget(targets,@battle.battlers[i]) if i!=@index
  2048. end
  2049. when PBTargets::UserOrPartner
  2050. if target>=0 # Pre-chosen target
  2051. pbAddTarget(targets,targetBattler.pbPartner) if !pbAddTarget(targets,targetBattler)
  2052. else
  2053. pbAddTarget(targets,self)
  2054. end
  2055. when PBTargets::Partner
  2056. pbAddTarget(targets,pbPartner)
  2057. else
  2058. move.pbAddTarget(targets,self)
  2059. end
  2060. return user
  2061. end
  2062.  
  2063. def pbChangeUser(thismove,user)
  2064. # Cambia el usuario actual por el usuario de Robo
  2065. if thismove.canSnatch?
  2066. for i in priority
  2067. if i.effects[PBEffects::Snatch]
  2068. @battle.pbDisplay(_INTL("¡{1} robó el movimiento de {2}!",i.pbThis,user.pbThis(true)))
  2069. PBDebug.log("[Efecto prolongado disparado] Robo de #{i.pbThis} permitió usar #{thismove.name} de #{user.pbThis(true)}")
  2070. i.effects[PBEffects::Snatch]=false
  2071. target=user
  2072. user=i
  2073. # Los PP se Robo son reducidos si el usuario anterior tiene Presión
  2074. [email protected][user.index][1]
  2075. if target.hasWorkingAbility(:PRESSURE) && user.pbIsOpposing?(target.index) && userchoice>=0
  2076. pressuremove=user.moves[userchoice]
  2077. pbSetPP(pressuremove,pressuremove.pp-1) if pressuremove.pp>0
  2078. end
  2079. break if USENEWBATTLEMECHANICS
  2080. end
  2081. end
  2082. end
  2083. return user
  2084. end
  2085.  
  2086. def pbTarget(move)
  2087. target=move.target
  2088. if move.function==0x10D && pbHasType?(:GHOST) # Curse
  2089. target=PBTargets::OppositeOpposing
  2090. end
  2091. return target
  2092. end
  2093.  
  2094. def pbAddTarget(targets,target)
  2095. if !target.isFainted?
  2096. targets[targets.length]=target
  2097. return true
  2098. end
  2099. return false
  2100. end
  2101.  
  2102. def pbRandomTarget(targets)
  2103. choices=[]
  2104. pbAddTarget(choices,pbOpposing1)
  2105. pbAddTarget(choices,pbOpposing2)
  2106. if choices.length>0
  2107. pbAddTarget(targets,choices[@battle.pbRandom(choices.length)])
  2108. end
  2109. end
  2110.  
  2111. def pbChangeTarget(thismove,userandtarget,targets)
  2112. changeeffect=0
  2113. user=userandtarget[0]
  2114. target=userandtarget[1]
  2115. # Pararrayos
  2116. if targets.length==1 && isConst?(thismove.pbType(thismove.type,user,target),PBTypes,:ELECTRIC) &&
  2117. !target.hasWorkingAbility(:LIGHTNINGROD)
  2118. for i in priority # usa Pokémon con mayor prioridad
  2119. next if user.index==i.index || target.index==i.index
  2120. if i.hasWorkingAbility(:LIGHTNINGROD)
  2121. PBDebug.log("[Habilidad disparada] Pararrayos de #{i.pbThis} (cambio de objetivo)")
  2122. target=i # Pararrayos de X recibe el ataque!
  2123. changeeffect=1
  2124. break
  2125. end
  2126. end
  2127. end
  2128. # Colector
  2129. if targets.length==1 && isConst?(thismove.pbType(thismove.type,user,target),PBTypes,:WATER) &&
  2130. !target.hasWorkingAbility(:STORMDRAIN)
  2131. for i in priority # usa Pokémon con mayor prioridad
  2132. next if user.index==i.index || target.index==i.index
  2133. if i.hasWorkingAbility(:STORMDRAIN)
  2134. PBDebug.log("[Habilidad disparada] Colector de #{i.pbThis} (cambio de objetivo)")
  2135. target=i # Colector de X recibe el ataque!
  2136. changeeffect=1
  2137. break
  2138. end
  2139. end
  2140. end
  2141. # Cambio de objtivo por el usuario de Señuelo (sobreescribe Capa Mágica
  2142. # porque la verificación de Capa Mágica de abajo usa este objetivo)
  2143. if PBTargets.targetsOneOpponent?(thismove)
  2144. newtarget=nil; strength=100
  2145. for i in priority # usa Pokémon con mayor prioridad
  2146. next if !user.pbIsOpposing?(i.index)
  2147. if !i.isFainted? && [email protected] && !i.effects[PBEffects::SkyDrop] &&
  2148. i.effects[PBEffects::FollowMe]>0 && i.effects[PBEffects::FollowMe]<strength
  2149. PBDebug.log("[Efecto prolongado disparado] Señuelo de #{i.pbThis}")
  2150. newtarget=i; strength=i.effects[PBEffects::FollowMe]
  2151. changeeffect=0
  2152. end
  2153. end
  2154. target=newtarget if newtarget
  2155. end
  2156. # TODO: Presión es incorrecta aquí si Capa Mágica cambio el objetivo
  2157. if user.pbIsOpposing?(target.index) && target.hasWorkingAbility(:PRESSURE)
  2158. PBDebug.log("[Habilidad disparada] Presión de #{target.pbThis} (en pbChangeTarget)")
  2159. user.pbReducePP(thismove) # Reduce PP
  2160. end
  2161. # Cambia el usuario actual por el usuario de Robo
  2162. if thismove.canSnatch?
  2163. for i in priority
  2164. if i.effects[PBEffects::Snatch]
  2165. @battle.pbDisplay(_INTL("¡{1} robó el movimiento de {2}!",i.pbThis,user.pbThis(true)))
  2166. PBDebug.log("[Efecto prolongado disparado] Robo de #{i.pbThis} permite usar #{thismove.name} de #{user.pbThis(true)}")
  2167. i.effects[PBEffects::Snatch]=false
  2168. target=user
  2169. user=i
  2170. # Los PP de Robo son reducidos si el usuario anterior tiene Presión
  2171. [email protected][user.index][1]
  2172. if target.hasWorkingAbility(:PRESSURE) && user.pbIsOpposing?(target.index) && userchoice>=0
  2173. PBDebug.log("[Habilidad disparada] Presión de #{target.pbThis} (parte de Robo)")
  2174. pressuremove=user.moves[userchoice]
  2175. pbSetPP(pressuremove,pressuremove.pp-1) if pressuremove.pp>0
  2176. end
  2177. end
  2178. end
  2179. end
  2180. if thismove.canMagicCoat?
  2181. if target.effects[PBEffects::MagicCoat]
  2182. # intercambio usuario y objetivo
  2183. PBDebug.log("[Efecto prolongado disparado] Capa Mágica de #{i.pbThis} permite usar #{thismove.name} de #{user.pbThis(true)}")
  2184. changeeffect=3
  2185. tmp=user
  2186. user=target
  2187. target=tmp
  2188. # Los PP de Capa Mágica son reducidos si el usuario anterior tiene Presión
  2189. [email protected][user.index][1]
  2190. if target.hasWorkingAbility(:PRESSURE) && user.pbIsOpposing?(target.index) && userchoice>=0
  2191. PBDebug.log("[Habilidad disparada] Presión de #{target.pbThis} (parte de Capa Mágica)")
  2192. pressuremove=user.moves[userchoice]
  2193. pbSetPP(pressuremove,pressuremove.pp-1) if pressuremove.pp>0
  2194. end
  2195. elsif !user.hasMoldBreaker && target.hasWorkingAbility(:MAGICBOUNCE) # Espejo Mágico
  2196. # intercambio usuario y objetivo
  2197. PBDebug.log("[Habilidad disparada] Espejo Mágico de #{target.pbThis} permite usar #{thismove.name} de #{user.pbThis(true)}")
  2198. changeeffect=3
  2199. tmp=user
  2200. user=target
  2201. target=tmp
  2202. end
  2203. end
  2204. if changeeffect==1
  2205. @battle.pbDisplay(_INTL("¡{2} de {1} atrajo el ataque!",target.pbThis,PBAbilities.getName(target.ability)))
  2206. elsif changeeffect==3
  2207. @battle.pbDisplay(_INTL("¡{1} ha devuelto {2}!",user.pbThis,thismove.name))
  2208. end
  2209. userandtarget[0]=user
  2210. userandtarget[1]=target
  2211. if !user.hasMoldBreaker && target.hasWorkingAbility(:SOUNDPROOF) &&
  2212. thismove.isSoundBased? &&
  2213. thismove.function!=0xE5 && # Canto Mortal es controlado en otro lugar
  2214. thismove.function!=0x151 # Última Palabra es controlado en otro lugar
  2215. PBDebug.log("[Habilidad disparada] Insonorizar de #{target.pbThis} ha bloqueado #{thismove.name} de #{user.pbThis(true)}")
  2216. @battle.pbDisplay(_INTL("¡{2} de {1} lo hace inmune a {3}!",target.pbThis,
  2217. PBAbilities.getName(target.ability),thismove.name))
  2218. return false
  2219. end
  2220. return true
  2221. end
  2222.  
  2223. ################################################################################
  2224. # PP de movimientos
  2225. ################################################################################
  2226. def pbSetPP(move,pp)
  2227. move.pp=pp
  2228. # [PBEffects::Mimic] sin efectos, dado que Mimético no puede copiar Mimético
  2229. if move.thismove && move.id==move.thismove.id && !@effects[PBEffects::Transform]
  2230. move.thismove.pp=pp
  2231. end
  2232. end
  2233.  
  2234. def pbReducePP(move)
  2235. if @effects[PBEffects::TwoTurnAttack]>0 ||
  2236. @effects[PBEffects::Bide]>0 ||
  2237. @effects[PBEffects::Outrage]>0 ||
  2238. @effects[PBEffects::Rollout]>0 ||
  2239. @effects[PBEffects::HyperBeam]>0 ||
  2240. @effects[PBEffects::Uproar]>0
  2241. # No need to reduce PP if two-turn attack
  2242. return true
  2243. end
  2244. return true if move.pp<0 # No se reducen PP por llamados especiales de un movimiento
  2245. return true if move.totalpp==0 # PP infinitos, se pueden usar por siempre
  2246. return false if move.pp==0
  2247. if move.pp>0
  2248. pbSetPP(move,move.pp-1)
  2249. end
  2250. return true
  2251. end
  2252.  
  2253. def pbReducePPOther(move)
  2254. pbSetPP(move,move.pp-1) if move.pp>0
  2255. end
  2256.  
  2257. ################################################################################
  2258. # Uso de movimiento
  2259. ################################################################################
  2260. def pbObedienceCheck?(choice)
  2261. return true if choice[0]!=1
  2262. if @battle.pbOwnedByPlayer?(@index) && @battle.internalbattle
  2263. badgelevel=10
  2264. badgelevel=20 if @battle.pbPlayer.numbadges>=1
  2265. badgelevel=30 if @battle.pbPlayer.numbadges>=2
  2266. badgelevel=40 if @battle.pbPlayer.numbadges>=3
  2267. badgelevel=50 if @battle.pbPlayer.numbadges>=4
  2268. badgelevel=60 if @battle.pbPlayer.numbadges>=5
  2269. badgelevel=70 if @battle.pbPlayer.numbadges>=6
  2270. badgelevel=80 if @battle.pbPlayer.numbadges>=7
  2271. badgelevel=100 if @battle.pbPlayer.numbadges>=8
  2272. move=choice[2]
  2273. disobedient=false
  2274. if @pokemon.isForeign?(@battle.pbPlayer) && @level>badgelevel
  2275. a=((@level+badgelevel)*@battle.pbRandom(256)/255).floor
  2276. disobedient|=a<badgelevel
  2277. end
  2278. if self.respond_to?("pbHyperModeObedience")
  2279. disobedient|=!self.pbHyperModeObedience(move)
  2280. end
  2281. if disobedient
  2282. PBDebug.log("[Desobediencia] #{pbThis} ha desobedecido")
  2283. @effects[PBEffects::Rage]=false
  2284. if self.status==PBStatuses::SLEEP &&
  2285. (move.function==0x11 || move.function==0xB4) # Snore, Sleep Talk
  2286. @battle.pbDisplay(_INTL("¡{1} ignora las órdenes mientras se va a dormir!",pbThis))
  2287. return false
  2288. end
  2289. b=((@level+badgelevel)*@battle.pbRandom(256)/255).floor
  2290. if b<badgelevel
  2291. return false if [email protected]?(@index)
  2292. othermoves=[]
  2293. for i in 0...4
  2294. next if i==choice[1]
  2295. othermoves[othermoves.length]=i if @battle.pbCanChooseMove?(@index,i,false)
  2296. end
  2297. if othermoves.length>0
  2298. @battle.pbDisplay(_INTL("¡{1} se hace el distraido!",pbThis))
  2299. newchoice=othermoves[@battle.pbRandom(othermoves.length)]
  2300. choice[1]=newchoice
  2301. choice[2]=@moves[newchoice]
  2302. choice[3]=-1
  2303. end
  2304. return true
  2305. elsif self.status!=PBStatuses::SLEEP
  2306. c=@level-b
  2307. if r<c && pbCanSleep?(self,false)
  2308. pbSleepSelf()
  2309. @battle.pbDisplay(_INTL("¡{1} está tomando una siesta!",pbThis))
  2310. return false
  2311. end
  2312. r-=c
  2313. if r<c
  2314. @battle.pbDisplay(_INTL("¡Está tan confuso que se hirió a sí mismo!"))
  2315. pbConfusionDamage
  2316. else
  2317. @battle.pbDisplay(_INTL("¡{1} ignoró las órdenes!",pbThis)) if message==0
  2318. @battle.pbDisplay(_INTL("¡{1} se alejó!",pbThis)) if message==1
  2319. @battle.pbDisplay(_INTL("¡{1} está con pereza!",pbThis)) if message==2
  2320. @battle.pbDisplay(_INTL("¡{1} fingió no darse cuenta!",pbThis)) if message==3
  2321. end
  2322. return false
  2323. end
  2324. end
  2325. return true
  2326. else
  2327. return true
  2328. end
  2329. end
  2330.  
  2331. def pbSuccessCheck(thismove,user,target,turneffects,accuracy=true)
  2332. if user.effects[PBEffects::TwoTurnAttack]>0
  2333. return true
  2334. end
  2335. # TODO: "Before Protect" applies to Counter/Mirror Coat
  2336. if thismove.function==0xDE && target.status!=PBStatuses::SLEEP # Dream Eater / Come Sueños
  2337. @battle.pbDisplay(_INTL("¡{1} no se vió afectado!",target.pbThis))
  2338. PBDebug.log("[Movimiento falló] El objetivo de Come Sueños de #{user.pbThis} no está dormido")
  2339. return false
  2340. end
  2341. if thismove.function==0x113 && user.effects[PBEffects::Stockpile]==0 # Spit Up / Escupir
  2342. @battle.pbDisplay(_INTL("¡Pero no consiguió escupir energía!"))
  2343. PBDebug.log("[Movimiento falló] Escupir de #{user.pbThis} no hizo nada debido a que el contador de Reserva está en 0")
  2344. return false
  2345. end
  2346. if target.effects[PBEffects::Protect] && thismove.canProtectAgainst? && # Protección
  2347. !target.effects[PBEffects::ProtectNegation]
  2348. @battle.pbDisplay(_INTL("¡{1} se está protegiendo!",target.pbThis))
  2349. @battle.successStates[user.index].protected=true
  2350. PBDebug.log("[Movimiento falló] Protección de #{target.pbThis} se está protegiendo")
  2351. return false
  2352. end
  2353. p=thismove.priority
  2354. if USENEWBATTLEMECHANICS
  2355. p+=1 if user.hasWorkingAbility(:PRANKSTER) && thismove.pbIsStatus? # Bromista
  2356. p+=1 if user.hasWorkingAbility(:GALEWINGS) && isConst?(thismove.type,PBTypes,:FLYING) # Alas Vendaval
  2357. end
  2358. if target.pbOwnSide.effects[PBEffects::QuickGuard] && thismove.canProtectAgainst? && # Anticipo
  2359. p>0 && !target.effects[PBEffects::ProtectNegation]
  2360. @battle.pbDisplay(_INTL("¡{1} ha sido protegido por Anticipo!",target.pbThis))
  2361. PBDebug.log("[Movimiento falló] El Anticipo del lado del oponente ha detenido el ataque")
  2362. return false
  2363. end
  2364. if target.pbOwnSide.effects[PBEffects::WideGuard] && # Vastaguardia
  2365. PBTargets.hasMultipleTargets?(thismove) && !thismove.pbIsStatus? &&
  2366. !target.effects[PBEffects::ProtectNegation]
  2367. @battle.pbDisplay(_INTL("¡{1} ha sido protegido por Vastaguardia!",target.pbThis))
  2368. PBDebug.log("[Movimiento falló] La Vastaguardia del lado del oponente ha detenido el ataque")
  2369. return false
  2370. end
  2371. if target.pbOwnSide.effects[PBEffects::CraftyShield] && thismove.pbIsStatus? && # Truco Defensa
  2372. thismove.function!=0xE5 # Canto Mortal
  2373. @battle.pbDisplay(_INTL("¡Truco Defensa ha protegido a {1}!",target.pbThis(true)))
  2374. PBDebug.log("[Movimiento falló] El Truco Defensa del lado del oponente ha detenido el ataque")
  2375. return false
  2376. end
  2377. if target.pbOwnSide.effects[PBEffects::MatBlock] && !thismove.pbIsStatus? && # Escudo Tatami
  2378. thismove.canProtectAgainst? && !target.effects[PBEffects::ProtectNegation]
  2379. @battle.pbDisplay(_INTL("¡Escudo Tatami ha neutralizado {1}!",thismove.name))
  2380. PBDebug.log("[Movimiento falló] El Escudo Tatami del lado del oponente ha detenido el ataque")
  2381. return false
  2382. end
  2383. # TODO: Telépata/Fijar Blanco (Mind Reader/Lock-On)
  2384. # --Esquema/Premonición/Más Psique funcionan incluso en Vuelo/Buceo/Excavar
  2385. if thismove.pbMoveFailed(user,target) # TODO: Aplica a Ronquido/Sorpresa (Snore/Fake Out)
  2386. @battle.pbDisplay(_INTL("¡Pero falló!"))
  2387. PBDebug.log(sprintf("[Movimiento falló] Falló pbMoveFailed (código de función %02X)",thismove.function))
  2388. return false
  2389. end
  2390. # Escudo Real (deliberadamente después de pbMoveFailed)
  2391. if target.effects[PBEffects::KingsShield] && !thismove.pbIsStatus? &&
  2392. thismove.canProtectAgainst? && !target.effects[PBEffects::ProtectNegation]
  2393. @battle.pbDisplay(_INTL("¡{1} se está protegiendo!",target.pbThis))
  2394. @battle.successStates[user.index].protected=true
  2395. PBDebug.log("[Movimiento falló] Escudo Real de #{target.pbThis} ha detenido el ataque")
  2396. if thismove.isContactMove?
  2397. user.pbReduceStat(PBStats::ATTACK,2,nil,false)
  2398. end
  2399. return false
  2400. end
  2401. # Barrera Espinosa
  2402. if target.effects[PBEffects::SpikyShield] && thismove.canProtectAgainst? &&
  2403. !target.effects[PBEffects::ProtectNegation]
  2404. @battle.pbDisplay(_INTL("¡{1} se está protegiendo!",target.pbThis))
  2405. @battle.successStates[user.index].protected=true
  2406. PBDebug.log("[Movimiento falló] Barrera Espinosa de #{user.pbThis} ha detenido el ataque")
  2407. if thismove.isContactMove? && !user.isFainted?
  2408. @battle.scene.pbDamageAnimation(user,0)
  2409. amt=user.pbReduceHP((user.totalhp/8).floor)
  2410. @battle.pbDisplay(_INTL("¡{1} ha sido dañado!",user.pbThis)) if amt>0
  2411. end
  2412. return false
  2413. end
  2414. # Inmunidad a movimientos basados en polvos
  2415. if USENEWBATTLEMECHANICS && thismove.isPowderMove? &&
  2416. (target.pbHasType?(:GRASS) ||
  2417. (!user.hasMoldBreaker && target.hasWorkingAbility(:OVERCOAT)) ||
  2418. target.hasWorkingItem(:SAFETYGOGGLES))
  2419. @battle.pbDisplay(_INTL("No ha afectado a\r\n{1}...",target.pbThis(true)))
  2420. PBDebug.log("[Movimiento falló] #{target.pbThis} es inmune a movimientos basados en polvo por alguna razón")
  2421. return false
  2422. end
  2423. if thismove.basedamage>0 && thismove.function!=0x02 && # Combate
  2424. thismove.function!=0x111 # Premonición
  2425. type=thismove.pbType(thismove.type,user,target)
  2426. typemod=thismove.pbTypeModifier(type,user,target)
  2427. # Inmunidad a movimientos de tipo Tierra en base a Pokémon en el aire
  2428. if isConst?(type,PBTypes,:GROUND) && target.isAirborne?(user.hasMoldBreaker) &&
  2429. !target.hasWorkingItem(:RINGTARGET) && thismove.function!=0x11C # Obj. Blanco - Mov. Antiaéreo
  2430. if !user.hasMoldBreaker && target.hasWorkingAbility(:LEVITATE) # Levitación
  2431. @battle.pbDisplay(_INTL("¡{1} es inmune a movimientos de tipo Tierra gracias a Levitación!",target.pbThis))
  2432. PBDebug.log("[Habilidad disparada] Levitación de #{target.pbThis} anula movimientos de tipo Tierra")
  2433. return false
  2434. end
  2435. if target.hasWorkingItem(:AIRBALLOON) # Globo Helio
  2436. @battle.pbDisplay(_INTL("¡{1} evita los movimientos de tipo Tierra gracias al Globo Helio!",target.pbThis))
  2437. PBDebug.log("[Objeto disparado] Globo Helio de #{target.pbThis} anula movimientos de tipo Tierra")
  2438. return false
  2439. end
  2440. if target.effects[PBEffects::MagnetRise]>0 # Levitón
  2441. @battle.pbDisplay(_INTL("¡{1} evita los movimientos de tipo Tierra con Levitón!",target.pbThis))
  2442. PBDebug.log("[Efecto prolongado disparado] Levitón de #{target.pbThis} anula movimientos de tipo Tierra")
  2443. return false
  2444. end
  2445. if target.effects[PBEffects::Telekinesis]>0 # Telequinesis
  2446. @battle.pbDisplay(_INTL("¡{1} evita los movimientos de tipo Tierra con Telequinesis!",target.pbThis))
  2447. PBDebug.log("[Efecto prolongado disparado] Telequinesis de #{target.pbThis} anula movimientos de tipo Tierra")
  2448. return false
  2449. end
  2450. end
  2451. if !user.hasMoldBreaker && target.hasWorkingAbility(:WONDERGUARD) && # Superguarda
  2452. type>=0 && typemod<=8
  2453. @battle.pbDisplay(_INTL("¡{1} evitó el daño usando Superguarda!",target.pbThis))
  2454. PBDebug.log("[Habilidad disparada] Superguarda de #{target.pbThis}")
  2455. return false
  2456. end
  2457. if typemod==0
  2458. @battle.pbDisplay(_INTL("No afecta a\r\n{1}...",target.pbThis(true)))
  2459. PBDebug.log("[Movimiento falló] Inmunidad por tipo")
  2460. return false
  2461. end
  2462. end
  2463. if accuracy
  2464. if target.effects[PBEffects::LockOn]>0 && target.effects[PBEffects::LockOnPos]==user.index # Fijar Blanco
  2465. PBDebug.log("[Efecto prolongado disparado] Fijar Blanco de #{target.pbThis}")
  2466. return true
  2467. end
  2468. miss=false; override=false
  2469. invulmove=PBMoveData.new(target.effects[PBEffects::TwoTurnAttack]).function
  2470. case invulmove
  2471. when 0xC9, 0xCC # Vuelo, Bote
  2472. miss=true unless thismove.function==0x08 || # Trueno
  2473. thismove.function==0x15 || # Vendaval
  2474. thismove.function==0x77 || # Tornado
  2475. thismove.function==0x78 || # Ciclón
  2476. thismove.function==0x11B || # Gancho Alto
  2477. thismove.function==0x11C || # Antiaéreo
  2478. isConst?(thismove.id,PBMoves,:WHIRLWIND)
  2479. when 0xCA # Dig
  2480. miss=true unless thismove.function==0x76 || # Terremoto
  2481. thismove.function==0x95 # Magnitud
  2482. when 0xCB # Buceo
  2483. miss=true unless thismove.function==0x75 || # Surf
  2484. thismove.function==0xD0 # Torbellino
  2485. when 0xCD # Golpe Umbrío
  2486. miss=true
  2487. when 0xCE # Caída Libre
  2488. miss=true unless thismove.function==0x08 || # Trueno
  2489. thismove.function==0x15 || # Vendaval
  2490. thismove.function==0x77 || # Tornado
  2491. thismove.function==0x78 || # Ciclón
  2492. thismove.function==0x11B || # Gancho Alto
  2493. thismove.function==0x11C # Antiaéreo
  2494. when 0x14D # Golpe Fantasma
  2495. miss=true
  2496. end
  2497. if target.effects[PBEffects::SkyDrop]
  2498. miss=true unless thismove.function==0x08 || # Trueno
  2499. thismove.function==0x15 || # Vendaval
  2500. thismove.function==0x77 || # Tornado
  2501. thismove.function==0x78 || # Ciclón
  2502. thismove.function==0xCE || # Caída Libre
  2503. thismove.function==0x11B || # Gancho Alto
  2504. thismove.function==0x11C # Antiaéreo
  2505. end
  2506. miss=false if user.hasWorkingAbility(:NOGUARD) || # Indefenso
  2507. target.hasWorkingAbility(:NOGUARD) ||
  2508. @battle.futuresight
  2509. override=true if USENEWBATTLEMECHANICS && thismove.function==0x06 && # Tóxico
  2510. thismove.basedamage==0 && user.pbHasType?(:POISON)
  2511. override=true if !miss && turneffects[PBEffects::SkipAccuracyCheck] # Called by another move
  2512. if !override && (miss || !thismove.pbAccuracyCheck(user,target)) # Incluye Contraataque/Manto Espejo
  2513. PBDebug.log(sprintf("[Movimiento falló] Falló pbAccuracyCheck (código de función %02X) o el objetivo es semi-invulnerable",thismove.function))
  2514. if thismove.target==PBTargets::AllOpposing &&
  2515. (!user.pbOpposing1.isFainted? ? 1 : 0) + (!user.pbOpposing2.isFainted? ? 1 : 0) > 1
  2516. @battle.pbDisplay(_INTL("¡{1} ha evitado el ataque!",target.pbThis))
  2517. elsif thismove.target==PBTargets::AllNonUsers &&
  2518. (!user.pbOpposing1.isFainted? ? 1 : 0) + (!user.pbOpposing2.isFainted? ? 1 : 0) + (!user.pbPartner.isFainted? ? 1 : 0) > 1
  2519. @battle.pbDisplay(_INTL("¡{1} ha esquivado el ataque!",target.pbThis))
  2520. elsif target.effects[PBEffects::TwoTurnAttack]>0
  2521. @battle.pbDisplay(_INTL("¡{1} ha evitado el ataque!",target.pbThis))
  2522. elsif thismove.function==0xDC # Drenadoras
  2523. @battle.pbDisplay(_INTL("¡{1} ha esquivado el ataque!",target.pbThis))
  2524. else
  2525. @battle.pbDisplay(_INTL("¡Falló el ataque de {1}!",user.pbThis))
  2526. end
  2527. return false
  2528. end
  2529. end
  2530. return true
  2531. end
  2532.  
  2533. def pbTryUseMove(choice,thismove,turneffects)
  2534. return true if turneffects[PBEffects::PassedTrying]
  2535. # TODO: Devolver true si el ataque ya ha sido reflejado por Capa Mágica una vez
  2536. if !turneffects[PBEffects::SkipAccuracyCheck]
  2537. return false if !pbObedienceCheck?(choice)
  2538. end
  2539. if @effects[PBEffects::SkyDrop] # No hay mensajes aquí intencionalmente
  2540. PBDebug.log("[Movimiento falló] #{pbThis} no puede usar #{thismove.name} debido a Caída Libre")
  2541. return false
  2542. end
  2543. if @battle.field.effects[PBEffects::Gravity]>0 && thismove.unusableInGravity? # Gravedad
  2544. @battle.pbDisplay(_INTL("¡{1} no pudo usar {2} debido a la gravedad!",pbThis,thismove.name))
  2545. PBDebug.log("[Movimiento falló] #{pbThis} no puede usar #{thismove.name} debido a Gravedad")
  2546. return false
  2547. end
  2548. if @effects[PBEffects::Taunt]>0 && thismove.basedamage==0 # Mofa
  2549. @battle.pbDisplay(_INTL("¡{1} no puede usar {2} debido a la Mofa!",pbThis,thismove.name))
  2550. PBDebug.log("[Movimiento falló] #{pbThis} no puede usar #{thismove.name} debido a la Mofa")
  2551. return false
  2552. end
  2553. if @effects[PBEffects::HealBlock]>0 && thismove.isHealingMove? # Anticura
  2554. @battle.pbDisplay(_INTL("¡{1} no puede usar {2} debido a Anticura!",pbThis,thismove.name))
  2555. PBDebug.log("[Movimiento falló] #{pbThis} no puede usar #{thismove.name} debido a Anticura")
  2556. return false
  2557. end
  2558. if @effects[PBEffects::Torment] && thismove.id==@lastMoveUsed &&
  2559. [email protected] && @effects[PBEffects::TwoTurnAttack]==0
  2560. @battle.pbDisplayPaused(_INTL("¡{1} no puede usar el mismo movimiento dos veces seguidas debido al Tormento!",pbThis))
  2561. PBDebug.log("[Movimiento falló] #{pbThis} no puede usar #{thismove.name} debido al Tormento")
  2562. return false
  2563. end
  2564. if pbOpposing1.effects[PBEffects::Imprison] && !pbOpposing1.isFainted? # Cerca
  2565. if thismove.id==pbOpposing1.moves[0].id ||
  2566. thismove.id==pbOpposing1.moves[1].id ||
  2567. thismove.id==pbOpposing1.moves[2].id ||
  2568. thismove.id==pbOpposing1.moves[3].id
  2569. @battle.pbDisplay(_INTL("¡{1} no puede usar {2} porque está sellado!",pbThis,thismove.name))
  2570. PBDebug.log("[Movimiento falló] #{thismove.name} no puede usar #{thismove.name} debido a la Cerca de #{pbOpposing1.pbThis(true)}")
  2571. return false
  2572. end
  2573. end
  2574. if pbOpposing2.effects[PBEffects::Imprison] && !pbOpposing2.isFainted? # Cerca
  2575. if thismove.id==pbOpposing2.moves[0].id ||
  2576. thismove.id==pbOpposing2.moves[1].id ||
  2577. thismove.id==pbOpposing2.moves[2].id ||
  2578. thismove.id==pbOpposing2.moves[3].id
  2579. @battle.pbDisplay(_INTL("¡{1} no puede usar {2} porque está sellado!",pbThis,thismove.name))
  2580. PBDebug.log("[Movimiento falló] #{thismove.name} no puede usar #{thismove.name} debido a la Cerca de #{pbOpposing2.pbThis(true)}")
  2581. return false
  2582. end
  2583. end
  2584. if @effects[PBEffects::Disable]>0 && thismove.id==@effects[PBEffects::DisableMove] &&
  2585. [email protected] # Persecución ignora si se encuentra desactivado
  2586. @battle.pbDisplayPaused(_INTL("¡{2} de {1} está desactivado!",pbThis,thismove.name))
  2587. PBDebug.log("[Movimiento falló] #{thismove.name} de #{pbThis} está desactivado")
  2588. return false
  2589. end
  2590. if choice[1]==-2 # Palacio Batalla
  2591. @battle.pbDisplay(_INTL("¡{1} parece incapaz de usar su poder!",pbThis))
  2592. PBDebug.log("[Movimiento falló] Palacio Batalla: #{pbThis} no es capaz de usar su poder")
  2593. return false
  2594. end
  2595. if @effects[PBEffects::HyperBeam]>0
  2596. @battle.pbDisplay(_INTL("¡{1} necesita recuperarse de su ataque!",pbThis))
  2597. PBDebug.log("[Movimiento falló] #{pbThis} debe descansar después de usar #{PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(@currentMove)).name}")
  2598. return false
  2599. end
  2600. if self.hasWorkingAbility(:TRUANT) && @effects[PBEffects::Truant] # Ausente
  2601. @battle.pbDisplay(_INTL("¡{1} está vagueando!",pbThis))
  2602. PBDebug.log("[Habilidad disparada] Ausente de #{pbThis}")
  2603. return false
  2604. end
  2605. if !turneffects[PBEffects::SkipAccuracyCheck]
  2606. if self.status==PBStatuses::SLEEP
  2607. self.statusCount-=1
  2608. if self.statusCount<=0
  2609. self.pbCureStatus
  2610. else
  2611. self.pbContinueStatus
  2612. PBDebug.log("[Estado] #{pbThis} sigue dormido (contador: #{self.statusCount})")
  2613. if !thismove.pbCanUseWhileAsleep? # Ronquido / Sonámbulo / Enfado
  2614. PBDebug.log("[Movimiento falló] #{pbThis} no puede usar #{thismove.name} mientras duerme")
  2615. return false
  2616. end
  2617. end
  2618. end
  2619. end
  2620. if self.status==PBStatuses::FROZEN
  2621. if thismove.canThawUser?
  2622. PBDebug.log("[Efecto de mov. disparado] #{pbThis} se ha descongelado usando #{thismove.name}")
  2623. self.pbCureStatus(false)
  2624. @battle.pbDisplay(_INTL("¡{1} derritió el hielo!",pbThis))
  2625. pbCheckForm
  2626. elsif @battle.pbRandom(10)<2 && !turneffects[PBEffects::SkipAccuracyCheck]
  2627. self.pbCureStatus
  2628. pbCheckForm
  2629. elsif !thismove.canThawUser?
  2630. self.pbContinueStatus
  2631. PBDebug.log("[Estado] #{pbThis} continúa congelado y no se puedo mover")
  2632. return false
  2633. end
  2634. end
  2635. if !turneffects[PBEffects::SkipAccuracyCheck]
  2636. if @effects[PBEffects::Confusion]>0
  2637. @effects[PBEffects::Confusion]-=1
  2638. if @effects[PBEffects::Confusion]<=0
  2639. pbCureConfusion
  2640. else
  2641. pbContinueConfusion
  2642. PBDebug.log("[Estado] #{pbThis} sigue confuso (contador: #{@effects[PBEffects::Confusion]})")
  2643. if @battle.pbRandom(2)==0
  2644. pbConfusionDamage
  2645. @battle.pbDisplay(_INTL("¡Está tan confuso que se hirió a sí mismo!"))
  2646. PBDebug.log("[Estado] #{pbThis} se daña a sí mismo en su confusión y no se puede mover")
  2647. return false
  2648. end
  2649. end
  2650. end
  2651. end
  2652. if @effects[PBEffects::Flinch]
  2653. @effects[PBEffects::Flinch]=false
  2654. @battle.pbDisplay(_INTL("¡{1} retrocedió y no se pudo mover!",self.pbThis))
  2655. PBDebug.log("[Efecto prolongado disparado] #{pbThis} retrocedió y no se pudo mover")
  2656. if self.hasWorkingAbility(:STEADFAST) # Impasible
  2657. if pbIncreaseStatWithCause(PBStats::SPEED,1,self,PBAbilities.getName(self.ability))
  2658. PBDebug.log("[Habilidad disparada] Impasible de #{pbThis}")
  2659. end
  2660. end
  2661. return false
  2662. end
  2663. if !turneffects[PBEffects::SkipAccuracyCheck]
  2664. if @effects[PBEffects::Attract]>=0
  2665. pbAnnounceAttract(@battle.battlers[@effects[PBEffects::Attract]])
  2666. if @battle.pbRandom(2)==0
  2667. pbContinueAttract
  2668. PBDebug.log("[Efecto prolongado disparado] #{pbThis} está enamorado y no se pudo mover")
  2669. return false
  2670. end
  2671. end
  2672. if self.status==PBStatuses::PARALYSIS
  2673. if @battle.pbRandom(4)==0
  2674. pbContinueStatus
  2675. PBDebug.log("[Estado] #{pbThis} está completamente paralizado y no se pudo mover")
  2676. return false
  2677. end
  2678. end
  2679. end
  2680. turneffects[PBEffects::PassedTrying]=true
  2681. return true
  2682. end
  2683.  
  2684. def pbConfusionDamage
  2685. self.damagestate.reset
  2686. confmove=PokeBattle_Confusion.new(@battle,nil)
  2687. confmove.pbEffect(self,self)
  2688. pbFaint if self.isFainted?
  2689. end
  2690.  
  2691. def pbUpdateTargetedMove(thismove,user)
  2692. # TODO: Robo, movimientos que usan otros movimientos
  2693. # TODO: Todos los casos de objetivos
  2694. # Ataques en dos turnos, control de Capa Mágica, Premonición, Contraataque / Manto Espejo / Venganza
  2695. end
  2696.  
  2697. def pbProcessMoveAgainstTarget(thismove,user,target,numhits,turneffects,nocheck=false,alltargets=nil,showanimation=true)
  2698. realnumhits=0
  2699. totaldamage=0
  2700. destinybond=false
  2701. for i in 0...numhits
  2702. target.damagestate.reset
  2703. # Verificación de éxito (cálculo de precisión/evasión)
  2704. if !nocheck &&
  2705. !pbSuccessCheck(thismove,user,target,turneffects,i==0 || thismove.successCheckPerHit?)
  2706. if thismove.function==0xBF && realnumhits>0 # Triplepatada
  2707. break # Se considera éxitoso si Triplepatada golpea al menos una vez
  2708. elsif thismove.function==0x10B # Patada Super Alta, Patada Salto
  2709. if !user.hasWorkingAbility(:MAGICGUARD)
  2710. PBDebug.log("[Efecto de mov. disparado] #{user.pbThis} es dañado por la caída")
  2711. #TODO: No se muestra es el mensaje es "No afecta a XXX..."
  2712. @battle.pbDisplay(_INTL("¡{1} ha fallado y terminó en el suelo!",user.pbThis))
  2713. damage=(user.totalhp/2).floor
  2714. if damage>0
  2715. @battle.scene.pbDamageAnimation(user,0)
  2716. user.pbReduceHP(damage)
  2717. end
  2718. user.pbFaint if user.isFainted?
  2719. end
  2720. end
  2721. user.effects[PBEffects::Outrage]=0 if thismove.function==0xD2 # Enfado
  2722. user.effects[PBEffects::Rollout]=0 if thismove.function==0xD3 # Desenrollar
  2723. user.effects[PBEffects::FuryCutter]=0 if thismove.function==0x91 # Cortefuria
  2724. user.effects[PBEffects::Stockpile]=0 if thismove.function==0x113 # Escupir
  2725. return
  2726. end
  2727. # Incremento de contadores de movimientos que llevan la cuenta de usos sucesivos
  2728. if thismove.function==0x91 # Cortefuria
  2729. user.effects[PBEffects::FuryCutter]+=1 if user.effects[PBEffects::FuryCutter]<4
  2730. else
  2731. user.effects[PBEffects::FuryCutter]=0
  2732. end
  2733. if thismove.function==0x92 # Eco Voz
  2734. if !user.pbOwnSide.effects[PBEffects::EchoedVoiceUsed] &&
  2735. user.pbOwnSide.effects[PBEffects::EchoedVoiceCounter]<5
  2736. user.pbOwnSide.effects[PBEffects::EchoedVoiceCounter]+=1
  2737. end
  2738. user.pbOwnSide.effects[PBEffects::EchoedVoiceUsed]=true
  2739. end
  2740. # Cuenta los golpes para Amor Filial si aplica
  2741. user.effects[PBEffects::ParentalBond]-=1 if user.effects[PBEffects::ParentalBond]>0
  2742. # Este golpe sucederá, contarlo
  2743. realnumhits+=1
  2744. # Cálculo de daño y/o efecto principal
  2745. damage=thismove.pbEffect(user,target,i,alltargets,showanimation) # Retroceso/drenaje, etc. se aplican aquí
  2746. totaldamage+=damage if damage>0
  2747. # Mensaje y consumo de las bayas que debilitan ataques
  2748. if target.damagestate.berryweakened
  2749. @battle.pbDisplay(_INTL("¡La {1} ha debilitado el daño en {2}!",
  2750. PBItems.getName(target.item),target.pbThis(true)))
  2751. target.pbConsumeItem
  2752. end
  2753. # Ilusión
  2754. if target.effects[PBEffects::Illusion] && target.hasWorkingAbility(:ILLUSION) &&
  2755. damage>0 && !target.damagestate.substitute
  2756. PBDebug.log("[Habilidad disparada] La Ilusión de #{target.pbThis} se terminó")
  2757. target.effects[PBEffects::Illusion]=nil
  2758. @battle.scene.pbChangePokemon(target,target.pokemon)
  2759. @battle.pbDisplay(_INTL("¡La {2} de {1} se terminó!",target.pbThis,
  2760. PBAbilities.getName(target.ability)))
  2761. end
  2762. if user.isFainted?
  2763. user.pbFaint # no return
  2764. end
  2765. return if numhits>1 && target.damagestate.calcdamage<=0
  2766. @battle.pbJudgeCheckpoint(user,thismove)
  2767. # Efectos adicionales
  2768. if target.damagestate.calcdamage>0 &&
  2769. !user.hasWorkingAbility(:SHEERFORCE) &&
  2770. (user.hasMoldBreaker || !target.hasWorkingAbility(:SHIELDDUST))
  2771. addleffect=thismove.addlEffect
  2772. addleffect*=2 if (user.hasWorkingAbility(:SERENEGRACE) ||
  2773. user.pbOwnSide.effects[PBEffects::Rainbow]>0) &&
  2774. thismove.function!=0xA4 # Daño Secreto
  2775. addleffect=100 if $DEBUG && Input.press?(Input::CTRL)
  2776. if @battle.pbRandom(100)<addleffect
  2777. PBDebug.log("[Efecto de mov. disparado] Efecto secundario de #{thismove.name}")
  2778. thismove.pbAdditionalEffect(user,target)
  2779. end
  2780. end
  2781. # Efectos de habilidades
  2782. pbEffectsOnDealingDamage(thismove,user,target,damage)
  2783. # Rabia
  2784. if !user.isFainted? && target.isFainted?
  2785. if target.effects[PBEffects::Grudge] && target.pbIsOpposing?(user.index)
  2786. thismove.pp=0
  2787. @battle.pbDisplay(_INTL("¡{2} de {1} perdió todos sus PP debido a la Rabia!",
  2788. user.pbThis,thismove.name))
  2789. PBDebug.log("[Efecto prolongado disparado] Rabia de #{target.pbThis} hizo perder todos los PP de #{thismove.name}")
  2790. end
  2791. end
  2792. if target.isFainted?
  2793. destinybond=destinybond || target.effects[PBEffects::DestinyBond]
  2794. end
  2795. user.pbFaint if user.isFainted? # no return
  2796. break if user.isFainted?
  2797. break if target.isFainted?
  2798. # Hace retroceder al objetivo
  2799. if target.damagestate.calcdamage>0 && !target.damagestate.substitute
  2800. if user.hasMoldBreaker || !target.hasWorkingAbility(:SHIELDDUST)
  2801. canflinch=false
  2802. if (user.hasWorkingItem(:KINGSROCK) || user.hasWorkingItem(:RAZORFANG)) &&
  2803. thismove.canKingsRock?
  2804. canflinch=true
  2805. end
  2806. if user.hasWorkingAbility(:STENCH) && # Hedor
  2807. thismove.function!=0x09 && # Colmillo Rayo
  2808. thismove.function!=0x0B && # Colmillo Ígneo
  2809. thismove.function!=0x0E && # Colmillo Hielo
  2810. thismove.function!=0x0F && # movimientos que causan retroceso
  2811. thismove.function!=0x10 && # Pisotón
  2812. thismove.function!=0x11 && # Ronquido
  2813. thismove.function!=0x12 && # Sorpresa
  2814. thismove.function!=0x78 && # Ciclón
  2815. thismove.function!=0xC7 # Ataque Aéreo
  2816. canflinch=true
  2817. end
  2818. if canflinch && @battle.pbRandom(10)==0
  2819. PBDebug.log("[Objeto/Habilidad disparado] Roca del Rey, Colmillagudo o Hedor de #{user.pbThis}")
  2820. target.pbFlinch(user)
  2821. end
  2822. end
  2823. end
  2824. if target.damagestate.calcdamage>0 && !target.isFainted?
  2825. # Descongelamiento
  2826. if target.status==PBStatuses::FROZEN &&
  2827. (isConst?(thismove.pbType(thismove.type,user,target),PBTypes,:FIRE) ||
  2828. (USENEWBATTLEMECHANICS && isConst?(thismove.id,PBMoves,:SCALD)))
  2829. target.pbCureStatus
  2830. end
  2831. # Furia
  2832. if target.effects[PBEffects::Rage] && target.pbIsOpposing?(user.index)
  2833. # TODO: Aparentemente se dispara cuando un Pokémon enemigo usa Premonición después de un ataque de Premonición
  2834. if target.pbIncreaseStatWithCause(PBStats::ATTACK,1,target,"",true,false)
  2835. PBDebug.log("[Efecto prolongado disparado] Furia de #{target.pbThis}")
  2836. @battle.pbDisplay(_INTL("¡La furia de {1} está aumentando!",target.pbThis))
  2837. end
  2838. end
  2839. end
  2840. target.pbFaint if target.isFainted? # no return
  2841. user.pbFaint if user.isFainted? # no return
  2842. break if user.isFainted? || target.isFainted?
  2843. # Verificación de bayas (maybe just called by ability effect, since only necessary Berries are checked)
  2844. for j in 0...4
  2845. @battle.battlers[j].pbBerryCureCheck
  2846. end
  2847. break if user.isFainted? || target.isFainted?
  2848. target.pbUpdateTargetedMove(thismove,user)
  2849. break if target.damagestate.calcdamage<=0
  2850. end
  2851. turneffects[PBEffects::TotalDamage]+=totaldamage if totaldamage>0
  2852. # Battle Arena only - attack is successful
  2853. @battle.successStates[user.index].useState=2
  2854. @battle.successStates[user.index].typemod=target.damagestate.typemod
  2855. # Efectividad por tipo
  2856. if numhits>1
  2857. if target.damagestate.typemod>8
  2858. if alltargets.length>1
  2859. @battle.pbDisplay(_INTL("¡Es super efectivo en {1}!",target.pbThis(true)))
  2860. else
  2861. @battle.pbDisplay(_INTL("¡Es super efectivo!"))
  2862. end
  2863. elsif target.damagestate.typemod>=1 && target.damagestate.typemod<8
  2864. if alltargets.length>1
  2865. @battle.pbDisplay(_INTL("No es muy efectivo en {1}...",target.pbThis(true)))
  2866. else
  2867. @battle.pbDisplay(_INTL("No es muy efectivo..."))
  2868. end
  2869. end
  2870. if realnumhits==1
  2871. @battle.pbDisplay(_INTL("¡Golpeó {1} vez!",realnumhits))
  2872. else
  2873. @battle.pbDisplay(_INTL("¡Golpeó {1} veces!",realnumhits))
  2874. end
  2875. end
  2876. PBDebug.log("El movimiento golpeó #{numhits} vez(es), daño total=#{turneffects[PBEffects::TotalDamage]}")
  2877. # Debilitamiento si llega a 0 PS
  2878. target.pbFaint if target.isFainted? # no return
  2879. user.pbFaint if user.isFainted? # no return
  2880. thismove.pbEffectAfterHit(user,target,turneffects)
  2881. target.pbFaint if target.isFainted? # no return
  2882. user.pbFaint if user.isFainted? # no return
  2883. # Mismo Destino
  2884. if !user.isFainted? && target.isFainted?
  2885. if destinybond && target.pbIsOpposing?(user.index)
  2886. PBDebug.log("[Efecto prolongado disparado] Mismo Destino de #{target.pbThis}")
  2887. @battle.pbDisplay(_INTL("¡{1} se llevó al atacante consigo!",target.pbThis))
  2888. user.pbReduceHP(user.hp)
  2889. user.pbFaint # no return
  2890. @battle.pbJudgeCheckpoint(user)
  2891. end
  2892. end
  2893. pbEffectsAfterHit(user,target,thismove,turneffects)
  2894. # Verificación de bayas
  2895. for j in 0...4
  2896. @battle.battlers[j].pbBerryCureCheck
  2897. end
  2898. target.pbUpdateTargetedMove(thismove,user)
  2899. end
  2900.  
  2901. def pbUseMoveSimple(moveid,index=-1,target=-1)
  2902. choice=[]
  2903. choice[0]=1 # "Use move"
  2904. choice[1]=index # Índice del movimiento a ser usado entre los movimientos del usuario
  2905. choice[2]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(moveid)) # PokeBattle_Move object of the move
  2906. choice[2].pp=-1
  2907. choice[3]=target # Objetivo (-1 significa que no tiene objetivo aún)
  2908. if index>=0
  2909. @battle.choices[@index][1]=index
  2910. end
  2911. PBDebug.log("#{pbThis} usa movimiento simple #{choice[2].name}")
  2912. pbUseMove(choice,true)
  2913. return
  2914. end
  2915.  
  2916. def pbUseMove(choice,specialusage=false)
  2917. # TODO: lastMoveUsed is not to be updated on nested calls
  2918. # Note: user.lastMoveUsedType IS to be updated on nested calls; is used for Conversion 2
  2919. turneffects=[]
  2920. turneffects[PBEffects::SpecialUsage]=specialusage
  2921. turneffects[PBEffects::SkipAccuracyCheck]=specialusage
  2922. turneffects[PBEffects::PassedTrying]=false
  2923. turneffects[PBEffects::TotalDamage]=0
  2924. # Start using the move
  2925. pbBeginTurn(choice)
  2926. # Force the use of certain moves if they're already being used
  2927. if @effects[PBEffects::TwoTurnAttack]>0 ||
  2928. @effects[PBEffects::HyperBeam]>0 ||
  2929. @effects[PBEffects::Outrage]>0 ||
  2930. @effects[PBEffects::Rollout]>0 ||
  2931. @effects[PBEffects::Uproar]>0 ||
  2932. @effects[PBEffects::Bide]>0
  2933. choice[2]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(@currentMove))
  2934. turneffects[PBEffects::SpecialUsage]=true
  2935. PBDebug.log("Continuación de movimiento multi-turnos #{choice[2].name}")
  2936. elsif @effects[PBEffects::Encore]>0
  2937. if @battle.pbCanShowCommands?(@index) &&
  2938. @battle.pbCanChooseMove?(@index,@effects[PBEffects::EncoreIndex],false)
  2939. if choice[1]!=@effects[PBEffects::EncoreIndex] # Was Encored mid-round
  2940. choice[1]=@effects[PBEffects::EncoreIndex]
  2941. choice[2]=@moves[@effects[PBEffects::EncoreIndex]]
  2942. choice[3]=-1 # No target chosen
  2943. end
  2944. PBDebug.log("Using Encored move #{choice[2].name}")
  2945. end
  2946. end
  2947. thismove=choice[2]
  2948. return if !thismove || thismove.id==0 # if move was not chosen
  2949. if !turneffects[PBEffects::SpecialUsage]
  2950. # TODO: Quick Claw message
  2951. end
  2952. # Cambio Táctico
  2953. if hasWorkingAbility(:STANCECHANGE) && isConst?(species,PBSpecies,:AEGISLASH) &&
  2954. !@effects[PBEffects::Transform]
  2955. if thismove.pbIsDamaging? && self.form!=1
  2956. self.form=1
  2957. pbUpdate(true)
  2958. @battle.scene.pbChangePokemon(self,@pokemon)
  2959. @battle.pbDisplay(_INTL("¡{1} ha cambiado a su Forma Filo!",pbThis))
  2960. PBDebug.log("[Cambio de forma] #{pbThis} ha cambiado a su Forma Filo")
  2961. elsif isConst?(thismove.id,PBMoves,:KINGSSHIELD) && self.form!=0
  2962. self.form=0
  2963. pbUpdate(true)
  2964. @battle.scene.pbChangePokemon(self,@pokemon)
  2965. @battle.pbDisplay(_INTL("¡{1} ha cambiado a su Forma Escudo!",pbThis))
  2966. PBDebug.log("[Cambio de forma] #{pbThis} ha cambiado a su Forma Escudo")
  2967. end
  2968. end
  2969. # Record that user has used a move this round (ot at least tried to)
  2970. # Intenta usar el movimiento
  2971. if !pbTryUseMove(choice,thismove,turneffects)
  2972. self.lastMoveUsed=-1
  2973. self.lastMoveUsedType=-1
  2974. if !turneffects[PBEffects::SpecialUsage]
  2975. self.lastMoveUsedSketch=-1 if self.effects[PBEffects::TwoTurnAttack]==0
  2976. self.lastRegularMoveUsed=-1
  2977. end
  2978. pbCancelMoves
  2979. @battle.pbGainEXP
  2980. pbEndTurn(choice)
  2981. @battle.pbJudge # @battle.pbSwitch
  2982. return
  2983. end
  2984. if !turneffects[PBEffects::SpecialUsage]
  2985. if !pbReducePP(thismove)
  2986. @battle.pbDisplay(_INTL("¡{1} usó\r\n{2}!",pbThis,thismove.name))
  2987. @battle.pbDisplay(_INTL("¡Pero no le quedan PP al movimiento!"))
  2988. self.lastMoveUsed=-1
  2989. self.lastMoveUsedType=-1
  2990. self.lastMoveUsedSketch=-1 if self.effects[PBEffects::TwoTurnAttack]==0
  2991. self.lastRegularMoveUsed=-1
  2992. pbEndTurn(choice)
  2993. @battle.pbJudge # @battle.pbSwitch
  2994. PBDebug.log("[Movimiento falló] #{thismove.name} no tiene más PP")
  2995. return
  2996. end
  2997. end
  2998. # Remember that user chose a two-turn move
  2999. if thismove.pbTwoTurnAttack(self)
  3000. # Beginning use of two-turn attack
  3001. @effects[PBEffects::TwoTurnAttack]=thismove.id
  3002. @currentMove=thismove.id
  3003. else
  3004. @effects[PBEffects::TwoTurnAttack]=0 # Cancel use of two-turn attack
  3005. end
  3006. # Charge up Metronome item
  3007. if self.lastMoveUsed==thismove.id
  3008. self.effects[PBEffects::Metronome]+=1
  3009. else
  3010. self.effects[PBEffects::Metronome]=0
  3011. end
  3012. # "X used Y!" message
  3013. case thismove.pbDisplayUseMessage(self)
  3014. when 2 # Continuing Bide
  3015. return
  3016. when 1 # Starting Bide
  3017. self.lastMoveUsed=thismove.id
  3018. self.lastMoveUsedType=thismove.pbType(thismove.type,self,nil)
  3019. if !turneffects[PBEffects::SpecialUsage]
  3020. self.lastMoveUsedSketch=thismove.id if self.effects[PBEffects::TwoTurnAttack]==0
  3021. self.lastRegularMoveUsed=thismove.id
  3022. end
  3023. @battle.lastMoveUsed=thismove.id
  3024. @battle.lastMoveUser=self.index
  3025. @battle.successStates[self.index].useState=2
  3026. @battle.successStates[self.index].typemod=8
  3027. return
  3028. when -1 # Was hurt while readying Focus Punch, fails use
  3029. self.lastMoveUsed=thismove.id
  3030. self.lastMoveUsedType=thismove.pbType(thismove.type,self,nil)
  3031. if !turneffects[PBEffects::SpecialUsage]
  3032. self.lastMoveUsedSketch=thismove.id if self.effects[PBEffects::TwoTurnAttack]==0
  3033. self.lastRegularMoveUsed=thismove.id
  3034. end
  3035. @battle.lastMoveUsed=thismove.id
  3036. @battle.lastMoveUser=self.index
  3037. @battle.successStates[self.index].useState=2 # somehow treated as a success
  3038. @battle.successStates[self.index].typemod=8
  3039. PBDebug.log("[Movimiento falló] #{pbThis} fue dañado mientras preparaba el Puño Certero")
  3040. return
  3041. end
  3042. # Find the user and target(s)
  3043. targets=[]
  3044. user=pbFindUser(choice,targets)
  3045. # Battle Arena only - assume failure
  3046. @battle.successStates[user.index].useState=1
  3047. @battle.successStates[user.index].typemod=8
  3048. # Check whether Selfdestruct works
  3049. if !thismove.pbOnStartUse(user) # Selfdestruct, Natural Gift, Beat Up can return false here
  3050. PBDebug.log(sprintf("[Movimiento falló] Falló pbOnStartUse (código de función %02X)",thismove.function))
  3051. user.lastMoveUsed=thismove.id
  3052. user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  3053. if !turneffects[PBEffects::SpecialUsage]
  3054. user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  3055. user.lastRegularMoveUsed=thismove.id
  3056. end
  3057. @battle.lastMoveUsed=thismove.id
  3058. @battle.lastMoveUser=user.index
  3059. return
  3060. end
  3061. # Mar del Albor, Tierra del Ocaso
  3062. if thismove.pbIsDamaging?
  3063. case @battle.pbWeather
  3064. when PBWeather::HEAVYRAIN
  3065. if isConst?(thismove.pbType(thismove.type,user,nil),PBTypes,:FIRE)
  3066. PBDebug.log("[Movimiento falló] La lluvia del Mar del Albor anuló el ataque de tipo fuego #{thismove.name}")
  3067. @battle.pbDisplay(_INTL("¡El ataque de tipo Fuego desapareció en medio del diluvio!"))
  3068. user.lastMoveUsed=thismove.id
  3069. user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  3070. if !turneffects[PBEffects::SpecialUsage]
  3071. user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  3072. user.lastRegularMoveUsed=thismove.id
  3073. end
  3074. @battle.lastMoveUsed=thismove.id
  3075. @battle.lastMoveUser=user.index
  3076. return
  3077. end
  3078. when PBWeather::HARSHSUN
  3079. if isConst?(thismove.pbType(thismove.type,user,nil),PBTypes,:WATER)
  3080. PBDebug.log("[Movimiento falló] El sol de la Tierra del Ocaso anuló el ataque de tipo Agua #{thismove.name}")
  3081. @battle.pbDisplay(_INTL("¡El ataque de tipo Agua se evaporó por la fuerza del sol abrazador!"))
  3082. user.lastMoveUsed=thismove.id
  3083. user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  3084. if !turneffects[PBEffects::SpecialUsage]
  3085. user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  3086. user.lastRegularMoveUsed=thismove.id
  3087. end
  3088. @battle.lastMoveUsed=thismove.id
  3089. @battle.lastMoveUser=user.index
  3090. return
  3091. end
  3092. end
  3093. end
  3094. # Polvo Explosivo
  3095. if user.effects[PBEffects::Powder] && isConst?(thismove.pbType(thismove.type,user,nil),PBTypes,:FIRE)
  3096. PBDebug.log("[Efecto prolongado disparado] Polvo Explosivo de anuló el movimiento de tipo Fuego")
  3097. @battle.pbCommonAnimation("Powder",user,nil)
  3098. @battle.pbDisplay(_INTL("¡Cuando las llamas tocaron el polvo que cubría al Pokémon, éste explotó!"))
  3099. user.pbReduceHP(1+(user.totalhp/4).floor) if !user.hasWorkingAbility(:MAGICGUARD)
  3100. user.lastMoveUsed=thismove.id
  3101. user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  3102. if !turneffects[PBEffects::SpecialUsage]
  3103. user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  3104. user.lastRegularMoveUsed=thismove.id
  3105. end
  3106. @battle.lastMoveUsed=thismove.id
  3107. @battle.lastMoveUser=user.index
  3108. user.pbFaint if user.isFainted?
  3109. pbEndTurn(choice)
  3110. return
  3111. end
  3112. # Mutatipo
  3113. if user.hasWorkingAbility(:PROTEAN) &&
  3114. thismove.function!=0xAE && # Mirror Move
  3115. thismove.function!=0xAF && # Copycat
  3116. thismove.function!=0xB0 && # Me First
  3117. thismove.function!=0xB3 && # Nature Power
  3118. thismove.function!=0xB4 && # Sleep Talk
  3119. thismove.function!=0xB5 && # Assist
  3120. thismove.function!=0xB6 # Metronome
  3121. movetype=thismove.pbType(thismove.type,user,nil)
  3122. if !user.pbHasType?(movetype)
  3123. typename=PBTypes.getName(movetype)
  3124. PBDebug.log("[Habilidad disparada] Mutatipo de #{pbThis} lo hizo de tipo #{typename}")
  3125. user.type1=movetype
  3126. user.type2=movetype
  3127. user.effects[PBEffects::Type3]=-1
  3128. @battle.pbDisplay(_INTL("¡{1} se ha transformado en tipo {2}!",user.pbThis,typename))
  3129. end
  3130. end
  3131. # Try to use move against user if there aren't any targets
  3132. if targets.length==0
  3133. user=pbChangeUser(thismove,user)
  3134. if thismove.target==PBTargets::SingleNonUser ||
  3135. thismove.target==PBTargets::RandomOpposing ||
  3136. thismove.target==PBTargets::AllOpposing ||
  3137. thismove.target==PBTargets::AllNonUsers ||
  3138. thismove.target==PBTargets::Partner ||
  3139. thismove.target==PBTargets::UserOrPartner ||
  3140. thismove.target==PBTargets::SingleOpposing ||
  3141. thismove.target==PBTargets::OppositeOpposing
  3142. @battle.pbDisplay(_INTL("Pero no hay objetivo..."))
  3143. else
  3144. PBDebug.logonerr{
  3145. thismove.pbEffect(user,nil)
  3146. }
  3147. end
  3148. else
  3149. # We have targets
  3150. showanimation=true
  3151. alltargets=[]
  3152. for i in 0...targets.length
  3153. alltargets.push(targets[i].index) if !targets.include?(targets[i].index)
  3154. end
  3155. # For each target in turn
  3156. i=0; loop do break if i>=targets.length
  3157. # Get next target
  3158. userandtarget=[user,targets[i]]
  3159. success=pbChangeTarget(thismove,userandtarget,targets)
  3160. user=userandtarget[0]
  3161. target=userandtarget[1]
  3162. if i==0 && thismove.target==PBTargets::AllOpposing
  3163. # Add target's partner to list of targets
  3164. pbAddTarget(targets,target.pbPartner)
  3165. end
  3166. # If couldn't get the next target
  3167. if !success
  3168. i+=1
  3169. next
  3170. end
  3171. # Get the number of hits
  3172. numhits=thismove.pbNumHits(user)
  3173. # Reset damage state, set Focus Band/Focus Sash to available
  3174. target.damagestate.reset
  3175. # Use move against the current target
  3176. pbProcessMoveAgainstTarget(thismove,user,target,numhits,turneffects,false,alltargets,showanimation)
  3177. showanimation=false
  3178. i+=1
  3179. end
  3180. end
  3181. # Pokémon switching caused by Roar, Whirlwind, Circle Throw, Dragon Tail, Red Card
  3182. if !user.isFainted?
  3183. switched=[]
  3184. for i in 0...4
  3185. if @battle.battlers[i].effects[PBEffects::Roar]
  3186. @battle.battlers[i].effects[PBEffects::Roar]=false
  3187. @battle.battlers[i].effects[PBEffects::Uturn]=false
  3188. next if @battle.battlers[i].isFainted?
  3189. next if [email protected]?(i,-1,false)
  3190. choices=[]
  3191. for j in 0...party.length
  3192. choices.push(j) if @battle.pbCanSwitchLax?(i,j,false)
  3193. end
  3194. if choices.length>0
  3195. newpoke=choices[@battle.pbRandom(choices.length)]
  3196. newpokename=newpoke
  3197. if isConst?(party[newpoke].ability,PBAbilities,:ILLUSION)
  3198. newpokename=pbGetLastPokeInTeam(i)
  3199. end
  3200. switched.push(i)
  3201. @battle.battlers[i].pbResetForm
  3202. @battle.pbRecallAndReplace(i,newpoke,newpokename,false,user.hasMoldBreaker)
  3203. @battle.pbDisplay(_INTL("¡{1} ha sido arrastrado!",@battle.battlers[i].pbThis))
  3204. @battle.choices[i]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
  3205. end
  3206. end
  3207. end
  3208. for i in @battle.pbPriority
  3209. next if !switched.include?(i.index)
  3210. i.pbAbilitiesOnSwitchIn(true)
  3211. end
  3212. end
  3213. # Pokémon switching caused by U-Turn, Volt Switch, Eject Button
  3214. switched=[]
  3215. for i in 0...4
  3216. if @battle.battlers[i].effects[PBEffects::Uturn]
  3217. @battle.battlers[i].effects[PBEffects::Uturn]=false
  3218. @battle.battlers[i].effects[PBEffects::Roar]=false
  3219. if [email protected][i].isFainted? && @battle.pbCanChooseNonActive?(i) &&
  3220. [email protected]?(@battle.pbOpposingParty(i))
  3221. # TODO: Pursuit should go here, and negate this effect if it KO's attacker
  3222. @battle.pbDisplay(_INTL("¡{1} regresó con {2}!",@battle.battlers[i].pbThis,@battle.pbGetOwner(i).name))
  3223. newpoke=0
  3224. [email protected](i,true,false)
  3225. newpokename=newpoke
  3226. if isConst?(@battle.pbParty(i)[newpoke].ability,PBAbilities,:ILLUSION)
  3227. newpokename=pbGetLastPokeInTeam(i)
  3228. end
  3229. switched.push(i)
  3230. @battle.battlers[i].pbResetForm
  3231. @battle.pbRecallAndReplace(i,newpoke,newpokename,@battle.battlers[i].effects[PBEffects::BatonPass])
  3232. @battle.choices[i]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
  3233. end
  3234. end
  3235. end
  3236. for i in @battle.pbPriority
  3237. next if !switched.include?(i.index)
  3238. i.pbAbilitiesOnSwitchIn(true)
  3239. end
  3240. # Baton Pass
  3241. if user.effects[PBEffects::BatonPass]
  3242. user.effects[PBEffects::BatonPass]=false
  3243. if !user.isFainted? && @battle.pbCanChooseNonActive?(user.index) &&
  3244. [email protected]?(@battle.pbParty(user.index))
  3245. newpoke=0
  3246. [email protected](user.index,true,false)
  3247. newpokename=newpoke
  3248. if isConst?(@battle.pbParty(user.index)[newpoke].ability,PBAbilities,:ILLUSION)
  3249. newpokename=pbGetLastPokeInTeam(user.index)
  3250. end
  3251. user.pbResetForm
  3252. @battle.pbRecallAndReplace(user.index,newpoke,newpokename,true)
  3253. @battle.choices[user.index]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
  3254. user.pbAbilitiesOnSwitchIn(true)
  3255. end
  3256. end
  3257. # Record move as having been used
  3258. user.lastMoveUsed=thismove.id
  3259. user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  3260. if !turneffects[PBEffects::SpecialUsage]
  3261. user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  3262. user.lastRegularMoveUsed=thismove.id
  3263. user.movesUsed.push(thismove.id) if !user.movesUsed.include?(thismove.id) # For Last Resort
  3264. end
  3265. @battle.lastMoveUsed=thismove.id
  3266. @battle.lastMoveUser=user.index
  3267. # Gain Exp
  3268. @battle.pbGainEXP
  3269. # Battle Arena only - update skills
  3270. for i in 0...4
  3271. @battle.successStates[i].updateSkill
  3272. end
  3273. # End of move usage
  3274. pbEndTurn(choice)
  3275. @battle.pbJudge # @battle.pbSwitch
  3276. return
  3277. end
  3278.  
  3279. def pbCancelMoves
  3280. # If failed pbTryUseMove or have already used Pursuit to chase a switching foe
  3281. # Cancel multi-turn attacks (note: Hyper Beam effect is not canceled here)
  3282. @effects[PBEffects::TwoTurnAttack]=0 if @effects[PBEffects::TwoTurnAttack]>0
  3283. @effects[PBEffects::Outrage]=0
  3284. @effects[PBEffects::Rollout]=0
  3285. @effects[PBEffects::Uproar]=0
  3286. @effects[PBEffects::Bide]=0
  3287. @currentMove=0
  3288. # Reset counters for moves which increase them when used in succession
  3289. @effects[PBEffects::FuryCutter]=0
  3290. PBDebug.log("Cancelled using the move")
  3291. end
  3292.  
  3293. ################################################################################
  3294. # Turn processing
  3295. ################################################################################
  3296. def pbBeginTurn(choice)
  3297. # Cancel some lingering effects which only apply until the user next moves
  3298. @effects[PBEffects::DestinyBond]=false
  3299. @effects[PBEffects::Grudge]=false
  3300. # Reset Parental Bond's count
  3301. @effects[PBEffects::ParentalBond]=0
  3302. # Encore's effect ends if the encored move is no longer available
  3303. if @effects[PBEffects::Encore]>0 &&
  3304. @moves[@effects[PBEffects::EncoreIndex]].id!=@effects[PBEffects::EncoreMove]
  3305. PBDebug.log("Resetting Encore effect")
  3306. @effects[PBEffects::Encore]=0
  3307. @effects[PBEffects::EncoreIndex]=0
  3308. @effects[PBEffects::EncoreMove]=0
  3309. end
  3310. # Wake up in an uproar
  3311. if self.status==PBStatuses::SLEEP && !self.hasWorkingAbility(:SOUNDPROOF)
  3312. for i in 0...4
  3313. if @battle.battlers[i].effects[PBEffects::Uproar]>0
  3314. pbCureStatus(false)
  3315. @battle.pbDisplay(_INTL("¡{1} se despertó con el Alboroto!",pbThis))
  3316. end
  3317. end
  3318. end
  3319. end
  3320.  
  3321. def pbEndTurn(choice)
  3322. # True end(?)
  3323. if @effects[PBEffects::ChoiceBand]<0 && @lastMoveUsed>=0 && !self.isFainted? &&
  3324. (self.hasWorkingItem(:CHOICEBAND) ||
  3325. self.hasWorkingItem(:CHOICESPECS) ||
  3326. self.hasWorkingItem(:CHOICESCARF))
  3327. @effects[PBEffects::ChoiceBand]=@lastMoveUsed
  3328. end
  3329. @battle.pbPrimordialWeather
  3330. for i in 0...4
  3331. @battle.battlers[i].pbBerryCureCheck
  3332. end
  3333. for i in 0...4
  3334. @battle.battlers[i].pbAbilityCureCheck
  3335. end
  3336. for i in 0...4
  3337. @battle.battlers[i].pbAbilitiesOnSwitchIn(false)
  3338. end
  3339. for i in 0...4
  3340. @battle.battlers[i].pbCheckForm
  3341. end
  3342. end
  3343.  
  3344. def pbProcessTurn(choice)
  3345. # Can't use a move if fainted
  3346. return false if self.isFainted?
  3347. # Wild roaming Pokémon always flee if possible
  3348. if [email protected] && @battle.pbIsOpposing?(self.index) &&
  3349. @battle.rules["alwaysflee"] && @battle.pbCanRun?(self.index)
  3350. pbBeginTurn(choice)
  3351. @battle.pbDisplay(_INTL("¡{1} ha huido!",self.pbThis))
  3352. @battle.decision=3
  3353. pbEndTurn(choice)
  3354. PBDebug.log("[Huida] #{pbThis} ha huido")
  3355. return true
  3356. end
  3357. # If this battler's action for this round wasn't "use a move"
  3358. if choice[0]!=1
  3359. # Clean up effects that end at battler's turn
  3360. pbBeginTurn(choice)
  3361. pbEndTurn(choice)
  3362. return false
  3363. end
  3364. # Turn is skipped if Pursuit was used during switch
  3365. if @effects[PBEffects::Pursuit]
  3366. @effects[PBEffects::Pursuit]=false
  3367. pbCancelMoves
  3368. pbEndTurn(choice)
  3369. @battle.pbJudge # @battle.pbSwitch
  3370. return false
  3371. end
  3372. # Use the move
  3373. # @battle.pbDisplayPaused("Before: [#{@lastMoveUsedSketch},#{@lastMoveUsed}]")
  3374. PBDebug.log("#{pbThis} usó #{choice[2].name}")
  3375. PBDebug.logonerr{
  3376. pbUseMove(choice,choice[2][email protected])
  3377. }
  3378. # @battle.pbDisplayPaused("After: [#{@lastMoveUsedSketch},#{@lastMoveUsed}]")
  3379. return true
  3380. end
  3381. end
Add Comment
Please, Sign In to add comment