TeamBG

Hex Editing Tutorial #1


Introduction
Greetings to all welcome to Hex Editing Tutorial #1.
These pages were brought to you by Thalic, GMAN, Graf, Seroki, and Suryiel. Thank them!
AND don't forget to thank Ken and TeamBG for these editors
They don't get paid for this!
Remember it is not a sin nor a bad thing to read the references at the top of the Struct List.
A lot of Questions can be answered quickly there.
Now lets start!


TeamBG Home Page
TeamBG Utilities
Message Board
Hex Editing Message Board
Hex Editing FAQ Main Page

 
 
 
 
 
 
 
 
 
 
Adding a Struct Walk through #1back to top
Tutorial

We want to make a new item, it will be a bastard sword +2, +4d4 cold damage.
The first thing to do is to open an existing bastard sword with an Hex Editor.
You'll get them from using BiffstripperL.exe. NOTE: Make sure you saved the item
under different name, for example tutorial.itm.

Here we go:

SW1H01.ITM - Bastard Sword
00000000 49 54 4D 20 56 31 20 20 F6 19 00 00 51 1A 00 00
00000010 4D 49 53 43 35 36 00 00 2C 00 00 00 14 00 80 D7
00000020 4C 40 53 31 00 00 0B 00 00 00 00 00 00 00 00 00
00000030 00 00 00 00 19 00 00 00 01 00 49 53 57 31 48 30
00000040 31 00 00 00 47 53 57 31 48 30 31 00 0A 00 00 00
00000050 52 1A 00 00 FF FF FF FF 43 53 57 31 48 30 31 00
00000060 00 00 00 00 72 00 00 00 01 00 AA 00 00 00 00 00
00000070 03 00 01 00 01 00 49 53 57 31 48 30 31 00 01 00
00000080 01 00 00 00 08 00 00 00 04 00 02 00 00 00 03 00
00000090 00 00 03 00 00 00 02 00 03 00 00 00 01 00 32 00
000000A0 32 00 00 00 00 00 00 00 00 00 07 00 01 00 05 00
000000B0 00 00 15 00 00 00 02 00 00 00 00 00 64 00 00 00
000000C0 00 A4 14 24 00 04 00 00 00 00 00 00 00 00 00 00
000000D0 00 00 00 00 00 00 00 00 00 00 07 00 01 00 5E 00
000000E0 00 00 14 00 00 00 02 00 00 00 00 00 64 00 00 00
000000F0 00 A4 14 24 00 04 00 00 00 00 00 00 00 00 00 00
00000100 00 00 00 00 00 00 00 00 00 00 07 00 01 00 63 00
00000110 00 00 10 00 00 00 02 00 00 00 00 00 64 00 00 00
00000120 00 A4 14 24 00 04 00 00 00 00
Offset:  00000018 Item Attributes 03
  00000034 Item Price (length 2h) 00
  00000035   03
  00000042 Lore to Identify 00
  0000004C Item Weight 03
  00000068 ExtHeaderCount 01
  0000006A FeatureBlockOffset( 2 byte) AA
  0000006B   00
  00000070 FeatureBlockCount (Equip) 03
  00000084 Speed Factor 08
  00000086 THAC0 Bonus 03
  00000088 Number of die sides AA
  0000008A Number of throws 00
  0000008C Damage Bonus 03
  00000090 FeatureBlockCount  00
  00000092 FeatureBlockSeperator 03
The red- colored part is the header. There are Item Type, Weight, Price and much more are set. For now that's enough to know about it. Important is offset 0x070, the value counts the structs being active when the item is equipped affecting user.
The blue- colored part is the (or one of, there could be more than one) extended header. It contains damage (if it is a weapon), THAC0- modifiers and so on. Here are the offsets 0x090 and 0x092 important. 0x090 counts the structs being active on hit/use, 0x092 separates the 0x070 and 0x090 structs. 0x092 is the same number as 0x070.
Now we start making our custom weapon, starting with changing the color.
We want the sword to have a blue blade:
Changing Colors
00000000 07 00 01 00 5E 00 00 00 15 00 00 00 02 00 00 00
00000010 00 00 64 00 00 00 00 A4 14 24 00 04 00 00 00 00
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Offset:  00000004 Color ("gray") 05
  00000008 Location ("blade") 15
This is the struct for setting the color of an item. This struct changes the color of the blade to gray.
Now, we are going to change the color of the blade to sea blue, see the mailing list for a list of colors and locations:
00000000 07 00 01 00 66 00 00 00 15 00 00 00 02 00 00 00
00000010 00 00 64 00 00 00 00 A4 14 24 00 04 00 00 00 00
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Offset:  00000004 Color ("sea- blue") 66
  00000008 Location ("blade") 15
Ok, the next thing to do is to insert a struct, that does the extra damage.
Bonus Damage: Cold
00000000 0C 00 02 00 00 00 00 00 00 00 02 00 01 00 00 00
00000010 00 00 64 00 00 00 00 A4 14 24 00 04 04 00 00 00
00000020 04 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00
Offset:  00000002 SubTargetIdentifier (01 on wielder, 02 on target) 02
  00000004 Amount of fixed damage 00
  0000000A Type of desired damage (see mailing list)(length 2h) 02
  0000000B   00
  0000000C Timing Identifier  01
  0000001C Number of throws (4d?) 04
  00000020 Sides of the dice (d4) 04
  00000024 Saving throw (01 00 00 00 Spell) 01
  00000025   00
  00000026   00
  00000027   00
The previous struct makes the weapon damage the opponent for 4d4 points of extra, cold damage if a saving throw vs. spell fail. This struct has to be inserted now: copy and paste this stuct at offset 0x12A. Then get the value at 0x090 (in our case it's 00) and increment it (now 01). Now we have a normal Bastard Sword, that does 4d4 points of extra, cold damage.
NOTE: Whenever you add a struct to the 0x070 section, you have to increment 0x092!
00000090 01 00 03 00 00 00 02 00 03 00 00 00 01 00 32 00
The next steps are to make the weapon a magical weapon, set prices, lore and weight values
set THAC0 and damage bonus.
Change Item Attributes
00000010 4D 49 53 43 35 36 00 00 2C 00 00 00 14 00 80 D7
Offset 18 is responsible for the item attributes. It's only one byte long and manages whether you can also use a shield, it is cursed or it is an magical weapon. All that is defined in a bit mask.  
bit7 bit set defines a bow
bit6 bit set defines unbreakable/magical
bit5 still unknown
bit4 bit set defines cursed
bit3 still unknown
bit2 bit set enables ground icon
bit1 bit unset allows to wear a shield
bit0 still unknown
 
Offset 18 Explanation bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
Value(2C) normal item that allows a shield
0
0
1
0
1
1
0
0
Value(2E) normal item that disallows a shield
0
0
1
0
1
1
1
0
Value(6C) magical item that allows a shield 0 1 1 0 1 1 0 0
Value(6E) magical item that disallows a shield 0 1 1 0 1 1 1 0
Value(7C) magical item that allows a shield and is cursed 0 1 1 1 1 1 0 0
Value(7E) magical item that disallows a shield and is cursed 0 1 1 1 1 1 1 0
We want a magical weapon, that allows a shield and for that reason we change the value
of offset 18 to 6C. We should get this:
00000010 4D 49 53 43 35 36 00 00 6C 00 00 00 14 00 80 D7
Set THAC0 and Damage
00000080 01 00 00 00 08 00 00 00 04 00 02 00 00 00 03 00
The next to do is to set the weapon statistics. We want a sword with a speed factor of 7, THAC0: +2 and damage: 2d4 +2. Let's start:
Offset:  00000084 Speed Factor 07
  00000086 THAC0 Modifier 02
  00000088 Number of Dice Sides(no change) 04
  0000008A Number of Throws(no change) 02
  0000008C Damage Modifier 02
00000080 01 00 00 00 07 00 02 00 04 00 02 00 02 00 03 00
Set THAC0 and Damage
00000030 00 00 00 00 19 00 00 00 01 00 49 53 57 31 48 30
00000040 31 00 00 00 47 53 57 31 48 30 31 00 0A 00 00 00
Last, but not least, we'll change the price, the lore needed to identify and the item weight.
We want the item to cost 5000. It's a mighty weapon, so the lore should be 45. And the weight doesn't need to be changed, since the weapon type is the same.

NOTE: Offsets 34,35 control the price and the price is converted to Little Endian: that simply mean reverse order, take a look at the table:  

Little Endian Hexadecimal Decimal
0A 00 00 0A 10
30 02 02 30 560
88 13 13 88 5000
56 22 22 56 8790
10 27 27 10 10000
Offset:  00000034 Item Price 88
  00000035   13
  00000042 Lore To Identify 2D
  0000004C Item Weight 0A
00000030 00 00 00 00 88 13 00 00 01 00 49 53 57 31 48 30
00000040 31 00 2D 00 47 53 57 31 48 30 31 00 0A 00 00 00

There is one thing left to do, it's not necessary for gaming, but I recommend it to do:

00000050 52 1A 00 00 FF FF FF FF 43 53 57 31 48 30 31 00
Offset:  00000054 IdentifiedScriptReference FF
  00000055   FF
  00000056   FF
  00000057   FF
Get the values from the offsets 54,55,56,57:
If they all are FF, then change them all to 00. If you don't, TextMaker isn't able to save your custom Identified Item Description.
Offset:  00000054 IdentifiedScriptReference 00
  00000055   00
  00000056   00
  00000057   00
00000050 52 1A 00 00 00 00 00 00 43 53 57 31 48 30 31 00
Now our first custom Item has been finished. Save it, and then write a nice description
with the TextMaker.
 

It should look like this.
Congrats!

tutorial.itm - Bastard Sword +2,
4d4 cold damage unless
save vs. spell
00000000 49 54 4D 20 56 31 20 20 F6 19 00 00 51 1A 00 00
00000010 4D 49 53 43 35 36 00 00 6C 00 00 00 14 00 80 D7
00000020 4C 40 53 31 00 00 0B 00 00 00 00 00 00 00 00 00
00000030 00 00 00 00 88 13 00 00 01 00 49 53 57 31 48 30
00000040 31 00 2D 00 47 53 57 31 48 30 31 00 0A 00 00 00
00000050 52 1A 00 00 00 00 00 00 43 53 57 31 48 30 31 00
00000060 00 00 00 00 72 00 00 00 01 00 AA 00 00 00 00 00
00000070 03 00 01 00 01 00 49 53 57 31 48 30 31 00 01 00
00000080 01 00 00 00 07 00 02 00 04 00 02 00 02 00 03 00
00000090 01 00 03 00 00 00 02 00 03 00 00 00 01 00 32 00
000000A0 32 00 00 00 00 00 00 00 00 00 07 00 01 00 66 00
000000B0 00 00 15 00 00 00 02 00 00 00 00 00 64 00 00 00
000000C0 00 A4 14 24 00 04 00 00 00 00 00 00 00 00 00 00
000000D0 00 00 00 00 00 00 00 00 00 00 07 00 01 00 5E 00
000000E0 00 00 14 00 00 00 02 00 00 00 00 00 64 00 00 00
000000F0 00 A4 14 24 00 04 00 00 00 00 00 00 00 00 00 00
00000100 00 00 00 00 00 00 00 00 00 00 07 00 01 00 63 00
00000110 00 00 10 00 00 00 02 00 00 00 00 00 64 00 00 00
00000120 00 A4 14 24 00 04 00 00 00 00 00 00 00 00 00 00
00000130 00 00 00 00 00 00 00 00 00 00 0C 00 02 00 00 00
00000140 00 00 00 00 02 00 01 00 00 00 00 00 64 00 00 00
00000150 00 A4 14 24 00 04 04 00 00 00 04 00 00 00 01 00
00000160 00 00 00 00 00 00 00 00 00 00

Enjoy and have fun

Tutorial made by Graf Hohfels



 

    back to top

 
 

BACK TO MAIN