Attack nearest creature until dead:
function getNearestCreature()
local nearestCreatureID = 0
local nearestCreatureDist = 10
foreach creature m 'ms' do
if m.dist < nearestCreatureDist then
nearestCreatureID = m.id
nearestCreatureDist = m.dist
end
end
return nearestCreatureID
end
auto(1000)
if $target == 0 then
attack(getNearestCreature())
end
Attack nearest creature until a nearer one comes along:
function getNearestCreature() local nearestCreatureID = 0
local nearestCreatureDist = 10
foreach creature m 'ms' do
if m.dist < nearestCreatureDist then
nearestCreatureID = m.id
nearestCreatureDist = m.dist
end
end
return nearestCreatureID
end
auto(1000)
if $target.id ~= getcreature(getNearestCreature()).id then
attack(getNearestCreature())
end
Didn't test it, but it looks about right.
@ratrider