I was redoing an old script for version 1.3, but if I log off the char, it crashes the server.
Lua:
function getPosDirs(p, dir)
return dir == 1 and {x=p.x-1, y=p.y, z=p.z} or dir == 2 and {x=p.x-1, y=p.y+1, z=p.z} or dir == 3 and {x=p.x, y=p.y+1, z=p.z} or dir == 4 and {x=p.x+1, y=p.y+1, z=p.z} or dir == 5 and {x=p.x+1, y=p.y, z=p.z} or dir == 6 and {x=p.x+1, y=p.y-1, z=p.z} or dir == 7 and {x=p.x, y=p.y-1, z=p.z} or dir == 8 and {x=p.x-1, y=p.y-1, z=p.z}
end
function posIgual(pos1, pos2)
return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z and true or false
end
effect = 10
distance = CONST_ANI_SUDDENDEATH
damage = COMBAT_DEATHDAMAGE
function evilspiritwalk(creature, danomin, danomax, pos, rounds, ultimapos)
if rounds == 0 then
return true
end
if not isCreature(creature) then
return true
end
posdisp = {}
for _, dir in pairs({1, 5, 7, 3}) do
local tile
tile = Tile(Position(getPosDirs(pos, dir)))
if tile:isWalkable() and not posIgual(getPosDirs(pos, dir), getThingPos(creature)) and not posIgual(getPosDirs(pos, dir), ultimapos) then
table.insert(posdisp, getPosDirs(pos, dir))
end
end
if #posdisp < 1 then
return true
end
posesc = posdisp[math.random(1, #posdisp)]
ultimapos = pos
doSendDistanceShoot(pos, posesc, distance)
doAreaCombatHealth(creature, damage, posesc, 0, -1000, -2000, effect)
addEvent(function()
evilspiritwalk(creature, danomin, danomax, posesc, rounds - 1, ultimapos)
end, 140)
end
function onCastSpell(creature, var)
evilspiritwalk(creature, 10, 20, getThingPos(creature), 20, {x=1, y=1, z=1})
return true
end