Description:
Turns away from the spot taken by other player.
Code:
init start
local minHppc = 100 -- Minimum monster hppc
-- DO NOT EDIT ANYTHING BELOW --
local Positioning = {
{Dir = 's', x = 0, y = 1},
{Dir = 'n', x = 0, y = -1},
{Dir = 'w', x = -1, y = 0},
{Dir = 'e', x = 1, y = 0},
}
init end
auto(100, 200)
if $attacked.id > 0 and $attacked.hppc <= minHppc then
for _, v in ipairs(Positioning) do
if v.Dir == $self.dir then
if iscreatureontile($posx+v.x, $posy+v.y, $posz, "player") then
local tempSelfDir = $self.dir
local freeDirs = {}
for i, j in ipairs(Positioning) do
if j.Dir ~= tempSelfDir and not iscreatureontile($posx + j.x, $posy+j.y, $posz, "player") then
table.insert(freeDirs, j.Dir)
end
end
if #freeDirs > 0 then
turn(freeDirs[math.random(1, #freeDirs)])
else
ignorecreature($attacked.id)
end
end
break
end
end
end
-- Stop attack ignored creature
if $attacked.ignored then
keyevent(0x1B)
waitping()
end
-- Let's unignore these creatures that are ignored atm
-- if no players around
if paround(10) == 0 and $timems - $playerlastseen > 6000 then
foreach creature m "mf" do
if m.ignored then
ignorecreature(m.id, true)
end
end
end