Mousetat

Magnet shaman game vanilla

Feb 17th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. local magnet = ""
  2. local timeLeft = 0
  3.  
  4. local settings = {
  5. maxVX = 150,
  6. maxVY = 150,
  7. }
  8.  
  9. function getSpeed(data, data2)
  10. local abs = math.abs
  11.  
  12. local direction = {x = 1, y = 1}
  13. if data.x < data2.x then direction.x = -1 end
  14. if data.y < data2.y then direction.y = -1 end
  15.  
  16. local speed = {
  17. x = abs(data.x - data2.x) / 3,
  18. y = abs(data.y - data2.y) / 3,
  19. }
  20. if speed.x > settings.maxVX then speed.x = settings.maxVX end
  21. if speed.y > settings.maxVY then speed.y = settings.maxVY end
  22. speed.x = speed.x * direction.x
  23. speed.y = speed.y * direction.y
  24.  
  25. return speed
  26. end
  27.  
  28. function main()
  29. tfm.exec.disableAutoNewGame(true)
  30. tfm.exec.disableAutoShaman(true)
  31. tfm.exec.disableAutoTimeLeft(true)
  32. tfm.exec.disableMinimalistMode(true)
  33. tfm.exec.disablePhysicalConsumables(true)
  34.  
  35. ui.addBotText("A reverse magnet effect is applied onto the shaman each round! Bring the cheese to the hole safely!", nil)
  36. newGame()
  37. end
  38.  
  39. function newGame()
  40. tfm.exec.newGame("#V")
  41. end
  42.  
  43. local tfm_exec_newGame = tfm.exec.newGame
  44. function tfm.exec.newGame(map)
  45. if map == "#V" then
  46. local vanilla = {}
  47. for num = 0, 143 do
  48. table.insert(vanilla, num)
  49. end
  50. for num = 200, 210 do
  51. table.insert(vanilla, num)
  52. end
  53. tfm_exec_newGame(vanilla[math.random(#vanilla)])
  54. else
  55. tfm_exec_newGame(map)
  56. end
  57. end
  58.  
  59. function ui.addBotText(text, n)
  60. ui.addTextArea(100, "<v>[~Soupbot]<n> "..text, n, 6, 380, nil, 30, 0x324650, 0x171918, 0.7, true)
  61. end
  62.  
  63. function eventNewGame()
  64. local selected = {n = "", score = 0}
  65. for n, data in pairs(tfm.get.room.playerList) do
  66. if data.score >= selected.score then
  67. selected.n = n
  68. selected.score = data.score
  69. end
  70. end
  71.  
  72. magnet = selected.n
  73. tfm.exec.setShaman(magnet)
  74.  
  75. ui.setShamanName("<rose> "..magnet)
  76. ui.addBotText("You must bring the mice to the cheese and the hole safely! A reverse magnet is applied onto you!", magnet)
  77. end
  78.  
  79. function eventPlayerDied(n)
  80. local num, n2 = 0, ""
  81. for n, data in pairs(tfm.get.room.playerList) do
  82. if not data.isDead then num = num + 1 n2 = n end
  83. end
  84. if n == magnet or num <= 1 then
  85. if timeLeft > 5 then tfm.exec.setGameTime(5) end
  86. ui.addBotText("The shaman and the mice has failed this round!", nil)
  87. end
  88. end
  89.  
  90. function eventPlayerWon(n)
  91. if n ~= magnet then
  92. local num = 0
  93. for n, data in pairs(tfm.get.room.playerList) do
  94. if not data.isDead then num = num + 1 end
  95. end
  96. if num == 1 then
  97. ui.addBotText("The shaman and the mice has succeeded this round!", nil)
  98. ui.addBotText("You have succeeded! Go in the hole!", magnet)
  99. end
  100. elseif timeLeft > 5 then
  101. tfm.exec.setGameTime(5)
  102. end
  103. end
  104.  
  105. function eventLoop(passed, left)
  106. local data = tfm.get.room.playerList[magnet]
  107.  
  108. if data and not data.isDead then
  109. for attracted, data2 in pairs(tfm.get.room.playerList) do
  110. if attracted ~= magnet then
  111. local speed = getSpeed(data, data2)
  112. tfm.exec.movePlayer(attracted, 0, 0, false, speed.x, speed.y, true)
  113. end
  114. end
  115. end
  116.  
  117. if left <= 0 then
  118. newGame()
  119. end
  120.  
  121. timeLeft = left / 1000
  122. end
  123.  
  124. main()
Advertisement
Add Comment
Please, Sign In to add comment