Vasto Lord X 1 Postado Janeiro 31, 2016 Share Postado Janeiro 31, 2016 Eu Queria Uma Spell Que Teleporta-se o Player Aleatoriamente Numa Areá 4x4 . Exemplo: To Preso Numa Trap Usa e Sou Teleportado Para Fora Dela Aleatoriamente Para Um Lugar Perto de Min Que Não Tem Parede Nem PZ Nem Água . Nota : Eu Já Um Spell Desse Em Um NTO @UP @UP @UP @UP @UP @UP Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/ Compartilhar em outros sites More sharing options...
0 zipter98 1102 Postado Fevereiro 1, 2016 Share Postado Fevereiro 1, 2016 OK. local teleport_area = { --Área com as posições que o jogador pode ser teleportado. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 2, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, } local exhaust_time = xxx --Exhaust, em segundos. function onCastSpell(cid) local area_positions = getPosfromArea(cid, teleport_area) local position = area_positions[math.random(#area_positions)] if getPlayerStorageValue(cid, 2019) > os.time() then doPlayerSendCancel(cid, "Wait "..getPlayerStorageValue(cid, 2019) - os.time().." second(s) to use this spell again.") return true end if not isWalkable(position) or getTileInfo(position).protection then while not isWalkable(position) do position = area_positions[math.random(#area_positions)] end end doTeleportThing(cid, position) setPlayerStorageValue(cid, 2019, os.time() + exhaust_time) return true end Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684283 Compartilhar em outros sites More sharing options...
0 zipter98 1102 Postado Janeiro 31, 2016 Share Postado Janeiro 31, 2016 Em algum arquivo da lib, coloque as seguintes funções: ------------------ Function getPosfromArea(cid,area) by Dokmos ------------------ function getPosfromArea(cid,area) icenter = math.floor(table.getn(area)/2)+1 jcenter = math.floor(table.getn(area[1])/2)+1 center = area[icenter] ivar = table.getn(area) jvar = table.getn(area[1]) i = table.getn(area)^2 j = table.getn(area[1])^2 local mydir = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid) setPlayerStorageValue(cid, 21101, -1) --alterado v1.6 if center[jcenter] == 3 then if mydir == 0 then signal = {-1,1,1,2} elseif mydir == 1 then signal = {1,-1,2,1} elseif mydir == 2 then signal = {1,-1,1,2} elseif mydir == 3 then signal = {-1,1,2,1} end else signal = {-1,1,1,2} end POSITIONS = {} P = 0 repeat pvar = {0,0} I = area[ivar] J = I[jvar] i = i-1 j = j-1 if J == 1 then if jvar < jcenter then pvar[signal[3]] = signal[1]*math.abs((jcenter-jvar)) elseif jvar > jcenter then pvar[signal[3]] = signal[2]*math.abs((jcenter-jvar)) end if ivar < icenter then pvar[signal[4]] = signal[1]*math.abs((icenter-ivar)) elseif ivar > icenter then pvar[signal[4]] = signal[2]*math.abs((icenter-ivar)) end end if jvar > 1 then jvar = (jvar-1) elseif ivar > 1 then jvar = table.getn(area[1]) ivar = (ivar-1) end local pos = getThingPos(cid) local areapos = {x=pos.x+(pvar[1]),y=pos.y+(pvar[2]),z=pos.z} if pos.x ~= areapos.x or pos.y ~= areapos.y then P = P+1 POSITIONS[P] = areapos end until i <= 0 and j <= 0 return POSITIONS end 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 Código da spell: local teleport_area = { --Área com as posições que o jogador pode ser teleportado. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 2, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, } function onCastSpell(cid) local area_positions = getPosfromArea(cid, teleport_area) local position = area_positions[math.random(#area_positions)] if not isWalkable(position) or getTileInfo(position).protection then while not isWalkable(position) do position = area_positions[math.random(#area_positions)] end end doTeleportThing(cid, position) return true end Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684190 Compartilhar em outros sites More sharing options...
0 Vasto Lord X 1 Postado Janeiro 31, 2016 Autor Share Postado Janeiro 31, 2016 (editado) Tem Como Fazer o Teleport ter Um Efeito ? Editado Janeiro 31, 2016 por Vasto Lord X Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684191 Compartilhar em outros sites More sharing options...
0 Caronte 446 Postado Fevereiro 1, 2016 Share Postado Fevereiro 1, 2016 doSendMagicEffect(cidPos, CONST_ME_TELEPORT) em baixo de doTeleportThing(cid, position) Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684209 Compartilhar em outros sites More sharing options...
0 Vasto Lord X 1 Postado Fevereiro 1, 2016 Autor Share Postado Fevereiro 1, 2016 doSendMagicEffect(cidPos, CONST_ME_TELEPORT) em baixo de doTeleportThing(cid, position) Não Funciono Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684226 Compartilhar em outros sites More sharing options...
0 Caronte 446 Postado Fevereiro 1, 2016 Share Postado Fevereiro 1, 2016 affe, esqueci de uma coisa mude cidPos para getThingPos(cid) ... Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684229 Compartilhar em outros sites More sharing options...
0 Vasto Lord X 1 Postado Fevereiro 1, 2016 Autor Share Postado Fevereiro 1, 2016 Funciono, Tem Como Botar Um Exhaust ? Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684232 Compartilhar em outros sites More sharing options...
0 zipter98 1102 Postado Fevereiro 1, 2016 Share Postado Fevereiro 1, 2016 Tem, na tag. Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684281 Compartilhar em outros sites More sharing options...
0 Vasto Lord X 1 Postado Fevereiro 1, 2016 Autor Share Postado Fevereiro 1, 2016 Tem, na tag. Eu Sei Mais Eu Quero Que Aparece Escrito Falta ... Segundos Para Acabar . Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684282 Compartilhar em outros sites More sharing options...
0 Danihcv 335 Postado Fevereiro 5, 2016 Share Postado Fevereiro 5, 2016 Tópico movido para dúvidas / pedidos resolvidos. Link para o comentário https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/#findComment-1684951 Compartilhar em outros sites More sharing options...
Pergunta
Vasto Lord X 1
Eu Queria Uma Spell Que Teleporta-se o Player Aleatoriamente Numa Areá 4x4 .
Exemplo: To Preso Numa Trap Usa e Sou Teleportado Para Fora Dela Aleatoriamente Para Um Lugar Perto de Min Que Não Tem Parede Nem PZ Nem Água .
Nota : Eu Já Um Spell Desse Em Um NTO
@UP
@UP
@UP
@UP
@UP
@UP
Link para o comentário
https://xtibia.com/forum/topic/239177-spell-teleport-aleatorio/Compartilhar em outros sites
10 respostass a esta questão
Posts Recomendados