some stats on .cof

This is the place to discuss all issues relating to the manipulation of graphics/animations, sounds, music and cinematics within Diablo 2.

Moderators: Necrolis, Nefarius

User avatar
Paul Siramy
Retired staff
Principality
Posts: 2828
Joined: Sat May 25, 2002 2:39 pm
Location: La Garenne Colombes (near Paris)
France

Hand-picked

some stats on .cof

Post by Paul Siramy » Wed Jul 24, 2002 5:15 am

I have made a prog that have checked 3512 .cof.

1 cof have a variable amount of layers, 1 layer beeing the head, the torso, the legs, etc... There is is total of 12059 layers for all this 3512 cof.

# layers : between 1 & 11
# frame per direction : between 1 & 200
# directions : between 1 & 16
total frames of 1 cof : between 1 & 592

in the begening of the cof file, there is a byte at a value of 20 (14 in hexa). It is always this value in all the cof. Right after : 1 byte, that can be either 0 or 1. Then some values than are never the same. Then the 3 bytes right before the 1st bytes of the 9 bytes string : 1st byte is either 0, 1 or 2. The 2 bytes right after are always set to 0.

Now, the 9 bytes string ...
There is 1 string for each layer.

Byte 1 is between 0 & 15. Check composit.txt in d2data.mpq, you'll get the relation between these number and the part of the body.

Bytes 2 & 3 : between 0 & 1 (don't know what they are for)

Bytes 4 & 5 controls transparency drawins mode :
this zip make the clay golem transparent (alpha blended) just by seting this 2 bytes to 1 & 3 for all its cof). Transparency in cof is similar to the trans column in missiles.txt Seting theses bytes to 1 & 3 make the layer transparent (alpha blending is : the more dark the pixel is, the more it will be transparent, the lighter the pixel is, the more opaque it will be). Here are all the conbinations, and the number of layers in which they appeared :

0 0 : 6647 layers
0 3 : 1 layer
0 4 : 1 layer
0 5 : 4701 layers

1 0 : 9 layers
1 1 : 15 layers
1 2 : 3 layer
1 3 : 651 layers
1 4 : 1 layer
1 6 : 29 layers

Bytes 6, 7, 8 & 9 a 3-letter weapon's class code, with a zero termination.



After these 9 bytes string come some data for each [strike]layer[/strike] frames (# of bytes = # of frames per direction, NOT total amount of frames). Theses bytes range all from 0 to 3. They are use to tell for instance which is the frame that do the hit.
Alkalund" wrote:In the hardcoded animation sequences in d2common.dll, there is a dword for every frame in the sequence that controls event information as well, and in there 04 is also a valid value:

00 No Event
01 Attack
02 Missile
03 Sound
04 Skill

So perhaps 04 can also be used here in the COF files. How this works is still unknown (at least to me), but perhaps in the future this may be of use somehow. My naive guess is this is tied to AI in some way.
I'll make some .txt with all these infos, but I need to rewrite my prog before.


The golem have only 1 layer, so making this Torso transparent make the whole golem to be transparent. But you can make transparent just 1 layer of 1 animation. Imagine a fire-sword, with animated flame when you swing. You can make just the sword layer alpha blended to have the darkest flame be very transparent, while the lightest flame beeing opaque. Or what about only a shield tranparent, only the armor...

EDIT : corrected an error ("After these 9 bytes string come some data for each [strike]layer[/strike] ...")

EDIT 2 : quoted Alkalund, about that tag '04' in the frame datas.

EDIT 3 : new infos about bytes 4 and 5.
Byte 4 is a boolean. 0 disable special drawing effect, non-zero (01 to FF) enable it.
if Byte 4 is enable, then byte 5 is check to know which mode will be used to draw that layer :
00 = 75 % transparency (colormaps 561-816 in a .pl2)
01 = 50 % transparency (colormaps 305-560 in a .pl2)
02 = 25 % transparency (colormaps 49-304 in a .pl2)
03 = [strike]alpha blending[/strike] screen (colormaps 817-1072 in a .pl2)
04 = luminance (colormaps 1073-1328 in a .pl2)
06 = bright alpha blending (colormaps 1457-1712 in a .pl2)

if you try to use 05 or >= 07, then it'll draw the layer normally instead, withtout any special effect.

Luminance mode works like this : the pixel of the sprite takes its luminance value from the background, hue & saturation are not changed. Now, imagine a monster that is dark when over dark flrors, and normal when on white floors... you have a Lurker that is almost invisible in dark areas, and only visible when he's in light, out of his beloved shadows.

Of course you can combine drawing mode for different layers. For instance the Arcane Teleport Pad is draw like that :
* a 75% transparency dark mask
* the red aura with alpha blending
* the stone, normal mode

The mask is usefull here to darken the background a bit before the red aura is draw over it, which makes it more visible.

EDIT 4 : 2 usefull infos but for expert only.

In fact the so-called 'alpha blending' mode is not that, but a 'screen' blending mode. I made some tests with pl2 and paint shop pro, and there's a noticable difference. So if you're the owner of Paint Shop Pro and want to reproduce the effect of "alpha blending" layer (like the red aura of the Arcane stone portal) you should avoid using a 'mask' but use the 'screen' blending mode instead, that's the closest to what D2 use.

The COF that is using the Luminance blending mode is the object 'Flies' (token FL). If you hexedit this cof and make it use 50% transparency blending mode instead, then you have 1 colormap free to your own need in the pl2... in 2D mode at least, I'm not sure if it'll work in 3D and I doubt it in fact. I'll test that later.
Last edited by Paul Siramy on Sun Aug 17, 2003 4:08 am, edited 10 times in total.

User avatar
Myhrginoc
Retired Admin
Cherub
Posts: 12100
Joined: Sat May 25, 2002 7:28 am
Location: Percussion U
United States of America

Hand-picked

Post by Myhrginoc » Wed Jul 24, 2002 6:39 am

Excellent work, Paul! You certainly dove right in there.

Is a COF editor in the works? :mrgreen:
Do the right thing. It will gratify some people and astonish the rest.
~ Mark Twain
Run Diablo II in any version for mods: tutorial
The Terms of Service!! Know them, abide by them, and enjoy the forums at peace.
The Beginner's Guide v1.4: (MS Word | PDF) || Mod Running Scripts || TFW: Awakening

User avatar
Paul Siramy
Retired staff
Principality
Posts: 2828
Joined: Sat May 25, 2002 2:39 pm
Location: La Garenne Colombes (near Paris)
France

Hand-picked

Post by Paul Siramy » Wed Jul 24, 2002 7:51 am

Nope, not yet. I mean i CAN make such a tool, it's easy to hell (surely more if it's Joel that do it in vc6 than me with djgpp) nothing like a ds1 editor :mrgreen: , but I prefer to study the animdata.d2 & others .d2 first. It's just 2 days that I'm studying cof, and whith the links you give me it was quite easy, almost all was explain already, I just make a prog that check automatically all the .cof in all the mpq in fact, not a big deal. Now I need to do the same for *.d2 because I want to understand all the relations between .d2, .cof & .dcc before making a multisprite editor.

I don't say that this editor, if I make it one day, will decode/encode dcc. If I make it, it will surely only woks with pcxs as gfx files (dcc can't be decode easily for now, and gif neither), but the way I see it, you'll be able to load multiple animations at the same time, all aligned (no offsets problems), and by reading the .cof it should now the sprite priority (this one is very easy), and it'll be easy then to make a "merge all layers" option for instance, or to set some properties to a layer / to change the priority, etc... Dealing with gfx is what enjoy me, so despite I said "one day", you can be sure I'll make it ;) But I still need .d2 knowledge. I do have the link about animdata.d2 you gave me in a post, so it's just a matter of time. Then we'll see what we can do.

Do I have to say that I have never try to make a monster conversion ? I'm just starting to learn how all is working. .d2, .cof & .dcc : theses 3 file formats are the key of all the animations of D2 (herm... I forgot the palshift.dat too ;) )

User avatar
Joel
Moderator
Dominion
Posts: 6921
Joined: Mon May 27, 2002 7:19 am
Location: Orsay

Hand-picked

Post by Joel » Wed Jul 24, 2002 9:47 am

arggh

** Joel's Shield of Faith shatters and the Dark Ray of Overbooking stroke him in the head **

Tuuu, i'm considering cloning myself ;)

I'll wrote it to the job stack ...

I think it's easy, just a dialog box with stuff to show datas nicely ...
Expect it Friday ... free of charges (hmm if i could gain 1cts when everyone dl one tool of mine ....)
"How much suffering, mortal, does it take before you lose your grace?"
Shadow Empire (coming soon) | forum

User avatar
Myhrginoc
Retired Admin
Cherub
Posts: 12100
Joined: Sat May 25, 2002 7:28 am
Location: Percussion U
United States of America

Hand-picked

Re: some stats on .cof

Post by Myhrginoc » Wed Jun 04, 2003 7:17 am

A topic this old should be **bumped** when something is edited in it. It was eleven pages back!
Do the right thing. It will gratify some people and astonish the rest.
~ Mark Twain
Run Diablo II in any version for mods: tutorial
The Terms of Service!! Know them, abide by them, and enjoy the forums at peace.
The Beginner's Guide v1.4: (MS Word | PDF) || Mod Running Scripts || TFW: Awakening

User avatar
Joel
Moderator
Dominion
Posts: 6921
Joined: Mon May 27, 2002 7:19 am
Location: Orsay

Hand-picked

Re: some stats on .cof

Post by Joel » Wed Jun 04, 2003 7:53 am

Oh so this odd behavior of the forum telling m something is here ...
Well maybe the time to sticky it ??
"How much suffering, mortal, does it take before you lose your grace?"
Shadow Empire (coming soon) | forum

User avatar
Myhrginoc
Retired Admin
Cherub
Posts: 12100
Joined: Sat May 25, 2002 7:28 am
Location: Percussion U
United States of America

Hand-picked

Re: some stats on .cof

Post by Myhrginoc » Thu Jun 05, 2003 1:31 am

Yes, that is why it was so blasted hard to find. But now the thread is at the top of the stack, so no need to worry about it for a while. We can't sticky all the worthwhile topics!
Do the right thing. It will gratify some people and astonish the rest.
~ Mark Twain
Run Diablo II in any version for mods: tutorial
The Terms of Service!! Know them, abide by them, and enjoy the forums at peace.
The Beginner's Guide v1.4: (MS Word | PDF) || Mod Running Scripts || TFW: Awakening

User avatar
Alkalund
Retired Admin
Throne
Posts: 7597
Joined: Sun May 26, 2002 5:54 pm
Location: Toronto, Ontario, Canada

Hand-picked

Re: some stats on .cof

Post by Alkalund » Thu Jun 05, 2003 1:42 am

Heheh Myhrginoc, you also wen't back searching if there was an edited post somewhere :mrgreen: indeed, this one was buried on page 11.
After these 9 bytes string come some data for each layer frames (# of bytes = # of frames per direction, NOT total amount of frames). Theses bytes range all from 0 to 3. They are use to tell for instance which is the frame that do the hit.
In the hardcoded animation sequences in d2common.dll, there is a dword for every frame in the sequence that controls event information as well, and in there 04 is also a valid value:

00 No Event
01 Attack
02 Missile
03 Sound
04 Skill

So perhaps 04 can also be used here in the COF files. How this works is still unknown (at least to me), but perhaps in the future this may be of use somehow. My naive guess is this is tied to AI in some way.

User avatar
Paul Siramy
Retired staff
Principality
Posts: 2828
Joined: Sat May 25, 2002 2:39 pm
Location: La Garenne Colombes (near Paris)
France

Hand-picked

Re: some stats on .cof

Post by Paul Siramy » Thu Jun 05, 2003 2:24 am

Edited again the 1st post due to Alkalund infos.

[quote=Myhrginoc";p="103314"]We can't sticky all the worthwhile topics![/quote]
In any case, we have a link to that post from this topic ("Files format (DT1, DS1, COF, D2) & win_ds1edit doc") in the Tools forum, so it's not absolutly necessary to fix it.

User avatar
Paul Siramy
Retired staff
Principality
Posts: 2828
Joined: Sat May 25, 2002 2:39 pm
Location: La Garenne Colombes (near Paris)
France

Hand-picked

Re: some stats on .cof

Post by Paul Siramy » Thu Aug 14, 2003 5:14 am

Edited 1st post, with interesting informations about Bytes 4 & 5 in a cof that control layer drawing mode.

Return to “Multimedia”