How to Add Upgrades to Your Items
This tutorial is brought to you by LiliArch and Fair Strides (me).
Okay, today I have great news you guys! LiliArch and I were talking one night and she put me up to figuring out how the game stored an item's upgrades, and both us of wanted to find out if it was even possible to attach upgrades to an item outside of the game itself. And the answer is yes. When I began investigating for LiliArch, we both had the idea to check a savegame to see what it had, and when I checked the saves for both games, I discovered that, once again, Obsidian had re-done (and I might very much say improved upon) something Bioware did: the upgrade slot storage. I'll be detailing the steps for adding an upgrade to an item for both games, though I must say that KotOR 2 is much friendlier to accommodate the upgrades. KotOR 1: In KotOR 1, the items have an Upgrade field that simply has a number. While this number might appear to be random (such as 8192 for the Vibration Cell in the swords or 65536 for the Scope on the blasters), the upgrades follow a simple formula: 1 x 2 x 2 per each row above and including the upgrade in the upgrade.2da = Your upgrade # What this means is simple: Row 0 = 1, and then keep doubling this number (Row 1 = 2, Row 2 = 4, .etc) until you get to your row; then double the number again and use that. Short: 1. Add DWORD field to main branch. 2. Label "Upgrade". 3. Enter combined numbers of desired upgrades (see the list at the bottom). 4. Click a new field and then save. 5. Done! Long: Here's an example .uti (item) file from KotOR 1. I've opened it in K-GFF and minimized all the branches: Now, you'll need to add the Upgrades field yourself, since none of the game's normal items come with upgrades and KotOR Tool doesn't use this field at all. To do so, right-click on the second thing in the window (the entry that just says "[sTRUCT ID: -1]" And then you'll want to select "Add Field: DWORD" Click on the added field, and then on the right-hand side, you will see some boxes. You will want to select the second box down (labelled "Label:") like so: And replace the "New DWORD" with "Upgrades". At this point, you will just need to enter the value of your upgrade into the Value box below the Label box. After that, you can click on another field in the .uti file and then save the .uti. Done! A list of the default upgrade items' (vanilla, no mods) numbers: KotOR 2: In KotOR 2, Obsidian made 6 fields to handle the upgrades, and each field has an index into the row of upgrade.2da to control what the item is. Much simpler to plug in a row number than a big number, right?! (Actually, this is probably more to do with the big influx of upgrades in K2 and the Upgrades field from K1 being a DWORD [a 4-byte unsigned integer], it could only hold a maximum value of 4294967295. In KotOR 1 Upgrade terms, this means that the upgrade.2da effectively becomes maxed out at 32 or 33 items... and it has 24 in the base game.) Short: 1. Add INT field. 2. Label "UpgradeSlot#", where "#" refers to the next slot you're adding, starting at 0. 3. Enter the index of the row in upgrade.2da for your desired upgrade. 4. Click on a new field and save the uti. 5. Repeat 1-4 as needed for each slot you want. 6. Done! Long: So, you have up to 6 fields to create, though you'll only use 2 for the armors, 3 for the ranged and melee weapons, and the full 6 for the lightsabers. The fields are all INT fields: UpgradeSlot0, UpgradeSlot1, UpgradeSlot2, UpgradeSlot3, UpgradeSlot4, and UpgradeSlot5. UpgradeSlot0 and UpgradeSlot1 are for the Armor Overlay and Armor Underlays in armors. UpgradeSlot0 through Upgrade Slot2 are used from left-to-right in order for the melee and ranged weapons. And for UpgradeSlot0 through UpgradeSlot5 in regards to lightsabers: UpgradeSlot0 = First Crystal slot (upper-left) UpgradeSlot1 = Color Crystal slot (middle-left) *THIS CAN"T BE EDITED, IT'S ALWAYS -1!!! UpgradeSlot2 = Second Crystal slot (lower-left) UpgradeSlot3 = Focusing Lens slot (upper-right) UpgradeSlot4 = Emitter slot (middle-right) UpgradeSlot5 = Energy Cell slot (lower-right) Now I'll run through the process of adding the UpgradeSlot0 field and then you can just add the rest if the item you're upgrading needs those slots. Here's an example .uti (item) file from KotOR 2. I've opened it in K-GFF and minimized all the branches: Now, you'll need to add the UpgradeSlot field yourself, since none of the game's normal items come with upgrades and KotOR Tool doesn't use this field at all. To do so, right-click on the second thing in the window (the entry that just says "[sTRUCT ID: -1]" And then you'll want to select "Add Field: INT" Click on the added field, and then on the right-hand side, you will see some boxes. You will want to select the second box down (labelled "Label:") like so: And replace the "New INT" with "UpgradeSlot0". At this point, you will just need to enter the value of your upgrade into the Value box below the Label box. After that, you can click on another field in the .uti file and then save the .uti. Done!