Added a Setting that makes a new Pokémon's Pokédex entry show after evolution, trading, hatching, gaining from Mystery Gift and general adding

This commit is contained in:
Maruno17
2022-04-03 19:06:56 +01:00
parent e87d55f56f
commit 026e6f5c0a
7 changed files with 133 additions and 23 deletions

View File

@@ -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)

View File

@@ -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),

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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