All pastes #939192 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-12 02:45 UTC
rendered paste body
function defenseCalc(item)
   for i = 0, item.stats:size() -1 do
      if item.stats[i].Stat.Stat == "armorclass" then
         basedef = item.stats[i].Value
         break
      end
   end

   if basedef then
      for i = 0, item.mods:size() -1 do
         if item.mods[i].Stat.Stat == "item_armor_percent" then
            edef = item.mods[i].Value
         elseif item.mods[i].Stat.Stat == "armorclass" then
            adef = item.mods[i].Value
         end
      end
   else
      return -1
   end

   return (basedef * (edef / 100 + 1) + adef)
end