Credits go to Nesox for GCD snippet, just updated the function to the current patch and declared all needed. GetSpellCD made in the same way here.
PHP Code:
public enum eSpellHistory : uint
{
SpellHistory=0xBD0B68,
FirstRec=0x8,
NextRec = 0x4,
StartTime=0x10,
GlobalCooldown = 0x30,
SpellID=0x8,
SpellCoolDown=0x20
}
[DllImport("kernel32.dll", SetLastError = true)]
static extern uint QueryPerformanceCounter(out long lpPerformanceCount);
[DllImport("kernel32.dll", SetLastError = true)]
static extern uint QueryPerformanceFrequency(out long lpFrequency);
public int GetSpellCooldown(int spellID)
{
long frequency;
long perfCount;
QueryPerformanceFrequency(out frequency);
QueryPerformanceCounter(out perfCount);
//Current time in ms
long currentTime = (perfCount * 1000) / frequency;
//Get first list object
var currentListObject = wow.ReadUInt((uint)Offsets.eSpellHistory.SpellHistory + dwCodeLoc + (uint)Offsets.eSpellHistory.FirstRec);
int cooldown = 0;
uint startTime = 0;//get record with latest starttime
while ((currentListObject != 0) && ((currentListObject & 1) == 0))
{
if (wow.ReadInt(currentListObject + (uint)Offsets.eSpellHistory.SpellID) == spellID)//filter by ID here
{
var currentStartTime = wow.ReadUInt(currentListObject + (uint)Offsets.eSpellHistory.StartTime);
if (currentStartTime > startTime) //get CD for the latest start time record
{
startTime = currentStartTime;
var spellCD=wow.ReadInt(currentListObject + (uint)Offsets.eSpellHistory.SpellCoolDown);
cooldown = (int)(startTime + spellCD - currentTime);
}
}
//Get next list object
currentListObject = wow.ReadUInt(currentListObject + (uint)Offsets.eSpellHistory.NextRec);
}
return (cooldown<0) ? 0 : cooldown/1000;
}
public bool GlobalCooldown
{
get
{
long frequency;
long perfCount;
QueryPerformanceFrequency(out frequency);
QueryPerformanceCounter(out perfCount);
//Current time in ms
long currentTime = (perfCount * 1000) / frequency;
//Get first list object
var currentListObject = wow.ReadUInt((uint)Offsets.eSpellHistory.SpellHistory + dwCodeLoc + (uint)Offsets.eSpellHistory.FirstRec);
while ((currentListObject != 0) && ((currentListObject & 1) == 0))
{
var bytes = wow.ReadBytes(currentListObject, 0x100);
//Start time of the spell cooldown in ms
var startTime = wow.ReadUInt(currentListObject + (uint)Offsets.eSpellHistory.StartTime);
//Absolute gcd of the spell in ms
var globalCooldown = wow.ReadUInt(currentListObject + (uint)Offsets.eSpellHistory.GlobalCooldown);
//Spell on gcd?
if ((startTime + globalCooldown) > currentTime)
return true;
//Get next list object
currentListObject = wow.ReadUInt(currentListObject + (uint)Offsets.eSpellHistory.NextRec);
}
return false;
}
}