local curseCommands = "|cffffcc00Cursive:|cffffaaaa Commands:" local commands = { ["curse"] = "/cursive curse || highestHP then highestHP = health targetedGuid = guid end end end end end -- run again if no target found ignoring range if not targetedGuid and not skipCheckRange then targetedGuid = pickHighestHpTarget(selectedPriority, spellNameNoRank, true) end return targetedGuid end local function pickRaidMarkTarget(selectedPriority, spellNameNoRank, skipCheckRange) -- Curse the target with the highest raid mark local highestMark = 0 local targetedGuid = nil for guid, time in pairs(Cursive.core.guids) do -- apply filters local shouldDisplay = Cursive:ShouldDisplayGuid(guid) -- check if target exists/displayed/infight if UnitExists(guid) and shouldDisplay and Cursive.filter.infight(guid) then if not skipCheckRange and CheckInteractDistance(guid, 4) then -- check if the target has the curse if not Cursive.curses:HasCurse(spellNameNoRank, guid) and not isMobCrowdControlled(guid) then local raidMark = GetRaidTargetIndex(guid) if not raidMark or raidMark == 0 then if highestMark == 0 then targetedGuid = guid end else if raidMark > highestMark then highestMark = raidMark targetedGuid = guid end end end end end end -- run again if no target found ignoring range if not targetedGuid and not skipCheckRange then targetedGuid = pickRaidMarkTarget(selectedPriority, spellNameNoRank, true) end return targetedGuid end function Cursive:Curse(spellName, targetedGuid, noFailureWarning) if not spellName or not targetedGuid then DEFAULT_CHAT_FRAME:AddMessage(commands["curse"]) return end if targetedGuid and string.sub(targetedGuid, 1, 2) ~= "0x" then _, targetedGuid = UnitExists(targetedGuid) if not targetedGuid then if not (noFailureWarning and noFailureWarning == "1") then DEFAULT_CHAT_FRAME:AddMessage(curseNoTarget) end return end end -- remove (Rank x) from spellName if it exists local spellNameNoRank = string.gsub(spellName, "%(.+%)", "") if targetedGuid and not Cursive.curses:HasCurse(spellNameNoRank, targetedGuid) and not isMobCrowdControlled(targetedGuid) then CastSpellByName(spellName, targetedGuid) elseif not (noFailureWarning and noFailureWarning == "1") then DEFAULT_CHAT_FRAME:AddMessage(curseNoTarget) end end function Cursive:Multicurse(spellName, priority, noFailureWarning) if not spellName then DEFAULT_CHAT_FRAME:AddMessage(commands["multicurse"]) return end local selectedPriority = priority or "HIGHEST_HP" local targetedGuid = nil -- remove (Rank x) from spellName if it exists local spellNameNoRank = string.gsub(spellName, "%(.+%)", "") if not targetedGuid then if selectedPriority == "HIGHEST_HP" then targetedGuid = pickHighestHpTarget(selectedPriority, spellNameNoRank) elseif selectedPriority == "RAID_MARK" then targetedGuid = pickRaidMarkTarget(selectedPriority, spellNameNoRank) else DEFAULT_CHAT_FRAME:AddMessage(multiCurseUsage) return end end if targetedGuid then CastSpellByName(spellName, targetedGuid) elseif not (noFailureWarning and noFailureWarning == "1") then DEFAULT_CHAT_FRAME:AddMessage(curseNoTarget) end end SLASH_CURSIVE1 = "/cursive" --creating the slash command SlashCmdList["CURSIVE"] = handleSlashCommands --associating the function with the slash command