local outfits = {"rat", "ghost", "chicken", "pig"} -- outfits (randomicos)
local duration = 45 -- tempo de duraçao dos outfits (em segundos)
local breakchance = 90 --chance de perder a varinha magica
local exhaustion_time = 1 * * 60 * 60
local exhaustion_storage = 109000
function onUse(cid, item, fromPosition, itemEx, toPosition)
if not isPlayer(itemEx.uid) then
doPlayerSendCancel(cid, "Use only on players.")
return true
elseif exhaustion.check(cid, exhaustion_storage) then
doPlayerSendCancel(cid, "Wait " .. exhaustion.get(cid, exhaustion_storage) .. " seconds.")
return true
end
if math.random(100) <= breakchance then
local pos = getClosestFreeTile(cid, toPosition, true, false)
if isWalkable(pos) then
doSummonCreature("Mad Sheep", pos)
doSendMagicEffect(pos, CONST_ME_SOUND_BLUE)
end
doRemoveItem(item.uid, 1)
else
doSetMonsterOutfit(itemEx.uid, outfits[math.random(#outfits)], duration * 1000)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
end
exhaustion.set(cid, exhaustion_storage, exhaustion_time)
return true
end