mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Fixed AI accuracy calculation for OHKO moves, reviewed more AI function code score modifiers
This commit is contained in:
@@ -1361,13 +1361,9 @@ class Battle::Move::TypeAndPowerDependOnUserBerry < Battle::Move
|
||||
return false
|
||||
end
|
||||
|
||||
# NOTE: The AI calls this method via pbCalcType, and this method returns a
|
||||
# type assuming user has an item even though it might not. Since the AI
|
||||
# won't want to use this move if the user has no item, though, perhaps
|
||||
# this is good enough.
|
||||
def pbBaseType(user)
|
||||
item = user.item
|
||||
ret = :NORMAL
|
||||
item = user.item
|
||||
if item
|
||||
item.flags.each do |flag|
|
||||
next if !flag[/^NaturalGift_(\w+)_(?:\d+)$/i]
|
||||
@@ -1431,12 +1427,9 @@ class Battle::Move::TypeDependsOnUserPlate < Battle::Move
|
||||
|
||||
def pbBaseType(user)
|
||||
ret = :NORMAL
|
||||
if user.itemActive?
|
||||
@itemTypes.each do |item, itemType|
|
||||
next if user.item != item
|
||||
ret = itemType if GameData::Type.exists?(itemType)
|
||||
break
|
||||
end
|
||||
if user.item_id && user.itemActive?
|
||||
typ = @itemTypes[user.item_id]
|
||||
ret = typ if typ && GameData::Type.exists?(typ)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -1471,12 +1464,9 @@ class Battle::Move::TypeDependsOnUserMemory < Battle::Move
|
||||
|
||||
def pbBaseType(user)
|
||||
ret = :NORMAL
|
||||
if user.itemActive?
|
||||
@itemTypes.each do |item, itemType|
|
||||
next if user.item != item
|
||||
ret = itemType if GameData::Type.exists?(itemType)
|
||||
break
|
||||
end
|
||||
if user.item_id && user.itemActive?
|
||||
typ = @itemTypes[user.item_id]
|
||||
ret = typ if typ && GameData::Type.exists?(typ)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -1498,12 +1488,9 @@ class Battle::Move::TypeDependsOnUserDrive < Battle::Move
|
||||
|
||||
def pbBaseType(user)
|
||||
ret = :NORMAL
|
||||
if user.itemActive?
|
||||
@itemTypes.each do |item, itemType|
|
||||
next if user.item != item
|
||||
ret = itemType if GameData::Type.exists?(itemType)
|
||||
break
|
||||
end
|
||||
if user.item_id && user.itemActive?
|
||||
typ = @itemTypes[user.item_id]
|
||||
ret = typ if typ && GameData::Type.exists?(typ)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -68,8 +68,8 @@ module Battle::AI::Handlers
|
||||
MoveBasePower = HandlerHash.new
|
||||
MoveFailureCheck = HandlerHash.new
|
||||
GeneralMoveScore = HandlerHash.new
|
||||
# Move type
|
||||
# Move accuracy
|
||||
# Move type - uses main battle code via rough_type
|
||||
# Move accuracy - uses main battle code via rough_accuracy
|
||||
# Move target
|
||||
# Move additional effect chance
|
||||
# Move unselectable check
|
||||
|
||||
@@ -133,7 +133,7 @@ class Battle::AI
|
||||
# after all.
|
||||
return true if @move.move.pbImmunityByAbility(@user.battler, @target.battler, false)
|
||||
# Type immunity
|
||||
calc_type = @move.pbCalcType(@user.battler)
|
||||
calc_type = @move.rough_type(@user.battler)
|
||||
typeMod = @move.move.pbCalcTypeMod(calc_type, @user.battler, @target.battler)
|
||||
return true if @move.move.pbDamagingMove? && Effectiveness.ineffective?(typeMod)
|
||||
# Dark-type immunity to moves made faster by Prankster
|
||||
|
||||
@@ -833,6 +833,6 @@ Battle::AI::Handlers::MoveFailureCheck.add("TransformUserIntoTarget",
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("TransformUserIntoTarget",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score - 40
|
||||
next score - 20
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,81 +1,50 @@
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("FixedDamage20",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
next move.pbFixedDamage(user.battler, target.battler)
|
||||
}
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("FixedDamage20",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
if target.hp <= 20
|
||||
score += 80
|
||||
elsif target.level >= 25
|
||||
score -= 60 # Not useful against high-level Pokemon
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("FixedDamage40",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
next move.pbFixedDamage(user.battler, target.battler)
|
||||
}
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("FixedDamage40",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 80 if target.hp <= 40
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("FixedDamageHalfTargetHP",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
next move.pbFixedDamage(user.battler, target.battler)
|
||||
}
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("FixedDamageHalfTargetHP",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
score -= 50
|
||||
next score + target.hp * 100 / target.totalhp
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("FixedDamageUserLevel",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
next move.pbFixedDamage(user.battler, target.battler)
|
||||
}
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("FixedDamageUserLevel",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 80 if target.hp <= user.level
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("FixedDamageUserLevelRandom",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
next user.level # Average power
|
||||
}
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("FixedDamageUserLevelRandom",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 30 if target.hp <= user.level
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveFailureCheck.add("LowerTargetHPToUserHP",
|
||||
proc { |move, user, target, ai, battle|
|
||||
@@ -87,11 +56,6 @@ Battle::AI::Handlers::MoveBasePower.add("LowerTargetHPToUserHP",
|
||||
next move.pbFixedDamage(user.battler, target.battler)
|
||||
}
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("LowerTargetHPToUserHP",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 50 if user.hp < target.hp / 2
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
@@ -104,7 +68,7 @@ Battle::AI::Handlers::MoveFailureCheck.add("OHKO",
|
||||
)
|
||||
Battle::AI::Handlers::MoveBasePower.add("OHKO",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
next 999
|
||||
next target.hp
|
||||
}
|
||||
)
|
||||
|
||||
@@ -120,32 +84,31 @@ Battle::AI::Handlers::MoveFailureCheck.add("OHKOIce",
|
||||
)
|
||||
Battle::AI::Handlers::MoveBasePower.copy("OHKO",
|
||||
"OHKOIce")
|
||||
Battle::AI::Handlers::MoveEffectScore.copy("OHKO",
|
||||
"OHKOIce")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveFailureCheck.copy("OHKO",
|
||||
"OHKOHitsUndergroundTarget")
|
||||
Battle::AI::Handlers::MoveBasePower.copy("OHKO",
|
||||
"OHKOHitsUndergroundTarget")
|
||||
Battle::AI::Handlers::MoveEffectScore.copy("OHKO",
|
||||
"OHKOHitsUndergroundTarget")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("DamageTargetAlly",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
target.battler.allAllies.each do |b|
|
||||
next if !b.near?(target.battler)
|
||||
next if !b.near?(target.battler) || !b.battler.takesIndirectDamage?
|
||||
score += 10
|
||||
score += 15 if b.hp <= b.totalhp / 16
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("PowerHigherWithUserHP",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -154,55 +117,55 @@ Battle::AI::Handlers::MoveBasePower.add("PowerHigherWithUserHP",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP",
|
||||
"PowerLowerWithUserHP")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP",
|
||||
"PowerHigherWithTargetHP")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP",
|
||||
"PowerHigherWithUserHappiness")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP",
|
||||
"PowerLowerWithUserHappiness")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP",
|
||||
"PowerHigherWithUserPositiveStatStages")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP",
|
||||
"PowerHigherWithTargetPositiveStatStages")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP",
|
||||
"PowerHigherWithUserFasterThanTarget")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP",
|
||||
"PowerHigherWithTargetFasterThanUser")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("PowerHigherWithLessPP",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -214,7 +177,7 @@ Battle::AI::Handlers::MoveBasePower.add("PowerHigherWithLessPP",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("PowerHigherWithTargetWeight",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -223,7 +186,7 @@ Battle::AI::Handlers::MoveBasePower.add("PowerHigherWithTargetWeight",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithTargetWeight",
|
||||
"PowerHigherWithUserHeavierThanTarget")
|
||||
@@ -247,7 +210,7 @@ Battle::AI::Handlers::MoveBasePower.add("PowerHigherWithConsecutiveUseOnUserSide
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("RandomPowerDoublePowerIfTargetUnderground",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -257,7 +220,7 @@ Battle::AI::Handlers::MoveBasePower.add("RandomPowerDoublePowerIfTargetUndergrou
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetHPLessThanHalf",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -266,7 +229,7 @@ Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetHPLessThanHalf",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("DoublePowerIfTargetHPLessThanHalf",
|
||||
"DoublePowerIfUserPoisonedBurnedParalyzed")
|
||||
@@ -284,7 +247,7 @@ Battle::AI::Handlers::MoveEffectScore.add("DoublePowerIfTargetAsleepCureTarget",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetPoisoned",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -304,7 +267,7 @@ Battle::AI::Handlers::MoveEffectScore.add("DoublePowerIfTargetParalyzedCureTarge
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetStatusProblem",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -313,7 +276,7 @@ Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetStatusProblem",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfUserHasNoItem",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -322,7 +285,7 @@ Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfUserHasNoItem",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetUnderwater",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -331,13 +294,13 @@ Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetUnderwater",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("DoublePowerIfTargetUnderwater",
|
||||
"DoublePowerIfTargetUnderground")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetInSky",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -346,19 +309,19 @@ Battle::AI::Handlers::MoveBasePower.add("DoublePowerIfTargetInSky",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("DoublePowerIfTargetInSky",
|
||||
"DoublePowerInElectricTerrain")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("DoublePowerIfTargetInSky",
|
||||
"DoublePowerIfUserLastMoveFailed")
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("DoublePowerIfTargetInSky",
|
||||
"DoublePowerIfAllyFaintedLastTurn")
|
||||
@@ -368,7 +331,7 @@ Battle::AI::Handlers::MoveBasePower.copy("DoublePowerIfTargetInSky",
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("DoublePowerIfUserLostHPThisTurn",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 30 if target.faster_than?(user)
|
||||
next score + 15 if target.faster_than?(user)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -377,7 +340,7 @@ Battle::AI::Handlers::MoveEffectScore.add("DoublePowerIfUserLostHPThisTurn",
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("DoublePowerIfTargetLostHPThisTurn",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 20 if battle.pbOpposingBattlerCount(user.battler) > 1
|
||||
next score + 15 if battle.pbOpposingBattlerCount(user.battler) > 1
|
||||
}
|
||||
)
|
||||
|
||||
@@ -391,14 +354,18 @@ Battle::AI::Handlers::MoveEffectScore.add("DoublePowerIfTargetLostHPThisTurn",
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("DoublePowerIfTargetActed",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 30 if target.faster_than?(user)
|
||||
next score + 15 if target.faster_than?(user)
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#===============================================================================
|
||||
# DoublePowerIfTargetNotActed
|
||||
Battle::AI::Handlers::MoveEffectScore.add("DoublePowerIfTargetNotActed",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 15 if user.faster_than?(target)
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
@@ -440,9 +407,9 @@ Battle::AI::Handlers::MoveEffectScore.add("CannotMakeTargetFaint",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next 0 if target.hp == 1
|
||||
if target.hp <= target.totalhp / 8
|
||||
score -= 60
|
||||
score -= 20
|
||||
elsif target.hp <= target.totalhp / 4
|
||||
score -= 30
|
||||
score -= 10
|
||||
end
|
||||
next score
|
||||
}
|
||||
@@ -454,12 +421,12 @@ Battle::AI::Handlers::MoveEffectScore.add("CannotMakeTargetFaint",
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("UserEnduresFaintingThisTurn",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
score -= 25 if user.hp > user.totalhp / 2
|
||||
score -= 10 if user.hp > user.totalhp / 2
|
||||
if ai.trainer.medium_skill?
|
||||
score -= 50 if user.effects[PBEffects::ProtectRate] > 1
|
||||
score -= 50 if target.effects[PBEffects::HyperBeam] > 0
|
||||
score -= 20 if user.effects[PBEffects::ProtectRate] > 1
|
||||
score -= 20 if target.effects[PBEffects::HyperBeam] > 0
|
||||
else
|
||||
score -= user.effects[PBEffects::ProtectRate] * 40
|
||||
score -= user.effects[PBEffects::ProtectRate] * 10
|
||||
end
|
||||
next score
|
||||
}
|
||||
@@ -477,11 +444,6 @@ Battle::AI::Handlers::MoveFailureCheck.add("StartWeakenElectricMoves",
|
||||
end
|
||||
}
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("StartWeakenElectricMoves",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next 0 if user.effects[PBEffects::MudSport]
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
@@ -495,11 +457,6 @@ Battle::AI::Handlers::MoveFailureCheck.add("StartWeakenFireMoves",
|
||||
end
|
||||
}
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("StartWeakenFireMoves",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next 0 if user.effects[PBEffects::WaterSport]
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
@@ -539,9 +496,9 @@ Battle::AI::Handlers::MoveEffectScore.add("StartWeakenDamageAgainstUserSideIfHai
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("RemoveScreens",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
score += 20 if user.pbOpposingSide.effects[PBEffects::AuroraVeil] > 0
|
||||
score += 20 if user.pbOpposingSide.effects[PBEffects::Reflect] > 0
|
||||
score += 20 if user.pbOpposingSide.effects[PBEffects::LightScreen] > 0
|
||||
score += 10 if user.pbOpposingSide.effects[PBEffects::AuroraVeil] > 0
|
||||
score += 10 if user.pbOpposingSide.effects[PBEffects::Reflect] > 0
|
||||
score += 10 if user.pbOpposingSide.effects[PBEffects::LightScreen] > 0
|
||||
next score
|
||||
}
|
||||
)
|
||||
@@ -762,21 +719,15 @@ Battle::AI::Handlers::MoveEffectScore.add("RecoilHalfOfDamageDealt",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("EffectivenessIncludesFlyingType",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
if GameData::Type.exists?(:FLYING)
|
||||
if ai.trainer.high_skill?
|
||||
targetTypes = target.battler.pbTypes(true)
|
||||
mult = Effectiveness.calculate(
|
||||
:FLYING, targetTypes[0], targetTypes[1], targetTypes[2]
|
||||
)
|
||||
else
|
||||
mult = Effectiveness.calculate(
|
||||
:FLYING, target.types[0], target.types[1], target.effects[PBEffects::Type3]
|
||||
)
|
||||
end
|
||||
targetTypes = target.battler.pbTypes(true)
|
||||
mult = Effectiveness.calculate(
|
||||
:FLYING, targetTypes[0], targetTypes[1], targetTypes[2]
|
||||
)
|
||||
next (power.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
|
||||
end
|
||||
}
|
||||
@@ -858,12 +809,12 @@ Battle::AI::Handlers::MoveEffectScore.add("StartNegateTargetEvasionStatStageAndD
|
||||
# IgnoreTargetDefSpDefEvaStatStages
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
# TypeIsUserFirstType
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("TypeDependsOnUserIVs",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -890,17 +841,17 @@ Battle::AI::Handlers::MoveBasePower.add("TypeAndPowerDependOnUserBerry",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
# TypeDependsOnUserPlate
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
# TypeDependsOnUserMemory
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
# TypeDependsOnUserDrive
|
||||
|
||||
@@ -919,7 +870,7 @@ Battle::AI::Handlers::MoveEffectScore.add("TypeDependsOnUserMorpekoFormRaiseUser
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.add("TypeAndPowerDependOnWeather",
|
||||
proc { |power, move, user, target, ai, battle|
|
||||
@@ -928,15 +879,10 @@ Battle::AI::Handlers::MoveBasePower.add("TypeAndPowerDependOnWeather",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("TypeAndPowerDependOnWeather",
|
||||
"TypeAndPowerDependOnTerrain")
|
||||
Battle::AI::Handlers::MoveEffectScore.add("TypeAndPowerDependOnTerrain",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 40 if battle.field.terrain != :None
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
|
||||
@@ -194,9 +194,9 @@ Battle::AI::Handlers::MoveEffectScore.add("TwoTurnAttackParalyzeTarget",
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("TwoTurnAttackBurnTarget",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next 0 if !target.battler.pbCanBurn?(user.battler, false)
|
||||
score += 30
|
||||
score -= 40 if target.has_active_ability?([:GUTS, :MARVELSCALE, :QUICKFEET, :FLAREBOOST])
|
||||
next score - 40 if move.statusMove? && !target.battler.pbCanBurn?(user.battler, false)
|
||||
score += 10
|
||||
score -= 20 if target.has_active_ability?([:GUTS, :MARVELSCALE, :QUICKFEET, :FLAREBOOST])
|
||||
next score
|
||||
}
|
||||
)
|
||||
@@ -226,33 +226,27 @@ Battle::AI::Handlers::MoveFailureCheck.add("TwoTurnAttackRaiseUserSpAtkSpDefSpd2
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("TwoTurnAttackRaiseUserSpAtkSpDefSpd2",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
if user.statStageAtMax?(:SPECIAL_ATTACK) &&
|
||||
user.statStageAtMax?(:SPECIAL_DEFENSE) &&
|
||||
user.statStageAtMax?(:SPEED)
|
||||
score -= 90
|
||||
else
|
||||
score -= user.stages[:SPECIAL_ATTACK] * 10 # Only *10 instead of *20
|
||||
score -= user.stages[:SPECIAL_DEFENSE] * 10 # because two-turn attack
|
||||
score -= user.stages[:SPEED] * 10
|
||||
if ai.trainer.medium_skill?
|
||||
hasSpecialAttack = false
|
||||
user.battler.eachMove do |m|
|
||||
next if !m.specialMove?(m.type)
|
||||
hasSpecialAttack = true
|
||||
break
|
||||
end
|
||||
if hasSpecialAttack
|
||||
score += 20
|
||||
elsif ai.trainer.high_skill?
|
||||
score -= 90
|
||||
end
|
||||
score -= user.stages[:SPECIAL_ATTACK] * 10 # Only *10 instead of *20
|
||||
score -= user.stages[:SPECIAL_DEFENSE] * 10 # because two-turn attack
|
||||
score -= user.stages[:SPEED] * 10
|
||||
if ai.trainer.medium_skill?
|
||||
hasSpecialAttack = false
|
||||
user.battler.eachMove do |m|
|
||||
next if !m.specialMove?(m.type)
|
||||
hasSpecialAttack = true
|
||||
break
|
||||
end
|
||||
if ai.trainer.high_skill?
|
||||
aspeed = user.rough_stat(:SPEED)
|
||||
ospeed = target.rough_stat(:SPEED)
|
||||
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
||||
if hasSpecialAttack
|
||||
score += 20
|
||||
elsif ai.trainer.high_skill?
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
if ai.trainer.high_skill?
|
||||
aspeed = user.rough_stat(:SPEED)
|
||||
ospeed = target.rough_stat(:SPEED)
|
||||
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
@@ -27,13 +27,13 @@ Battle::AI::Handlers::MoveEffectScore.add("CannotBeRedirected",
|
||||
if b.effects[PBEffects::RagePowder] ||
|
||||
b.effects[PBEffects::Spotlight] > 0 ||
|
||||
b.effects[PBEffects::FollowMe] > 0 ||
|
||||
(b.hasActiveAbility?(:LIGHTNINGROD) && move.pbCalcType == :ELECTRIC) ||
|
||||
(b.hasActiveAbility?(:STORMDRAIN) && move.pbCalcType == :WATER)
|
||||
(b.hasActiveAbility?(:LIGHTNINGROD) && move.rough_type == :ELECTRIC) ||
|
||||
(b.hasActiveAbility?(:STORMDRAIN) && move.rough_type == :WATER)
|
||||
redirection = true
|
||||
break
|
||||
end
|
||||
end
|
||||
score += 50 if redirection && ai.trainer.medium_skill?
|
||||
score += 20 if redirection && ai.trainer.medium_skill?
|
||||
next score
|
||||
}
|
||||
)
|
||||
@@ -115,7 +115,8 @@ Battle::AI::Handlers::MoveBasePower.add("HitsAllFoesAndPowersUpInPsychicTerrain"
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("HitsAllFoesAndPowersUpInPsychicTerrain",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 40 if battle.field.terrain == :Psychic && user.battler.affectedByTerrain?
|
||||
next score + 20 if battle.field.terrain == :Psychic && user.battler.affectedByTerrain? &&
|
||||
battle.allOtherSideBattlers(user.index).length > 1
|
||||
}
|
||||
)
|
||||
|
||||
@@ -176,17 +177,14 @@ Battle::AI::Handlers::MoveBasePower.add("CounterPhysicalDamage",
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("CounterPhysicalDamage",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
if target.effects[PBEffects::HyperBeam] > 0
|
||||
score -= 90
|
||||
else
|
||||
attack = user.rough_stat(:ATTACK)
|
||||
spatk = user.rough_stat(:SPECIAL_ATTACK)
|
||||
if attack * 1.5 < spatk
|
||||
score -= 60
|
||||
elsif ai.trainer.medium_skill? && target.battler.lastMoveUsed
|
||||
moveData = GameData::Move.get(target.battler.lastMoveUsed)
|
||||
score += 60 if moveData.physical?
|
||||
end
|
||||
next score - 40 if target.effects[PBEffects::HyperBeam] > 0
|
||||
attack = user.rough_stat(:ATTACK)
|
||||
spatk = user.rough_stat(:SPECIAL_ATTACK)
|
||||
if attack * 1.5 < spatk
|
||||
score -= 60
|
||||
elsif ai.trainer.medium_skill? && target.battler.lastMoveUsed
|
||||
moveData = GameData::Move.get(target.battler.lastMoveUsed)
|
||||
score += 60 if moveData.physical?
|
||||
end
|
||||
next score
|
||||
}
|
||||
@@ -203,17 +201,14 @@ Battle::AI::Handlers::MoveBasePower.add("CounterSpecialDamage",
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("CounterSpecialDamage",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
if target.effects[PBEffects::HyperBeam] > 0
|
||||
score -= 90
|
||||
else
|
||||
attack = user.rough_stat(:ATTACK)
|
||||
spatk = user.rough_stat(:SPECIAL_ATTACK)
|
||||
if attack > spatk * 1.5
|
||||
score -= 60
|
||||
elsif ai.trainer.medium_skill? && target.battler.lastMoveUsed
|
||||
moveData = GameData::Move.get(target.battler.lastMoveUsed)
|
||||
score += 60 if moveData.special?
|
||||
end
|
||||
next score - 40 if target.effects[PBEffects::HyperBeam] > 0
|
||||
attack = user.rough_stat(:ATTACK)
|
||||
spatk = user.rough_stat(:SPECIAL_ATTACK)
|
||||
if attack > spatk * 1.5
|
||||
score -= 60
|
||||
elsif ai.trainer.medium_skill? && target.battler.lastMoveUsed
|
||||
moveData = GameData::Move.get(target.battler.lastMoveUsed)
|
||||
score += 60 if moveData.special?
|
||||
end
|
||||
next score
|
||||
}
|
||||
@@ -230,7 +225,7 @@ Battle::AI::Handlers::MoveBasePower.add("CounterDamagePlusHalf",
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("CounterDamagePlusHalf",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score - 90 if target.effects[PBEffects::HyperBeam] > 0
|
||||
next score - 40 if target.effects[PBEffects::HyperBeam] > 0
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveFailureCheck.add("FleeFromBattle",
|
||||
proc { |move, user, target, ai, battle|
|
||||
next true if battle.pbCanRun?(user.index)
|
||||
next true if !battle.pbCanRun?(user.index)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ Battle::AI::Handlers::MoveFailureCheck.add("SwitchOutUserStatusMove",
|
||||
)
|
||||
Battle::AI::Handlers::MoveEffectScore.add("SwitchOutUserStatusMove",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
next score + 10 if user.wild?
|
||||
if battle.pbTeamAbleNonActiveCount(user.index) > 1 # Don't switch in ace
|
||||
score -= 60
|
||||
else
|
||||
@@ -505,10 +506,10 @@ Battle::AI::Handlers::MoveFailureCheck.copy("StartSunWeather",
|
||||
Battle::AI::Handlers::MoveEffectScore.add("StartShadowSkyWeather",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
score += 20 # Shadow moves are more preferable
|
||||
if battle.pbCheckGlobalAbility(:AIRLOCK) ||
|
||||
battle.pbCheckGlobalAbility(:CLOUDNINE)
|
||||
score -= 50
|
||||
end
|
||||
next score - 40 if battle.pbCheckGlobalAbility(:AIRLOCK) ||
|
||||
battle.pbCheckGlobalAbility(:CLOUDNINE)
|
||||
score += 10 if battle.field.weather != :None # Prefer replacing another weather
|
||||
score -= 10 if user.hp < user.totalhp / 2 # Not worth it at lower HP
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
@@ -115,7 +115,7 @@ Battle::AI::Handlers::GeneralMoveScore.add(:damaging_moves_if_last_pokemon,
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::GeneralMoveScore.add(:target_semi_invulnerable,
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
if move.accuracy > 0 && target && user.faster_than?(target) &&
|
||||
if move.rough_accuracy > 0 && target && user.faster_than?(target) &&
|
||||
(target.battler.semiInvulnerable? || target.effects[PBEffects::SkyDrop] >= 0)
|
||||
miss = true
|
||||
miss = false if user.has_active_ability?(:NOGUARD)
|
||||
|
||||
@@ -75,13 +75,10 @@ class Battle::AI::AIMove
|
||||
def type; return @move.type; end
|
||||
|
||||
def rough_type
|
||||
return @move.pbCalcType(@ai.user.battler) if @ai.trainer.high_skill?
|
||||
return @move.pbCalcType(@ai.user.battler) if @ai.trainer.medium_skill?
|
||||
return @move.type
|
||||
end
|
||||
|
||||
# TODO: Should this exist, or should all type checks go through rough_type?
|
||||
def pbCalcType(user); return @move.pbCalcType(user); end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
# Returns this move's base power, taking into account various effects that
|
||||
@@ -369,6 +366,7 @@ class Battle::AI::AIMove
|
||||
#=============================================================================
|
||||
|
||||
def accuracy
|
||||
return @move.pbBaseAccuracy(@ai.user.battler, @ai.target.battler) if @ai.trainer.medium_skill?
|
||||
return @move.accuracy
|
||||
end
|
||||
|
||||
@@ -379,18 +377,14 @@ class Battle::AI::AIMove
|
||||
return 100 if target.effects[PBEffects::Minimize] && @move.tramplesMinimize? &&
|
||||
Settings::MECHANICS_GENERATION >= 6
|
||||
end
|
||||
baseAcc = self.accuracy
|
||||
return 100 if baseAcc == 0
|
||||
# Determine user and target
|
||||
user = @ai.user
|
||||
user_battler = user.battler
|
||||
target = @ai.target
|
||||
target_battler = target.battler
|
||||
# Get better base accuracy
|
||||
if @ai.trainer.medium_skill?
|
||||
baseAcc = @move.pbBaseAccuracy(user_battler, target_battler)
|
||||
return 100 if baseAcc == 0
|
||||
end
|
||||
# Get base accuracy
|
||||
baseAcc = self.accuracy
|
||||
return 100 if baseAcc == 0
|
||||
# Get the move's type
|
||||
type = rough_type
|
||||
# Calculate all modifier effects
|
||||
@@ -420,6 +414,27 @@ class Battle::AI::AIMove
|
||||
def apply_rough_accuracy_modifiers(user, target, calc_type, modifiers)
|
||||
user_battler = user.battler
|
||||
target_battler = target.battler
|
||||
# OHKO special calculation
|
||||
if @ai.trainer.medium_skill?
|
||||
case function
|
||||
when "OHKO", "OHKOHitsUndergroundTarget"
|
||||
modifiers[:base_accuracy] = self.accuracy + user.level - target.level
|
||||
modifiers[:base_accuracy] = -1 if target.level > user.level
|
||||
modifiers[:base_accuracy] = -1 if !@ai.battle.moldBreaker && target.has_active_ability?(:STURDY)
|
||||
modifiers[:accuracy_stage] = 6
|
||||
modifiers[:evasion_stage] = 6
|
||||
return
|
||||
when "OHKOIce"
|
||||
modifiers[:base_accuracy] = self.accuracy + user.level - target.level
|
||||
modifiers[:base_accuracy] -= 10 if !user.has_type?(:ICE)
|
||||
modifiers[:base_accuracy] = -1 if modifiers[:base_accuracy] == 0
|
||||
modifiers[:base_accuracy] = -1 if target.level > user.level
|
||||
modifiers[:base_accuracy] = -1 if !@ai.battle.moldBreaker && target.has_active_ability?(:STURDY)
|
||||
modifiers[:accuracy_stage] = 6
|
||||
modifiers[:evasion_stage] = 6
|
||||
return
|
||||
end
|
||||
end
|
||||
# Ability effects that alter accuracy calculation
|
||||
if user.ability_active?
|
||||
Battle::AbilityEffects.triggerAccuracyCalcFromUser(
|
||||
@@ -472,15 +487,6 @@ class Battle::AI::AIMove
|
||||
when "BadPoisonTarget"
|
||||
modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS &&
|
||||
@move.statusMove? && @user.has_type?(:POISON)
|
||||
when "OHKO", "OHKOHitsUndergroundTarget"
|
||||
modifiers[:base_accuracy] = self.accuracy + user.level - target.level
|
||||
modifiers[:accuracy_multiplier] = 0 if target.level > user.level
|
||||
modifiers[:accuracy_multiplier] = 0 if !@ai.battle.moldBreaker && target.has_active_ability?(:STURDY)
|
||||
when "OHKOIce"
|
||||
modifiers[:base_accuracy] = self.accuracy + user.level - target.level
|
||||
modifiers[:base_accuracy] -= 10 if !user.has_type?(:ICE)
|
||||
modifiers[:accuracy_multiplier] = 0 if target.level > user.level
|
||||
modifiers[:accuracy_multiplier] = 0 if !@ai.battle.moldBreaker && target.has_active_ability?(:STURDY)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user