forked from aethys256/AethysTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPullAnnouncer.lua
More file actions
240 lines (232 loc) · 9.55 KB
/
Copy pathPullAnnouncer.lua
File metadata and controls
240 lines (232 loc) · 9.55 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
--- ============================ HEADER ============================
--- ======= LOCALIZE =======
-- Addon
local addonName, AT = ...;
-- HeroLib
local HL = HeroLib;
local Cache = HeroCache;
local Unit = HL.Unit;
local Player = Unit.Player;
local Target = Unit.Target;
local Spell = HL.Spell;
local Item = HL.Item;
-- Lua
-- File Locals
local CombatTime, OutCombatTime = 0, 0;
local Pulled, Roster = {}, {};
local SpecialSpells = {
-- Taunt
[355] = true, -- Warrior - Taunt
[62124] = true, -- Paladin - Reckoning
[20736] = true, -- Hunter - Distracting Shot
[56222] = true, -- DK - Dark Command
[115546] = true, -- Monk - Provoke
[6795] = true, -- Druid - Growl
[185245] = true, -- DH - Torment
-- Silence/Interrupt
[6552] = true, -- Warrior - Pummel
[96231] = true, -- Paladin - Rebuke
[147362] = true, -- Hunter - Counter Shot
[1766] = true, -- Rogue - Kick
[47476] = true, -- DK - Strangulate
[47528] = true, -- DK - Mindfreeze
[183752] = true, -- DH - Consume Magic
-- Debuff
[45524] = true, -- DK - Chains of Ice
[49576] = true, -- DK - Death Grip
[77606] = true, -- DK - Dark Simulacrum
-- Channel
[117952] = true -- Monk - Crackling Jade Lightning
};
--- ============================ CONTENT ============================
-- Functions to send the message.
local function Output (Message, Channel)
local BossModTime = HL.BossModTime or 0;
local BossModEndTime = HL.BossModEndTime or 0;
if BossModTime ~= 0 and BossModEndTime-GetTime() >= -1 then
if Channel then
SendChatMessage(Message .. " at " .. string.format("%0.2f", BossModEndTime-GetTime()) .. "s.", Channel);
else
print(Message .. " at " .. string.format("%0.2f", BossModEndTime-GetTime()) .. "s.");
end
else
if Channel then
SendChatMessage(Message .. ".", Channel);
else
print(Message .. ".");
end
end
end
local function Announce (Message)
local Channel = AT.GUISettings.PullAnnouncer.Channel;
if Channel == "AUTO" then
if IsInGroup(LE_PARTY_CATEGORY_HOME) then
if IsInRaid() then
Output(Message, "RAID");
else
Output(Message, "PARTY");
end
else
Output(Message);
end
elseif Channel == "AUTOX" then
if IsInGroup() then
if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
Output(Message, "INSTANCE_CHAT");
elseif IsInRaid() then
Output(Message, "RAID");
else
Output(Message, "PARTY");
end
else
Output(Message);
end
elseif Channel == "LOCAL" then
Output(Message);
elseif Channel == "SAY" or Channel == "YELL" or Channel == "PARTY" or Channel == "GUILD" or Channel == "OFFICER" or Channel == "RAID" or Channel == "RAID_WARNING" or Channel == "INSTANCE_CHAT" then
Output(Message, Channel);
else
print("[WA_PullAnnoucer] Wrong channel set in the Init Section.");
end
CombatTime = CombatTime - 3;
return;
end
-- Events listener
-- PLAYER_REGEN_DISABLED
-- Allow further Checks when going in combat.
HL:RegisterForEvent(
function ()
CombatTime = GetTime() + 2;
end
, "PLAYER_REGEN_DISABLED"
);
-- PLAYER_REGEN_ENABLED
-- Prevent further Checks when going out of combat.
HL:RegisterForEvent(
function ()
OutCombatTime = GetTime() + 5;
Pulled = {};
end
, "PLAYER_REGEN_ENABLED"
);
-- RAID_INSTANCE_WELCOME & GROUP_ROSTER_UPDATE
-- Update the Group Roster if the mode is set to Group.
HL:RegisterForEvent(
function ()
if AT.GUISettings.PullAnnouncer.FromWho == "GROUP" then
Roster = {};
if IsInGroup() then
local Type, Name, Server;
if IsInRaid() then Type = "Raid"; else Type = "Party"; end
for i = 1, GetNumGroupMembers() do
Name, Server = UnitName(Type..i);
if Name then
Roster[Server and Server ~= "" and Name.."-"..Server or Name] = true;
end
end
else
Roster[UnitName("Player")] = true;
end
end
end
, "RAID_INSTANCE_WELCOME"
, "GROUP_ROSTER_UPDATE"
);
-- COMBAT_LOG_EVENT_UNFILTERED"
-- Pull Check Handler
-- TODO: Optimizations!
HL:RegisterForCombatEvent(
function (TimeStamp, CombatEvent, _, SourceGUID, SourceName, SourceFlags, _, DestGUID, DestName, DestFlags, _, SpellID, SpellName)
if AT.GUISettings.PullAnnouncer.Difficulty[Player:InstanceDifficulty()] then
if GetTime() >= OutCombatTime and not Player:IsDeadOrGhost() and (not Player:AffectingCombat() or GetTime() <= CombatTime)
and SourceName and DestName and SourceName ~= DestName and (AT.GUISettings.PullAnnouncer.FromWho == "ALL" or Roster[SourceName] or Roster[DestName])
and not string.find(CombatEvent, "PERIODIC")
and (string.find(CombatEvent, "_DAMAGE") or string.find(CombatEvent, "_MISSED") or string.find(CombatEvent, "CAST_SUCCESS")) then
-- Player Attack
if bit.band(SourceFlags, COMBATLOG_OBJECT_TYPE_PLAYER) ~= 0 and bit.band(DestFlags, COMBATLOG_OBJECT_TYPE_NPC) ~= 0 then
if not Pulled[DestGUID] then
if string.find(CombatEvent, "SWING") then
Pulled[DestGUID] = true;
Announce(SourceName.." pulled "..DestName.." with Auto Attack");
return;
elseif not string.find(CombatEvent, "CAST_SUCCESS") or SpecialSpells[SpellID] then
Pulled[DestGUID] = true;
Announce(SourceName.." pulled "..DestName.." with "..SpellName);
return;
end
end
-- Body Pull
elseif bit.band(DestFlags, COMBATLOG_OBJECT_TYPE_PLAYER) ~= 0 and bit.band(SourceFlags, COMBATLOG_OBJECT_TYPE_NPC) ~= 0 then
if not Pulled[SourceGUID] then
Pulled[SourceGUID] = true;
Announce(DestName.." body pulled "..SourceName);
return;
end
-- Pet Attack
elseif bit.band(SourceFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) ~= 0 and bit.band(DestFlags, COMBATLOG_OBJECT_TYPE_NPC) ~= 0 then
if not Pulled[DestGUID] then
Pulled[DestGUID] = true;
Announce(SourceName.."(Pet) pulled "..DestName);
return;
end
-- Pet Body Pull
elseif bit.band(SourceFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) ~= 0 and bit.band(SourceFlags, COMBATLOG_OBJECT_TYPE_NPC) ~= 0 then
if not Pulled[SourceGUID] then
Pulled[SourceGUID] = true;
Announce(DestName.."(Pet) body pulled "..SourceName);
return;
end
end
end
end
end
, "CAST_SUCCESS"
);
HL:RegisterForCombatSuffixEvent(
function (TimeStamp, CombatEvent, _, SourceGUID, SourceName, SourceFlags, _, DestGUID, DestName, DestFlags, _, SpellID, SpellName)
if AT.GUISettings.PullAnnouncer.Difficulty[Player:InstanceDifficulty()] then
if GetTime() >= OutCombatTime and not Player:IsDeadOrGhost() and (not Player:AffectingCombat() or GetTime() <= CombatTime)
and SourceName and DestName and SourceName ~= DestName and (AT.GUISettings.PullAnnouncer.FromWho == "ALL" or Roster[SourceName] or Roster[DestName])
and not string.find(CombatEvent, "PERIODIC")
and (string.find(CombatEvent, "_DAMAGE") or string.find(CombatEvent, "_MISSED") or string.find(CombatEvent, "CAST_SUCCESS")) then
-- Player Attack
if bit.band(SourceFlags, COMBATLOG_OBJECT_TYPE_PLAYER) ~= 0 and bit.band(DestFlags, COMBATLOG_OBJECT_TYPE_NPC) ~= 0 then
if not Pulled[DestGUID] then
if string.find(CombatEvent, "SWING") then
Pulled[DestGUID] = true;
Announce(SourceName.." pulled "..DestName.." with Auto Attack");
return;
elseif not string.find(CombatEvent, "CAST_SUCCESS") or SpecialSpells[SpellID] then
Pulled[DestGUID] = true;
Announce(SourceName.." pulled "..DestName.." with "..SpellName);
return;
end
end
-- Body Pull
elseif bit.band(DestFlags, COMBATLOG_OBJECT_TYPE_PLAYER) ~= 0 and bit.band(SourceFlags, COMBATLOG_OBJECT_TYPE_NPC) ~= 0 then
if not Pulled[SourceGUID] then
Pulled[SourceGUID] = true;
Announce(DestName.." body pulled "..SourceName);
return;
end
-- Pet Attack
elseif bit.band(SourceFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) ~= 0 and bit.band(DestFlags, COMBATLOG_OBJECT_TYPE_NPC) ~= 0 then
if not Pulled[DestGUID] then
Pulled[DestGUID] = true;
Announce(SourceName.."(Pet) pulled "..DestName);
return;
end
-- Pet Body Pull
elseif bit.band(SourceFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) ~= 0 and bit.band(SourceFlags, COMBATLOG_OBJECT_TYPE_NPC) ~= 0 then
if not Pulled[SourceGUID] then
Pulled[SourceGUID] = true;
Announce(DestName.."(Pet) body pulled "..SourceName);
return;
end
end
end
end
end
, "_DAMAGE"
, "_MISSED"
);