mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-10 14:44:58 +00:00
Obsoleted battle methods that yield battlers in favour of ones that return all of them at once
This commit is contained in:
@@ -58,7 +58,7 @@ class PokeBattle_AI
|
||||
if idxEncoredMove>=0
|
||||
scoreSum = 0
|
||||
scoreCount = 0
|
||||
battler.eachOpposing do |b|
|
||||
battler.allOpposing.each do |b|
|
||||
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove],battler,b,skill)
|
||||
scoreCount += 1
|
||||
end
|
||||
@@ -167,7 +167,7 @@ class PokeBattle_AI
|
||||
sum = 0
|
||||
pkmn.moves.each do |m|
|
||||
next if m.base_damage == 0
|
||||
@battle.battlers[idxBattler].eachOpposing do |b|
|
||||
@battle.battlers[idxBattler].allOpposing.each do |b|
|
||||
bTypes = b.pbTypes(true)
|
||||
sum += Effectiveness.calculate(m.type, bTypes[0], bTypes[1], bTypes[2])
|
||||
end
|
||||
|
||||
@@ -122,7 +122,7 @@ class PokeBattle_AI
|
||||
if target_data.num_targets > 1
|
||||
# If move affects multiple battlers and you don't choose a particular one
|
||||
totalScore = 0
|
||||
@battle.eachBattler do |b|
|
||||
@battle.allBattlers.each do |b|
|
||||
next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data)
|
||||
score = pbGetMoveScore(move,user,b,skill)
|
||||
totalScore += ((user.opposes?(b)) ? score : -score)
|
||||
@@ -135,7 +135,7 @@ class PokeBattle_AI
|
||||
else
|
||||
# If move affects one battler and you have to choose which one
|
||||
scoresAndTargets = []
|
||||
@battle.eachBattler do |b|
|
||||
@battle.allBattlers.each do |b|
|
||||
next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data)
|
||||
next if target_data.targets_foe && !user.opposes?(b)
|
||||
score = pbGetMoveScore(move,user,b,skill)
|
||||
|
||||
@@ -1157,7 +1157,7 @@ class PokeBattle_AI
|
||||
when "ResetAllBattlersStatStages"
|
||||
if skill>=PBTrainerAI.mediumSkill
|
||||
stages = 0
|
||||
@battle.eachBattler do |b|
|
||||
@battle.allBattlers.each do |b|
|
||||
totalStages = 0
|
||||
GameData::Stat.each_battle { |s| totalStages += b.stages[s.id] }
|
||||
if b.opposes?(user)
|
||||
@@ -1583,7 +1583,7 @@ class PokeBattle_AI
|
||||
score -= 90 if target.effects[PBEffects::HyperBeam]>0
|
||||
#---------------------------------------------------------------------------
|
||||
when "DamageTargetAlly"
|
||||
target.eachAlly do |b|
|
||||
target.allAllies.each do |b|
|
||||
next if !b.near?(target)
|
||||
score += 10
|
||||
end
|
||||
@@ -1629,7 +1629,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "UsedAfterAllyRoundWithDoublePower"
|
||||
if skill>=PBTrainerAI.mediumSkill
|
||||
user.eachAlly do |b|
|
||||
user.allAllies.each do |b|
|
||||
next if !b.pbHasMove?(move.id)
|
||||
score += 20
|
||||
end
|
||||
@@ -1690,7 +1690,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "PowerUpAllyMove"
|
||||
hasAlly = false
|
||||
user.eachAlly do |b|
|
||||
user.allAllies.each do |b|
|
||||
hasAlly = true
|
||||
score += 30
|
||||
break
|
||||
@@ -2252,15 +2252,9 @@ class PokeBattle_AI
|
||||
if user.pbOpposingSide.effects[PBEffects::Spikes]>=3
|
||||
score -= 90
|
||||
else
|
||||
canChoose = false
|
||||
user.eachOpposing do |b|
|
||||
next if !@battle.pbCanChooseNonActive?(b.index)
|
||||
canChoose = true
|
||||
break
|
||||
end
|
||||
if !canChoose
|
||||
if user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) }
|
||||
# Opponent can't switch in any Pokemon
|
||||
score -= 90
|
||||
score -= 90
|
||||
else
|
||||
score += 10*@battle.pbAbleNonActiveCount(user.idxOpposingSide)
|
||||
score += [40,26,13][user.pbOpposingSide.effects[PBEffects::Spikes]]
|
||||
@@ -2271,13 +2265,7 @@ class PokeBattle_AI
|
||||
if user.pbOpposingSide.effects[PBEffects::ToxicSpikes]>=2
|
||||
score -= 90
|
||||
else
|
||||
canChoose = false
|
||||
user.eachOpposing do |b|
|
||||
next if !@battle.pbCanChooseNonActive?(b.index)
|
||||
canChoose = true
|
||||
break
|
||||
end
|
||||
if !canChoose
|
||||
if user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) }
|
||||
# Opponent can't switch in any Pokemon
|
||||
score -= 90
|
||||
else
|
||||
@@ -2290,13 +2278,7 @@ class PokeBattle_AI
|
||||
if user.pbOpposingSide.effects[PBEffects::StealthRock]
|
||||
score -= 90
|
||||
else
|
||||
canChoose = false
|
||||
user.eachOpposing do |b|
|
||||
next if !@battle.pbCanChooseNonActive?(b.index)
|
||||
canChoose = true
|
||||
break
|
||||
end
|
||||
if !canChoose
|
||||
if user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) }
|
||||
# Opponent can't switch in any Pokemon
|
||||
score -= 90
|
||||
else
|
||||
@@ -2412,12 +2394,7 @@ class PokeBattle_AI
|
||||
when "FailsIfTargetActed"
|
||||
#---------------------------------------------------------------------------
|
||||
when "RedirectAllMovesToUser"
|
||||
hasAlly = false
|
||||
user.eachAlly do |b|
|
||||
hasAlly = true
|
||||
break
|
||||
end
|
||||
score -= 90 if !hasAlly
|
||||
score -= 90 if user.allAllies.length == 0
|
||||
#---------------------------------------------------------------------------
|
||||
when "StartGravity"
|
||||
if @battle.field.effects[PBEffects::Gravity]>0
|
||||
@@ -2538,7 +2515,7 @@ class PokeBattle_AI
|
||||
when "RaisePlusMinusUserAndAlliesDefSpDef1"
|
||||
hasEffect = user.statStageAtMax?(:DEFENSE) &&
|
||||
user.statStageAtMax?(:SPECIAL_DEFENSE)
|
||||
user.eachAlly do |b|
|
||||
user.allAllies.each do |b|
|
||||
next if b.statStageAtMax?(:DEFENSE) && b.statStageAtMax?(:SPECIAL_DEFENSE)
|
||||
hasEffect = true
|
||||
score -= b.stages[:DEFENSE]*10
|
||||
@@ -2600,7 +2577,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "RaiseGroundedGrassBattlersAtkSpAtk1"
|
||||
count = 0
|
||||
@battle.eachBattler do |b|
|
||||
@battle.allBattlers.each do |b|
|
||||
if b.pbHasType?(:GRASS) && !b.airborne? &&
|
||||
(!b.statStageAtMax?(:ATTACK) || !b.statStageAtMax?(:SPECIAL_ATTACK))
|
||||
count += 1
|
||||
@@ -2616,7 +2593,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "RaiseGrassBattlersDef1"
|
||||
count = 0
|
||||
@battle.eachBattler do |b|
|
||||
@battle.allBattlers.each do |b|
|
||||
if b.pbHasType?(:GRASS) && !b.statStageAtMax?(:DEFENSE)
|
||||
count += 1
|
||||
if user.opposes?(b)
|
||||
@@ -2630,7 +2607,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerPoisonedTargetAtkSpAtkSpd1"
|
||||
count=0
|
||||
@battle.eachBattler do |b|
|
||||
@battle.allBattlers.each do |b|
|
||||
if b.poisoned? &&
|
||||
(!b.statStageAtMin?(:ATTACK) ||
|
||||
!b.statStageAtMin?(:SPECIAL_ATTACK) ||
|
||||
@@ -2822,7 +2799,7 @@ class PokeBattle_AI
|
||||
when "RaisePlusMinusUserAndAlliesAtkSpAtk1"
|
||||
hasEffect = user.statStageAtMax?(:ATTACK) &&
|
||||
user.statStageAtMax?(:SPECIAL_ATTACK)
|
||||
user.eachAlly do |b|
|
||||
user.allAllies.each do |b|
|
||||
next if b.statStageAtMax?(:ATTACK) && b.statStageAtMax?(:SPECIAL_ATTACK)
|
||||
hasEffect = true
|
||||
score -= b.stages[:ATTACK]*10
|
||||
@@ -2931,12 +2908,7 @@ class PokeBattle_AI
|
||||
when "TypeIsUserFirstType"
|
||||
#---------------------------------------------------------------------------
|
||||
when "RedirectAllMovesToTarget"
|
||||
hasAlly = false
|
||||
target.eachAlly do |b|
|
||||
hasAlly = true
|
||||
break
|
||||
end
|
||||
score -= 90 if !hasAlly
|
||||
score -= 90 if user.allAllies.length == 0
|
||||
#---------------------------------------------------------------------------
|
||||
when "TargetUsesItsLastUsedMoveAgain"
|
||||
if skill>=PBTrainerAI.mediumSkill
|
||||
@@ -3098,7 +3070,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "RaiseUserAndAlliesAtkDef1"
|
||||
has_ally = false
|
||||
user.eachAlly do |b|
|
||||
user.allAllies.each do |b|
|
||||
next if !b.pbCanLowerStatStage?(:ATTACK, user) &&
|
||||
!b.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
has_ally = true
|
||||
@@ -3185,7 +3157,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "CannotBeRedirected"
|
||||
redirection = false
|
||||
user.eachOpposing do |b|
|
||||
user.allOpposing.each do |b|
|
||||
next if b.index == target.index
|
||||
if b.effects[PBEffects::RagePowder] ||
|
||||
b.effects[PBEffects::Spotlight] > 0 ||
|
||||
@@ -3228,7 +3200,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "HealUserAndAlliesQuarterOfTotalHP"
|
||||
ally_amt = 30
|
||||
@battle.eachSameSideBattler(user.index) do |b|
|
||||
@battle.allSameSideBattlers(user.index).each do |b|
|
||||
if b.hp == b.totalhp || (skill >= PBTrainerAI.mediumSkill && !b.canHeal?)
|
||||
score -= ally_amt / 2
|
||||
elsif b.hp < b.totalhp * 3 / 4
|
||||
@@ -3238,7 +3210,7 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "HealUserAndAlliesQuarterOfTotalHPCureStatus"
|
||||
ally_amt = 80 / @battle.pbSideSize(user.index)
|
||||
@battle.eachSameSideBattler(user.index) do |b|
|
||||
@battle.allSameSideBattlers(user.index).each do |b|
|
||||
if b.hp == b.totalhp || (skill >= PBTrainerAI.mediumSkill && !b.canHeal?)
|
||||
score -= ally_amt
|
||||
elsif b.hp < b.totalhp * 3 / 4
|
||||
@@ -3307,7 +3279,7 @@ class PokeBattle_AI
|
||||
:MARANGABERRY, :PECHABERRY, :PERSIMBERRY, :PETAYABERRY,
|
||||
:RAWSTBERRY, :SALACBERRY, :STARFBERRY, :WIKIBERRY
|
||||
]
|
||||
@battle.eachSameSideBattler(user.index) do |b|
|
||||
@battle.allSameSideBattlers(user.index).each do |b|
|
||||
if !b.item || !b.item.is_berry? || !b.itemActive?
|
||||
score -= 100 / @battle.pbSideSize(user.index)
|
||||
else
|
||||
@@ -3325,7 +3297,7 @@ class PokeBattle_AI
|
||||
end
|
||||
end
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
@battle.eachOtherSideBattler(user.index) do |b|
|
||||
@battle.allOtherSideBattlers(user.index).each do |b|
|
||||
amt = 10 / @battle.pbSideSize(target.index)
|
||||
score -= amt if b.hasActiveItem?(useful_berries)
|
||||
score -= amt if b.canHeal? && b.hp < b.totalhp / 3 && b.hasActiveAbility?(:CHEEKPOUCH)
|
||||
|
||||
@@ -8,17 +8,17 @@ class PokeBattle_AI
|
||||
num_targets = 0
|
||||
case target_data.id
|
||||
when :AllAllies
|
||||
@battle.eachSameSideBattler(user) { |b| num_targets += 1 if b.index != user.index }
|
||||
@battle.allSameSideBattlers(user).each { |b| num_targets += 1 if b.index != user.index }
|
||||
when :UserAndAllies
|
||||
@battle.eachSameSideBattler(user) { |_b| num_targets += 1 }
|
||||
@battle.allSameSideBattlers(user).each { |_b| num_targets += 1 }
|
||||
when :AllNearFoes
|
||||
@battle.eachOtherSideBattler(user) { |b| num_targets += 1 if b.near?(user) }
|
||||
@battle.allOtherSideBattlers(user).each { |b| num_targets += 1 if b.near?(user) }
|
||||
when :AllFoes
|
||||
@battle.eachOtherSideBattler(user) { |_b| num_targets += 1 }
|
||||
@battle.allOtherSideBattlers(user).each { |_b| num_targets += 1 }
|
||||
when :AllNearOthers
|
||||
@battle.eachBattler { |b| num_targets += 1 if b.near?(user) }
|
||||
@battle.allBattlers.each { |b| num_targets += 1 if b.near?(user) }
|
||||
when :AllBattlers
|
||||
@battle.eachBattler { |_b| num_targets += 1 }
|
||||
@battle.allBattlers.each { |_b| num_targets += 1 }
|
||||
end
|
||||
return num_targets > 1
|
||||
end
|
||||
@@ -343,7 +343,7 @@ class PokeBattle_AI
|
||||
end
|
||||
end
|
||||
if skill>=PBTrainerAI.mediumSkill && !moldBreaker
|
||||
user.eachAlly do |b|
|
||||
user.allAllies.each do |b|
|
||||
next if !b.abilityActive?
|
||||
BattleHandlers.triggerDamageCalcUserAllyAbility(b.ability,
|
||||
user,target,move,multipliers,baseDmg,type)
|
||||
@@ -365,7 +365,7 @@ class PokeBattle_AI
|
||||
end
|
||||
end
|
||||
if skill>=PBTrainerAI.bestSkill && !moldBreaker
|
||||
target.eachAlly do |b|
|
||||
target.allAllies.each do |b|
|
||||
next if !b.abilityActive?
|
||||
BattleHandlers.triggerDamageCalcTargetAllyAbility(b.ability,
|
||||
user,target,move,multipliers,baseDmg,type)
|
||||
@@ -418,20 +418,16 @@ class PokeBattle_AI
|
||||
# Mud Sport and Water Sport
|
||||
if skill>=PBTrainerAI.mediumSkill
|
||||
if type == :ELECTRIC
|
||||
@battle.eachBattler do |b|
|
||||
next if !b.effects[PBEffects::MudSport]
|
||||
if @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] }
|
||||
multipliers[:base_damage_multiplier] /= 3
|
||||
break
|
||||
end
|
||||
if @battle.field.effects[PBEffects::MudSportField]>0
|
||||
multipliers[:base_damage_multiplier] /= 3
|
||||
end
|
||||
end
|
||||
if type == :FIRE
|
||||
@battle.eachBattler do |b|
|
||||
next if !b.effects[PBEffects::WaterSport]
|
||||
if @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] }
|
||||
multipliers[:base_damage_multiplier] /= 3
|
||||
break
|
||||
end
|
||||
if @battle.field.effects[PBEffects::WaterSportField]>0
|
||||
multipliers[:base_damage_multiplier] /= 3
|
||||
@@ -645,7 +641,7 @@ class PokeBattle_AI
|
||||
BattleHandlers.triggerAccuracyCalcUserAbility(user.ability,
|
||||
modifiers,user,target,move,type)
|
||||
end
|
||||
user.eachAlly do |b|
|
||||
user.allAllies.each do |b|
|
||||
next if !b.abilityActive?
|
||||
BattleHandlers.triggerAccuracyCalcUserAllyAbility(b.ability,
|
||||
modifiers,user,target,move,type)
|
||||
|
||||
Reference in New Issue
Block a user