mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-20 14:43:27 +02:00
Updated to OTCv8 3.1 rev 105
This commit is contained in:
@@ -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
|
@@ -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
|
@@ -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()
|
@@ -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
|
@@ -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)
|
@@ -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)
|
@@ -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()
|
Reference in New Issue
Block a user