-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathReadyCheck.lua
More file actions
385 lines (368 loc) · 14.6 KB
/
ReadyCheck.lua
File metadata and controls
385 lines (368 loc) · 14.6 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
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
local _, NSI = ... -- Internal namespace
local minlvl = 200
local buffs = {
[1] = 6673, -- Battle Shout
[5] = 21562, -- Stamina
[7] = 462854, -- Skyfury
[8] = 1459, -- Intellect
[9] = 20707, -- Soulstone
[11] = 1126, -- Mark of the Wild
[13] = {381741, 381757, 381756, 381732, 381752, 381748, 381750, 381749, 381746, 381751, 381753, 381754, 381758}, -- Evoker Buff, every class has a different buffid for some annoying reason.
}
local buffrequired = {
[1] = {1, 2, 3, 4, 6, 7, 10, 11, 12, 250, 251, 252, 577, 581, 103, 104, 253, 254, 255, 268, 269, 66, 70, 259, 260, 261, 263, 71, 72, 73}, -- Battle Shout
[8] = {2, 5, 7, 8, 9, 10, 11, 12, 13, 1480, 102, 105, 1467, 1468, 1473, 62, 63, 64, 270, 65, 256, 257, 258, 262, 264, 265, 266, 267}, -- Intellect
}
function NSI:SoulstoneCheck()
if self:Restricted() then return end
local class = select(3, UnitClass("player"))
if class ~= 9 then return end
local cooldown = C_Spell.GetSpellCooldown(20707)
local timeRemaining = cooldown and cooldown.duration ~= 0 and cooldown.duration + cooldown.startTime - GetTime()
if timeRemaining and timeRemaining > 30 then return false end -- only check if soulstone is ready or about to be ready
local buffed = false
local refresh = false
for unit in self:IterateGroupMembers() do
if UnitGroupRolesAssigned(unit) == "HEALER" and UnitIsVisible(unit) then
local aura = self:UnitAura(unit, buffs[class])
if aura then
local source = aura.sourceUnit
if UnitExists(source) and UnitIsUnit("player", source) then
local expires = aura.expirationTime
if expires - GetTime() > 300 then
buffed = true
return false
else
refresh = true
end
end
end
end
end
NSAPI:TTS("Soulstone")
return refresh and "Refresh Soulstone" or "|cFFFF0000Soulstone Missing|r"
end
function NSI:SourceOfMagicCheck()
if self:Restricted() then return end
local class = select(3, UnitClass("player"))
if class ~= 13 then return end
local spellID = 369459
local sourceTalented = C_SpellBook.IsSpellKnownOrInSpellBook(spellID, nil, true)
if not sourceTalented then return end
local refresh = false
for unit in self:IterateGroupMembers() do
if UnitGroupRolesAssigned(unit) == "HEALER" and UnitIsVisible(unit) and not UnitIsUnit(unit, "player") then
local aura = self:UnitAura(unit, spellID)
if aura then
local source = aura.sourceUnit
if UnitExists(source) and UnitIsUnit("player", source) then
local expires = aura.expirationTime
if expires and expires - GetTime() > 300 then
return false
else
refresh = true
end
end
end
end
end
NSAPI:TTS("Source of Magic")
return refresh and "Refresh Source of Magic" or "|cFFFF0000Source of Magic Missing|r"
end
function NSI:BuffCheck()
if self:Restricted() then return end
local class = select(3, UnitClass("player"))
local spellID = buffs[class]
if spellID then
for unit in self:IterateGroupMembers() do
local specID = (self.specs and self.specs[unit]) or select(3, UnitClass(unit)) -- if specdata exists we use that, otherwise class which means maybe some useless buffs are being done.
if specID and (class == 5 or class == 13 or class == 11 or class == 7 or (buffrequired[class] and tContains(buffrequired[class], specID))) and UnitIsVisible(unit) then
local buffed
if type(spellID) == "table" then -- for Evoker Buff
for i=1, #spellID do
buffed = self:UnitAura(unit, spellID[i])
if buffed then break end
end
else
buffed = self:UnitAura(unit, spellID)
end
if buffed then
local source = buffed.sourceUnit
if (not (UnitExists(source)) and (UnitIsVisible(source))) and not (UnitIsUnit("player", source)) then
-- this means someone has the buff but it's from another player that is no longer in the raid so the buff would disappear on pull.
local name = C_Spell.GetSpellInfo(spellID).name
NSAPI:TTS("Rebuff "..name)
return "|cFFFF0000Rebuff:|r |cFF00FF00"..name.."|r"
end
elseif buffed ~= "" then
if type(spellID) == "table" then
spellID = spellID[1] -- use first entry as they all have the same name anyway
end
local spellInfo = C_Spell.GetSpellInfo(spellID)
local name = spellInfo and spellInfo.name or ""
NSAPI:TTS("Rebuff "..name)
return "|cFFFF0000Rebuff:|r |cFF00FF00"..name.."|r"
end
end
end
end
return false
end
local SlotName = {
"Head", -- 1
"Neck", -- 2
"Shoulder", -- 3
"Shirt", -- 4
"Chest", -- 5
"Waist", -- 6
"Legs", -- 7
"Feet", -- 8
"Wrist", -- 9
"Hands", -- 10
"Finger 1", -- 11
"Finger 2", -- 12
"Trinket 1", -- 13
"Trinket 2", -- 14
"Back", -- 15
"Main Hand", -- 16
"Off Hand" -- 17
}
function NSI:GemCheck(slot, itemString)
local gemsMissing = 0
if slot == 2 or slot == 11 or slot == 12 then
gemsMissing = 1
end
if itemString then
for key, num in pairs(C_Item.GetItemStats(itemString)) do
if (string.find(key, "EMPTY_SOCKET_")) then
for i = 1, num do
local gem = C_Item.GetItemGem(itemString,i)
if gem then
if string.find(gem, "Eversong Diamond") then -- Midnight Primary Stat Gem
self.MainstatGem = true
end
gemsMissing = gemsMissing -1
end
if not gem then
gemsMissing = gemsMissing + 1
end
end
end
end
return gemsMissing > 0
else
return false
end
end
function NSI:EnchantCheck(slot, itemString)
local enchantedSlots = {1, 3, 5, 7, 8, 11, 12, 16, 17}
if tContains(enchantedSlots, slot) and itemString then
if slot == 17 and select(12, C_Item.GetItemInfo(itemString)) == 4 then return false end -- skip shield/offhand
local link = select(2, C_Item.GetItemInfo(itemString))
local _, enchant = link:match("item:(%d+):(%d+)")
if enchant then return false else return true end
else
return false
end
end
local ArmorTypes = {
[1] = 4, -- Warrior
[2] = 4, -- Paladin
[3] = 3, -- Hunter
[4] = 2, -- Rogue
[5] = 1, -- Priest
[6] = 4, -- Death Knight
[7] = 3, -- Shaman
[8] = 1, -- Mage
[9] = 1, -- Warlock
[10] = 2, -- Monk
[11] = 2, -- Druid
[12] = 2, -- Demon Hunter
[13] = 3, -- Evoker
}
function NSI:GearCheck()
local missing = {}
local crafted = 0
local tier = 0
local repair = false
local spec = GetSpecializationInfo(GetSpecialization())
local ilvl = minlvl
self.MainstatGem = false
local MyArmorType = ArmorTypes[select(3, UnitClass("player"))]
for slot = 1, #SlotName do
local itemString = GetInventoryItemLink("player", slot)
if itemString then
if NSRT.ReadyCheckSettings.CraftedCheck and string.find(itemString, "8960") then
crafted = crafted+1
end
if NSRT.ReadyCheckSettings.EnchantCheck and self:EnchantCheck(slot,itemString) then
table.insert(missing, "Missing Enchant on: |cFF00FF00"..SlotName[slot].."|r")
end
if NSRT.ReadyCheckSettings.GemCheck and self:GemCheck(slot, itemString) then
table.insert(missing, "Missing Gem in: |cFF00FF00"..SlotName[slot].."|r")
end
if NSRT.ReadyCheckSettings.ItemLevelCheck and slot ~= 4 and select(4, C_Item.GetItemInfo(itemString)) < ilvl then
table.insert(missing, "Low Itemlvl equipped on: |cFF00FF00"..SlotName[slot].."|r")
end
if NSRT.ReadyCheckSettings.RepairCheck and not repair then
local min, max = GetInventoryItemDurability(slot)
if min and min/max <= 0.2 then
repair = true
end
end
if NSRT.ReadyCheckSettings.TierCheck then
if self:TierCheck(slot) then
tier = tier+1
end
end
-- Cloak is always considered Cloth, also don't even need to check for cloth wearers. Also don't check weapons
if MyArmorType ~= 1 and NSRT.ReadyCheckSettings.MissingItemCheck and slot ~= 4 and slot ~= 15 and slot ~= 16 and slot ~= 17 then
local armorType = itemString and select(13, C_Item.GetItemInfo(itemString))
if armorType and armorType <= 4 and armorType ~= MyArmorType and armorType ~= 0 then
table.insert(missing, "|cFFFF0000Wrong armor type:|r |cFF00FF00"..SlotName[slot].."|r")
end
end
elseif NSRT.ReadyCheckSettings.MissingItemCheck and slot ~= 4 then
if slot == 17 then
itemString = GetInventoryItemLink("player", 16)
local type = itemString and select(13, C_Item.GetItemInfo(itemString)) or ""
local onehand = {0, 4, 7, 9, 11, 12, 13, 15, 19}
if tContains(onehand, type) or spec == 72 then -- only check offhand if mainhand is a onehand or player is a fury warrior
table.insert(missing, "|cFFFF0000Not equipped:|r |cFF00FF00"..SlotName[slot].."|r")
end
else
table.insert(missing, "|cFFFF0000Not equipped:|r |cFF00FF00"..SlotName[slot].."|r")
end
end
end
-- Gateway Control Shard
if NSRT.ReadyCheckSettings.GatewayShardCheck then
local Gateway = self:GatewayControlCheck()
if Gateway then table.insert(missing, Gateway) end
end
if NSRT.ReadyCheckSettings.GemCheck and not self.MainstatGem then
table.insert(missing, "Missing |cFF00FF00Mainstat Gem|r")
end
if repair then
table.insert(missing, "Item needs |cFF00FF00Repair|r")
end
if NSRT.ReadyCheckSettings.CraftedCheck and crafted < 2 then
table.insert(missing, "Missing |cFF00FF00Embellishment|r")
end
if NSRT.ReadyCheckSettings.TierCheck and tier < 4 then
if tier < 2 then
table.insert(missing, "|cFFFF0000No Set Bonus equipped|r")
else
table.insert(missing, "|cFFFF0000Only 2pc equipped|r")
end
end
local text = ""
for i=1, #missing do
text = text..missing[i].."\n"
end
return text
end
function NSI:GatewayControlCheck()
for bagID = 0, NUM_BAG_SLOTS do
for invID = 1, C_Container.GetContainerNumSlots(bagID) do
local itemID = C_Container.GetContainerItemID(bagID, invID)
if itemID and itemID == 188152 then -- Gateway Shard found in Inventory
local bound = false
local onbar = false
for Slot = 1, 180 do
local actionType, ID = GetActionInfo(Slot)
if actionType == "item" and ID == itemID then -- found on actionbar
onbar = true
bound = self:CheckGateWayKeybind(Slot)
if bound then break end
end
end
bound = bound or (NSRT.ReadyCheckSettings.SkipGatewayKeybindCheck and onbar)
if bound then
return false
elseif onbar then
return "|cFF00FF00Gateway Control Shard|r Not Bound"
else
return "|cFF00FF00Gateway Control Shard|r Not on Actionbar"
end
end
end
end
return "|cFF00FF00Gateway Control Shard|r Missing"
end
local keymapping = {
[1] = "ACTIONBUTTON",
[13] = "CustomName",
[25] = "MULTIACTIONBAR3BUTTON",
[37] = "MULTIACTIONBAR4BUTTON",
[49] = "MULTIACTIONBAR2BUTTON",
[61] = "MULTIACTIONBAR1BUTTON",
[73] = "CustomName",
[85] = "CustomName",
[97] = "CustomName",
[109] = "CustomName",
[121] = "CustomName",
[133] = "CustomName",
[145] = "MULTIACTIONBAR5BUTTON",
[157] = "MULTIACTIONBAR6BUTTON",
[169] = "MULTIACTIONBAR7BUTTON",
}
function NSI:CheckGateWayKeybind(Slot)
for SlotRange, BarName in pairs(keymapping) do
if Slot >= SlotRange and Slot < SlotRange+12 then
local buttonnum = Slot % 12 == 0 and 12 or Slot % 12
if BarName == "CustomName" then
if Bartender4 then
BarName = "CLICK BT4Button"..Slot..":Keybind"
elseif ElvUI then
BarName = "ELVUIBAR"..math.ceil(Slot/12).."BUTTON"..buttonnum
elseif Dominos then
BarName = "CLICK DominosActionButton"..Slot..":HOTKEY"
end
else
BarName = BarName..buttonnum
end
return GetBindingKey(BarName)
end
end
end
local validsets = {
-- Manaforge Sets
[1921] = true, -- Druid
[1923] = true, -- Hunter
[1924] = true, -- Mage
[1926] = true, -- Paladin
[1927] = true, -- Priest
[1928] = true, -- Rogue
[1929] = true, -- Shaman
[1930] = true, -- Warlock
[1931] = true, -- Warrior
[1919] = true, -- Death Knight
[1920] = true, -- Demon Hunter
[1925] = true, -- Monk
[1922] = true, -- Evoker
-- Midnight S1
[1980] = true, -- Druid
[1982] = true, -- Hunter
[1983] = true, -- Mage
[1985] = true, -- Paladin
[1986] = true, -- Priest
[1987] = true, -- Rogue
[1988] = true, -- Shaman
[1989] = true, -- Warlock
[1990] = true, -- Warrior
[1978] = true, -- Death Knight
[1979] = true, -- Demon Hunter
[1984] = true, -- Monk
[1981] = true, -- Evoker
}
function NSI:TierCheck(Slot)
local tier = 0
local itemLink = GetInventoryItemLink("player", Slot)
if itemLink then
local setID = select(16, C_Item.GetItemInfo(itemLink))
if setID and validsets[setID] then
return true
end
end
end