0% found this document useful (0 votes)
33 views4 pages

Message

This document contains Lua code for Tibia macros and functions. It defines macros for area of effect spells, intelligent targeting of monsters, automatically following a player or creature, and displaying monster health percentages. It also includes code for exiting auto tasks and cleaning map text.

Uploaded by

zoekingtv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views4 pages

Message

This document contains Lua code for Tibia macros and functions. It defines macros for area of effect spells, intelligent targeting of monsters, automatically following a player or creature, and displaying monster health percentages. It also includes code for exiting auto tasks and cleaning map text.

Uploaded by

zoekingtv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

macro(500, "AOE Spell", function()

local monsters = 0
for i, mob in ipairs(getSpectators(posz())) do
if mob:isMonster() and getDistanceBetween(player:getPosition(),
mob:getPosition()) <=3 then -- verificar monstros num raio de 10 sqm
monsters = monsters + 1
end
end
if monsters >= 1 then -- quantidade de monstros
saySpell('self destruction', 200) -- magia a ser alterada
end
end)
-------------
macro(100, "Target Inteligente", function()
local battlelist = getSpectators();
local closest = 10
local highesthpc = 1
for key, val in pairs(battlelist) do
if val:isMonster() then
if getDistanceBetween(player:getPosition(), val:getPosition()) <= closest
then
closest = getDistanceBetween(player:getPosition(), val:getPosition())
if val:getHealthPercent() > highesthpc then
highesthpc = val:getHealthPercent()
end
end
end
end
for key, val in pairs(battlelist) do
if val:isMonster() then
if getDistanceBetween(player:getPosition(), val:getPosition()) <= closest
then
if g_game.getAttackingCreature() ~= val and val:getHealthPercent() >=
highesthpc then
g_game.attack(val)
break
end
end
end
end
end)

onTalk(function(name, level, mode, text, channelId, pos)


if mode ~= 44 then return end
deltext = now + 1
end)

macro(1, 'BorrarMsg', function()


if deltext and deltext >= now then return end
g_map.cleanTexts()
end)

macro(250, "Atacar Seguindo", "Shift+R", function()


if g_game.isOnline() and g_game.isAttacking() then
g_game.setChaseMode(1)
end
end)
followName = "autofollow"
if not storage[followName] then storage[followName] = { player = 'name'} end
local toFollowPos = {}

UI.Separator()
UI.Label("Auto Follow")

followTE = UI.TextEdit(storage[followName].player or "name", function(widget,


newText)
storage[followName].player = newText
end)

local followChange = macro(200, "Follow Change", function() end)

local followMacro = macro(20, "Follow", function()


local target = getCreatureByName(storage[followName].player)
if target then
local tpos = target:getPosition()
toFollowPos[tpos.z] = tpos
end
if player:isWalking() then
return
end
local p = toFollowPos[posz()]
if not p then
return
end
if autoWalk(p, 20, { ignoreNonPathable = true, precision = 1 }) then
delay(100)
end
end)
UI.Separator()
onPlayerPositionChange(function(newPos, oldPos)
if followChange:isOff() then return end
if (g_game.isFollowing()) then
tfollow = g_game.getFollowingCreature()

if tfollow then
if tfollow:getName() ~= storage[followName].player then
followTE:setText(tfollow:getName())
storage[followName].player = tfollow:getName()
end
end
end
end)

onCreaturePositionChange(function(creature, newPos, oldPos)


if creature:getName() == storage[followName].player and newPos then
toFollowPos[newPos.z] = newPos
end
end)
local exit = macro(500, "Exit Auto Task", function()
end)

onTextMessage(function(mode, text)
if exit.isOff() then return end
if not text:find("You have finished the Future Saiyans task") then return end
CaveBot.gotoLabel("exit")
delay(500)
return true
end)
local showhp = macro(20000, "Monster HP %", function() end)
onCreatureHealthPercentChange(function(creature, healthPercent)
if showhp:isOff() then return end
if creature:isMonster() or creature:isPlayer() and creature:getPosition() and
pos() then
if getDistanceBetween(pos(), creature:getPosition()) <= 5 then
creature:setText(healthPercent .. "%")
else
creature:clearText()
end
end
end)
addLabel("Label", "Follow Name")
addTextEdit("TxtEdit", storage.fName or "name", function(widget, text)
storage.fName = text
end)
--------------------------
local lastPos = nil
macro(200, "Follow", function()
local leader = getCreatureByName(storage.fName)
local target = g_game.getAttackingCreature()
if leader then
if target and lastPos then
return player:autoWalk(lastPos)
end
if not g_game.getFollowingCreature() then
return g_game.follow(leader)
end
elseif lastPos then
player:autoWalk(lastPos)
end
end)

onCreaturePositionChange(function(creature, newPos, oldPos)


local leader = getCreatureByName(storage.fName)
if leader ~= creature or not newPos then return end
lastPos = newPos
end)
----------------------
macro(100, "Smarter targeting", function()
local battlelist = getSpectators();
local closest = 10
local lowesthpc = 101
for key, val in pairs(battlelist) do
if val:isMonster() then
if getDistanceBetween(player:getPosition(), val:getPosition()) <= closest
then
closest = getDistanceBetween(player:getPosition(), val:getPosition())
if val:getHealthPercent() < lowesthpc then
lowesthpc = val:getHealthPercent()
end
end
end
end
for key, val in pairs(battlelist) do
if val:isMonster() then
if getDistanceBetween(player:getPosition(), val:getPosition()) <= closest
then
if g_game.getAttackingCreature() ~= val and val:getHealthPercent() <=
lowesthpc then
g_game.attack(val)
break
end
end
end
end
end)
-------------------

You might also like