1 QuestHelper_File
["collect_merchant.lua"] = "Development Version"
2 QuestHelper_Loadtime
["collect_merchant.lua"] = GetTime()
4 -- http://www.penny-arcade.com/comic/2005/01/05/
6 local debug_output
= false
7 if QuestHelper_File
["collect_merchant.lua"] == "Development Version" then debug_output
= true end
15 local function AddChatType(typ
)
16 local target
= UnitGUID("target")
17 if not target
then return end
19 if not IsMonsterGUID(target
) then return end
21 target
= GetMonsterType(target
)
23 if not QHCM
[target
] then QHCM
[target
] = {} end
24 QHCM
[target
]["chat_" .. typ
] = (QHCM
[target
]["chat_" .. typ
] or 0) + 1
28 local function MerchantShow()
29 local ct
= GetMerchantNumItems()
30 for i
= 1, ct
do if not GetMerchantItemLink(i
) then return end end -- We want to make sure it's cached, otherwise we'll return wonky data. Technically this biases things away from "yes he's a shopkeeper", but honestly, it doesn't matter that much.
32 targ
= AddChatType("shop")
33 if not targ
then return end -- welllllp
35 local ct
= GetMerchantNumItems()
36 --QuestHelper:TextOut(string.format("nitems %d", ct))
39 local itemid
= GetMerchantItemLink(i
)
40 QuestHelper
: Assert(itemid
)
41 itemid
= GetItemType(itemid
)
42 local _
, _
, price
, quant
, avail
, _
, _
= GetMerchantItemInfo(i
)
43 local dstr
= string.format("%d@@%d@@%d@@%d", itemid
, quant
, avail
, price
)
44 --if debug_output then QuestHelper:TextOut(dstr) end
45 targ
["shop_" .. dstr
] = (targ
["shop_" .. dstr
] or 0) + 1
49 local function GossipShow()
53 local function QuestGreeting()
58 function QH_Collect_Merchant_Init(QHCData
, API
)
59 if not QHCData
.monster
then QHCData
.monster
= {} end
60 QHCM
= QHCData
.monster
62 QH_Event("MERCHANT_SHOW", MerchantShow
)
63 QH_Event("GOSSIP_SHOW", GossipShow
)
64 QH_Event("QUEST_GREETING", QuestGreeting
)
66 IsMonsterGUID
= API
.Utility_IsMonsterGUID
67 GetMonsterType
= API
.Utility_GetMonsterType
68 GetItemType
= API
.Utility_GetItemType
69 QuestHelper
: Assert(IsMonsterGUID
)
70 QuestHelper
: Assert(GetMonsterType
)
71 QuestHelper
: Assert(GetItemType
)