Added Gen 8's shiny chance increase with number battled, fixed other shiny chance-boosting effects not working

This commit is contained in:
Maruno17
2021-08-31 16:54:03 +01:00
parent 3c88c897f0
commit 218307d993
12 changed files with 172 additions and 40 deletions

View File

@@ -35,10 +35,13 @@ module Settings
SHINY_POKEMON_CHANCE = (MECHANICS_GENERATION >= 6) ? 16 : 8 SHINY_POKEMON_CHANCE = (MECHANICS_GENERATION >= 6) ? 16 : 8
# Whether super shininess is enabled (uses a different shiny animation). # Whether super shininess is enabled (uses a different shiny animation).
SUPER_SHINY = (MECHANICS_GENERATION >= 8) SUPER_SHINY = (MECHANICS_GENERATION >= 8)
# Whether shiny wild Pokémon are more likely to appear if the player has
# previously defeated/caught lots of other Pokémon of the same species.
HIGHER_SHINY_CHANCES_WITH_NUMBER_BATTLED = (MECHANICS_GENERATION >= 8)
# The odds of a wild Pokémon/bred egg having Pokérus (out of 65536). # The odds of a wild Pokémon/bred egg having Pokérus (out of 65536).
POKERUS_CHANCE = 3 POKERUS_CHANCE = 3
# Whether a bred baby Pokémon can inherit any TM/HM moves from its father. It # Whether a bred baby Pokémon can inherit any TM/TR/HM moves from its father.
# can never inherit TM/HM moves from its mother. # It can never inherit TM/TR/HM moves from its mother.
BREEDING_CAN_INHERIT_MACHINE_MOVES = (MECHANICS_GENERATION <= 5) BREEDING_CAN_INHERIT_MACHINE_MOVES = (MECHANICS_GENERATION <= 5)
# Whether a bred baby Pokémon can inherit egg moves from its mother. It can # Whether a bred baby Pokémon can inherit egg moves from its mother. It can
# always inherit egg moves from its father. # always inherit egg moves from its father.

View File

@@ -88,3 +88,14 @@ SaveData.register_conversion(:v19_2_fix_berry_plants) do
end end
end end
end end
SaveData.register_conversion(:v20_add_battled_counts) do
essentials_version 20
display_title 'Adding Pokédex battle counts'
to_value :player do |player|
player.pokedex.instance_eval do
@caught_counts = {} if @caught_counts.nil?
@defeated_counts = {} if @defeated_counts.nil?
end
end
end

View File

@@ -55,6 +55,7 @@ class PokeBattle_Battler
@battle.pbDisplayBrief(_INTL("{1} fainted!",pbThis)) if showMessage @battle.pbDisplayBrief(_INTL("{1} fainted!",pbThis)) if showMessage
PBDebug.log("[Pokémon fainted] #{pbThis} (#{@index})") if !showMessage PBDebug.log("[Pokémon fainted] #{pbThis} (#{@index})") if !showMessage
@battle.scene.pbFaintBattler(self) @battle.scene.pbFaintBattler(self)
@battle.pbSetDefeated(self) if opposes?
pbInitEffects(false) pbInitEffects(false)
# Reset status # Reset status
self.status = :NONE self.status = :NONE

View File

@@ -42,7 +42,8 @@ module PokeBattle_BattleCommon
# Register all caught Pokémon in the Pokédex, and store them. # Register all caught Pokémon in the Pokédex, and store them.
def pbRecordAndStoreCaughtPokemon def pbRecordAndStoreCaughtPokemon
@caughtPokemon.each do |pkmn| @caughtPokemon.each do |pkmn|
pbPlayer.pokedex.register(pkmn) # In case the form changed upon leaving battle pbSetCaught(pkmn)
pbSetSeen(pkmn) # In case the form changed upon leaving battle
# Record the Pokémon's species as owned in the Pokédex # Record the Pokémon's species as owned in the Pokédex
if !pbPlayer.owned?(pkmn.species) if !pbPlayer.owned?(pkmn.species)
pbPlayer.pokedex.set_owned(pkmn.species) pbPlayer.pokedex.set_owned(pkmn.species)

View File

@@ -628,7 +628,29 @@ class PokeBattle_Battle
def pbSetSeen(battler) def pbSetSeen(battler)
return if !battler || !@internalBattle return if !battler || !@internalBattle
if battler.is_a?(PokeBattle_Battler)
pbPlayer.pokedex.register(battler.displaySpecies,battler.displayGender,battler.displayForm) pbPlayer.pokedex.register(battler.displaySpecies,battler.displayGender,battler.displayForm)
else
pbPlayer.pokedex.register(battler)
end
end
def pbSetCaught(battler)
return if !battler || !@internalBattle
if battler.is_a?(PokeBattle_Battler)
pbPlayer.pokedex.register_caught(battler.displaySpecies)
else
pbPlayer.pokedex.register_caught(battler.species)
end
end
def pbSetDefeated(battler)
return if !battler || !@internalBattle
if battler.is_a?(PokeBattle_Battler)
pbPlayer.pokedex.register_defeated(battler.displaySpecies)
else
pbPlayer.pokedex.register_defeated(battler.species)
end
end end
def nextPickupUse def nextPickupUse

View File

@@ -355,6 +355,24 @@ class PokeBattle_SafariZone
def pbGetOwnerFromBattlerIndex(idxBattler); return pbPlayer; end def pbGetOwnerFromBattlerIndex(idxBattler); return pbPlayer; end
def pbSetSeen(battler)
return if !battler || !@internalBattle
if battler.is_a?(PokeBattle_Battler)
pbPlayer.pokedex.register(battler.displaySpecies,battler.displayGender,battler.displayForm)
else
pbPlayer.pokedex.register(battler)
end
end
def pbSetCaught(battler)
return if !battler || !@internalBattle
if battler.is_a?(PokeBattle_Battler)
pbPlayer.pokedex.register_caught(battler.displaySpecies)
else
pbPlayer.pokedex.register_caught(battler.species)
end
end
#============================================================================= #=============================================================================
# Get party info (counts all teams on the same side) # Get party info (counts all teams on the same side)
#============================================================================= #=============================================================================
@@ -417,7 +435,7 @@ class PokeBattle_SafariZone
def pbStartBattle def pbStartBattle
begin begin
pkmn = @party2[0] pkmn = @party2[0]
self.pbPlayer.pokedex.register(pkmn) pbSetSeen(pkmn)
@scene.pbStartBattle(self) @scene.pbStartBattle(self)
pbDisplayPaused(_INTL("Wild {1} appeared!",pkmn.name)) pbDisplayPaused(_INTL("Wild {1} appeared!",pkmn.name))
@scene.pbSafariStart @scene.pbSafariStart

View File

@@ -411,10 +411,26 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
elsif itemrnd<(chances[0]+chances[1]+chances[2]) elsif itemrnd<(chances[0]+chances[1]+chances[2])
genwildpoke.item = items[2] genwildpoke.item = items[2]
end end
# Shiny Charm makes shiny Pokémon more likely to generate # Improve chances of shiny Pokémon with Shiny Charm and battling more of the
if GameData::Item.exists?(:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM) # same species
2.times do # 3 times as likely shiny_retries = 0
shiny_retries += 2 if GameData::Item.exists?(:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
if Settings::HIGHER_SHINY_CHANCES_WITH_NUMBER_BATTLED
values = [0, 0]
case $Trainer.pokedex.battled_count(species)
when 0...50 then values = [0, 0]
when 50...100 then values = [1, 15]
when 100...200 then values = [2, 20]
when 200...300 then values = [3, 25]
when 300...500 then values = [4, 30]
else values = [5, 30]
end
shiny_retries += values[0] if values[1] > 0 && rand(1000) < values[1]
end
if shiny_retries > 0
shiny_retries.times do
break if genwildpoke.shiny? break if genwildpoke.shiny?
genwildpoke.shiny = nil # Make it recalculate shininess
genwildpoke.personalID = rand(2**16) | rand(2**16) << 16 genwildpoke.personalID = rand(2**16) | rand(2**16) << 16
end end
end end

View File

@@ -324,6 +324,7 @@ def pbDayCareGenerateEgg
if shinyretries>0 if shinyretries>0
shinyretries.times do shinyretries.times do
break if egg.shiny? break if egg.shiny?
egg.shiny = nil # Make it recalculate shininess
egg.personalID = rand(2**16) | rand(2**16) << 16 egg.personalID = rand(2**16) | rand(2**16) << 16
end end
end end

View File

@@ -338,7 +338,7 @@ class Pokemon
else @gender = 2 else @gender = 2
end end
else else
female_chance = GameData::GenderRatio.get(gender_ratio).female_chance female_chance = GameData::GenderRatio.get(species_data.gender_ratio).female_chance
@gender = ((@personalID & 0xFF) < female_chance) ? 1 : 0 @gender = ((@personalID & 0xFF) < female_chance) ? 1 : 0
end end
end end

View File

@@ -27,6 +27,8 @@ class Player < Trainer
@seen_forms = {} @seen_forms = {}
@last_seen_forms = {} @last_seen_forms = {}
@owned_shadow = {} @owned_shadow = {}
@caught_counts = {}
@defeated_counts = {}
self.refresh_accessible_dexes self.refresh_accessible_dexes
end end
@@ -199,6 +201,51 @@ class Player < Trainer
#=========================================================================== #===========================================================================
# @param species [Symbol, GameData::Species] species to check
# @return [Integer] the number of Pokémon of the given species that have
# been caught by the player
def caught_count(species)
species_id = GameData::Species.try_get(species)&.species
return 0 if species_id.nil?
return @caught_counts[species] || 0
end
# @param species [Symbol, GameData::Species] species to check
# @return [Integer] the number of Pokémon of the given species that have
# been defeated by the player
def defeated_count(species)
species_id = GameData::Species.try_get(species)&.species
return 0 if species_id.nil?
return @defeated_counts[species] || 0
end
# @param species [Symbol, GameData::Species] species to check
# @return [Integer] the number of Pokémon of the given species that have
# been defeated or caught by the player
def battled_count(species)
species_id = GameData::Species.try_get(species)&.species
return 0 if species_id.nil?
return (@defeated_counts[species] || 0) + (@caught_counts[species] || 0)
end
# @param species [Symbol, GameData::Species] species to count as caught
def register_caught(species)
species_id = GameData::Species.try_get(species)&.species
return if species_id.nil?
@caught_counts[species] = 0 if @caught_counts[species].nil?
@caught_counts[species] += 1
end
# @param species [Symbol, GameData::Species] species to count as defeated
def register_defeated(species)
species_id = GameData::Species.try_get(species)&.species
return if species_id.nil?
@defeated_counts[species] = 0 if @defeated_counts[species].nil?
@defeated_counts[species] += 1
end
#===========================================================================
# Unlocks the given Dex, -1 being the National Dex. # Unlocks the given Dex, -1 being the National Dex.
# @param dex [Integer] Dex ID (-1 is the National Dex) # @param dex [Integer] Dex ID (-1 is the National Dex)
def unlock(dex) def unlock(dex)

View File

@@ -9,6 +9,7 @@ class PokemonPokedexInfo_Scene
@index = index @index = index
@region = region @region = region
@page = 1 @page = 1
@show_battled_count = false
@typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Pokedex/icon_types")) @typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Pokedex/icon_types"))
@sprites = {} @sprites = {}
@sprites["background"] = IconSprite.new(0,0,@viewport) @sprites["background"] = IconSprite.new(0,0,@viewport)
@@ -219,14 +220,20 @@ class PokemonPokedexInfo_Scene
end end
textpos = [ textpos = [
[_INTL("{1}{2} {3}", indexText, " ", species_data.name), [_INTL("{1}{2} {3}", indexText, " ", species_data.name),
246, 36, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)], 246, 36, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)]
[_INTL("Height"), 314, 152, 0, base, shadow],
[_INTL("Weight"), 314, 184, 0, base, shadow]
] ]
if @show_battled_count
textpos.push([_INTL("Number Battled"), 314, 152, 0, base, shadow])
textpos.push([$Trainer.pokedex.battled_count(@species).to_s, 452, 184, 1, base, shadow])
else
textpos.push([_INTL("Height"), 314, 152, 0, base, shadow])
textpos.push([_INTL("Weight"), 314, 184, 0, base, shadow])
end
if $Trainer.owned?(@species) if $Trainer.owned?(@species)
# Write the category # Write the category
textpos.push([_INTL("{1} Pokémon", species_data.category), 246, 68, 0, base, shadow]) textpos.push([_INTL("{1} Pokémon", species_data.category), 246, 68, 0, base, shadow])
# Write the height and weight # Write the height and weight
if !@show_battled_count
height = species_data.height height = species_data.height
weight = species_data.weight weight = species_data.weight
if System.user_language[3..4] == "US" # If the user is in the United States if System.user_language[3..4] == "US" # If the user is in the United States
@@ -238,6 +245,7 @@ class PokemonPokedexInfo_Scene
textpos.push([_ISPRINTF("{1:.1f} m", height / 10.0), 470, 152, 1, base, shadow]) textpos.push([_ISPRINTF("{1:.1f} m", height / 10.0), 470, 152, 1, base, shadow])
textpos.push([_ISPRINTF("{1:.1f} kg", weight / 10.0), 482, 184, 1, base, shadow]) textpos.push([_ISPRINTF("{1:.1f} kg", weight / 10.0), 482, 184, 1, base, shadow])
end end
end
# Draw the Pokédex entry text # Draw the Pokédex entry text
drawTextEx(overlay, 40, 244, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines drawTextEx(overlay, 40, 244, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines
species_data.pokedex_entry, base, shadow) species_data.pokedex_entry, base, shadow)
@@ -263,6 +271,7 @@ class PokemonPokedexInfo_Scene
# Write the category # Write the category
textpos.push([_INTL("????? Pokémon"), 246, 68, 0, base, shadow]) textpos.push([_INTL("????? Pokémon"), 246, 68, 0, base, shadow])
# Write the height and weight # Write the height and weight
if !@show_battled_count
if System.user_language[3..4] == "US" # If the user is in the United States if System.user_language[3..4] == "US" # If the user is in the United States
textpos.push([_INTL("???'??\""), 460, 152, 1, base, shadow]) textpos.push([_INTL("???'??\""), 460, 152, 1, base, shadow])
textpos.push([_INTL("????.? lbs."), 494, 184, 1, base, shadow]) textpos.push([_INTL("????.? lbs."), 494, 184, 1, base, shadow])
@@ -271,6 +280,7 @@ class PokemonPokedexInfo_Scene
textpos.push([_INTL("????.? kg"), 482, 184, 1, base, shadow]) textpos.push([_INTL("????.? kg"), 482, 184, 1, base, shadow])
end end
end end
end
# Draw all text # Draw all text
pbDrawTextPositions(overlay, textpos) pbDrawTextPositions(overlay, textpos)
# Draw all images # Draw all images
@@ -458,7 +468,10 @@ class PokemonPokedexInfo_Scene
pbPlayCloseMenuSE pbPlayCloseMenuSE
break break
elsif Input.trigger?(Input::USE) elsif Input.trigger?(Input::USE)
if @page==2 # Area if @page == 1 # Info
@show_battled_count = !@show_battled_count
dorefresh = true
elsif @page == 2 # Area
# dorefresh = true # dorefresh = true
elsif @page == 3 # Forms elsif @page == 3 # Forms
if @available.length>1 if @available.length>1

View File

@@ -4,11 +4,6 @@
# To do # To do
#=============================================================================== #===============================================================================
The game records, for each species, how many have been caught or defeated
(counts both wild and trainer battles), and the shiny chance increases for that
species because of this. This value is also shown in the Pokédex entry screen.
(Will be implemented by me in the next PR)
Some moves have changed properties/effects: Some moves have changed properties/effects:
- Parting Shot is able to make the user switch out if its effect is redirected - Parting Shot is able to make the user switch out if its effect is redirected
by Mirror Armor. Throat Spray is triggered and applies before the switch. by Mirror Armor. Throat Spray is triggered and applies before the switch.
@@ -173,4 +168,8 @@ In Gen 7+, Shaymin/Hoopa revert their form when withdrawn from storage rather
than when deposited. It still also reverts under other conditions. Shaymin than when deposited. It still also reverts under other conditions. Shaymin
reverts its form when deposited in the Day Care (all Gens). reverts its form when deposited in the Day Care (all Gens).
The game records, for each species, how many have been caught or defeated
(counts both wild and trainer battles), and the shiny chance increases for that
species because of this. This value is also shown in the Pokédex entry screen.
=end =end