All pastes #951139 Raw Edit

Stuff

public text v1 · immutable
·published 2008-03-21 01:47 UTC
rendered paste body
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
		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, ClassSkillsBonus) >= 2 or checkModStatType(item, SkillTabBonus) then
					return false
				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
-- Ex: checkModStatType(item, ClassSkillsBonus)
function checkModStatType(item, modName)
	for i = 0, item.mods:size() - 1 do
		if item.mods[i].Stat.Type == StatType.modName
			return item.mods[i].Value
		end
	end
	
	return -1
end