rdw-archive/RagnarokFileFormats

Create a specification for the IMF format

rdw-software opened this issue · 6 comments

I was under the impression that it's unused, but apparently that's not quite right. This I find rather confusing, since I didn't notice any visible glitches in my rendition of the animations.

Of course I didn't check every conceivable combination of equipment, so I might've missed something.

I actually wrote an IMF parser at some point, but I didn't know what to do with the output (or if it's even correct). I should try to find it again...

Yes they are still used (At least I still see the path table for them in the client). But no idea where exactly they are being used.

Well, I believe it was curiosity who wrote this about them:

They also made new formats, like the worthless IMF format that no one understand what is supposed to do... (Just kidding, IMF is used when combining ACT files for player characters, but it turns out it wasn't really necessary or useful. The client uses IMF offsets when drawing the player on the character select, which is probably why headgear sometimes looks a little wonky there. It also uses it for drawing order for player character sprites in-game.

So even if they're "used", the question is rather if they're useful. The offsets can be calculated from the ACT data, so it doesn't seem like anyone would need to care about IMFs for that.

The draw order might be more relevant, but it's hard to say what exactly it's referring to. I find it difficult to untangle which of the various priorities interact with each other, e.g. the 2dlayerdir Lua file and then there's a _New_2DLayerDir_F one (both mentioned by @zhad3 ); there's IMF layers and you can also try to take into account the relative direction of the player to the camera itself.

All of it seems like an unholy mess and I'm not sure if it's even worth the effort to understand what they did, when you don't really need it to render sprites properly. That's the part I'll need to investigate first; AFAIK RoBrowser and other implementations didn't care about IMF files, so it's at least possible they're not that important.

zhad3 commented

So even if they're "used", the question is rather if they're useful. The offsets can be calculated from the ACT data, so it doesn't seem like anyone would need to care about IMFs for that.

I don't think they're that useful. If they are still used by the UI components then there's that but I haven't tested it and am not really that interested either. They are apparently still used for the render order between head and body but I haven't tested if there is any body sprite in which the order would be changed (head drawn first then body). If there is none, then it is pretty useless in that regard...

The draw order might be more relevant, but it's hard to say what exactly it's referring to.

I can create some info about the file structure but honestly its rather boring. Just something along the lines of:

struct ImfFrame {
    int priority;
    int cx;
    int cy;
}
ImfFrame data[numLayer][numAction][numFrame];

With numFrame, numLayer and numAction defined inside the IMF file for each action and layer respectively.
priority is the resulting layer which should be drawn instead. For example assuming that the head layer is 1 and the body layer is 0. You just check the data for the outcome layer. If we input the head layer: data[1][action][frame], the outcome could be 0 which is the body layer. So instead of the head layer we will draw the body layer.

I find it difficult to untangle which of the various priorities interact with each other

I am also still trying to fully understand the whole drawing process, though I am pretty confident in that I can render sprites the way gravity does it. I still need to dig a bit deeper into the lua resources. For example they seem to have (additional?) offsets for the head/headgear when riding or being a doram. But I am not sure if they're really used or not.

All of it seems like an unholy mess and I'm not sure if it's even worth the effort to understand what they did, when you don't really need it to render sprites properly.

Some things are required such as the lua files for the garments to render sprites properly, but I think it is totally fine to completely omit the IMF files.

Yeah, exactly... I mean, I only encountered one issue with the animations and I completely ignored them. The garment "special case" is curious, I'll have to look into that more.

Otherwise I could reduce the priority of this, but it probably doesn't change anything since I haven't the time to research much currently.

For example they seem to have (additional?) offsets for the head/headgear when riding or being a doram.

That's the first time I've heard of that, do you happen to know where they are stored / have an example? I didn't try dorams, but riding appears to have worked. Hmm.

I can create some info about the file structure but honestly its rather boring

Sure, that'd be great! Can never hurt to have more information in the specs, no matter how trivial.

Closing this issue here in favor of the new repo, but it might still be worth documenting (if only for completion's sake).