local config = {
[17003] = {
nameDz = "Bronze", --Shiny Raticate Ok!
chave = 2155,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1211, fromz = 15, tox = 1966, toy = 1303, toz= 15},
{fromx = 1970, fromy = 1319, fromz = 15, tox = 2248, toy = 1303, toz= 15},
{fromx = 1712, fromy = 1211, fromz = 14, tox = 1966, toy = 1303, toz= 14},
{fromx = 1970, fromy = 1319, fromz = 14, tox = 2248, toy = 1303, toz= 14}
},
teleport = { -- Criado teleporte para cada área
{x = 1789, y = 1288, z = 15},
{x = 2062, y = 1288, z = 15},
{x = 1789, y = 1288, z = 14},
{x = 2062, y = 1288, z = 14}
},
pokemons = {"Elder Zubat", "Elder Rattata"},
finish = 15 * 60 * 1000,
spawnCount = 234,
},
[16990] = {
nameDz = "Silver Fire", --Volcanic Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1313, fromz = 15, tox = 1966, toy = 1416, toz= 15},
{fromx = 1970, fromy = 1313, fromz = 15, tox = 2248, toy = 1416, toz= 15},
},
teleport = { -- Criado teleporte para cada área
{x = 1789, y = 1396, z = 15},
{x = 2062, y = 1396, z = 15}
},
pokemons = {"Elder Charizard", "Elder Magmar", "Elder Blaziken"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16991] = {
nameDz = "Silver Grass", --Naturia Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1313, fromz = 14, tox = 1966, toy = 1416, toz= 14},
{fromx = 1970, fromy = 1313, fromz = 14, tox = 2248, toy = 1416, toz= 14}
},
teleport = { -- Criado teleporte para cada área
{x = 1790, y = 1394, z = 14},
{x = 2063, y = 1394, z = 14}
},
pokemons = {"Elder Tangela", "Elder Sceptile", "Elder Venusaur"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16992] = {
nameDz = "Silver Water", --Seavel Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1313, fromz = 13, tox = 1966, toy = 1416, toz= 13},
{fromx = 1970, fromy = 1313, fromz = 13, tox = 2248, toy = 1416, toz= 13},
},
teleport = { -- Criado teleporte para cada área
{x = 1791, y = 1398, z = 13},
{x = 2064, y = 1398, z = 13}
},
pokemons = {"Elder Blastoise", "Elder Swampert", "Elder Feebas"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16993] = {
nameDz = "Silver Flying", --Wingeon Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1313, fromz = 12, tox = 1966, toy = 1416, toz= 12},
{fromx = 1970, fromy = 1313, fromz = 12, tox = 2248, toy = 1416, toz= 12},
},
teleport = { -- Criado teleporte para cada área
{x = 1792, y = 1399, z = 12},
{x = 2065, y = 1399, z = 12}
},
pokemons = {"Elder Pidgeot", "Elder Shelgon"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16994] = {
nameDz = "Silver Fighting", --Gardestrike Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1211, fromz = 13, tox = 1966, toy = 1303, toz= 13},
{fromx = 1970, fromy = 1319, fromz = 13, tox = 2248, toy = 1303, toz= 13},
},
teleport = { -- Criado teleporte para cada área
{x = 1791, y = 1290, z = 13},
{x = 2064, y = 1290, z = 13},
},
pokemons = {"Elder Heracross", "Elder Kangaskhan", "Elder Vigoroth"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16995] = {
nameDz = "Silver Ghost", --Malefic Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1211, fromz = 12, tox = 1966, toy = 1303, toz= 12},
{fromx = 1970, fromy = 1319, fromz = 12, tox = 2248, toy = 1303, toz= 12}
},
teleport = { -- Criado teleporte para cada área
{x = 1792, y = 1291, z = 12},
{x = 2065, y = 1291, z = 12}
},
pokemons = {"Elder Gengar", "Elder Banette", "Elder Dusclops"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16996] = {
nameDz = "Silver Rock", --Orebound Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1415, fromz = 12, tox = 1966, toy = 1529, toz= 12},
{fromx = 1970, fromy = 1415, fromz = 12, tox = 2248, toy = 1529, toz= 12}
},
teleport = { -- Criado teleporte para cada área
{x = 1792, y = 1507, z = 12},
{x = 2065, y = 1507, z = 12}
},
pokemons = {"Elder Tyranitar", "Elder Rhydon", "Elder Aggron"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16997] = {
nameDz = "Silver Psychic", --Psycraft Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1415, fromz = 13, tox = 1966, toy = 1529, toz= 13},
{fromx = 1970, fromy = 1415, fromz = 13, tox = 2248, toy = 1529, toz= 13}
},
teleport = { -- Criado teleporte para cada área
{x = 1791, y = 1506, z = 13},
{x = 2064, y = 1506, z = 13}
},
pokemons = {"Elder Alakazam", "Elder Gardevoir", "Elder Metang"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16998] = {
nameDz = "Silver Electric", --Raibolt Ok!
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1313, fromz = 13, tox = 1966, toy = 1416, toz= 13},
{fromx = 1970, fromy = 1313, fromz = 13, tox = 2248, toy = 1416, toz= 13},
},
teleport = { -- Criado teleporte para cada área
{x = 1791, y = 1398, z = 13},
{x = 2064, y = 1398, z = 13}
},
pokemons = {"Elder Manectric", "Elder Ampharos", "Elder Electabuzz"},
finish = 30 * 60 * 1000,
spawnCount = 234,
},
[16999] = {
nameDz = "Silver Iron", --Ironhard
chave = 2156,
count = 1,
areas = { -- Criei uma tabela de áreas para simplificar
{fromx = 1712, fromy = 1313, fromz = 12, tox = 1966, toy = 1416, toz= 12},
{fromx = 1970, fromy = 1313, fromz = 12, tox = 2248, toy = 1416, toz= 12},
},
teleport = { -- Criado teleporte para cada área
{x = 1789, y = 1396, z = 12},
{x = 2062, y = 1396, z = 12}
},
pokemons = {"Elder Mawile", "Elder Aggron", "Elder Riolu"},
finish = 30 * 60 * 1000,
spawnCount = 234,
}
}
-- Função para verificar se o local é walkable
function isWalkable(pos, creature, proj, pz, water)-- by Nord
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
if isWater(getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid) and water 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 3 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
-- Função para spawnar Pokémons na área correta
function spawnPokemons(area, pokemons, spawnCount)
for i = 1, spawnCount do
local posX = math.random(area.fromx, area.tox)
local posY = math.random(area.fromy, area.toy)
local posZ = area.fromz
local position = {x = posX, y = posY, z = posZ}
-- Verifica se a posição é "walkable"
if isWalkable(position) then
local chosenPokemon = pokemons[math.random(1, #pokemons)]
doCreateMonster(chosenPokemon, position)
else
i = i - 1 -- Se a posição não for válida, tenta novamente
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg = config[item.actionid]
if not cfg then
return true
end
if isRiderOrFlyOrSurf(cid) then
doPlayerSendCancel(cid, "Saia do ride ou fly para acessar a dungeon.")
return true
end
if getPlayerStorageValue(cid, 468703) - os.time() > 0 then
doPlayerSendCancel(cid, "Aguarde "..convertTime(getPlayerStorageValue(cid, 468703) - os.time()).." para entrar na Dungeon.")
return true
end
if getPlayerItemCount(cid, cfg.chave) >= cfg.count then
for i, area in ipairs(cfg.areas) do
if #getPlayersInArea(area) < 1 then
-- Remove monstros existentes e inicia os novos spawns
removeNpcInArea({x = area.fromx, y = area.fromy, z = area.fromz}, {x = area.tox, y = area.toy, z = area.toz}, true, false)
creatureInSurvival({x = area.fromx, y = area.fromy, z = area.fromz}, {x = area.tox, y = area.toy, z = area.toz}, true, false)
-- Teleporta o jogador para a área correspondente
doTeleportThing(cid, cfg.teleport[i])
setPlayerStorageValue(cid, 2154610, 1)
doPlayerRemoveItem(cid, cfg.chave, cfg.count)
addEvent(doTeleportFinish2, cfg.finish, cid)
doSendPlayerExtendedOpcode(cid, 133, (cfg.finish / 1000))
-- Spawna os Pokémons
spawnPokemons(area, cfg.pokemons, cfg.spawnCount)
return true
end
end
doPlayerSendCancel(cid, "Nao tem Zonas disponiveis no momento, tente mais tarde!")
else
doPlayerSendCancel(cid, "Você precisa de uma Dimensional Key para acessar essa Dungeon.")
end
return true
end