• 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] Battle Engine Upgrade

46
Posts
17
Years
  • Seen Jan 23, 2024
It seems when I used this everything worked great but it glitches the Double Trainer Battle with Steven at Moss Deep in the Space Station. I imagine this has something to do with the 'custom battles' scripts. Any way to make sure this doesn't happen?

EDIT: Sorry realized I was using the old version of the battle engine here: https://www.pokecommunity.com/showthread.php?t=374338

Still if anyone knows how to change the backsprite in this battle or could help at all to fix this in my rom hack would be greatly appreciated. . .
 

Attachments

  • ec05tphib3k31.png
    ec05tphib3k31.png
    3.8 KB · Views: 35
Last edited:
10
Posts
4
Years
Mid-Battle Trainer Messages​

How do they work:
1) In your decomp, navigate to src/battle_messages.c, then search for the following structure inside it:

30LYqjr.png


Underneath it, you will find this:

jhx334v.png


Which is apparently nonsensical giving what the structure above is supposed to do.
This is because that is just a test line: It is there only to make you understand how the structure should work.
Honestly I found it to be more confusing than anything the first time I saw it, so let's just delete the sTrainerSlides content for now.

Now, imagine you've got a brand new Trainer you've just implemented in your decomp, (I'll use my Zinnia as an example), and you want to give it some cool mid-battle messages. Nothing simpler!
Navigate above until you find the strings of the mid-battle messages, it's better if you create the messages where the other messages end, so find:

4EQXhmj.png


And add your messages underneath it. The TrainerSlide struct by default needs the trainerId + 3 messages, where the messages are:
  1. The message that triggers when the Trainer only has one Pokemon left.
  2. The message that triggers when the last Pokemon of the Trainer has Low HP left.
  3. The message that triggers when the first Pokemon of the Trainer faints.

So we'll do as it follows:

2) we create the messages:
IuCekef.png


3) We assign them in the array:
hCo6Upw.png


Note: If you don't need one or more of those triggers, you can do as it follows:
For example, If you only want the Trainer to speak when It has got one pokemon left, but not when it is low or after the first Pokemon of the trainer faints,
you can just set the unwanted fields to NULL or 0. Like this:
axlOE8V.png


Now let's see how a complete message setup looks in-game!

First Pokemon Down: https://i.imgur.com/D5MhGKe.png
Last Pokemon: https://i.imgur.com/C60Cobf.png
Last Pokemon has Low HP: https://i.imgur.com/xBIqqNB.png

Done!

How to add more triggers:

Todo! I'll update this message when I got time.
 
Last edited:
5
Posts
4
Years
  • Age 38
  • Seen Jun 8, 2020
1) git clone *can't post links*
2) cd pokeemerald
3) git pull origin battle_engine_v2
4) git pull origin pokemon_expansion
5) Fix merge conflicts as I show in *can't post links*

I'm kinda new to Git and still learning so please bear with me. For me, the moment I have done step 3, there are merges that need attention before I can move on to step 4, none of which are the merges mentioned in step 5. If I skip step 1 and 2 and directly clone the battle_engine_v2 branch, then pull in the pokemon_expansion branch, I once again get a whole list of merges that need attention, none of which are the ones addressed in step 5.

I've read through the basics of the Git documentation and I think I understand the concepts of cloning, pulling, merging etc. but as far as merging goes, it tells you how but not why. Why do we fix those particular merge conflicts that aren't even listed as conflicts and not any of the others? How does one know which files need special attention and which ones don't? Clearly some people here just understand how without needing to be told, like the person that wrote this small guide. So there must be something obvious that I'm missing here. Any help?
 
1,591
Posts
10
Years
  • Age 30
  • Seen Mar 20, 2024
I'm kinda new to Git and still learning so please bear with me. For me, the moment I have done step 3, there are merges that need attention before I can move on to step 4, none of which are the merges mentioned in step 5. If I skip step 1 and 2 and directly clone the battle_engine_v2 branch, then pull in the pokemon_expansion branch, I once again get a whole list of merges that need attention, none of which are the ones addressed in step 5.

I've read through the basics of the Git documentation and I think I understand the concepts of cloning, pulling, merging etc. but as far as merging goes, it tells you how but not why. Why do we fix those particular merge conflicts that aren't even listed as conflicts and not any of the others? How does one know which files need special attention and which ones don't? Clearly some people here just understand how without needing to be told, like the person that wrote this small guide. So there must be something obvious that I'm missing here. Any help?

Presumably what's happening here is Egg's repos have been updated since Lunos wrote that guide, so now there are a different set of merge conflicts to resolve. When you're merging you'll always need to resolve all the conflicts for a successful merge; you can't pick and choose which ones need resolving and which ones don't. Conflicts happen when you have differences between two versions of a file and git can't figure out which version it should keep, so it asks you to decide instead. Usually it's pretty straightforward to figure out which changes you want to keep, but if you get stuck you can always ask here or over on pret's discord.
 
5
Posts
4
Years
  • Age 38
  • Seen Jun 8, 2020
Thank you. Yeah, it's obvious that when it comes to merging the base pokeemerald and battle engine upgrade, that it would basically just be a case of overwriting everything with the battle engine content. It's when it comes to merging the battle engine upgrade with the other modified content that I'm not sure where I would begin yet.

Is there any good reason that there isn't one unified 'Gen 7 Upgrade' branch anywhere? Is it to get people to learn how to use Git? Because I imagine that 99.9% of people that use this would want to use it with the other modifications too. I know that Git is supposed to be the superior way forward but it almost feels like the whole thing was just quicker and simpler when it involved patchers. At least if there was one unified branch, people could spend more time modding Pokemon Emerald and less time figuring out how to use Git.
 
1,591
Posts
10
Years
  • Age 30
  • Seen Mar 20, 2024
Thank you. Yeah, it's obvious that when it comes to merging the base pokeemerald and battle engine upgrade, that it would basically just be a case of overwriting everything with the battle engine content. It's when it comes to merging the battle engine upgrade with the other modified content that I'm not sure where I would begin yet.

Is there any good reason that there isn't one unified 'Gen 7 Upgrade' branch anywhere? Is it to get people to learn how to use Git? Because I imagine that 99.9% of people that use this would want to use it with the other modifications too. I know that Git is supposed to be the superior way forward but it almost feels like the whole thing was just quicker and simpler when it involved patchers. At least if there was one unified branch, people could spend more time modding Pokemon Emerald and less time figuring out how to use Git.

For the most part you can let the battle engine's changes take priority unless it's changing something related to Pokemon or item data. If you're familiar with C a quick skim through the conflicting code usually makes it clear which change to keep.

There are a couple of reasons I can think of to keep these as separate branches; it makes squashing bugs easier if each branch can be tested separately, and it's a lot easier to merge the branches than it is to separate them. There's at least one hack around that uses the battle engine without the Pokemon expansion. Initial set up with patches was definitely easier, but maintaining them is a nightmare compared to having proper version control with git. It's well worth learning to use it just so you don't need to have a folder of backups, and can revert bad changes with a single command or click.
 
Last edited:
5
Posts
4
Years
  • Age 38
  • Seen Jun 8, 2020
Thanks again for the info. I was hoping to use this as an exercise to learn C. I'm no stranger to tinkering with code but wouldn't call myself a coder, yet. This isn't the only C related project that I want to play with though so I think I'm going to actually look for an online course first, then come back here.

I just want to say that this is frikken amazing guys. Years ago when I first started 'modding' this game with a hex editor on my phone, I never thought it would reach the point where basically the whole game has been cracked wide open like this.
 
169
Posts
7
Years
  • Age 28
  • Seen Jan 17, 2023
Usually it's pretty straightforward to figure out which changes you want to keep, but if you get stuck you can always ask here or over on pret's discord.

I can't read code for crap, so if I could get a layman's terms walkthrough from someone, that'd be much appreciated. Specifically for the conflicts about pokemon.c and global.h; I don't even know where to begin with those.

(Bonus points if someone can help with any conflicts that might be present with the items expansion part, too)
 
1,591
Posts
10
Years
  • Age 30
  • Seen Mar 20, 2024
I can't read code for crap, so if I could get a layman's terms walkthrough from someone, that'd be much appreciated. Specifically for the conflicts about pokemon.c and global.h; I don't even know where to begin with those.

(Bonus points if someone can help with any conflicts that might be present with the items expansion part, too)
It's hard to say without seeing the conflicts; if you can post them (maybe put the entire file in a pastebin if there are too many to post) someone should be able to help. I'll certainly give it a try at least.
 
169
Posts
7
Years
  • Age 28
  • Seen Jan 17, 2023
It's hard to say without seeing the conflicts; if you can post them (maybe put the entire file in a pastebin if there are too many to post) someone should be able to help. I'll certainly give it a try at least.

All I get when I reach step 4 from the tutorial earlier in the thread (here) is "CONFLICT (content): Merge conflict in include/global.h"

I don't know what the conflict is; just that there's at least one, and that it exists in pokemon.c, global.h, level_up_learnsets.h, and base_stats.h. A full dump of what's spitted out when I follow step 4 in the tutorial should be here: https://pastebin.com/Zn1Tb83J

Edit: If any of this matters, this is being done with MSYS2 on Windows 10. Devkitpro and Pokeemerald are both in the C folder.
 
Last edited:
53
Posts
5
Years
  • Age 27
  • Seen Mar 9, 2022
If you'd like help, it's easier to obtain it in the Discord server. As some general useful information, you can use the command in MSYS2
Code:
git grep "<<<"
to find files that have "<<<" which are where the conflicts are.
 
169
Posts
7
Years
  • Age 28
  • Seen Jan 17, 2023
If you'd like help, it's easier to obtain it in the Discord server. As some general useful information, you can use the command in MSYS2
Code:
git grep "<<<"
to find files that have "<<<" which are where the conflicts are.

Call me old fashioned, but I like forums better than Discord for troubleshooting. When I use a search engine, I'll find forum threads in the results, not a Discord server. And in the event someone else has my problem and their first inclination is to use Google to try and fix it, I'd like to try and help by leaving some evidence in this thread.

Now, when I typed that in MSYS2, it only said which files have that string in there, which doesn't help much, since I already knew those were the files that have conflicts in them. Opening them up in Notepad++ and using control F to look for "<<<", however, lets me see exactly where in those files I can find that. Based on my experience editing the base_stats.h and level_up_learnsets.h files (for which the previously mentioned tutorial is still... mostly correct), the following bit of code looks suspect:
Spoiler:


Any instances of "<<<<<<<HEAD", "=======", and that bottom line of seemingly random numbers and letters are all suspect to me, that last one in particular since the only time I've seen it appear is exactly like that; I doubt it's trying to do anything with a different part of the code.
 
1,591
Posts
10
Years
  • Age 30
  • Seen Mar 20, 2024
Call me old fashioned, but I like forums better than Discord for troubleshooting. When I use a search engine, I'll find forum threads in the results, not a Discord server. And in the event someone else has my problem and their first inclination is to use Google to try and fix it, I'd like to try and help by leaving some evidence in this thread.

Now, when I typed that in MSYS2, it only said which files have that string in there, which doesn't help much, since I already knew those were the files that have conflicts in them. Opening them up in Notepad++ and using control F to look for "<<<", however, lets me see exactly where in those files I can find that. Based on my experience editing the base_stats.h and level_up_learnsets.h files (for which the previously mentioned tutorial is still... mostly correct), the following bit of code looks suspect:
Spoiler:


Any instances of "<<<<<<<HEAD", "=======", and that bottom line of seemingly random numbers and letters are all suspect to me, that last one in particular since the only time I've seen it appear is exactly like that; I doubt it's trying to do anything with a different part of the code.
You may want to take a look at Git's explanation of merge conflicts: https://help.github.com/en/articles/about-merge-conflicts. I don't think it's overly technical so it should be helpful, but if not, here's the short version: everything between "<<<<<<< HEAD" and "=======" is your current change (i.e. what your code looked like before the merge). Everything between "=======" and ">>>>>>>[hash]" is the new, incoming change that conflicts with the old code. To resolve the conflict you can choose to keep either the old code or the new code, or combine the two. Once you've decided what to keep, delete the rest and get rid of the "<<<<<<< HEAD", "=======" and ">>>>>>>[hash]" lines so that Git knows the conflict is resolved.

So for those conflicts I'd suggest the following:
Spoiler:
With the next conflict it doesn't matter which one you keep, all that's happening is a function input has been renamed and that won't affect anything outside of that function. I guess keep the old code for simplicity? Hard to say without the surrounding code.
 
169
Posts
7
Years
  • Age 28
  • Seen Jan 17, 2023
I apologize for the late reply, but thank you so much! Your explanation was exactly the thing I needed!

One last thing (hopefully): I added item_expansion and I believe I'm ready to actually make the damn thing. So I type in "make" and I get greeted with this:
Spoiler:

So it seems like I need this stddef.h file. Google isn't helping me terribly much, and I also don't know how bad those errors at the bottom are.
 
Last edited:
1,591
Posts
10
Years
  • Age 30
  • Seen Mar 20, 2024
I apologize for the late reply, but thank you so much! Your explanation was exactly the thing I needed!

One last thing (hopefully): I added item_expansion and I believe I'm ready to actually make the damn thing. So I type in "make" and I get greeted with this:
Spoiler:

So it seems like I need this stddef.h file. Google isn't helping me terribly much, and I also don't know how bad those errors at the bottom are.
No problem, glad I could help! Assuming you're using msys to build the ROM, that file should be in tools/agbcc/include after building agbcc. This wasn't always a required step, so if you followed an older set of installation instructions they wouldn't have mentioned it. Lunos has an excellent guide on the latest method here: https://www.pokecommunity.com/showthread.php?t=425246.
 

Outwitter

You reap what you plant...
163
Posts
6
Years
Is there any tutorial on how to fully utilize this engine? Normal editors won't work with this engine except porymap. There are ample tutorials and tools available for normal emerald hacking. I am planning a hack and would like to use this engine, but at the moment everything seems a bit confusing (No disrespect please). What are the possibilities and limits of this engine? Is there a simple workflow to follow and build on my ideas.
 

bcrobert

Lazy Antagonist
82
Posts
12
Years
  • Seen Aug 8, 2022
There are no limitations at all to this engine compared to traditional hacks. But the workflow will strictly involve coding.

Pros:
-No more pointer problems.
-More organized coding environment.
-Easily edit assets like sprites etc.
-Full engine at your fingertips.

Cons:
-Decidedly not beginner friendly.
-Tools are still in development.
-Documentation is sparse.

If you want to take the plunge then the pret discord server can help you a lot.
 
180
Posts
6
Years
  • Age 20
  • Seen Apr 15, 2024
Hi! Do you know how to set a Trainer's Pokémon's ability to its hidden ability? I wanted Wally to have a Kecleon with Protean without changing the ability Color Change
And, how can i set up multi battles?
 
Last edited:
7
Posts
5
Years
  • Age 24
  • Seen May 21, 2023
can someone hit me up with a compiled version. I cannot get it for the life of me.
 

Flowerchild

fleeting assembly
8,709
Posts
13
Years
can someone hit me up with a compiled version. I cannot get it for the life of me.

Even if sending you a ROM was allowed (it's not), it would be useless to you since to use decomps you need to edit a decompiled version and then build it yourself each change.
 
Back
Top