logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Decoding NWN memory - Part 3 - Items

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
isilweo



Joined: 29 Dec 2004
Posts: 22
Location: poland

PostPosted: Wed Feb 09, 2005 0:59    Post subject: Decoding NWN memory - Part 3 - Items Reply with quote

Welcome to Part 3 of decoding memory series ;)
i hope you don't think i'll everyday post new discoveries about nwn memory (as i am just translating them from polish)

Below is items memory copied from ram. it's filed with my notes. there'are few item types in this memory piece cause i update it when i find new info with item part.

There is one important thing about offsets. It's also very strange. Normally when requesting nwnx function the gameObject pointer is set to first byte of object structure. There is an array with object ids and pointers somewhere in memory (maybe i'll write about it in next post) - pointers from that array points to same address as nwnx gameObject. So we can asume that that address (gameObject) is begining of object structure. And it is true for all objects but items. Items starts 0x10 bytes earlier!
There is also array with objects tags (and pointers to objects). Elements in that array also point to gameObject...all except items. Pointer to items from this tag_array points not to gameObject but 0x10 bytes before. That 0x10 bytes before are quite important cause info about color of weapons is stored there.

short legend:
unknown pointers are stars
zeros are replaced by - (minuses)

Code:

0000:   C8326100   25251416   03190000   11------
0010:   E0316100   OBJECTID   06------   ********
0020:   FFFFFFFF   --------   TAGPOINT   TAG__LEN
0030:   RESREFPT   RESRFLEN   --------   --------
0040:   --------   --------   FFFF----   --------
0050:   --------   --------   --------   --------
0060:   --------   ------7F   01------   --------
0070:   --------   --------   --------   --------
0080:   --------   AREA__ID   XPositio   YPositio
0090:   ZPositio   Xorient    Yorient    --------
00A0:   --------   --------   --------   --------
00B0:   --------   --------   --------   01------
00c0:   0000803F   01------   01------   --------
00D0:   01------   01------   --------   --------
00E0:   PLOTFLAG   ********   VARSPTR    VARSNUM
00F0:   10------   --------   EFECTPTR   EFECTNUM
0100:   10------   --------   --------   --------
0110:   --------   --------   --------   --------
0120:   FFFFFFFF   --------   ------7F   ------7F
0130:   ------7F   ------7F   ------7F   ********
0140:   --------   ------7F   ------7F   --------
0150:   ------7F   --------   FFFFFFFF   --------
0160:   --------   --------   --------   --------
0170:   --------   --------   --------   --------
0180:   --------   ********   --------   --------
0190:   --------   ------7F   FFFFFFFF   --------
01A0:   --------   --------   --------   FFFF----
01B0:   ------7F   FFFFFFFF   --------   FFFF----
01C0:   --------   --------   --------   --------
01D0:   --------   --------   --------   --------
01E0:   IDENTIFI   --------   PROPS1pt   PRPS1num
01F0:   --------   PROPS2pt   PRPS2num   10------
0200:   CHARGES    COST       --------   ADDCOST
0210:   01------   MODELPART  --------   --------
0220:   --------   --------   --------   ------7F
0230:   --------   --------   DESCIDPT   DSCSTRRF
0240:   DSCUNPTR   DSCUNSRF   NAME PTR   NAMESREF
0250:   --------   --------   --------   CURSED
0260:   STACKSIZE  STOLEN     14------   --------
0270:   ------7F   --------   --------   --------
0280:   81005100   03000800



now comments

Code:
0000:   C8326100   25251416   03190000   11------

here we have header and it's first int (header is not constant for all objects.. i don't know what is is. i just call it header)
after that there are 6 bytes describing colors:
leather1color (25) leather2color(25)
cloth1color (14) cloth2color (16)
metal1color (03) metal2color (19)
then two zero bytes (or one word) maybe reserved for other color thing (plastic1color? ;>)
next is basetype/baseitem (11)

Code:
0010:   E0316100   12------   06------   ********

here we are at gameObject (from nwnx request). 12 is object id and 06 is information that object is ITEM.

base address of offset is gameObject - 0x10

0x4 - leather 1 color (byte)
0x5 - leather 2 color (byte)
0x6 - cloth 1 color (byte)
0x7 - cloth 2 color (byte)
0x8 - metal 1 color (byte)
0x9 - metal 2 color (byte)
0xC - basetype (int)
0x14 - Object ID (int) - the same that is ObjectToString()
0x18 - object type (byte)
0x28 - Tag pointer (int)
0x2C - Tag Length (int)
0x30 - Resref pointer (int)
0x34 - ResRef Length (int)
0x84 - Area ID (float) - it is "where am i laying"
0x88 - Xposition (float)
0x8C - YPosition (float)
0x90 - ZPosition (float)
0x94 - XOrientatin (float)
0x98 - YOrientation (float)
0xE0 - Plot flag (byte)
0xE8 - LocalVarsPointer (see Part 2 of series)
0xEC - LocalVarsCount
0xF8 - pointer to array of pointers to (int - efekt_id)
0xFC - number of elements in array from 0xf8
0x1E0 - identified flag (byte)
0x1E8 - properties 1 pointer (active?)
0x1Ec - properties 1 count
0x1F4 - properties 2 pointer (passive?)
0x1F8 - properties 2 count
0x200 - charges (byte)
0x204 - cost (int)
0x20C - addcost (int)
0x214 - modelpart (byte)
0x215 - modelpart2 (byte) - if item is layered (ie sword)
0x216 - modelpart 3 (byte) as above
0x217 - ArmorPart_RFoot
0x218 - ArmorPart_LFoot
0x219 - ArmorPart_RShin
0x21A - ArmorPart_LShin
0x21B - ArmorPart_LThigh
0x21C - ArmorPart_RThigh
0x21D - ArmorPart_Pelvis
0x21E - ArmorPart_Torso
0x21F - ArmorPart_Belt
0x220 - ArmorPart_Neck
0x221 - ArmorPart_RFArm
0x222 - ArmorPart_LFArm
0x223 - ArmorPart_RBicep
0x224 - ArmorPart_LBicep
0x225 - ArmorPart_RShoul
0x226 - ArmorPart_LShoul
0x227 - ArmorPart_RHand
0x228 - ArmorPart_LHand
0x229 - ArmorPart_Robe
0x238 - Pointer to description (identified) (int);
0x23c - StrRef of desc (identified) (int) [if = FF FF FF FF then desc is in the pointer if not check in tlk];
0x240 - Pointer to desc (unidentified) (int);
0x244 - StrRef of desc (unidentified) (int);
0x248 - Pointer to name;
0x24c - StrRef of name;
0x25C -cursed flag = non drop (bytE)
0x260 - stacksize (word (czyli 2 bajty))
0x264 - stolen flag (byte)

some notes:
armors don't have modelpart instead they use Armorpart*. Simple objects have only modelpart1. Layered items have modelpart1,2,3

What is active and passive properties?
It seems that item properites are stored in two diffrent addresses. They're split. Active means that propery will work when you use it, passive means that property is working all the time (if you have item equiped of course)

SItemProperties
0x00 - Property name (word)
0x02 - Subtype (word)
0x04 - Cost Table (byte)
0x05 - number 0x25
0x06 - Cost Value (word)
0x08 - Param1
0x09 - Param1Value
0x0A - Chance Appear (unused, always 0x64)
0x0B - 9 bytes of something (always same): 0001000000ff02e11f

example:
Code:
Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F

00000000 27 00 00 00 0B 25 04 00 '....%..
00000010 FF 00 64 00 01 00 00 00 FF 02 E1 1F ˙.d.....˙.á.
Back to top
View user's profile Send private message
isilweo



Joined: 29 Dec 2004
Posts: 22
Location: poland

PostPosted: Wed Feb 09, 2005 1:07    Post subject: Reply with quote

also we can write offsets using structures that we know

0x4 - SItemColors
0xC - basetype (int)
0x14 - Object ID (int) - the same that is ObjectToString()
0x18 - object type (byte)
0x28 - SNWString ItemTag
0x30 - SNWString ResRef (int)
0x84 - Area ID (float) - it is "where am i laying"
0x88 - Xposition (float)
0x8C - YPosition (float)
0x90 - ZPosition (float)
0x94 - XOrientatin (float)
0x98 - YOrientation (float)
0xE0 - Plot flag (byte)
0xE8 - SLocalVarsPtr localvars
0xF8 - pointer to array of pointers to (int - efect_id)
0xFC - number of elements in array from 0xf8
0x1E0 - identified flag (byte)
0x1E8 - properties 1 pointer (active?)
0x1Ec - properties 1 count
0x1F4 - properties 2 pointer (passive?)
0x1F8 - properties 2 count
0x200 - charges (byte)
0x204 - cost (int)
0x20C - addcost (int)
0x214 - SItemModels
0x238 - CExoLocString DescIdentified
0x240 - CExoLocString DescUnidentified
0x248 - CExoLocString name;
0x25C -cursed flag = non drop (bytE)
0x260 - stacksize (word (czyli 2 bajty))
0x264 - stolen flag (byte)

SItemColors
byte leather 1 color
byte leather 2 color
byte cloth 1 color
byte cloth 2 color
byte metal 1 color
byte metal 2 color


SItemModels
byte modelpart
byte modelpart2
byte modelpart 3
byte ArmorPart_RFoot
byte ArmorPart_LFoot
byte ArmorPart_RShin
byte ArmorPart_LShin
byte ArmorPart_LThigh
byte ArmorPart_RThigh
byte ArmorPart_Pelvis
byte ArmorPart_Torso
byte ArmorPart_Belt
byte ArmorPart_Neck
byte ArmorPart_RFArm
byte ArmorPart_LFArm
byte ArmorPart_RBicep
byte ArmorPart_LBicep
byte ArmorPart_RShoul
byte ArmorPart_LShoul
byte ArmorPart_RHand
byte ArmorPart_LHand
byte ArmorPart_Robe
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group