Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Basic IFF Exercices

Deny everything.
Joined
Jun 17, 2005
Messages
488
Reaction score
110
Quite a few people seem to have trouble with the basics of IFF-editing, so here's a quick roundup about the basics of the basics.

This tutorial will give you a bit of insight how to calculate record lengths, find typeids and copy items from one file to another.

Please note that this guide is not meant as an extensive "how do I import items" thread - that task requires a bit more insight than a basic 3-step doing will give you and I simply don't want to write up details for dozens of different version-specific kinks.

Prerequisites

To follow the exercises you'll need a few things, most of which you can get for free:
  • A good hex-editor
  • An archiver (like 7-zip or WinRAR)
  • A pangya_th.iff from update 584 or earlier.
  • A pangya_gb.iff from... well, doesn't really matter - for best mileage get one from the current update and one from S4.5.

If you have no idea how to satisfy these prerequisites you can already stop reading this guide and search the forum for answers.

It is important that you can handle your hex-editor well, especially the (hopefully) built-in data-interpreter (as in: see the respective 16bit and 32bit UINT values of a given range of bytes). How this works for the editor of your choice is beyond the scope of this guide, so cram the help-file of your program. :)

If you have the pangya_*.iff files at hand, use your favorite archiver to unpack them to separate subdirectories. Treat them as zip-files and you should end up with a directory full of iff-files.

Exercise 1: Counting the number of items in a file
It's important to understand how iff-files work internally, so let's start with something simple we can also re-use later on.

Open your pangya_gb\Part.iff in your hex-editor and let the program interpret the first two bytes as a UINT16 value. With the file I have at hand here I get the value 5124 - that's the number of items in the file. A 580 TH Part.iff should give you about 4184 items.

Exercise 2: Finding out the record length
The second we know how many items are in the file, we can also find out the record-length without having to do any manual counting.

If the file contains 5124 items and the file-size of the file is 2.664.488 bytes, the following calculation will give us the record-length of one item in the file:

(2.664.488 - 8) / 5124

Wait... Where did that 8 come from? It's the header of the IFF file that contains informations like the aforementioned number of records/items.

Punching these numbers into a calculator gives you a value of 520 - the length of one record.

Exercise 3: Finding out TypeIDs
Admittedly you don't really need the first two exercises for this one, although knowing the details is never a bad thing.

You still have that pangya_gb\Part.iff of yours opened in the hex-editor? Good!

Let's say you want to find out the ID for the Cowboy Hat. Do a string search for "Cowboy Hat". From the position you land on, go 4 bytes backwards and interpret these 4 bytes as an UINT32 value.

It should give you the number 134219776 - the ID of the item. The basic layout of the records can be seen here, just in case you're interested what else you can pull from the record.

Exercise 4: The theory of copying items from one file to another
Please note that this exercise is just the theory, the practical application has several gotchas I'll point out. There's no "How to import every item for beginners"-kind of way. Copying items around requires a fair bit of knowledge about the file you copy from, the file you copy to and the structure of the record you move around.

Let me make this clear once again: If you want to copy items around, learn about the files and don't rely on other people's tools (which can become outdated rather quick, thus corrupting your files).

Now that I'm done preaching, let's get started.

So, we do know a few things about our files. For instance, I know that while my current pangya_gb/Part.iff has a record-length of 520 bytes, the old 580 TH Part.iff has only 512 bytes per record. So there's a difference of 8 bytes - meaning I can't just copy & paste data from one file to another without translating values and cutting out excess bytes.

If I do the same check on an older pangya_gb\Part.iff from S4.5 I can see that the record-length is 512 - so I am able to copy entire records from a pre-S5 GB Part.iff to a TH Part.iff without much trouble.

Let's assume I want to copy a record from a S4.5 GB Part.iff to my TH Part.iff - how would that work?

Since I know the record-structure of the record, I can pinpoint it's start, select the following 512 bytes and copy and paste them to the end of the TH Part.iff.

Because I've modified the number of items in the file by adding another one at the end, I would then have to go to the start of my Part.iff and change the first 2 bytes so the corresponding number of items in the file equals the new number of items in the file (in this case: old value + 1), otherwise the game would simply stop reading the file before reaching my pasted item.

Thankfully you don't need to worry about typeid collisions between items, all IDs are unique worldwide and can therefore be safely used when copying.

Some items consist of so-called "subparts", i.e. Kooh's Vocaloid boots are actually 2 records, not just one. Consequently you'll need to copy both records for the item to work. Finding the subparts in a record requires a bit of knowledge about the record-schema, so read, try and learn. There's simply no way around it.

Exercise 5: Wrapping it all up
If you're done modifying the individual iff-files, you want to pack them again.

There's two things to keep in mind:
  1. Pack the files directly, not the directory they're in.
  2. Remember to use a plain old zip archive, not rar or 7z.

Rename the resulting archive to pangya_th.iff and you're done. Ready to copy the file to your game-server and pack them into PAKs.
 
Last edited:
Junior Spellweaver
Joined
Jan 18, 2011
Messages
113
Reaction score
25
Tsukasa if they don't get it after that post then there's no need in running a server...

Working with iff files isn't Rocket Science in fact its just as Tsukasa stated copy paste

Also this is from my experience but Ultra edit doesn't like copy paste in iff files. When i tried nothing would show up in the shop but my version was from 2001 so it might have been age... However Hex Workshop worked flawless.
 
Last edited:
Back
Top