Advertisement
superpaste

Football

Apr 25th, 2017
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.52 KB | None | 0 0
  1. tfm.exec.disableAfkDeath(true)
  2. tfm.exec.disableAutoNewGame(true)
  3. tfm.exec.disableAutoScore(true)
  4. tfm.exec.disableAutoShaman(true)
  5. tfm.exec.disableAutoTimeLeft(true)
  6. tfm.exec.newGame('@7123013', nil)
  7. blueGoal = ""
  8. blueFall = ""
  9. redGoal = ""
  10. redFall = ""
  11. bluePoint = 0
  12. redPoint = 0
  13. ball = ""
  14. team = "B"
  15. teams = {}
  16. function expertMove(j)
  17. if teams[j] == "B" then
  18. tfm.exec.movePlayer(j, math.random(10,800), 360, false, 0, 0, false)
  19. elseif teams[j] == "R" then
  20. tfm.exec.movePlayer(j, math.random(800,1590), 360, false, 0, 0, false)
  21. else
  22. end
  23. end
  24.  
  25. function eventNewPlayer(j)
  26. ui.addTextArea(1, '<p align="center">' .. bluePoint .. '</p>', j, 350, 20, 20, 20, 0x123450, 0x0000ff, 1, true)
  27. ui.addTextArea(2, '<p align="center">' .. redPoint .. '</p>', j, 450, 20, 20, 20, 0x123450, 0xff0000, 1, true)
  28. end
  29.  
  30. function start()
  31. bluePoint = 0
  32. redPoint = 0
  33. for i, v in pairs(tfm.get.room.playerList) do
  34. eventNewPlayer(i)
  35. tfm.exec.respawnPlayer(i)
  36. if team == "B" then
  37. teams[i] = "B"
  38. team = "R"
  39. tfm.exec.setNameColor(i, 0x0000ff)
  40. expertMove(i)
  41. elseif team == "R" then
  42.  
  43. teams[i] = "R"
  44. team = "B"
  45. tfm.exec.setNameColor(i, 0xff0000)
  46. expertMove(i)
  47. end
  48. end
  49. end
  50.  
  51.  
  52.     eventNewGame = function()
  53.         pisos = {} -- Limpa a tabela
  54.         local xml = tfm.get.room.xmlMapInfo.xml
  55.         local tagPisos = xml:match("<S>(.*)</S>") or "" -- Coleta todas as tag <S do script
  56.         for piso in tagPisos:gmatch("<S (.-)/>") do
  57.             local atributos = {}
  58.             for atributo,_,valor in piso:gmatch("(%w+) ?= ?([\"'])(.-)%2") do
  59.                 atributos[atributo] = valor
  60.             end
  61. pisos[#pisos + 1] = atributos
  62.         end
  63. for i, v in pairs(pisos) do
  64. for n, g in pairs(v) do
  65. if n == "lua" then
  66. if g == "1" then
  67. blueGoal = v
  68. end
  69. if g == "2" then
  70. blueFall = v
  71. end
  72. if g == "3" then
  73. redGoal = v
  74. end
  75. if g == "4" then
  76. redFall = v
  77. end
  78. end
  79. end
  80. end
  81. start()
  82. ball = tfm.exec.addShamanObject(604, 800, 200, 0, 0, -10, false)
  83.     end
  84.  
  85. function eventLoop(p, r)
  86. if p > 100 then
  87. excedent = nil
  88. for i, v in pairs(tfm.get.room.objectList) do
  89. if not(i == ball) then
  90. excedent = i
  91.  
  92. print("BUG: discovered more than one ball in game, removing excedent")
  93. end
  94.  
  95. end
  96. if not(excedent == nil) then
  97. tfm.exec.removeObject(excedent)
  98. end
  99. if not(ball == "") then
  100. if tfm.get.room.objectList[ball].x < blueGoal.X + (blueGoal.L/2) and tfm.get.room.objectList[ball].x > blueGoal.X - (blueGoal.L/2) and tfm.get.room.objectList[ball].y > blueGoal.Y - (blueGoal.H/2) and tfm.get.room.objectList[ball].y < blueGoal.Y + (blueGoal.H/2) then
  101.  
  102. redPoint = redPoint + 1
  103. tfm.exec.removeObject(ball)
  104. ui.updateTextArea(2, '<p align="center">' .. redPoint .. '</p>', nil)
  105. for i, v in pairs(tfm.get.room.playerList) do
  106. expertMove(i)
  107. if teams[i] == "B" then
  108. tfm.exec.playEmote(i,2, nil)
  109. elseif teams[i] == "R" then
  110. tfm.exec.playEmote(i,9, nil)
  111. end
  112. end
  113. ball = tfm.exec.addShamanObject(604, 800, 200, 0, -1, -10, false)
  114. end
  115. if tfm.get.room.objectList[ball].x < redGoal.X + (redGoal.L/2) and tfm.get.room.objectList[ball].x > redGoal.X - (redGoal.L/2) and tfm.get.room.objectList[ball].y > redGoal.Y - (redGoal.H/2) and tfm.get.room.objectList[ball].y < redGoal.Y + (redGoal.H/2) then
  116.  
  117. bluePoint = bluePoint + 1
  118. tfm.exec.removeObject(ball)
  119. ui.updateTextArea(1, '<p align="center">' .. bluePoint .. '</p>', nil)
  120. for i, v in pairs(tfm.get.room.playerList) do
  121. expertMove(i)
  122. if teams[i] == "R" then
  123. tfm.exec.playEmote(i,2, nil)
  124. elseif teams[i] == "B" then
  125. tfm.exec.playEmote(i,9, nil)
  126. end
  127. end
  128. ball = tfm.exec.addShamanObject(604, 800, 200, 0, 1, -10, false)
  129. end
  130. end
  131.  
  132. if tfm.get.room.objectList[ball].x < blueFall.X + (blueFall.L/2) and tfm.get.room.objectList[ball].x > blueFall.X - (blueFall.L/2) and tfm.get.room.objectList[ball].y > blueFall.Y - (blueFall.H/2) and tfm.get.room.objectList[ball].y < blueFall.Y + (blueFall.H/2) then
  133.  
  134. tfm.exec.removeObject(ball)
  135.  
  136. for i, v in pairs(tfm.get.room.playerList) do
  137. expertMove(i)
  138. if teams[i] == "R" then
  139. tfm.exec.playEmote(i,4, nil)
  140.  
  141. end
  142. ball = tfm.exec.addShamanObject(604, 800, 200, 0, 0, -10, false)
  143. end
  144. end
  145. if tfm.get.room.objectList[ball].x < redFall.X + (redFall.L/2) and tfm.get.room.objectList[ball].x > redFall.X - (redFall.L/2) and tfm.get.room.objectList[ball].y > redFall.Y - (redFall.H/2) and tfm.get.room.objectList[ball].y < redFall.Y + (redFall.H/2) then
  146.  
  147. tfm.exec.removeObject(ball)
  148.  
  149. for i, v in pairs(tfm.get.room.playerList) do
  150. expertMove(i)
  151. if teams[i] == "B" then
  152. tfm.exec.playEmote(i,4, nil)
  153.  
  154. end
  155. ball = tfm.exec.addShamanObject(604, 800, 200, 0, 0, -10, false)
  156. end
  157. end
  158. if bluePoint > 4 then
  159. start()
  160. end
  161. if redPoint > 4 then
  162. start()
  163. end
  164. end
  165. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement