Game Data Editing Tutorial (Hex Style) - Android Friendly
Trasd
Member Posts: 63
Editing Infinity Engine Game Data (on Android)
Copyright: Like all others, this post is copyrighted (© 2024). 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.
Please Note: After 9 years, because of changing tools, this tutorial has been reworked to be more generic. I hope it holds up better in the future when the tools change again. If anything is unclear, please let me know.
Tutorial
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 (I blame Gaggle, who has no business managing an OS; the Android API is completely befuddled), 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 its 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 45 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).
If you cannot get to your apps' data files, you cannot edit your saved games (as of this writing, you can still get to your data files on all available Android versions, even if you are not rooted). If you are not aware of how to get to the files, I suggest a DuckDuckGo internet search.
The apps needed (or something similar) are:
- A hexadecimal calculator (I use RealCal Plus, but there are alternatives).
- A hexadecimal editor (I use HEX Editor, but there may be alternatives).
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 experiment on your own.
Editing Ability Scores
Screenshots 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 saved game or character 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 (again, note the order):
Ability | Decimal | Hexadecimal |
Strength | 18 | 12 |
Strength Bonus | 31 | 1f |
Intelligence | 10 | 0a |
Wisdom | 11 | 0b |
Dexterity | 16 | 10 |
Constitution | 18 | 12 |
Charisma | 8 | 08 |
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).
Note: "0x" is just shorthand that means the value is in hexadecimal format.
- 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 modify in your hex editor.
- 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 your hex editor's hex pane (usually on the left) to make sure we are working on the correct character].
- Activate your hex editor's edit feature on the ability score you want to modify [in the example, we would edit 1f, the Strength Bonus].
- In the resulting Edit dialog box (usually a dialog box in Android), confirm the value displayed (to make sure you're editing the correct entry; 1f in the example) and change it to whatever value you want (in hex) [in the example, we'd change it to "64" (hex for 100)]
- Commit your changes with your hex editor's write feature.
- Save the modified file.
Manipulating Inventory Items
Screenshots 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 your hex editor.
- 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 your hex editor's hex pane (usually on the left) to make sure we are working on the correct character].
- Look for DAGG01 (in your hex editor'a ASCII pane (usually on the right) 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, select "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 activate your hex editor's edit feature (usually a dialog box in Android).
- In your hex editor's edit feature (again, usually a dialog box in Android), switch to ASCII mode if available. If editing in ASCII mode is not available in your hex editor, you'll have to edit the values in hex.
- Change the 'D' to a 'B'. In HEX Editor, you can simply select 'String' and type your whole string (BAG31). How ever your editor works, just make sure DAGG01 is replaced, character for character, and the BALDUR.gam file does not change size (typeover, not insert). 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).
- You may have noticed that you have a leftover '1' as "BAG31" is shorter than "DAGG01"! To fix this (and it must be fixed), replace the final '1' in DAGG01 with 00 (do not use the space bar), by switching back to hex and enter 00 (zero zero). The 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".
- Commit your changes with your hex editor's write feature.
- Save the modified file.
Cautions
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.Conclusion
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.
Have fun!
Screenshots
These screenshots are from an older defunct hex editor named Hex Editor Pro, but it works well as a visual aid. Your hex editor will not look the same, but should have the same features. See my recommendation above.Search
Edit
ASCII
Before
After
Notes
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. 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.
Post edited by Trasd on
15
Comments
@subtledoctor You can get to the saved game data without rooting (all the data files really, if you know what you're doing; I have), but the dialog.tlk (and other files) are setup a little differently on Android. I'm pretty sure others have tried to put a modded dialog.tlk into override, but it doesn't seem to work on Android. However, my tutorial is not about modding, not really. Oh, and I did mention transferring the saved game to a desktop for editing with a saved-game editor.
EDITED: For those interested, I explained a little more about how the data files for Beamdog's EE games are laid out, here.
@suraj No, sorry. There are plenty of hacking sites available and more than a few free books on the subject.
@Everyone:
Please, don't anyone mistake this tutorial for a general hacking how-to! As I stated, I wrote it to help Beamdog EE Android customers close the gap with some of the advantages that folks using other OSs enjoy.
This is a Beamdog forum for their games. I will not discuss the specifics of other games here (within this context) nor will I help anyone edit (hack) those games. Please keep any questions about this tutorial within the scope of the subjects actually covered in the tutorial.
Thanks and good luck in your pursuits.
Also, if editing basic data is all you're after, it's easy enough to transfer a save-game file to a PC for manipulation.
You know what they say: "Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime."
I believe these are valuable skills that should be learned, especially as computers have taken over every aspect of modern life.
For example, look at my IWD:EE Thief's weapon proficiencies:
Hex Edited Proficiencies
This was done without mods or a PC, on Android itself using the methods I outlined above. I like the freedom editing the data files affords me. But maybe that's just me....
But I do, and I mean I really do, believe knowledge is power! Plus, I wanted to use the opportunity to demonstrate what else can be done with my technique.
I have no problem with GameKiller and if it works for you, then there is nothing wrong with using it (obviously). Learning how to edit the save-game file works well for many apps too, and what's more is, I really like the challenge.
But, for those following, T2av and I have been PMing in an attempt for him to figure it out (as I'm going by memory though, I may have given more than one bad piece of advice). I'm hoping if he figures it out before I get around to answering the question, he will document how he did it using his tools. Sorry to call you out T2av!
Also, I hope I've helped T2 learn something new about computers! If that is true, I count it a good day. After all, that's my main goal in writing this tutorial.
I would love to run everyone through the process I used to identify the correct address to edit*, but I don't have the time right now to write another tutorial. Even though it's normally not in my nature, I'm going to tell you where to look rather than demonstrating by example.
(T2av: As we discussed via PM,) Proficiency data is transient (though the structure is consistent, its location is not) and only exists if at least one rank is taken.
To edit Two Weapon Style ranks ("pips"):
In-Game:
BALDUR.gam:
Unfortunately, I haven't found the specific Weapon Proficiency identifiers (I figured out 0xe9 was Weapon Proficiencies, but I haven't looked at any other proficiency). I think they're probably referenced in a header somewhere, but like I said, I don't really have the time to figure it all out right now.
If you have more than one weapon proficiency, you will have to change them one at a time until you find the right one (or some other method that works for you).
Good luck!
* In short: I saved a game just before leveling a fighter (I think, but any should do as the structure is the same); then I leveled and added a second rank to Two Weapon Style (again, any will work); finally, I compared the two files to see which value increased (remember, many (if not all) proficiency structures are consistent).
http://gemrb.org/iesdp/files/ids/bg2/animate.htm
I also managed to successfully changed male cleric/Mage to Mage avatar with robes. The codes can be found here ↓
This is why I push teaching something over doing it for someone.
Look at "Notes" at the bottom of my tutorial and you will see why some hex values are reversed. It is called endian-ness and is how the data is fetched. Depending upon a few different reasons, it is more efficient for the processor.
Nice job! Did the GemRB site I sent you to help?
So now you have items,stats and avatar. What drove me to do avatar, was absolutely zero mods work as its a weidu, or you have to edit via PC which is a hassle.
If anything else comes to mind, I'll add more to this
Basically you are spelling out the item name in hex format.
Here's the entire alphabet
[Spoiler]
41=A.
42=B
43=C
44=D
45=E
46=F
47=G
48=H
49=I
4A=J
4B=K
4C=L
4D=M
4E=N
4F=O
50= P
51=Q
52=R
53=S
54=T
55=U
56=V
57=W
58=X
59=Y
5A=Z
[/spoiler]
Here's numbers 0-9
[Spoiler]
O=30
1=31
2=32
3=33
4=34
5=35
6=36
7=37
8=38
9=39
[/spoiler]
Google "ASCII Table" for a complete list or "Unicode Table" for Android. There are free apps available that list the values and their hexadecimal equivalents, as well.
Save a game, learn a new spell, save that game, then compare saves.
I would suspect spells are header reference to dynamic tables, though,.
The 4 dot after dplayer seems to control what your class is. 11 is triple class I believe. 05 is bard.. Starting as cleric of helm and changing it from 03 to 0F. Makes it cleric of helm/theif multi
All I've tested so far
It is a bit tricky and you will need a PC, but you do not need the PC game version to make this work.
The direction are here, thanks to @WhiteAgnus and @Isaya.
Also, I want to thank @Kamigoroshi for pointing me in the right direction.
I haven't tested this myself, but it seems everyone who did has had great success.
Thanks @Trasd it was very educational.
I have a question T. im new at HEXing android and im trying to HEX the Marvel Future Fight(gold and crystal) . I don't know if u played the game or not ive download it from GPlay and found the file in android data and obb now the obb folder is empty but there are plenty of file inside the data folder so which file shoud i choose?