diff --git a/Data/Scripts/010_Data/001_Hardcoded data/007_Evolution.rb b/Data/Scripts/010_Data/001_Hardcoded data/007_Evolution.rb index 4bc41d89a..de2548bea 100644 --- a/Data/Scripts/010_Data/001_Hardcoded data/007_Evolution.rb +++ b/Data/Scripts/010_Data/001_Hardcoded data/007_Evolution.rb @@ -645,7 +645,7 @@ GameData::Evolution.register({ #=============================================================================== def pbEvolutionEvent(number) return if !$player - $player.able_pokemon_party.each do |pkmn| + $player.able_party.each do |pkmn| pkmn.trigger_event_evolution(number) end end diff --git a/Data/Scripts/010_Data/002_PBS data/008_Species.rb b/Data/Scripts/010_Data/002_PBS data/008_Species.rb index 9071925db..df236109d 100644 --- a/Data/Scripts/010_Data/002_PBS data/008_Species.rb +++ b/Data/Scripts/010_Data/002_PBS data/008_Species.rb @@ -8,8 +8,7 @@ module GameData attr_reader :real_category attr_reader :real_pokedex_entry attr_reader :pokedex_form - attr_reader :type1 - attr_reader :type2 + attr_reader :types attr_reader :base_stats attr_reader :evs attr_reader :base_exp @@ -77,8 +76,7 @@ module GameData "FormName" => [0, "q"], "Category" => [0, "s"], "Pokedex" => [0, "q"], - "Type1" => [0, "e", :Type], - "Type2" => [0, "e", :Type], + "Types" => [0, "eE", :Type, :Type], "BaseStats" => [0, "vvvvvv"], "EVs" => [0, "uuuuuu"], "BaseExp" => [0, "v"], @@ -110,6 +108,8 @@ module GameData "BattlerShadowSize" => [0, "u"], # All properties below here are old names for some properties above. # They will be removed in v21. + "Type1" => [0, "e", :Type], + "Type2" => [0, "e", :Type], "Rareness" => [0, "u"], "Compatibility" => [0, "*e", :EggGroup], "Kind" => [0, "s"], @@ -142,51 +142,50 @@ module GameData end def initialize(hash) - @id = hash[:id] - @species = hash[:species] || @id - @form = hash[:form] || 0 - @real_name = hash[:name] || "Unnamed" - @real_form_name = hash[:form_name] - @real_category = hash[:category] || "???" - @real_pokedex_entry = hash[:pokedex_entry] || "???" - @pokedex_form = hash[:pokedex_form] || @form - @type1 = hash[:type1] || :NORMAL - @type2 = hash[:type2] || @type1 - @base_stats = hash[:base_stats] || {} - @evs = hash[:evs] || {} + @id = hash[:id] + @species = hash[:species] || @id + @form = hash[:form] || 0 + @real_name = hash[:name] || "Unnamed" + @real_form_name = hash[:form_name] + @real_category = hash[:category] || "???" + @real_pokedex_entry = hash[:pokedex_entry] || "???" + @pokedex_form = hash[:pokedex_form] || @form + @types = hash[:types] || [:NORMAL] + @base_stats = hash[:base_stats] || {} + @evs = hash[:evs] || {} GameData::Stat.each_main do |s| @base_stats[s.id] = 1 if !@base_stats[s.id] || @base_stats[s.id] <= 0 @evs[s.id] = 0 if !@evs[s.id] || @evs[s.id] < 0 end - @base_exp = hash[:base_exp] || 100 - @growth_rate = hash[:growth_rate] || :Medium - @gender_ratio = hash[:gender_ratio] || :Female50Percent - @catch_rate = hash[:catch_rate] || 255 - @happiness = hash[:happiness] || 70 - @moves = hash[:moves] || [] - @tutor_moves = hash[:tutor_moves] || [] - @egg_moves = hash[:egg_moves] || [] - @abilities = hash[:abilities] || [] - @hidden_abilities = hash[:hidden_abilities] || [] - @wild_item_common = hash[:wild_item_common] || [] - @wild_item_uncommon = hash[:wild_item_uncommon] || [] - @wild_item_rare = hash[:wild_item_rare] || [] - @egg_groups = hash[:egg_groups] || [:Undiscovered] - @hatch_steps = hash[:hatch_steps] || 1 - @incense = hash[:incense] - @offspring = hash[:offspring] || [] - @evolutions = hash[:evolutions] || [] - @height = hash[:height] || 1 - @weight = hash[:weight] || 1 - @color = hash[:color] || :Red - @shape = hash[:shape] || :Head - @habitat = hash[:habitat] || :None - @generation = hash[:generation] || 0 - @flags = hash[:flags] || [] - @mega_stone = hash[:mega_stone] - @mega_move = hash[:mega_move] - @unmega_form = hash[:unmega_form] || 0 - @mega_message = hash[:mega_message] || 0 + @base_exp = hash[:base_exp] || 100 + @growth_rate = hash[:growth_rate] || :Medium + @gender_ratio = hash[:gender_ratio] || :Female50Percent + @catch_rate = hash[:catch_rate] || 255 + @happiness = hash[:happiness] || 70 + @moves = hash[:moves] || [] + @tutor_moves = hash[:tutor_moves] || [] + @egg_moves = hash[:egg_moves] || [] + @abilities = hash[:abilities] || [] + @hidden_abilities = hash[:hidden_abilities] || [] + @wild_item_common = hash[:wild_item_common] || [] + @wild_item_uncommon = hash[:wild_item_uncommon] || [] + @wild_item_rare = hash[:wild_item_rare] || [] + @egg_groups = hash[:egg_groups] || [:Undiscovered] + @hatch_steps = hash[:hatch_steps] || 1 + @incense = hash[:incense] + @offspring = hash[:offspring] || [] + @evolutions = hash[:evolutions] || [] + @height = hash[:height] || 1 + @weight = hash[:weight] || 1 + @color = hash[:color] || :Red + @shape = hash[:shape] || :Head + @habitat = hash[:habitat] || :None + @generation = hash[:generation] || 0 + @flags = hash[:flags] || [] + @mega_stone = hash[:mega_stone] + @mega_move = hash[:mega_move] + @unmega_form = hash[:unmega_form] || 0 + @mega_message = hash[:mega_message] || 0 end # @return [String] the translated name of this species diff --git a/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb b/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb index 5550c089e..591c9b614 100644 --- a/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb +++ b/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb @@ -6,8 +6,7 @@ class Battle::Battler attr_reader :pokemon attr_accessor :pokemonIndex attr_accessor :species - attr_accessor :type1 - attr_accessor :type2 + attr_accessor :types attr_accessor :ability_id attr_accessor :item_id attr_accessor :moves @@ -304,8 +303,7 @@ class Battle::Battler # same type more than once, and should not include any invalid type numbers # (e.g. -1). def pbTypes(withType3=false) - ret = [@type1] - ret.push(@type2) if @type2!=@type1 + ret = @types.clone # Burn Up erases the Fire-type. ret.delete(:FIRE) if @effects[PBEffects::BurnUp] # Roost erases the Flying-type. If there are no types left, adds the Normal- diff --git a/Data/Scripts/011_Battle/002_Battler/002_Battler_Initialize.rb b/Data/Scripts/011_Battle/002_Battler/002_Battler_Initialize.rb index db9497cfe..3e5595d32 100644 --- a/Data/Scripts/011_Battle/002_Battler/002_Battler_Initialize.rb +++ b/Data/Scripts/011_Battle/002_Battler/002_Battler_Initialize.rb @@ -20,7 +20,7 @@ class Battle::Battler @form = 0 @level = 0 @hp = @totalhp = 0 - @type1 = @type2 = nil + @types = [] @ability_id = nil @item_id = nil @gender = 0 @@ -44,8 +44,7 @@ class Battle::Battler @level = pkmn.level @hp = pkmn.hp @totalhp = pkmn.totalhp - @type1 = pkmn.type1 - @type2 = pkmn.type2 + @types = pkmn.types # ability and item intentionally not copied across here @gender = pkmn.gender @attack = pkmn.attack @@ -78,8 +77,7 @@ class Battle::Battler @level = pkmn.level @hp = pkmn.hp @totalhp = pkmn.totalhp - @type1 = pkmn.type1 - @type2 = pkmn.type2 + @types = pkmn.types @ability_id = pkmn.ability_id @item_id = pkmn.item_id @gender = pkmn.gender @@ -312,8 +310,7 @@ class Battle::Battler @spdef = @pokemon.spdef @speed = @pokemon.speed if fullChange - @type1 = @pokemon.type1 - @type2 = @pokemon.type2 + @types = @pokemon.types @ability_id = @pokemon.ability_id end end diff --git a/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb b/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb index fe860f55e..9d19dd565 100644 --- a/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb +++ b/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb @@ -127,13 +127,11 @@ class Battle::Battler newTypes.push(:NORMAL) if newTypes.length == 0 newType3 = newType.effects[PBEffects::Type3] newType3 = nil if newTypes.include?(newType3) - @type1 = newTypes[0] - @type2 = (newTypes.length == 1) ? newTypes[0] : newTypes[1] + @types = newTypes.clone @effects[PBEffects::Type3] = newType3 else newType = GameData::Type.get(newType).id - @type1 = newType - @type2 = newType + @types = [newType] @effects[PBEffects::Type3] = nil end @effects[PBEffects::BurnUp] = false @@ -141,8 +139,7 @@ class Battle::Battler end def pbResetTypes - @type1 = @pokemon.type1 - @type2 = @pokemon.type2 + @types = @pokemon.types @effects[PBEffects::Type3] = nil @effects[PBEffects::BurnUp] = false @effects[PBEffects::Roost] = false diff --git a/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb b/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb index d54fb9cd9..1538c3dca 100644 --- a/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb +++ b/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb @@ -2458,8 +2458,8 @@ class Battle::AI when "UseTargetDefenseInsteadOfTargetSpDef" #--------------------------------------------------------------------------- when "FailsUnlessTargetSharesTypeWithUser" - if !target.pbHasType?(user.type1) && - !target.pbHasType?(user.type2) + if !(user.types[0] && target.pbHasType?(user.types[0])) && + !(user.types[1] && target.pbHasType?(user.types[1])) score -= 90 end #--------------------------------------------------------------------------- diff --git a/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb b/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb index 43ee57e63..32130f21f 100644 --- a/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb +++ b/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb @@ -82,10 +82,10 @@ class Battle::AI # For switching. Determines the effectiveness of a potential switch-in against # an opposing battler. def pbCalcTypeModPokemon(battlerThis,_battlerOther) - mod1 = Effectiveness.calculate(battlerThis.type1,target.type1,target.type2) + mod1 = Effectiveness.calculate(battlerThis.types[0], target.types[0], target.types[1]) mod2 = Effectiveness::NORMAL_EFFECTIVE - if battlerThis.type1!=battlerThis.type2 - mod2 = Effectiveness.calculate(battlerThis.type2,target.type1,target.type2) + if battlerThis.types.length > 1 + mod2 = Effectiveness.calculate(battlerThis.types[1], target.types[0], target.types[1]) mod2 = mod2.to_f / Effectivenesss::NORMAL_EFFECTIVE end return mod1*mod2 @@ -275,7 +275,7 @@ class Battle::AI baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round else mult = Effectiveness.calculate(:FLYING, - target.type1,target.type2,target.effects[PBEffects::Type3]) + target.types[0], target.types[1], target.effects[PBEffects::Type3]) baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round end end diff --git a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb index f21014c92..360ce7d6f 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb @@ -2590,19 +2590,17 @@ Battle::AbilityEffects::OnSwitchIn.add(:ANTICIPATION, proc { |ability,battler,battle| next if !battler.pbOwnedByPlayer? battlerTypes = battler.pbTypes(true) - type1 = battlerTypes[0] - type2 = battlerTypes[1] || type1 - type3 = battlerTypes[2] || type2 + types = battlerTypes found = false battle.allOtherSideBattlers(battler.index).each do |b| b.eachMove do |m| next if m.statusMove? - if type1 + if types.length > 0 moveType = m.type if Settings::MECHANICS_GENERATION >= 6 && m.function == "TypeDependsOnUserIVs" # Hidden Power moveType = pbHiddenPower(b.pokemon)[0] end - eff = Effectiveness.calculate(moveType,type1,type2,type3) + eff = Effectiveness.calculate(moveType, types[0], types[1], types[2]) next if Effectiveness.ineffective?(eff) next if !Effectiveness.super_effective?(eff) && !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function) diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/003_Overworld_WildEncounters.rb b/Data/Scripts/012_Overworld/002_Battle triggering/003_Overworld_WildEncounters.rb index 3e6952ae3..c333082f5 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/003_Overworld_WildEncounters.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/003_Overworld_WildEncounters.rb @@ -305,9 +305,7 @@ class PokemonEncounters new_enc_list = [] enc_list.each do |enc| species_data = GameData::Species.get(enc[1]) - t1 = species_data.type1 - t2 = species_data.type2 - new_enc_list.push(enc) if t1 == favored_type || t2 == favored_type + new_enc_list.push(enc) if species_data.types.include?(favored_type) end enc_list = new_enc_list if new_enc_list.length > 0 end diff --git a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb index ead5445f7..9ad99745b 100644 --- a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb +++ b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb @@ -192,9 +192,9 @@ class BerryPlantMoistureSprite def update_graphic case @moisture_stage when -1 then @sprite.setBitmap("") - when 0 then @sprite.setBitmap("Graphics/Characters/berrytreeDry") - when 1 then @sprite.setBitmap("Graphics/Characters/berrytreeDamp") - when 2 then @sprite.setBitmap("Graphics/Characters/berrytreeWet") + when 0 then @sprite.setBitmap("Graphics/Characters/berrytreedry") + when 1 then @sprite.setBitmap("Graphics/Characters/berrytreedamp") + when 2 then @sprite.setBitmap("Graphics/Characters/berrytreewet") end end diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb index 8eb68588a..1ef7e20c6 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb @@ -192,10 +192,7 @@ class Battle::Battler __shadow__pbInitPokemon(*arg) # Called into battle if shadowPokemon? - if GameData::Type.exists?(:SHADOW) - self.type1 = :SHADOW - self.type2 = :SHADOW - end + self.types = [:SHADOW] if GameData::Type.exists?(:SHADOW) self.pokemon.change_heart_gauge("battle") if pbOwnedByPlayer? end end diff --git a/Data/Scripts/014_Pokemon/001_Pokemon.rb b/Data/Scripts/014_Pokemon/001_Pokemon.rb index 02e38b522..25352229d 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon.rb @@ -304,23 +304,21 @@ class Pokemon # Types #============================================================================= - # @return [Symbol] this Pokémon's first type - def type1 - return species_data.type1 - end - - # @return [Symbol] this Pokémon's second type, or the first type if none is defined - def type2 - sp_data = species_data - return sp_data.type2 || sp_data.type1 - end - # @return [Array] an array of this Pokémon's types def types - sp_data = species_data - ret = [sp_data.type1] - ret.push(sp_data.type2) if sp_data.type2 && sp_data.type2 != sp_data.type1 - return ret + return species_data.types.clone + end + + # @deprecated This method is slated to be removed in v21. + def type1 + Deprecation.warn_method('type1', 'v21', 'pkmn.types') + return types[0] + end + + # @deprecated This method is slated to be removed in v21. + def type2 + Deprecation.warn_method('type2', 'v21', 'pkmn.types') + return types[1] || types[0] end # @param type [Symbol, String, GameData::Type] type to check diff --git a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb index 471c10b32..80083eaa1 100644 --- a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb +++ b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb @@ -359,8 +359,8 @@ class PokemonPokedex_Scene _gender, form = $player.pokedex.last_form_seen(species) species_data = GameData::Species.get_species_form(species, form) color = species_data.color - type1 = species_data.type1 - type2 = species_data.type2 || type1 + type1 = species_data.types[0] + type2 = species_data.types[1] || type1 shape = species_data.shape height = species_data.height weight = species_data.weight diff --git a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb index 4360a9736..0cd5c4e71 100644 --- a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb +++ b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb @@ -258,14 +258,11 @@ class PokemonPokedexInfo_Scene # Show the owned icon imagepos.push(["Graphics/Pictures/Pokedex/icon_own", 212, 44]) # Draw the type icon(s) - type1 = species_data.type1 - type2 = species_data.type2 - type1_number = GameData::Type.get(type1).icon_position - type2_number = GameData::Type.get(type2).icon_position - type1rect = Rect.new(0, type1_number * 32, 96, 32) - type2rect = Rect.new(0, type2_number * 32, 96, 32) - overlay.blt(296, 120, @typebitmap.bitmap, type1rect) - overlay.blt(396, 120, @typebitmap.bitmap, type2rect) if type1 != type2 + species_data.types.each_with_index do |type, i| + type_number = GameData::Type.get(type).icon_position + type_rect = Rect.new(0, type_number * 32, 96, 32) + overlay.blt(296 + 100 * i, 120, @typebitmap.bitmap, type_rect) + end else # Write the category textpos.push([_INTL("????? Pokémon"), 246, 68, 0, base, shadow]) diff --git a/Data/Scripts/016_UI/006_UI_Summary.rb b/Data/Scripts/016_UI/006_UI_Summary.rb index dc92cbcf6..8b48a877e 100644 --- a/Data/Scripts/016_UI/006_UI_Summary.rb +++ b/Data/Scripts/016_UI/006_UI_Summary.rb @@ -452,15 +452,11 @@ class PokemonSummary_Scene # Draw all text pbDrawTextPositions(overlay,textpos) # Draw Pokémon type(s) - type1_number = GameData::Type.get(@pokemon.type1).icon_position - type2_number = GameData::Type.get(@pokemon.type2).icon_position - type1rect = Rect.new(0, type1_number * 28, 64, 28) - type2rect = Rect.new(0, type2_number * 28, 64, 28) - if @pokemon.type1==@pokemon.type2 - overlay.blt(402,146,@typebitmap.bitmap,type1rect) - else - overlay.blt(370,146,@typebitmap.bitmap,type1rect) - overlay.blt(436,146,@typebitmap.bitmap,type2rect) + @pokemon.types.each_with_index do |type, i| + type_number = GameData::Type.get(type).icon_position + type_rect = Rect.new(0, type_number * 28, 64, 28) + type_x = (@pokemon.types.length == 1) ? 402 : 370 + 66 * i + overlay.blt(type_x, 146, @typebitmap.bitmap, type_rect) end # Draw Exp bar if @pokemon.level