local storePlayers, playerTile = {}
local function startfirstwave()
local m = 0
repeat
local posx = math.random(24823, 24864)
local posy = math.random(24221, 24254)
Game.createMonster("Demon", {x = posx, y = posy, z = 7})
m = m + 1
until m == 30
return true
end
local function firstwave()
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting First Wave...")
Game.setStorageValue(4700, os.time()+10)
end
while os.time() < Game.getStorageValue(4700) do
for a = 10, 0, -1 do
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
end
if a == 0 then
startfirstwave()
Game.setStorageValue(4700, 30)
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/30 monsters left.")
players:setStorageValue(4700, 0)
end
end
end
end
return true
end
local function startsecondwave()
local m = 0
repeat
local posx = math.random(24823, 24864)
local posy = math.random(24221, 24254)
Game.createMonster("Orshabaal", {x = posx, y = posy, z = 7})
m = m + 1
until m == 15
return true
end
local function secondwave()
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting Second Wave...")
Game.setStorageValue(4700, os.time()+10)
end
while os.time() < Game.getStorageValue(4700) do
for a = 10, 0, -1 do
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
end
if a == 0 then
startsecondwave()
Game.setStorageValue(4700, 15)
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/15 monsters left.")
players:setStorageValue(4700, 1)
end
end
end
end
return true
end
local function startthirdwave()
local m = 0
repeat
local posx = math.random(24823, 24864)
local posy = math.random(24221, 24254)
Game.createMonster("Morgaroth", {x = posx, y = posy, z = 7})
m = m + 1
until m == 10
return true
end
local function thirdwave()
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting Third Wave...")
Game.setStorageValue(4700, os.time()+10)
end
while os.time() < Game.getStorageValue(4700) do
for a = 10, 0, -1 do
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
end
if a == 0 then
startthirdwave()
Game.setStorageValue(4700, 10)
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/10 monsters left.")
players:setStorageValue(4700, 2)
end
end
end
end
return true
end
local function startfourthwave()
local m = 0
repeat
local posx = math.random(24823, 24864)
local posy = math.random(24221, 24254)
Game.createMonster("Guardian of Skandinavia", {x = posx, y = posy, z = 7})
m = m + 1
until m == 5
return true
end
local function fourthwave()
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting Fourth Wave...")
Game.setStorageValue(4700, os.time()+10)
end
while os.time() < Game.getStorageValue(4700) do
for a = 10, 0, -1 do
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
end
if a == 0 then
startfourthwave()
Game.setStorageValue(4700, 5)
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/5 monsters left.")
players:setStorageValue(4700, 3)
end
end
end
end
return true
end
local function startfifthwave()
local m = 0
repeat
local posx = math.random(24823, 24864)
local posy = math.random(24221, 24254)
Game.createMonster("Gaz'Haragoth", {x = posx, y = posy, z = 7})
m = m + 1
until m == 3
return true
end
local function fifthwave()
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting Fifth Wave...")
Game.setStorageValue(4700, os.time()+10)
end
while os.time() < Game.getStorageValue(4700) do
for a = 10, 0, -1 do
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
end
if a == 0 then
startfifthwave()
Game.setStorageValue(4700, 3)
for i = 1, #storePlayers do
local players = storePlayers[i]
players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/3 monsters left.")
players:setStorageValue(4700, 4)
end
end
end
end
return true
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerPositions = {
Position(24846, 24233, 7),
Position(24847, 24233, 7),
Position(24848, 24233, 7)
}
for i = 1, #playerPositions do
playerTile = Tile(playerPositions[i]):getTopCreature()
storePlayers[#storePlayers + 1] = playerTile
end
if Game.getStorageValue(4700) > 0 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "A wave is already running...")
end
if Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) <= 0 and player:getStorageValue(4700) == -1 then
firstwave()
elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) <= 0 and player:getStorageValue(4700) == 0 then
for i = 1, #storePlayers do
local players = storePlayers[i]
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
return true
end
players:setStorageValue(4700, 1)
Game.setStorageValue(4801, 1)
end
secondwave()
elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 1 and player:getStorageValue(4700) == 1 then
for i = 1, #storePlayers do
local players = storePlayers[i]
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
return true
end
players:setStorageValue(4700, 2)
Game.setStorageValue(4801, 2)
end
thirdwave()
elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 2 and player:getStorageValue(4700) == 2 then
for i = 1, #storePlayers do
local players = storePlayers[i]
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
return true
end
players:setStorageValue(4700, 3)
Game.setStorageValue(4801, 3)
end
fourthwave()
elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 3 and player:getStorageValue(4700) == 3 then
for i = 1, #storePlayers do
local players = storePlayers[i]
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
return true
end
players:setStorageValue(4700, 4)
Game.setStorageValue(4801, 4)
end
fifthwave()
elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 4 and player:getStorageValue(4700) == 4 then
Game.setStorageValue(4801, 0)
Game.setStorageValue(4800, os.time()+2400)
for i = 1, #storePlayers do
local players = storePlayers[i]
players:setStorageValue(4700, 5)
players:sendTextMessage(TALKTYPE_MONSTER_YELL, "Fifth Wave finished. Congratulations! You got DemonHunter Second Addon.")
players:teleportTo(Position(32369, 32241, 7))
players:addOutfitAddon(288, 2)
players:addOutfitAddon(289, 2)
end
end
return true
end