AI now keeps their last defined Pokémon for last, tweaks to some battle effects based on mechanics generation

This commit is contained in:
Maruno17
2021-10-24 23:06:47 +01:00
parent 18049c22b9
commit 680c1de392
8 changed files with 49 additions and 13 deletions

View File

@@ -91,7 +91,9 @@ class PokeBattle_AI
end
if shouldSwitch
list = []
idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)
@battle.pbParty(idxBattler).each_with_index do |pkmn,i|
next if i == idxPartyEnd - 1 # Don't choose to switch in ace
next if !@battle.pbCanSwitch?(idxBattler,i)
# If perish count is 1, it may be worth it to switch
# even with Spikes, since Perish Song's effect will end
@@ -147,7 +149,9 @@ class PokeBattle_AI
#=============================================================================
def pbDefaultChooseNewEnemy(idxBattler,party)
enemies = []
idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)
party.each_with_index do |_p,i|
next if i == idxPartyEnd - 1 && enemies.length > 0 # Ignore ace if possible
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i)
end
return -1 if enemies.length==0

View File

@@ -2021,8 +2021,9 @@ class PokeBattle_AI
score -= 100 if @battle.trainerBattle?
#---------------------------------------------------------------------------
when "SwitchOutUserStatusMove"
if !@battle.pbCanChooseNonActive?(user.index)
score -= 80
if !@battle.pbCanChooseNonActive?(user.index) ||
@battle.pbTeamAbleNonActiveCount(user.index) > 1 # Don't switch in ace
score -= 100
else
score += 40 if user.effects[PBEffects::Confusion]>0
total = 0
@@ -2042,6 +2043,12 @@ class PokeBattle_AI
end
end
#---------------------------------------------------------------------------
when "SwitchOutUserDamagingMove"
if !@battle.pbCanChooseNonActive?(user.index) ||
@battle.pbTeamAbleNonActiveCount(user.index) > 1 # Don't switch in ace
score -= 100
end
#---------------------------------------------------------------------------
when "SwitchOutTargetStatusMove"
if target.effects[PBEffects::Ingrain] ||
(skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:SUCTIONCUPS))
@@ -2069,7 +2076,7 @@ class PokeBattle_AI
#---------------------------------------------------------------------------
when "SwitchOutUserPassOnEffects"
if !@battle.pbCanChooseNonActive?(user.index)
score -= 80
score -= 100
else
score -= 40 if user.effects[PBEffects::Confusion]>0
total = 0
@@ -2089,8 +2096,6 @@ class PokeBattle_AI
end
end
#---------------------------------------------------------------------------
when "SwitchOutUserDamagingMove"
#---------------------------------------------------------------------------
when "TrapTargetInBattle"
score -= 90 if target.effects[PBEffects::MeanLook]>=0
#---------------------------------------------------------------------------