mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-19 22:23:28 +02:00
Added waypoints for bot
This commit is contained in:
@@ -11,9 +11,10 @@ context.callback = function(callbackType, callback)
|
||||
local callbackData = {}
|
||||
table.insert(context._callbacks[callbackType], function(...)
|
||||
if not callbackData.delay or callbackData.delay < context.now then
|
||||
local prevExecution = context._currentExecution
|
||||
context._currentExecution = callbackData
|
||||
callback(...)
|
||||
context._currentExecution = nil
|
||||
context._currentExecution = prevExecution
|
||||
end
|
||||
end)
|
||||
end
|
||||
@@ -68,6 +69,16 @@ context.onCreatureHealthPercentChange = function(callback)
|
||||
return context.callback("onCreatureHealthPercentChange", callback)
|
||||
end
|
||||
|
||||
-- onUse(callback) -- callback = function(pos, itemId, stackPos, subType)
|
||||
context.onUse = function(callback)
|
||||
return context.callback("onUse", callback)
|
||||
end
|
||||
|
||||
-- onUseWith(callback) -- callback = function(pos, itemId, target, subType)
|
||||
context.onUseWith = function(callback)
|
||||
return context.callback("onUseWith", callback)
|
||||
end
|
||||
|
||||
|
||||
-- custom callbacks
|
||||
|
||||
|
@@ -52,7 +52,7 @@ context.macro = function(timeout, name, hotkey, callback, parent)
|
||||
local macroData = context._macros[#context._macros]
|
||||
macroData.callback = function()
|
||||
if not macroData.delay or macroData.delay < context.now then
|
||||
context._currentExecution = macroData
|
||||
context._currentExecution = macroData
|
||||
callback()
|
||||
context._currentExecution = nil
|
||||
return true
|
||||
|
@@ -36,4 +36,40 @@ context.getPlayerByName = function(name, multifloor)
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
context.findPath = function(startPos, destPos, maxDist, ignoreFields, ignoreCreatures)
|
||||
if type(maxDist) ~= 'number' then
|
||||
maxDist = 100
|
||||
end
|
||||
local complexity = math.min(10000, maxDist * maxDist)
|
||||
local flags = 0
|
||||
if ignoreFields then
|
||||
flags = flags + 4
|
||||
end
|
||||
if ignoreCreatures then
|
||||
flags = flags + 16
|
||||
end
|
||||
return g_map.findPath(startPos, destPos, complexity, flags)
|
||||
end
|
||||
|
||||
context.autoWalk = function(destination, maxDist, ignoreFields, ignoreCreatures)
|
||||
if maxDist == nil then
|
||||
maxDist = 100
|
||||
end
|
||||
if ignoreFields == nil then
|
||||
ignoreFields = false
|
||||
end
|
||||
if ignoreCreatures == nil then
|
||||
ignoreCreatures = false
|
||||
end
|
||||
if context.player:getPosition().z ~= destination.z then
|
||||
return false
|
||||
end
|
||||
local path = context.findPath(context.player:getPosition(), destination, maxDist, ignoreFields, ignoreCreatures)
|
||||
if #path < 1 then
|
||||
return false
|
||||
end
|
||||
g_game.autoWalk(path, context.player:getPosition())
|
||||
return true
|
||||
end
|
@@ -54,7 +54,6 @@ end
|
||||
context.changeOutfit = context.setOutfit
|
||||
context.setSpeed = function(value) context.player:setSpeed(value) end
|
||||
|
||||
context.autoWalk = function(destination) return context.player:autoWalk(destination) end
|
||||
context.walk = function(dir) return modules.game_walking.walk(dir) end
|
||||
context.turn = function(dir) return g_game.turn(dir) end
|
||||
|
||||
|
Reference in New Issue
Block a user