Okay, I think I understand what Cyper said, let me just throw this out there, and please tell me if it is right.
All objects in the object manager are subclasses from a "base class". I'm calling this base class WowObject. To my knowledge, the object manager never has an object with its class being WowObject. All the objects in there are subclasses of this WowObject and inherit all of WowObject's members, and they also extend WowObject depending on what class they are. This can be described programmatically like this:
Code:
class WowObject
{
ulong Guid; // read from base+0x30
uint Type; // read from base+0x14
double XPosition; // read from base+0x7D0
...
}
class PlayerObject : WowObject
{
int Health; // read from player unit fields + (0x17 * 4)
int MaxHealth; // read from player unit fields + (0x1F * 4)
...
}
class DynamicObject : WowObject
{
ulong Caster;
int SpellId;
...
}
...
Which means that for every WowObject, be it a player or gameobject or dynamic object or w/e, you can get certain information from them (ie guid) in the same way, but then you can get information pertaining only to that object type (ie spell id)
Is that about right?
Thanks.
Edit: I tried to implement this functionality in my current code, but apparently it turns out casting (more specifically downcasting) is quite... interesting. Instead I just put in a "WowObject.ToPlayerObject" for every subclass. Eg. I'm reading from ObjectManager, and then determining what type of object it is, and then converting it to the type of object it is and continue reading information about it (only have a couple of NPC fields done but it shows what I'm doing (actual code, lol):
Code:
publicvoid UpdateObjectList()
{
// this method will loop through every item in the object manager
// and retrieve information about that object, then add it to the
// objectlist.
// make a temporary object and set the base address of it to the
// first object in the object manager
WowObject CurrentObject = newWowObject();
CurrentObject.BaseAddress = ReadUInt32((IntPtr)(ObjectManagerBase + GlobalAddresses.FirstObjectOffset));
// read from first object to last object in object manager
while (CurrentObject.BaseAddress != 0)
{
CurrentObject.Guid = ReadUInt64((IntPtr)(CurrentObject.BaseAddress + ObjectAddresses.GuidOffset));
CurrentObject.Type = ReadUInt32((IntPtr)(CurrentObject.BaseAddress + ObjectAddresses.TypeOffset));
CurrentObject.XPos = ReadFloat((IntPtr)(CurrentObject.BaseAddress + ObjectAddresses.XPositionOffset));
CurrentObject.YPos = ReadFloat((IntPtr)(CurrentObject.BaseAddress + ObjectAddresses.YPositionOffset));
CurrentObject.ZPos = ReadFloat((IntPtr)(CurrentObject.BaseAddress + ObjectAddresses.ZPositionOffset));
CurrentObject.Rotation = ReadFloat((IntPtr)(CurrentObject.BaseAddress + ObjectAddresses.RotationOffset));
switch (CurrentObject.Type)
{
case (uint)ObjectTypes.Item:
break;
case (uint)ObjectTypes.Container:
break;
case (uint)ObjectTypes.NPC:
NPCObject CurrentNPCObject = CurrentObject.ToNPCObject();
CurrentNPCObject.UnitFieldsAddress = ReadUInt32((IntPtr)(CurrentNPCObject.BaseAddress + 0x8));
CurrentNPCObject.CurrentHealth = ReadInt32((IntPtr)(CurrentNPCObject.UnitFieldsAddress + UnitFieldsOffsets.CurrentHealth));
CurrentNPCObject.MaxHealth = ReadInt32((IntPtr)(CurrentNPCObject.UnitFieldsAddress + UnitFieldsOffsets.MaxHealth));
// more to do
ObjectList.Add(CurrentNPCObject.Guid, newNPCObject(CurrentNPCObject));
// copy that into my local idictionary of wowobjects through copy constructor
break;
case (uint)ObjectTypes.Player:
break;
case (uint)ObjectTypes.GameObject:
break;
case (uint)ObjectTypes.DynamicObject:
break;
case (uint)ObjectTypes.Corpse:
break;
}
// set our current object as the next object
CurrentObject.BaseAddress = ReadUInt32((IntPtr)(CurrentObject.BaseAddress + ObjectAddresses.NextObjectOffset));
}
}
And by the way Cypher, I understand now what you were saying, applied it and it worked. Your terminology was what put me off.
EditEdit: Okay apparently this textbox cant understand the indentations in my code copied from Express C# so I screw it, its still kind of readable.