diff --git a/Data/CommonEvents.rxdata b/Data/CommonEvents.rxdata index 20d8e8f84..77966b330 100644 Binary files a/Data/CommonEvents.rxdata and b/Data/CommonEvents.rxdata differ diff --git a/Data/Map001.rxdata b/Data/Map001.rxdata index 4718bd45f..8de12b105 100644 Binary files a/Data/Map001.rxdata and b/Data/Map001.rxdata differ diff --git a/Data/Map010.rxdata b/Data/Map010.rxdata index cbceaeb8d..1312406b3 100644 Binary files a/Data/Map010.rxdata and b/Data/Map010.rxdata differ diff --git a/Data/Map129.rxdata b/Data/Map129.rxdata index 712a3d3d8..0f071b7ae 100644 Binary files a/Data/Map129.rxdata and b/Data/Map129.rxdata differ diff --git a/Data/Map495.rxdata b/Data/Map495.rxdata index c11176d37..85bfcd7ad 100644 Binary files a/Data/Map495.rxdata and b/Data/Map495.rxdata differ diff --git a/Data/MapInfos.rxdata b/Data/MapInfos.rxdata index a4bf549b8..018ef966c 100644 Binary files a/Data/MapInfos.rxdata and b/Data/MapInfos.rxdata differ diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index a9a6a2d1c..1566587d9 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -238,7 +238,7 @@ module Settings # Dex list, no matter which region the player is currently in. def self.pokedex_names return [ - [_INTL("Kanto Pokédex"), 0] + # [_INTL("Kanto Pokédex"), 0] ] end diff --git a/Data/Scripts/015_Trainers and player/005_Player_Pokedex.rb b/Data/Scripts/015_Trainers and player/005_Player_Pokedex.rb index c99d18dce..8d6655aaf 100644 --- a/Data/Scripts/015_Trainers and player/005_Player_Pokedex.rb +++ b/Data/Scripts/015_Trainers and player/005_Player_Pokedex.rb @@ -26,10 +26,12 @@ class Player < Trainer @owned = {} #deprecated @seen_standard = initStandardDexArray() - @owned_standard = initStandardDexArray() - @seen_fusion = initFusionDexArray() + @seen_triple = {} + + @owned_standard = initStandardDexArray() @owned_fusion = initFusionDexArray() + @owned_triple = {} @seen_forms = {} @last_seen_forms = {} @@ -39,62 +41,63 @@ class Player < Trainer def initStandardDexArray() dex_array = [] - for poke in 0..NB_POKEMON + (0..NB_POKEMON).each { |poke| if poke == 0 dex_array << nil end dex_array << false - end + } return dex_array end def initFusionDexArray() head_array = [] - for head in 0..NB_POKEMON + (0..NB_POKEMON).each { |head| body_array = [] if head == 0 head_array << nil end - for body in 0..NB_POKEMON + (0..NB_POKEMON).each { |body| if body == 0 body_array << nil end body_array << false - end + } head_array << body_array - end + } return head_array end - def isFusion(species) - num = getDexNumberForSpecies(species) - return num > Settings::NB_POKEMON && num < Settings::ZAPMOLCUNO_NB + def isTripleFusion(num) + return num >= Settings::ZAPMOLCUNO_NB end - #=========================================================================== + def isFusion(num) + return num > Settings::NB_POKEMON && !isTripleFusion(num) + end - # Sets the given species as seen in the Pokédex. - # @param species [Symbol, GameData::Species] species to set as seen - # @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated def set_seen_fusion(species) bodyId = getBodyID(species) headId = getHeadID(species, bodyId) @seen_fusion[headId][bodyId] = true end - - # def set_seen_normalDex(species) - # species_id = GameData::Species.try_get(species)&.species - # return if species_id.nil? - # @seen[species_id] = true - # end def set_seen_normalDex(species) dex_num = getDexNumberForSpecies(species) @seen_standard[dex_num] = true end + def set_seen_triple(species) + species_id = GameData::Species.try_get(species)&.species + return if species_id.nil? + @seen_triple[species_id] = true + end + def set_seen(species, should_refresh_dexes = true) - if isFusion(species) + dexNum = getDexNumberForSpecies(species) + if isTripleFusion(dexNum) + set_seen_triple(species) + elsif isFusion(dexNum) set_seen_fusion(species) else set_seen_normalDex(species) @@ -120,18 +123,23 @@ class Player < Trainer return @seen_standard[getDexNumberForSpecies(species)] end + def seen_triple?(species) + species_id = GameData::Species.try_get(species)&.species + return false if species_id.nil? + return @seen_triple[species_id] + end + def seen?(species) - if isFusion(species) + num = getDexNumberForSpecies(species) + if isTripleFusion(num) + return seen_triple?(species) + elsif isFusion(num) return seen_fusion?(species) else return seen_normalDex?(species) end end - # @param species [Symbol, GameData::Species] species to check - # @param gender [Integer] gender to check - # @param form [Integer] form to check - # @return [Boolean] whether the species of the given gender and form is seen def seen_form?(species, gender, form) return false # species_id = GameData::Species.try_get(species)&.species @@ -145,10 +153,10 @@ class Player < Trainer # in that region. # @param dex [Integer] region ID def seen_count(dex = -1) - if @seen_standard == nil || @owned_standard == nil + if dex_sync_needed?() resync_pokedex() end - count_dex(@seen_standard,@seen_fusion) + return count_dex(@seen_standard, @seen_fusion) + @owned_triple.size end # Returns whether there are any seen Pokémon. @@ -160,35 +168,12 @@ class Player < Trainer return seen_count >= 1 end - # def seen_any?(dex = -1) - # validate dex => Integer - # if dex == -1 - # GameData::Species.each { |s| return true if s.form == 0 && @seen[s.species] } - # else - # pbAllRegionalSpecies(dex).each { |s| return true if s && @seen[s] } - # end - # return false - # end - - # Returns the amount of seen forms for the given species. # @param species [Symbol, GameData::Species] Pokémon species # @return [Integer] amount of seen forms def seen_forms_count(species) return 0 end - # def seen_forms_count(species) - # species_id = GameData::Species.try_get(species)&.species - # return 0 if species_id.nil? - # ret = 0 - # @seen_forms[species_id] ||= [[], []] - # array = @seen_forms[species_id] - # for i in 0...[array[0].length, array[1].length].max - # ret += 1 if array[0][i] || array[1][i] - # end - # return ret - # end - # @param species [Symbol, GameData::Species] Pokémon species def last_form_seen(species) @@ -214,18 +199,21 @@ class Player < Trainer @owned_fusion[headId][bodyId] = true end + def set_owned_triple(species) + species_id = GameData::Species.try_get(species)&.species + return if species_id.nil? + @owned_triple[species_id] = true + end - # def set_owned_normalDex(species) - # species_id = GameData::Species.try_get(species)&.species - # return if species_id.nil? - # @owned[species_id] = true - # end def set_owned_normalDex(species) @owned_standard[getDexNumberForSpecies(species)] = true end def set_owned(species, should_refresh_dexes = true) - if isFusion(species) + dexNum = getDexNumberForSpecies(species) + if isTripleFusion(dexNum) + set_owned_triple(species) + elsif isFusion(dexNum) set_owned_fusion(species) else set_owned_normalDex(species) @@ -237,10 +225,6 @@ class Player < Trainer # @param species [Symbol, GameData::Species] species to set as owned def set_shadow_pokemon_owned(species) return - # species_id = GameData::Species.try_get(species)&.species - # return if species_id.nil? - # @owned_shadow[species_id] = true - # self.refresh_accessible_dexes end # @param species [Symbol, GameData::Species] species to check @@ -251,29 +235,31 @@ class Player < Trainer return @owned_fusion[headId][bodyId] == true end + def owned_triple?(species) + species_id = GameData::Species.try_get(species)&.species + return false if species_id.nil? + return @owned_triple[species_id] + end + def owned?(species) - if isFusion(species) + num = getDexNumberForSpecies(species) + if isTripleFusion(num) + return owned_triple?(species) + elsif isFusion(num) return owned_fusion?(species) else return owned_normalDex?(species) end end - # def owned_normalDex?(species) - # species_id = GameData::Species.try_get(species)&.species - # return false if species_id.nil? - # return @owned[species_id] == true - # end def owned_normalDex?(species) return @owned_standard[getDexNumberForSpecies(species)] end + # @param species [Symbol, GameData::Species] species to check # @return [Boolean] whether a Shadow Pokémon of the species is owned def owned_shadow_pokemon?(species) return - # species_id = GameData::Species.try_get(species)&.species - # return false if species_id.nil? - # return @owned_shadow[species_id] == true end # Returns the amount of owned Pokémon. @@ -281,45 +267,82 @@ class Player < Trainer # in that region. # @param region [Integer] region ID def owned_count(dex = -1) - if @owned_standard == nil || @owned_fusion == nil + if dex_sync_needed?() resync_pokedex() end - count_dex(@owned_standard,@owned_fusion) - # - # validate dex => Integer - # return self.count_species(@owned, dex) + return count_dex(@owned_standard, @owned_fusion) + @owned_triple.size end - def count_dex(standardList,fusedList) + def count_dex(standardList, fusedList) owned_standard = count_true(standardList) owned_fused = 0 - for head_poke_list in fusedList + fusedList.each { |head_poke_list| if head_poke_list != nil owned_fused += count_true(head_poke_list) end - end + } return owned_standard + owned_fused end def count_true(list) - count=0 - for owned in list + count = 0 + list.each { |owned| if owned - count+=1 + count += 1 end - end + } return count end + def dex_sync_needed?() + return @owned_standard == nil || @owned_fusion == nil || @owned_triple == nil + end #todo: # loop on @owned and @seen and add the pokemon in @owned_standard/fusion @seen_standard/fusion # then clear @owned and @seen def resync_pokedex() - self.clear + Kernel.pbMessage(_INTL("Syncing Pokédex... This might take some time.")) + init_new_pokedex_if_needed() + + @seen.each { |pokemon| + set_seen(pokemon[0]) + } + @owned.each { |pokemon| + set_owned(pokemon[0]) + } + + self.refresh_accessible_dexes + + @seen = {} #deprecated + @owned = {} #deprecated + #self.clear end + def resync_boxes_to_pokedex + $PokemonStorage.boxes.each { |box| + box.pokemon.each { |pokemon| + if pokemon != nil + if !pokemon.egg? + set_owned(pokemon.species) + set_seen(pokemon.species) + end + end + } + } + end + + def init_new_pokedex_if_needed() + @seen_standard = initStandardDexArray() if @seen_standard == nil + @seen_fusion = initFusionDexArray() if @seen_fusion == nil + @seen_triple = {} if @seen_triple == nil + + @owned_standard = initStandardDexArray() if @owned_standard == nil + @owned_fusion = initFusionDexArray() if @owned_fusion == nil + @owned_triple = {} if @owned_triple == nil + end + #=========================================================================== # @param pkmn [Pokemon, Symbol, GameData::Species] Pokemon to register as seen @@ -327,16 +350,6 @@ class Player < Trainer # @param form [Integer] form to register def register(species, gender = 0, form = 0, should_refresh_dexes = true) set_seen(species, should_refresh_dexes) - # return - # if species.is_a?(Pokemon) - # species_data = species.species_data - # #gender = species.gender - # else - # species_data = GameData::Species.get(species) - # end - # species = species_data.species - # @seen[species] = true - # self.refresh_accessible_dexes if should_refresh_dexes end # @param pkmn [Pokemon] Pokemon to register as most recently seen @@ -372,9 +385,10 @@ class Player < Trainer # @param dex [Integer] Dex ID (-1 is the National Dex) # @return [Boolean] whether the given Dex is unlocked def unlocked?(dex) - validate dex => Integer - dex = @unlocked_dexes.length - 1 if dex == -1 - return @unlocked_dexes[dex] == true + return dex == -1 + # validate dex => Integer + # dex = @unlocked_dexes.length - 1 if dex == -1 + # return @unlocked_dexes[dex] == true end # @return [Integer] the number of defined Dexes (including the National Dex) @@ -390,25 +404,8 @@ class Player < Trainer # if a species in the current region has been seen - doesn't look at other # regions. def refresh_accessible_dexes - @accessible_dexes = [] - if Settings::USE_CURRENT_REGION_DEX - region = pbGetCurrentRegion - region = -1 if region >= dexes_count - 1 - @accessible_dexes[0] = region if self.seen_any?(region) - return - end - if dexes_count == 1 # Only National Dex is defined - if self.unlocked?(0) && self.seen_any? - @accessible_dexes.push(-1) - end - else - # Regional Dexes + National Dex - for i in 0...dexes_count - dex_list_to_check = (i == dexes_count - 1) ? -1 : i - if self.unlocked?(i) && self.seen_any?(dex_list_to_check) - @accessible_dexes.push(dex_list_to_check) - end - end + if self.unlocked?(0) && self.seen_any? + @accessible_dexes.push(-1) end end @@ -421,13 +418,6 @@ class Player < Trainer # @return [Integer] def count_species(hash, region = -1) return hash.size() - # ret = 0 - # if region == -1 - # GameData::Species.each { |s| ret += 1 if s.form == 0 && hash[s.species] } - # else - # pbAllRegionalSpecies(region).each { |s| ret += 1 if s && hash[s] } - # end - # return ret end end end diff --git a/Data/Scripts/016_UI/001_UI_PauseMenu.rb b/Data/Scripts/016_UI/001_UI_PauseMenu.rb index 6d43a0a6a..d304f0f33 100644 --- a/Data/Scripts/016_UI/001_UI_PauseMenu.rb +++ b/Data/Scripts/016_UI/001_UI_PauseMenu.rb @@ -156,7 +156,7 @@ class PokemonPauseMenu @scene.pbRefresh } else - if $Trainer.pokedex.accessible_dexes.length == 1 + #if $Trainer.pokedex.accessible_dexes.length == 1 $PokemonGlobal.pokedexDex = $Trainer.pokedex.accessible_dexes[0] pbFadeOutIn { scene = PokemonPokedex_Scene.new @@ -164,14 +164,14 @@ class PokemonPauseMenu screen.pbStartScreen @scene.pbRefresh } - else - pbFadeOutIn { - scene = PokemonPokedexMenu_Scene.new - screen = PokemonPokedexMenuScreen.new(scene) - screen.pbStartScreen - @scene.pbRefresh - } - end + # else + # pbFadeOutIn { + # scene = PokemonPokedexMenu_Scene.new + # screen = PokemonPokedexMenuScreen.new(scene) + # screen.pbStartScreen + # @scene.pbRefresh + # } + # end end elsif cmdPokemon>=0 && command==cmdPokemon pbPlayDecisionSE diff --git a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb index 1b35d463c..693fcea9a 100644 --- a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb +++ b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb @@ -25,7 +25,7 @@ class Window_Pokedex < Window_DrawableCommand end def species - if self.index > @commands.size + if self.index > @commands.size-1 self.index = 0 end current_position= self.index diff --git a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb index 7c93ddc38..230dabe24 100644 --- a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb +++ b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb @@ -124,7 +124,9 @@ class PokemonPokedexInfo_Scene def pbUpdateDummyPokemon @species = @dexlist[@index][0] @gender, @form = $Trainer.pokedex.last_form_seen(@species) - species_data = GameData::Species.get_species_form(@species, @form) + + # species_data = pbGetSpeciesData(@species) + species_data = GameData::Species.get_species_form(@species, @form) @sprites["infosprite"].setSpeciesBitmap(@species,@gender,@form) if @sprites["formfront"] @sprites["formfront"].setSpeciesBitmap(@species,@gender,@form) @@ -141,42 +143,43 @@ class PokemonPokedexInfo_Scene def pbGetAvailableForms ret = [] - multiple_forms = false - # Find all genders/forms of @species that have been seen - GameData::Species.each do |sp| - next if sp.species != @species - next if sp.form != 0 && (!sp.real_form_name || sp.real_form_name.empty?) - next if sp.pokedex_form != sp.form - multiple_forms = true if sp.form > 0 - case sp.gender_ratio - when :AlwaysMale, :AlwaysFemale, :Genderless - real_gender = (sp.gender_ratio == :AlwaysFemale) ? 1 : 0 - next if !$Trainer.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS - real_gender = 2 if sp.gender_ratio == :Genderless - ret.push([sp.form_name, real_gender, sp.form]) - else # Both male and female - for real_gender in 0...2 - next if !$Trainer.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS - ret.push([sp.form_name, real_gender, sp.form]) - break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form - end - end - end - # Sort all entries - ret.sort! { |a, b| (a[2] == b[2]) ? a[1] <=> b[1] : a[2] <=> b[2] } - # Create form names for entries if they don't already exist - ret.each do |entry| - if !entry[0] || entry[0].empty? # Necessarily applies only to form 0 - case entry[1] - when 0 then entry[0] = _INTL("Male") - when 1 then entry[0] = _INTL("Female") - else - entry[0] = (multiple_forms) ? _INTL("One Form") : _INTL("Genderless") - end - end - entry[1] = 0 if entry[1] == 2 # Genderless entries are treated as male - end return ret + # multiple_forms = false + # # Find all genders/forms of @species that have been seen + # GameData::Species.each do |sp| + # next if sp.species != @species + # next if sp.form != 0 && (!sp.real_form_name || sp.real_form_name.empty?) + # next if sp.pokedex_form != sp.form + # multiple_forms = true if sp.form > 0 + # case sp.gender_ratio + # when :AlwaysMale, :AlwaysFemale, :Genderless + # real_gender = (sp.gender_ratio == :AlwaysFemale) ? 1 : 0 + # next if !$Trainer.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS + # real_gender = 2 if sp.gender_ratio == :Genderless + # ret.push([sp.form_name, real_gender, sp.form]) + # else # Both male and female + # for real_gender in 0...2 + # next if !$Trainer.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS + # ret.push([sp.form_name, real_gender, sp.form]) + # break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form + # end + # end + # end + # # Sort all entries + # ret.sort! { |a, b| (a[2] == b[2]) ? a[1] <=> b[1] : a[2] <=> b[2] } + # # Create form names for entries if they don't already exist + # ret.each do |entry| + # if !entry[0] || entry[0].empty? # Necessarily applies only to form 0 + # case entry[1] + # when 0 then entry[0] = _INTL("Male") + # when 1 then entry[0] = _INTL("Female") + # else + # entry[0] = (multiple_forms) ? _INTL("One Form") : _INTL("Genderless") + # end + # end + # entry[1] = 0 if entry[1] == 2 # Genderless entries are treated as male + # end + # return ret end def drawPage(page) diff --git a/Data/System.rxdata b/Data/System.rxdata index b8bc6ff32..c8407f09c 100644 Binary files a/Data/System.rxdata and b/Data/System.rxdata differ