From cb86e3cc92c67e201e558b3f9c959e625c56ee66 Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Fri, 4 Apr 2025 07:32:21 -0700 Subject: [PATCH] fix issue with LOWEST_HP and improve melee spell failure checks --- Localization.lua | 12 ++++++++---- commands.lua | 8 +++++--- curses.lua | 39 ++++++++++++++++++++++++++------------- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/Localization.lua b/Localization.lua index fe617cc..266fcb7 100644 --- a/Localization.lua +++ b/Localization.lua @@ -36,7 +36,9 @@ L:RegisterTranslations("enUS", function() ["Your (.+) was resisted by (.+)"] = true, ["Your (.+) missed (.+)"] = true, ["Your (.+) is parried by (.+)"] = true, - ["Your (.+) fails. (.+) is immune"] = true, + ["Your (.+) fail.+\. (.+) is immune"] = true, + ["Your (.+) was blocked by (.+)"] = true, + ["Your (.+) was dodged by (.+)"] = true, -- global ["|cffffcc00Cursive:|cffffaaaa Couldn't detect SuperWoW."] = true, @@ -222,9 +224,11 @@ L:RegisterTranslations("zhCN", function() -- curses ["(.+) fades from (.+)"] = "(.+)效果从(.+)身上消失", ["Your (.+) was resisted by (.+)"] = "你的(.+)被(.+)抵抗了", - ["Your (.+) missed (.+)"] = "你的(.+)未命中(.+)", - ["Your (.+) is parried by (.+)"] = "你的(.+)被(.+)招架", - ["Your (.+) fails. (.+) is immune"] = "你的(.+)失败,(.+)免疫", + ["Your (.+) is parried by (.+)"] = "你的(.+)被(.+)招架了", + ["Your (.+) missed (.+)"] = "你的(.+)没有击中(.+)", + ["Your (.+) was dodged by (.+)"] = "你的(.+)被(.+)躲闪过去了", + ["Your (.+) was blocked by (.+)"] = "你的(.+)被(.+)格挡了", + ["Your (.+) fail.+\. (.+) is immune"] = "你的(.+)施放失败。(.+)对此免疫", -- global ["|cffffcc00Cursive:|cffffaaaa Couldn't detect SuperWoW."] = "|cffffcc00Cursive:|cffffaaaa 无法检测到SuperWoW.", diff --git a/commands.lua b/commands.lua index e008900..20768fb 100644 --- a/commands.lua +++ b/commands.lua @@ -419,9 +419,11 @@ local function pickTarget(selectedPriority, spellNameNoRank, checkRange, options primaryValue = UnitHealth(guid) or 0 end - if selectedPriority == PRIORITY_LOWEST_HP and primaryValue < highestPrimaryValue then - highestPrimaryValue = primaryValue - targetedGuid = guid + if selectedPriority == PRIORITY_LOWEST_HP then + if primaryValue < highestPrimaryValue then + highestPrimaryValue = primaryValue + targetedGuid = guid + end elseif primaryValue > highestPrimaryValue then highestPrimaryValue = primaryValue highestSecondaryValue = secondaryValue diff --git a/curses.lua b/curses.lua index 4b4b326..f8fda36 100644 --- a/curses.lua +++ b/curses.lua @@ -34,7 +34,9 @@ local fades_test = L["(.+) fades from (.+)"] local resist_test = L["Your (.+) was resisted by (.+)"] local missed_test = L["Your (.+) missed (.+)"] local parry_test = L["Your (.+) is parried by (.+)"] -local immune_test = L["Your (.+) fails. (.+) is immune"] +local immune_test = L["Your (.+) fail.+\. (.+) is immune"] +local block_test = L["Your (.+) was blocked by (.+)"] +local dodge_test = L["Your (.+) was dodged by (.+)"] local lastGuid = nil @@ -225,19 +227,30 @@ end) Cursive:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE", function(message) - -- check for resist - local _, _, spellName, target = string.find(message, resist_test) - -- check for missed - if not spellName then - _, _, spellName, target = string.find(message, missed_test) + local spell_failed_tests = { + resist_test, + immune_test + } + -- only some classes have melee spells that need to check for dodge, parry, miss, block + if playerClassName == "DRUID" or playerClassName == "HUNTER" or playerClassName == "ROGUE" then + spell_failed_tests = { + resist_test, + immune_test, + missed_test, + parry_test, + block_test, + dodge_test + } end - -- check for parry - if not spellName then - _, _, spellName, target = string.find(message, parry_test) - end - -- check for immune - if not spellName then - _, _, spellName, target = string.find(message, immune_test) + + local spellName, target + for _, test in pairs(spell_failed_tests) do + local _, _, foundSpell, foundTarget = string.find(message, test) + if foundSpell and foundTarget then + spellName = foundSpell + target = foundTarget + break + end end if spellName and target then