castbar: add initial interrupt detection

This commit is contained in:
shagu
2017-02-04 13:59:06 +01:00
parent 1bfc5dd27c
commit d43fdc7a3d
+26 -24
View File
@@ -317,6 +317,7 @@ pfUI:RegisterModule("castbar", function ()
pfUI.castbar.target:SetScript("OnEvent", function() pfUI.castbar.target:SetScript("OnEvent", function()
if (arg1 ~= nil) then if (arg1 ~= nil) then
-- cast action
for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_CAST']) do for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_CAST']) do
pfUI.castbar.target:Action(mob, spell) pfUI.castbar.target:Action(mob, spell)
return return
@@ -325,25 +326,24 @@ pfUI:RegisterModule("castbar", function ()
pfUI.castbar.target:Action(mob, spell) pfUI.castbar.target:Action(mob, spell)
return return
end end
-- this part will be used for interruption of spells
--for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_GAINS']) do -- interrupt action
-- pfUI.castbar.target:Action(mob, spell, true) for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_GAINS']) do
-- return pfUI.castbar.target:StopAction(mob, spell)
--end return
--for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_AFFLICTED']) do end
-- pfUI.castbar.target:Action(mob, spell, "afflicted") for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_AFFLICTED']) do
-- return pfUI.castbar.target:StopAction(mob, spell)
--end return
--for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_HIT']) do end
-- -- you hit mob with XX for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_HIT']) do
-- -- pfUI.castbar.target:Action(mob, spell, "hit") pfUI.castbar.target:StopAction(mob, spell)
-- return return
--end end
--for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['OTHER_SPELL_HIT']) do for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['OTHER_SPELL_HIT']) do
-- -- someone hits mob with XX pfUI.castbar.target:StopAction(mob, spell)
-- -- pfUI.castbar.target:Action(mob, spell, "hit") return
-- return end
--end
end end
if UnitExists("target") and pfUI.castbar.target.casterDB[UnitName("target")] then if UnitExists("target") and pfUI.castbar.target.casterDB[UnitName("target")] then
@@ -362,12 +362,8 @@ pfUI:RegisterModule("castbar", function ()
end end
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 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 casttime = pfLocaleSpells[pfUI.cache["locale"]][spell].t / 1000
local icon = pfLocaleSpells[pfUI.cache["locale"]][spell].icon local icon = pfLocaleSpells[pfUI.cache["locale"]][spell].icon
pfUI.castbar.target.casterDB[mob] = {cast = spell, starttime = GetTime(), casttime = casttime, icon = 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 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) end)