• 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] [19.1] Problem with changing form on evolution/defining form to evolve into

Kowi

avid Stadium 2 enjoyer
  • 5
    Posts
    4
    Years
    (first post on this site woooo)
    Basically, I want to incorporate a Pokémon being able to evolve into 2 seperate forms of the same species through seperate evolution methods.
    As it seems, that's not supported in Essentials by default, as simply adding something like ',RAICHU_1,Item,SUNSTONE' in the PBS only produces this in the error log:
    Spoiler:

    As I'm only starting to work with Essentials and never used Ruby before, I am not well versed with how the scripts work, so I've been looking around for workarounds.
    I've tried applying the fix described in post 18 of this thread, even though its made with v18 in mind: https://www.pokecommunity.com/showthread.php?t=466059
    But, to no avail, as I believe the methods it relies on are either deprecated or just removed in v19.1, because if i try to integrate it without any adjustment, the log spits out this:
    undefined method 'pbCheckPokemonBitmapFiles' for class 'Object'
    I've tried glancing over other functions that might be its new equivalent and replacing mentions of pbCheckPokemonBitmapFiles in the new script with them, but also to no avail, as I'm only getting numerous compiler errors if I try to run it then.
    I don't think it would help posting them here considering I am likely just on the complety wrong track in trying to fix this, which is why I'm asking for help here.
    I've also considered working around this by defining a new form for the base Pokémon, which it changes into while holding the evolution item, but with no visual change, and having it evolve by leveling up while holding said item, but I'd prefer a more elegant solution to this, if possible.
    If it matters, I'm using the Gen8 project, EBDX and the ZUD plugin.

    Would gladly appreciate any help on this.
     
  • 104
    Posts
    2
    Years
    • Seen Mar 12, 2024
    So the script page you want to be looking at is called Form Handlers. Its beneath [Pokemon-related]. Pikachu has a rather large section (as it has all the costume forms) but at the bottom is this code

    Code:
     "getForm" => proc { |pkmn|
        next if pkmn.form_simple>=2
        next if !$game_map
        map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
        next 1 if map_metadata && map_metadata.town_map_position &&
                  map_metadata.town_map_position[0] == 1   # Tiall region
        next 0
      },

    This is where you would create the split evolution ( the current split evolution is based on when evolving Pikachu on a Tiall region map.) I tinkered a little bit with it, but couldn't figure out how to make it evolution stone dependent yet, but I wanted to point you to the right area to edit.
    -next 1 is when it while evolve into Raichu Alolan
    -Next 0 is when it evolves into normal Raichu.

    The other form to look at is Lycanrocs, which defines the form on creation of Lycanroc as opposed to the evolution of Pikachu.

    Code:
    MultipleForms.register(:LYCANROC,{
      "getFormOnCreation" => proc { |pkmn|
        next 2 if PBDayNight.isEvening?   # Dusk
        next 1 if PBDayNight.isNight?     # Midnight
        next 0                            # Midday
      },
    })
    This just another example to look at.
     

    Kowi

    avid Stadium 2 enjoyer
  • 5
    Posts
    4
    Years
    Thanks, I'll try to work off of this.
    I mostly just used Raichu as an example as the other thread had it too, I'll also need this for Pokémon who don't really have alternate forms in the base game.
    If I encounter more problems, I'll post them here again.
     

    Frost the Fox

    FroststormFrenzy
  • 16
    Posts
    2
    Years
    • Seen Jun 14, 2023
    I'm currently working on getting a piece of code set up for this. It DOES work for changing the form, but I'm trying to make it differentiate between the two evolution methods and only change the form when it's needed.
     

    Frost the Fox

    FroststormFrenzy
  • 16
    Posts
    2
    Years
    • Seen Jun 14, 2023
    Yeah no I can't seem to get it to work. I got it working on levelling, but the same method I used there doesn't seem to work on item evolutions.

    I do have a few more ideas I'll try though, and I'll come back if there's any success
     
  • 104
    Posts
    2
    Years
    • Seen Mar 12, 2024
    I have figured out a way to do this for evolution stones/items (and presumably trades, but I don't have an interest in trade evos, so not tested.) It is not the cleanest looking code wise, but it works.

    Over on the "Evolution" page in the scripts you will see this code

    Code:
    GameData::Evolution.register({
      :id            => :Item,
      :parameter     => :Item,
      :use_item_proc => proc { |pkmn, parameter, item|
        next item == parameter
      }
    })

    This is the code for "Use on Pokemon" evolutions, like stones. Here you can make exceptions for specific Pokemon-item combinations like so:

    Code:
    GameData::Evolution.register({
      :id            => :Item,
      :parameter     => :Item,
      :use_item_proc => proc { |pkmn, parameter, item|
        if pkmn.isSpecies?(:PIKACHU) && item == (:SUNSTONE)
          pkmn.form = 1
        end
        next item == parameter
      }
    })

    This code makes it so that when you evolve a Pikachu using a Sunstone, it becomes form 1 version of Pikachu, allowing it to evolve into a Raichu-A.

    Note, with this code, if you were to devolve it using debug, it will always evolve into Raichu-A, regardless of how you evolve it (assuming you don't change anything else about its evolution.) This is because when you evolve it once, it permanently stays "form 1" unless something else changes its form. Its a non-issue except for while testing (or if you plan on making reverse evolution apart of your game), but I thought I'd bring it up in case someone tests by just devolving the same Pikachu.

    If you want to do multiple Pokemon with exceptions, you have to use "elsif" like so:

    Code:
    GameData::Evolution.register({
      :id            => :Item,
      :parameter     => :Item,
      :use_item_proc => proc { |pkmn, parameter, item|
        if pkmn.isSpecies?(:KOFFING) && item == (:DUSKSTONE)
          pkmn.form = 1
        elsif pkmn.isSpecies?(:PIKACHU) && item == (:SUNSTONE)
          pkmn.form = 1
        end
        next item == parameter
      }
    })

    You also have to remove parameters from the "FormHandlers" page, if a Pokemon has multiple forms registered there. If you don't remove them for this page, then it overwrites the form change on the "Evolutions" page.
     
    Back
    Top