I looked into Judgement and double Jeopardy and i think that setting focus for double jeopardy is a limitation that could be avoided. My suggestion is this
First an Event Handler that record who we judged
Code:
function CombatLog_OnEvent(self, event, ...)
local type, _, sourceGUID, sourceNAME, _, _, destGUID, destNAME = select(2, ...)
if (event=="COMBAT_LOG_EVENT_UNFILTERED") then
if type == "SPELL_DAMAGE"
and select(12, ...) == 20271
and sourceNAME == UnitName("player")
then
JudgeTargetGUID = destGUID
end
end
end
We also need to define UnitIdsTargets that we are allowed to use in API calls
Code:
-- List if targets based on UnitIds
if not UnitIdTargets then
UnitIdTargets = {"target","focus","mouseover",""boss1","boss2","boss3","boss4","boss5",
arena1","arena2","arena3","arena4","arena5","arenapet1","arenapet2","arenapet3","arenapet4","arenapet5","pettarget"
}
end
And finally in the ability it self
Code:
if GetShapeshiftForm() == 0 then
print("No Seal Activated")
return false
end
if SpellCheck(20271) and UnitPower("player", 9) < 5 then
--if we do not have the glyph then we should just judge our main target
if UnitBuffID("player", 121027) then -- We have the double Jeopardy buff
if JudgeTargetGUID then
print("Found TargetGUID")
--Check if current target is our last Judged target
if JudgeTargetGUID == UnitGUID("target") then
for i=1,#UnitIdTargets do
if UnitExists(UnitIdTargets[i]) then
if JudgeTargetGUID ~= UnitGUID(UnitIdTargets[i]) and TargetCheck(UnitIdTargets[i], 20271) and PQR_UnitFacing("player",UnitIdTargets[i])
then
PQR_CustomTarget = UnitIdTargets[i]
return true
end
end
end
end
end
end
--Default value if no other target is available for Double Jeopardy
PQR_CustomTarget = "target"
return true
end
Tested on dummies and it works
I looked on what paintpuller did for Avery and then refined it a bit. SpellCheck and TargetCheck is just functions i created that handles the normal checks we have for each ability.