Vynn@0
|
1 local PROSPECT_ID = 31252
|
Vynn@0
|
2 local MILLING_ID = 51005
|
mischivin@11
|
3 local MASS_PROSPECT_FELSLATE_ID = 225902
|
mischivin@11
|
4 local MASS_PROSPECT_LEYSTONE_ID = 225902
|
mischivin@11
|
5 local MASS_MILLING_YSERALLINE_ID = 210116
|
mischivin@14
|
6 local PROSPECT = GetSpellInfo(PROSPECT_ID):lower()
|
mischivin@14
|
7 local MILLING = GetSpellInfo(MILLING_ID):lower()
|
mischivin@14
|
8 local MASS_PROSPECT_FELSLATE = GetSpellInfo(MASS_PROSPECT_FELSLATE_ID):lower()
|
mischivin@14
|
9 local MASS_PROSPECT_LEYSTONE = GetSpellInfo(MASS_PROSPECT_FELSLATE_ID):lower()
|
mischivin@14
|
10 local MASS_MILLING_YSERALLINE = GetSpellInfo(MASS_PROSPECT_FELSLATE_ID):lower()
|
Vynn@0
|
11 local containerID, containerLink = nil, nil
|
Vynn@0
|
12 local getContents = false
|
mischivin@11
|
13 local bulkMultiplier = 1 --This will be used for mass prospecting/milling in Legion
|
Vynn@0
|
14
|
Vynn@0
|
15 local function CreateTableEntry(id)
|
Vynn@0
|
16 local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(id)
|
Vynn@0
|
17 PM_ItemTable[id] = {}
|
Vynn@0
|
18 PM_ItemTable[id].name = name
|
Vynn@0
|
19 PM_ItemTable[id].link = link
|
Vynn@0
|
20 PM_ItemTable[id].quality = quality
|
Vynn@0
|
21 PM_ItemTable[id].iLevel = iLevel
|
Vynn@0
|
22 PM_ItemTable[id].reqLevel = reqLevel
|
Vynn@0
|
23 PM_ItemTable[id].class = class
|
Vynn@0
|
24 PM_ItemTable[id].subclass = subclass
|
Vynn@0
|
25 PM_ItemTable[id].maxStack = maxStack
|
Vynn@0
|
26 PM_ItemTable[id].equipSlot = equipSlot
|
Vynn@0
|
27 PM_ItemTable[id].texture = texture
|
Vynn@0
|
28 PM_ItemTable[id].vendorPrice = vendorPrice
|
Vynn@0
|
29 PM_ItemTable[id].price = PM_GetItemValue(id)
|
Vynn@0
|
30 end
|
Vynn@0
|
31
|
mischivin@21
|
32 function PM_GemCleanup()
|
mischivin@21
|
33 local cleanupIDs = { "129099", "130200", "130201", "130202", "130203", "130204" }
|
mischivin@21
|
34 if not PM_ItemTable["129100"] then
|
mischivin@21
|
35 CreateTableEntry("129100")
|
mischivin@21
|
36 end
|
mischivin@21
|
37 for i, r in pairs(PM_ResultsTable) do
|
mischivin@21
|
38 for k, v in pairs(cleanupIDs) do
|
mischivin@21
|
39 if PM_ResultsTable[i][v] then
|
mischivin@21
|
40 if not PM_ResultsTable[i]["129100"] then
|
mischivin@21
|
41 PM_ResultsTable[i]["129100"] = 0
|
mischivin@21
|
42 end
|
mischivin@21
|
43 PM_ResultsTable[i]["129100"] = PM_ResultsTable[i]["129100"] + PM_ResultsTable[i][v]
|
mischivin@21
|
44 PM_ResultsTable[i][v] = nil
|
mischivin@21
|
45 end
|
mischivin@21
|
46 end
|
mischivin@21
|
47 end
|
mischivin@21
|
48 for k, v in pairs(cleanupIDs) do
|
mischivin@21
|
49 if PM_ItemTable[v] then
|
mischivin@21
|
50 PM_ItemTable[v] = nil
|
mischivin@21
|
51 end
|
mischivin@21
|
52 end
|
mischivin@21
|
53 end
|
mischivin@21
|
54
|
mischivin@21
|
55 local function PM_Init()
|
mischivin@21
|
56 if not PM_ResultsTable then
|
mischivin@21
|
57 PM_ResultsTable = {}
|
mischivin@21
|
58 PM_ItemTable = {}
|
mischivin@21
|
59 end
|
mischivin@21
|
60 PM_SessionTable = {}
|
mischivin@21
|
61 PM_GemCleanup() --Run cleanup on excess Gem Chips created in v1.7.0.2 and earlier
|
mischivin@21
|
62 end
|
mischivin@21
|
63
|
Vynn@0
|
64 --debugging function to print the databases results
|
Vynn@0
|
65 function PM_PrintResults()
|
Vynn@0
|
66 for container, k in pairs(PM_ResultsTable) do
|
Vynn@0
|
67 print(PM_ItemTable[container].link, PM_ResultsTable[container].timesProspected)
|
Vynn@0
|
68 for i, num in pairs(k) do
|
Vynn@0
|
69 if i ~= "timesProspected" then
|
Vynn@0
|
70 print(PM_ItemTable[i].link, num)
|
Vynn@0
|
71 end
|
Vynn@0
|
72 end
|
Vynn@0
|
73 end
|
Vynn@0
|
74 end
|
Vynn@0
|
75
|
Vynn@0
|
76 local function GetResults()
|
Vynn@0
|
77 --Create tables for the Container if it doesn't exist yet
|
Vynn@0
|
78 if not PM_ResultsTable[containerID] then
|
Vynn@0
|
79 PM_ResultsTable[containerID] = {timesProspected = 0}
|
Vynn@0
|
80 CreateTableEntry(containerID)
|
Vynn@0
|
81 end
|
Vynn@0
|
82
|
Vynn@0
|
83 --Creates a session table entry, this will be cleared on log out/UI reload
|
Vynn@0
|
84 if not PM_SessionTable[containerID] then
|
Vynn@0
|
85 PM_SessionTable[containerID] = {timesProspected = 0}
|
Vynn@0
|
86 end
|
mischivin@18
|
87
|
Vynn@0
|
88 for i = 1, GetNumLootItems() do
|
Vynn@0
|
89 local itemID = GetLootSlotLink(i):match("Hitem:(%d+)")
|
mischivin@18
|
90 if itemID == "129099" or itemID == "130200" or itemID == "130201" or itemID == "130202" or itemID == "130203" or itemID == "130204" then --consolidate Colored Gem Chips into their resulting item
|
mischivin@18
|
91 itemID = "129100"
|
mischivin@18
|
92 end
|
Vynn@0
|
93 local quantity = select(3, GetLootSlotInfo(i))
|
Vynn@0
|
94 if not PM_ItemTable[itemID] then
|
Vynn@0
|
95 CreateTableEntry(itemID)
|
Vynn@0
|
96 end
|
Vynn@0
|
97 if PM_ResultsTable[containerID][itemID] then
|
Vynn@0
|
98 PM_ResultsTable[containerID][itemID] = PM_ResultsTable[containerID][itemID] + quantity
|
Vynn@0
|
99 else
|
Vynn@0
|
100 PM_ResultsTable[containerID][itemID] = quantity
|
Vynn@0
|
101 end
|
Vynn@0
|
102 if PM_SessionTable[containerID][itemID] then
|
Vynn@0
|
103 PM_SessionTable[containerID][itemID] = PM_SessionTable[containerID][itemID] + quantity
|
Vynn@0
|
104 else
|
Vynn@0
|
105 PM_SessionTable[containerID][itemID] = quantity
|
Vynn@0
|
106 end
|
Vynn@0
|
107 end
|
Vynn@0
|
108
|
mischivin@11
|
109 PM_ResultsTable[containerID].timesProspected = PM_ResultsTable[containerID].timesProspected + bulkMultiplier
|
mischivin@11
|
110 PM_SessionTable[containerID].timesProspected = PM_SessionTable[containerID].timesProspected + bulkMultiplier
|
Vynn@0
|
111 end
|
Vynn@0
|
112
|
Vynn@0
|
113 local function EventHandler(self, event, ...)
|
Vynn@0
|
114 if event == "VARIABLES_LOADED" then
|
Vynn@0
|
115 PM_Init()
|
Vynn@0
|
116 PM_UpdateValues()
|
Vynn@0
|
117 end
|
Vynn@0
|
118 if event == "UNIT_SPELLCAST_INTERRUPTED" then
|
Vynn@0
|
119 local unitID, spell, rank = ...
|
mischivin@14
|
120 spell = spell:lower()
|
mischivin@12
|
121 if unitID == "player" and (spell == PROSPECT or spell == MILLING or spell == MASS_PROSPECT_FELSLATE or spell == MASS_PROSPECT_LEYSTONE or spell == MASS_MILLING_YSERALLINE)then
|
Vynn@0
|
122 getContents = false
|
Vynn@0
|
123 end
|
Vynn@0
|
124 end
|
Vynn@0
|
125 if event == "LOOT_OPENED" then
|
Vynn@0
|
126 if getContents then
|
Vynn@0
|
127 GetResults()
|
Vynn@0
|
128 end
|
Vynn@0
|
129 end
|
Vynn@0
|
130 if event == "LOOT_CLOSED" then
|
Vynn@0
|
131 getContents = false
|
Vynn@0
|
132 end
|
Vynn@0
|
133 if event == "AUCTION_ITEM_LIST_UPDATE" then
|
Vynn@0
|
134 PM_UpdateValues()
|
Vynn@0
|
135 end
|
Vynn@0
|
136 end
|
Vynn@0
|
137
|
Vynn@0
|
138 local frame = CreateFrame("FRAME", "PM_Frame")
|
Vynn@0
|
139 frame:RegisterEvent("VARIABLES_LOADED")
|
Vynn@0
|
140 frame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
|
Vynn@0
|
141 frame:RegisterEvent("LOOT_OPENED")
|
Vynn@0
|
142 frame:RegisterEvent("LOOT_CLOSED")
|
Vynn@0
|
143 frame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE")
|
Vynn@0
|
144 frame:SetScript("OnEvent", EventHandler)
|
Vynn@0
|
145
|
Vynn@0
|
146 hooksecurefunc("UseContainerItem", function(...)
|
Vynn@0
|
147 if getContents then
|
Vynn@0
|
148 containerLink = GetContainerItemLink(...)
|
Vynn@0
|
149 containerID = containerLink:match("Hitem:(%d+)")
|
Vynn@0
|
150 end
|
Vynn@0
|
151
|
Vynn@0
|
152 end)
|
Vynn@0
|
153
|
Vynn@0
|
154 hooksecurefunc("UseItemByName", function(itemName)
|
Vynn@0
|
155 if getContents then
|
Vynn@0
|
156 containerLink = select(2, GetItemInfo(itemName))
|
Vynn@0
|
157 containerID = containerLink:match("Hitem:(%d+)")
|
Vynn@0
|
158 end
|
Vynn@0
|
159 end)
|
Vynn@0
|
160
|
Vynn@0
|
161 hooksecurefunc("SpellTargetItem", function(itemName)
|
Vynn@0
|
162 if getContents then
|
Vynn@0
|
163 containerLink = select(2, GetItemInfo(itemName))
|
Vynn@0
|
164 containerID = containerLink:match("Hitem:(%d+)")
|
Vynn@0
|
165 end
|
Vynn@0
|
166 end)
|
Vynn@0
|
167
|
Vynn@0
|
168 hooksecurefunc("CastSpell", function(...)
|
mischivin@14
|
169 local spellName = GetSpellInfo(...):lower()
|
mischivin@14
|
170 if spellName == PROSPECT or spellName == MILLING or spellName == MASS_PROSPECT_FELSLATE or spellName == MASS_PROSPECT_LEYSTONE or spellName == MASS_MILLING_YSERALLINE then
|
Vynn@0
|
171 getContents = true
|
mischivin@14
|
172 if spellName == MASS_PROSPECT_FELSLATE or spellName == MASS_PROSPECT_LEYSTONE or spellName == MASS_MILLING_YSERALLINE then
|
mischivin@11
|
173 bulkMultiplier = 4
|
mischivin@11
|
174 else
|
mischivin@11
|
175 bulkMultiplier = 1
|
mischivin@11
|
176 end
|
Vynn@0
|
177 end
|
Vynn@0
|
178 end)
|
Vynn@0
|
179
|
Vynn@0
|
180 hooksecurefunc("CastSpellByID", function(spellID)
|
mischivin@11
|
181 if spellID == PROSPECT_ID or spellID == MILLING_ID or spellID == MASS_PROSPECT_FELSTATE_ID or spellID == MASS_PROSPECT_LEYSTONE_ID or spellID == MASS_MILLING_YSERALLINE_ID then
|
Vynn@0
|
182 getContents = true
|
mischivin@11
|
183 if spellID == MASS_PROSPECT_FELSTATE_ID or spellID == MASS_PROSPECT_LEYSTONE_ID or spellID == MASS_MILLING_YSERALLINE_ID then
|
mischivin@11
|
184 bulkMultiplier = 4
|
mischivin@11
|
185 else
|
mischivin@11
|
186 bulkMultiplier = 1
|
mischivin@11
|
187 end
|
Vynn@0
|
188 end
|
Vynn@0
|
189 end)
|
Vynn@0
|
190
|
Vynn@0
|
191 hooksecurefunc("UseAction", function(actionID)
|
Vynn@0
|
192 local spellID = select(2, GetActionInfo(actionID))
|
mischivin@11
|
193 if spellID == PROSPECT_ID or spellID == MILLING_ID or spellID == MASS_PROSPECT_FELSTATE_ID or spellID == MASS_PROSPECT_LEYSTONE_ID or spellID == MASS_MILLING_YSERALLINE_ID then
|
Vynn@0
|
194 getContents = true
|
mischivin@11
|
195 if spellID == MASS_PROSPECT_FELSTATE_ID or spellID == MASS_PROSPECT_LEYSTONE_ID or spellID == MASS_MILLING_YSERALLINE_ID then
|
mischivin@11
|
196 bulkMultiplier = 4
|
mischivin@11
|
197 else
|
mischivin@11
|
198 bulkMultiplier = 1
|
mischivin@11
|
199 end
|
Vynn@0
|
200 end
|
Vynn@0
|
201 end)
|
Vynn@0
|
202
|
Vynn@0
|
203 hooksecurefunc("CastSpellByName", function(spellName, onSelf)
|
mischivin@14
|
204 spellName = spellName:lower()
|
mischivin@14
|
205 if spellName == PROSPECT or spellName == MILLING or spellName == MASS_PROSPECT_FELSLATE or spellName == MASS_PROSPECT_LEYSTONE or spellName == MASS_MILLING_YSERALLINE then
|
Vynn@0
|
206 getContents = true
|
mischivin@14
|
207 if spellName == MASS_PROSPECT_FELSLATE or spellName == MASS_PROSPECT_LEYSTONE or spellName == MASS_MILLING_YSERALLINE then
|
mischivin@11
|
208 bulkMultiplier = 4
|
mischivin@11
|
209 else
|
mischivin@11
|
210 bulkMultiplier = 1
|
mischivin@11
|
211 end
|
Vynn@0
|
212 end
|
Vynn@0
|
213 end) |