Kid02

help

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