Tuesday, December 23, 2014

Understanding in game stores (Doctor's page and Aprodisiacs). aka "Health" and "Aphro" files.

There are two "stores" in Creatures 1, at least that's how I call them.

Those are the panels allowing you to inject additional items to the world through the Doctor's page and the aphrodisiacs page from the reproduction kit.

The C1 "Stores"

In this post I will show you reversing of those stores file formats, so we can replenish, parse, and edit them.

The files and their backups

The data for both those stores is kept in the "Health" and "Aphro" files, in the game main directory.

Note that the "HealthBU" and "AphroBU" files are clean backups of those.
Whenever you use the backup kit to restore their contents, the files are deleted, and replaced by the "BU" files.

So what's inside ?
Thanks to our previous knowledge of various file formats, and especially raw image files, understanding those is now a breeze.

Reversing the file format:


At this point I will spare you the very details of the process as you should've become pretty familiar with reversing file formats if you've read my other articles on the topic.
The idea is the same as always:
  • pick the file, 
  • study game panel that seems to manipulate it to guess what data might be in there,
  • Identify known structures
  • Compare found values with values shown inside the kits
  • Manipulate fields to see how they impact the file, and the other way round.
  • Test our findings!
The following are my annotations from reversing the "Health" file:

The beginning of the file...

... and the end of the first record.

Pretty straightforward wasn't it?
The contents of the "Aphro" file are of the same format.

The "Health" and "Aphro" file format:

The following schemes sum up the file format.

Overall file layout

Where each Item entry is of the form:

Entry detail

And Picture data is the raw data of the corresponding sprite.
Note that this gives us the opportunity to use pictures for the kit that are different from the actual in-game item.

Making use of the information:

Now we understand how those stores work, let's confirm we can indeed produce valid files.
To add an item, we simply need to modify file header to count 1 more item than what it was previously, and craft a valid item entry to be appended at the end of the file.

Let's keep things simple and just mimic the injection of a honey jar.
We can copy most of required information already made for us from a Honey Jars.cob file for a standard honey pot ( injection script, image data...).

If you ever mess the file too badly, chances are the kit will restore it automatically for you.
Otherwise, you can just recover it from the "HealthBU" file.

It works!

So what can we do with today's learned information?
  • Restore the game stores from the "HealthBU" and "AphroBU" files if our run empty
  • Change quantity of injectable items by editing the corresponding field in the right file
  • Add arbitrary items to the game stores for easier access than through the Injector kit for commonly used items
  • Parse the Health and Aphro files to display similar content in our own third party kit.
  • Correct translation errors (Available patches seem to mess up my French install of the game by using English terms here and there after an update)

See you next time for some more file format voodoo :)
(We will talk about graves, yay !)

No comments:

Post a Comment