diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index 0ce14074c..99a83927c 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -150,6 +150,9 @@ module Settings REPEL_COUNTS_FAINTED_POKEMON = (MECHANICS_GENERATION >= 6) # Whether Rage Candy Bar acts as a Full Heal (true) or a Potion (false). RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS = (MECHANICS_GENERATION >= 7) + # Whether Rare Candy can be used on a Pokémon that is already at its maximum + # level if it is able to evolve by level-up (if so, triggers that evolution). + RARE_CANDY_USABLE_AT_MAX_LEVEL = (MECHANICS_GENERATION >= 8) #============================================================================= 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 896845700..8715be8d6 100644 --- a/Data/Scripts/010_Data/001_Hardcoded data/007_Evolution.rb +++ b/Data/Scripts/010_Data/001_Hardcoded data/007_Evolution.rb @@ -7,6 +7,7 @@ module GameData attr_reader :level_up_proc attr_reader :use_item_proc attr_reader :on_trade_proc + attr_reader :event_proc attr_reader :after_evolution_proc DATA = {} @@ -25,6 +26,7 @@ module GameData @level_up_proc = hash[:level_up_proc] @use_item_proc = hash[:use_item_proc] @on_trade_proc = hash[:on_trade_proc] + @event_proc = hash[:event_proc] @after_evolution_proc = hash[:after_evolution_proc] end @@ -40,6 +42,10 @@ module GameData return (@on_trade_proc) ? @on_trade_proc.call(*args) : nil end + def call_event(*args) + return (@event_proc) ? @event_proc.call(*args) : nil + end + def call_after_evolution(*args) @after_evolution_proc.call(*args) if @after_evolution_proc end @@ -597,3 +603,71 @@ GameData::Evolution.register({ next pkmn.species == parameter && !other_pkmn.hasItem?(:EVERSTONE) } }) + +#=============================================================================== +# Evolution methods that are triggered by an event +#=============================================================================== +GameData::Evolution.register({ + :id => :Event, + :parameter => Integer, + :event_proc => proc { |pkmn, parameter, value| + next true + } +}) + +GameData::Evolution.register({ + :id => :EventValue, + :parameter => Integer, + :event_proc => proc { |pkmn, parameter, value| + next value == parameter + } +}) + +GameData::Evolution.register({ + :id => :EventLevel, + :parameter => Integer, + :event_proc => proc { |pkmn, parameter, value| + next pkmn.level >= parameter + } +}) + +GameData::Evolution.register({ + :id => :EventMale, + :event_proc => proc { |pkmn, parameter, value| + next pkmn.male? + } +}) + +GameData::Evolution.register({ + :id => :EventFemale, + :event_proc => proc { |pkmn, parameter, value| + next pkmn.female? + } +}) + +GameData::Evolution.register({ + :id => :EventDay, + :event_proc => proc { |pkmn, parameter, value| + next PBDayNight.isDay? + } +}) + +GameData::Evolution.register({ + :id => :EventNight, + :event_proc => proc { |pkmn, parameter, value| + next PBDayNight.isNight? + } +}) + +GameData::Evolution.register({ + :id => :EventItem, + :parameter => :Item, + :event_proc => proc { |pkmn, parameter, value| + next pkmn.item == parameter + }, + :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species| + next false if evo_species != new_species || !pkmn.hasItem?(parameter) + pkmn.item = nil # Item is now consumed + next true + } +}) diff --git a/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb b/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb index 7f145dcfe..086156dcc 100644 --- a/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb +++ b/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb @@ -405,6 +405,7 @@ class PokeBattle_Battler return false if fainted? && !ignoreFainted return false if @effects[PBEffects::Embargo]>0 return false if @battle.field.effects[PBEffects::MagicRoom]>0 + return false if @battle.corrosiveGas[@index % 2][@pokemonIndex] return false if hasActiveAbility?(:KLUTZ,ignoreFainted) return true end diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index 11b3e9961..33766045a 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -779,11 +779,28 @@ ItemHandlers::UseOnPokemon.add(:SWIFTFEATHER,proc { |item,pkmn,scene| ItemHandlers::UseOnPokemon.copy(:SWIFTFEATHER,:SWIFTWING) ItemHandlers::UseOnPokemon.add(:RARECANDY,proc { |item,pkmn,scene| - if pkmn.level>=GameData::GrowthRate.max_level || pkmn.shadowPokemon? + if pkmn.shadowPokemon? scene.pbDisplay(_INTL("It won't have any effect.")) next false end - pbChangeLevel(pkmn,pkmn.level+1,scene) + if pkmn.level >= GameData::GrowthRate.max_level + new_species = pkmn.check_evolution_on_level_up + if !Settings::RARE_CANDY_USABLE_AT_MAX_LEVEL || !new_species + scene.pbDisplay(_INTL("It won't have any effect.")) + next false + end + # Check for evolution + pbFadeOutInWithMusic { + evo = PokemonEvolutionScene.new + evo.pbStartScreen(pkmn, new_species) + evo.pbEvolution + evo.pbEndScreen + scene.pbRefresh if scene.is_a?(PokemonPartyScreen) + } + next true + end + # Level up + pbChangeLevel(pkmn,pkmn.level + 1, scene) scene.pbHardRefresh next true }) diff --git a/Data/Scripts/014_Pokemon/001_Pokemon.rb b/Data/Scripts/014_Pokemon/001_Pokemon.rb index c16b8868f..08b08f52a 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon.rb @@ -961,6 +961,16 @@ class Pokemon } end + # Checks whether this Pokemon can evolve by a triggered event. + # @param value [Integer] a value that may be used by the evolution method + # @return [Symbol, nil] the ID of the species to evolve into + def check_evolution_by_event(value = 0) + return check_evolution_internal { |pkmn, new_species, method, parameter, value| + success = GameData::Evolution.get(method).call_event(pkmn, parameter, value) + next (success) ? new_species : nil + } + end + # Called after this Pokémon evolves, to remove its held item (if the evolution # required it to have a held item) or duplicate this Pokémon (Shedinja only). # @param new_species [Symbol] the species that this Pokémon evolved into @@ -986,6 +996,20 @@ class Pokemon return nil end + def trigger_event_evolution(value = 0) + new_species = check_evolution_by_event(value) + if new_species + pbFadeOutInWithMusic { + evo = PokemonEvolutionScene.new + evo.pbStartScreen(self, new_species) + evo.pbEvolution + evo.pbEndScreen + } + return true + end + return false + end + #============================================================================= # Stat calculations #============================================================================= diff --git a/Data/Scripts/Gen 8 notes.txt b/Data/Scripts/Gen 8 notes.txt index c0cabfc07..775fd7f50 100644 --- a/Data/Scripts/Gen 8 notes.txt +++ b/Data/Scripts/Gen 8 notes.txt @@ -1,52 +1,57 @@ =begin +#=============================================================================== +# 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. + +Some moves have changed properties/effects. + +Can use Fly from within the Town Map if possible. (Good QoL, add if possible.) + +Example event that combines the Gen 8 fossils. + +New evolution methods: +- Galarian Farfetch'd: performing 3 critical hits in a single battle + +PBS file data: +- Form differences. +- Moveset changes. +- Changes to evolutions due to removal of moss rock/ice rock/magnetic field. +- Some (12) existing species changed egg groups. +- Aegislash's stats changed. +- 2 existing Pokémon gained new abilities. +- Vice Grip becomes Vise Grip. +- Some items change names (Stick -> Leek, etc.). + +Add AI for new moves/items/abilities. + +#=============================================================================== +# Low priority or ignorable +#=============================================================================== + Marks, which are symbols randomly given to wild Pokémon which append a title to its name when sent out in battle. A Pokémon can only have 0 or 1 marks. The title can be toggled. Ribbons also provide a title, and can similarly be toggled. (Probably don't bother implementing.) -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. - -In Gen 8+, a taught TR should be added to the Pokémon's first_moves array. - -Some moves have changed properties/effects. - -Can now give a Rare Candy to a max level Pokémon, which will trigger its -evolution (presumably the item isn't consumed if it can't at least try to evolve -it). - Bicycle that can work on water. -Town Map added to the pause menu (don't bother adding). Can use Fly from within -the Town Map if possible (good QoL, add if possible). +Town Map added to the pause menu. (Don't bother adding.) -Remote access to storage boxes. Add an option to the pause screen for this -unless Settings::HEAL_STORED_POKEMON? - -Example event that combines the Gen 8 fossils. +Remote access to storage boxes. See the Pokémon Box Link item. New evolution methods: -- Milcery (spinning while holding an item) -- Galarian Farfetch'd (performing 3 critical hits in a single battle) -- Galarian Yamask (going to a particular spot after a battle in which it lost - 49+ HP from a single attack and hasn't fainted since then; healing doesn't - affect this) -- Kubfu (triggered by an event; Kubfu's form can be set beforehand by the event, - so don't worry about the multiple forms it can evolve into) - -# PBS file data: -# - Form differences. -# - Moveset changes. -# - Changes to evolutions due to removal of moss rock/ice rock/magnetic field. -# - Some (12) existing species changed egg groups. -# - Aegislash's stats changed. -# - 2 existing Pokémon gained new abilities. -# - Vice Grip becomes Vise Grip. -# - Some items change names (Stick -> Leek, etc.). - -Add AI for new moves/items/abilities. +- Milcery: spinning while holding an item. (Doesn't suit our control scheme, + we're not adding a way to easily spin on the spot just for this, cf. + not having to turn your computer upside-down to evolve Inkay.) +- Galarian Yamask: going to a particular spot after a battle in which it lost + 49+ HP from a single attack and hasn't fainted since then; + healing doesn't affect this. (Utter nonsense, find a better + way.) #=============================================================================== # Implemented @@ -58,4 +63,15 @@ Super shininess. Only difference is an alternate shiny common animation with square sparkles; a mon is super shiny if the calculated number that is compared to Settings::SHINY_POKEMON_CHANCE is exactly 0 - see Settings::SUPER_SHINY. +Can now give a Rare Candy to a max level Pokémon, which will trigger its +evolution (presumably the item isn't consumed if it can't at least try to evolve +it) - see Settings::RARE_CANDY_USABLE_AT_MAX_LEVEL. + +In Gen 8+, a taught TR should be added to the Pokémon's first_moves array. This +is done regardless of Generation, and doesn't need to be limited to Gen 8+. + +New evolution methods: +- Kubfu (triggered by an event; Kubfu's form can be set beforehand by the event, + so don't worry about the multiple forms it can evolve into) + =end