Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. owner = "nobody" -- replace with your username
  2.  
  3. interval = 10
  4. cannonInfo = {}
  5. difficulty = 8
  6.  
  7. maps = {3107377,305748,1539148,4543602,390649,495880,1463332,1492805,292678,305753,1545834,3175437,2964900,1812056,852617,799141,1794907,2939549,459284,1519483,1794873,811211,306360,489829,479091,3419948,290546,276534,3220945,1754355,281649,390657,311496,295988,802958,2643833}
  8.  
  9. function main()
  10. tfm.exec.disableAutoNewGame(true)
  11. tfm.exec.disableAutoShaman(true)
  12. tfm.exec.disableAutoTimeLeft(true)
  13. tfm.exec.newGame(maps[math.random(#maps)])
  14. end
  15.  
  16. function eventNewGame()
  17. interval = 10
  18. end
  19.  
  20. function eventNewPlayer(name)
  21. ui.addTextArea(1, "<a href='event:easy'><VP><font size='14'>E", name, 728, 21, nil, nil, 0x000001, nil, 0.7)
  22. ui.addTextArea(2, "<a href='event:medium'><J><font size='14'>M", name, 753, 21, nil, nil, 0x000001, nil, 0.7)
  23. ui.addTextArea(3, "<a href='event:hard'><R><font size='14'>H", name, 781, 21, nil, nil, 0x000001, nil, 0.7)
  24. end
  25.  
  26. function eventTextAreaCallback(id, name, cb)
  27. if (owner==name or owner=="nobody") and interval > 6 then
  28. interval = 10
  29. if cb == "easy" then
  30. difficulty = 7
  31. elseif cb == "medium" then
  32. difficulty = 8
  33. elseif cb == "hard" then
  34. difficulty = 9
  35. end
  36. end
  37. end
  38.  
  39. function eventLoop(time, remaining)
  40. if time>3000 then
  41. interval = interval - 1
  42. if interval == difficulty then
  43. ui.removeTextArea(4)
  44. local users = {}
  45. for name,p in pairs(tfm.get.room.playerList) do
  46. if not p.isDead then
  47. users[#users+1] = name
  48. end
  49. end
  50. cannonInfo = spawnCannon(users[math.random(#users)])
  51. interval = 11
  52. elseif interval<=5 then
  53. tfm.exec.setUIMapName("<ROSE>The next map will start in "..interval)
  54. if interval == 0 then
  55. tfm.exec.newGame(maps[math.random(#maps)])
  56. end
  57. elseif interval == 10 then
  58. tfm.exec.addShamanObject(17, cannonInfo[1], cannonInfo[2], cannonInfo[3]-90)
  59. cannonInfo={}
  60. end
  61. end
  62. if remaining<=0 then
  63. ui.addTextArea(4, "<VP><p align='center'><B>CONGRATULATIONS</B>\n\n<CH><i>you beat the CPU!", nil, 290, 22, 180, nil, 0x000001, 0xCA0805, 0.8)
  64. tfm.exec.newGame(maps[math.random(#maps)])
  65. end
  66. end
  67.  
  68. function eventPlayerDied(name)
  69. if playerCount() < 1 then
  70. interval = 6
  71. end
  72. end
  73.  
  74. function playerCount()
  75. local n=0
  76. for name, player in pairs(tfm.get.room.playerList) do
  77. if not player.isDead then
  78. n=n+1
  79. end
  80. end
  81. return n
  82. end
  83.  
  84. function spawnCannon(name)
  85. local info = {}
  86. local px = tfm.get.room.playerList[name].x
  87. local py = tfm.get.room.playerList[name].y
  88. local cnnx = math.random()*800
  89. local cnny = math.random()*400
  90. if cnny > py then
  91. cnny = py-math.random(50)-20
  92. end
  93. if math.abs(cnnx-px) > 300 then
  94. cnnx = px + math.random(-50, 50)
  95. end
  96. local ang = math.deg(math.atan2(cnny-py, cnnx-px))
  97. tfm.exec.addShamanObject(0, cnnx, cnny, ang+90)
  98. info[1] = cnnx
  99. info[2] = cnny
  100. info[3] = ang
  101. return info
  102. end
  103.  
  104. function eventChatCommand(name, cmd)
  105. if cmd == "easy" then
  106. difficulty = 8
  107. easy = true
  108. interval = 10
  109. elseif cmd == "medium" then
  110. difficulty = 8
  111. easy = false
  112. interval = 10
  113. elseif cmd == "hard" then
  114. difficulty = 9
  115. easy = false
  116. interval = 10
  117. end
  118. end
  119.  
  120. for name in pairs(tfm.get.room.playerList) do
  121. eventNewPlayer(name)
  122. end
  123.  
  124. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement