f.Seek(PFunction(5)+$48,soFromBeginning); //PFunction(5) returns offset for function 5
f.ReadBuffer(bdw,4);
invitcount:=invertbyteorder(bdw);// Number of items in inventory.
bdw2:=$80;//pointer on first item
i:=1;
while i<=invitcount do
begin
f.Seek(PFunction(5)+bdw2+$30,soFromBeginning);
f.ReadBuffer(bdw,4);
j:=invertbyteorder(bdw);//j=Object ID
//FindFieldInItemInvert(ItemID,Offset) – finds loaded pro file by ID and return value at offset
if FindFieldInItemInvert(j,_ItemType)=_container then
begin
f.Seek(PFunction(5)+bdw2+$4C,soFromBeginning);// 0x4C = Number of items in container.
f.ReadBuffer(bdw,4);
invitcount:=invitcount+invertbyteorder(bdw);
end;
bdw2:=bdw2+GetItemSizeFromItemType(FindFieldInItemInvert(j,_ItemType));
i:=i+1;
end;