Advertisement
Guest User

arena

a guest
Feb 22nd, 2012
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.41 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Arena" version="1.00" author="Zyntax" contact="otland.net" enabled="yes">
  3. <config name="arena_config"><![CDATA[
  4. center = {x=996,y=1014,z=7} --center of arena
  5. x = {993, 999} --fromX, toX
  6. y = {1011, 1017} --fromY, toY
  7. z1 = 7
  8. storage = 5005 --value 1=first level, value 2= second level....
  9. global = 5006
  10. spawnrate = 2 --increasing spawn by "2"
  11. spawntime = 10 --next wave spawning in minutes (for testing , its seconds!)
  12. spawnmax = 8 --maximum of 8 monsters
  13. rewardroom = {x=995,y=1019,z=7} --reward room
  14. exit = {x=991,y=1019,z=7} --if player fails, exit there
  15. monsters = {
  16.     "hydra", --first level
  17.     "giant spider", --second level
  18.     "warlock", --third level
  19.     "dark torturer", --fourth level
  20.     "hellhound", --fifth level
  21.     "demon" --sixth level
  22. }
  23. ]]></config>
  24. <moveevent type="stepIn" actionid="5010" event="script"><![CDATA[
  25. domodlib('arena_config')
  26. local function succes(cid)
  27.     if getGlobalStorageValue(global) > 0 then
  28.     local fail = {}
  29.         for x=x[1], x[2] do
  30.             for y=y[1], y[2] do
  31.                 local monster = getThingFromPos({x=x,y=y,z=z1,stackpos=255}).uid
  32.                 if isMonster(monster) then
  33.                     doRemoveCreature(monster)
  34.                     table.insert(fail, 1)
  35.                 end
  36.             end
  37.         end
  38.         if #fail > 0 then
  39.             doPlayerSendTextMessage(cid, 17, "You failed to clear the arena in the given time.")
  40.             setPlayerStorageValue(cid, storage, -1)
  41.             setGlobalStorageValue(global, 0)
  42.             doTeleportThing(cid, exit)
  43.         elseif #fail == 0 then
  44.             doPlayerSendTextMessage(cid, 17, "Congratulations on surviving!\nGrab your reward!")
  45.             doTeleportThing(cid, rewardroom)
  46.             setGlobalStorageValue(global, 0)
  47.             setPlayerStorageValue(cid, storage, -1)
  48.         end
  49.     end
  50. end
  51.  
  52. local function spawn(cid, s)
  53.     if getGlobalStorageValue(global) > 0 then
  54.         if s <= spawnmax then
  55.             local monster = monsters[getPlayerStorageValue(cid, storage)]
  56.             for i = 1, s do
  57.                 doSummonCreature(monster, center)
  58.             end
  59.             if s == spawnmax then
  60.                 doPlayerSendTextMessage(cid, 17, "This is the last wave!\nStand firm "..getPlayerName(cid).." !")
  61.             elseif s < spawnmax then
  62.                 doPlayerSendTextMessage(cid, 17, "The next wave with "..(s+s).." monsters will spawn in "..spawntime.." minutes.")
  63.             end
  64.             addEvent(spawn, spawntime*1000, cid, s+s)
  65.         else
  66.             addEvent(succes, 5000, cid)
  67.         end
  68.     end
  69. end
  70.  
  71. function onStepIn(cid, item, fromPosition, toPosition)
  72.     if getPlayerStorageValue(cid, storage) > 0 then
  73.         doPlayerSendTextMessage(cid, 34, "You have entered the arena.\nYour chosen level is: "..getPlayerStorageValue(cid, storage).." out of 6.\nGood luck!")
  74.         doTeleportThing(cid, center)
  75.         addEvent(spawn, spawntime*1000, cid, spawnrate)
  76.     else
  77.         doPlayerSendCancel(cid, "You cannot enter this portal.")
  78.         doTeleportThing(cid, toPosition)
  79.     end
  80. end
  81. ]]></moveevent>
  82.  
  83. <event type="login" name="arenaLogin" event="script"><![CDATA[
  84. function onLogin(cid)
  85.     setPlayerStorageValue(cid, storage, -1)
  86.     return registerCreatureEvent(cid, 'arenaDeath')
  87. end
  88. ]]></event>
  89. <event type="death" name="arenaDeath" event="script"><![CDATA[
  90. domodlib('arena_config')
  91. function onDeath(cid)
  92.     if isPlayer(cid) then
  93.         if getPlayerStorageValue(cid, storage) > 0 then
  94.         setGlobalStorageValue(global, 0)
  95.             for x=x[1], x[2] do
  96.                 for y=y[1], y[2] do
  97.                     local id = getThingFromPos({x=x,y=y,z=z1,stackpos=255}).uid
  98.                     if isMonster(id) then
  99.                         doRemoveCreature(monster)
  100.                     end
  101.                 end
  102.             end
  103.         end
  104.     end
  105. return true
  106. end
  107. ]]></event>
  108. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement