disable the flight stuff for now, we'll fix it after thanksgiving
[QuestHelper.git] / collect_object.lua
blob4a898dff66e6b5fc073860ed27f263c1ddefdbbe
1 QuestHelper_File["collect_object.lua"] = "Development Version"
3 local debug_output = false
4 if QuestHelper_File["collect_object.lua"] == "Development Version" then debug_output = true end
6 local QHCO
8 local GetLoc
9 local Merger
10 local Patterns
12 local minetypes = {
13 mine = UNIT_SKINNABLE_ROCK,
14 herb = UNIT_SKINNABLE_HERB,
17 local function Tooltipy(self, ...)
18 -- objects are a bitch since they have no unique ID or any standard way to detect them (that I know of).
19 -- So we kind of guess at it.
20 if self:GetAnchorType() == "ANCHOR_NONE" then
21 if self:GetItem() or self:GetUnit() or self:GetSpell() then return end
22 -- rglrglrglrglrglrgl
24 local skintype = nil
26 local lines = GameTooltip:NumLines()
27 if lines > 2 then -- not a normal world item
28 return
29 elseif lines == 2 then -- see if we're mine or herb
30 for k, v in pairs(minetypes) do
31 if _G["GameTooltipTextLeft2"]:GetText() == v then
32 skintype = k
33 end
34 end
35 if not skintype then return end -- we are neither!
36 else
37 QuestHelper: Assert(lines == 1, string.format("Zorba knew there was going to be bug here, but couldn't figure out how to check it more throughly. Please report this, and if possible, say what you just moved the mouse over! Thanks!")) -- I just know this is going to break in stupid ways later on
38 end
40 local name = _G["GameTooltipTextLeft1"]:GetText()
42 if string.match(name, Patterns.CORPSE_TOOLTIP) then return end -- no corpses plzkthx
44 if not QHCO[name] then QHCO[name] = {} end
45 local qhci = QHCO[name]
47 for k, _ in pairs(minetypes) do
48 if k == skintype then
49 qhci[k .. "_yes"] = (qhci[k .. "_yes"] or 0) + 1
50 else
51 qhci[k .. "_no"] = (qhci[k .. "_no"] or 0) + 1
52 end
53 end
55 -- We have no unique identifier, so I'm just going to record every position we see. That said, I wonder if it's a good idea to add a cooldown.
56 -- Obviously, we also have no possible range data, so, welp.
57 Merger.Add(qhci, GetLoc())
58 end
59 end
61 function QH_Collect_Object_Init(QHCData, API)
62 if not QHCData.object then QHCData.object = {} end
63 QHCO = QHCData.object
65 API.Registrar_TooltipHook(Tooltipy)
67 Patterns = API.Patterns
68 QuestHelper: Assert(Patterns)
70 API.Patterns_Register("CORPSE_TOOLTIP", "[^%s]+")
72 GetLoc = API.Callback_LocationBolusCurrent
73 QuestHelper: Assert(GetLoc)
75 Merger = API.Utility_Merger
76 QuestHelper: Assert(Merger)
77 end