diff --git a/Data/Scripts/011_Battle/005_AI/004_AI_Move.rb b/Data/Scripts/011_Battle/005_AI/004_AI_Move.rb index c0fb9091c..2f31f5f97 100644 --- a/Data/Scripts/011_Battle/005_AI/004_AI_Move.rb +++ b/Data/Scripts/011_Battle/005_AI/004_AI_Move.rb @@ -233,6 +233,8 @@ class Battle::AI end end end + # Don't prefer moves that are ineffective because of abilities or effects + return 0 if pbCheckMoveImmunity(score, move, user, target, skill) # Adjust score based on how much damage it can deal if move.damagingMove? score = pbGetMoveScoreDamage(score, move, user, target, skill) @@ -254,8 +256,7 @@ class Battle::AI # of the target's current HP) #============================================================================= def pbGetMoveScoreDamage(score, move, user, target, skill) - # Don't prefer moves that are ineffective because of abilities or effects - return 0 if score <= 0 || pbCheckMoveImmunity(score, move, user, target, skill) + return 0 if score <= 0 # Calculate how much damage the move will do (roughly) baseDmg = pbMoveBaseDamage(move, user, target, skill) realDamage = pbRoughDamage(move, user, target, skill, baseDmg) diff --git a/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb b/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb index c7d3fff7f..58f6419ef 100644 --- a/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb +++ b/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb @@ -100,7 +100,7 @@ class Battle::AI type = pbRoughType(move, user, skill) typeMod = pbCalcTypeMod(type, user, target) # Type effectiveness - return true if Effectiveness.ineffective?(typeMod) || score <= 0 + return true if (move.damagingMove? && Effectiveness.ineffective?(typeMod)) || score <= 0 # Immunity due to ability/item/other effects if skill >= PBTrainerAI.mediumSkill case type @@ -115,7 +115,7 @@ class Battle::AI when :ELECTRIC return true if target.hasActiveAbility?([:LIGHTNINGROD, :MOTORDRIVE, :VOLTABSORB]) end - return true if Effectiveness.not_very_effective?(typeMod) && + return true if move.damagingMove? && Effectiveness.not_very_effective?(typeMod) && target.hasActiveAbility?(:WONDERGUARD) return true if move.damagingMove? && user.index != target.index && !target.opposes?(user) && target.hasActiveAbility?(:TELEPATHY) @@ -128,10 +128,11 @@ class Battle::AI return true if target.hasActiveAbility?(:OVERCOAT) return true if target.hasActiveItem?(:SAFETYGOGGLES) end - return true if target.effects[PBEffects::Substitute] > 0 && move.statusMove? && + return true if move.statusMove? && target.effects[PBEffects::Substitute] > 0 && !move.ignoresSubstitute?(user) && user.index != target.index - return true if Settings::MECHANICS_GENERATION >= 7 && user.hasActiveAbility?(:PRANKSTER) && - target.pbHasType?(:DARK) && target.opposes?(user) + return true if move.statusMove? && Settings::MECHANICS_GENERATION >= 7 && + user.hasActiveAbility?(:PRANKSTER) && target.pbHasType?(:DARK) && + target.opposes?(user) return true if move.priority > 0 && @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) end