-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcore.lua
60 lines (49 loc) · 1.49 KB
/
core.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
if not Cursive.superwow then
return
end
-- add (1) for first stack of buffs/debuffs
-- other addons already do this, avoid having to parse both formats
AURAADDEDOTHERHELPFUL = "%s gains %s (1)."
AURAADDEDOTHERHARMFUL = "%s is afflicted by %s (1)."
AURAADDEDSELFHARMFUL = "You are afflicted by %s (1)."
AURAADDEDSELFHELPFUL = "You gain %s (1)."
Cursive.core = CreateFrame("Frame", "Cursive", UIParent)
Cursive.core.tooltipScan = CreateFrame("GameTooltip", "CursiveTooltipScan", UIParent, "GameTooltipTemplate")
Cursive.core.guids = {}
Cursive.core.add = function(unit)
local _, guid = UnitExists(unit)
if guid and not UnitIsDead(unit) then
Cursive.core.guids[guid] = GetTime()
end
end
Cursive.core.addGuid = function(guid)
-- check if first two characters are 0x
if string.sub(guid, 1, 2) ~= "0x" then
return
end
if UnitExists(guid) and not UnitIsDead(guid) then
Cursive.core.guids[guid] = GetTime()
end
end
Cursive.core.remove = function(guid)
Cursive.core.guids[guid] = nil
end
Cursive.core.enable = function()
-- unitstr
Cursive.core:RegisterEvent("PLAYER_TARGET_CHANGED")
-- arg1
Cursive.core:RegisterEvent("UNIT_COMBAT") -- this can get called with player/target/raid1 etc
Cursive.core:RegisterEvent("UNIT_MODEL_CHANGED")
end
Cursive.core.disable = function()
Cursive.core:UnregisterAllEvents()
Cursive.core.guids = {}
end
Cursive.core:SetScript("OnEvent", function()
if event == "PLAYER_TARGET_CHANGED" then
this.add("target")
else
-- arg1 is guid
this.addGuid(arg1)
end
end)