Check Hunter Mark
More actions
Sample Code: Check Hunter's Mark by Pholus 17:00, 1 Jan 2005 (EST)
Hunter Mark is a mob debuff. The following code uses UnitDebuff to determine if a target is carrying a specific debuff by name. see Sample Code Check Hunter Aspect for how to determine buffs by name.
function isUnitDebuffUp(sUnitname, sDebuffname)
local iIterator = 1
while (UnitDebuff(sUnitname, iIterator)) do
if (string.find(UnitDebuff(sUnitname, iIterator), sDebuffname)) then
return true
end
iIterator = iIterator + 1
end
return false
end
function isTargetDebuffUp(sDebuffname)
if not sDebuffname then dbg("isTargetDebuffUp:sBuffname empty")return false end;
return isUnitDebuffUp("target", sDebuffname)
end;
The actual names are quite different than the display texts eg: "Hunters Mark" has the queriable name "Sniper".
--Spell Names local spellConcussion = "Concussive Shot" local spellHuntersMark = "Hunter's Mark(Rank 2)" --Spell Queries local qryConcussion = "Spell_Frost_Stun" local qryHuntersMark = "Sniper"
You can determine the query name of an ad-hoc debuff by casting it and using the following /script showAllUnitDebuffs("target") in a macro.
function showAllUnitDebuffs(sUnitname)
local iIterator = 1
DEFAULT_CHAT_FRAME:AddMessage(string.format("%s", "Debuff"), 1, 1, 0)
while (UnitDebuff(sUnitname, iIterator)) do
DEFAULT_CHAT_FRAME:AddMessage(format(UnitDebuff("target", iIterator)), 1, 1, 0)
iIterator = iIterator + 1
DEFAULT_CHAT_FRAME:AddMessage("---", 1, 1, 0)
end
end
From here is it simple to create functions that check to see if particular debuffs are already up before casting them.
function isTargetMarked()
if isTargetDead() then return false end;
if UnitIsFriend("player","target") then return false end;
return isTargetDebuffUp(qryHuntersMark)
end;
function isTargetConcussed()
if isTargetDead() then return false end;
if UnitIsFriend("player","target") then return false end;
return isTargetDebuffUp(qryConcussion)
end;
function setHuntersMark()
if (not isTargetMarked()) then
CastSpellByName(spellHuntersMark)
return true
else
return false
end;
end;
function setConcussed()
if (not isTargetConcussed()) then
CastSpellByName(spellConcussion);
return true
else
return false
end;
end;
I use a boolean to indicate whether a cast was necessary, that way in my macros I can chain a followup cast.
eg: /script if not setHuntersMark() then if not setConcussed() then CastSpellByName(("Auto Shot") end end;
If the target wasn't already marked then this macro would mark them otherwise skip to the next phase qwhich is to concuss them, if they were already concussed this macro would start Auto firing. Combining this technique of casting debuffs only when necessary, and the technique in Sample Code Check Hunter Aspect for only casting bufs when necessary it is possible to set up a one key macro for hunting that will take care of most of your ranged skirmishes.
See List of known buff and debuff effects that can be queried