local STORAGE = 18008 local TASKSTATE_COMPLETED = 1 local TASKSTATE_BOSS = 2 local TASKSTATE_FINALIZED = 3 local tasks = { [18009] = {storage = 18009, kills = 5000, position = Position(1302, 2110, 10), corners = {Position(1296, 2104, 10), Position(1309, 2216, 10)}, monsters = {'The Horned Fox'}, once = false}, [18010] = {storage = 18010, kills = 3000, position = Position(1337, 2111, 10), corners = {Position(1331, 2101, 10), Position(1343, 2120, 10)}, monsters = {'Brutus Bloodbeard', 'Lethal Lissy', 'Ron the Ripper', 'Deadeye Devious'}, once = false}, [18011] = {storage = 18011, kills = 2000, position = Position(1377, 2115, 10), corners = {Position(1369, 2107, 10), Position(1385, 2121, 10)}, monsters = {'Leviathan'}, once = false}, [18012] = {storage = 18012, kills = 1500, position = Position(1435, 2121, 10), corners = {Position(1427, 2110, 10), Position(1451, 2128, 10)}, monsters = {'The Noxious Spawn'}, once = false}, [18013] = {storage = 18013, kills = 6666, position = Position(1296, 2161, 10), corners = {Position(1284, 2154, 10), Position(1307, 2171, 10)}, monsters = {'Orshabaal'}, once = true}, [18014] = {storage = 18014, kills = 2000, position = Position(1352, 2161, 10), corners = {Position(1341, 2151, 10), Position(1361, 2171, 10)}, monsters = {'Stonecracker'}, once = false}, [18015] = {storage = 18015, kills = 2000, position = Position(1398, 2167, 10), corners = {Position(1389, 2149, 10), Position(1413, 2173, 10)}, monsters = {'The Many'}, once = false}, [18016] = {storage = 18016, kills = 10000, position = Position(1440, 2161, 10), corners = {Position(1433, 2154, 10), Position(1451, 2170, 10)}, monsters = {'Demodras'}, once = false}, [18017] = {storage = 18017, kills = 4000, position = Position(1294, 2203, 10), corners = {Position(1286, 2196, 10), Position(1304, 2212, 10)}, monsters = {'Necropharus'}, once = false}, [18018] = {storage = 18018, kills = 5000, position = Position(1345, 2202, 10), corners = {Position(1333, 2193, 10), Position(1357, 2212, 10)}, monsters = {'The Old Widow'}, once = false}, [18019] = {storage = 18019, kills = 500, position = Position(1392, 2205, 10), corners = {Position(1383, 2192, 10), Position(1399, 2215, 10)}, monsters = {'Massacre'}, once = false}, [18020] = {storage = 18020, kills = 500, position = Position(1436, 2205, 10), corners = {Position(1428, 2199, 10), Position(1440, 2211, 10)}, monsters = {'The Handmaiden'}, once = false}, [18021] = {storage = 18021, kills = 1000, position = Position(1285, 2238, 10), corners = {Position(1282, 2235, 10), Position(1290, 2241, 10)}, monsters = {'Mr. Punish'}, once = false}, [18022] = {storage = 18022, kills = 2000, position = Position(1335, 2244, 10), corners = {Position(1327, 2237, 10), Position(1344, 2250, 10)}, monsters = {'Coutness Sorrow'}, once = false}, [18023] = {storage = 18023, kills = 2000, position = Position(1389, 2248, 10), corners = {Position(1379, 2243, 10), Position(1396, 2252, 10)}, monsters = {'Wizard'}, once = false}, [18024] = {storage = 18024, kills = 2000, position = Position(1432, 2252, 10), corners = {Position(1427, 2241, 10), Position(1442, 2255, 10)}, monsters = {'The Death'}, once = false} } local p = Position(1080, 2094, 7) local function finish(cid, f, t) if isPlayer(cid) and isInRange(getThingPosition(cid), f, t) then doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doCreatureSay(cid, 'Your time is over.', TALKTYPE_MONSTER_SAY, false, cid) end end local function kick(cid, message) doTeleportThing(cid, p) doCreatureSay(cid, message, TALKTYPE_MONSTER_SAY, false, cid) end function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) if not isPlayer(cid) then return true end if getCreatureStorage(cid, STORAGE) == EMPTY_STORAGE then doTeleportThing(cid, p) doSendMagicEffect(p, CONST_ME_TELEPORT) doCreatureSay(cid, 'You are not doing any task at this moment. Speak with Grizzly Adams to start one.', TALKTYPE_MONSTER_SAY, false, cid) return true end local task = tasks[item.uid] if task then local kills = getCreatureStorage(cid, task.storage) if kills == EMPTY_STORAGE then kick(cid, 'You are doing another task at the moment.') elseif kills <= task.kills then kick(cid, 'You haven\'t killed enough monsters to enter this magic forcefield. You have already killed '.. kills ..' out of '.. task.kills ..' monsters.') elseif kills == task.kills + TASKSTATE_COMPLETED then kick(cid, 'You have to talk with Grizzly Adams first.') elseif kills == task.kills + TASKSTATE_BOSS then local players, monsters = getPlayersInRange(task.corners[1], task.corners[2]), getMonstersInRange(task.corners[1], task.corners[2]) if #players > 0 then kick(cid, getCreatureName(players[1]) ..' is killing boss at the moment, please try again later.') end if #monsters > 0 then for _, monster in ipairs(monsters) do doRemoveCreature(monster) end end doTeleportThing(cid, task.position) local monster = task.monsters[math.random(#task.monsters)] doCreateMonster(monster, task.position) doCreatureSetStorage(cid, STORAGE, EMPTY_STORAGE) if task.once then doCreatureSetStorage(cid, task.storage, task.kills + TASKSTATE_FINALIZED) doCreatureSay(cid, 'You have 15 minutes to kill '.. monster ..'. Moreover, you only have one opportunity to kill '.. monster ..'! You can\'t do this task again. Good luck!', TALKTYPE_MONSTER_SAY, false, cid) addEvent(finish, 15 * 60 * 1000, cid, task.corners[1], task.corners[2]) else doCreatureSetStorage(cid, task.storage, EMPTY_STORAGE) doCreatureSay(cid, 'You have 15 minutes to kill '.. monster ..'. Moreover, if you don\'t kill the boss within that time, or you die, you will have to complete the task again. Good luck!', TALKTYPE_MONSTER_SAY, false, cid) addEvent(finish, 15 * 60 * 1000, cid, task.corners[1], task.corners[2]) end end end return true end