Generalised a species' types to allow any number of types

This commit is contained in:
Maruno17
2022-12-31 17:24:33 +00:00
parent 3a4b01e2dc
commit 3fe324d0da
24 changed files with 200 additions and 203 deletions

View File

@@ -30,58 +30,51 @@ class Battle::Move
# Type effectiveness calculation
#=============================================================================
def pbCalcTypeModSingle(moveType, defType, user, target)
ret = Effectiveness.calculate_one(moveType, defType)
ret = Effectiveness.calculate(moveType, defType)
if Effectiveness.ineffective_type?(moveType, defType)
# Ring Target
if target.hasActiveItem?(:RINGTARGET)
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
end
# Foresight
if (user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]) &&
defType == :GHOST
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
end
# Miracle Eye
if target.effects[PBEffects::MiracleEye] && defType == :DARK
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
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_ONE
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_ONE
ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
end
return ret
end
def pbCalcTypeMod(moveType, user, target)
return Effectiveness::NORMAL_EFFECTIVE if !moveType
return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) &&
target.hasActiveItem?(:IRONBALL)
# Determine types
tTypes = target.pbTypes(true)
ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER
return ret if !moveType
return ret if moveType == :GROUND && target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL)
# Get effectivenesses
typeMods = [Effectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max
if moveType == :SHADOW
if target.shadowPokemon?
typeMods[0] = Effectiveness::NOT_VERY_EFFECTIVE_ONE
ret = Effectiveness::NOT_VERY_EFFECTIVE_MULTIPLIER
else
typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE
ret = Effectiveness::SUPER_EFFECTIVE_MULTIPLIER
end
else
tTypes.each_with_index do |type, i|
typeMods[i] = pbCalcTypeModSingle(moveType, type, user, target)
target.pbTypes(true).each do |type|
ret *= pbCalcTypeModSingle(moveType, type, user, target)
end
ret *= 2 if target.effects[PBEffects::TarShot] && moveType == :FIRE
end
# Multiply all effectivenesses together
ret = 1
typeMods.each { |m| ret *= m }
ret *= 2 if target.effects[PBEffects::TarShot] && moveType == :FIRE
return ret
end
@@ -449,7 +442,7 @@ class Battle::Move
end
end
# Type effectiveness
multipliers[:final_damage_multiplier] *= target.damageState.typeMod.to_f / Effectiveness::NORMAL_EFFECTIVE
multipliers[:final_damage_multiplier] *= target.damageState.typeMod
# Burn
if user.status == :BURN && physicalMove? && damageReducedByBurn? &&
!user.hasActiveAbility?(:GUTS)

View File

@@ -280,7 +280,7 @@ end
#===============================================================================
class Battle::Move::FreezeTargetSuperEffectiveAgainstWater < Battle::Move::FreezeTarget
def pbCalcTypeModSingle(moveType, defType, user, target)
return Effectiveness::SUPER_EFFECTIVE_ONE if defType == :WATER
return Effectiveness::SUPER_EFFECTIVE_MULTIPLIER if defType == :WATER
return super
end
end
@@ -786,7 +786,7 @@ class Battle::Move::SetUserTypesToTargetTypes < Battle::Move
return true
end
if user.pbTypes == target.pbTypes &&
user.effects[PBEffects::Type3] == target.effects[PBEffects::Type3]
user.effects[PBEffects::ExtraType] == target.effects[PBEffects::ExtraType]
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -895,7 +895,7 @@ class Battle::Move::AddGhostTypeToTarget < Battle::Move
end
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Type3] = :GHOST
target.effects[PBEffects::ExtraType] = :GHOST
typeName = GameData::Type.get(:GHOST).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName))
end
@@ -916,7 +916,7 @@ class Battle::Move::AddGrassTypeToTarget < Battle::Move
end
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Type3] = :GRASS
target.effects[PBEffects::ExtraType] = :GRASS
typeName = GameData::Type.get(:GRASS).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName))
end
@@ -1278,7 +1278,7 @@ class Battle::Move::HitsTargetInSkyGroundsTarget < Battle::Move
def hitsFlyingTargets?; return true; end
def pbCalcTypeModSingle(moveType, defType, user, target)
return Effectiveness::NORMAL_EFFECTIVE_ONE if moveType == :GROUND && defType == :FLYING
return Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER if moveType == :GROUND && defType == :FLYING
return super
end

View File

@@ -1113,8 +1113,7 @@ class Battle::Move::EffectivenessIncludesFlyingType < Battle::Move
def pbCalcTypeModSingle(moveType, defType, user, target)
ret = super
if GameData::Type.exists?(:FLYING)
flyingEff = Effectiveness.calculate_one(:FLYING, defType)
ret *= flyingEff.to_f / Effectiveness::NORMAL_EFFECTIVE_ONE
ret *= Effectiveness.calculate(:FLYING, defType)
end
return ret
end

View File

@@ -444,7 +444,7 @@ class Battle::Move::TwoTurnAttackInvulnerableInSkyTargetCannotAct < Battle::Move
end
def pbCalcTypeMod(movetype, user, target)
return Effectiveness::INEFFECTIVE if target.pbHasType?(:FLYING)
return Effectiveness::INEFFECTIVE_MULTIPLIER if target.pbHasType?(:FLYING)
return super
end