1 QuestHelper_File
["collect_equip.lua"] = "Development Version"
2 QuestHelper_Loadtime
["collect_equip.lua"] = GetTime()
4 local debug_output
= false
5 if QuestHelper_File
["collect_equip.lua"] == "Development Version" then debug_output
= true end
13 -- why does this need to exist
14 local invloc_lookup_proto
= {
15 INVTYPE_HEAD
= {"HeadSlot"},
16 INVTYPE_NECK
= {"NeckSlot"},
17 INVTYPE_SHOULDER
= {"ShoulderSlot"},
18 INVTYPE_CHEST
= {"ChestSlot"},
19 INVTYPE_ROBE
= {"ChestSlot"},
20 INVTYPE_WAIST
= {"WaistSlot"},
21 INVTYPE_LEGS
= {"LegsSlot"},
22 INVTYPE_FEET
= {"FeetSlot"},
23 INVTYPE_WRIST
= {"WristSlot"},
24 INVTYPE_HAND
= {"HandsSlot"},
25 INVTYPE_FINGER
= {"Finger0Slot", "Finger1Slot"},
26 INVTYPE_TRINKET
= {"Trinket0Slot", "Trinket1Slot"},
27 INVTYPE_CLOAK
= {"BackSlot"},
28 INVTYPE_WEAPON
= {"MainHandSlot", "SecondaryHandSlot"},
29 INVTYPE_SHIELD
= {"SecondaryHandSlot"},
30 INVTYPE_2HWEAPON
= {"MainHandSlot"},
31 INVTYPE_WEAPONMAINHAND
= {"MainHandSlot"},
32 INVTYPE_WEAPONOFFHAND
= {"SecondaryHandSlot"},
33 INVTYPE_HOLDABLE
= {"RangedSlot"},
34 INVTYPE_RANGED
= {"RangedSlot"},
35 INVTYPE_THROWN
= {"RangedSlot"},
36 INVTYPE_RANGEDRIGHT
= {"RangedSlot"},
37 INVTYPE_RELIC
= {"RangedSlot"},
40 local invloc_lookup
= {}
42 for k
, v
in pairs(invloc_lookup_proto
) do
44 for _
, tv
in pairs(v
) do
45 local gisi
= GetInventorySlotInfo(tv
)
46 QuestHelper
:TextOut(string.format("%s %s", tv
, gisi
))
47 table.insert(temp
, (GetInventorySlotInfo(tv
)))
49 invloc_lookup
[k
] = temp
52 local function Recheck(item
, location
, competing
)
54 local confused
= false
56 for i
, v
in pairs(invloc_lookup
[location
]) do
58 local ilink
= GetInventoryItemLink("player", v
)
60 local itype
= GetItemType(ilink
)
63 replaced
= competing
[i
]
64 elseif itype
== competing
[i
] then
73 if debug_output
then QuestHelper
:TextOut(string.format("Confused about %s", GetItemInfo(item
))) end
77 if not QHCI
[item
] then QHCI
[item
] = {} end
79 if debug_output
then QuestHelper
:TextOut(string.format("Equipped %s over %s", GetItemInfo(item
), GetItemInfo(replaced
))) end
80 QHCI
[item
].equip_yes
= (QHCI
[item
].equip_yes
or "") .. string.format("I%di%s", replaced
, GetSpecBolus())
82 for _
, v
in pairs(competing
) do
83 if debug_output
then QuestHelper
:TextOut(string.format("Did not equip %s over %s", GetItemInfo(item
), GetItemInfo(v
))) end
84 QHCI
[item
].equip_no
= (QHCI
[item
].equip_no
or "") .. string.format("I%di%s", v
, GetSpecBolus())
89 local function Looted(message
)
90 if string.find(message
, string.gsub(LOOT_ITEM_CREATED_SELF
, "%%.*", "")) then -- YOU CANNOT EAT A PURSE
94 local item
= GetItemType(message
, true)
96 local name
, _
, quality
, ilvl
, min, itype
, isubtype
, _
, equiploc
, _
= GetItemInfo(item
)
98 if name
and IsEquippableItem(item
) and min <= UnitLevel("player") and invloc_lookup
[equiploc
] then -- The level comparison may be redundant
100 local nonempty
= false
101 for i
, v
in pairs(invloc_lookup
[equiploc
]) do
102 local litem
= GetInventoryItemLink("player", v
)
103 if litem
then litem
= GetItemType(litem
) end
104 if litem
and litem
~= item
then competing
[i
] = litem nonempty
= true end
107 if not nonempty
then return end -- congratulations you are better than nothing, we do not care
109 Notifier(GetTime() + 5 * 60, function () Recheck(item
, equiploc
, competing
) end)
113 function QH_Collect_Equip_Init(QHCData
, API
)
114 if not QHCData
.item
then QHCData
.item
= {} end
117 API
.Registrar_EventHook("CHAT_MSG_LOOT", Looted
)
119 GetItemType
= API
.Utility_GetItemType
120 Notifier
= API
.Utility_Notifier
121 GetSpecBolus
= API
.Utility_GetSpecBolus
122 QuestHelper
: Assert(GetItemType
)
123 QuestHelper
: Assert(Notifier
)
124 QuestHelper
: Assert(GetSpecBolus
)