More AI bug fixes, more work on testing AI

This commit is contained in:
Maruno17
2023-06-18 23:36:06 +01:00
parent b5e37248b9
commit 539bc0fb50
5 changed files with 308 additions and 44 deletions

View File

@@ -22,6 +22,17 @@ class Battle::AI
# against it.
def pbGetMoveScores
choices = []
# TODO: Delete this after testing AI.
if $tested_abilities && @user.ability_id
$tested_abilities[@user.ability_id] ||= 0
$tested_abilities[@user.ability_id] += 1
end
if $tested_items && @user.item_id
$tested_items[@user.item_id] ||= 0
$tested_items[@user.item_id] += 1
end
@user.battler.eachMoveWithIndex do |orig_move, idxMove|
# TODO: Delete this after testing AI.

View File

@@ -456,7 +456,7 @@ Battle::AI::Handlers::ItemRanking.add(:BLACKSLUDGE,
Battle::AI::Handlers::ItemRanking.add(:CHESTOBERRY,
proc { |item, score, battler, ai|
if ai.trainer.high_skill?
score += 1 if battler.has_move_with_function("HealUserFullyAndFallAsleep")
score += 1 if battler.has_move_with_function?("HealUserFullyAndFallAsleep")
end
next score
}
@@ -784,7 +784,7 @@ Battle::AI::Handlers::ItemRanking.add(:TOXICORB,
Battle::AI::Handlers::ItemRanking.add(:WHITEHERB,
proc { |item, score, battler, ai|
if ai.trainer.high_skill?
score += 1 if battler.has_move_with_function("LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2")
score += 1 if battler.has_move_with_function?("LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2")
end
next score
}

View File

@@ -453,7 +453,7 @@ class Battle::AI::AIMove
if user.item_active?
if user.item == :ZOOMLENS
if rough_priority(user) <= 0
mods[:accuracy_multiplier] *= 1.2 if target.faster_than?(user)
modifiers[:accuracy_multiplier] *= 1.2 if target.faster_than?(user)
end
else
Battle::ItemEffects.triggerAccuracyCalcFromUser(

View File

@@ -147,7 +147,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DestroyTargetBerryOrGem"
#===============================================================================
Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("CorrodeTargetItem",
proc { |move, user, target, ai, battle|
next true if !target.item || target.unlosableItem?(target.item) ||
next true if !target.item || target.battler.unlosableItem?(target.item) ||
target.effects[PBEffects::Substitute] > 0
next true if target.has_active_ability?(:STICKYHOLD)
next true if battle.corrosiveGas[target.index % 2][target.party_index]