Tweaks to item-consuming AI function codes

This commit is contained in:
Maruno17
2023-02-05 19:09:01 +00:00
parent 5086f692df
commit d0c39a3e89

View File

@@ -204,6 +204,8 @@ Battle::AI::Handlers::MoveEffectScore.add("UserConsumeBerryRaiseDefense2",
score += 4 if !user.battler.canConsumeBerry? score += 4 if !user.battler.canConsumeBerry?
# Prefer if user will become able to use Belch # Prefer if user will become able to use Belch
score += 4 if !user.battler.belched? && user.has_move_with_function?("FailsIfUserNotConsumedBerry") score += 4 if !user.battler.belched? && user.has_move_with_function?("FailsIfUserNotConsumedBerry")
# Prefer if user will benefit from not having an item
score += 5 if user.has_active_ability?(:UNBURDEN)
end end
next score next score
} }
@@ -232,9 +234,9 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("AllBattlersConsumeBerry"
# Prefer if target couldn't normally consume the berry # Prefer if target couldn't normally consume the berry
score_change += 4 if !target.battler.canConsumeBerry? score_change += 4 if !target.battler.canConsumeBerry?
# Prefer if target will become able to use Belch # Prefer if target will become able to use Belch
ai.each_same_side_battler(user.side) do |b, i| score += 4 if !target.battler.belched? && target.has_move_with_function?("FailsIfUserNotConsumedBerry")
score += 4 if !b.battler.belched? && b.has_move_with_function?("FailsIfUserNotConsumedBerry") # Prefer if target will benefit from not having an item
end score += 5 if target.has_active_ability?(:UNBURDEN)
end end
score += (target.opposes?(user)) ? -score_change : score_change score += (target.opposes?(user)) ? -score_change : score_change
next score next score
@@ -257,6 +259,10 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("UserConsumeTargetBerry",
# Prefer if user will heal itself with Cheek Pouch # Prefer if user will heal itself with Cheek Pouch
score += 5 if user.battler.canHeal? && user.hp < user.totalhp / 2 && score += 5 if user.battler.canHeal? && user.hp < user.totalhp / 2 &&
user.has_active_ability?(:CHEEKPOUCH) user.has_active_ability?(:CHEEKPOUCH)
# Prefer if user will become able to use Belch
score += 4 if !user.battler.belched? && user.has_move_with_function?("FailsIfUserNotConsumedBerry")
# Don't prefer if target will benefit from not having an item
score -= 5 if target.has_active_ability?(:UNBURDEN)
end end
# Score the target no longer having the item # Score the target no longer having the item
target_item_preference = ai.battler_wants_item?(target, target.item_id) target_item_preference = ai.battler_wants_item?(target, target.item_id)
@@ -301,13 +307,19 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("ThrowUserItemAtTarget",
else else
score -= ai.get_score_change_for_consuming_item(target, user.item_id) score -= ai.get_score_change_for_consuming_item(target, user.item_id)
end end
# Score for other results of consuming the berry
if ai.trainer.medium_skill?
# Don't prefer if target will become able to use Belch
score -= 4 if user.item.is_berry? && !target.battler.belched? &&
target.has_move_with_function?("FailsIfUserNotConsumedBerry")
# Prefer if user will benefit from not having an item
score += 5 if user.has_active_ability?(:UNBURDEN)
end
# Prefer if the user doesn't want its held item/don't prefer if it wants to # Prefer if the user doesn't want its held item/don't prefer if it wants to
# keep its held item # keep its held item
user_item_preference = ai.battler_wants_item?(user, user.item_id) user_item_preference = ai.battler_wants_item?(user, user.item_id)
user_no_item_preference = ai.battler_wants_item?(user, :NONE) user_no_item_preference = ai.battler_wants_item?(user, :NONE)
score += (user_item_preference - user_no_item_preference) * 4 score += (user_item_preference - user_no_item_preference) * 4
# Prefer if user will benefit from not having an item
score += 5 if user.has_active_ability?(:UNBURDEN)
next score next score
} }
) )