News:

The forum has been updated to SMF (2.1.3)!
Please be patient as we work to polish up the place and update features as we can.

Main Menu

How is enemy data stored in the game?

Started by ReyJavikVI, 26, February, 2010, 09:35:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ReyJavikVI

Maybe this already exists, but I couldn't find it.

I thought it would be nice if it was possible to make a script that can pull all the enemies' data from a ROM and put it into a text file. I figured that since you can view this stuff with the Editor, someone has to know where the data is and how to interpret the hex.

Atrius (He/Him)

#1
GS & TLA both store them differently, I haven't fully documented the original GS's format yet, but here's what I have for TLA

The data begins at 0x080B9E7C, each entry is 76 bytes.

BYTE x 15 = 0x20, likely reserved space for their name, but is unused.
BYTE - Level
SHORT - HP
SHORT - PP
SHORT - Attack
SHORT - Defense
SHORT - Agility
BYTE - Luck
BYTE - Turns
BYTE - HP Regen
BYTE - PP Regen
SHORT x 4 = Items
BYTE x 4 = Item quantities
BYTE = Elemental Stats index (They're read from a separate location)
BYTE = Unknown
BYTE = This affects how often different attacks are used, see note 1.
BYTE = Each bit of this represents a checkbox beside an attack in the editor, the exact effects although unknown seem to be determined by Unknown Value #1
SHORT x 8 = Attacks
SHORT = Unknown
SHORT = Unknown
SHORT = Coin prize for defeating
SHORT = Item prize for defeating
SHORT = Chance of receiving item (corresponds to ICC values if you're familiar with them)
SHORT = Experience for defeating


Note 1
For this value the settings indicated give each attack the listed chance of being used
0 - All attacks have an equal 1/8 chance of being used.

1
Attack 0=53/256
Attack 1=47/256
Attack 2=41/256
Attack 3=35/256
Attack 4=29/256
Attack 5=23/256
Attack 6=17/256
Attack 7=11/256

2
Attack 0=113/256
Attack 1=56/256
Attack 2=31/256
Attack 3=20/256
Attack 4=14/256
Attack 5=10/256
Attack 6=7/256
Attack 7=5/256

3, and 4 are handled similarly to each other, but are more complex than 0-2.  They seem to be used for enemies with multiple move sets, and haven't fully been figured out.

5 always selects the first ability.

6 always defends.

Anything above 6 is treated as though it is 6.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

ReyJavikVI

#2
Wow, thank you.

Oh, and do you know where the names are stored?

Wait, there is something weird. Are you sure the ICC is a byte? Because that means the short that holds the experience is reversed (in the monster I was checking, it seemed to be 0xE600 instead of ox00E6). I understand how big endian vs little endian works; all the other numbers match perfectly. It's just this one. It seems that there should be an extra empty byte between the ICC and the experience.

Aile~♥

DUDE! NO TRIPLE POSTING! OMG!!!

...Just use the edit button, k?

Don't want nice new mems gettin' banned or anything.
[sprite=16, 6, 0]:P[/sprite]

Lloyd: Easy as pie.
Genis: Sweet!
Presea: ...Sweetie pie...
Zelos: Let's not start on this again...

[spoiler=epic mindscrew][/spoiler]

ReyJavikVI


Atrius (He/Him)

#5
*combines posts*
The rule is, double posts are only allowed if it's been a couple days, and it contributes something important to the topic.  So the first one would have been alright, you should have edited the second one into the same post though.

Names, like all other text in the game, are compressed.  It would be a lot of work to pull them out of the game's data.

You're right about the ICC, my mistake, it is a SHORT.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

ReyJavikVI

Yeah, I know about the double posts. Sorry.

And thanks for the info. Maybe I'm asking a lot of things, but would you mind giving me a rough description of how the text is compressed? I don't need to know a specific algorithm to uncompress, just simple things. Like, does it use a dictionary for common words? Thank you in advance.

Atrius (He/Him)

I'm not even sure how exactly to describe it really...

Each character is encoded individually, and they rarely use the same number of bits.  There is different encoding data used depending on what the last character in the string was.  Basically a single character like 'A' is encoded differently depending on what character appears before it, so the compression algorithm takes advantage of characters that commonly appear beside each other to compress the text.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

ReyJavikVI

Well, this sucks. Okay, last question, I promise. Can you think of any way to get a text file with a list of enemies (at least the names, since that's what's difficult to extract from the ROM)? The editor obviously can pull all the data, so there must be a way. Maybe someone already has such a list?

Max

I haven't gotten to enemies yet, but I've been working on extracting data into XML formats for a project of mine. Attached is what I have so far, including the raw list of all strings in case that is at all useful for you (I believe enemy names start at index 1068). Perhaps I'll make enemies the next full data set I work on and post it here.