mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-20 22:53:26 +02:00
Bot update - waypoints, attacking, looting
This commit is contained in:
@@ -25,7 +25,10 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback)
|
||||
onCreaturePositionChange = {},
|
||||
onCreatureHealthPercentChange = {},
|
||||
onUse = {},
|
||||
onUseWith = {}
|
||||
onUseWith = {},
|
||||
onContainerOpen = {},
|
||||
onContainerClose = {},
|
||||
onContainerUpdateItem = {}
|
||||
}
|
||||
|
||||
-- basic functions & classes
|
||||
@@ -48,8 +51,13 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback)
|
||||
context.g_game = g_game
|
||||
context.g_map = g_map
|
||||
context.g_ui = g_ui
|
||||
context.g_platform = g_platform
|
||||
context.g_sounds = g_sounds
|
||||
context.g_window = g_window
|
||||
context.g_mouse = g_mouse
|
||||
|
||||
context.StaticText = StaticText
|
||||
context.Position = Position
|
||||
context.Config = Config
|
||||
context.HTTP = HTTP
|
||||
|
||||
-- log functions
|
||||
@@ -80,14 +88,24 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback)
|
||||
|
||||
for i, macro in ipairs(context._macros) do
|
||||
if macro.lastExecution + macro.timeout <= context.now and (macro.name == nil or macro.name:len() < 1 or context.storage._macros[macro.name]) then
|
||||
if macro.callback() then
|
||||
macro.lastExecution = context.now
|
||||
local status, result = pcall(function()
|
||||
if macro.callback() then
|
||||
macro.lastExecution = context.now
|
||||
end
|
||||
end)
|
||||
if not status then
|
||||
context.error("Macro: " .. macro.name .. " execution error: " .. result)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
while #context._scheduler > 0 and context._scheduler[1].execution <= g_clock.millis() do
|
||||
context._scheduler[1].callback()
|
||||
local status, result = pcall(function()
|
||||
context._scheduler[1].callback()
|
||||
end)
|
||||
if not status then
|
||||
context.error("Schedule execution error: " .. result)
|
||||
end
|
||||
table.remove(context._scheduler, 1)
|
||||
end
|
||||
end,
|
||||
@@ -161,7 +179,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback)
|
||||
onCreatureDisappear = function(creature)
|
||||
for i, callback in ipairs(context._callbacks.onCreatureDisappear) do
|
||||
callback(creature)
|
||||
end
|
||||
end
|
||||
end,
|
||||
onCreaturePositionChange = function(creature, newPos, oldPos)
|
||||
for i, callback in ipairs(context._callbacks.onCreaturePositionChange) do
|
||||
@@ -182,7 +200,22 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback)
|
||||
for i, callback in ipairs(context._callbacks.onUseWith) do
|
||||
callback(pos, itemId, target, subType)
|
||||
end
|
||||
end
|
||||
end,
|
||||
onContainerOpen = function(container, previousContainer)
|
||||
for i, callback in ipairs(context._callbacks.onContainerOpen) do
|
||||
callback(container, previousContainer)
|
||||
end
|
||||
end,
|
||||
onContainerClose = function(container)
|
||||
for i, callback in ipairs(context._callbacks.onContainerClose) do
|
||||
callback(container)
|
||||
end
|
||||
end,
|
||||
onContainerUpdateItem = function(container, slot, item)
|
||||
for i, callback in ipairs(context._callbacks.onContainerUpdateItem) do
|
||||
callback(container, slot, item)
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
Reference in New Issue
Block a user