Advertisement
C00lgamer

mobSpawnAlgorithm

Sep 21st, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.61 KB | None | 0 0
  1. -- sets the difficulty level of the area the player is in
  2. areaDifficulty = 10
  3. -- timer for spawning new mobs
  4. mobTimer = 120
  5. -- player"playerName"lvlxx
  6. endPlayerName = string.len(event[4]) - 5
  7. playerName = string.sub(event[4],6,endPlayerName)
  8. playerLevel = string.sub(event[4],endPlayerName,string.len(event[4]))
  9.  
  10. while true do
  11.     os.startTimer(5)
  12.     mobTimer = mobTimer - 5
  13.     event = { os.pullEvent() }
  14.     if string.sub(event[4],0,6) == "player" and event[5]<20 and event[5]>10  and event[1] == "modem_message" then
  15.         if mobTimer > 60
  16.             mobTimer = mobTimer - 1
  17.             timer = nil
  18.             timer = os.startTimer(5)
  19.         elseif mobTimer < 10
  20.             if areadifficulty + 1 < playerLevel/3
  21.                 math.randomseed(os.time())
  22.                 local diceRoll = math.random(100)
  23.                 if diceRoll < 40 then
  24.                     mobTimer - 1
  25.                 elseif diceRoll < 60  and diceRoll > 40 then
  26.                     spawnMediumHostile()
  27.                     mobTimer = 150
  28.                 elseif diceRoll > 60
  29.                     spawnHardHostile()
  30.                     mobTimer = 210
  31.                 end
  32.             elseif areadifficulty + 1 < playerLevel/2
  33.                 math.randomseed(os.time())
  34.                 local diceRoll = math.random(100)
  35.                 if diceRoll < 20 then
  36.                     mobTimer - 1
  37.                 elseif diceRoll < 60  and diceRoll > 20 then
  38.                     spawnMediumHostile()
  39.                     mobTimer = 150
  40.                 elseif diceRoll > 60 and diceRoll < 70
  41.                     spawnEasyHostile()
  42.                     mobTimer = 90
  43.                 elseif diceRoll > 70
  44.                     spawnHardHostile()
  45.                     mobTimer = 210
  46.                 end
  47.             elseif areadifficulty + 1 < playerLevel/1.5
  48.                 math.randomseed(os.time())
  49.                 local diceRoll = math.random(100)
  50.                 if diceRoll < 20 then
  51.                     mobTimer - 1
  52.                 elseif diceRoll < 50  and diceRoll > 20 then
  53.                     spawnMediumHostile()
  54.                     mobTimer = 150
  55.                 elseif diceRoll > 80 and diceRoll < 50
  56.                     spawnEasyHostile()
  57.                     mobTimer = 90
  58.                 elseif diceRoll > 80
  59.                     spawnHardHostile()
  60.                     mobTimer = 210
  61.                 end
  62.             elseif areadifficulty + 1 < playerLevel
  63.                 math.randomseed(os.time())
  64.                 local diceRoll = math.random(100)
  65.                 if diceRoll < 30 then
  66.                     mobTimer - 1
  67.                 elseif diceRoll < 50  and diceRoll > 30 then
  68.                     spawnMediumHostile()
  69.                     mobTimer = 150
  70.                 elseif diceRoll > 95 and diceRoll < 50
  71.                     spawnEasyHostile()
  72.                     mobTimer = 90
  73.                 elseif diceRoll > 95
  74.                     spawnHardHostile()
  75.                     mobTimer = 210
  76.                 end
  77.             elseif areadifficulty + 1 < playerLevel/2
  78.                 math.randomseed(os.time())
  79.                 local diceRoll = math.random(100)
  80.                 if diceRoll < 20 then
  81.                     mobTimer - 1
  82.                 elseif diceRoll < 30  and diceRoll > 20 then
  83.                     spawnMediumHostile()
  84.                     mobTimer = 150
  85.                 elseif diceRoll < 40
  86.                     spawnEasyHostile()
  87.                     mobTimer = 90
  88.                 end
  89.             end
  90.  
  91.  
  92.         end
  93.     elseif event[1] == "timer" then
  94.     end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement