1 QuestHelper_File
["collect_equip.lua"] = "Development Version"
3 local debug_output
= false
4 if QuestHelper_File
["collect_equip.lua"] == "Development Version" then debug_output
= true end
12 -- why does this need to exist
13 local invloc_lookup_proto
= {
14 INVTYPE_HEAD
= {"HeadSlot"},
15 INVTYPE_NECK
= {"NeckSlot"},
16 INVTYPE_SHOULDER
= {"ShoulderSlot"},
17 INVTYPE_CHEST
= {"ChestSlot"},
18 INVTYPE_ROBE
= {"ChestSlot"},
19 INVTYPE_WAIST
= {"WaistSlot"},
20 INVTYPE_LEGS
= {"LegsSlot"},
21 INVTYPE_FEET
= {"FeetSlot"},
22 INVTYPE_WRIST
= {"WristSlot"},
23 INVTYPE_HAND
= {"HandsSlot"},
24 INVTYPE_FINGER
= {"Finger0Slot", "Finger1Slot"},
25 INVTYPE_TRINKET
= {"Trinket0Slot", "Trinket1Slot"},
26 INVTYPE_CLOAK
= {"BackSlot"},
27 INVTYPE_WEAPON
= {"MainHandSlot", "SecondaryHandSlot"},
28 INVTYPE_SHIELD
= {"SecondaryHandSlot"},
29 INVTYPE_2HWEAPON
= {"MainHandSlot"},
30 INVTYPE_WEAPONMAINHAND
= {"MainHandSlot"},
31 INVTYPE_WEAPONOFFHAND
= {"SecondaryHandSlot"},
32 INVTYPE_HOLDABLE
= {"RangedSlot"},
33 INVTYPE_RANGED
= {"RangedSlot"},
34 INVTYPE_THROWN
= {"RangedSlot"},
35 INVTYPE_RANGEDRIGHT
= {"RangedSlot"},
36 INVTYPE_RELIC
= {"RangedSlot"},
39 local invloc_lookup
= {}
41 for k
, v
in pairs(invloc_lookup_proto
) do
43 for _
, tv
in pairs(v
) do
44 local gisi
= GetInventorySlotInfo(tv
)
45 QuestHelper
:TextOut(string.format("%s %s", tv
, gisi
))
46 table.insert(temp
, (GetInventorySlotInfo(tv
)))
48 invloc_lookup
[k
] = temp
51 local function Recheck(item
, location
, competing
)
53 local confused
= false
55 for i
, v
in pairs(invloc_lookup
[location
]) do
57 local ilink
= GetInventoryItemLink("player", v
)
59 local itype
= GetItemType(ilink
)
62 replaced
= competing
[i
]
63 elseif itype
== competing
[i
] then
72 if debug_output
then QuestHelper
:TextOut(string.format("Confused about %s", GetItemInfo(item
))) end
76 if not QHCI
[item
] then QHCI
[item
] = {} end
78 if debug_output
then QuestHelper
:TextOut(string.format("Equipped %s over %s", GetItemInfo(item
), GetItemInfo(replaced
))) end
79 QHCI
[item
].equip_yes
= (QHCI
[item
].equip_yes
or "") .. string.format("I%di%s", replaced
, GetSpecBolus())
81 for _
, v
in pairs(competing
) do
82 if debug_output
then QuestHelper
:TextOut(string.format("Did not equip %s over %s", GetItemInfo(item
), GetItemInfo(v
))) end
83 QHCI
[item
].equip_no
= (QHCI
[item
].equip_no
or "") .. string.format("I%di%s", v
, GetSpecBolus())
88 local function Looted(message
)
89 local item
= GetItemType(message
, true)
91 local name
, _
, quality
, ilvl
, min, itype
, isubtype
, _
, equiploc
, _
= GetItemInfo(item
)
93 if name
and IsEquippableItem(item
) and min <= UnitLevel("player") and invloc_lookup
[equiploc
] then -- The level comparison may be redundant
95 local nonempty
= false
96 for i
, v
in pairs(invloc_lookup
[equiploc
]) do
97 local litem
= GetInventoryItemLink("player", v
)
98 if litem
then litem
= GetItemType(litem
) end
99 if litem
and litem
~= item
then competing
[i
] = litem nonempty
= true end
102 if not nonempty
then return end -- congratulations you are better than nothing, we do not care
104 --Notifier(GetTime() + 5 * 60, function () Recheck(item, equiploc, competing) end)
105 Notifier(GetTime() + 15, function () Recheck(item
, equiploc
, competing
) end)
109 function QH_Collect_Equip_Init(QHCData
, API
)
110 if not QHCData
.item
then QHCData
.item
= {} end
113 API
.Registrar_EventHook("CHAT_MSG_LOOT", Looted
)
115 GetItemType
= API
.Utility_GetItemType
116 Notifier
= API
.Utility_Notifier
117 GetSpecBolus
= API
.Utility_GetSpecBolus
118 QuestHelper
: Assert(GetItemType
)
119 QuestHelper
: Assert(Notifier
)
120 QuestHelper
: Assert(GetSpecBolus
)