Lucidious89

Custom Abilities

Dec 28th, 2020 (edited)
2,850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 62.09 KB | None | 0 0
  1. ############[CUSTOM ABILITIES]##################################################
  2. #===============================================================================
  3. # General additions for custom abilities.
  4. #===============================================================================
  5. # Adds a new ability type that triggers at the beginning of the round.
  6. module BattleHandlers
  7.   SOREffectAbility = AbilityHandlerHash.new
  8.  
  9.   def self.triggerSOREffectAbility(ability,battler,battle)
  10.     SOREffectAbility.trigger(ability,battler,battle)
  11.   end
  12. end
  13.  
  14. #===============================================================================
  15. # Custom Ability #1 - Leeching Fangs
  16. #===============================================================================
  17. BattleHandlers::UserAbilityOnHit.add(:LEECHINGFANGS,
  18.   proc { |ability,user,target,move,battle|
  19.     next false if !move.pbContactMove?(user)
  20.     next false if !move.bitingMove?
  21.     changehp=(user.totalhp/16).floor
  22.     changehp*=1.3 if user.hasActiveItem?(:BIGROOT)
  23.     if target.hasActiveAbility?(:LIQUIDOOZE) && target.abilityActive?(true)
  24.       battle.pbShowAbilitySplash(user)
  25.       battle.pbShowAbilitySplash(target)
  26.       user.pbReduceHP(changehp,true)
  27.       if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
  28.         battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",user.pbThis))
  29.       end
  30.       battle.pbHideAbilitySplash(user)
  31.       battle.pbHideAbilitySplash(target)
  32.       user.pbFaint if user.fainted?
  33.       next
  34.     else
  35.       if user.canHeal?
  36.         battle.pbShowAbilitySplash(user)
  37.         user.pbRecoverHP(changehp,true)
  38.         battle.pbDisplay(_INTL("{1} drained HP with {2}!",user.pbThis,user.abilityName))
  39.         battle.pbHideAbilitySplash(user)
  40.       end
  41.     end
  42.   }
  43. )
  44.  
  45. #===============================================================================
  46. # Custom Ability #2 - Echo-Lock
  47. #===============================================================================
  48. BattleHandlers::AccuracyCalcUserAbility.add(:ECHOLOCK,
  49.   proc { |ability,mods,user,target,move,type|
  50.     mods[BASE_ACC] = 0 if move.soundMove?
  51.   }
  52. )
  53.  
  54. #===============================================================================
  55. # Custom Ability #3 - Inflatable
  56. #===============================================================================
  57. # Added def windMove? in "PokeBattle_Move"
  58. # Must add "q" flag to all appropriate moves in moves PBS file
  59.  
  60. BattleHandlers::MoveImmunityTargetAbility.add(:INFLATABLE,
  61.   proc { |ability,user,target,move,type,battle|
  62.     next false if !move.windMove?
  63.     next false if !target.pbCanRaiseStatStage?(PBStats::DEFENSE,target)
  64.     target.pbRaiseStatStageByAbility(PBStats::DEFENSE,1,target)
  65.     target.effects[PBEffects::WeightChange]+=25
  66.     next true
  67.    
  68.   }
  69. )
  70.  
  71. #===============================================================================
  72. # Custom Ability #4 - Wind Rider
  73. #===============================================================================
  74. # Added def windMove? in "PokeBattle_Move"
  75. # Must add "q" flag to all appropriate moves in moves PBS file
  76.  
  77. BattleHandlers::MoveImmunityTargetAbility.add(:WINDRIDER,
  78.   proc { |ability,user,target,move,type,battle|
  79.     next false if !move.windMove?
  80.     next false if !target.pbCanRaiseStatStage?(PBStats::SPEED,target)
  81.     target.pbRaiseStatStageByAbility(PBStats::SPEED,1,target)
  82.     target.effects[PBEffects::WeightChange]-=25
  83.     next true
  84.    
  85.   }
  86. )
  87.  
  88. BattleHandlers::SpeedCalcAbility.add(:WINDRIDER,
  89.   proc { |ability,battler,mult|
  90.     w = battler.battle.pbWeather
  91.     next mult*2 if w==PBWeather::StrongWinds
  92.   }
  93. )
  94.  
  95. #===============================================================================
  96. # Custom Ability #5 - Cannon Fire
  97. #===============================================================================
  98. BattleHandlers::DamageCalcUserAbility.add(:CANNONFIRE,
  99.   proc { |ability,user,target,move,mults,baseDmg,type|
  100.     mults[BASE_DMG_MULT] *= 1.5 if move.bombMove?
  101.   }
  102. )
  103.  
  104. #===============================================================================
  105. # Custom Ability #6 - Sharpshooter
  106. #===============================================================================
  107. # Redirection immunity added to "def pbChangeTargets"
  108.  
  109. BattleHandlers::AccuracyCalcUserAbility.add(:SHARPSHOOTER,
  110.   proc { |ability,mods,user,target,move,type|
  111.     mods[BASE_ACC] = 0 if move.damagingMove? && !move.contactMove?
  112.   }
  113. )
  114.  
  115. #===============================================================================
  116. # Custom Ability #7 - Sharp Edge
  117. #===============================================================================
  118. # Added def swordMove? in "PokeBattle_Move"
  119. # Must add "p" flag to all appropriate moves in moves PBS file
  120.  
  121. BattleHandlers::DamageCalcUserAbility.add(:SHARPEDGE,
  122.   proc { |ability,user,target,move,mults,baseDmg,type|
  123.     mults[BASE_DMG_MULT] *= 1.2 if move.swordMove?
  124.   }
  125. )
  126.  
  127. #===============================================================================
  128. # Custom Ability #8 - Spellcaster
  129. #===============================================================================
  130. BattleHandlers::DamageCalcUserAbility.add(:SPELLCASTER,
  131.   proc { |ability,user,target,move,mults,baseDmg,type|
  132.     if (isConst?(move.type,PBTypes,:ICE) ||
  133.         isConst?(move.type,PBTypes,:FIRE) ||
  134.         isConst?(move.type,PBTypes,:ELECTRIC)) && move.specialMove?
  135.       spellmove=true
  136.     end
  137.     mults[BASE_DMG_MULT] *= 1.2 if spellmove
  138.   }
  139. )
  140.  
  141. #===============================================================================
  142. # Custom Ability #9 - Icy Veins
  143. #===============================================================================
  144. # Hail immunity added to "def takesHailDamage?"
  145.  
  146. BattleHandlers::DamageCalcUserAbility.add(:ICYVEINS,
  147.   proc { |ability,user,target,move,mults,baseDmg,type|
  148.     if user.battle.pbWeather==PBWeather::Hail &&
  149.        (isConst?(type,PBTypes,:ICE) || isConst?(type,PBTypes,:WATER))
  150.       mults[BASE_DMG_MULT] *= 1.3
  151.     end
  152.   }
  153. )
  154.  
  155. #===============================================================================
  156. # Custom Ability #10 - Crystallized
  157. #===============================================================================
  158. # Damage reduction added to "DamageCalcTargetAbility.copy"
  159.  
  160. #===============================================================================
  161. # Custom Ability #11 - Cold Blooded
  162. #===============================================================================
  163. BattleHandlers::DamageCalcTargetAbility.add(:COLDBLOODED,
  164.   proc { |ability,user,target,move,mults,baseDmg,type|
  165.     if isConst?(type,PBTypes,:FIRE)
  166.       mults[BASE_DMG_MULT] *= 0.75
  167.     elsif isConst?(type,PBTypes,:ICE)
  168.       mults[BASE_DMG_MULT] *= 1.25
  169.     end
  170.   }
  171. )
  172.  
  173. BattleHandlers::SpeedCalcAbility.add(:COLDBLOODED,
  174.   proc { |ability,battler,mult|
  175.     w = battler.battle.pbWeather
  176.     next mult/1.5.floor if w==PBWeather::Hail
  177.     next mult*1.5.floor if w==PBWeather::Sun || w==PBWeather::HarshSun
  178.   }
  179. )
  180.  
  181. BattleHandlers::TargetAbilityOnHit.add(:COLDBLOODED,
  182.   proc { |ability,user,target,move,battle|
  183.     if isConst?(move.calcType,PBTypes,:FIRE) &&
  184.        target.pbCanRaiseStatStage?(PBStats::SPEED,target)
  185.       target.pbRaiseStatStageByAbility(PBStats::SPEED,1,target)
  186.     end
  187.     if isConst?(move.calcType,PBTypes,:ICE) &&
  188.        target.pbCanLowerStatStage?(PBStats::SPEED,target)
  189.       target.pbLowerStatStageByAbility(PBStats::SPEED,1,target)
  190.     end
  191.   }
  192. )
  193.  
  194. #===============================================================================
  195. # Custom Ability #12 - Iron Hide
  196. #===============================================================================
  197. BattleHandlers::TargetAbilityOnHit.add(:IRONHIDE,
  198.   proc { |ability,user,target,move,battle|
  199.     next false if !isConst?(move.calcType,PBTypes,:WATER)
  200.     target.pbLowerStatStageByAbility(PBStats::SPEED,1,target)
  201.   }
  202. )
  203.  
  204. BattleHandlers::DamageCalcTargetAbility.add(:IRONHIDE,
  205.   proc { |ability,user,target,move,mults,baseDmg,type|
  206.     mults[FINAL_DMG_MULT] /= 2 if move.contactMove?
  207.   }
  208. )
  209.  
  210. #===============================================================================
  211. # Custom Ability #13 - Ethereal Body
  212. #===============================================================================
  213. BattleHandlers::MoveImmunityTargetAbility.add(:ETHEREALBODY,
  214.   proc { |ability,user,target,move,type,battle|
  215.     next false if !move.pbContactMove?(user)
  216.     battle.pbShowAbilitySplash(target)
  217.     if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
  218.       battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
  219.     else
  220.       battle.pbDisplay(_INTL("{1}'s {2} makes {3} ineffective!",target.pbThis,target.abilityName,move.name))
  221.     end
  222.     battle.pbHideAbilitySplash(target)
  223.     next true
  224.   }
  225. )
  226.  
  227. #===============================================================================
  228. # Custom Ability #14 - Phantom Image
  229. #===============================================================================
  230. BattleHandlers::AccuracyCalcTargetAbility.add(:PHANTOMIMAGE,
  231.   proc { |ability,mods,user,target,move,type|
  232.     if target.speed>=user.speed*2
  233.       mods[EVA_MULT] *= 2
  234.     elsif target.speed>=user.speed*1.5
  235.       mods[EVA_MULT] *= 1.5
  236.     elsif target.speed>=user.speed*1.25
  237.       mods[EVA_MULT] *= 1.25
  238.     end
  239.   }
  240. )
  241.  
  242. #===============================================================================
  243. # Custom Ability #15 - Patriarchy
  244. #===============================================================================
  245. BattleHandlers::DamageCalcUserAbility.add(:PATRIARCHY,
  246.   proc { |ability,user,target,move,mults,baseDmg,type|
  247.     onlymales = true
  248.     user.eachAlly do |b|
  249.       onlymales = false if b.gender==1 || b.gender==2
  250.     end
  251.     mults[BASE_DMG_MULT] *= 1.25 if onlymales
  252.   }
  253. )
  254.  
  255. BattleHandlers::DamageCalcUserAllyAbility.add(:PATRIARCHY,
  256.   proc { |ability,user,target,move,mults,baseDmg,type|
  257.     onlymales = true
  258.     user.eachAlly do |b|
  259.       onlymales = false if b.gender==1 || b.gender==2
  260.     end
  261.     mults[BASE_DMG_MULT] *= 1.25 if onlymales
  262.   }
  263. )
  264.  
  265. #===============================================================================
  266. # Custom Ability #16 - Matriarchy
  267. #===============================================================================
  268. BattleHandlers::DamageCalcUserAbility.add(:MATRIARCHY,
  269.   proc { |ability,user,target,move,mults,baseDmg,type|
  270.     onlyfemales = true
  271.     user.eachAlly do |b|
  272.       onlyfemales = false if b.gender==0 || b.gender==2
  273.     end
  274.     mults[BASE_DMG_MULT] *= 1.25 if onlyfemales
  275.   }
  276. )
  277.  
  278. BattleHandlers::DamageCalcUserAllyAbility.add(:MATRIARCHY,
  279.   proc { |ability,user,target,move,mults,baseDmg,type|
  280.     onlyfemales = true
  281.     user.eachAlly do |b|
  282.       onlyfemales = false if b.gender==0 || b.gender==2
  283.     end
  284.     mults[BASE_DMG_MULT] *= 1.25 if onlyfemales
  285.   }
  286. )
  287.  
  288. #===============================================================================
  289. # Custom Ability #17 - Underdog
  290. #===============================================================================
  291. BattleHandlers::DamageCalcUserAbility.add(:UNDERDOG,
  292.   proc { |ability,user,target,move,mults,baseDmg,type|
  293.     userstage = 0
  294.     targstage = 0
  295.     for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,PBStats::SPATK,
  296.               PBStats::SPDEF,PBStats::EVASION,PBStats::ACCURACY]
  297.       if user.stages[i]>0; userstage+=user.stages[i]; end
  298.       if target.stages[i]>0; targstage+=target.stages[i]; end
  299.     end
  300.     bonus  = 1
  301.     bonus += 0.5 if targstage>=userstage+6
  302.     bonus += 0.3 if targstage>=userstage+3
  303.     bonus += 0.2 if targstage>=userstage+1
  304.     bonus += 0.5 if target.level>=user.level+10
  305.     bonus += 0.3 if user.hp<=user.totalhp/8 && target.hp>=target.totalhp/2
  306.     bonus += 0.2 if user.status>0 && target.status==0
  307.     mults[BASE_DMG_MULT] *= bonus
  308.   }
  309. )
  310.  
  311. #===============================================================================
  312. # Custom Ability #18 - Pack Leader
  313. #===============================================================================
  314. BattleHandlers::AbilityOnSwitchIn.add(:PACKLEADER,
  315.   proc { |ability,battler,battle|
  316.     next false if battle.pbAbleCount(battler)<4
  317.     next false if battle.pbTeamLengthFromBattlerIndex(battler)<4
  318.     next false if battle.pbParty(battler)[0] != battler.pokemon
  319.     battle.pbShowAbilitySplash(battler)
  320.     battle.pbDisplay(_INTL("{1} leads the pack!",battler.pbThis))
  321.     battle.pbHideAbilitySplash(battler)
  322.   }
  323. )
  324.  
  325. BattleHandlers::DamageCalcUserAbility.add(:PACKLEADER,
  326.   proc { |ability,user,target,move,mults,baseDmg,type|
  327.     next false if user.battle.pbAbleCount(user)<4
  328.     next false if user.battle.pbTeamLengthFromBattlerIndex(user)<4
  329.     next false if user.battle.pbParty(user)[0] != user.pokemon
  330.     mults[BASE_DMG_MULT] *= 1.5
  331.   }
  332. )
  333.  
  334. #===============================================================================
  335. # Custom Ability #19 - Pounce
  336. #===============================================================================
  337. BattleHandlers::PriorityChangeAbility.add(:POUNCE,
  338.   proc { |ability,battler,move,pri|
  339.     next pri+1 if battler.turnCount==1
  340.   }
  341. )
  342.  
  343. #===============================================================================
  344. # Custom Ability #20 - Nine Lives
  345. #===============================================================================
  346. # Damage and life reduction added to "def pbReduceDamage"
  347. # Survival message added to "def pbEndureKOMessage"
  348. # Life counter reset added to "def pbEndOfBattle"
  349. # Destiny Bond survival added to "def pbEffectsAfterMove"
  350. # Perish Song survival added to "def pbEndOfRoundPhase"
  351. # OHKO survival added to "class PokeBattle_Move_070"
  352.  
  353. BattleHandlers::AbilityOnSwitchIn.add(:NINELIVES,
  354.   proc { |ability,battler,battle|
  355.     if battler.lives>0
  356.       battle.pbShowAbilitySplash(battler)
  357.       text="life" if battler.lives==1
  358.       text="lives" if battler.lives>1
  359.       battle.pbDisplay(_INTL("{1} has {2} {3} to spare!",battler.pbThis,battler.lives,text))
  360.       battle.pbHideAbilitySplash(battler)
  361.     end
  362.   }
  363. )
  364.  
  365. class PokeBattle_Pokemon
  366.   attr_accessor :ninelives
  367.   def lives
  368.     return @ninelives || 9
  369.   end
  370.  
  371.   def lives=(value)
  372.     @ninelives=value
  373.   end
  374. end
  375.  
  376. class PokeBattle_Battler
  377.   def lives; return @pokemon ? @pokemon.lives : 0; end
  378. end
  379.  
  380. #===============================================================================
  381. # Custom Ability #21 - Bad Blood
  382. #===============================================================================
  383. BattleHandlers::AbilityOnSwitchIn.add(:BADBLOOD,
  384.   proc { |ability,battler,battle|
  385.     battle.eachBattler do |b|
  386.       next if !b.hasActiveAbility?(:BADBLOOD)
  387.       next if b.species == battler.species
  388.       battle.pbShowAbilitySplash(battler)
  389.       battle.pbDisplay(_INTL("{1} became enraged at the presence of a rival!",
  390.         battler.pbThis,b.pbThis(true)))
  391.       battle.pbHideAbilitySplash(battler)
  392.       break
  393.     end
  394.   }
  395. )
  396.  
  397. BattleHandlers::TrappingTargetAbility.add(:BADBLOOD,
  398.   proc { |ability,switcher,bearer,battle|
  399.     next true if switcher.hasActiveAbility(:BADBLOOD) &&
  400.                  switcher.species != bearer.species
  401.   }
  402. )
  403.  
  404. BattleHandlers::EOREffectAbility.add(:BADBLOOD,
  405.   proc { |ability,battler,battle|
  406.     feuds = 0
  407.     battle.eachBattler do |b|
  408.       next if b.index == battler.index
  409.       next if b.species == battler.species
  410.       next if !b.hasActiveAbility?(:BADBLOOD)
  411.       feuds +=1
  412.     end
  413.     if feuds>0 && battler.pbCanRaiseStatStage?(PBStats::ATTACK,battler)
  414.       battler.pbRaiseStatStageByAbility(PBStats::ATTACK,feuds,battler)
  415.     end
  416.   }
  417. )
  418.  
  419. #===============================================================================
  420. # Custom Ability #22 - Wild Tantrum
  421. #===============================================================================
  422. BattleHandlers::AbilityOnSwitchIn.add(:WILDTANTRUM,
  423.   proc { |ability,battler,battle|
  424.     battle.pbShowAbilitySplash(battler)
  425.     battler.effects[PBEffects::Rage] = true
  426.     battle.pbDisplay(_INTL("{1}'s rage is out of control!",battler.pbThis))
  427.     battle.pbHideAbilitySplash(battler)
  428.   }
  429. )
  430.  
  431. #===============================================================================
  432. # Custom Ability #23 - Headache
  433. #===============================================================================
  434. BattleHandlers::EOREffectAbility.add(:HEADACHE,
  435.   proc { |ability,battler,battle|
  436.     next if battler.effects[PBEffects::Confusion]==0
  437.     if battler.pbCanRaiseStatStage?(PBStats::SPATK,battler)
  438.       battler.pbRaiseStatStageByAbility(PBStats::SPATK,1,battler)
  439.     end
  440.   }
  441. )
  442.  
  443. #===============================================================================
  444. # Custom Ability #24 - Numbing Poison
  445. #===============================================================================
  446. # Paralysis effects added to "class PokeBattle_PoisonMove"
  447.  
  448. #===============================================================================
  449. # Custom Ability #25 - Searing Poison
  450. #===============================================================================
  451. # Burn effects added to "class PokeBattle_PoisonMove"
  452.  
  453. #===============================================================================
  454. # Custom Ability #26 - Outbreak
  455. #===============================================================================
  456. BattleHandlers::TargetAbilityOnHit.add(:OUTBREAK,
  457.   proc { |ability,user,target,move,battle|
  458.     next false if !move.pbContactMove?(user)
  459.     next false if user.status!=0
  460.     next false if target.status==0 || target.asleep? || target.frozen?
  461.     battle.pbShowAbilitySplash(target)
  462.     msg = nil
  463.     if target.poisoned?
  464.       if user.pbCanPoison?(target,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) &&
  465.          user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
  466.         msg = _INTL("{1}'s {2} spread its poison to {3}!",target.pbThis,target.abilityName,user.pbThis(true))
  467.         user.pbPoison(target,msg)
  468.       end
  469.     elsif target.burned?
  470.       if user.pbCanBurn?(target,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) &&
  471.          user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
  472.         msg = _INTL("{1}'s {2} spread its burn to {3}!",target.pbThis,target.abilityName,user.pbThis(true))
  473.         user.pbBurn(target,msg)
  474.       end
  475.     elsif target.paralyzed?
  476.       if user.pbCanParalyze?(target,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) &&
  477.          user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
  478.         msg = _INTL("{1}'s {2} spread its paralysis to {3}!",target.pbThis,target.abilityName,user.pbThis(true))
  479.         user.pbParalyze(target,msg)
  480.       end
  481.     end
  482.     battle.pbHideAbilitySplash(target)
  483.   }
  484. )
  485.  
  486. #===============================================================================
  487. # Custom Ability #27 - Sweet Dreams
  488. #===============================================================================
  489. BattleHandlers::EOREffectAbility.add(:SWEETDREAMS,
  490.   proc { |ability,battler,battle|
  491.     battle.eachBattler do |b|
  492.       next if !b.asleep?
  493.       next if !b.canHeal?
  494.       next if !(b.near?(battler) || b.index == battler.index)
  495.       battle.pbShowAbilitySplash(battler)
  496.       b.pbRecoverHP(b.totalhp/8,true)
  497.       if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
  498.         battle.pbDisplay(_INTL("{1} is having a sweet dream!",b.pbThis))
  499.       else
  500.         battle.pbDisplay(_INTL("{1} is soothed by {2}'s {3}!",b.pbThis,
  501.            battler.pbThis(true),battler.abilityName))
  502.       end
  503.       battle.pbHideAbilitySplash(battler)  
  504.     end
  505.   }
  506. )
  507.  
  508. #===============================================================================
  509. # Custom Ability #28 - Night Terrors
  510. #===============================================================================
  511. BattleHandlers::EOREffectAbility.add(:NIGHTTERRORS,
  512.   proc { |ability,battler,battle|
  513.     bearer = battle.pbCheckGlobalAbility(:SWEETDREAMS)
  514.     next false if !battler.asleep?
  515.     next false if bearer && bearer.near?(battler)
  516.     battle.pbShowAbilitySplash(battler)
  517.     if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
  518.       battle.pbDisplay(_INTL("{1} thrashes about in its sleep!",battler.pbThis))
  519.     else
  520.       battle.pbDisplay(_INTL("{1} thrashes about due to its {2}!",battler.pbThis,battler.abilityName))
  521.     end
  522.     battle.pbHideAbilitySplash(battler)
  523.     battle.eachBattler do |b|
  524.       next if b.semiInvulnerable?
  525.       next if !b.near?(battler)
  526.       oldHP = b.hp
  527.       b.damageState.reset
  528.       b.damageState.initialHP = b.hp
  529.       sleepMove = PokeBattle_Confusion.new(battle,nil)
  530.       sleepMove.calcType = sleepMove.pbCalcType(battler)
  531.       b.damageState.typeMod = sleepMove.pbCalcTypeMod(sleepMove.calcType,battler,b)
  532.       sleepMove.pbCalcDamage(battler,b)
  533.       bearer = battle.pbCheckGlobalAbility(:BADDREAMS)
  534.       if battler.effects[PBEffects::Nightmare] || (bearer && bearer.near?(battler))
  535.         b.damageState.calcDamage *= 2
  536.       end
  537.       sleepMove.pbReduceDamage(battler,b)
  538.       b.hp -= b.damageState.hpLost
  539.       sleepMove.pbAnimateHitAndHPLost(battler,[b])
  540.       sleepMove.pbRecordDamageLost(battler,b)
  541.       sleepMove.pbEndureKOMessage(b)
  542.       b.pbItemHPHealCheck
  543.       b.pbAbilitiesOnDamageTaken(oldHP)
  544.       b.pbFaint if b.fainted?
  545.     end
  546.   }
  547. )
  548.  
  549. #===============================================================================
  550. # Custom Ability #29 - Delivery
  551. #===============================================================================
  552. BattleHandlers::AbilityOnSwitchIn.add(:DELIVERY,
  553.   proc { |ability,battler,battle|
  554.     next false if battler.item==0 || battler.unlosableItem?(battler.item)
  555.     recipient = nil
  556.     battle.eachOtherSideBattler(battler.index) do |b|
  557.       next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
  558.       next if b.item>0 || !b.near?(battler)
  559.       if b == battler.pbDirectOpposing
  560.         recipient = b
  561.         break
  562.       end
  563.       recipient = b
  564.     end
  565.     if recipient
  566.       battle.pbShowAbilitySplash(battler)
  567.       recipient.item = battler.item
  568.       battler.item = 0
  569.       if battle.wildBattle? && recipient.initialItem==0 && battler.initialItem==recipient.item
  570.         recipient.setInitialItem(recipient.item)
  571.         battler.setInitialItem(0)
  572.       end
  573.       battle.pbDisplay(_INTL("{1}'s {2} was delivered to {3}!",battler.pbThis,
  574.           recipient.itemName,recipient.pbThis(true)))
  575.       battle.pbHideAbilitySplash(battler)
  576.       recipient.pbHeldItemTriggerCheck
  577.     end
  578.   }
  579. )
  580.  
  581. #===============================================================================
  582. # Custom Ability #30 - Graverobber
  583. #===============================================================================
  584. BattleHandlers::AbilityOnBattlerFainting.add(:GRAVEROBBER,
  585.   proc { |ability,battler,fainted,battle|
  586.     next false if battler.item>0
  587.     next false if fainted.item==0 || fainted.unlosableItem?(fainted.item)
  588.     next false if !fainted.near?(battler)
  589.     battle.pbShowAbilitySplash(battler)
  590.     battler.item = fainted.item
  591.     fainted.item = 0
  592.     if battle.wildBattle? && battler.initialItem==0 && fainted.initialItem==battler.item
  593.       battler.setInitialItem(battler.item)
  594.       fainted.setInitialItem(0)
  595.     end
  596.     battle.pbDisplay(_INTL("{1} robbed {2}'s {3}!",battler.pbThis,
  597.         fainted.pbThis(true),battler.itemName))
  598.     battle.pbHideAbilitySplash(battler)
  599.     battler.pbHeldItemTriggerCheck
  600.   }
  601. )
  602.  
  603. #===============================================================================
  604. # Custom Ability #31 - Solidarity
  605. #===============================================================================
  606. BattleHandlers::AbilityOnSwitchIn.add(:SOLIDARITY,
  607.   proc { |ability,battler,battle|
  608.     foes = []
  609.     battle.eachOtherSideBattler(battler.index) do |b|
  610.       foes.push(b) if b.nature == battler.nature
  611.     end
  612.     if foes.length>0
  613.       battle.pbShowAbilitySplash(battler)
  614.       foes.each do |b|
  615.         battle.pbDisplay(_INTL("{1} shares a common nature with {2}!",
  616.            battler.pbThis,b.pbThis(true)))
  617.       end
  618.       battle.pbHideAbilitySplash(battler)
  619.     end
  620.   }
  621. )
  622.  
  623. #===============================================================================
  624. # Custom Ability #32 - Mutate
  625. #===============================================================================
  626. # Form changing added to "def pbUseMove"
  627.  
  628. #===============================================================================
  629. # Custom Ability #33 - Midnight Curse
  630. #===============================================================================
  631. BattleHandlers::AbilityOnSwitchIn.add(:MIDNIGHTCURSE,
  632.   proc { |ability,battler,battle|
  633.     if isConst?(battler.species,PBSpecies,:LYCANROC)
  634.       outdoors = pbGetMetadata($game_map.map_id,MetadataOutdoor)
  635.       newabils = [:DAYLIGHTRUSH,:MOONLITFRENZY,:TWILIGHTSHIFT]
  636.       battle.pbShowAbilitySplash(battler,true,false)
  637.       if PBDayNight.isNight? && outdoors
  638.         battler.pbChangeForm(1,_INTL("Exposure to moonlight changed {1} into its Midnight form!",
  639.           battler.pbThis)) if battler.form!=1
  640.       elsif PBDayNight.isEvening? && outdoors
  641.         battler.pbChangeForm(2,_INTL("Being caught in twilight changed {1} into its Dusk form!",
  642.           battler.pbThis)) if battler.form!=2
  643.       elsif PBDayNight.isDay? && outdoors
  644.         battler.pbChangeForm(0,_INTL("Exposure to daylight reverted {1} into its Midday form!",
  645.           battler.pbThis)) if battler.form!=0
  646.       end
  647.       battler.ability = getConst(PBAbilities,newabils[battler.form])
  648.       battle.pbReplaceAbilitySplash(battler)
  649.       battle.pbDisplay(_INTL("{1} acquired {2}!",battler.pbThis,battler.abilityName))
  650.       battle.pbHideAbilitySplash(battler)
  651.     end
  652.   }
  653. )
  654.  
  655. #===============================================================================
  656. # Custom Ability #34 - Daylight Rush
  657. #===============================================================================
  658. BattleHandlers::DamageCalcUserAbility.add(:DAYLIGHTRUSH,
  659.   proc { |ability,user,target,move,mults,baseDmg,type|
  660.     daylight = true if PBDayNight.isDay? || PBWeather::Sun || PBWeather::HarshSun
  661.     next false if !daylight
  662.     firstToAct = true
  663.     user.battle.eachBattler do |b|
  664.       next if b.fainted?
  665.       next if b.index==user.index
  666.       next if b.battle.choices[target.index][0]!=:UseMove &&
  667.               b.battle.choices[target.index][0]!=:Shift
  668.       firstToAct = false if b.movedThisRound?
  669.     end
  670.     if firstToAct
  671.       user.battle.pbShowAbilitySplash(user)
  672.       user.battle.pbDisplay(_INTL("{1} strikes first!",user.pbThis))
  673.       user.battle.pbHideAbilitySplash(user)
  674.       mults[BASE_DMG_MULT] *= 1.3
  675.     end
  676.   }
  677. )
  678.  
  679. #===============================================================================
  680. # Custom Ability #35 - Twilight Shift
  681. #===============================================================================
  682. # Start of round ability trigger added to "def pbAttackPhaseMoves"
  683.  
  684. BattleHandlers::SOREffectAbility.add(:TWILIGHTSHIFT,
  685.   proc { |ability,battler,battle|
  686.     next false if !PBDayNight.isEvening?
  687.     showAnim = true
  688.     battle.pbShowAbilitySplash(battler)
  689.     if battler.turnCount%2==0
  690.       if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
  691.         battle.pbDisplay(_INTL("{1} shifted in favor of moonlight!",battler.pbThis))
  692.       else
  693.         battle.pbDisplay(_INTL("{1}'s {2} embraced the moonlight!",battler.pbThis,battler.abilityName))
  694.       end
  695.       battle.pbHideAbilitySplash(battler)
  696.       if battler.stages[PBStats::SPEED]>=2
  697.         if battler.pbCanLowerStatStage?(PBStats::SPEED,battler)
  698.           battler.pbLowerStatStage(PBStats::SPEED,2,battler,true)
  699.         end
  700.       end
  701.       for i in [PBStats::ATTACK,PBStats::DEFENSE]
  702.         if battler.pbCanRaiseStatStage?(i,battler)
  703.           battler.pbRaiseStatStage(i,1,battler,showAnim)
  704.         end
  705.         showAnim = false
  706.       end
  707.     else
  708.       if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
  709.         battle.pbDisplay(_INTL("{1} shifted in favor of daylight!",battler.pbThis))
  710.       else
  711.         battle.pbDisplay(_INTL("{1}'s {2} embraced the daylight!",battler.pbThis,battler.abilityName))
  712.       end
  713.       battle.pbHideAbilitySplash(battler)
  714.       for i in [PBStats::ATTACK,PBStats::DEFENSE]
  715.         if battler.stages[i]>=1
  716.           if battler.pbCanLowerStatStage?(i,battler)
  717.             battler.pbLowerStatStage(i,1,battler,showAnim)
  718.           end
  719.           showAnim = false
  720.         end
  721.       end
  722.       if battler.pbCanRaiseStatStage?(PBStats::SPEED,battler)
  723.         battler.pbRaiseStatStage(PBStats::SPEED,2,battler,true)
  724.       end
  725.     end
  726.   }
  727. )
  728.  
  729. #===============================================================================
  730. # Custom Ability #36 - Moonlit Frenzy
  731. #===============================================================================
  732. BattleHandlers::TargetAbilityOnHit.add(:MOONLITFRENZY,
  733.   proc { |ability,user,target,move,battle|
  734.     next false if !PBDayNight.isNight?
  735.     next false if !user.near?(target)
  736.     next false if target.fainted?
  737.     next false if target.asleep? || target.frozen?
  738.     next false if user.semiInvulnerable? || target.semiInvulnerable?
  739.     battle.pbShowAbilitySplash(target)
  740.     if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
  741.       battle.pbDisplay(_INTL("{1} retaliated in response to {2}'s attack!",target.pbThis,user.pbThis(true)))
  742.     else
  743.       battle.pbDisplay(_INTL("{1} retaliated with its {2}!",target.pbThis,target.abilityName))
  744.     end
  745.     oldHP = user.hp
  746.     battle.pbHideAbilitySplash(target)
  747.     user.damageState.reset
  748.     user.damageState.initialHP = user.hp
  749.     counterMove = PokeBattle_Confusion.new(battle,nil)
  750.     counterMove.calcType = counterMove.pbCalcType(target)
  751.     user.damageState.typeMod = counterMove.pbCalcTypeMod(counterMove.calcType,target,user)
  752.     counterMove.pbCheckDamageAbsorption(target,user)
  753.     counterMove.pbCalcDamage(target,user)
  754.     user.damageState.calcDamage*=0.5
  755.     counterMove.pbReduceDamage(target,user)
  756.     user.hp -= user.damageState.hpLost
  757.     counterMove.pbAnimateHitAndHPLost(target,[user])
  758.     counterMove.pbRecordDamageLost(target,user)
  759.     counterMove.pbEndureKOMessage(user)
  760.     user.pbItemHPHealCheck
  761.     user.pbAbilitiesOnDamageTaken(oldHP)
  762.     user.pbFaint if user.fainted?
  763.   }
  764. )
  765.  
  766. #===============================================================================
  767. # Custom Ability #37 - Astral Plane
  768. #===============================================================================
  769. # Continuous type check added to "def pbAbilitiesOnFainting"
  770. # Continuous type check added to "def pbContinualAbilityChecks"
  771.  
  772. BattleHandlers::AbilityOnSwitchIn.add(:ASTRALPLANE,
  773.   proc { |ability,battler,battle|
  774.     newType = getConst(PBTypes,:GHOST)
  775.     typeName = PBTypes.getName(newType)
  776.     battle.pbShowAbilitySplash(battler)
  777.     battle.pbDisplay(_INTL("The {1} type is added to all battlers while on the {2}!",
  778.       typeName,battler.abilityName))
  779.     battle.pbHideAbilitySplash(battler)
  780.   }
  781. )
  782.  
  783. BattleHandlers::AbilityOnSwitchOut.add(:ASTRALPLANE,
  784.   proc { |ability,battler,endOfBattle|
  785.     next if endOfBattle
  786.     newType = getConst(PBTypes,:GHOST)
  787.     battler.eachAlly do |b|
  788.       if b.effects[PBEffects::Type3]==newType
  789.         b.effects[PBEffects::Type3] = -1
  790.       end
  791.     end
  792.     battler.eachOpposing do |b|
  793.       if b.effects[PBEffects::Type3]==newType
  794.         b.effects[PBEffects::Type3] = -1
  795.       end
  796.     end
  797.   }
  798. )
  799.  
  800. #===============================================================================
  801. # Custom Ability #38 - Petrifying Gaze
  802. #===============================================================================
  803. BattleHandlers::AbilityOnSwitchIn.add(:PETRIFYINGGAZE,
  804.   proc { |ability,battler,battle|
  805.     newType  = getConst(PBTypes,:ROCK)
  806.     typeName = PBTypes.getName(newType)
  807.     battle.pbShowAbilitySplash(battler)
  808.     battle.pbDisplay(_INTL("{1} peered into the eyes of {2}!",
  809.       battler.pbThis,battler.pbOpposingTeam(true)))
  810.     battle.pbHideAbilitySplash(battler)
  811.     battle.eachOtherSideBattler(battler.index) do |b|
  812.       next if !b.near?(battler)
  813.       next if b.pbHasType?(newType)
  814.       next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
  815.       battle.pbDisplay(_INTL("The {1} type was added to {2}!",typeName,b.pbThis(true)))
  816.       b.effects[PBEffects::Type3] = newType
  817.     end
  818.   }
  819. )
  820.  
  821. #===============================================================================
  822. # Custom Ability #39 - Pheromone Lure
  823. #===============================================================================
  824. BattleHandlers::TrappingTargetAbility.add(:PHEROMONELURE,
  825.   proc { |ability,switcher,bearer,battle|
  826.     next false if switcher.gender>1 || bearer.gender>1
  827.     next true if switcher.gender!=bearer.gender
  828.   }
  829. )
  830.  
  831. #===============================================================================
  832. # Custom Ability #40 - Seed Parasite
  833. #===============================================================================
  834. BattleHandlers::TargetAbilityOnHit.add(:SEEDPARASITE,
  835.   proc { |ability,user,target,move,battle|
  836.     next if !target.fainted?
  837.     next if !move.pbContactMove?(user)
  838.     next if user.pbHasType?(:GRASS) || user.effects[PBEffects::LeechSeed]>0
  839.     battle.pbShowAbilitySplash(target)
  840.     user.effects[PBEffects::LeechSeed] = target.index
  841.     battle.pbDisplay(_INTL("A leech seed was attached to {1}!",user.pbThis(true)))
  842.     battle.pbHideAbilitySplash(target)
  843.   }
  844. )
  845.  
  846. #===============================================================================
  847. # Custom Ability #41 - Spike Burst
  848. #===============================================================================
  849. BattleHandlers::TargetAbilityOnHit.add(:SPIKEBURST,
  850.   proc { |ability,user,target,move,battle|
  851.   if move.contactMove?
  852.     if target.pbHasType?(:POISON)
  853.       if user.pbOwnSide.effects[PBEffects::ToxicSpikes]<2
  854.         battle.pbShowAbilitySplash(target)
  855.         user.pbOwnSide.effects[PBEffects::ToxicSpikes] += 1
  856.         battle.pbDisplay(_INTL("Poison spikes were scattered all around {1}'s feet!",user.pbThis(true)))
  857.         battle.pbHideAbilitySplash(target)
  858.       end
  859.     else
  860.       if user.pbOwnSide.effects[PBEffects::Spikes]<3
  861.         battle.pbShowAbilitySplash(target)
  862.         user.pbOwnSide.effects[PBEffects::Spikes] += 1
  863.         battle.pbDisplay(_INTL("Spikes were scattered all around {1}'s feet!",user.pbThis(true)))
  864.         battle.pbHideAbilitySplash(target)
  865.       end
  866.     end
  867.   end
  868.   }
  869. )
  870.  
  871. #===============================================================================
  872. # Custom Ability #42 - Color Aura
  873. #===============================================================================
  874. BattleHandlers::AbilityOnSwitchIn.add(:COLORAURA,
  875.   proc { |ability,battler,battle|
  876.     choice = battler.pbDirectOpposing
  877.     color  = pbGetSpeciesData(choice.species,choice.form,SpeciesColor)
  878.     next if choice.fainted?
  879.     next if choice.effects[PBEffects::Substitute]>0 ||
  880.             choice.effects[PBEffects::SkyDrop]>=0 ||
  881.             choice.semiInvulnerable?
  882.     next false if color<0 || color==nil
  883.     battle.pbShowAbilitySplash(battler)
  884.     battle.pbDisplay(_INTL("{1} reacted to the sight of {2}'s {3} coloring!",
  885.       battler.pbThis,choice.pbThis(true),PBColors.getName(color).downcase))
  886.       pbWait(5)
  887.     battle.pbHideAbilitySplash(battler)
  888.     if color==0     # Red
  889.       battler.pbRaiseStatStage(PBStats::ATTACK,1,battler)
  890.     elsif color==1  # Blue
  891.       battler.pbRaiseStatStage(PBStats::DEFENSE,1,battler)
  892.     elsif color==2  # Yellow
  893.       battler.pbRaiseStatStage(PBStats::SPEED,1,battler)
  894.     elsif color==3  # Green
  895.       battler.pbRaiseStatStage(PBStats::SPDEF,1,battler)
  896.     elsif color==4  # Black
  897.       battler.pbRaiseStatStage(PBStats::EVASION,1,battler)
  898.     elsif color==5  # Brown
  899.       battler.effects[PBEffects::FocusEnergy] = 2
  900.       battle.pbDisplay(_INTL("{1} is getting pumped!",battler.pbThis))
  901.     elsif color==6  # Purple
  902.       battler.pbRaiseStatStage(PBStats::SPATK,1,battler)
  903.     elsif color==7  # Gray
  904.       battle.pbDisplay(_INTL("{1}'s stats cannot be lowered while it sees gray!",battler.pbThis))
  905.     elsif color==8  # White
  906.       battler.pbRaiseStatStage(PBStats::ACCURACY,1,battler)
  907.     elsif color==9  # Pink
  908.       battle.pbDisplay(_INTL("{1} is immune to status conditions while it sees pink!",battler.pbThis))
  909.     end
  910.   }
  911. )
  912.  
  913. BattleHandlers::StatLossImmunityAbility.add(:COLORAURA,
  914.   proc { |ability,battler,stat,battle,showMessages|
  915.     choice = battler.pbDirectOpposing
  916.     color  = pbGetSpeciesData(choice.species,choice.form,SpeciesColor)
  917.     next false if color!=7
  918.     if showMessages
  919.       battle.pbShowAbilitySplash(battler)
  920.       if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
  921.         battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!",battler.pbThis))
  922.       else
  923.         battle.pbDisplay(_INTL("{1}'s {2} prevents stat loss!",battler.pbThis,battler.abilityName))
  924.       end
  925.       battle.pbHideAbilitySplash(battler)
  926.     end
  927.     next true
  928.   }
  929. )
  930.  
  931. BattleHandlers::StatusImmunityAbility.add(:COLORAURA,
  932.   proc { |ability,battler,status|
  933.     choice = battler.pbDirectOpposing
  934.     color  = pbGetSpeciesData(choice.species,choice.form,SpeciesColor)
  935.     next true if color==9
  936.   }
  937. )
  938.  
  939. #===============================================================================
  940. # Custom Ability #43 - Dancing Panic
  941. #===============================================================================
  942. # Added reverse effects in "class PokeBattle_StatUpMove"
  943. # Added reverse effects in "class PokeBattle_MultiStatUpMove"
  944. # Added reverse effects in "class PokeBattle_StatDownMove"
  945. # Added reverse effects in "class PokeBattle_TargetStatDownMove"
  946. # Added reverse effects in "class PokeBattle_TargetMultiStatDownMove"
  947.  
  948. BattleHandlers::AbilityOnSwitchIn.add(:DANCINGPANIC,
  949.   proc { |ability,battler,battle|
  950.     battle.pbShowAbilitySplash(battler)
  951.     battle.pbDisplay(_INTL("{1} makes other Pokémon dance to a frantic beat!",battler.pbThis))
  952.     battle.pbHideAbilitySplash(battler)
  953.   }
  954. )
  955.  
  956. class PokeBattle_Move
  957.   def pbReverseDanceEffect?(user)
  958.     if @battle.pbCheckGlobalAbility(:DANCINGPANIC) && danceMove?
  959.       return false if user.hasActiveAbility?(:DANCINGPANIC)
  960.       return true
  961.     end
  962.   end
  963. end
  964.  
  965. #===============================================================================
  966. # Custom Ability #44 - Bounty Hunter
  967. #===============================================================================
  968. # Effects added to "module PBEffects"
  969. # Effects added to "def pbInitEffects"
  970. # Exp. bonus added to "def pbGainExpOne"
  971.  
  972. BattleHandlers::AbilityOnSwitchIn.add(:BOUNTYHUNTER,
  973.   proc { |ability,battler,battle|
  974.     target = []  
  975.     rarity = []
  976.     battle.eachOtherSideBattler(battler.index) do |b|
  977.       rareness = pbGetSpeciesData(b.species,b.form,SpeciesRareness)
  978.       rareness/=2 if b.shiny?
  979.       next if rareness>75
  980.       target.push(b)
  981.       rarity.push(rareness)
  982.     end
  983.     for i in 0...rarity.length
  984.       if rarity[i]!=rarity.min
  985.         rarity.delete_at(i)
  986.         target.delete_at(i)
  987.       end
  988.     end
  989.     if target.length>0
  990.       target = target[0]
  991.       target.effects[PBEffects::BountyTarget] = true
  992.       battle.pbShowAbilitySplash(battler)
  993.       battle.pbDisplay(_INTL("{1} identified {2} as the bounty target!",
  994.         battler.pbThis,target.pbThis(true)))
  995.       battle.pbHideAbilitySplash(battler)
  996.     end
  997.   }
  998. )
  999.  
  1000. BattleHandlers::UserAbilityOnHit.add(:BOUNTYHUNTER,
  1001.   proc { |ability,user,target,move,battle|
  1002.     if target.effects[PBEffects::BountyTarget] && target.fainted?
  1003.       battle.pbShowAbilitySplash(user)
  1004.       battle.pbDisplay(_INTL("{1} collected its bounty on {2}!",user.pbThis,target.pbThis(true)))
  1005.       if user.pbOwnedByPlayer? && battle.internalBattle
  1006.         bounty   = (target.level+user.level)*(150+rand(50))
  1007.         rareness = pbGetSpeciesData(target.species,target.form,SpeciesRareness)
  1008.         rareness/=2 if target.shiny?
  1009.         battle.field.effects[PBEffects::PayDay] += (bounty/rareness).round
  1010.         battle.pbDisplay(_INTL("{1} was showered in coins!",user.pbThis))
  1011.         user.effects[PBEffects::BountyCollected] = (bounty/rareness).round
  1012.       end
  1013.       battle.pbHideAbilitySplash(user)
  1014.       if user.item==0 && (target.item>0 && !target.unlosableItem?(target.item))
  1015.         user.item = target.item
  1016.         target.item = 0
  1017.         if battle.wildBattle? && user.initialItem==0 && target.initialItem==user.item
  1018.           user.setInitialItem(user.item)
  1019.           target.setInitialItem(0)
  1020.         end
  1021.         battle.pbDisplay(_INTL("{1} took {2}'s {3} as a trophy!",
  1022.           user.pbThis,target.pbThis(true),user.itemName))
  1023.       else
  1024.         battle.pbDisplay(_INTL("But it failed!")) if !battle.internalBattle
  1025.       end
  1026.     end
  1027.   }
  1028. )
  1029.  
  1030. #===============================================================================
  1031. # Custom Ability #45 - Honey Frenzy
  1032. #===============================================================================
  1033. # Re-Targetting added to "pbChangeTargets"
  1034.  
  1035. BattleHandlers::AbilityOnSwitchIn.add(:HONEYFRENZY,
  1036.   proc { |ability,battler,battle|
  1037.     if !battler.hasActiveItem?(:HONEY)
  1038.       battle.eachBattler do |b|
  1039.         if b.hasActiveItem?(:HONEY)
  1040.           battle.pbShowAbilitySplash(battler)
  1041.           battle.pbDisplay(_INTL("{1} sniffs the presence of {2} on {3}!",
  1042.             battler.pbThis,b.itemName,b.pbThis(true)))
  1043.           battle.pbHideAbilitySplash(battler)
  1044.         end
  1045.       end
  1046.     end
  1047.   }
  1048. )
  1049.  
  1050. BattleHandlers::DamageCalcUserAbility.add(:HONEYFRENZY,
  1051.   proc { |ability,user,target,move,mults,baseDmg,type|
  1052.     targethoney=true if target.hasActiveItem?(:HONEY) && !user.hasActiveItem?(:HONEY)
  1053.     mults[BASE_DMG_MULT] *= 2 if targethoney
  1054.   }
  1055. )
  1056.  
  1057. BattleHandlers::EORHealingAbility.add(:HONEYFRENZY,
  1058.   proc { |ability,battler,battle|
  1059.     next false if !battler.hasActiveItem?(:HONEY)
  1060.     next false if !battler.canHeal?
  1061.     battle.pbShowAbilitySplash(battler)
  1062.     battler.pbRecoverHP(battler.totalhp/8).floor
  1063.     battle.pbDisplay(_INTL("{1}'s {2} restored some HP with its held {3}!",
  1064.       battler.pbThis,battler.abilityName,battler.itemName))
  1065.     battle.pbHideAbilitySplash(battler)
  1066.   }
  1067. )
  1068.  
  1069. BattleHandlers::SpeedCalcAbility.add(:HONEYFRENZY,
  1070.   proc { |ability,battler,mult|
  1071.     next mult/2 if battler.hasActiveItem?(:HONEY)
  1072.   }
  1073. )
  1074.  
  1075. class PokeBattle_Battler
  1076.   def pbHoneyFrenzyTarget(move,user,targets,priority,nearOnly)
  1077.     if user.hasActiveAbility?(:HONEYFRENZY)
  1078.       getID = pbGetMoveData(move.id,MOVE_FUNCTION_CODE)
  1079.       blacklist = ["0C9","0CA","0CB","0CC","0CD","0CE","14D"].include?(getID)
  1080.       usingmultiturn = (user.effects[PBEffects::TwoTurnAttack]!=0 && blacklist)
  1081.       if move.damagingMove? && targets.length==1 && !usingmultiturn
  1082.         newTarget = nil
  1083.         priority.each do |b|
  1084.           next if b.index==user.index || b.index==targets[0].index
  1085.           next if !b.hasActiveItem?(:HONEY)
  1086.           next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
  1087.           next if nearOnly && !b.near?(user)
  1088.           newTarget = b
  1089.         end
  1090.         if newTarget!=nil
  1091.           targets.clear
  1092.           @battle.pbShowAbilitySplash(user)
  1093.           pbAddTarget(targets,user,newTarget,move,nearOnly)
  1094.           @battle.pbDisplay(_INTL("{1} targeted {2} instead because of its held {3}!",
  1095.             user.pbThis,newTarget.pbThis(true),newTarget.itemName))
  1096.           @battle.pbHideAbilitySplash(user)
  1097.           return targets
  1098.         end
  1099.       end
  1100.     end
  1101.     return targets
  1102.   end
  1103. end
  1104.  
  1105. #===============================================================================
  1106. # Custom Ability #46 - Grizzly Guard
  1107. #===============================================================================
  1108. # Effect added to "module PBEffects"
  1109. # Effect added to "def pbInitEffects"
  1110. # Re-Targetting added to "def pbChangeTargets"
  1111.  
  1112. BattleHandlers::AbilityOnSwitchIn.add(:GRIZZLYGUARD,
  1113.   proc { |ability,battler,battle|
  1114.     battle.eachSameSideBattler(battler.index) do |ally|
  1115.       next if !ally.near?(battler)
  1116.       if ally
  1117.         battle.pbShowAbilitySplash(battler)
  1118.         battle.pbDisplay(_INTL("{1} guards its allies!",battler.pbThis))
  1119.         battle.pbHideAbilitySplash(battler)
  1120.         break
  1121.       end
  1122.     end
  1123.   }
  1124. )
  1125.            
  1126. BattleHandlers::TargetAbilityOnHit.add(:GRIZZLYGUARD,
  1127.   proc { |ability,user,target,move,battle|
  1128.     if target.effects[PBEffects::GrizzlyGuard] &&
  1129.        target.pbCanRaiseStatStage?(PBStats::ATTACK,target)
  1130.       target.pbRaiseStatStage(PBStats::ATTACK,1,target)
  1131.     end
  1132.     target.effects[PBEffects::GrizzlyGuard] = false
  1133.   }
  1134. )
  1135.  
  1136. class PokeBattle_Battler
  1137.   def pbGrizzlyGuardTarget(move,user,targets,priority,nearOnly)
  1138.     if @battle.pbCheckOpposingAbility(:GRIZZLYGUARD,user.index,nearOnly) && !user.hasMoldBreaker?
  1139.       getID = pbGetMoveData(move.id,MOVE_FUNCTION_CODE)
  1140.       blacklist = ["0C9","0CA","0CB","0CC","0CD","0CE","14D"].include?(getID)
  1141.       usingmultiturn = (user.effects[PBEffects::TwoTurnAttack]!=0 && blacklist)
  1142.       if move.damagingMove? && targets.length==1 && !usingmultiturn
  1143.         newTarget = nil
  1144.         for oldTarget in targets
  1145.           next if oldTarget.semiInvulnerable?
  1146.           next if oldTarget.effects[PBEffects::Protect]
  1147.           next if oldTarget.effects[PBEffects::KingsShield]
  1148.           next if oldTarget.effects[PBEffects::SpikyShield]
  1149.           next if oldTarget.effects[PBEffects::BanefulBunker]
  1150.           next if oldTarget.effects[PBEffects::Obstruct]
  1151.           next if oldTarget.effects[PBEffects::SkyDrop]>=0
  1152.           next if oldTarget.effects[PBEffects::Substitute]>0
  1153.           next if oldTarget.pbOwnSide.effects[PBEffects::WideGuard]
  1154.           next if oldTarget.pbOwnSide.effects[PBEffects::QuickGuard]
  1155.           next if oldTarget.pbOwnSide.effects[PBEffects::MatBlock]
  1156.           next if defined?(oldTarget.dynamax?) && oldTarget.dynamax?
  1157.           priority.each do |b|
  1158.             next if !(b.opposes?(user.index) && b.hasActiveAbility?(:GRIZZLYGUARD))
  1159.             next if b.hp <= b.totalhp/4.floor
  1160.             next if b.level <= oldTarget.level-10
  1161.             next if b.index==oldTarget.index
  1162.             next if b.frozen? || b.asleep?
  1163.             next if b.effects[PBEffects::Protect]
  1164.             next if b.effects[PBEffects::KingsShield]
  1165.             next if b.effects[PBEffects::SpikyShield]
  1166.             next if b.effects[PBEffects::BanefulBunker]
  1167.             next if b.effects[PBEffects::Obstruct]
  1168.             next if b.effects[PBEffects::Substitute]>0
  1169.             next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
  1170.             next if nearOnly && !b.near?(user)
  1171.             next if nearOnly && !b.near?(oldTarget)
  1172.             next if defined?(b.dynamax?) && b.dynamax?
  1173.             newTarget = b
  1174.           end
  1175.           if newTarget!=nil
  1176.             targets.clear
  1177.             pbAddTarget(targets,user,newTarget,move,nearOnly)
  1178.             @battle.pbShowAbilitySplash(newTarget)
  1179.             @battle.pbDisplay(_INTL("{1} takes attacks for its allies with {2}!",
  1180.               newTarget.pbThis,newTarget.abilityName))
  1181.             @battle.pbHideAbilitySplash(newTarget)
  1182.             newTarget.effects[PBEffects::GrizzlyGuard] = true
  1183.             return targets
  1184.           end
  1185.         end
  1186.       end
  1187.     end
  1188.     return targets
  1189.   end
  1190. end
  1191.  
  1192. #===============================================================================
  1193. # Custom Ability #47 - Hive Mind
  1194. #===============================================================================
  1195. # Re-Targetting added to "pbChangeTargets"
  1196.  
  1197. BattleHandlers::AbilityOnSwitchIn.add(:HIVEMIND,
  1198.   proc { |ability,battler,battle|
  1199.     battle.eachSameSideBattler(battler.index) do |ally|
  1200.       next if !ally.near?(battler)
  1201.       if ally
  1202.         battle.pbShowAbilitySplash(battler)
  1203.         battle.pbDisplay(_INTL("{1} commands its allies to shield it from harm!",battler.pbThis))
  1204.         battle.pbHideAbilitySplash(battler)
  1205.         break
  1206.       end
  1207.     end
  1208.   }
  1209. )
  1210.  
  1211. class PokeBattle_Battler
  1212.   def pbHiveMindTarget(move,user,targets,priority,nearOnly)
  1213.     if targets[0].hasActiveAbility?(:HIVEMIND) && !user.hasMoldBreaker?
  1214.       getID = pbGetMoveData(move.id,MOVE_FUNCTION_CODE)
  1215.       blacklist = ["0C9","0CA","0CB","0CC","0CD","0CE","14D"].include?(getID)
  1216.       usingmultiturn = (user.effects[PBEffects::TwoTurnAttack]!=0 && blacklist)
  1217.       if move.damagingMove? && targets.length==1 && !usingmultiturn
  1218.         newTarget = nil
  1219.         for oldTarget in targets
  1220.           next if oldTarget.semiInvulnerable?
  1221.           next if oldTarget.effects[PBEffects::Protect]
  1222.           next if oldTarget.effects[PBEffects::KingsShield]
  1223.           next if oldTarget.effects[PBEffects::SpikyShield]
  1224.           next if oldTarget.effects[PBEffects::BanefulBunker]
  1225.           next if oldTarget.effects[PBEffects::Obstruct]
  1226.           next if oldTarget.effects[PBEffects::SkyDrop]>=0
  1227.           next if oldTarget.effects[PBEffects::Substitute]>0
  1228.           next if oldTarget.pbOwnSide.effects[PBEffects::WideGuard]
  1229.           next if oldTarget.pbOwnSide.effects[PBEffects::QuickGuard]
  1230.           next if oldTarget.pbOwnSide.effects[PBEffects::MatBlock]
  1231.           next if defined?(oldTarget.dynamax?) && oldTarget.dynamax?
  1232.           priority.each do |b|
  1233.             next if !b.opposes?(user.index)
  1234.             next if b.index==oldTarget.index
  1235.             next if b.hp <= b.totalhp/4.floor
  1236.             next if b.level <= oldTarget.level-10
  1237.             next if b.frozen? || b.asleep?
  1238.             next if b.effects[PBEffects::Protect]
  1239.             next if b.effects[PBEffects::KingsShield]
  1240.             next if b.effects[PBEffects::SpikyShield]
  1241.             next if b.effects[PBEffects::BanefulBunker]
  1242.             next if b.effects[PBEffects::Obstruct]
  1243.             next if b.effects[PBEffects::Substitute]>0
  1244.             next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
  1245.             next if nearOnly && !b.near?(user)
  1246.             next if nearOnly && !b.near?(oldTarget)
  1247.             next if defined?(b.dynamax?) && b.dynamax?
  1248.             newTarget = b
  1249.           end
  1250.         end
  1251.         if newTarget!=nil
  1252.           targets.clear
  1253.           @battle.pbShowAbilitySplash(oldTarget)
  1254.           pbAddTarget(targets,user,newTarget,move,nearOnly)
  1255.           @battle.pbDisplay(_INTL("{1} ordered {2} to take {3}'s attack!",
  1256.             oldTarget.pbThis,newTarget.pbThis(true),user.pbThis(true)))
  1257.           @battle.pbHideAbilitySplash(oldTarget)
  1258.           return targets
  1259.         end
  1260.       end
  1261.     end
  1262.     return targets
  1263.   end
  1264. end
  1265.  
  1266. #===============================================================================
  1267. # Custom Ability #48 - Gambler
  1268. #===============================================================================
  1269. BattleHandlers::AbilityOnSwitchIn.add(:GAMBLER,
  1270.   proc { |ability,battler,battle|
  1271.     battle.pbShowAbilitySplash(battler)
  1272.     battle.pbDisplay(_INTL("{1} is ready to roll the dice!",battler.pbThis))
  1273.     battle.pbHideAbilitySplash(battler)
  1274.   }
  1275. )
  1276.  
  1277. BattleHandlers::EOREffectAbility.add(:GAMBLER,
  1278.   proc { |ability,battler,battle|
  1279.     next false if battler.asleep? || battler.frozen?
  1280.     rand = battle.pbRandom(11)
  1281.     battle.pbShowAbilitySplash(battler)
  1282.     # Roll 2 - Halves user's HP
  1283.     if rand==0
  1284.       battle.pbDisplay(_INTL("{1} rolled a 2!",battler.pbThis))
  1285.       battler.pbReduceHP(battler.hp/2,false)
  1286.       battle.pbDisplay(_INTL("{1}'s HP was cut by half!",battler.pbThis))
  1287.     # Roll 3 - Free Turn
  1288.     elsif rand==1
  1289.       battle.pbDisplay(_INTL("{1} rolled a 3!",battler.pbThis))
  1290.       battle.pbDisplay(_INTL("Free turn!"))
  1291.     # Roll 4 - Traps all Pokemon
  1292.     elsif rand==2
  1293.       battle.pbDisplay(_INTL("{1} rolled a 4!",battler.pbThis))
  1294.       battle.eachBattler do |b|
  1295.         if NEWEST_BATTLE_MECHANICS && b.pbHasType?(:GHOST)
  1296.           battle.pbDisplay(_INTL("{1} cannot be trapped!",b.pbThis))
  1297.         else
  1298.           b.effects[PBEffects::MeanLook] = battler.index
  1299.           if !battle.pbCanSwitch?(b.index) || battle.wildBattle?
  1300.             battle.pbDisplay(_INTL("{1} can no longer escape!",b.pbThis))
  1301.           end
  1302.         end
  1303.       end
  1304.     # Roll 5 - Curses user
  1305.     elsif rand==3
  1306.       battle.pbDisplay(_INTL("{1} rolled a 5!",battler.pbThis))
  1307.       if !battler.effects[PBEffects::Curse]
  1308.         battler.effects[PBEffects::Curse]=true
  1309.         battle.pbDisplay(_INTL("A curse was laid on {1}!",battler.pbThis))
  1310.       else
  1311.         battle.pbDisplay(_INTL("But it failed!",battler.pbThis))
  1312.       end
  1313.     # Roll 6 - Eliminates all stat changes
  1314.     elsif rand==4
  1315.       battle.pbDisplay(_INTL("{1} rolled a 6!",battler.pbThis))
  1316.       battle.eachBattler do |b|
  1317.         b.stages[PBStats::ATTACK]   = 0
  1318.         b.stages[PBStats::DEFENSE]  = 0
  1319.         b.stages[PBStats::SPEED]    = 0
  1320.         b.stages[PBStats::SPATK]    = 0
  1321.         b.stages[PBStats::SPDEF]    = 0
  1322.         b.stages[PBStats::ACCURACY] = 0
  1323.         b.stages[PBStats::EVASION]  = 0
  1324.       end
  1325.       battle.pbDisplay(_INTL("All stat changes were eliminated!"))
  1326.     # Roll 7 - Fully heals allies
  1327.     elsif rand==5
  1328.       battle.pbDisplay(_INTL("{1} rolled a 7!",battler.pbThis))
  1329.       battle.eachSameSideBattler(battler.index) do |b|
  1330.         b.effects[PBEffects::Curse]=false
  1331.         b.effects[PBEffects::Confusion]=0
  1332.         b.effects[PBEffects::Disable]= 0
  1333.         b.effects[PBEffects::DisableMove]= 0
  1334.         b.effects[PBEffects::Imprison]= false
  1335.         b.effects[PBEffects::MeanLook]=-1
  1336.         b.effects[PBEffects::Nightmare]=false
  1337.         b.effects[PBEffects::Taunt]=0
  1338.         b.effects[PBEffects::Torment]=false
  1339.         b.effects[PBEffects::GastroAcid]=false
  1340.         b.effects[PBEffects::LeechSeed]=-1
  1341.         b.effects[PBEffects::Toxic]=0
  1342.         b.effects[PBEffects::HealBlock]=0
  1343.         b.pbCureStatus(false)
  1344.         b.pbCureAttract
  1345.         b.pbRecoverHP(b.totalhp)
  1346.       end
  1347.       battle.pbDisplay(_INTL("{1} were fully restored!",battler.pbTeam))
  1348.     # Roll 8 - Puts all battlers to sleep & inflicts Nightmare
  1349.     elsif rand==6
  1350.       battle.pbDisplay(_INTL("{1} rolled an 8!",battler.pbThis))
  1351.       battle.eachBattler do |b|
  1352.         b.pbSleep if b.pbCanSleep?(nil,false)
  1353.         b.effects[PBEffects::Nightmare]=true if b.asleep?
  1354.       end
  1355.       battle.pbDisplay(_INTL("All sleeping Pokémon began having a nightmare!"))
  1356.     # Roll 9 - Reduces opponent's offense by 3 stages
  1357.     elsif rand==7
  1358.       battle.pbDisplay(_INTL("{1} rolled a 9!",battler.pbThis))
  1359.       battle.eachOtherSideBattler(battler.index) do |b|
  1360.         showAnim = true
  1361.         for i in [PBStats::ATTACK,PBStats::SPATK]
  1362.           if b.pbCanLowerStatStage?(i,battler,nil,true)
  1363.             b.pbLowerStatStage(i,3,battler,showAnim)
  1364.             showAnim = false
  1365.           end
  1366.         end
  1367.       end
  1368.     # Roll 10 - Gives opponents Truant
  1369.     elsif rand==8
  1370.       battle.pbDisplay(_INTL("{1} rolled a 10!",battler.pbThis))
  1371.       battle.eachOtherSideBattler(battler.index) do |b|
  1372.         if b.unstoppableAbility?
  1373.           battle.pbDisplay(_INTL("{1}'s ability could not be changed!",b.pbThis))
  1374.         elsif b.hasActiveAbility?(:TRUANT)
  1375.           battle.pbDisplay(_INTL("{1} already has the {2} ability!",b.pbThis,b.abilityName))
  1376.         else
  1377.           battle.pbShowAbilitySplash(b,true,false)
  1378.           oldAbil = b.ability
  1379.           b.ability = getConst(PBAbilities,:TRUANT) || 0
  1380.           battle.pbReplaceAbilitySplash(b)
  1381.           battle.pbDisplay(_INTL("{1} acquired {2}!",b.pbThis,b.abilityName))
  1382.           battle.pbHideAbilitySplash(b)
  1383.           b.pbOnAbilityChanged(oldAbil)
  1384.           b.pbEffectsOnSwitchIn
  1385.         end
  1386.       end
  1387.     # Roll 11 - Fully heals opponents
  1388.     elsif rand==9
  1389.       battle.pbDisplay(_INTL("{1} rolled an 11!",battler.pbThis))
  1390.       battle.eachOtherSideBattler(battler.index) do |b|
  1391.         b.effects[PBEffects::Curse]=false
  1392.         b.effects[PBEffects::Confusion]=0
  1393.         b.effects[PBEffects::Disable]= 0
  1394.         b.effects[PBEffects::DisableMove]= 0
  1395.         b.effects[PBEffects::Imprison]= false
  1396.         b.effects[PBEffects::MeanLook]=-1
  1397.         b.effects[PBEffects::Nightmare]=false
  1398.         b.effects[PBEffects::Taunt]=0
  1399.         b.effects[PBEffects::Torment]=false
  1400.         b.effects[PBEffects::GastroAcid]=false
  1401.         b.effects[PBEffects::LeechSeed]=-1
  1402.         b.effects[PBEffects::Toxic]=0
  1403.         b.effects[PBEffects::HealBlock]=0
  1404.         b.pbCureStatus(false)
  1405.         b.pbCureAttract
  1406.         b.pbRecoverHP(b.totalhp)
  1407.       end
  1408.       battle.pbDisplay(_INTL("{1} were fully restored!",battler.pbOpposingTeam))
  1409.     # Roll 12 - Raises users stats by 2 stages
  1410.     elsif rand==10
  1411.       battle.pbDisplay(_INTL("{1} rolled a 12!",battler.pbThis))
  1412.       showAnim=true
  1413.       for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPATK,
  1414.                 PBStats::SPDEF,PBStats::SPEED]
  1415.         if battler.pbCanRaiseStatStage?(i,battler)
  1416.           battler.pbRaiseStatStage(i,2,battler,showAnim)
  1417.           showAnim=false
  1418.         end
  1419.       end
  1420.     end
  1421.     battle.pbHideAbilitySplash(battler)
  1422.   }
  1423. )
  1424.  
  1425. #===============================================================================
  1426. # Custom Ability #49 - Lucky 7
  1427. #===============================================================================
  1428. # Start of round ability trigger added to "def pbAttackPhaseMoves"
  1429.  
  1430. BattleHandlers::AbilityOnSwitchIn.add(:LUCKY7,
  1431.   proc { |ability,battler,battle|
  1432.     battle.pbShowAbilitySplash(battler)
  1433.     battle.pbDisplay(_INTL("{1} awaits for its luck to kick in!",battler.pbThis))
  1434.     battle.pbHideAbilitySplash(battler)
  1435.   }
  1436. )
  1437.  
  1438. BattleHandlers::SOREffectAbility.add(:LUCKY7,
  1439.   proc { |ability,battler,battle|
  1440.     if battler.turnCount%7==0
  1441.       battle.pbShowAbilitySplash(battler)
  1442.       battle.pbDisplay(_INTL("{1} is feelin' lucky!",battler.pbThis))
  1443.       battle.pbHideAbilitySplash(battler)
  1444.       if !battler.effects[PBEffects::Endure]
  1445.         battler.effects[PBEffects::Endure]=true
  1446.       end
  1447.       if battler.effects[PBEffects::LaserFocus]<=0
  1448.         battler.effects[PBEffects::LaserFocus]=2
  1449.       end
  1450.       if battler.pbOwnSide.effects[PBEffects::Rainbow]<=0
  1451.         battler.pbOwnSide.effects[PBEffects::Rainbow]=2
  1452.       end
  1453.       if battler.pbOwnSide.effects[PBEffects::LuckyChant]<=0
  1454.         battler.pbOwnSide.effects[PBEffects::LuckyChant]=2
  1455.       end
  1456.       if battle.positions[battler.index].effects[PBEffects::Wish]<=0
  1457.         battle.positions[battler.index].effects[PBEffects::Wish]=1
  1458.         battle.positions[battler.index].effects[PBEffects::WishAmount]= (battler.totalhp/2).round
  1459.         battle.positions[battler.index].effects[PBEffects::WishMaker]= battler.pokemonIndex
  1460.         battle.pbDisplay(_INTL("{1} made a wish!",battler.pbThis))
  1461.       end
  1462.       if battler.status>0
  1463.         battler.pbCureStatus(false)
  1464.         battler.pbCureAttract
  1465.         battler.pbCureConfusion
  1466.         battle.pbDisplay(_INTL("{1}'s status was miraculously cured!",battler.pbThis))
  1467.       end
  1468.     end
  1469.   }
  1470. )
  1471.  
  1472. BattleHandlers::AccuracyCalcUserAbility.add(:LUCKY7,
  1473.   proc { |ability,mods,user,target,move,type|
  1474.     mods[BASE_ACC] = 0 if user.turnCount%7==0
  1475.   }
  1476. )
  1477.  
  1478. BattleHandlers::EOREffectAbility.add(:LUCKY7,
  1479.   proc { |ability,battler,battle|
  1480.     if battler.turnCount%7==0
  1481.       battler.effects[PBEffects::LaserFocus]=0
  1482.       battler.pbOwnSide.effects[PBEffects::Rainbow]=0
  1483.       battler.pbOwnSide.effects[PBEffects::LuckyChant]=0
  1484.       battle.pbDisplay(_INTL("{1}'s luck ran out!",battler.pbThis))
  1485.     end
  1486.   }
  1487. )
  1488.  
  1489. #===============================================================================
  1490. # Custom Ability #50 - Countdown
  1491. #===============================================================================
  1492. BattleHandlers::AbilityOnSwitchIn.add(:COUNTDOWN,
  1493.   proc { |ability,battler,battle|
  1494.     battle.pbShowAbilitySplash(battler)
  1495.     battle.pbDisplay(_INTL("{1}'s timer has been set!",battler.pbThis))
  1496.     battle.pbHideAbilitySplash(battler)
  1497.   }
  1498. )
  1499.  
  1500. BattleHandlers::EOREffectAbility.add(:COUNTDOWN,
  1501.   proc { |ability,battler,battle|
  1502.     if battler.turnCount==1
  1503.       battle.pbShowAbilitySplash(battler)
  1504.       battle.pbDisplay(_INTL("{1}'s {2} reached 3!",battler.pbThis,battler.abilityName))
  1505.     elsif battler.turnCount==2
  1506.       battle.pbShowAbilitySplash(battler)
  1507.       battle.pbDisplay(_INTL("{1}'s {2} reached 2!",battler.pbThis,battler.abilityName))
  1508.     elsif battler.turnCount==3
  1509.       battle.pbShowAbilitySplash(battler)
  1510.       battle.pbDisplay(_INTL("{1}'s {2} reached 1!",battler.pbThis,battler.abilityName))
  1511.     elsif battler.turnCount==4
  1512.       battle.pbShowAbilitySplash(battler)
  1513.       battle.pbDisplay(_INTL("{1}'s {2} reached 0!",battler.pbThis,battler.abilityName))
  1514.       bearer = battle.pbCheckGlobalAbility(:DAMP)
  1515.       if bearer!=nil
  1516.         battle.pbShowAbilitySplash(bearer)
  1517.         battle.pbDisplay(_INTL("{1}'s {2} prevents {3} from detonating!",
  1518.           bearer.pbThis,bearer.abilityName,battler.pbThis(true)))
  1519.         battle.pbHideAbilitySplash(bearer)
  1520.       else
  1521.         battle.pbDisplay(_INTL("{1} detonated with a devastating blast!",battler.pbThis))
  1522.         battle.pbHideAbilitySplash(battler)
  1523.         battle.scene.pbDamageAnimation(battler)
  1524.         battler.pbReduceHP(battler.totalhp)
  1525.         battler.pbFaint
  1526.         battle.eachBattler do |b|
  1527.           next if !b.near?(battler)
  1528.           next if b.semiInvulnerable?
  1529.           next if battler.effects[PBEffects::SkyDrop]>=0
  1530.           if b.effects[PBEffects::Protect] ||
  1531.              b.effects[PBEffects::KingsShield] ||
  1532.              b.effects[PBEffects::SpikyShield] ||
  1533.              b.effects[PBEffects::BanefulBunker] ||
  1534.              b.effects[PBEffects::Obstruct]  ||
  1535.              (defined?(b.dynamax?) && b.effects[PBEffects::MaxGuard])
  1536.             battle.pbDisplay(_INTL("{1} protected itself!",b.pbThis))
  1537.           elsif b.pbOwnSide.effects[PBEffects::WideGuard] && b.opposes?
  1538.              battle.pbDisplay(_INTL("{1} was protected by Wide Guard!",b.pbThis))
  1539.           elsif b.pbOwnSide.effects[PBEffects::MatBlock] && b.opposes?
  1540.             battle.pbDisplay(_INTL("{1} was protected by the kicked-up mat!",b.pbThis))
  1541.           elsif b.effects[PBEffects::Substitute]>0
  1542.             battle.pbDisplay(_INTL("The substitute took damage for {1}!",b.pbThis(true)))
  1543.             b.effects[PBEffects::Substitute] = 0
  1544.             battle.pbDisplay(_INTL("{1}'s substitute faded!",b.pbThis))
  1545.           else
  1546.             oldHP = b.hp
  1547.             b.damageState.reset
  1548.             b.damageState.initialHP = b.hp
  1549.             ohkoMove = PokeBattle_Confusion.new(battle,nil)
  1550.             ohkoMove.calcType = ohkoMove.pbCalcType(battler)
  1551.             b.damageState.typeMod = ohkoMove.pbCalcTypeMod(ohkoMove.calcType,battler,b)
  1552.             ohkoMove.pbCalcDamage(battler,b)
  1553.             b.damageState.calcDamage = b.hp
  1554.             ohkoMove.pbReduceDamage(battler,b)
  1555.             b.hp -= b.damageState.hpLost
  1556.             ohkoMove.pbAnimateHitAndHPLost(battler,[b])
  1557.             ohkoMove.pbEndureKOMessage(b)
  1558.             b.pbItemHPHealCheck
  1559.             b.pbAbilitiesOnDamageTaken(oldHP)
  1560.             b.pbFaint if b.fainted?
  1561.           end
  1562.         end
  1563.       end
  1564.     end
  1565.     battle.pbHideAbilitySplash(battler)
  1566.   }
  1567. )
Add Comment
Please, Sign In to add comment