• 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] "Evolution Chaos" in Essentials?

  • 30
    Posts
    11
    Years
    • Seen Apr 9, 2023
    I recently got turned on to a Pokemon challenge concept in which the Pokemon evolve every single level, but most importantly they evolve into a random species. Presumably one of any available.
    I am quite charmed by the concept tbh, and I was wondering if anyone here knows what must be done (if its possible) to make that happen in essentials?
    Certainly it sounds like a lot going on, but I think the thing that would trip me up the most would be how to make the evolution chosen randomly.

    I would also consider a similar principle if that was too complicated. Perhaps simply a script the player can run to change a pokemon in question to any other randomly. Pretty much the same output for the player, but doesn't have to be tasked through the evolution process? Not sure if that makes it easier or harder to do though.

    If anyone has any insight or even a process to go about doing this, I'd love to hear it! Thanks either way.
     

    StCooler

    Mayst thou thy peace discover.
  • 9,308
    Posts
    4
    Years
    • Seen yesterday
    It sounds entirely possible to implement in Pokémon Essentials, but that would require a custom script.
    Since you're posting in the Game Development forum, I assume that you're looking for tips on how to do it in Pokémon Essentials (the framework we use to make fangames, which is not the same as Rom Hacks or Decompilations).

    Also, the current version of Pokémon Essentials is v20.1, but I know only v18.1. I do know that many things changed between v18 and v19, and between v19 and v20, but I don't know what / how. Maybe what I'm going to tell you doesn't exist anymore but it probably still contains the word "Evolution" in the names, so you can adapt what I'm saying.

    Anyway, in Essentials v18, you can look into how
    Code:
    def pbCheckEvolution(pokemon,item=0)
    works.

    The complete code is:

    Code:
    def pbCheckEvolution(pokemon,item=0)
      if item==0
        return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke|
          next pbMiniCheckEvolution(pokemon,evonib,level,poke)
        }
      else
        return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke|
          next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
        }
      end
    end

    Code:
    pbCheckEvolutionEx(pokemon)
    allows to loop through all the evolution methods that the current Pokémon may have, and the line:
    Code:
    pbMiniCheckEvolution(pokemon,evonib,level,poke)
    checks whether the conditions are met for the Pokémon to evolve.
    Thus, the three functions gets the ID of the first valid Pokémon species to evolve into (or -1 if the Pokémon cannot evolve).

    Which function should you edit?

    You mention evolving on levelling up. This happens during battle, or when you give a Candy to your Pokémon. After a quick search, I found out that evolution on change of level is handled by
    Code:
    def pbCheckEvolution(pokemon,item=0)
    so I'd say that's the function you should edit.

    How to edit an existing function? Ruby is a fantastic language because it allows rewriting functions. It's an automatic backup. So, create a new script above Main, and start like this:

    Code:
    alias __evolutionchaos__pbCheckEvolution pbCheckEvolution
    def pbCheckEvolution(pokemon,item=0)
      return rand(PBSpecies.maxValue) + 1
    end
    This code chooses a random species among all the species. Note that if you want to also include forms, you can use:
    Code:
      return rand(PBSpecies.maxValueF) + 1
    You can also do it a smarter way (for example, by filtering some Pokémons), but I'm too lazy to do it right now lol.
    Note that modifying the function this way is very "brutal", in the sense that I'm not adding tests on whether it's evolving with an item; maybe you want to preserve the normal evolution if you're given an item and not levelling up. Or maybe you want to use a switch so the player (or the dev) can control when the Pokémon should evolve randomly.

    Combining those ideas, the code would look like this:

    Code:
    alias __evolutionchaos__pbCheckEvolution pbCheckEvolution
    def pbCheckEvolution(pokemon,item=0)
      return rand(PBSpecies.maxValue) + 1 if item == 0 && $game_switches[SOME_SWITCH] # if no item is given, and if some switch is triggered.
      return __evolutionchaos__pbCheckEvolution(pokemon,item) # Otherwise, just return the usual function.
    end
     
  • 30
    Posts
    11
    Years
    • Seen Apr 9, 2023
    You are a magician honestly. I'm shocked that not only did some one figure out how to do it, but they were able to explain it to me so easily that I got it working in just a few minutes.
    I thought it would take a lot more work honestly.
    So that being said, do you have any creative solutions to the "evolve every level" thing?
    I know of the most straightforward way of course. Just edit the PBS to have an evolution for every single level. Seems like a LOT of work and of course will completely prevent there from being a way to turn it off within the same game.

    If you have any ideas on that, I can't wait to hear them. But even if not, know you have helped me tremendously. I am extremely excited to experiment with this now!
     

    StCooler

    Mayst thou thy peace discover.
  • 9,308
    Posts
    4
    Years
    • Seen yesterday
    You are a magician honestly. I'm shocked that not only did some one figure out how to do it, but they were able to explain it to me so easily that I got it working in just a few minutes.
    I thought it would take a lot more work honestly.
    😊

    I would also consider a similar principle if that was too complicated. Perhaps simply a script the player can run to change a pokemon in question to any other randomly. Pretty much the same output for the player, but doesn't have to be tasked through the evolution process? Not sure if that makes it easier or harder to do though.

    So that being said, do you have any creative solutions to the "evolve every level" thing?
    I know of the most straightforward way of course. Just edit the PBS to have an evolution for every single level. Seems like a LOT of work and of course will completely prevent there from being a way to turn it off within the same game.

    If you have any ideas on that, I can't wait to hear them. But even if not, know you have helped me tremendously. I am extremely excited to experiment with this now!

    I forgot to reply to the second question lol, but I'm not sure what you want to do.
    The second question from your original post seems to mean that you want, say, an event that you can talk to, and that changes a given Pokémon from your party to another Pokémon?
    But I don't understand what you mean in your second post, it doesn't seem to correlate my first interpretation...
     
  • 30
    Posts
    11
    Years
    • Seen Apr 9, 2023
    I forgot to reply to the second question lol, but I'm not sure what you want to do.
    The second question from your original post seems to mean that you want, say, an event that you can talk to, and that changes a given Pokémon from your party to another Pokémon?
    But I don't understand what you mean in your second post, it doesn't seem to correlate my first interpretation...

    The second question was simply there as a backup plan in case it was too difficult to make this happen within the actual evolution routine. I assumed it would be much more complicated than a single line of code haha. I figured if there was just an item or a script I could run or something to make it happen every time a Pokemon would level manually that would be fine too, but seems that's not needed, so we can move past that.

    In terms of the rest though, I'll explain more specifically what the "evolution chaos" runs are so that I might elucidate the problem further.

    Evolution Chaos is a run where EVERY level a pokemon will evolve, and that evolution will be entirely random. It gets wild because you might be coming up to a gym and your pokemon evolves from a legendary into a baby, so they you are trying to figure out what to do etc. Pretty interesting challenge.

    Anyway, your masterful code accomplished what I expected to be the difficult part. That being the "evolve into random pokemon" part.
    Like I said, the other half (evolve every single level into something) is very straightforward. All it would require is altering the PBS of every single pokemon to just actually evolve into anything every level.
    But of course altering the PBS means that the game is permanently altered.

    So I was wondering if you knew of anything you could do to make it so whenever you level at all, this concept happens.

    In my completely uneducated head, I imagine something like
    IF a pokemon gains a level
    THEN trigger the evolution script
    WHEN the Switch is turned on

    Or perhaps you can just rewrite it to not even loop through evolving or something, idk.

    Either way, thanks so much!
     

    StCooler

    Mayst thou thy peace discover.
  • 9,308
    Posts
    4
    Years
    • Seen yesterday
    I apologize, I still don't understand. You admit that my script already does what you want, so I don't understand the difference between what I've already coded, and what you specify.

    So I was wondering if you knew of anything you could do to make it so whenever you level at all, this concept happens.

    In my completely uneducated head, I imagine something like
    IF a pokemon gains a level
    THEN trigger the evolution script
    WHEN the Switch is turned on

    This is exactly what my code does, and you've stated that you've tested the code, so I really don't understand what's missing?
     
  • 30
    Posts
    11
    Years
    • Seen Apr 9, 2023
    This is exactly what my code does, and you've stated that you've tested the code, so I really don't understand what's missing?
    Oh wow I'm just a dummy apparently. Honestly, I just (yet again) assumed this would be something more complicated. I tested it on a bunch of Pokemon that I knew would evolve at a specific level and then just came right back here lol...
    I'm sorry to have wasted your time after you answered the question perfectly the first time.

    I didn't understand what I was reading the first time, and now I certainly can not understand it all together, but I thank you again for your amazing work and quick response!
     
    Back
    Top