-- Script made by Zoriath --
-- Variables --
-- What level does the player need to have to go on the annihilator? --
local playerLevelNeed = 100
-- Enter the positions of the demon which is most on the right (in front of the door). --
local firstMonster = {"Demon", {x = 33224, y = 31659, z = 13}}
-- Preferably, do not edit this (only if you don't have a standard annihilator). --
local monsterSummons = {
{"Demon", {x = firstMonster.x - 1, y = firstMonster.y, z = firstMonster.z}},
{"Demon", {x = firstMonster.x - 2, y = firstMonster.y - 1, z = firstMonster.z}},
{"Demon", {x = firstMonster.x - 3, y = firstMonster.y - 1, z = firstMonster.z}},
{"Demon", {x = firstMonster.x - 2, y = firstMonster.y + 1, z = firstMonster.z}},
{"Demon", {x = firstMonster.x - 3, y = firstMonster.y + 1, z = firstMonster.z}}
}
-- Enter the position of the first player (the one most on the right). --
local firstPlayer = {x = 33225, y = 31671, z = 13, stackpos = STACKPOS_TOP_CREATURE}
-- Preferably, do not edit this (only if you don't have a standard annihilator). --
local playersPositions = {
{x = firstPlayer.x - 1, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos},
{x = firstPlayer.x - 2, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos},
{x = firstPlayer.x - 3, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos}
}
-- Enter the position of the first player (the one most on the right) for the position after they've been teleported into the annihilator. --
local firstNewPlayer = {x = 33222, y = 31659, z = 13, stackpos = STACKPOS_TOP_CREATURE}
-- Preferably, do not edit this (only if you don't have a standard annihilator). --
local playersPositionsNew = {
{x = firstPlayer.x - 1, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos},
{x = firstPlayer.x - 2, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos},
{x = firstPlayer.x - 3, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos}
}
-- Enter the position of the beginning of the annihilator (the top left sqm). --
startAnnihilator = {x = 33219, y = 31657, z = 13, stackpos = STACKPOS_TOP_CREATURE}
-- Enter the position of the ending of the annihilator (the lowest right sqm). --
endAnnihilator = {x = 33237, y = 31662, z = 13, stackpos = STACKPOS_TOP_CREATURE}
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- Checks if the ItemID of the lever is correct. --
if(item.itemid == 1945) then
-- Checks if the player has enough level. --
for _, v in ipairs(firstPlayer + playerPositions) do
if(getPlayerLevel(cid) >= playerLevelNeed) then
-- Checks if the player hasn't done annihilator already. --
for _, v in ipairs(firstPlayer + playerPositions) do
if(getPlayerStorageValue ~= TRUE) then
-- Checks if all the players are there. --
for _, d in ipairs(firstPlayer + playerPositions) do
if(getThingFromPos(unpack(d)).itemid > 0) then
-- Checks how many monsters there are in the annihilator. --
for _, v in ipairs(firstMonster + monsterSummons) do
-- Makes everything happen (the summoning/teleporting). --
doSummonCreature(unpack(v))
doTeleportThing(unpack(d), firstNewPlayer + playersPositionsNew)
end
else
doPlayerSendCancel(unpack(d), 22, "You need " .. #firstPlayer + #playerPositions .. " players to go on annihilator!")
end
end
else
doPlayerSendCancel(unpack(v), 22, "Someone has already done the annihilator.")
end
end
else
doPlayerSendCancel(unpack(v), 22, "Someone in your team hasn't got the required level to do the annihilator.")
end
end
-- Checks if the annihilator hasn't been done before. --
elseif(item.itemid == 1946) then
if(cleanArea()) then
doTransformItem(item.uid, 1945)
else
return FALSE
end
-- Checks if the amounts are correct (from the players). --
elseif(#firstPlayer + #playersPositions ~= #firstNewPlayer + #playersPositionsNew) then
for _, v in ipairs(firstPlayer + playersPositions) do
doPlayerSendCancel(unpack(v), 22, "The annihilator is not (yet) useable in this server.")
end
elseif(#firstPlayer > 2 or #firstNewPlayer > 2) then
for _, v in ipairs(firstPlayer + playersPositions) do
doPlayerSendCancel(unpack(v), 22, "The annihilator is not (yet) useable in this server.")
end
end
return TRUE
end
-- This is not made by myself but by Tworn (was too lazy to make it myself :P). --
function cleanArea()
local checkAnnihilator = {x = startAnnihilator.x, y = startAnnihilator.y, z = startAnnihilator.z, stackpos = STACKPOS_TOP_CREATURE}
local monster = {}
while(checkAnnihilator.y <= endAnnihilator.y) do
local creature = getTopCreature(checkAnnihilator)
if(isCreature(creature) == TRUE) then
if(isPlayer(creature) == TRUE) then
return FALSE
else
table.insert(monster, creature)
end
end
if(checkAnnihilator.x == endAnnihilator.x) then
checkAnnihilator.x = startAnnihilator.x
checkAnnihilator.y = checkAnnihilator.y + 1
end
checkAnnihilator.x = checkAnnihilator.x + 1
end
end