All pastes #951946 Raw Edit

Miscellany

public lua v1 · immutable
#951946 ·published 2008-03-21 19:59 UTC
rendered paste body
-- 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 -1end-- 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)	endend