Welcome Guest [Log In] [Register]
BN6 Battle data structure
Topic Started: Oct 5 2010, 05:07 PM (1,522 Views)
MegaRockEXE
Member Avatar
BN Guides Author

I've revisited the battle structure for BN6, now that I know more. My goal is to understand the format more so I can make a hack I'm working on. I still don't know how to make a chained battle.


Current battle data loaded
02001B9C

Code:
 

[b]Battle Settings[/b]

0x00 battlefield value
0x01 unknown
0x02 music value
0x03 battle type
0x04 background value
0x05 battle number
0x06 battlefield sides modifier
0x07 unlock byte
0x08 optional settings (4 bytes)
0x0C enemy setup pointer


[Battlefield values]
-uses the value as a pointer to get a stage setup

[Battle number]
-the number of the battle in the chain

[Battlefield Sides Modifier]
-bits determine blue and red panels
1 is red
0 is blue

[Unlock byte]
-value determines if the battle can be encountered or not

[Optional settings]
-1st byte, 2nd bit enables results
-1st byte, 4th bit enables net battle mode
-1st byte, 8th bit randomizes folder
-2nd byte, 3rd bit begins chain battle

[enemy setup pointer]
-pointer to the enemy setup data to use with the settings.
____
Nothing is final and I didn't have much luck in finding out these "optional values". More hacking needs to be done here.
The Rockman EXE Zone | YouTube
Profile
Quote
 
Agro
No Avatar
Programmer!

Hm! With that battle encounter, might it be possible that some battles in the game are programmed, but not used?

And what is a chained battle?
Edited by Agro, Oct 5 2010, 08:29 PM.
Profile
Quote
 
MegaRockEXE
Member Avatar
BN Guides Author

The only battle I'm aware of is the Rare Fan 2 virus. A chained battle is a consecutive battle where one battle follows another. The trigger I have listed only chains to a random battle with a player which freezes for lack of a player 2, I assume. I'm thinking the message controls the chain, but I'm not sure.
The Rockman EXE Zone | YouTube
Profile
Quote
 
Dramz
No Avatar
Spastic Colon

0x03 battle type
00-Normal
01- Crossover
02 - Tutorial battle #1
03 - Tutorial battle #2
04 - Tutorial battle #3
05 - Cybeast Tutorial
06 - Virus Battler
07 - Tomahawkman Mini Game
08 - Spoutcross/Heatcross tutorial
09 - Dustman mini game
0A - Invincible enemy (Hackjack battle)
0B - Normal Battle
0C - Freezes
Profile
Quote
 
MegaRockEXE
Member Avatar
BN Guides Author

Yeah, I knew most of the values I left out because they were in the last battle hacking guide. I think 0B was actually another type of battle that was removed form the US game.
The Rockman EXE Zone | YouTube
Profile
Quote
 
Agro
No Avatar
Programmer!

Hm... Maybe you can look for a structure that points to an offset and loads that battle data, and then comes back? I'm sure it is possible. There is a consecutive battle, where someone tests you for 10 battles in BN6. If we can get to that point and look at the data, I'm sure we can figure it out.
Profile
Quote
 
MegaRockEXE
Member Avatar
BN Guides Author

Right, but whatever says a chained battle will begin must back it up with battle data. It's weird because if you get into a battle that is normally chained using a cheat, the chain continues, yet there is no way to reproduce this effect. I have to keep looking.
The Rockman EXE Zone | YouTube
Profile
Quote
 
Agro
No Avatar
Programmer!

Hm. Is it some special battle structure that has some special hex values? Maybe its mixed between all the other things?

Try looking at the message stuff in the RAM and the ROM for the text that guy brings up. It has a pointer to something, I'm sure of it.

Would you mind giving me an offset of anything you find?
Profile
Quote
 
MegaRockEXE
Member Avatar
BN Guides Author

command in the message that loads the battle
020303DD

Aquaman SP's battle data
080AEF10
The Rockman EXE Zone | YouTube
Profile
Quote
 
Agro
No Avatar
Programmer!

Hm. Could you find the offset at which the chained battle begans?
Profile
Quote
 
Prof. 9
Member Avatar
Moderaptor

Stuff I found while trying to figure out how chained battles work.

Note that I regard the four bytes at 0x0C as a single 32-bit value which is what the game does as well.

Battle settings flags
00000002 = Enable result screen
00000008 = Enable multiplayer NetBattle mode (glitchy)
00000020 = Enable run away
00000080 = ??? (seems to be related to flag 00200000)
00000400 = Enable chain battle
00004000 = Enable battle can be LocEnemy'd
00200000 = ??? (checked continuously during battle) (seems to be related to 0x03 (battle type) and NetBattle mode) (might disable battle type if turned on???)



Also, here's what happens when you chain battles. There's actually some more stuff but that's either irrelevant or too complicated.

Start of battle (if 400h is ON):
Increase value at 0203489A by 1
(This value is used to determine what it says on "Battle XX Start!")

After battle (if 400h is ON):
Load value at 0203489A and subtract 1 from it
Load byte from 0203CA50 + battle value
Load next battle data from 080B0D88 + (byte * 10h)

That's what I've found so far. With some ASM hacking, I was able to chain a valid battle (though the background changed for some reason) to one that had just ended. However, it had no message at the start of the battle and the game froze after the battle. As for why it froze, I have absolutely no idea. It's not caused by the battle number, it's not caused by the chain flag. There must be some more to it.





Also, I had a look at the unlock byte. The unlock byte behaves in a very interesting way. Based on the unlock byte, a special routine is executed right before the battle is loaded.

Routine executed = 080AA6B8 + (unlock byte * 4)

The routine executed determines whether or not the battle can be picked. Returns: r0 (0 means no, anything else nonzero means yes). Only r0 is important, so you're free to do whatever you want in the routine. Fun fact: if the unlock byte = 0, the "unlock byte routine" that is executed just sets r0 to 1h, then returns.

Additionally, the unlock byte is compared to 2h some time afterwards (at 080AA82A). I have no idea why though. I think it's not really important since it's only for 1 value.

After the game runs the unlock byte routine for every battle in the area, a battle is picked. If none of the battles can be picked, no battle starts and the game continues on normally.

The cool thing about this is that you can set virtually any prerequisite for a battle, and you can set a different one for each battle in the area! Also, instead of locking a battle BEFORE you do something, you can also lock a battle AFTER you do something. This way, you can do stuff like increase virus levels as you progress through the story.
Edited by Prof. 9, Oct 10 2010, 11:58 AM.
:ninja: Follow me on Twitter! :trap: Fork me on GitHub!
Posted Image
Profile
Quote
 
MegaRockEXE
Member Avatar
BN Guides Author

I'm 5 days late to this marvelous post. Excellent backtracing. I was well aware that the last chunk was 4 bytes, only it was difficult to test. The only way I can seem to chain battles is if it becomes a Net Battle chain. Net Battle mode also doesn't function like the cheat. It will always freeze before the enemy's name shows up.
Did you test these on random encounters? I was testing a freefight which should technically use some bytes differently. Like this unlock byte. Does it apply to freefights? And what kind of prereqs can be set? I think a value of 02 is used on Rare Viruses. Some areas could use a 01 or a 02.
The Rockman EXE Zone | YouTube
Profile
Quote
 
Prof. 9
Member Avatar
Moderaptor

Quote:
 
Did you test these on random encounters?
Yeah, I was. In the ACDC HP iirc.

Quote:
 
Like this unlock byte. Does it apply to freefights?
It does. It seems to be specifically used for determining which battles can be found as a random battle and which cannot.

Quote:
 
And what kind of prereqs can be set? I think a value of 02 is used on Rare Viruses. Some areas could use a 01 or a 02.
Since the prereqs are tested in a special routine specific to each unlock value, you could test for anything.

If all the Rare Viruses use unlock value 02h, they probably check an area-specific flag or something.
:ninja: Follow me on Twitter! :trap: Fork me on GitHub!
Posted Image
Profile
Quote
 
Prof. 9
Member Avatar
Moderaptor

I found a cool flag.

00000100 = Losing results in Game Over (if it's off, you'll be returned to the overworld with 1 HP)
Edited by Prof. 9, Nov 28 2010, 09:37 AM.
:ninja: Follow me on Twitter! :trap: Fork me on GitHub!
Posted Image
Profile
Quote
 
Prof. 9
Member Avatar
Moderaptor

If battle setting flag 00000008 is on (multiplayer mode), the game will always use music value 0x15 instead of the battle's music byte. You can change that with this so you could load custom music:

08009229: D0 -> E0

This disables the check so it will use the music byte from the battle data instead.
Edited by Prof. 9, Apr 20 2011, 09:53 AM.
:ninja: Follow me on Twitter! :trap: Fork me on GitHub!
Posted Image
Profile
Quote
 
MegaRockEXE
Member Avatar
BN Guides Author

Okay, but is there a better way to lock a battle in a Net Battle? I've tried something like that before but it didn't work for some reason. How can a Net Battle be changed from random to a single battle?
The Rockman EXE Zone | YouTube
Profile
Quote
 
brianuuu
Member Avatar
SF Noise Spriter
if you want all battle with the same battle sequence, just change all the pointers at the end of the battle settings =\
Posted ImagePosted ImagePosted Image
Posted Image
Profile
Quote
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Guides & Research · Next Topic »