Guest User

TFM BRIDGE - 1.3

a guest
Sep 1st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.83 KB | None | 0 0
  1. -- variaveis
  2. listaNegra = {}
  3. tfm.exec.disableAutoScore ( true )
  4. tfm.exec.disableAutoShaman ( true )
  5. tfm.exec.disableAutoTimeLeft ( true )
  6. tfm.exec.disableMortCommand ( true )
  7. tfm.exec.setGameTime ( 300, true )
  8. tfm.exec.disableAutoNewGame ( true )
  9. tfm.exec.disableAfkDeath ( true )
  10. bombTime = {}
  11. bombX = {}
  12. bombY = {}
  13.  
  14. desgasteT = {}
  15. desgasteX = {}
  16. desgasteY = {}
  17.  
  18. necroX = {}
  19. necroY = {}
  20.  
  21. info = { pisos={},
  22.          coins={},
  23.          gTime={}}
  24. shop={ [1] = {},
  25.        [2] = {},
  26.        [3] = {},
  27.        [4] = {}}
  28.  
  29. onTimer = {}
  30. onTimerPos = {}
  31. --rotação de mapas v
  32. mapas = {"@7375532", "@7376059", "@7376057", "@7377575", "@7395456", "@7416636", "@7415964", "@7474400", "@7472960", "@7475044"}
  33. -- resto v
  34. function rotacao ()
  35.     local choicedMap = mapas[math.random(1, #mapas)]
  36.     tfm.exec.newGame ( choicedMap, false )
  37.     tfm.exec.setGameTime ( 300, true )
  38.     ui.setMapName ( "<b>Bridge</b> - "..choicedMap )
  39. end
  40. function clearNecro (n)
  41.  necroX[tfm.get.room.playerList[n].id] = -5000
  42. end
  43. function eventNewGame ()
  44.     tfm.exec.setGameTime ( 300, true )
  45.     table.foreach(tfm.get.room.playerList, clearNecro)
  46. end
  47. -- pisos especiais vv
  48. --timer vv
  49.  
  50. function timer (n)
  51.     bomba (n)
  52.     desgaste (n)
  53.     info.gTime[tfm.get.room.playerList[n].id] =  info.gTime[tfm.get.room.playerList[n].id] - 1
  54.     if  (info.gTime[tfm.get.room.playerList[n].id] == 0) then
  55.         tfm.exec.removePhysicObject(tfm.get.room.playerList[n].id)
  56.     end
  57. end
  58. --bomba vv
  59. function bomba (n)
  60.     bombTime[tfm.get.room.playerList[n].id] = bombTime[tfm.get.room.playerList[n].id] - 1
  61.     bomba2 (bombX[tfm.get.room.playerList[n].id], bombY[tfm.get.room.playerList[n].id], n)
  62. end
  63. function bomba2 (bombX, bombY, n)
  64.     if (bombTime[tfm.get.room.playerList[n].id] == 6) then
  65.         tfm.exec.displayParticle ( 9, bombX, bombY, -1, 0, 0, 0, nil)
  66.         tfm.exec.displayParticle ( 9, bombX, bombY, 1, 0, 0, 0, nil)
  67.         tfm.exec.displayParticle ( 9, bombX, bombY, 0, 1, 0, 0, nil)
  68.         tfm.exec.displayParticle ( 9, bombX, bombY, 0, -1, 0, 0, nil)
  69.     elseif (bombTime[tfm.get.room.playerList[n].id]  == 4) then
  70.         tfm.exec.displayParticle ( 2, bombX, bombY, -1, 0, 0, 0, nil)
  71.         tfm.exec.displayParticle ( 2, bombX, bombY, 1, 0, 0, 0, nil)
  72.         tfm.exec.displayParticle ( 2, bombX, bombY, 0, 1, 0, 0, nil)
  73.         tfm.exec.displayParticle ( 2, bombX, bombY, 0, -1, 0, 0, nil)
  74.     elseif (bombTime[tfm.get.room.playerList[n].id]  == 2) then
  75.         tfm.exec.displayParticle ( 13, bombX, bombY, -1, 0, 0, 0, nil)
  76.         tfm.exec.displayParticle ( 13, bombX, bombY, 1, 0, 0, 0, nil)
  77.         tfm.exec.displayParticle ( 13, bombX, bombY, 0, 1, 0, 0, nil)
  78.         tfm.exec.displayParticle ( 13, bombX, bombY, 0, -1, 0, 0, nil)
  79.     elseif (bombTime[tfm.get.room.playerList[n].id]  == 0) then
  80.         tfm.exec.displayParticle ( 3, bombX, bombY, -1, 0, 0, 0, nil)
  81.         tfm.exec.displayParticle ( 3, bombX, bombY, 1, 0, 0, 0, nil)
  82.         tfm.exec.displayParticle ( 3, bombX, bombY, 0, 1, 0, 0, nil)
  83.         tfm.exec.displayParticle ( 3, bombX, bombY, 0, -1, 0, 0, nil)
  84.         tfm.exec.explosion ( bombX, bombY, 10000, 200, true )
  85.         tfm.exec.removePhysicObject ( tfm.get.room.playerList[n].id )
  86.         listaNegra[tfm.get.room.playerList[n].id] = 1
  87.     end
  88. end
  89.  
  90. function string.nick(name)
  91.     local var = name:lower():gsub('%a', string.upper, 1)
  92.     for i, v in pairs(tfm.get.room.playerList) do
  93.         if i:find(var) then
  94.             return i
  95.         end
  96.     end
  97. end
  98.  
  99. -- desgaste vv
  100. function desgaste (n)
  101.     if desgasteT[tfm.get.room.playerList[n].id] >= 10 then
  102.         desgasteT[tfm.get.room.playerList[n].id] = desgasteT[tfm.get.room.playerList[n].id] - 2
  103.         tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].id, desgasteX[tfm.get.room.playerList[n].id], desgasteY[tfm.get.room.playerList[n].id], { type = 12, width = desgasteT[tfm.get.room.playerList[n].id], height = desgasteT[tfm.get.room.playerList[n].id], foreground = false, friction = 0.2, restitution = 0.1, angle = 0, color=0x573600, miceCollision = true, groundCollision = false})
  104.         tfm.exec.displayParticle ( 3, desgasteX[tfm.get.room.playerList[n].id], desgasteY[tfm.get.room.playerList[n].id], 0, 0, 0, 0.1, nil )
  105.     end
  106.     if desgasteT[tfm.get.room.playerList[n].id] >= 20 then
  107.         tfm.exec.displayParticle ( 3, desgasteX[tfm.get.room.playerList[n].id] - 10, desgasteY[tfm.get.room.playerList[n].id], 0, 0, 0, 0.1, nil )
  108.         tfm.exec.displayParticle ( 3, desgasteX[tfm.get.room.playerList[n].id] + 10, desgasteY[tfm.get.room.playerList[n].id], 0, 0, 0, 0.1, nil )
  109.     elseif (desgasteT == 0) then
  110.         tfm.exec.removePhysicObject (tfm.get.room.playerList[n].id)
  111.     end
  112. end
  113.  
  114. rotacao ()
  115. posicaoX = 1
  116. posicaoY = 2
  117. tipo = 0
  118. invocador = "opa"
  119.  
  120. function invocarPiso (nome)
  121.     if  (listaNegra[tfm.get.room.playerList[nome].id] == 1) then
  122.         desgasteT[tfm.get.room.playerList[nome].id] = 0
  123.         tfm.exec.removePhysicObject ( tfm.get.room.playerList[nome].id )
  124.         frictable = {[0]= 0.3, 0, 0, 0, 10, 0.3, 0.3, 0.3, 0.3, 0, 0.3, 0.3, 0.3, 0.3}
  125.         resttable = {[0]= 0.2, 0.2, 1.2, 20, 0.2, 0.2, 0.2, 0.2, 0.2, 0, 0.2, 0.2, 0.2, 0.2}
  126.         local grounds = info.pisos[tfm.get.room.playerList[nome].id]
  127.         posicaoX = tfm.get.room.playerList[nome].x
  128.         posicaoY = tfm.get.room.playerList[nome].y + 14
  129.         info.gTime[tfm.get.room.playerList[nome].id] = 10
  130.         tipo = grounds[math.random(1, #grounds)]
  131.         if (tipo == 100) then
  132.             bombTime[tfm.get.room.playerList[nome].id] = 7
  133.             bombX[tfm.get.room.playerList[nome].id] = posicaoX
  134.             bombY[tfm.get.room.playerList[nome].id] = posicaoY
  135.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[nome].id, posicaoX, posicaoY, { type = 12, width = 24, height = 24, foreground = false, friction = 0.2, restitution = 0.1, angle = 0, color=0x000000, miceCollision = true, groundCollision = false})
  136.             listaNegra[tfm.get.room.playerList[nome].id] = 0
  137.             tfm.exec.displayParticle ( 37, posicaoX, posicaoY, 0, 0, 0, 0, nil)
  138.         elseif (tipo == 200) then
  139.             desgasteT[tfm.get.room.playerList[nome].id] = 24
  140.             desgasteX[tfm.get.room.playerList[nome].id] = posicaoX
  141.             desgasteY[tfm.get.room.playerList[nome].id] = posicaoY
  142.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[nome].id, posicaoX, posicaoY, { type = 12, width = 24, height = 24, foreground = false, friction = 0.2, restitution = 0.1, angle = 0, color=0x573600, miceCollision = true, groundCollision = false})
  143.         elseif (tipo == 300) then
  144.             necroX[tfm.get.room.playerList[nome].id] = posicaoX
  145.             necroY[tfm.get.room.playerList[nome].id] = posicaoY
  146.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[nome].id, posicaoX, posicaoY, { type = 12, width = 24, height = 24, foreground = false, friction = 0.2, restitution = 0.1, angle = 0, color=0x3c1960, miceCollision = true, groundCollision = false})
  147.             tfm.exec.displayParticle ( 1, posicaoX, posicaoY, -1, 0, 0, 0, nil)
  148.             tfm.exec.displayParticle ( 1, posicaoX, posicaoY, 1, 0, 0, 0, nil)
  149.             tfm.exec.displayParticle ( 1, posicaoX, posicaoY, 0, 1, 0, 0, nil)
  150.             tfm.exec.displayParticle ( 1, posicaoX, posicaoY, 0, -1, 0, 0, nil)
  151.         elseif (tipo == 13) then
  152.             fric = math.random(frictable[0], frictable[13])
  153.             rest = math.random(resttable[0], resttable[13])
  154.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[nome].id, posicaoX, posicaoY, { type = tipo, width = 14, height = 14, foreground = false, friction = fric, restitution = rest, angle = 0, color=0x5E80B3, miceCollision = true, groundCollision = false})
  155.         elseif (tipo == 14) then
  156.             fric = math.random(frictable[0], frictable[13])
  157.             rest = math.random(resttable[0], resttable[13])
  158.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[nome].id, posicaoX, posicaoY, { type = tipo, width = 24, height = 24, foreground = false, friction = fric, restitution = rest, angle = 0, miceCollision = true, groundCollision = false})
  159.         else
  160.             fric = frictable[tipo]
  161.             rest = resttable[tipo]
  162.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[nome].id, posicaoX, posicaoY, { type = tipo, width = 24, height = 24, foreground = false, friction = fric, restitution = rest, angle = 0, miceCollision = true, groundCollision = false})
  163.         end
  164.     if not tipo == 300 then
  165.         tfm.exec.displayParticle ( 3, posicaoX, posicaoY, -1, 0, 0, 0, nil)
  166.         tfm.exec.displayParticle ( 3, posicaoX, posicaoY, 1, 0, 0, 0, nil)
  167.         tfm.exec.displayParticle ( 3, posicaoX, posicaoY, 0, 1, 0, 0, nil)
  168.         tfm.exec.displayParticle ( 3, posicaoX, posicaoY, 0, -1, 0, 0, nil)
  169.     end
  170.     end
  171.  end
  172. function eventKeyboard ( jogador, codigoTecla, pressionando, posicaoX, posicaoY )
  173.     if (codigoTecla == 32) then
  174.         invocarPiso (jogador)
  175.     end
  176. end
  177. function eventPlayerGetCheese (n)
  178.     giveCoins (n, 15)
  179. end
  180. function eventPlayerDied (jogador)
  181.     if necroX[tfm.get.room.playerList[jogador].id] == -5000 then
  182.         tfm.exec.respawnPlayer (jogador)
  183.     else
  184.         tfm.exec.respawnPlayer (jogador)
  185.         tfm.exec.movePlayer ( jogador, necroX[tfm.get.room.playerList[jogador].id], necroY[tfm.get.room.playerList[jogador].id], false, 0, 0, 0 )
  186.         tfm.exec.addPhysicObject ( tfm.get.room.playerList[jogador].id, necroX[tfm.get.room.playerList[jogador].id], necroY[tfm.get.room.playerList[jogador].id] + 15, { type = 12, width = 24, height = 24, foreground = false, friction = 0.2, restitution = 0.1, angle = 0, color=0x3c1960, miceCollision = true, groundCollision = false})
  187.         info.gTime[tfm.get.room.playerList[jogador].id] = 10
  188.         tfm.exec.displayParticle ( 1, necroX[tfm.get.room.playerList[jogador].id], necroY[tfm.get.room.playerList[jogador].id] -5, -1, 0, 0, 0, nil)
  189.         tfm.exec.displayParticle ( 1, necroX[tfm.get.room.playerList[jogador].id], necroY[tfm.get.room.playerList[jogador].id] -5, 1, 0, 0, 0, nil)
  190.         tfm.exec.displayParticle ( 1, necroX[tfm.get.room.playerList[jogador].id], necroY[tfm.get.room.playerList[jogador].id] -5, 0, 1, 0, 0, nil)
  191.         tfm.exec.displayParticle ( 1, necroX[tfm.get.room.playerList[jogador].id], necroY[tfm.get.room.playerList[jogador].id] -5, 0, -1, 0, 0, nil)   
  192.         necroX[tfm.get.room.playerList[jogador].id] = -5000
  193.     end
  194. end
  195. -- comandos v
  196. system.disableChatCommandDisplay ( "start", true )
  197. system.disableChatCommandDisplay ( "r", true )
  198. system.disableChatCommandDisplay ( "remove", true )
  199. system.disableChatCommandDisplay ( "skip", true )
  200.  
  201. function eventChatCommand ( jogador, comando )
  202.     if comando == "start" then
  203.         start(jogador)
  204.     elseif comando == "r" then
  205.         tfm.exec.killPlayer(jogador)
  206.         tfm.exec.respawnPlayer(jogador)
  207.     elseif comando == "remove" then
  208.         tfm.exec.removePhysicObject(tfm.get.room.playerList[jogador].id)
  209.     end
  210.     if jogador == "Tempo#5571" then
  211.         if (comando == "skip") then
  212.             rotacao()
  213.         elseif comando:sub(1,4) == "rich" then
  214.             local player = string.nick(comando:sub(6))
  215.             giveCoins(player, 10000)
  216.         elseif comando:sub(1,3) == "map" then
  217.             local map = (comando:sub(5))
  218.             tfm.exec.newGame(rotacao[map], false)
  219.         end
  220.     end
  221. end
  222.  
  223. function eventPlayerWon ( jogador, tempo, tempoRespawn )
  224.     tfm.exec.respawnPlayer ( jogador )
  225.     giveCoins (jogador, 50)
  226. end
  227.  
  228.  
  229. --ajuda v
  230.  
  231. function ajuda (clicker)
  232.     ui.addPopup ( 76, 0, "<html><b><font color='#BABD2F'><p align='center'>Ajuda</p></font></b><br/><b><font color='#009D9D'>- Instruções:</font></b><br/><br/><font color='#6C77C1'>Aperte espaço para invocar os pisos. Seu objetivo é construir uma <b>ponte</b> até o queijo, e depois outra para retornar. Você pode fazer isso com um amigo ou sozinho, mas alguns mapas são difíceis de se completar sem ajuda.</font><br/><br/><b><font color='#009D9D'>- Comandos:</font></b><br/><br/><font color='#6C77C1'>!r - Usado para respawnar</font><br/><font color='#6C77C1'>!remove - Remove o seu piso</font><br/><font color='#6C77C1'>!skip - Pula o mapa</font></html>", clicker, 200, 110, 400, true )
  233. end
  234.  
  235. ----------------------------------------- Loja v -----------------------------------------
  236.  
  237. function execPurchase (n, c, shopId)
  238.     shop[shopId][tfm.get.room.playerList[n].id] = shop[shopId][tfm.get.room.playerList[n].id] + 1
  239.     giveCoins(n, 0 - c)
  240.     openShop(n)
  241. end
  242.  
  243. function giveCoins (n, q)
  244.     info.coins[tfm.get.room.playerList[n].id] = info.coins[tfm.get.room.playerList[n].id] + q
  245.     ui.addTextArea ( 74 + tfm.get.room.playerList[n].id, "<b><font color='#ffc700'> © </font>Moedas: </b>"..info.coins[tfm.get.room.playerList[n].id], n, 95, 376, 0, 0, 0x324650, 0x213540, 1, true)
  246. end
  247.  
  248. function openShop (n)
  249.     ui.addTextArea (75 + tfm.get.room.playerList[n].id, "<b><p align='right'><font color='#C83E3E'><a href='event:closeShop'>X</a></font></p><p align='center'><font color='#ffc700' size='15'>Loja:</font></p></b><br><br><font color='#e51414'>Vanilla</font>          - "..shop[1][tfm.get.room.playerList[n].id].."/5  -  <font color='#78b72d'><i>Aumenta as chances do piso de grama.</i></font>                 -  <font color='#2d66b7'><a href='event:shop1'> 30 Moedas</a></font><br><font color='#e51414'>Pacífico</font>         - "..shop[2][tfm.get.room.playerList[n].id].."/1  -  <font color='#78b72d'><i>Você não irá mais criar pisos de lava.</i></font>                    -  <font color='#2d66b7'><a href='event:shop2'> 50 Moedas</a></font><br><font color='#e51414'>Sobremesa</font>    - "..shop[3][tfm.get.room.playerList[n].id].."/5  -  <font color='#78b72d'><i>Aumenta as chances do piso de chocolate.</i></font>             -  <font color='#2d66b7'><a href='event:shop3'> 40 Moedas</a></font><br><font color='#e51414'>Necromancer</font> - "..shop[4][tfm.get.room.playerList[n].id].."/1  -  <i><font color='#78b72d'>Ao comprar, você poderá criar pisos </font><font color='#3c1960'>Necromancer</font><font color='#78B72D'>.</font></i> -  <font color='#2d66b7'><a href='event:shop4'> 80 Moedas</a></font>", n, 150, 100, 500, 200, 0x324650, 0x324650, 1, true )
  250. end
  251.  
  252. function eventTextAreaCallback ( id, jogador, c )
  253.     if (id == 1) then
  254.         ajuda (jogador)
  255.     elseif (id == 2) then
  256.         openShop (jogador)
  257.     elseif (c == 'closeShop') then
  258.         ui.removeTextArea (75 + tfm.get.room.playerList[jogador].id, jogador)
  259.     elseif (c == 'shop1') then
  260.         if shop[1][tfm.get.room.playerList[jogador].id] <= 4 then
  261.             if info.coins[tfm.get.room.playerList[jogador].id] >= 30 then
  262.                 inserirPiso (6, 2, jogador)
  263.                 execPurchase (jogador, 30, 1)
  264.             end
  265.         end
  266.     elseif (c == 'shop2') then
  267.         if shop[2][tfm.get.room.playerList[jogador].id] <= 0 then
  268.             if info.coins[tfm.get.room.playerList[jogador].id] >= 50 then
  269.                 removerPiso (3, 0, jogador)
  270.                 execPurchase (jogador, 50, 2)
  271.             end
  272.         end
  273.     elseif (c == 'shop3') then
  274.         if shop[3][tfm.get.room.playerList[jogador].id] <= 4 then
  275.             if info.coins[tfm.get.room.playerList[jogador].id] >= 40 then
  276.                 inserirPiso (4, 2, jogador)
  277.                 execPurchase (jogador, 40, 3)
  278.             end
  279.         end
  280.     elseif (c == 'shop4') then
  281.         if shop[4][tfm.get.room.playerList[jogador].id] <= 0 then
  282.             if info.coins[tfm.get.room.playerList[jogador].id] >= 80 then
  283.                 inserirPiso (300, 1, jogador)
  284.                 execPurchase (jogador, 80, 4)
  285.             end
  286.         end
  287.     end
  288. end
  289.  
  290. function inserirPiso (id, q, n)
  291.     local gInserted = 0
  292.     repeat
  293.         table.insert(info.pisos[tfm.get.room.playerList[n].id], id)
  294.         gInserted = gInserted + 1
  295.     until gInserted == q
  296. end
  297.  
  298. function removerPiso (id, q, n)
  299.     local numb = #info.pisos[tfm.get.room.playerList[n].id]
  300.     local gRemoved = 0
  301.     if q == 0 then
  302.         repeat
  303.         if info.pisos[tfm.get.room.playerList[n].id][numb] == id then
  304.             table.remove(info.pisos[tfm.get.room.playerList[n].id], numb)
  305.         end
  306.         numb = numb - 1
  307.         until numb == 0
  308.     else
  309.         repeat
  310.         if info.pisos[tfm.get.room.playerList[n].id][numb] == id then
  311.             table.remove(info.pisos[tfm.get.room.playerList[n].id], numb)
  312.             gRemoved = gRemoved + 1
  313.         end
  314.         numb = numb - 1
  315.         until gRemoved == q or numb == 0
  316.     end
  317. end
  318. --------------------------------------------------------------------------
  319. function eventNewPlayer ( jogador )
  320.     system.bindKeyboard ( jogador , 32, true, true)
  321.     system.bindKeyboard ( jogador , 65, true, true)
  322.     tfm.exec.respawnPlayer ( jogador )
  323.     listaNegra[tfm.get.room.playerList[jogador].id] = 1
  324.     ui.addTextArea ( 1, "<a href='event:click'>Ajuda", nil, 6, 376, 0, 0, 0x324650, 0x213540, 1, true)
  325.     ui.addTextArea ( 2, "<a href='event:click'>Loja", nil, 55, 376, 0, 0, 0x324650, 0x213540, 1, true)
  326.     bombTime[tfm.get.room.playerList[jogador].id] = -1
  327.     bombX[tfm.get.room.playerList[jogador].id] = -1
  328.     bombY[tfm.get.room.playerList[jogador].id] = -1
  329.     desgasteT[tfm.get.room.playerList[jogador].id] = 0
  330.     desgasteX[tfm.get.room.playerList[jogador].id] = 0
  331.     desgasteY[tfm.get.room.playerList[jogador].id] = 0
  332.     necroX[tfm.get.room.playerList[jogador].id] = -5000
  333.     info.pisos[tfm.get.room.playerList[jogador].id] = {0, 1, 2, 4, 5, 6, 7, 10, 11, 13, 14, 1, 2, 3, 4, 5, 6, 7, 10, 11, 13, 14, 100, 200}
  334.     info.coins[tfm.get.room.playerList[jogador].id] = 0
  335.     info.gTime[tfm.get.room.playerList[jogador].id] = 0
  336.     ui.addTextArea ( 74 + tfm.get.room.playerList[jogador].id, "<b><font color='#ffc700'> ©</font> Moedas: </b>"..info.coins[tfm.get.room.playerList[jogador].id], jogador, 95, 376, 0, 0, 0x324650, 0x213540, 1, true)
  337.     local shopTabQ = 0
  338.     repeat
  339.         shopTabQ = shopTabQ + 1
  340.         shop[shopTabQ][tfm.get.room.playerList[jogador].id] = 0
  341.     until shopTabQ == 4
  342.     end
  343.     table.foreach(tfm.get.room.playerList, eventNewPlayer)
  344. --eventLoop v
  345. function eventLoop(tempoAtual, tempoRestante)
  346.     if (tempoRestante <= 0) then
  347.         rotacao()
  348.     end
  349.     table.foreach(tfm.get.room.playerList, timer)
  350. end
Add Comment
Please, Sign In to add comment