• 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.

[Pokeemerald] Choose between 2 pokémon to decide trainer party

3
Posts
4
Years
  • [PokeEmerald] Choose between 2 random pokémon to decide trainer party.

    I wanted to implement a rematch system that lets you slightly randomize a battle but with constant values, it was easy and I haven't seen anybody else explain something like this yet so, here's how to do it.
    There's comments in the code about naming standards and a few thoughts too. Feel free to remove those in your actual code.

    For people who only want to copypaste, you can check out this branch's comparison in github. You can also git pull. Note that there's a test party in src/data/trainer_parties.h TrainerMonDouble sParty_Test1 and that src/data/trainers.h TRAINER_CALVIN_1 has its .party modified.

    Notes:
    • I tried implementing this with (constant) arrays but since my experience is mostly C# I have no idea how unions, pointers and const work in C, I couldn't figure an implementation. If you have any ideas don't be shy to share.
    • If you want an implementation with trainer_control or trainer_control_v2 hit me up and I'll look into it.
    • This tutorial works for pokeemerald and in the case of pokeemerald-expansion the steps are identical but also you need to add the same logic that we added in src/battle_main.c into src/battle_tower.c, in the FillPartnerParty function.

    Setup
    Spoiler:

    Now we are done. Yes, this is it, there's really no need to do anything else. The next steps are optional, but recommended to flesh out the code and to test it in an actual battle.


    Flesh out the code by adding support for F_TRAINER_PARTY_RANDOM
    Spoiler:


    • Try out this thing
      Spoiler:


      I think this is my first post here in pokecommunity btw, hi. Anyways, some additional thoughts,
      • About the whole switch(partyFlags) ordeal, I'm pretty sure that, since most of the code is shared and that the flags are actually bit shifted in the defines, there's a way to simplify the code into just bitwise checks, instead of a switch case for each F_TRAINER_PARTY_CUSTOM_MOVESET, F_TRAINER_PARTY_HELD_ITEM, F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM, etc.
      • Some code in switch(partyFlags) could also get sent to a function that processes the partyData common stuff, which is the name hash, personality value, iv, level and creating the mon. Specific changes can go after.
      • You can keep it working for 2 mons or extend it so it can work with more than that, by just adding more entries in TrainerMonDouble and processing them in src/battle_main.c and src/battle_tower.c for the expansion.
     
    Last edited:
    3
    Posts
    4
    Years
  • Well, I'm sorry. I've made a few mistakes in the tutorial that I'll update as soon as I can. Meanwhile, the code in the repo works properly.
     
    Back
    Top