auto(100)
local corpseIds = {5362, 5362} -- ids of bodies
local itemIdToUse = 7803 -- id of the item to use on bodies
function table.find(t, value)
for k,v in pairs(t) do
if v == value then return k end
end
end
local tiles = g_map.getTiles()
local corpses = {}
for _, tile in pairs(tiles) do
if tile:getPosition():getDistance(g_game.getLocalPlayer():getPosition()) <= 1 then
local topItem = tile:getTopItem()
if topItem and table.find(corpseIds, topItem:getId()) then
table.insert(corpses, topItem)
end
end
end
if #corpses > 0 then
for _, corpse in pairs(corpses) do
setOption("Cavebot/Enabled", "false")
g_game.stop()
g_game.useItemOnPosition(itemIdToUse, corpse:getPosition())
sleep(1000)
end
else
setOption("Cavebot/Enabled", "true")
end