From 5086f692dffce6e68ad92f1dcab8b2c21e5d5264 Mon Sep 17 00:00:00 2001 From: Conmh <97131221+Conmh@users.noreply.github.com> Date: Sat, 4 Feb 2023 16:22:22 -0500 Subject: [PATCH] added Belch to consideration for some function codes and fixed a typo (#199) * added Belch to consideration for some AI function codes and fixed a typo --- .../011_Battle/005_AI/020_AI_Move_EffectScoresGeneric.rb | 2 +- Data/Scripts/011_Battle/005_AI/057_AI_MoveHandlers_Items.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Data/Scripts/011_Battle/005_AI/020_AI_Move_EffectScoresGeneric.rb b/Data/Scripts/011_Battle/005_AI/020_AI_Move_EffectScoresGeneric.rb index d207c9893..01debe46f 100644 --- a/Data/Scripts/011_Battle/005_AI/020_AI_Move_EffectScoresGeneric.rb +++ b/Data/Scripts/011_Battle/005_AI/020_AI_Move_EffectScoresGeneric.rb @@ -1092,7 +1092,7 @@ class Battle::AI :KEEBERRY => :DEFENSE, :MARANGABERRY => :SPECIAL_DEFENSE }[item] - ret += 8 if stat && ai.stat_raise_worthwhile?(battler, stat) + ret += 8 if stat && stat_raise_worthwhile?(battler, stat) ret = ret * 3 / 2 if GameData::Item.get(item).is_berry? && battler.has_active_ability?(:RIPEN) when :STARFBERRY # Random stat raise diff --git a/Data/Scripts/011_Battle/005_AI/057_AI_MoveHandlers_Items.rb b/Data/Scripts/011_Battle/005_AI/057_AI_MoveHandlers_Items.rb index 79857a780..5e910b1a3 100644 --- a/Data/Scripts/011_Battle/005_AI/057_AI_MoveHandlers_Items.rb +++ b/Data/Scripts/011_Battle/005_AI/057_AI_MoveHandlers_Items.rb @@ -202,6 +202,8 @@ Battle::AI::Handlers::MoveEffectScore.add("UserConsumeBerryRaiseDefense2", user.has_move_with_function?("RestoreUserConsumedItem") # Prefer if user couldn't normally consume the berry score += 4 if !user.battler.canConsumeBerry? + # Prefer if user will become able to use Belch + score += 4 if !user.battler.belched? && user.has_move_with_function?("FailsIfUserNotConsumedBerry") end next score } @@ -229,6 +231,10 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("AllBattlersConsumeBerry" target.has_move_with_function?("RestoreUserConsumedItem") # Prefer if target couldn't normally consume the berry score_change += 4 if !target.battler.canConsumeBerry? + # Prefer if target will become able to use Belch + ai.each_same_side_battler(user.side) do |b, i| + score += 4 if !b.battler.belched? && b.has_move_with_function?("FailsIfUserNotConsumedBerry") + end end score += (target.opposes?(user)) ? -score_change : score_change next score