add gettarget command that returns guid of mob it would target

This commit is contained in:
pepopo978
2025-06-17 07:36:01 -07:00
parent c52fd33d71
commit 703321dbec
5 changed files with 34 additions and 16 deletions
+3 -3
View File
@@ -1,10 +1,10 @@
## Interface: 11200
## Title: [|CFF33AAFFSUPERWOW|R] Cursive 1.1.0
## Title-zhCN: [|CFF33AAFFSUPERWOW|R] Cursive 1.1.0
## Title: [|CFF33AAFFSUPERWOW|R] Cursive 1.2.0
## Title-zhCN: [|CFF33AAFFSUPERWOW|R] Cursive 1.2.0
## Author: Pepopo
## Notes: Uses SuperWoW GUIDs to show units in combat and track curses
## Notes-zhCN: 使用SuperWoW的GUID功能来显示战斗中的单位并监视诅咒等
## Version: 1.1.0
## Version: 1.2.0
## SavedVariablesPerCharacter: CursiveDB
## X-Embeds: Ace2, FuBarPlugin-2.0, CompostLib, DewDropLib, TabletLib
+4
View File
@@ -45,6 +45,10 @@ EXAMPLE: `/cursive target Icicles|HIGHEST_HP` will target the enemy with the hig
can also do it only if you don't have a target already:
`/run if not UnitName("target") then SlashCmdList.CURSIVE("target Icicles|HIGHEST_HP") end`
`/cursive gettarget <spellName:str>|<priority?:str>|<options?:comma separated str>`: Returns guid of the unit that would be targeted based on priority and options.
EXAMPLE: `/cursive gettarget Corruption|HIGHEST_HP` will return guid of the enemy with the highest HP in range of the spell Corruption that doesn't already have Corruption.
## Priority Options
- HIGHEST_HP - Target highest HP enemy without a curse first.
+20 -6
View File
@@ -89,7 +89,7 @@ end
local function handleSlashCommands(msg, editbox)
if not msg or msg == "" then
DEFAULT_CHAT_FRAME:AddMessage(curseCommands)
for command, description in pairs(commands) do
for _, description in pairs(commands) do
DEFAULT_CHAT_FRAME:AddMessage(description)
end
DEFAULT_CHAT_FRAME:AddMessage(priorityChoices)
@@ -117,6 +117,16 @@ local function handleSlashCommands(msg, editbox)
local spellName, priority, optionsStr = Cursive.utils.strsplit("|", args)
local options = parseOptions(optionsStr)
Cursive:Target(spellName, priority, options)
elseif command == "gettarget" then
local spellName, optionsStr = Cursive.utils.strsplit("|", args)
local options = parseOptions(optionsStr)
Cursive:GetSpellTarget(spellName, options)
else
DEFAULT_CHAT_FRAME:AddMessage(L["|cffffcc00Cursive:|cffffaaaa Unknown command."])
DEFAULT_CHAT_FRAME:AddMessage(curseCommands)
for _, description in pairs(commands) do
DEFAULT_CHAT_FRAME:AddMessage(description)
end
end
end
@@ -499,10 +509,10 @@ function Cursive:Curse(spellName, targetedGuid, options)
end
-- remove (Rank x) from spellName if it exists
local spellNameNoRank = Cursive.utils.GetSpellNameNoRank(spellName)
local lowercaseSpellNameNoRank = Cursive.utils.GetLowercaseSpellNameNoRank(spellName)
if targetedGuid and not Cursive.curses:HasCurse(spellNameNoRank, targetedGuid, options["refreshtime"]) and not isMobCrowdControlled(targetedGuid) then
castSpellWithOptions(string.lower(spellName), spellNameNoRank, targetedGuid, options)
if targetedGuid and not Cursive.curses:HasCurse(lowercaseSpellNameNoRank, targetedGuid, options["refreshtime"]) and not isMobCrowdControlled(targetedGuid) then
castSpellWithOptions(string.lower(spellName), lowercaseSpellNameNoRank, targetedGuid, options)
return true
elseif options["warnings"] then
DEFAULT_CHAT_FRAME:AddMessage(curseNoTarget)
@@ -528,7 +538,7 @@ local function getSpellTarget(spellName, priority, options)
local selectedPriority = priority or PRIORITY_HIGHEST_HP
-- remove (Rank x) from spellName if it exists
local spellNameNoRank = Cursive.utils.GetSpellNameNoRank(spellName)
local spellNameNoRank = Cursive.utils.GetLowercaseSpellNameNoRank(spellName)
return pickTarget(selectedPriority, spellNameNoRank, true, options)
end
@@ -536,7 +546,7 @@ end
function Cursive:Multicurse(spellName, priority, options)
local targetedGuid = getSpellTarget(spellName, priority, options)
if targetedGuid then
local spellNameNoRank = Cursive.utils.GetSpellNameNoRank(spellName)
local spellNameNoRank = Cursive.utils.GetLowercaseSpellNameNoRank(spellName)
castSpellWithOptions(string.lower(spellName), spellNameNoRank, targetedGuid, options)
return true
elseif options["warnings"] then
@@ -545,6 +555,10 @@ function Cursive:Multicurse(spellName, priority, options)
return false
end
function Cursive:GetTarget(spellName, priority, options)
return getSpellTarget(spellName, priority, options)
end
function Cursive:Target(spellName, priority, options)
local targetedGuid = getSpellTarget(spellName, priority, options)
if targetedGuid then
+6 -6
View File
@@ -438,19 +438,19 @@ function curses:HasAnyCurse(guid)
return nil
end
function curses:HasCurse(spellName, targetGuid, minRemaining)
function curses:HasCurse(lowercaseSpellNameNoRank, targetGuid, minRemaining)
if not minRemaining then
minRemaining = 0 -- default to 0
end
-- handle faerie fire special case
if curses.isDruid and string.find(spellName, L["faerie fire"]) then
if curses.isDruid and string.find(lowercaseSpellNameNoRank, L["faerie fire"]) then
-- remove (feral) or (bear) from spell name
spellName = L["faerie fire"]
lowercaseSpellNameNoRank = L["faerie fire"]
end
if curses.guids[targetGuid] and curses.guids[targetGuid][spellName] then
local remaining = Cursive.curses:TimeRemaining(curses.guids[targetGuid][spellName])
if curses.guids[targetGuid] and curses.guids[targetGuid][lowercaseSpellNameNoRank] then
local remaining = Cursive.curses:TimeRemaining(curses.guids[targetGuid][lowercaseSpellNameNoRank])
if remaining > minRemaining then
return true
end
@@ -461,7 +461,7 @@ function curses:HasCurse(spellName, targetGuid, minRemaining)
curses.pendingCast.targetGuid == targetGuid and
curses.pendingCast.spellID and
curses.trackedCurseIds[curses.pendingCast.spellID] and
curses.trackedCurseIds[curses.pendingCast.spellID].name == spellName then
curses.trackedCurseIds[curses.pendingCast.spellID].name == lowercaseSpellNameNoRank then
return true
end
+1 -1
View File
@@ -205,7 +205,7 @@ utils.GetLevelString = function(unitstr)
return level
end
utils.GetSpellNameNoRank = function(spellName)
utils.GetLowercaseSpellNameNoRank = function(spellName)
return string.lower(string.gsub(spellName, "%([rR]ank %d%)", ""))
end