Advertisement
Allounett_Deathmatic

Bubbles v1.1

Nov 25th, 2013
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.52 KB | None | 0 0
  1. baseXML = [[
  2. <C><P DS="y;90" Ca="" /><Z><S><S P="0,0,9999,0.2,0,0,0,0" L="800" o="0" H="10" v="3000" Y="110" T="12" X="400" /><S L="800" o="fffffffff" H="10" X="400" v="3000" Y="70" T="12" P="0,0,9999,0.2,0,0,0,0" /><S P="0,0,9999,0.2,0,0,0,0" L="50" o="0" X="400" Y="-200" T="12" H="10" /><S L="50" o="0" X="400" H="10" Y="-240" T="12" P="0,0,9999,0.2,0,0,0,0" /><S P="0,0,9999,0.2,90,0,0,0" L="50" o="0" H="10" Y="-220" T="12" X="430" /><S L="50" o="0" H="10" X="370" Y="-220" T="12" P="0,0,9999,0.2,90,0,0,0" /></S><D><DS Y="90" X="400" /></D><O /></Z></C>
  3. ]]
  4.  
  5. tfm.exec.disableAfkDeath(true)
  6. tfm.exec.disableAutoShaman(true)
  7. tfm.exec.disableAutoNewGame(true)
  8. tfm.exec.disableAutoScore(true)
  9. tfm.exec.disableAutoTimeLeft(true)
  10.  
  11. system.disableChatCommandDisplay("afk")
  12. --          jour      jour     crepuscule   aurore     nuages     colision  colision  colision    nocturne     noel
  13. maps = {"@4535536","@4535536","@4533657","@4535757","@4535960","@4537526","@4537526","@4537526","@4537528","@4537632"}
  14. players = {}
  15. afk = {}
  16.  
  17. -- Fréquence de spawn des bulles au début
  18. spawnFrequency = 1
  19.  
  20. -- Fréquence de spawn des esprits
  21. spiritFrequency = 4
  22.  
  23. -- Fréquence de spawn des boulets
  24. cannonFrequency = 5
  25.  
  26. -- Nombre de secondes avant que la fréquence de spawn des bulles ne baisse
  27. delayUnfrequency = 5
  28.  
  29. -- Nombre de secondes avant que les esprits n'apparaîssent
  30. spiritTime = 20
  31.  
  32. -- Nombre de secondes avant que les boulets n'apparaissent
  33. cannonTime = 40
  34.  
  35. lang = {}
  36.  
  37. lang.fr = {
  38.   info = "Bubbles !",
  39.   afk = "<N>Vous êtes <J>AFK<N>. Pour jouer, dites : <ROSE>!afk<N>."
  40. }
  41.  
  42. lang.en = {
  43.   info = "Bubbles !",
  44.   afk = "<N>You are <J>AFK<N>. To play, say : <ROSE>!afk<N>."
  45. }
  46.  
  47. text = lang.fr
  48.  
  49. timer = {
  50.   start = 0,
  51.   frequence = 0,
  52.   unfrequence = 0
  53. }
  54.  
  55. bubbles = {}
  56.  
  57. function eventNewGame()
  58.   bubbles = {}
  59.   players = {}
  60.   spawnFrequency = 0.5
  61.  
  62.   for timerName,value in pairs(timer) do
  63.     timer[timerName] = 0
  64.   end
  65.  
  66.   for n,p in pairs(tfm.get.room.playerList) do
  67.     table.insert(players, n)
  68.   end
  69.  
  70.   local bestPlayer = bestPlayer()
  71.   tfm.exec.setUIMapName("<PT>"..text.info.." <font color='#60608F'>|</font>   <N>Bubble Master : <VP>"..bestPlayer)
  72.  
  73.   for _,p in pairs(players) do
  74.     if afk[p] then
  75.       tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
  76.     else
  77.       tfm.exec.movePlayer(p, math.random(100, 700), 90, false, 0, 0, false)
  78.     end
  79.   end
  80.  
  81.   showAfk()
  82. end
  83.  
  84. function eventNewPlayer(playerName)
  85.   table.insert(players, playerName)
  86.   afk[playerName] = false
  87. end
  88.  
  89. function eventPlayerLeft(playerName)
  90.   local toRemove = 0
  91.  
  92.   for i,p in pairs(players) do
  93.     if p==playerName then
  94.       toRemove = i
  95.     end
  96.   end
  97.  
  98.   table.remove(players, toRemove)
  99.   afk[playerName] = false
  100. end
  101.  
  102. function eventPlayerDied(playerName)
  103.   if #players > 1 then
  104.     local alive = 0
  105.     local pname = ""
  106.    
  107.     for _,p in pairs(players) do
  108.       if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
  109.         alive = alive + 1
  110.         pname = p
  111.       end
  112.     end
  113.    
  114.     if alive == 1 then
  115.       tfm.exec.giveCheese(pname)
  116.       tfm.exec.playerVictory(pname)
  117.       tfm.exec.setGameTime(5)
  118.     elseif alive == 0 then
  119.       newGame()
  120.     end
  121.   else
  122.     newGame()
  123.   end
  124. end
  125.  
  126. function eventPlayerWon(playerName)
  127.   if playerName == bestPlayer() then
  128.     tfm.exec.setPlayerScore(playerName, 5, true)
  129.   else
  130.     tfm.exec.setPlayerScore(playerName, 16, true)
  131.   end
  132. end
  133.  
  134. function eventLoop(currentTime, timeRemaining)
  135.   timer.start = timer.start + 0.5
  136.  
  137.   if timeRemaining <= 0 then
  138.     for _,p in pairs(players) do
  139.       if not tfm.get.room.playerList[p].isDead and not afk[p] then
  140.         tfm.exec.giveCheese(p)
  141.         tfm.exec.playerVictory(p)
  142.       end
  143.     end
  144.    
  145.     newGame()
  146.   end
  147.  
  148.   if timer.start > 40 and (timer.start % 52) == 0 and tfm.get.room.currentMap == "@4537632" then
  149.     tfm.exec.snow()
  150.   end
  151.  
  152.   if timer.start > spiritTime then
  153.     if (timer.start % spiritFrequency) == 0 then
  154.       local nbAfk = math.random(#bubbles)
  155.       local target = bubbles[nbAfk]
  156.      
  157.       tfm.exec.addShamanObject(24, tfm.get.room.objectList[target].x, tfm.get.room.objectList[target].y, 0, 0, 0, false)
  158.       tfm.exec.removeObject(target)
  159.       table.remove(bubbles, nbAfk)
  160.     end
  161.   end
  162.  
  163.   if timer.start > cannonTime then
  164.     if (timer.start % cannonFrequency) == 0 then
  165.       tfm.exec.addShamanObject(18, math.random(30, 770), 20, 0, 0, 75, false)
  166.     end
  167.   end
  168.  
  169.   for _,p in pairs(players) do
  170.     if not tfm.get.room.playerList[p].isDead then
  171.       if tfm.get.room.playerList[p].x < 0 or tfm.get.room.playerList[p].x > 800 or tfm.get.room.playerList[p].y < 10 then
  172.         if tfm.get.room.playerList[p].y > -150 then
  173.           tfm.exec.movePlayer(p, 400, 500, false, 0, 0, false)
  174.         end
  175.       end
  176.     end
  177.   end
  178.  
  179.   timer.frequence = timer.frequence + 0.5
  180.      
  181.   if timer.frequence >= spawnFrequency then
  182.     timer.frequence = 0
  183.      
  184.     timer.unfrequence = timer.unfrequence + 0.5
  185.      
  186.     if timer.unfrequence == delayUnfrequency and spawnFrequency < 2 then
  187.       timer.unfrequence = 0
  188.       spawnFrequency = spawnFrequency + 0.5
  189.     end
  190.        
  191.     spawnBubble()
  192.   end
  193.  
  194.   for i,id in pairs(bubbles)do
  195.     if tfm.get.room.objectList[id] and tfm.get.room.objectList[id].y<=20 then
  196.       tfm.exec.removeObject(id)
  197.       table.remove(bubbles, i)
  198.     end
  199.   end
  200. end
  201.  
  202. function eventChatCommand(playerName, message)
  203.   if message == "afk" and timer.start > 3 then
  204.     toggleAfk(playerName)
  205.   end
  206. end
  207.  
  208. function toggleAfk(playerName)
  209.   for p,v in pairs(afk) do
  210.     if p == playerName then
  211.       if v then
  212.         afk[p] = false
  213.  
  214.         if #players == 1 then
  215.           newGame()
  216.         else
  217.           local diff = 0
  218.          
  219.           for p,v in pairs(afk) do
  220.             if v then
  221.               diff = diff + 1
  222.             end
  223.           end
  224.          
  225.           if #players - diff == 1 then
  226.             newGame()
  227.           end
  228.         end
  229.       else
  230.         afk[p] = true
  231.         tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
  232.        
  233.         if #players > 1 then
  234.           local alive = 0
  235.           local pname = ""
  236.          
  237.           for _,p in pairs(players) do
  238.             if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
  239.               alive = alive + 1
  240.               pname = p
  241.             end
  242.           end
  243.          
  244.           if alive == 1 then
  245.             tfm.exec.giveCheese(pname)
  246.             tfm.exec.playerVictory(pname)
  247.             tfm.exec.setGameTime(5)
  248.           elseif alive == 0 then
  249.             newGame()
  250.           end
  251.         else
  252.           newGame()
  253.         end
  254.       end
  255.     end
  256.   end
  257.  
  258.   showAfk()
  259. end
  260.  
  261. function showAfk()
  262.   local nbAfk = 0
  263.   local nbNonAfk = 0
  264.   local nbPreAfk = 0
  265.   local message = ""
  266.  
  267.   while nbAfk <= #players do
  268.     ui.removeTextArea(nbAfk)
  269.     nbAfk = nbAfk + 1
  270.   end
  271.  
  272.   while nbNonAfk <= #players do
  273.     ui.removeTextArea(nbNonAfk)
  274.     nbNonAfk = nbNonAfk + 1
  275.   end
  276.  
  277.   nbAfk = 0
  278.   nbNonAfk = 0
  279.  
  280.   for p,v in pairs(afk) do
  281.     if v then nbPreAfk = nbPreAfk + 1 end
  282.   end
  283.  
  284.   for p,v in pairs(afk) do
  285.     if v then
  286.       ui.addTextArea(nbAfk, "<p align='center'>"..text.afk.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
  287.        
  288.       nbAfk = nbAfk + 1
  289.      
  290.       if nbAfk == nbPreAfk then
  291.         if nbAfk == 1 then
  292.           message = message.."<J>"..p.."<N> est AFK."
  293.         else
  294.           message = message.."<N>et <J>"..p.."<N> sont AFK."
  295.         end
  296.       else
  297.         message = message.."<J>"..p.."<N>, "
  298.       end
  299.     end
  300.   end
  301.  
  302.   for p,v in pairs(afk) do
  303.     if not v and nbAfk > 0 then
  304.       ui.addTextArea(nbNonAfk, "<p align='center'>"..message.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
  305.        
  306.       nbNonAfk = nbNonAfk + 1
  307.     end
  308.   end
  309. end
  310.  
  311. function spawnBubble()
  312.   local id
  313.   id = tfm.exec.addShamanObject(59, math.random(30, 770), 400, 0, 0, 0, false)
  314.   table.insert(bubbles, id)
  315. end
  316.  
  317. function newGame()
  318.   local map = tfm.get.room.currentMap
  319.  
  320.   if map == "@4537632" then -- Map neige
  321.     tfm.exec.snow()
  322.   end
  323.  
  324.   if #maps > 1 then
  325.     while map == tfm.get.room.currentMap do
  326.       map = maps[math.random(#maps)]
  327.     end
  328.   else
  329.     map = maps[math.random(#maps)]
  330.   end
  331.  
  332.   tfm.exec.newGame(map)
  333.  
  334.   if map == "@4537632" then -- Map neige
  335.     tfm.exec.snow()
  336.   end
  337. end
  338.  
  339. function bestPlayer()
  340.   local topScore = 16
  341.   local bestPlayer = "-"
  342.  
  343.   for name,player in pairs(tfm.get.room.playerList) do
  344.     if player.score >= topScore then
  345.       topScore = player.score
  346.       bestPlayer = name
  347.     end
  348.   end
  349.  
  350.   return bestPlayer
  351. end
  352.  
  353. for name,player in pairs(tfm.get.room.playerList) do
  354.   tfm.exec.setPlayerScore(name, 0, false)
  355.   afk[name] = false
  356. end
  357.  
  358. newGame()
  359. -- Fréquence de spawn des boulets
  360. cannonFrequency = 5
  361.  
  362. -- Nombre de secondes avant que la fréquence de spawn des bulles ne baisse
  363. delayUnfrequency = 5
  364.  
  365. -- Nombre de secondes avant que les esprits n'apparaîssent
  366. spiritTime = 20
  367.  
  368. -- Nombre de secondes avant que les boulets n'apparaissent
  369. cannonTime = 40
  370.  
  371. lang = {}
  372.  
  373. lang.fr = {
  374.   info = "Bubbles !",
  375.   afk = "<N>Vous êtes <J>AFK<N>. Pour jouer, dites : <ROSE>!afk<N>."
  376. }
  377.  
  378. lang.en = {
  379.   info = "Bubbles !",
  380.   afk = "<N>You are <J>AFK<N>. To play, say : <ROSE>!afk<N>."
  381. }
  382.  
  383. text = lang.fr
  384.  
  385. timer = {
  386.   start = 0,
  387.   frequence = 0,
  388.   unfrequence = 0
  389. }
  390.  
  391. bubbles = {}
  392.  
  393. function eventNewGame()
  394.   bubbles = {}
  395.   players = {}
  396.   spawnFrequency = 0.5
  397.  
  398.   for timerName,value in pairs(timer) do
  399.     timer[timerName] = 0
  400.   end
  401.  
  402.   for n,p in pairs(tfm.get.room.playerList) do
  403.     table.insert(players, n)
  404.   end
  405.  
  406.   local bestPlayer = bestPlayer()
  407.   tfm.exec.setUIMapName("<PT>"..text.info.." <font color='#60608F'>|</font>   <N>Bubble Master : <VP>"..bestPlayer)
  408.  
  409.   for _,p in pairs(players) do
  410.     if afk[p] then
  411.       tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
  412.     else
  413.       tfm.exec.movePlayer(p, math.random(100, 700), 90, false, 0, 0, false)
  414.     end
  415.   end
  416.  
  417.   showAfk()
  418. end
  419.  
  420. function eventNewPlayer(playerName)
  421.   table.insert(players, playerName)
  422.   afk[playerName] = false
  423. end
  424.  
  425. function eventPlayerLeft(playerName)
  426.   local toRemove = 0
  427.  
  428.   for i,p in pairs(players) do
  429.     if p==playerName then
  430.       toRemove = i
  431.     end
  432.   end
  433.  
  434.   table.remove(players, toRemove)
  435.   afk[playerName] = false
  436. end
  437.  
  438. function eventPlayerDied(playerName)
  439.   if #players > 1 then
  440.     local alive = 0
  441.     local pname = ""
  442.    
  443.     for _,p in pairs(players) do
  444.       if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
  445.         alive = alive + 1
  446.         pname = p
  447.       end
  448.     end
  449.    
  450.     if alive == 1 then
  451.       tfm.exec.giveCheese(pname)
  452.       tfm.exec.playerVictory(pname)
  453.       tfm.exec.setGameTime(5)
  454.     elseif alive == 0 then
  455.       newGame()
  456.     end
  457.   else
  458.     newGame()
  459.   end
  460. end
  461.  
  462. function eventPlayerWon(playerName)
  463.   if playerName == bestPlayer() then
  464.     tfm.exec.setPlayerScore(playerName, 5, true)
  465.   else
  466.     tfm.exec.setPlayerScore(playerName, 16, true)
  467.   end
  468. end
  469.  
  470. function eventLoop(currentTime, timeRemaining)
  471.   timer.start = timer.start + 0.5
  472.  
  473.   if timeRemaining <= 0 then
  474.     for _,p in pairs(players) do
  475.       if not tfm.get.room.playerList[p].isDead and not afk[p] then
  476.         tfm.exec.giveCheese(p)
  477.         tfm.exec.playerVictory(p)
  478.       end
  479.     end
  480.    
  481.     newGame()
  482.   end
  483.  
  484.   if timer.start > 40 and (timer.start % 52) == 0 and tfm.get.room.currentMap == "@4537632" then
  485.     tfm.exec.snow()
  486.   end
  487.  
  488.   if timer.start > spiritTime then
  489.     if (timer.start % spiritFrequency) == 0 then
  490.       local nbAfk = math.random(#bubbles)
  491.       local target = bubbles[nbAfk]
  492.      
  493.       tfm.exec.addShamanObject(24, tfm.get.room.objectList[target].x, tfm.get.room.objectList[target].y, 0, 0, 0, false)
  494.       tfm.exec.removeObject(target)
  495.       table.remove(bubbles, nbAfk)
  496.     end
  497.   end
  498.  
  499.   if timer.start > cannonTime then
  500.     if (timer.start % cannonFrequency) == 0 then
  501.       tfm.exec.addShamanObject(18, math.random(30, 770), 20, 0, 0, 75, false)
  502.     end
  503.   end
  504.  
  505.   for _,p in pairs(players) do
  506.     if not tfm.get.room.playerList[p].isDead then
  507.       if tfm.get.room.playerList[p].x < 0 or tfm.get.room.playerList[p].x > 800 or tfm.get.room.playerList[p].y < 10 then
  508.         if tfm.get.room.playerList[p].y > -150 then
  509.           tfm.exec.movePlayer(p, 400, 500, false, 0, 0, false)
  510.         end
  511.       end
  512.     end
  513.   end
  514.  
  515.   timer.frequence = timer.frequence + 0.5
  516.      
  517.   if timer.frequence >= spawnFrequency then
  518.     timer.frequence = 0
  519.      
  520.     timer.unfrequence = timer.unfrequence + 0.5
  521.      
  522.     if timer.unfrequence == delayUnfrequency and spawnFrequency < 2 then
  523.       timer.unfrequence = 0
  524.       spawnFrequency = spawnFrequency + 0.5
  525.     end
  526.        
  527.     spawnBubble()
  528.   end
  529.  
  530.   for i,id in pairs(bubbles)do
  531.     if tfm.get.room.objectList[id] and tfm.get.room.objectList[id].y<=20 then
  532.       tfm.exec.removeObject(id)
  533.       table.remove(bubbles, i)
  534.     end
  535.   end
  536. end
  537.  
  538. function eventChatCommand(playerName, message)
  539.   if message == "afk" and timer.start > 3 then
  540.     toggleAfk(playerName)
  541.   end
  542. end
  543.  
  544. function toggleAfk(playerName)
  545.   for p,v in pairs(afk) do
  546.     if p == playerName then
  547.       if v then
  548.         afk[p] = false
  549.  
  550.         if #players == 1 then
  551.           newGame()
  552.         else
  553.           local diff = 0
  554.          
  555.           for p,v in pairs(afk) do
  556.             if v then
  557.               diff = diff + 1
  558.             end
  559.           end
  560.          
  561.           if #players - diff == 1 then
  562.             newGame()
  563.           end
  564.         end
  565.       else
  566.         afk[p] = true
  567.         tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
  568.        
  569.         if #players > 1 then
  570.           local alive = 0
  571.           local pname = ""
  572.          
  573.           for _,p in pairs(players) do
  574.             if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
  575.               alive = alive + 1
  576.               pname = p
  577.             end
  578.           end
  579.          
  580.           if alive == 1 then
  581.             tfm.exec.giveCheese(pname)
  582.             tfm.exec.playerVictory(pname)
  583.             tfm.exec.setGameTime(5)
  584.           elseif alive == 0 then
  585.             newGame()
  586.           end
  587.         else
  588.           newGame()
  589.         end
  590.       end
  591.     end
  592.   end
  593.  
  594.   showAfk()
  595. end
  596.  
  597. function showAfk()
  598.   local nbAfk = 0
  599.   local nbNonAfk = 0
  600.   local nbPreAfk = 0
  601.   local message = ""
  602.  
  603.   while nbAfk <= #players do
  604.     ui.removeTextArea(nbAfk)
  605.     nbAfk = nbAfk + 1
  606.   end
  607.  
  608.   while nbNonAfk <= #players do
  609.     ui.removeTextArea(nbNonAfk)
  610.     nbNonAfk = nbNonAfk + 1
  611.   end
  612.  
  613.   nbAfk = 0
  614.   nbNonAfk = 0
  615.  
  616.   for p,v in pairs(afk) do
  617.     if v then nbPreAfk = nbPreAfk + 1 end
  618.   end
  619.  
  620.   for p,v in pairs(afk) do
  621.     if v then
  622.       ui.addTextArea(nbAfk, "<p align='center'>"..text.afk.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
  623.        
  624.       nbAfk = nbAfk + 1
  625.      
  626.       if nbAfk == nbPreAfk then
  627.         if nbAfk == 1 then
  628.           message = message.."<J>"..p.."<N> est AFK."
  629.         else
  630.           message = message.."<N>et <J>"..p.."<N> sont AFK."
  631.         end
  632.       else
  633.         message = message.."<J>"..p.."<N>, "
  634.       end
  635.     end
  636.   end
  637.  
  638.   for p,v in pairs(afk) do
  639.     if not v and nbAfk > 0 then
  640.       ui.addTextArea(nbNonAfk, "<p align='center'>"..message.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
  641.        
  642.       nbNonAfk = nbNonAfk + 1
  643.     end
  644.   end
  645. end
  646.  
  647. function spawnBubble()
  648.   local id
  649.   id = tfm.exec.addShamanObject(59, math.random(30, 770), 400, 0, 0, 0, false)
  650.   table.insert(bubbles, id)
  651. end
  652.  
  653. function newGame()
  654.   local map = tfm.get.room.currentMap
  655.  
  656.   if map == "@4537632" then -- Map neige
  657.     tfm.exec.snow()
  658.   end
  659.  
  660.   if #maps > 1 then
  661.     while map == tfm.get.room.currentMap do
  662.       map = maps[math.random(#maps)]
  663.     end
  664.   else
  665.     map = maps[math.random(#maps)]
  666.   end
  667.  
  668.   tfm.exec.newGame(map)
  669.  
  670.   if map == "@4537632" then -- Map neige
  671.     tfm.exec.snow()
  672.   end
  673. end
  674.  
  675. function bestPlayer()
  676.   local topScore = 16
  677.   local bestPlayer = "-"
  678.  
  679.   for name,player in pairs(tfm.get.room.playerList) do
  680.     if player.score >= topScore then
  681.       topScore = player.score
  682.       bestPlayer = name
  683.     end
  684.   end
  685.  
  686.   return bestPlayer
  687. end
  688.  
  689. for name,player in pairs(tfm.get.room.playerList) do
  690.   tfm.exec.setPlayerScore(name, 0, false)
  691.   afk[name] = false
  692. end
  693.  
  694. newGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement