mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-21 23:15:54 +02:00
Added waypoints for bot
This commit is contained in:
@@ -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
|
Reference in New Issue
Block a user