-
Notifications
You must be signed in to change notification settings - Fork 4
/
raid.lua
358 lines (308 loc) · 8.89 KB
/
raid.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
-- Raid tracking
local _, addonData = ...
local buffs
local util
-- SetLootMethod("method" [,"masterPlayer" or threshold])
local raid = {
caninvite = {},
roster = {},
rosterOld = {},
clickers = {},
me = "",
init = function(self)
addonData.debug:registerCategory("raid.event")
buffs = addonData.buffs
util = addonData.util
self.me = UnitName("player")
end,
callback = function(self, event, ...)
db("raid.event", event, ...)
self = addonData.raid
if (event == "GROUP_ROSTER_UPDATE" or event == "RAID_ROSTER_UPDATE") then
self:updateRaid()
self:assign()
end
if (event == "PARTY_LEADER_CHANGED") then
if IsInGroup(LE_PARTY_CATEGORY_HOME) then
self:updateRaid()
if UnitIsGroupLeader("player") then
if SteaSummonSave.convertToRaid and not IsInRaid() then
ConvertToRaid()
end
if SteaSummonRelinquishRaidLeadButton then
SteaSummonRelinquishRaidLeadButton:Show()
end
else
if SteaSummonRelinquishRaidLeadButton then
SteaSummonRelinquishRaidLeadButton:Hide()
end
end
self:assign()
else
if SteaSummonRelinquishRaidLeadButton then
SteaSummonRelinquishRaidLeadButton:Hide()
end
end
end
end,
updateRaid = function(self)
self.roster, self.rosterOld = self.rosterOld, self.roster
wipe(self.roster)
if not IsInGroup(LE_PARTY_CATEGORY_HOME) then
addonData.summon:listClear()
addonData.gossip:raidLeft()
wipe(self.rosterOld)
return
end
for i = 1, GetNumGroupMembers() do
local name, rank = GetRaidRosterInfo(i)
if name ~= nil then
self.roster[name] = 1
if self.rosterOld[name] == nil then
db("raid", name, "joined the raid.")
if self.me == name then
addonData.gossip:raidJoined()
end
end
if rank > 0 then
self.caninvite[name] = true
else
self.caninvite[name] = false
end
end
end
-- remove old members who left
for k, _ in pairs(self.rosterOld) do
if not self.roster[k] then
db("raid", k, " left the raid.")
addonData.summon:remove(k)
local name, _ = UnitName("player")
if k == name then
addonData.gossip:raidLeft()
addonData.summon:listClear()
wipe(self.rosterOld)
addonData.raid.groupInit = true
else
addonData.gossip:raiderLeft(k)
end
end
end
end,
fishedClickers = function(self)
return self.clickers
end,
fishArea = function(self)
if not IsInGroup(LE_PARTY_CATEGORY_HOME) then
return
end
wipe(self.clickers)
for k, _ in pairs(self.roster) do
if UnitInRange(k) then
table.insert(self.clickers, k)
end
end
addonData.gossip:setClicks()
end,
isInvTrigger = function(_, trigger)
for _,v in pairs(SteaSummonSave.autoInviteTriggers) do
if v == trigger then
return true
end
return false
end
end,
inGuild = function(_, player)
local _, server = UnitFullName("player")
local gNum = GetNumGuildMembers()
for i=1, gNum do
local guildy = GetGuildRosterInfo(i)
if player == guildy then
return true
end
if player .. "-" .. server == guildy then
return true
end
end
return false
end,
whisperedTrigger = function(self, player)
local setting = SteaSummonSave.autoInvite
if setting == 4 or UnitInRaid(player) then
return
end
if setting == 1 then
db("raid", "auto invites set to guild")
if not self:inGuild(player) then
db("raid", "requester not in guild")
return
end
db("raid", "requester in guild", player)
end
if setting == 2 then
db("raid", "auto invites set to guild and friends")
local f = C_FriendList.GetFriendInfo(player)
if not f then
db("raid", "requester not a friend")
if not self:inGuild(player) then
db("raid", "requester not in guild")
return
end
db("raid", "requester in guild", player)
end
end
InviteUnit(player)
end,
acceptInvites = function(self, event, player, isTank, isHealer, isDamage, isNativeRealm,
allowMultipleRoles, inviterGUID, isQuestSessionActive)
db("raid", event, player, isTank, isHealer, isDamage, isNativeRealm,
allowMultipleRoles, inviterGUID, isQuestSessionActive)
self = addonData.raid
local setting = SteaSummonSave.autoAccept
if setting == 4 then
db("raid", "invites set to off")
return
end
if setting == 1 then
db("raid", "invites set to guild")
if not self:inGuild(player) then
db("raid", "invite not in guild")
return
end
db("raid", "inviter in guild", player)
end
if setting == 2 then
db("raid", "invites set to guild and friends")
local friend = C_FriendList.IsFriend(inviterGUID)
db("raid", "it's", friend, "that inviter is friend", player)
if not friend then
db("raid", "invite not a friend")
if not self:inGuild(player) then
db("raid", "invite not in guild")
return
end
db("raid", "inviter in guild", player)
end
end
db("raid", "accepting group")
AcceptGroup()
StaticPopup_Hide("PARTY_INVITE")
end,
assign = function(self)
self = addonData.raid
if UnitIsGroupLeader("player") then
local leader
local gNum = GetNumGroupMembers()
for i = 1, gNum do
local name, rank = GetRaidRosterInfo(i)
local set = false
if name and name ~= "" and rank == 0 then
db("raid", "leader testing", name)
if SteaSummonSave.warlocksAssist and util:playerCanSummon(name) and #buffs:report(name) == 0 then
set = true
else
for _,v in pairs(SteaSummonSave.assistPlayers) do
if name == v then
set = true
break
end
end
end
if not set then
for _,v in pairs(SteaSummonSave.raidLeaders) do
if name == v then
if not leader then
leader = name
end
set = true
break
end
end
end
if not set then
for _,v in pairs(SteaSummonSave.masterLoot) do
if name == v then
set = true
break
end
end
end
db("raid", "should promote:", set)
if set and name ~= self.me then
PromoteToAssistant(name)
end
end
end
if not SteaSummonSave.delayLeadership and leader and leader ~= self.me then
self:relinquish()
end
end
end,
relinquish = function(self)
self = addonData.raid
if UnitIsGroupLeader("player") then
local leader, ML = {}, {}
local gNum = GetNumGroupMembers()
for i = 1, gNum do
local name, rank = GetRaidRosterInfo(i)
local set = false
if name and name ~= "" and rank > 0 then
for _,v in pairs(SteaSummonSave.assistPlayers) do
db('raid', "assist checking:", v, "=", name)
if v and name == v then
set = true
break
end
end
for _,v in pairs(SteaSummonSave.raidLeaders) do
db('raid', "raid lead checking:", v, "=", name)
if v and name == v then
leader[name] = 1
set = true
end
end
for _,v in pairs(SteaSummonSave.masterLoot) do
db('raid', "ML checking:", v, "=", name)
if v and name == v then
ML[name] = 1
set = true
end
end
db("raid", "should demote:", name, not set)
if not set and name ~= self.me and SteaSummonSave.finalLeadership then
DemoteAssistant(name)
end
end
end
db("raid", #ML, "candidates", #leader, "candidates")
local ml
for _,v in pairs (SteaSummonSave.masterLoot) do
db("raid", "checking ML candidate", v, "against", ML[v])
if ML[v] then
ml = v
break
end
end
if ml then
db("raid", "ML is", ml)
SetLootMethod("master", ml)
end
local l
for _,v in pairs (SteaSummonSave.raidLeaders) do
db("raid", "checking raid lead candidate", v, "against", leader[v])
if leader[v] then
if v == self.me then
db("raid", "you are already leader")
return
end
l = v
break
end
end
if l then
db("raid", "raid leader is", l)
PromoteToLeader(l)
end
end
end,
}
addonData.raid = raid