Version 2.3.1 - bug fixes, hotkeys and anction bars work now in old tibia version (<780)

This commit is contained in:
OTCv8 2020-04-15 21:41:49 +02:00
parent 9a4ab2ae3b
commit 401eb76bba
44 changed files with 101 additions and 47 deletions

View File

@ -1,2 +1,2 @@
GameButtonsWindow < MiniWindow GameButtonsWindow < MiniWindow
height: 40 height: 26

View File

@ -1,5 +1,5 @@
GameButtonsWindow < HeadlessMiniWindow GameButtonsWindow < HeadlessMiniWindow
height: 52 height: 26
&forceOpen: true &forceOpen: true
&autoOpen: 4 &autoOpen: 4

View File

@ -135,7 +135,7 @@ function UIComboBox:onMousePress(mousePos, mouseButton)
end end
function UIComboBox:onMouseWheel(mousePos, direction) function UIComboBox:onMouseWheel(mousePos, direction)
if not self.mouseScroll then if not self.mouseScroll or self.disableScroll then
return false return false
end end
if direction == MouseWheelUp and self.currentIndex > 1 then if direction == MouseWheelUp and self.currentIndex > 1 then

View File

@ -254,7 +254,7 @@ function UIScrollBar:onGeometryChange()
end end
function UIScrollBar:onMouseWheel(mousePos, mouseWheel) function UIScrollBar:onMouseWheel(mousePos, mouseWheel)
if not self.mouseScroll or not self:isOn() then if not self.mouseScroll or not self:isOn() or self.disableScroll then
return false return false
end end
if mouseWheel == MouseWheelUp then if mouseWheel == MouseWheelUp then

View File

@ -23,7 +23,7 @@ function UISpinBox:onSetup()
end end
function UISpinBox:onMouseWheel(mousePos, direction) function UISpinBox:onMouseWheel(mousePos, direction)
if not self.mouseScroll then if not self.mouseScroll or self.disableScroll then
return false return false
end end
if direction == MouseWheelUp then if direction == MouseWheelUp then

View File

@ -299,7 +299,7 @@ function actionOnMouseRelease(action, mousePosition, mouseButton)
end end
function actionOnItemChange(widget) function actionOnItemChange(widget)
updateAction(widget:getParent(), {text="", item=widget:getItemId(), count=widget:getItemCount()}) updateAction(widget:getParent(), {text="", item=widget:getItemId(), count=widget:getItemCountOrSubType()})
end end
function onSpellCooldown(iconId, duration) function onSpellCooldown(iconId, duration)
@ -366,8 +366,8 @@ function executeAction(action, ticks)
action.actionDelayTo = g_clock.millis() + actionDelay action.actionDelayTo = g_clock.millis() + actionDelay
elseif action.item:getItemId() > 0 then elseif action.item:getItemId() > 0 then
if actionType == ActionTypes.USE then if actionType == ActionTypes.USE then
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local item = g_game.findPlayerItem(action.item:getItemId(), hotKey.subType or -1) local item = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1)
if item then if item then
g_game.use(item) g_game.use(item)
end end
@ -376,8 +376,8 @@ function executeAction(action, ticks)
end end
action.actionDelayTo = g_clock.millis() + actionDelay action.actionDelayTo = g_clock.millis() + actionDelay
elseif actionType == ActionTypes.USE_SELF then elseif actionType == ActionTypes.USE_SELF then
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local item = g_game.findPlayerItem(action.item:getItemId(), hotKey.subType or -1) local item = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1)
if item then if item then
g_game.useWith(item, g_game.getLocalPlayer()) g_game.useWith(item, g_game.getLocalPlayer())
end end
@ -389,7 +389,7 @@ function executeAction(action, ticks)
local attackingCreature = g_game.getAttackingCreature() local attackingCreature = g_game.getAttackingCreature()
if not attackingCreature then if not attackingCreature then
local item = Item.create(action.item:getItemId()) local item = Item.create(action.item:getItemId())
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local tmpItem = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1) local tmpItem = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1)
if not tmpItem then return end if not tmpItem then return end
item = tmpItem item = tmpItem
@ -400,7 +400,7 @@ function executeAction(action, ticks)
end end
if not attackingCreature:getTile() then return end if not attackingCreature:getTile() then return end
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local item = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1) local item = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1)
if item then if item then
g_game.useWith(item, attackingCreature, action.item:getItemSubType() or -1) g_game.useWith(item, attackingCreature, action.item:getItemSubType() or -1)
@ -411,7 +411,7 @@ function executeAction(action, ticks)
action.actionDelayTo = g_clock.millis() + actionDelay action.actionDelayTo = g_clock.millis() + actionDelay
elseif actionType == ActionTypes.USE_WITH then elseif actionType == ActionTypes.USE_WITH then
local item = Item.create(action.item:getItemId()) local item = Item.create(action.item:getItemId())
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local tmpItem = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1) local tmpItem = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1)
if not tmpItem then return true end if not tmpItem then return true end
item = tmpItem item = tmpItem

View File

@ -7,6 +7,9 @@ CaveBot.addAction = function(action, value, focus)
if not raction then if not raction then
return error("Invalid cavebot action: " .. action) return error("Invalid cavebot action: " .. action)
end end
if type(value) == 'number' then
value = tostring(value)
end
local widget = UI.createWidget("CaveBotAction", CaveBot.actionList) local widget = UI.createWidget("CaveBotAction", CaveBot.actionList)
widget:setText(action .. ":" .. value:split("\n")[1]) widget:setText(action .. ":" .. value:split("\n")[1])
widget.action = action widget.action = action

View File

@ -38,6 +38,7 @@ CaveBot.Editor.registerAction = function(action, text, params)
end end
local widget = CaveBot.addAction(action, value) local widget = CaveBot.addAction(action, value)
CaveBot.actionList:moveChildToIndex(widget, index + 1) CaveBot.actionList:moveChildToIndex(widget, index + 1)
CaveBot.actionList:focusChild(widget)
CaveBot.save() CaveBot.save()
end) end)
end end
@ -58,6 +59,11 @@ CaveBot.Editor.setup = function()
CaveBot.actionList:ensureChildVisible(action) CaveBot.actionList:ensureChildVisible(action)
CaveBot.save() CaveBot.save()
end) end)
registerAction("edit", function()
local action = CaveBot.actionList:getFocusedChild()
if not action or not action.onDoubleClick then return end
action.onDoubleClick(action)
end)
registerAction("move down", function() registerAction("move down", function()
local action = CaveBot.actionList:getFocusedChild() local action = CaveBot.actionList:getFocusedChild()
if not action then return end if not action then return end
@ -67,11 +73,6 @@ CaveBot.Editor.setup = function()
CaveBot.actionList:ensureChildVisible(action) CaveBot.actionList:ensureChildVisible(action)
CaveBot.save() CaveBot.save()
end) end)
registerAction("edit", function()
local action = CaveBot.actionList:getFocusedChild()
if not action or not action.onDoubleClick then return end
action.onDoubleClick(action)
end)
registerAction("remove", function() registerAction("remove", function()
local action = CaveBot.actionList:getFocusedChild() local action = CaveBot.actionList:getFocusedChild()
if not action then return end if not action then return end

View File

@ -26,10 +26,7 @@ local function setup()
onUse(function(pos, itemId, stackPos, subType) onUse(function(pos, itemId, stackPos, subType)
if CaveBot.isOn() or not isEnabled then return end if CaveBot.isOn() or not isEnabled then return end
if pos.x == 0xFFFF then if pos.x ~= 0xFFFF then
lastPos = pos
CaveBot.addAction("use", itemId, true)
else
lastPos = pos lastPos = pos
CaveBot.addAction("use", pos.x .. "," .. pos.y .. "," .. pos.z, true) CaveBot.addAction("use", pos.x .. "," .. pos.y .. "," .. pos.z, true)
end end

View File

@ -58,9 +58,14 @@ for i, healingInfo in ipairs({storage.hpitem1, storage.hpitem2, storage.manaitem
local hp = i <= 2 and player:getHealthPercent() or math.min(100, math.floor(100 * (player:getMana() / player:getMaxMana()))) local hp = i <= 2 and player:getHealthPercent() or math.min(100, math.floor(100 * (player:getMana() / player:getMaxMana())))
if healingInfo.max >= hp and hp >= healingInfo.min then if healingInfo.max >= hp and hp >= healingInfo.min then
if TargetBot then if TargetBot then
TargetBot.useItem(healingInfo.item, player) -- sync spell with targetbot if available TargetBot.useItem(healingInfo.item, healingInfo.subType, player) -- sync spell with targetbot if available
else else
useWith(healingInfo.item, player) local thing = g_things.getThingType(healingInfo.item)
local subType = g_game.getClientVersion() >= 860 and 0 or 1
if thing and thing:isFluidContainer() then
subType = healingInfo.subType
end
g_game.useInventoryItemWith(healingInfo.item, player, subType)
end end
end end
end) end)
@ -68,10 +73,14 @@ for i, healingInfo in ipairs({storage.hpitem1, storage.hpitem2, storage.manaitem
UI.DualScrollItemPanel(healingInfo, function(widget, newParams) UI.DualScrollItemPanel(healingInfo, function(widget, newParams)
healingInfo = newParams healingInfo = newParams
healingmacro.setOn(healingInfo.on) healingmacro.setOn(healingInfo.on and healingInfo.item > 100)
end) end)
end end
if g_game.getClientVersion() < 780 then
UI.Label("In old tibia potions & runes work only when you have backpack with them opened")
end
UI.Separator() UI.Separator()
UI.Label("Mana shield spell:") UI.Label("Mana shield spell:")
@ -143,6 +152,7 @@ macro(10000, "eat food", function()
end end
end end
-- can't find any food, try to eat random item using hotkey -- can't find any food, try to eat random item using hotkey
if g_game.getClientVersion() < 780 then return end -- hotkey's dont work on old tibia
local toEat = storage.foodItems[math.random(1, #storage.foodItems)] local toEat = storage.foodItems[math.random(1, #storage.foodItems)]
if toEat then g_game.useInventoryItem(toEat.id) end if toEat then g_game.useInventoryItem(toEat.id) end
end) end)

View File

@ -1,5 +1,5 @@
-- main tab -- main tab
VERSION = "1.0" VERSION = "1.1"
UI.Label("Config version: " .. VERSION) UI.Label("Config version: " .. VERSION)

View File

@ -39,7 +39,7 @@ TargetBot.Creature.attack = function(params, targets, isLooting) -- params {conf
end end
end end
if config.useRuneAttack and config.attackRune > 100 then if config.useRuneAttack and config.attackRune > 100 then
if TargetBot.useAttackItem(config.attackRune, creature, config.attackRuneDelay) then if TargetBot.useAttackItem(config.attackRune, 0, creature, config.attackRuneDelay) then
return return
end end
end end

View File

@ -1,6 +1,6 @@
TargetBot.Creature.calculatePriority = function(creature, config, path) TargetBot.Creature.calculatePriority = function(creature, config, path)
-- config is based on creature_editor -- config is based on creature_editor
local priority = config.priority local priority = 0
-- extra priority if it's current target -- extra priority if it's current target
if g_game.getAttackingCreature() == creature then if g_game.getAttackingCreature() == creature then
@ -12,6 +12,9 @@ TargetBot.Creature.calculatePriority = function(creature, config, path)
return priority return priority
end end
-- add config priority
priority = priority + config.priority
-- extra priority for close distance -- extra priority for close distance
local path_length = #path local path_length = #path
if path_length == 1 then if path_length == 1 then

View File

@ -237,7 +237,7 @@ TargetBot.Looting.lootContainer = function(lootContainers, container)
if nextContainer.lootTries < 2 then -- max 0.6s to open it if nextContainer.lootTries < 2 then -- max 0.6s to open it
g_game.open(nextContainer, container) g_game.open(nextContainer, container)
waitTill = now + 300 -- give it 0.3s to open waitTill = now + 300 -- give it 0.3s to open
waitingForContainer = loot.container waitingForContainer = nextContainer:getId()
return return
end end
end end

View File

@ -216,16 +216,41 @@ TargetBot.sayAttackSpell = function(text, delay)
return false return false
end end
local lastItemUse = 0
local lastRuneAttack = 0 local lastRuneAttack = 0
TargetBot.useItem = function(item, target, delay) TargetBot.useItem = function(item, subType, target, delay)
useWith(item, target) if not delay then delay = 200 end
if lastItemUse + delay < now then
local thing = g_things.getThingType(item)
if not thing or not thing:isFluidContainer() then
subType = g_game.getClientVersion() >= 860 and 0 or 1
end
if g_game.getClientVersion() < 780 then
local tmpItem = g_game.findPlayerItem(item, subType)
if not tmpItem then return end
g_game.useWith(tmpItem, target, subType) -- using item from bp
else
g_game.useInventoryItemWith(item, target, subType) -- hotkey
end
lastItemUse = now
end
end end
TargetBot.useAttackItem = function(item, target, delay) TargetBot.useAttackItem = function(item, subType, target, delay)
if not delay then delay = 2000 end if not delay then delay = 2000 end
if lastRuneAttack + delay < now then if lastRuneAttack + delay < now then
useWith(item, target) local thing = g_things.getThingType(item)
if not thing or not thing:isFluidContainer() then
subType = g_game.getClientVersion() >= 860 and 0 or 1
end
if g_game.getClientVersion() < 780 then
local tmpItem = g_game.findPlayerItem(item, subType)
if not tmpItem then return end
g_game.useWith(tmpItem, target, subType) -- using item from bp
else
g_game.useInventoryItemWith(healingInfo.item, target, subType) -- hotkey
end
lastRuneAttack = now lastRuneAttack = now
end end
end end

View File

@ -1,5 +0,0 @@
# Default config for OTClientV8 bot (min. otcv8 version 2.2.3)
### Website: http://bot.otclient.ovh/
### Forum: https://otland.net/forums/otclient.494/
### Discord: https://discord.gg/t4ntS5p

View File

@ -95,6 +95,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo
context.g_sounds = g_sounds context.g_sounds = g_sounds
context.g_window = g_window context.g_window = g_window
context.g_mouse = g_mouse context.g_mouse = g_mouse
context.g_things = g_things
context.Item = Item context.Item = Item
context.Creature = Creature context.Creature = Creature

View File

@ -150,12 +150,14 @@ UI.DualScrollItemPanel = function(params, callback, parent) -- callback = functi
--[[ params: --[[ params:
on - bool, on - bool,
item - number, item - number,
subType - number,
title - string, title - string,
min - number, min - number,
max - number, max - number,
]] ]]
params.title = params.title or "title" params.title = params.title or "title"
params.item = params.item or 0 params.item = params.item or 0
params.subType = params.subType or 0
params.min = params.min or 20 params.min = params.min or 20
params.max = params.max or 80 params.max = params.max or 80
@ -170,9 +172,10 @@ UI.DualScrollItemPanel = function(params, callback, parent) -- callback = functi
end end
end end
widget.item:setItemId(params.item) widget.item:setItem(Item.create(params.item, params.subType))
widget.item.onItemChange = function() widget.item.onItemChange = function()
params.item = widget.item:getItemId() params.item = widget.item:getItemId()
params.subType = widget.item:getItemSubType()
if callback then if callback then
callback(widget, params) callback(widget, params)
end end

View File

@ -19,6 +19,7 @@ DualScrollPanel < Panel
minimum: 0 minimum: 0
maximum: 100 maximum: 100
step: 1 step: 1
&disableScroll: true
HorizontalScrollBar HorizontalScrollBar
id: scroll2 id: scroll2
@ -29,6 +30,7 @@ DualScrollPanel < Panel
minimum: 0 minimum: 0
maximum: 100 maximum: 100
step: 1 step: 1
&disableScroll: true
BotTextEdit BotTextEdit
id: text id: text
@ -66,6 +68,7 @@ SingleScrollItemPanel < Panel
minimum: 0 minimum: 0
maximum: 100 maximum: 100
step: 1 step: 1
&disableScroll: true
DualScrollItemPanel < Panel DualScrollItemPanel < Panel
height: 33 height: 33
@ -95,6 +98,7 @@ DualScrollItemPanel < Panel
minimum: 0 minimum: 0
maximum: 100 maximum: 100
step: 1 step: 1
&disableScroll: true
HorizontalScrollBar HorizontalScrollBar
id: scroll2 id: scroll2
@ -105,6 +109,7 @@ DualScrollItemPanel < Panel
minimum: 0 minimum: 0
maximum: 100 maximum: 100
step: 1 step: 1
&disableScroll: true
ItemsRow < Panel ItemsRow < Panel
height: 33 height: 33
@ -197,6 +202,7 @@ ItemAndSlotPanel < Panel
anchors.top: prev.bottom anchors.top: prev.bottom
margin-top: 2 margin-top: 2
height: 20 height: 20
&disableScroll: true
TwoItemsAndSlotPanel < Panel TwoItemsAndSlotPanel < Panel
height: 35 height: 35
@ -230,4 +236,5 @@ TwoItemsAndSlotPanel < Panel
anchors.top: prev.bottom anchors.top: prev.bottom
margin-top: 2 margin-top: 2
height: 20 height: 20
&disableScroll: true

View File

@ -37,4 +37,13 @@ function updateOrder()
return (a.index or 1000) < (b.index or 1000) return (a.index or 1000) < (b.index or 1000)
end) end)
contentsPanel.buttons:reorderChildren(children) contentsPanel.buttons:reorderChildren(children)
local visibleCount = 0
for _, child in ipairs(children) do
if child:isVisible() then
visibleCount = visibleCount + 1
end
end
if visibleCount > 6 and buttonsWindow:getHeight() < 30 then
buttonsWindow:setHeight(buttonsWindow:getHeight() + 22)
end
end end

View File

@ -459,7 +459,7 @@ function doKeyCombo(keyCombo, repeated)
end end
hotKey.hotkeyDelayTo = g_clock.millis() + hotkeyDelay hotKey.hotkeyDelayTo = g_clock.millis() + hotkeyDelay
elseif hotKey.useType == HOTKEY_MANAGER_USE then elseif hotKey.useType == HOTKEY_MANAGER_USE then
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1) local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
if item then if item then
g_game.use(item) g_game.use(item)
@ -469,7 +469,7 @@ function doKeyCombo(keyCombo, repeated)
end end
hotKey.hotkeyDelayTo = g_clock.millis() + hotkeyDelay hotKey.hotkeyDelayTo = g_clock.millis() + hotkeyDelay
elseif hotKey.useType == HOTKEY_MANAGER_USEONSELF then elseif hotKey.useType == HOTKEY_MANAGER_USEONSELF then
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1) local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
if item then if item then
g_game.useWith(item, g_game.getLocalPlayer()) g_game.useWith(item, g_game.getLocalPlayer())
@ -482,7 +482,7 @@ function doKeyCombo(keyCombo, repeated)
local attackingCreature = g_game.getAttackingCreature() local attackingCreature = g_game.getAttackingCreature()
if not attackingCreature then if not attackingCreature then
local item = Item.create(hotKey.itemId) local item = Item.create(hotKey.itemId)
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local tmpItem = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1) local tmpItem = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
if not tmpItem then return end if not tmpItem then return end
item = tmpItem item = tmpItem
@ -493,7 +493,7 @@ function doKeyCombo(keyCombo, repeated)
end end
if not attackingCreature:getTile() then return end if not attackingCreature:getTile() then return end
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1) local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
if item then if item then
g_game.useWith(item, attackingCreature, hotKey.subType or -1) g_game.useWith(item, attackingCreature, hotKey.subType or -1)
@ -504,7 +504,7 @@ function doKeyCombo(keyCombo, repeated)
hotKey.hotkeyDelayTo = g_clock.millis() + hotkeyDelay hotKey.hotkeyDelayTo = g_clock.millis() + hotkeyDelay
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
local item = Item.create(hotKey.itemId) local item = Item.create(hotKey.itemId)
if g_game.getClientVersion() < 740 then if g_game.getClientVersion() < 780 then
local tmpItem = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1) local tmpItem = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
if not tmpItem then return true end if not tmpItem then return true end
item = tmpItem item = tmpItem

View File

@ -376,7 +376,7 @@ function walk(dir, ticks)
g_game.stop() g_game.stop()
return return
else else
return player:lockWalk(200)
end end
end end

View File

@ -26,7 +26,7 @@ function UIItem:onDrop(widget, mousePos, forced)
if not item or not item:isItem() then return false end if not item or not item:isItem() then return false end
if self.selectable then if self.selectable then
self:setItem(Item.create(item:getId(), item:getCount())) self:setItem(Item.create(item:getId(), item:getCountOrSubType()))
return return
end end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.