Fixes relating to added support of more Pokémon types

This commit is contained in:
Maruno17
2022-12-31 17:43:42 +00:00
parent 05b954e262
commit 4585533a4a
5 changed files with 20 additions and 73 deletions

View File

@@ -173,7 +173,7 @@ class Battle::AI
next if m.base_damage == 0 next if m.base_damage == 0
@battle.battlers[idxBattler].allOpposing.each do |b| @battle.battlers[idxBattler].allOpposing.each do |b|
bTypes = b.pbTypes(true) bTypes = b.pbTypes(true)
sum += Effectiveness.calculate(m.type, bTypes[0], bTypes[1], bTypes[2]) sum += Effectiveness.calculate(m.type, *bTypes)
end end
end end
if best == -1 || sum > bestSum if best == -1 || sum > bestSum

View File

@@ -24,54 +24,6 @@ class Battle::AI
#============================================================================= #=============================================================================
# Move's type effectiveness # 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 # For switching. Determines the effectiveness of a potential switch-in against
# an opposing battler. # an opposing battler.
def pbCalcTypeModPokemon(pkmn, target_battler) def pbCalcTypeModPokemon(pkmn, target_battler)

View File

@@ -904,11 +904,10 @@ Battle::AI::Handlers::MoveBasePower.add("EffectivenessIncludesFlyingType",
proc { |power, move, user, target, ai, battle| proc { |power, move, user, target, ai, battle|
if GameData::Type.exists?(:FLYING) if GameData::Type.exists?(:FLYING)
targetTypes = target.battler.pbTypes(true) targetTypes = target.battler.pbTypes(true)
mult = Effectiveness.calculate( mult = Effectiveness.calculate(:FLYING, *targetTypes)
:FLYING, targetTypes[0], targetTypes[1], targetTypes[2] power = (power * mult).round
)
next (power.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
end end
next power
} }
) )

View File

@@ -193,27 +193,23 @@ class Battle::AI::AIBattler
end end
def effectiveness_of_type_against_battler(type, user = nil) def effectiveness_of_type_against_battler(type, user = nil)
return Effectiveness::NORMAL_EFFECTIVE if !type ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
return Effectiveness::NORMAL_EFFECTIVE if type == :GROUND && return ret if !type
has_type?(:FLYING) && return ret if type == :GROUND && has_type?(:FLYING) && has_active_item?(:IRONBALL)
has_active_item?(:IRONBALL)
# Get effectivenesses # Get effectivenesses
type_mults = [Effectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max
if type == :SHADOW if type == :SHADOW
if @battler.shadowPokemon? if @battler.shadowPokemon?
type_mults[0] = Effectiveness::NOT_VERY_EFFECTIVE_ONE ret = Effectiveness::NOT_VERY_EFFECTIVE_MULTIPLIER
else else
type_mults[0] = Effectiveness::SUPER_EFFECTIVE_ONE ret = Effectiveness::SUPER_EFFECTIVE_MULTIPLIER
end end
else 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. # 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 end
ret *= 2 if target.effects[PBEffects::TarShot] && type == :FIRE
end end
# Multiply all effectivenesses together
ret = 1
type_mults.each { |m| ret *= m }
return ret return ret
end end
@@ -282,30 +278,30 @@ class Battle::AI::AIBattler
private private
def effectiveness_of_type_against_single_battler_type(type, defend_type, user = nil) 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) if Effectiveness.ineffective_type?(type, defend_type)
# Ring Target # Ring Target
if has_active_item?(:RINGTARGET) if has_active_item?(:RINGTARGET)
ret = Effectiveness::NORMAL_EFFECTIVE_ONE ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
end end
# Foresight # Foresight
if (user&.has_active_ability?(:SCRAPPY) || @battler.effects[PBEffects::Foresight]) && if (user&.has_active_ability?(:SCRAPPY) || @battler.effects[PBEffects::Foresight]) &&
defend_type == :GHOST defend_type == :GHOST
ret = Effectiveness::NORMAL_EFFECTIVE_ONE ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
end end
# Miracle Eye # Miracle Eye
if @battler.effects[PBEffects::MiracleEye] && defend_type == :DARK if @battler.effects[PBEffects::MiracleEye] && defend_type == :DARK
ret = Effectiveness::NORMAL_EFFECTIVE_ONE ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
end end
elsif Effectiveness.super_effective_type?(type, defend_type) elsif Effectiveness.super_effective_type?(type, defend_type)
# Delta Stream's weather # Delta Stream's weather
if @battler.effectiveWeather == :StrongWinds && defend_type == :FLYING if @battler.effectiveWeather == :StrongWinds && defend_type == :FLYING
ret = Effectiveness::NORMAL_EFFECTIVE_ONE ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
end end
end end
# Grounded Flying-type Pokémon become susceptible to Ground moves # Grounded Flying-type Pokémon become susceptible to Ground moves
if !@battler.airborne? && type == :GROUND && defend_type == :FLYING if !@battler.airborne? && defend_type == :FLYING && type == :GROUND
ret = Effectiveness::NORMAL_EFFECTIVE_ONE ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
end end
return ret return ret
end end

View File

@@ -322,7 +322,7 @@ class Battle::AI::AIMove
# Type effectiveness # Type effectiveness
typemod = target.effectiveness_of_type_against_battler(calc_type, user) 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 # Burn
if @ai.trainer.high_skill? && user.status == :BURN && physicalMove?(calc_type) && if @ai.trainer.high_skill? && user.status == :BURN && physicalMove?(calc_type) &&