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?
Spell para TFS 1x, Teleporta Tile
Por julhinhuu, 03 de fev. de 2016 em Scripts
info
Grupo: Herói
Registrado: 14/02/14
Posts: 341
Reputação: +285
Gênero: Masculino
Char no Tibia: Night Wolf

info
Grupo: Visconde
Registrado: 28/06/11
Posts: 356
Reputação: +26
Char no Tibia: Akor Rysea

Mds, me perdi hahaha, mais tipo assim... ele teleporta 3 sqms de uma só vez.. se tiver espaço de 2 ele vai da sorry not possible. Então é isso, a sim e ele não atravessará paredes igual gms.
info
Grupo: Visconde
Registrado: 28/06/11
Posts: 356
Reputação: +26
Char no Tibia: Akor Rysea

Up
info
Grupo: Herói
Registrado: 14/02/14
Posts: 341
Reputação: +285
Gênero: Masculino
Char no Tibia: Night Wolf

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...
info
Grupo: Visconde
Registrado: 28/06/11
Posts: 356
Reputação: +26
Char no Tibia: Akor Rysea

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.
info
Grupo: Herói
Registrado: 14/02/14
Posts: 341
Reputação: +285
Gênero: Masculino
Char no Tibia: Night Wolf

troca essa linha aqui:
nextPosition = nextPosition:getNextPosition(cid:getDirection())
por
nextPosition:getNextPosition(cid:getDirection())
Testa numa area aberta
info
Grupo: Visconde
Registrado: 28/06/11
Posts: 356
Reputação: +26
Char no Tibia: Akor Rysea

info
Grupo: Herói
Registrado: 14/02/14
Posts: 341
Reputação: +285
Gênero: Masculino
Char no Tibia: Night Wolf

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
info
Grupo: Visconde
Registrado: 28/06/11
Posts: 356
Reputação: +26
Char no Tibia: Akor Rysea

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:
info
Grupo: Herói
Registrado: 14/02/14
Posts: 341
Reputação: +285
Gênero: Masculino
Char no Tibia: Night Wolf

eita, n era pra dar esse erro... tenta assim:
no lugar de Position.isWalkable
usa Position:isWalkable
info
Grupo: Visconde
Registrado: 28/06/11
Posts: 356
Reputação: +26
Char no Tibia: Akor Rysea

eita, n era pra dar esse erro... tenta assim:
no lugar de Position.isWalkable
usa Position:isWalkable
Ja havia tentado, esta dando erro no ':'
info
Grupo: Herói
Registrado: 14/02/14
Posts: 341
Reputação: +285
Gênero: Masculino
Char no Tibia: Night Wolf

é 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
info
Grupo: Visconde
Registrado: 28/06/11
Posts: 356
Reputação: +26
Char no Tibia: Akor Rysea

é 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 ^^
info
Grupo: Herói
Registrado: 14/02/14
Posts: 341
Reputação: +285
Gênero: Masculino
Char no Tibia: Night Wolf

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


info
Grupo: Visconde
Registrado: 28/06/11
Posts: 356
Reputação: +26
Char no Tibia: Akor Rysea
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. :*