• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[TFS 1.0] Squeezings

LUA:
local ropeSpots = {
    386, 421
}

local holeSpots = {
    293, 294, 369, 370, 385, 394, 411, 412,
    421, 432, 433, 435, 482, 5081, 483, 594,
    595, 607, 609, 610, 615, 1066, 1067, 1080
}

local pools = {2886, 2887, 2888, 2889, 2890, 2891, 2895, 2896, 2897, 2898, 2899, 2900}

local pitsOfInfernoLava = {
    Position(32808, 32336, 11),
    Position(32809, 32336, 11),
    Position(32810, 32336, 11),
    Position(32808, 32334, 11),
    Position(32807, 32334, 11),
    Position(32807, 32335, 11),
    Position(32807, 32336, 11),
    Position(32807, 32337, 11),
    Position(32806, 32337, 11),
    Position(32805, 32337, 11),
    Position(32805, 32338, 11),
    Position(32805, 32339, 11),
    Position(32806, 32339, 11),
    Position(32806, 32338, 11),
    Position(32807, 32338, 11),
    Position(32808, 32338, 11),
    Position(32808, 32337, 11),
    Position(32809, 32337, 11),
    Position(32810, 32337, 11),
    Position(32811, 32337, 11),
    Position(32811, 32338, 11),
    Position(32806, 32338, 11),
    Position(32810, 32338, 11),
    Position(32810, 32339, 11),
    Position(32809, 32339, 11),
    Position(32809, 32338, 11),
    Position(32811, 32336, 11),
    Position(32811, 32335, 11),
    Position(32810, 32335, 11),
    Position(32809, 32335, 11),
    Position(32808, 32335, 11),
    Position(32809, 32334, 11),
    Position(32809, 32333, 11),
    Position(32810, 32333, 11),
    Position(32811, 32333, 11),
    Position(32806, 32338, 11),
    Position(32810, 32334, 11),
    Position(32811, 32334, 11),
    Position(32812, 32334, 11),
    Position(32813, 32334, 11),
    Position(32812, 32333, 11),
    Position(32810, 32334, 11),
    Position(32812, 32335, 11),
    Position(32813, 32335, 11),
    Position(32813, 32333, 11)
}

function onUse(player, item, fromPosition, target, toPosition)
    if not target:isItem() then
        return false
    end

    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end

    local function handleRope()
        if table.contains(ropeSpots, ground:getId()) then
            player:teleportTo(toPosition:moveRel(0, 1, -1))
            return true
        elseif table.contains(holeSpots, ground:getId()) or target:getId() == 435 then
            local tileBelow = Tile(toPosition:moveRel(0, 0, 1))
            if not tileBelow then
                return false
            end

            local thing = tileBelow:getTopCreature() or tileBelow:getTopVisibleThing()
            if thing:isCreature() then
                thing:teleportTo(toPosition:moveRel(0, 1, -1), false)
                return true
            elseif thing:isItem() and thing:getType():isMovable() then
                thing:moveTo(toPosition:moveRel(0, 1, -1))
                return true
            end

            -- Roping items from holes
            local itemsBelow = tileBelow:getItems()
            if itemsBelow then
                for _, item in ipairs(itemsBelow) do
                    if item and item:isMovable() then
                        item:moveTo(toPosition:moveRel(0, 1, -1))
                    end
                end
            end
        end
        return false
    end

    local function handleShovel()
        if ground:getId() == 231 and math.random(1, 100) <= 10 then
            toPosition:sendMagicEffect(3)
            Game.createItem(3042, 1, toPosition)
            return true
        elseif ground:getId() == 231 and math.random(1, 100) <= 30 then
            toPosition:sendMagicEffect(3)
            Game.createMonster("scarab", toPosition)
            return true
        elseif ground:getId() == 231 then
            toPosition:sendMagicEffect(3)
            return true
        elseif target:getId() == 593 then
            target:transform(594, 1)
            target:decay()
            doRelocate(toPosition, toPosition:moveRel(0, 0, 1))
            return true
        elseif target:getId() == 606 then
            target:transform(607, 1)
            target:decay()
            doRelocate(toPosition, toPosition:moveRel(0, 0, 1))
            return true
        elseif target:getId() == 608 then
            target:transform(609, 1)
            target:decay()
            doRelocate(toPosition, toPosition:moveRel(0, 0, 1))
            return true
        elseif target:getId() == 614 and math.random(1, 100) <= 50 then
            target:transform(615, 1)
            target:decay()
            toPosition:sendMagicEffect(3)
            doRelocate(toPosition, toPosition:moveRel(0, 0, 1))
            return true
        elseif target:getId() == 614 then
            toPosition:sendMagicEffect(3)
            return true
        elseif target:getId() == 616 and math.random(1, 100) <= 95 then
            target:transform(617, 1)
            target:decay()
            toPosition:sendMagicEffect(3)
            Game.createMonster("scarab", toPosition)
            return true
        elseif target:getId() == 616 then
            toPosition:sendMagicEffect(3)
            Game.createItem(3042, 1, toPosition)
            target:transform(617, 1)
            target:decay()
            return true
        elseif target:getId() == 617 then
            toPosition:sendMagicEffect(3)
            return true
        end
        return false
    end

    local function handlePick()
        if ground:getId() == 372 then
            ground:transform(394, 1)
            ground:decay()
            return true
        elseif target:getId() == 1772 and toPosition.x == 32648 and toPosition.y == 32134 and toPosition.z == 10 and math.random(1, 100) <= 40 then
            toPosition:sendMagicEffect(3)
            Game.removeItemOnMap({x = 32648, y = 32134, z = 10}, 1772)
            return true
        elseif target:getId() == 1772 and toPosition.x == 32648 and toPosition.y == 32134 and toPosition.z == 10 then
            toPosition:sendMagicEffect(3)
            doTargetCombatHealth(0, player, COMBAT_PHYSICALDAMAGE, -40, -40)
            return true
        elseif target:getId() == 1791 and toPosition.x == 32356 and toPosition.y == 32074 and toPosition.z == 10 and math.random(1, 100) <= 40 then
            toPosition:sendMagicEffect(3)
            Game.removeItemOnMap({x = 32356, y = 32074, z = 10}, 1791)
            return true
        elseif target:getId() == 1791 and toPosition.x == 32356 and toPosition.y == 32074 and toPosition.z == 10 then
            toPosition:sendMagicEffect(3)
            doTargetCombatHealth(0, player, COMBAT_PHYSICALDAMAGE, -50, -50)
            return true
        elseif target:getActionId() == 17643 then
            for i = 1, #pitsOfInfernoLava do
                Game.createItem(5815, 1, pitsOfInfernoLava[i])
            end
            target:transform(3141)
            toPosition:sendMagicEffect(CONST_ME_POFF)
            return true
        end
        return false
    end

    local function handleMachete()
        if target:getId() == 3696 then
            target:transform(3695, 1)
            target:decay()
            return true
        elseif target:getId() == 3702 then
            target:transform(3701, 1)
            target:decay()
            return true
        elseif target:getId() == 2130 then
            target:remove()
            return true
        end
        return false
    end
    
    local function handleScythe()
        if target:getId() == 3652 then
            player:sendCancelMessage(target:getType():getDescription() .. ".")
            return true
        elseif target:getId() == 3653 then
            target:transform(3651, 1)
            target:decay()
            Game.createItem(3605, 1, target:getPosition())
            return true
        elseif target:getId() == 5463 then
            target:transform(5462, 1)
            target:decay()
            Game.createItem(5466, 1, target:getPosition())
        end
        return true
    end

    return handleRope() or handleShovel() or handlePick() or handleMachete() or handleScythe()
end

working in TFS 1.2 Sabrehaven.com based on Nostalrius, read and edit items id according to your items.
 
Back
Top