mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 05:34:58 +00:00
Yet more Rubocopping
This commit is contained in:
@@ -115,12 +115,10 @@ class Battle::AI
|
||||
end
|
||||
end
|
||||
# Log Full Restores (HP healer and status curer)
|
||||
if losthp > 0 || battler.status != :NONE
|
||||
if fullRestoreItems.include?(i)
|
||||
usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
|
||||
usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
|
||||
next
|
||||
end
|
||||
if fullRestoreItems.include?(i) && (losthp > 0 || battler.status != :NONE)
|
||||
usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
|
||||
usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
|
||||
next
|
||||
end
|
||||
# Log single status-curing items
|
||||
if oneStatusItems.include?(i)
|
||||
|
||||
@@ -48,8 +48,8 @@ class Battle::AI
|
||||
skill >= PBTrainerAI.highSkill
|
||||
toxicHP = battler.totalhp / 16
|
||||
nextToxicHP = toxicHP * (battler.effects[PBEffects::Toxic] + 1)
|
||||
if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2
|
||||
shouldSwitch = true if pbAIRandom(100) < 80
|
||||
if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2 && pbAIRandom(100) < 80
|
||||
shouldSwitch = true
|
||||
end
|
||||
end
|
||||
# Pokémon is Encored into an unfavourable move
|
||||
@@ -62,8 +62,8 @@ class Battle::AI
|
||||
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove], battler, b, skill)
|
||||
scoreCount += 1
|
||||
end
|
||||
if scoreCount > 0 && scoreSum / scoreCount <= 20
|
||||
shouldSwitch = true if pbAIRandom(100) < 80
|
||||
if scoreCount > 0 && scoreSum / scoreCount <= 20 && pbAIRandom(100) < 80
|
||||
shouldSwitch = true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -72,9 +72,9 @@ class Battle::AI
|
||||
if @battle.pbSideSize(battler.index + 1) == 1 &&
|
||||
!battler.pbDirectOpposing.fainted? && skill >= PBTrainerAI.highSkill
|
||||
opp = battler.pbDirectOpposing
|
||||
if opp.effects[PBEffects::HyperBeam] > 0 ||
|
||||
(opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant])
|
||||
shouldSwitch = false if pbAIRandom(100) < 80
|
||||
if (opp.effects[PBEffects::HyperBeam] > 0 ||
|
||||
(opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant])) && pbAIRandom(100) < 80
|
||||
shouldSwitch = false
|
||||
end
|
||||
end
|
||||
# Sudden Death rule - I'm not sure what this means
|
||||
@@ -103,9 +103,8 @@ class Battle::AI
|
||||
# Don't switch to this if too little HP
|
||||
if spikes > 0
|
||||
spikesDmg = [8, 6, 4][spikes - 1]
|
||||
if pkmn.hp <= pkmn.totalhp / spikesDmg
|
||||
next if !pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE)
|
||||
end
|
||||
next if pkmn.hp <= pkmn.totalhp / spikesDmg &&
|
||||
!pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE)
|
||||
end
|
||||
end
|
||||
# moveType is the type of the target's last used move
|
||||
@@ -136,7 +135,7 @@ class Battle::AI
|
||||
end
|
||||
if @battle.pbRegisterSwitch(idxBattler, list[0])
|
||||
PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will switch with " +
|
||||
"#{@battle.pbParty(idxBattler)[list[0]].name}")
|
||||
@battle.pbParty(idxBattler)[list[0]].name)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,9 +61,9 @@ class Battle::AI
|
||||
# Decide whether all choices are bad, and if so, try switching instead
|
||||
if !wildBattler && skill >= PBTrainerAI.highSkill
|
||||
badMoves = false
|
||||
if (maxScore <= 20 && user.turnCount > 2) ||
|
||||
(maxScore <= 40 && user.turnCount > 5)
|
||||
badMoves = true if pbAIRandom(100) < 80
|
||||
if ((maxScore <= 20 && user.turnCount > 2) ||
|
||||
(maxScore <= 40 && user.turnCount > 5)) && pbAIRandom(100) < 80
|
||||
badMoves = true
|
||||
end
|
||||
if !badMoves && totalScore < 100 && user.turnCount > 1
|
||||
badMoves = true
|
||||
@@ -160,13 +160,12 @@ class Battle::AI
|
||||
return 0 if score <= 0
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
# Prefer damaging moves if AI has no more Pokémon or AI is less clever
|
||||
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
|
||||
if !(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0)
|
||||
if move.statusMove?
|
||||
score /= 1.5
|
||||
elsif target.hp <= target.totalhp / 2
|
||||
score *= 1.5
|
||||
end
|
||||
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 &&
|
||||
!(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0)
|
||||
if move.statusMove?
|
||||
score /= 1.5
|
||||
elsif target.hp <= target.totalhp / 2
|
||||
score *= 1.5
|
||||
end
|
||||
end
|
||||
# Don't prefer attacking the target if they'd be semi-invulnerable
|
||||
@@ -266,18 +265,16 @@ class Battle::AI
|
||||
end
|
||||
# Prefer flinching external effects (note that move effects which cause
|
||||
# flinching are dealt with in the function code part of score calculation)
|
||||
if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove?
|
||||
if !target.hasActiveAbility?(:INNERFOCUS) &&
|
||||
!target.hasActiveAbility?(:SHIELDDUST) &&
|
||||
target.effects[PBEffects::Substitute] == 0
|
||||
canFlinch = false
|
||||
if user.hasActiveItem?([:KINGSROCK, :RAZORFANG])
|
||||
canFlinch = true
|
||||
elsif user.hasActiveAbility?(:STENCH)
|
||||
canFlinch = true
|
||||
end
|
||||
realDamage *= 1.3 if canFlinch
|
||||
if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove? &&
|
||||
!target.hasActiveAbility?(:INNERFOCUS) &&
|
||||
!target.hasActiveAbility?(:SHIELDDUST) &&
|
||||
target.effects[PBEffects::Substitute] == 0
|
||||
canFlinch = false
|
||||
if user.hasActiveItem?([:KINGSROCK, :RAZORFANG]) ||
|
||||
user.hasActiveAbility?(:STENCH)
|
||||
canFlinch = true
|
||||
end
|
||||
realDamage *= 1.3 if canFlinch
|
||||
end
|
||||
# Convert damage to percentage of target's remaining HP
|
||||
damagePercentage = realDamage * 100.0 / target.hp
|
||||
|
||||
@@ -859,9 +859,7 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAttack1"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score += target.stages[:ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasPhysicalAttack = false
|
||||
@@ -876,6 +874,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 20 if target.stages[:ATTACK] > 0
|
||||
@@ -892,10 +892,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetDefense1"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score += target.stages[:DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:DEFENSE] > 0
|
||||
score += 20
|
||||
@@ -903,15 +903,15 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpeed1", "LowerTargetSpeed1WeakerInGrassyTerrain"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPEED, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPEED, user)
|
||||
score += target.stages[:SPEED] * 10
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
aspeed = pbRoughStat(user, :SPEED, skill)
|
||||
ospeed = pbRoughStat(target, :SPEED, skill)
|
||||
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif user.stages[:SPEED] > 0
|
||||
score += 20
|
||||
@@ -919,9 +919,7 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpAtk1"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score += user.stages[:SPECIAL_ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasSpecicalAttack = false
|
||||
@@ -936,6 +934,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 20 if user.stages[:SPECIAL_ATTACK] > 0
|
||||
@@ -952,10 +952,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpDef1"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||
score += target.stages[:SPECIAL_DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:SPECIAL_DEFENSE] > 0
|
||||
score += 20
|
||||
@@ -963,10 +963,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAccuracy1", "LowerTargetAccuracy2", "LowerTargetAccuracy3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:ACCURACY, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:ACCURACY, user)
|
||||
score += target.stages[:ACCURACY] * 10
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:ACCURACY] > 0
|
||||
score += 20
|
||||
@@ -974,10 +974,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetEvasion1", "LowerTargetEvasion2", "LowerTargetEvasion3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:EVASION, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:EVASION, user)
|
||||
score += target.stages[:EVASION] * 10
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:EVASION] > 0
|
||||
score += 20
|
||||
@@ -985,10 +985,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetEvasion1RemoveSideEffects"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:EVASION, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:EVASION, user)
|
||||
score += target.stages[:EVASION] * 10
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:EVASION] > 0
|
||||
score += 20
|
||||
@@ -1009,9 +1009,7 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAttack2", "LowerTargetAttack3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
@@ -1027,6 +1025,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1044,11 +1044,11 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetDefense2", "LowerTargetDefense3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1057,9 +1057,7 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpeed2", "LowerTargetSpeed3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPEED, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPEED, user)
|
||||
score += 20 if user.turnCount == 0
|
||||
score += target.stages[:SPEED] * 20
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
@@ -1067,6 +1065,8 @@ class Battle::AI
|
||||
ospeed = pbRoughStat(target, :SPEED, skill)
|
||||
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1078,9 +1078,7 @@ class Battle::AI
|
||||
target.hasActiveAbility?(:OBLIVIOUS)
|
||||
score -= 90
|
||||
elsif move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:SPECIAL_ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
@@ -1096,6 +1094,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1113,11 +1113,11 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpDef2", "LowerTargetSpDef3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:SPECIAL_DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1323,9 +1323,7 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "SetUserTypesToUserMoveType"
|
||||
if !user.canChangeType?
|
||||
score -= 90
|
||||
else
|
||||
if user.canChangeType?
|
||||
has_possible_type = false
|
||||
user.eachMoveWithIndex do |m, i|
|
||||
break if Settings::MECHANICS_GENERATION >= 6 && i > 0
|
||||
@@ -1335,6 +1333,8 @@ class Battle::AI
|
||||
break
|
||||
end
|
||||
score -= 90 if !has_possible_type
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "SetUserTypesToResistLastAttack"
|
||||
@@ -1350,9 +1350,7 @@ class Battle::AI
|
||||
aType = m.pbCalcType(user)
|
||||
break
|
||||
end
|
||||
if !aType
|
||||
score -= 90
|
||||
else
|
||||
if aType
|
||||
has_possible_type = false
|
||||
GameData::Type.each do |t|
|
||||
next if t.pseudo_type || user.pbHasType?(t.id) ||
|
||||
@@ -1361,6 +1359,8 @@ class Battle::AI
|
||||
break
|
||||
end
|
||||
score -= 90 if !has_possible_type
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -1793,9 +1793,7 @@ class Battle::AI
|
||||
if target.effects[PBEffects::Encore] > 0
|
||||
score -= 90
|
||||
elsif aspeed > ospeed
|
||||
if !target.lastRegularMoveUsed
|
||||
score -= 90
|
||||
else
|
||||
if target.lastRegularMoveUsed
|
||||
moveData = GameData::Move.get(target.lastRegularMoveUsed)
|
||||
if moveData.category == 2 && # Status move
|
||||
[:User, :BothSides].include?(moveData.target)
|
||||
@@ -1805,6 +1803,8 @@ class Battle::AI
|
||||
Effectiveness.ineffective?(pbCalcTypeMod(moveData.type, target, user))
|
||||
score += 60
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -2056,9 +2056,7 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "SwitchOutUserPassOnEffects"
|
||||
if !@battle.pbCanChooseNonActive?(user.index)
|
||||
score -= 100
|
||||
else
|
||||
if @battle.pbCanChooseNonActive?(user.index)
|
||||
score -= 40 if user.effects[PBEffects::Confusion] > 0
|
||||
total = 0
|
||||
GameData::Stat.each_battle { |s| total += user.stages[s.id] }
|
||||
@@ -2075,6 +2073,8 @@ class Battle::AI
|
||||
end
|
||||
score += 75 if !hasDamagingMove
|
||||
end
|
||||
else
|
||||
score -= 100
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "TrapTargetInBattle"
|
||||
@@ -2505,9 +2505,7 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAttack1BypassSubstitute"
|
||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score += target.stages[:ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasPhysicalAttack = false
|
||||
@@ -2522,6 +2520,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAtkSpAtk1"
|
||||
@@ -2537,11 +2537,11 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpAtk2", "LowerTargetSpAtk3"
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:SPECIAL_ATTACK] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "RaiseGroundedGrassBattlersAtkSpAtk1"
|
||||
@@ -3005,7 +3005,7 @@ class Battle::AI
|
||||
end
|
||||
GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] <= 0 }
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasDamagingAttack = user.moves.any? { |m| next m && m.damagingMove? }
|
||||
hasDamagingAttack = user.moves.any? { |m| next m&.damagingMove? }
|
||||
score += 20 if hasDamagingAttack
|
||||
end
|
||||
end
|
||||
@@ -3031,7 +3031,7 @@ class Battle::AI
|
||||
end
|
||||
GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] <= 0 }
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasDamagingAttack = user.moves.any? { |m| next m && m.damagingMove? }
|
||||
hasDamagingAttack = user.moves.any? { |m| next m&.damagingMove? }
|
||||
score += 20 if hasDamagingAttack
|
||||
end
|
||||
end
|
||||
@@ -3064,11 +3064,11 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetDefense1DoublePowerInGravity"
|
||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score += 20
|
||||
score += target.stages[:DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
score += 30 if @battle.field.effects[PBEffects::Gravity] > 0
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -28,28 +28,29 @@ class Battle::AI
|
||||
#=============================================================================
|
||||
def pbCalcTypeModSingle(moveType, defType, user, target)
|
||||
ret = Effectiveness.calculate_one(moveType, defType)
|
||||
# Ring Target
|
||||
if target.hasActiveItem?(:RINGTARGET)
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Foresight
|
||||
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
|
||||
Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Miracle Eye
|
||||
if target.effects[PBEffects::MiracleEye]
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
|
||||
Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Delta Stream's weather
|
||||
if target.effectiveWeather == :StrongWinds
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
|
||||
Effectiveness.super_effective_type?(moveType, defType)
|
||||
if Effectiveness.ineffective_type?(moveType, defType)
|
||||
# Ring Target
|
||||
if target.hasActiveItem?(:RINGTARGET)
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
# Foresight
|
||||
if (user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]) &&
|
||||
defType == :GHOST
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
# Miracle Eye
|
||||
if target.effects[PBEffects::MiracleEye] && defType == :DARK
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
elsif Effectiveness.super_effective_type?(moveType, defType)
|
||||
# Delta Stream's weather
|
||||
if target.effectiveWeather == :StrongWinds && defType == :FLYING
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
end
|
||||
# Grounded Flying-type Pokémon become susceptible to Ground moves
|
||||
if !target.airborne?
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
|
||||
if !target.airborne? && defType == :FLYING && moveType == :GROUND
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -256,7 +257,7 @@ class Battle::AI
|
||||
when "HitOncePerUserTeamMember" # Beat Up
|
||||
mult = 0
|
||||
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn, _i|
|
||||
mult += 1 if pkmn && pkmn.able? && pkmn.status == :NONE
|
||||
mult += 1 if pkmn&.able? && pkmn.status == :NONE
|
||||
end
|
||||
baseDmg *= mult
|
||||
when "TwoTurnAttackOneTurnInSun" # Solar Beam
|
||||
@@ -390,26 +391,20 @@ class Battle::AI
|
||||
)
|
||||
end
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill && target.itemActive?
|
||||
# NOTE: Type-weakening berries aren't suitable for checking at the start
|
||||
# of the round.
|
||||
if target.item && !target.item.is_berry?
|
||||
if skill >= PBTrainerAI.bestSkill && target.itemActive? && (target.item && !target.item.is_berry?)
|
||||
Battle::ItemEffects.triggerDamageCalcFromTarget(
|
||||
target.item, user, target, move, multipliers, baseDmg, type
|
||||
)
|
||||
end
|
||||
end
|
||||
# Global abilities
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
|
||||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
|
||||
if skill >= PBTrainerAI.mediumSkill && ((@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
|
||||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY))
|
||||
if @battle.pbCheckGlobalAbility(:AURABREAK)
|
||||
multipliers[:base_damage_multiplier] *= 2 / 3.0
|
||||
else
|
||||
multipliers[:base_damage_multiplier] *= 4 / 3.0
|
||||
end
|
||||
end
|
||||
end
|
||||
# Parental Bond
|
||||
if skill >= PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND)
|
||||
multipliers[:base_damage_multiplier] *= 1.25
|
||||
@@ -418,11 +413,9 @@ class Battle::AI
|
||||
# TODO
|
||||
# Helping Hand - n/a
|
||||
# Charge
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
|
||||
if skill >= PBTrainerAI.mediumSkill && (user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC)
|
||||
multipliers[:base_damage_multiplier] *= 2
|
||||
end
|
||||
end
|
||||
# Mud Sport and Water Sport
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if type == :ELECTRIC
|
||||
@@ -456,25 +449,17 @@ class Battle::AI
|
||||
end
|
||||
end
|
||||
# Badge multipliers
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if @battle.internalBattle
|
||||
# Don't need to check the Atk/Sp Atk-boosting badges because the AI
|
||||
# won't control the player's Pokémon.
|
||||
if target.pbOwnedByPlayer?
|
||||
if skill >= PBTrainerAI.highSkill && @battle.internalBattle && target.pbOwnedByPlayer?
|
||||
if move.physicalMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_DEFENSE
|
||||
multipliers[:defense_multiplier] *= 1.1
|
||||
elsif move.specialMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_SPDEF
|
||||
multipliers[:defense_multiplier] *= 1.1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Multi-targeting attacks
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if pbTargetsMultiple?(move, user)
|
||||
if skill >= PBTrainerAI.highSkill && pbTargetsMultiple?(move, user)
|
||||
multipliers[:final_damage_multiplier] *= 0.75
|
||||
end
|
||||
end
|
||||
# Weather
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
case user.effectiveWeather
|
||||
@@ -502,31 +487,26 @@ class Battle::AI
|
||||
# Critical hits - n/a
|
||||
# Random variance - n/a
|
||||
# STAB
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if type && user.pbHasType?(type)
|
||||
if skill >= PBTrainerAI.mediumSkill && (type && user.pbHasType?(type))
|
||||
if user.hasActiveAbility?(:ADAPTABILITY)
|
||||
multipliers[:final_damage_multiplier] *= 2
|
||||
else
|
||||
multipliers[:final_damage_multiplier] *= 1.5
|
||||
end
|
||||
end
|
||||
end
|
||||
# Type effectiveness
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
typemod = pbCalcTypeMod(type, user, target)
|
||||
multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE
|
||||
end
|
||||
# Burn
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if user.status == :BURN && move.physicalMove?(type) &&
|
||||
if skill >= PBTrainerAI.highSkill && (user.status == :BURN && move.physicalMove?(type) &&
|
||||
!user.hasActiveAbility?(:GUTS) &&
|
||||
!(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed") # Facade
|
||||
!(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed")) # Facade
|
||||
multipliers[:final_damage_multiplier] /= 2
|
||||
end
|
||||
end
|
||||
# Aurora Veil, Reflect, Light Screen
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR)
|
||||
if skill >= PBTrainerAI.highSkill && (!move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR))
|
||||
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
|
||||
if @battle.pbSideBattlerCount(target) > 1
|
||||
multipliers[:final_damage_multiplier] *= 2 / 3.0
|
||||
@@ -547,13 +527,10 @@ class Battle::AI
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Minimize
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2)
|
||||
if skill >= PBTrainerAI.highSkill && (target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2))
|
||||
multipliers[:final_damage_multiplier] *= 2
|
||||
end
|
||||
end
|
||||
# Move-specific base damage modifiers
|
||||
# TODO
|
||||
# Move-specific final damage modifiers
|
||||
@@ -572,20 +549,16 @@ class Battle::AI
|
||||
if c >= 0 && user.abilityActive?
|
||||
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
if c >= 0 && !moldBreaker && target.abilityActive?
|
||||
if skill >= PBTrainerAI.bestSkill && (c >= 0 && !moldBreaker && target.abilityActive?)
|
||||
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
|
||||
end
|
||||
end
|
||||
# Item effects that alter critical hit rate
|
||||
if c >= 0 && user.itemActive?
|
||||
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
if c >= 0 && target.itemActive?
|
||||
if skill >= PBTrainerAI.bestSkill && (c >= 0 && target.itemActive?)
|
||||
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
|
||||
end
|
||||
end
|
||||
# Other efffects
|
||||
c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0
|
||||
if c >= 0
|
||||
@@ -659,28 +632,22 @@ class Battle::AI
|
||||
)
|
||||
end
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
if target.abilityActive? && !moldBreaker
|
||||
if skill >= PBTrainerAI.bestSkill && (target.abilityActive? && !moldBreaker)
|
||||
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(
|
||||
target.ability, modifiers, user, target, move, type
|
||||
)
|
||||
end
|
||||
end
|
||||
# Item effects that alter accuracy calculation
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if user.itemActive?
|
||||
if skill >= PBTrainerAI.mediumSkill && user.itemActive?
|
||||
Battle::ItemEffects.triggerAccuracyCalcFromUser(
|
||||
user.item, modifiers, user, target, move, type
|
||||
)
|
||||
end
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
if target.itemActive?
|
||||
if skill >= PBTrainerAI.bestSkill && target.itemActive?
|
||||
Battle::ItemEffects.triggerAccuracyCalcFromTarget(
|
||||
target.item, modifiers, user, target, move, type
|
||||
)
|
||||
end
|
||||
end
|
||||
# Other effects, inc. ones that set accuracy_multiplier or evasion_stage to specific values
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if @battle.field.effects[PBEffects::Gravity] > 0
|
||||
@@ -699,15 +666,15 @@ class Battle::AI
|
||||
user.effects[PBEffects::LockOnPos] == target.index
|
||||
end
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if move.function == "BadPoisonTarget" # Toxic
|
||||
modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
|
||||
user.pbHasType?(:POISON)
|
||||
if move.function == "BadPoisonTarget" && (Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
|
||||
user.pbHasType?(:POISON)) # Toxic
|
||||
modifiers[:base_accuracy] = 0
|
||||
end
|
||||
if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function)
|
||||
modifiers[:base_accuracy] = move.accuracy + user.level - target.level
|
||||
modifiers[:accuracy_multiplier] = 0 if target.level > user.level
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
modifiers[:accuracy_multiplier] = 0 if target.hasActiveAbility?(:STURDY)
|
||||
if skill >= PBTrainerAI.bestSkill && target.hasActiveAbility?(:STURDY)
|
||||
modifiers[:accuracy_multiplier] = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user