local positions = {
{fromPosition = Position(1102, 1391, 11), toPosition = Position(1101, 1407, 11)},
{fromPosition = Position(1103, 1391, 11), toPosition = Position(1102, 1407, 11)},
{fromPosition = Position(1104, 1391, 11), toPosition = Position(1103, 1407, 11)},
{fromPosition = Position(1105, 1391, 11), toPosition = Position(1104, 1407, 11)}
}
local demons = {
[1] = Position(1101, 1405, 11),
[2] = Position(1103, 1405, 11),
[3] = Position(1102, 1409, 11),
[4] = Position(1104, 1409, 11),
[5] = Position(1105, 1407, 11),
[6] = Position(1106, 1407, 11)
}
local pull_pos = Position(1105, 1391, 11)
local duration = 30 -- in minutes
local function resetAnnihilator(uid)
local item = Item(uid)
if item.itemid == 1946 then
item:transform(1945)
end
for i = 1, #demons do
local creatures = Tile(demons[i]):getCreatures()
for key, creature in pairs(creatures) do
if creature:getName() == "Demon" then
creature:remove()
end
end
end
for key, value in pairs(positions) do
local creatures = Tile(value.toPosition):getCreatures()
for k, creature in pairs(creatures) do
if creature:getName() == "Demon" then
creature:remove()
end
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 1945 then
local players = {}
for i = 1, #positions do
if positions[i].fromPosition == pull_pos and player:getPosition() ~= pull_pos then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You are in the wrong position.')
return false
end
local tile = Tile(positions[i].fromPosition)
if tile then
local creature = tile:getBottomCreature()
if creature then
local temp_player = creature:getPlayer()
if not temp_player then
player:sendTextMessage(MESSAGE_INFO_DESCR, creature:getName()..' is not a valid participant.')
return false
end
if temp_player:getLevel() < 100 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Some players are under the required level 100.')
return false
end
players[#players + 1] = temp_player
end
else
print("Cannot find tile for position " .. positions[i].fromPosition.x .. ", " .. positions[i].fromPosition.y .. ", " .. positions[i].fromPosition.z)
end
end
if #players ~= 4 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You do not have the required amount of players.')
return false
end
for i = 1, #players do
local temp_player = players[i]
if creature then
players[i]:teleportTo(positions[i].toPosition)
positions[i].toPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
end
for i = 1, #demons do
doSummonCreature('Demon', demons[i], false, true)
end
item:transform(1946)
addEvent(resetAnnihilator, duration*60*1000, item.uid)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Someone has recently started this quest, the cooldown is '..duration..' minutes.')
return false
end
return true
end