mirror of
https://github.com/OTCv8/otclientv8.git
synced 2026-01-21 01:46:22 +01:00
Version 1.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# OTClientV8
|
# OTClientV8
|
||||||
|
|
||||||
Preview version of OTClientV8, version v1.0 with tutorials will be released soon.
|
Tibia client design for versions 7.40 - 10.99
|
||||||
It's based on https://github.com/edubart/otclient and it's not backward compatible.
|
It's based on https://github.com/edubart/otclient and it's not backward compatible.
|
||||||
|
|
||||||
## DISCORD: https://discord.gg/feySup6
|
## DISCORD: https://discord.gg/feySup6
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ local battleTab = addTab("Battle")
|
|||||||
local caveTab = addTab("Cave")
|
local caveTab = addTab("Cave")
|
||||||
local toolsTab = addTab("Tools")
|
local toolsTab = addTab("Tools")
|
||||||
|
|
||||||
|
Panels.Eating(battleTab)
|
||||||
Panels.Health(battleTab)
|
Panels.Health(battleTab)
|
||||||
Panels.HealthItem(battleTab)
|
Panels.HealthItem(battleTab)
|
||||||
Panels.ManaItem(battleTab)
|
Panels.ManaItem(battleTab)
|
||||||
@@ -40,6 +41,30 @@ macro(1000, "this macro does nothing", "f7", function()
|
|||||||
|
|
||||||
end, toolsTab)
|
end, toolsTab)
|
||||||
|
|
||||||
|
macro(100, "debug pathfinding", nil, function()
|
||||||
|
for i, tile in ipairs(g_map.getTiles(posz())) do
|
||||||
|
tile:setText("")
|
||||||
|
end
|
||||||
|
local path = findEveryPath(pos(), 20, {
|
||||||
|
ignoreNonPathable = false
|
||||||
|
})
|
||||||
|
local total = 0
|
||||||
|
for i, p in pairs(path) do
|
||||||
|
local s = i:split(",")
|
||||||
|
local pos = {x=tonumber(s[1]), y=tonumber(s[2]), z=tonumber(s[3])}
|
||||||
|
local tile = g_map.getTile(pos)
|
||||||
|
if tile then
|
||||||
|
tile:setText(p[2])
|
||||||
|
end
|
||||||
|
total = total + 1
|
||||||
|
end
|
||||||
|
end, toolsTab)
|
||||||
|
|
||||||
|
macro(1000, "speed hack", nil, function()
|
||||||
|
player:setSpeed(1000)
|
||||||
|
end, toolsTab)
|
||||||
|
|
||||||
|
|
||||||
--#hotkeys
|
--#hotkeys
|
||||||
|
|
||||||
hotkey("f5", "example hotkey", function()
|
hotkey("f5", "example hotkey", function()
|
||||||
@@ -48,6 +73,7 @@ end)
|
|||||||
|
|
||||||
singlehotkey("ctrl+f6", "singlehotkey", function()
|
singlehotkey("ctrl+f6", "singlehotkey", function()
|
||||||
info("Wow, you clicked f6 singlehotkey")
|
info("Wow, you clicked f6 singlehotkey")
|
||||||
|
usewith(268, player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--#callbacks
|
--#callbacks
|
||||||
@@ -58,15 +84,6 @@ onPlayerPositionChange(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
--#other
|
--#other
|
||||||
|
|
||||||
HTTP.getJSON("https://api.ipify.org/?format=json", function(data, err)
|
|
||||||
if err then
|
|
||||||
warn("Whoops! Error occured: " .. err)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local myIp = data['ip']
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
]=]},
|
]=]},
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback)
|
|||||||
context.math = math
|
context.math = math
|
||||||
context.table = table
|
context.table = table
|
||||||
context.string = string
|
context.string = string
|
||||||
|
context.tonumber = tonumber
|
||||||
context.tr = tr
|
context.tr = tr
|
||||||
context.json = json
|
context.json = json
|
||||||
context.regexMatch = regexMatch
|
context.regexMatch = regexMatch
|
||||||
|
|||||||
@@ -51,42 +51,145 @@ context.getPlayerByName = function(name, multifloor)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
context.findPath = function(startPos, destPos, maxDist, ignoreFields, ignoreCreatures)
|
context.findAllPaths = function(start, maxDist, params)
|
||||||
|
--[[
|
||||||
|
Available params:
|
||||||
|
ignoreLastCreature
|
||||||
|
ignoreCreatures
|
||||||
|
ignoreNonPathable
|
||||||
|
ignoreNonWalkable
|
||||||
|
ignoreStairs
|
||||||
|
ignoreCost
|
||||||
|
allowUnseen
|
||||||
|
]]--
|
||||||
|
if type(params) ~= 'table' then
|
||||||
|
params = {}
|
||||||
|
end
|
||||||
|
for key, value in pairs(params) do
|
||||||
|
if value == nil or value == false then
|
||||||
|
params[key] = 0
|
||||||
|
elseif value == true then
|
||||||
|
params[key] = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return g_map.findEveryPath(start, maxDist, params)
|
||||||
|
end
|
||||||
|
context.findEveryPath = context.findAllPaths
|
||||||
|
|
||||||
|
context.translateAllPathsToPath = function(paths, destPos)
|
||||||
|
local predirections = {}
|
||||||
|
local directions = {}
|
||||||
|
local destPosStr = destPos
|
||||||
|
if type(destPos) ~= 'string' then
|
||||||
|
destPosStr = destPos.x .. "," .. destPos.y .. "," .. destPos.z
|
||||||
|
end
|
||||||
|
|
||||||
|
while destPosStr:len() > 0 do
|
||||||
|
local node = paths[destPosStr]
|
||||||
|
if not node then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if node[3] < 0 then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
table.insert(predirections, node[3])
|
||||||
|
destPosStr = node[4]
|
||||||
|
end
|
||||||
|
-- reverse
|
||||||
|
for i=#predirections,1,-1 do
|
||||||
|
table.insert(directions, predirections[i])
|
||||||
|
end
|
||||||
|
return directions
|
||||||
|
end
|
||||||
|
context.translateEveryPathToPath = context.translateAllPathsToPath
|
||||||
|
|
||||||
|
|
||||||
|
context.findPath = function(startPos, destPos, maxDist, params)
|
||||||
|
--[[
|
||||||
|
Available params:
|
||||||
|
ignoreLastCreature
|
||||||
|
ignoreCreatures
|
||||||
|
ignoreNonPathable
|
||||||
|
ignoreNonWalkable
|
||||||
|
ignoreStairs
|
||||||
|
ignoreCost
|
||||||
|
allowUnseen
|
||||||
|
precision
|
||||||
|
marginMin
|
||||||
|
marginMax
|
||||||
|
]]--
|
||||||
|
if startPos.z ~= destPos.z then
|
||||||
|
return
|
||||||
|
end
|
||||||
if type(maxDist) ~= 'number' then
|
if type(maxDist) ~= 'number' then
|
||||||
maxDist = 100
|
maxDist = 100
|
||||||
end
|
end
|
||||||
local complexity = math.min(10000, maxDist * maxDist)
|
if type(params) ~= 'table' then
|
||||||
local flags = 0
|
params = {}
|
||||||
if ignoreFields then
|
|
||||||
flags = flags + 4
|
|
||||||
end
|
end
|
||||||
if ignoreCreatures then
|
local destPosStr = destPos.x .. "," .. destPos.y .. "," .. destPos.z
|
||||||
flags = flags + 16
|
params["destination"] = destPosStr
|
||||||
|
local paths = context.findAllPaths(startPos, maxDist, params)
|
||||||
|
|
||||||
|
local marginMin = params.marginMin or params.minMargin
|
||||||
|
local marginMax = params.marginMax or params.maxMargin
|
||||||
|
if type(marginMin) == 'number' and type(marginMax) == 'number' then
|
||||||
|
local bestCandidate = nil
|
||||||
|
local bestCandidatePos = nil
|
||||||
|
for x = -marginMax, marginMax do
|
||||||
|
for y = -marginMax, marginMax do
|
||||||
|
if math.abs(x) >= marginMin or math.abs(y) >= marginMin then
|
||||||
|
local dest = (destPos.x + x) .. "," .. (destPos.y + y) .. "," .. destPos.z
|
||||||
|
local node = paths[dest]
|
||||||
|
if node and (not bestCandidate or bestCandidate[1] > node[1]) then
|
||||||
|
bestCandidate = node
|
||||||
|
bestCandidatePos = dest
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if bestCandidate then
|
||||||
|
return context.translateAllPathsToPath(paths, bestCandidatePos)
|
||||||
|
end
|
||||||
|
return
|
||||||
end
|
end
|
||||||
return g_map.findPath(startPos, destPos, complexity, flags)
|
|
||||||
|
if not paths[destPosStr] then
|
||||||
|
local precision = params.precision
|
||||||
|
if type(precision) == 'number' then
|
||||||
|
for p = 1, precision do
|
||||||
|
local bestCandidate = nil
|
||||||
|
local bestCandidatePos = nil
|
||||||
|
for x = -p, p do
|
||||||
|
for y = -p, p do
|
||||||
|
local dest = (destPos.x + x) .. "," .. (destPos.y + y) .. "," .. destPos.z
|
||||||
|
local node = paths[dest]
|
||||||
|
if node and (not bestCandidate or bestCandidate[1] > node[1]) then
|
||||||
|
bestCandidate = node
|
||||||
|
bestCandidatePos = dest
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if bestCandidate then
|
||||||
|
return context.translateAllPathsToPath(paths, bestCandidatePos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return context.translateAllPathsToPath(paths, destPos)
|
||||||
|
end
|
||||||
|
context.getPath = context.findPath
|
||||||
|
|
||||||
|
context.autoWalk = function(destination, maxDist, params)
|
||||||
|
-- Available params same as for findPath
|
||||||
|
local path = context.findPath(context.player:getPosition(), destination, maxDist, params)
|
||||||
|
if not path then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
-- autowalk without prewalk animation
|
||||||
|
g_game.autoWalk(path, {x=0,y=0,z=0})
|
||||||
|
return true
|
||||||
end
|
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
|
|
||||||
if g_game.getFeature(GameNewWalking) then
|
|
||||||
g_game.autoWalk(path, context.player:getPosition())
|
|
||||||
else
|
|
||||||
g_game.autoWalk(path, {x=0,y=0,z=0})
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
@@ -621,6 +621,8 @@ Panel
|
|||||||
end
|
end
|
||||||
|
|
||||||
refreshConfig()
|
refreshConfig()
|
||||||
|
|
||||||
|
-- processing
|
||||||
|
|
||||||
local getMonsterConfig = function(monster)
|
local getMonsterConfig = function(monster)
|
||||||
if monsters[monster:getName():lower()] then
|
if monsters[monster:getName():lower()] then
|
||||||
@@ -639,21 +641,28 @@ Panel
|
|||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
local distance = context.getDistanceBetween(context.player:getPosition(), monster:getPosition())
|
local pos = context.player:getPosition()
|
||||||
if distance > 10 then
|
local mpos = monster:getPosition()
|
||||||
|
local hp = monster:getHealthPercent()
|
||||||
|
|
||||||
|
if config.minHealth > hp or config.maxHealth < hp then
|
||||||
|
return -1
|
||||||
|
end
|
||||||
|
|
||||||
|
local maxDistance = 5
|
||||||
|
if config.chase and hp < 20 then
|
||||||
|
maxDistance = 7
|
||||||
|
end
|
||||||
|
|
||||||
|
local distance = math.max(math.abs(pos.x-mpos.x), math.abs(pos.y-mpos.y))
|
||||||
|
if distance > maxDistance then
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
local mpos = monster:getPosition()
|
|
||||||
local hasPath = false
|
local hasPath = false
|
||||||
for x=-1,1 do
|
local pathTo = context.findPath(context.player:getPosition(), {x=mpos.x, y=mpos.y, z=mpos.z}, 10, { ignoreNonPathable = true, precision=1 })
|
||||||
for y=-1,1 do
|
if pathTo then
|
||||||
local pathTo = context.findPath(context.player:getPosition(), {x=mpos.x-x, y=mpos.y-y, z=mpos.z}, 100, true, false)
|
hasPath = true
|
||||||
if #pathTo > 0 then
|
|
||||||
hasPath = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if distance > 2 and not hasPath then
|
if distance > 2 and not hasPath then
|
||||||
return -1
|
return -1
|
||||||
@@ -667,19 +676,26 @@ Panel
|
|||||||
priority = priority + 10
|
priority = priority + 10
|
||||||
end
|
end
|
||||||
if distance <= 2 then
|
if distance <= 2 then
|
||||||
priority = priority + 20
|
priority = priority + 10
|
||||||
|
end
|
||||||
|
if distance <= 1 then
|
||||||
|
priority = priority + 10
|
||||||
end
|
end
|
||||||
|
|
||||||
if monster:getHealthPercent() <= 10 then
|
if hp <= 20 and config.chase then
|
||||||
|
priority = priority + 30
|
||||||
|
end
|
||||||
|
|
||||||
|
if hp <= 10 then
|
||||||
priority = priority + 10
|
priority = priority + 10
|
||||||
end
|
end
|
||||||
if monster:getHealthPercent() <= 25 then
|
if hp <= 25 then
|
||||||
priority = priority + 10
|
priority = priority + 10
|
||||||
end
|
end
|
||||||
if monster:getHealthPercent() <= 50 then
|
if hp <= 50 then
|
||||||
priority = priority + 10
|
priority = priority + 10
|
||||||
end
|
end
|
||||||
if monster:getHealthPercent() <= 75 then
|
if hp <= 75 then
|
||||||
priority = priority + 10
|
priority = priority + 10
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -720,13 +736,13 @@ Panel
|
|||||||
table.remove(lootContainers, 1)
|
table.remove(lootContainers, 1)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if lootTries >= 5 then
|
if lootTries >= 5 then
|
||||||
lootTries = 0
|
lootTries = 0
|
||||||
table.remove(lootContainers, 1)
|
table.remove(lootContainers, 1)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
local dist = math.max(math.abs(pos.x-cpos.x), math.abs(pos.y-cpos.y))
|
local dist = math.max(math.abs(pos.x-cpos.x), math.abs(pos.y-cpos.y))
|
||||||
if dist <= 5 then
|
if dist <= 5 then
|
||||||
local tile = g_map.getTile(cpos)
|
local tile = g_map.getTile(cpos)
|
||||||
if not tile then
|
if not tile then
|
||||||
@@ -739,7 +755,8 @@ Panel
|
|||||||
table.remove(lootContainers, 1)
|
table.remove(lootContainers, 1)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
topItem:setMarked('orange')
|
||||||
|
|
||||||
if dist <= 1 then
|
if dist <= 1 then
|
||||||
lootTries = lootTries + 1
|
lootTries = lootTries + 1
|
||||||
openContainerRequest = context.now
|
openContainerRequest = context.now
|
||||||
@@ -755,30 +772,19 @@ Panel
|
|||||||
end
|
end
|
||||||
|
|
||||||
lootTries = lootTries + 1
|
lootTries = lootTries + 1
|
||||||
if context.autoWalk(cpos, 100 + dist * 2) then
|
if context.autoWalk(cpos, 20, { precision = 1}) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if context.autoWalk(cpos, 100 + dist * 2, true) then
|
if context.autoWalk(cpos, 20, { ignoreNonPathable = true, precision = 1}) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1,5 do
|
if context.autoWalk(cpos, 20, { ignoreNonPathable = true, precision = 2}) then
|
||||||
local cpos2 = {x=cpos.x + math.random(-1, 1),y = cpos.y + math.random(-1, 1), z = cpos.z}
|
return true
|
||||||
if context.autoWalk(cpos2, 100 + dist * 2) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- try again, ignore field
|
|
||||||
for i=1,5 do
|
|
||||||
local cpos2 = {x=cpos.x + math.random(-1, 1),y = cpos.y + math.random(-1, 1), z = cpos.z}
|
|
||||||
if context.autoWalk(cpos2, 100 + dist * 2, true) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ignore fields and monsters
|
if context.autoWalk(cpos, 20, { ignoreNonPathable = true, ignoreCreatures = true, precision = 2}) then
|
||||||
if context.autoWalk(cpos, 100 + dist * 2, true, true) then
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -817,6 +823,7 @@ Panel
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
topItem:setMarked('blue')
|
||||||
table.insert(lootContainers, tpos)
|
table.insert(lootContainers, tpos)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -916,40 +923,23 @@ Panel
|
|||||||
|
|
||||||
local distance = math.max(math.abs(offsetX), math.abs(offsetY))
|
local distance = math.max(math.abs(offsetX), math.abs(offsetY))
|
||||||
if config.keepDistance then
|
if config.keepDistance then
|
||||||
if (distance == config.distance or distance == config.distance + 1) then
|
local minDistance = config.distance
|
||||||
|
if target:getHealthPercent() < 20 and config.chase and danger < 10 then
|
||||||
|
minDistance = 1
|
||||||
|
end
|
||||||
|
if (distance == minDistance or distance == minDistance + 1) then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
local bestDist = 10
|
local bestDist = 10
|
||||||
local bestPos = pos
|
local bestPos = pos
|
||||||
|
if not context.autoWalk(tpos, 8, { minMargin=minDistance, maxMargin=minDistance + 1}) then
|
||||||
for i=1,5 do
|
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, minMargin=minDistance, maxMargin=minDistance + 1}) then
|
||||||
local testPos = {x=pos.x + math.random(-3,3), y=pos.y + math.random(-3,3), z=pos.z}
|
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, ignoreCreatures = true, minMargin=minDistance, maxMargin=minDistance + 2}) then
|
||||||
local dist = math.abs(config.distance - math.max(math.abs(tpos.x - testPos.x), math.abs(tpos.y - testPos.y)))
|
return
|
||||||
if dist < bestDist then
|
|
||||||
local path = context.findPath(pos, testPos, 100, false, false)
|
|
||||||
if #path > 0 then
|
|
||||||
bestPos = testPos
|
|
||||||
bestDist = dist
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if bestDist > 1 then
|
context.delay(300)
|
||||||
for i=1,10 do
|
|
||||||
local testPos = {x=pos.x + math.random(-4,4), y=pos.y + math.random(-4,4), z=pos.z}
|
|
||||||
local dist = math.abs(config.distance - math.max(math.abs(tpos.x - testPos.x), math.abs(tpos.y - testPos.y)))
|
|
||||||
if dist < bestDist then
|
|
||||||
local path = context.findPath(pos, testPos, 100, true, false)
|
|
||||||
if #path > 0 then
|
|
||||||
bestPos = testPos
|
|
||||||
bestDist = dist
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if bestDist < 10 then
|
|
||||||
context.autoWalk(bestPos, 100, true, false)
|
|
||||||
context.delay(300)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -971,16 +961,14 @@ Panel
|
|||||||
end
|
end
|
||||||
|
|
||||||
if distance > 1 then
|
if distance > 1 then
|
||||||
for x=-1,1 do
|
if not context.autoWalk(tpos, 8, { precision = 1}) then
|
||||||
for y=-1,1 do
|
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, precision = 1}) then
|
||||||
if context.autoWalk({x=tpos.x-x, y=tpos.y-y, z=tpos.z}, 100, true, false) then
|
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, precision = 2}) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not context.autoWalk(tpos, 100, false, true) then
|
context.delay(300)
|
||||||
context.autoWalk(tpos, 100, true, true)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -316,6 +316,87 @@ Panel
|
|||||||
end
|
end
|
||||||
Panels.ManaItem = Panels.Mana
|
Panels.ManaItem = Panels.Mana
|
||||||
|
|
||||||
|
Panels.Eating = function(parent)
|
||||||
|
if not parent then
|
||||||
|
parent = context.panel
|
||||||
|
end
|
||||||
|
|
||||||
|
local panelName = "autoEatingPanel"
|
||||||
|
local panelId = 1
|
||||||
|
while parent:getChildById(panelName .. panelId) do
|
||||||
|
panelId = panelId + 1
|
||||||
|
end
|
||||||
|
panelName = panelName .. panelId
|
||||||
|
|
||||||
|
local ui = context.setupUI([[
|
||||||
|
Panel
|
||||||
|
height: 55
|
||||||
|
margin-top: 2
|
||||||
|
|
||||||
|
Label
|
||||||
|
id: info
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
text: Auto Eating
|
||||||
|
text-align: center
|
||||||
|
|
||||||
|
BotItem
|
||||||
|
id: item1
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 3
|
||||||
|
margin-left: 10
|
||||||
|
|
||||||
|
BotItem
|
||||||
|
id: item2
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.top: prev.top
|
||||||
|
|
||||||
|
BotItem
|
||||||
|
id: item3
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: prev.top
|
||||||
|
margin-right: 10
|
||||||
|
|
||||||
|
]], parent)
|
||||||
|
ui:setId(panelName)
|
||||||
|
|
||||||
|
if not context.storage["autoEating" .. panelId] then
|
||||||
|
context.storage["autoEating" .. panelId] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
ui.item1.onItemChange = function(widget)
|
||||||
|
context.storage["autoEating" .. panelId][1] = widget:getItemId()
|
||||||
|
end
|
||||||
|
ui.item1:setItemId(context.storage["autoEating" .. panelId][1] or 3725)
|
||||||
|
|
||||||
|
ui.item2.onItemChange = function(widget)
|
||||||
|
context.storage["autoEating" .. panelId][2] = widget:getItemId()
|
||||||
|
end
|
||||||
|
ui.item2:setItemId(context.storage["autoEating" .. panelId][2] or 0)
|
||||||
|
|
||||||
|
ui.item3.onItemChange = function(widget)
|
||||||
|
context.storage["autoEating" .. panelId][3] = widget:getItemId()
|
||||||
|
end
|
||||||
|
ui.item3:setItemId(context.storage["autoEating" .. panelId][3] or 0)
|
||||||
|
|
||||||
|
|
||||||
|
context.macro(15000, function()
|
||||||
|
local candidates = {}
|
||||||
|
for i, item in pairs(context.storage["autoEating" .. panelId]) do
|
||||||
|
if item >= 100 then
|
||||||
|
table.insert(candidates, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #candidates == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
context.usewith(candidates[math.random(1, #candidates)], context.player)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
Panels.ManaItem = Panels.Mana
|
||||||
|
|
||||||
Panels.Turning = function(parent)
|
Panels.Turning = function(parent)
|
||||||
context.macro(1000, "Turning / AntiIdle", nil, function()
|
context.macro(1000, "Turning / AntiIdle", nil, function()
|
||||||
context.turn(math.random(1, 4))
|
context.turn(math.random(1, 4))
|
||||||
|
|||||||
@@ -488,7 +488,7 @@ Panel
|
|||||||
|
|
||||||
context.onContainerOpen(function(container)
|
context.onContainerOpen(function(container)
|
||||||
if container:getItemsCount() > 0 then
|
if container:getItemsCount() > 0 then
|
||||||
lastOpenedContainer = context.now
|
lastOpenedContainer = context.now + container:getItemsCount() * 100
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -547,32 +547,35 @@ Panel
|
|||||||
if distance > 100 or position.z ~= context.player:getPosition().z then
|
if distance > 100 or position.z ~= context.player:getPosition().z then
|
||||||
lastGotoSuccesful = false
|
lastGotoSuccesful = false
|
||||||
elseif distance > 0 then
|
elseif distance > 0 then
|
||||||
commandExecutionNo = commandExecutionNo + 1
|
if not context.findPath(context.player:getPosition(), position, 100, { ignoreNonPathable = true, precision = 1, ignoreCreatures = true }) then
|
||||||
lastGotoSuccesful = false
|
lastGotoSuccesful = false
|
||||||
if commandExecutionNo <= 3 then -- try max 3 times
|
executeNextMacroCall = true
|
||||||
if not context.autoWalk(position, 100 + distance * 2, commandExecutionNo > 1, false) then
|
else
|
||||||
if commandExecutionNo > 1 then
|
commandExecutionNo = commandExecutionNo + 1
|
||||||
context.autoWalk(position, 100 + distance * 2, true, true) -- ignore creatures
|
lastGotoSuccesful = false
|
||||||
end
|
if commandExecutionNo <= 3 then -- try max 3 times
|
||||||
context.delay(500)
|
if not context.autoWalk(position, distance * 2, { ignoreNonPathable = false }) then
|
||||||
return
|
if commandExecutionNo > 1 then
|
||||||
end
|
if context.autoWalk(position, distance * 2, { ignoreNonPathable = true, precision = 1 }) then
|
||||||
return
|
context.delay(500)
|
||||||
elseif commandExecutionNo == 4 then -- try last time, location close to destination
|
end
|
||||||
for i=1,3 do
|
end
|
||||||
position.x = position.x + math.random(-1, 1)
|
|
||||||
position.y = position.y + math.random(-1, 1)
|
|
||||||
if context.autoWalk(position, 100 + distance * 2, true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
return
|
||||||
|
elseif commandExecutionNo == 4 then -- try last time, location close to destination
|
||||||
|
if context.autoWalk(position, distance * 2, { ignoreNonPathable = true, ignoreLastCreature = true, precision = 2, allowUnseen = true }) then
|
||||||
|
context.delay(500)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
elseif distance <= 2 then
|
||||||
|
lastGotoSuccesful = true
|
||||||
|
executeNextMacroCall = true
|
||||||
end
|
end
|
||||||
elseif distance <= 2 then
|
|
||||||
lastGotoSuccesful = true
|
|
||||||
executeNextMacroCall = lastGotoSuccesful
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lastGotoSuccesful = true
|
lastGotoSuccesful = true
|
||||||
executeNextMacroCall = lastGotoSuccesful
|
executeNextMacroCall = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
context.error("Waypoints: invalid use of goto function")
|
context.error("Waypoints: invalid use of goto function")
|
||||||
|
|||||||
BIN
otclient_dx.exe
BIN
otclient_dx.exe
Binary file not shown.
BIN
otclient_gl.exe
BIN
otclient_gl.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user