• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

[ASM & Hex] Help Make My Pseudocode into Real Code ASM for Emerald and Ruby?

  • 15
    Posts
    4
    Years
    Pseudocode:
    It applies to all encounters and Pokemon trainer battles both NPC and Gym
    1. Check party pokemon's levels.

    2. Select the highest level pokemon in your team.

    3. Generate a pokemon wild or trainer based on the highest level pokemon possessed. The limit would be two levels above or below. For example: You have a level 15 Mudkip. The Pokemon generated would range from level 13 to 17.

    4. Check how many badges you possess. Depending on the badge, the trainer will have a different set of Pokemon whose level match according to step 3.

    5. If the trainer possesses a Pokemon which has a level at or exceeding its evolutionary level, evolve the pokemon. For example: A grunt has a level 25 Zubat and Ratatta. Make the game have them become a Golbat and Raticate because they exceed their evolution levels of 22 and 20.

    Optional: With number 5 in place, is there a way I can have the trainer analyze your Pokemon party's type and then randomly pick a non legendary Pokemon from a provided list of pokemon of that type to own?
    Or can I set the trainer to pick a Pokemon from a type group randomly?
    Example:
    My team: Spinarak 16 & Mudkip 15
    Bug/Poison, Ground/Water
    Battler generates: Drowzee 15 and Paras 16
    Second Example:
    Bug catcher: generates bug types from level 14 to 18 (due to Spinarak's level) from only bug type pokemon.
    So one run he could have a Butterfree 18 and Dustox 15 but another run a Pinsir 16 and Beedrill 17.



    I am looking to make an open world game with replayability.

    Thank you. 😀
     
    I would look into a few of the tutorials that are available to learn about assembly, including ones that are available on this forum. and general ARM ASM tutorials on YouTube. This basically involves looping through an array. The player's party is located at 0x020244EC in Emerald, while the opponent (wild or trainer) has their data at 0x02024744. The arrays are 6 entries of this data structure and are 100 bytes each. There's also a function that generates a 16-bit random number located at 0x0806F5CD. So, if you learn the basics of ASM, including how to loop through an array, set data structures, and compile and insert assembly into the game, doing what you want to do should be very simple. There's also a function that generates a specified pokemon, used by setwildbattle under the hood. It's located at 0x08067B4D in Emerald and it takes a pointer to whatever pokemon slot you want to change, the species as a 16 bit number, the level as an 8 bit number, the IVs as an 8 bit number, a flag that tells it whether you're giving it a custom PID (8 bit), the PID (32 bit), a flag for a custom TID (8 bit), and the TID (32 bit). As you learn ASM you'll realize it's basically a matter of putting all these values on the stack and then branching out to that address. The return value will be sent back to you in a register.

    Each game has a table for evolution stuff with the same data but at different locations. Here's a description of that. A table is basically a big array. So if you wanted to expand the very simple "generate a pokemon at the same level as your party" scheme, you'd need to find the table entry that corresponds to the pokemon you're looking at, read its evolutions, check if it has a level-up evolution (if the first byte = 0x0400), if yes, at what level, if the randomly generated level is higher, save your randomly generated level and generate a new pokemon with the ID of whatever's in the evolution table.

    Picking a pokemon of a specific type seems like such a pain. Because you'd have to loop through all 380something Pokemon (there's actually 400+ entries in the gen3 games, lot's of empty slots) and find all the pokemon for which one of its two types matches the type you want. Here's what pokemon data looks like in hex. At that point I would honestly take the time to just make 18 lists of pokemon IDs that contain all the pokemon of each type in order. Like use a hex editor to add that to your ROM and then loop through those whenever you want a random ghost type pokemon or whatever.

    Yeah it's a little intimidating but it gets easier the more you practice. There's a reason why a lot of ROM hacks don't add too many features that weren't available in the main games. The more cool features you want to add the better at hex editing and ASM you need to be
     
    Back
    Top