TeamBG

Hex Editing Tutorial #2


Introduction
Greetings to all welcome to Hex Editing Tutorial #2.
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 an Extended Header
Walk through #2 back to top
Tutorial#2

Now we will try to make some more difficult changes: we want to create
Bastard Sword +2, 4d4 cold damage unless save vs. spell with the
special ability to cast an ice ball (range: 50m, 4d4+4 cold damage unless
save vs. wand (then 2d4+2). Whenever this ability is used, the wielder
suffers 1d6+1 cold damage. But now it's a mighty weapon, so we will have to build
in a penalty: constitution and strength are decreased by 1 while the
weapon is equipped. And not enough, we're going to change the icons.

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 33 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
Offset: 00000068 ExtHeaderCount 01
  0000006A FeatureBlockOffset( 2 byte) AA
  0000006B   00
  00000070 FeatureBlockCount (Equip) 03
  00000090 FeatureBlockCount (Attack/Use) 01
  00000092 FeatureBlockSeperator 03
This is the weapon we have created in the first tutorial. Open it with a Hex Editor and save it under tutoria2.itm.
Ok, let's start with the penalties. We'll need two structs:
one manages strength and the other dexterity.
Penalties
This is what these lines look like now. 
[note: 3 structs affect user (0070h) and 1 for attacks(0090h), 0092h indicates how many structs are ahead of the structs that will be applied to this ext. header.]
00000070 03 00 01 00 01 00 49 53 57 31 48 30 31 00 01 00
00000090 01 00 03 00 00 00 02 00 03 00 00 00 01 00 32 00
The structs we are looking for the structs 0A 00 and 2C 00.
00000000 0A 00 01 00 FF FF 00 00 00 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
00000000 2C 00 01 00 FF FF 00 00 00 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: 00000002 TargetSubIdentifier (01 -> the wielder) 01
  00000004 Value to change (FF FF -> -1) FF
  00000005   FF
  0000000C Timing Identifier (02 -> while equipped) 02
Now we will insert both structs into the item code using offset 0x13A. Next thing to do is to get the value at 0x070 and increment it by two. Same process for offset 0x092.
00000070 05 00 01 00 01 00 49 53 57 31 48 30 31 00 01 00
00000090 01 00 05 00 00 00 02 00 03 00 00 00 01 00 32 00
The next step is to change the icons.



 
 
 
 
 
 
 
 
 

Changing Icons
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
00000070 05 00 01 00 01 00 49 53 57 31 48 30 31 00 01 00
Offset: 0000003A InventoryIcon(length 8h), Value: I 49
  0000003B Value: S 53
  0000003C Value: W 57
  0000003D Value: 1 31
  0000003E Value: H 48
  0000003F Value: 0 30
  00000040 Value: 1 31
  00000041 no Value 00
  00000076 QuickSlotIcon(length 8h), Value: I 49
  00000077 Value: S 53
  00000078 Value: W 57
  00000079 Value: 1 31
  0000007A Value: H 48
  0000007B Value: 0 30
  0000007C Value: 1 31
  0000007D no Value 00
Most Hex Editors have a ascii-code display (this is shown  here) . With them you can get the values directly from the editor and make any changes on this side so you don't need to know the numbers for every letter. What we have for the icons is: ISW1H01 . Now we change the values to ISW1H03
00000030 00 00 00 00 88 13 00 00 01 00 49 53 57 31 48 30
00000040 33 00 2D 00 47 53 57 31 48 30 31 00 0A 00 00 00
00000070 05 00 01 00 01 00 49 53 57 31 48 30 33 00 01 00
Ok, that was it. Now it's getting interesting: we will make the weapon cast a spell.
The first thing to do is to include a second extended header. To make it easy, we will take
the one from WAND02.ITM.
Including ExtHeader
00000070     03 01 03 00 49 57 41 4E 44 30 32 00 04 00
00000080 3C 00 00 00 00 00 00 00 06 00 00 00 00 00 01 00
00000090 04 00 00 00 64 00 01 00 00 00 00 00 AA 00 22 00
000000A0 21 00 21 00 00 00 00 00 00 00
Offset: 00000076 QuickSlotIcon(length 8h), Value: I 49
  00000077 Value: W 57
  00000078 Value: A 41
  00000079 Value: N 4E
  0000007A Value: D 44
  0000007B Value: 0 30
  0000007C Value: 2 32
  0000007D no Value 00
  0000007E Target Identifier 04
  00000080 Range 3C
  00000094 MaxCharges 64
  0000009C Ranged Effect AA
Note: open WAND02.ITM and make all changes on that object. You may save it under a different name, but the important detail in this tutorial is, that we copy and paste the new ExtHeader only when it is correct!

If we want this Ext. Header to work correctly for our deeds we need to make some changes. First we will change the QuickSlotItem reference to ISW1H03, the same way we did before. Then take a look at offset 7E -> Target Identifier:  

Value Meaning
01 target a single object
02 target inventory item
03 target dead person
04 target area
05 target self
We want the spell to have only one target, for that reason our choice is 01. 
The maximum range for that spell should be 50, in Hex 32.
Now we need to set the maximum charges. We don't want to use charges, so we change the value to 00. 
The last thing to do is to set the Ranged Effect. The mailing list contains a list of effects, what we want to have is the "Winterwolf's Ranged Attack": value 69

Now the Ext. Header has been prepared for being inserted. Copy and paste it in at offset 0x0AA.(Save!). This is what we should get for now:

00000070     03 01 03 00 49 53 57 31 48 30 33 00 01 00
00000080 32 00 00 00 00 00 00 00 06 00 00 00 00 00 01 00
00000090 04 00 00 00 00 00 01 00 00 00 00 00 69 00 22 00
000000A0 21 00 21 00 00 00 00 00 00 00
What is missing yet? The damage structs for the special effect!
Cold Damage
000000C0 06 00 00 00 00 00 01 00 04 00 00 00 00 00 01 00
Offset: 000000C8 FeatureBlockCount (Attack/Use) 04
  000000CA FeatureBlockSeperator 00
The Question is: what exactly was the special ability to do?
     
  • 4d4 +4 cold damage, save vs. wands -> 2d4 +2 cold damage
  • 1d4 +1 cold damage to user 
What do we need?
  • a 2d4 +2 cold damage (on target) struct with save possibility
  • a 2d4 +2 cold damage (on target) struct without save possibility
  • a 1d4 +1 cold damage (on user) struct without save possibility
Here they are:
00000000 0C 00 02 00 02 00 00 00 00 00 02 00 01 00 00 00
00000010 00 00 64 00 00 00 00 A4 14 24 00 04 02 00 00 00
00000020 04 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00
00000000 0C 00 02 00 02 00 00 00 00 00 02 00 01 00 00 00
00000010 00 00 64 00 00 00 00 A4 14 24 00 04 02 00 00 00
00000020 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000000 0C 00 01 00 01 00 00 00 00 00 02 00 01 00 00 00
00000010 00 00 64 00 00 00 00 A4 14 24 00 04 01 00 00 00
00000020 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Offset: 00000002 SubTargetIdentifier (02-> preset Target, 01-> self) spz.
  00000004 Amount of fixed damage spz.
  0000000A Damage Type (02 00-> cold damage) 02
  0000000B   00
  0000001C NunberOfThrows spz.
  00000020 Sides of the dice 04
  00000024 Saving Throw (08 00 00 00 -> wand) spz.
  00000025   spz.
  00000026   spz.
  00000027   spz.
These 3 struct have be inserted at the end of the item file. To make them accessible, we have to change the offset 0x0C8 to 03 and the offset 0xCA to 06 (0x0CA is FeatureBlockSeperator, that means, it counts any struct, which is used in previous ExtHeaders and on equip: in our case: 05 [on equip] + 01 [first ExtHeader] = 06)
000000C0 06 00 00 00 00 00 01 00 03 00 06 00 00 00 01 00
One thing left to do: we must make the second ExtHeader accessible:



 
 
 
 
 
 
 
 
 

Last Step
00000060 00 00 00 00 72 00 00 00 01 00 AA 00 00 00 00 00
Now, we have two ExtHeaders and that's our value for offset 0x068. The second ExtHeader places the first Feature Block at offset 0x0E2, and that's the value for offset 0x06A. 

Note: the more ExtHeaders you use, the more the value of this offset will grow, where the first Feature Block starts. You have to write it down as little- endian (explained in Tutorial #1). For example: you use 3 ExtHeaders, then the offset of the first Feature Block 0x11A. You have to write it in offset 0x06A as 1A 01 !!!

00000060 00 00 00 00 72 00 00 00 02 00 E2 00 00 00 00 00
Our weapon had been finished.
Congratulations!
Your source code should look like this:
tutoria2.itm 
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 33 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 02 00 E2 00 00 00 00 00
00000070 05 00 01 00 01 00 49 53 57 31 48 30 33 00 01 00
00000080 01 00 00 00 07 00 02 00 04 00 02 00 02 00 03 00
00000090 01 00 05 00 00 00 02 00 03 00 00 00 01 00 32 00
000000A0 32 00 00 00 00 00 00 00 00 00 03 01 03 00 49 53
000000B0 57 31 48 30 33 00 01 00 32 00 00 00 00 00 00 00
000000C0 06 00 00 00 00 00 01 00 03 00 06 00 00 00 01 00
000000D0 00 00 00 00 69 00 22 00 21 00 21 00 00 00 00 00
000000E0 00 00 07 00 01 00 66 00 00 00 15 00 00 00 02 00
000000F0 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 00 00
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000110 00 00 07 00 01 00 5E 00 00 00 14 00 00 00 02 00
00000120 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 00 00
00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000140 00 00 07 00 01 00 63 00 00 00 10 00 00 00 02 00
00000150 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 00 00
00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000170 00 00 0A 00 01 00 FF FF 00 00 00 00 00 00 02 00
00000180 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 00 00
00000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000001A0 00 00 2C 00 01 00 FF FF 00 00 00 00 00 00 02 00
000001B0 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 00 00
000001C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000001D0 00 00 0C 00 02 00 00 00 00 00 00 00 02 00 01 00
000001E0 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 00 00
000001F0 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00
00000200 00 00 0C 00 02 00 02 00 00 00 00 00 02 00 01 00
00000210 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 02 00
00000220 00 00 04 00 00 00 08 00 00 00 00 00 00 00 00 00
00000230 00 00 0C 00 02 00 02 00 00 00 00 00 02 00 01 00
00000240 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 02 00
00000250 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00
00000260 00 00 0C 00 01 00 01 00 00 00 00 00 02 00 01 00
00000270 00 00 00 00 64 00 00 00 00 A4 14 24 00 04 01 00
00000280 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00
00000290 00 00
Enjoy and have a lot of fun

made by Graf Hohfels


 
 
    back to top

 
 

BACK TO MAIN