Untitled

 avatar
unknown
plain_text
20 days ago
10 kB
5
Indexable
local lootItemIds = {
    ["3281"] = "giant sword",
    ["3420"] = "demon shield",
    ["3364"] = "golden legs",
    ["3079"] = "boots of haste",
    ["3366"] = "magic plate armor",
    ["3386"] = "dragon scale mail",
    ["3320"] = "fire axe",
    ["3309"] = "thunder hammer",
    ["3422"] = "great shield",
    ["3392"] = "royal helmet",
    ["3414"] = "mastermind shield"
}

local ids = {}
local currentIdIdx = 0
local count = 0

for k, _ in pairs(lootItemIds) do
    count = count + 1
    ids[count] = k
end

macro(5000, "LOOT SELL", function()
    if not g_game.isOnline() then return end
    
    for idx, id in ipairs(ids) do
        if idx <= currentIdIdx then goto continue end
        currentIdIdx = idx
        local found = findItem(id)
        if found then
            say("!sell " .. lootItemIds[id])
            return
        end
        ::continue::
    end
    currentIdIdx = 0
end)

local lists = {
    ["Raid"] = {
        "Glejt", "Shop Point", "Giant Eye", "Exp Potion", "Loss Item Box",
        "Gold Ingot", "Farm Coin", "Crystal Coin", "undead heart", "Demoniczny Kamien"
    },
    ["Exp"] = {
        "exp potion", "boots of haste", "magic plate armor", "dragon scale mail",
        "fire axe", "gold ingot", "great shield", "Crystal Coin",
        "Farm Coin", "mastermind shield"
    }
}

local isAddingItems = false

local function addItemsWithDelay(items)
    if isAddingItems then return end
    isAddingItems = true

    local delay = 100
    say("!autoloot clear")
    
    for _, item in ipairs(items) do
        delay = delay + 3000
        schedule(delay, function()
            say("!autoloot add, " .. item)
        end)
    end
    
    schedule(delay + 100, function()
        isAddingItems = false
    end)
end

local tekst = "EXP"
local tekst2 = "TRYB: EXP"

local ikona = addIcon("ctrl", {
    item = 3039,
    text = tekst,
    pos = { x = 50, y = 20 }
}, function(widget, enabled)
    if enabled then
        CaveBot.setOff()
        TargetBot.setOff()
        addItemsWithDelay(lists["Raid"])
        storage._configs.cavebot_configs.selected = "miasto"
        storage._configs.targetbot_configs.selected = "Raid"
        CaveBot.setOn()
        TargetBot.setOn()
        tekst = "RAID"
        widget.text:setColor("orange")
    else
        CaveBot.setOff()
        TargetBot.setOff()
        addItemsWithDelay(lists["Exp"])
        storage._configs.cavebot_configs.selected = "bojowy_ogar_ch2_gora"
        storage._configs.targetbot_configs.selected = "Przyklad"
        CaveBot.setOn()
        TargetBot.setOn()
        tekst = "EXP"
        widget.text:setColor("blue")
    end
    widget.text:setText(tekst)
end)

local caveIcon = addIcon("cavebot", {
    item = 9018,
    text = "CaveBot",
    pos = { x = 20, y = 100 }
}, function(widget, enabled)
    if enabled then 
        CaveBot.setOn()
    else 
        CaveBot.setOff()
    end
end)

local targetIcon = addIcon("targetbot", {
    item = 7417,
    text = "TargetBot",
    pos = { x = 120, y = 100 }
}, function(widget, enabled)
    if enabled then
        TargetBot.setOn()
    else
        TargetBot.setOff()
    end
end)

local expbossicon
expbossicon = addIcon("expboss", {
    item = 8148,
    text = tekst2,
    pos = { x = 50, y = 180 }
}, function(widget, enabled)
    local currentProfile = AttackBot.getActiveProfile()
    if currentProfile == 1 then
        AttackBot.setActiveProfile(2)
        widget.text:setText("TARGET/BOSS")
        widget.text:setColor("pink")
    else
        AttackBot.setActiveProfile(1)
        widget.text:setText("UE/EXP")
        widget.text:setColor("blue")
    end
end)

local function updateBotStatuses()
    -- Aktualizacja CaveBot
    if CaveBot.isOn() then
        if caveIcon then
            caveIcon.text:setText("CaveBot: ON")
            caveIcon.text:setColor("green")
        end
    else
        if caveIcon then
            caveIcon.text:setText("CaveBot: OFF")
            caveIcon.text:setColor("red")
        end
    end

    -- Aktualizacja TargetBot
    if TargetBot.isOn() then
        if targetIcon then
            targetIcon.text:setText("TargetBot: ON")
            targetIcon.text:setColor("green")
        end
        AttackBot.setActiveProfile(1)  -- Jeśli TargetBot jest włączony, ustawiamy profil 1 (UE/EXP)
        if expbossicon then
            expbossicon.text:setText("UE/EXP")
            expbossicon.text:setColor("blue")
        end
    else
        if targetIcon then
            targetIcon.text:setText("TargetBot: OFF")
            targetIcon.text:setColor("red")
        end
        AttackBot.setActiveProfile(2)  -- Jeśli TargetBot jest wyłączony, ustawiamy profil 2 (TARGET/BOSS)
        if expbossicon then
            expbossicon.text:setText("TARGET/BOSS")
            expbossicon.text:setColor("pink")
        end
    end

    schedule(500, updateBotStatuses)  -- Odświeżaj status co 1 sekundę
end

updateBotStatuses()


macro(500, "Kopanie Kryształów", function()
    local activeCrystalId = 11821  -- ID aktywnego kryształu
    local inactiveCrystalId = 11822  -- ID nieaktywnego kryształu
    local playerPos = player:getPosition()
    local radius = 7

    -- Funkcja szukająca aktywnego kryształu
    local function findCrystal()
        for x = -radius, radius do
            for y = -radius, radius do
                local tilePos = {x = playerPos.x + x, y = playerPos.y + y, z = playerPos.z}
                local tile = g_map.getTile(tilePos)

                if tile then
                    for _, item in ipairs(tile:getItems()) do
                        if item:getId() == activeCrystalId then
                            return tilePos, item
                        end
                    end
                end
            end
        end
        return nil, nil
    end

    -- Funkcja, która sprawdza, czy kryształ jest aktywny
    local function isCrystalActive(crystal)
        return crystal:getId() == activeCrystalId
    end

    -- Funkcja wykonująca akcję, gdy znajdziemy kryształ
    local function handleCrystal()
        local pos, crystal = findCrystal()
        if pos and crystal then
            autoWalk(pos)  -- Przechodzimy do kryształu
            schedule(500, function()
                use(crystal)  -- Klikamy PPM na kryształ
            end)

            -- Czekamy na zakończenie kopania kryształu, następnie sprawdzamy, czy zmienił się na nieaktywny
            schedule(2000, function()
                if not isCrystalActive(crystal) then
                    -- Kryształ stał się nieaktywny, szukamy kolejnego aktywnego
                    handleCrystal()
                end
            end)
        end
    end

    -- Rozpoczynamy proces
    handleCrystal()
end)

macro(100, "Auto Cut Bushes", function()
    local MacheteID = 3308
    local BushID = 3702
    local playerPos = pos() -- Pobranie pozycji gracza jako oddzielna zmienna

    for x = -1, 1 do
        for y = -1, 1 do
            if x ~= 0 or y ~= 0 then
                local tile = g_map.getTile({x = playerPos.x + x, y = playerPos.y + y, z = playerPos.z})
                if tile then
                    for _, item in ipairs(tile:getItems() or {}) do
                        if item:getId() == BushID then
                            useWith(MacheteID, item)
                        end
                    end
                end
            end
        end
    end
end)

local holdMwallHotkey = '5'
local holdMwallText = 'Hold MWall'
local holdMwallTextCol = 'yellow'
local holdMwallTiles = {}
local holdMwallIsOn = false

onKeyPress(function(keys)
 if keys == holdMwallHotkey and holdMwallIsOn then
   local tile = getTileUnderCursor()
   local currTile = table.find(holdMwallTiles, tile)
   if currTile then
     holdMwallTiles[currTile]:setText('')
     table.remove(holdMwallTiles, currTile)
   else
     table.insert(holdMwallTiles, tile)
     holdMwallTiles[#holdMwallTiles]:setText(holdMwallText, holdMwallTextCol)
   end
 end
end)

addSwitch('holdMwall', 'Better Hold MWall', function(widget)
 widget:setOn(not widget:isOn())
 if not widget:isOn() then
   for i = 1, #holdMwallTiles do
     holdMwallTiles[1]:setText('')
     table.remove(holdMwallTiles, 1)
   end
 end
 holdMwallIsOn = widget:isOn()
end)

macro(1, function()
 if holdMwallIsOn then
   for _, holdMwallTile in pairs(holdMwallTiles) do
     if holdMwallTile:getTopThing():getId() ~= 2129 then
       useWith(3180, holdMwallTile:getTopUseThing())
       return
     end
   end
 end
end)

local key = "1" -- Hotkey to shoot mwall
local mwallId = 3180 -- Mwall ID
local squaresThreshold = 1 -- Amount of tiles to shoot infront of player

singlehotkey(key, "Mwall target", function()
 local target = g_game.getAttackingCreature()
 if target then
   local targetPos = target:getPosition()
   local targetDir = target:getDirection()
   local mwallTile
   if targetDir == 0 then -- north
     targetPos.y = targetPos.y - squaresThreshold
     mwallTile = g_map.getTile(targetPos)
     useWith(mwallId, mwallTile:getTopUseThing())
   elseif targetDir == 1 then -- east
     targetPos.x = targetPos.x + squaresThreshold
     mwallTile = g_map.getTile(targetPos)
     useWith(mwallId, mwallTile:getTopUseThing())
   elseif targetDir == 2 then -- south
     targetPos.y = targetPos.y + squaresThreshold
     mwallTile = g_map.getTile(targetPos)
     useWith(mwallId, mwallTile:getTopUseThing())
   elseif targetDir == 3 then -- west
     targetPos.x = targetPos.x - squaresThreshold
     mwallTile = g_map.getTile(targetPos)
     useWith(mwallId, mwallTile:getTopUseThing())
   end
 end
end)

local holdMwallHotkey = '2' -- Klawisz, którym będziesz rzucał MWall

-- Funkcja, która rzuca MWall tam, gdzie znajduje się kursor
singlehotkey(holdMwallHotkey, "Throw MWall", function()
  local tile = getTileUnderCursor() -- Uzyskujemy tile pod kursorem
  if tile then
    -- Używamy 'mwall' na odpowiednim obiekcie w miejscu kursora
    useWith(mwallId, tile:getTopUseThing())
  end
end)

Editor is loading...
Leave a Comment