mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-10 06:34:59 +00:00
AI now checks for immunities to status moves
This commit is contained in:
@@ -233,6 +233,8 @@ class Battle::AI
|
|||||||
end
|
end
|
||||||
end
|
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
|
# Adjust score based on how much damage it can deal
|
||||||
if move.damagingMove?
|
if move.damagingMove?
|
||||||
score = pbGetMoveScoreDamage(score, move, user, target, skill)
|
score = pbGetMoveScoreDamage(score, move, user, target, skill)
|
||||||
@@ -254,8 +256,7 @@ class Battle::AI
|
|||||||
# of the target's current HP)
|
# of the target's current HP)
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
def pbGetMoveScoreDamage(score, move, user, target, skill)
|
def pbGetMoveScoreDamage(score, move, user, target, skill)
|
||||||
# Don't prefer moves that are ineffective because of abilities or effects
|
return 0 if score <= 0
|
||||||
return 0 if score <= 0 || pbCheckMoveImmunity(score, move, user, target, skill)
|
|
||||||
# Calculate how much damage the move will do (roughly)
|
# Calculate how much damage the move will do (roughly)
|
||||||
baseDmg = pbMoveBaseDamage(move, user, target, skill)
|
baseDmg = pbMoveBaseDamage(move, user, target, skill)
|
||||||
realDamage = pbRoughDamage(move, user, target, skill, baseDmg)
|
realDamage = pbRoughDamage(move, user, target, skill, baseDmg)
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class Battle::AI
|
|||||||
type = pbRoughType(move, user, skill)
|
type = pbRoughType(move, user, skill)
|
||||||
typeMod = pbCalcTypeMod(type, user, target)
|
typeMod = pbCalcTypeMod(type, user, target)
|
||||||
# Type effectiveness
|
# 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
|
# Immunity due to ability/item/other effects
|
||||||
if skill >= PBTrainerAI.mediumSkill
|
if skill >= PBTrainerAI.mediumSkill
|
||||||
case type
|
case type
|
||||||
@@ -115,7 +115,7 @@ class Battle::AI
|
|||||||
when :ELECTRIC
|
when :ELECTRIC
|
||||||
return true if target.hasActiveAbility?([:LIGHTNINGROD, :MOTORDRIVE, :VOLTABSORB])
|
return true if target.hasActiveAbility?([:LIGHTNINGROD, :MOTORDRIVE, :VOLTABSORB])
|
||||||
end
|
end
|
||||||
return true if Effectiveness.not_very_effective?(typeMod) &&
|
return true if move.damagingMove? && Effectiveness.not_very_effective?(typeMod) &&
|
||||||
target.hasActiveAbility?(:WONDERGUARD)
|
target.hasActiveAbility?(:WONDERGUARD)
|
||||||
return true if move.damagingMove? && user.index != target.index && !target.opposes?(user) &&
|
return true if move.damagingMove? && user.index != target.index && !target.opposes?(user) &&
|
||||||
target.hasActiveAbility?(:TELEPATHY)
|
target.hasActiveAbility?(:TELEPATHY)
|
||||||
@@ -128,10 +128,11 @@ class Battle::AI
|
|||||||
return true if target.hasActiveAbility?(:OVERCOAT)
|
return true if target.hasActiveAbility?(:OVERCOAT)
|
||||||
return true if target.hasActiveItem?(:SAFETYGOGGLES)
|
return true if target.hasActiveItem?(:SAFETYGOGGLES)
|
||||||
end
|
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
|
!move.ignoresSubstitute?(user) && user.index != target.index
|
||||||
return true if Settings::MECHANICS_GENERATION >= 7 && user.hasActiveAbility?(:PRANKSTER) &&
|
return true if move.statusMove? && Settings::MECHANICS_GENERATION >= 7 &&
|
||||||
target.pbHasType?(:DARK) && target.opposes?(user)
|
user.hasActiveAbility?(:PRANKSTER) && target.pbHasType?(:DARK) &&
|
||||||
|
target.opposes?(user)
|
||||||
return true if move.priority > 0 && @battle.field.terrain == :Psychic &&
|
return true if move.priority > 0 && @battle.field.terrain == :Psychic &&
|
||||||
target.affectedByTerrain? && target.opposes?(user)
|
target.affectedByTerrain? && target.opposes?(user)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user