-
Notifications
You must be signed in to change notification settings - Fork 1
/
AlteracPullAnnouncer.lua
executable file
·122 lines (99 loc) · 3.43 KB
/
AlteracPullAnnouncer.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
local start
local isPulled = false
local PULL_ACTION = ""
local PULL_BODY = "body-"
local MELEE = "MELEE"
local nonCombatSpells = {
["Mind Vision"] = true,
["Hunter's Mark"] = true,
["Detect Magic"] = true,
["Distract"] = true,
["Flare"] = true,
}
local frame = CreateFrame("FRAME", "AVPullFrame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:RegisterEvent("UNIT_TARGET")
frame:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
frame:SetScript("OnEvent", function(self, event)
self:OnEvent(event, CombatLogGetCurrentEventInfo())
end)
function frame:OnEvent(event, ...)
-- reset on BG end
if event == "UPDATE_BATTLEFIELD_STATUS" then
if GetBattlefieldWinner() then
isPulled = false
start = nil
-- debug
DEFAULT_CHAT_FRAME:AddMessage("left bg, setting pull to false")
end
return
end
local battelfieldRunTime = GetBattlefieldInstanceRunTime()
-- Do not do anything if not in BattleGround
if not battelfieldRunTime or battelfieldRunTime <= 0 then
return
end
local subevent, _, _, sourceName, _, _, _, destName = select(2, ...)
local spellId, spellName
if destName == sourceName then
return
end
if isBossOrGuard(destName) then
if isPulled == false then
if stringstarts(subevent, "SPELL") then
spellName = select(13, ...)
pullAnnounce(destName, sourceName, PULL_ACTION, spellName)
elseif subevent == "SWING_DAMAGE" or subevent == "SWING_MISSED" then
pullAnnounce(destName, sourceName, PULL_ACTION, MELEE)
end
else
start = GetTime()
end
elseif isPulled == true then
if start ~= nil and GetTime() - start > 20 then
-- debug
DEFAULT_CHAT_FRAME:AddMessage("20 sec elapsed, setting pull to false")
isPulled = false
end
end
if isBossOrGuard(sourceName) then
if isPulled == false then
if stringstarts(subevent, "SPELL") then
spellName = select(13, ...)
pullAnnounce(sourceName, destName, PULL_BODY, spellName)
elseif subevent == "SWING_DAMAGE" or subevent == "SWING_MISSED" then
pullAnnounce(sourceName, destName, PULL_BODY, MELEE)
end
else
start = GetTime()
end
end
end
function pullAnnounce(pullee, puller, pullType, pullAction)
if nonCombatSpells[pullAction] then
-- If the spell is a non-combat spell, ignore it
return
end
isPulled = true
start = GetTime()
local msg = pullee .. " ".. pullType .."pulled by " .. puller
if pullType == PULL_BODY then
msg = msg .. " and got hit with " .. pullAction .. "."
else
msg = msg .. " with " .. pullAction .. "."
end
DEFAULT_CHAT_FRAME:AddMessage(msg)
SendChatMessage(msg, "SAY", nil, 0)
end
function isBossOrGuard(name)
if not name then
return false
end
return name == "Vanndar Stormpike" or name == "Drek'Thar" or stringends(name, "Marshal") or stringends(name, "Warmaster")
end
function stringstarts(value, search)
return string.sub(value, 1, string.len(search)) == search
end
function stringends(value, search)
return string.sub(value, -#search) == search
end