local items = {
-- [chance] = {item, min, max}
[{1, 40}] = {2148, 25, 90},
[{41, 45}] = {2160, 1, 3},
[{46, 55}] = {2152, 1, 20},
[{56, 65}] = {2145, 1, 10},
[{66,100}] = {},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(itemEx.itemid == 11221) then
local random = math.random(100)
for k, v in pairs(items) do
if(random >= k[1] and random <= k[2]) then
doRemoveItem(itemEx.uid, 1)
if #v > 0 then
doPlayerAddItem(cid, v[1], v[2] and (v[3] and math.random(v[2], v[3]) or v[2]) or 1)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_RED)
else
doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
end
break
end
end
elseif(itemEx.itemid == 7200) then
doTransformItem(itemEx.uid, 7236)
doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
elseif not isInArray({0,65535}, toPosition.x) then
local itemGround = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})
if(isInArray(SPOTS, itemGround.itemid) and isInArray({354, 355}, itemEx.itemid)) then
doTransformItem(itemEx.uid, 392)
doDecayItem(itemEx.uid)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
return false
end
return true
end