PHO - Pokémon Hackers Online
Go Back   PHO - Pokémon Hackers Online > ROM Hacking > Guides & Documentation

Guides & Documentation Learn how to make your own Pokémon game through the process of ROM Hacking, or help out the community by sharing your information.

Reply
 
Thread Tools Display Modes
Old 8th January 2017, 11:41 PM   #21
Thirteen1355
n00b
 
Thirteen1355's Avatar
 
Join Date: Jan 2017
Location: Lands of Nether
Posts: 6
Thirteen1355
Default

Hello, @Sky0fBlades, many thanks for helping me out in advance with the information you posted earlier!
I want to do the same thing as Gameskiller01, change an already existing trainer so I can change the music. I have opened the script for Sidney of the Elite Four in this case. What exactly do I have to do now? Do I just have to add:
special 0x3E
playsong 0x1C2 0x0
(1C2 is Leaf Green Elite 4 song)
just above the trainerbattle line, and should it work then?
And how do you save the script into the ROM?

This is the part of the script I'm referring to, with the lines I added in bold:
'---------------
#org 0x109A4D3
lock
faceplayer
checkflag 0x1202
if 0x1 goto 0x909A710
special 0x3E
playsong 0x1C2 0x0

trainerbattle 0x1 0x201 0x0 0x90D8C02 0x90D8C8A 0x909A72D
msgbox 0x9107066 MSG_FACE '"IVAN: I am not familiar with the\n..."
release
end
Is this how it should be done?

Last edited by Thirteen1355; 9th January 2017 at 12:12 PM.
Thirteen1355 is offline   Reply With Quote
Sponsored Links
Old 9th January 2017, 10:54 PM   #22
Sky0fBlades
Reaching new heights
 
Sky0fBlades's Avatar
 
Join Date: Sep 2012
Location: ☆ • ○ ° ☾
Age: 24
Posts: 103
Sky0fBlades
Default

Quote:
Originally Posted by Thirteen1355 View Post
Hello, @Sky0fBlades, many thanks for helping me out in advance with the information you posted earlier!
I want to do the same thing as Gameskiller01, change an already existing trainer so I can change the music. I have opened the script for Sidney of the Elite Four in this case. What exactly do I have to do now? Do I just have to add:
special 0x3E
playsong 0x1C2 0x0
(1C2 is Leaf Green Elite 4 song)
just above the trainerbattle line, and should it work then?
And how do you save the script into the ROM?

This is the part of the script I'm referring to, with the lines I added in bold:
'---------------
#org 0x109A4D3
lock
faceplayer
checkflag 0x1202
if 0x1 goto 0x909A710
special 0x3E
playsong 0x1C2 0x0

trainerbattle 0x1 0x201 0x0 0x90D8C02 0x90D8C8A 0x909A72D
msgbox 0x9107066 MSG_FACE '"IVAN: I am not familiar with the\n..."
release
end
Is this how it should be done?
Hey there @Thirteen1355, welcome to the forum. I tried to use my method with Sidney's script, but that one seems a bit tricky compared to the others for some reason. Those Elite 4 battles seem to have some kind of attribute where the battle itself will be immediately repeated once, with the first time using the new music and the second time using its normal theme; only then moving on to the rest of the event. This problem was mentioned earlier as a script offset problem, but it seems to still be happening to me after double-checking the offset.

Right now I'm not certain why this happens, but with the script you showed me here it should work as long as you have the other elements of the script (like the other message boxes you need) working too. You are hacking Emerald, right? If not, you will need FR/LG's variant of "special 0x3E", which is apparently "special 0x3B". If you are hacking FR/LG, the song #s don't go as high as 0x1C2, which in Sidney's script in Emerald is the song that plays when you talk to him before the battle. Hopefully this helped. Just give it a try, if it doesn't work just let me know and I'll see what I can do to help.

Oh yeah, almost forgot: to save the script into the ROM, open it in A-Map (assuming that you are using a new offset instead of the original), browse to and open the event script you want to change in XSE, edit it in XSE, then use XSE to compile it (but after replacing the old offset with a dynamic one so you don't overwrite other data). Copy the offset it gives you, paste this offset into the offset box in A-Map for your event, then save the ROM in A-Map. It seems that if using A-Map 1.95, you may have to exit out of the program to really save the changes to the ROM. If you are using the same offset the whole time, make sure that it won't take up any more space than it did before, and then recompile it. I mention dynamic offsets here too

Last edited by Sky0fBlades; 9th January 2017 at 11:30 PM.
Sky0fBlades is offline   Reply With Quote
Old 10th January 2017, 01:33 AM   #23
Thirteen1355
n00b
 
Thirteen1355's Avatar
 
Join Date: Jan 2017
Location: Lands of Nether
Posts: 6
Thirteen1355
Default

Thanks for the detailed explanation! The elite four guy was actually just an example of the trainers I wanted to change the music of. I also want tot change Gym Leader and normal trainer music.

And yes, I'm editing Emerald, or better said, Pokémon Glazed. I wanted to make all Johto trainers play custom-made music (based on Gold and Silver music).

But if I understand correctly, you cannot just keep the same offset of the trainer script, even though you are only adding two lines to an already existing trainer script?

EDIT:
So I just boldly (after making a backup of course) added these two lines to the Elite Four member.
*(special 0x3E
playsong 0x1C2 0x0)*
Compiled the script, and tested. The outcome was something like you said already. The battle immediately starts upon talking to the member, playing the E4 encounter music during the battle. After defeating him, the door leading to the next room doesn't open, and upon talking to the member again, the battle starts over:
https://www.youtube.com/watch?v=lKBaN0R_LGk

Last edited by Thirteen1355; 10th January 2017 at 01:55 AM.
Thirteen1355 is offline   Reply With Quote
Old 10th January 2017, 06:53 PM   #24
Sky0fBlades
Reaching new heights
 
Sky0fBlades's Avatar
 
Join Date: Sep 2012
Location: ☆ • ○ ° ☾
Age: 24
Posts: 103
Sky0fBlades
Default

Quote:
Originally Posted by Thirteen1355 View Post
Thanks for the detailed explanation! The elite four guy was actually just an example of the trainers I wanted to change the music of. I also want tot change Gym Leader and normal trainer music.

And yes, I'm editing Emerald, or better said, Pokémon Glazed. I wanted to make all Johto trainers play custom-made music (based on Gold and Silver music).

But if I understand correctly, you cannot just keep the same offset of the trainer script, even though you are only adding two lines to an already existing trainer script?

EDIT:
So I just boldly (after making a backup of course) added these two lines to the Elite Four member.
*(special 0x3E
playsong 0x1C2 0x0)*
Compiled the script, and tested. The outcome was something like you said already. The battle immediately starts upon talking to the member, playing the E4 encounter music during the battle. After defeating him, the door leading to the next room doesn't open, and upon talking to the member again, the battle starts over:
https://www.youtube.com/watch?v=lKBaN0R_LGk
When adding lines to an existing script (with commands that take up bytes), it will increase the size of that script in the ROM, causing it to start overlapping/interfering with other scripts and/or offsets, corrupting them.

As for what is going on in the script in your video, I think it may either have to do with corrupted segments from overlapping, or it is something that is just inherent in that kind of trainer battle. The scripts that this seems to cause problems in (at least for me) are the ones with "trainerbattle 0x3", such as Steven in Meteor Falls but Gameskiller01 seems to have gotten it working in post #19.

I tested things out again just now, but this time by converting the "trainerbattle 0x3" to 0x0 - correcting the message pointers and laying the script out like a normal battle. I managed to make it work by doing this, so maybe your script will function correctly in this case by changing the 'type' of trainer battle to 0x0 and re-structuring it to where the message pointers are in the right places. I think the reason your map changes weren't happening correctly could be due to how the "special 0x3E" and "playsong" interact with "trainerbattle 0x3".

Last edited by Sky0fBlades; 10th January 2017 at 10:51 PM.
Sky0fBlades is offline   Reply With Quote
Old 10th January 2017, 11:05 PM   #25
Thirteen1355
n00b
 
Thirteen1355's Avatar
 
Join Date: Jan 2017
Location: Lands of Nether
Posts: 6
Thirteen1355
Default

Thanks! I will give it a try.
Thirteen1355 is offline   Reply With Quote
Old 13th January 2017, 01:49 AM   #26
Thirteen1355
n00b
 
Thirteen1355's Avatar
 
Join Date: Jan 2017
Location: Lands of Nether
Posts: 6
Thirteen1355
Default

Another thing about the script editing:
So when exactly do you have to find a new offset when editing? When the script becomes a single letter or more longer, or when you edit anything at all (even without actually extending the script)?
Thirteen1355 is offline   Reply With Quote
Old 13th January 2017, 03:21 AM   #27
Sky0fBlades
Reaching new heights
 
Sky0fBlades's Avatar
 
Join Date: Sep 2012
Location: ☆ • ○ ° ☾
Age: 24
Posts: 103
Sky0fBlades
Default

Quote:
Originally Posted by Thirteen1355 View Post
Another thing about the script editing:
So when exactly do you have to find a new offset when editing? When the script becomes a single letter or more longer, or when you edit anything at all (even without actually extending the script)?
The bytes of space taken up in the ROM by a script are independent of the character-length of a script in a program like XSE, unless the data we are talking about is actual text data (like a person talking in-game). The command's name is just a translation from a piece of byte data in the ROM and so the length of the command word itself (like "setflag") doesn't affect the actual size of the data to be compiled. "Setflag 0x123" (or 0x0123) shows up as "29 23 01" in the ROM (the 29 being Setflag itself), which is 3 bytes total. Pressing F1 in XSE lets you scroll through a list of commands as well as see what they do and how many bytes of space they take up with themselves and their parameters.

Any time more actual bytes are being added into a script than there were before, it is a very good idea to use an offset where there is enough free space. For example, consider that in XSE two commands may take up the same amount of bytes as one another (like "setflag" and "clearflag" which take up 3 bytes, or "nop", "end", and "return" which each take up 1 byte). If you come across a script with a command you'd like to switch out for another, you can change it to another command with the same byte data length as the one you are replacing, without overwriting things you wouldn't want to. Basically, you want to make sure that the new script is either the same compilation size or smaller if you don't want to corrupt the next sections of data. If it is smaller but you want it to stay the same size as the unedited script, you can take up some more space using "nop"s which will write a "00" into the ROM for each one you add to your script.

To sum it up, as long as you are not adding more commands to the script or editing-in one that takes up more bytes than what was already there, you don't really have to use free space. For example, if you just want to change the Pokémon that you face when a 'legendary-style' battle script happens, all you have to do is change the value of a byte that is already there so you don't have to use a different offset. Also, when using the Dynamic way of scripting into free space, make sure to use pointer placeholders (like "@battleforbadge", or "@battle_for_badge) in place of any offsets you have added more data to. On compiling the script XSE will then automatically associate each placeholder with its own offset of free space and take up the space it needs for the script.

Last edited by Sky0fBlades; 13th January 2017 at 03:45 AM.
Sky0fBlades is offline   Reply With Quote
Old 13th January 2017, 11:01 PM   #28
Thirteen1355
n00b
 
Thirteen1355's Avatar
 
Join Date: Jan 2017
Location: Lands of Nether
Posts: 6
Thirteen1355
Default

Thanks for helping, once again. I didn't really manage to get the trainer music working, but at least, now I can learn some more script editing.

Also, I recently joined the website Romhack.me, and I noticed you were member of the site. For some reason, whenever I try to log in, a message pops up, saying:
"Your account is pending approval."

But I joined about five days ago. Does approving take that long?
Thirteen1355 is offline   Reply With Quote
Old 14th January 2017, 04:59 AM   #29
Sky0fBlades
Reaching new heights
 
Sky0fBlades's Avatar
 
Join Date: Sep 2012
Location: ☆ • ○ ° ☾
Age: 24
Posts: 103
Sky0fBlades
Default

Quote:
Originally Posted by Thirteen1355 View Post
Thanks for helping, once again. I didn't really manage to get the trainer music working, but at least, now I can learn some more script editing.

Also, I recently joined the website Romhack.me, and I noticed you were member of the site. For some reason, whenever I try to log in, a message pops up, saying:
"Your account is pending approval."

But I joined about five days ago. Does approving take that long?
I can't remember if I had that problem with account approval, as it has been quite a long time since I joined Romhack.me. However, LinkandZelda might be able to get your account running. Be sure to also check your e-mail as well, if you haven't already.

As for your ROM hack, I could still probably help get your script working if you would like. I imagine that there were problems converting between the different types of trainer battle?
Sky0fBlades is offline   Reply With Quote
Old 14th January 2017, 11:11 AM   #30
Thirteen1355
n00b
 
Thirteen1355's Avatar
 
Join Date: Jan 2017
Location: Lands of Nether
Posts: 6
Thirteen1355
Default

About the script editing, it wasn't really important. I've managed to insert some custom music into Glazed to make it feel even more real as an unique Pokémon game. The fact that I managed to do that without corrupting the Emerald ROM is already a huge achievement for me
Thirteen1355 is offline   Reply With Quote
Reply

Tags
asm, battle, controlling, emerald, music, trainer, [Tutorial]

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:05 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc. User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Pokémon characters and images belong to Pokémon USA, Inc. and Nintendo.
Pokémon Hackers Online (PHO) is in no way affiliated with or endorsed by Nintendo LLC, Creatures, GAMEFREAK inc,
The Pokémon Company, Pokémon USA, Inc., The Pokémon Company International, or Wizards of the Coast.
All forum/site content (unless noted otherwise) and site designs are © 2006-2013 Pokémon Hackers Online (PHO).
Green Charizard Christos TreeckoLv100

"Black 2" by ARTPOP. Kyurem artwork by XOUS.

no new posts