diff --git a/Localization.lua b/Localization.lua index b50d895..3cf4f35 100644 --- a/Localization.lua +++ b/Localization.lua @@ -19,6 +19,7 @@ L:RegisterTranslations("enUS", function() ["Only choose players and ignore npcs when choosing target for multicurse. Does not affect 'curse' command."] = true, ["/cursive curse ||>: Casts spell if not already on target/guid"] = true, ["/cursive multicurse ||>: Picks target based on priority and casts spell if not already on target"] = true, + ["/cursive target ||>: Targets unit based on priority if spell in range and not already on target"] = true, ["Target with the highest HP."] = true, ["Target with the highest raid mark."] = true, ["Target with the highest raid mark with Cross set to -1 and Skull set to -2 (Square highest prio at 6)."] = true, @@ -195,6 +196,7 @@ L:RegisterTranslations("zhCN", function() ["Only choose players and ignore npcs when choosing target for multicurse. Does not affect 'curse' command."] = "选择多重诅咒目标时只选择玩家,忽略NPC。不影响‘诅咒’命令。", ["/cursive curse ||>: Casts spell if not already on target/guid"] = "/cursive curse <法术名称>|<目标ID>|<选项列表,用半角逗号分隔>: 如果目标/ID身上没有此法术,目标ID可以是以下内容(mouseover), (player), (pet), (party)(%d), (partypet)(%d), (raid)(%d+), (raidpet)(%d+), (target), (targettarget)", ["/cursive multicurse ||>: Picks target based on priority and casts spell if not already on target"] = "/cursive multicurse <法术名称>|<优先级>|<选项列表,用半角逗号分隔>: 根据优先级选择目标并施放法术,如果目标上没有", + ["/cursive target ||>: Targets unit based on priority if spell in range and not already on target"] = "/cursive target <法术名称>|<优先级>|<选项列表,用半角逗号分隔>:如果法术在范围内且目标上没有此法术,则根据优先级选择目标", ["Target with the highest HP."] = "选择生命值最高的目标.", ["Target with the highest raid mark."] = "选择团队标记最高的目标.", ["Target with the highest raid mark with Cross set to -1 and Skull set to -2 (Square highest prio at 6)."] = "选择团队标记最高的目标,但是将红叉设为-1,骷髅设为-2(方块标记最高优先级为6).", @@ -227,7 +229,7 @@ L:RegisterTranslations("zhCN", function() ["Text Size"] = "文本大小", ["Scale"] = "缩放", ["In Combat"] = "战斗中", - ["Player"] = "玩家", + ["Player"] = "玩家", ["Player Desc"] = "只显示玩家单位", ["Hostile"] = "敌对", ["Attackable"] = "可攻击", diff --git a/commands.lua b/commands.lua index 9d637aa..94d1f9d 100644 --- a/commands.lua +++ b/commands.lua @@ -21,6 +21,7 @@ local commandOptions = { local commands = { ["curse"] = L["/cursive curse ||>: Casts spell if not already on target/guid"], ["multicurse"] = L["/cursive multicurse ||>: Picks target based on priority and casts spell if not already on target"], + ["target"] = L["/cursive target ||>: Targets unit based on priority if spell in range and not already on target"], } local PRIORITY_HIGHEST_HP = "HIGHEST_HP" @@ -110,6 +111,10 @@ local function handleSlashCommands(msg, editbox) local spellName, priority, optionsStr = Cursive.utils.strsplit("|", args) local options = parseOptions(optionsStr) Cursive:Multicurse(spellName, priority, options) + elseif command == "target" then + local spellName, priority, optionsStr = Cursive.utils.strsplit("|", args) + local options = parseOptions(optionsStr) + Cursive:Target(spellName, priority, options) end end @@ -478,7 +483,7 @@ function Cursive:Curse(spellName, targetedGuid, options) end end -function Cursive:Multicurse(spellName, priority, options) +local function getSpellTarget(spellName, priority, options) if not spellName then DEFAULT_CHAT_FRAME:AddMessage(commands["multicurse"]) return @@ -497,14 +502,25 @@ function Cursive:Multicurse(spellName, priority, options) -- remove (Rank x) from spellName if it exists local spellNameNoRank = string.lower(string.gsub(spellName, "%(.+%)", "")) - local targetedGuid = pickTarget(selectedPriority, spellNameNoRank, true, options) + return pickTarget(selectedPriority, spellNameNoRank, true, options) +end +function Cursive:Multicurse(spellName, priority, options) + local targetedGuid = getSpellTarget(spellName, priority, options) if targetedGuid then + local spellNameNoRank = string.lower(string.gsub(spellName, "%(.+%)", "")) castSpellWithOptions(string.lower(spellName), spellNameNoRank, targetedGuid, options) elseif options["warnings"] then DEFAULT_CHAT_FRAME:AddMessage(curseNoTarget) end end +function Cursive:Target(spellName, priority, options) + local targetedGuid = getSpellTarget(spellName, priority, options) + if targetedGuid then + TargetUnit(targetedGuid) + end +end + SLASH_CURSIVE1 = "/cursive" --creating the slash command SlashCmdList["CURSIVE"] = handleSlashCommands --associating the function with the slash command