[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
TrainerMonDouble sParty_Test1 and that
TRAINER_CALVIN_1 has its
- 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_tower.c, in the
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
Try out this thing
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
TrainerMonDoubleand processing them in
src/battle_tower.cfor the expansion.
- About the whole