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