Untitled

Anonymous
Plain Text
10/23/2025 8:19 AM
4.8 KB
21
Indexable
Never
-- config
local toFollow = "Vithrax"

-- data
local useId = {
    [34847] = true,
    [1764] = true,
    [21051] = true,
    [30823] = true,
    [6264] = true,
    [5282] = true,
    [20453] = true,
    [20454] = true,
    [20474] = true,
    [11708] = true,
    [11705] = true,
    [6257] = true,
    [6256] = true,
    [2772] = true,
    [27260] = true,
    [2773] = true,
    [1632] = true,
    [1633] = true,
    [1948] = true,
    [435] = true,
    [6252] = true,
    [6253] = true,
    [5007] = true,
    [4911] = true,
    [1629] = true,
    [1630] = true,
    [5108] = true,
    [5107] = true,
    [5281] = true,
    [1968] = true,
    [435] = true,
    [1948] = true,
    [5542] = true,
    [31116] = true,
    [31120] = true,
    [30742] = true,
    [31115] = true,
    [31118] = true,
    [20474] = true,
    [5737] = true,
    [5736] = true,
    [5734] = true,
    [5733] = true,
    [31202] = true,
    [31228] = true,
    [31199] = true,
    [31200] = true,
    [33262] = true,
    [30824] = true,
    [5125] = true,
    [5126] = true,
    [5116] = true,
    [5117] = true,
    [8257] = true,
    [8258] = true,
    [8255] = true,
    [8256] = true,
    [5120] = true,
    [30777] = true,
    [30776] = true,
    [23873] = true,
    [23877] = true,
    [5736] = true,
    [6264] = true,
    [31262] = true,
    [31130] = true,
    [31129] = true,
    [6250] = true,
    [6249] = true,
    [5122] = true,
    [30049] = true,
    [7131] = true,
    [7132] = true,
	[5102] = true,
	[5111] = true,
    [7727] = true
}
local shovelId = {
    [606] = true,
    [593] = true,
    [867] = true,
    [608] = true
}
local ropeId = {
    [17238] = true,
    [12202] = true,
    [12935] = true,
    [386] = true,
    [421] = true,
    [21966] = true,
    [14238] = true
}
local macheteId = {
    [2130] = true, 
    [3696] = true
}
local scytheId = {
    [3653] = true
}
local tables = {useId, shovelId, ropeId, macheteId, scytheId}
local settings = storage.extras
local movementHistory = {}
storage.vithraxFollow = storage.vithraxFollow or ''

-- functions
local function useAll()
    local tiles = getNearTiles(pos())
    table.insert(tiles, g_map.getTile(pos()))

    for _, tile in ipairs(tiles) do
        for __, item in ipairs(tile:getItems()) do
            local id = item:getId()
            for i, array in ipairs(tables) do
                if array[id] then
                    if i == 1 then
                        use(item)
                    elseif i == 2 then
                        useWith(settings.shovel, item)
                    elseif i == 3 then
                        useWith(settings.rope, item) 
                    elseif i == 4 then
                        useWith(settings.machete, item)
                    else
                        useWith(settings.scythe, item)
                    end
                    return true
                end
            end
        end
    end

    return false
end


local switch = macro(75, "Ultimate Follow:", function(macro)
    local target = getCreatureByName(storage.vithraxFollow)
    local tpos = target and target:getPosition()

    -- clear table, target is near you
    if tpos and getDistanceBetween(tpos,pos()) < 2 then
        movementHistory = {}
        return
    end
    local dest = movementHistory[posz()]

    -- position is not registered but target is on screen, so add it
    if tpos and not dest then
        local path = findPath(tpos, pos(), 20, { ignoreNonPathable = true, precision = 1 })
        if path then
            dest = tpos
        end
    end

    -- no registered position on current floor, maybe falled into some hole
    if not dest then
        if useAll() then
            return
        end
        delay(100)
    end

    -- reached position on current floor and still no target, maybe he ladder/rope or something
    if dest and getDistanceBetween(dest, pos()) == 0 then
        delay(100)
        useAll()
        return
    end

    local path = findPath(pos(), dest, 20, { ignoreNonPathable = true, precision = 1 })
    if not path then
        -- cant find a way to next waypoint, need to figure out some pathfinding option
        useAll()
        delay(100)
        return
    end

    -- probably reachable
    CaveBot.walkTo(dest, 20, { ignoreNonPathable = true, precision = target and 1 or 0 })
end)

UI.TextEdit(storage.vithraxFollow or 'Player Name', function(widget, newText)
    storage.vithraxFollow = newText
end)

onCreaturePositionChange(function(creature, oldPos, newPos)
    if switch.isOff() then return end
    if not newPos then return end
    if creature:getName():lower() ~= storage.vithraxFollow:lower():trim() then return end

    -- register position on current floor
    movementHistory[newPos.z] = newPos
end)
Editor is loading...
Leave a Comment