local config = {
reward_position = {x = 111111, y = 111111, z = 111}, -- Teleport location when Arena is Cleared.
global_storage = 1111111, -- any free storage
top_left_corner = {x = 111111, y = 111111, z = 111}, -- top left corner of arena
bottom_right_corner = {x = 111111, y = 111111, z = 111} -- bottom right corner of arena
}
local monsters = { -- All monsters in arena (including joke monster)
[1] = "rat",
[2] = "cave rat",
[3] = "spider",
[4] = "snake",
[5] = "bug"
}
local monster_config_wave_one = { -- wave 1
[1] = {position = {x = 111111, y = 111111, z = 111}, name = "cave rat"},
[2] = {position = {x = 111111, y = 111111, z = 111}, name = "spider"},
[3] = {position = {x = 111111, y = 111111, z = 111}, name = "snake"},
[4] = {position = {x = 111111, y = 111111, z = 111}, name = "bug"}
}
local monster_config_wave_two = { -- wave 2
[1] = {position = {x = 111111, y = 111111, z = 111}, name = "cave rat"},
[2] = {position = {x = 111111, y = 111111, z = 111}, name = "spider"},
[3] = {position = {x = 111111, y = 111111, z = 111}, name = "snake"},
[4] = {position = {x = 111111, y = 111111, z = 111}, name = "bug"}
}
local monster_config_wave_three = { -- wave 3
[1] = {position = {x = 111111, y = 111111, z = 111}, name = "cave rat"},
[2] = {position = {x = 111111, y = 111111, z = 111}, name = "spider"},
[3] = {position = {x = 111111, y = 111111, z = 111}, name = "snake"},
[4] = {position = {x = 111111, y = 111111, z = 111}, name = "bug"}
}
local function teleport()
for t = config.top_left_corner.x, config.bottom_right_corner.x do
for f = config.top_left_corner.y, config.bottom_right_corner.y do
pos = {x = t, y = f, z = 7}
pid = getTopCreature(pos).uid
if isPlayer(pid) then
doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! Go collect your reward.")
doTeleportThing(pid, config.reward_position)
end
end
end
end
function onKill(cid, target, damage, flags)
-- check if target is player
if isPlayer(target) then
return true
end
-- check if target is on list of monsters in arena
local name = getCreatureName(target):lower()
count = 0
for i = 1, #monsters do
if name == monsters[i]:lower() then
count = count + 1
end
end
if count == 0 then -- if target is not on list
return true
end
-- check if target is in area and add to global storage if it is
for t = config.top_left_corner.x, config.bottom_right_corner.x do
for f = config.top_left_corner.y, config.bottom_right_corner.y do
pos = {x = t, y = f, z = 7}
pid = getTopCreature(pos).uid
if pid == target then
setGlobalStorageValue(global_storage, getGlobalStorageValue(global_storage) + 1)
end
end
end
-- Start checks for waves of arena
-- Wave 1
if getGlobalStorageValue(global_storage) == 1 then
for i = 1, #monster_config_wave_one do
doCreateMonster(monster_config_wave_one[i].name, monster_config_wave_one[i].position)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wave 1.")
end
-- Wave 2
if getGlobalStorageValue(global_storage) == 5 then
for i = 1, #monster_config_wave_two do
doCreateMonster(monster_config_wave_two[i].name, monster_config_wave_two[i].position)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wave 2.")
end
-- Wave 3
if getGlobalStorageValue(global_storage) == 9 then
for i = 1, #monster_config_wave_three do
doCreateMonster(monster_config_wave_three[i].name, monster_config_wave_three[i].position)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wave 3. Final Wave.")
end
-- When final wave ends
-- Teleport player
if getGlobalStorageValue(global_storage) == 13 then
addEvent(teleport, 5000)
setGlobalStorageValue(global_storage, 0)
end
return true
end