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 enterGame
local enterGameButton
local logpass
local clientBox
local protocolLogin
local server = nil
@ -106,9 +107,8 @@ local function validateThings(things)
g_settings.setNode("things", {})
end
if missingFiles then
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."
end
return incorrectThings
@ -134,10 +134,18 @@ local function onTibia12HTTPResult(session, playdata)
local things = {
data = {G.clientVersion .. "/Tibia.dat", ""},
sprites = {G.clientVersion .. "/Tibia.spr", ""},
sprites = {G.clientVersion .. "/Tibia.cwm", ""},
}
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
g_logger.error(incorrectThings)
if Updater and not checkedByUpdater[G.clientVersion] then
@ -290,6 +298,9 @@ end
function EnterGame.init()
if USE_NEW_ENERGAME then return end
enterGame = g_ui.displayUI('entergame')
if LOGPASS ~= nil then
logpass = g_ui.loadUI('logpass', enterGame:getParent())
end
serverSelectorPanel = enterGame:getChildById('serverSelectorPanel')
customServerSelectorPanel = enterGame:getChildById('customServerSelectorPanel')
@ -351,6 +362,11 @@ end
function EnterGame.terminate()
if not enterGame then return end
g_keyboard.unbindKeyDown('Ctrl+G')
if logpass then
logpass:destroy()
logpass = nil
end
enterGame:destroy()
if loadBox then
@ -370,11 +386,22 @@ function EnterGame.show()
enterGame:raise()
enterGame:focus()
enterGame:getChildById('accountNameTextEdit'):focus()
if logpass then
logpass:show()
logpass:raise()
logpass:focus()
end
end
function EnterGame.hide()
if not enterGame then return end
enterGame:hide()
if logpass then
logpass:hide()
if modules.logpass then
modules.logpass:hide()
end
end
end
function EnterGame.openWindow()
@ -415,19 +442,19 @@ function EnterGame.onServerChange()
end
end
function EnterGame.doLogin()
function EnterGame.doLogin(account, password, token, host)
if g_game.isOnline() then
local errorBox = displayErrorBox(tr('Login Error'), tr('Cannot login while already in game.'))
connect(errorBox, { onOk = EnterGame.show })
return
end
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
G.authenticatorToken = enterGame:getChildById('accountTokenTextEdit'):getText()
G.account = account or enterGame:getChildById('accountNameTextEdit'):getText()
G.password = password or enterGame:getChildById('accountPasswordTextEdit'):getText()
G.authenticatorToken = token or enterGame:getChildById('accountTokenTextEdit'):getText()
G.stayLogged = true
G.server = serverSelector:getText():trim()
G.host = serverHostTextEdit:getText()
G.host = host or serverHostTextEdit:getText()
G.clientVersion = tonumber(clientVersionSelector:getText())
if not rememberPasswordBox:isChecked() then
@ -467,10 +494,17 @@ function EnterGame.doLogin()
local things = {
data = {G.clientVersion .. "/Tibia.dat", ""},
sprites = {G.clientVersion .. "/Tibia.spr", ""},
sprites = {G.clientVersion .. "/Tibia.cwm", ""},
}
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
g_logger.error(incorrectThings)
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
data = json.encode(data)
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}
return operation
end
@ -122,6 +122,9 @@ function HTTP.onGet(operationId, url, err, data)
err = nil
end
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)
if not status then
err = "JSON ERROR: " .. result
@ -153,6 +156,9 @@ function HTTP.onPost(operationId, url, err, data)
err = nil
end
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)
if not status then
err = "JSON ERROR: " .. result
@ -221,6 +227,9 @@ function HTTP.onWsMessage(operationId, message)
end
if operation.callbacks.onMessage then
if operation.json then
if message:len() == 0 then
message = "null"
end
local status, result = pcall(function() return json.decode(message) end)
local err = nil
if not status then

View File

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

View File

@ -1036,6 +1036,14 @@ function getMonstersInArea(category, posOrCreature, pattern, minHp, maxHp, safeP
t = monsterNamesTable
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
for i, spec in pairs(getSpectators()) do
local specHp = spec:getHealthPercent()
@ -1046,14 +1054,6 @@ function getMonstersInArea(category, posOrCreature, pattern, minHp, maxHp, safeP
return monsters
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
if spec ~= player then
local specHp = spec:getHealthPercent()
@ -1075,7 +1075,7 @@ function getBestTileByPattern(pattern, minHp, maxHp, safePattern, monsterNamesTa
for i, tile in pairs(tiles) do
local tPos = tile:getPosition()
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)
if amount > targetTile.amount then
targetTile = {amount=amount,pos=tPos}
@ -1184,15 +1184,15 @@ macro(100, function()
local pCat = entry.patternCategory
local pattern = entry.pattern
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)
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)
end
elseif entry.category == 2 then
local pCat = entry.patternCategory
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 safe = currentSettings.PvpSafe and spellPatterns[pCat][entry.pattern][2] or false
local data = getBestTileByPattern(spellPatterns[pCat][entry.pattern][1], entry.minHp, entry.maxHp, safe, entry.monsters)
local monsterAmount
local pos
if data then

View File

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

View File

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

View File

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

View File

@ -113,7 +113,7 @@ if true then
vocText = "- ED"
end
macro(2000, function()
macro(5000, function()
if settings.title then
if hppercent() > 0 then
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.Separator()

View File

@ -15,9 +15,9 @@ function load()
local datPath, sprPath
if things and things["data"] ~= nil and things["sprites"] ~= nil then
datPath = '/things/' .. things["data"]
sprPath = '/things/' .. things["sprites"]
else
datPath = resolvepath('/things/' .. things["data"])
sprPath = resolvepath('/things/' .. things["sprites"])
else
if filename then
datPath = 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'
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)
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
GameNewCreatureStacking = 121 -- Ignore MAX_THINGS limit while adding to tile
GameCreaturesMana = 122 -- get mana from server for creatures other than Player
GameQuickLootFlags = 123 -- enables quick loot feature for all protocols
LastGameFeature = 130

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.