mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-12-16 00:49:46 +01:00
Updated to OTCv8 3.1 rev 118
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
CaveBot.Actions = {}
|
||||
|
||||
vBot.lastLabel = ""
|
||||
|
||||
local antiTrapTriggered = false
|
||||
-- it adds an action widget to list
|
||||
@@ -77,6 +77,7 @@ CaveBot.registerAction = function(action, color, callback)
|
||||
end
|
||||
|
||||
CaveBot.registerAction("label", "yellow", function(value, retries, prev)
|
||||
vBot.lastLabel = value
|
||||
return true
|
||||
end)
|
||||
|
||||
@@ -177,7 +178,8 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev)
|
||||
if not path2 then
|
||||
local target = {} -- c = creature, d = distance
|
||||
for i, spec in pairs(getSpectators()) do
|
||||
if spec:isMonster() then
|
||||
local hppc = spec:getHealthPercent()
|
||||
if spec:isMonster() and (hppc and hppc > 0) then
|
||||
local path = findPath(playerPos, spec:getPosition(), 7, { ignoreNonPathable = true, precision = 1 })
|
||||
if path then
|
||||
local dist = getDistanceBetween(pos, spec:getPosition())
|
||||
@@ -193,8 +195,7 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev)
|
||||
end
|
||||
g_game.setChaseMode(1)
|
||||
CaveBot.setOff()
|
||||
antiTrapTriggered = true
|
||||
return "retry"
|
||||
schedule(1000, function() CaveBot.setOn() end)
|
||||
else
|
||||
return false -- no other way
|
||||
end
|
||||
@@ -234,13 +235,6 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev)
|
||||
return "retry"
|
||||
end)
|
||||
|
||||
onAttackingCreatureChange(function(creature, oldCreature)
|
||||
if antiTrapTriggered then
|
||||
CaveBot.setOn()
|
||||
antiTrapTriggered = false
|
||||
end
|
||||
end)
|
||||
|
||||
CaveBot.registerAction("use", "#FFB272", function(value, retries, prev)
|
||||
local pos = regexMatch(value, "\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)")
|
||||
if not pos[1] then
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
CaveBot.Extensions.Bank = {}
|
||||
|
||||
local balance = 0
|
||||
|
||||
CaveBot.Extensions.Bank.setup = function()
|
||||
CaveBot.registerAction("bank", "#db5a5a", function(value, retries)
|
||||
local data = string.split(value, ",")
|
||||
@@ -7,7 +9,9 @@ CaveBot.Extensions.Bank.setup = function()
|
||||
local amount = 0
|
||||
local actionType
|
||||
local npcName
|
||||
if #data ~= 3 and #data ~= 2 then
|
||||
local transferName
|
||||
local balanceLeft
|
||||
if #data ~= 3 and #data ~= 2 and #data ~= 4 then
|
||||
warn("CaveBot[Bank]: incorrect value!")
|
||||
return false
|
||||
else
|
||||
@@ -16,10 +20,14 @@ CaveBot.Extensions.Bank.setup = function()
|
||||
if #data == 3 then
|
||||
amount = tonumber(data[3]:trim())
|
||||
end
|
||||
if #data == 4 then
|
||||
transferName = data[3]:trim()
|
||||
balanceLeft = tonumber(data[4]:trim())
|
||||
end
|
||||
end
|
||||
|
||||
if actionType ~= "withdraw" and actionType ~= "deposit" then
|
||||
warn("CaveBot[Bank]: incorrect action type! should be withdraw/deposit, is: " .. actionType)
|
||||
if actionType ~= "withdraw" and actionType ~= "deposit" and actionType ~= "transfer" then
|
||||
warn("CaveBot[Bank]: incorrect action type! should be withdraw/deposit/transfer, is: " .. actionType)
|
||||
return false
|
||||
elseif actionType == "withdraw" then
|
||||
local value = tonumber(amount)
|
||||
@@ -48,16 +56,37 @@ CaveBot.Extensions.Bank.setup = function()
|
||||
CaveBot.Conversation("hi", "deposit all", "yes")
|
||||
CaveBot.delay(storage.extras.talkDelay*3)
|
||||
return true
|
||||
else
|
||||
elseif actionType == "withdraw" then
|
||||
CaveBot.Conversation("hi", "withdraw", value, "yes")
|
||||
CaveBot.delay(storage.extras.talkDelay*4)
|
||||
return true
|
||||
else
|
||||
-- first check balance
|
||||
CaveBot.Conversation("hi", "balance")
|
||||
schedule(5000, function()
|
||||
local amountToTransfer = balance - balanceLeft
|
||||
if amountToTransfer <= 0 then
|
||||
warn("CaveBot[Bank] Not enough gold to transfer! proceeding")
|
||||
return false
|
||||
end
|
||||
CaveBot.Conversation("hi", "transfer", amountToTransfer, transferName, "yes")
|
||||
warn("CaveBot[Bank] transferred "..amountToTransfer.." gold to: "..transferName)
|
||||
end)
|
||||
CaveBot.delay(storage.extras.talkDelay*11)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
CaveBot.Editor.registerAction("bank", "bank", {
|
||||
value="action, NPC name",
|
||||
title="Banker",
|
||||
description="action type(withdraw/deposit), NPC name, if withdraw: amount",
|
||||
description="action type(withdraw/deposit/transfer), NPC name, (if withdraw: amount|if transfer: name, balance left)",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
onTalk(function(name, level, mode, text, channelId, pos)
|
||||
if mode == 51 and text:find("Your account balance is") then
|
||||
balance = getFirstNumberInText(text)
|
||||
end
|
||||
end)
|
||||
@@ -189,6 +189,149 @@ CaveBot.getCurrentProfile = function()
|
||||
return storage._configs.cavebot_configs.selected
|
||||
end
|
||||
|
||||
CaveBot.lastReachedLabel = function()
|
||||
return vBot.lastLabel
|
||||
end
|
||||
|
||||
CaveBot.gotoNextWaypointInRange = function()
|
||||
local currentAction = ui.list:getFocusedChild()
|
||||
local index = ui.list:getChildIndex(currentAction)
|
||||
local actions = ui.list:getChildren()
|
||||
|
||||
-- start searching from current index
|
||||
for i, child in ipairs(actions) do
|
||||
if i > index then
|
||||
local text = child:getText()
|
||||
if string.starts(text, "goto:") then
|
||||
local re = regexMatch(text, [[(?:goto:)([^,]+),([^,]+),([^,]+)]])
|
||||
local pos = {x = tonumber(re[1][2]), y = tonumber(re[1][3]), z = tonumber(re[1][4])}
|
||||
|
||||
if posz() == pos.z then
|
||||
if distanceFromPlayer(pos) <= storage.extras.gotoMaxDistance/2 then
|
||||
return ui.list:focusChild(child)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- if not found then damn go from start
|
||||
for i, child in ipairs(actions) do
|
||||
if i <= index then
|
||||
local text = child:getText()
|
||||
if string.starts(text, "goto:") then
|
||||
local re = regexMatch(text, [[(?:goto:)([^,]+),([^,]+),([^,]+)]])
|
||||
local pos = {x = tonumber(re[1][2]), y = tonumber(re[1][3]), z = tonumber(re[1][4])}
|
||||
|
||||
if posz() == pos.z then
|
||||
if distanceFromPlayer(pos) <= storage.extras.gotoMaxDistance/2 then
|
||||
return ui.list:focusChild(child)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- not found
|
||||
return false
|
||||
end
|
||||
|
||||
CaveBot.getFirstWaypointBeforeLabel = function(label)
|
||||
label = "label:"..label
|
||||
label = label:lower()
|
||||
local actions = ui.list:getChildren()
|
||||
local index
|
||||
|
||||
-- find index of label
|
||||
for i, child in pairs(actions) do
|
||||
local name = child:getText():lower()
|
||||
if name == label then
|
||||
index = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- if there's no index then label was not found
|
||||
if not index then return false end
|
||||
|
||||
for i=1,#actions do
|
||||
if index - 1 < 1 then
|
||||
-- did not found any waypoint in range before label
|
||||
return false
|
||||
end
|
||||
|
||||
local child = ui.list:getChildByIndex(index-i)
|
||||
if child then
|
||||
local text = child:getText()
|
||||
if string.starts(text, "goto:") then
|
||||
local re = regexMatch(text, [[(?:goto:)([^,]+),([^,]+),([^,]+)]])
|
||||
local pos = {x = tonumber(re[1][2]), y = tonumber(re[1][3]), z = tonumber(re[1][4])}
|
||||
|
||||
if posz() == pos.z then
|
||||
if distanceFromPlayer(pos) <= storage.extras.gotoMaxDistance/2 then
|
||||
return ui.list:focusChild(child)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
CaveBot.getPreviousLabel = function()
|
||||
local actions = ui.list:getChildren()
|
||||
-- check if config is empty
|
||||
if #actions == 0 then return false end
|
||||
|
||||
local currentAction = ui.list:getFocusedChild()
|
||||
--check we made any progress in waypoints, if no focused or first then no point checking
|
||||
if not currentAction or currentAction == ui.list:getFirstChild() then return false end
|
||||
|
||||
local index = ui.list:getChildIndex(currentAction)
|
||||
|
||||
-- if not index then something went wrong and there's no selected child
|
||||
if not index then return false end
|
||||
|
||||
for i=1,#actions do
|
||||
if index - i < 1 then
|
||||
-- did not found any waypoint in range before label
|
||||
return false
|
||||
end
|
||||
|
||||
local child = ui.list:getChildByIndex(index-i)
|
||||
if child then
|
||||
if child.action == "label" then
|
||||
return child.value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
CaveBot.getNextLabel = function()
|
||||
local actions = ui.list:getChildren()
|
||||
-- check if config is empty
|
||||
if #actions == 0 then return false end
|
||||
|
||||
local currentAction = ui.list:getFocusedChild() or ui.list:getFirstChild()
|
||||
local index = ui.list:getChildIndex(currentAction)
|
||||
|
||||
-- if not index then something went wrong
|
||||
if not index then return false end
|
||||
|
||||
for i=1,#actions do
|
||||
if index + i > #actions then
|
||||
-- did not found any waypoint in range before label
|
||||
return false
|
||||
end
|
||||
|
||||
local child = ui.list:getChildByIndex(index+i)
|
||||
if child then
|
||||
if child.action == "label" then
|
||||
return child.value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local botConfigName = modules.game_bot.contentsPanel.config:getCurrentOption().text
|
||||
CaveBot.setCurrentProfile = function(name)
|
||||
if not g_resources.fileExists("/bot/"..botConfigName.."/cavebot_configs/"..name..".cfg") then
|
||||
|
||||
@@ -6,7 +6,7 @@ CaveBot.Extensions.DWithdraw.setup = function()
|
||||
local data = string.split(value, ",")
|
||||
if retries > 600 then
|
||||
print("CaveBot[DepotWithdraw]: actions limit reached, proceeding")
|
||||
return true
|
||||
return false
|
||||
end
|
||||
local destContainer
|
||||
local depotContainer
|
||||
@@ -32,7 +32,7 @@ CaveBot.Extensions.DWithdraw.setup = function()
|
||||
end
|
||||
end
|
||||
print("CaveBot[DepotWithdraw]: cap limit reached, proceeding")
|
||||
return true
|
||||
return false
|
||||
end
|
||||
|
||||
-- containers
|
||||
@@ -74,7 +74,7 @@ CaveBot.Extensions.DWithdraw.setup = function()
|
||||
end
|
||||
end
|
||||
print("CaveBot[DepotWithdraw]: loot containers full!")
|
||||
return true
|
||||
return false
|
||||
end
|
||||
|
||||
if not CaveBot.OpenDepotBox(indexDp) then
|
||||
|
||||
111
modules/game_bot/default_configs/vBot_4.0/cavebot/imbuing.lua
Normal file
111
modules/game_bot/default_configs/vBot_4.0/cavebot/imbuing.lua
Normal file
@@ -0,0 +1,111 @@
|
||||
-- imbuing window should be handled separatly
|
||||
-- reequiping should be handled separatly (ie. equipment manager)
|
||||
|
||||
CaveBot.Extensions.Imbuing = {}
|
||||
|
||||
local SHRINES = {25060, 25061, 25182, 25183}
|
||||
local currentIndex = 1
|
||||
local shrine = nil
|
||||
local item = nil
|
||||
local currentId = 0
|
||||
local triedToTakeOff = false
|
||||
local destination = nil
|
||||
|
||||
local function reset()
|
||||
EquipManager.setOn()
|
||||
shrine = nil
|
||||
currentIndex = 1
|
||||
item = nil
|
||||
currentId = 0
|
||||
triedToTakeOff = false
|
||||
destination = nil
|
||||
end
|
||||
|
||||
CaveBot.Extensions.Imbuing.setup = function()
|
||||
CaveBot.registerAction("imbuing", "red", function(value, retries)
|
||||
local data = string.split(value, ",")
|
||||
local ids = {}
|
||||
|
||||
if #data == 0 then
|
||||
warn("CaveBot[Imbuing] no items added, proceeding")
|
||||
reset()
|
||||
return false
|
||||
end
|
||||
|
||||
-- setting of equipment manager so it wont disturb imbuing process
|
||||
EquipManager.setOff()
|
||||
|
||||
-- convert to number
|
||||
for i, id in ipairs(data) do
|
||||
id = tonumber(id)
|
||||
if not table.find(ids, id) then
|
||||
table.insert(ids, id)
|
||||
end
|
||||
end
|
||||
|
||||
-- all items imbued, can proceed
|
||||
if currentIndex > #ids then
|
||||
warn("CaveBot[Imbuing] used shrine on all items, proceeding")
|
||||
reset()
|
||||
return true
|
||||
end
|
||||
|
||||
for _, tile in ipairs(g_map.getTiles(posz())) do
|
||||
for _, item in ipairs(tile:getItems()) do
|
||||
local id = item:getId()
|
||||
if table.find(SHRINES, id) then
|
||||
shrine = item
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- if not shrine
|
||||
if not shrine then
|
||||
warn("CaveBot[Imbuing] shrine not found! proceeding")
|
||||
reset()
|
||||
return false
|
||||
end
|
||||
|
||||
destination = shrine:getPosition()
|
||||
|
||||
currentId = ids[currentIndex]
|
||||
item = findItem(currentId)
|
||||
|
||||
-- maybe equipped? try to take off
|
||||
if not item then
|
||||
-- did try before, still not found so item is unavailable
|
||||
if triedToTakeOff then
|
||||
warn("CaveBot[Imbuing] item not found! proceeding")
|
||||
reset()
|
||||
return false
|
||||
end
|
||||
triedToTakeOff = true
|
||||
g_game.equipItemId(currentId)
|
||||
delay(1000)
|
||||
return "retry"
|
||||
end
|
||||
|
||||
-- we are past unequiping so just in case we were forced before, reset var
|
||||
triedToTakeOff = false
|
||||
|
||||
-- reaching shrine
|
||||
if not CaveBot.MatchPosition(destination, 1) then
|
||||
CaveBot.GoTo(destination, 1)
|
||||
delay(200)
|
||||
return "retry"
|
||||
end
|
||||
|
||||
useWith(shrine, item)
|
||||
currentIndex = currentIndex + 1
|
||||
warn("CaveBot[Imbuing] Using shrine on item: "..currentId)
|
||||
delay(2000)
|
||||
return "retry"
|
||||
end)
|
||||
|
||||
CaveBot.Editor.registerAction("imbuing", "imbuing", {
|
||||
value="item id 1, item id 2",
|
||||
title="Auto Imbuing",
|
||||
description="insert below item ids to be imbued, separated by comma",
|
||||
})
|
||||
end
|
||||
Reference in New Issue
Block a user