Advertisement
Eliaseeg

#tribewar

Jul 21st, 2017 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.22 KB | None | 0 0
  1. local maps = {
  2.     203664, 375455, 394132, 173816, 171776, 199210, 562897, 172951, 171148, 166430, 169076, 330933, 179488, 172621, 168754, 159145,
  3.     163596, 152733, 410040, 158909, 261814, 195453, 281985, 191205, 159932, 2176211, 586901, 285589, 257324, 236768, 303151, 270924,
  4.     1324259, 1225867, 563436, 424604, 523270, 172547, 2693587, 168204, 2693344, 193662, 1788490, 305680, 149451, 176253, 342035, 2466489,
  5.     292808, 176615, 438333, 394125, 162482, 304861, 458528, 159298, 184648, 268915, 329318, 373105, 261298, 302080, 449496, 159187, 176710,
  6.     161023, 366260, 1852910, 201172, 549759, 257715, 397478, 261298, 177652, 408643, 447805, 155606, 176619, 460961, 455271, 172512, 320607,
  7.     166271, 299942, 150664, 186066, 152260, 155628, 166805, 178297, 313138, 167903, 223947, 191177, 185873, 113156, 156720, 163159, 197229,
  8.     204647, 163531, 232675, 216173, 166361, 169059, 271411, 277824, 306365, 172520, 157098, 225744, 608368, 215933, 266398, 343875, 327354,
  9.     331344, 333002, 223174, 332130, 254785, 295487, 184817, 159691, 235717, 169228, 191203, 503679, 506032, 2747525, 192255, 208056, 171480,
  10.     182681, 219956, 270143, 2887929, 247329, 250610, 2118599, 445133, 149853, 212903, 220737, 397296, 2617003, 629731, 329627, 221767, 422655,
  11.     417816, 164931, 245152, 371072, 2458243, 214788, 274963, 2439335, 269534, 8679, 321268, 398041, 5591416, 5650343, 5650250, 161730, 4273207,
  12.     4091580, 5650303, 5172709, 5650469, 214660, 3579335, 4003729, 508451, 314205, 156510, 5545443, 606723, 3946626, 332467, 1665516, 1614563,
  13.     3679884, 414899, 1531388, 905496, 3834905, 3821104, 1851411, 3816991, 2331474, 313245, 266854, 193588, 2141379, 3738767, 232791, 285752,
  14.     278506, 406266, 1976857, 301315, 180469, 3693822, 280896, 403698, 259604, 418022, 323366, 594883, 477603, 437860, 590641, 3688419, 3682405,
  15.     645288, 419374, 664949, 704015, 398942, 195720, 314159, 613985, 3683383, 3683201, 3680223, 3680221, 363625, 1693705, 319524, 3667358, 1718723,
  16.     1490438, 3630433, 3620542, 3617674, 3556489, 3548406, 3548376, 3408247, 2953315, 2883986, 2683170, 2645615, 2536577, 2453022, 2372538, 2287914,
  17.     2286056, 2223685, 2150335, 2150335, 2101747, 2018511, 2007205, 1975684, 1964752, 1964700, 1956555, 1923785, 1862800, 1716949, 1674534, 1658171,
  18.     1659639, 1657360, 1657021, 1654105, 1651658, 1643157, 1634741, 1632706, 1622737, 1619934, 1618110, 1613550, 1612796, 1612436, 1608638, 6212895,
  19.     1602654, 1601492, 1586439, 1588884, 1573997, 1567620, 1542618, 1539791, 1513407, 1509474, 1503393, 1487161, 1450554, 1425101, 1394120, 1393405,
  20.     1373000, 1371239, 1368222, 1359797, 1358446, 1352534, 1346440, 1321664, 1321417, 1281981, 1255130, 1222899, 1214182, 1195842, 1143815, 1132357,
  21.     1058681, 979179, 829657, 813156, 798953, 749102, 737841, 627609, 624721, 608459, 616373, 594049, 606719, 586688, 580031, 564033, 558790, 551126,
  22.     545493, 536235, 528428, 511275, 508106, 501711, 496945, 496091, 483924, 472665, 472379, 447556, 445133, 444490, 441047, 438154, 436447, 436107,
  23.     431373, 430145, 429822, 428517, 427300, 425806, 424795, 422361, 421302, 420956, 420806, 418658, 418600, 416142, 412316, 410813, 412211, 410565,
  24.     410532, 410230, 407457, 407455, 407230, 407165, 406982, 406881, 406486, 405295, 403910, 401995, 401945, 401778, 397938, 397812, 397296, 396861,
  25.     396645, 391625, 387270, 387180, 386046, 385295, 386029, 379745, 378826, 379866, 364998, 359055, 352885, 352710, 350251, 344952, 340069, 339896,
  26.     339643, 337774, 323600, 319841, 317754, 309029, 308711, 308435, 306213, 292348, 278916, 277784, 275514, 270819, 1017676, 160762, 2089069, 234039,
  27.     267187, 263163, 262144, 330590, 403698, 396105, 6538564, 396105, 419735, 6547536, 355658, 6607378, 191716, 292348, 6456247, 5326916, 6077025,
  28.     356722, 2564883, 1450554, 494706, 254291, 1503393, 6467947, 6263285, 2953315, 6114281, 412752, 4038817, 5461992, 319841, 359901, 191716, 452016,
  29.     1450554, 397296, 250610, 499684, 5848412, 238791, 2283, 232274, 1716693, 330590, 459349, 6583596, 455167, 6460747, 251459, 244888, 5755208,
  30.     240973, 235501, 235034, 234039, 233398, 232274, 230510, 216735, 216439, 216505, 214037, 212542, 211565, 198715, 193936, 191716, 186604, 180274,
  31.     176263, 178657, 146801, 145020, 3154, 2283, 5382692, 5249500, 4412890, 5163891, 789128, 2245005, 2030343, 5712914, 372401, 5087373, 4953687,
  32.     2369254, 4853690, 226069, 422509, 5436200, 732880, 4038817, 400866, 3730656, 3985806, 355658, 5175727, 5699298, 5588646, 3921436, 3639993, 3984750,
  33.     508796, 1985019, 4734427, 1703617, 289068, 197219, 333666, 6077025, 5710586, 322321, 331572, 4741601, 158128, 6310411, 6312498, 6310396, 6312188,
  34.     6473912, 6389619, 6854536, 6854539, 6312173, 6315208, 6312203, 6310370, 6310383, 6853060, 6310440, 6547670, 7062105, 6545742, 6985344, 960547
  35. }
  36. local tribes = {}
  37. local scores = {}
  38. local mice = {}
  39. local round = 0
  40. local rounds = 2
  41. local miceAlive
  42. local places
  43. local particles
  44. local xIni
  45. local yIni
  46.  
  47. function main()
  48.     tfm.exec.disableAutoNewGame(true)
  49.     tfm.exec.disableAutoShaman(true)
  50.     tfm.exec.disableAutoTimeLeft(true)
  51.     table.foreach(tfm.get.room.playerList,  eventNewPlayer)
  52.     startNewGame()
  53.     math.randomseed(os.time())
  54. end
  55.  
  56. function startNewGame()
  57.     if round < rounds then
  58.         local newMap
  59.         repeat
  60.             newMap = maps[math.random(#maps)]
  61.         until newMap ~= tfm.get.room.currentMap
  62.         tfm.exec.newGame (newMap)
  63.     else
  64.         tfm.exec.newGame(0)
  65.     end
  66. end
  67.  
  68. function eventNewPlayer(name)
  69.     local tribeName = tfm.get.room.playerList[name].tribeName
  70.     if tribeName ~= nil then
  71.         if not tribes[tribeName] then
  72.             tribes[tribeName] = {
  73.                 name = tribeName,
  74.                 members = {name},
  75.                 points = 0
  76.             }
  77.         else
  78.             table.insert(tribes[tribeName].members,  name)
  79.         end
  80.     end
  81.    
  82.     if not mice[name] then
  83.         mice[name] = {
  84.             help = false
  85.         }
  86.     end
  87.    
  88.     for i = 1, 1000 do
  89.         system.bindKeyboard(name, i, true, true)
  90.     end
  91.    
  92. end
  93.  
  94. function eventNewGame()
  95.     scores = {}
  96.     places = 0
  97.     miceAlive = 0
  98.     round = round + 1
  99.     particles = false
  100.     tfm.exec.setUIMapName("<J>".. tfm.get.room.xmlMapInfo.author .. "<G> - " .. tfm.get.room.currentMap .. "   |   <BV>Rondas: <CH>"..round .. "<BL><b>/</b><BV>" .. rounds)
  101.     if (round == rounds + 1) then
  102.         local ladder = getWinners()
  103.         for i = 1, math.min(#ladder, 3) do
  104.             if ladder[i].points <= 0 then
  105.                 ladder[i].name = "Nobody :("
  106.             end
  107.             if ladder[i].name ~= "Nobody :(" then
  108.                 print("<G> ("..i..") </G><BV><b>"..ladder[i].name.."</b></BV><G> with " .. ladder[i].points .. " points")
  109.             end
  110.         end
  111.         if ladder[1].name == "Nobody :(" then
  112.             print("Nobody won :(")
  113.         end
  114.         xIni = math.random(400-100*4, 400+10*4)
  115.         yIni = math.random(100-100*2, 100+100*2)
  116.         particles = true
  117.         round = 0
  118.         tfm.exec.setUIMapName("<J>".. tfm.get.room.xmlMapInfo.author .. "<G> - " .. tfm.get.room.currentMap .. "   |   <J>WINNERS!!!! ")
  119.         tfm.exec.setGameTime(20)
  120.         for name, tribe in pairs(tribes) do
  121.             tribe.points = 0
  122.         end
  123.     end
  124.    
  125.     for name in pairs(tfm.get.room.playerList) do
  126.         miceAlive = miceAlive + 1
  127.     end
  128.    
  129. end
  130.  
  131. function eventLoop(time, left)
  132.     if left <= 0 then
  133.         startNewGame()
  134.     end
  135.     if particles then
  136.         i = true
  137.         if i then
  138.             i = false
  139.             for i = 0,30 do
  140.                 tfm.exec.displayParticle(21, xIni, yIni,0, math.random(0,4), 0, 0, name)
  141.                 tfm.exec.displayParticle(22, xIni, yIni,0, math.random(0,4), 0, 0, name)
  142.                 tfm.exec.displayParticle(23, xIni, yIni,0, math.random(0,4), 0, 0, name)
  143.                 xIni = math.random(400-100*4, 400+100*4)
  144.                 yIni = math.random(100-100*2, 100+100*2)
  145.             end
  146.         end
  147.     end
  148. end
  149.  
  150. function eventKeyboard(name, key, down, x, y)
  151.     if key == 72 then
  152.         if mice[name].help then
  153.             for i = 0, 3 do
  154.                 ui.removeTextArea(i, name)
  155.             end
  156.             mice[name].help = false
  157.         else
  158.             ui.addTextArea(0, "<p align='center'><font size='20'>¡</font><font size='20' color='#FF9602'>Bienvenido a </font><font size='20' color='#3D1149'><b>#tribewar</b></font><font size='30'>!</font></p>\n\n<font size='13'><p align='justify'><b>#tribewar</b> es un minijuego en donde competirás con otras tribus para ver quién es la mejor. Asegúrate de tener en cuenta lo siguiente:\n\n • Los primeros lugares recibirán: <b>3 2 1</b> puntos, respectivamente.\n • <b>No</b> cuentan los firsts.\n • <b>10</b> rondas para juntar la mayor cantidad de puntos, la tribu que tenga mayor cantidad de puntos al finalizar las <b>10</b> rondas gana.\n</p></font>\n\n\n<font size='10'><p align='right'>Para saber la lista de comandos disponibles \npasa a la siguiente página.</p></font>", name, 150, 58, 497, 248, 0x526E9A, 0x081B5D, 1, true)
  159.             ui.addTextArea(1, "<font size='30'><p align='center'><a href='event:page2'>&gt;</p></font>", name, 663, 263, 44, 43, 0x526E9A, 0x081B5D, 1, true)
  160.             ui.addTextArea(3, "<font size='30'><p align='center'><a href='event:close'>X</a></p></font>", name, 663, 59, 44, 43, 0xc22323, 0xf00000, 1, true)
  161.             mice[name].help = true
  162.         end
  163.     end
  164. end
  165.  
  166. function eventTextAreaCallback(id, name, callback)
  167.     if callback == "page1" then
  168.         ui.updateTextArea(0, "<p align='center'><font size='20'>¡</font><font size='20' color='#FF9602'>Bienvenido a </font><font size='20' color='#3D1149'><b>#tribewar</b></font><font size='30'>!</font></p>\n\n<font size='13'><p align='justify'><b>#tribewar</b> es un minijuego en donde competirás con otras tribus para ver quién es la mejor. Asegúrate de tener en cuenta lo siguiente:\n\n • Los primeros lugares recibirán: <b>3 2 1</b> puntos, respectivamente.\n • <b>No</b> cuentan los firsts.\n • <b>10</b> rondas para juntar la mayor cantidad de puntos, la tribu que tenga mayor cantidad de puntos al finalizar las <b>10</b> rondas gana.\n</p></font>\n\n\n<font size='10'><p align='right'>Para saber la lista de comandos disponibles \npasa a la siguiente página.</p></font>", name)
  169.         ui.updateTextArea(1, "<font size='30'><p align='center'><a href='event:page2'>&gt;</p></font>", name)
  170.         ui.removeTextArea(2, name)
  171.     elseif callback == "page2" then
  172.         ui.updateTextArea(0, "<p align='center'><font size='20'>¡</font><font size='20' color='#FF9602'>Comandos </font><font size='20' color='#3D1149'><b>#tribewar</b></font><font size='30'>!</font></p>\n\n<font size='13'><p align='justify'><b>•!help</b>: Muestra esta ayuda.\n\n<b>•!profile [player]</b>: Revisa el perfil de un jugador junto al de su tribu.\n\n<b>•!tribe [tribe]</b>: Revisa el perfil de una tribu.\n\n<b>•!compare [player] [player2]:</b> Compara perfiles personales y de tribu.\n</p></font>\n\n\n<font size='10'><p align='right'>Para ver otra información \npasa a la siguiente página</p></font>", name)
  173.         ui.addTextArea(2, "<font size='30'><p align='center'><a href='event:page1'>&lt;</a></p></font>", name, 663, 199, 44, 43, 0x526E9A, 0x081B5D, 1, true)
  174.         ui.updateTextArea(1, "<font size='30'><p align='center'><a href='event:page3'>&gt;</p></font>", name)
  175.     elseif callback == "page3" then
  176.         ui.updateTextArea(0, "<p align='center'><font size='20'>¡</font><font size='20' color='#FF9602'>Bienvenido a </font><font size='20' color='#3D1149'><b>#tribewar</b></font><font size='30'>!</font></p>\n\n<font size='13'><p align = 'justify'>Colocar más texto acá</p></font>", name)
  177.         ui.updateTextArea(1, "<font size='30'><p align='center'><a href='event:page2'>&lt;</p></font>", name)
  178.         ui.removeTextArea(2, name)
  179.     elseif callback == "close" then
  180.         for i=0, 3 do
  181.             ui.removeTextArea(i, name)
  182.         end
  183.    
  184.     end
  185. end
  186.  
  187. function eventPlayerWon(name)
  188.     local tribeName = tfm.get.room.playerList[name].tribeName
  189.     local points = 0
  190.     places = places + 1
  191.     if places <= 3 then
  192.         if places == 1 then
  193.             points = 3
  194.         elseif places == 2 then
  195.             points = 2
  196.         elseif places == 3 then
  197.             points = 1
  198.         end
  199.         tribes[tribeName].points = tribes[tribeName].points + points
  200.         print(name.. " ha sumado ".. points .. " puntos para la tribu: " .. tribeName .. " (".. tribes[tribeName].points .. ")")
  201.     end
  202.     checkAlives()
  203. end
  204.  
  205. function eventPlayerLeft(name)
  206.     checkAlives()
  207. end
  208.  
  209. function eventPlayerDied(name)
  210.     checkAlives()
  211. end
  212.  
  213. function checkAlives()
  214.     miceAlive = miceAlive - 1
  215.     if miceAlive == 1 then
  216.         tfm.exec.setGameTime(20)
  217.     elseif miceAlive == 0 then
  218.         startNewGame()
  219.     end
  220. end
  221.  
  222. function getWinners()
  223.     local score = {}
  224.     for name, tribe in pairs(tribes) do
  225.         table.insert(score, tribe)
  226.     end
  227.     table.sort(score, function(a, b) return a.points > b.points end)
  228.     return score
  229. end
  230.  
  231. function table.contains(table, element)
  232.     for k, v in pairs(table) do
  233.         if v == element then
  234.             return true
  235.         end
  236.     end
  237.     return nil
  238. end
  239.  
  240. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement