Updated to OTCv8 3.1 rev 105

This commit is contained in:
OTCv8 2021-09-23 18:48:09 +00:00
parent 3f82a78a78
commit 526c57cecf
96 changed files with 124 additions and 55 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -4,6 +4,7 @@ EnterGame = { }
local loadBox local loadBox
local enterGame local enterGame
local enterGameButton local enterGameButton
local logpass
local clientBox local clientBox
local protocolLogin local protocolLogin
local server = nil local server = nil
@ -106,9 +107,8 @@ local function validateThings(things)
g_settings.setNode("things", {}) g_settings.setNode("things", {})
end end
if missingFiles then if missingFiles then
incorrectThings = incorrectThings .. "\nYou should open data/things and create directory " .. versionForMissingFiles .. incorrectThings = incorrectThings .. "\nYou should open data/things and create directory " .. versionForMissingFiles ..
".\nIn this directory (data/things/" .. versionForMissingFiles .. ") you should put missing\nfiles (Tibia.dat and Tibia.spr) " .. ".\nIn this directory (data/things/" .. versionForMissingFiles .. ") you should put missing\nfiles (Tibia.dat and Tibia.spr/Tibia.cwm) " ..
"from correct Tibia version." "from correct Tibia version."
end end
return incorrectThings return incorrectThings
@ -134,10 +134,18 @@ local function onTibia12HTTPResult(session, playdata)
local things = { local things = {
data = {G.clientVersion .. "/Tibia.dat", ""}, data = {G.clientVersion .. "/Tibia.dat", ""},
sprites = {G.clientVersion .. "/Tibia.spr", ""}, sprites = {G.clientVersion .. "/Tibia.cwm", ""},
} }
local incorrectThings = validateThings(things) local incorrectThings = validateThings(things)
if #incorrectThings > 0 then
things = {
data = {G.clientVersion .. "/Tibia.dat", ""},
sprites = {G.clientVersion .. "/Tibia.spr", ""},
}
incorrectThings = validateThings(things)
end
if #incorrectThings > 0 then if #incorrectThings > 0 then
g_logger.error(incorrectThings) g_logger.error(incorrectThings)
if Updater and not checkedByUpdater[G.clientVersion] then if Updater and not checkedByUpdater[G.clientVersion] then
@ -290,6 +298,9 @@ end
function EnterGame.init() function EnterGame.init()
if USE_NEW_ENERGAME then return end if USE_NEW_ENERGAME then return end
enterGame = g_ui.displayUI('entergame') enterGame = g_ui.displayUI('entergame')
if LOGPASS ~= nil then
logpass = g_ui.loadUI('logpass', enterGame:getParent())
end
serverSelectorPanel = enterGame:getChildById('serverSelectorPanel') serverSelectorPanel = enterGame:getChildById('serverSelectorPanel')
customServerSelectorPanel = enterGame:getChildById('customServerSelectorPanel') customServerSelectorPanel = enterGame:getChildById('customServerSelectorPanel')
@ -351,6 +362,11 @@ end
function EnterGame.terminate() function EnterGame.terminate()
if not enterGame then return end if not enterGame then return end
g_keyboard.unbindKeyDown('Ctrl+G') g_keyboard.unbindKeyDown('Ctrl+G')
if logpass then
logpass:destroy()
logpass = nil
end
enterGame:destroy() enterGame:destroy()
if loadBox then if loadBox then
@ -370,11 +386,22 @@ function EnterGame.show()
enterGame:raise() enterGame:raise()
enterGame:focus() enterGame:focus()
enterGame:getChildById('accountNameTextEdit'):focus() enterGame:getChildById('accountNameTextEdit'):focus()
if logpass then
logpass:show()
logpass:raise()
logpass:focus()
end
end end
function EnterGame.hide() function EnterGame.hide()
if not enterGame then return end if not enterGame then return end
enterGame:hide() enterGame:hide()
if logpass then
logpass:hide()
if modules.logpass then
modules.logpass:hide()
end
end
end end
function EnterGame.openWindow() function EnterGame.openWindow()
@ -415,19 +442,19 @@ function EnterGame.onServerChange()
end end
end end
function EnterGame.doLogin() function EnterGame.doLogin(account, password, token, host)
if g_game.isOnline() then if g_game.isOnline() then
local errorBox = displayErrorBox(tr('Login Error'), tr('Cannot login while already in game.')) local errorBox = displayErrorBox(tr('Login Error'), tr('Cannot login while already in game.'))
connect(errorBox, { onOk = EnterGame.show }) connect(errorBox, { onOk = EnterGame.show })
return return
end end
G.account = enterGame:getChildById('accountNameTextEdit'):getText() G.account = account or enterGame:getChildById('accountNameTextEdit'):getText()
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText() G.password = password or enterGame:getChildById('accountPasswordTextEdit'):getText()
G.authenticatorToken = enterGame:getChildById('accountTokenTextEdit'):getText() G.authenticatorToken = token or enterGame:getChildById('accountTokenTextEdit'):getText()
G.stayLogged = true G.stayLogged = true
G.server = serverSelector:getText():trim() G.server = serverSelector:getText():trim()
G.host = serverHostTextEdit:getText() G.host = host or serverHostTextEdit:getText()
G.clientVersion = tonumber(clientVersionSelector:getText()) G.clientVersion = tonumber(clientVersionSelector:getText())
if not rememberPasswordBox:isChecked() then if not rememberPasswordBox:isChecked() then
@ -467,10 +494,17 @@ function EnterGame.doLogin()
local things = { local things = {
data = {G.clientVersion .. "/Tibia.dat", ""}, data = {G.clientVersion .. "/Tibia.dat", ""},
sprites = {G.clientVersion .. "/Tibia.spr", ""}, sprites = {G.clientVersion .. "/Tibia.cwm", ""},
} }
local incorrectThings = validateThings(things) local incorrectThings = validateThings(things)
if #incorrectThings > 0 then
things = {
data = {G.clientVersion .. "/Tibia.dat", ""},
sprites = {G.clientVersion .. "/Tibia.spr", ""},
}
incorrectThings = validateThings(things)
end
if #incorrectThings > 0 then if #incorrectThings > 0 then
g_logger.error(incorrectThings) g_logger.error(incorrectThings)
if Updater and not checkedByUpdater[G.clientVersion] then if Updater and not checkedByUpdater[G.clientVersion] then

View File

@ -0,0 +1,9 @@
UIWidget
id: logpass
size: 248 41
anchors.top: enterGame.bottom
anchors.horizontalCenter: enterGame.horizontalCenter
margin-top: 25
image-size: 248 41
image-source: /images/ui/continue_with_logpass.png
@onClick: modules.logpass.show()

View File

@ -44,7 +44,7 @@ function HTTP.postJSON(url, data, callback)
if type(data) == "table" then if type(data) == "table" then
data = json.encode(data) data = json.encode(data)
end end
local operation = g_http.post(url, data, HTTP.timeout) local operation = g_http.post(url, data, HTTP.timeout, true)
HTTP.operations[operation] = {type="post", json=true, url=url, callback=callback} HTTP.operations[operation] = {type="post", json=true, url=url, callback=callback}
return operation return operation
end end
@ -122,6 +122,9 @@ function HTTP.onGet(operationId, url, err, data)
err = nil err = nil
end end
if not err and operation.json then if not err and operation.json then
if data:len() == 0 then
data = "null"
end
local status, result = pcall(function() return json.decode(data) end) local status, result = pcall(function() return json.decode(data) end)
if not status then if not status then
err = "JSON ERROR: " .. result err = "JSON ERROR: " .. result
@ -153,6 +156,9 @@ function HTTP.onPost(operationId, url, err, data)
err = nil err = nil
end end
if not err and operation.json then if not err and operation.json then
if data:len() == 0 then
data = "null"
end
local status, result = pcall(function() return json.decode(data) end) local status, result = pcall(function() return json.decode(data) end)
if not status then if not status then
err = "JSON ERROR: " .. result err = "JSON ERROR: " .. result
@ -221,6 +227,9 @@ function HTTP.onWsMessage(operationId, message)
end end
if operation.callbacks.onMessage then if operation.callbacks.onMessage then
if operation.json then if operation.json then
if message:len() == 0 then
message = "null"
end
local status, result = pcall(function() return json.decode(message) end) local status, result = pcall(function() return json.decode(message) end)
local err = nil local err = nil
if not status then if not status then

View File

@ -38,27 +38,38 @@ local oldTibia = g_game.getClientVersion() < 960
-- main loop, controlled by config -- main loop, controlled by config
targetbotMacro = macro(100, function() targetbotMacro = macro(100, function()
local pos = player:getPosition() local pos = player:getPosition()
local creatures = g_map.getSpectatorsInRange(pos, false, 6, 6) -- 12x12 area local specs = g_map.getSpectatorsInRange(pos, false, 6, 6) -- 12x12 area
if #creatures > 10 then -- if there are too many monsters around, limit area local creatures = 0
for i, spec in ipairs(specs) do
if spec:isMonster() then
creatures = creatures + 1
end
end
if creatures > 10 then -- if there are too many monsters around, limit area
creatures = g_map.getSpectatorsInRange(pos, false, 3, 3) -- 6x6 area creatures = g_map.getSpectatorsInRange(pos, false, 3, 3) -- 6x6 area
else
creatures = specs
end end
local highestPriority = 0 local highestPriority = 0
local dangerLevel = 0 local dangerLevel = 0
local targets = 0 local targets = 0
local highestPriorityParams = nil local highestPriorityParams = nil
for i, creature in ipairs(creatures) do for i, creature in ipairs(creatures) do
local path = findPath(player:getPosition(), creature:getPosition(), 7, {ignoreLastCreature=true, ignoreNonPathable=true, ignoreCost=true, ignoreCreatures=true}) local hppc = creature:getHealthPercent()
if creature:isMonster() and (oldTibia or creature:getType() < 3) and path then if hppc and hppc > 0 then
local params = TargetBot.Creature.calculateParams(creature, path) -- return {craeture, config, danger, priority} local path = findPath(player:getPosition(), creature:getPosition(), 7, {ignoreLastCreature=true, ignoreNonPathable=true, ignoreCost=true, ignoreCreatures=true})
dangerLevel = dangerLevel + params.danger if creature:isMonster() and (oldTibia or creature:getType() < 3) and path then
if params.priority > 0 then local params = TargetBot.Creature.calculateParams(creature, path) -- return {craeture, config, danger, priority}
targets = targets + 1 dangerLevel = dangerLevel + params.danger
if params.priority > highestPriority then if params.priority > 0 then
highestPriority = params.priority targets = targets + 1
highestPriorityParams = params if params.priority > highestPriority then
end highestPriority = params.priority
if ui.editor.debug:isOn() then highestPriorityParams = params
creature:setText(params.config.name .. "\n" .. params.priority) end
if ui.editor.debug:isOn() then
creature:setText(params.config.name .. "\n" .. params.priority)
end
end end
end end
end end

View File

@ -1036,6 +1036,14 @@ function getMonstersInArea(category, posOrCreature, pattern, minHp, maxHp, safeP
t = monsterNamesTable t = monsterNamesTable
end end
if safePattern then
for i, spec in pairs(getSpectators(posOrCreature, safePattern)) do
if spec ~= player and spec:isPlayer() then
return 0
end
end
end
if category == 1 or category == 3 or category == 4 then if category == 1 or category == 3 or category == 4 then
for i, spec in pairs(getSpectators()) do for i, spec in pairs(getSpectators()) do
local specHp = spec:getHealthPercent() local specHp = spec:getHealthPercent()
@ -1046,14 +1054,6 @@ function getMonstersInArea(category, posOrCreature, pattern, minHp, maxHp, safeP
return monsters return monsters
end end
if safePattern then
for i, spec in pairs(getSpectators(posOrCreature, safePattern)) do
if spec ~= player and spec:isPlayer() then
return 0
end
end
end
for i, spec in pairs(getSpectators(posOrCreature, pattern)) do for i, spec in pairs(getSpectators(posOrCreature, pattern)) do
if spec ~= player then if spec ~= player then
local specHp = spec:getHealthPercent() local specHp = spec:getHealthPercent()
@ -1075,7 +1075,7 @@ function getBestTileByPattern(pattern, minHp, maxHp, safePattern, monsterNamesTa
for i, tile in pairs(tiles) do for i, tile in pairs(tiles) do
local tPos = tile:getPosition() local tPos = tile:getPosition()
local distance = distanceFromPlayer(tPos) local distance = distanceFromPlayer(tPos)
if tile:canShoot() and tile:isWalkable() then if tile:canShoot() and tile:isWalkable() and (not safePattern or distance < 4) then
local amount = getMonstersInArea(2, tPos, pattern, minHp, maxHp, safePattern, monsterNamesTable) local amount = getMonstersInArea(2, tPos, pattern, minHp, maxHp, safePattern, monsterNamesTable)
if amount > targetTile.amount then if amount > targetTile.amount then
targetTile = {amount=amount,pos=tPos} targetTile = {amount=amount,pos=tPos}
@ -1184,15 +1184,15 @@ macro(100, function()
local pCat = entry.patternCategory local pCat = entry.patternCategory
local pattern = entry.pattern local pattern = entry.pattern
local anchorParam = (pattern == 2 or pattern == 6 or pattern == 7 or pattern > 9) and player or pos() local anchorParam = (pattern == 2 or pattern == 6 or pattern == 7 or pattern > 9) and player or pos()
local safe = currentSettings.pvpSafe and spellPatterns[pCat][entry.pattern][2] or false local safe = currentSettings.PvpSafe and spellPatterns[pCat][entry.pattern][2] or false
local monsterAmount = pCat ~= 8 and getMonstersInArea(entry.category, anchorParam, spellPatterns[pCat][entry.pattern][1], entry.minHp, entry.maxHp, safe, entry.monsters) local monsterAmount = pCat ~= 8 and getMonstersInArea(entry.category, anchorParam, spellPatterns[pCat][entry.pattern][1], entry.minHp, entry.maxHp, safe, entry.monsters)
if (pattern ~= 8 and (entry.orMore and monsterAmount >= entry.count or not entry.orMore and monsterAmount == entry.count)) or pattern == 8 and bestSide >= entry.count then if (pattern ~= 8 and (entry.orMore and monsterAmount >= entry.count or not entry.orMore and monsterAmount == entry.count)) or pattern == 8 and bestSide >= entry.count then
return executeAttackBotAction(entry.category, attackData, entry.cooldown) return executeAttackBotAction(entry.category, attackData, entry.cooldown)
end end
elseif entry.category == 2 then elseif entry.category == 2 then
local pCat = entry.patternCategory local pCat = entry.patternCategory
local safe = currentSettings.pvpSafe and spellPatterns[pCat][entry.pattern][2] or false local safe = currentSettings.PvpSafe and spellPatterns[pCat][entry.pattern][2] or false
local data = getBestTileByPattern(spellPatterns[pCat][entry.pattern][1], entry.minHp, entry.maxHp, spellPatterns[pCat][entry.pattern][2], entry.monsters) local data = getBestTileByPattern(spellPatterns[pCat][entry.pattern][1], entry.minHp, entry.maxHp, safe, entry.monsters)
local monsterAmount local monsterAmount
local pos local pos
if data then if data then

View File

@ -161,7 +161,7 @@ end)
-- mana -- mana
local lastMana = 0 local lastMana = 0
macro(100, function() macro(500, function()
if config.manaInfo then if config.manaInfo then
if manapercent() ~= lastMana then if manapercent() ~= lastMana then
lastMana = manapercent() lastMana = manapercent()

View File

@ -505,14 +505,17 @@ macro(100, function()
if config.forceOpen then if config.forceOpen then
local container = getContainerByItem(dId) local container = getContainerByItem(dId)
if not container then if not container then
if getBack() and getBack():getId() == dId then local t = {getBack(), getAmmo(), getFinger(), getNeck(), getLeft(), getRight()}
g_game.open(getBack()) for i=1,#t do
else local slot = t[i]
local cItem = findItem(dId) if slot and slot:getId() == dId then
if cItem then return g_game.open(slot)
return g_game.open(cItem)
end end
end end
local cItem = findItem(dId)
if cItem then
return g_game.open(cItem)
end
end end
end end
end end

View File

@ -109,9 +109,11 @@ if rootWidget then
widget:setOn(config.privateMessage) widget:setOn(config.privateMessage)
end end
local pName = player:getName()
onTextMessage(function(mode, text) onTextMessage(function(mode, text)
if config.enabled and config.playerAttack and mode == 16 and string.match(text, "hitpoints due to an attack") and not string.match(text, "hitpoints due to an attack by a ") then if config.enabled and config.playerAttack and mode == 16 and string.match(text, "hitpoints due to an attack") and not string.match(text, "hitpoints due to an attack by a ") then
playSound("/sounds/Player_Attack.ogg") playSound("/sounds/Player_Attack.ogg")
g_window.setTitle(pName .. " - Player Detected!")
end end
end) end)
@ -126,7 +128,7 @@ if rootWidget then
if math.max(math.abs(posx()-specPos.x), math.abs(posy()-specPos.y)) <= 8 then if math.max(math.abs(posx()-specPos.x), math.abs(posy()-specPos.y)) <= 8 then
playSound("/sounds/Player_Detected.ogg") playSound("/sounds/Player_Detected.ogg")
delay(1500) delay(1500)
g_window.setTitle(name() .. " - Player Detected!") g_window.setTitle(pName .. " - Player Detected!")
if config.playerDetectedLogout then if config.playerDetectedLogout then
modules.game_interface.tryLogout(false) modules.game_interface.tryLogout(false)
end end
@ -143,7 +145,7 @@ if rootWidget then
if math.max(math.abs(posx()-specPos.x), math.abs(posy()-specPos.y)) <= 8 then if math.max(math.abs(posx()-specPos.x), math.abs(posy()-specPos.y)) <= 8 then
playSound("/sounds/Creature_Detected.ogg") playSound("/sounds/Creature_Detected.ogg")
delay(1500) delay(1500)
g_window.setTitle(name() .. " - Creature Detected! ") g_window.setTitle(pName .. " - Creature Detected! ")
return return
end end
end end
@ -153,7 +155,7 @@ if rootWidget then
if config.healthBelow then if config.healthBelow then
if hppercent() <= config.healthValue then if hppercent() <= config.healthValue then
playSound("/sounds/Low_Health.ogg") playSound("/sounds/Low_Health.ogg")
g_window.setTitle(name() .. " - Low Health!") g_window.setTitle(pName .. " - Low Health!")
delay(1500) delay(1500)
return return
end end
@ -162,7 +164,7 @@ if rootWidget then
if config.manaBelow then if config.manaBelow then
if manapercent() <= config.manaValue then if manapercent() <= config.manaValue then
playSound("/sounds/Low_Mana.ogg") playSound("/sounds/Low_Mana.ogg")
g_window.setTitle(name() .. " - Low Mana!") g_window.setTitle(pName .. " - Low Mana!")
delay(1500) delay(1500)
return return
end end
@ -172,7 +174,7 @@ if rootWidget then
onTalk(function(name, level, mode, text, channelId, pos) onTalk(function(name, level, mode, text, channelId, pos)
if mode == 4 and config.enabled and config.privateMessage then if mode == 4 and config.enabled and config.privateMessage then
playSound("/sounds/Private_Message.ogg") playSound("/sounds/Private_Message.ogg")
g_window.setTitle(name() .. " - Private Message") g_window.setTitle(pName .. " - Private Message")
return return
end end
end) end)

View File

@ -113,7 +113,7 @@ if true then
vocText = "- ED" vocText = "- ED"
end end
macro(2000, function() macro(5000, function()
if settings.title then if settings.title then
if hppercent() > 0 then if hppercent() > 0 then
g_window.setTitle("Tibia - " .. name() .. " - " .. lvl() .. "lvl " .. vocText) g_window.setTitle("Tibia - " .. name() .. " - " .. lvl() .. "lvl " .. vocText)

View File

@ -1,3 +1,3 @@
UI.Label("vBot v3.4 \n Vithrax#5814") UI.Label("vBot v3.45 \n Vithrax#5814")
UI.Button("Official OTCv8 Discord!", function() g_platform.openUrl("https://discord.gg/yhqBE4A") end) UI.Button("Official OTCv8 Discord!", function() g_platform.openUrl("https://discord.gg/yhqBE4A") end)
UI.Separator() UI.Separator()

View File

@ -15,9 +15,9 @@ function load()
local datPath, sprPath local datPath, sprPath
if things and things["data"] ~= nil and things["sprites"] ~= nil then if things and things["data"] ~= nil and things["sprites"] ~= nil then
datPath = '/things/' .. things["data"] datPath = resolvepath('/things/' .. things["data"])
sprPath = '/things/' .. things["sprites"] sprPath = resolvepath('/things/' .. things["sprites"])
else else
if filename then if filename then
datPath = resolvepath('/things/' .. filename) datPath = resolvepath('/things/' .. filename)
sprPath = resolvepath('/things/' .. filename) sprPath = resolvepath('/things/' .. filename)
@ -38,7 +38,7 @@ function load()
errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n' errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n'
end end
end end
if not g_sprites.loadSpr(sprPath, false) then if not g_sprites.loadSpr(sprPath) then
errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath) errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)
end end

View File

@ -208,6 +208,7 @@ GameBigAurasCenter = 119 -- Automatic negative offset for aura bigger than 32x32
GameNewUpdateWalk = 120 -- Walk update rate dependant on FPS GameNewUpdateWalk = 120 -- Walk update rate dependant on FPS
GameNewCreatureStacking = 121 -- Ignore MAX_THINGS limit while adding to tile GameNewCreatureStacking = 121 -- Ignore MAX_THINGS limit while adding to tile
GameCreaturesMana = 122 -- get mana from server for creatures other than Player GameCreaturesMana = 122 -- get mana from server for creatures other than Player
GameQuickLootFlags = 123 -- enables quick loot feature for all protocols
LastGameFeature = 130 LastGameFeature = 130

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.