mischivin@32: --[[ mischivin@33: Event Flow --> UNIT_SPELLCAST_SUCCEDED --> Prospecting --> Set Multiplier --> LOOT_OPENED --> parse --> ITEM_LOCKED (Get Item ID) --> LOOT_CLOSED (Add Results) mischivin@33: --> Mass Prospecting (Get Item ID from spell) --> Set Multiplier --> CHAT_MSG_LOOT --> parse --> TRADE_SKILL_UPDATE (Add Results) mischivin@33: mischivin@32: ]] mischivin@33: mischivin@33: --[[ mischivin@33: Declarations of constants. mischivin@33: ]] mischivin@33: mischivin@33: local PROSPECT_SPELLID = 31252 mischivin@33: local MILLING_SPELLID = 51005 mischivin@33: local MASS_PROSPECT_FELSLATE_SPELLID = 225904 mischivin@33: local MASS_PROSPECT_LEYSTONE_SPELLID = 225902 mischivin@33: local MASS_MILLING_YSERALLINE_SPELLID = 210116 mischivin@33: local PROSPECT = GetSpellInfo(PROSPECT_SPELLID) mischivin@33: local MILLING = GetSpellInfo(MILLING_SPELLID) mischivin@33: local MASS_PROSPECT_FELSLATE = GetSpellInfo(MASS_PROSPECT_FELSLATE_SPELLID) mischivin@33: local MASS_PROSPECT_LEYSTONE = GetSpellInfo(MASS_PROSPECT_LEYSTONE_SPELLID) mischivin@33: local MASS_MILLING_YSERALLINE = GetSpellInfo(MASS_MILLING_YSERALLINE_SPELLID) mischivin@33: mischivin@33: local ORE = select(7,GetItemInfo(123918)) -- Get Ore Subclass from a known quantity (leystone ore) mischivin@33: local HERB = select(7,GetItemInfo(128304)) -- Get Herb Subclass from a known quantity (yseralline seed) mischivin@33: mischivin@33: local VALIDSPELLS = { mischivin@33: [PROSPECT] = true, mischivin@33: [MILLING] = true, mischivin@33: [MASS_PROSPECT_LEYSTONE] = true, mischivin@33: [MASS_PROSPECT_FELSLATE] = true, mischivin@33: [MASS_MILLING_YSERALLINE] = true, mischivin@33: } mischivin@33: mischivin@33: --[[ mischivin@33: Local Variables mischivin@33: ]] mischivin@33: local ContainerID = nil mischivin@33: local Table = {} mischivin@33: local ParseResults = false mischivin@33: local MassMultiplier = 1 mischivin@33: local Results = {} mischivin@33: mischivin@33: --[[ mischivin@33: 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: ]] mischivin@33: local function Initialize() mischivin@33: --[[ mischivin@33: Sets Default Variables mischivin@33: ]] mischivin@33: if not ProspectMe.Config then mischivin@33: ProspectMe.Config = { mischivin@33: ShowQualities = { mischivin@33: Junk = false, mischivin@33: Common = false, mischivin@33: Uncommon = true, mischivin@33: Rare = true, mischivin@33: Epic = true, mischivin@33: }, mischivin@33: PerSession = false, mischivin@33: ShowPercent = true, mischivin@33: ShowNumber = true, mischivin@31: } mischivin@33: end mischivin@33: if not ProspectMe.Results then mischivin@33: ProspectMe.Results = {} mischivin@33: end mischivin@33: ProspectMe.Session = {} mischivin@33: mischivin@33: ProspectMe.Debug = function (...) mischivin@33: for k, v in pairs(...) do mischivin@33: print("key: " .. k " | value: " .. v) mischivin@33: end mischivin@33: end mischivin@33: mischivin@33: --[[ mischivin@33: 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: ]] mischivin@33: ProspectMe.BeginCapture = function (event, ...) mischivin@33: local unit, spell = ... mischivin@33: if unit == "player" then mischivin@33: if spell == PROSPECT or spell == MILLING then mischivin@33: MassMultiplier = 1 mischivin@33: ParseResults = true mischivin@33: elseif spell == MASS_PROSPECT_FELSLATE or spell == MASS_PROSPECT_LEYSTONE or spell == MASS_MILLING_YSERALLINE then mischivin@33: MassMultiplier = 4 mischivin@33: ParseResults = true mischivin@33: if spell == MASS_PROSPECT_FELSLATE then mischivin@33: ContainerID = 123919 mischivin@33: end mischivin@33: if spell == MASS_PROSPECT_LEYSTONE then mischivin@33: ContainerID = 123918 mischivin@33: end mischivin@33: if spell == MASS_MILLING_YSERALLINE then mischivin@33: ContainerID = 128304 mischivin@33: end mischivin@33: else mischivin@33: ParseResults = false mischivin@33: end mischivin@33: end mischivin@33: Results = {} mischivin@33: end mischivin@33: mischivin@33: --[[ mischivin@33: Ends the capture process and resets variables so they're ready for use the next time. mischivin@33: ]] mischivin@33: ProspectMe.EndCapture = function (event, ...) mischivin@33: if ParseResults then mischivin@33: ProspectMe.AddEntry(ContainerID, MassMultiplier, Results) mischivin@33: end mischivin@33: ParseResults = false mischivin@33: MassMultiplier = 1 mischivin@33: ContainerID = nil mischivin@33: end mischivin@33: mischivin@33: --[[ mischivin@33: Creates an table entry, if it does not exist, and adds results to the entry. mischivin@33: 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: ]] mischivin@33: ProspectMe.AddEntry = function (ItemID, BatchSize, ResultsTable) mischivin@33: if not ProspectMe.Results[ItemID] then mischivin@33: ProspectMe.Results[ItemID] = { TimesProspected = 0 } mischivin@33: end mischivin@33: if not ProspectMe.Session[ItemID] then mischivin@33: ProspectMe.Session[ItemID] = { TimesProspected = 0 } mischivin@33: end mischivin@33: for k, v in pairs(ResultsTable) do mischivin@33: if not ProspectMe.Results[ItemID][k] then mischivin@33: ProspectMe.Results[ItemID][k] = v mischivin@33: else mischivin@33: ProspectMe.Results[ItemID][k] = ProspectMe.Results[ItemID][k] + v mischivin@33: end mischivin@33: if not ProspectMe.Session[ItemID][k] then mischivin@33: ProspectMe.Session[ItemID][k] = v mischivin@33: else mischivin@33: ProspectMe.Session[ItemID][k] = ProspectMe.Session[ItemID][k] + v mischivin@33: end mischivin@33: end mischivin@33: ProspectMe.Results[ItemID].TimesProspected = ProspectMe.Results[ItemID].TimesProspected + BatchSize mischivin@33: ProspectMe.Session[ItemID].TimesProspected = ProspectMe.Session[ItemID].TimesProspected + BatchSize mischivin@33: mischivin@33: end mischivin@33: mischivin@33: --[[ mischivin@33: Parses the results of the spellcast or loot containerand returns a table of those results in key/value pairs of item/quantity. mischivin@33: Expects an event and a set of arguments if the event has them. mischivin@33: ]] mischivin@33: ProspectMe.GetResults = function (event, ...) mischivin@33: if event == "CHAT_MSG_LOOT" then mischivin@33: local ItemID = tonumber((...):match("Hitem:(%d+)")) mischivin@33: if ItemID == 129099 or ItemID == 130200 or ItemID == 130201 or ItemID == 130202 or ItemID == 130203 or ItemID == 130204 then mischivin@33: ItemID = 129100 mischivin@33: end mischivin@33: local Quantity = tonumber((...):match("|h|rx(%d+)")) mischivin@33: if Quantity == nil then mischivin@33: Quantity = 1 mischivin@33: end mischivin@33: Results[ItemID] = Quantity mischivin@33: end mischivin@33: if event == "LOOT_OPENED" then mischivin@33: for i = 1, GetNumLootItems() do mischivin@33: local ItemID = tonumber(GetLootSlotLink(i):match("Hitem:(%d+)")) mischivin@33: if ItemID == 129099 or ItemID == 130200 or ItemID == 130201 or ItemID == 130202 or ItemID == 130203 or ItemID == 130204 then mischivin@33: ItemID = 129100 mischivin@33: end mischivin@33: local Quantity = select(3, GetLootSlotInfo(i)) mischivin@33: Results[ItemID] = Quantity mischivin@33: end mischivin@33: end mischivin@33: end mischivin@31: end mischivin@31: mischivin@33: mischivin@33: local function EventHandler(self, event, ...) mischivin@33: if event == "VARIABLES_LOADED" then mischivin@33: Initialize() mischivin@31: end mischivin@33: if event == "UNIT_SPELLCAST_SUCCEEDED" then mischivin@33: local unit, spell = ... mischivin@33: if unit == "player" and VALIDSPELLS[spell] then mischivin@33: ProspectMe.BeginCapture(event, ...) mischivin@32: end mischivin@32: end mischivin@33: if event == "CHAT_MSG_LOOT" or "LOOT_OPENED" then mischivin@33: if ParseResults then mischivin@33: ProspectMe.GetResults(event, ...) mischivin@33: end mischivin@33: ProspectMeDebug = Results mischivin@21: end mischivin@33: if event == "ITEM_LOCKED" then mischivin@33: local bag, slot = ... mischivin@33: ContainerID = select(10, GetContainerItemInfo(bag, slot)) mischivin@33: end mischivin@33: if event == "TRADE_SKILL_LIST_UPDATE" or event == "LOOT_CLOSED" then mischivin@33: if ParseResults then mischivin@33: ProspectMe.EndCapture() Vynn@0: end Vynn@0: end Vynn@0: end Vynn@0: mischivin@33: local frame = CreateFrame("FRAME", "ProspectMe") Vynn@0: frame:RegisterEvent("VARIABLES_LOADED") mischivin@33: frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") mischivin@33: frame:RegisterEvent("CHAT_MSG_LOOT") Vynn@0: frame:RegisterEvent("LOOT_OPENED") mischivin@33: frame:RegisterEvent("ITEM_LOCKED") Vynn@0: frame:RegisterEvent("LOOT_CLOSED") mischivin@33: frame:RegisterEvent("TRADE_SKILL_LIST_UPDATE") Vynn@0: frame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE") mischivin@33: frame:SetScript("OnEvent", EventHandler)