def pbTypeImmunityByAbility(type,attacker,opponent)
return false if attacker.index==opponent.index
return false if attacker.hasMoldBreaker
if opponent.hasWorkingAbility(:SAPSIPPER) && isConst?(type,PBTypes,:GRASS)
PBDebug.log("[Ability triggered] #{opponent.pbThis}'s Sap Sipper (made #{@name} ineffective)")
if opponent.pbCanIncreaseStatStage?(PBStats::ATTACK,opponent)
opponent.pbIncreaseStatWithCause(PBStats::ATTACK,1,opponent,PBAbilities.getName(opponent.ability))
else
@battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
end
return true
end
if (opponent.hasWorkingAbility(:STORMDRAIN) && isConst?(type,PBTypes,:WATER)) ||
(opponent.hasWorkingAbility(:LIGHTNINGROD) && isConst?(type,PBTypes,:ELECTRIC))
PBDebug.log("[Ability triggered] #{opponent.pbThis}'s #{PBAbilities.getName(opponent.ability)} (made #{@name} ineffective)")
if opponent.pbCanIncreaseStatStage?(PBStats::SPATK,opponent)
opponent.pbIncreaseStatWithCause(PBStats::SPATK,1,opponent,PBAbilities.getName(opponent.ability))
else
@battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
end
return true
end
if opponent.hasWorkingAbility(:MOTORDRIVE) && isConst?(type,PBTypes,:ELECTRIC)
PBDebug.log("[Ability triggered] #{opponent.pbThis}'s Motor Drive (made #{@name} ineffective)")
if opponent.pbCanIncreaseStatStage?(PBStats::SPEED,opponent)
opponent.pbIncreaseStatWithCause(PBStats::SPEED,1,opponent,PBAbilities.getName(opponent.ability))
else
@battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
end
return true
end
if opponent.hasWorkingAbility(:SCARECROW) && isConst?(type,PBTypes,:FLYING)
PBDebug.log("[Ability triggered] #{opponent.pbThis}'s Scarecrow (made #{@name} ineffective)")
if opponent.pbCanIncreaseStatStage?(PBStats::SPEED,opponent)
opponent.pbIncreaseStatWithCause(PBStats::SPEED,1,opponent,PBAbilities.getName(opponent.ability))
else
@battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
end
return true
end
if (opponent.hasWorkingAbility(:DRYSKIN) && isConst?(type,PBTypes,:WATER)) ||
(opponent.hasWorkingAbility(:VOLTABSORB) && isConst?(type,PBTypes,:ELECTRIC)) ||
(opponent.hasWorkingAbility(:WATERABSORB) && isConst?(type,PBTypes,:WATER))
PBDebug.log("[Ability triggered] #{opponent.pbThis}'s #{PBAbilities.getName(opponent.ability)} (made #{@name} ineffective)")
healed=false
if opponent.effects[PBEffects::HealBlock]==0
if opponent.pbRecoverHP((opponent.totalhp/4).floor,true)>0
@battle.pbDisplay(_INTL("{1}'s {2} restored its HP!",
opponent.pbThis,PBAbilities.getName(opponent.ability)))
end
end
if !healed
@battle.pbDisplay(_INTL("{1}'s {2} made {3} useless!",
opponent.pbThis,PBAbilities.getName(opponent.ability),@name))
end
return true
end
if opponent.hasWorkingAbility(:FLASHFIRE) && isConst?(type,PBTypes,:FIRE)
PBDebug.log("[Ability triggered] #{opponent.pbThis}'s Flash Fire (made #{@name} ineffective)")
if !opponent.effects[PBEffects::FlashFire]
opponent.effects[PBEffects::FlashFire]=true
@battle.pbDisplay(_INTL("{1}'s {2} raised its Fire power!",
opponent.pbThis,PBAbilities.getName(opponent.ability)))
else
@battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
end
return true
end
if opponent.hasWorkingAbility(:TELEPATHY) && pbIsDamaging? &&
!opponent.pbIsOpposing?(attacker.index)
PBDebug.log("[Ability triggered] #{opponent.pbThis}'s Telepathy (made #{@name} ineffective)")
@battle.pbDisplay(_INTL("{1} avoids attacks by its ally Pokémon!",opponent.pbThis))
return true
end
if opponent.hasWorkingAbility(:BULLETPROOF) && isBombMove?
PBDebug.log("[Ability triggered] #{opponent.pbThis}'s Bulletproof (made #{@name} ineffective)")
@battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
return true
end
return false
end
def pbTypeModifier(type,attacker,opponent)
return 8 if type<0
return 8 if isConst?(type,PBTypes,:GROUND) && opponent.pbHasType?(:FLYING) &&
opponent.hasWorkingItem(:IRONBALL) && !USENEWBATTLEMECHANICS
atype=type # attack type
otype1=opponent.type1
otype2=opponent.type2
otype3=opponent.effects[PBEffects::Type3] || -1
# Roost
if isConst?(otype1,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]
if isConst?(otype2,PBTypes,:FLYING) && isConst?(otype3,PBTypes,:FLYING)
otype1=getConst(PBTypes,:NORMAL) || 0
else
otype1=otype2
end
end
if isConst?(otype2,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]
otype2=otype1
end
# Get effectivenesses
mod1=PBTypes.getEffectiveness(atype,otype1)
mod2=(otype1==otype2) ? 2 : PBTypes.getEffectiveness(atype,otype2)
mod3=(otype3<0 || otype1==otype3 || otype2==otype3) ? 2 : PBTypes.getEffectiveness(atype,otype3)
if opponent.hasWorkingItem(:RINGTARGET)
mod1=2 if mod1==0
mod2=2 if mod2==0
mod3=2 if mod3==0
end
# Foresight
if attacker.hasWorkingAbility(:SCRAPPY) || opponent.effects[PBEffects::Foresight]
mod1=2 if isConst?(otype1,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype1)
mod2=2 if isConst?(otype2,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype2)
mod3=2 if isConst?(otype3,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype3)
end
# Miracle Eye
if opponent.effects[PBEffects::MiracleEye]
mod1=2 if isConst?(otype1,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype1)
mod2=2 if isConst?(otype2,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype2)
mod3=2 if isConst?(otype3,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype3)
end
# Delta Stream's weather
if @battle.pbWeather==PBWeather::STRONGWINDS
mod1=2 if isConst?(otype1,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype1)
mod2=2 if isConst?(otype2,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype2)
mod3=2 if isConst?(otype3,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype3)
end
# Smack Down makes Ground moves work against fliers
if (!opponent.isAirborne?(attacker.hasMoldBreaker) || @function==0x11C) && # Smack Down
isConst?(atype,PBTypes,:GROUND)
mod1=2 if isConst?(otype1,PBTypes,:FLYING)
mod2=2 if isConst?(otype2,PBTypes,:FLYING)
mod3=2 if isConst?(otype3,PBTypes,:FLYING)
end
if @function==0x135 && !attacker.effects[PBEffects::Electrify] # Freeze-Dry
mod1=4 if isConst?(otype1,PBTypes,:WATER)
if isConst?(otype2,PBTypes,:WATER)
mod2=(otype1==otype2) ? 2 : 4
end
if isConst?(otype3,PBTypes,:WATER)
mod3=(otype1==otype3 || otype2==otype3) ? 2 : 4
end
end
return mod1*mod2*mod3
end
def pbTypeModMessages(type,attacker,opponent)
return 8 if type<0
typemod=pbTypeModifier(type,attacker,opponent)
if typemod==0
@battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
else
return 0 if pbTypeImmunityByAbility(type,attacker,opponent)
end
return typemod
end