From 026e6f5c0a73da0be218fcba17683ea20a3fdc47 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sun, 3 Apr 2022 19:06:56 +0100 Subject: [PATCH] =?UTF-8?q?Added=20a=20Setting=20that=20makes=20a=20new=20?= =?UTF-8?q?Pok=C3=A9mon's=20Pok=C3=A9dex=20entry=20show=20after=20evolutio?= =?UTF-8?q?n,=20trading,=20hatching,=20gaining=20from=20Mystery=20Gift=20a?= =?UTF-8?q?nd=20general=20adding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/Scripts/001_Settings.rb | 4 ++ .../003_UI_EggHatching.rb | 34 ++++++++++++-- .../004_UI_Evolution.rb | 30 ++++++++++--- .../001_Non-interactive UI/005_UI_Trading.rb | 23 +++++++--- Data/Scripts/016_UI/023_UI_MysteryGift.rb | 11 +++++ .../019_Utilities/002_Utilities_Pokemon.rb | 45 ++++++++++++++++--- .../005_Debug_PokemonCommands.rb | 9 ++-- 7 files changed, 133 insertions(+), 23 deletions(-) diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index 82fd9c97c..648249420 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -75,6 +75,10 @@ module Settings # Whether a bred baby Pokémon can inherit egg moves from its mother. It can # always inherit egg moves from its father. BREEDING_CAN_INHERIT_EGG_MOVES_FROM_MOTHER = (MECHANICS_GENERATION >= 6) + # Whether the Pokédex entry of a newly owned species will be shown after it + # hatches from an egg, after it evolves and after obtaining it from a trade, + # in addition to after catching it in battle. + SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN = (MECHANICS_GENERATION >= 7) # Whether you get 1 Premier Ball for every 10 of any kind of Poké Ball bought # at once (true), or 1 Premier Ball for buying 10+ Poké Balls (false). MORE_BONUS_PREMIER_BALLS = (MECHANICS_GENERATION >= 8) diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb index 68eef5dec..67bb1fb7c 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb @@ -103,6 +103,22 @@ class PokemonEggHatch_Scene pbMEPlay("Evolution success") @pokemon.name = nil pbMessage(_INTL("\\se[]{1} hatched from the Egg!\\wt[80]", @pokemon.name)) { update } + # Record the Pokémon's species as owned in the Pokédex + was_owned = $player.owned?(@pokemon.species) + $player.pokedex.register(@pokemon) + $player.pokedex.set_owned(@pokemon.species) + $player.pokedex.set_seen_egg(@pokemon.species) + # Show Pokédex entry for new species if it hasn't been owned before + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + pbMessage(_INTL("{1}'s data was added to the Pokédex.", @pokemon.name)) { update } + $player.pokedex.register_last_seen(@pokemon) + pbFadeOutIn { + scene = PokemonPokedexInfo_Scene.new + screen = PokemonPokedexInfoScreen.new(scene) + screen.pbDexEntry(@pokemon.species) + } + end + # Nickname the Pokémon if $PokemonSystem.givenicknames == 0 && pbConfirmMessage( _INTL("Would you like to nickname the newly hatched {1}?", @pokemon.name) @@ -199,15 +215,27 @@ def pbHatch(pokemon) pokemon.timeEggHatched = pbGetTimeNow pokemon.obtain_method = 1 # hatched from egg pokemon.hatched_map = $game_map.map_id - $player.pokedex.register(pokemon) - $player.pokedex.set_owned(pokemon.species) - $player.pokedex.set_seen_egg(pokemon.species) pokemon.record_first_moves if !pbHatchAnimation(pokemon) pbMessage(_INTL("Huh?\1")) pbMessage(_INTL("...\1")) pbMessage(_INTL("... .... .....\1")) pbMessage(_INTL("{1} hatched from the Egg!", speciesname)) + was_owned = $player.owned?(pokemon.species) + $player.pokedex.register(pokemon) + $player.pokedex.set_owned(pokemon.species) + $player.pokedex.set_seen_egg(pokemon.species) + # Show Pokédex entry for new species if it hasn't been owned before + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + pbMessage(_INTL("{1}'s data was added to the Pokédex.", speciesname)) + $player.pokedex.register_last_seen(pokemon) + pbFadeOutIn { + scene = PokemonPokedexInfo_Scene.new + screen = PokemonPokedexInfoScreen.new(scene) + screen.pbDexEntry(pokemon.species) + } + end + # Nickname the Pokémon if $PokemonSystem.givenicknames == 0 && pbConfirmMessage(_INTL("Would you like to nickname the newly hatched {1}?", speciesname)) nickname = pbEnterPokemonName(_INTL("{1}'s nickname?", speciesname), diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb b/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb index 8a50c7c44..6fdcbc5bb 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb @@ -517,9 +517,11 @@ class PokemonEvolutionScene end # Closes the evolution screen. - def pbEndScreen - pbDisposeMessageWindow(@sprites["msgwindow"]) - pbFadeOutAndHide(@sprites) { pbUpdate } + def pbEndScreen(need_fade_out = true) + pbDisposeMessageWindow(@sprites["msgwindow"]) if @sprites["msgwindow"] + if need_fade_out + pbFadeOutAndHide(@sprites) { pbUpdate } + end pbDisposeSpriteHash(@sprites) @viewport.dispose @bgviewport.dispose @@ -600,13 +602,31 @@ class PokemonEvolutionScene @pokemon.calc_stats @pokemon.ready_to_evolve = false # See and own evolved species + was_owned = $player.owned?(@newspecies) $player.pokedex.register(@pokemon) $player.pokedex.set_owned(@newspecies) - # Learn moves upon evolution for evolved species + moves_to_learn = [] movelist = @pokemon.getMoveList movelist.each do |i| next if i[0] != 0 && i[0] != @pokemon.level # 0 is "learn upon evolution" - pbLearnMove(@pokemon, i[1], true) { pbUpdate } + moves_to_learn.push(i[1]) + end + # Show Pokédex entry for new species if it hasn't been owned before + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + pbMessageDisplay(@sprites["msgwindow"], + _INTL("{1}'s data was added to the Pokédex.", newspeciesname)) { pbUpdate } + $player.pokedex.register_last_seen(@pokemon) + pbFadeOutIn { + scene = PokemonPokedexInfo_Scene.new + screen = PokemonPokedexInfoScreen.new(scene) + screen.pbDexEntry(@pokemon.species) + @sprites["msgwindow"].text = "" if moves_to_learn.length > 0 + pbEndScreen(false) if moves_to_learn.length == 0 + } + end + # Learn moves upon evolution for evolved species + moves_to_learn.each do |move| + pbLearnMove(@pokemon, move, true) { pbUpdate } end end diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb b/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb index fcba29166..e7b62b0d3 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb @@ -152,9 +152,9 @@ class PokemonTrade_Scene spriteBall.dispose end - def pbEndScreen - pbDisposeMessageWindow(@sprites["msgwindow"]) - pbFadeOutAndHide(@sprites) + def pbEndScreen(need_fade_out = true) + pbDisposeMessageWindow(@sprites["msgwindow"]) if @sprites["msgwindow"] + pbFadeOutAndHide(@sprites) if need_fade_out pbDisposeSpriteHash(@sprites) @viewport.dispose newspecies = @pokemon2.check_evolution_on_trade(@pokemon) @@ -167,6 +167,9 @@ class PokemonTrade_Scene end def pbTrade + was_owned = $player.owned?(@pokemon2.species) + $player.pokedex.register(@pokemon2) + $player.pokedex.set_owned(@pokemon2.species) pbBGMStop @pokemon.play_cry speciesname1 = GameData::Species.get(@pokemon.species).name @@ -187,6 +190,18 @@ class PokemonTrade_Scene @pokemon2.name, @pokemon2.owner.public_id, @pokemon2.owner.name)) { pbUpdate } pbMessageDisplay(@sprites["msgwindow"], _INTL("Take good care of {1}.", speciesname2)) { pbUpdate } + # Show Pokédex entry for new species if it hasn't been owned before + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + pbMessageDisplay(@sprites["msgwindow"], + _INTL("{1}'s data was added to the Pokédex.", speciesname2)) { pbUpdate } + $player.pokedex.register_last_seen(@pokemon2) + pbFadeOutIn { + scene = PokemonPokedexInfo_Scene.new + screen = PokemonPokedexInfoScreen.new(scene) + screen.pbDexEntry(@pokemon2.species) + pbEndScreen(false) + } + end end end @@ -212,8 +227,6 @@ def pbStartTrade(pokemonIndex, newpoke, nickname, trainerName, trainerGender = 0 yourPokemon.obtain_method = 2 # traded yourPokemon.reset_moves if resetmoves yourPokemon.record_first_moves - $player.pokedex.register(yourPokemon) - $player.pokedex.set_owned(yourPokemon.species) pbFadeOutInWithMusic { evo = PokemonTrade_Scene.new evo.pbStartScreen(myPokemon, yourPokemon, $player.name, trainerName) diff --git a/Data/Scripts/016_UI/023_UI_MysteryGift.rb b/Data/Scripts/016_UI/023_UI_MysteryGift.rb index d39a36302..f1daf6fc2 100644 --- a/Data/Scripts/016_UI/023_UI_MysteryGift.rb +++ b/Data/Scripts/016_UI/023_UI_MysteryGift.rb @@ -384,9 +384,20 @@ def pbReceiveMysteryGift(id) gift[2].record_first_moves gift[2].obtain_level = gift[2].level gift[2].obtain_map = $game_map&.map_id || 0 + was_owned = $player.owned?(gift[2].species) if pbAddPokemonSilent(gift[2]) pbMessage(_INTL("\\me[Pkmn get]{1} received {2}!", $player.name, gift[2].name)) $player.mystery_gifts[index] = [id] + # Show Pokédex entry for new species if it hasn't been owned before + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + pbMessage(_INTL("{1}'s data was added to the Pokédex.", gift[2].name)) + $player.pokedex.register_last_seen(gift[2]) + pbFadeOutIn { + scene = PokemonPokedexInfo_Scene.new + screen = PokemonPokedexInfoScreen.new(scene) + screen.pbDexEntry(gift[2].species) + } + end return true end elsif gift[1] > 0 # Item diff --git a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb index 5306ee019..e67702065 100644 --- a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb +++ b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb @@ -55,8 +55,20 @@ def pbAddPokemon(pkmn, level = 1, see_form = true) pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) species_name = pkmn.speciesName pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $player.name, species_name)) - pbNicknameAndStore(pkmn) + was_owned = $player.owned?(pkmn.species) $player.pokedex.register(pkmn) if see_form + # Show Pokédex entry for new species if it hasn't been owned before + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + pbMessage(_INTL("{1}'s data was added to the Pokédex.", species_name)) + $player.pokedex.register_last_seen(pkmn) + pbFadeOutIn { + scene = PokemonPokedexInfo_Scene.new + screen = PokemonPokedexInfoScreen.new(scene) + screen.pbDexEntry(pkmn.species) + } + end + # Nickname and add the Pokémon + pbNicknameAndStore(pkmn) return true end @@ -82,8 +94,20 @@ def pbAddToParty(pkmn, level = 1, see_form = true) pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) species_name = pkmn.speciesName pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $player.name, species_name)) - pbNicknameAndStore(pkmn) + was_owned = $player.owned?(pkmn.species) $player.pokedex.register(pkmn) if see_form + # Show Pokédex entry for new species if it hasn't been owned before + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + pbMessage(_INTL("{1}'s data was added to the Pokédex.", species_name)) + $player.pokedex.register_last_seen(pkmn) + pbFadeOutIn { + scene = PokemonPokedexInfo_Scene.new + screen = PokemonPokedexInfoScreen.new(scene) + screen.pbDexEntry(pkmn.species) + } + end + # Nickname and add the Pokémon + pbNicknameAndStore(pkmn) return true end @@ -100,20 +124,29 @@ end def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner_gender = 0, see_form = true) return false if !pkmn || $player.party_full? pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) - # Set original trainer to a foreign one pkmn.owner = Pokemon::Owner.new_foreign(owner_name || "", owner_gender) - # Set nickname pkmn.name = nickname[0, Pokemon::MAX_NAME_SIZE] if !nil_or_empty?(nickname) - # Recalculate stats pkmn.calc_stats if owner_name pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon from {2}.\1", $player.name, owner_name)) else pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon.\1", $player.name)) end - pbStorePokemon(pkmn) + was_owned = $player.owned?(pkmn.species) $player.pokedex.register(pkmn) if see_form $player.pokedex.set_owned(pkmn.species) + # Show Pokédex entry for new species if it hasn't been owned before + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + pbMessage(_INTL("The Pokémon's data was added to the Pokédex.")) + $player.pokedex.register_last_seen(pkmn) + pbFadeOutIn { + scene = PokemonPokedexInfo_Scene.new + screen = PokemonPokedexInfoScreen.new(scene) + screen.pbDexEntry(pkmn.species) + } + end + # Add the Pokémon + pbStorePokemon(pkmn) return true end diff --git a/Data/Scripts/020_Debug/003_Debug menus/005_Debug_PokemonCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/005_Debug_PokemonCommands.rb index 2039bb229..7538a866e 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/005_Debug_PokemonCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/005_Debug_PokemonCommands.rb @@ -729,7 +729,7 @@ MenuHandlers.add(:pokemon_debug_menu, :set_gender, { when 2 # Reset pkmn.gender = nil end - $player.pokedex.register(pkmn) if !settingUpBattle + $player.pokedex.register(pkmn) if !settingUpBattle && !pkmn.egg? screen.pbRefreshSingle(pkmnid) end end @@ -756,7 +756,7 @@ MenuHandlers.add(:pokemon_debug_menu, :species_and_form, { if species && species != pkmn.species pkmn.species = species pkmn.calc_stats - $player.pokedex.register(pkmn) if !settingUpBattle + $player.pokedex.register(pkmn) if !settingUpBattle && !pkmn.egg? screen.pbRefreshSingle(pkmnid) end when 1 # Set form @@ -783,7 +783,7 @@ MenuHandlers.add(:pokemon_debug_menu, :species_and_form, { pkmn.forced_form = f end pkmn.form = f - $player.pokedex.register(pkmn) if !settingUpBattle + $player.pokedex.register(pkmn) if !settingUpBattle && !pkmn.egg? screen.pbRefreshSingle(pkmnid) end end @@ -828,7 +828,7 @@ MenuHandlers.add(:pokemon_debug_menu, :set_shininess, { pkmn.shiny = nil pkmn.super_shiny = nil end - $player.pokedex.register(pkmn) if !settingUpBattle + $player.pokedex.register(pkmn) if !settingUpBattle && !pkmn.egg? screen.pbRefreshSingle(pkmnid) end next false @@ -1031,6 +1031,7 @@ MenuHandlers.add(:pokemon_debug_menu, :set_egg, { pkmn.steps_to_hatch = 0 pkmn.hatched_map = 0 pkmn.obtain_method = 0 + $player.pokedex.register(pkmn) if !settingUpBattle screen.pbRefreshSingle(pkmnid) end when 2 # Set steps left to 1