mov esi, [esp+dwId]
mov eax, esi
xor edx, edx
div dword ptr [ecx+24h]
mov eax, [ecx+18h]
mov edx, [eax+edx*4]
public enum WorldObjectType
{
Player = 0x20,
Monster = 0x24,
Item = 0x28,
}
public abstract class WorldObject
{
public uint Id { get; private set; }
protected uint BaseAddress { get; private set; }
protected IntPtr hProcess;
public WorldObject(IntPtr hProcess, uint id, uint baseAddress)
{
Id = id;
BaseAddress = baseAddress;
this.hProcess = hProcess;
}
public static WorldObjectType ResolveId(uint id)
{
WorldObjectType type;
if ((id & 0x80000000) == 0x80000000)
{
type = WorldObjectType.Monster;
}
else if ((id & 0x40000000) == 0x40000000)
{
type = WorldObjectType.Item;
}
else type = WorldObjectType.Player;
return type;
}
public static WorldObject GetObjectById(IntPtr hProcess, uint baseAddress, uint id)
{
WorldObjectType woType = ResolveId(id);
WorldObject output = null;
// standard stuff
// baseAddress is the so called real base, whatever you wanna call it, as of 15. nov its 0xA5B90C in PWI
uint pointer = Memory.GetUintAt(hProcess, baseAddress) + 0x1C;
// WorldObjects class, contains the 3 lists for world objects
pointer = Memory.GetUintAt(hProcess, pointer) + 0x8;
// WorldObjectType enum resolves to list offsets, smart huh? right... moving on.
pointer = Memory.GetUintAt(hProcess, pointer) + (uint)woType;
// hash seed pointer for the selected list
uint hash = Memory.GetUintAt(hProcess, pointer) + 0x24;
// hash seed
hash = Memory.GetUintAt(hProcess, hash);
// sequential list of pointers to listEntry objects
pointer = Memory.GetUintAt(hProcess, pointer) + 0x18;
// now, pointer contains the base of the array
pointer = Memory.GetUintAt(hProcess, pointer);
// hash function, this converts a given id to an index into the correct list.
uint index = pointer + (id % hash) * 4;
// base of this particular list entry
uint listEntry = Memory.GetUintAt(hProcess, index);
// pointer to the object desired
uint objectBase = Memory.GetUintAt(hProcess, listEntry + 0x4);
// the id of an object is stored directly inside the list entry struct
uint idImm = Memory.GetUintAt(hProcess, listEntry + 0x8);
// instantiate a WorldObject object, according to type
if (woType == WorldObjectType.Monster)
output = new Monster(hProcess, idImm, objectBase);
else if (woType == WorldObjectType.Player)
output = new Player(hProcess, idImm, objectBase);
else output = new Item(hProcess, idImm, objectBase);
return output;
}
}
public class Monster : WorldObject
{
private const uint HpOffset = 0x12C;
private const uint MaxHpOffset = 0x16C;
public uint Hp { get { return Memory.GetUintAt(hProcess, base.BaseAddress + HpOffset); } }
public uint MaxHp { get { return Memory.GetUintAt(hProcess, base.BaseAddress + MaxHpOffset); } }
public Monster(IntPtr hProcess, uint id, uint baseAddress)
: base(hProcess, id, baseAddress)
{
}
}
public class Player : WorldObject
{
private const uint HpOffset = 0x474;
private const uint MaxHpOffset = 0x4B4;
private const uint MpOffset = 0x478;
private const uint MaxMpOffset = 0x4B8;
public uint Hp { get { return Memory.GetUintAt(hProcess, base.BaseAddress + HpOffset); } }
public uint MaxHp { get { return Memory.GetUintAt(hProcess, base.BaseAddress + MaxHpOffset); } }
public uint Mp { get { return Memory.GetUintAt(hProcess, base.BaseAddress + MpOffset); } }
public uint MaxMp { get { return Memory.GetUintAt(hProcess, base.BaseAddress + MaxMpOffset); } }
public Player(IntPtr hProcess, uint id, uint baseAddress)
: base(hProcess, id, baseAddress)
{
}
}
public class Item : WorldObject
{
public Item(IntPtr hProcess, uint id, uint baseAddress)
: base(hProcess, id, baseAddress)
{
}
}