bapereira

Snowball War

Oct 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. -------------------- System --------------------
  2.  
  3. _, nickname = pcall(nil)
  4. local admin = string.match(nickname, "(.-)%.")
  5.  
  6. for _, v in next, {'AutoShaman', 'AutoNewGame', 'AutoTimeLeft', 'PhysicalConsumables','AutoScore','MortCommand','MinimalistMode'} do
  7. tfm.exec['disable' .. v]()
  8. end
  9.  
  10. system.disableChatCommandDisplay()
  11.  
  12. ------------------------------------------------
  13.  
  14. local info = {_time = 0,_map_time = 300,_start_time = 10,_click = false,_last = false,_winner = nil,_interval = 2}
  15.  
  16. local config = {_object = 34,_radius = 50,_force = 4,_velocity = 7}
  17.  
  18. local player = {}
  19.  
  20. local alive = {}
  21.  
  22. local map = {'@7639406','@7639469','@7639505'}
  23. local random_map = true
  24. local current_map = 1
  25.  
  26. hypo = function(x,y) return ((x)^2 + (y)^2)^0.5 end
  27.  
  28. reverse = function(ad,op,r)
  29. return math.floor(op < 0 and math.deg(math.acos(ad / r)) or 360 - math.deg(math.acos(ad / r)))
  30. end
  31.  
  32. click_switch = function(activate)
  33. for name,value in next, tfm.get.room.playerList do system.bindMouse(name,activate) end
  34. end
  35.  
  36. eventNewGame = function()
  37. info._time = 0
  38. info._last = false
  39. info._winner = nil
  40. click_switch(false)
  41. alive = {}
  42. for name,value in next, tfm.get.room.playerList do player[name] = {_time = 0} tfm.exec.setNameColor(name,'0xC2C2DA') end
  43. tfm.exec.setGameTime(info._map_time,true)
  44. tfm.exec.snow(10000,999999999999999)
  45. ui.setMapName('<CH>Snowball War</CH>')
  46. end
  47.  
  48. eventMouse = function(name,x,y)
  49. if player[name] and player[name]._time < info._time then
  50. local p = tfm.get.room.playerList[name]
  51. local ang = reverse(x - p.x,y - p.y,hypo(x - p.x,y - p.y))
  52. local ad = (math.cos(math.rad(ang)) * config._radius)
  53. local op = (math.sin(math.rad(ang)) * config._radius)
  54. tfm.exec.addShamanObject(config._object,p.x + ad,p.y - op,-ang,(ad / config._force),(-op / config._force))
  55. player[name]._time = (info._time + info._interval)
  56. end
  57. end
  58.  
  59. change_map = function()
  60. alive = {}
  61. for name,value in next, tfm.get.room.playerList do
  62. if not value.isDead then
  63. alive[#alive + 1] = name
  64. end
  65. end
  66. if #alive <= 1 then info._last = true info._winner = alive[1] ui.setMapName('<CH>Snowball War</CH> <G>|</G> '..(info._winner and '<N>Vencedor: </N><A:ACTIVE>'..info._winner..'</A:ACTIVE> ' or '<N>Sem vencedores</N> ')) tfm.exec.setGameTime(10,true) info._click = false click_switch(false) tfm.exec.setNameColor(info._winner,'0xC2C2DA') end
  67. end
  68.  
  69. eventLoop = function(ct,tl)
  70. info._time = (info._time + 0.5)
  71. if info._time > 3 and tl < 0 then
  72. current_map = (current_map + 1 > #map and 1 or current_map + 1)
  73. tfm.exec.newGame(map[(random_map and math.random(1,#map) or current_map)])
  74. end
  75. if info._time <= info._start_time then ui.addTextArea(1,'<p align="center"><b><font size="40"><N>'..(info._time < info._start_time and math.ceil(info._start_time - info._time) or 0)..'</N></font></b></p>',nil,370,30,60,60,'0x1','0x1',0.7,true) end
  76. if info._time > info._start_time and not info._last then
  77. if not info._click then info._click = true click_switch(true) ui.removeTextArea(1) end
  78. for name,value in next, tfm.get.room.playerList do
  79. tfm.exec.movePlayer(name,0,0,true,0,0,true)
  80. if player[name] and player[name]._time < info._time then tfm.exec.setNameColor(name,'0xE9E654') else tfm.exec.setNameColor(name,'0xC2C2DA') end
  81. if value.vx > config._velocity or value.vx < -config._velocity or value.vy > (config._velocity + 10) or value.vy < -(config._velocity + 10) and info._click then
  82. tfm.exec.killPlayer(name)
  83. end
  84. end
  85. end
  86. if not info._last then change_map() end
  87. end
  88.  
  89. start = function()
  90. current_map = 1
  91. tfm.exec.newGame(map[(random_map and math.random(1,#map) or current_map)])
  92. end
  93. start()
Add Comment
Please, Sign In to add comment