function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey)
if target.itemid == 7932 then
target:transform(7933)
target:decay()
return true
end
local tile = Tile(toPosition)
if not tile then
return false
end
local ground = tile:getGround()
if not ground then
return false
end
local groundId = ground:getId()
if table.contains(holes, groundId) then
ground:transform(groundId + 1)
ground:decay()
toPosition.z = toPosition.z + 1
tile:relocateTo(toPosition)
player:addAchievementProgress("The Undertaker", 500)
elseif target.itemid == 20230 then -- swamp digging
if (player:getStorageValue(PlayerStorageKeys.swampDigging)) <= os.time() then
local chance = math.random(100)
if chance >= 1 and chance <= 42 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dug up a dead snake.")
player:addItem(3077)
elseif chance >= 43 and chance <= 79 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dug up a small diamond.")
player:addItem(2145)
elseif chance >= 80 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dug up a leech.")
player:addItem(20138)
end
player:setStorageValue(PlayerStorageKeys.swampDigging, os.time() + 7 * 24 * 60 * 60)
player:getPosition():sendMagicEffect(CONST_ME_GREEN_RINGS)
end
elseif table.contains(sandIds, groundId) then
local randomValue = math.random(1, 100)
if target.actionid == actionIds.sandHole and randomValue <= 20 then
ground:transform(489)
ground:decay()
elseif randomValue == 1 then
Game.createItem(2159, 1, toPosition)
player:addAchievementProgress("Gold Digger", 100)
elseif randomValue > 95 then
Game.createMonster("Scarab", toPosition)
end
toPosition:sendMagicEffect(CONST_ME_POFF)
else
return false
end
return true
end