• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Form Change on Evolution

Foxx_Gaming

Wacky Wahoo Pizza Pasta Man
35
Posts
3
Years
  • As someone who hardly understands the way scripts work, I'm trying to figure out how to evolve a Pokémon into a certain form based on what item you use on it.
    Example: Pikachu > Raichu w/ Thunder Stone, Pikachu > Alolan Raichu w/ Sun Stone
    It detects that it's able to evolve with a Sun Stone, but how do I set the mon's form to 1 (or any number) during the evolution?
     
    104
    Posts
    2
    Years
    • Seen Mar 12, 2024
    It should just be RAICHU_1 in the evolutions section to denote the second form. Make sure your pokemonforms.txt has raichu alola defined.

    Note that base essentials 19.1 doesnt have a graphic for raichu alolan, so it will look like raichu, so check your pokemons stats to see if it is a psychic type.
     

    Foxx_Gaming

    Wacky Wahoo Pizza Pasta Man
    35
    Posts
    3
    Years
  • is that how it works in v19?
    apologies for not making it clear in my initial post, i use v18.1. my bad!
    i have tried that before, and it came with some... interesting results?
    during the evolution scene, instead of there being a raichu, it's the placeholder "? circle" sprite.
    it said "congratulations! your pikachu evolved into !"
    and that " " wanted to learn psychic upon evolution.
    so the moves and types were all there, but the pokemon itself was not.
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    EDIT: Check this post of the complete answer.


    is that how it works in v19?
    apologies for not making it clear in my initial post, i use v18.1. my bad!
    i have tried that before, and it came with some... interesting results?
    during the evolution scene, instead of there being a raichu, it's the placeholder "? circle" sprite.
    it said "congratulations! your pikachu evolved into !"
    and that " " wanted to learn psychic upon evolution.
    so the moves and types were all there, but the pokemon itself was not.

    This is due to the way pokemon.txt is compiled (in v18.1). When you compile the game, pokemon.txt is compiled, then it's pokemonforms.txt, as pokemonforms.txt relies on the data of pokemon.txt. However, pokemon.txt cannot rely on data defined in pokemonforms.txt, so you can't make a Pokémon evolve into different forms depending on the method.

    (EDIT: Actually the evolutions are stored in a string, which is interpreted later when a Pokémon actually evolves. Which is weird because in pbCompilePokemonData, there is a step that checks if the given Pokémon (the evolution) exists... So I think it's a bug in the compiler. )

    So, your problem looks like what happens with Exeggcute or Cubone. For these, Essentials defines a new form, and there is a function that says which form you have depending on the region where you caught the Pokémon. That's not very compatible with what you want to do.

    I have not tested what I'm going to tell you, but here is a hint:
    • Put the second method of evolution in the PBS file:
      Code:
      Evolutions = RAICHU,Item,ThunderStone,RAICHU,Item,SunStone
    • Paste this code in a separate script above Main:
      Code:
      alias __specific__pbMiniCheckEvolutionItem pbMiniCheckEvolutionItem
      def pbMiniCheckEvolutionItem(pkmn, method, parameter, new_species, item)
        ret = __specific__pbMiniCheckEvolutionItem(pkmn, method, parameter, new_species, item)
        # Specific code for Pikachu to evolve into Alolan Raichu due to Sun Stone
        if isConst?(pkmn.species, PBSpecies, :PIKACHU) && isConst?(ret, PBSpecies, :RAICHU) && isConst?(item, PBItems, :SUNSTONE)
          ret = PBSpecies::RAICHU_1
        end 
        return ret 
      end
      Basically, what this does, is override the function that checks whether a Pokémon can evolve into another with an item, and forces that evolution to be Alolan Raichu if this is a Pikachu that gets exposed to a Moon Stone. You will have to mimic the "if" statement if you want to adapt the code to other forms.
     
    Last edited:

    Foxx_Gaming

    Wacky Wahoo Pizza Pasta Man
    35
    Posts
    3
    Years
  • plugged that in, but it had the same issue as just putting RAICHU_1 into pikachu's evolutions.
    i haven't quite figured out how to set forms within scripts just yet, but this here means that we're close to solving the issue. how would i go about setting the form within the scripts itself?
    also, thank you both for your help
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    EDIT: Check this post of the complete answer.


    plugged that in, but it had the same issue as just putting RAICHU_1 into pikachu's evolutions.
    i haven't quite figured out how to set forms within scripts just yet, but this here means that we're close to solving the issue. how would i go about setting the form within the scripts itself?
    also, thank you both for your help

    Is Alolan Raichu defined in your pokemonforms.txt? If so, can you send us the PBS code for Pikachu and Alolan Raichu?
    Also, can you screen the error too?
     
    Last edited:

    Foxx_Gaming

    Wacky Wahoo Pizza Pasta Man
    35
    Posts
    3
    Years
  • yes, alolan raichu is in pokemonforms.txt.
    here's the pbs code for pikachu (using the script above):
    Spoiler:

    and for a-raichu:

    Spoiler:

    as for the error:
    Spoiler:


    how this happened baffles me.
    the weird part about the sprite not being there is that RAICHU_1 DOES have a sprite in the right folder!

    Spoiler:
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    EDIT: Check this post of the complete answer.


    Paste this code near the code I gave you, and tell me what the DEBUG message is:

    Code:
    alias __debug__pbCheckEvolution pbCheckEvolution
    def pbCheckEvolution(pokemon,item=0)
      ret = __debug__pbCheckEvolution(pokemon, item)
      pbMessage(_INTL("DEBUG: Evolved species is: {1}, {2}", PBSpecies.getName(ret), ret)) if ret
      return ret 
    end
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    EDIT: Check this post of the complete answer.


    "DEBUG: Evolved species is: , 1035"
    the first one is totally empty.
    What is going on XD
    Replace the previous code with the message, with this one:

    Code:
    alias __debug__pbCheckEvolution pbCheckEvolution
    def pbCheckEvolution(pokemon,item=0)
      ret = __debug__pbCheckEvolution(pokemon, item)
      if ret 
        species_name = PBSpecies.getName(ret)
        form_name = pbGetMessage(MessageTypes::FormNames,ret)
        temp = pbGetSpeciesFromFSpecies(ret)
        form = temp[0]
        species_id = temp[0]
        fspecies_id = ret
        pbMessage(_INTL("DEBUG: species_name = {1}, form_name = {2}, fspecies_id = {3}, species_id = {4}, form = {5}", species_name, form_name, fspecies_id, species_id, form))
      
      end 
      return ret 
    end

    EDIT: Someone necro'd this topic. Does that help?
     
    Last edited:

    Foxx_Gaming

    Wacky Wahoo Pizza Pasta Man
    35
    Posts
    3
    Years
  • that topic appears to be for an older build of essentials, but i could try to translate.
    at any rate, i plugged in the new debug code. it says "DEBUG: species_name = , form_name = Alolan Form, fspecies_id = 1035, species_id = 26, form = 26"
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    EDIT: Check this post of the complete answer.



    that topic appears to be for an older build of essentials, but i could try to translate.
    at any rate, i plugged in the new debug code. it says "DEBUG: species_name = , form_name = Alolan Form, fspecies_id = 1035, species_id = 26, form = 26"

    That topic is for Essentials v16.2 but from what I saw, it should work with Essentials v18.1. Forms have always been a problem in Essentials XD
    I remember Pokémon Insurgence, where forms were defined as separate Pokémons ^^

    I made a mistake in my code:

    Code:
    alias __debug__pbCheckEvolution pbCheckEvolution
    def pbCheckEvolution(pokemon,item=0)
      ret = __debug__pbCheckEvolution(pokemon, item)
      if ret 
        species_name = PBSpecies.getName(ret)
        form_name = pbGetMessage(MessageTypes::FormNames,ret)
        temp = pbGetSpeciesFromFSpecies(ret)
        form = temp[1] # Here, replace 0 by 1
        species_id = temp[0]
        fspecies_id = ret
        pbMessage(_INTL("DEBUG: species_name = {1}, form_name = {2}, fspecies_id = {3}, species_id = {4}, form = {5}", species_name, form_name, fspecies_id, species_id, form))
      
      end 
      return ret 
    end
     
    Last edited:

    Foxx_Gaming

    Wacky Wahoo Pizza Pasta Man
    35
    Posts
    3
    Years
  • might still need to convert regardless, but if you say it should work, i'll take a look into it.
    new debug message with the error fixed (just replaces the last number with "1"): "DEBUG: species_name = , form_name = Alolan Form, fspecies_id = 1035, species_id = 26, form = 1"

    update: i looked into converting the code over to fit v18's structure, and either the pikachu evolved into normal raichu, or i got a syntax error upon either startup or evolution.
    pain.
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    EDIT: Check this post of the complete answer.


    might still need to convert regardless, but if you say it should work, i'll take a look into it.
    new debug message with the error fixed (just replaces the last number with "1"): "DEBUG: species_name = , form_name = Alolan Form, fspecies_id = 1035, species_id = 26, form = 1"
    Ok, this is weird. The Pokémon ID and the form seem correct.
    Can you try to make a Cubone evolve into its Alolan form, to see if you have the same problem? You'll need to be in a map with a different region number (check out the docs, check out the "MapPosition" row in the table).


    update: i looked into converting the code over to fit v18's structure, and either the pikachu evolved into normal raichu, or i got a syntax error upon either startup or evolution.
    pain.

    Cna you post the code?
     
    Last edited:

    Foxx_Gaming

    Wacky Wahoo Pizza Pasta Man
    35
    Posts
    3
    Years
  • here's my interpretation of a translation. all this does is give me regular raichu.
    Spoiler:

    as for the cubone, strangely enough, it'll evolve just fine in the other region.
    same with raichu, if and only if it's in the tiall region map. (context: pikachu form 0 evolving into raichu form 1 in tiall region)
    i'd like for it, as well as cubone and exeggcute, to be able to evolve into their alolan forms from anywhere, but if push comes to shove, i might just make it only evolve in ultra space.

    strangely enough tho, pikachu is missing its form 1 data in pokemonforms.txt, whilst cubone has it. i was told that it wouldn't matter as the two forms (pika form 0 and form 1) are more or less the same.
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    EDIT: Check this post of the complete answer.


    here's my interpretation of a translation. all this does is give me regular raichu.
    Spoiler:
    The syntax error is in the condition of the "if".
    It should be:
    Code:
        if pkmn.isSpecies?(:PIKACHU) && isConst?(item, PBItems, :SUNSTONE)

    But the correct translation for me, should be a variant of what I gave you before:
    Spoiler:


    as for the cubone, strangely enough, it'll evolve just fine in the other region.
    same with raichu, if and only if it's in the tiall region map. (context: pikachu form 0 evolving into raichu form 1 in tiall region)
    i'd like for it, as well as cubone and exeggcute, to be able to evolve into their alolan forms from anywhere, but if push comes to shove, i might just make it only evolve in ultra space.

    strangely enough tho, pikachu is missing its form 1 data in pokemonforms.txt, whilst cubone has it. i was told that it wouldn't matter as the two forms (pika form 0 and form 1) are more or less the same.
    Those two forms are similar indeed. I'll investigate this if the above doesn't work.
     
    Last edited:

    Foxx_Gaming

    Wacky Wahoo Pizza Pasta Man
    35
    Posts
    3
    Years
  • update, i've tried with the new syntax, nothing. i've tried it with your variation, still nothing. i've also tried re-adding the pikachu_1 form to see if that'd work. nope.
    i can only hope that you're able to figure something out with this, bc this is super confusing for me and going right over my head at times lol
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    EDIT: Check this post of the complete answer.


    update, i've tried with the new syntax, nothing. i've tried it with your variation, still nothing. i've also tried re-adding the pikachu_1 form to see if that'd work. nope.
    i can only hope that you're able to figure something out with this, bc this is super confusing for me and going right over my head at times lol

    Hey, so I did what I didn't want to do.
    I added the new evolution to my PBS files (I hate changing the PBS files because I have a bunch of custom compilers, so it takes 5 whole minutes to compile my own data).
    I checked the evolution scene, and it turns out you're kinda right and wrong. I mean; you didn't report the right bug, so I was investigating the wrong track.

    Also, I was wrong too. You CAN define RAICHU_1 as an evolution in the PBS file. I didn't realise but the compiler actually saves this data as a Symbol for later, and the point I made about the compiler needing to have the whole data too, is false.

    So, here is my finding.
    The bug is actually not in the actual evolution process, but in the files that the evolution scene uses. This is probable that this bug occurs in several other places of Essentials, but haven't been found yet. The fact is, if you give a species ID (like RAICHU_1), the evolution scene will look for the bitmap file that corresponds to RAICHU_1 (in your case, PBSpecies::RAICHU_1 == 1035), so it will look or that file, and will not know it is a form of a species. Some functions always convert a form ID into species ID + form, but some don't. The class that handles the evolution process doesn't do that conversion.

    Here is the (tested) solution to your problem:
    Remove everything I told you to add.
    In the PBS file for Pikachu, add RAICHU_1 for the second evolution:

    Code:
    Evolutions = RAICHU,Item,THUNDERSTONE,RAICHU_1,Item,SUNSTONE

    Then, a new script, add this code:

    Spoiler:


    Then, in the file PScreen_Evolution,
    In the class:
    Code:
    class PokemonEvolutionScene
    In the function:
    Code:
      def pbEvolutionSuccess
    Below
    Code:
        newspeciesname = PBSpecies.getName(@newspecies)
    paste this:
    Code:
        if !newspeciesname || newspeciesname == ""
          formname = pbGetMessage(MessageTypes::FormNames, @newspecies)
          newspeciesname = PBSpecies.getName(pbGetSpeciesFromFSpecies(@newspecies)[0])
          newspeciesname = newspeciesname + " - " + formname if formname != ""
        end

    This should solve your issue.
     
    Last edited:

    Foxx_Gaming

    Wacky Wahoo Pizza Pasta Man
    35
    Posts
    3
    Years
  • actually, one slight issue here. the evolution scene works perfectly, but now the message afterwards asking if it would like to learn a move doesn't display a name. i tried to paste in the code you have there, tweaking it a little bit, but no dice.
    update to the issue, it isn't just the message afterwards. rather, the pokemon's name entirely is missing post-evolution.
     
    Last edited:
    Back
    Top