function sellItem(item)
-----------------------------------
-- NORMAL ITEMS --
-----------------------------------
if item.quality == ItemQuality.Normal then
-----------------------------------
-- SUPERIOR ITEMS --
-----------------------------------
elseif item.quality == ItemQuality.Superior then
-----------------------------------
-- MAGIC ITEMS --
-----------------------------------
elseif item.quality == ItemQuality.Magic then
-----------------------------------
-- SET ITEMS --
-----------------------------------
elseif item.quality == ItemQuality.Set then
-----------------------------------
-- RARE ITEMS --
-----------------------------------
elseif item.quality == ItemQuality.Rare then
-- mThreshhold is used for setting the point where an item reaches minimum quality
mThreshhold = 5
mTotal = 0
if item.flags.Identified == true then
-- Circlets
if item.baseItem.type == ItemType.Circlet then
-- +2 Class skills or +2 specific skill tab
if checkModStatType(item, StatType.ClassSkillsBonus) >= 2 or checkModStatType(item, StatType.SkillTabBonus) >= 2 then
if checkModStatType(item, StatType.FasterCastRate) == 20 then
mTotal = mTotal + 2
end
if checkResists(item, "1111", 0) > 10 then
mTotal = mTotal + 2
end
temp = checkModStatType(item, StatType.Sockets)
if temp == 1 then
mTotal = mTotal + 1
elseif temp == 2 then
mTotal = mTotal + 2
end
if mTotal >= mThreshhold then
return false
end
end
end
end
return true
-----------------------------------
-- UNIQUE ITEMS --
-----------------------------------
elseif item.quality == ItemQuality.Unique then
-----------------------------------
-- CRAFTED ITEMS --
-----------------------------------
elseif item.quality == ItemQuality.Crafted then
-----------------------------------
-- MISC ITEMS --
-----------------------------------
-- Items like gems, runes and potions fall under Misc
else
end
return false
end
-- checkModStatType
-- Checks modName against item.mods[].Stat.Type
-- Req: None
-- Ex: checkModStatType(item, StatType.ClassSkillsBonus)
function checkModStatType(item, modName)
for i = 0, item.mods:size() - 1 do
if item.mods[i].Stat.Type == modName then
return item.mods[i].Value
end
end
return -1
end
-- checkResists
-- Checks for resists and returns the chosen value type
--
-- wRes is a mock bitfield; checking all resists would be 1111
-- 1 1 1 1
-- | | | |_ Poison
-- | | |___ Cold
-- | |_____ Lightning
-- |_______ Fire
-- 0 means it doesn't check for the resist. It does not mean
-- it will fail if it _does_ exist.
--
-- rType is the return value type
-- 0 - Lowest resist value
-- 1 - Highest resist value
-- 2 - Average resist value
--
-- Returns -1 if the resists are not found
-- Req: checkModStatType
-- Ex: checkResists(item, "1111", 1)
function checkResists(item, wRes, rType)
nRes = 0
highest = 0
lowest = 300
total = 0
for i = 1, 4 do
if string.byte(wRes, i) == 49 then
temp = checkModStatType(item, (i + (i-1) + 38))
if temp ~= -1 then
if temp > highest then
highest = temp
end
if temp < lowest then
lowest = temp
end
total = total + temp
nRes = nRes + 1
else
return -1
end
end
end
if rType == 0 then
return lowest
elseif rType == 1 then
return highest
elseif rType == 2 then
return math.floor(total / nRes)
end
end