Ah, thanks!
Ah, thanks!
@ bierstud:
Thanks for the info on how to get the auras. I have one question, when I get the endTime and try to calculate the time remaining and use GetTickCount() as reference, it seems that the result is around 728000 ms off.
Right now im using: unsigned long timeleft = aura->endTime - GetTickCount() - 728000;
Should I use something else than GetTickCount() as reference?
Edit: nvm, I just read the rest of the thread and gonna look into how to use QueryPerformanceCounter.
Edit2: Got it working:
LARGE_INTEGER count;
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&count);
unsigned long time = (((double)count.QuadPart/(double)freq.QuadPart) * 1000);
unsigned long timeleft = aura->endTime - time;
Last edited by akh; 06-13-2009 at 10:40 AM.
Here's what I've got for it:
Hope this helps someone!!Code:public const uint OFFSET_BUFF_POSITION = 0xDB0; public const uint OFFSET_BUFF_POSITION_1 = 0xC38; public const uint OFFSET_BUFF_POSITION_2 = 0xC30; public const uint OFFSET_BUFF_SIZE = 0x18; public const uint OFFSET_BUFF_SPELL_ID = 0x8; private Buffs GetBuffs() { Buffs buffs = new Buffs(); uint spellID = 0; uint buffBase = (uint)Globals.memoryManager.ReadInt(Globals.playerBase + 0xC30); if (buffBase == 0) { buffBase = (uint)Globals.playerBase + Constants.OFFSET_BUFF_POSITION_1; } else { buffBase = (uint)Globals.playerBase + Constants.OFFSET_BUFF_POSITION_2; } uint buffCounter = 1; spellID = (uint)Globals.memoryManager.ReadInt(buffBase + (Constants.OFFSET_BUFF_SIZE * buffCounter) + 0x8); while (spellID != 0) { long expires = (long)Globals.memoryManager.ReadLong(buffBase + (Constants.OFFSET_BUFF_SIZE * buffCounter) + 0x14); Buff newBuff = new Buff(); newBuff.id = spellID; newBuff.expires = expires; newBuff.name = ""; if (newBuff.expires > 0) { buffs.addBuffToCollection(newBuff); } buffCounter++; spellID = (uint)Globals.memoryManager.ReadInt(buffBase + (0x18 * buffCounter) + 0x8); } return buffs; }
It seems to collect buffs correctly, but it collects both passive and non-passive buffs. Is there a way of distinguishing the 2? Also, is there an accessor for the spell name?
Im trying to figure out the flags atm:
I still have to find the dispellType, but I dont see the pattern. Anyone have more info on what the flags mean?Code:unsigned long stacks = (aura->flags & 0xFF0000) >> 16; bool harmfull = aura->flags & 0x80; bool removable = aura->flags & 0x20; //(might be the passive / non-passive)
btw, the second unknown in the struct isnt dispellType, its the duration of the aura:
Code:struct AURA { WGUID creatorGuid; // 0x00 - 0x08 unsigned long auraId; // 0x08 - 0x0C unsigned long flags; // 0x0C - 0x10 unsigned long duration; // 0x10 - 0x14 unsigned long endTime; // 0x14 - 0x18 };
Last edited by akh; 06-13-2009 at 02:35 PM.
Actually, it seems like 'flags' is actually two shorts, the second being stack count.
There's another flag (0xCode:/// <summary> /// Gets the creator GUID of this <see cref="WoWBuff"/>. /// </summary> /// <value>The creator GUID.</value> public ulong CreatorGuid { get { return _aura.creatorGuid; } } /// <summary> /// Gets the spell id of this <see cref="WoWBuff"/>. /// </summary> /// <value>The spell id.</value> public uint SpellId { get { return _aura.auraId; } } private byte[] Bytes { get { return _aura.bytes; } } /// <summary> /// Gets the duration of this <see cref="WoWBuff"/>. /// </summary> /// <value>The duration.</value> public uint Duration { get { return _aura.duration; } } /// <summary> /// Gets the end time of this <see cref="WoWBuff"/>. /// </summary> /// <value>The end time.</value> public uint EndTime { get { return _aura.endTime; } } /// <summary> /// Gets the stack count of this <see cref="WoWBuff"/>. /// </summary> /// <value>The stack count.</value> public uint StackCount { get { return _aura.stackCount; } } /// <summary> /// Gets the level of this <see cref="WoWBuff"/>. /// </summary> /// <value>The level.</value> public uint Level { get { return Bytes[1]; } } /// <summary> /// Gets a value indicating whether this instance is harmful. /// </summary> /// <value> /// <c>true</c> if this instance is harmful; otherwise, <c>false</c>. /// </value> public bool IsHarmful { get { return (Bytes[0] & 0x20) == 0; } } /// <summary> /// Gets a value indicating whether this instance is active. /// </summary> /// <value><c>true</c> if this instance is active; otherwise, <c>false</c>.</value> public bool IsActive { get { return (Bytes[0] & 0x80) == 0; } } /// <summary> /// Gets a value indicating whether this instance is passive. /// </summary> /// <value> /// <c>true</c> if this instance is passive; otherwise, <c>false</c>. /// </value> public bool IsPassive { get { return (Bytes[0] & 0x10) == 0 && !IsActive; } } [StructLayout(LayoutKind.Sequential)] private struct AURA { public ulong creatorGuid; public uint auraId; // [0] = flags, [1] = level, [2] = stack count, [3] = unk [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] bytes; // Note: This can be in the byte array above, but the 4th byte is always 00, so we might as well just do it this way. public ushort stackCount; public uint duration; public uint endTime; }, but I'm not sure what it's for yet. (Still reversing)
Last edited by Apoc; 06-15-2009 at 07:39 AM.
My GetAura() method works wonderfull using the offsets posted above me.
But it only works for my local player and npc/units.
But I'm not able to get any buffs / debuffs of other players.
Are the buffoffsets for player objects somewhere else?
It confuses me a little, since my local player is also stored as a player object in the objmgr.
I tried to dump all offsets from a player objects baseaddress + 32000;
I wasn't able to find the spellID my target was buffed with in the memory.
I considered to do this via lua_dostring, but I'm only able to get the buffs from my target or party members.
But I need them for all objects lingering around (e.g. warlock dot checks).
Last edited by jockel; 06-24-2009 at 02:25 PM.
But if you use GetUnitAura, you aren't able to get buffs/debuffs from unit's you aren't targeting, right?
That's at least what the wowwiki API documentation says.
The function Apoc is referring to:
"CGUnit_C__GetUnitAura(int index) (0x00566D80)"
Has NOTHING to do with Lua. Lua may expose some of its functionality, but it is not a lua function! You pass it an index and it returns a pointer to a UnitBuff structure (or w/e you call your buff struct). At that point you work directly with the structure and pull out any data you're interested in.
Jesus christ the noobs have REALLY been spoiled with Lua access. :s
A method for returning the name of any buffs a player has.
You could also pickup other info about a buff in this mannor such as:Code:FM.DoString( "local buffs, i = { }, 1;"+ "local buff = UnitBuff(\""+player+"\", i);"+ "while buff do\n"+ "buffs[#buffs + 1] = buff;"+ "i = i + 1;"+ "buff = UnitBuff(\""+player+"\", i);"+ "end;"+ "if #buffs < 1 then\n"+ "buffs = \"\";"+ "else\n"+ "PlayerBuffs = table.concat(buffs, \", \");" + "end;"); string[] PlayerBuffs = FM.GetLocalizedText("PlayerBuffs").Split(',');
rank, icon, count, debuffType, duration, expirationTime, source, and isStealable.
It's absolutely no problem to figure out the buffs my local player or a npc has.
But I'm currently not able to get the buffs, debuffs an other player object has.
Is there a solution besides CGUnit_C__GetUnitAura?
I'd rather do it the mem reading way.
I searched 32000 bytes from the targeted player address for the buffid, but was not able to find it there.
So my question ist, where are the buffs,debuffs stored for player objects?