Hello, I have a script to attack mobs and attack them with autoattacks, how can I add to this script so that it also attacks with a spell called "dark illusion"?
local distance = 12
macro(100, "EASYSTONE", function()
if isInPz() then return end
if g_game.isAttacking() then return end
local highestAmount = 100
local mob
for i, val in pairs(getSpectators()) do
if val:isMonster() and val:canShoot() then
if getDistanceBetween(player:getPosition(), val:getPosition()) <= distance then
local valHp = val:getHealthPercent()
if valHp <= highestAmount then
highestAmount = valHp
mob = val
end
end
end
end
if mob then
g_game.attack(mob)
end
end)
local distance = 12
macro(100, "EASYSTONE", function()
if isInPz() then return end
if g_game.isAttacking() then return end
local highestAmount = 100
local mob
for i, val in pairs(getSpectators()) do
if val:isMonster() and val:canShoot() then
if getDistanceBetween(player:getPosition(), val:getPosition()) <= distance then
local valHp = val:getHealthPercent()
if valHp <= highestAmount then
highestAmount = valHp
mob = val
end
end
end
end
if mob then
g_game.attack(mob)
end
end)