Editing Infinity Engine Game Data (on Android)COPYRIGHT:
I have found this tutorial posted elsewhere with others taking credit! Beamdog forums has the only official and author authorized post. If you reproduce it, be courteous enough to give me credit - in fact, I insist upon it. You must give credit to "Trasd" and link to this post. If you follow this very simple and reasonable requirement, you are free to repost it.Please Note:
These techniques work with any OS, but I chose to demonstrate on Android for the reasons sited.
It seems, once again, as far as convenience, Android users are left out in the cold. Specifically, I am referring to the Beamdog Infinity Engine game ports' modding and console cheats. I don't blame Beamdog in the least (in fact, I both praise them for their efforts and applaud them for their accomplishments), but it would be nice if we could enjoy the same benefits as players of other OSs!
I find it highly unlikely Android users will ever be able to load most Infinity Engine game mods or that all users will be able to get to the console. To help close the gap just a little, I've decided to write a couple tutorials on editing saved games. This is essentially what a saved-game editor does, we're just going to do it manually and, we're going to do it all on Android itself (these same techniques work perfectly well on other OSs, but there are usually much easier methods for those). Theoretically, you can change nearly all values associated with your characters (any dynamic game data, for that matter), but it can get very complicated. I'm going to keep the tutorials fairly simple. My goal is not to show you how to change every modifiable value in your game, but to give you the knowledge and techniques necessary to do this for yourself. For sanity's sake, though, I would suggest using these procedures for nothing more than simple game tweaks.
Be aware, you will be editing the games' raw data (I hesitate to call it hacking because I believe executable code is hacked, data is edited). Even keeping it simple, it's easy to get confused (hopefully not with this tutorial, though), I still do and I've been doing this stuff for over 35 years (see Notes at the bottom of this post)! Always make a backup (you only need to copy the files to somewhere safe). Also, be aware, sometimes problems won't show up until much later; simple changes can have unexpected and catastrophic consequences and sometimes, a cascading effect. If you have problems with your Beamdog Infinity Engine game after editing one of its files, do not (I repeat, do not)
blame me or Beamdog or, bother them with bug reports (unless you can reproduce the problem with a clean game). You are on your own! Take responsibility for your own actions. OK, this was actually the disclaimer, but if I put "disclaimer" at the beginning, no one would read this paragraph!
If you are not technically inclined, stop here or proceed with extreme caution (I don't give specific step-by-step instructions on what I consider to be prerequisite knowledge). At a minimum, you will need to be able to manipulate hexadecimal values
. If you decide to do this, you will need a hexadecimal editor and calculator (for my recommendations, see the app links below). If you are not comfortable with these procedures, you should be able to transfer the data to your PC, then edit it with a saved-game editor (I haven't tried this, but it should work fine).
The apps needed (or something similar) are:
- A hexadecimal calculator (I use NeoCal*, but there are alternatives)
- A hexadecimal editor (I use Hex Editor Pro*, but there may be alternatives, though I haven't found one)
* I link to and use the Pro version of these apps because I believe people should be paid for their work (and I hate ads), but some do offer a free and or ad-supported version.
I also suggest bookmarking the following sites:
- BGII item code list (many of these item codes work across all Beamdog's Enhanced Editions (in theory) as they share the same engine)
- IWD item code list (Sorcerer's Place)
- Infinity Engine game data file formats, which give you a rough idea of where to look, what to look for, and its format and size (in this tutorial we're specifically interested in the CRE layout)
Don't worry if all this looks intimidating, this tutorial should
, at the least, get you through editing your ability scores and manipulating inventory items. After that, you should be knowledgeable enough to proceed on your own.Editing Ability ScoresScreenshots at the bottom.
This procedure can be used on both saved game files (BALDUR.gam) and character files (*.chr). One thing you need to be aware of (you can see this by examining the CRE file format linked above) is that ability scores are in a different order than they are presented in-game. Instead of: Str, Dex, Con, Int, Wis, then Cha, the data files store them as: Str, Str Bonus, Int, Wis, Dex, Con, then Cha. Since we will be using the ability scores to locate specific characters in the BALDUR.gam file (character names are not necessarily stored with their data), I suggest you write them down in the data file's order (translating them to hex at this point can save time). If you happen to have more than one character with the same ability scores, examine the data beneath the scores to help determine which toon you are viewing.
In this tutorial's example, we will be editing the Strength Bonus ability score in a BALDUR.gam file. Editing ability scores is quite easy. I will be using the following scores in the example (you will use your own toon's scores for your game, that's why we write them down), most likely, your values will be different than my example's:
|Ability|| Decimal || Hexadecimal |
For the example, lets say this is a Dwarven fighter and we want the strength bonus to be 100% (hex 64, aka 0x64). We need to change the 31 (0x1f) to 100 (0x64).
- Write down the ability scores of the character(s) you want to modify making sure to put them in the data file's order: Str, Str Bonus, Int, Wis, Dex, Con, Cha, then convert them to hexadecimal and put them together (side-by-side) [in the example, the resulting value would be: 121f0a0b101208 - from the hexadecimal column above]
- Open the BALDUR.gam save file you want to edit in Hex Editor Pro
- Search for the hex value of the toon you want to modify (the value you previously wrote down) keeping in mind that you usually only need the first three or four values to uniquely identify the character [in the example, we'd use 121f0a0b, then verify the rest (101208) in Hex Editor Pro's left pane to make sure we are working on the correct character]
- Tap the ability score you want to modify in Hex Editor Pro's left pane [in the example, we would tap 1f]
- In the resulting Edit dialog box, confirm the value displayed (to make sure you tapped the correct entry) and change it to whatever value you want (in hex) [in the example, we'd change it to 64 (hex for 100)]
- Tap the disk icon in the Edit dialog box to commit your changes
- Tap the disk icon in the menu bar to save the file
That's it! Open the game and verify your new ability score (make sure you load the modified saved game). If the toon's score is not what you expected, restore your backup and try again.Manipulating Inventory ItemsScreenshots at the bottom.
In this tutorial, we are going to add a Bag of Holding (BAG31) to our inventory! At the beginning of a game, I use this procedure to add a Find Familiar scroll (SCRL6D) to my main magic user's inventory so I don't have to worry about finding the spell or wasting a spell slot.
Rather than trying to calculate exactly where each inventory slot's data address begins (based off the CRE data format information linked above), which is fraught with danger, I'm going to teach you a much easier method. The best way I've found to insure I'm editing a valid address is to put a cheap, unique item into an empty slot before saving the game; a placeholder. I don't recommend using a stackable item, but if you do, make sure there is only one and not a stack (even if it appears to work with a quantity greater than one, the data will not be what the engine expects and this translates to trouble
For the example, we will assume our Dwarven fighter (from the previous tutorial) does not normally carry a dagger and so, we'll use one as the placeholder. Grab an ordinary dagger (DAGG01) from somewhere in the game and put it into one of your character's inventory slots, then save the game.
- Use the procedure outlined in the previous tutorial to identify the character who's inventory you want to modify
- Open the BALDUR.gam file you want to edit in Hex Editor Pro
- Search for the hex value of the toon you want to modify (the value you previously wrote down) [in the example, if we continue with the modified Dwarven character from the previous tutorial, we'd search for the hex value 12640a0b (notice the 64 now, instead of 1f), then verify the rest of the scores (101208) in Hex Editor Pro's left pane to make sure we are working on the correct character]
- Look for DAGG01 (in Hex Editor Pro's right pane) below the ability scores (if you examine the CRE format, you'll see a character's inventory items are below the ability scores), it shouldn't be too far down
- In the left pane, tap on 44, the capital letter D's hexadecimal value (this should be on the same row as the 'D' in DAGG01 you found in the right pane - count the spaces if needed to insure you're editing the correct 'D' if there is more than one on that row, the correct one begins the "44 41 47 47 30 31" sequence), and you will get Hex Editor Pro's Edit dialog box
- In the Edit dialog box, tap the small white down-arrow and select the ASCII radio button (the 44 on the edit line will change to the letter D)
- Change the 'D' to a 'B', then to get to the next value, tap the '>' icon in the dialog box (Item codes are case-sensitive: there are a few Bag of Holding codes, but from my experience, BAG31 is the only one that works correctly)
- Continue changing DAGG01 to BAG31 until you get to the final '1' and, as the Bag of Holding code is shorter than the dagger's item code, be sure to replace the final '1' in DAGG01 with 00 (do not use the space bar, either switch back to hex and enter 00 (zero zero) or just delete the value from the edit line altogether (Hex Edit Pro will replace an empty edit line with 00), this final value must be 00 in the left pane); in the right pane, "DAGG01" should now be replaced with "BAG31." (zero zero from the left pane is represented as a period in the right pane) and in the left pane, "44 41 47 47 30 31" should now be "42 41 47 33 31 00"
- Tap the disk icon in the Edit dialog box to commit your changes
- Tap the disk icon in the menu bar to save the file
That's it! Open the game and verify your new Bag of Holding (make sure you load the modified saved game). If something did not work, restore your backup and try again.Do not
try to add quest items with this method - it will not work (no triggers are activated) and will usually result in a corrupt game. You've been warned.
I hope this helps! Remember, with knowledge comes responsibility. Be careful as you can easily make the game boring by over-powering your party.
If any part of these tutorials is unclear or if you find a mistake, please send me a PM so I can correct it.
One of the ways working on raw data can become confusing is in an understanding of which method a system chooses to store its values in memory. All Android devices (from my understanding) use a technique called little-endian
, though strictly speaking, they don't have to (it depends upon a number of factors). This topic is far to complicated for me to try to explain here, so I will just give an example and leave it to you to explore further, if you feel the need.
Lets say your party currently has 964 (0x03c4) gold pieces and you want to change it to 2000 even (0x07d0). The easiest way would be to simply search for your current number of gold pieces and change the value, but because the data is stored in little-endian, you have to reverse the hexadecimal numbers (this is because the value here is 2 bytes wide, not 1, like with ability scores). Instead of searching for 03c4, you'd have to search for c403 (the bytes in the word are stored with the least significant byte at the lowest address) and replace it with d007! I told you it can get confusing! For numbers that are larger than a single byte (greater than 8 bits: 4 bits = a single hexadecimal digit), just remember to reverse the hexadecimal values (the hex digit pairs) when manipulating them.