Ir para conteúdo
  • 0

Spell para TFS 1x, Teleporta Tile


julhinhuu

Pergunta

Olá galera do xt;

Gostaria de pedir a vocês uma spell que quando player a usar ele sera teleportado 3 sqms na direção que ele está, porém ele não poderá atravessar paredes, rios e etc.

 

Agradeço desde já... estarei tentando fazer também, mais comecei agora com tfs 1x.

 

Abraços e me ajudem por favor. :*

Link para o comentário
Compartilhar em outros sites

Posts Recomendados

  • 0
local times = 3       --Quantos SQMs o jogador irá se mover.
 
function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 2 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end
 
function onCastSpell(cid)
    local playerPos = getThingPos(cid)
	for i = 1, times do
		playerPos:getNextPosition(getCreatureLookDirection(cid))    
		if not isWalkable(playerPos, i == times, i == times, i == times) then
			doPlayerSendCancel(cid, "Sorry, destination not possible.")
			return false
		end
    end
	doTeleportThing(cid, playerPos)
    return true
end

 

Link para o comentário
Compartilhar em outros sites

  • 0

Vamos pras seguintes situações.

p = player
x = sqm
z = obstáculo.

pxxz (antes da spell)
Ao castar ele ficaria
xxpz (anda só 2 sqm) OU pxxz (não casta e diz que tem obstaculo?)

No caso de pxzx ele não atravessaria mas no caso de pzxx ele atravessa?

Link para o comentário
Compartilhar em outros sites

  • 0

tenta assim..

 

local function isWalkable(position, pz)
    local tile = Tile(position)
    if not tile then
        return false
    end
	
	if pz and Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then
		return false
	end
	
    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, #items do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end
	
function onCastSpell(cid, var)
	local nextPosition = cid:getPosition()
	for i = 1, 3 do
		nextPosition = nextPosition:getNextPosition(cid:getDirection())
		if not isWalkable(nextPosition, i == 3) then
			cid:sendCancelMessage("Sorry not possible.")
		return false
		end
	end
    self:teleportTo(nextPosition, true)
return true
end

 


se não for tenta assim

 

local function isWalkable(position, pz)
    local tile = Tile(position)
    if not tile then
        return false
    end
	
	if pz and Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then
		return false
	end
	
    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, #items do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end
	
function onCastSpell(player, var)
	cid = Player(player)
	local nextPosition = cid:getPosition()
	for i = 1, 3 do
		nextPosition = nextPosition:getNextPosition(cid:getDirection())
		if not isWalkable(nextPosition, i == 3) then
			cid:sendCancelMessage("Sorry not possible.")
		return false
		end
	end
    self:teleportTo(nextPosition, true)
return true
end

 



Se algum dos dois funcionar me diz qual que foi...

Link para o comentário
Compartilhar em outros sites

  • 0

tenta assim..

 

 

local function isWalkable(position, pz)
    local tile = Tile(position)
    if not tile then
        return false
    end
	
	if pz and Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then
		return false
	end
	
    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, #items do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end
	
function onCastSpell(cid, var)
	local nextPosition = cid:getPosition()
	for i = 1, 3 do
		nextPosition = nextPosition:getNextPosition(cid:getDirection())
		if not isWalkable(nextPosition, i == 3) then
			cid:sendCancelMessage("Sorry not possible.")
		return false
		end
	end
    self:teleportTo(nextPosition, true)
return true
end

 

 

se não for tenta assim

 

 

local function isWalkable(position, pz)
    local tile = Tile(position)
    if not tile then
        return false
    end
	
	if pz and Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then
		return false
	end
	
    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, #items do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end
	
function onCastSpell(player, var)
	cid = Player(player)
	local nextPosition = cid:getPosition()
	for i = 1, 3 do
		nextPosition = nextPosition:getNextPosition(cid:getDirection())
		if not isWalkable(nextPosition, i == 3) then
			cid:sendCancelMessage("Sorry not possible.")
		return false
		end
	end
    self:teleportTo(nextPosition, true)
return true
end

 

 

 

Se algum dos dois funcionar me diz qual que foi...

 

Não da nenhum erro nos dois, so aparece 'Sorry not possible' e não teleporta de forma alguma.

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

tenta assim:

local function Position.isWalkable(position, playerBlock, pz)
    local tile = Tile(position)
    if not tile then return false end
    if playerBlock and tile:getCreatureCount() ~= 0 then return false end	
	if pz and Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then return false end	
    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then return false end
    local items = tile:getItems()
    for i = 1, tile:getItemCount() do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end
	
function onCastSpell(creature, var, isHotkey)
	local nextPosition = creature:getPosition()
	for i = 1, 3 do
		nextPosition:getNextPosition(creature:getDirection())
		if not nextPosition:isWalkable(i == 3, i == 3) then
			creature:sendCancelMessage("Sorry not possible.")
		return false
		end
	end
    creature:teleportTo(nextPosition, true)
return true
end
Link para o comentário
Compartilhar em outros sites

  • 0

 

tenta assim:

 

local function Position.isWalkable(position, playerBlock, pz)
    local tile = Tile(position)
    if not tile then return false end
    if playerBlock and tile:getCreatureCount() ~= 0 then return false end	
	if pz and Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then return false end	
    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then return false end
    local items = tile:getItems()
    for i = 1, tile:getItemCount() do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end
	
function onCastSpell(creature, var, isHotkey)
	local nextPosition = creature:getPosition()
	for i = 1, 3 do
		nextPosition:getNextPosition(creature:getDirection())
		if not nextPosition:isWalkable(i == 3, i == 3) then
			creature:sendCancelMessage("Sorry not possible.")
		return false
		end
	end
    creature:teleportTo(nextPosition, true)
return true
end

 

ta dando esse erro e não teleporta:

post-321783-0-64971700-1455111207_thumb.png

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

é com . mesmo, engraçado estar dando erro :// remove a linha e reescreve ela manualmente (sem ctrl + v).. as vezes pode ser erro pelo editor, tá no notepad++? se tiver clica em formatar -> converter para ansii

 

Então ja fiz, não estava usando o Notepad mais coloquei lá também e nada, tenho um script aqui que funciona so que ele atravessa parede

Segue ai:

 

 

local times = 3       --Quantos SQMs o jogador irá se mover.
 
function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 2 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end
 
function onCastSpell(cid)
    local playerPos = getThingPos(cid)
    local toPos = {
        [0] = {x = playerPos.x, y = playerPos.y - times, z = playerPos.z},
        [1] = {x = playerPos.x + times, y = playerPos.y, z = playerPos.z},
        [2] = {x = playerPos.x, y = playerPos.y + times, z = playerPos.z},
        [3] = {x = playerPos.x - times, y = playerPos.y, z = playerPos.z}
    }
    
    local spellToPos = toPos[getCreatureLookDirection(cid)]
    if isWalkable(spellToPos) then
        doTeleportThing(cid, spellToPos)
    else
        doPlayerSendCancel(cid, "Sorry, destination not possible.")
    end
    return true
end

 

 

ver se esse ajudar em alguma coisas ^^

 

Link para o comentário
Compartilhar em outros sites

  • 0
local times = 3       --Quantos SQMs o jogador irá se mover.
 
function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 2 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end
 
function onCastSpell(cid)
    local playerPos = getThingPos(cid)
	for i = 1, times do
		playerPos = getPosByDir(playerPos, getCreatureLookDirection(cid))    
		if not isWalkable(playerPos, i == times, i == times, i == times) then
			doPlayerSendCancel(cid, "Sorry, destination not possible.")
			return false
		end
    end
	doTeleportThing(cid, playerPos)
    return true
end

vê assim

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...