View Single Post
Old 30th July 2014, 10:50 PM  
Reaching new heights
Sky0fBlades's Avatar
Join Date: Sep 2012
Location: ☆ • ○ ° ☾
Age: 24
Posts: 100
Default [Emerald] Controlling Trainer Battle Music... Without ASM.

Controlling Trainer Battle Music in Pokemon Emerald... Without ASM

by Sky0fBlades

Supplies List:

☆ A Pokemon: Emerald ROM
XSE (Xtreme Script Editor) by HackMew
☆ Some basic scripting ability

Intro, and Method:

Hey again guys. Ever since I've gotten back into hacking I've been making all sorts of little 'discoveries' and whatnot and here's a good one that I managed to somehow pull off a long time ago but ever since then totally forgot how. I've noticed there's a few guides out there for this kind of thing but they either require ASM (assembly language) or a different ROM like FireRed. Some of us don't prefer having to use ASM, some aren't hacking FireRed. Basically, I needed to figure this out through trial and error - especially since I already knew it was possible. I think this is a different method than the one I used before... but whatever works, right? It's easy, here's how you do it:

Make a trainer battle script that uses this format, and fill in the "?"s with what you want. All bold parts are very important things that seem to have to be in that order (just to make sure the song plays at the same time the battle does). In Italics are the comments (you can leave them there if you copy-paste), and the red parts are things you may/may not need to change:
#freespace 0xFF
#dynamic 0x9C0B20

#org @start
checkflag 0x???? // *Has this trainer been beaten?
if 0x1 goto @nobattle
playsong 0x??? 0x0 // Trainer's intro theme.
msgbox @intro MSG_KEEPOPEN // You'll need to put this here, or the battle will start with no intro.
special 0x3E // Special that makes a default battle happen. Required.
playsong 0x??? 0x0 // What song you want during battle.
trainerbattle 0x0 0x??? 0x0 @intro @defeated
setflag 0x???? // *Trainer has been beaten.

#org @nobattle
msgbox @afterward MSG_KEEPOPEN

#org @intro
= Hi there. I can beat you. Easily.

#org @defeated
= You just killed me bro!

#org @afterward
= See you around. My team's wasted...
*= About the setflag commands... This script was mostly made for special trainer battles (ones where they don't challenge you on sight like the average route trainer). I tested it without the setflag and with a typical trainer ID and the battle could be repeated over and over without them, likely because of the additional commands in this script that aren't in normal battles.

Now, Special 0x3E is the real key here. It's purpose is to simply start a trainer battle that can be customized somewhat as long as things are in the right order. If you don't use it, as far as I know it will never give you the right results. It has specific equivalents in the other games (Ruby, FireRed), and you can find those in their special lists which have been publicized already.

EDIT: The values you use for "playsong" can be found in Advance-Map's "Musik_??.ini" files (be sure to find the correct game code: BPEE for the US Emerald ROM), and in Sappy's song list - though Sappy displays them in decimal instead of hex.

You should be able to pull off this same thing the same way with other types of trainer battles (double, gym), although it could work a little differently. Go ahead and experiment though, make things work for you. Thanks for reading.

UPDATE: Here's a script template I wrote for Gym Battles, which I posted later in this thread:

Last edited by Sky0fBlades; 18th March 2015 at 09:29 AM.
Sky0fBlades is offline   Reply With Quote