local MAJOR_VERSION = "LibDogTag-Unit-3.0" local MINOR_VERSION = 90000 + tonumber(("$Revision: 171 $"):match("%d+")) or 0 if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then _G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION end DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag) local L = DogTag_Unit.L local newList = DogTag.newList DogTag:AddTag("Unit", "RuneCooldown", { code = function(runeid) if runeid > 6 or runeid < 1 then return nil end local r_start, r_duration, r_ready = GetRuneCooldown(runeid) if r_start > 0 then return math.ceil((r_start + r_duration) - GetTime()) else return nil end end, arg = { 'runeid', 'number', '@req' }, ret = "number;nil", events = "Update", doc = L["Returns the cooldown of specified rune. 1-2 are Blood, 3-4 Unholy and 5-6 Frost."], example = ('[RuneCooldown(1)] => "7"'), category = L["Runes"] }) DogTag:AddTag("Unit", "NextRune", { code = function(head) local runes = newList() for i = 1, 6 do runes[i] = newList() runes[i]["cd"] = GetRuneCooldown(i) if runes[i]["cd"] == 0 then runes[i]["cd"] = GetTime() + 1 end runes[i]["id"] = i end local vn = newList() for i = 2, 6 do --[[insertion sort]] vn = runes[i] local value = vn["cd"] local j = i-1 while j >= 1 and runes[j]["cd"] > value do runes[j + 1] = runes[j] j = j-1 end runes[j+1] = vn end if head > 6 or head < 1 then return nil end return runes[head]["id"] end, arg = { 'head', 'number;undef', 1 }, ret = "number", events = "Update", doc = L["Returns the id of the next rune to come off cooldown. Giving this tag a parameter n from 1-6 will return the n-th rune to come off cooldown."], example = ('[NextRune] => "1";[NextRune(3)] => "3"'), category = L["Runes"] }) DogTag:AddTag("Unit", "RuneType", { code = function(runeid) if runeid > 6 or runeid < 1 then return nil end local rune_type = GetRuneType(runeid) if rune_type == 1 then return "Blood" elseif rune_type == 2 then return "Unholy" elseif rune_type == 3 then return "Frost" else return "Death" end end, arg = { 'runeid', 'number', '@req' }, ret = "string;nil", events = "Update", doc = L["Returns the type of the rune ID given."], example = ('[RuneType(3)] => "Unholy"'), category = L["Runes"] }) DogTag:AddTag("Unit", "ShortRuneType", { code = function(runeid) if runeid > 6 or runeid < 1 then return nil end local rune_type = GetRuneType(runeid) if rune_type == 1 then return "B" elseif rune_type == 2 then return "U" elseif rune_type == 3 then return "F" else return "D" end end, arg = { 'runeid', 'number', '@req' }, ret = "string;nil", events = "Update", doc = L["Returns the shorthand type of the rune ID given."], example = ('[RuneName(3)] => "U"'), category = L["Runes"] }) DogTag:AddTag("Unit", "IsDeathRune", { code = function(runeid) if runeid > 6 or runeid < 1 then return false end if GetRuneType(runeid) == 4 then return true else return false end end, arg = { 'runeid', 'number', '@req' }, ret = "boolean", events = "Update", doc = L["Returns true if the given rune number is a death rune."], example = ('[IsDeathRune(1)] => "true"'), category = L["Runes"] }) DogTag:AddTag("Unit", "BloodCooldown", { code = function(number) local runenum if number == 1 then runenum = 1 elseif number == 2 then runenum = 2 else local first_rune = GetRuneCooldown(1) local second_rune = GetRuneCooldown(2) if first_rune > second_rune then runenum = 2 else runenum = 1 end end local r_start, r_duration, r_ready = GetRuneCooldown(runenum) if r_start > 0 then return math.ceil((r_start + r_duration) - GetTime()) else return nil end end, arg = { 'number', 'number;undef', 0 }, ret = "number;nil", events = "Update", doc = L["Returns the cooldown of either the first or second blood rune. If no argument is given it will display the time until a single blood rune is available."], example = ('[BloodCooldown(1)] => "7";[BloodCooldown] => "7"'), category = L["Runes"] }) DogTag:AddTag("Unit", "UnholyCooldown", { code = function(number) local runenum if number == 1 then runenum = 3 elseif number == 2 then runenum = 4 else local first_rune = GetRuneCooldown(3) local second_rune = GetRuneCooldown(4) if first_rune > second_rune then runenum = 4 else runenum = 3 end end local r_start, r_duration, r_ready = GetRuneCooldown(runenum) if r_start > 0 then return math.ceil((r_start + r_duration) - GetTime()) else return nil end end, arg = { 'number', 'number;undef', 0 }, ret = "number;nil", events = "Update", doc = L["Returns the cooldown of either the first or second unholy rune. If no argument is given it will display the time until a single unholy rune is available."], example = ('[UnholyCooldown(1)] => "7";[UnholyCooldown] => "7"'), category = L["Runes"] }) DogTag:AddTag("Unit", "FrostCooldown", { code = function(number) local runenum if number == 1 then runenum = 5 elseif number == 2 then runenum = 6 else local first_rune = GetRuneCooldown(5) local second_rune = GetRuneCooldown(6) if first_rune > second_rune then runenum = 6 else runenum = 5 end end local r_start, r_duration, r_ready = GetRuneCooldown(runenum) if r_start > 0 then return math.ceil((r_start + r_duration) - GetTime()) else return nil end end, arg = { 'number', 'number;undef', 0 }, ret = "number;nil", events = "Update", doc = L["Returns the cooldown of either the first or second frost rune. If no argument is given it will display the time until a single frost rune is available."], example = ('[FrostCooldown(1)] => "7";[FrostCooldown] => "7"'), category = L["Runes"] }) end