diff --git a/Data/Scripts/011_Battle/005_AI/003_AI_Switch.rb b/Data/Scripts/011_Battle/005_AI/003_AI_Switch.rb index 3b1e2856a..ada1b6079 100644 --- a/Data/Scripts/011_Battle/005_AI/003_AI_Switch.rb +++ b/Data/Scripts/011_Battle/005_AI/003_AI_Switch.rb @@ -173,7 +173,7 @@ class Battle::AI next if m.base_damage == 0 @battle.battlers[idxBattler].allOpposing.each do |b| bTypes = b.pbTypes(true) - sum += Effectiveness.calculate(m.type, bTypes[0], bTypes[1], bTypes[2]) + sum += Effectiveness.calculate(m.type, *bTypes) end end if best == -1 || sum > bestSum diff --git a/Data/Scripts/011_Battle/005_AI/008_AI_Move_Utilities.rb b/Data/Scripts/011_Battle/005_AI/008_AI_Move_Utilities.rb index 046813c8b..ecfec85b3 100644 --- a/Data/Scripts/011_Battle/005_AI/008_AI_Move_Utilities.rb +++ b/Data/Scripts/011_Battle/005_AI/008_AI_Move_Utilities.rb @@ -24,54 +24,6 @@ class Battle::AI #============================================================================= # Move's type effectiveness #============================================================================= - def pbCalcTypeModSingle(moveType, defType, user, target) - ret = Effectiveness.calculate(moveType, defType) - if Effectiveness.ineffective_type?(moveType, defType) - # Ring Target - if target.hasActiveItem?(:RINGTARGET) - ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER - end - # Foresight - if (user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]) && - defType == :GHOST - ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER - end - # Miracle Eye - if target.effects[PBEffects::MiracleEye] && defType == :DARK - ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER - end - elsif Effectiveness.super_effective_type?(moveType, defType) - # Delta Stream's weather - if target.effectiveWeather == :StrongWinds && defType == :FLYING - ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER - end - end - # Grounded Flying-type Pokémon become susceptible to Ground moves - if !target.airborne? && defType == :FLYING && moveType == :GROUND - ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER - end - return ret - end - - def pbCalcTypeMod(moveType, user, target) - ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER - return ret if !moveType - return ret if moveType == :GROUND && target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL) - # Get effectivenesses - if moveType == :SHADOW - if target.shadowPokemon? - ret = Effectiveness::NOT_VERY_EFFECTIVE_MULTIPLIER - else - ret = Effectiveness::SUPER_EFFECTIVE_MULTIPLIER - end - else - target.pbTypes(true).each do |type| - ret *= pbCalcTypeModSingle(moveType, type, user, target) - end - end - return ret - end - # For switching. Determines the effectiveness of a potential switch-in against # an opposing battler. def pbCalcTypeModPokemon(pkmn, target_battler) diff --git a/Data/Scripts/011_Battle/005_AI/054_AI_MoveHandlers_MoveAttributes.rb b/Data/Scripts/011_Battle/005_AI/054_AI_MoveHandlers_MoveAttributes.rb index 69d7bcdf0..08f568715 100644 --- a/Data/Scripts/011_Battle/005_AI/054_AI_MoveHandlers_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/005_AI/054_AI_MoveHandlers_MoveAttributes.rb @@ -904,11 +904,10 @@ Battle::AI::Handlers::MoveBasePower.add("EffectivenessIncludesFlyingType", proc { |power, move, user, target, ai, battle| if GameData::Type.exists?(:FLYING) targetTypes = target.battler.pbTypes(true) - mult = Effectiveness.calculate( - :FLYING, targetTypes[0], targetTypes[1], targetTypes[2] - ) - next (power.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round + mult = Effectiveness.calculate(:FLYING, *targetTypes) + power = (power * mult).round end + next power } ) diff --git a/Data/Scripts/011_Battle/005_AI/102_AIBattler.rb b/Data/Scripts/011_Battle/005_AI/102_AIBattler.rb index 39cf3f052..fa7799abe 100644 --- a/Data/Scripts/011_Battle/005_AI/102_AIBattler.rb +++ b/Data/Scripts/011_Battle/005_AI/102_AIBattler.rb @@ -193,27 +193,23 @@ class Battle::AI::AIBattler end def effectiveness_of_type_against_battler(type, user = nil) - return Effectiveness::NORMAL_EFFECTIVE if !type - return Effectiveness::NORMAL_EFFECTIVE if type == :GROUND && - has_type?(:FLYING) && - has_active_item?(:IRONBALL) + ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER + return ret if !type + return ret if type == :GROUND && has_type?(:FLYING) && has_active_item?(:IRONBALL) # Get effectivenesses - type_mults = [Effectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max if type == :SHADOW if @battler.shadowPokemon? - type_mults[0] = Effectiveness::NOT_VERY_EFFECTIVE_ONE + ret = Effectiveness::NOT_VERY_EFFECTIVE_MULTIPLIER else - type_mults[0] = Effectiveness::SUPER_EFFECTIVE_ONE + ret = Effectiveness::SUPER_EFFECTIVE_MULTIPLIER end else - @battler.pbTypes(true).each_with_index do |defend_type, i| + @battler.pbTypes(true).each do |defend_type| # TODO: Need to check the move's pbCalcTypeModSingle. - type_mults[i] = effectiveness_of_type_against_single_battler_type(type, defend_type, user) + ret *= effectiveness_of_type_against_single_battler_type(type, defend_type, user) end + ret *= 2 if target.effects[PBEffects::TarShot] && type == :FIRE end - # Multiply all effectivenesses together - ret = 1 - type_mults.each { |m| ret *= m } return ret end @@ -282,30 +278,30 @@ class Battle::AI::AIBattler private def effectiveness_of_type_against_single_battler_type(type, defend_type, user = nil) - ret = Effectiveness.calculate_one(type, defend_type) + ret = Effectiveness.calculate(type, defend_type) if Effectiveness.ineffective_type?(type, defend_type) # Ring Target if has_active_item?(:RINGTARGET) - ret = Effectiveness::NORMAL_EFFECTIVE_ONE + ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER end # Foresight if (user&.has_active_ability?(:SCRAPPY) || @battler.effects[PBEffects::Foresight]) && defend_type == :GHOST - ret = Effectiveness::NORMAL_EFFECTIVE_ONE + ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER end # Miracle Eye if @battler.effects[PBEffects::MiracleEye] && defend_type == :DARK - ret = Effectiveness::NORMAL_EFFECTIVE_ONE + ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER end elsif Effectiveness.super_effective_type?(type, defend_type) # Delta Stream's weather if @battler.effectiveWeather == :StrongWinds && defend_type == :FLYING - ret = Effectiveness::NORMAL_EFFECTIVE_ONE + ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER end end # Grounded Flying-type Pokémon become susceptible to Ground moves - if !@battler.airborne? && type == :GROUND && defend_type == :FLYING - ret = Effectiveness::NORMAL_EFFECTIVE_ONE + if !@battler.airborne? && defend_type == :FLYING && type == :GROUND + ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER end return ret end diff --git a/Data/Scripts/011_Battle/005_AI/103_AIMove.rb b/Data/Scripts/011_Battle/005_AI/103_AIMove.rb index 3e3c89593..78efc12d1 100644 --- a/Data/Scripts/011_Battle/005_AI/103_AIMove.rb +++ b/Data/Scripts/011_Battle/005_AI/103_AIMove.rb @@ -322,7 +322,7 @@ class Battle::AI::AIMove # Type effectiveness typemod = target.effectiveness_of_type_against_battler(calc_type, user) - multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE + multipliers[:final_damage_multiplier] *= typemod # Burn if @ai.trainer.high_skill? && user.status == :BURN && physicalMove?(calc_type) &&