Advertisement
Guest User

TFM BRIDGE - 1.4

a guest
Sep 2nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.23 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.  
  11. groundsInfo = {tempo = {}, x = {}, y = {}, special={}, necroActive={}, necroX={}, necroY={}}
  12.  
  13. info = { pisos={},
  14.          coins={},
  15.          gTime={}}
  16. shop={ [1] = {},
  17.        [2] = {},
  18.        [3] = {},
  19.        [4] = {}}
  20.  
  21. onTimer = {}
  22. onTimerPos = {}
  23. --rotação de mapas v
  24. mapas = {"@7375532", "@7376059", "@7376057", "@7377575", "@7395456", "@7416636", "@7474400", "@7472960", "@7475044"}
  25. -- resto v
  26. function rotacao ()
  27.     local choicedMap = mapas[math.random(1, #mapas)]
  28.     tfm.exec.newGame ( choicedMap, false )
  29.     tfm.exec.setGameTime ( 300, true )
  30.     ui.setMapName ( "<b>Bridge</b> - "..choicedMap )
  31. end
  32. function clearInfo (n)
  33.     groundsInfo.necroActive[n] = false
  34.     groundsInfo.special[n] = nil
  35.     groundsInfo.tempo[n] = 0
  36.     tfm.exec.removePhysicObject(tfm.get.room.playerList[n].id)
  37. end
  38. function eventNewGame ()
  39.     tfm.exec.setGameTime ( 300, true )
  40.     table.foreach(tfm.get.room.playerList, clearInfo)
  41.     if tfm.get.room.xmlMapInfo.author:sub(#tfm.get.room.xmlMapInfo.author-4, #tfm.get.room.xmlMapInfo.author-4) == "#" then
  42.         tfm.exec.setUIMapName("<font color='#98E2EB'><b>Bridge</b> - "..tfm.get.room.currentMap.." - <font color='#009D9D'><b>".. tfm.get.room.xmlMapInfo.author:sub(1, #tfm.get.room.xmlMapInfo.author - 5).."<font color='#606090' size='8'>".. tfm.get.room.xmlMapInfo.author:sub(#tfm.get.room.xmlMapInfo.author - 4, #tfm.get.room.xmlMapInfo.author).."</font></b></font>")
  43.     else
  44.         tfm.exec.setUIMapName("<font color='#98E2EB'><b>Bridge</b> - "..tfm.get.room.currentMap.." - <font color='#009D9D'><b>".. tfm.get.room.xmlMapInfo.author.."</b></font>")
  45.     end
  46. end
  47. -- pisos especiais vv
  48. --timer vv
  49.  
  50. function timer (n)
  51.     if groundsInfo.special[n] == "bomba" then
  52.         bomba2 (groundsInfo.x[n], groundsInfo.y[n], n)
  53.     elseif groundsInfo.special[n] == "desgaste" then
  54.         desgaste (n)
  55.     end
  56.     groundsInfo.tempo[n] =  groundsInfo.tempo[n] - 1
  57.     if  (groundsInfo.tempo[n] <= 0) then
  58.         tfm.exec.removePhysicObject(tfm.get.room.playerList[n].id)
  59.     end
  60. end
  61. --bomba vv
  62. function bomba2 (bombX, bombY, n)
  63.     if groundsInfo.tempo[n] == 6 then
  64.         tfm.exec.displayParticle ( 22, bombX, bombY, -1, 0, 0, 0, nil)
  65.         tfm.exec.displayParticle ( 22, bombX, bombY, 1, 0, 0, 0, nil)
  66.         tfm.exec.displayParticle ( 22, bombX, bombY, 0, 1, 0, 0, nil)
  67.         tfm.exec.displayParticle ( 22, bombX, bombY, 0, -1, 0, 0, nil)
  68.     elseif groundsInfo.tempo[n] == 4 then
  69.         tfm.exec.displayParticle ( 24, bombX, bombY, -1, 0, 0, 0, nil)
  70.         tfm.exec.displayParticle ( 24, bombX, bombY, 1, 0, 0, 0, nil)
  71.         tfm.exec.displayParticle ( 24, bombX, bombY, 0, 1, 0, 0, nil)
  72.         tfm.exec.displayParticle ( 24, bombX, bombY, 0, -1, 0, 0, nil)
  73.     elseif groundsInfo.tempo[n] == 2 then
  74.         tfm.exec.displayParticle ( 21, bombX, bombY, -1, 0, 0, 0, nil)
  75.         tfm.exec.displayParticle ( 21, bombX, bombY, 1, 0, 0, 0, nil)
  76.         tfm.exec.displayParticle ( 21, bombX, bombY, 0, 1, 0, 0, nil)
  77.         tfm.exec.displayParticle ( 21, bombX, bombY, 0, -1, 0, 0, nil)
  78.     elseif groundsInfo.tempo[n] == 0 then
  79.         tfm.exec.displayParticle ( 3, bombX, bombY, -1, 0, 0, 0, nil)
  80.         tfm.exec.displayParticle ( 3, bombX, bombY, 1, 0, 0, 0, nil)
  81.         tfm.exec.displayParticle ( 3, bombX, bombY, 0, 1, 0, 0, nil)
  82.         tfm.exec.displayParticle ( 3, bombX, bombY, 0, -1, 0, 0, nil)
  83.         tfm.exec.explosion ( bombX, bombY, 10000, 200, true )
  84.         tfm.exec.removePhysicObject ( tfm.get.room.playerList[n].id )
  85.         listaNegra[n] = 1
  86.     end
  87. end
  88.  
  89. function string.nick(name)
  90.     local var = name:lower():gsub('%a', string.upper, 1)
  91.     for i, v in pairs(tfm.get.room.playerList) do
  92.         if i:find(var) then
  93.             return i
  94.         end
  95.     end
  96. end
  97.  
  98. -- desgaste vv
  99. function desgaste (n)
  100.     if groundsInfo.tempo[n] >= 10 then
  101.         groundsInfo.tempo[n] = groundsInfo.tempo[n] - 2
  102.         tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].id, groundsInfo.x[n], groundsInfo.y[n], { type = 12, width = groundsInfo.tempo[n], height = groundsInfo.tempo[n], foreground = false, friction = 0.2, restitution = 0.1, angle = 0, color=0x573600, miceCollision = true, groundCollision = false})
  103.         tfm.exec.displayParticle ( 3, groundsInfo.x[n], groundsInfo.y[n], 0, 0, 0, 0.1, nil )
  104.     end
  105.     if groundsInfo.tempo[n] >= 20 then
  106.         tfm.exec.displayParticle ( 3, groundsInfo.x[n] - 10, groundsInfo.y[n], 0, 0, 0, 0.1, nil )
  107.         tfm.exec.displayParticle ( 3, groundsInfo.x[n] + 10, groundsInfo.y[n], 0, 0, 0, 0.1, nil )
  108.     elseif (desgasteT == 0) then
  109.         tfm.exec.removePhysicObject (tfm.get.room.playerList[n].id)
  110.     end
  111. end
  112.  
  113. rotacao ()
  114.  
  115. function invocarPiso (n)
  116.     if  (listaNegra[n] == 1) then
  117.         groundsInfo.special[n] = nil
  118.         groundsInfo.tempo[n] = 12
  119.         tfm.exec.removePhysicObject ( tfm.get.room.playerList[n].id )
  120.         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}
  121.         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}
  122.         local grounds = info.pisos[n]
  123.         local posicaoX = tfm.get.room.playerList[n].x
  124.         local posicaoY = tfm.get.room.playerList[n].y + 14
  125.         groundsInfo.x[n] = posicaoX
  126.         groundsInfo.y[n] = posicaoY
  127.         info.gTime[n] = 10
  128.         local tipo = grounds[math.random(1, #grounds)]
  129.         if (tipo == 100) then
  130.             groundsInfo.special[n] = "bomba"
  131.             groundsInfo.tempo[n] = 7
  132.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].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})
  133.             listaNegra[n] = 0
  134.             tfm.exec.displayParticle ( 37, posicaoX, posicaoY, 0, 0, 0, 0, nil)
  135.         elseif (tipo == 200) then
  136.             groundsInfo.special[n] = "desgaste"
  137.             groundsInfo.tempo[n] = 24
  138.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].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})
  139.         elseif (tipo == 300) then
  140.             groundsInfo.special[n] = "necro"
  141.             groundsInfo.necroActive[n] = true
  142.             groundsInfo.necroX[n] = posicaoX
  143.             groundsInfo.necroY[n] = posicaoY
  144.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].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})
  145.             tfm.exec.displayParticle ( 1, posicaoX, posicaoY, -1, 0, 0, 0, nil)
  146.             tfm.exec.displayParticle ( 1, posicaoX, posicaoY, 1, 0, 0, 0, nil)
  147.             tfm.exec.displayParticle ( 1, posicaoX, posicaoY, 0, 1, 0, 0, nil)
  148.             tfm.exec.displayParticle ( 1, posicaoX, posicaoY, 0, -1, 0, 0, nil)
  149.         elseif (tipo == 13) then
  150.             fric = math.random(frictable[0], frictable[13])
  151.             rest = math.random(resttable[0], resttable[13])
  152.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].id, posicaoX, posicaoY, { type = tipo, width = 14, height = 14, foreground = false, friction = fric, restitution = rest, angle = 0, color=0x5E80B3, miceCollision = true, groundCollision = false})
  153.         elseif (tipo == 14) then
  154.             fric = math.random(frictable[0], frictable[13])
  155.             rest = math.random(resttable[0], resttable[13])
  156.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].id, posicaoX, posicaoY, { type = tipo, width = 24, height = 24, foreground = false, friction = fric, restitution = rest, angle = 0, miceCollision = true, groundCollision = false})
  157.         else
  158.             fric = frictable[tipo]
  159.             rest = resttable[tipo]
  160.             tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].id, posicaoX, posicaoY, { type = tipo, width = 24, height = 24, foreground = false, friction = fric, restitution = rest, angle = 0, miceCollision = true, groundCollision = false})
  161.         end
  162.         if tipo ~= 300 then
  163.             tfm.exec.displayParticle ( 3, posicaoX, posicaoY, -1, 0, 0, 0, nil)
  164.             tfm.exec.displayParticle ( 3, posicaoX, posicaoY, 1, 0, 0, 0, nil)
  165.             tfm.exec.displayParticle ( 3, posicaoX, posicaoY, 0, 1, 0, 0, nil)
  166.             tfm.exec.displayParticle ( 3, posicaoX, posicaoY, 0, -1, 0, 0, nil)
  167.         end
  168.     end
  169. end
  170. function eventKeyboard ( n, codigoTecla, pressionando, posicaoX, posicaoY )
  171.     if (codigoTecla == 32) then
  172.         invocarPiso (n)
  173.     end
  174. end
  175. function eventPlayerGetCheese (n)
  176.     giveCoins (n, 15)
  177. end
  178. function eventPlayerDied (n)
  179.     if groundsInfo.necroActive[n] then
  180.         tfm.exec.respawnPlayer (n)
  181.         tfm.exec.movePlayer ( n, groundsInfo.necroX[n], groundsInfo.necroY[n], false, 0, 0, 0 )
  182.         tfm.exec.addPhysicObject ( tfm.get.room.playerList[n].id, groundsInfo.necroX[n], groundsInfo.necroY[n] + 15, { type = 12, width = 24, height = 24, foreground = false, friction = 0.2, restitution = 0.1, angle = 0, color=0x3c1960, miceCollision = true, groundCollision = false})
  183.         groundsInfo.tempo[n] = 10
  184.         tfm.exec.displayParticle ( 1, groundsInfo.necroX[n], groundsInfo.necroY[n] -5, -1, 0, 0, 0, nil)
  185.         tfm.exec.displayParticle ( 1, groundsInfo.necroX[n], groundsInfo.necroY[n] -5, 1, 0, 0, 0, nil)
  186.         tfm.exec.displayParticle ( 1, groundsInfo.necroX[n], groundsInfo.necroY[n] -5, 0, 1, 0, 0, nil)
  187.         tfm.exec.displayParticle ( 1, groundsInfo.necroX[n], groundsInfo.necroY[n] -5, 0, -1, 0, 0, nil)   
  188.         groundsInfo.special[n] = nil
  189.         groundsInfo.necroActive[n] = false
  190.     else
  191.         tfm.exec.respawnPlayer (n)
  192.     end
  193. end
  194. -- comandos v
  195. system.disableChatCommandDisplay ( "start", true )
  196. system.disableChatCommandDisplay ( "r", true )
  197. system.disableChatCommandDisplay ( "remove", true )
  198. system.disableChatCommandDisplay ( "skip", true )
  199. system.disableChatCommandDisplay ( "map", true )
  200.  
  201. function eventChatCommand ( n, comando )
  202.     if comando == "start" then
  203.         start(n)
  204.     elseif comando == "r" then
  205.         tfm.exec.killPlayer(n)
  206.         tfm.exec.respawnPlayer(n)
  207.     elseif comando == "remove" then
  208.         tfm.exec.removePhysicObject(tfm.get.room.playerList[n].id)
  209.     end
  210.     if n == "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 = tonumber(comando:sub(5))
  218.             tfm.exec.newGame(mapas[map], false)
  219.         end
  220.     end
  221. end
  222.  
  223. function eventPlayerWon ( n, tempo, tempoRespawn )
  224.     tfm.exec.respawnPlayer ( n )
  225.     giveCoins (n, 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][n] = shop[shopId][n] + 1
  239.     giveCoins(n, 0 - c)
  240.     openShop(n)
  241. end
  242.  
  243. function giveCoins (n, q)
  244.     info.coins[n] = info.coins[n] + q
  245.     ui.addTextArea ( 74 + tfm.get.room.playerList[n].id, "<b><font color='#ffc700'> © </font>Moedas: </b>"..info.coins[n], 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][n].."/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][n].."/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][n].."/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][n].."/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, n, c )
  253.     if (id == 1) then
  254.         ajuda (n)
  255.     elseif (id == 2) then
  256.         openShop (n)
  257.     elseif (c == 'closeShop') then
  258.         ui.removeTextArea (75 + tfm.get.room.playerList[n].id, n)
  259.     elseif (c == 'shop1') then
  260.         if shop[1][n] <= 4 then
  261.             if info.coins[n] >= 30 then
  262.                 inserirPiso (6, 2, n)
  263.                 execPurchase (n, 30, 1)
  264.             end
  265.         end
  266.     elseif (c == 'shop2') then
  267.         if shop[2][n] <= 0 then
  268.             if info.coins[n] >= 50 then
  269.                 removerPiso (3, 0, n)
  270.                 execPurchase (n, 50, 2)
  271.             end
  272.         end
  273.     elseif (c == 'shop3') then
  274.         if shop[3][n] <= 4 then
  275.             if info.coins[n] >= 40 then
  276.                 inserirPiso (4, 2, n)
  277.                 execPurchase (n, 40, 3)
  278.             end
  279.         end
  280.     elseif (c == 'shop4') then
  281.         if shop[4][n] <= 0 then
  282.             if info.coins[n] >= 80 then
  283.                 inserirPiso (300, 1, n)
  284.                 execPurchase (n, 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[n], id)
  294.         gInserted = gInserted + 1
  295.     until gInserted == q
  296. end
  297.  
  298. function removerPiso (id, q, n)
  299.     local numb = #info.pisos[n]
  300.     local gRemoved = 0
  301.     if q == 0 then
  302.         repeat
  303.         if info.pisos[n][numb] == id then
  304.             table.remove(info.pisos[n], numb)
  305.         end
  306.         numb = numb - 1
  307.         until numb == 0
  308.     else
  309.         repeat
  310.         if info.pisos[n][numb] == id then
  311.             table.remove(info.pisos[n], 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 ( n )
  320.     system.bindKeyboard ( n , 32, true, true)
  321.     system.bindKeyboard ( n , 65, true, true)
  322.     tfm.exec.respawnPlayer ( n )
  323.     listaNegra[n] = 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.     groundsInfo.tempo[n] = 0
  327.     groundsInfo.special[n] = nil
  328.     groundsInfo.x[n] = 0
  329.     groundsInfo.y[n] = 0
  330.     groundsInfo.necroX[n] = 0
  331.     groundsInfo.necroY[n] = 0
  332.     info.pisos[n] = {0, 1, 2, 4, 5, 6, 7, 10, 11, 13, 14, 1, 2, 3, 4, 5, 6, 7, 10, 11, 13, 14, 100, 200}
  333.     info.coins[n] = 0
  334.     info.gTime[n] = 0
  335.     ui.addTextArea ( 74 + tfm.get.room.playerList[n].id, "<b><font color='#ffc700'> ©</font> Moedas: </b>"..info.coins[n], n, 95, 376, 0, 0, 0x324650, 0x213540, 1, true)
  336.     local shopTabQ = 0
  337.     repeat
  338.         shopTabQ = shopTabQ + 1
  339.         shop[shopTabQ][n] = 0
  340.     until shopTabQ == 4
  341. end
  342. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  343. --eventLoop v
  344. function eventLoop(tempoAtual, tempoRestante)
  345.     if (tempoRestante <= 0) then
  346.         rotacao()
  347.     end
  348.     table.foreach(tfm.get.room.playerList, timer)
  349. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement