1
0
Bifurcation 0

Merchant data now includes non-money currency collection... i.e. Epicurean Awards.

Since for some reason we aren't actually getting the itemlink for the currencies, we are collecting the currencies ids by collecting finding out what currencies a vendor takes and storing the id, localized name and icon name. In the item info, we store the localized name and the texture (excepting the path elements, they should always be the same).
Cette révision appartient à :
Nathanial.C.Jones 2013-02-01 02:17:27 +00:00
Parent b50a530943
révision f2939581bc
1 fichiers modifiés avec 59 ajouts et 13 suppressions

Voir le fichier

@ -29,16 +29,40 @@ local function AddChatType(typ)
return ret
end
local function MerchantShow()
local ct = GetMerchantNumItems()
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.
local merchant_shown = {}
local session_currencies = {}
local function MerchantUpdate()
local ct = GetMerchantNumItems()
if merchant_shown[UnitGUID("target")] then return end -- don't collect again.
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.
-- now, we haven't collected and everything is ready to go.
merchant_shown[UnitGUID("target")] = true -- cache the shop keeper for the session. It is possible for the items to change, buy meh, we won't worry about it... they might come up in the next session.
targ = AddChatType("shop")
if not targ then return end -- welllllp
local ct = GetMerchantNumItems()
--QuestHelper:TextOut(string.format("nitems %d", ct))
local currency_list = { GetMerchantCurrencies() }
local currency_rev_list
if #currency_list ~= 0 then
for j = 1, #currency_list do
local id = currency_list[j]
if not session_currencies[id] then
session_currencies[id] = true
local name, _, icon = GetCurrencyInfo(currency_list[j])
table.insert(QHCC, string.format("%d\t%s\t%s", id, name, icon))
end
end
end
for i = 1, ct do
local itemid = GetMerchantItemLink(i)
QuestHelper: Assert(itemid)
@ -49,15 +73,13 @@ local function MerchantShow()
if ext_cost then
ext_costs = {}
for curr = 1, GetMerchantItemCostInfo(i) do
for curr = 1, 3 do
local tex, val, link, name = GetMerchantItemCostItem(i, curr)
local ext_cost_detail = {}
ext_cost_detail.base_info = string.format("%s\t%d", name, val)
ext_cost_detail.link = link
ext_cost_detail.texture = tex
table.insert(ext_costs, ext_cost_detail)
if tex then
local base_info = string.format("%s\t%s\t%d\t%s", name, tex, val, link or "NO LINK")
table.insert(ext_costs, base_info)
end
end
shop_item.ext_costs = ext_costs
end
@ -73,17 +95,41 @@ local function GossipShow()
end
local function QuestGreeting()
AddChatType("quest")
AddChatType("quest_greet")
end
local function QuestComplete()
AddChatType("quest_complete")
end
local function QuestDetail()
AddChatType("quest_detail")
end
local function QuestFinished()
AddChatType("quest_finished")
end
local function QuestProgress()
AddChatType("quest_progress")
end
function QH_Collect_Merchant_Init(QHCData, API)
if not QHCData.merchant then QHCData.merchant = {} end
if not QHCData.merchant then QHCData.merchant = {} end
QHCM = QHCData.merchant
QH_Event("MERCHANT_SHOW", MerchantShow)
if not QHCData.currencies then QHCData.currencies = {} end
QHCC = QHCData.currencies
QH_Event("MERCHANT_SHOW", MerchantUpdate)
--QH_Event("MERCHANT_UPDATE", MerchantUpdate)
QH_Event("GOSSIP_SHOW", GossipShow)
QH_Event("QUEST_GREETING", QuestGreeting)
QH_Event("QUEST_COMPLETE", QuestComplete)
QH_Event("QUEST_DETAIL", QuestDetail)
QH_Event("QUEST_FINISHED", QuestFinished)
QH_Event("QUEST_PROGRESS", QuestProgress)
IsMonsterGUID = API.Utility_IsMonsterGUID
GetMonsterType = API.Utility_GetMonsterType