From d43fdc7a3dacb2ac7d7a506f793859af65fe09b2 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 4 Feb 2017 13:59:06 +0100 Subject: [PATCH] castbar: add initial interrupt detection --- modules/castbar.lua | 50 +++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/modules/castbar.lua b/modules/castbar.lua index 40878ec1..6137d4f8 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -317,6 +317,7 @@ pfUI:RegisterModule("castbar", function () pfUI.castbar.target:SetScript("OnEvent", function() if (arg1 ~= nil) then + -- cast action for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_CAST']) do pfUI.castbar.target:Action(mob, spell) return @@ -325,25 +326,24 @@ pfUI:RegisterModule("castbar", function () pfUI.castbar.target:Action(mob, spell) return end - -- this part will be used for interruption of spells - --for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_GAINS']) do - -- pfUI.castbar.target:Action(mob, spell, true) - -- return - --end - --for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_AFFLICTED']) do - -- pfUI.castbar.target:Action(mob, spell, "afflicted") - -- return - --end - --for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_HIT']) do - -- -- you hit mob with XX - -- -- pfUI.castbar.target:Action(mob, spell, "hit") - -- return - --end - --for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['OTHER_SPELL_HIT']) do - -- -- someone hits mob with XX - -- -- pfUI.castbar.target:Action(mob, spell, "hit") - -- return - --end + + -- interrupt action + for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_GAINS']) do + pfUI.castbar.target:StopAction(mob, spell) + return + end + for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_AFFLICTED']) do + pfUI.castbar.target:StopAction(mob, spell) + return + end + for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_HIT']) do + pfUI.castbar.target:StopAction(mob, spell) + return + end + for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['OTHER_SPELL_HIT']) do + pfUI.castbar.target:StopAction(mob, spell) + return + end end if UnitExists("target") and pfUI.castbar.target.casterDB[UnitName("target")] then @@ -362,12 +362,8 @@ pfUI:RegisterModule("castbar", function () end end) - function pfUI.castbar.target:Action(mob, spell, gains) + function pfUI.castbar.target:Action(mob, spell) if pfLocaleSpells[pfUI.cache["locale"]][spell] ~= nil then - if gains and pfUI.castbar.target.casterDB[mob] and pfUI.castbar.target.casterDB[mob]["cast"] == spell then - pfUI.castbar.target.casterDB[mob] = nil - return - end local casttime = pfLocaleSpells[pfUI.cache["locale"]][spell].t / 1000 local icon = pfLocaleSpells[pfUI.cache["locale"]][spell].icon pfUI.castbar.target.casterDB[mob] = {cast = spell, starttime = GetTime(), casttime = casttime, icon = icon} @@ -382,4 +378,10 @@ pfUI:RegisterModule("castbar", function () end end end + + function pfUI.castbar.target:StopAction(mob, spell) + if pfUI.castbar.target.casterDB[mob] and pfLocaleSpellInterrupts[pfUI.cache["locale"]][spell] ~= nil then + pfUI.castbar.target.casterDB[mob] = nil + end + end end)