From e6fe242d4bd8e3dc4f7e30bbc144da4f563ba44a Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Thu, 1 Feb 2024 23:50:09 +0000 Subject: [PATCH] AI changes, fixed input detection Conditional Branch, Fishious Rend is now a biting move --- .../004_Interpreter_Commands.rb | 16 +- .../001_Battle/009_Battle_CommandPhase.rb | 2 +- .../011_Battle/005_AI/002_AI_Switch.rb | 3 +- .../006_AI_ChooseMove_GenericEffects.rb | 30 +++- .../005_AI/007_AI_ChooseMove_OtherScores.rb | 13 +- Data/Scripts/011_Battle/005_AI/011_AIMove.rb | 29 +++- .../003_AI_MoveEffects_BattlerOther.rb | 138 +++++++++--------- .../004_AI_MoveEffects_MoveAttributes.rb | 6 + .../006_AI_MoveEffects_Healing.rb | 12 +- .../009_AI_MoveEffects_SwitchingActing.rb | 14 +- PBS/Gen 8 backup/moves.txt | 2 +- PBS/moves.txt | 2 +- 12 files changed, 159 insertions(+), 108 deletions(-) diff --git a/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb b/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb index 581672311..e17ae073d 100644 --- a/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb +++ b/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb @@ -429,7 +429,21 @@ class Interpreter result = (@parameters[2] == 0) ? (gold >= @parameters[1]) : (gold <= @parameters[1]) # when 8, 9, 10 # item, weapon, armor when 11 # button - result = Input.press?(@parameters[1]) + button = { + 2 => Input::DOWN, + 4 => Input::LEFT, + 6 => Input::RIGHT, + 8 => Input::UP, + 11 => Input::ACTION, + 12 => Input::BACK, + 13 => Input::USE, + 14 => Input::JUMPUP, + 15 => Input::JUMPDOWN, + 16 => Input::SPECIAL, + 17 => Input::AUX1, + 18 => Input::AUX2 + }[@parameters[1]] + result = button && Input.press?(button) when 12 # script result = execute_script(@parameters[1]) end diff --git a/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb b/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb index 9f38551f8..aadd0e1fb 100644 --- a/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb +++ b/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb @@ -207,7 +207,7 @@ class Battle next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler) != isPlayer if @choices[idxBattler][0] != :None || !pbCanShowCommands?(idxBattler) # Action is forced, can't choose one - PBDebug.log_ai("#{@battlers[idxBattler].pbThis} (#{idxBattler}) is forced to use a multi-turn move") + PBDebug.log("[Command phase] #{@battlers[idxBattler].pbThis} (#{idxBattler}) is forced to use a multi-turn move") next end # AI controls this battler diff --git a/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb b/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb index 7df74a9eb..1ff88b2cc 100644 --- a/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb +++ b/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb @@ -192,13 +192,14 @@ Battle::AI::Handlers::ShouldSwitch.add(:perish_song, Battle::AI::Handlers::ShouldSwitch.add(:significant_eor_damage, proc { |battler, reserves, ai, battle| eor_damage = battler.rough_end_of_round_damage + next false if eor_damage <= 0 # Switch if battler will take significant EOR damage if eor_damage >= battler.hp / 2 || eor_damage >= battler.totalhp / 4 PBDebug.log_ai("#{battler.name} wants to switch because it will take a lot of EOR damage") next true end # Switch to remove certain effects that cause the battler EOR damage - if ai.trainer.high_skill? && eor_damage > 0 + if ai.trainer.high_skill? if battler.effects[PBEffects::LeechSeed] >= 0 && ai.pbAIRandom(100) < 50 PBDebug.log_ai("#{battler.name} wants to switch to get rid of its Leech Seed") next true diff --git a/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb b/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb index 2c5babf09..2f0bbfa83 100644 --- a/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb +++ b/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb @@ -69,12 +69,19 @@ class Battle::AI end # Discard move if it can't raise any stats if real_stat_changes.length == 0 + PBDebug.log(" ignore stat raising (it can't be changed)") return (whole_effect) ? MOVE_USELESS_SCORE : score end # Make score change based on the additional effect chance - score += add_effect + if add_effect != 0 + old_score = score + score += add_effect + PBDebug.log_score_change(score - old_score, "stat raising is an additional effect") + end # Make score changes based on the general concept of raising stats at all + old_score = score score = get_target_stat_raise_score_generic(score, target, real_stat_changes, desire_mult) + PBDebug.log_score_change(score - old_score, "generic calculations for raising any stat") # Make score changes based on the specific changes to each stat that will be # raised real_stat_changes.each do |change| @@ -159,15 +166,15 @@ class Battle::AI total_increment = stat_changes.sum { |change| change[1] } # Prefer if move is a status move and it's the user's first/second turn if @user.turnCount < 2 && @move.statusMove? - score += total_increment * desire_mult * 5 + score += total_increment * desire_mult * 4 end if @trainer.has_skill_flag?("HPAware") # Prefer if user is at high HP, don't prefer if user is at low HP if target.index != @user.index - score += total_increment * desire_mult * ((100 * @user.hp / @user.totalhp) - 50) / 8 # +6 to -6 per stage + score += total_increment * desire_mult * ((100 * @user.hp / @user.totalhp) - 50) / 12 # +4 to -4 per stage end # Prefer if target is at high HP, don't prefer if target is at low HP - score += total_increment * desire_mult * ((100 * target.hp / target.totalhp) - 50) / 8 # +6 to -6 per stage + score += total_increment * desire_mult * ((100 * target.hp / target.totalhp) - 50) / 12 # +4 to -4 per stage end # NOTE: There are no abilities that trigger upon stat raise, but this is # where they would be accounted for if they existed. @@ -366,12 +373,19 @@ class Battle::AI end # Discard move if it can't lower any stats if real_stat_changes.length == 0 + PBDebug.log(" ignore stat lowering (it can't be changed)") return (whole_effect) ? MOVE_USELESS_SCORE : score end # Make score change based on the additional effect chance - score += add_effect + if add_effect != 0 + old_score = score + score += add_effect + PBDebug.log_score_change(score - old_score, "stat lowering is an additional effect") + end # Make score changes based on the general concept of lowering stats at all + old_score = score score = get_target_stat_drop_score_generic(score, target, real_stat_changes, desire_mult) + PBDebug.log_score_change(score - old_score, "generic calculations for lowering any stat") # Make score changes based on the specific changes to each stat that will be # lowered real_stat_changes.each do |change| @@ -447,15 +461,15 @@ class Battle::AI total_decrement = stat_changes.sum { |change| change[1] } # Prefer if move is a status move and it's the user's first/second turn if @user.turnCount < 2 && @move.statusMove? - score += total_decrement * desire_mult * 5 + score += total_decrement * desire_mult * 4 end if @trainer.has_skill_flag?("HPAware") # Prefer if user is at high HP, don't prefer if user is at low HP if target.index != @user.index - score += total_decrement * desire_mult * ((100 * @user.hp / @user.totalhp) - 50) / 8 # +6 to -6 per stage + score += total_decrement * desire_mult * ((100 * @user.hp / @user.totalhp) - 50) / 12 # +4 to -4 per stage end # Prefer if target is at high HP, don't prefer if target is at low HP - score += total_decrement * desire_mult * ((100 * target.hp / target.totalhp) - 50) / 8 # +6 to -6 per stage + score += total_decrement * desire_mult * ((100 * target.hp / target.totalhp) - 50) / 12 # +4 to -4 per stage end # Don't prefer if target has an ability that triggers upon stat loss # (Competitive, Defiant) diff --git a/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb b/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb index 178c21633..f301b814c 100644 --- a/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb +++ b/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb @@ -241,6 +241,9 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:target_can_make_moves_E #=============================================================================== # Don't prefer attacking the target if they'd be semi-invulnerable. +# TODO: Don't treat the move as useless? If the user's moves are all useless +# because of this, it will want to switch instead, which may not be +# desirable. #=============================================================================== Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:target_semi_invulnerable, proc { |score, move, user, target, ai, battle| @@ -308,7 +311,7 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:predicted_damage, PBDebug.log_score_change(score - old_score, "damaging move (predicted damage #{dmg} = #{100 * dmg / target.hp}% of target's HP)") if ai.trainer.has_skill_flag?("HPAware") && dmg > target.hp * 1.1 # Predicted to KO the target old_score = score - score += 10 + score += 20 PBDebug.log_score_change(score - old_score, "predicted to KO the target") if move.move.multiHitMove? && target.hp == target.totalhp && (target.has_active_ability?(:STURDY) || target.has_active_item?(:FOCUSSASH)) @@ -365,7 +368,7 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:thawing_move_against_fr # Don't prefer a damaging move if it will trigger the target's ability or held # item when used, e.g. Effect Spore/Rough Skin, Pickpocket, Rocky Helmet, Red # Card. -# NOTE: These abilities/items may not be triggerable after all (e.g. they +# TODO: These abilities/items may not be triggerable after all (e.g. they # require the move to make contact but it doesn't), or may have a negative # effect for the target (e.g. Air Balloon popping), but it's too much # effort to go into detail deciding all this. @@ -378,14 +381,14 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:trigger_target_ability_ (Battle::AbilityEffects::AfterMoveUseFromTarget[target.ability] && (!user.has_active_ability?(:SHEERFORCE) || move.move.addlEffect == 0)) old_score = score - score += 8 + score -= 8 PBDebug.log_score_change(score - old_score, "can trigger the target's ability") end end if target.battler.isSpecies?(:CRAMORANT) && target.ability == :GULPMISSILE && target.battler.form > 0 && !target.effects[PBEffects::Transform] old_score = score - score += 8 + score -= 8 PBDebug.log_score_change(score - old_score, "can trigger the target's ability") end if target.item_active? @@ -393,7 +396,7 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:trigger_target_ability_ (Battle::ItemEffects::AfterMoveUseFromTarget[target.item] && (!user.has_active_ability?(:SHEERFORCE) || move.move.addlEffect == 0)) old_score = score - score += 8 + score -= 8 PBDebug.log_score_change(score - old_score, "can trigger the target's item") end end diff --git a/Data/Scripts/011_Battle/005_AI/011_AIMove.rb b/Data/Scripts/011_Battle/005_AI/011_AIMove.rb index ef17fa87e..3b10b9d28 100644 --- a/Data/Scripts/011_Battle/005_AI/011_AIMove.rb +++ b/Data/Scripts/011_Battle/005_AI/011_AIMove.rb @@ -543,21 +543,34 @@ class Battle::AI::AIMove #----------------------------------------------------------------------------- # Return values: - # 0: Regular additional effect chance or isn't an additional effect + # 0: Isn't an additional effect or always triggers # -999: Additional effect will be negated # Other: Amount to add to a move's score + # TODO: This value just gets added to the score, but it should only modify the + # score for the additional effect and shouldn't reduce that to less than + # 0. def get_score_change_for_additional_effect(user, target = nil) + chance = @move.addlEffect # Doesn't have an additional effect - return 0 if @move.addlEffect == 0 + return 0 if chance == 0 # Additional effect will be negated return -999 if user.has_active_ability?(:SHEERFORCE) return -999 if target && user.index != target.index && target.has_active_ability?(:SHIELDDUST) && !@ai.battle.moldBreaker - # Prefer if the additional effect will have an increased chance of working - return 5 if @move.addlEffect < 100 && - (Settings::MECHANICS_GENERATION >= 6 || function_code != "EffectDependsOnEnvironment") && - (user.has_active_ability?(:SERENEGRACE) || user.pbOwnSide.effects[PBEffects::Rainbow] > 0) - # No change to score - return 0 + # Additional effect will always trigger + return 0 if chance > 100 + # Calculate the chance + chance *= 2 if (Settings::MECHANICS_GENERATION >= 6 || function_code != "EffectDependsOnEnvironment") && + (user.has_active_ability?(:SERENEGRACE) || user.pbOwnSide.effects[PBEffects::Rainbow] > 0) + # Don't prefer if the additional effect has a low chance of happening + ret = 0 + if chance <= 10 + ret -= 10 + elsif chance <= 50 + ret -= 5 + elsif chance >= 80 + ret += 5 + end + return ret end end diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/003_AI_MoveEffects_BattlerOther.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/003_AI_MoveEffects_BattlerOther.rb index ac6fff5f8..d00d0943b 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/003_AI_MoveEffects_BattlerOther.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/003_AI_MoveEffects_BattlerOther.rb @@ -20,32 +20,32 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("SleepTarget", next useless_score if add_effect == -999 # Additional effect will be negated score += add_effect # Inherent preference - score += 15 + score += 8 # Prefer if the user or an ally has a move/ability that is better if the target is asleep ai.each_same_side_battler(user.side) do |b, i| - score += 5 if b.has_move_with_function?("DoublePowerIfTargetAsleepCureTarget", + score += 4 if b.has_move_with_function?("DoublePowerIfTargetAsleepCureTarget", "DoublePowerIfTargetStatusProblem", "HealUserByHalfOfDamageDoneIfTargetAsleep", "StartDamageTargetEachTurnIfTargetAsleep") - score += 10 if b.has_active_ability?(:BADDREAMS) + score += 8 if b.has_active_ability?(:BADDREAMS) end # Don't prefer if target benefits from having the sleep status problem # NOTE: The target's Guts/Quick Feet will benefit from the target being # asleep, but the target won't (usually) be able to make use of # them, so they're not worth considering. - score -= 10 if target.has_active_ability?(:EARLYBIRD) - score -= 8 if target.has_active_ability?(:MARVELSCALE) + score -= 5 if target.has_active_ability?(:EARLYBIRD) + score -= 4 if target.has_active_ability?(:MARVELSCALE) # Don't prefer if target has a move it can use while asleep - score -= 8 if target.check_for_move { |m| m.usableWhenAsleep? } + score -= 4 if target.check_for_move { |m| m.usableWhenAsleep? } # Don't prefer if the target can heal itself (or be healed by an ally) if target.has_active_ability?(:SHEDSKIN) - score -= 8 + score -= 5 elsif target.has_active_ability?(:HYDRATION) && [:Rain, :HeavyRain].include?(target.battler.effectiveWeather) - score -= 15 + score -= 8 end ai.each_same_side_battler(target.side) do |b, i| - score -= 8 if i != target.index && b.has_active_ability?(:HEALER) + score -= 5 if i != target.index && b.has_active_ability?(:HEALER) end end next score @@ -109,38 +109,38 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("PoisonTarget", next useless_score if add_effect == -999 # Additional effect will be negated score += add_effect # Inherent preference - score += 15 - # Prefer if the target is at high HP if ai.trainer.has_skill_flag?("HPAware") - score += 15 * target.hp / target.totalhp + score += 8 * target.hp / target.totalhp + else + score += 8 end # Prefer if the user or an ally has a move/ability that is better if the target is poisoned ai.each_same_side_battler(user.side) do |b, i| - score += 5 if b.has_move_with_function?("DoublePowerIfTargetPoisoned", + score += 4 if b.has_move_with_function?("DoublePowerIfTargetPoisoned", "DoublePowerIfTargetStatusProblem") - score += 10 if b.has_active_ability?(:MERCILESS) + score += 5 if b.has_active_ability?(:MERCILESS) end # Don't prefer if target benefits from having the poison status problem - score -= 8 if target.has_active_ability?([:GUTS, :MARVELSCALE, :QUICKFEET, :TOXICBOOST]) - score -= 25 if target.has_active_ability?(:POISONHEAL) - score -= 20 if target.has_active_ability?(:SYNCHRONIZE) && + score -= 5 if target.has_active_ability?([:GUTS, :MARVELSCALE, :QUICKFEET, :TOXICBOOST]) + score -= 15 if target.has_active_ability?(:POISONHEAL) + score -= 15 if target.has_active_ability?(:SYNCHRONIZE) && user.battler.pbCanPoisonSynchronize?(target.battler) - score -= 5 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed", + score -= 4 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed", "CureUserBurnPoisonParalysis") - score -= 15 if target.check_for_move { |m| + score -= 8 if target.check_for_move { |m| m.function_code == "GiveUserStatusToTarget" && user.battler.pbCanPoison?(target.battler, false, m) } # Don't prefer if the target won't take damage from the poison - score -= 20 if !target.battler.takesIndirectDamage? + score -= 10 if !target.battler.takesIndirectDamage? # Don't prefer if the target can heal itself (or be healed by an ally) if target.has_active_ability?(:SHEDSKIN) - score -= 8 + score -= 5 elsif target.has_active_ability?(:HYDRATION) && [:Rain, :HeavyRain].include?(target.battler.effectiveWeather) - score -= 15 + score -= 8 end ai.each_same_side_battler(target.side) do |b, i| - score -= 8 if i != target.index && b.has_active_ability?(:HEALER) + score -= 5 if i != target.index && b.has_active_ability?(:HEALER) end end next score @@ -195,40 +195,40 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("ParalyzeTarget", next useless_score if add_effect == -999 # Additional effect will be negated score += add_effect # Inherent preference (because of the chance of full paralysis) - score += 10 + score += 8 # Prefer if the target is faster than the user but will become slower if # paralysed if target.faster_than?(user) user_speed = user.rough_stat(:SPEED) target_speed = target.rough_stat(:SPEED) - score += 15 if target_speed < user_speed * ((Settings::MECHANICS_GENERATION >= 7) ? 2 : 4) + score += 8 if target_speed < user_speed * ((Settings::MECHANICS_GENERATION >= 7) ? 2 : 4) end # Prefer if the target is confused or infatuated, to compound the turn skipping - score += 7 if target.effects[PBEffects::Confusion] > 1 - score += 7 if target.effects[PBEffects::Attract] >= 0 + score += 4 if target.effects[PBEffects::Confusion] > 1 + score += 4 if target.effects[PBEffects::Attract] >= 0 # Prefer if the user or an ally has a move/ability that is better if the target is paralysed ai.each_same_side_battler(user.side) do |b, i| - score += 5 if b.has_move_with_function?("DoublePowerIfTargetParalyzedCureTarget", + score += 4 if b.has_move_with_function?("DoublePowerIfTargetParalyzedCureTarget", "DoublePowerIfTargetStatusProblem") end # Don't prefer if target benefits from having the paralysis status problem - score -= 8 if target.has_active_ability?([:GUTS, :MARVELSCALE, :QUICKFEET]) - score -= 20 if target.has_active_ability?(:SYNCHRONIZE) && + score -= 5 if target.has_active_ability?([:GUTS, :MARVELSCALE, :QUICKFEET]) + score -= 15 if target.has_active_ability?(:SYNCHRONIZE) && user.battler.pbCanParalyzeSynchronize?(target.battler) - score -= 5 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed", + score -= 4 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed", "CureUserBurnPoisonParalysis") - score -= 15 if target.check_for_move { |m| + score -= 8 if target.check_for_move { |m| m.function_code == "GiveUserStatusToTarget" && user.battler.pbCanParalyze?(target.battler, false, m) } # Don't prefer if the target can heal itself (or be healed by an ally) if target.has_active_ability?(:SHEDSKIN) - score -= 8 + score -= 5 elsif target.has_active_ability?(:HYDRATION) && [:Rain, :HeavyRain].include?(target.battler.effectiveWeather) - score -= 15 + score -= 8 end ai.each_same_side_battler(target.side) do |b, i| - score -= 8 if i != target.index && b.has_active_ability?(:HEALER) + score -= 5 if i != target.index && b.has_active_ability?(:HEALER) end end next score @@ -295,37 +295,37 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("BurnTarget", next useless_score if add_effect == -999 # Additional effect will be negated score += add_effect # Inherent preference - score += 15 + score += 8 # Prefer if the target knows any physical moves that will be weaked by a burn if !target.has_active_ability?(:GUTS) && target.check_for_move { |m| m.physicalMove? } - score += 8 - score += 8 if !target.check_for_move { |m| m.specialMove? } + score += 4 + score += 4 if !target.check_for_move { |m| m.specialMove? } end # Prefer if the user or an ally has a move/ability that is better if the target is burned ai.each_same_side_battler(user.side) do |b, i| - score += 5 if b.has_move_with_function?("DoublePowerIfTargetStatusProblem") + score += 4 if b.has_move_with_function?("DoublePowerIfTargetStatusProblem") end # Don't prefer if target benefits from having the burn status problem - score -= 8 if target.has_active_ability?([:FLAREBOOST, :GUTS, :MARVELSCALE, :QUICKFEET]) - score -= 5 if target.has_active_ability?(:HEATPROOF) - score -= 20 if target.has_active_ability?(:SYNCHRONIZE) && + score -= 4 if target.has_active_ability?([:FLAREBOOST, :GUTS, :MARVELSCALE, :QUICKFEET]) + score -= 4 if target.has_active_ability?(:HEATPROOF) + score -= 15 if target.has_active_ability?(:SYNCHRONIZE) && user.battler.pbCanBurnSynchronize?(target.battler) - score -= 5 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed", + score -= 4 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed", "CureUserBurnPoisonParalysis") - score -= 15 if target.check_for_move { |m| + score -= 8 if target.check_for_move { |m| m.function_code == "GiveUserStatusToTarget" && user.battler.pbCanBurn?(target.battler, false, m) } # Don't prefer if the target won't take damage from the burn - score -= 20 if !target.battler.takesIndirectDamage? + score -= 10 if !target.battler.takesIndirectDamage? # Don't prefer if the target can heal itself (or be healed by an ally) if target.has_active_ability?(:SHEDSKIN) - score -= 8 + score -= 5 elsif target.has_active_ability?(:HYDRATION) && [:Rain, :HeavyRain].include?(target.battler.effectiveWeather) - score -= 15 + score -= 8 end ai.each_same_side_battler(target.side) do |b, i| - score -= 8 if i != target.index && b.has_active_ability?(:HEALER) + score -= 5 if i != target.index && b.has_active_ability?(:HEALER) end end next score @@ -377,27 +377,27 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("FreezeTarget", next useless_score if add_effect == -999 # Additional effect will be negated score += add_effect # Inherent preference - score += 15 + score += 8 # Prefer if the user or an ally has a move/ability that is better if the target is frozen ai.each_same_side_battler(user.side) do |b, i| - score += 5 if b.has_move_with_function?("DoublePowerIfTargetStatusProblem") + score += 4 if b.has_move_with_function?("DoublePowerIfTargetStatusProblem") end # Don't prefer if target benefits from having the frozen status problem # NOTE: The target's Guts/Quick Feet will benefit from the target being # frozen, but the target won't be able to make use of them, so # they're not worth considering. - score -= 8 if target.has_active_ability?(:MARVELSCALE) + score -= 5 if target.has_active_ability?(:MARVELSCALE) # Don't prefer if the target knows a move that can thaw it - score -= 15 if target.check_for_move { |m| m.thawsUser? } + score -= 8 if target.check_for_move { |m| m.thawsUser? } # Don't prefer if the target can heal itself (or be healed by an ally) if target.has_active_ability?(:SHEDSKIN) - score -= 8 + score -= 5 elsif target.has_active_ability?(:HYDRATION) && [:Rain, :HeavyRain].include?(target.battler.effectiveWeather) - score -= 15 + score -= 8 end ai.each_same_side_battler(target.side) do |b, i| - score -= 8 if i != target.index && b.has_active_ability?(:HEALER) + score -= 5 if i != target.index && b.has_active_ability?(:HEALER) end end next score @@ -532,11 +532,11 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("CureTargetBurn", add_effect = move.get_score_change_for_additional_effect(user, target) next score if add_effect == -999 # Additional effect will be negated if target.status == :BURN - score -= add_effect + score += add_effect if target.wants_status_problem?(:BURN) - score += 15 + score += 10 else - score -= 10 + score -= 8 end end next score @@ -581,10 +581,10 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("FlinchTarget", next score if add_effect == -999 # Additional effect will be negated score += add_effect # Inherent preference - score += 15 + score += 8 # Prefer if the target is paralysed, confused or infatuated, to compound the # turn skipping - score += 8 if target.status == :PARALYSIS || + score += 5 if target.status == :PARALYSIS || target.effects[PBEffects::Confusion] > 1 || target.effects[PBEffects::Attract] >= 0 next score @@ -636,15 +636,15 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("ConfuseTarget", next score if add_effect == -999 # Additional effect will be negated score += add_effect # Inherent preference - score += 10 - # Prefer if the target is at high HP if ai.trainer.has_skill_flag?("HPAware") - score += 20 * target.hp / target.totalhp + score += 8 * target.hp / target.totalhp + else + score += 8 end # Prefer if the target is paralysed or infatuated, to compound the turn skipping - score += 8 if target.status == :PARALYSIS || target.effects[PBEffects::Attract] >= 0 + score += 5 if target.status == :PARALYSIS || target.effects[PBEffects::Attract] >= 0 # Don't prefer if target benefits from being confused - score -= 15 if target.has_active_ability?(:TANGLEDFEET) + score -= 8 if target.has_active_ability?(:TANGLEDFEET) end next score } @@ -671,14 +671,14 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("AttractTarget", next score if add_effect == -999 # Additional effect will be negated score += add_effect # Inherent preference - score += 15 + score += 8 # Prefer if the target is paralysed or confused, to compound the turn skipping - score += 8 if target.status == :PARALYSIS || target.effects[PBEffects::Confusion] > 1 + score += 5 if target.status == :PARALYSIS || target.effects[PBEffects::Confusion] > 1 # Don't prefer if the target can infatuate the user because of this move - score -= 15 if target.has_active_item?(:DESTINYKNOT) && + score -= 10 if target.has_active_item?(:DESTINYKNOT) && user.battler.pbCanAttract?(target.battler, false) # Don't prefer if the user has another way to infatuate the target - score -= 15 if move.statusMove? && user.has_active_ability?(:CUTECHARM) + score -= 8 if move.statusMove? && user.has_active_ability?(:CUTECHARM) end next score } diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb index 91e0363a5..c41f37f63 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb @@ -647,6 +647,8 @@ Battle::AI::Handlers::MoveEffectScore.add("StartWeakenPhysicalDamageAgainstUserS proc { |score, move, user, ai, battle| # Doesn't stack with Aurora Veil next Battle::AI::MOVE_USELESS_SCORE if user.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 + # Prefer if the user is newly in battle + score += 15 if user.turnCount < 2 # Don't prefer the lower the user's HP is if ai.trainer.has_skill_flag?("HPAware") && battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 if user.hp <= user.totalhp / 2 @@ -677,6 +679,8 @@ Battle::AI::Handlers::MoveEffectScore.add("StartWeakenSpecialDamageAgainstUserSi proc { |score, move, user, ai, battle| # Doesn't stack with Aurora Veil next Battle::AI::MOVE_USELESS_SCORE if user.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 + # Prefer if the user is newly in battle + score += 15 if user.turnCount < 2 # Don't prefer the lower the user's HP is if ai.trainer.has_skill_flag?("HPAware") && battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 if user.hp <= user.totalhp / 2 @@ -710,6 +714,8 @@ Battle::AI::Handlers::MoveEffectScore.add("StartWeakenDamageAgainstUserSideIfHai # Doesn't stack with Reflect/Light Screen next Battle::AI::MOVE_USELESS_SCORE if user.pbOwnSide.effects[PBEffects::Reflect] > 0 && user.pbOwnSide.effects[PBEffects::LightScreen] > 0 + # Prefer if the user is newly in battle + score += 15 if user.turnCount < 2 # Don't prefer the lower the user's HP is if ai.trainer.has_skill_flag?("HPAware") && battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 if user.hp <= user.totalhp / 2 diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb index 400b10ef7..385dae654 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb @@ -148,11 +148,11 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("HealUserByTargetAttackLo heal_amt = target.rough_stat(:ATTACK) heal_amt *= 1.3 if user.has_active_item?(:BIGROOT) heal_amt = [heal_amt, user.totalhp - user.hp].min - if heal_amt > user.totalhp * 0.3 # Only modify the score if it'll heal a decent amount + if heal_amt > user.totalhp * 0.2 # Only modify the score if it'll heal a decent amount if user.hp < user.totalhp * 0.5 score += 20 * (user.totalhp - user.hp) / user.totalhp # +10 to +20 end - score += 20 * heal_amt / user.totalhp # +6 to +20 + score += 20 * heal_amt / user.totalhp # +4 to +20 end end end @@ -175,11 +175,11 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("HealUserByHalfOfDamageDo heal_amt = rough_dmg / 2 heal_amt *= 1.3 if user.has_active_item?(:BIGROOT) heal_amt = [heal_amt, user.totalhp - user.hp].min - if heal_amt > user.totalhp * 0.3 # Only modify the score if it'll heal a decent amount + if heal_amt > user.totalhp * 0.2 # Only modify the score if it'll heal a decent amount if user.hp < user.totalhp * 0.5 score += 20 * (user.totalhp - user.hp) / user.totalhp # +10 to +20 end - score += 20 * heal_amt / user.totalhp # +6 to +20 + score += 20 * heal_amt / user.totalhp # +4 to +20 end end end @@ -213,11 +213,11 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("HealUserByThreeQuartersO heal_amt = rough_dmg * 0.75 heal_amt *= 1.3 if user.has_active_item?(:BIGROOT) heal_amt = [heal_amt, user.totalhp - user.hp].min - if heal_amt > user.totalhp * 0.3 # Only modify the score if it'll heal a decent amount + if heal_amt > user.totalhp * 0.2 # Only modify the score if it'll heal a decent amount if user.hp < user.totalhp * 0.5 score += 20 * (user.totalhp - user.hp) / user.totalhp # +10 to +20 end - score += 20 * heal_amt / user.totalhp # +6 to +20 + score += 20 * heal_amt / user.totalhp # +4 to +20 end end end diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb index 5d7403633..287c0d20d 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb @@ -241,30 +241,30 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("BindTarget", next score if target.effects[PBEffects::Substitute] > 0 # Prefer if the user has a Binding Band or Grip Claw (because why have it if # you don't want to use it?) - score += 5 if user.has_active_item?([:BINDINGBAND, :GRIPCLAW]) + score += 4 if user.has_active_item?([:BINDINGBAND, :GRIPCLAW]) # Target will take damage at the end of each round from the binding - score += 10 if target.battler.takesIndirectDamage? + score += 8 if target.battler.takesIndirectDamage? # Check whether the target will be trapped in battle by the binding if target.can_become_trapped? - score += 8 # Prefer if the target will become trapped by this move + score += 4 # Prefer if the target will become trapped by this move eor_damage = target.rough_end_of_round_damage if eor_damage > 0 # Prefer if the target will take damage at the end of each round on top # of binding damage - score += 10 + score += 5 elsif eor_damage < 0 # Don't prefer if the target will heal itself at the end of each round - score -= 10 + score -= 5 end # Prefer if the target has been Perish Songed - score += 15 if target.effects[PBEffects::PerishSong] > 0 + score += 10 if target.effects[PBEffects::PerishSong] > 0 end # Don't prefer if the target can remove the binding (and the binding has an # effect) if target.can_become_trapped? || target.battler.takesIndirectDamage? if ai.trainer.medium_skill? && target.has_move_with_function?("RemoveUserBindingAndEntryHazards") - score -= 10 + score -= 8 end end next score diff --git a/PBS/Gen 8 backup/moves.txt b/PBS/Gen 8 backup/moves.txt index fa5dbaf27..84cef3428 100644 --- a/PBS/Gen 8 backup/moves.txt +++ b/PBS/Gen 8 backup/moves.txt @@ -8408,7 +8408,7 @@ Accuracy = 100 TotalPP = 10 Target = NearOther FunctionCode = DoublePowerIfTargetNotActed -Flags = Contact,CanProtect,CanMirrorMove +Flags = Contact,CanProtect,CanMirrorMove,Biting Description = The user rends the target with its hard gills. Power doubles if the user moves first. #------------------------------- [LIQUIDATION] diff --git a/PBS/moves.txt b/PBS/moves.txt index fa5dbaf27..84cef3428 100644 --- a/PBS/moves.txt +++ b/PBS/moves.txt @@ -8408,7 +8408,7 @@ Accuracy = 100 TotalPP = 10 Target = NearOther FunctionCode = DoublePowerIfTargetNotActed -Flags = Contact,CanProtect,CanMirrorMove +Flags = Contact,CanProtect,CanMirrorMove,Biting Description = The user rends the target with its hard gills. Power doubles if the user moves first. #------------------------------- [LIQUIDATION]