• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Close Theard Solved!

Status
Not open for further replies.

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,780
Solutions
31
Reaction score
2,299
Location
Sweden?
Close Theard Solved!
 
Last edited:
LUA:
function onCastSpell(cid, var)
    doTeleportThing(cid,getClosestFreeTile(cid, getCreaturePosition(getCreatureTarget(cid))))
    return true
end
 
Scarlet got a problem, now they can get stuck into a wall, stone or other items :/
 
Its just happend if there is 8 sqm around the monster and 1 sqm is blocked with the wall, it will not go just around the 7 left, it will still go around the 8 sqm but i can get into a wall.

@War
I tested your backstabb the walkable but i get this error :/
LUA:
[15/06/2012 17:15:20] [Error - Spell Interface] 
[15/06/2012 17:15:20] data/spells/scripts/players/swift lux.lua:onCastSpell
[15/06/2012 17:15:20] Description: 
[15/06/2012 17:15:20] data/spells/scripts/players/swift lux.lua:28: attempt to index local 'aux' (a nil value)
[15/06/2012 17:15:20] stack traceback:
[15/06/2012 17:15:20] 	data/spells/scripts/players/swift lux.lua:28: in function <data/spells/scripts/players/swift lux.lua:8>
 
Last edited:
that's odd

anyway, I'll just make you one, you just need to find a isWalkable function

LUA:
function onCastSpell(cid, var)
    local pos = getCreaturePosition(getCreatureTarget(cid))
    for x = -1, 1, 1 do
        for y = -1, 1, 1 do
            local pos2 = pos
            pos2.x = pos2.x + x
            pos2.y = pos2.y + y
            if isWalkable(pos2) then
                doTeleportThing(cid, pos2)
                return true
            end
        end
    end
    doTeleportThing(cid, pos)
    return true
end
like this, it'll try to find a free spot around the target position, if it can't then it'll just teleport to the exact position, this is to prevent random bugs incase a target is completely surrounded by unwalkable stuff


Edit:
try this one, it might work, but i made it a long long time ago(2009)
LUA:
function isWalkable(cid,pos)
    pos.stackpos = 253
    if doTileQueryAdd(cid, pos) == 1 and getTilePzInfo(pos) == FALSE and isCreature(getThingFromPos(pos).uid) == FALSE then
        return TRUE
    end
    return FALSE
end
 
It's very easy...

Use scarlet ayleids function that is edited by cykotitan:
LUA:
function isWalkable(cid, pos)
	pos.stackpos = 0
	if getTileThingByPos(pos).uid ~= 0 then
		local n = getTileInfo(pos)
		if n.protection == false and n.house == false and getTopCreature(pos).uid == 0 and doTileQueryAdd(cid, pos) == RETURNVALUE_NOERROR then
			return true
		end
	end
end

and here is the spell....

LUA:
function onCastSpell(cid, var)
	local target = getCreatureTarget(cid)
	local pos = getCreaturePosition(target)
	local closest = getClosestFreeTile(cid, pos, false, false)
	if(isPlayer(cid)) then
		if(isWalkable(cid, closest)) then
			doTeleportThing(cid, closest, true)
			doSendMagicEffect(closest, CONST_ME_TELEPORT)
		else
			doPlayerSendCancel(cid, "There is no space to teleport to your target.")
			return false
		end
	end
	return true
end

All credits to me (for the spell)... Rep plx :)
 
Last edited:
War its working like a charm :)

Rep!!

But one thing. Ex. if there is 8 sqm around the monster and 2sqm is blocked with stones or other things, i still get this "There is no space to teleport to your target", this should come when all sqm around it is blocked not just 2sqm :(

If you can fix it i will be happy :)

Still the script is nice i will rep you for it :)
 
Last edited:
Status
Not open for further replies.
Back
Top