ZeroBot Documentation

website·Indexed 31 days ago

https://docs.zerobot.net

Comprehensive documentation for ZeroBot, featuring guides on CaveBot configuration, waypoint management, and a detailed Lua scripting API. The API includes modules for the Engine, Game, Player, Creature, Inventory, HUD, and Map, as well as support for game events and JSON serialization.

Tokens
28.9K
Snippets
184
Records
225
Agent score
49%

What's inside ZeroBot

  1. ZeroBot Modular Architecture Overview

    ZeroBot is organized into independent modules that can be configured and enabled separately. Because available controls and conditions vary based on the game-client version and the selected OTServer, users should validate any new profile on the target server before unattended use.
  2. Manage Magic Shooter profiles

    Use these Engine functions to switch between and retrieve information about Magic Shooter profiles. Profiles are indexed from 0 to 9.
    -- Switch to a specific profile index (0-9)
    Engine.magicShooterSwitchProfile(profileIndex)
    
    -- Get the index of the currently selected profile
    local currentProfile = Engine.magicShooterGetProfile()
    
    -- Get the name of a profile by its index (0-9)
    local profileName = Engine.magicShooterGetProfileName(index)
  3. Understand CaveBot navigation and waypoint logic

    CaveBot manages character navigation by following a sequence of waypoints. A waypoint can be defined as a destination, a floor-change action, a lure transition, a label/jump, or a Lua script. Note that CaveBot only handles movement; combat and survival behaviors (such as healing and equipment) must be configured via separate modules like Healing, Targeting, Magic Shooter, and Equipment.
  4. Manage Hunting Tasks using the TaskBoard API

    The TaskBoard API (requiring protocol 15.20+) provides methods to interact with Bounty, Weekly, and Shop windows. Because these actions are stateful, you must open the corresponding window and wait for the Game.Events.TASK_BOARD_DATA event to receive a complete server snapshot before performing actions. ZeroBot caches these snapshots separately for Bounty, Weekly, and Shop, and clears them upon disconnect.

    Return values for these methods are true if the request was accepted by the packet sender, or nil if the protocol is unsupported, a snapshot is missing, or a state check fails. A true return does not guarantee the server completed the action.

    local function onHuntingTasksData(data)
        if not data.complete then
            return
        end
    
        if data.windowType == Enums.TaskBoardWindow.BOUNTY then
            for _, task in ipairs(data.bounty.tasks) do
                -- task.index is the zero-based server index
                print("bounty", task.index, task.raceId, task.currentKills)
            end
        elseif data.windowType == Enums.TaskBoardWindow.WEEKLY then
            for _, task in ipairs(data.weekly.deliveryTasks) do
                print("delivery", task.index, task.itemId, task.availableItems)
            end
        elseif data.windowType == Enums.TaskBoardWindow.SHOP then
            print("offer count", data.shop.offerCount)
        end
    end
    
    Game.registerEvent(Game.Events.TASK_BOARD_DATA, onHuntingTasksData)
    Game.openTaskBoardBounty()
  5. Handle Task Board data events

    Listen for Game.Events.TASK_BOARD_DATA (value 22) to receive updates about the Task Board state. The callback provides a table containing windowType (from Enums.TaskBoardWindow), a complete boolean, and a data table specific to the window (bounty, weekly, or shop).

    Important: Do not process the data if complete is false.

    Window Types (Enums.TaskBoardWindow):

    • BOUNTY = 0
    • WEEKLY = 1
    • SHOP = 2
  6. Access static item and monster data

    Retrieve comprehensive data about items and monsters available in the client. Client.getAllItems() returns a table of items with id and flags (use Enums.ThingFlagAttr for bitwise checks). Client.getAllMonsters() returns a list of all monsters, while Client.getMonsterByRaceId(raceId) retrieves specific data for a single monster race.
    -- Check if an item is on the ground
    local items = Client.getAllItems()
    for _, item in pairs(items) do
        local isGround = bit.band(item.flags, Enums.ThingFlagAttr.Ground) ~= 0
    end
    
    -- Get specific monster info
    local monster = Client.getMonsterByRaceId(1234)
    print("Monster Name: " .. monster.name)
  7. Query map tiles and items

    Retrieve information about tiles and the items (things) located at specific coordinates on the map.
    -- Get all map tiles on screen
    -- @return A table of all tiles containing things and their position.
    Map.getTiles()
    
    -- Get the things at a specific map position.
    -- @param x, y, z (number) - Coordinates
    -- @return A table of things at the specified position, or nil if tile doesn't exist.
    Map.getThings(x, y, z)
    
    -- Get the count of things at a specific map position.
    -- @param x, y, z (number) - Coordinates
    -- @return Things count, or nil if tile doesn't exist.
    Map.getThingsCount(x, y, z)
  8. Retrieve container and item information

    Methods to get metadata about the container, its capacity, and the items it contains.
    local index = container:getIndex()
    local name = container:getName()
    local items = container:getItems() -- Returns a table of items
    local capacity = container:getCapacity()
    local totalItems = container:getItemCount()
    local countById = container:getItemCountById(itemId)
  9. Use Sell Loot and Refill quick action buttons

    The CaveBot Options window includes 'Sell Loot' and 'Refill' buttons. These are helper tools that do not use a unique Enums.WaypointType; instead, they automatically generate a Node waypoint followed by a Script waypoint.

    • Sell Loot: Sells non-equipped items matching the current Sell List via an open NPC shop.
    • Refill: Uses the current Refill List to replenish items. Refill entries follow the format: {id=ITEM_ID,min=MIN_COUNT,max=MAX_COUNT}.

    Because NPC dialogs, prices, and action limits vary between OT servers, you should review the generated script and test it with the target NPC.

    {id=268,min=100,max=500}
  10. Move items from a container

    The Container class provides three methods to move items out of a container: to the player's inventory, to a specific map coordinate (ground), or to another open container.
    -- Move to inventory
    container:moveItemToInventory(containerSlot, inventorySlot, itemCount)
    
    -- Move to ground
    container:moveItemToGround(containerSlot, itemCount, toX, toY, toZ)
    
    -- Move to another container
    container:moveItemToContainer(containerSlot, itemCount, toContainerIndex, toContainerSlot)
  11. Manage CaveBot configurations

    Use the main control buttons to manage your CaveBot setup:

    • Load: Import a saved configuration file.
    • Save: Save the current configuration.
    • New: Clear the current configuration to start over (unsaved changes will be lost).
    • Settings: Access advanced configuration options.
    • Special Areas: Open the area editor to define regions the bot should avoid.
    • Enable Waypoint Colors: Visually distinguish between different waypoint types.
    • Encrypt CaveBot on Save: Encrypts the configuration file. Note: Encrypted files cannot be converted back to readable form; maintain an unencrypted backup.
  12. Register and unregister game events

    Use Game.registerEvent to attach a callback function to a specific game event and Game.unregisterEvent to remove it. You must pass the same function reference to both methods.
    local function onTalk(authorName, authorLevel, talkType, x, y, z, text, channelId)
        print(authorName, text)
    end
    
    -- Register the event
    Game.registerEvent(Game.Events.TALK, onTalk)
    
    -- Later: Unregister the event
    Game.unregisterEvent(Game.Events.TALK, onTalk)