mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-20 22:53:26 +02:00
Version 1.0
This commit is contained in:
@@ -621,6 +621,8 @@ Panel
|
||||
end
|
||||
|
||||
refreshConfig()
|
||||
|
||||
-- processing
|
||||
|
||||
local getMonsterConfig = function(monster)
|
||||
if monsters[monster:getName():lower()] then
|
||||
@@ -639,21 +641,28 @@ Panel
|
||||
return -1
|
||||
end
|
||||
|
||||
local distance = context.getDistanceBetween(context.player:getPosition(), monster:getPosition())
|
||||
if distance > 10 then
|
||||
local pos = context.player:getPosition()
|
||||
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
|
||||
end
|
||||
|
||||
local mpos = monster:getPosition()
|
||||
local hasPath = false
|
||||
for x=-1,1 do
|
||||
for y=-1,1 do
|
||||
local pathTo = context.findPath(context.player:getPosition(), {x=mpos.x-x, y=mpos.y-y, z=mpos.z}, 100, true, false)
|
||||
if #pathTo > 0 then
|
||||
hasPath = true
|
||||
break
|
||||
end
|
||||
end
|
||||
local pathTo = context.findPath(context.player:getPosition(), {x=mpos.x, y=mpos.y, z=mpos.z}, 10, { ignoreNonPathable = true, precision=1 })
|
||||
if pathTo then
|
||||
hasPath = true
|
||||
end
|
||||
if distance > 2 and not hasPath then
|
||||
return -1
|
||||
@@ -667,19 +676,26 @@ Panel
|
||||
priority = priority + 10
|
||||
end
|
||||
if distance <= 2 then
|
||||
priority = priority + 20
|
||||
priority = priority + 10
|
||||
end
|
||||
if distance <= 1 then
|
||||
priority = priority + 10
|
||||
end
|
||||
|
||||
if monster:getHealthPercent() <= 10 then
|
||||
if hp <= 20 and config.chase then
|
||||
priority = priority + 30
|
||||
end
|
||||
|
||||
if hp <= 10 then
|
||||
priority = priority + 10
|
||||
end
|
||||
if monster:getHealthPercent() <= 25 then
|
||||
if hp <= 25 then
|
||||
priority = priority + 10
|
||||
end
|
||||
if monster:getHealthPercent() <= 50 then
|
||||
if hp <= 50 then
|
||||
priority = priority + 10
|
||||
end
|
||||
if monster:getHealthPercent() <= 75 then
|
||||
if hp <= 75 then
|
||||
priority = priority + 10
|
||||
end
|
||||
|
||||
@@ -720,13 +736,13 @@ Panel
|
||||
table.remove(lootContainers, 1)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
if lootTries >= 5 then
|
||||
lootTries = 0
|
||||
table.remove(lootContainers, 1)
|
||||
return true
|
||||
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
|
||||
local tile = g_map.getTile(cpos)
|
||||
if not tile then
|
||||
@@ -739,7 +755,8 @@ Panel
|
||||
table.remove(lootContainers, 1)
|
||||
return true
|
||||
end
|
||||
|
||||
topItem:setMarked('orange')
|
||||
|
||||
if dist <= 1 then
|
||||
lootTries = lootTries + 1
|
||||
openContainerRequest = context.now
|
||||
@@ -755,30 +772,19 @@ Panel
|
||||
end
|
||||
|
||||
lootTries = lootTries + 1
|
||||
if context.autoWalk(cpos, 100 + dist * 2) then
|
||||
if context.autoWalk(cpos, 20, { precision = 1}) then
|
||||
return true
|
||||
end
|
||||
|
||||
if context.autoWalk(cpos, 100 + dist * 2, true) then
|
||||
if context.autoWalk(cpos, 20, { ignoreNonPathable = true, precision = 1}) then
|
||||
return true
|
||||
end
|
||||
|
||||
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) 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
|
||||
if context.autoWalk(cpos, 20, { ignoreNonPathable = true, precision = 2}) then
|
||||
return true
|
||||
end
|
||||
|
||||
-- ignore fields and monsters
|
||||
if context.autoWalk(cpos, 100 + dist * 2, true, true) then
|
||||
if context.autoWalk(cpos, 20, { ignoreNonPathable = true, ignoreCreatures = true, precision = 2}) then
|
||||
return true
|
||||
end
|
||||
else
|
||||
@@ -817,6 +823,7 @@ Panel
|
||||
return
|
||||
end
|
||||
|
||||
topItem:setMarked('blue')
|
||||
table.insert(lootContainers, tpos)
|
||||
end)
|
||||
|
||||
@@ -916,40 +923,23 @@ Panel
|
||||
|
||||
local distance = math.max(math.abs(offsetX), math.abs(offsetY))
|
||||
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
|
||||
else
|
||||
local bestDist = 10
|
||||
local bestPos = pos
|
||||
|
||||
for i=1,5 do
|
||||
local testPos = {x=pos.x + math.random(-3,3), y=pos.y + math.random(-3,3), 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, false, false)
|
||||
if #path > 0 then
|
||||
bestPos = testPos
|
||||
bestDist = dist
|
||||
if not context.autoWalk(tpos, 8, { minMargin=minDistance, maxMargin=minDistance + 1}) then
|
||||
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, minMargin=minDistance, maxMargin=minDistance + 1}) then
|
||||
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, ignoreCreatures = true, minMargin=minDistance, maxMargin=minDistance + 2}) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
if bestDist > 1 then
|
||||
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
|
||||
context.delay(300)
|
||||
end
|
||||
return
|
||||
end
|
||||
@@ -971,16 +961,14 @@ Panel
|
||||
end
|
||||
|
||||
if distance > 1 then
|
||||
for x=-1,1 do
|
||||
for y=-1,1 do
|
||||
if context.autoWalk({x=tpos.x-x, y=tpos.y-y, z=tpos.z}, 100, true, false) then
|
||||
if not context.autoWalk(tpos, 8, { precision = 1}) then
|
||||
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, precision = 1}) then
|
||||
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, precision = 2}) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
if not context.autoWalk(tpos, 100, false, true) then
|
||||
context.autoWalk(tpos, 100, true, true)
|
||||
end
|
||||
context.delay(300)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@@ -316,6 +316,87 @@ Panel
|
||||
end
|
||||
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)
|
||||
context.macro(1000, "Turning / AntiIdle", nil, function()
|
||||
context.turn(math.random(1, 4))
|
||||
|
@@ -488,7 +488,7 @@ Panel
|
||||
|
||||
context.onContainerOpen(function(container)
|
||||
if container:getItemsCount() > 0 then
|
||||
lastOpenedContainer = context.now
|
||||
lastOpenedContainer = context.now + container:getItemsCount() * 100
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -547,32 +547,35 @@ Panel
|
||||
if distance > 100 or position.z ~= context.player:getPosition().z then
|
||||
lastGotoSuccesful = false
|
||||
elseif distance > 0 then
|
||||
commandExecutionNo = commandExecutionNo + 1
|
||||
lastGotoSuccesful = false
|
||||
if commandExecutionNo <= 3 then -- try max 3 times
|
||||
if not context.autoWalk(position, 100 + distance * 2, commandExecutionNo > 1, false) then
|
||||
if commandExecutionNo > 1 then
|
||||
context.autoWalk(position, 100 + distance * 2, true, true) -- ignore creatures
|
||||
end
|
||||
context.delay(500)
|
||||
return
|
||||
end
|
||||
return
|
||||
elseif commandExecutionNo == 4 then -- try last time, location close to destination
|
||||
for i=1,3 do
|
||||
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
|
||||
if not context.findPath(context.player:getPosition(), position, 100, { ignoreNonPathable = true, precision = 1, ignoreCreatures = true }) then
|
||||
lastGotoSuccesful = false
|
||||
executeNextMacroCall = true
|
||||
else
|
||||
commandExecutionNo = commandExecutionNo + 1
|
||||
lastGotoSuccesful = false
|
||||
if commandExecutionNo <= 3 then -- try max 3 times
|
||||
if not context.autoWalk(position, distance * 2, { ignoreNonPathable = false }) then
|
||||
if commandExecutionNo > 1 then
|
||||
if context.autoWalk(position, distance * 2, { ignoreNonPathable = true, precision = 1 }) then
|
||||
context.delay(500)
|
||||
end
|
||||
end
|
||||
return
|
||||
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
|
||||
elseif distance <= 2 then
|
||||
lastGotoSuccesful = true
|
||||
executeNextMacroCall = lastGotoSuccesful
|
||||
end
|
||||
else
|
||||
lastGotoSuccesful = true
|
||||
executeNextMacroCall = lastGotoSuccesful
|
||||
executeNextMacroCall = true
|
||||
end
|
||||
else
|
||||
context.error("Waypoints: invalid use of goto function")
|
||||
|
Reference in New Issue
Block a user