Smarter skull targeting
#12
This will target creatures with a black skull first, then other skulls and then lowest health found.
macro(100, "Smarter skull targeting", function()
if isInPz() then return end
local skulls_array = { 1,2, 3, 4, 5, 6 }
local skull_black = 5
local skull_found = false
local distance = 6
local lowest_health = 101
local tNpc = nil
for _, spec in pairs(getSpectators()) do
if spec:isMonster() then
if getDistanceBetween(player:getPosition(), spec:getPosition()) <= distance then
local pSkull = spec:getSkull()
if table.find(skulls_array, pSkull) then
tNpc = spec
skull_found = true
if pSkull == skull_black then
break
end
else
if spec:getHealthPercent() < lowest_health and not skull_found then
lowest_health = spec:getHealthPercent()
tNpc = spec
end
end
end
end
end
if tNpc and tNpc:isMonster() then
if getDistanceBetween(player:getPosition(), tNpc:getPosition()) <= distance then
if (g_game.getAttackingCreature() ~= tNpc) then
if skull_found or tNpc:getHealthPercent() <= lowest_health then
g_game.attack(tNpc)
end
end
end
end
end)
- remove | + add
01 Jan 2020