• 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] Mega Evolutions from Alternate Forms

7
Posts
6
Years
    • Seen Apr 18, 2018
    I saw a similar thread to this one several pages back, but it was in regards to v16, whereas I'm on 17. Currently trying to figure out how to have several different forms of the same species (mostly recolors) each evolve into their own corresponding megas. The pbs doesn't appear to allow for it - just for when it turns unmega. Spent all day searching for answers and this is me giving up and asking for help. Anyone, please? If my explanation is hard to understand, just assume I'd like to make separate mega evolutions for Alolan and Kantonian Ninetales or something. Just need to know how to script that and would like to avoid splitting their Pokédex numbers at all costs. Thanks for your time!
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    What you can do is have different mega stones (like with Charizard and Mewtwo) for the two different mega forms. In your case it would be a Ninetalesinite and an Alolan Ninetalesinite (abbreviate if you like). The PBS code would be as follows:
    Code:
    #-------------------------------
    [NINETALES-2]
    FormName=Mega Ninetales
    MegaStone=NINETALESINITE
    UnmegaForm=0
    #-------------------------------
    [NINETALES-3]
    FormName=Mega Alolan Ninetales
    MegaStone=ALOLANNINETALESINITE
    UnmegaForm=1
    The FormName is only needed if you want the mega forms to appear in the Pokédex. Stats, abilities, types, etc are defined in the PBS file like every other alternate form.

    EDIT: There may still be a potential bug where one form has the other form's mega stone attached.
     
    Last edited:
    7
    Posts
    6
    Years
    • Seen Apr 18, 2018
    Hey, thanks for the reply! But yeah, that's what I'm stuck on, actually. I tried exactly that with two different mega forms of Pidgeot. Now I need a way to make sure that only the intended form of that species can evolve into its corresponding mega. Seems like there has to be a way to either do that, or have, for example, form 2 mega evolve into form 5. Or if it's simpler, form 1 into form 11, 3 into 13, etc.
    I don't care whether or not I have to make a stone for every version of every mega, as long as it works, ya know?
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    I may have a way to pull this off. It will involve creating a function checking mega stones against the species' form:
    Code:
    class PokeBattle_Pokemon
      def getMegaForm(itemonly=false)
        formdata = pbLoadFormsData
        return 0 if !formdata[@species] || formdata[@species].length==0
        ret = 0
        dexdata = pbOpenDexData
        for i in formdata[@species]
          next if !i || i<=0
          pbDexDataOffset(dexdata,i,29)
          megastone = dexdata.fgetw
          if megastone>0 && self.hasItem?(megastone) [COLOR="red"]&& formMatches?(megastone)[/COLOR]
            ret = i; break
          end
          if !itemonly
            pbDexDataOffset(dexdata,i,56)
            megamove = dexdata.fgetw
            if megamove>0 && self.hasMove?(megamove)
              ret = i; break
            end
          end
        end
        dexdata.close
        return ret  # fSpecies or 0
      end
    
      [COLOR="red"]def formMatches?(megastone)
        case @species
        when PBSpecies::NINETALES
          case @form
          when 0
            return true if isConst?(megastone,PBItems,:NINETALESINITE)
            return false
          when 1
            return true if isConst?(megastone,PBItems,:ALOLANNINETALESINITE)
            return false
          end
        else
          return true if megastone>0 && self.hasItem?(megastone)
          return false
        end
      end[/COLOR]
     
    Last edited:
    7
    Posts
    6
    Years
    • Seen Apr 18, 2018
    That worked! Thank you very much. I?ll go with that as a backup plan if necessary, but I was hoping for a way to make a certain one of a Pokemon?s form numbers line up with another one by using the same mega stone. Since nearly every species is going to have at least two alternate color forms, that would probably be easier in the end.

    I was thinking of having the script force form 1 to M Evo to form 11, 2 to 12, etc. OR set up a line in pokemonforms.txt called MegaForm to basically serve as a reverse of the existing Unmega line. I?ve been playing with both possibilities and have learned a lot about the script in the process, but it?s got me stumped.

    Does anyone have an idea or suggestion, or should I go about it the long way?
     
    Last edited:
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    This code will allow you to set multiple mega forms using the same mega stone:
    Code:
    class PokeBattle_Pokemon
      def getMegaForm(itemonly=false)
        formdata = pbLoadFormsData
        [COLOR="Red"]multiformspec = [PBSpecies::NINETALES, PBSpecies::PIDGEOT][/COLOR] [COLOR="Green"]# add more species if necessary[/COLOR]
        return 0 if !formdata[@species] || formdata[@species].length==0
        ret = 0
        dexdata = pbOpenDexData
        for i in formdata[@species]
          next if !i || i<=0
          pbDexDataOffset(dexdata,i,29)
          megastone = dexdata.fgetw
          if megastone>0 && self.hasItem?(megastone)
            [COLOR="Red"]if multiformspec.include?(@species)
              ret = @form + 10; break
            else[/COLOR]
              ret = i; break
            [COLOR="red"]end[/COLOR]
          end
          if !itemonly
            pbDexDataOffset(dexdata,i,56)
            megamove = dexdata.fgetw
            if megamove>0 && self.hasMove?(megamove)
              ret = i; break
            end
          end
        end
        dexdata.close
        return ret  # fSpecies or 0
      end
    This will ensure form 1 goes to form 11, form 2 goes to form 12, etc.
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • You could as well add a condition to the pbs file. Just like MegaMove, which enables Mega Evolution only when a certain move is known. You could call it like MegaForm or sth. But it requiressome scripting to make this possible. On the positive side though it makes it much easier to define those special forms for multiple Pokemon. I think it's a good option unless you only need to define 1-4 Mons.
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    You could as well add a condition to the pbs file. Just like MegaMove, which enables Mega Evolution only when a certain move is known. You could call it like MegaForm or sth. But it requiressome scripting to make this possible. On the positive side though it makes it much easier to define those special forms for multiple Pokemon. I think it's a good option unless you only need to define 1-4 Mons.
    That can be done as follows:

    In Compiler, add the line in red under this line:
    Code:
        "MegaMessage"      => [58,"u"]
        [COLOR="Red"]"MegaForm"         => [59,"u"][/COLOR]

    In Pokemon_MegaEvolution, add the lines in red:
    Code:
    class PokeBattle_Pokemon
      def getMegaForm(itemonly=false)
        formdata = pbLoadFormsData
        return 0 if !formdata[@species] || formdata[@species].length==0
        ret = 0
        dexdata = pbOpenDexData
        for i in formdata[@species]
          next if !i || i<=0
          pbDexDataOffset(dexdata,i,29)
          megastone = dexdata.fgetw
          if megastone>0 && self.hasItem?(megastone)
            ret = i; break
          end
          if !itemonly
            pbDexDataOffset(dexdata,i,56)
            megamove = dexdata.fgetw
            if megamove>0 && self.hasMove?(megamove)
              ret = i; break
            end
          end
          [COLOR="Red"]pbDexDataOffset(dexdata,i,59)
          megaform = dexdata.fgetb
          if megaform>0 && self.hasItem?(megastone)
            ret = i; break
          end[/COLOR]
        end
        dexdata.close
        return ret  # fSpecies or 0
      end
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • That can be done as follows:

    In Compiler, add the line in red under this line:
    Code:
        "MegaMessage"      => [58,"u"]
        [COLOR="Red"]"MegaForm"         => [59,"u"][/COLOR]

    In Pokemon_MegaEvolution, add the lines in red:
    Code:
    class PokeBattle_Pokemon
      def getMegaForm(itemonly=false)
        formdata = pbLoadFormsData
        return 0 if !formdata[@species] || formdata[@species].length==0
        ret = 0
        dexdata = pbOpenDexData
        for i in formdata[@species]
          next if !i || i<=0
          pbDexDataOffset(dexdata,i,29)
          megastone = dexdata.fgetw
          if megastone>0 && self.hasItem?(megastone)
            ret = i; break
          end
          if !itemonly
            pbDexDataOffset(dexdata,i,56)
            megamove = dexdata.fgetw
            if megamove>0 && self.hasMove?(megamove)
              ret = i; break
            end
          end
          [COLOR="Red"]pbDexDataOffset(dexdata,i,59)
          megaform = dexdata.fgetb
          if megaform>0 && self.hasItem?(megastone)
            ret = i; break
          end[/COLOR]
        end
        dexdata.close
        return ret  # fSpecies or 0
      end

    Is it tested? Looks like exactlywhat I had in mind
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    During testing, I realised an even easier method that doesn't involve adding new keys to pokemon.txt or pokemonforms.txt:
    Code:
    class PokeBattle_Pokemon
      def getMegaForm(itemonly=false)
        formdata = pbLoadFormsData
        return 0 if !formdata[@species] || formdata[@species].length==0
        ret = 0
        dexdata = pbOpenDexData
        for i in formdata[@species]
          next if !i || i<=0
          pbDexDataOffset(dexdata,i,29)
          megastone = dexdata.fgetw
          if megastone>0 && self.hasItem?(megastone)
            [COLOR="Red"]pbDexDataOffset(dexdata,i,37)
            unmegaform = dexdata.fgetb
            if @form == unmegaform
              [/COLOR]ret = i; break
            [COLOR="Red"]end[/COLOR]
          end
          if !itemonly
            pbDexDataOffset(dexdata,i,56)
            megamove = dexdata.fgetw
            if megamove>0 && self.hasMove?(megamove)
              ret = i; break
            end
          end
        end
        dexdata.close
        return ret  # fSpecies or 0
      end
     
    Last edited:
    7
    Posts
    6
    Years
    • Seen Apr 18, 2018
    Sorry for the delay. That?s exactly the script I was trying to make on my own. Was closer than I thought! But I don?t have a very deep understanding of how it works.

    When I implement this last one you sent - and I triple checked to make sure it?s all in there properly - my Pok?mon goes to the correct Mega form, but skips the mega evo animation and doesn?t devolve at the end of the battle for some reason. I had this issue in some of my own attempts at well.

    Think I forgot to mention that I?m using EBS. Would that make a difference here? Sorry; it didn?t even occur to me until now that it could potentially play a role in the issue.
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    I don't really know if scripting on the EBS is any different compared to the original.
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • Sorry for the delay. That?s exactly the script I was trying to make on my own. Was closer than I thought! But I don?t have a very deep understanding of how it works.

    When I implement this last one you sent - and I triple checked to make sure it?s all in there properly - my Pok?mon goes to the correct Mega form, but skips the mega evo animation and doesn?t devolve at the end of the battle for some reason. I had this issue in some of my own attempts at well.

    Think I forgot to mention that I?m using EBS. Would that make a difference here? Sorry; it didn?t even occur to me until now that it could potentially play a role in the issue.

    There might be an unmega script in the ebs that you need to modify
     
    7
    Posts
    6
    Years
    • Seen Apr 18, 2018
    In any case, thank you so much for the script and the help. And I?ll be searching the EBS section for everything related to mega evolution to check for hints. The word ?unmega? isn?t in that area at all, but the issue has to be in here or an area referenced by it, I suppose.
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • In any case, thank you so much for the script and the help. And I?ll be searching the EBS section for everything related to mega evolution to check for hints. The word ?unmega? isn?t in that area at all, but the issue has to be in here or an area referenced by it, I suppose.

    I recommend using the general search to find all instances of the word unmega
     
    7
    Posts
    6
    Years
    • Seen Apr 18, 2018
    That was my initial thought, but it turned out that the term isn?t used a single time in all of the EBS scripts. I spent most of yesterday and all of this morning trying to get the issue ironed out, and just now got it to manage the forms properly by making a few changes to the original MegaEvolution script. Now, I believe all that?s amiss is the animation for the mega evolving process, which isn?t playing at all. Hopefully that won?t take as long to figure out!
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • That was my initial thought, but it turned out that the term isn?t used a single time in all of the EBS scripts. I spent most of yesterday and all of this morning trying to get the issue ironed out, and just now got it to manage the forms properly by making a few changes to the original MegaEvolution script. Now, I believe all that?s amiss is the animation for the mega evolving process, which isn?t playing at all. Hopefully that won?t take as long to figure out!

    I think the animation is not even there in vanilla essentials. Then you'd need to add it
     
    7
    Posts
    6
    Years
    • Seen Apr 18, 2018
    Okay, I thought that was the case. We initially planned not to use EBS, then changed our minds a couple of months ago, but we didn?t add any Megas until just a few weeks ago. The animation apparently came with EBS, because it worked until I brought in variants of Megas within the same species. Just had to adjust several things here and there, but I hope I don?t have to do it again. Forgot to make notes on a couple of the changes. :/
     
    Back
    Top