Rearranged and tidied up game data scripts

This commit is contained in:
Maruno17
2021-03-29 19:01:03 +01:00
parent cd62ba840c
commit 01a066a4d9
55 changed files with 263 additions and 276 deletions
+7 -7
View File
@@ -195,17 +195,17 @@ module GameData
# A bulk loader method for all data stored in .dat files in the Data folder. # A bulk loader method for all data stored in .dat files in the Data folder.
#============================================================================= #=============================================================================
def self.load_all def self.load_all
Type.load
Ability.load Ability.load
Move.load
Item.load Item.load
BerryPlant.load BerryPlant.load
Species.load
Ribbon.load
Encounter.load
TrainerType.load
Trainer.load
Metadata.load Metadata.load
MapMetadata.load MapMetadata.load
Move.load
TrainerType.load
Type.load
Species.load
Trainer.load
Encounter.load
Ribbon.load
end end
end end
@@ -1,58 +0,0 @@
module GameData
class Type
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :special_type
attr_reader :pseudo_type
attr_reader :weaknesses
attr_reader :resistances
attr_reader :immunities
DATA = {}
DATA_FILENAME = "types.dat"
SCHEMA = {
"Name" => [1, "s"],
"InternalName" => [2, "s"],
"IsPseudoType" => [3, "b"],
"IsSpecialType" => [4, "b"],
"Weaknesses" => [5, "*s"],
"Resistances" => [6, "*s"],
"Immunities" => [7, "*s"]
}
extend ClassMethods
include InstanceMethods
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number] || -1
@real_name = hash[:name] || "Unnamed"
@pseudo_type = hash[:pseudo_type] || false
@special_type = hash[:special_type] || false
@weaknesses = hash[:weaknesses] || []
@weaknesses = [@weaknesses] if !@weaknesses.is_a?(Array)
@resistances = hash[:resistances] || []
@resistances = [@resistances] if !@resistances.is_a?(Array)
@immunities = hash[:immunities] || []
@immunities = [@immunities] if !@immunities.is_a?(Array)
end
# @return [String] the translated name of this item
def name
return pbGetMessage(MessageTypes::Types, @id_number)
end
def physical?; return !@special_type; end
def special?; return @special_type; end
def effectiveness(other_type)
return PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if !other_type
return PBTypeEffectiveness::SUPER_EFFECTIVE_ONE if @weaknesses.include?(other_type)
return PBTypeEffectiveness::NOT_EFFECTIVE_ONE if @resistances.include?(other_type)
return PBTypeEffectiveness::INEFFECTIVE if @immunities.include?(other_type)
return PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
end
end
end
@@ -4,10 +4,10 @@
class PokemonTemp class PokemonTemp
attr_accessor :townMapData attr_accessor :townMapData
attr_accessor :phoneData attr_accessor :phoneData
attr_accessor :regionalDexes
attr_accessor :speciesShadowMovesets attr_accessor :speciesShadowMovesets
attr_accessor :moveToAnim attr_accessor :regionalDexes
attr_accessor :battleAnims attr_accessor :battleAnims
attr_accessor :moveToAnim
attr_accessor :mapInfos attr_accessor :mapInfos
end end
@@ -15,10 +15,10 @@ def pbClearData
if $PokemonTemp if $PokemonTemp
$PokemonTemp.townMapData = nil $PokemonTemp.townMapData = nil
$PokemonTemp.phoneData = nil $PokemonTemp.phoneData = nil
$PokemonTemp.regionalDexes = nil
$PokemonTemp.speciesShadowMovesets = nil $PokemonTemp.speciesShadowMovesets = nil
$PokemonTemp.moveToAnim = nil $PokemonTemp.regionalDexes = nil
$PokemonTemp.battleAnims = nil $PokemonTemp.battleAnims = nil
$PokemonTemp.moveToAnim = nil
$PokemonTemp.mapInfos = nil $PokemonTemp.mapInfos = nil
end end
MapFactoryHelper.clear MapFactoryHelper.clear
@@ -52,17 +52,6 @@ def pbLoadPhoneData
return $PokemonTemp.phoneData return $PokemonTemp.phoneData
end end
#===============================================================================
# Method to get Regional Dexes data.
#===============================================================================
def pbLoadRegionalDexes
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.regionalDexes
$PokemonTemp.regionalDexes = load_data("Data/regional_dexes.dat")
end
return $PokemonTemp.regionalDexes
end
#=============================================================================== #===============================================================================
# Method to get Shadow Pokémon moveset data. # Method to get Shadow Pokémon moveset data.
#=============================================================================== #===============================================================================
@@ -75,16 +64,19 @@ def pbLoadShadowMovesets
end end
#=============================================================================== #===============================================================================
# Methods relating to battle animations data. # Method to get Regional Dexes data.
#=============================================================================== #===============================================================================
def pbLoadMoveToAnim def pbLoadRegionalDexes
$PokemonTemp = PokemonTemp.new if !$PokemonTemp $PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.moveToAnim if !$PokemonTemp.regionalDexes
$PokemonTemp.moveToAnim = load_data("Data/move2anim.dat") || [] $PokemonTemp.regionalDexes = load_data("Data/regional_dexes.dat")
end end
return $PokemonTemp.moveToAnim return $PokemonTemp.regionalDexes
end end
#===============================================================================
# Methods relating to battle animations data.
#===============================================================================
def pbLoadBattleAnimations def pbLoadBattleAnimations
$PokemonTemp = PokemonTemp.new if !$PokemonTemp $PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.battleAnims if !$PokemonTemp.battleAnims
@@ -95,6 +87,14 @@ def pbLoadBattleAnimations
return $PokemonTemp.battleAnims return $PokemonTemp.battleAnims
end end
def pbLoadMoveToAnim
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.moveToAnim
$PokemonTemp.moveToAnim = load_data("Data/move2anim.dat") || []
end
return $PokemonTemp.moveToAnim
end
#=============================================================================== #===============================================================================
# Method relating to map infos data. # Method relating to map infos data.
#=============================================================================== #===============================================================================
@@ -0,0 +1,132 @@
module GameData
class Type
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :special_type
attr_reader :pseudo_type
attr_reader :weaknesses
attr_reader :resistances
attr_reader :immunities
DATA = {}
DATA_FILENAME = "types.dat"
SCHEMA = {
"Name" => [1, "s"],
"InternalName" => [2, "s"],
"IsPseudoType" => [3, "b"],
"IsSpecialType" => [4, "b"],
"Weaknesses" => [5, "*s"],
"Resistances" => [6, "*s"],
"Immunities" => [7, "*s"]
}
extend ClassMethods
include InstanceMethods
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number] || -1
@real_name = hash[:name] || "Unnamed"
@pseudo_type = hash[:pseudo_type] || false
@special_type = hash[:special_type] || false
@weaknesses = hash[:weaknesses] || []
@weaknesses = [@weaknesses] if !@weaknesses.is_a?(Array)
@resistances = hash[:resistances] || []
@resistances = [@resistances] if !@resistances.is_a?(Array)
@immunities = hash[:immunities] || []
@immunities = [@immunities] if !@immunities.is_a?(Array)
end
# @return [String] the translated name of this item
def name
return pbGetMessage(MessageTypes::Types, @id_number)
end
def physical?; return !@special_type; end
def special?; return @special_type; end
def effectiveness(other_type)
return Effectiveness::NORMAL_EFFECTIVE_ONE if !other_type
return Effectiveness::SUPER_EFFECTIVE_ONE if @weaknesses.include?(other_type)
return Effectiveness::NOT_VERY_EFFECTIVE_ONE if @resistances.include?(other_type)
return Effectiveness::INEFFECTIVE if @immunities.include?(other_type)
return Effectiveness::NORMAL_EFFECTIVE_ONE
end
end
end
#===============================================================================
module Effectiveness
INEFFECTIVE = 0
NOT_VERY_EFFECTIVE_ONE = 1
NORMAL_EFFECTIVE_ONE = 2
SUPER_EFFECTIVE_ONE = 4
NORMAL_EFFECTIVE = NORMAL_EFFECTIVE_ONE ** 3
module_function
def ineffective?(value)
return value == INEFFECTIVE
end
def not_very_effective?(value)
return value > INEFFECTIVE && value < NORMAL_EFFECTIVE
end
def resistant?(value)
return value < NORMAL_EFFECTIVE
end
def normal?(value)
return value == NORMAL_EFFECTIVE
end
def super_effective?(value)
return value > NORMAL_EFFECTIVE
end
def ineffective_type?(attack_type, defend_type1, defend_type2 = nil, defend_type3 = nil)
value = calculate(attack_type, target_type1, target_type2, target_type3)
return ineffective?(value)
end
def not_very_effective_type?(attack_type, defend_type1, defend_type2 = nil, defend_type3 = nil)
value = calculate(attack_type, target_type1, target_type2, target_type3)
return not_very_effective?(value)
end
def resistant_type?(attack_type, defend_type1, defend_type2 = nil, defend_type3 = nil)
value = calculate(attack_type, target_type1, target_type2, target_type3)
return resistant?(value)
end
def normal_type?(attack_type, defend_type1, defend_type2 = nil, defend_type3 = nil)
value = calculate(attack_type, target_type1, target_type2, target_type3)
return normal?(value)
end
def super_effective_type?(attack_type, defend_type1, defend_type2 = nil, defend_type3 = nil)
value = calculate(attack_type, target_type1, target_type2, target_type3)
return super_effective?(value)
end
def calculate_one(attack_type, defend_type)
return GameData::Type.get(defend_type).effectiveness(attack_type)
end
def calculate(attack_type, defend_type1, defend_type2 = nil, defend_type3 = nil)
mod1 = calculate_one(attack_type, defend_type1)
mod2 = NORMAL_EFFECTIVE_ONE
mod3 = NORMAL_EFFECTIVE_ONE
if defend_type2 && defend_type1 != defend_type2
mod2 = calculate_one(attack_type, defend_type2)
end
if defend_type3 && defend_type1 != defend_type3 && defend_type2 != defend_type3
mod3 = calculate_one(attack_type, defend_type3)
end
return mod1 * mod2 * mod3
end
end
-83
View File
@@ -1,83 +0,0 @@
module PBTypeEffectiveness
INEFFECTIVE = 0
NOT_EFFECTIVE_ONE = 1
NORMAL_EFFECTIVE_ONE = 2
SUPER_EFFECTIVE_ONE = 4
NORMAL_EFFECTIVE = NORMAL_EFFECTIVE_ONE ** 3
def self.ineffective?(value)
return value == INEFFECTIVE
end
def self.notVeryEffective?(value)
return value > INEFFECTIVE && value < NORMAL_EFFECTIVE
end
def self.resistant?(value)
return value < NORMAL_EFFECTIVE
end
def self.normalEffective?(value)
return value == NORMAL_EFFECTIVE
end
def self.superEffective?(value)
return value > NORMAL_EFFECTIVE
end
end
module PBTypes
def self.regularTypesCount
ret = 0
GameData::Type.each { |t| ret += 1 if !t.pseudo_type && t.id != :SHADOW }
return ret
end
def self.isPhysicalType?(type); return GameData::Type.get(type).physical?; end
def self.isSpecialType?(type); return GameData::Type.get(type).special?; end
def self.isPseudoType?(type); return GameData::Type.get(type).pseudo_type; end
def self.getEffectiveness(attack_type, target_type)
return GameData::Type.get(target_type).effectiveness(attack_type)
end
def self.getCombinedEffectiveness(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
mod1 = self.getEffectiveness(attack_type, target_type1)
mod2 = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
mod3 = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
if target_type2 && target_type1 != target_type2
mod2 = self.getEffectiveness(attack_type, target_type2)
end
if target_type3 && target_type1 != target_type3 && target_type2 != target_type3
mod3 = self.getEffectiveness(attack_type, target_type3)
end
return mod1 * mod2 * mod3
end
def self.ineffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.ineffective?(value)
end
def self.notVeryEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.notVeryEffective?(value)
end
def self.resistant?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.resistant?(value)
end
def self.normalEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.normalEffective?(value)
end
def self.superEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.superEffective?(value)
end
end
@@ -360,7 +360,7 @@ class PokeBattle_Battler
end end
# Protean # Protean
if user.hasActiveAbility?(:PROTEAN) && !move.callsAnotherMove? && !move.snatched if user.hasActiveAbility?(:PROTEAN) && !move.callsAnotherMove? && !move.snatched
if user.pbHasOtherType?(move.calcType) && !PBTypes.isPseudoType?(move.calcType) if user.pbHasOtherType?(move.calcType) && !GameData::Type.get(move.calcType).pseudo_type
@battle.pbShowAbilitySplash(user) @battle.pbShowAbilitySplash(user)
user.pbChangeTypes(move.calcType) user.pbChangeTypes(move.calcType)
typeName = GameData::Type.get(move.calcType).name typeName = GameData::Type.get(move.calcType).name
@@ -401,7 +401,7 @@ class PokeBattle_Battler
# Immunity because of ability (intentionally before type immunity check) # Immunity because of ability (intentionally before type immunity check)
return false if move.pbImmunityByAbility(user,target) return false if move.pbImmunityByAbility(user,target)
# Type immunity # Type immunity
if move.pbDamagingMove? && PBTypeEffectiveness.ineffective?(typeMod) if move.pbDamagingMove? && Effectiveness.ineffective?(typeMod)
PBDebug.log("[Target immune] #{target.pbThis}'s type immunity") PBDebug.log("[Target immune] #{target.pbThis}'s type immunity")
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true))) @battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
return false return false
@@ -75,7 +75,7 @@ class PokeBattle_Move
thisType ||= @calcType thisType ||= @calcType
thisType ||= @type thisType ||= @type
return true if !thisType return true if !thisType
return !PBTypes.isSpecialType?(thisType) return GameData::Type.get(thisType).physical?
end end
# NOTE: This method is only ever called while using a move (and also by the # NOTE: This method is only ever called while using a move (and also by the
@@ -85,7 +85,7 @@ class PokeBattle_Move
thisType ||= @calcType thisType ||= @calcType
thisType ||= @type thisType ||= @type
return false if !thisType return false if !thisType
return PBTypes.isSpecialType?(thisType) return GameData::Type.get(thisType).special?
end end
def damagingMove?; return @category!=2; end def damagingMove?; return @category!=2; end
@@ -234,8 +234,8 @@ class PokeBattle_Move
oldHP = b.hp+b.damageState.hpLost oldHP = b.hp+b.damageState.hpLost
PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})") PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})")
effectiveness = 0 effectiveness = 0
if PBTypeEffectiveness.resistant?(b.damageState.typeMod); effectiveness = 1 if Effectiveness.resistant?(b.damageState.typeMod); effectiveness = 1
elsif PBTypeEffectiveness.superEffective?(b.damageState.typeMod); effectiveness = 2 elsif Effectiveness.super_effective?(b.damageState.typeMod); effectiveness = 2
end end
animArray.push([b,oldHP,effectiveness]) animArray.push([b,oldHP,effectiveness])
end end
@@ -251,13 +251,13 @@ class PokeBattle_Move
#============================================================================= #=============================================================================
def pbEffectivenessMessage(user,target,numTargets=1) def pbEffectivenessMessage(user,target,numTargets=1)
return if target.damageState.disguise return if target.damageState.disguise
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod) if Effectiveness.super_effective?(target.damageState.typeMod)
if numTargets>1 if numTargets>1
@battle.pbDisplay(_INTL("It's super effective on {1}!",target.pbThis(true))) @battle.pbDisplay(_INTL("It's super effective on {1}!",target.pbThis(true)))
else else
@battle.pbDisplay(_INTL("It's super effective!")) @battle.pbDisplay(_INTL("It's super effective!"))
end end
elsif PBTypeEffectiveness.notVeryEffective?(target.damageState.typeMod) elsif Effectiveness.not_very_effective?(target.damageState.typeMod)
if numTargets>1 if numTargets>1
@battle.pbDisplay(_INTL("It's not very effective on {1}...",target.pbThis(true))) @battle.pbDisplay(_INTL("It's not very effective on {1}...",target.pbThis(true)))
else else
@@ -30,41 +30,41 @@ class PokeBattle_Move
# Type effectiveness calculation # Type effectiveness calculation
#============================================================================= #=============================================================================
def pbCalcTypeModSingle(moveType,defType,user,target) def pbCalcTypeModSingle(moveType,defType,user,target)
ret = PBTypes.getEffectiveness(moveType,defType) ret = Effectiveness.calculate_one(moveType, defType)
# Ring Target # Ring Target
if target.hasActiveItem?(:RINGTARGET) if target.hasActiveItem?(:RINGTARGET)
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if PBTypes.ineffective?(moveType,defType) ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType)
end end
# Foresight # Foresight
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight] if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST && ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
PBTypes.ineffective?(moveType,defType) Effectiveness.ineffective_type?(moveType, defType)
end end
# Miracle Eye # Miracle Eye
if target.effects[PBEffects::MiracleEye] if target.effects[PBEffects::MiracleEye]
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK && ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
PBTypes.ineffective?(moveType,defType) Effectiveness.ineffective_type?(moveType, defType)
end end
# Delta Stream's weather # Delta Stream's weather
if @battle.pbWeather == :StrongWinds if @battle.pbWeather == :StrongWinds
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
PBTypes.superEffective?(moveType,defType) Effectiveness.super_effective_type?(moveType, defType)
end end
# Grounded Flying-type Pokémon become susceptible to Ground moves # Grounded Flying-type Pokémon become susceptible to Ground moves
if !target.airborne? if !target.airborne?
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
end end
return ret return ret
end end
def pbCalcTypeMod(moveType,user,target) def pbCalcTypeMod(moveType,user,target)
return PBTypeEffectiveness::NORMAL_EFFECTIVE if !moveType return Effectiveness::NORMAL_EFFECTIVE if !moveType
return PBTypeEffectiveness::NORMAL_EFFECTIVE if moveType == :GROUND && return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL) target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL)
# Determine types # Determine types
tTypes = target.pbTypes(true) tTypes = target.pbTypes(true)
# Get effectivenesses # Get effectivenesses
typeMods = [PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max typeMods = [Effectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max
tTypes.each_with_index do |type,i| tTypes.each_with_index do |type,i|
typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target) typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target)
end end
@@ -412,7 +412,7 @@ class PokeBattle_Move
end end
end end
# Type effectiveness # Type effectiveness
multipliers[:final_damage_multiplier] *= target.damageState.typeMod.to_f / PBTypeEffectiveness::NORMAL_EFFECTIVE multipliers[:final_damage_multiplier] *= target.damageState.typeMod.to_f / Effectiveness::NORMAL_EFFECTIVE
# Burn # Burn
if user.status == :BURN && physicalMove? && damageReducedByBurn? && if user.status == :BURN && physicalMove? && damageReducedByBurn? &&
!user.hasActiveAbility?(:GUTS) !user.hasActiveAbility?(:GUTS)
@@ -112,7 +112,7 @@ class PokeBattle_Move_007 < PokeBattle_ParalysisMove
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if @id == :THUNDERWAVE && PBTypeEffectiveness.ineffective?(target.damageState.typeMod) if @id == :THUNDERWAVE && Effectiveness.ineffective?(target.damageState.typeMod)
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true))) @battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
return true return true
end end
@@ -1789,7 +1789,7 @@ class PokeBattle_Move_05E < PokeBattle_Move
@newTypes = [] @newTypes = []
user.eachMoveWithIndex do |m,i| user.eachMoveWithIndex do |m,i|
break if Settings::MECHANICS_GENERATION >= 6 && i>0 break if Settings::MECHANICS_GENERATION >= 6 && i>0
next if PBTypes.isPseudoType?(m.type) next if GameData::Type.get(m.type).pseudo_type
next if userTypes.include?(m.type) next if userTypes.include?(m.type)
@newTypes.push(m.type) if !@newTypes.include?(m.type) @newTypes.push(m.type) if !@newTypes.include?(m.type)
end end
@@ -1827,14 +1827,14 @@ class PokeBattle_Move_05F < PokeBattle_Move
def pbFailsAgainstTarget?(user, target) def pbFailsAgainstTarget?(user, target)
if !target.lastMoveUsed || !target.lastMoveUsedType || if !target.lastMoveUsed || !target.lastMoveUsedType ||
PBTypes.isPseudoType?(target.lastMoveUsedType) GameData::Type.get(target.lastMoveUsedType).pseudo_type
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@newTypes = [] @newTypes = []
GameData::Type.each do |t| GameData::Type.each do |t|
next if t.pseudo_type || user.pbHasType?(t.id) || next if t.pseudo_type || user.pbHasType?(t.id) ||
!PBTypes.resistant?(target.lastMoveUsedType, t.id) !Effectiveness.resistant_type?(target.lastMoveUsedType, t.id)
@newTypes.push(t.id) @newTypes.push(t.id)
end end
if @newTypes.length == 0 if @newTypes.length == 0
@@ -2253,7 +2253,7 @@ class PokeBattle_Move_0CE < PokeBattle_TwoTurnMove
end end
def pbCalcTypeMod(movetype,user,target) def pbCalcTypeMod(movetype,user,target)
return PBTypeEffectiveness::INEFFECTIVE if target.pbHasType?(:FLYING) return Effectiveness::INEFFECTIVE if target.pbHasType?(:FLYING)
return super return super
end end
@@ -768,7 +768,7 @@ class PokeBattle_Move_11C < PokeBattle_Move
def hitsFlyingTargets?; return true; end def hitsFlyingTargets?; return true; end
def pbCalcTypeModSingle(moveType,defType,user,target) def pbCalcTypeModSingle(moveType,defType,user,target)
return PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if moveType == :GROUND && defType == :FLYING return Effectiveness::NORMAL_EFFECTIVE_ONE if moveType == :GROUND && defType == :FLYING
return super return super
end end
@@ -1064,7 +1064,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_Move_135 < PokeBattle_FreezeMove class PokeBattle_Move_135 < PokeBattle_FreezeMove
def pbCalcTypeModSingle(moveType,defType,user,target) def pbCalcTypeModSingle(moveType,defType,user,target)
return PBTypeEffectiveness::SUPER_EFFECTIVE_ONE if defType == :WATER return Effectiveness::SUPER_EFFECTIVE_ONE if defType == :WATER
return super return super
end end
end end
@@ -1453,8 +1453,8 @@ class PokeBattle_Move_144 < PokeBattle_Move
def pbCalcTypeModSingle(moveType,defType,user,target) def pbCalcTypeModSingle(moveType,defType,user,target)
ret = super ret = super
if GameData::Type.exists?(:FLYING) if GameData::Type.exists?(:FLYING)
flyingEff = PBTypes.getEffectiveness(:FLYING, defType) flyingEff = Effectiveness.calculate_one(:FLYING, defType)
ret *= flyingEff.to_f / PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE ret *= flyingEff.to_f / Effectiveness::NORMAL_EFFECTIVE_ONE
end end
return ret return ret
end end
@@ -352,9 +352,9 @@ class PokeBattle_Battle
if battler.pbOwnSide.effects[PBEffects::StealthRock] && battler.takesIndirectDamage? && if battler.pbOwnSide.effects[PBEffects::StealthRock] && battler.takesIndirectDamage? &&
GameData::Type.exists?(:ROCK) GameData::Type.exists?(:ROCK)
bTypes = battler.pbTypes(true) bTypes = battler.pbTypes(true)
eff = PBTypes.getCombinedEffectiveness(:ROCK, bTypes[0], bTypes[1], bTypes[2]) eff = Effectiveness.calculate(:ROCK, bTypes[0], bTypes[1], bTypes[2])
if !PBTypeEffectiveness.ineffective?(eff) if !Effectiveness.ineffective?(eff)
eff = eff.to_f/PBTypeEffectiveness::NORMAL_EFFECTIVE eff = eff.to_f / Effectiveness::NORMAL_EFFECTIVE
oldHP = battler.hp oldHP = battler.hp
battler.pbReduceHP(battler.totalhp*eff/8,false) battler.pbReduceHP(battler.totalhp*eff/8,false)
pbDisplay(_INTL("Pointed stones dug into {1}!",battler.pbThis)) pbDisplay(_INTL("Pointed stones dug into {1}!",battler.pbThis))
@@ -22,7 +22,7 @@ class PokeBattle_AI
moveData = GameData::Move.get(target.lastMoveUsed) moveData = GameData::Move.get(target.lastMoveUsed)
moveType = moveData.type moveType = moveData.type
typeMod = pbCalcTypeMod(moveType,target,battler) typeMod = pbCalcTypeMod(moveType,target,battler)
if PBTypeEffectiveness.superEffective?(typeMod) && moveData.base_damage > 50 if Effectiveness.super_effective?(typeMod) && moveData.base_damage > 50
switchChance = (moveData.base_damage > 70) ? 30 : 20 switchChance = (moveData.base_damage > 70) ? 30 : 20
shouldSwitch = (pbAIRandom(100) < switchChance) shouldSwitch = (pbAIRandom(100) < switchChance)
end end
@@ -107,18 +107,18 @@ class PokeBattle_AI
end end
end end
# moveType is the type of the target's last used move # moveType is the type of the target's last used move
if moveType>=0 && PBTypeEffectiveness.ineffective?(pbCalcTypeMod(moveType,battler,battler)) if moveType>=0 && Effectiveness.ineffective?(pbCalcTypeMod(moveType,battler,battler))
weight = 65 weight = 65
typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true)) typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true))
if PBTypeEffectiveness.superEffective?(typeMod.to_f/PBTypeEffectivenesss::NORMAL_EFFECTIVE) if Effectiveness.super_effective?(typeMod)
# Greater weight if new Pokemon's type is effective against target # Greater weight if new Pokemon's type is effective against target
weight = 85 weight = 85
end end
list.unshift(i) if pbAIRandom(100)<weight # Put this Pokemon first list.unshift(i) if pbAIRandom(100)<weight # Put this Pokemon first
elsif moveType>=0 && PBTypeEffectiveness.resistant?(pbCalcTypeMod(moveType,battler,battler)) elsif moveType>=0 && Effectiveness.resistant?(pbCalcTypeMod(moveType,battler,battler))
weight = 40 weight = 40
typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true)) typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true))
if PBTypeEffectiveness.superEffective?(typeMod.to_f/PBTypeEffectivenesss::NORMAL_EFFECTIVE) if Effectiveness.super_effective?(typeMod)
# Greater weight if new Pokemon's type is effective against target # Greater weight if new Pokemon's type is effective against target
weight = 60 weight = 60
end end
@@ -165,7 +165,7 @@ class PokeBattle_AI
next if m.base_damage == 0 next if m.base_damage == 0
@battle.battlers[idxBattler].eachOpposing do |b| @battle.battlers[idxBattler].eachOpposing do |b|
bTypes = b.pbTypes(true) bTypes = b.pbTypes(true)
sum += PBTypes.getCombinedEffectiveness(m.type, bTypes[0], bTypes[1], bTypes[2]) sum += Effectiveness.calculate(m.type, bTypes[0], bTypes[1], bTypes[2])
end end
end end
if best==-1 || sum>bestSum if best==-1 || sum>bestSum
@@ -71,7 +71,7 @@ class PokeBattle_AI
if target.pbCanParalyze?(user,false) && if target.pbCanParalyze?(user,false) &&
!(skill>=PBTrainerAI.mediumSkill && !(skill>=PBTrainerAI.mediumSkill &&
move.id == :THUNDERWAVE && move.id == :THUNDERWAVE &&
PBTypeEffectiveness.ineffective?(pbCalcTypeMod(move.type,user,target))) Effectiveness.ineffective?(pbCalcTypeMod(move.type,user,target)))
score += 30 score += 30
if skill>=PBTrainerAI.mediumSkill if skill>=PBTrainerAI.mediumSkill
aspeed = pbRoughStat(user,:SPEED,skill) aspeed = pbRoughStat(user,:SPEED,skill)
@@ -1317,7 +1317,7 @@ class PokeBattle_AI
types = [] types = []
user.eachMove do |m| user.eachMove do |m|
next if m.id==@id next if m.id==@id
next if PBTypes.isPseudoType?(m.type) next if GameData::Type.get(m.type).pseudo_type
next if user.pbHasType?(m.type) next if user.pbHasType?(m.type)
types.push(m.type) if !types.include?(m.type) types.push(m.type) if !types.include?(m.type)
end end
@@ -1342,7 +1342,7 @@ class PokeBattle_AI
types = [] types = []
GameData::Type.each do |t| GameData::Type.each do |t|
next if t.pseudo_type || user.pbHasType?(t.id) || next if t.pseudo_type || user.pbHasType?(t.id) ||
!PBTypes.resistant?(aType, t.id) !Effectiveness.resistant_type?(aType, t.id)
types.push(t.id) types.push(t.id)
end end
score -= 90 if types.length==0 score -= 90 if types.length==0
@@ -1512,11 +1512,7 @@ class PokeBattle_AI
score -= 60 score -= 60
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed
moveData = GameData::Move.get(target.lastMoveUsed) moveData = GameData::Move.get(target.lastMoveUsed)
if moveData.base_damage > 0 && score += 60 if moveData.physical?
(Settings::MOVE_CATEGORY_PER_MOVE && moveData.category == 0) ||
(!Settings::MOVE_CATEGORY_PER_MOVE && PBTypes.isPhysicalType?(moveData.type))
score -= 60
end
end end
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -1530,11 +1526,7 @@ class PokeBattle_AI
score -= 60 score -= 60
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed
moveData = GameData::Move.get(target.lastMoveUsed) moveData = GameData::Move.get(target.lastMoveUsed)
if moveData.base_damage > 0 && score += 60 if moveData.special?
(Settings::MOVE_CATEGORY_PER_MOVE && moveData.category == 1) ||
(!Settings::MOVE_CATEGORY_PER_MOVE && !PBTypes.isSpecialType?(moveData.type))
score -= 60
end
end end
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -1779,7 +1771,7 @@ class PokeBattle_AI
score += 60 score += 60
elsif moveData.category != 2 && # Damaging move elsif moveData.category != 2 && # Damaging move
moveData.target == :NearOther && moveData.target == :NearOther &&
PBTypeEffectiveness.ineffective?(pbCalcTypeMod(moveData.type, target, user)) Effectiveness.ineffective?(pbCalcTypeMod(moveData.type, target, user))
score += 60 score += 60
end end
end end
@@ -25,41 +25,41 @@ class PokeBattle_AI
# Move's type effectiveness # Move's type effectiveness
#============================================================================= #=============================================================================
def pbCalcTypeModSingle(moveType,defType,user,target) def pbCalcTypeModSingle(moveType,defType,user,target)
ret = PBTypes.getEffectiveness(moveType,defType) ret = Effectiveness.calculate_one(moveType,defType)
# Ring Target # Ring Target
if target.hasActiveItem?(:RINGTARGET) if target.hasActiveItem?(:RINGTARGET)
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if PBTypes.ineffective?(moveType,defType) ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType)
end end
# Foresight # Foresight
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight] if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST && ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
PBTypes.ineffective?(moveType,defType) Effectiveness.ineffective_type?(moveType, defType)
end end
# Miracle Eye # Miracle Eye
if target.effects[PBEffects::MiracleEye] if target.effects[PBEffects::MiracleEye]
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK && ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
PBTypes.ineffective?(moveType,defType) Effectiveness.ineffective_type?(moveType, defType)
end end
# Delta Stream's weather # Delta Stream's weather
if @battle.pbWeather == :StrongWinds if @battle.pbWeather == :StrongWinds
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
PBTypes.superEffective?(moveType,defType) Effectiveness.super_effective_type?(moveType, defType)
end end
# Grounded Flying-type Pokémon become susceptible to Ground moves # Grounded Flying-type Pokémon become susceptible to Ground moves
if !target.airborne? if !target.airborne?
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
end end
return ret return ret
end end
def pbCalcTypeMod(moveType,user,target) def pbCalcTypeMod(moveType,user,target)
return PBTypeEffectiveness::NORMAL_EFFECTIVE if !moveType return Effectiveness::NORMAL_EFFECTIVE if !moveType
return PBTypeEffectiveness::NORMAL_EFFECTIVE if moveType == :GROUND && return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL) target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL)
# Determine types # Determine types
tTypes = target.pbTypes(true) tTypes = target.pbTypes(true)
# Get effectivenesses # Get effectivenesses
typeMods = [PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max typeMods = [Effectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max
tTypes.each_with_index do |type,i| tTypes.each_with_index do |type,i|
typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target) typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target)
end end
@@ -72,12 +72,13 @@ class PokeBattle_AI
# 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(battlerThis,_battlerOther) def pbCalcTypeModPokemon(battlerThis,_battlerOther)
mod1 = PBTypes.getCombinedEffectiveness(battlerThis.type1,target.type1,target.type2) mod1 = Effectiveness.calculate(battlerThis.type1,target.type1,target.type2)
mod2 = PBTypeEffectiveness::NORMAL_EFFECTIVE mod2 = Effectiveness::NORMAL_EFFECTIVE
if battlerThis.type1!=battlerThis.type2 if battlerThis.type1!=battlerThis.type2
mod2 = PBTypes.getCombinedEffectiveness(battlerThis.type2,target.type1,target.type2) mod2 = Effectiveness.calculate(battlerThis.type2,target.type1,target.type2)
mod2 = mod2.to_f / Effectivenesss::NORMAL_EFFECTIVE
end end
return mod1*mod2 # Normal effectiveness is 64 here return mod1*mod2
end end
#============================================================================= #=============================================================================
@@ -87,7 +88,7 @@ class PokeBattle_AI
type = pbRoughType(move,user,skill) type = pbRoughType(move,user,skill)
typeMod = pbCalcTypeMod(type,user,target) typeMod = pbCalcTypeMod(type,user,target)
# Type effectiveness # Type effectiveness
return true if PBTypeEffectiveness.ineffective?(typeMod) || score<=0 return true if Effectiveness.ineffective?(typeMod) || score<=0
# Immunity due to ability/item/other effects # Immunity due to ability/item/other effects
if skill>=PBTrainerAI.mediumSkill if skill>=PBTrainerAI.mediumSkill
case type case type
@@ -102,7 +103,7 @@ class PokeBattle_AI
when :ELECTRIC when :ELECTRIC
return true if target.hasActiveAbility?([:LIGHTNINGROD,:MOTORDRIVE,:VOLTABSORB]) return true if target.hasActiveAbility?([:LIGHTNINGROD,:MOTORDRIVE,:VOLTABSORB])
end end
return true if PBTypeEffectiveness.notVeryEffective?(typeMod) && return true if Effectiveness.not_very_effective?(typeMod) &&
target.hasActiveAbility?(:WONDERGUARD) target.hasActiveAbility?(:WONDERGUARD)
return true if move.damagingMove? && user.index!=target.index && !target.opposes?(user) && return true if move.damagingMove? && user.index!=target.index && !target.opposes?(user) &&
target.hasActiveAbility?(:TELEPATHY) target.hasActiveAbility?(:TELEPATHY)
@@ -227,13 +228,13 @@ class PokeBattle_AI
if GameData::Type.exists?(:FLYING) if GameData::Type.exists?(:FLYING)
if skill>=PBTrainerAI.highSkill if skill>=PBTrainerAI.highSkill
targetTypes = target.pbTypes(true) targetTypes = target.pbTypes(true)
mult = PBTypes.getCombinedEffectiveness(:FLYING, mult = Effectiveness.calculate(:FLYING,
targetTypes[0],targetTypes[1],targetTypes[2]) targetTypes[0],targetTypes[1],targetTypes[2])
baseDmg = (baseDmg.to_f*mult/PBTypeEffectiveness::NORMAL_EFFECTIVE).round baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round
else else
mult = PBTypes.getCombinedEffectiveness(:FLYING, mult = Effectiveness.calculate(:FLYING,
target.type1,target.type2,target.effects[PBEffects::Type3]) target.type1,target.type2,target.effects[PBEffects::Type3])
baseDmg = (baseDmg.to_f*mult/PBTypeEffectiveness::NORMAL_EFFECTIVE).round baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round
end end
end end
baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
@@ -462,7 +463,7 @@ class PokeBattle_AI
# Type effectiveness # Type effectiveness
if skill>=PBTrainerAI.mediumSkill if skill>=PBTrainerAI.mediumSkill
typemod = pbCalcTypeMod(type,user,target) typemod = pbCalcTypeMod(type,user,target)
multipliers[:final_damage_multiplier] *= typemod.to_f / PBTypeEffectiveness::NORMAL_EFFECTIVE multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE
end end
# Burn # Burn
if skill>=PBTrainerAI.highSkill if skill>=PBTrainerAI.highSkill
@@ -580,7 +580,7 @@ end
def pbBattleTypeWeakingBerry(type,moveType,target,mults) def pbBattleTypeWeakingBerry(type,moveType,target,mults)
return if moveType != type return if moveType != type
return if PBTypeEffectiveness.resistant?(target.damageState.typeMod) && moveType != :NORMAL return if Effectiveness.resistant?(target.damageState.typeMod) && moveType != :NORMAL
mults[:final_damage_multiplier] /= 2 mults[:final_damage_multiplier] /= 2
target.damageState.berryWeakened = true target.damageState.berryWeakened = true
target.battle.pbCommonAnimation("EatBerry",target) target.battle.pbCommonAnimation("EatBerry",target)
@@ -695,7 +695,7 @@ BattleHandlers::MoveImmunityTargetAbility.copy(:WATERABSORB,:DRYSKIN)
BattleHandlers::MoveImmunityTargetAbility.add(:WONDERGUARD, BattleHandlers::MoveImmunityTargetAbility.add(:WONDERGUARD,
proc { |ability,user,target,move,type,battle| proc { |ability,user,target,move,type,battle|
next false if move.statusMove? next false if move.statusMove?
next false if !type || PBTypeEffectiveness.superEffective?(target.damageState.typeMod) next false if !type || Effectiveness.super_effective?(target.damageState.typeMod)
battle.pbShowAbilitySplash(target) battle.pbShowAbilitySplash(target)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true))) battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
@@ -970,7 +970,7 @@ BattleHandlers::DamageCalcUserAbility.copy(:MINUS,:PLUS)
BattleHandlers::DamageCalcUserAbility.add(:NEUROFORCE, BattleHandlers::DamageCalcUserAbility.add(:NEUROFORCE,
proc { |ability,user,target,move,mults,baseDmg,type| proc { |ability,user,target,move,mults,baseDmg,type|
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod) if Effectiveness.super_effective?(target.damageState.typeMod)
mults[:final_damage_multiplier] *= 1.25 mults[:final_damage_multiplier] *= 1.25
end end
} }
@@ -1076,7 +1076,7 @@ BattleHandlers::DamageCalcUserAbility.add(:TECHNICIAN,
BattleHandlers::DamageCalcUserAbility.add(:TINTEDLENS, BattleHandlers::DamageCalcUserAbility.add(:TINTEDLENS,
proc { |ability,user,target,move,mults,baseDmg,type| proc { |ability,user,target,move,mults,baseDmg,type|
mults[:final_damage_multiplier] *= 2 if PBTypeEffectiveness.resistant?(target.damageState.typeMod) mults[:final_damage_multiplier] *= 2 if Effectiveness.resistant?(target.damageState.typeMod)
} }
) )
@@ -1139,7 +1139,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:DRYSKIN,
BattleHandlers::DamageCalcTargetAbility.add(:FILTER, BattleHandlers::DamageCalcTargetAbility.add(:FILTER,
proc { |ability,user,target,move,mults,baseDmg,type| proc { |ability,user,target,move,mults,baseDmg,type|
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod) if Effectiveness.super_effective?(target.damageState.typeMod)
mults[:final_damage_multiplier] *= 0.75 mults[:final_damage_multiplier] *= 0.75
end end
} }
@@ -1214,7 +1214,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:WATERBUBBLE,
BattleHandlers::DamageCalcTargetAbilityNonIgnorable.add(:PRISMARMOR, BattleHandlers::DamageCalcTargetAbilityNonIgnorable.add(:PRISMARMOR,
proc { |ability,user,target,move,mults,baseDmg,type| proc { |ability,user,target,move,mults,baseDmg,type|
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod) if Effectiveness.super_effective?(target.damageState.typeMod)
mults[:final_damage_multiplier] *= 0.75 mults[:final_damage_multiplier] *= 0.75
end end
} }
@@ -1712,7 +1712,7 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:BERSERK,
BattleHandlers::TargetAbilityAfterMoveUse.add(:COLORCHANGE, BattleHandlers::TargetAbilityAfterMoveUse.add(:COLORCHANGE,
proc { |ability,target,user,move,switched,battle| proc { |ability,target,user,move,switched,battle|
next if target.damageState.calcDamage==0 || target.damageState.substitute next if target.damageState.calcDamage==0 || target.damageState.substitute
next if !move.calcType || PBTypes.isPseudoType?(move.calcType) next if !move.calcType || GameData::Type.get(move.calcType).pseudo_type
next if target.pbHasType?(move.calcType) && !target.pbHasOtherType?(move.calcType) next if target.pbHasType?(move.calcType) && !target.pbHasOtherType?(move.calcType)
typeName = GameData::Type.get(move.calcType).name typeName = GameData::Type.get(move.calcType).name
battle.pbShowAbilitySplash(target) battle.pbShowAbilitySplash(target)
@@ -2078,9 +2078,9 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION,
if Settings::MECHANICS_GENERATION >= 6 && m.function == "090" # Hidden Power if Settings::MECHANICS_GENERATION >= 6 && m.function == "090" # Hidden Power
moveType = pbHiddenPower(b.pokemon)[0] moveType = pbHiddenPower(b.pokemon)[0]
end end
eff = PBTypes.getCombinedEffectiveness(moveType,type1,type2,type3) eff = Effectiveness.calculate(moveType,type1,type2,type3)
next if PBTypeEffectiveness.ineffective?(eff) next if Effectiveness.ineffective?(eff)
next if !PBTypeEffectiveness.superEffective?(eff) && m.function != "070" # OHKO next if !Effectiveness.super_effective?(eff) && m.function != "070" # OHKO
else else
next if m.function != "070" # OHKO next if m.function != "070" # OHKO
end end
@@ -528,7 +528,7 @@ BattleHandlers::DamageCalcUserItem.add(:ELECTRICGEM,
BattleHandlers::DamageCalcUserItem.add(:EXPERTBELT, BattleHandlers::DamageCalcUserItem.add(:EXPERTBELT,
proc { |item,user,target,move,mults,baseDmg,type| proc { |item,user,target,move,mults,baseDmg,type|
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod) if Effectiveness.super_effective?(target.damageState.typeMod)
mults[:final_damage_multiplier] *= 1.2 mults[:final_damage_multiplier] *= 1.2
end end
} }
@@ -1022,7 +1022,7 @@ BattleHandlers::TargetItemOnHit.add(:CELLBATTERY,
BattleHandlers::TargetItemOnHit.add(:ENIGMABERRY, BattleHandlers::TargetItemOnHit.add(:ENIGMABERRY,
proc { |item,user,target,move,battle| proc { |item,user,target,move,battle|
next if target.damageState.substitute || target.damageState.disguise next if target.damageState.substitute || target.damageState.disguise
next if !PBTypeEffectiveness.superEffective?(target.damageState.typeMod) next if !Effectiveness.super_effective?(target.damageState.typeMod)
if BattleHandlers.triggerTargetItemOnHitPositiveBerry(item,target,battle,false) if BattleHandlers.triggerTargetItemOnHitPositiveBerry(item,target,battle,false)
target.pbHeldItemTriggered(item) target.pbHeldItemTriggered(item)
end end
@@ -1136,7 +1136,7 @@ BattleHandlers::TargetItemOnHit.add(:STICKYBARB,
BattleHandlers::TargetItemOnHit.add(:WEAKNESSPOLICY, BattleHandlers::TargetItemOnHit.add(:WEAKNESSPOLICY,
proc { |item,user,target,move,battle| proc { |item,user,target,move,battle|
next if target.damageState.disguise next if target.damageState.disguise
next if !PBTypeEffectiveness.superEffective?(target.damageState.typeMod) next if !Effectiveness.super_effective?(target.damageState.typeMod)
next if !target.pbCanRaiseStatStage?(:ATTACK,target) && next if !target.pbCanRaiseStatStage?(:ATTACK,target) &&
!target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,target) !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,target)
battle.pbCommonAnimation("UseItem",target) battle.pbCommonAnimation("UseItem",target)
@@ -24,7 +24,7 @@ class PokeBattle_DamageState
def reset def reset
@initialHP = 0 @initialHP = 0
@typeMod = PBTypeEffectiveness::INEFFECTIVE @typeMod = Effectiveness::INEFFECTIVE
@unaffected = false @unaffected = false
@protected = false @protected = false
@magicCoat = false @magicCoat = false
@@ -63,7 +63,7 @@ class PokeBattle_SuccessState
def initialize; clear; end def initialize; clear; end
def clear(full=true) def clear(full=true)
@typeMod = PBTypeEffectiveness::NORMAL_EFFECTIVE @typeMod = Effectiveness::NORMAL_EFFECTIVE
@useState = 0 @useState = 0
@protected = false @protected = false
@skill = 0 if full @skill = 0 if full
@@ -73,9 +73,9 @@ class PokeBattle_SuccessState
if @useState==1 if @useState==1
@skill = -2 if !@protected @skill = -2 if !@protected
elsif @useState==2 elsif @useState==2
if PBTypeEffectiveness.superEffective?(@typeMod); @skill = 2 if Effectiveness.super_effective?(@typeMod); @skill = 2
elsif PBTypeEffectiveness.normalEffective?(@typeMod); @skill = 1 elsif Effectiveness.normal?(@typeMod); @skill = 1
elsif PBTypeEffectiveness.notVeryEffective?(@typeMod); @skill = -1 elsif Effectiveness.not_very_effective?(@typeMod); @skill = -1
else; @skill = -2 # Ineffective else; @skill = -2 # Ineffective
end end
end end
@@ -835,7 +835,9 @@ class PokemonPokedex_Scene
when 0 then @sprites["searchbg"].setBitmap("Graphics/Pictures/Pokedex/bg_search_order") when 0 then @sprites["searchbg"].setBitmap("Graphics/Pictures/Pokedex/bg_search_order")
when 1 then @sprites["searchbg"].setBitmap("Graphics/Pictures/Pokedex/bg_search_name") when 1 then @sprites["searchbg"].setBitmap("Graphics/Pictures/Pokedex/bg_search_name")
when 2 when 2
if PBTypes.regularTypesCount==18 count = 0
GameData::Type.each { |t| count += 1 if !t.pseudo_type && t.id != :SHADOW }
if count == 18
@sprites["searchbg"].setBitmap("Graphics/Pictures/Pokedex/bg_search_type_18") @sprites["searchbg"].setBitmap("Graphics/Pictures/Pokedex/bg_search_type_18")
else else
@sprites["searchbg"].setBitmap("Graphics/Pictures/Pokedex/bg_search_type") @sprites["searchbg"].setBitmap("Graphics/Pictures/Pokedex/bg_search_type")
@@ -132,7 +132,7 @@ class PurifyChamberSet
# Purify Chamber treats Normal/Normal matchup as super effective # Purify Chamber treats Normal/Normal matchup as super effective
def self.typeAdvantage(p1,p2) def self.typeAdvantage(p1,p2)
return true if p1 == :NORMAL && p2 == :NORMAL return true if p1 == :NORMAL && p2 == :NORMAL
return PBTypes.superEffective?(p1,p2) return Effectiveness.super_effective_type?(p1, p2)
end end
def self.isSuperEffective(p1,p2) def self.isSuperEffective(p1,p2)
@@ -51,10 +51,10 @@ class TriadCard
end end
def bonus(opponent) def bonus(opponent)
case PBTypes.getEffectiveness(@type, opponent.type) case Effectiveness.calculate_one(@type, opponent.type)
when PBTypeEffectiveness::INEFFECTIVE then return -2 when Effectiveness::INEFFECTIVE then return -2
when PBTypeEffectiveness::NOT_EFFECTIVE_ONE then return -1 when Effectiveness::NOT_VERY_EFFECTIVE_ONE then return -1
when PBTypeEffectiveness::SUPER_EFFECTIVE_ONE then return 1 when Effectiveness::SUPER_EFFECTIVE_ONE then return 1
end end
return 0 return 0
end end
@@ -726,8 +726,9 @@ class TriadScreen
if @elements if @elements
loop do loop do
trial_type = type_keys[rand(type_keys.length)] trial_type = type_keys[rand(type_keys.length)]
next if PBTypes.isPseudoType?(trial_type) type_data = GameData::Type.get(trial_type)
square.type = GameData::Type.get(trial_type).id next if type_data.pseudo_type
square.type = type_data.id
break break
end end
end end
@@ -773,13 +773,13 @@ def pbDecideWinnerEffectiveness(move, otype1, otype2, ability, scores)
data = GameData::Move.get(move) data = GameData::Move.get(move)
return 0 if data.base_damage == 0 return 0 if data.base_damage == 0
atype = data.type atype = data.type
typemod = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE * PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE typemod = Effectiveness::NORMAL_EFFECTIVE_ONE ** 2
if ability != :LEVITATE || data.type != :GROUND if ability != :LEVITATE || data.type != :GROUND
mod1 = PBTypes.getEffectiveness(atype, otype1) mod1 = Effectiveness.calculate_one(atype, otype1)
mod2 = (otype1 == otype2) ? PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE : PBTypes.getEffectiveness(atype, otype2) mod2 = (otype1 == otype2) ? Effectiveness::NORMAL_EFFECTIVE_ONE : Effectiveness.calculate_one(atype, otype2)
if ability == :WONDERGUARD if ability == :WONDERGUARD
mod1 = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if mod1 <= PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE mod1 = Effectiveness::NORMAL_EFFECTIVE_ONE if mod1 <= Effectiveness::NORMAL_EFFECTIVE_ONE
mod2 = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if mod2 <= PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE mod2 = Effectiveness::NORMAL_EFFECTIVE_ONE if mod2 <= Effectiveness::NORMAL_EFFECTIVE_ONE
end end
typemod = mod1 * mod2 typemod = mod1 * mod2
end end