-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.lua
More file actions
394 lines (375 loc) · 17 KB
/
items.lua
File metadata and controls
394 lines (375 loc) · 17 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
386
387
388
389
390
391
392
393
394
local colorDebug = CreateColor(1, 0.41, 0) -- orange
angleurItems = {
baitPossibilities = {
{itemID = 111111},
{name= "Shiny Bauble", itemID = 6529, icon = 134335},
{itemID = 222222},
{name = "Nightcrawlers", itemID = 6530, icon = 134324},
{itemID = 333333},
--{name = "Aquadynamic Fish Lens", itemID = 6811, icon = 134440},
{name = "Bright Baubles", itemID = 6532, icon = 134139},
{name = "Flesh Eating Worm", itemID = 7307, icon = 134324},
{name = "Aquadynamic Fish Attractor", itemID = 6533, icon = 133982},
{name = "Feathered Lure", itemID = 62673, icon = 135992},
{name = "Sharpened Fish Hook", itemID = 34861, icon = 134226},
{name = "Glow Worm", itemID = 46006, icon = 237147},
{name = "Heat-Treated Spinning Lure", itemID = 68049, icon = 135811}
},
--baitPossibilities = {{itemID = 111111, spellID = 111111}, {itemID = 222222, spellID = 222222}, {itemID = 333333, spellID = 333333}} --filled with fake items for testing purposes, normally quoted out
ownedBait = {},
selectedBaitTable = {name = 0, itemID = 0, icon = 0, hasItem = false, loaded = false, dropDownID = 0}
}
Angleur_SlottedExtraItems = {
first = {
name = 0, itemID = 0, spellID = 0, icon = 0, auraActive = false, loaded = false, macroName = 0,
macroIcon = 0, macroBody = 0, macroSpellID = 0, macroItemID = 0, delay = 0, lastUsed = 0,
equipLoc = 0, forceEquip = false
},
second = {
name = 0, itemID = 0, spellID = 0, icon = 0, auraActive = false, loaded = false, macroName = 0,
macroIcon = 0, macroBody = 0, macroSpellID = 0, macroItemID = 0, delay = 0, lastUsed = 0,
equipLoc = 0, forceEquip = false
},
third = {
name = 0, itemID = 0, spellID = 0, icon = 0, auraActive = false, loaded = false, macroName = 0,
macroIcon = 0, macroBody = 0, macroSpellID = 0, macroItemID = 0, delay = 0, lastUsed = 0,
equipLoc = 0, forceEquip = false
}
}
local function initializeSavedItems()
for i, slot in pairs(Angleur_SlottedExtraItems) do
if not slot.name then slot.name = 0 end
if not slot.itemID then slot.itemID = 0 end
if not slot.spellID then slot.spellID = 0 end
if not slot.icon then slot.icon = 0 end
if not slot.auraActive then slot.auraActive = false end
if not slot.loaded then slot.loaded = false end
if not slot.macroName then slot.macroName = 0 end
if not slot.macroIcon then slot.macroIcon = 0 end
if not slot.macroBody then slot.macroBody = 0 end
if not slot.macroSpellID then slot.macroSpellID = 0 end
if not slot.macroItemID then slot.macroItemID = 0 end
if not slot.delay then slot.delay = 0 end
if not slot.lastUsed then slot.lastUsed = 0 end
if not slot.equipLoc then slot.equipLoc = 0 end
if not slot.forceEquip then slot.forceEquip = false end
end
end
local function clearTable(table)
for i, v in pairs(table) do
table[i] = nil
end
end
function Angleur_LoadItems()
initializeSavedItems()
GetTimePreciseSec()
Angleur_RequestItems(angleurItems.selectedBaitTable, angleurItems.ownedBait, angleurItems.baitPossibilities)
end
function Angleur_RequestItems(selectedItemTable, ownedItemsTable, possibilityTable)
local requestFrame = CreateFrame("Frame")
requestFrame:RegisterEvent("ITEM_DATA_LOAD_RESULT")
requestFrame:SetScript("OnEvent", function(self, event, itemID, success)
if event ~= "ITEM_DATA_LOAD_RESULT" then return end
local allTrue = true
for i, item in pairs(possibilityTable) do
if item.itemID == itemID then
item.loaded = true
end
if item.loaded ~= true then
allTrue = false
end
end
if allTrue == true then
self:SetScript("OnEvent", nil)
Angleur_CheckOwnedItems(angleurItems.selectedBaitTable, angleurItems.ownedBait, angleurItems.baitPossibilities)
Angleur_SetSelectedItem(angleurItems.selectedBaitTable, angleurItems.ownedBait, AngleurConfig.chosenBait.itemID)
end
end)
for i, item in pairs(possibilityTable) do
item.loaded = false
C_Item.RequestLoadItemDataByID(item.itemID)
end
--if foundUsableItem == false then print("NOTHING FOUND") end
return foundUsableItem
end
function Angleur_CheckOwnedItems(selectedItemTable, ownedItemsTable, possibilityTable)
clearTable(ownedItemsTable)
for i, item in pairs(possibilityTable) do
if C_Item.IsItemDataCachedByID(item.itemID) then
--print("Item name: ", item.name)
if C_Item.GetItemCount(item.itemID) > 0 then
--print("in bag")
table.insert(ownedItemsTable, item)
foundUsableItem = true
end
end
end
end
function Angleur_SetSelectedItem(selectedItemTable, ownedItemsTable, chosenByPlayer)
local selection = {}
local dropDownID
for i, ownedItem in pairs(ownedItemsTable) do
selection = ownedItem
dropDownID = i
if chosenByPlayer == ownedItem.itemID then
break
end
end
if next(selection) == nil then return end
selectedItemTable.itemID = selection.itemID
selectedItemTable.dropDownID = dropDownID
selectedItemTable.hasItem = true
selectedItemTable.loaded = true
selectedItemTable.name = C_Item.GetItemNameByID(selection.itemID)
selectedItemTable.spellID = selection.spellID
selectedItemTable.icon = selection.icon
end
function Angleur_LoadExtraItems(self)
initializeSavedItems()
for i, slot in pairs(Angleur_SlottedExtraItems) do
Angleur_SlottedExtraItems[i].loaded = false
--self[i].name = Angleur_SlottedExtraItems[i].name
--self[i].spellID = Angleur_SlottedExtraItems[i].spellID
if Angleur_SlottedExtraItems[i].name ~= 0 then
self[i].itemID = Angleur_SlottedExtraItems[i].itemID
self[i].icon:SetTexture(Angleur_SlottedExtraItems[i].icon)
self[i].closeButton:Show()
self[i].Name:SetText(nil)
self[i].timeButton:Show()
if Angleur_SlottedExtraItems[i].delay ~= nil then
self[i].timeButton.inputBoxes.minutes:SetNumber(math.floor(Angleur_SlottedExtraItems[i].delay / 60))
self[i].timeButton.inputBoxes.seconds:SetNumber(Angleur_SlottedExtraItems[i].delay % 60)
Angleur_FillEditBox(self[i].timeButton.inputBoxes.minutes)
Angleur_FillEditBox(self[i].timeButton.inputBoxes.seconds)
end
local item = Item:CreateFromItemID(Angleur_SlottedExtraItems[i].itemID)
item:ContinueOnItemLoad(function(self)
Angleur_SlottedExtraItems[i].loaded = true
--print("Extra item loaded: ", item:GetItemLink())
end)
elseif Angleur_SlottedExtraItems[i].macroName ~= 0 then
self[i].icon:SetTexture(Angleur_SlottedExtraItems[i].macroIcon)
self[i].closeButton:Show()
self[i].Name:SetText(Angleur_SlottedExtraItems[i].macroName)
self[i].timeButton:Show()
if Angleur_SlottedExtraItems[i].delay ~= nil then
self[i].timeButton.inputBoxes.minutes:SetNumber(math.floor(Angleur_SlottedExtraItems[i].delay / 60))
self[i].timeButton.inputBoxes.seconds:SetNumber(Angleur_SlottedExtraItems[i].delay % 60)
Angleur_FillEditBox(self[i].timeButton.inputBoxes.minutes)
Angleur_FillEditBox(self[i].timeButton.inputBoxes.seconds)
end
else
self[i].itemID = nil
self[i].icon:SetTexture(nil)
self[i].closeButton:Hide()
self[i].Name:SetText(nil)
self[i].timeButton:Hide()
end
end
end
function Angleur_RemoveExtraItem(self)
local colorYellow = CreateColor(1.0, 0.82, 0.0)
local colorBlu = CreateColor(0.61, 0.85, 0.92)
local parent = self:GetParent()
local keyofParent = parent:GetParentKey()
--if Angleur_SlottedExtraItems[keyofParent].name == 0 then error("Angleur ERROR: Trying to remove extra item, but it is already removed.") end
Angleur_SlottedExtraItems[keyofParent].name = 0
Angleur_SlottedExtraItems[keyofParent].itemID = 0
Angleur_SlottedExtraItems[keyofParent].spellID = 0
Angleur_SlottedExtraItems[keyofParent].icon = 0
Angleur_SlottedExtraItems[keyofParent].auraActive = false
Angleur_SlottedExtraItems[keyofParent].loaded = false
Angleur_SlottedExtraItems[keyofParent].macroName = 0
Angleur_SlottedExtraItems[keyofParent].macroIcon = 0
Angleur_SlottedExtraItems[keyofParent].macroBody = 0
Angleur_SlottedExtraItems[keyofParent].macroSpellID = 0
Angleur_SlottedExtraItems[keyofParent].macroItemID = 0
Angleur_SlottedExtraItems[keyofParent].delay = 0
Angleur_SlottedExtraItems[keyofParent].lastUsed = 0
if Angleur_SlottedExtraItems[keyofParent].equipLoc ~= 0 then
Angleur_SlottedExtraItems[keyofParent].equipLoc = 0
print("Unslotted " .. colorBlu:WrapTextInColorCode("Angleur ") .. colorYellow:WrapTextInColorCode("Equipment Set ") .. " item. Remove it from the Angleur set in the equipment manager if you don't want Angleur to keep equipping it.")
end
Angleur_SlottedExtraItems[keyofParent].forceEquip = false
local grandParent = parent:GetParent()
Angleur_LoadExtraItems(grandParent)
end
local typeToSlotID = {
INVTYPE_HEAD = 1,
INVTYPE_NECK = 2,
INVTYPE_SHOULDER = 3,
INVTYPE_BODY = 4,
INVTYPE_CHEST = 5,
INVTYPE_WAIST = 6,
INVTYPE_LEGS = 7,
INVTYPE_FEET = 8,
INVTYPE_WRIST = 9,
INVTYPE_HAND = 10,
INVTYPE_FINGER = {11, 12},
INVTYPE_TRINKET = {13, 14},
INVTYPE_WEAPON = {16, 17},
INVTYPE_SHIELD = 17,
INVTYPE_RANGED = 16,
INVTYPE_CLOAK = 15,
INVTYPE_2HWEAPON = 16,
INVTYPE_TABARD = 19,
INVTYPE_ROBE = 5,
INVTYPE_WEAPONMAINHAND = 16,
INVTYPE_WEAPONOFFHAND = 16,
INVTYPE_HOLDABLE = 17,
INVTYPE_THROWN = 16,
INVTYPE_RANGEDRIGHT = 16
}
local warningHats = {
[88710] = "Nat's Hat",
[117405] = "Nat's Drinking Hat",
[33820] = "Weather-Beaten Fishing Hat",
}
local function checkForHats(itemID)
if warningHats[itemID] ~= nil then
local colorBlu = CreateColor(0.61, 0.85, 0.92)
local colorYellow = CreateColor(1.0, 0.82, 0.0)
local colorRed = CreateColor(1, 0, 0)
local colorGrae = CreateColor(0.85, 0.85, 0.85)
print(" ")
print(" ")
print(" ")
print(colorBlu:WrapTextInColorCode("Angleur: ") .. colorYellow:WrapTextInColorCode("Fishing Hat") .. " detected.")
print("For it to work properly, please make sure to add it as a macro like so: ")
print(colorGrae:WrapTextInColorCode(" _____________________"))
print(colorGrae:WrapTextInColorCode(" I"))
print(" /use " .. warningHats[itemID])
print(" /use 16")
print(colorGrae:WrapTextInColorCode(" _____________________I"))
print(" ")
print("Otherwise, you will have to manually target your fishing rod every time."
.. "If you want to see an example of how to slot macros, click the "
.. colorRed:WrapTextInColorCode("[HOW?] ") .. "button on the "
.. colorYellow:WrapTextInColorCode("Extra Tab"))
end
end
function Angleur_GrabCursorItem(self)
if InCombatLockdown() then
ClearCursor()
print("Can't drag item in combat.")
return
end
local itemLoc = C_Cursor.GetCursorItem()
local itemID = C_Item.GetItemID(itemLoc)
local link = C_Item.GetItemLink(itemLoc)
local itemInfo = {C_Item.GetItemInfo(itemID)}
if not C_Item.IsUsableItem(itemID) then
print("Please select a usable item.")
ClearCursor()
return
end
local _, spellID = C_Item.GetItemSpell(itemID)
if spellID == nil then
print("This item does not have a castable spell.")
ClearCursor()
return
end
ClearCursor()
Angleur_RemoveExtraItem(self.closeButton)
local name = C_Item.GetItemName(itemLoc)
local icon = C_Item.GetItemIcon(itemLoc)
local parentKey = self:GetParentKey()
Angleur_SlottedExtraItems[parentKey].itemID = itemID
Angleur_SlottedExtraItems[parentKey].name = name
Angleur_SlottedExtraItems[parentKey].icon = icon
Angleur_SlottedExtraItems[parentKey].spellID = spellID
if C_Item.IsEquippableItem(itemID) then
Angleur_SlottedExtraItems[parentKey].equipLoc = typeToSlotID[itemInfo[9]]
Angleur_SlottedExtraItems[parentKey].forceEquip = true
end
--print(itemID)
--DevTools_Dump(C_Item.GetItemInventoryType(itemLoc))
--DevTools_Dump(GetItemInteractionInfo(itemLoc))
checkForHats(itemID)
Angleur_LoadExtraItems(self:GetParent())
end
function Angleur_GrabCursorMacro(self, macroIndex)
if InCombatLockdown() then
ClearCursor()
print("Can't drag macro in combat.")
return
end
local parentKey = self:GetParentKey()
local colorYellow = CreateColor(1.0, 0.82, 0.0)
local colorBlu = CreateColor(0.61, 0.85, 0.92)
Angleur_RemoveExtraItem(self.closeButton)
if macroIndex then
local spellID = GetMacroSpell(macroIndex)
local itemName, itemLink = GetMacroItem(macroIndex)
if spellID then
Angleur_SlottedExtraItems[parentKey].macroSpellID = spellID
print("link of macro spell: " .. C_Spell.GetSpellLink(Angleur_SlottedExtraItems[parentKey].macroSpellID))
elseif itemName then
print("link of macro item: ", itemLink)
local _, spellID = C_Item.GetItemSpell(itemName)
if spellID == nil then
print(colorYellow:WrapTextInColorCode("Can't use Macro: ")
.. "The item used in this macro doesn't have a trackable spell/aura.")
ClearCursor()
else
Angleur_SlottedExtraItems[parentKey].macroSpellID = spellID
local itemID = C_Item.GetItemIDForItemInfo(itemName)
Angleur_SlottedExtraItems[parentKey].macroItemID = itemID
checkForHats(itemID)
if C_Item.IsEquippableItem(itemID) then
local itemInfo = {C_Item.GetItemInfo(itemID)}
Angleur_SlottedExtraItems[parentKey].equipLoc = typeToSlotID[itemInfo[9]]
Angleur_SlottedExtraItems[parentKey].forceEquip = true
end
local _, zarinku = C_Item.GetItemInfo(Angleur_SlottedExtraItems[parentKey].macroItemID)
print("spell link of macro item: " .. C_Spell.GetSpellLink(Angleur_SlottedExtraItems[parentKey].macroSpellID))
end
else
print(colorBlu:WrapTextInColorCode("Angleur: ") .. "Failed to get macro spell/item. If you are using " .. colorYellow:WrapTextInColorCode("macro conditions \n") ..
"you need to drag the macro into the button frame when the conditions are met.")
ClearCursor()
return
end
else
print("Failed to get macro index")
return
end
Angleur_SlottedExtraItems[parentKey].macroName, Angleur_SlottedExtraItems[parentKey].macroIcon, Angleur_SlottedExtraItems[parentKey].macroBody = GetMacroInfo(macroIndex)
local body = GetMacroBody(macroIndex)
Angleur_SlottedExtraItems[parentKey].macroBody = body
if Angleur_SlottedExtraItems[parentKey].macroBody == "" then
print("Macro empty")
else
print(colorBlu:WrapTextInColorCode("Angleur: ") .. "Macro successfully slotted. If you make changes to it, you need to " .. colorYellow:WrapTextInColorCode("re-drag ") .. "the new version to the slot. You can also delete the macro to save space, Angleur will remember it.")
end
Angleur_LoadExtraItems(self:GetParent())
end
function Angleur_FillEditBox(self)
local number = self:GetNumber()
if number > 10 then return end
self:SetCursorPosition(0)
self:Insert(0)
if number > 0 then return end
self:SetCursorPosition(0)
self:Insert(0)
end
function Angleur_GetTimeFromBox(self)
local keyOfGrandGrandParent = self:GetParent():GetParent():GetParentKey()
Angleur_SlottedExtraItems[keyOfGrandGrandParent].delay = self.minutes:GetNumber() * 60 + self.seconds:GetNumber()
print("Timer set to: ", math.floor(Angleur_SlottedExtraItems[keyOfGrandGrandParent].delay/60), " minutes, ", Angleur_SlottedExtraItems[keyOfGrandGrandParent].delay%60, " seconds")
end
local function startTimer_ItemOrMacro(self, event, unit, ...)
local arg4, arg5 = ...
if event == "UNIT_SPELLCAST_SUCCEEDED" and unit == "player" then
for i, slot in pairs(Angleur_SlottedExtraItems) do
if slot.spellID == arg5 or slot.macroSpellID == arg5 then
slot.lastUsed = GetTime()
Angleur_BetaPrint(colorDebug:WrapTextInColorCode("Angleur_GrabCursorMacro ") .. ": ", i, "delay timer starting")
return
end
end
end
end
local timerFrame = CreateFrame("Frame")
timerFrame:SetScript("OnEvent", startTimer_ItemOrMacro)
timerFrame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")