Jump to content
Sign in to follow this  
Guest Avenger_guest

some bytes in the iwd2 .gam structure

Recommended Posts

Guest Avenger_guest

IWD2 stores the 9 customisable qslots in the .gam's actor structure, right before the name.

These quickslots are initially class dependent (as seen in qslots.2da).

 

See this example snippet as generated by ielister:

 

024eh QSlot 1 00000005

0252h QSlot 2 0000000b

0256h QSlot 3 00000004

025ah QSlot 4 00000002

025eh QSlot 5 0000005e

0262h QSlot 6 00000003

0266h QSlot 7 00000051

026ah QSlot 8 00000052

026eh QSlot 9 0000000a

0272h Name Sheris

0292h Talk count 00000000

0296h Statistics

0296h MPV name 00003ef0

029ah MPV XP 0000012c

029eh UNKNOWN 00000000

02a2h Time of join 00007b0c

02a6h UNKNOWN 00000001

02aah Kill xp 0000022f

02aeh Kill number 0000000b

02b2h Total kill x 0000022f

Share this post


Link to post

Ok, i've been able to find more fields in the iwd2 game structure

 

Explanation:

The quick weapon slots are 2x4 words, they point to item slots.

The slot usable field seems redundant, if it is 0 the slot is enabled, if it is -1 (0xffff) then the slot is disabled. (In iwd2 it is disabled if it isn't equipped).

In bg2 a similar structure exists, it is disabled when a class has less than 4 weapon slots.

Then follows 9 resrefs (in bg2 there are only 3), they contain the selected quick spells.

In iwd2 there are also 9 bytes which select the class for the quick spell. (in bg2 the class is trivial, so these fields are not existing).

The 9 class bytes are followed by a padding byte (apparently 0).

The quick item slots are self explanatory, they are also followed by redundant enabler fields. (I think these words exist in other game structures in the proper place).

Then 9 resrefs designate preselected innates. This is also damn redundant, the class selector could have been set to 0xff to designate an innate, as a quickslot cannot stand for a quick innate and a quick spell simultaneously.

19 dwords are still unknown.

Then follow the qslot fields i already wrote about.

 

Here comes an actor header from a saved game (also created by the updated ielister):

 

000000h Selected 0000

000002h Order 0000

000004h Offset 00001434

000008h Size 00000d22

00000ch Creature

000014h Orientation 00000002

000018h Area AR4102

000020h Position [07d8.09df]

000024h Viewport [0629.0870]

000028h ModalState 0000

00002ah Happiness 0000

00002ch UNKNOWN 00000000

000030h UNKNOWN 00000000

000034h UNKNOWN 00000000

000038h UNKNOWN 00000000

00003ch UNKNOWN 00000000

000040h UNKNOWN 00000000

000044h UNKNOWN 00000000

000048h UNKNOWN 00000000

00004ch UNKNOWN 00000000

000050h UNKNOWN 00000000

000054h UNKNOWN 00000000

000058h UNKNOWN 00000000

00005ch UNKNOWN 00000000

000060h UNKNOWN 00000000

000064h UNKNOWN 00000000

000068h UNKNOWN 00000000

00006ch UNKNOWN 00000000

000070h UNKNOWN 00000000

000074h UNKNOWN 00000000

000078h UNKNOWN 00000000

00007ch UNKNOWN 00000000

000080h UNKNOWN 00000000

000084h UNKNOWN 00000000

000088h UNKNOWN 00000000

00008ch Quickweapon 002b

00008eh Quickshield ffff

000090h Quickweapon 000b

000092h Quickshield ffff

000094h Quickweapon ffff

000096h Quickshield ffff

000098h Quickweapon ffff

00009ah Quickshield ffff

00009ch Slot usable 0000

00009eh Slot usable ffff

0000a0h Slot usable 0000

0000a2h Slot usable ffff

0000a4h Slot usable ffff

0000a6h Slot usable ffff

0000a8h Slot usable ffff

0000aah Slot usable ffff

0000ach Quickspell 1

0000b4h Quickspell 2

0000bch Quickspell 3

0000c4h Quickspell 4

0000cch Quickspell 5

0000d4h Quickspell 6

0000dch Quickspell 7

0000e4h Quickspell 8

0000ech Quickspell 9

0000f4h QS class 00

0000f5h QS class 00

0000f6h QS class 00

0000f7h QS class 00

0000f8h QS class 00

0000f9h QS class 00

0000fah QS class 00

0000fbh QS class 00

0000fch QS class 00

0000fdh UNKNOWN 00

0000feh Quickitem 1 000f

000100h Quickitem 2 0010

000102h Quickitem 3 0011

000104h Slot usable 0000

000106h Slot usable 0000

000108h Slot usable 0000

00010ah Quick innate

000112h Quick innate

00011ah Quick innate

000122h Quick innate

00012ah Quick innate

000132h Quick innate

00013ah Quick innate

000142h Quick innate

00014ah Quick innate

000152h UNKNOWN 00000000

000156h UNKNOWN 00000000

00015ah UNKNOWN 00000000

00015eh UNKNOWN 00000000

000162h UNKNOWN 00000000

000166h UNKNOWN 00000000

00016ah UNKNOWN 00000000

00016eh UNKNOWN 00000000

000172h UNKNOWN 00000000

000176h UNKNOWN 00000000

00017ah UNKNOWN 00000000

00017eh UNKNOWN 00000000

000182h UNKNOWN 00000000

000186h UNKNOWN 00000000

00018ah UNKNOWN 00000000

00018ah UNKNOWN 00000000

00018eh UNKNOWN 00000000

000192h UNKNOWN 00000000

000196h UNKNOWN 00000000

00019ah QSlot 1 0000000a

00019eh QSlot 2 0000000b

0001a2h QSlot 3 00000004

0001a6h QSlot 4 00000002

0001aah QSlot 5 00000003

0001aeh QSlot 6 00000052

0001b2h QSlot 7 00000050

0001b6h QSlot 8 00000051

0001bah QSlot 9 0000000a

0001beh Name Sheris

0001deh Talk count 00000000

Share this post


Link to post

Some (bg1,bg2,iwd,pst - all except iwd2) clarifications follow:

 

This was already mentioned:

0x0028 2 (word) Modal state

 

There is a typo:

0x002a 2 (word) Happiness

 

These were missing, now discovered:

0x0094 2 (word) Quick weapon slot 1 enabled (0)/disabled (-1)

0x0096 2 (word) Quick weapon slot 2 enabled (0)/disabled (-1)

0x0098 2 (word) Quick weapon slot 3 enabled (0)/disabled (-1)

0x009a 2 (word) Quick weapon slot 4 enabled (0)/disabled (-1)

 

These were marked unknown and bad size was shown, now discovered:

0x00ba 2 (word) Quick item slot 1 enabled (0)/disabled (-1)

0x00bc 2 (word) Quick item slot 2 enabled (0)/disabled (-1)

0x00be 2 (word) Quick item slot 3 enabled (0)/disabled (-1)

Edited by Avenger

Share this post


Link to post

pst info:

 

PST has 5 quick items (and 5 slot enablers).

This solved a weirdness where i thought there are 8 empty bytes after the name field.

(And this name field occasionally became 0xffffffff) which is now clearly caused by the enabler field's value!

 

So the 8 empty bytes are not after the name field, but before it, and not unknown anymore!

 

Hope some people find this useful :O

Share this post


Link to post

I've been trying to figure out how IWD2 keeps track of which quick slot is selected. I don't think it uses the CRE field at 0x9CA because that lacks sufficient information for missile weapons (it stores a number on the order of 0xFFFFFFE0 - 0xFFFFFFE3 as noted in IESDP). What I did notice is this:

 

What count as slots in the other version of the GAM file (starting at offset 0x08C in the Party/NPC struct) is used to keep track of which quick slots are filled and the byte at offset 0x289 stores the selected weapon. Here are my notes on this:

 

Quick slots in GAM V2.2 Pary/NPC fields

Weapon Slot(/Selected Ammo Slot)

1	   2	   3	   4   |   8c  8e  90  92  94  96  98  |   0x289
----------------------------+-------------------------------+--------
M	   m	   m	   m   |   43  -1  45  -1  47  -1  49  |   0
m	   M	   m	   m   |   43  -1  45  -1  47  -1  49  |   1
m	   m	   M	   m   |   43  -1  45  -1  47  -1  49  |   2
m	   m	   m	   M   |   43  -1  45  -1  47  -1  49  |   3
r/1	 r/1	 R/1		 |   11  -1  10  -1  11  -1	  |   2
	R/1				 |	   -1  11  -1	  -1	  |   1
					R/1 |	   -1	  -1	  -1  11  |   3
R/2						 |   12  -1	  -1	  -1	  |   0
R/3						 |   13  -1	  -1	  -1	  |   0
M/M	 m/m				 |   43  44  45  46			  |   0
M/M	 m	   m		   |   43  44  45	  47		  |   0


Key:
	m	   - Melee weapon
	M	   - Selected Melee weapon
	m/m	 - Dual wield melee weapons
	M/M	 - Selected dual wield melee weapons
	r/{n}   - Ranged weapon/ammo slot {n}
	R/{n}   - Selected ranged weapon/ammo slot {n}

The byte at offset 0x289 appears to correspond to the selected weapon
slot.

Share this post


Link to post

I thought i already mentioned this stuff.

 

The negative numbers for quiver slots are because the engine subtracts the weapon slot number from the value, and the quiver slots are coming before the weapon slots.

Share this post


Link to post

You are right, that the CHR info (the gam file contains that) contains the currently equipped weapon index.

The problem with the bg2 (and other previous engine versions) is that they didn't let two launchers of the same type in the quick weapon slots, because they stored only the quiver slot, and matched the launcher by the projectile type.

IWD2 allows you to set up 4 different slots with the same launcher type, but each of them could use a different quiver slot.

This additional information is stored in the fields you mentioned.

Probably this is what you meant, but it wasn't clear :)

Share this post


Link to post

Hmm, i don't see any such hex packed numbers.

Ahh, because they are not hex packed :)

 

They are decimal, and don't work as you believe either.

The slots in this case are straight quiver slots.

Their position is what determines the weapon slot :)

10 is fist

11-13 are the quiver slots.

 

Here is an actor wielding all melee (offset 480h==8ch):

 

0480h Quickweapon 002b

0482h Quickshield ffff

0484h Quickweapon 002d

0486h Quickshield ffff

0488h Quickweapon 002f

048ah Quickshield ffff

048ch Quickweapon 0031

048eh Quickshield ffff

 

2b (the first quickweapon slot) cannot be elsewhere than 480h, because the melee weapons don't need this. The 3 quivers however could be assigned to random slots.

Btw, offhand weapons in shield slots would also show order, and they would be: 2c,2e,30,32

Fist would be 0a. (10 in your chart), but it doesn't always show up.

Shields themselves never show up.

Here is a lefthanded equip, in the second slot group:

0140h Quickweapon ffff

0142h Quickshield ffff

0144h Quickweapon ffff

0146h Quickshield 002e

0148h Quickweapon ffff

014ah Quickshield ffff

014ch Quickweapon ffff

014eh Quickshield ffff

Edited by Avenger

Share this post


Link to post

Just another note:

r/1 r/1 R/1 | 11 -1 10 -1 11 -1 | 2

 

This line seems a fluke, i think the second slot was a fist slot. Or, maybe an empty quiver :)

Share this post


Link to post
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...