mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 13:44:59 +00:00
Errors in the AI no longer cause it to do nothing
This commit is contained in:
@@ -3,7 +3,9 @@ class Battle::AI
|
|||||||
# Decide whether the opponent should use an item on the Pokémon
|
# Decide whether the opponent should use an item on the Pokémon
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
def pbEnemyShouldUseItem?
|
def pbEnemyShouldUseItem?
|
||||||
item, idxTarget = pbEnemyItemToUse
|
item = nil
|
||||||
|
idxTarget = nil
|
||||||
|
PBDebug.logonerr { item, idxTarget = pbEnemyItemToUse }
|
||||||
return false if !item
|
return false if !item
|
||||||
# Determine target of item (always the Pokémon choosing the action)
|
# Determine target of item (always the Pokémon choosing the action)
|
||||||
useType = GameData::Item.get(item).battle_use
|
useType = GameData::Item.get(item).battle_use
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ class Battle::AI
|
|||||||
# Decide whether the opponent should switch Pokémon
|
# Decide whether the opponent should switch Pokémon
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
def pbEnemyShouldWithdraw?
|
def pbEnemyShouldWithdraw?
|
||||||
return pbEnemyShouldWithdrawEx?(false)
|
ret = false
|
||||||
|
PBDebug.logonerr { ret = pbEnemyShouldWithdrawEx?(false) }
|
||||||
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbEnemyShouldWithdrawEx?(forceSwitch)
|
def pbEnemyShouldWithdrawEx?(forceSwitch)
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ class Battle::AI
|
|||||||
# If move has no targets, affects the user, a side or the whole field, or
|
# If move has no targets, affects the user, a side or the whole field, or
|
||||||
# specially affects multiple Pokémon and the AI calculates an overall
|
# specially affects multiple Pokémon and the AI calculates an overall
|
||||||
# score at once instead of per target
|
# score at once instead of per target
|
||||||
score = pbGetMoveScore(move)
|
score = 100
|
||||||
|
PBDebug.logonerr { score = pbGetMoveScore(move) }
|
||||||
choices.push([idxMove, score, -1])
|
choices.push([idxMove, score, -1])
|
||||||
elsif target_data.num_targets > 1
|
elsif target_data.num_targets > 1
|
||||||
# Includes: AllFoes, AllNearFoes, AllNearOthers
|
# Includes: AllFoes, AllNearFoes, AllNearOthers
|
||||||
@@ -65,7 +66,8 @@ class Battle::AI
|
|||||||
num_targets = 0
|
num_targets = 0
|
||||||
@battle.allBattlers.each do |b|
|
@battle.allBattlers.each do |b|
|
||||||
next if !@battle.pbMoveCanTarget?(battler.index, b.index, target_data)
|
next if !@battle.pbMoveCanTarget?(battler.index, b.index, target_data)
|
||||||
score = pbGetMoveScore(move, b)
|
score = 100
|
||||||
|
PBDebug.logonerr { score = pbGetMoveScore(move, b) }
|
||||||
total_score += ((battler.opposes?(b)) ? score : -score)
|
total_score += ((battler.opposes?(b)) ? score : -score)
|
||||||
num_targets += 1
|
num_targets += 1
|
||||||
end
|
end
|
||||||
@@ -84,7 +86,8 @@ class Battle::AI
|
|||||||
# that the target can be immune to by an ability (you may want to
|
# that the target can be immune to by an ability (you may want to
|
||||||
# attack the ally anyway so it gains the effect of that ability).
|
# attack the ally anyway so it gains the effect of that ability).
|
||||||
next if target_data.targets_foe && !battler.opposes?(b)
|
next if target_data.targets_foe && !battler.opposes?(b)
|
||||||
score = pbGetMoveScore(move, b)
|
score = 100
|
||||||
|
PBDebug.logonerr { score = pbGetMoveScore(move, b) }
|
||||||
choices.push([idxMove, score, b.index])
|
choices.push([idxMove, score, b.index])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user