C#, Diablo 2

Understanding the diablo 2 save file format / Part 1

First of all , we need to understand the basic structure of the file , which consist of several parts each with their own header.

First we have the main header , which contains basic information such as name , class , which patch the character is on , is it a HC character? etc…

The second part is the quest completion data , which starts with the header  Woo! . On a sidenote , when setting future waypoints active which are located in acts you have not yet visited I’m pretty sure you need to have completed the previous act’s main quest.

Next up is the waypoint data with the WS header. This part is a bit more tricky as the data for the waypoints is stored in 5 bytes , which means you need to check if these bytes’ bits individually to see if they are set thus extracting the byte array to a bit array  and then modifying them to store them in a byte array once again ( this isn’t necessary , but is in my opinion a cleaner way of managing the data in your application as an array of bits ( bools ) rather than constantly managing a byte array.

The third part isn’t such an important part , it just contains the information about introductions being made to certain npcs or not. the identifier is w4.

Now comes arguably the hardest part of the file , the statistics part. Up until now ,the structure is identical for every file , meaning the byte offsets are always the same and can easily be indexed. These stats however , vary from file to file. There are 16 statistics in total , but not every statistic is always present. Meaning the size of this block varies, this block also isn’t byte-aligned anymore , giving you even more of a headache. The exact way to read this file will be explained in another blog post with some example code.

Next up is the skills block , this is fairly trivial to read. It starts with the header “if”. This is followed by 30 bytes which correspond with the points invested in your character’s skills (meaning if you have an item equipped which boosts skill points , this will not be reflected here.) The correct indexes for every skill , depending on your class can be found here .

The last major part contains all your characters items ( equipped, in belt , in stash , in inventory… ) and starts with “JM” , followed by a short , which represents the number of items. After this there will be other headers similar to this one (starting with JM , followed by a short ) . The first ones short will be either 1 or 0 , if it’s 1 , your character is alive and there is nothing special. When it is 0 however , this means your character is dead  and thus has a corpse. 12 unknown bytes will follow , and after this another item header , this time containing the items which can be found on your corpse. If you have an expansion character , this will be followed by the identifier jf if you have a mercenary. Potentially followed by another item header , containing your mercenaries items. This item list will finally be closed by “kf”.

Oof , that’s it. A lot , I know , but a necessary evil nonetheless. More information on the exact indexes can be found here .

I’d like to thank both xmission and coreyh for putting these handy resources out there as they have been a great help to me and a multitude of others. If these resources ever become offline , do not hesitate to contact me as I have tried to conserve these offline myself if something ever were to happen to these pages.

Now , on to the next post , containing some vital information on reading the character statistics.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s