Author Topic: ff8 monsters : .dat files analysis  (Read 19137 times)

myst6re

  • Freak
  • *
  • Posts: 532
  • Karma: 58
  • Light King of the Savegame - Field Master
    • View Profile
    • FF8.fr
ff8 monsters : .dat files analysis
« on: 2010-12-07 22:12:52 »
Hello!
I currently working on the dat files of Final Fantasy VIII. So I put everything on the wiki I found on theses files:
http://wiki.qhimm.com/FF8/FileFormat_DAT (thanks to JWP and Mirex)
But... the model animation section is hard to understand, and without it, my 3d models are... incomplete:



Anyone know how to interpret this section? help...

obesebear

  • Administrator
  • No life
  • *
  • Posts: 3266
  • Karma: 114
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #1 on: 2010-12-08 01:25:13 »
I know Mr Adults (aka Rich Whitehouse) over at richwhitehouse.com has cracked the FF8 model format.  Might be good to see if he can give you some pointers.

random_npc

  • Cool newbie
  • *
  • Posts: 63
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #2 on: 2010-12-08 17:34:24 »
I can't help for the model section, but if you need some informations about the AI section, you can ask me.

ultima espio

  • No life
  • *
  • Posts: 1359
  • Karma: 20
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #3 on: 2010-12-08 17:42:28 »
MrAdults blew it open months ago :P

His new model viewer can view them, with animations too. Just ask him :P

myst6re

  • Freak
  • *
  • Posts: 532
  • Karma: 58
  • Light King of the Savegame - Field Master
    • View Profile
    • FF8.fr
Re: ff8 monsters : .dat files analysis
« Reply #4 on: 2010-12-08 18:06:25 »
Okay, thank you for your replies, I watched Mr. Adults' tools, and "mesh2rdm" supports battle models. I also saw that "Noesis" read them very well.
I'm going to ask how MrAdults did it.

I can't help for the model section, but if you need some informations about the AI section, you can ask me.

I'm interested, I will think when the time comes because I want to completely fill the page on the wiki.

random_npc

  • Cool newbie
  • *
  • Posts: 63
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #5 on: 2010-12-08 19:25:22 »
Just to avoid confusion : I just look at the wiki, the part I meant is section 8 ('Battle scripts'), not section 5.

Some informations here looks a bit weird. It says section4 : unknown, section5: Ai scripts?; section10=sounds and section 11=textures, but if you take the common galbadian soldier for example, headers 4 & 5 are the same, and so are headers 10 & 11.

I wonder about sounds. If you replace the whole pampa .dat file with Ifrit's, on pampa island you'll met some Ifrits that will still use pampa sounds... 
« Last Edit: 2010-12-08 19:56:26 by random_npc »

myst6re

  • Freak
  • *
  • Posts: 532
  • Karma: 58
  • Light King of the Savegame - Field Master
    • View Profile
    • FF8.fr
Re: ff8 monsters : .dat files analysis
« Reply #6 on: 2010-12-08 21:15:41 »
Thank you for the clarification, I wasn't sure for these sections.


Edit: section 7 completed!

Edit 2:
Some informations here looks a bit weird. It says section4 : unknown, section5: Ai scripts?; section10=sounds and section 11=textures, but if you take the common galbadian soldier for example, headers 4 & 5 are the same, and so are headers 10 & 11.

Although section 4 starts at the same position as section 5, there are still 11 sections. It simply means that section 4 is empty.

random_npc

  • Cool newbie
  • *
  • Posts: 63
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #7 on: 2010-12-08 21:36:38 »
Nice work!

Just one thing I'd add - for abilities :
Quote
May be 0x02 (= magic) or 0x08 (= monster ability).

...or 0x04  (=item). 

« Last Edit: 2010-12-08 21:41:27 by random_npc »

myst6re

  • Freak
  • *
  • Posts: 532
  • Karma: 58
  • Light King of the Savegame - Field Master
    • View Profile
    • FF8.fr
Re: ff8 monsters : .dat files analysis
« Reply #8 on: 2010-12-08 21:46:04 »
Damn, I had not seen this case. Raijin I suppose? I'll check that there is no other cases. thanks!
« Last Edit: 2010-12-08 21:55:12 by myst6re »

random_npc

  • Cool newbie
  • *
  • Posts: 63
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #9 on: 2010-12-08 21:56:58 »
Yes, Raijin it is   :D

(or my edited galbadians, which are using several items as well)
 
« Last Edit: 2010-12-09 19:23:01 by random_npc »

myst6re

  • Freak
  • *
  • Posts: 532
  • Karma: 58
  • Light King of the Savegame - Field Master
    • View Profile
    • FF8.fr
Re: ff8 monsters : .dat files analysis
« Reply #10 on: 2011-02-14 23:24:29 »
I don't know if Mr. Adults answer me someday...

Chev

  • Fast newbie
  • *
  • Posts: 35
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #11 on: 2011-03-21 20:17:47 »
I hope it's not necro bumping that one up since it's still on the first page. I started implementing the specs written on the wiki and the vertices seem to come out fine, but I get some weird values for the triangles and quads (like index 32000 or so for one of the vertices), so I still need to find the flaw in my geometry reader, but after that I'm gonna try my hand at the animation data.

EDIT: in fact yeah, that's really weird, the values always seem to be off by 0x8000 in the first index of each face/triangle.
« Last Edit: 2011-03-21 22:14:53 by Chev »

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3689
  • Karma: 42
  • GUI Master :P
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #12 on: 2011-03-21 23:06:59 »
I hope it's not necro bumping that one up since it's still on the first page. I started implementing the specs written on the wiki and the vertices seem to come out fine, but I get some weird values for the triangles and quads (like index 32000 or so for one of the vertices), so I still need to find the flaw in my geometry reader, but after that I'm gonna try my hand at the animation data.

EDIT: in fact yeah, that's really weird, the values always seem to be off by 0x8000 in the first index of each face/triangle.

We are taking a soft stance to necro'ing these days. If it seems that there is useful information in your post it will be allowed.

Chev

  • Fast newbie
  • *
  • Posts: 35
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #13 on: 2011-03-21 23:27:49 »
OK then. Well, I finally decided to just substract 0x8000 from each triangle/quad's first index and they all seem to make a lot more sense now, so I'll take a shot at assembling a mesh tomorrow. It's sorta really weird how much space seems to be wasted in .dat models though, with the huge empty stretches in bones or those seemingly useless bits. Ah well, what's important is that it works.

Dark_Ansem

  • Insane poster
  • *
  • Posts: 297
  • Karma: 2
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #14 on: 2011-03-22 09:48:03 »
what about animations, chew?

myst6re

  • Freak
  • *
  • Posts: 532
  • Karma: 58
  • Light King of the Savegame - Field Master
    • View Profile
    • FF8.fr
Re: ff8 monsters : .dat files analysis
« Reply #15 on: 2011-03-22 10:36:09 »
OK then. Well, I finally decided to just substract 0x8000 from each triangle/quad's first index and they all seem to make a lot more sense now, so I'll take a shot at assembling a mesh tomorrow.

I had forgot to talk about this substraction. You can do "poly3.vertex_indexes[0] &= 0x7FFF;". I have edited the wiki page.

Chev

  • Fast newbie
  • *
  • Posts: 35
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #16 on: 2011-03-22 21:53:40 »
OK! I was wondering if maybe that bit being set was a psx-specific thing and they'd gotten rid of that on PC or something, but I guess it's not the case.

Dark_Ansem> well, one thing at a time, I'll have a much better shot at seeing if I'm on the right track with anims once I get the mesh displayed. I'm still going over the mesh assembling code I originally made for the FF9 viewer, I've had an exhausting day so it's not progressing very fast. While I'd love to start on anims tomorrow the weekend's probably a more realistic target. Plus I can't yet be sure it'll amount to anything, since So far all of my work has mostly been following existing specs. But fingers crossed.

All I can say for now is the anim section starts just like the texture section, ie there's a uint32 anim count, then anim_count uint32 offsets from the beginning of the block to each anim, but that's already on the wiki.

EDIT: I used the already existing (though not quite getting everything right) model viewer from kvaks to spot a few potentially interesting files, namely c0m080, one of NORG's orbs (two bones, one anim that's not moving at all) and c0m125, one of Ultimecia/Griever's spirals (first two anims are respectively rotating clockwise around the vertical axis and counterclockwise), which hopefully ought to simplify figuring out the format quite a bit. Well, we'll see.
« Last Edit: 2011-03-23 22:36:31 by Chev »

myst6re

  • Freak
  • *
  • Posts: 532
  • Karma: 58
  • Light King of the Savegame - Field Master
    • View Profile
    • FF8.fr
Re: ff8 monsters : .dat files analysis
« Reply #17 on: 2011-03-24 15:18:23 »
EDIT: I used the already existing (though not quite getting everything right) model viewer from kvaks to spot a few potentially interesting files, namely c0m080, one of NORG's orbs (two bones, one anim that's not moving at all) and c0m125, one of Ultimecia/Griever's spirals (first two anims are respectively rotating clockwise around the vertical axis and counterclockwise), which hopefully ought to simplify figuring out the format quite a bit. Well, we'll see.

Yes I have the same approach.

Chev

  • Fast newbie
  • *
  • Posts: 35
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #18 on: 2011-03-24 21:27:50 »
Ok, so let's take the spiral rotations as an example, both 20 frames animations of rotations on a single axis. In the clockwise one there's a 36 bit pattern that goes (in little endian, and the start may not actually be at that bit so the whole thing could be shifted)

Code: [Select]
0    0    C    7    6    E    1    0    0
0000 0000 0011 1110 0110 0111 1000 0000 0000

and in the counterclockwise one there's, with the same offsets,
Code: [Select]
0    0    C    B    9    1    0    0    0
0000 0000 0011 1101 1001 1000 0000 0000 0000

Now, if you just take bits 14 to 25 (leftmost bit being 1), 12 bits in total, you have
Code: [Select]
110 0110 0111 1 in little endian
111100110011  in big endian
which is 3891, aka -205, about -18 degrees with 12 bit angles

Code: [Select]
101 1001 1000 0 in little endian
000011001101  in big endian
         
which is 205, about 18 degrees

20 frames animation, 18 degrees by frame, so full revolution per anim cycle, delta stored. We're on the right track! Since the animation really only rotates on a single axis the three preceding bits, 0x7, must be some kind of flag. And, well, 0x7 followed by a 12 bit angle, that really looks like FF7's compressed rotations thingie. So I'm gonna choose, as a work hypothesis, that it indeed works kinda like that and see where it gets me.

I'm rather unhappy with the 21 remaining zeros though, with a FF7-like system if I understand correctly I should be getting a lot less of them.
« Last Edit: 2011-03-24 22:56:56 by Chev »

Vehek

  • Crazy poster
  • *
  • Posts: 220
  • Karma: 9
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #19 on: 2011-05-29 02:41:36 »
I think that section 4 is texture-animation data (for example, eye-blinks).

The section begins with a list of 16-bit offsets into the section for the different animations. Unfortunately, there doesn't seem to be a count of how many different texture animations the model has. Many models have 0000 as their first offset. I assume that this is for models that don't always have a texture-animation running.

This is what I have so far for an individual texture-animation. It's all guesswork and I haven't checked it ingame yet.
Code: [Select]
struct texAnim
{
uint8 textureNum;
uint8 originalUCoord; //All UV coords here are for the upper left corner
uint8 originalVCoord;
uint8 regionUSize;
uint8 regionVSize;
uint8 copiedRegionCount; //1 less than the actual number
uint8 unknown1;
uint8 unknown2;
//Insert remaining UV coords here
};
I always have to double the "U" part of the UV coords and region-size to get a reasonable U coord/size. Maybe it has something to do with how the TIM format works?

Chev

  • Fast newbie
  • *
  • Posts: 35
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #20 on: 2011-05-30 22:14:30 »
Quote
Unfortunately, there doesn't seem to be a count of how many different texture animations the model has
While there is no count, that kind of list usually marks its end with a zero offset, so you could check for those if you haven't already.

For the coordinate transformation, I don't know. The closest thing I can think of is that in FF9 you have to shift the UV for the weapon textures because in-engine they're not loaded at the beginning of a texture page, but that would only account for translating the coordinates, not scaling them.

LandonRayW

  • Fast newbie
  • *
  • Posts: 37
  • Karma: 2
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #21 on: 2011-06-03 00:25:21 »
Does anyone have any information on section 8?

random_npc

  • Cool newbie
  • *
  • Posts: 63
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #22 on: 2011-06-03 07:54:09 »
if you need some informations about the AI section, you can ask me.
the part I meant is section 8 ('Battle scripts')

>:(

What do you wish to know exactly? I cannot answer everything, especially 'cause I am not home this week, but I have been playing a lot with this part and decrypted a lot of enemies strategy code. 

LandonRayW

  • Fast newbie
  • *
  • Posts: 37
  • Karma: 2
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #23 on: 2011-06-03 17:24:15 »
I apologize.  The question was mostly posed to you, but I thought it best to phrase it in a more general sense.  No offense intended.  Actually, your the only person I know of who is knowledgeable about FF8's battle scripts (others have likely done work on it too, I'm just unaware of it).  I'm new to working on FF8's AI, most of my AI work has been on FF6, which is far more simplistic.  As of now, the only thing I can do reliable is change targeting.  That said, any information on section 8 would be useful, but mostly I'm looking for some basics.

random_npc

  • Cool newbie
  • *
  • Posts: 63
  • Karma: 1
    • View Profile
Re: ff8 monsters : .dat files analysis
« Reply #24 on: 2011-06-07 17:37:46 »
I'm finally back home, sorry for keeping you waiting!

Okay, I'll tell you some things about FFVIII ai scripts, I hope myst6re doesn't mind the huge post in this topic. You might have figured out already part (or all?) of what is written below, but I find it more apropriate to start with the basics. I have no idea how monsters ai is coded in other FF game, FFVIII is the only one I've been toying with.

First, structure. Part 8 can be divided as follow :
- offsets
- ai script
- text

I'd be detailling the offsets. Let's take the classical galbadian for example : (note -  '__' stands for '00')

03 __ __ __   
10 __ __ __   : point to ai offsets
d8 __ __ __   : point to text offsets
e4 __ __ __   : point to text lines
 
14 __ __ __   : point to loading code (executed when the enemy appears)
58 __ __ __   : point to code executed at enemy's turn
bc __ __ __   : point to counterattack code
c0 __ __ __   : point to death code
c4 __ __ __   : not sure about that one.

values are given starting from the beginning of part 8 for the first four, and from one line after for the other (I suppose that's what the second offset is for.)



Now, syntaxis.
Let's take an extract from Edea1 :
02 04 c8 03 15 __ 07__ 04 c8 0c 06 23 06 __ 04 c9 0b 01 02 03 23 06 __

here we have three parts. The first one is actually a test : 02 04 c8 03 15
All tests begin with 02 ; I'll detail them later. If the result from this test is true, it will follow with the amount of bytes that is given afterwards : 07 00, that's 7 bytes. So now we have : [test] __ 07 00 [code if true] 04 c9 0b 01 02 03 23 06 __

That 'code if true' ends with 23 06 00. You can translate that by : skip 6 bytes. So in this case, we have a simple "if(condition is true) {04 c8 0c 06} else {04 c9 0b 01 02 03}"!

Last thing to tell : when the code will enconter a 00 it will stop. Best example is that piece of code, which you'll encounter with a lot of enemies, that tell them to skip their turn :
02 02 03 __ __ __ 04 __ [__ 23 __ __]
(02 02 03 is a probabilty of 1/3)



Now. Let's detail a little more what we can encounter - keep in mind that I'm far for having decrytped everything.


Tests

for most of them (I'm not sure about how the probability thing exactly works)
first byte  : 02
third byte : target.
fourth byte  :
   00 :  =
   01 : <
   02 : >
   03 : !=
   04 : <or= 
   05 : >or=
fith byte : number

second byte - tells what to check
00 : monster own HP   (ex : 02 00 c8 01 03 __ would be if his HP are below 30%)
01 : other monster HP (ex: 02 01 57 01 05 __ would be if a galbadian is below 50%)
03 : battle scene         (ex : 02 03 c8 03 04 : if we are not in fight 04)
04 : self, status (ex below : 02 04 c8 03 15, if she haven't got status 15 (safe))
05 : ennemies, status  (ex : 02 05 c8 00 17, if one of us acursed seeds have got status 17 (reflect))
06 : number of alive members in our party (ex : 02 06 c8 00 01, only one remains)
09 : is a certain character is present & alive (ex : 02 09 c8 00 03 : if Quistis is here)
0e : monster difficulty level (ex : 02 0e c8 05 01 : if difficulty level higher or equal to ‘1’ (medium)
   00 = retarded n00b, 01 = medium, 02 = hard.
11 : check if we have stolen a GF (ex : 02 11 c8 03 cc : monster lost his GF.)

talking of status, here is my current list :
        01 :   poison
        03 :   blind
        04 :   mute
        05 :   berserk
        06 :   zombi
        10 :   sleep
        11 :   haste
        15 :   safe
        16 :   shell
        17 :   reflect 
        18 :   aura
        1d :   float
        1e :   confuse
        21 :   double
        22 :   triple


Variables - just a few examples

ex : dc, dd, de, df, 60, 61 ...
0e dc 00 : set dc = 0
13 60 01 : add 1 to 60.
02 dc c8 00 00 : if(dc=0)

 
Text :
texts can be launched by some attacks, but it can be called directly from the ai code as well.
01 02 : say text line n°3.
1a 01 : say text line n°2, but after attack.
There are others, I won't detail all of them.


... I will continue later
« Last Edit: 2011-06-09 14:22:35 by random_npc »