Updated to OTCv8 3.0 rev 91

This commit is contained in:
OTCv8 2021-07-18 11:09:50 +00:00
parent e2e56f82ed
commit de2ac3e972
102 changed files with 3050 additions and 2654 deletions

View File

@ -475,9 +475,9 @@ function initCallbacks()
onOpenChannel = botOpenChannel,
onCloseChannel = botCloseChannel,
onChannelEvent = botChannelEvent,
onImbuementWindow = botOnImbuementWindow,
onModalDialog = botOnModalDialog,
onAttackingCreatureChange = botOnAttackingCreatureChange
onImbuementWindow = botImbuementWindow,
onModalDialog = botModalDialog,
onAttackingCreatureChange = botAttackingCreatureChange,
})
connect(Tile, {
@ -499,12 +499,15 @@ function initCallbacks()
onHealthPercentChange = botCraetureHealthPercentChange,
onTurn = botCreatureTurn,
onWalk = botCreatureWalk,
onManaChange = botManaChange,
onStatesChange = botStatesChange
})
connect(Container, {
onOpen = botContainerOpen,
onClose = botContainerClose,
onUpdateItem = botContainerUpdateItem
onUpdateItem = botContainerUpdateItem,
onAddItem = botContainerAddItem,
})
connect(g_map, {
@ -531,9 +534,9 @@ function terminateCallbacks()
onOpenChannel = botOpenChannel,
onCloseChannel = botCloseChannel,
onChannelEvent = botChannelEvent,
onImbuementWindow = botOnImbuementWindow,
onModalDialog = botOnModalDialog,
onAttackingCreatureChange = botOnAttackingCreatureChange
onImbuementWindow = botImbuementWindow,
onModalDialog = botModalDialog,
onAttackingCreatureChange = botAttackingCreatureChange
})
disconnect(Tile, {
@ -555,12 +558,15 @@ function terminateCallbacks()
onHealthPercentChange = botCraetureHealthPercentChange,
onTurn = botCreatureTurn,
onWalk = botCreatureWalk,
onManaChange = botManaChange,
onStatesChange = botStatesChange
})
disconnect(Container, {
onOpen = botContainerOpen,
onClose = botContainerClose,
onUpdateItem = botContainerUpdateItem
onUpdateItem = botContainerUpdateItem,
onAddItem = botContainerAddItem,
})
disconnect(g_map, {
@ -660,9 +666,9 @@ function botContainerClose(container)
safeBotCall(function() botExecutor.callbacks.onContainerClose(container) end)
end
function botContainerUpdateItem(container, slot, item)
function botContainerUpdateItem(container, slot, item, oldItem)
if botExecutor == nil then return false end
safeBotCall(function() botExecutor.callbacks.onContainerUpdateItem(container, slot, item) end)
safeBotCall(function() botExecutor.callbacks.onContainerUpdateItem(container, slot, item, oldItem) end)
end
function botOnMissle(missle)
@ -710,17 +716,32 @@ function botCreatureWalk(creature, oldPos, newPos)
safeBotCall(function() botExecutor.callbacks.onWalk(creature, oldPos, newPos) end)
end
function botOnImbuementWindow(itemId, slots, activeSlots, imbuements, needItems)
function botImbuementWindow(itemId, slots, activeSlots, imbuements, needItems)
if botExecutor == nil then return false end
safeBotCall(function() botExecutor.callbacks.onImbuementWindow(itemId, slots, activeSlots, imbuements, needItems) end)
end
function botOnModalDialog(id, title, message, buttons, enterButton, escapeButton, choices, priority)
function botModalDialog(id, title, message, buttons, enterButton, escapeButton, choices, priority)
if botExecutor == nil then return false end
safeBotCall(function() botExecutor.callbacks.onModalDialog(id, title, message, buttons, enterButton, escapeButton, choices, priority) end)
end
function botOnAttackingCreatureChange(creature, oldCreature)
function botAttackingCreatureChange(creature, oldCreature)
if botExecutor == nil then return false end
safeBotCall(function() botExecutor.callbacks.onAttackingCreatureChange(creature,oldCreature) end)
end
function botManaChange(player, mana, maxMana, oldMana, oldMaxMana)
if botExecutor == nil then return false end
safeBotCall(function() botExecutor.callbacks.onManaChange(player, mana, maxMana, oldMana, oldMaxMana) end)
end
function botStatesChange(states, oldStates)
if botExecutor == nil then return false end
safeBotCall(function() botExecutor.callbacks.onStatesChange(states, oldStates) end)
end
function botContainerAddItem(container, slot, item)
if botExecutor == nil then return false end
safeBotCall(function() botExecutor.callbacks.onAddItem(container, slot, item) end)
end

View File

@ -1,57 +0,0 @@
-- load all otui files, order doesn't matter
local configName = modules.game_bot.contentsPanel.config:getCurrentOption().text
local configFiles = g_resources.listDirectoryFiles("/bot/" .. configName .."/vBot/", true, false)
for i, file in ipairs(configFiles) do
local ext = file:split(".")
if ext[#ext]:lower() == "ui" or ext[#ext]:lower() == "otui" then
g_ui.importStyle(file)
end
end
local function loadScript(name)
return dofile("/vBot/" .. name .. ".lua")
end
-- here you can set manually order of scripts
-- libraries should be loaded first
local luaFiles = {
"main",
"vlib",
"new_cavebot_lib",
"configs", -- do not change this and above
"extras",
"playerlist",
"BotServer",
"alarms",
"Conditions",
"pushmax",
"combo",
"HealBot",
"Sio",
"AttackBot", -- last of major modules
"ingame_editor",
"items_management",
"quiver_manager",
"tools",
"antiRs",
"cavebot",
"depot_withdraw",
"eat_food",
"equip",
"exeta",
"info",
"items",
"jewellery_equipper",
"spy_level",
"supplies"
}
for i, file in ipairs(luaFiles) do
loadScript(file)
end
setDefaultTab("Main")
UI.Separator()
UI.Label("Private Scripts:")
UI.Separator()

View File

@ -1,188 +0,0 @@
CaveBot.Extensions.DWithdraw = {}
comparePosition = function(pPos, tPos)
return (getDistanceBetween(pPos, tPos) <= 1)
end
local depotIDs = {3497, 3498, 3499, 3500}
local depotContainers = {22797, 22798, 22799, 22800, 22801, 22802, 22803, 22804, 22805, 22806, 22807, 22808, 22809, 22810, 22811, 22812, 22813}
storage.stopSearch = false
storage.lootContainerOpen = false
local i = 1
CaveBot.Extensions.DWithdraw.setup = function()
CaveBot.registerAction("dpwithdraw", "#002FFF", function(value, retries)
local capLimit = nil
if retries > 600 then
print("CaveBot[DepotWithdraw]: actions limit reached, proceeding")
return true
end
delay(50)
if not value or #string.split(value, ",") ~= 3 and #string.split(value, ",") ~= 4 then
warn("CaveBot[DepotWithdraw]: incorrect value!")
return false
end
local indexDp = tonumber(string.split(value, ",")[1]:trim())
local destName = string.split(value, ",")[2]:trim()
local destId = tonumber(string.split(value, ",")[3]:trim())
if #string.split(value, ",") == 4 then
capLimit = tonumber(string.split(value, ",")[4]:trim())
end
if freecap() < (capLimit or 200) then
print("CaveBot[DepotWithdraw]: cap limit reached, proceeding")
return true
end
local destContainer
for i, container in pairs(getContainers()) do
if container:getName():lower() == destName:lower() then
destContainer = container
end
if string.find(container:getName():lower(), "depot box") then
if #container:getItems() == 0 then
print("CaveBot[DepotWithdraw]: all items withdrawn")
return true
end
end
end
if not destContainer then
print("CaveBot[DepotWithdraw]: container not found!")
return false
end
if destContainer:getCapacity() == destContainer:getSize() then
for j, item in pairs(destContainer:getItems()) do
if item:getId() == destId then
g_game.open(item, destContainer)
return "retry"
end
end
print("CaveBot[DepotWithdraw]: loot containers full!")
return true
end
local tileList = {}
local tPos
local depotClear = false
local depotOpen = false
local depotBoxOpen = false
for _,tile in pairs(g_map.getTiles(posz())) do
for i,thing in pairs(tile:getThings()) do
if table.find(depotIDs, thing:getId()) then
table.insert(tileList, {tileObj = tile, distance = getDistanceBetween(pos(), tile:getPosition()), depotID = thing:getId()})
end
end
end
table.sort(tileList, function(a,b) return a.distance < b.distance end)
::findEmptyDP::
if tileList[i] and not storage.stopSearch then
if tileList[i].depotID == 3498 then
tPos = {x = tileList[i].tileObj:getPosition().x + 1, y = tileList[i].tileObj:getPosition().y, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3499 then
tPos = {x = tileList[i].tileObj:getPosition().x, y = tileList[i].tileObj:getPosition().y + 1, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3500 then
tPos = {x = tileList[i].tileObj:getPosition().x - 1, y = tileList[i].tileObj:getPosition().y, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3497 then
tPos = {x = tileList[i].tileObj:getPosition().x, y = tileList[i].tileObj:getPosition().y - 1, z = tileList[i].tileObj:getPosition().z}
end
if tPos then
local dest = g_map.getTile(tPos)
if not comparePosition(pos(), dest:getPosition()) then
if not dest:getCreatures()[1] and dest:isWalkable() then
if CaveBot.walkTo(dest:getPosition(), {ignoreNonPathable=true}) then
storage.stopSearch = true
delay(100)
end
else
i = i + 1
goto findEmptyDP
end
end
end
end
if tileList[i].tileObj and not table.find(depotIDs, tileList[i].tileObj:getTopLookThing():getId()) and comparePosition(pos(), tileList[i].tileObj:getPosition()) then
for j=1,table.getn(tileList[i].tileObj:getThings()),1 do
if not tileList[i].tileObj:getThings()[j]:isNotMoveable() then
delay(500)
g_game.move(tileList[i].tileObj:getThings()[j], pos(), tileList[i].tileObj:getThings()[j]:getCount())
end
end
if table.find(depotIDs, tileList[i].tileObj:getTopLookThing():getId()) then
depotClear = true
end
else
depotClear = true
end
if depotClear then
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "locker" then
depotOpen = true
end
end
end
if tileList[i].tileObj and depotClear and not depotOpen and not storage.lootContainerOpen then
delay(500)
g_game.use(tileList[i].tileObj:getTopUseThing())
depotOpen = true
end
i = 1
--Version Check to know what to do with the depot--
if g_game.getClientVersion() > 910 then
if depotOpen then
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "depot chest" then
depotBoxOpen = true
end
end
if findItem(3502) and not depotBoxOpen then
delay(500)
g_game.use(findItem(3502))
depotBoxOpen = true
end
end
if depotBoxOpen and not storage.lootContainerOpen then
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "depot chest" then
for _, item in ipairs(container:getItems()) do
if item:isContainer() and table.find({22797, 22798}, item:getId()) then
g_game.open(findItem(depotContainers[indexDp]), container)
delay(500)
for _, cont in pairs(g_game.getContainers()) do
if string.find(cont:getName():lower(), "depot box") then
storage.lootContainerOpen = true
break
end
end
end
end
break
end
end
end
for i, container in pairs(g_game.getContainers()) do
if string.find(container:getName():lower(), "depot box") then
for j, item in ipairs(container:getItems()) do
g_game.move(item, destContainer:getSlotPosition(destContainer:getItemsCount()), item:getCount())
return "retry"
end
end
end
end
return "retry"
end)
CaveBot.Editor.registerAction("dpwithdraw", "dpwithdraw", {
value="1, shopping bag, 21411",
title="Loot Withdraw",
description="insert index, destination container name and it's ID",
})
end
onPlayerPositionChange(function(newPos, oldPos)
storage.lootContainerOpen = false
storage.stopSearch = false
end)

View File

@ -1,384 +0,0 @@
CaveBot.Extensions.Depositor = {}
local depotIDs = {3497, 3498, 3499, 3500}
local reset = function()
storage.stopSearch = false
storage.lootContainerOpen = false
storage.containersClosed = false
storage.containersReset = false
storage.currentStack = 0
storage.currentNonStack = nonStackMin
storage.lastTry = nil
storage.lootItemsCount = 0
storage.depositDone = false
end
local i = 1
local ifPing = function()
if ping() and ping() > 150 then
return ping()
else
return 1
end
end
CaveBot.Extensions.Depositor.setup = function()
CaveBot.registerAction("depositor", "#002FFF", function(value, retries)
if retries > 400 then
print("CaveBot[Depositor]: Depositor actions limit reached, proceeding")
reset()
return true
end
local name = storage["_configs"]["targetbot_configs"]["selected"]
local file = configDir .. "/targetbot_configs/" .. name .. ".json"
local data = g_resources.readFileContents(file)
local lootList = Config.parse(data)['looting']['items']
local lootContainers = Config.parse(data)['looting']['containers']
local mainBp
local stackBp
local nonStackBp
local valueString = string.split(value, ",") -- if 3 then it's old tibia
-- if old tibia then setup backpacks
if #valueString == 3 then
mainBp = tonumber(valueString[1]:trim())
stackBp = tonumber(valueString[2]:trim()) -- non-stack bp count
nonStackBp = tonumber(valueString[3]:trim()) -- stack bp count
if not mainBp or not stackBp or not nonStackBp then
warn("CaveBot[Depositor]: incorrect values! should be 3x ID of containers!")
reset()
return false
end
end
-- start with checking the containers
local lootDestination = {}
for _, container in pairs(lootContainers) do
if not table.find(lootDestination, container['id']) then
table.insert(lootDestination, container['id'])
end
end
-- pretty much every container action is needed only if you want to work with containers
if (value:lower() == "yes" or #valueString == 3) and not storage.containersReset then
-- what is open and what's not
local currentContainers = {}
for i, container in pairs(getContainers()) do
if not table.find(currentContainers, container:getContainerItem():getId()) then
table.insert(currentContainers, container:getContainerItem():getId())
end
end
delay(500 + 2*ifPing()) -- slow down this function until containers reset
if #lootDestination > 0 then
-- first closing all that are opened
if not storage.containersClosed then
for i, container in pairs(getContainers()) do
if table.find(lootDestination, container:getContainerItem():getId()) then
g_game.close(container)
return "retry"
end
end
storage.containersClosed = true
end
-- now reopen them
if not storage.containersReset and storage.containersClosed then
for i, container in pairs(getContainers()) do
for j, item in pairs(container:getItems()) do
if table.find(lootDestination, item:getId()) and not table.find(currentContainers, item:getId()) then
g_game.open(item)
return "retry"
end
end
end
storage.containersReset = true
end
end
end
if storage.depositDone then
reset()
print("CaveBot[Depositor]: Deposit finished, proceeding")
return true
end
local tileList = {}
local tPos
local depotClear = false
local depotOpen = false
local depotBoxOpen = false
for _,tile in pairs(g_map.getTiles(posz())) do
for i,thing in pairs(tile:getThings()) do
if table.find(depotIDs, thing:getId()) then
table.insert(tileList, {tileObj = tile, distance = getDistanceBetween(pos(), tile:getPosition()), depotID = thing:getId()})
end
end
end
table.sort(tileList, function(a,b) return a.distance < b.distance end)
::findEmptyDP::
if tileList[i] and not storage.stopSearch then
if tileList[i].depotID == 3498 then
tPos = {x = tileList[i].tileObj:getPosition().x + 1, y = tileList[i].tileObj:getPosition().y, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3499 then
tPos = {x = tileList[i].tileObj:getPosition().x, y = tileList[i].tileObj:getPosition().y + 1, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3500 then
tPos = {x = tileList[i].tileObj:getPosition().x - 1, y = tileList[i].tileObj:getPosition().y, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3497 then
tPos = {x = tileList[i].tileObj:getPosition().x, y = tileList[i].tileObj:getPosition().y - 1, z = tileList[i].tileObj:getPosition().z}
end
if tPos then
local dest = g_map.getTile(tPos)
if not (getDistanceBetween(pos(), dest:getPosition()) <= 1) then
if not dest:getCreatures()[1] and dest:isWalkable() then
if CaveBot.walkTo(dest:getPosition(), {ignoreNonPathable=true}) then
storage.stopSearch = true
delay(100+ifPing())
end
else
i = i + 1
goto findEmptyDP
end
end
end
end
if tileList[i] and not table.find(depotIDs, tileList[i].tileObj:getTopLookThing():getId()) and (getDistanceBetween(pos(), tileList[i].tileObj:getPosition()) <= 1) then
for j=1,table.getn(tileList[i].tileObj:getThings()),1 do
if not tileList[i].tileObj:getThings()[j]:isNotMoveable() then
delay(500+2*ifPing())
g_game.move(tileList[i].tileObj:getThings()[j], pos(), tileList[i].tileObj:getThings()[j]:getCount())
end
end
if table.find(depotIDs, tileList[i].tileObj:getTopLookThing():getId()) then
depotClear = true
end
else
depotClear = true
end
if depotClear then
for _, container in pairs(getContainers()) do
if container:getName():lower() == "locker" then
depotOpen = true
end
end
end
if tileList[i] and depotClear and not depotOpen and not storage.lootContainerOpen then
delay(500+2*ifPing())
g_game.use(tileList[i].tileObj:getTopUseThing())
depotOpen = true
end
i = 1
-- finding depot
if depotOpen then
for _, container in pairs(getContainers()) do
if container:getName():lower() == "depot chest" then
depotBoxOpen = true
end
end
if findItem(3502) and not depotBoxOpen then
delay(500+2*ifPing())
g_game.use(findItem(3502))
depotBoxOpen = true
end
end
if depotBoxOpen and not storage.lootContainerOpen then
for _, container in pairs(getContainers()) do
if container:getName():lower() == "depot chest" then
for _, item in ipairs(container:getItems()) do
if #valueString ~= 3 then -- new depot
if item:isContainer() and table.find({22797, 22798}, item:getId()) then
delay(500+2*ifPing())
storage.lootContainerOpen = true
break
end
else
if item:isContainer() and item:getId() == mainBp then
delay(500+2*ifPing())
g_game.use(item, container)
storage.lootContainerOpen = true
break
end
end
end
break
end
end
end
if #valueString == 3 then
delay(150+ifPing())
for _, container in pairs(getContainers()) do
if container:getContainerItem():getId() == mainBp then
storage.lootContainerOpen = true
storage.isDepositing = true
break
end
end
end
local looting = {}
for _, lootItem in pairs(lootList) do
if not table.find(looting, lootItem['id']) and not table.find({3031, 3035, 3043}, lootItem['id']) then
table.insert(looting, lootItem['id'])
end
end
delay(200+ifPing())
local currentItems = 0
for _, container in pairs(getContainers()) do
for _, item in ipairs(container:getItems()) do
if table.find(looting, item:getId()) then
currentItems = currentItems + item:getCount()
end
end
end
if currentItems == 0 then
if value:lower() ~= "yes" and #valueString ~= 3 then
storage.containersClosed = false
storage.containersReset = false
storage.depositDone = true
return "retry"
end
for i, container in pairs(getContainers()) do
for j, item in pairs(container:getItems()) do
if table.find(lootDestination, container:getContainerItem():getId()) and table.find(lootDestination, item:getId()) then
g_game.open(item, container)
return "retry"
end
end
end
storage.containersClosed = false
storage.containersReset = false
storage.depositDone = true
return "retry"
end
-- only if old depot
local stackMin
local stackMax
local nonStackMin
local nonStackMax
if #valueString == 3 then
-- backpacks setup
local stack = 0
local nonStack = 0
for i, container in pairs(getContainers()) do
if container:getContainerItem():getId() == mainBp then
for i, item in pairs(container:getItems()) do
if item:getId() == stackBp then
stack = stack + 1
elseif item:getId() == nonStackBp then
nonStack = nonStack + 1
end
end
end
end
stackMax = stack - 1
nonStackMin = stack
nonStackMax = (stack + nonStack) - 1
storage.currentStack = 0
storage.currentNonStack = nonStackMin
if storage.lootItemsCount == currentItems then
if storage.lastTry == 1 then
if storage.currentStack < stackMax then
storage.currentStack = storage.currentStack + 1
else
warn("CaveBot[Depositer]: Stack Backpack full! Proceeding.")
reset()
return true
end
elseif storage.lastTry == 2 then
if storage.currentNonStack < nonStackMax then
storage.currentNonStack = storage.currentNonStack + 1
else
warn("CaveBot[Depositer]: Non-Stack Backpack full! Proceeding.")
reset()
return true
end
end
end
storage.lootItemsCount = currentItems
end
if #looting > 0 then
if #valueString ~= 3 then -- version check, if value is set of 3 i
for i, depotcontainer in pairs(getContainers()) do
containerItemId = depotcontainer:getContainerItem():getId()
--check if open depot
if containerItemId == 3502 then
-- check all containers and items
for l, lootcontainer in pairs(getContainers()) do
for j, item in ipairs(lootcontainer:getItems()) do
-- now the criteria
if table.find(looting, item:getId()) then
-- move the item
if item:isStackable() then
g_game.move(item, depotcontainer:getSlotPosition(1), item:getCount())
return "retry"
else
g_game.move(item, depotcontainer:getSlotPosition(0), item:getCount())
return "retry"
end
end
end
end
end
end
else -- to be written, last part missing is stashing items for old depots
for i, depotcontainer in pairs(getContainers()) do
containerItemId = depotcontainer:getContainerItem():getId()
--check if open depot
if containerItemId == mainBp then
-- check all containers and items
for l, lootcontainer in pairs(getContainers()) do
for j, item in ipairs(lootcontainer:getItems()) do
-- now the criteria
if table.find(looting, item:getId()) then
-- move the item
if item:isStackable() then
g_game.move(item, depotcontainer:getSlotPosition(storage.currentStack), item:getCount())
storage.lastTry = 1
return "retry"
else
g_game.move(item, depotcontainer:getSlotPosition(storage.currentNonStack), item:getCount())
storage.lastTry = 2
return "retry"
end
end
end
end
end
end
end
else
warn("no items in looting list!")
reset()
return false
end
return "retry"
end)
CaveBot.Editor.registerAction("depositor", "depositor", {
value="no",
title="Depositor",
description="No - just deposit \n Yes - also reopen loot containers \n mainID, stackId, nonStackId - for older tibia",
})
end
onPlayerPositionChange(function(newPos, oldPos)
if CaveBot.isOn() then
reset()
end
end)

View File

@ -1,184 +0,0 @@
CaveBot.Extensions.InWithdraw = {}
comparePosition = function(pPos, tPos)
return (getDistanceBetween(pPos, tPos) <= 1)
end
local depotIDs = {3497, 3498, 3499, 3500}
storage.stopSearch = false
storage.inboxContainerOpen = false
local i = 1
CaveBot.Extensions.InWithdraw.setup = function()
CaveBot.registerAction("inwithdraw", "#002FFF", function(value, retries)
local data = string.split(value, ",")
local withdrawId
local count
local itemCount = 0
local depotAmount = 0
if #data ~= 2 then
warn("CaveBot[InboxWithdraw]: incorrect withdraw value")
return false
else
withdrawId = tonumber(data[1])
count = tonumber(data[2])
end
for i, container in pairs(getContainers()) do
if not string.find(container:getName():lower(), "inbox") then
for j, item in pairs(container:getItems()) do
if item:getId() == withdrawId then
itemCount = itemCount + item:getCount()
end
end
end
end
if itemCount >= count then
for i, container in pairs(getContainers()) do
if string.find(container:getName():lower(), "your inbox") then
g_game.close(container)
end
end
print("CaveBot[InboxWithdraw]: enough items, proceeding")
return true
end
if retries > 400 then
print("CaveBot[InboxWithdraw]: actions limit reached, proceeding")
return true
end
delay(200)
local tileList = {}
local tPos
local depotClear = false
local depotOpen = false
local depotBoxOpen = false
for _,tile in pairs(g_map.getTiles(posz())) do
for i,thing in pairs(tile:getThings()) do
if table.find(depotIDs, thing:getId()) then
table.insert(tileList, {tileObj = tile, distance = getDistanceBetween(pos(), tile:getPosition()), depotID = thing:getId()})
end
end
end
table.sort(tileList, function(a,b) return a.distance < b.distance end)
::findEmptyDP::
if tileList[i] and not storage.stopSearch then
if tileList[i].depotID == 3498 then
tPos = {x = tileList[i].tileObj:getPosition().x + 1, y = tileList[i].tileObj:getPosition().y, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3499 then
tPos = {x = tileList[i].tileObj:getPosition().x, y = tileList[i].tileObj:getPosition().y + 1, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3500 then
tPos = {x = tileList[i].tileObj:getPosition().x - 1, y = tileList[i].tileObj:getPosition().y, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3497 then
tPos = {x = tileList[i].tileObj:getPosition().x, y = tileList[i].tileObj:getPosition().y - 1, z = tileList[i].tileObj:getPosition().z}
end
if tPos then
local dest = g_map.getTile(tPos)
if not comparePosition(pos(), dest:getPosition()) then
if not dest:getCreatures()[1] and dest:isWalkable() then
if CaveBot.walkTo(dest:getPosition(), {ignoreNonPathable=true}) then
storage.stopSearch = true
delay(100)
end
else
i = i + 1
goto findEmptyDP
end
end
end
end
if tileList[i].tileObj and not table.find(depotIDs, tileList[i].tileObj:getTopLookThing():getId()) and comparePosition(pos(), tileList[i].tileObj:getPosition()) then
for j=1,table.getn(tileList[i].tileObj:getThings()),1 do
if not tileList[i].tileObj:getThings()[j]:isNotMoveable() then
delay(500)
g_game.move(tileList[i].tileObj:getThings()[j], pos(), tileList[i].tileObj:getThings()[j]:getCount())
end
end
if table.find(depotIDs, tileList[i].tileObj:getTopLookThing():getId()) then
depotClear = true
end
else
depotClear = true
end
if depotClear then
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "locker" then
depotOpen = true
end
end
end
if tileList[i].tileObj and depotClear and not depotOpen and not storage.inboxContainerOpen then
delay(500)
g_game.use(tileList[i].tileObj:getTopUseThing())
depotOpen = true
end
i = 1
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "your inbox" then
depotBoxOpen = true
end
end
if depotOpen and not depotBoxOpen then
if findItem(12902) then
delay(500)
g_game.use(findItem(12902))
depotBoxOpen = true
end
end
if depotBoxOpen and not storage.inboxContainerOpen then
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "your" then
storage.inboxContainerOpen = true
end
end
end
delay(500)
for i, container in pairs(getContainers()) do
if string.find(container:getName():lower(), "your") then
for j, item in pairs(container:getItems()) do
if item:getId() == withdrawId then
depotAmount = depotAmount + item:getCount()
end
end
break
end
end
local destination
for i, container in pairs(getContainers()) do
if container:getCapacity() > #container:getItems() and not string.find(container:getName():lower(), "quiver") and not string.find(container:getName():lower(), "depot") and not string.find(container:getName():lower(), "loot") and not string.find(container:getName():lower(), "inbox") then
destination = container
end
end
if itemCount < count and destination then
for i, container in pairs(getContainers()) do
if string.find(container:getName():lower(), "your inbox") then
for j, item in pairs(container:getItems()) do
if item:getId() == withdrawId then
if item:isStackable() then
g_game.move(item, destination:getSlotPosition(destination:getItemsCount()), math.min(item:getCount(), (count - itemCount)))
return "retry"
else
g_game.move(item, destination:getSlotPosition(destination:getItemsCount()), 1)
return "retry"
end
return "retry"
end
end
end
end
end
return "retry"
end)
CaveBot.Editor.registerAction("inwithdraw", "in withdraw", {
value="id,amount",
title="Withdraw Items",
description="insert item id and amount",
})
end

View File

@ -1,71 +0,0 @@
CaveBot.Extensions.SupplyCheck = {}
SuppliesConfig.supplyRetries = 0
CaveBot.Extensions.SupplyCheck.setup = function()
CaveBot.registerAction("supplyCheck", "#db5a5a", function(value)
local supplies = SuppliesConfig[suppliesPanelName]
local softCount = itemAmount(6529) + itemAmount(3549)
local totalItem1 = itemAmount(supplies.item1)
local totalItem2 = itemAmount(supplies.item2)
local totalItem3 = itemAmount(supplies.item3)
local totalItem4 = itemAmount(supplies.item4)
local totalItem5 = itemAmount(supplies.item5)
local totalItem6 = itemAmount(supplies.item6)
if SuppliesConfig.supplyRetries > 50 then
print("CaveBot[SupplyCheck]: Round limit reached, going back on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (supplies.imbues and player:getSkillLevel(11) == 0) then
print("CaveBot[SupplyCheck]: Imbues ran out. Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (supplies.staminaSwitch and stamina() < tonumber(supplies.staminaValue)) then
print("CaveBot[SupplyCheck]: Stamina ran out. Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (softCount < 1 and supplies.SoftBoots) then
print("CaveBot[SupplyCheck]: No soft boots left. Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (totalItem1 < tonumber(supplies.item1Min) and supplies.item1 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item1 .. "(only " .. totalItem1 .. " left). Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (totalItem2 < tonumber(supplies.item2Min) and supplies.item2 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item2 .. "(only " .. totalItem2 .. " left). Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (totalItem3 < tonumber(supplies.item3Min) and supplies.item3 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item3 .. "(only " .. totalItem3 .. " left). Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (totalItem4 < tonumber(supplies.item4Min) and supplies.item4 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item4 .. "(only " .. totalItem4 .. " left). Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (totalItem5 < tonumber(supplies.item5Min) and supplies.item5 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item5 .. "(only " .. totalItem5 .. " left). Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (totalItem6 < tonumber(supplies.item6Min) and supplies.item6 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item6 .. "(only " .. totalItem6 .. " left). Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
elseif (freecap() < tonumber(supplies.capValue) and supplies.capSwitch) then
print("CaveBot[SupplyCheck]: Not enough capacity. Going on refill.")
SuppliesConfig.supplyRetries = 0
return false
else
print("CaveBot[SupplyCheck]: Enough supplies. Hunting. Round (" .. SuppliesConfig.supplyRetries .. "/50)")
SuppliesConfig.supplyRetries = SuppliesConfig.supplyRetries + 1
return CaveBot.gotoLabel(value)
end
end)
CaveBot.Editor.registerAction("supplycheck", "supply check", {
value="startHunt",
title="Supply check label",
description="Insert here hunting start label",
})
end

View File

@ -1,221 +0,0 @@
CaveBot.Extensions.Withdraw = {}
comparePosition = function(pPos, tPos)
return (getDistanceBetween(pPos, tPos) <= 1)
end
local depotContainers = {22797, 22798, 22799, 22800, 22801, 22802, 22803, 22804, 22805, 22806, 22807, 22808, 22809, 22810, 22811, 22812, 22813}
local depotIDs = {3497, 3498, 3499, 3500}
storage.stopSearch = false
storage.lootContainerOpen = false
local i = 1
CaveBot.Extensions.Withdraw.setup = function()
CaveBot.registerAction("withdraw", "#002FFF", function(value, retries)
local data = string.split(value, ",")
local stashIndex
local withdrawId
local count
local itemCount = 0
local depotAmount
if #data ~= 3 then
warn("incorrect withdraw value")
return false
else
stashIndex = tonumber(data[1])
withdrawId = tonumber(data[2])
count = tonumber(data[3])
end
local withdrawSource = depotContainers[stashIndex]
for i, container in pairs(getContainers()) do
if not string.find(container:getName():lower(), "depot") then
for j, item in pairs(container:getItems()) do
if item:getId() == withdrawId then
itemCount = itemCount + item:getCount()
end
end
end
end
if itemCount >= count then
for i, container in pairs(getContainers()) do
if string.find(container:getName():lower(), "depot box") then
g_game.close(container)
end
end
print("enough items")
return true
end
if retries > 400 then
return true
end
delay(200)
local tileList = {}
local tPos
local depotClear = false
local depotOpen = false
local depotBoxOpen = false
for _,tile in pairs(g_map.getTiles(posz())) do
for i,thing in pairs(tile:getThings()) do
if table.find(depotIDs, thing:getId()) then
table.insert(tileList, {tileObj = tile, distance = getDistanceBetween(pos(), tile:getPosition()), depotID = thing:getId()})
end
end
end
table.sort(tileList, function(a,b) return a.distance < b.distance end)
::findEmptyDP::
if tileList[i] and not storage.stopSearch then
if tileList[i].depotID == 3498 then
tPos = {x = tileList[i].tileObj:getPosition().x + 1, y = tileList[i].tileObj:getPosition().y, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3499 then
tPos = {x = tileList[i].tileObj:getPosition().x, y = tileList[i].tileObj:getPosition().y + 1, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3500 then
tPos = {x = tileList[i].tileObj:getPosition().x - 1, y = tileList[i].tileObj:getPosition().y, z = tileList[i].tileObj:getPosition().z}
elseif tileList[i].depotID == 3497 then
tPos = {x = tileList[i].tileObj:getPosition().x, y = tileList[i].tileObj:getPosition().y - 1, z = tileList[i].tileObj:getPosition().z}
end
if tPos then
local dest = g_map.getTile(tPos)
if not comparePosition(pos(), dest:getPosition()) then
if not dest:getCreatures()[1] and dest:isWalkable() then
if CaveBot.walkTo(dest:getPosition(), {ignoreNonPathable=true}) then
storage.stopSearch = true
delay(100)
end
else
i = i + 1
goto findEmptyDP
end
end
end
end
if tileList[i].tileObj and not table.find(depotIDs, tileList[i].tileObj:getTopLookThing():getId()) and comparePosition(pos(), tileList[i].tileObj:getPosition()) then
for j=1,table.getn(tileList[i].tileObj:getThings()),1 do
if not tileList[i].tileObj:getThings()[j]:isNotMoveable() then
delay(500)
g_game.move(tileList[i].tileObj:getThings()[j], pos(), tileList[i].tileObj:getThings()[j]:getCount())
end
end
if table.find(depotIDs, tileList[i].tileObj:getTopLookThing():getId()) then
depotClear = true
end
else
depotClear = true
end
if depotClear then
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "locker" then
depotOpen = true
end
end
end
if tileList[i].tileObj and depotClear and not depotOpen and not storage.lootContainerOpen then
delay(500)
g_game.use(tileList[i].tileObj:getTopUseThing())
depotOpen = true
end
i = 1
--Version Check to know what to do with the depot--
if g_game.getClientVersion() > 910 then
if depotOpen then
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "depot chest" then
depotBoxOpen = true
end
end
if findItem(3502) and not depotBoxOpen then
delay(500)
g_game.use(findItem(3502))
depotBoxOpen = true
end
end
if depotBoxOpen and not storage.lootContainerOpen then
for _, container in pairs(g_game.getContainers()) do
if container:getName():lower() == "depot chest" then
for _, item in ipairs(container:getItems()) do
if item:isContainer() and table.find({22797, 22798}, item:getId()) then
delay(500)
storage.lootContainerOpen = true
break
end
end
break
end
end
end
local boxOpened = false
for _, container in pairs(getContainers()) do
if string.find(container:getName():lower(), "depot box") then
boxOpened = true
end
end
if not boxOpened then
for _, container in pairs(getContainers()) do
if container:getName():lower() == "depot chest" then
for _, item in pairs(container:getItems()) do
if item:getId() == withdrawSource then
g_game.open(item)
break
end
end
end
end
end
for i, container in pairs(getContainers()) do
if string.find(container:getName():lower(), "depot") then
for j, item in pairs(container:getItems()) do
if item:getId() == withdrawId then
depotAmount = depotAmount + item:getCount()
end
end
break
end
end
if depotAmount == 0 then
print("lack of withdraw items!")
return false
end
local destination
for i, container in pairs(getContainers()) do
if container:getCapacity() > #container:getItems() and not string.find(container:getName():lower(), "quiver") and not string.find(container:getName():lower(), "depot") and not string.find(container:getName():lower(), "loot") and not string.find(container:getName():lower(), "inbox") then
destination = container
end
end
if itemCount < count and destination then
for i, container in pairs(getContainers()) do
if string.find(container:getName():lower(), "depot box") then
for j, item in pairs(container:getItems()) do
if item:getId() == withdrawId then
if item:isStackable() then
g_game.move(item, destination:getSlotPosition(destination:getItemsCount()), math.min(item:getCount(), (count - itemCount)))
return "retry"
else
g_game.move(item, destination:getSlotPosition(destination:getItemsCount()), 1)
return "retry"
end
return "retry"
end
end
end
end
end
return "retry"
end
end)
CaveBot.Editor.registerAction("withdraw", "withdraw", {
value="index,id,amount",
title="Withdraw Items",
description="insert source index, item id and amount",
})
end

View File

@ -1,247 +0,0 @@
setDefaultTab("HP")
local conditionPanelName = "ConditionPanel"
local ui = setupUI([[
Panel
height: 19
BotSwitch
id: title
anchors.top: parent.top
anchors.left: parent.left
text-align: center
width: 130
!text: tr('Conditions')
Button
id: conditionList
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 3
height: 17
text: Setup
]])
ui:setId(conditionPanelName)
if not HealBotConfig[conditionPanelName] then
HealBotConfig[conditionPanelName] = {
enabled = false,
curePosion = false,
poisonCost = 20,
cureCurse = false,
curseCost = 80,
cureBleed = false,
bleedCost = 45,
cureBurn = false,
burnCost = 30,
cureElectrify = false,
electrifyCost = 22,
cureParalyse = false,
paralyseCost = 40,
paralyseSpell = "utani hur",
holdHaste = false,
hasteCost = 40,
hasteSpell = "utani hur",
holdUtamo = false,
utamoCost = 40,
holdUtana = false,
utanaCost = 440,
holdUtura = false,
uturaType = "",
uturaCost = 100,
ignoreInPz = true,
stopHaste = false
}
end
ui.title:setOn(HealBotConfig[conditionPanelName].enabled)
ui.title.onClick = function(widget)
HealBotConfig[conditionPanelName].enabled = not HealBotConfig[conditionPanelName].enabled
widget:setOn(HealBotConfig[conditionPanelName].enabled)
vBotConfigSave("heal")
end
ui.conditionList.onClick = function(widget)
conditionsWindow:show()
conditionsWindow:raise()
conditionsWindow:focus()
end
local rootWidget = g_ui.getRootWidget()
if rootWidget then
conditionsWindow = UI.createWindow('ConditionsWindow', rootWidget)
conditionsWindow:hide()
-- text edits
conditionsWindow.Cure.PoisonCost:setText(HealBotConfig[conditionPanelName].poisonCost)
conditionsWindow.Cure.PoisonCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].poisonCost = tonumber(text)
end
conditionsWindow.Cure.CurseCost:setText(HealBotConfig[conditionPanelName].curseCost)
conditionsWindow.Cure.CurseCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].curseCost = tonumber(text)
end
conditionsWindow.Cure.BleedCost:setText(HealBotConfig[conditionPanelName].bleedCost)
conditionsWindow.Cure.BleedCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].bleedCost = tonumber(text)
end
conditionsWindow.Cure.BurnCost:setText(HealBotConfig[conditionPanelName].burnCost)
conditionsWindow.Cure.BurnCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].burnCost = tonumber(text)
end
conditionsWindow.Cure.ElectrifyCost:setText(HealBotConfig[conditionPanelName].electrifyCost)
conditionsWindow.Cure.ElectrifyCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].electrifyCost = tonumber(text)
end
conditionsWindow.Cure.ParalyseCost:setText(HealBotConfig[conditionPanelName].paralyseCost)
conditionsWindow.Cure.ParalyseCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].paralyseCost = tonumber(text)
end
conditionsWindow.Cure.ParalyseSpell:setText(HealBotConfig[conditionPanelName].paralyseSpell)
conditionsWindow.Cure.ParalyseSpell.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].paralyseSpell = text
end
conditionsWindow.Hold.HasteSpell:setText(HealBotConfig[conditionPanelName].hasteSpell)
conditionsWindow.Hold.HasteSpell.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].hasteSpell = text
end
conditionsWindow.Hold.HasteCost:setText(HealBotConfig[conditionPanelName].hasteCost)
conditionsWindow.Hold.HasteCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].hasteCost = tonumber(text)
end
conditionsWindow.Hold.UtamoCost:setText(HealBotConfig[conditionPanelName].utamoCost)
conditionsWindow.Hold.UtamoCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].utamoCost = tonumber(text)
end
conditionsWindow.Hold.UtanaCost:setText(HealBotConfig[conditionPanelName].utanaCost)
conditionsWindow.Hold.UtanaCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].utanaCost = tonumber(text)
end
conditionsWindow.Hold.UturaCost:setText(HealBotConfig[conditionPanelName].uturaCost)
conditionsWindow.Hold.UturaCost.onTextChange = function(widget, text)
HealBotConfig[conditionPanelName].uturaCost = tonumber(text)
end
-- combo box
conditionsWindow.Hold.UturaType:setOption(HealBotConfig[conditionPanelName].uturaType)
conditionsWindow.Hold.UturaType.onOptionChange = function(widget)
HealBotConfig[conditionPanelName].uturaType = widget:getCurrentOption().text
end
-- checkboxes
conditionsWindow.Cure.CurePoison:setChecked(HealBotConfig[conditionPanelName].curePoison)
conditionsWindow.Cure.CurePoison.onClick = function(widget)
HealBotConfig[conditionPanelName].curePoison = not HealBotConfig[conditionPanelName].curePoison
widget:setChecked(HealBotConfig[conditionPanelName].curePoison)
end
conditionsWindow.Cure.CureCurse:setChecked(HealBotConfig[conditionPanelName].cureCurse)
conditionsWindow.Cure.CureCurse.onClick = function(widget)
HealBotConfig[conditionPanelName].cureCurse = not HealBotConfig[conditionPanelName].cureCurse
widget:setChecked(HealBotConfig[conditionPanelName].cureCurse)
end
conditionsWindow.Cure.CureBleed:setChecked(HealBotConfig[conditionPanelName].cureBleed)
conditionsWindow.Cure.CureBleed.onClick = function(widget)
HealBotConfig[conditionPanelName].cureBleed = not HealBotConfig[conditionPanelName].cureBleed
widget:setChecked(HealBotConfig[conditionPanelName].cureBleed)
end
conditionsWindow.Cure.CureBurn:setChecked(HealBotConfig[conditionPanelName].cureBurn)
conditionsWindow.Cure.CureBurn.onClick = function(widget)
HealBotConfig[conditionPanelName].cureBurn = not HealBotConfig[conditionPanelName].cureBurn
widget:setChecked(HealBotConfig[conditionPanelName].cureBurn)
end
conditionsWindow.Cure.CureElectrify:setChecked(HealBotConfig[conditionPanelName].cureElectrify)
conditionsWindow.Cure.CureElectrify.onClick = function(widget)
HealBotConfig[conditionPanelName].cureElectrify = not HealBotConfig[conditionPanelName].cureElectrify
widget:setChecked(HealBotConfig[conditionPanelName].cureElectrify)
end
conditionsWindow.Cure.CureParalyse:setChecked(HealBotConfig[conditionPanelName].cureParalyse)
conditionsWindow.Cure.CureParalyse.onClick = function(widget)
HealBotConfig[conditionPanelName].cureParalyse = not HealBotConfig[conditionPanelName].cureParalyse
widget:setChecked(HealBotConfig[conditionPanelName].cureParalyse)
end
conditionsWindow.Hold.HoldHaste:setChecked(HealBotConfig[conditionPanelName].holdHaste)
conditionsWindow.Hold.HoldHaste.onClick = function(widget)
HealBotConfig[conditionPanelName].holdHaste = not HealBotConfig[conditionPanelName].holdHaste
widget:setChecked(HealBotConfig[conditionPanelName].holdHaste)
end
conditionsWindow.Hold.HoldUtamo:setChecked(HealBotConfig[conditionPanelName].holdUtamo)
conditionsWindow.Hold.HoldUtamo.onClick = function(widget)
HealBotConfig[conditionPanelName].holdUtamo = not HealBotConfig[conditionPanelName].holdUtamo
widget:setChecked(HealBotConfig[conditionPanelName].holdUtamo)
end
conditionsWindow.Hold.HoldUtana:setChecked(HealBotConfig[conditionPanelName].holdUtana)
conditionsWindow.Hold.HoldUtana.onClick = function(widget)
HealBotConfig[conditionPanelName].holdUtana = not HealBotConfig[conditionPanelName].holdUtana
widget:setChecked(HealBotConfig[conditionPanelName].holdUtana)
end
conditionsWindow.Hold.HoldUtura:setChecked(HealBotConfig[conditionPanelName].holdUtura)
conditionsWindow.Hold.HoldUtura.onClick = function(widget)
HealBotConfig[conditionPanelName].holdUtura = not HealBotConfig[conditionPanelName].holdUtura
widget:setChecked(HealBotConfig[conditionPanelName].holdUtura)
end
conditionsWindow.Hold.IgnoreInPz:setChecked(HealBotConfig[conditionPanelName].ignoreInPz)
conditionsWindow.Hold.IgnoreInPz.onClick = function(widget)
HealBotConfig[conditionPanelName].ignoreInPz = not HealBotConfig[conditionPanelName].ignoreInPz
widget:setChecked(HealBotConfig[conditionPanelName].ignoreInPz)
end
conditionsWindow.Hold.StopHaste:setChecked(HealBotConfig[conditionPanelName].stopHaste)
conditionsWindow.Hold.StopHaste.onClick = function(widget)
HealBotConfig[conditionPanelName].stopHaste = not HealBotConfig[conditionPanelName].stopHaste
widget:setChecked(HealBotConfig[conditionPanelName].stopHaste)
end
-- buttons
conditionsWindow.closeButton.onClick = function(widget)
conditionsWindow:hide()
vBotConfigSave("heal")
end
end
local utanaCast = nil
macro(500, function()
if not HealBotConfig[conditionPanelName].enabled or modules.game_cooldown.isGroupCooldownIconActive(2) then return end
if hppercent() > 95 then
if HealBotConfig[conditionPanelName].curePoison and mana() >= HealBotConfig[conditionPanelName].poisonCost and isPoisioned() then say("exana pox")
elseif HealBotConfig[conditionPanelName].cureCurse and mana() >= HealBotConfig[conditionPanelName].curseCost and isCursed() then say("exana mort")
elseif HealBotConfig[conditionPanelName].cureBleed and mana() >= HealBotConfig[conditionPanelName].bleedCost and isBleeding() then say("exana kor")
elseif HealBotConfig[conditionPanelName].cureBurn and mana() >= HealBotConfig[conditionPanelName].burnCost and isBurning() then say("exana flam")
elseif HealBotConfig[conditionPanelName].cureElectrify and mana() >= HealBotConfig[conditionPanelName].electrifyCost and isEnergized() then say("exana vis")
end
end
if (not HealBotConfig[conditionPanelName].ignoreInPz or not isInPz()) and HealBotConfig[conditionPanelName].holdUtura and mana() >= HealBotConfig[conditionPanelName].uturaCost and not hasPartyBuff() then say(HealBotConfig[conditionPanelName].uturaType)
elseif (not HealBotConfig[conditionPanelName].ignoreInPz or not isInPz()) and HealBotConfig[conditionPanelName].holdUtana and mana() >= HealBotConfig[conditionPanelName].utanaCost and (not utanaCast or (now - utanaCast > 120000)) then say("utana vid") utanaCast = now
end
end)
macro(50, function()
if not HealBotConfig[conditionPanelName].enabled then return end
if (not HealBotConfig[conditionPanelName].ignoreInPz or not isInPz()) and HealBotConfig[conditionPanelName].holdUtamo and mana() >= HealBotConfig[conditionPanelName].utamoCost and not hasManaShield() then say("utamo vita")
elseif (not HealBotConfig[conditionPanelName].ignoreInPz or not isInPz()) and HealBotConfig[conditionPanelName].holdHaste and mana() >= HealBotConfig[conditionPanelName].hasteCost and not hasHaste() and not getSpellCoolDown(HealBotConfig[conditionPanelName].hasteSpell) and (not target() or not HealBotConfig[conditionPanelName].stopHaste or TargetBot.isCaveBotActionAllowed()) then say(HealBotConfig[conditionPanelName].hasteSpell)
elseif HealBotConfig[conditionPanelName].cureParalyse and mana() >= HealBotConfig[conditionPanelName].paralyseCost and isParalyzed() and not getSpellCoolDown(HealBotConfig[conditionPanelName].paralyseSpell) then say(HealBotConfig[conditionPanelName].paralyseSpell)
end
end)

View File

@ -1,178 +0,0 @@
alarmsPanelName = "alarms"
local ui = setupUI([[
Panel
height: 19
BotSwitch
id: title
anchors.top: parent.top
anchors.left: parent.left
text-align: center
width: 130
!text: tr('Alarms')
Button
id: alerts
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 3
height: 17
text: Edit
]])
ui:setId(alarmsPanelName)
if not storage[alarmsPanelName] then
storage[alarmsPanelName] = {
enabled = false,
playerAttack = false,
playerDetected = false,
playerDetectedLogout = false,
creatureDetected = false,
healthBelow = false,
healthValue = 40,
manaBelow = false,
manaValue = 50,
privateMessage = false
}
end
ui.title:setOn(storage[alarmsPanelName].enabled)
ui.title.onClick = function(widget)
storage[alarmsPanelName].enabled = not storage[alarmsPanelName].enabled
widget:setOn(storage[alarmsPanelName].enabled)
end
rootWidget = g_ui.getRootWidget()
if rootWidget then
alarmsWindow = UI.createWindow('AlarmsWindow', rootWidget)
alarmsWindow:hide()
alarmsWindow.closeButton.onClick = function(widget)
alarmsWindow:hide()
end
alarmsWindow.playerAttack:setOn(storage[alarmsPanelName].playerAttack)
alarmsWindow.playerAttack.onClick = function(widget)
storage[alarmsPanelName].playerAttack = not storage[alarmsPanelName].playerAttack
widget:setOn(storage[alarmsPanelName].playerAttack)
end
alarmsWindow.playerDetected:setOn(storage[alarmsPanelName].playerDetected)
alarmsWindow.playerDetected.onClick = function(widget)
storage[alarmsPanelName].playerDetected = not storage[alarmsPanelName].playerDetected
widget:setOn(storage[alarmsPanelName].playerDetected)
end
alarmsWindow.playerDetectedLogout:setChecked(storage[alarmsPanelName].playerDetectedLogout)
alarmsWindow.playerDetectedLogout.onClick = function(widget)
storage[alarmsPanelName].playerDetectedLogout = not storage[alarmsPanelName].playerDetectedLogout
widget:setChecked(storage[alarmsPanelName].playerDetectedLogout)
end
alarmsWindow.creatureDetected:setOn(storage[alarmsPanelName].creatureDetected)
alarmsWindow.creatureDetected.onClick = function(widget)
storage[alarmsPanelName].creatureDetected = not storage[alarmsPanelName].creatureDetected
widget:setOn(storage[alarmsPanelName].creatureDetected)
end
alarmsWindow.healthBelow:setOn(storage[alarmsPanelName].healthBelow)
alarmsWindow.healthBelow.onClick = function(widget)
storage[alarmsPanelName].healthBelow = not storage[alarmsPanelName].healthBelow
widget:setOn(storage[alarmsPanelName].healthBelow)
end
alarmsWindow.healthValue.onValueChange = function(scroll, value)
storage[alarmsPanelName].healthValue = value
alarmsWindow.healthBelow:setText("Health < " .. storage[alarmsPanelName].healthValue .. "%")
end
alarmsWindow.healthValue:setValue(storage[alarmsPanelName].healthValue)
alarmsWindow.manaBelow:setOn(storage[alarmsPanelName].manaBelow)
alarmsWindow.manaBelow.onClick = function(widget)
storage[alarmsPanelName].manaBelow = not storage[alarmsPanelName].manaBelow
widget:setOn(storage[alarmsPanelName].manaBelow)
end
alarmsWindow.manaValue.onValueChange = function(scroll, value)
storage[alarmsPanelName].manaValue = value
alarmsWindow.manaBelow:setText("Mana < " .. storage[alarmsPanelName].manaValue .. "%")
end
alarmsWindow.manaValue:setValue(storage[alarmsPanelName].manaValue)
alarmsWindow.privateMessage:setOn(storage[alarmsPanelName].privateMessage)
alarmsWindow.privateMessage.onClick = function(widget)
storage[alarmsPanelName].privateMessage = not storage[alarmsPanelName].privateMessage
widget:setOn(storage[alarmsPanelName].privateMessage)
end
onTextMessage(function(mode, text)
if storage[alarmsPanelName].enabled and storage[alarmsPanelName].playerAttack and mode == 16 and string.match(text, "hitpoints due to an attack") and not string.match(text, "hitpoints due to an attack by a ") then
playSound("/sounds/Player_Attack.ogg")
end
end)
macro(100, function()
if not storage[alarmsPanelName].enabled then
return
end
if storage[alarmsPanelName].playerDetected then
for _, spec in ipairs(getSpectators()) do
if spec:isPlayer() and spec:getName() ~= name() then
specPos = spec:getPosition()
if math.max(math.abs(posx()-specPos.x), math.abs(posy()-specPos.y)) <= 8 then
playSound("/sounds/Player_Detected.ogg")
delay(1500)
if storage[alarmsPanelName].playerDetectedLogout then
modules.game_interface.tryLogout(false)
end
return
end
end
end
end
if storage[alarmsPanelName].creatureDetected then
for _, spec in ipairs(getSpectators()) do
if not spec:isPlayer()then
specPos = spec:getPosition()
if math.max(math.abs(posx()-specPos.x), math.abs(posy()-specPos.y)) <= 8 then
playSound("/sounds/Creature_Detected.ogg")
delay(1500)
return
end
end
end
end
if storage[alarmsPanelName].healthBelow then
if hppercent() <= storage[alarmsPanelName].healthValue then
playSound("/sounds/Low_Health.ogg")
delay(1500)
return
end
end
if storage[alarmsPanelName].manaBelow then
if manapercent() <= storage[alarmsPanelName].manaValue then
playSound("/sounds/Low_Mana.ogg")
delay(1500)
return
end
end
end)
onTalk(function(name, level, mode, text, channelId, pos)
if mode == 4 and storage[alarmsPanelName].enabled and storage[alarmsPanelName].privateMessage then
playSound("/sounds/Private_Message.ogg")
return
end
end)
end
ui.alerts.onClick = function(widget)
alarmsWindow:show()
alarmsWindow:raise()
alarmsWindow:focus()
end

View File

@ -1,441 +0,0 @@
setDefaultTab("Main")
ComboPanelName = "combobot"
local ui = setupUI([[
Panel
height: 19
BotSwitch
id: title
anchors.top: parent.top
anchors.left: parent.left
text-align: center
width: 130
!text: tr('ComboBot')
Button
id: combos
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 3
height: 17
text: Setup
]])
ui:setId(ComboPanelName)
if not storage[ComboPanelName] then
storage[ComboPanelName] = {
enabled = false,
onSayEnabled = false,
onShootEnabled = false,
onCastEnabled = false,
followLeaderEnabled = false,
attackLeaderTargetEnabled = false,
attackSpellEnabled = false,
attackItemToggle = false,
sayLeader = "",
shootLeader = "",
castLeader = "",
sayPhrase = "",
spell = "",
serverLeader = "",
item = 3155,
attack = "",
follow = "",
commandsEnabled = true,
serverEnabled = false,
serverLeaderTarget = false,
serverTriggers = true
}
end
ui.title:setOn(storage[ComboPanelName].enabled)
ui.title.onClick = function(widget)
storage[ComboPanelName].enabled = not storage[ComboPanelName].enabled
widget:setOn(storage[ComboPanelName].enabled)
end
ui.combos.onClick = function(widget)
comboWindow:show()
comboWindow:raise()
comboWindow:focus()
end
rootWidget = g_ui.getRootWidget()
if rootWidget then
comboWindow = UI.createWindow('ComboWindow', rootWidget)
comboWindow:hide()
-- bot item
comboWindow.actions.attackItem:setItemId(storage[ComboPanelName].item)
comboWindow.actions.attackItem.onItemChange = function(widget)
storage[ComboPanelName].item = widget:getItemId()
end
-- switches
comboWindow.actions.commandsToggle:setOn(storage[ComboPanelName].commandsEnabled)
comboWindow.actions.commandsToggle.onClick = function(widget)
storage[ComboPanelName].commandsEnabled = not storage[ComboPanelName].commandsEnabled
widget:setOn(storage[ComboPanelName].commandsEnabled)
end
comboWindow.server.botServerToggle:setOn(storage[ComboPanelName].serverEnabled)
comboWindow.server.botServerToggle.onClick = function(widget)
storage[ComboPanelName].serverEnabled = not storage[ComboPanelName].serverEnabled
widget:setOn(storage[ComboPanelName].serverEnabled)
end
comboWindow.server.Triggers:setOn(storage[ComboPanelName].serverTriggers)
comboWindow.server.Triggers.onClick = function(widget)
storage[ComboPanelName].serverTriggers = not storage[ComboPanelName].serverTriggers
widget:setOn(storage[ComboPanelName].serverTriggers)
end
comboWindow.server.targetServerLeaderToggle:setOn(storage[ComboPanelName].serverLeaderTarget)
comboWindow.server.targetServerLeaderToggle.onClick = function(widget)
storage[ComboPanelName].serverLeaderTarget = not storage[ComboPanelName].serverLeaderTarget
widget:setOn(storage[ComboPanelName].serverLeaderTarget)
end
-- buttons
comboWindow.closeButton.onClick = function(widget)
comboWindow:hide()
end
-- combo boxes
comboWindow.actions.followLeader:setOption(storage[ComboPanelName].follow)
comboWindow.actions.followLeader.onOptionChange = function(widget)
storage[ComboPanelName].follow = widget:getCurrentOption().text
end
comboWindow.actions.attackLeaderTarget:setOption(storage[ComboPanelName].attack)
comboWindow.actions.attackLeaderTarget.onOptionChange = function(widget)
storage[ComboPanelName].attack = widget:getCurrentOption().text
end
-- checkboxes
comboWindow.trigger.onSayToggle:setChecked(storage[ComboPanelName].onSayEnabled)
comboWindow.trigger.onSayToggle.onClick = function(widget)
storage[ComboPanelName].onSayEnabled = not storage[ComboPanelName].onSayEnabled
widget:setChecked(storage[ComboPanelName].onSayEnabled)
end
comboWindow.trigger.onShootToggle:setChecked(storage[ComboPanelName].onShootEnabled)
comboWindow.trigger.onShootToggle.onClick = function(widget)
storage[ComboPanelName].onShootEnabled = not storage[ComboPanelName].onShootEnabled
widget:setChecked(storage[ComboPanelName].onShootEnabled)
end
comboWindow.trigger.onCastToggle:setChecked(storage[ComboPanelName].onCastEnabled)
comboWindow.trigger.onCastToggle.onClick = function(widget)
storage[ComboPanelName].onCastEnabled = not storage[ComboPanelName].onCastEnabled
widget:setChecked(storage[ComboPanelName].onCastEnabled)
end
comboWindow.actions.followLeaderToggle:setChecked(storage[ComboPanelName].followLeaderEnabled)
comboWindow.actions.followLeaderToggle.onClick = function(widget)
storage[ComboPanelName].followLeaderEnabled = not storage[ComboPanelName].followLeaderEnabled
widget:setChecked(storage[ComboPanelName].followLeaderEnabled)
end
comboWindow.actions.attackLeaderTargetToggle:setChecked(storage[ComboPanelName].attackLeaderTargetEnabled)
comboWindow.actions.attackLeaderTargetToggle.onClick = function(widget)
storage[ComboPanelName].attackLeaderTargetEnabled = not storage[ComboPanelName].attackLeaderTargetEnabled
widget:setChecked(storage[ComboPanelName].attackLeaderTargetEnabled)
end
comboWindow.actions.attackSpellToggle:setChecked(storage[ComboPanelName].attackSpellEnabled)
comboWindow.actions.attackSpellToggle.onClick = function(widget)
storage[ComboPanelName].attackSpellEnabled = not storage[ComboPanelName].attackSpellEnabled
widget:setChecked(storage[ComboPanelName].attackSpellEnabled)
end
comboWindow.actions.attackItemToggle:setChecked(storage[ComboPanelName].attackItemEnabled)
comboWindow.actions.attackItemToggle.onClick = function(widget)
storage[ComboPanelName].attackItemEnabled = not storage[ComboPanelName].attackItemEnabled
widget:setChecked(storage[ComboPanelName].attackItemEnabled)
end
-- text edits
comboWindow.trigger.onSayLeader:setText(storage[ComboPanelName].sayLeader)
comboWindow.trigger.onSayLeader.onTextChange = function(widget, text)
storage[ComboPanelName].sayLeader = text
end
comboWindow.trigger.onShootLeader:setText(storage[ComboPanelName].shootLeader)
comboWindow.trigger.onShootLeader.onTextChange = function(widget, text)
storage[ComboPanelName].shootLeader = text
end
comboWindow.trigger.onCastLeader:setText(storage[ComboPanelName].castLeader)
comboWindow.trigger.onCastLeader.onTextChange = function(widget, text)
storage[ComboPanelName].castLeader = text
end
comboWindow.trigger.onSayPhrase:setText(storage[ComboPanelName].sayPhrase)
comboWindow.trigger.onSayPhrase.onTextChange = function(widget, text)
storage[ComboPanelName].sayPhrase = text
end
comboWindow.actions.attackSpell:setText(storage[ComboPanelName].spell)
comboWindow.actions.attackSpell.onTextChange = function(widget, text)
storage[ComboPanelName].spell = text
end
comboWindow.server.botServerLeader:setText(storage[ComboPanelName].serverLeader)
comboWindow.server.botServerLeader.onTextChange = function(widget, text)
storage[ComboPanelName].serverLeader = text
end
end
-- bot server
-- [[ join party made by Frosty ]] --
local shouldCloseWindow = false
local firstInvitee = true
local isInComboTeam = false
macro(10, function()
if shouldCloseWindow and storage[ComboPanelName].serverEnabled and storage[ComboPanelName].enabled then
local channelsWindow = modules.game_console.channelsWindow
if channelsWindow then
local child = channelsWindow:getChildById("buttonCancel")
if child then
child:onClick()
shouldCloseWindow = false
isInComboTeam = true
end
end
end
end)
comboWindow.server.partyButton.onClick = function(widget)
if storage[ComboPanelName].serverEnabled and storage[ComboPanelName].enabled then
if storage[ComboPanelName].serverLeader:len() > 0 and storage.BotServerChannel:len() > 0 then
talkPrivate(storage[ComboPanelName].serverLeader, "request invite " .. storage.BotServerChannel)
else
error("Request failed. Lack of data.")
end
end
end
onTextMessage(function(mode, text)
if storage[ComboPanelName].serverEnabled and storage[ComboPanelName].enabled then
if mode == 20 then
if string.find(text, "invited you to") then
local regex = "[a-zA-Z]*"
local regexData = regexMatch(text, regex)
if regexData[1][1]:lower() == storage[ComboPanelName].serverLeader:lower() then
local leader = getCreatureByName(regexData[1][1])
if leader then
g_game.partyJoin(leader:getId())
g_game.requestChannels()
g_game.joinChannel(1)
shouldCloseWindow = true
end
end
end
end
end
end)
onTalk(function(name, level, mode, text, channelId, pos)
if storage[ComboPanelName].serverEnabled and storage[ComboPanelName].enabled then
if mode == 4 then
if string.find(text, "request invite") then
local access = string.match(text, "%d.*")
if access and access == storage.BotServerChannel then
local minion = getCreatureByName(name)
if minion then
g_game.partyInvite(minion:getId())
if firstInvitee then
g_game.requestChannels()
g_game.joinChannel(1)
shouldCloseWindow = true
firstInvitee = false
end
end
else
talkPrivate(name, "Incorrect access key!")
end
end
end
end
-- [[ End of Frosty's Code ]] --
if storage[ComboPanelName].enabled and storage[ComboPanelName].enabled then
if name:lower() == storage[ComboPanelName].sayLeader:lower() and string.find(text, storage[ComboPanelName].sayPhrase) and storage[ComboPanelName].onSayEnabled then
startCombo = true
end
if (storage[ComboPanelName].castLeader and name:lower() == storage[ComboPanelName].castLeader:lower()) and isAttSpell(text) and storage[ComboPanelName].onCastEnabled then
startCombo = true
end
end
if storage[ComboPanelName].enabled and storage[ComboPanelName].commandsEnabled and (storage[ComboPanelName].shootLeader and name:lower() == storage[ComboPanelName].shootLeader:lower()) or (storage[ComboPanelName].sayLeader and name:lower() == storage[ComboPanelName].sayLeader:lower()) or (storage[ComboPanelName].castLeader and name:lower() == storage[ComboPanelName].castLeader:lower()) then
if string.find(text, "ue") then
say(storage[ComboPanelName].spell)
elseif string.find(text, "sd") then
local params = string.split(text, ",")
if #params == 2 then
local target = params[2]:trim()
if getCreatureByName(target) then
useWith(3155, getCreatureByName(target))
end
end
elseif string.find(text, "att") then
local attParams = string.split(text, ",")
if #attParams == 2 then
local atTarget = attParams[2]:trim()
if getCreatureByName(atTarget) and storage[ComboPanelName].attack == "COMMAND TARGET" then
g_game.attack(getCreatureByName(atTarget))
end
end
end
end
if isAttSpell(text) and storage[ComboPanelName].enabled and storage[ComboPanelName].serverEnabled then
BotServer.send("trigger", "start")
end
end)
onMissle(function(missle)
if storage[ComboPanelName].enabled and storage[ComboPanelName].onShootEnabled then
if not storage[ComboPanelName].shootLeader or storage[ComboPanelName].shootLeader:len() == 0 then
return
end
local src = missle:getSource()
if src.z ~= posz() then
return
end
local from = g_map.getTile(src)
local to = g_map.getTile(missle:getDestination())
if not from or not to then
return
end
local fromCreatures = from:getCreatures()
local toCreatures = to:getCreatures()
if #fromCreatures ~= 1 or #toCreatures ~= 1 then
return
end
local c1 = fromCreatures[1]
local t1 = toCreatures[1]
leaderTarget = t1
if c1:getName():lower() == storage[ComboPanelName].shootLeader:lower() then
if storage[ComboPanelName].attackItemEnabled and storage[ComboPanelName].item and storage[ComboPanelName].item > 100 and findItem(storage[ComboPanelName].item) then
useWith(storage[ComboPanelName].item, t1)
end
if storage[ComboPanelName].attackSpellEnabled and storage[ComboPanelName].spell:len() > 1 then
say(storage[ComboPanelName].spell)
end
end
end
end)
macro(10, function()
if not storage[ComboPanelName].enabled or not storage[ComboPanelName].attackLeaderTargetEnabled then return end
if leaderTarget and storage[ComboPanelName].attack == "LEADER TARGET" then
if not getTarget() or (getTarget() and getTarget():getName() ~= leaderTarget:getName()) then
g_game.attack(leaderTarget)
end
end
if storage[ComboPanelName].enabled and storage[ComboPanelName].serverEnabled and storage[ComboPanelName].attack == "SERVER LEADER TARGET" and serverTarget then
if serverTarget and not getTarget() or (getTarget() and getTarget():getname() ~= serverTarget)
then
g_game.attack(serverTarget)
end
end
end)
local toFollow
local toFollowPos = {}
macro(100, function()
toFollow = nil
if not storage[ComboPanelName].enabled or not storage[ComboPanelName].followLeaderEnabled then return end
if leaderTarget and storage[ComboPanelName].follow == "LEADER TARGET" and leaderTarget:isPlayer() then
toFollow = leaderTarget:getName()
elseif storage[ComboPanelName].follow == "SERVER LEADER TARGET" and storage[ComboPanelName].serverLeader:len() ~= 0 then
toFollow = serverTarget
elseif storage[ComboPanelName].follow == "SERVER LEADER" and storage[ComboPanelName].serverLeader:len() ~= 0 then
toFollow = storage[ComboPanelName].serverLeader
elseif storage[ComboPanelName].follow == "LEADER" then
if storage[ComboPanelName].onSayEnabled and storage[ComboPanelName].sayLeader:len() ~= 0 then
toFollow = storage[ComboPanelName].sayLeader
elseif storage[ComboPanelName].onCastEnabled and storage[ComboPanelName].castLeader:len() ~= 0 then
toFollow = storage[ComboPanelName].castLeader
elseif storage[ComboPanelName].onShootEnabled and storage[ComboPanelName].shootLeader:len() ~= 0 then
toFollow = storage[ComboPanelName].shootLeader
end
end
if not toFollow then return end
local target = getCreatureByName(toFollow)
if target then
local tpos = target:getPosition()
toFollowPos[tpos.z] = tpos
end
if player:isWalking() then return end
local p = toFollowPos[posz()]
if not p then return end
if CaveBot.walkTo(p, 20, {ignoreNonPathable=true, precision=1, ignoreStairs=false}) then
delay(100)
end
end)
onCreaturePositionChange(function(creature, oldPos, newPos)
if creature:getName() == toFollow and newPos then
toFollowPos[newPos.z] = newPos
end
end)
local timeout = now
macro(10, function()
if storage[ComboPanelName].enabled and startCombo then
if storage[ComboPanelName].attackItemEnabled and storage[ComboPanelName].item and storage[ComboPanelName].item > 100 and findItem(storage[ComboPanelName].item) then
useWith(storage[ComboPanelName].item, getTarget())
end
if storage[ComboPanelName].attackSpellEnabled and storage[ComboPanelName].spell:len() > 1 then
say(storage[ComboPanelName].spell)
end
startCombo = false
end
-- attack part / server
if BotServer._websocket and storage[ComboPanelName].enabled and storage[ComboPanelName].serverEnabled then
if target() and now - timeout > 500 then
targetPos = target():getName()
BotServer.send("target", targetPos)
timeout = now
end
end
end)
onUseWith(function(pos, itemId, target, subType)
if BotServer._websocket and itemId == 3155 then
BotServer.send("useWith", target:getPosition())
end
end)
if BotServer._websocket and storage[ComboPanelName].enabled and storage[ComboPanelName].serverEnabled then
BotServer.listen("trigger", function(name, message)
if message == "start" and name:lower() ~= player:getName():lower() and name:lower() == storage[ComboPanelName].serverLeader:lower() and storage[ComboPanelName].serverTriggers then
startCombo = true
end
end)
BotServer.listen("target", function(name, message)
if name:lower() ~= player:getName():lower() and name:lower() == storage[ComboPanelName].serverLeader:lower() then
if not target() or target():getName() == getCreatureByName(message) then
if storage[ComboPanelName].serverLeaderTarget then
serverTarget = getCreatureByName(message)
g_game.attack(getCreatureByName(message))
end
end
end
end)
BotServer.listen("useWith", function(name, message)
local tile = g_map.getTile(message)
if storage[ComboPanelName].serverTriggers and name:lower() ~= player:getName():lower() and name:lower() == storage[ComboPanelName].serverLeader:lower() and storage[ComboPanelName].attackItemEnabled and storage[ComboPanelName].item and findItem(storage[ComboPanelName].item) then
useWith(storage[ComboPanelName].item, tile:getTopUseThing())
end
end)
end

View File

@ -1,115 +0,0 @@
setDefaultTab("Tools")
function quiverManager()
quiverPanelName = "quiverManager"
local ui = setupUI([[
Panel
height: 33
margin-top: 2
BotItem
id: BoltsID
anchors.left: parent.left
anchors.top: parent.top
BotItem
id: ArrowsID
anchors.left: prev.right
anchors.verticalCenter: prev.verticalCenter
BotSwitch
id: BoltsSwitch
anchors.top: parent.top
anchors.bottom: prev.verticalCenter
anchors.right: parent.right
text: Sort Bolts
BotSwitch
id: ArrowsSwitch
anchors.top: prev.bottom
anchors.bottom: ArrowsID.bottom
anchors.right: parent.right
text: Sort Arrows
]])
ui:setId(quiverPanelName)
if not storage[quiverPanelName] then
storage[quiverPanelName] = {
arrowsId = 35848,
boltsId = 35849,
bolts = false,
arrows = false
}
end
ui.BoltsSwitch:setOn(storage[quiverPanelName].bolts)
ui.BoltsSwitch.onClick = function(widget)
storage[quiverPanelName].bolts = not storage[quiverPanelName].bolts
widget:setOn(storage[quiverPanelName].bolts)
end
ui.ArrowsSwitch:setOn(storage[quiverPanelName].arrows)
ui.ArrowsSwitch.onClick = function(widget)
storage[quiverPanelName].arrows = not storage[quiverPanelName].arrows
widget:setOn(storage[quiverPanelName].arrows)
end
ui.BoltsID:setItemId(storage[quiverPanelName].boltsId)
ui.BoltsID.onItemChange = function(widget)
storage[quiverPanelName].boltsId = widget:getItemId()
end
ui.ArrowsID:setItemId(storage[quiverPanelName].arrowsId)
ui.ArrowsID.onItemChange = function(widget)
storage[quiverPanelName].arrowsId = widget:getItemId()
end
local arrows = {16143, 763, 761, 7365, 3448, 762, 21470, 7364, 14251, 3447, 3449, 15793, 25757, 774}
local bolts = {6528, 7363, 3450, 16141, 25758, 14252, 3446, 16142}
macro(200, function()
local dArrow
local dBolt
for _, c in pairs(getContainers()) do
if not containerIsFull(c) then
if c:getContainerItem():getId() == storage[quiverPanelName].arrowsId and storage[quiverPanelName].arrows then
dArrow = c
elseif c:getContainerItem():getId() == storage[quiverPanelName].boltsId and storage[quiverPanelName].bolts then
dBolt = c
end
end
end
if dArrow and storage[quiverPanelName].arrows then
for _, c in pairs(getContainers()) do
if c:getName():lower():find("backpack") or c:getName():lower():find("bag") or c:getName():lower():find("chess") then
for _, i in pairs(c:getItems()) do
if table.find(arrows, i:getId()) then
return g_game.move(i, dArrow:getSlotPosition(dArrow:getItemsCount()), i:getCount())
end
end
end
end
end
if dBolt and storage[quiverPanelName].bolts then
for _, c in pairs(getContainers()) do
if c:getName():lower():find("backpack") or c:getName():lower():find("bag") or c:getName():lower():find("chess") then
for _, i in pairs(c:getItems()) do
if table.find(bolts, i:getId()) then
return g_game.move(i, dBolt:getSlotPosition(dBolt:getItemsCount()), i:getCount())
end
end
end
end
end
end)
end
if voc() == 2 or voc() == 12 then
addSeparator()
UI.Label("[[ Quiver Manager ]]")
addSeparator()
quiverManager()
end

View File

@ -1,402 +0,0 @@
function SuppliesPanel(parent)
suppliesPanelName = "supplies"
if not parent then
parent = panel
end
if not SuppliesConfig[suppliesPanelName] then
SuppliesConfig[suppliesPanelName] = {
item1 = 0,
item2 = 0,
item3 = 0,
item4 = 0,
item5 = 0,
item6 = 0,
item7 = 0,
capValue = 0,
capSwitch = false,
SoftBoots = false,
staminaSwitch = false,
staminaValue = 900,
imbues = false,
item1Min = 0,
item1Max = 0,
item2Min = 0,
item2Max = 0,
item3Min = 0,
item3Max = 0,
item4Min = 0,
item4Max = 0,
item5Min = 0,
item5Max = 0,
item6Min = 0,
item6Max = 0,
item7Max = 0,
sortSupplies = false,
potionBp = 0,
runeBp = 0,
ammoBp = 0
}
end
-- data validation
local setup = SuppliesConfig[suppliesPanelName]
setup.item1 = setup.item1 or 0
setup.item2 = setup.item2 or 0
setup.item3 = setup.item3 or 0
setup.item4 = setup.item4 or 0
setup.item5 = setup.item5 or 0
setup.item6 = setup.item6 or 0
setup.item1Min = setup.item1Min or 0
setup.item1Max = setup.item1Max or 0
setup.item2Min = setup.item2Min or 0
setup.item2Max = setup.item2Max or 0
setup.item3Min = setup.item3Min or 0
setup.item3Max = setup.item3Max or 0
setup.item4Min = setup.item4Min or 0
setup.item4Max = setup.item4Max or 0
setup.item5Min = setup.item5Min or 0
setup.item5Max = setup.item5Max or 0
setup.item6Min = setup.item6Min or 0
setup.item6Max = setup.item6Max or 0
setup.capValue = setup.capValue or 0
setup.staminaValue = setup.staminaValue or 0
setup.potionBp = setup.potionBp or 0
setup.runeBp = setup.runeBp or 0
setup.ammoBp = setup.ammoBp or 0
rootWidget = g_ui.getRootWidget()
if rootWidget then
SuppliesWindow = g_ui.createWidget('SuppliesWindow', rootWidget)
SuppliesWindow:hide()
SuppliesWindow.capSwitch:setOn(SuppliesConfig[suppliesPanelName].capSwitch)
SuppliesWindow.capSwitch.onClick = function(widget)
SuppliesConfig[suppliesPanelName].capSwitch = not SuppliesConfig[suppliesPanelName].capSwitch
widget:setOn(SuppliesConfig[suppliesPanelName].capSwitch)
end
SuppliesWindow.SoftBoots:setOn(SuppliesConfig[suppliesPanelName].SoftBoots)
SuppliesWindow.SoftBoots.onClick = function(widget)
SuppliesConfig[suppliesPanelName].SoftBoots = not SuppliesConfig[suppliesPanelName].SoftBoots
widget:setOn(SuppliesConfig[suppliesPanelName].SoftBoots)
end
SuppliesWindow.imbues:setOn(SuppliesConfig[suppliesPanelName].imbues)
SuppliesWindow.imbues.onClick = function(widget)
SuppliesConfig[suppliesPanelName].imbues = not SuppliesConfig[suppliesPanelName].imbues
widget:setOn(SuppliesConfig[suppliesPanelName].imbues)
end
SuppliesWindow.staminaSwitch:setOn(SuppliesConfig[suppliesPanelName].staminaSwitch)
SuppliesWindow.staminaSwitch.onClick = function(widget)
SuppliesConfig[suppliesPanelName].staminaSwitch = not SuppliesConfig[suppliesPanelName].staminaSwitch
widget:setOn(SuppliesConfig[suppliesPanelName].staminaSwitch)
end
SuppliesWindow.SortSupplies:setOn(SuppliesConfig[suppliesPanelName].sortSupplies)
SuppliesWindow.SortSupplies.onClick = function(widget)
SuppliesConfig[suppliesPanelName].sortSupplies = not SuppliesConfig[suppliesPanelName].sortSupplies
widget:setOn(SuppliesConfig[suppliesPanelName].sortSupplies)
end
-- bot items
SuppliesWindow.item1:setItemId(SuppliesConfig[suppliesPanelName].item1)
SuppliesWindow.item1.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].item1 = widget:getItemId()
end
SuppliesWindow.item2:setItemId(SuppliesConfig[suppliesPanelName].item2)
SuppliesWindow.item2.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].item2 = widget:getItemId()
end
SuppliesWindow.item3:setItemId(SuppliesConfig[suppliesPanelName].item3)
SuppliesWindow.item3.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].item3 = widget:getItemId()
end
SuppliesWindow.item4:setItemId(SuppliesConfig[suppliesPanelName].item4)
SuppliesWindow.item4.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].item4 = widget:getItemId()
end
SuppliesWindow.item5:setItemId(SuppliesConfig[suppliesPanelName].item5)
SuppliesWindow.item5.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].item5 = widget:getItemId()
end
SuppliesWindow.item6:setItemId(SuppliesConfig[suppliesPanelName].item6)
SuppliesWindow.item6.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].item6 = widget:getItemId()
end
SuppliesWindow.PotionBp:setItemId(SuppliesConfig[suppliesPanelName].potionBp)
SuppliesWindow.PotionBp.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].potionBp = widget:getItemId()
end
SuppliesWindow.RuneBp:setItemId(SuppliesConfig[suppliesPanelName].runeBp)
SuppliesWindow.RuneBp.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].runeBp = widget:getItemId()
end
SuppliesWindow.AmmoBp:setItemId(SuppliesConfig[suppliesPanelName].ammoBp)
SuppliesWindow.AmmoBp.onItemChange = function(widget)
SuppliesConfig[suppliesPanelName].ammoBp = widget:getItemId()
end
-- text windows
SuppliesWindow.capValue:setText(SuppliesConfig[suppliesPanelName].capValue)
SuppliesWindow.capValue.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.capValue:getText())
if not value then
SuppliesWindow.capValue:setText(0)
SuppliesConfig[suppliesPanelName].capValue = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].capValue = text
end
end
SuppliesWindow.item1Min:setText(SuppliesConfig[suppliesPanelName].item1Min)
SuppliesWindow.item1Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item1Min:getText())
if not value then
SuppliesWindow.item1Min:setText(0)
SuppliesConfig[suppliesPanelName].item1Min = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item1Min = text
end
end
SuppliesWindow.item1Max:setText(SuppliesConfig[suppliesPanelName].item1Max)
SuppliesWindow.item1Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item1Max:getText())
if not value then
SuppliesWindow.item1Max:setText(0)
SuppliesConfig[suppliesPanelName].item1Max = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item1Max = text
end
end
SuppliesWindow.item2Min:setText(SuppliesConfig[suppliesPanelName].item2Min)
SuppliesWindow.item2Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item2Min:getText())
if not value then
SuppliesWindow.item2Min:setText(0)
SuppliesConfig[suppliesPanelName].item2Min = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item2Min = text
end
end
SuppliesWindow.item2Max:setText(SuppliesConfig[suppliesPanelName].item2Max)
SuppliesWindow.item2Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item2Max:getText())
if not value then
SuppliesWindow.item2Max:setText(0)
SuppliesConfig[suppliesPanelName].item2Max = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item2Max = text
end
end
SuppliesWindow.item3Min:setText(SuppliesConfig[suppliesPanelName].item3Min)
SuppliesWindow.item3Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item3Min:getText())
if not value then
SuppliesWindow.item3Min:setText(0)
SuppliesConfig[suppliesPanelName].item3Min = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item3Min = text
end
end
SuppliesWindow.item3Max:setText(SuppliesConfig[suppliesPanelName].item3Max)
SuppliesWindow.item3Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item3Max:getText())
if not value then
SuppliesWindow.item3Max:setText(0)
SuppliesConfig[suppliesPanelName].item3Max = 0
else
SuppliesConfig[suppliesPanelName].item3Max = text
end
end
SuppliesWindow.item4Min:setText(SuppliesConfig[suppliesPanelName].item4Min)
SuppliesWindow.item4Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item4Min:getText())
if not value then
SuppliesWindow.item4Min:setText(0)
SuppliesConfig[suppliesPanelName].item4Min = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item4Min = text
end
end
SuppliesWindow.staminaValue:setText(SuppliesConfig[suppliesPanelName].staminaValue)
SuppliesWindow.staminaValue.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.staminaValue:getText())
if not value then
SuppliesWindow.staminaValue:setText(0)
SuppliesConfig[suppliesPanelName].staminaValue = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].staminaValue = text
end
end
SuppliesWindow.item4Max:setText(SuppliesConfig[suppliesPanelName].item4Max)
SuppliesWindow.item4Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item4Max:getText())
if not value then
SuppliesWindow.item4Max:setText(0)
SuppliesConfig[suppliesPanelName].item4Max = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item4Max = text
end
end
SuppliesWindow.item5Min:setText(SuppliesConfig[suppliesPanelName].item5Min)
SuppliesWindow.item5Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item5Min:getText())
if not value then
SuppliesWindow.item5Min:setText(0)
SuppliesConfig[suppliesPanelName].item5Min = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item5Min = text
end
end
SuppliesWindow.item5Max:setText(SuppliesConfig[suppliesPanelName].item5Max)
SuppliesWindow.item5Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item5Max:getText())
if not value then
SuppliesWindow.item5Max:setText(0)
SuppliesConfig[suppliesPanelName].item5Max = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item5Max = text
end
end
SuppliesWindow.item6Min:setText(SuppliesConfig[suppliesPanelName].item6Min)
SuppliesWindow.item6Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item6Min:getText())
if not value then
SuppliesWindow.item6Min:setText(0)
SuppliesConfig[suppliesPanelName].item6Min = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item6Min = text
end
end
SuppliesWindow.item6Max:setText(SuppliesConfig[suppliesPanelName].item6Max)
SuppliesWindow.item6Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item6Max:getText())
if not value then
SuppliesWindow.item6Max:setText(0)
SuppliesConfig[suppliesPanelName].item6Max = 0
else
text = text:match("0*(%d+)")
SuppliesConfig[suppliesPanelName].item6Max = text
end
end
end
UI.Button("Supplies", function()
SuppliesWindow:show()
SuppliesWindow:raise()
SuppliesWindow:focus()
end)
SuppliesWindow.close.onClick = function(widget)
SuppliesWindow:hide()
vBotConfigSave("supply")
end
end
local potions = {23375, 268, 237, 238, 23373, 266, 236, 239, 7643, 7642, 23374}
local runes = {3725, 3203, 3161, 3147, 3178, 3177, 3153, 3148, 3197, 3149, 3164, 3166, 3200, 3192, 3188, 3190, 3189, 3191, 3198, 3182, 3158, 3152, 3174, 3180, 3165, 3173, 3172, 3176, 3195, 3179, 3175, 3155, 3202, 3160, 3156}
local ammo = {3446, 16142, 6528, 7363, 3450, 16141, 25785, 14252, 3447, 3449, 15793, 25757, 774, 16143, 763, 761, 7365, 3448, 762, 21470, 7364, 14251, 7368, 25759, 3287, 7366, 3298, 25758}
macro(250, function()
if not SuppliesConfig[suppliesPanelName].sortSupplies then return end
local sortPotions = SuppliesConfig[suppliesPanelName].potionBp > 100
local sortRunes = SuppliesConfig[suppliesPanelName].runeBp > 100
local sortAmmo = SuppliesConfig[suppliesPanelName].ammoBp > 100
local potionsContainer = nil
local runesContainer = nil
local ammoContainer = nil
-- set the containers
if not potionsContainer or not runesContainer or not ammoContainer then
for i, container in pairs(getContainers()) do
if not containerIsFull(container) then
if sortPotions and container:getContainerItem():getId() == SuppliesConfig[suppliesPanelName].potionBp then
potionsContainer = container
elseif sortRunes and container:getContainerItem():getId() == SuppliesConfig[suppliesPanelName].runeBp then
runesContainer = container
elseif sortAmmo and container:getContainerItem():getId() == SuppliesConfig[suppliesPanelName].ammoBp then
ammoContainer = container
end
end
end
end
-- potions
if potionsContainer then
for i, container in pairs(getContainers()) do
if (container:getContainerItem():getId() ~= SuppliesConfig[suppliesPanelName].potionBp and (string.find(container:getName(), "backpack") or string.find(container:getName(), "bag") or string.find(container:getName(), "chess"))) then
for j, item in pairs(container:getItems()) do
if table.find(potions, item:getId()) then
return g_game.move(item, potionsContainer:getSlotPosition(potionsContainer:getItemsCount()), item:getCount())
end
end
end
end
end
-- runes
if runesContainer then
for i, container in pairs(getContainers()) do
if (container:getContainerItem():getId() ~= SuppliesConfig[suppliesPanelName].runeBp and (string.find(container:getName(), "backpack") or string.find(container:getName(), "bag") or string.find(container:getName(), "chess"))) then
for j, item in pairs(container:getItems()) do
if table.find(runes, item:getId()) then
return g_game.move(item, runesContainer:getSlotPosition(runesContainer:getItemsCount()), item:getCount())
end
end
end
end
end
-- ammo
if ammoContainer then
for i, container in pairs(getContainers()) do
if (container:getContainerItem():getId() ~= SuppliesConfig[suppliesPanelName].ammoBp and (string.find(container:getName(), "backpack") or string.find(container:getName(), "bag") or string.find(container:getName(), "chess"))) and not string.find(container:getName():lower(), "loot") then
for j, item in pairs(container:getItems()) do
if table.find(ammo, item:getId()) then
return g_game.move(item, ammoContainer:getSlotPosition(ammoContainer:getItemsCount()), item:getCount())
end
end
end
end
end
end)
UI.Separator()
SuppliesPanel(setDefaultTab("Cave"))

View File

@ -0,0 +1,60 @@
-- load all otui files, order doesn't matter
local configName = modules.game_bot.contentsPanel.config:getCurrentOption().text
local configFiles = g_resources.listDirectoryFiles("/bot/" .. configName .. "/vBot", true, false)
for i, file in ipairs(configFiles) do
local ext = file:split(".")
if ext[#ext]:lower() == "ui" or ext[#ext]:lower() == "otui" then
g_ui.importStyle(file)
end
end
local function loadScript(name)
return dofile("/vBot/" .. name .. ".lua")
end
-- here you can set manually order of scripts
-- libraries should be loaded first
local luaFiles = {
"main",
"vlib",
"new_cavebot_lib",
"configs", -- do not change this and above
"extras",
"playerlist",
"BotServer",
"alarms",
"Conditions",
"pushmax",
"combo",
"HealBot",
"Sio",
"AttackBot", -- last of major modules
"ingame_editor",
"Dropper",
"Containers",
"quiver_manager",
"tools",
"antiRs",
"cavebot",
"depot_withdraw",
"cast_food",
"eat_food",
"equip",
"exeta",
"info",
"jewellery_equipper",
"spy_level",
"supplies",
"depositer_config",
"npc_talk"
}
for i, file in ipairs(luaFiles) do
loadScript(file)
end
setDefaultTab("Main")
UI.Separator()
UI.Label("Private Scripts:")
UI.Separator()

View File

@ -2,7 +2,7 @@ CaveBot.Extensions.BuySupplies = {}
CaveBot.Extensions.BuySupplies.setup = function()
CaveBot.registerAction("BuySupplies", "#C300FF", function(value, retries)
local supplies = SuppliesConfig[suppliesPanelName]
local supplies = SuppliesConfig.supplies
local item1Count = itemAmount(supplies.item1)
local item2Count = itemAmount(supplies.item2)
local item3Count = itemAmount(supplies.item3)

View File

@ -5,6 +5,7 @@ CaveBot.Extensions.ClearTile.setup = function()
local data = string.split(value, ",")
local pos = {x=tonumber(data[1]), y=tonumber(data[2]), z=tonumber(data[3])}
local doors
local pPos = player:getPosition()
if #data == 4 then
doors = true
end
@ -27,6 +28,7 @@ CaveBot.Extensions.ClearTile.setup = function()
print("CaveBot[ClearTile]: can't find tile or tile is unreachable, skipping")
return false
end
local tPos = tile:getPosition()
-- no items on tile and walkability means we are done
if tile:isWalkable() and tile:getTopUseThing():isNotMoveable() and not tile:hasCreature() and not doors then

View File

@ -0,0 +1,96 @@
CaveBot.Extensions.DWithdraw = {}
CaveBot.Extensions.DWithdraw.setup = function()
CaveBot.registerAction("dpwithdraw", "#002FFF", function(value, retries)
local capLimit
local data = string.split(value, ",")
if retries > 600 then
print("CaveBot[DepotWithdraw]: actions limit reached, proceeding")
return true
end
local destContainer
local depotContainer
-- input validation
if not value or #data ~= 3 and #data ~= 4 then
warn("CaveBot[DepotWithdraw]: incorrect value!")
return false
end
local indexDp = tonumber(data[1]:trim())
local destName = data[2]:trim():lower()
local destId = tonumber(data[3]:trim())
if #data == 4 then
capLimit = tonumber(data[4]:trim())
end
-- cap check
if freecap() < (capLimit or 200) then
print("CaveBot[DepotWithdraw]: cap limit reached, proceeding")
return true
end
-- containers
for i, container in ipairs(getContainers()) do
local cName = container:getName():lower()
if destName == cName then
destContainer = container
elseif cName:find("depot box") then
depotContainer = container
end
end
if not destContainer then
print("CaveBot[DepotWithdraw]: container not found!")
return false
end
if containerIsFull(destContainer) then
for i, item in pairs(destContainer:getItems()) do
if item:getId() == destId then
g_game.open(item, destContainer)
return "retry"
end
end
end
-- stash validation
if depotContainer and #depotContainer:getItems() == 0 then
print("CaveBot[DepotWithdraw]: all items withdrawn")
return true
end
if containerIsFull(destContainer) then
for i, item in pairs(destContainer:getItems()) do
if item:getId() == destId then
g_game.open(foundNextContainer, destContainer)
return "retry"
end
end
print("CaveBot[DepotWithdraw]: loot containers full!")
return true
end
if not CaveBot.OpenDepotBox(indexDp) then
return "retry"
end
CaveBot.PingDelay(2)
for i, container in pairs(g_game.getContainers()) do
if string.find(container:getName():lower(), "depot box") then
for j, item in ipairs(container:getItems()) do
g_game.move(item, destContainer:getSlotPosition(destContainer:getItemsCount()), item:getCount())
return "retry"
end
end
end
return "retry"
end)
CaveBot.Editor.registerAction("dpwithdraw", "dpwithdraw", {
value="1, shopping bag, 21411",
title="Loot Withdraw",
description="insert index, destination container name and it's ID",
})
end

View File

@ -0,0 +1,125 @@
CaveBot.Extensions.Depositor = {}
--local variables
local closedContainers = false
local reopenedContainers = false
local destination = nil
local lootTable = nil
local function resetCache()
closedContainers = false
reopenedContainers = false
destination = nil
lootTable = nil
end
local description = g_game.getClientVersion() > 960 and "No - just deposit \n Yes - also reopen loot containers" or "currently not supported, will be added in near future"
CaveBot.Extensions.Depositor.setup = function()
CaveBot.registerAction("depositor", "#002FFF", function(value, retries)
-- version check, TODO old tibia
if g_game.getClientVersion() < 960 then
warn("CaveBot[Depositor]: unsupported Tibia version, will be added in near future")
return false
end
-- loot list check
lootTable = lootTable or CaveBot.GetLootItems()
if #lootTable == 0 then
print("CaveBot[Depositor]: no items in loot list. Wrong TargetBot Config? Proceeding")
resetCache()
return true
end
-- backpacks etc
if value:lower() == "yes" then
-- reopening backpacks
if not reopenedContainers then
if not closedContainers then
if not CaveBot.CloseLootContainer() then
return "retry"
else
closedContainers = true
end
else
if not CaveBot.OpenLootContainer() then
return "retry"
else
reopenedContainers = true
end
end
end
-- open next backpacks if no more loot
if not CaveBot.HasLootItems() then
local lootContainers = CaveBot.GetLootContainers()
for _, container in ipairs(getContainers()) do
local cId = container:getContainerItem():getId()
if table.find(lootContainers, cId) then
for i, item in ipairs(container:getItems()) do
if item:getId() == cId then
g_game.open(item, container)
delay(100)
return "retry"
end
end
-- couldn't find next container, so we done
print("CaveBot[Depositor]: all items stashed, no backpack to open next, proceeding")
resetCache()
return true
end
end
end
end
-- first check items
if retries == 0 then
if not CaveBot.HasLootItems() then -- resource consuming function
print("CaveBot[Depositor]: no items to stash, proceeding")
resetCache()
return true
end
end
-- next check retries
if retries > 400 then
print("CaveBot[Depositor]: Depositor actions limit reached, proceeding")
resetCache()
return true
end
-- reaching and opening depot
if not CaveBot.ReachAndOpenDepot() then
return "retry"
end
-- add delay to prevent bugging
CaveBot.PingDelay(2)
-- prep time and stashing
destination = destination or getContainerByName("Depot chest")
if not destination then return "retry" end
for _, container in pairs(getContainers()) do
local name = container:getName():lower()
if not name:find("depot") and not name:find("your inbox") then
for _, item in pairs(container:getItems()) do
local id = item:getId()
if table.find(lootTable, id) then
local index = getStashingIndex(id) or item:isStackable() and 1 or 0
CaveBot.StashItem(item, index, destination)
return "retry"
end
end
end
end
-- we gucci
return true
end)
CaveBot.Editor.registerAction("depositor", "depositor", {
value="no",
title="Depositor",
description=description,
})
end

View File

@ -0,0 +1,89 @@
CaveBot.Extensions.InWithdraw = {}
CaveBot.Extensions.InWithdraw.setup = function()
CaveBot.registerAction("inwithdraw", "#002FFF", function(value, retries)
local data = string.split(value, ",")
local withdrawId
local amount
-- validation
if #data ~= 2 then
warn("CaveBot[InboxWithdraw]: incorrect withdraw value")
return false
else
withdrawId = tonumber(data[1])
amount = tonumber(data[2])
end
local currentAmount = itemAmount(withdrawId)
if currentAmount >= amount then
print("CaveBot[InboxWithdraw]: enough items, proceeding")
return true
end
if retries > 400 then
print("CaveBot[InboxWithdraw]: actions limit reached, proceeding")
return true
end
-- actions
local inboxContainer = getContainerByName("your inbox")
delay(100)
if not inboxContainer then
if not CaveBot.ReachAndOpenInbox() then
return "retry"
end
end
local inboxAmount = 0
if not inboxContainer then
return "retry"
end
for i, item in pairs(inboxContainer:getItems()) do
if item:getId() == withdrawId then
inboxAmount = inboxAmount + item:getCount()
end
end
if inboxAmount == 0 then
warn("CaveBot[InboxWithdraw]: not enough items in inbox container, proceeding")
return true
end
local destination
for i, container in pairs(getContainers()) do
if container:getCapacity() > #container:getItems() and not string.find(container:getName():lower(), "quiver") and not string.find(container:getName():lower(), "depot") and not string.find(container:getName():lower(), "loot") and not string.find(container:getName():lower(), "inbox") then
destination = container
end
end
if not destination then
print("CaveBot[InboxWithdraw]: couldn't find proper destination container, skipping")
return falsed
end
CaveBot.PingDelay(2)
for i, container in pairs(getContainers()) do
if string.find(container:getName():lower(), "your inbox") then
for j, item in pairs(container:getItems()) do
if item:getId() == withdrawId then
if item:isStackable() then
g_game.move(item, destination:getSlotPosition(destination:getItemsCount()), math.min(item:getCount(), (amount - currentAmount)))
return "retry"
else
g_game.move(item, destination:getSlotPosition(destination:getItemsCount()), 1)
return "retry"
end
return "retry"
end
end
end
end
end)
CaveBot.Editor.registerAction("inwithdraw", "in withdraw", {
value="id,amount",
title="Withdraw Items",
description="insert item id and amount",
})
end

View File

@ -0,0 +1,119 @@
CaveBot.Extensions.SupplyCheck = {}
local supplyRetries = 0
local missedChecks = 0
local time = nil
CaveBot.Extensions.SupplyCheck.setup = function()
CaveBot.registerAction("supplyCheck", "#db5a5a", function(value)
local data = string.split(value, ",")
local round = 0
local label = data[1]:trim()
local pos = nil
if #data == 4 then
pos = {x=tonumber(data[2]),y=tonumber(data[3]),z=tonumber(data[4])}
end
if pos then
if missedChecks >= 4 then
missedChecks = 0
supplyRetries = 0
print("CaveBot[SupplyCheck]: Missed 5 supply checks, proceeding with waypoints")
return true
end
if getDistanceBetween(player:getPosition(), pos) > 10 then
missedChecks = missedChecks + 1
print("CaveBot[SupplyCheck]: Missed supply check! ".. 5-missedChecks .. " tries left before skipping.")
return CaveBot.gotoLabel(label)
end
end
if time then
round = math.ceil((now - time)/1000) .. "s"
else
round = ""
end
time = now
local supplies = SuppliesConfig.supplies
local softCount = itemAmount(6529) + itemAmount(3549)
local totalItem1 = itemAmount(supplies.item1)
local totalItem2 = itemAmount(supplies.item2)
local totalItem3 = itemAmount(supplies.item3)
local totalItem4 = itemAmount(supplies.item4)
local totalItem5 = itemAmount(supplies.item5)
local totalItem6 = itemAmount(supplies.item6)
if supplyRetries > (storage.extras.huntRoutes or 50) then
print("CaveBot[SupplyCheck]: Round limit reached, going back on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (supplies.imbues and player:getSkillLevel(11) == 0) then
print("CaveBot[SupplyCheck]: Imbues ran out. Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (supplies.staminaSwitch and stamina() < tonumber(supplies.staminaValue)) then
print("CaveBot[SupplyCheck]: Stamina ran out. Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (softCount < 1 and supplies.SoftBoots) then
print("CaveBot[SupplyCheck]: No soft boots left. Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (totalItem1 < tonumber(supplies.item1Min) and supplies.item1 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item1 .. "(only " .. totalItem1 .. " left). Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (totalItem2 < tonumber(supplies.item2Min) and supplies.item2 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item2 .. "(only " .. totalItem2 .. " left). Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (totalItem3 < tonumber(supplies.item3Min) and supplies.item3 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item3 .. "(only " .. totalItem3 .. " left). Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (totalItem4 < tonumber(supplies.item4Min) and supplies.item4 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item4 .. "(only " .. totalItem4 .. " left). Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (totalItem5 < tonumber(supplies.item5Min) and supplies.item5 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item5 .. "(only " .. totalItem5 .. " left). Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (totalItem6 < tonumber(supplies.item6Min) and supplies.item6 > 100) then
print("CaveBot[SupplyCheck]: Not enough item: " .. supplies.item6 .. "(only " .. totalItem6 .. " left). Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif (freecap() < tonumber(supplies.capValue) and supplies.capSwitch) then
print("CaveBot[SupplyCheck]: Not enough capacity. Going on refill. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
elseif ForcedRefill then
print("CaveBot[SupplyCheck]: Forced refill, going back to city. Last round took: " .. round)
supplyRetries = 0
missedChecks = 0
return false
else
print("CaveBot[SupplyCheck]: Enough supplies. Hunting. Round (" .. supplyRetries .. "/" .. (storage.extras.huntRoutes or 50) .."). Last round took: " .. round)
supplyRetries = supplyRetries + 1
missedChecks = 0
return CaveBot.gotoLabel(label)
end
end)
CaveBot.Editor.registerAction("supplycheck", "supply check", {
value=function() return "startHunt," .. posx() .. "," .. posy() .. "," .. posz() end,
title="Supply check label",
description="Insert here hunting start label",
})
end

View File

@ -80,7 +80,7 @@ CaveBot.Extensions.Tasker.setup = function()
-- let's cover markers now
if marker == 1 then -- starting task
NPC.Conversation("hi", "task", taskName, "yes")
CaveBot.Conversation("hi", "task", taskName, "yes")
delay(talkDelay*4)
storage.caveBotTasker.monster = monster
@ -114,7 +114,7 @@ CaveBot.Extensions.Tasker.setup = function()
elseif marker == 3 then -- reporting task
NPC.Conversation("hi", "report", "task")
CaveBot.Conversation("hi", "report", "task")
delay(talkDelay*3)
resetTaskData()

View File

@ -0,0 +1,45 @@
CaveBot.Extensions.Withdraw = {}
CaveBot.Extensions.Withdraw.setup = function()
CaveBot.registerAction("withdraw", "#002FFF", function(value, retries)
-- validation
local data = string.split(value, ",")
if #data ~= 3 then
print("CaveBot[Withdraw]: incorrect data! skipping")
return false
end
-- variables declaration
local source = tonumber(data[1])
local id = tonumber(data[2])
local amount = tonumber(data[3])
-- validation for correct values
if not id or not amount then
print("CaveBot[Withdraw]: incorrect id or amount! skipping")
return false
end
-- check for retries
if retries > 100 then
print("CaveBot[Withdraw]: actions limit reached, proceeding")
return true
end
-- check for items
if itemAmount(id) >= amount then
print("CaveBot[Withdraw]: enough items, proceeding")
return true
end
CaveBot.WithdrawItem(id, amount, source)
CaveBot.PingDelay()
return "retry"
end)
CaveBot.Editor.registerAction("withdraw", "withdraw", {
value="source,id,amount",
title="Withdraw Items",
description="index/inbox, item id and amount",
})
end

View File

@ -2,8 +2,7 @@ local targetBotLure = false
local targetCount = 0
local delayValue = 0
local lureMax = 0
local delayedLure = false
local anchorPosition = nil
TargetBot.Creature.attack = function(params, targets, isLooting) -- params {config, creature, danger, priority}
if player:isWalking() then
lastWalk = now
@ -91,8 +90,6 @@ TargetBot.Creature.walk = function(creature, config, targets)
targetBotLure = false
end
end
delayedLure = config.dynamicLureDelay
targetCount = targets
delayValue = config.lureDelay
@ -105,10 +102,12 @@ TargetBot.Creature.walk = function(creature, config, targets)
if TargetBot.canLure() and (config.lure or config.lureCavebot or config.dynamicLure) and not (config.chase and creature:getHealthPercent() < 5) and not isTrapped then
local monsters = 0
if targetBotLure then
anchorPosition = nil
return TargetBot.allowCaveBot(150)
else
if targets < config.lureCount then
if config.lureCavebot then
anchorPosition = nil
return TargetBot.allowCaveBot(150)
else
local path = findPath(pos, cpos, 5, {ignoreNonPathable=true, precision=2})
@ -121,15 +120,22 @@ TargetBot.Creature.walk = function(creature, config, targets)
end
local currentDistance = findPath(pos, cpos, 10, {ignoreCreatures=true, ignoreNonPathable=true, ignoreCost=true})
if config.chase and (creature:getHealthPercent() < 30 or not config.keepDistance) then
if config.chase and (creature:getHealthPercent() < (storage.extras.killUnder or 30) or not config.keepDistance) then
if #currentDistance > 1 then
return TargetBot.walkTo(cpos, 10, {ignoreNonPathable=true, precision=1})
end
elseif config.keepDistance then
if not anchorPosition or distanceFromPlayer(anchorPosition) > config.anchorRange then
anchorPosition = pos
end
if #currentDistance ~= config.keepDistanceRange and #currentDistance ~= config.keepDistanceRange + 1 then
if config.anchor and anchorPosition and getDistanceBetween(pos, anchorPosition) <= config.anchorRange*2 then
return TargetBot.walkTo(cpos, 10, {ignoreNonPathable=true, marginMin=config.keepDistanceRange, marginMax=config.keepDistanceRange + 1, maxDistanceFrom={anchorPosition, config.anchorRange}})
else
return TargetBot.walkTo(cpos, 10, {ignoreNonPathable=true, marginMin=config.keepDistanceRange, marginMax=config.keepDistanceRange + 1})
end
end
end
if config.avoidAttacks then
local diffx = cpos.x - pos.x
@ -180,8 +186,6 @@ onPlayerPositionChange(function(newPos, oldPos)
if TargetBot.isOff() then return end
if not lureMax then return end
if storage.TargetBotDelayWhenPlayer then return end
if not delayedLure then return end
if targetCount < lureMax/2 or not target() then return end
CaveBot.delay(delayValue or 0)

View File

@ -80,6 +80,7 @@ TargetBot.Creature.edit = function(config, callback) -- callback = function(newC
addScrollBar("danger", "Danger", 0, 10, 1)
addScrollBar("maxDistance", "Max distance", 1, 10, 10)
addScrollBar("keepDistanceRange", "Keep distance", 1, 5, 1)
addScrollBar("anchorRange", "Anchoring Range", 1, 10, 3)
addScrollBar("lureCount", "Classic Lure", 0, 5, 1)
addScrollBar("lureMin", "Dynamic lure min", 0, 9, 1)
addScrollBar("lureMax", "Dynamic lure max", 1, 9, 3)
@ -87,6 +88,7 @@ TargetBot.Creature.edit = function(config, callback) -- callback = function(newC
addCheckBox("chase", "Chase", true)
addCheckBox("keepDistance", "Keep Distance", false)
addCheckBox("anchor", "Anchoring", false)
addCheckBox("dontLoot", "Don't loot", false)
addCheckBox("lure", "Lure", false)
addCheckBox("lureCavebot", "Lure using cavebot", false)

View File

@ -26,15 +26,7 @@ TargetBot.Creature.calculatePriority = function(creature, config, path)
-- extra priority for paladin diamond arrows
if config.diamondArrows then
local mobCount = getCreaturesInArea(creature:getPosition(), diamondArrowArea, 2)
if mobCount > 5 then
priority = priority + 4
elseif mobCount > 4 then
priority = priority + 3
elseif mobCount > 3 then
priority = priority + 2
elseif mobCount > 2 then
priority = priority + 1
end
priority = priority + (mobCount * 4)
end
-- extra priority for low health

View File

@ -102,7 +102,7 @@ TargetBot.Looting.process = function(targets, dangerLevel)
TargetBot.Looting.list = {}
return false
end
local loot = TargetBot.Looting.list[1]
local loot = storage.extras.lootLast and TargetBot.Looting.list[#TargetBot.Looting.list] or TargetBot.Looting.list[1]
if loot == nil then
status = ""
return false
@ -134,7 +134,7 @@ TargetBot.Looting.process = function(targets, dangerLevel)
local dist = math.max(math.abs(pos.x-loot.pos.x), math.abs(pos.y-loot.pos.y))
local maxRange = storage.extras.looting or 40
if loot.tries > 30 or loot.pos.z ~= pos.z or dist > maxRange then
table.remove(TargetBot.Looting.list, 1)
table.remove(TargetBot.Looting.list, storage.extras.lootLast and #TargetBot.Looting.list or 1)
return true
end
@ -147,7 +147,7 @@ TargetBot.Looting.process = function(targets, dangerLevel)
local container = tile:getTopUseThing()
if not container or not container:isContainer() then
table.remove(TargetBot.Looting.list, 1)
table.remove(TargetBot.Looting.list, storage.extras.lootLast and #TargetBot.Looting.list or 1)
return true
end
@ -246,14 +246,14 @@ TargetBot.Looting.lootContainer = function(lootContainers, container)
-- looting finished, remove container from list
container.lootContainer = false
g_game.close(container)
table.remove(TargetBot.Looting.list, 1)
table.remove(TargetBot.Looting.list, storage.extras.lootLast and #TargetBot.Looting.list or 1)
end
onTextMessage(function(mode, text)
if TargetBot.isOff() then return end
if #TargetBot.Looting.list == 0 then return end
if string.find(text:lower(), "you are not the owner") then -- if we are not the owners of corpse then its a waste of time to try to loot it
table.remove(TargetBot.Looting.list, 1)
table.remove(TargetBot.Looting.list, storage.extras.lootLast and #TargetBot.Looting.list or 1)
end
end)

View File

@ -955,7 +955,7 @@ macro(100, function()
cast(entry.attack, entry.cd)
return
else
if not AttackBotConfig.isUsing and target():canShoot() then
if not vBot.isUsing and target():canShoot() then
g_game.useInventoryItemWith(entry.attack, target())
return
end
@ -965,7 +965,7 @@ macro(100, function()
if entry.category == 6 or entry.category == 7 then
if getMonsters(4) >= entry.minMonsters then
if type(entry.attack) == "number" then
if not AttackBotConfig.isUsing then
if not vBot.isUsing then
g_game.useInventoryItemWith(entry.attack, target())
return
end
@ -992,7 +992,7 @@ macro(100, function()
cast(entry.attack, entry.cd)
return
elseif entry.category == 8 and bestTile and bestTile.count >= entry.minMonsters then
if not AttackBotConfig.isUsing then
if not vBot.isUsing then
g_game.useInventoryItemWith(entry.attack, bestTile.pos:getTopUseThing())
end
return
@ -1003,7 +1003,7 @@ macro(100, function()
if entry.category == 6 or entry.category == 7 then
if getMonsters(4) >= entry.minMonsters then
if type(entry.attack) == "number" then
if not AttackBotConfig.isUsing then
if not vBot.isUsing then
g_game.useInventoryItemWith(entry.attack, target())
return
end
@ -1018,7 +1018,7 @@ macro(100, function()
if entry.category == 6 or entry.category == 7 then
if getMonsters(4) >= entry.minMonsters then
if type(entry.attack) == "number" then
if not AttackBotConfig.isUsing then
if not vBot.isUsing then
g_game.useInventoryItemWith(entry.attack, target())
return
end

View File

@ -34,7 +34,7 @@ end
local channel = tostring(storage.BotServerChannel)
BotServer.init(name(), channel)
BotServerMembers = {}
vBot.BotServerMembers = {}
rootWidget = g_ui.getRootWidget()
if rootWidget then
@ -189,7 +189,7 @@ BotServer.listen("voc", function(name, message)
if message == "yes" and config.vocation then
BotServer.send("voc", player:getVocation())
else
BotServerMembers[name] = message
vBot.BotServerMembers[name] = message
end
end)

View File

@ -0,0 +1,249 @@
setDefaultTab("HP")
local panelName = "ConditionPanel"
local ui = setupUI([[
Panel
height: 19
BotSwitch
id: title
anchors.top: parent.top
anchors.left: parent.left
text-align: center
width: 130
!text: tr('Conditions')
Button
id: conditionList
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 3
height: 17
text: Setup
]])
ui:setId(panelName)
if not HealBotConfig[panelName] then
HealBotConfig[panelName] = {
enabled = false,
curePosion = false,
poisonCost = 20,
cureCurse = false,
curseCost = 80,
cureBleed = false,
bleedCost = 45,
cureBurn = false,
burnCost = 30,
cureElectrify = false,
electrifyCost = 22,
cureParalyse = false,
paralyseCost = 40,
paralyseSpell = "utani hur",
holdHaste = false,
hasteCost = 40,
hasteSpell = "utani hur",
holdUtamo = false,
utamoCost = 40,
holdUtana = false,
utanaCost = 440,
holdUtura = false,
uturaType = "",
uturaCost = 100,
ignoreInPz = true,
stopHaste = false
}
end
local config = HealBotConfig[panelName]
ui.title:setOn(config.enabled)
ui.title.onClick = function(widget)
config.enabled = not config.enabled
widget:setOn(config.enabled)
vBotConfigSave("heal")
end
ui.conditionList.onClick = function(widget)
conditionsWindow:show()
conditionsWindow:raise()
conditionsWindow:focus()
end
local rootWidget = g_ui.getRootWidget()
if rootWidget then
conditionsWindow = UI.createWindow('ConditionsWindow', rootWidget)
conditionsWindow:hide()
-- text edits
conditionsWindow.Cure.PoisonCost:setText(config.poisonCost)
conditionsWindow.Cure.PoisonCost.onTextChange = function(widget, text)
config.poisonCost = tonumber(text)
end
conditionsWindow.Cure.CurseCost:setText(config.curseCost)
conditionsWindow.Cure.CurseCost.onTextChange = function(widget, text)
config.curseCost = tonumber(text)
end
conditionsWindow.Cure.BleedCost:setText(config.bleedCost)
conditionsWindow.Cure.BleedCost.onTextChange = function(widget, text)
config.bleedCost = tonumber(text)
end
conditionsWindow.Cure.BurnCost:setText(config.burnCost)
conditionsWindow.Cure.BurnCost.onTextChange = function(widget, text)
config.burnCost = tonumber(text)
end
conditionsWindow.Cure.ElectrifyCost:setText(config.electrifyCost)
conditionsWindow.Cure.ElectrifyCost.onTextChange = function(widget, text)
config.electrifyCost = tonumber(text)
end
conditionsWindow.Cure.ParalyseCost:setText(config.paralyseCost)
conditionsWindow.Cure.ParalyseCost.onTextChange = function(widget, text)
config.paralyseCost = tonumber(text)
end
conditionsWindow.Cure.ParalyseSpell:setText(config.paralyseSpell)
conditionsWindow.Cure.ParalyseSpell.onTextChange = function(widget, text)
config.paralyseSpell = text
end
conditionsWindow.Hold.HasteSpell:setText(config.hasteSpell)
conditionsWindow.Hold.HasteSpell.onTextChange = function(widget, text)
config.hasteSpell = text
end
conditionsWindow.Hold.HasteCost:setText(config.hasteCost)
conditionsWindow.Hold.HasteCost.onTextChange = function(widget, text)
config.hasteCost = tonumber(text)
end
conditionsWindow.Hold.UtamoCost:setText(config.utamoCost)
conditionsWindow.Hold.UtamoCost.onTextChange = function(widget, text)
config.utamoCost = tonumber(text)
end
conditionsWindow.Hold.UtanaCost:setText(config.utanaCost)
conditionsWindow.Hold.UtanaCost.onTextChange = function(widget, text)
config.utanaCost = tonumber(text)
end
conditionsWindow.Hold.UturaCost:setText(config.uturaCost)
conditionsWindow.Hold.UturaCost.onTextChange = function(widget, text)
config.uturaCost = tonumber(text)
end
-- combo box
conditionsWindow.Hold.UturaType:setOption(config.uturaType)
conditionsWindow.Hold.UturaType.onOptionChange = function(widget)
config.uturaType = widget:getCurrentOption().text
end
-- checkboxes
conditionsWindow.Cure.CurePoison:setChecked(config.curePoison)
conditionsWindow.Cure.CurePoison.onClick = function(widget)
config.curePoison = not config.curePoison
widget:setChecked(config.curePoison)
end
conditionsWindow.Cure.CureCurse:setChecked(config.cureCurse)
conditionsWindow.Cure.CureCurse.onClick = function(widget)
config.cureCurse = not config.cureCurse
widget:setChecked(config.cureCurse)
end
conditionsWindow.Cure.CureBleed:setChecked(config.cureBleed)
conditionsWindow.Cure.CureBleed.onClick = function(widget)
config.cureBleed = not config.cureBleed
widget:setChecked(config.cureBleed)
end
conditionsWindow.Cure.CureBurn:setChecked(config.cureBurn)
conditionsWindow.Cure.CureBurn.onClick = function(widget)
config.cureBurn = not config.cureBurn
widget:setChecked(config.cureBurn)
end
conditionsWindow.Cure.CureElectrify:setChecked(config.cureElectrify)
conditionsWindow.Cure.CureElectrify.onClick = function(widget)
config.cureElectrify = not config.cureElectrify
widget:setChecked(config.cureElectrify)
end
conditionsWindow.Cure.CureParalyse:setChecked(config.cureParalyse)
conditionsWindow.Cure.CureParalyse.onClick = function(widget)
config.cureParalyse = not config.cureParalyse
widget:setChecked(config.cureParalyse)
end
conditionsWindow.Hold.HoldHaste:setChecked(config.holdHaste)
conditionsWindow.Hold.HoldHaste.onClick = function(widget)
config.holdHaste = not config.holdHaste
widget:setChecked(config.holdHaste)
end
conditionsWindow.Hold.HoldUtamo:setChecked(config.holdUtamo)
conditionsWindow.Hold.HoldUtamo.onClick = function(widget)
config.holdUtamo = not config.holdUtamo
widget:setChecked(config.holdUtamo)
end
conditionsWindow.Hold.HoldUtana:setChecked(config.holdUtana)
conditionsWindow.Hold.HoldUtana.onClick = function(widget)
config.holdUtana = not config.holdUtana
widget:setChecked(config.holdUtana)
end
conditionsWindow.Hold.HoldUtura:setChecked(config.holdUtura)
conditionsWindow.Hold.HoldUtura.onClick = function(widget)
config.holdUtura = not config.holdUtura
widget:setChecked(config.holdUtura)
end
conditionsWindow.Hold.IgnoreInPz:setChecked(config.ignoreInPz)
conditionsWindow.Hold.IgnoreInPz.onClick = function(widget)
config.ignoreInPz = not config.ignoreInPz
widget:setChecked(config.ignoreInPz)
end
conditionsWindow.Hold.StopHaste:setChecked(config.stopHaste)
conditionsWindow.Hold.StopHaste.onClick = function(widget)
config.stopHaste = not config.stopHaste
widget:setChecked(config.stopHaste)
end
-- buttons
conditionsWindow.closeButton.onClick = function(widget)
conditionsWindow:hide()
vBotConfigSave("heal")
end
end
local utanaCast = nil
macro(500, function()
if not config.enabled or modules.game_cooldown.isGroupCooldownIconActive(2) then return end
if hppercent() > 95 then
if config.curePoison and mana() >= config.poisonCost and isPoisioned() then say("exana pox")
elseif config.cureCurse and mana() >= config.curseCost and isCursed() then say("exana mort")
elseif config.cureBleed and mana() >= config.bleedCost and isBleeding() then say("exana kor")
elseif config.cureBurn and mana() >= config.burnCost and isBurning() then say("exana flam")
elseif config.cureElectrify and mana() >= config.electrifyCost and isEnergized() then say("exana vis")
end
end
if (not config.ignoreInPz or not isInPz()) and config.holdUtura and mana() >= config.uturaCost and not hasPartyBuff() then say(config.uturaType)
elseif (not config.ignoreInPz or not isInPz()) and config.holdUtana and mana() >= config.utanaCost and (not utanaCast or (now - utanaCast > 120000)) then say("utana vid") utanaCast = now
end
end)
macro(50, function()
if not config.enabled then return end
if (not config.ignoreInPz or not isInPz()) and config.holdUtamo and mana() >= config.utamoCost and not hasManaShield() then say("utamo vita")
elseif (not config.ignoreInPz or not isInPz()) and standTime() < 5000 and config.holdHaste and mana() >= config.hasteCost and not hasHaste() and not getSpellCoolDown(config.hasteSpell) and (not target() or not config.stopHaste or TargetBot.isCaveBotActionAllowed()) then say(config.hasteSpell)
elseif config.cureParalyse and mana() >= config.paralyseCost and isParalyzed() and not getSpellCoolDown(config.paralyseSpell) then say(config.paralyseSpell)
end
end)

View File

@ -0,0 +1,527 @@
setDefaultTab("Tools")
local panelName = "renameContainers"
if type(storage[panelName]) ~= "table" then
storage[panelName] = {
enabled = false;
purse = true;
all = true;
list = {
{
value = "Main Backpack",
enabled = true,
item = 9601,
min = false,
items = { 3081, 3048 }
},
{
value = "Runes",
enabled = true,
item = 2866,
min = true,
items = { 3161, 3180 }
},
{
value = "Money",
enabled = true,
item = 2871,
min = true,
items = { 3031, 3035, 3043 }
},
{
value = "Purse",
enabled = true,
item = 23396,
min = true,
items = {}
},
}
}
end
local config = storage[panelName]
local renameContui = setupUI([[
Panel
height: 38
BotSwitch
id: title
anchors.top: parent.top
anchors.left: parent.left
text-align: center
width: 130
!text: tr('Minimise Containers')
Button
id: editContList
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 3
height: 17
text: Setup
Button
id: reopenCont
!text: tr('Reopen Containers')
anchors.left: parent.left
anchors.top: prev.bottom
anchors.right: parent.right
height: 17
margin-top: 3
]])
renameContui:setId(panelName)
g_ui.loadUIFromString([[
BackpackName < Label
background-color: alpha
text-offset: 18 0
focusable: true
height: 16
CheckBox
id: enabled
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: 15
height: 15
margin-top: 2
margin-left: 3
$focus:
background-color: #00000055
Button
id: state
!text: tr('M')
anchors.right: remove.left
margin-right: 5
width: 15
height: 15
Button
id: remove
!text: tr('x')
!tooltip: tr('Remove')
anchors.right: parent.right
margin-right: 15
width: 15
height: 15
ContListsWindow < MainWindow
!text: tr('Container Names')
size: 445 170
@onEscape: self:hide()
TextList
id: itemList
anchors.left: parent.left
anchors.top: parent.top
size: 180 83
margin-top: 3
margin-bottom: 3
margin-left: 3
vertical-scrollbar: itemListScrollBar
VerticalScrollBar
id: itemListScrollBar
anchors.top: itemList.top
anchors.bottom: itemList.bottom
anchors.right: itemList.right
step: 14
pixels-scroll: true
VerticalSeparator
id: sep
anchors.top: parent.top
anchors.left: itemList.right
anchors.bottom: separator.top
margin-top: 3
margin-bottom: 6
margin-left: 10
Label
id: lblName
anchors.left: sep.right
anchors.top: sep.top
width: 70
text: Name:
margin-left: 10
margin-top: 3
TextEdit
id: contName
anchors.left: lblName.right
anchors.top: sep.top
anchors.right: parent.right
Label
id: lblCont
anchors.left: lblName.left
anchors.verticalCenter: contId.verticalCenter
width: 70
text: Container:
BotItem
id: contId
anchors.left: contName.left
anchors.top: contName.bottom
margin-top: 3
BotContainer
id: sortList
anchors.left: prev.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 3
height: 32
Label
anchors.left: lblCont.left
anchors.verticalCenter: prev.verticalCenter
width: 70
text: Items:
Button
id: addItem
anchors.right: contName.right
anchors.top: contName.bottom
margin-top: 5
text: Add
width: 40
font: cipsoftFont
HorizontalSeparator
id: separator
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: closeButton.top
margin-bottom: 8
CheckBox
id: all
anchors.left: parent.left
anchors.bottom: parent.bottom
text: Open All
tooltip: Opens all containers in main backpack.
width: 90
height: 15
margin-top: 2
margin-left: 3
CheckBox
id: purse
anchors.left: prev.right
anchors.bottom: parent.bottom
text: Open Purse
tooltip: Opens Store/Charm Purse
width: 90
height: 15
margin-top: 2
margin-left: 3
CheckBox
id: sort
anchors.left: prev.right
anchors.bottom: parent.bottom
text: Sort Items
tooltip: Sort items based on items widget
width: 90
height: 15
margin-top: 2
margin-left: 15
Button
id: closeButton
!text: tr('Close')
font: cipsoftFont
anchors.right: parent.right
anchors.bottom: parent.bottom
size: 45 21
margin-top: 15
]])
function findItemsInArray(t, tfind)
local tArray = {}
for x,v in pairs(t) do
if type(v) == "table" then
local aItem = t[x].item
local aEnabled = t[x].enabled
if aItem then
if tfind and aItem == tfind then
return x
elseif not tfind then
if aEnabled then
table.insert(tArray, aItem)
end
end
end
end
end
if not tfind then return tArray end
end
local lstBPs
local openContainer = function(id)
local t = {getRight(), getLeft(), getAmmo()} -- if more slots needed then add them here
for i=1,#t do
local slotItem = t[i]
if slotItem and slotItem:getId() == id then
return g_game.open(slotItem, nil)
end
end
for i, container in pairs(g_game.getContainers()) do
for i, item in ipairs(container:getItems()) do
if item:isContainer() and item:getId() == id then
return g_game.open(item, nil)
end
end
end
end
function reopenBackpacks()
lstBPs = findItemsInArray(config.list)
for _, container in pairs(g_game.getContainers()) do g_game.close(container) end
bpItem = getBack()
if bpItem ~= nil then
g_game.open(bpItem)
end
schedule(250, function()
local delay = 200
if config.purse then
local item = getPurse()
if item then
use(item)
end
end
if config.all then
local nextContainers = {}
containers = getContainers()
for i, container in pairs(g_game.getContainers()) do
for i, item in ipairs(container:getItems()) do
if item:isContainer() then
if item:isContainer() and config.all then
table.insert(nextContainers, item)
end
end
end
end
if #nextContainers > 0 then
for i = 1, #nextContainers do
schedule(delay, function()
g_game.open(nextContainers[i], nil)
end)
delay = delay + 250
end
end
else
for i=1,#lstBPs do
schedule(delay, function()
openContainer(lstBPs[i])
end)
delay = delay + 250
end
end
end)
end
rootWidget = g_ui.getRootWidget()
if rootWidget then
contListWindow = UI.createWindow('ContListsWindow', rootWidget)
contListWindow:hide()
renameContui.editContList.onClick = function(widget)
contListWindow:show()
contListWindow:raise()
contListWindow:focus()
end
renameContui.reopenCont.onClick = function(widget)
reopenBackpacks()
end
renameContui.title:setOn(config.enabled)
renameContui.title.onClick = function(widget)
config.enabled = not config.enabled
widget:setOn(config.enabled)
end
contListWindow.closeButton.onClick = function(widget)
contListWindow:hide()
end
contListWindow.purse.onClick = function(widget)
config.purse = not config.purse
contListWindow.purse:setChecked(config.purse)
end
contListWindow.purse:setChecked(config.purse)
contListWindow.sort.onClick = function(widget)
config.sort = not config.sort
contListWindow.sort:setChecked(config.sort)
end
contListWindow.sort:setChecked(config.sort)
contListWindow.all.onClick = function(widget)
config.all = not config.all
contListWindow.all:setChecked(config.all)
label.enabled:setTooltip(config.all and 'Opens all containers in main backpack.' or 'Opens listed containers from main backpack.')
end
contListWindow.all:setChecked(config.all)
local function refreshSortList(k, t)
t = t or {}
UI.Container(function()
t = contListWindow.sortList:getItems()
config.list[k].items = t
end, true, nil, contListWindow.sortList)
contListWindow.sortList:setItems(t)
end
refreshSortList(t)
local refreshContNames = function(tFocus)
local storageVal = config.list
if storageVal and #storageVal > 0 then
for i, child in pairs(contListWindow.itemList:getChildren()) do
child:destroy()
end
for k, entry in pairs(storageVal) do
local label = g_ui.createWidget("BackpackName", contListWindow.itemList)
label.onMouseRelease = function()
contListWindow.contId:setItemId(entry.item)
contListWindow.contName:setText(entry.value)
if not entry.items then
entry.items = {}
end
contListWindow.sortList:setItems(entry.items)
refreshSortList(k, entry.items)
end
label.enabled.onClick = function(widget)
entry.enabled = not entry.enabled
label.enabled:setChecked(entry.enabled)
label.enabled:setTooltip(entry.enabled and 'Disable' or 'Enable')
label.enabled:setImageColor(entry.enabled and '#00FF00' or '#FF0000')
end
label.remove.onClick = function(widget)
table.removevalue(config.list, entry)
label:destroy()
end
label.state:setChecked(entry.min)
label.state.onClick = function(widget)
entry.min = not entry.min
label.state:setChecked(entry.min)
label.state:setColor(entry.min and '#00FF00' or '#FF0000')
label.state:setTooltip(entry.min and 'Open Minimised' or 'Do not minimise')
end
label:setText(entry.value)
label.enabled:setChecked(entry.enabled)
label.enabled:setTooltip(entry.enabled and 'Disable' or 'Enable')
label.enabled:setImageColor(entry.enabled and '#00FF00' or '#FF0000')
label.state:setColor(entry.min and '#00FF00' or '#FF0000')
label.state:setTooltip(entry.min and 'Open Minimised' or 'Do not minimise')
if tFocus and entry.item == tFocus then
tFocus = label
end
end
if tFocus then contListWindow.itemList:focusChild(tFocus) end
end
end
contListWindow.addItem.onClick = function(widget)
local id = contListWindow.contId:getItemId()
local trigger = contListWindow.contName:getText()
if id > 100 and trigger:len() > 0 then
local ifind = findItemsInArray(config.list, id)
if ifind then
config.list[ifind] = { item = id, value = trigger, enabled = config.list[ifind].enabled, min = config.list[ifind].min, items = config.list[ifind].items}
else
table.insert(config.list, { item = id, value = trigger, enabled = true, min = false, items = {} })
end
contListWindow.contId:setItemId(0)
contListWindow.contName:setText('')
contListWindow.contName:setColor('white')
contListWindow.contName:setImageColor('#ffffff')
contListWindow.contId:setImageColor('#ffffff')
refreshContNames(id)
else
contListWindow.contId:setImageColor('red')
contListWindow.contName:setImageColor('red')
contListWindow.contName:setColor('red')
end
end
refreshContNames()
end
onContainerOpen(function(container, previousContainer)
if renameContui.title:isOn() then
if not previousContainer then
if not container.window then return end
containerWindow = container.window
containerWindow:setContentHeight(34)
local storageVal = config.list
if storageVal and #storageVal > 0 then
for _, entry in pairs(storageVal) do
if entry.enabled and string.find(container:getContainerItem():getId(), entry.item) then
if entry.min then
containerWindow:minimize()
end
containerWindow:setText(entry.value)
end
end
end
end
end
end)
local function moveItem(item, destination)
return g_game.move(item, destination:getSlotPosition(destination:getItemsCount()), item:getCount())
end
local function properTable(t)
local r = {}
for _, entry in pairs(t) do
table.insert(r, entry.id)
end
return r
end
macro(100, function()
if not config.sort then return end
local storageVal = config.list
for _, entry in pairs(storageVal) do
local dId = entry.item
local items = properTable(entry.items)
for _, container in pairs(getContainers()) do
local cName = container:getName():lower()
if not cName:find("depot") and not cName:find("depot") and not cName:find("quiver") then
local cId = container:getContainerItem():getId()
for __, item in ipairs(container:getItems()) do
local id = item:getId()
if table.find(items, id) and cId ~= dId then
local destination = getContainerByItem(dId)
if destination and not containerIsFull(destination) then
return moveItem(item, destination)
end
end
end
end
end
end
delay(900)
end)

View File

@ -0,0 +1,146 @@
setDefaultTab("Tools")
local ui = setupUI([[
Panel
height: 19
BotSwitch
id: title
anchors.top: parent.top
anchors.left: parent.left
text-align: center
width: 130
!text: tr('Dropper')
Button
id: edit
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 3
height: 17
text: Edit
]])
local edit = setupUI([[
Panel
height: 150
Label
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
margin-top: 5
text-align: center
text: Trash:
BotContainer
id: TrashItems
anchors.top: prev.bottom
anchors.left: parent.left
anchors.right: parent.right
height: 32
Label
anchors.top: prev.bottom
margin-top: 5
anchors.left: parent.left
anchors.right: parent.right
text-align: center
text: Use:
BotContainer
id: UseItems
anchors.top: prev.bottom
anchors.left: parent.left
anchors.right: parent.right
height: 32
Label
anchors.top: prev.bottom
margin-top: 5
anchors.left: parent.left
anchors.right: parent.right
text-align: center
text: Drop if below 150 cap:
BotContainer
id: CapItems
anchors.top: prev.bottom
anchors.left: parent.left
anchors.right: parent.right
height: 32
]])
edit:hide()
if not storage.dropper then
storage.dropper = {
enabled = false,
trashItems = { 283, 284, 285 },
useItems = { 21203, 14758 },
capItems = { 21175 }
}
end
local config = storage.dropper
local showEdit = false
ui.edit.onClick = function(widget)
showEdit = not showEdit
if showEdit then
edit:show()
else
edit:hide()
end
end
ui.title:setOn(config.enabled)
ui.title.onClick = function(widget)
config.enabled = not config.enabled
ui.title:setOn(config.enabled)
end
UI.Container(function()
config.trashItems = edit.TrashItems:getItems()
end, true, nil, edit.TrashItems)
edit.TrashItems:setItems(config.trashItems)
UI.Container(function()
config.useItems = edit.UseItems:getItems()
end, true, nil, edit.UseItems)
edit.UseItems:setItems(config.useItems)
UI.Container(function()
config.capItems = edit.CapItems:getItems()
end, true, nil, edit.CapItems)
edit.CapItems:setItems(config.capItems)
local function properTable(t)
local r = {}
for _, entry in pairs(t) do
table.insert(r, entry.id)
end
return r
end
macro(200, function()
if not config.enabled then return end
local tables = {properTable(config.capItems), properTable(config.useItems), properTable(config.trashItems)}
local containers = getContainers()
for i=1,3 do
for _, container in pairs(containers) do
for __, item in ipairs(container:getItems()) do
for ___, userItem in ipairs(tables[i]) do
if item:getId() == userItem then
return i == 1 and freecap() < 150 and g_game.move(item, pos(), item:getCount()) or
i == 2 and use(item) or
g_game.move(item, pos(), item:getCount())
end
end
end
end
end
end)

View File

@ -554,7 +554,11 @@ if rootWidget then
end
-- spells
local lastMana = mana()
local standBySpells = false
local iterationsSpells = 0
macro(100, function()
if standBySpells then return end
if not currentSettings.enabled or modules.game_cooldown.isGroupCooldownIconActive(2) or #currentSettings.spellTable == 0 then return end
for _, entry in pairs(currentSettings.spellTable) do
@ -617,13 +621,17 @@ macro(100, function()
end
end
end
standBySpells = true
lastMana = mana()
end)
-- items
local standByItems = false
macro(100, function()
if standByItems then return end
if not currentSettings.enabled or #currentSettings.itemTable == 0 then return end
if currentSettings.Delay and storage.isUsing then return end
if currentSettings.MessageDelay and storage.isUsingPotion then return end
if currentSettings.Delay and vBot.isUsing then return end
if currentSettings.MessageDelay and vBot.isUsingPotion then return end
if not currentSettings.MessageDelay then
delay(400)
@ -698,5 +706,23 @@ macro(100, function()
end
end
end
standByItems = true
lastMana = mana()
end)
UI.Separator()
onAddThing(function(tile, thing)
if thing == player then return end
if getDistanceBetween(tile:getPosition(), player:getPosition()) == 0 then
standByItems = false
standBySpells = false
end
end)
macro(5000, function()
if (standByItems or standBySpells) and mana() >= lastMana then
lastMana = mana()
standByItems = false
standBySpells = false
end
end)

View File

@ -165,7 +165,7 @@ Panel
local function isValid(name)
if not newTibia then return true end
local voc = BotServerMembers[name]
local voc = vBot.BotServerMembers[name]
if not voc then return true end
if voc == 11 then voc = 1

View File

@ -0,0 +1,180 @@
local panelName = "alarms"
local ui = setupUI([[
Panel
height: 19
BotSwitch
id: title
anchors.top: parent.top
anchors.left: parent.left
text-align: center
width: 130
!text: tr('Alarms')
Button
id: alerts
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 3
height: 17
text: Edit
]])
ui:setId(panelName)
if not storage[panelName] then
storage[panelName] = {
enabled = false,
playerAttack = false,
playerDetected = false,
playerDetectedLogout = false,
creatureDetected = false,
healthBelow = false,
healthValue = 40,
manaBelow = false,
manaValue = 50,
privateMessage = false
}
end
local config = storage[panelName]
ui.title:setOn(config.enabled)
ui.title.onClick = function(widget)
config.enabled = not config.enabled
widget:setOn(config.enabled)
end
rootWidget = g_ui.getRootWidget()
if rootWidget then
alarmsWindow = UI.createWindow('AlarmsWindow', rootWidget)
alarmsWindow:hide()
alarmsWindow.closeButton.onClick = function(widget)
alarmsWindow:hide()
end
alarmsWindow.playerAttack:setOn(config.playerAttack)
alarmsWindow.playerAttack.onClick = function(widget)
config.playerAttack = not config.playerAttack
widget:setOn(config.playerAttack)
end
alarmsWindow.playerDetected:setOn(config.playerDetected)
alarmsWindow.playerDetected.onClick = function(widget)
config.playerDetected = not config.playerDetected
widget:setOn(config.playerDetected)
end
alarmsWindow.playerDetectedLogout:setChecked(config.playerDetectedLogout)
alarmsWindow.playerDetectedLogout.onClick = function(widget)
config.playerDetectedLogout = not config.playerDetectedLogout
widget:setChecked(config.playerDetectedLogout)
end
alarmsWindow.creatureDetected:setOn(config.creatureDetected)
alarmsWindow.creatureDetected.onClick = function(widget)
config.creatureDetected = not config.creatureDetected
widget:setOn(config.creatureDetected)
end
alarmsWindow.healthBelow:setOn(config.healthBelow)
alarmsWindow.healthBelow.onClick = function(widget)
config.healthBelow = not config.healthBelow
widget:setOn(config.healthBelow)
end
alarmsWindow.healthValue.onValueChange = function(scroll, value)
config.healthValue = value
alarmsWindow.healthBelow:setText("Health < " .. config.healthValue .. "%")
end
alarmsWindow.healthValue:setValue(config.healthValue)
alarmsWindow.manaBelow:setOn(config.manaBelow)
alarmsWindow.manaBelow.onClick = function(widget)
config.manaBelow = not config.manaBelow
widget:setOn(config.manaBelow)
end
alarmsWindow.manaValue.onValueChange = function(scroll, value)
config.manaValue = value
alarmsWindow.manaBelow:setText("Mana < " .. config.manaValue .. "%")
end
alarmsWindow.manaValue:setValue(config.manaValue)
alarmsWindow.privateMessage:setOn(config.privateMessage)
alarmsWindow.privateMessage.onClick = function(widget)
config.privateMessage = not config.privateMessage
widget:setOn(config.privateMessage)
end
onTextMessage(function(mode, text)
if config.enabled and config.playerAttack and mode == 16 and string.match(text, "hitpoints due to an attack") and not string.match(text, "hitpoints due to an attack by a ") then
playSound("/sounds/Player_Attack.ogg")
end
end)
macro(100, function()
if not config.enabled then
return
end
if config.playerDetected then
for _, spec in ipairs(getSpectators()) do
if spec:isPlayer() and spec:getName() ~= name() then
specPos = spec:getPosition()
if math.max(math.abs(posx()-specPos.x), math.abs(posy()-specPos.y)) <= 8 then
playSound("/sounds/Player_Detected.ogg")
delay(1500)
if config.playerDetectedLogout then
modules.game_interface.tryLogout(false)
end
return
end
end
end
end
if config.creatureDetected then
for _, spec in ipairs(getSpectators()) do
if not spec:isPlayer()then
specPos = spec:getPosition()
if math.max(math.abs(posx()-specPos.x), math.abs(posy()-specPos.y)) <= 8 then
playSound("/sounds/Creature_Detected.ogg")
delay(1500)
return
end
end
end
end
if config.healthBelow then
if hppercent() <= config.healthValue then
playSound("/sounds/Low_Health.ogg")
delay(1500)
return
end
end
if config.manaBelow then
if manapercent() <= config.manaValue then
playSound("/sounds/Low_Mana.ogg")
delay(1500)
return
end
end
end)
onTalk(function(name, level, mode, text, channelId, pos)
if mode == 4 and config.enabled and config.privateMessage then
playSound("/sounds/Private_Message.ogg")
return
end
end)
end
ui.alerts.onClick = function(widget)
alarmsWindow:show()
alarmsWindow:raise()
alarmsWindow:focus()
end

View File

@ -5,7 +5,6 @@ local frags = 0
onTextMessage(function(mode, text)
if not m.isOn() then return end
if not text:lower():find("warning! the murder of") then return end
info(text)
say("Don't bother, I have anti-rs and shit EQ. Don't waste our time.")
frags = frags + 1
if killsToRs() < 6 or frags > 1 then

View File

@ -0,0 +1,443 @@
setDefaultTab("Main")
local panelName = "combobot"
local ui = setupUI([[
Panel
height: 19
BotSwitch
id: title
anchors.top: parent.top
anchors.left: parent.left
text-align: center
width: 130
!text: tr('ComboBot')
Button
id: combos
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 3
height: 17
text: Setup
]])
ui:setId(panelName)
if not storage[panelName] then
storage[panelName] = {
enabled = false,
onSayEnabled = false,
onShootEnabled = false,
onCastEnabled = false,
followLeaderEnabled = false,
attackLeaderTargetEnabled = false,
attackSpellEnabled = false,
attackItemToggle = false,
sayLeader = "",
shootLeader = "",
castLeader = "",
sayPhrase = "",
spell = "",
serverLeader = "",
item = 3155,
attack = "",
follow = "",
commandsEnabled = true,
serverEnabled = false,
serverLeaderTarget = false,
serverTriggers = true
}
end
local config = storage[panelName]
ui.title:setOn(config.enabled)
ui.title.onClick = function(widget)
config.enabled = not config.enabled
widget:setOn(config.enabled)
end
ui.combos.onClick = function(widget)
comboWindow:show()
comboWindow:raise()
comboWindow:focus()
end
rootWidget = g_ui.getRootWidget()
if rootWidget then
comboWindow = UI.createWindow('ComboWindow', rootWidget)
comboWindow:hide()
-- bot item
comboWindow.actions.attackItem:setItemId(config.item)
comboWindow.actions.attackItem.onItemChange = function(widget)
config.item = widget:getItemId()
end
-- switches
comboWindow.actions.commandsToggle:setOn(config.commandsEnabled)
comboWindow.actions.commandsToggle.onClick = function(widget)
config.commandsEnabled = not config.commandsEnabled
widget:setOn(config.commandsEnabled)
end
comboWindow.server.botServerToggle:setOn(config.serverEnabled)
comboWindow.server.botServerToggle.onClick = function(widget)
config.serverEnabled = not config.serverEnabled
widget:setOn(config.serverEnabled)
end
comboWindow.server.Triggers:setOn(config.serverTriggers)
comboWindow.server.Triggers.onClick = function(widget)
config.serverTriggers = not config.serverTriggers
widget:setOn(config.serverTriggers)
end
comboWindow.server.targetServerLeaderToggle:setOn(config.serverLeaderTarget)
comboWindow.server.targetServerLeaderToggle.onClick = function(widget)
config.serverLeaderTarget = not config.serverLeaderTarget
widget:setOn(config.serverLeaderTarget)
end
-- buttons
comboWindow.closeButton.onClick = function(widget)
comboWindow:hide()
end
-- combo boxes
comboWindow.actions.followLeader:setOption(config.follow)
comboWindow.actions.followLeader.onOptionChange = function(widget)
config.follow = widget:getCurrentOption().text
end
comboWindow.actions.attackLeaderTarget:setOption(config.attack)
comboWindow.actions.attackLeaderTarget.onOptionChange = function(widget)
config.attack = widget:getCurrentOption().text
end
-- checkboxes
comboWindow.trigger.onSayToggle:setChecked(config.onSayEnabled)
comboWindow.trigger.onSayToggle.onClick = function(widget)
config.onSayEnabled = not config.onSayEnabled
widget:setChecked(config.onSayEnabled)
end
comboWindow.trigger.onShootToggle:setChecked(config.onShootEnabled)
comboWindow.trigger.onShootToggle.onClick = function(widget)
config.onShootEnabled = not config.onShootEnabled
widget:setChecked(config.onShootEnabled)
end
comboWindow.trigger.onCastToggle:setChecked(config.onCastEnabled)
comboWindow.trigger.onCastToggle.onClick = function(widget)
config.onCastEnabled = not config.onCastEnabled
widget:setChecked(config.onCastEnabled)
end
comboWindow.actions.followLeaderToggle:setChecked(config.followLeaderEnabled)
comboWindow.actions.followLeaderToggle.onClick = function(widget)
config.followLeaderEnabled = not config.followLeaderEnabled
widget:setChecked(config.followLeaderEnabled)
end
comboWindow.actions.attackLeaderTargetToggle:setChecked(config.attackLeaderTargetEnabled)
comboWindow.actions.attackLeaderTargetToggle.onClick = function(widget)
config.attackLeaderTargetEnabled = not config.attackLeaderTargetEnabled
widget:setChecked(config.attackLeaderTargetEnabled)
end
comboWindow.actions.attackSpellToggle:setChecked(config.attackSpellEnabled)
comboWindow.actions.attackSpellToggle.onClick = function(widget)
config.attackSpellEnabled = not config.attackSpellEnabled
widget:setChecked(config.attackSpellEnabled)
end
comboWindow.actions.attackItemToggle:setChecked(config.attackItemEnabled)
comboWindow.actions.attackItemToggle.onClick = function(widget)
config.attackItemEnabled = not config.attackItemEnabled
widget:setChecked(config.attackItemEnabled)
end
-- text edits
comboWindow.trigger.onSayLeader:setText(config.sayLeader)
comboWindow.trigger.onSayLeader.onTextChange = function(widget, text)
config.sayLeader = text
end
comboWindow.trigger.onShootLeader:setText(config.shootLeader)
comboWindow.trigger.onShootLeader.onTextChange = function(widget, text)
config.shootLeader = text
end
comboWindow.trigger.onCastLeader:setText(config.castLeader)
comboWindow.trigger.onCastLeader.onTextChange = function(widget, text)
config.castLeader = text
end
comboWindow.trigger.onSayPhrase:setText(config.sayPhrase)
comboWindow.trigger.onSayPhrase.onTextChange = function(widget, text)
config.sayPhrase = text
end
comboWindow.actions.attackSpell:setText(config.spell)
comboWindow.actions.attackSpell.onTextChange = function(widget, text)
config.spell = text
end
comboWindow.server.botServerLeader:setText(config.serverLeader)
comboWindow.server.botServerLeader.onTextChange = function(widget, text)
config.serverLeader = text
end
end
-- bot server
-- [[ join party made by Frosty ]] --
local shouldCloseWindow = false
local firstInvitee = true
local isInComboTeam = false
macro(10, function()
if shouldCloseWindow and config.serverEnabled and config.enabled then
local channelsWindow = modules.game_console.channelsWindow
if channelsWindow then
local child = channelsWindow:getChildById("buttonCancel")
if child then
child:onClick()
shouldCloseWindow = false
isInComboTeam = true
end
end
end
end)
comboWindow.server.partyButton.onClick = function(widget)
if config.serverEnabled and config.enabled then
if config.serverLeader:len() > 0 and storage.BotServerChannel:len() > 0 then
talkPrivate(config.serverLeader, "request invite " .. storage.BotServerChannel)
else
error("Request failed. Lack of data.")
end
end
end
onTextMessage(function(mode, text)
if config.serverEnabled and config.enabled then
if mode == 20 then
if string.find(text, "invited you to") then
local regex = "[a-zA-Z]*"
local regexData = regexMatch(text, regex)
if regexData[1][1]:lower() == config.serverLeader:lower() then
local leader = getCreatureByName(regexData[1][1])
if leader then
g_game.partyJoin(leader:getId())
g_game.requestChannels()
g_game.joinChannel(1)
shouldCloseWindow = true
end
end
end
end
end
end)
onTalk(function(name, level, mode, text, channelId, pos)
if config.serverEnabled and config.enabled then
if mode == 4 then
if string.find(text, "request invite") then
local access = string.match(text, "%d.*")
if access and access == storage.BotServerChannel then
local minion = getCreatureByName(name)
if minion then
g_game.partyInvite(minion:getId())
if firstInvitee then
g_game.requestChannels()
g_game.joinChannel(1)
shouldCloseWindow = true
firstInvitee = false
end
end
else
talkPrivate(name, "Incorrect access key!")
end
end
end
end
-- [[ End of Frosty's Code ]] --
if config.enabled and config.enabled then
if name:lower() == config.sayLeader:lower() and string.find(text, config.sayPhrase) and config.onSayEnabled then
startCombo = true
end
if (config.castLeader and name:lower() == config.castLeader:lower()) and isAttSpell(text) and config.onCastEnabled then
startCombo = true
end
end
if config.enabled and config.commandsEnabled and (config.shootLeader and name:lower() == config.shootLeader:lower()) or (config.sayLeader and name:lower() == config.sayLeader:lower()) or (config.castLeader and name:lower() == config.castLeader:lower()) then
if string.find(text, "ue") then
say(config.spell)
elseif string.find(text, "sd") then
local params = string.split(text, ",")
if #params == 2 then
local target = params[2]:trim()
if getCreatureByName(target) then
useWith(3155, getCreatureByName(target))
end
end
elseif string.find(text, "att") then
local attParams = string.split(text, ",")
if #attParams == 2 then
local atTarget = attParams[2]:trim()
if getCreatureByName(atTarget) and config.attack == "COMMAND TARGET" then
g_game.attack(getCreatureByName(atTarget))
end
end
end
end
if isAttSpell(text) and config.enabled and config.serverEnabled then
BotServer.send("trigger", "start")
end
end)
onMissle(function(missle)
if config.enabled and config.onShootEnabled then
if not config.shootLeader or config.shootLeader:len() == 0 then
return
end
local src = missle:getSource()
if src.z ~= posz() then
return
end
local from = g_map.getTile(src)
local to = g_map.getTile(missle:getDestination())
if not from or not to then
return
end
local fromCreatures = from:getCreatures()
local toCreatures = to:getCreatures()
if #fromCreatures ~= 1 or #toCreatures ~= 1 then
return
end
local c1 = fromCreatures[1]
local t1 = toCreatures[1]
leaderTarget = t1
if c1:getName():lower() == config.shootLeader:lower() then
if config.attackItemEnabled and config.item and config.item > 100 and findItem(config.item) then
useWith(config.item, t1)
end
if config.attackSpellEnabled and config.spell:len() > 1 then
say(config.spell)
end
end
end
end)
macro(10, function()
if not config.enabled or not config.attackLeaderTargetEnabled then return end
if leaderTarget and config.attack == "LEADER TARGET" then
if not getTarget() or (getTarget() and getTarget():getName() ~= leaderTarget:getName()) then
g_game.attack(leaderTarget)
end
end
if config.enabled and config.serverEnabled and config.attack == "SERVER LEADER TARGET" and serverTarget then
if serverTarget and not getTarget() or (getTarget() and getTarget():getname() ~= serverTarget)
then
g_game.attack(serverTarget)
end
end
end)
local toFollow
local toFollowPos = {}
macro(100, function()
toFollow = nil
if not config.enabled or not config.followLeaderEnabled then return end
if leaderTarget and config.follow == "LEADER TARGET" and leaderTarget:isPlayer() then
toFollow = leaderTarget:getName()
elseif config.follow == "SERVER LEADER TARGET" and config.serverLeader:len() ~= 0 then
toFollow = serverTarget
elseif config.follow == "SERVER LEADER" and config.serverLeader:len() ~= 0 then
toFollow = config.serverLeader
elseif config.follow == "LEADER" then
if config.onSayEnabled and config.sayLeader:len() ~= 0 then
toFollow = config.sayLeader
elseif config.onCastEnabled and config.castLeader:len() ~= 0 then
toFollow = config.castLeader
elseif config.onShootEnabled and config.shootLeader:len() ~= 0 then
toFollow = config.shootLeader
end
end
if not toFollow then return end
local target = getCreatureByName(toFollow)
if target then
local tpos = target:getPosition()
toFollowPos[tpos.z] = tpos
end
if player:isWalking() then return end
local p = toFollowPos[posz()]
if not p then return end
if CaveBot.walkTo(p, 20, {ignoreNonPathable=true, precision=1, ignoreStairs=false}) then
delay(100)
end
end)
onCreaturePositionChange(function(creature, oldPos, newPos)
if creature:getName() == toFollow and newPos then
toFollowPos[newPos.z] = newPos
end
end)
local timeout = now
macro(10, function()
if config.enabled and startCombo then
if config.attackItemEnabled and config.item and config.item > 100 and findItem(config.item) then
useWith(config.item, getTarget())
end
if config.attackSpellEnabled and config.spell:len() > 1 then
say(config.spell)
end
startCombo = false
end
-- attack part / server
if BotServer._websocket and config.enabled and config.serverEnabled then
if target() and now - timeout > 500 then
targetPos = target():getName()
BotServer.send("target", targetPos)
timeout = now
end
end
end)
onUseWith(function(pos, itemId, target, subType)
if BotServer._websocket and itemId == 3155 then
BotServer.send("useWith", target:getPosition())
end
end)
if BotServer._websocket and config.enabled and config.serverEnabled then
BotServer.listen("trigger", function(name, message)
if message == "start" and name:lower() ~= player:getName():lower() and name:lower() == config.serverLeader:lower() and config.serverTriggers then
startCombo = true
end
end)
BotServer.listen("target", function(name, message)
if name:lower() ~= player:getName():lower() and name:lower() == config.serverLeader:lower() then
if not target() or target():getName() == getCreatureByName(message) then
if config.serverLeaderTarget then
serverTarget = getCreatureByName(message)
g_game.attack(getCreatureByName(message))
end
end
end
end)
BotServer.listen("useWith", function(name, message)
local tile = g_map.getTile(message)
if config.serverTriggers and name:lower() ~= player:getName():lower() and name:lower() == config.serverLeader:lower() and config.attackItemEnabled and config.item and findItem(config.item) then
useWith(config.item, tile:getTopUseThing())
end
end)
end

View File

@ -0,0 +1,65 @@
setDefaultTab("Cave")
local panelName = "specialDeposit"
local depositerPanel
UI.Button("Depositer Settings", function()
depositerPanel:show()
depositerPanel:raise()
depositerPanel:focus()
end)
if not storage[panelName] then
storage[panelName] = {
items = {}
}
end
local config = storage[panelName]
local rootWidget = g_ui.getRootWidget()
if rootWidget then
depositerPanel = UI.createWindow('DepositerPanel', rootWidget)
depositerPanel:hide()
-- basic one
depositerPanel.CloseButton.onClick = function()
depositerPanel:hide()
end
if config.items and #config.items > 0 then
for _, value in ipairs(config.items) do
local label = g_ui.createWidget("ItemLabel", depositerPanel.DepositerList)
label.remove.onClick = function(widget)
table.remove(config.items, table.find(value))
label:destroy()
end
label:setText("Stash (".. value.id .. ") to depot: (" .. value.index .. ")")
end
end
depositerPanel.Add.onClick = function(widget)
local itemId = depositerPanel.ID:getItemId()
local index = tonumber(depositerPanel.Index:getText())
if index and itemId > 100 and not config.items[itemId] then
local value = {id=itemId,index=index}
table.insert(config.items, value)
local label = g_ui.createWidget("ItemLabel", depositerPanel.DepositerList)
label.remove.onClick = function(widget)
table.remove(config.items, table.find(value))
label:destroy()
end
label:setText("Stash (".. itemId .. ") to depot: (" .. index..")")
depositerPanel.ID:setItemId(0)
depositerPanel.Index:setText(0)
end
end
end
function getStashingIndex(id)
for _, v in pairs(config.items) do
if v.id == id then
return v.index - 1
end
end
end

View File

@ -0,0 +1,86 @@
ItemLabel < Label
background-color: alpha
text-offset: 2 0
focusable: true
height: 16
$focus:
background-color: #00000055
Button
id: remove
!text: tr('x')
anchors.right: parent.right
margin-right: 15
width: 15
height: 15
DepositerPanel < MainWindow
size: 250 450
!text: tr('Depositer Panel')
@onEscape: self:hide()
TextList
id: DepositerList
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
margin-top: 15
margin-bottom: 5
margin-right: 3
padding: 1
height: 300
vertical-scrollbar: DepositerScrollBar
VerticalScrollBar
id: DepositerScrollBar
anchors.top: DepositerList.top
anchors.bottom: DepositerList.bottom
anchors.right: DepositerList.right
step: 14
pixels-scroll: true
BotItem
id: ID
anchors.top: DepositerList.bottom
margin-top: 3
anchors.left: DepositerList.left
SpinBox
id: Index
anchors.top: DepositerList.bottom
margin-top: 3
anchors.left: prev.right
margin-left: 3
anchors.bottom: prev.bottom
width: 50
minimum: 3
maximum: 17
step: 1
text-align: center
Button
id: Add
anchors.top: DepositerList.bottom
margin-top: 3
anchors.left: prev.right
margin-left: 3
anchors.right: DepositerList.right
anchors.bottom: prev.bottom
!text: tr('Add Item')
HorizontalSeparator
anchors.bottom: CloseButton.top
margin-bottom: 5
anchors.left: parent.left
anchors.right: parent.right
Button
id: CloseButton
anchors.right: parent.right
anchors.bottom: parent.bottom
margin-right: 5
margin-bottom: 5
!text: tr('Close')
font: cipsoftFont
size: 41 25

View File

@ -17,7 +17,8 @@ if voc == 1 or voc == 11 then
end)
macro(500, "ExetaIfPlayer", function()
if getMonsters(6) >= 1 and getPlayers(6) > 0 then
if CaveBot.isOff() then return end
if getMonsters(1) >= 1 and getPlayers(6) > 0 then
say("exeta res")
delay(6000)
end

View File

@ -92,6 +92,9 @@ addItem("machete", "Machete Item", 9596, leftPanel)
addItem("scythe", "Scythe Item", 9596, leftPanel)
addScrollBar("talkDelay", "Global NPC Talk Delay", 0, 2000, 1000, leftPanel)
addScrollBar("looting", "Max Loot Distance", 0, 50, 40, leftPanel)
addScrollBar("huntRoutes", "Hunting Routes Limit", 0, 300, 50, leftPanel)
addScrollBar("killUnder", "Kill monsters below", 0, 100, 30, leftPanel)
addCheckBox("lootLast", "Start loot from last corpse", true, leftPanel)
addCheckBox("title", "Custom Window Title", true, rightPanel)
if true then
@ -127,7 +130,8 @@ if true then
6257, 6256, 2772, 27260, 2773, 1632, 1633, 1948, 435, 6252, 6253, 5007, 4911,
1629, 1630, 5108, 5107, 5281, 1968, 435, 1948, 5542, 31116, 31120, 30742, 31115,
31118, 20474, 5737, 5736, 5734, 5733, 31202, 31228, 31199, 31200, 33262, 30824,
5125, 5126, 5116, 5117, 8257, 8258, 8255, 8256, 5120, 30777, 30776}
5125, 5126, 5116, 5117, 8257, 8258, 8255, 8256, 5120, 30777, 30776, 23873, 23877,
5736, 6264, 31262, 31130, 31129, 6250, 6249, 5122, 30049}
local shovelId = {606, 593, 867}
local ropeId = {17238, 12202, 12935, 386, 421, 21966, 14238}
local macheteId = {2130, 3696}
@ -218,7 +222,7 @@ end
addCheckBox("stake", "Skin Monsters", false, leftPanel)
if true then
local knifeBodies = {4272, 4173, 4011, 4025, 4047, 4052, 4057, 4062, 4112, 4212, 4321, 4324, 4327, 10352, 10356, 10360, 10364}
local knifeBodies = {4286, 4272, 4173, 4011, 4025, 4047, 4052, 4057, 4062, 4112, 4212, 4321, 4324, 4327, 10352, 10356, 10360, 10364}
local stakeBodies = {4097, 4137, 8738, 18958}
local fishingBodies = {9582}
macro(500, function()
@ -281,7 +285,8 @@ if true then
local doorsIds = { 5007, 8265, 1629, 1632, 5129, 6252, 6249, 7715, 7712, 7714,
7719, 6256, 1669, 1672, 5125, 5115, 5124, 17701, 17710, 1642,
6260, 5107, 4912, 6251, 5291, 1683, 1696, 1692, 5006, 2179, 5116,
1632, 11705, 30772, 30774, 6248, 5735, 5732, 5120 }
1632, 11705, 30772, 30774, 6248, 5735, 5732, 5120, 23873, 5736,
6264, 5122, 30049, 30042 }
function checkForDoors(pos)
local tile = g_map.getTile(pos)
@ -432,3 +437,69 @@ if true then
end)
end
addCheckBox("checkPlayer", "Check Players", true, rightPanel)
if true then
local function checkPlayers()
local found = false
for i, spec in ipairs(getSpectators()) do
if spec:isPlayer() and spec:getText() == "" and spec:getPosition().z == posz() and spec ~= player then
g_game.look(spec)
found = true
end
end
if found then
schedule(20, function() modules.game_textmessage.clearMessages() end)
schedule(40, function() modules.game_textmessage.clearMessages() end)
schedule(60, function() modules.game_textmessage.clearMessages() end)
end
end
checkPlayers()
onPlayerPositionChange(function(x,y)
if not settings.checkPlayer then return end
if x.z ~= y.z then
schedule(20, function() checkPlayers() end)
end
end)
onCreatureAppear(function(creature)
if not settings.checkPlayer then return end
local found = false
if creature:isPlayer() and creature:getText() == "" and creature:getPosition().z == posz() and creature ~= player then
g_game.look(creature)
found = true
end
if found then
schedule(20, function() modules.game_textmessage.clearMessages() end)
schedule(40, function() modules.game_textmessage.clearMessages() end)
schedule(60, function() modules.game_textmessage.clearMessages() end)
end
end)
local regex = [[You see ([a-z 'A-z-]*) \(Level ([0-9]*)\)]]
onTextMessage(function(mode, text)
if not settings.checkPlayer then return end
if mode ~= 20 then return end
local re = regexMatch(text, regex)
if #re ~= 0 then
local name = re[1][2]
local level = re[1][3]
local voc
if text:lower():find("sorcerer") then
voc = "MS"
elseif text:lower():find("druid") then
voc = "ED"
elseif text:lower():find("knight") then
voc = "EK"
elseif text:lower():find("paladin") then
voc = "RP"
end
local creature = getCreatureByName(name)
if creature then
creature:setText(level..voc)
end
end
end)
end

View File

@ -1,3 +1,3 @@
UI.Label("vBot 2.11 \n Vithrax#5814")
UI.Label("vBot 3.01 \n Vithrax#5814")
UI.Button("Official OTCv8 Discord!", function() g_platform.openUrl("https://discord.gg/yhqBE4A") end)
UI.Separator()

View File

@ -15,6 +15,12 @@ CaveBot = {} -- global namespace
-- local variables, constants and functions, used by global functions
local LOCKERS_LIST = {3497, 3498, 3499, 3500}
local LOCKER_ACCESSTILE_MODIFIERS = {
[3497] = {0,-1},
[3498] = {1,0},
[3499] = {0,1},
[3500] = {-1,0}
}
local function CaveBotConfigParse()
local name = storage["_configs"]["targetbot_configs"]["selected"]
@ -76,6 +82,23 @@ function CaveBot.GetLootItems()
return returnTable
end
--- Checks whether player has any visible items to be stashed
-- @return boolean
function CaveBot.HasLootItems()
for _, container in pairs(getContainers()) do
local name = container:getName():lower()
if not name:find("depot") and not name:find("your inbox") then
for _, item in pairs(container:getItems()) do
local id = item:getId()
if table.find(CaveBot.GetLootItems(), id) then
return true
end
end
end
end
end
--- Parses config and extracts loot containers.
-- @return table
function CaveBot.GetLootContainers()
@ -152,7 +175,6 @@ function CaveBot.OpenLootContainer()
for _, item in pairs(container:getItems()) do
local id = item:getId()
if table.find(containers, id) and not table.find(t, id) then
test()
return g_game.open(item)
end
end
@ -185,7 +207,7 @@ function CaveBot.GoTo(position, precision)
if not precision then
precision = 3
end
return CaveBot.walkTo(position, 20, {ignoreNonPathable = true, precision = precision})
return CaveBot.walkTo(position, 20, {ignoreCreatures = true, precision = precision})
end
--- Finds position of npc by name and reaches its position.
@ -213,6 +235,9 @@ end
--- Reaches closest locker.
-- @return void(acion) or boolean
local depositerLockerTarget = nil
local depositerLockerReachRetries = 0
function CaveBot.ReachDepot()
local pPos = player:getPosition()
local tiles = getNearTiles(player:getPosition())
@ -220,31 +245,53 @@ function CaveBot.ReachDepot()
for i, tile in pairs(tiles) do
for i, item in pairs(tile:getItems()) do
if table.find(LOCKERS_LIST, item:getId()) then
depositerLockerTarget = nil
depositerLockerReachRetries = 0
return true -- if near locker already then return function
end
end
end
local candidate = {}
if depositerLockerReachRetries > 20 then
depositerLockerTarget = nil
depositerLockerReachRetries = 0
end
local candidates = {}
if not depositerLockerTarget or distanceFromPlayer(depositerLockerTarget, pPos) > 12 then
for i, tile in pairs(g_map.getTiles(posz())) do
local tPos = tile:getPosition()
local distance = getDistanceBetween(pPos, tPos)
for i, item in pairs(tile:getItems()) do
if table.find(LOCKERS_LIST, item:getId()) then
if findPath(pos(), tPos, 10, {ignoreNonPathable = true, precision = 1}) then
if #candidate == 0 or candidate.dist < distance then
candidate = {pos = tPos, dist = distance}
local lockerTilePos = tile:getPosition()
lockerTilePos.x = lockerTilePos.x + LOCKER_ACCESSTILE_MODIFIERS[item:getId()][1]
lockerTilePos.y = lockerTilePos.y + LOCKER_ACCESSTILE_MODIFIERS[item:getId()][2]
local lockerTile = g_map.getTile(lockerTilePos)
if not lockerTile:hasCreature() then
if findPath(pos(), tPos, 20, {ignoreNonPathable = false, precision = 1, ignoreCreatures = true}) then
local distance = getDistanceBetween(tPos, pPos)
table.insert(candidates, {pos=tPos, dist=distance})
end
end
end
end
end
if candidate.pos then
if not CaveBot.MatchPosition(candidate.pos) then
CaveBot.GoTo(candidate.pos, 1)
if #candidates > 1 then
table.sort(candidates, function(a,b) return a.dist < b.dist end)
end
end
depositerLockerTarget = depositerLockerTarget or candidates[1].pos
if depositerLockerTarget then
if not CaveBot.MatchPosition(depositerLockerTarget) then
depositerLockerReachRetries = depositerLockerReachRetries + 1
return CaveBot.GoTo(depositerLockerTarget, 1)
else
depositerLockerReachRetries = 0
depositerLockerTarget = nil
return true
end
end
@ -319,7 +366,7 @@ end
function CaveBot.OpenDepotBox(index)
local depot = getContainerByName("Depot chest")
if not depot then
return CaveBot.OpenDepotChest()
return CaveBot.ReachAndOpenDepot()
end
local foundParent = false
@ -364,13 +411,10 @@ end
-- @param destination is object
-- @return void
function CaveBot.StashItem(item, index, destination)
local depotContainer
if not destination then
depotContainer = getContainerByName("Depot chest")
end
if not depotContainer then return false end
destination = destination or getContainerByName("Depot chest")
if not destination then return false end
return g_game.move(item, depotContainer:getSlotPosition(index), item:getCount())
return g_game.move(item, destination:getSlotPosition(index), item:getCount())
end
--- Withdraws item from depot chest or mail inbox.
@ -414,7 +458,6 @@ function CaveBot.WithdrawItem(id, amount, fromDepot, destination)
end
local toMove = amount - itemCount
info(toMove)
for i, item in pairs(depot:getItems()) do
if item:getId() == id then
return g_game.move(item, destination:getSlotPosition(destination:getItemsCount()), math.min(toMove, item:getCount()))

View File

@ -0,0 +1,5 @@
onAttackingCreatureChange(function(creature, OldCreature)
if creature and creature:isNpc() and distanceFromPlayer(creature:getPosition()) <= 3 then
CaveBot.Conversation("hi", "trade")
end
end)

View File

@ -54,7 +54,7 @@ Panel
specOutfit.legs = 88
specOutfit.feet = 88
if storage.BOTserver.outfit then
local voc = BotServerMembers[spec:getName()]
local voc = vBot.BotServerMembers[spec:getName()]
specOutfit.addons = 3
if voc == 1 then
specOutfit.type = 131
@ -98,7 +98,7 @@ Panel
specOutfit.legs = 88
specOutfit.feet = 88
if storage.BOTserver.outfit then
local voc = BotServerMembers[creature:getName()]
local voc = vBot.BotServerMembers[creature:getName()]
specOutfit.addons = 3
if voc == 1 then
specOutfit.type = 131

View File

@ -35,10 +35,12 @@ if not storage[panelName] then
}
end
ui.title:setOn(storage[panelName].enabled)
local config = storage[panelName]
ui.title:setOn(config.enabled)
ui.title.onClick = function(widget)
storage[panelName].enabled = not storage[panelName].enabled
widget:setOn(storage[panelName].enabled)
config.enabled = not config.enabled
widget:setOn(config.enabled)
end
ui.push.onClick = function(widget)
@ -57,34 +59,34 @@ if rootWidget then
end
local updateDelayText = function()
pushWindow.delayText:setText("Push Delay: ".. storage[panelName].pushDelay)
pushWindow.delayText:setText("Push Delay: ".. config.pushDelay)
end
updateDelayText()
pushWindow.delay.onValueChange = function(scroll, value)
storage[panelName].pushDelay = value
config.pushDelay = value
updateDelayText()
end
pushWindow.delay:setValue(storage[panelName].pushDelay)
pushWindow.delay:setValue(config.pushDelay)
pushWindow.runeId.onItemChange = function(widget)
storage[panelName].pushMaxRuneId = widget:getItemId()
config.pushMaxRuneId = widget:getItemId()
end
pushWindow.runeId:setItemId(storage[panelName].pushMaxRuneId)
pushWindow.runeId:setItemId(config.pushMaxRuneId)
pushWindow.mwallId.onItemChange = function(widget)
storage[panelName].mwallBlockId = widget:getItemId()
config.mwallBlockId = widget:getItemId()
end
pushWindow.mwallId:setItemId(storage[panelName].mwallBlockId)
pushWindow.mwallId:setItemId(config.mwallBlockId)
pushWindow.hotkey.onTextChange = function(widget, text)
storage[panelName].pushMaxKey = text
config.pushMaxKey = text
end
pushWindow.hotkey:setText(storage[panelName].pushMaxKey)
pushWindow.hotkey:setText(config.pushMaxKey)
end
-- variables for config
local config = storage[panelName]
local config = config
local pushDelay = tonumber(config.pushDelay)
local rune = tonumber(config.pushMaxRuneId)
local customMwall = config.mwallBlockId
@ -189,9 +191,9 @@ macro(20, function()
local topThing = targetTile:getTopUseThing():getId()
if topThing == 2129 or topThing == 2130 or topThing == customMwall then
if targetTile:getTimer() < pushDelay+500 then
storage.isUsing = true
vBot.isUsing = true
schedule(pushDelay+700, function()
storage.isUsing = false
vBot.isUsing = false
end)
end
if targetTile:getTimer() > pushDelay then

View File

@ -0,0 +1,111 @@
setDefaultTab("Tools")
function quiverManager()
local panelName = "quiverManager"
local ui = setupUI([[
Panel
height: 33
margin-top: 2
BotItem
id: BoltsID
anchors.left: parent.left
anchors.top: parent.top
BotItem
id: ArrowsID
anchors.left: prev.right
anchors.verticalCenter: prev.verticalCenter
BotSwitch
id: BoltsSwitch
anchors.top: parent.top
anchors.bottom: prev.verticalCenter
anchors.right: parent.right
text: Sort Bolts
BotSwitch
id: ArrowsSwitch
anchors.top: prev.bottom
anchors.bottom: ArrowsID.bottom
anchors.right: parent.right
text: Sort Arrows
]]
)
ui:setId(panelName)
if not storage[panelName] then
storage[panelName] = {
arrowsId = 35848,
boltsId = 35849,
bolts = false,
arrows = false
}
end
local config = storage[panelName]
ui.BoltsSwitch:setOn(config.bolts)
ui.BoltsSwitch.onClick = function(widget)
config.bolts = not config.bolts
widget:setOn(config.bolts)
end
ui.ArrowsSwitch:setOn(config.arrows)
ui.ArrowsSwitch.onClick = function(widget)
config.arrows = not config.arrows
widget:setOn(config.arrows)
end
ui.BoltsID:setItemId(config.boltsId)
ui.BoltsID.onItemChange = function(widget)
config.boltsId = widget:getItemId()
end
ui.ArrowsID:setItemId(config.arrowsId)
ui.ArrowsID.onItemChange = function(widget)
config.arrowsId = widget:getItemId()
end
local arrows = {16143, 763, 761, 7365, 3448, 762, 21470, 7364, 14251, 3447, 3449, 15793, 25757, 774, 35901}
local bolts = {6528, 7363, 3450, 16141, 25758, 14252, 3446, 16142, 35902}
macro(100, function()
local dArrow
local dBolt
for _, c in pairs(getContainers()) do
if not containerIsFull(c) then
if c:getContainerItem():getId() == config.arrowsId and config.arrows then
dArrow = c
elseif c:getContainerItem():getId() == config.boltsId and config.bolts then
dBolt = c
end
end
end
for _, c in pairs(getContainers()) do
if c:getName():lower():find("backpack") or c:getName():lower():find("bag") or c:getName():lower():find("chess") then
for _, i in pairs(c:getItems()) do
-- arrows
if dArrow and config.arrows then
if table.find(arrows, i:getId()) and c ~= dArrow then
return g_game.move(i, dArrow:getSlotPosition(dArrow:getItemsCount()), i:getCount())
end
end
-- bolts
if dBolt and config.bolts then
if table.find(bolts, i:getId()) and c ~= dBolt then
return g_game.move(i, dBolt:getSlotPosition(dBolt:getItemsCount()), i:getCount())
end
end
end
end
end
delay(900)
end)
end
addSeparator()
if voc() == 2 or voc() == 12 then
UI.Label("[[ Quiver Manager ]]")
addSeparator()
quiverManager()
addSeparator()
end

View File

@ -0,0 +1,311 @@
function SuppliesPanel(parent)
local panelName = "supplies"
if not parent then
parent = panel
end
if not SuppliesConfig[panelName] then
SuppliesConfig[panelName] = {
item1 = 0,
item2 = 0,
item3 = 0,
item4 = 0,
item5 = 0,
item6 = 0,
item7 = 0,
capValue = 0,
capSwitch = false,
SoftBoots = false,
staminaSwitch = false,
staminaValue = 900,
imbues = false,
item1Min = 0,
item1Max = 0,
item2Min = 0,
item2Max = 0,
item3Min = 0,
item3Max = 0,
item4Min = 0,
item4Max = 0,
item5Min = 0,
item5Max = 0,
item6Min = 0,
item6Max = 0,
item7Max = 0,
sortSupplies = false,
potionBp = 0,
runeBp = 0,
ammoBp = 0
}
end
local config = SuppliesConfig[panelName]
-- data validation
local setup = config
setup.item1 = setup.item1 or 0
setup.item2 = setup.item2 or 0
setup.item3 = setup.item3 or 0
setup.item4 = setup.item4 or 0
setup.item5 = setup.item5 or 0
setup.item6 = setup.item6 or 0
setup.item1Min = setup.item1Min or 0
setup.item1Max = setup.item1Max or 0
setup.item2Min = setup.item2Min or 0
setup.item2Max = setup.item2Max or 0
setup.item3Min = setup.item3Min or 0
setup.item3Max = setup.item3Max or 0
setup.item4Min = setup.item4Min or 0
setup.item4Max = setup.item4Max or 0
setup.item5Min = setup.item5Min or 0
setup.item5Max = setup.item5Max or 0
setup.item6Min = setup.item6Min or 0
setup.item6Max = setup.item6Max or 0
setup.capValue = setup.capValue or 0
setup.staminaValue = setup.staminaValue or 0
rootWidget = g_ui.getRootWidget()
if rootWidget then
SuppliesWindow = g_ui.createWidget('SuppliesWindow', rootWidget)
SuppliesWindow:hide()
SuppliesWindow.capSwitch:setOn(config.capSwitch)
SuppliesWindow.capSwitch.onClick = function(widget)
config.capSwitch = not config.capSwitch
widget:setOn(config.capSwitch)
end
SuppliesWindow.SoftBoots:setOn(config.SoftBoots)
SuppliesWindow.SoftBoots.onClick = function(widget)
config.SoftBoots = not config.SoftBoots
widget:setOn(config.SoftBoots)
end
SuppliesWindow.imbues:setOn(config.imbues)
SuppliesWindow.imbues.onClick = function(widget)
config.imbues = not config.imbues
widget:setOn(config.imbues)
end
SuppliesWindow.staminaSwitch:setOn(config.staminaSwitch)
SuppliesWindow.staminaSwitch.onClick = function(widget)
config.staminaSwitch = not config.staminaSwitch
widget:setOn(config.staminaSwitch)
end
-- bot items
SuppliesWindow.item1:setItemId(config.item1)
SuppliesWindow.item1.onItemChange = function(widget)
config.item1 = widget:getItemId()
end
SuppliesWindow.item2:setItemId(config.item2)
SuppliesWindow.item2.onItemChange = function(widget)
config.item2 = widget:getItemId()
end
SuppliesWindow.item3:setItemId(config.item3)
SuppliesWindow.item3.onItemChange = function(widget)
config.item3 = widget:getItemId()
end
SuppliesWindow.item4:setItemId(config.item4)
SuppliesWindow.item4.onItemChange = function(widget)
config.item4 = widget:getItemId()
end
SuppliesWindow.item5:setItemId(config.item5)
SuppliesWindow.item5.onItemChange = function(widget)
config.item5 = widget:getItemId()
end
SuppliesWindow.item6:setItemId(config.item6)
SuppliesWindow.item6.onItemChange = function(widget)
config.item6 = widget:getItemId()
end
-- text windows
SuppliesWindow.capValue:setText(config.capValue)
SuppliesWindow.capValue.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.capValue:getText())
if not value then
SuppliesWindow.capValue:setText(0)
config.capValue = 0
else
text = text:match("0*(%d+)")
config.capValue = text
end
end
SuppliesWindow.item1Min:setText(config.item1Min)
SuppliesWindow.item1Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item1Min:getText())
if not value then
SuppliesWindow.item1Min:setText(0)
config.item1Min = 0
else
text = text:match("0*(%d+)")
config.item1Min = text
end
end
SuppliesWindow.item1Max:setText(config.item1Max)
SuppliesWindow.item1Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item1Max:getText())
if not value then
SuppliesWindow.item1Max:setText(0)
config.item1Max = 0
else
text = text:match("0*(%d+)")
config.item1Max = text
end
end
SuppliesWindow.item2Min:setText(config.item2Min)
SuppliesWindow.item2Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item2Min:getText())
if not value then
SuppliesWindow.item2Min:setText(0)
config.item2Min = 0
else
text = text:match("0*(%d+)")
config.item2Min = text
end
end
SuppliesWindow.item2Max:setText(config.item2Max)
SuppliesWindow.item2Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item2Max:getText())
if not value then
SuppliesWindow.item2Max:setText(0)
config.item2Max = 0
else
text = text:match("0*(%d+)")
config.item2Max = text
end
end
SuppliesWindow.item3Min:setText(config.item3Min)
SuppliesWindow.item3Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item3Min:getText())
if not value then
SuppliesWindow.item3Min:setText(0)
config.item3Min = 0
else
text = text:match("0*(%d+)")
config.item3Min = text
end
end
SuppliesWindow.item3Max:setText(config.item3Max)
SuppliesWindow.item3Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item3Max:getText())
if not value then
SuppliesWindow.item3Max:setText(0)
config.item3Max = 0
else
config.item3Max = text
end
end
SuppliesWindow.item4Min:setText(config.item4Min)
SuppliesWindow.item4Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item4Min:getText())
if not value then
SuppliesWindow.item4Min:setText(0)
config.item4Min = 0
else
text = text:match("0*(%d+)")
config.item4Min = text
end
end
SuppliesWindow.staminaValue:setText(config.staminaValue)
SuppliesWindow.staminaValue.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.staminaValue:getText())
if not value then
SuppliesWindow.staminaValue:setText(0)
config.staminaValue = 0
else
text = text:match("0*(%d+)")
config.staminaValue = text
end
end
SuppliesWindow.item4Max:setText(config.item4Max)
SuppliesWindow.item4Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item4Max:getText())
if not value then
SuppliesWindow.item4Max:setText(0)
config.item4Max = 0
else
text = text:match("0*(%d+)")
config.item4Max = text
end
end
SuppliesWindow.item5Min:setText(config.item5Min)
SuppliesWindow.item5Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item5Min:getText())
if not value then
SuppliesWindow.item5Min:setText(0)
config.item5Min = 0
else
text = text:match("0*(%d+)")
config.item5Min = text
end
end
SuppliesWindow.item5Max:setText(config.item5Max)
SuppliesWindow.item5Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item5Max:getText())
if not value then
SuppliesWindow.item5Max:setText(0)
config.item5Max = 0
else
text = text:match("0*(%d+)")
config.item5Max = text
end
end
SuppliesWindow.item6Min:setText(config.item6Min)
SuppliesWindow.item6Min.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item6Min:getText())
if not value then
SuppliesWindow.item6Min:setText(0)
config.item6Min = 0
else
text = text:match("0*(%d+)")
config.item6Min = text
end
end
SuppliesWindow.item6Max:setText(config.item6Max)
SuppliesWindow.item6Max.onTextChange = function(widget, text)
local value = tonumber(SuppliesWindow.item6Max:getText())
if not value then
SuppliesWindow.item6Max:setText(0)
config.item6Max = 0
else
text = text:match("0*(%d+)")
config.item6Max = text
end
end
end
UI.Button("Supplies", function()
SuppliesWindow:show()
SuppliesWindow:raise()
SuppliesWindow:focus()
end)
SuppliesWindow.close.onClick = function(widget)
SuppliesWindow:hide()
vBotConfigSave("supply")
end
end
UI.Separator()
SuppliesPanel(setDefaultTab("Cave"))

View File

@ -82,56 +82,6 @@ SuppliesWindow < MainWindow
margin-left: 10
text: No Imbues
HorizontalSeparator
anchors.top: prev.bottom
anchors.left: prev.left
anchors.right: prev.right
margin-top: 5
BotSwitch
id: SortSupplies
anchors.top: prev.bottom
anchors.left: prev.left
anchors.right: prev.right
margin-top: 5
text: Sort Supplies
BotItem
id: PotionBp
anchors.top: prev.bottom
anchors.left: prev.left
margin-top: 3
Label
anchors.verticalCenter: prev.verticalCenter
anchors.left: prev.right
margin-left: 5
text: Potions
BotItem
id: RuneBp
anchors.top: PotionBp.bottom
anchors.left: PotionBp.left
margin-top: 3
Label
anchors.verticalCenter: prev.verticalCenter
anchors.left: prev.right
margin-left: 5
text: Runes
BotItem
id: AmmoBp
anchors.top: RuneBp.bottom
anchors.left: RuneBp.left
margin-top: 3
Label
anchors.verticalCenter: prev.verticalCenter
anchors.left: prev.right
margin-left: 5
text: Ammo
BotItem
id: item1
anchors.left: parent.left

View File

@ -4,8 +4,26 @@
-- sums monster hits on a span of last 3seconds
-- if last message was more than 3s ago then clears the table
-- initial global variables declaration
BotServerMembers = {}
vBot = {} -- global namespace for bot variables
vBot.BotServerMembers = {}
vBot.standTime = now
vBot.isUsingPotion = false
vBot.isUsing = false
-- scripts / functions
onPlayerPositionChange(function(x,y)
vBot.standTime = now
end)
function standTime()
return now - vBot.standTime
end
local dmgTable = {}
local lastDmgMessage = now
@ -46,6 +64,7 @@ function whiteInfoMessage(text)
return modules.game_textmessage.displayGameMessage(text)
end
-- same as above but red message
function broadcastMessage(text)
return modules.game_textmessage.displayBroadcastMessage(text)
end
@ -170,16 +189,16 @@ function killsToRs()
end
-- calculates exhaust for potions based on "Aaaah..." message
-- changes state of storage variable, can be used in other scripts
-- changes state of vBot variable, can be used in other scripts
-- already used in pushmax, healbot, etc
storage.isUsingPotion = false
onTalk(function(name, level, mode, text, channelId, pos)
if name ~= player:getName() then return end
if mode ~= 34 then return end
if text == "Aaaah..." then
storage.isUsingPotion = true
schedule(950, function() storage.isUsingPotion = false end)
vBot.isUsingPotion = true
schedule(950, function() vBot.isUsingPotion = false end)
end
end)
@ -266,26 +285,35 @@ end
-- based on info extracted by getSpellData checks if spell is on cooldown
-- returns boolean
function getSpellCoolDown(text)
if not text then return false end
if not text then return nil end
text = text:lower()
if not getSpellData(text) then return false end
for i, v in pairs(Spells) do
if v.words == text then
return modules.game_cooldown.isCooldownIconActive(v.id)
local data = getSpellData(text)
if not data then return false end
local icon = modules.game_cooldown.isCooldownIconActive(data.id)
local group = false
for groupId, duration in pairs(data.group) do
if modules.game_cooldown.isGroupCooldownIconActive(groupId) then
group = true
break
end
end
if icon or group then
return true
else
return false
end
end
-- global var to indicate that player is trying to do something
-- prevents action blocking by scripts
-- below callbacks are triggers to changing the var state
local isUsingTime = now
storage.isUsing = false
macro(100, function()
storage.isUsing = now < isUsingTime and true or false
vBot.isUsing = now < isUsingTime and true or false
end)
onUse(function(pos, itemId, stackPos, subType)
if pos.x > 65000 then return end
if getDistanceBetween(player:getPosition(), pos) > 1 then return end
local tile = g_map.getTile(pos)
if not tile then return end
@ -323,7 +351,7 @@ function isFriend(c)
if table.find(storage.playerList.friendList, name) then
CachedFriends[c] = true
return true
elseif BotServerMembers[name] ~= nil then
elseif vBot.BotServerMembers[name] ~= nil then
CachedFriends[c] = true
return true
elseif storage.playerList.groupMembers then
@ -347,9 +375,18 @@ end
-- similar to isFriend but lighter version
-- accepts only name string
-- returns boolean
function isEnemy(name)
function isEnemy(c)
local name = c
local p
if type(c) ~= "string" then
if c == player then return false end
name = c:getName()
p = c
end
if not name then return false end
local p = getCreatureByName(name, true)
if not p then
p = getCreatureByName(name, true)
end
if not p then return end
if p:isLocalPlayer() then return end
@ -361,6 +398,43 @@ function isEnemy(name)
end
end
function getPlayerDistribution()
local friends = {}
local neutrals = {}
local enemies = {}
for i, spec in ipairs(getSpectators()) do
if spec:isPlayer() and not spec:isLocalPlayer() then
if isFriend(spec) then
table.insert(friends, spec)
elseif isEnemy(spec) then
table.insert(enemies, spec)
else
table.insert(neutrals, spec)
end
end
end
return friends, neutrals, enemies
end
function getFriends()
local friends, neutrals, enemies = getPlayerDistribution()
return friends
end
function getNeutrals()
local friends, neutrals, enemies = getPlayerDistribution()
return neutrals
end
function getEnemies()
local friends, neutrals, enemies = getPlayerDistribution()
return enemies
end
-- based on first word in string detects if text is a offensive spell
-- returns boolean
function isAttSpell(expr)

View File

@ -65,7 +65,10 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo
onWalk = {},
onImbuementWindow = {},
onModalDialog = {},
onAttackingCreatureChange = {}
onAttackingCreatureChange = {},
onManaChange = {},
onStatesChange = {},
onAddItem = {}
}
-- basic functions & classes
@ -75,6 +78,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo
context.tostring = tostring
context.math = math
context.table = table
context.setmetatable = setmetatable
context.string = string
context.tonumber = tonumber
context.type = type
@ -301,9 +305,9 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo
callback(container)
end
end,
onContainerUpdateItem = function(container, slot, item)
onContainerUpdateItem = function(container, slot, item, oldItem)
for i, callback in ipairs(context._callbacks.onContainerUpdateItem) do
callback(container, slot, item)
callback(container, slot, item, oldItem)
end
end,
onMissle = function(missle)
@ -361,6 +365,21 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo
callback(creature, oldCreature)
end
end,
onManaChange = function(player, mana, maxMana, oldMana, oldMaxMana)
for i, callback in ipairs(context._callbacks.onManaChange) do
callback(player, mana, maxMana, oldMana, oldMaxMana)
end
end,
onAddItem = function(container, slot, item)
for i, callback in ipairs(context._callbacks.onAddItem) do
callback(container, slot, item)
end
end,
onStatesChange = function(states, oldStates)
for i, callback in ipairs(context._callbacks.onStatesChange) do
callback(states, oldStates)
end
end
}
}
end

View File

@ -125,7 +125,7 @@ context.onContainerClose = function(callback)
return context.callback("onContainerClose", callback)
end
-- onContainerUpdateItem -- callback = function(container, slot, item)
-- onContainerUpdateItem -- callback = function(container, slot, item, oldItem)
context.onContainerUpdateItem = function(callback)
return context.callback("onContainerUpdateItem", callback)
end
@ -190,6 +190,21 @@ context.onAttackingCreatureChange = function(callback)
return context.callback("onAttackingCreatureChange", callback)
end
-- onManaChange -- callback = function(player, mana, maxMana, oldMana, oldMaxMana)
context.onManaChange = function(callback)
return context.callback("onManaChange", callback)
end
-- onAddItem - callback = function(container, slot, item)
context.onAddItem = function(callback)
return context.callback("onAddItem", callback)
end
-- onStatesChange - callback = function(states, oldStates)
context.onStatesChange = function(callback)
return context.callback("onStatesChange", callback)
end
-- CUSTOM CALLBACKS
-- listen(name, callback) -- callback = function(text, channelId, pos)

View File

@ -33,9 +33,12 @@ NPCItemBox < UICheckBox
MainWindow
id: npcWindow
!text: tr('NPC Trade')
size: 550 340
size: 550 460
@onEscape: modules.game_npctrade.closeNpcTrade()
$mobile:
size: 550 360
TabButton
id: buyTab
!tooltip: tr("List of items that you're able to buy")
@ -56,12 +59,15 @@ MainWindow
anchors.top: parent.top
FlatPanel
height: 150
height: 250
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 5
$mobile:
height: 150
VerticalScrollBar
id: itemsPanelListScrollBar
anchors.top: parent.top

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More