Tampek
ECHO 'Zarkonia.online';
Hello yesterday with some big join i copied the Annihilator lever to simulate a Dungeon system.
But i have problems with center postion to check players inside i think...
Room size:
-112sqm /\ \/
-108sqm < >
Can anyone know what i need change to try again?
Error console:
Reproduce: when all players are whaiting in lever positions appear that error.
But i have problems with center postion to check players inside i think...
Room size:
-112sqm /\ \/
-108sqm < >
Can anyone know what i need change to try again?
Lua:
local setting = {
-- At what level can do the quest?
requiredLevel = 450,
-- Can it be done daily? true = yes, false = no
daily = false,
-- Do not change from here down
centerDemonRoomPosition = {x = 4899, y = 3741, z = 15},
demonsPositions = {
{x = 4869, y = 3779, z = 15},
{x = 4887, y = 3780, z = 15},
{x = 4883, y = 3766, z = 15},
{x = 4900, y = 3777, z = 15},
{x = 4917, y = 3773, z = 15},
{x = 4939, y = 3776, z = 15},
{x = 4950, y = 3778, z = 15},
{x = 4946, y = 3759, z = 15},
{x = 4943, y = 3747, z = 15},
{x = 4933, y = 3747, z = 15},
{x = 4925, y = 3753, z = 15},
{x = 4928, y = 3738, z = 15},
{x = 4917, y = 3748, z = 15},
{x = 4905, y = 3755, z = 15},
{x = 4889, y = 3751, z = 15},
{x = 4899, y = 3737, z = 15},
{x = 4870, y = 3753, z = 15},
{x = 4855, y = 3756, z = 15},
{x = 4857, y = 3751, z = 15},
{x = 4870, y = 3735, z = 15},
{x = 4857, y = 3728, z = 15},
{x = 4868, y = 3714, z = 15},
{x = 4858, y = 3708, z = 15},
{x = 4854, y = 3700, z = 15},
{x = 4877, y = 3709, z = 15},
{x = 4883, y = 3698, z = 15}
},
towerPositions = {
{x = 4882, y = 3784, z = 15},
{x = 4878, y = 3746, z = 15}
},
bossPositions = {
{x = 4907, y = 3717, z = 15}
},
towerbossPositions = {
{x = 4909, y = 3707, z = 15}
},
playersPositions = {
{fromPos = {x = 4978, y = 5016, z = 9}, toPos = {x = 4860, y = 3784, z = 15}},
{fromPos = {x = 4979, y = 5016, z = 9}, toPos = {x = 4861, y = 3784, z = 15}},
{fromPos = {x = 4980, y = 5016, z = 9}, toPos = {x = 4862, y = 3784, z = 15}},
{fromPos = {x = 4981, y = 5016, z = 9}, toPos = {x = 4863, y = 3784, z = 15}},
}
}
local lever = Action()
function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 2772 then
-- Checks if you have the 4 players and if they have the required level
for i = 1, #setting.playersPositions do
local creature = Tile(setting.playersPositions[i].fromPos):getTopCreature()
if not creature then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Four players are required to start the dungeon level 1.")
return true
end
if creature and creature:getLevel() < setting.requiredLevel then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All the players need to be level ".. setting.requiredLevel .." or higher.")
return true
end
end
-- Checks if there are still players inside the room, if so, return true
if Position.hasPlayer(setting.centerDemonRoomPosition, 4, 4) then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A team is already inside the dungeon.")
return true
end
-- Create monsters
for i = 1, #setting.demonsPositions do
Game.createMonster("Elder Mage", setting.demonsPositions[i])
end
-- Create towers
for i = 1, #setting.towerPositions do
Game.createMonster("Force Field", setting.towerPositions[i])
end
-- Create boss
for i = 1, #setting.bossPositions do
Game.createMonster("The Abomination", setting.bossPositions[i])
end
-- Create bosstower
for i = 1, #setting.towerbossPositions do
Game.createMonster("Magic Field", setting.towerbossPositions[i])
end
-- Get players from the tiles "playersPositions" and teleport to the demons room if all of the above requirements are met
for i = 1, #setting.playersPositions do
local creature = Tile(setting.playersPositions[i].fromPos):getTopCreature()
if creature and creature:isPlayer() then
creature:teleportTo(setting.playersPositions[i].toPos)
creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
else
return false
end
end
item:transform(2773)
elseif item.itemid == 2773 then
-- If it has "daily = true" then it will execute this function
if setting.daily then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return true
end
-- Not be able to push the lever back if someone is still inside the monsters room
if Position.hasPlayer(setting.centerDemonRoomPosition, 4, 4) then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A team is already inside the dungeon.")
return true
end
-- Removes all monsters so that the next team can enter
if Position.removeMonster(setting.centerDemonRoomPosition, 4, 4) then
return true
end
item:transform(2772)
end
return true
end
lever:uid(30038)
lever:register()
Error console:
Reproduce: when all players are whaiting in lever positions appear that error.