DAYCARE Error / De-Evolution - Stack Level

TakakoJin

Eevee Breeder
Member
Joined
Mar 30, 2018
Posts
57
Hi there. An error from Aster Violet. (Pink and Purple have the same problem.)
Whenever I receive an egg from the daycare I get the error below.
The daycare script is untouched. Perhaps the problem is in the Pokemon PBS?
I tried several Pokemon, with and without ditto. Always the same.
Any ideas? Googling didn't turn up anything useful.

I'm using Essentials 16.2
If it helps, the game with all it's files and the rxproj is available here:
https://reliccastle.com/threads/1368/

The error log:
-------------------------
Code:
Exception: RuntimeError
Message: Script error within event 1, map 118 (ROUTE 510):
Exception: SystemStackError
Message: Section126:202:in `pbGetBabySpecies'stack level too deep
***Full script:
pbDayCareGenerateEgg
$PokemonGlobal.daycareEgg=0
$PokemonGlobal.daycareEggSteps=0
 
Interpreter:243:in `pbExecuteScript'
Pokemon_Evolution:197:in `loop'
Pokemon_Evolution:215:in `pbGetBabySpecies'
Pokemon_Evolution:191:in `pbRgssOpen'
SpriteWindow:1776:in `open'
SpriteWindow:1776:in `pbRgssOpen'
Pokemon_Evolution:191:in `pbGetBabySpecies'
Pokemon_Evolution:219:in `pbGetBabySpecies'
Pokemon_Evolution:219:in `pbGetBabySpecies'
Pokemon_Evolution:219:in `pbGetBabySpecies'
 
Interpreter:276:in `pbExecuteScript'
Interpreter:1606:in `command_355'
Interpreter:494:in `execute_command'
Interpreter:193:in `update'
Interpreter:106:in `loop'
Interpreter:198:in `update'
Scene_Map:103:in `update'
Scene_Map:101:in `loop'
Scene_Map:114:in `update'
Scene_Map:68:in `main'
 

TakakoJin

Eevee Breeder
Member
Joined
Mar 30, 2018
Posts
57
I found the problem.

How Essentials generates eggs is by checking what the earliest pre-evolution of the parent pokemon is.

Well, in my game I gave them the ability to "de-evolve" by using an item, which is technically still an evolution.

What this means is that the program will loop around the same evolution line eternally, never finding the earliest evolution.


GT-Baka came with the solution to use this kind of code in PItem_ItemEffects:

Code:
ItemHandlers::UseOnPokemon.add(:DEVOLUTIONSTONE,proc{|item,pokemon,scene|
   if isConst?(pokemon.species,PBSpecies,:NINETALES)
     pokemon.species=PBSpecies::VULPIX
     pokemon.calcStats
     scene.pbDisplay(_INTL("NINETALES devolved into VULPIX."))
     scene.pbHardRefresh
   else
     scene.pbDisplay(_INTL("It won't have any effect."))
   end
 })

A great solution. Just takes time to implement for every single Poke. :)

~TJ
 

Marin

Administrator
Administrator
This should make it a lot easier to add new Pokémon:

Code:
ItemHandlers::UseOnPokemon.add(:DEVOLUTIONSTONE,proc{|item,pokemon,scene|
  evos = {
  # :SPECIES => :BABY,
    :NINETALES => :VULPIX,
  }
  hash = {}
  evos.each { |e| hash[getConst(PBSpecies,e[0])] = e[1] }
  if hash[pokemon.species]
    oldname = PBSpecies.getName(pokemon.species).upcase
    pokemon.species = getConst(PBSpecies,hash[pokemon.species]
    newname = PBSpecies.getName(pokemon.species).upcase
    pokemon.calcStats
    scene.pbDisplay(_INTL("{1} devolved into {2}."), oldname, newname)
    scene.pbHardRefresh
  else
    scene.pbDisplay(_INTL("It won't have any effect."))
  end
})

To make species A devolve into species B, write down the species (e.g. :NINETALES) followed by =>, followed by the species you want it to devolve into (e.g. :VULPIX), and then just end it with a comma.
Example:
:NINETALES => :VULPIX,

So you should only need to add on to that in order to add new "devolutions".
 

TakakoJin

Eevee Breeder
Member
Joined
Mar 30, 2018
Posts
57
This should make it a lot easier to add new Pokémon:


To make species A devolve into species B, write down the species (e.g. :NINETALES) followed by =>, followed by the species you want it to devolve into (e.g. :VULPIX), and then just end it with a comma.
Example:
:NINETALES => :VULPIX,

So you should only need to add on to that in order to add new "devolutions".

Thanks :) You are amazing!

There were a few syntax errors in the code, so what I currently have is this:

Code:
ItemHandlers::UseOnPokemon.add(:RETURNSTONE,proc{|item,pokemon,scene|
  evos = {
  # :SPECIES => :BABY,
    :KAKUNA => :WEEDLE,
    :BEEDRILL => :KAKUNA,
    :NINETALES => :VULPIX,
  }
  hash = {}
  evos.each { |e| hash[getConst(PBSpecies,e[0])] = e[1] }
  if hash[pokemon.species]
    oldname = PBSpecies.getName(pokemon.species).upcase
    pokemon.species = getConst(PBSpecies,hash[pokemon.species])
    newname = PBSpecies.getName(pokemon.species).upcase
    pokemon.calcStats
#    scene.pbDisplay(_INTL("{1} devolved into {2}."), oldname, newname)
    scene.pbDisplay(_INTL("Devolution successful!"))
    scene.pbHardRefresh
  else
    scene.pbDisplay(_INTL("It won't have any effect."))
  end
})
 

Maruno

Pokémon Essentials dev
Essentials Developer
Joined
Apr 5, 2017
Posts
409
There's also pbGetPreviousForm(pokemon.species). Given a species, it'll return either the same species (if it can't devolve) or the immediately previous evolution (if it can devolve). No need to hardcode a bunch of originals => results in a hash.
 

TakakoJin

Eevee Breeder
Member
Joined
Mar 30, 2018
Posts
57
There's also pbGetPreviousForm(pokemon.species). Given a species, it'll return either the same species (if it can't devolve) or the immediately previous evolution (if it can devolve). No need to hardcode a bunch of originals => results in a hash.

I tried the other day to get that one to work with no results. I may have omitted the "pokemon." part in front of the "species" though.
 
Top