-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.lua
executable file
·262 lines (214 loc) · 8.69 KB
/
main.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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
local addonName, SheepMonitor = ...
SheepMonitor = LibStub('AceAddon-3.0'):NewAddon(SheepMonitor, addonName, 'AceEvent-3.0', 'AceTimer-3.0')
_G['SheepMonitor'] = SheepMonitor
local L = LibStub('AceLocale-3.0'):GetLocale('SheepMonitor')
local LibAuraInfo = LibStub('LibAuraInfo-1.0')
-- LuaFormatter off
LibAuraInfo.auraInfo[118] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[28271] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[28272] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[61305] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[61721] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[61780] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[126819] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[161353] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[161354] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[161355] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[161372] = '60;1' -- updating polymorph value for BFA
LibAuraInfo.auraInfo[383121] = '60;1' -- adding mass polymorph
LibAuraInfo.auraInfo[3355] = '60;1' -- fixing incorrect value
LibAuraInfo.auraInfo[115078] = '40;1' -- adding ability_monk_paralysis
LibAuraInfo.auraInfo[460392] = '60;1' -- updating polymorph value for TWW
-- LuaFormatter on
function SheepMonitor:OnInitialize()
self.db = LibStub('AceDB-3.0'):New('SheepMonitorDatabase', {
char = {
monitorRaid = false,
enableNotifier = true,
enableRaid = true,
enableChat = false,
enableParty = false,
enablePolymorphMessages = false,
enableBreakMessages = true,
enableBreakWarningMessages = false,
enableAudibleBreak = true,
audibleBreakSound = 'Sound\\Interface\\AlarmClockWarning3.wav',
enableAudibleBreakWarning = false,
audibleBreakWarningSound = 'Sound\\Interface\\RaidWarning.wav',
enableOmniCC = false,
enableQuartz = false,
growUpwards = false,
},
})
self:CreateInterfaceOptions()
-- InterfaceOptionsFrame_OpenToCategory('SheepMonitor')
if (self:IsClassic()) then
LibAuraInfo.auraInfo[118] = '20;1'
LibAuraInfo.auraInfo[12824] = '30;1'
LibAuraInfo.auraInfo[12825] = '40;1'
LibAuraInfo.auraInfo[12826] = '50;1'
LibAuraInfo.auraInfo[28272] = '50;1'
end
if (self:IsCata()) then
LibAuraInfo.auraInfo[118] = '50;1'
LibAuraInfo.auraInfo[28272] = '50;1'
end
end
function SheepMonitor:IsClassic()
return WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE
end
function SheepMonitor:IsCata()
return WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC
end
function SheepMonitor:OnEnable()
self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
end
function SheepMonitor:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
local timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2,
spellId, spellName, spellSchool = CombatLogGetCurrentEventInfo()
-- the classic always returns a spell id of zero so we
-- resolve the spell id using the spell name instead
if self:IsClassic() then
spellId = select(7, GetSpellInfo(spellName))
end
-- if (eventType == 'SPELL_AURA_APPLIED' or eventType == 'SPELL_AURA_REFRESH') and sourceName == UnitName('player') then
-- ATOM:Dump({ spellId = spellId, spellName = spellName })
-- end
-- watch for polymorphed mobs
if (eventType == 'SPELL_AURA_APPLIED' or eventType == 'SPELL_AURA_REFRESH') and self.trackableAuras[spellId] then
if (self.db.char.monitorRaid and UnitInRaid(sourceName)) or sourceName == UnitName('player') then
local aura = {
auraGUID = spellId .. destGUID, -- a unique identifier for this aura occurance
sourceGUID = sourceGUID,
sourceName = sourceName,
destGUID = destGUID,
destName = destName,
spellId = spellId,
spellName = spellName,
texture = self.trackableAuras[spellId],
timestamp = GetTime(),
duration = LibAuraInfo:GetDuration(spellId, sourceGUID, destGUID),
}
if not self:IsClassic() and destGUID == UnitGUID('target') then
local auraInfo = AuraUtil.FindAuraByName(spellName, 'target', 'PLAYER|HARMFUL')
aura.duration = auraInfo and auraInfo.duration or aura.duration
end
self:AuraApplied(aura)
end
end
-- watch for damage on our polymorph and record whoever breaks
local damageEventTypes = {
['SWING_DAMAGE'] = true,
['RANGE_DAMAGE'] = true,
['SPELL_DAMAGE'] = true,
['SPELL_PERIODIC_DAMAGE'] = true,
['SPELL_BUILDING_DAMAGE'] = true,
['ENVIRONMENTAL_DAMAGE'] = true,
['DAMAGE_SPLIT'] = true,
['DAMAGE_SHIELD'] = true,
}
if self.watchForBreakers and self.watchForBreakers > 0 and damageEventTypes[eventType] then
self:AuraBroken(destGUID, sourceName, eventType == 'SWING_DAMAGE' and 'Melee' or spellName)
end
-- watch for our polymorph to dissipate
if eventType == 'SPELL_AURA_REMOVED' then
if self.trackableAuras[spellId] then
self:AuraRemoved(destGUID, spellId)
end
end
end
function SheepMonitor:POLYMORPH_APPLIED(aura)
if self.db.char.enableOmniCC then
self:ShowOmniCC(aura)
end
if self.db.char.enableQuartz then
self:ShowQuartz(aura)
end
if self.db.char.enablePolymorphMessages then
local message = L['WARNING_APPLIED']:format(aura.spellName, aura.destName)
if self.db.char.enableRaid then
self:ShowRaidWarning(message)
end
if self.db.char.enableChat then
print(message)
end
if self.db.char.enableParty then
self:SendAnnouncement(message)
end
end
end
function SheepMonitor:POLYMORPH_UPDATE(aura, remaining)
if self.db.char.enableBreakWarningMessages and remaining < 6 then
local message = L['WARNING_BREAK_INCOMING']:format(aura.spellName, remaining)
if self.db.char.enableRaid then
self:ShowRaidWarning(message, ChatTypeInfo['BATTLEGROUND_LEADER'])
end
if self.db.char.enableChat then
print(message)
end
if self.db.char.enableParty then
self:SendAnnouncement(message)
end
end
if self.db.char.enableAudibleBreakWarning and remaining == 5 then
self:PlaySoundFile(self.db.char.audibleBreakWarningSound)
end
end
function SheepMonitor:POLYMORPH_REMOVED(aura)
if self.db.char.enableOmniCC then
self:HideOmniCC(aura)
end
if self.db.char.enableQuartz then
self:HideQuartz(aura)
end
if self.db.char.enableAudibleBreak then
self:PlaySoundFile(self.db.char.audibleBreakSound)
end
if self.db.char.enableBreakMessages then
local message = L['WARNING_BROKEN']:format(aura.spellName)
if aura.breakerName then
message = L['WARNING_BROKEN_BY']:format(aura.spellName, aura.breakerName, aura.breakerReason)
end
if self.db.char.enableRaid then
self:ShowRaidWarning(message)
end
if self.db.char.enableChat then
print(message)
end
if self.db.char.enableParty then
self:SendAnnouncement(message)
end
end
end
function SheepMonitor:ShowRaidWarning(message, color)
RaidBossEmoteFrame.slot1:Hide()
RaidNotice_AddMessage(RaidBossEmoteFrame, message, color or ChatTypeInfo['RAID_BOSS_EMOTE'])
end
function SheepMonitor:SendAnnouncement(message)
local chatType = false
if GetNumGroupMembers(LE_PARTY_CATEGORY_INSTANCE) > 0 then
chatType = 'INSTANCE_CHAT'
elseif IsInRaid() then
chatType = 'RAID'
elseif IsInGroup() then
chatType = 'PARTY'
end
if chatType then
SendChatMessage(message, chatType)
end
end
function SheepMonitor:PlaySoundFile(file)
local sounds
if self:IsClassic() then
sounds = {
['Sound\\Interface\\AlarmClockWarning3.wav'] = 'Sound\\Interface\\AlarmClockWarning3.ogg',
['Sound\\Interface\\RaidWarning.wav'] = 'Sound\\Interface\\RaidWarning.ogg',
}
else
sounds = { ['Sound\\Interface\\AlarmClockWarning3.wav'] = 567458, ['Sound\\Interface\\RaidWarning.wav'] = 567397 }
end
if sounds[file] then
file = sounds[file]
end
PlaySoundFile(file)
end