I am still struggling with the magic or better I have found a few different functions online but none of them seem to work. The code below is from d3adventure and should be faster than the one I posted above, but no matter the attribute I search for it always returns 0.
Code:
public static T GetAttributeShadwd<T>(uint FagGuid, uint attribute_index) where T : struct
{
IntPtr fagPtr = AcdToFAG((int) FagGuid);
if (fagPtr == IntPtr.Zero) return default(T);
IntPtr attrPtr = GetAttribute(fagPtr, attribute_index);
if (attrPtr == IntPtr.Zero) return default(T);
return mem.ReadMemory<T>(attrPtr);
}
private static IntPtr GetAttribute(IntPtr fagPtr, uint attribute_index)
{
attribute_index = attribute_index | 0xFFFFF000;
int _38 = mem.ReadMemoryAsInt((uint) fagPtr + 0x38);
int _c8 = mem.ReadMemoryAsInt((uint) fagPtr + 0xC8);
var v4 = (int) (_c8 & (attribute_index ^ (attribute_index >> 0x10)));
v4 = (_38 + 4*v4);
v4 = mem.ReadMemoryAsInt((uint) v4);
if (v4 != 0)
{
while (mem.ReadMemoryAsUint((uint) (v4 + 4)) != attribute_index)
{
v4 = mem.ReadMemoryAsInt((uint) (v4));
if (v4 == 0)
goto NEXT_SCAN;
}
return (IntPtr) v4 + 8;
}
NEXT_SCAN:
int _10 = mem.ReadMemoryAsInt((uint) (fagPtr + 0x10));
int _8 = mem.ReadMemoryAsInt((uint) (_10 + 0x8));
int _418 = mem.ReadMemoryAsInt((uint) (_10 + 0x418));
var v5 = (int) (_418 & (attribute_index ^ (attribute_index >> 0x10)));
int _res = (_8 + 4*v5);
v5 = mem.ReadMemoryAsInt((uint) _res);
if (v5 != 0)
{
while (mem.ReadMemoryAsUint((uint) (v5 + 4)) != attribute_index)
{
v5 = mem.ReadMemoryAsInt((uint) (v5));
if (v5 == 0)
return IntPtr.Zero;
}
return (IntPtr) v5 + 8;
}
return IntPtr.Zero;
}
//These are direct translations of D3s lookup methods. This might need to stay in sync if they make code changes to it.
//or if the structure offsets change.
public static IntPtr AcdToFAG(int FagGuid)
{
int result = 0;
uint objMgr = mem.ReadMemoryAsUint(Offsets.objectManager);
uint ptr = mem.ReadMemoryAsUint(objMgr + (0x844));
ptr = mem.ReadMemoryAsUint(ptr + 0x70);
uint max = mem.ReadMemoryAsUint(ptr + 0x100);
int size = 0x180;
if ((FagGuid & 0xFFFF) < max)
{
int _148 = mem.ReadMemoryAsInt(ptr + 0x148);
int _18c = mem.ReadMemoryAsInt(ptr + 0x18c);
int a = (_148 + 4*0);
int b = (size*(FagGuid & ((1 << _18c) - 1)));
int v3 = mem.ReadMemoryAsInt((uint) (a)) + b;
result = v3 & -1;
}
return (IntPtr) result;
}
Are some of the values wrong in this? I have stepped through it and followed the pointers etc with cheat engine, but I never seem to find the attribute data.
This is the last thing I need for my bot, I have it working for every other process other wise. Currently it is looting every drop, and because of this my toon always seems to be running to town.