mischivin@32
|
1 --[[
|
mischivin@33
|
2 Event Flow --> UNIT_SPELLCAST_SUCCEDED --> Prospecting --> Set Multiplier --> LOOT_OPENED --> parse --> ITEM_LOCKED (Get Item ID) --> LOOT_CLOSED (Add Results)
|
mischivin@33
|
3 --> Mass Prospecting (Get Item ID from spell) --> Set Multiplier --> CHAT_MSG_LOOT --> parse --> TRADE_SKILL_UPDATE (Add Results)
|
mischivin@33
|
4
|
mischivin@32
|
5 ]]
|
mischivin@33
|
6
|
mischivin@33
|
7 --[[
|
mischivin@33
|
8 Declarations of constants.
|
mischivin@33
|
9 ]]
|
mischivin@33
|
10
|
mischivin@33
|
11 local PROSPECT_SPELLID = 31252
|
mischivin@33
|
12 local MILLING_SPELLID = 51005
|
mischivin@33
|
13 local MASS_PROSPECT_FELSLATE_SPELLID = 225904
|
mischivin@33
|
14 local MASS_PROSPECT_LEYSTONE_SPELLID = 225902
|
mischivin@33
|
15 local MASS_MILLING_YSERALLINE_SPELLID = 210116
|
mischivin@33
|
16 local PROSPECT = GetSpellInfo(PROSPECT_SPELLID)
|
mischivin@33
|
17 local MILLING = GetSpellInfo(MILLING_SPELLID)
|
mischivin@33
|
18 local MASS_PROSPECT_FELSLATE = GetSpellInfo(MASS_PROSPECT_FELSLATE_SPELLID)
|
mischivin@33
|
19 local MASS_PROSPECT_LEYSTONE = GetSpellInfo(MASS_PROSPECT_LEYSTONE_SPELLID)
|
mischivin@33
|
20 local MASS_MILLING_YSERALLINE = GetSpellInfo(MASS_MILLING_YSERALLINE_SPELLID)
|
mischivin@33
|
21
|
mischivin@33
|
22 local ORE = select(7,GetItemInfo(123918)) -- Get Ore Subclass from a known quantity (leystone ore)
|
mischivin@33
|
23 local HERB = select(7,GetItemInfo(128304)) -- Get Herb Subclass from a known quantity (yseralline seed)
|
mischivin@33
|
24
|
mischivin@33
|
25 local VALIDSPELLS = {
|
mischivin@33
|
26 [PROSPECT] = true,
|
mischivin@33
|
27 [MILLING] = true,
|
mischivin@33
|
28 [MASS_PROSPECT_LEYSTONE] = true,
|
mischivin@33
|
29 [MASS_PROSPECT_FELSLATE] = true,
|
mischivin@33
|
30 [MASS_MILLING_YSERALLINE] = true,
|
mischivin@33
|
31 }
|
mischivin@33
|
32
|
mischivin@33
|
33 --[[
|
mischivin@33
|
34 Local Variables
|
mischivin@33
|
35 ]]
|
mischivin@33
|
36 local ContainerID = nil
|
mischivin@33
|
37 local Table = {}
|
mischivin@33
|
38 local ParseResults = false
|
mischivin@33
|
39 local MassMultiplier = 1
|
mischivin@33
|
40 local Results = {}
|
mischivin@33
|
41
|
mischivin@33
|
42 --[[
|
mischivin@33
|
43 Initialize - Dets default config variables if they don't exist, ensures all our functions exist and are included in the table in their current form.
|
mischivin@33
|
44 ]]
|
mischivin@33
|
45 local function Initialize()
|
mischivin@33
|
46 --[[
|
mischivin@33
|
47 Sets Default Variables
|
mischivin@33
|
48 ]]
|
mischivin@33
|
49 if not ProspectMe.Config then
|
mischivin@33
|
50 ProspectMe.Config = {
|
mischivin@33
|
51 ShowQualities = {
|
mischivin@33
|
52 Junk = false,
|
mischivin@33
|
53 Common = false,
|
mischivin@33
|
54 Uncommon = true,
|
mischivin@33
|
55 Rare = true,
|
mischivin@33
|
56 Epic = true,
|
mischivin@33
|
57 },
|
mischivin@33
|
58 PerSession = false,
|
mischivin@33
|
59 ShowPercent = true,
|
mischivin@33
|
60 ShowNumber = true,
|
mischivin@31
|
61 }
|
mischivin@33
|
62 end
|
mischivin@33
|
63 if not ProspectMe.Results then
|
mischivin@33
|
64 ProspectMe.Results = {}
|
mischivin@33
|
65 end
|
mischivin@33
|
66 ProspectMe.Session = {}
|
mischivin@33
|
67
|
mischivin@33
|
68 ProspectMe.Debug = function (...)
|
mischivin@33
|
69 for k, v in pairs(...) do
|
mischivin@33
|
70 print("key: " .. k " | value: " .. v)
|
mischivin@33
|
71 end
|
mischivin@33
|
72 end
|
mischivin@33
|
73
|
mischivin@33
|
74 --[[
|
mischivin@33
|
75 Begins the capture process, sets variables where we have them. Prospecting and Milling (non MASS) require an extra step to get the ContainerID
|
mischivin@33
|
76 ]]
|
mischivin@33
|
77 ProspectMe.BeginCapture = function (event, ...)
|
mischivin@33
|
78 local unit, spell = ...
|
mischivin@33
|
79 if unit == "player" then
|
mischivin@33
|
80 if spell == PROSPECT or spell == MILLING then
|
mischivin@33
|
81 MassMultiplier = 1
|
mischivin@33
|
82 ParseResults = true
|
mischivin@33
|
83 elseif spell == MASS_PROSPECT_FELSLATE or spell == MASS_PROSPECT_LEYSTONE or spell == MASS_MILLING_YSERALLINE then
|
mischivin@33
|
84 MassMultiplier = 4
|
mischivin@33
|
85 ParseResults = true
|
mischivin@33
|
86 if spell == MASS_PROSPECT_FELSLATE then
|
mischivin@33
|
87 ContainerID = 123919
|
mischivin@33
|
88 end
|
mischivin@33
|
89 if spell == MASS_PROSPECT_LEYSTONE then
|
mischivin@33
|
90 ContainerID = 123918
|
mischivin@33
|
91 end
|
mischivin@33
|
92 if spell == MASS_MILLING_YSERALLINE then
|
mischivin@33
|
93 ContainerID = 128304
|
mischivin@33
|
94 end
|
mischivin@33
|
95 else
|
mischivin@33
|
96 ParseResults = false
|
mischivin@33
|
97 end
|
mischivin@33
|
98 end
|
mischivin@33
|
99 Results = {}
|
mischivin@33
|
100 end
|
mischivin@33
|
101
|
mischivin@33
|
102 --[[
|
mischivin@33
|
103 Ends the capture process and resets variables so they're ready for use the next time.
|
mischivin@33
|
104 ]]
|
mischivin@33
|
105 ProspectMe.EndCapture = function (event, ...)
|
mischivin@33
|
106 if ParseResults then
|
mischivin@33
|
107 ProspectMe.AddEntry(ContainerID, MassMultiplier, Results)
|
mischivin@33
|
108 end
|
mischivin@33
|
109 ParseResults = false
|
mischivin@33
|
110 MassMultiplier = 1
|
mischivin@33
|
111 ContainerID = nil
|
mischivin@33
|
112 end
|
mischivin@33
|
113
|
mischivin@33
|
114 --[[
|
mischivin@33
|
115 Creates an table entry, if it does not exist, and adds results to the entry.
|
mischivin@33
|
116 Expects the Item ID and pairs of arguments in table with key being the result's ItemID and value being the quantity returned
|
mischivin@33
|
117 ]]
|
mischivin@33
|
118 ProspectMe.AddEntry = function (ItemID, BatchSize, ResultsTable)
|
mischivin@33
|
119 if not ProspectMe.Results[ItemID] then
|
mischivin@33
|
120 ProspectMe.Results[ItemID] = { TimesProspected = 0 }
|
mischivin@33
|
121 end
|
mischivin@33
|
122 if not ProspectMe.Session[ItemID] then
|
mischivin@33
|
123 ProspectMe.Session[ItemID] = { TimesProspected = 0 }
|
mischivin@33
|
124 end
|
mischivin@33
|
125 for k, v in pairs(ResultsTable) do
|
mischivin@33
|
126 if not ProspectMe.Results[ItemID][k] then
|
mischivin@33
|
127 ProspectMe.Results[ItemID][k] = v
|
mischivin@33
|
128 else
|
mischivin@33
|
129 ProspectMe.Results[ItemID][k] = ProspectMe.Results[ItemID][k] + v
|
mischivin@33
|
130 end
|
mischivin@33
|
131 if not ProspectMe.Session[ItemID][k] then
|
mischivin@33
|
132 ProspectMe.Session[ItemID][k] = v
|
mischivin@33
|
133 else
|
mischivin@33
|
134 ProspectMe.Session[ItemID][k] = ProspectMe.Session[ItemID][k] + v
|
mischivin@33
|
135 end
|
mischivin@33
|
136 end
|
mischivin@33
|
137 ProspectMe.Results[ItemID].TimesProspected = ProspectMe.Results[ItemID].TimesProspected + BatchSize
|
mischivin@33
|
138 ProspectMe.Session[ItemID].TimesProspected = ProspectMe.Session[ItemID].TimesProspected + BatchSize
|
mischivin@33
|
139
|
mischivin@33
|
140 end
|
mischivin@33
|
141
|
mischivin@33
|
142 --[[
|
mischivin@33
|
143 Parses the results of the spellcast or loot containerand returns a table of those results in key/value pairs of item/quantity.
|
mischivin@33
|
144 Expects an event and a set of arguments if the event has them.
|
mischivin@33
|
145 ]]
|
mischivin@33
|
146 ProspectMe.GetResults = function (event, ...)
|
mischivin@33
|
147 if event == "CHAT_MSG_LOOT" then
|
mischivin@33
|
148 local ItemID = tonumber((...):match("Hitem:(%d+)"))
|
mischivin@33
|
149 if ItemID == 129099 or ItemID == 130200 or ItemID == 130201 or ItemID == 130202 or ItemID == 130203 or ItemID == 130204 then
|
mischivin@33
|
150 ItemID = 129100
|
mischivin@33
|
151 end
|
mischivin@33
|
152 local Quantity = tonumber((...):match("|h|rx(%d+)"))
|
mischivin@33
|
153 if Quantity == nil then
|
mischivin@33
|
154 Quantity = 1
|
mischivin@33
|
155 end
|
mischivin@33
|
156 Results[ItemID] = Quantity
|
mischivin@33
|
157 end
|
mischivin@33
|
158 if event == "LOOT_OPENED" then
|
mischivin@33
|
159 for i = 1, GetNumLootItems() do
|
mischivin@33
|
160 local ItemID = tonumber(GetLootSlotLink(i):match("Hitem:(%d+)"))
|
mischivin@33
|
161 if ItemID == 129099 or ItemID == 130200 or ItemID == 130201 or ItemID == 130202 or ItemID == 130203 or ItemID == 130204 then
|
mischivin@33
|
162 ItemID = 129100
|
mischivin@33
|
163 end
|
mischivin@33
|
164 local Quantity = select(3, GetLootSlotInfo(i))
|
mischivin@33
|
165 Results[ItemID] = Quantity
|
mischivin@33
|
166 end
|
mischivin@33
|
167 end
|
mischivin@33
|
168 end
|
mischivin@31
|
169 end
|
mischivin@31
|
170
|
mischivin@33
|
171
|
mischivin@33
|
172 local function EventHandler(self, event, ...)
|
mischivin@33
|
173 if event == "VARIABLES_LOADED" then
|
mischivin@33
|
174 Initialize()
|
mischivin@31
|
175 end
|
mischivin@33
|
176 if event == "UNIT_SPELLCAST_SUCCEEDED" then
|
mischivin@33
|
177 local unit, spell = ...
|
mischivin@33
|
178 if unit == "player" and VALIDSPELLS[spell] then
|
mischivin@33
|
179 ProspectMe.BeginCapture(event, ...)
|
mischivin@32
|
180 end
|
mischivin@32
|
181 end
|
mischivin@33
|
182 if event == "CHAT_MSG_LOOT" or "LOOT_OPENED" then
|
mischivin@33
|
183 if ParseResults then
|
mischivin@33
|
184 ProspectMe.GetResults(event, ...)
|
mischivin@33
|
185 end
|
mischivin@33
|
186 ProspectMeDebug = Results
|
mischivin@21
|
187 end
|
mischivin@33
|
188 if event == "ITEM_LOCKED" then
|
mischivin@33
|
189 local bag, slot = ...
|
mischivin@33
|
190 ContainerID = select(10, GetContainerItemInfo(bag, slot))
|
mischivin@33
|
191 end
|
mischivin@33
|
192 if event == "TRADE_SKILL_LIST_UPDATE" or event == "LOOT_CLOSED" then
|
mischivin@33
|
193 if ParseResults then
|
mischivin@33
|
194 ProspectMe.EndCapture()
|
Vynn@0
|
195 end
|
Vynn@0
|
196 end
|
Vynn@0
|
197 end
|
Vynn@0
|
198
|
mischivin@33
|
199 local frame = CreateFrame("FRAME", "ProspectMe")
|
Vynn@0
|
200 frame:RegisterEvent("VARIABLES_LOADED")
|
mischivin@33
|
201 frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
|
mischivin@33
|
202 frame:RegisterEvent("CHAT_MSG_LOOT")
|
Vynn@0
|
203 frame:RegisterEvent("LOOT_OPENED")
|
mischivin@33
|
204 frame:RegisterEvent("ITEM_LOCKED")
|
Vynn@0
|
205 frame:RegisterEvent("LOOT_CLOSED")
|
mischivin@33
|
206 frame:RegisterEvent("TRADE_SKILL_LIST_UPDATE")
|
Vynn@0
|
207 frame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE")
|
mischivin@33
|
208 frame:SetScript("OnEvent", EventHandler) |