Advertisement
Guest User

Evilsantah

a guest
Jun 9th, 2014
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.43 KB | None | 0 0
  1. GLITTERS = {0, 1, 2, 9, 11, 13}
  2. SCROLLING_TXT = '<J>&#8226; [%s] %s~~! %s'
  3. HELP_MSG = ''
  4. NAMES = '<V>Impuredeath<J>, <V>Evilsantah<J>, <V>Paperonaruto<J>, <V>Fierying<J> %s <V>Thewav<J>'
  5. MAX_TIME = 90
  6.  
  7. translations = {
  8.     EN={
  9.         EVENT='Event',
  10.         HNY='Happy New Year',
  11.         BTYB='Greetings from %s.',
  12.         AND='and',
  13.         HELP='Gather around the barrels to ignite more fireworks!'
  14.     },
  15.     BR={
  16.         EVENT='Evento',
  17.         HNY='Feliz ano novo',
  18.         BTYB='Sauda&#231;&#245;es %s.',
  19.         AND='e',
  20.         HELP='Fique perto dos barr&#237;s para acender mais fogos de artif&#237;cio!'
  21.     },
  22.     ES={
  23.         EVENT='Evento',
  24.         HNY='&#161;Feliz a&#241;o nuevo',
  25.         BTYB='Saludos de %s.',
  26.         AND='y',
  27.         HELP='Re&#250;nanse alrededor de los barriles para encender m&#225;s fuegos artificiales!'
  28.     },
  29.     NL={
  30.         EVENT='Evenement',
  31.         HNY='Gelukkig nieuwjaar',
  32.         BTYB='Groeten van %s.',
  33.         AND='en',
  34.         HELP='Kom bijeen rond de tonnen om meer vuurwerk af te schieten!'
  35.     },
  36.     DE={
  37.         EVENT='Ereignis',
  38.         HNY='Frohes neues Jahr',
  39.         BTYB='Die besten Wünsche von %s.',
  40.         AND='und',
  41.         HELP='Versammelt euch sich um die Fässer, um mehr Feuerwerk zu zünden!'
  42.     },
  43.     FR={
  44.         EVENT='Événement',
  45.         HNY='Bonne année',
  46.         BTYB='Salutations de %s.',
  47.         AND='et',
  48.         HELP="Rassemblez-vous autour des tonneaux pour allumer plus de feux d'artifice!"
  49.     },
  50.     TR={
  51.         EVENT='Etkinlik',
  52.         HNY='Mutlu Y&#305;llar',
  53.         BTYB="%s'dan sevgiler.",
  54.         AND='ve',
  55.         HELP='Daha fazla havai fi&#351;ek toplamak i&#231;in varil etraf&#305;nda toplan&#305;n!'
  56.     },
  57.     RU={
  58.         EVENT='&#1057;&#1086;&#1073;&#1099;&#1090;&#1080;&#1077;',
  59.         HNY='&#1057; &#1053;&#1086;&#1074;&#1099;&#1084; &#1043;&#1086;&#1076;&#1086;&#1084;',
  60.         BTYB='&#1042;&#1072;&#1089; &#1087;&#1088;&#1080;&#1074;&#1077;&#1090;&#1089;&#1090;&#1074;&#1091;&#1077;&#1090; %s.',
  61.         AND='&#1080;',
  62.         HELP='&#1055;&#1086;&#1076;&#1086;&#1081;&#1076;&#1080; &#1082; &#1073;&#1086;&#1095;&#1082;&#1072;&#1084;, &#1095;&#1090;&#1086;&#1073;&#1099; &#1079;&#1072;&#1078;&#1077;&#1095;&#1100; &#1073;&#1086;&#1083;&#1100;&#1096;&#1077; &#1092;&#1077;&#1081;&#1077;&#1088;&#1074;&#1077;&#1088;&#1082;&#1086;&#1074;!'
  63.     },
  64.     RO={
  65.         EVENT='Evenimentului',
  66.         HNY='An nou fericit',
  67.         BTYB='Salut&#259;ri din partea %s.',
  68.         AND='&#537;i',
  69.         HELP='Aduna-&#539;i pe l&#226;ng&#259; butoaie pentru a c&#226;&#537;tiga mai multe petarde!'
  70.     },
  71.     CN={
  72.         EVENT='&#27963;&#21160;',
  73.         HNY='&#26032;&#24180;&#24555;&#27138;',
  74.         BTYB='&#20358;&#33258; %s &#30340;&#31069;&#36032;.',
  75.         AND='&#21644;',
  76.         HELP='&#32858;&#38598;&#21040;&#21040;&#26742;&#36793;&#19978;&#28857;&#29123;&#26356;&#22810;&#30340;&#28895;&#33457;!'
  77.     },
  78.     VK={
  79.         EVENT='Event',
  80.         HNY='Godt nytt&#229;r',
  81.         BTYB='Hilsener fra %s.',
  82.         AND='og',
  83.         HELP='St&#229; i n&#230;rheten av fatene for &#229; tenne flere fyrverkerier!'
  84.     },
  85.     ID={
  86.         EVENT='Event',
  87.         HNY='Selamat tahun baru',
  88.         BTYB='Salam dari %s.',
  89.         AND='dan',
  90.         HELP='Berkumpul di sekitar barel untuk membuat lebih banyak kembang api!'
  91.     },
  92.     PL={
  93.         EVENT='Event',
  94.         HNY='Szcz&#281;&#347;liwego nowego roku',
  95.         BTYB='Pozdrowienia od %s.',
  96.         AND='i',
  97.         HELP='Zbieraj beczki aby zapali&#263; wi&#281;cej fajerwerk&#243;w!'
  98.     },
  99.     HU={
  100.         EVENT='Event',
  101.         HNY='Boldog &#250;j &#233;vet',
  102.         BTYB='&#220;dv&#246;zlettel %s',
  103.         AND='és',
  104.         HELP='Gy&#369;ljetek a hord&#243;k k&#246;r&#233;, hogy min&#233;l t&#246;bb t&#369;zij&#225;t&#233;kot gy&#250;jtsatok meg!'
  105.     }
  106. }
  107.  
  108. ASCII_TABLE = {}
  109.  
  110. ASCII_TABLE[0] = {{0,0}} -- null / unknown
  111.  
  112. ASCII_TABLE[48] = {{-18,0},{-18,6},{-18,-6},{6,-24},{6,24},{-6,-24},{-6,24},{18,12},{18,-12},{18,0},{-18,-12},{18,-6},{18,6},{0,-24},{0,24},{-10,-21},{-14,-17},{-18,11},{-15,15},{-11,19},{11,20},{15,16},{10,-21},{14,-18}}
  113. ASCII_TABLE[49] = {{0,0},{0,-12},{0,12},{0,-24},{0,24},{-12,24},{12,24},{-12,-18},{4,24},{8,24},{-3,24},{-8,24},{0,15},{0,19},{-8,-20},{-4,-22},{0,-20},{0,-16},{0,-8},{0,-4},{0,4},{0,8}}
  114. ASCII_TABLE[50] = {{0,6},{-4,-24},{8,-24},{-16,-16},{-6,24},{6,24},{18,24},{-18,24},{18,-12},{-12,12},{12,0},{-11,-21},{2,-24},{15,-20},{17,-6},{6,3},{-6,9},{-16,17},{-12,24},{0,24},{12,24}}
  115. ASCII_TABLE[52] = {{-18,12},{-6,12},{6,12},{18,12},{6,24},{6,0},{6,-12},{6,-24},{-4,-10},{-12,0},{13,12},{0,12},{6,-18},{-14,5},{0,-16},{3,-20},{-12,12},{-8,-5},{6,18},{6,-6},{6,6}}
  116.  
  117. -- kitten face
  118. --ASCII_TABLE[string.byte('f')] = {{-14,-6},{-12,-7},{-8,-8},{-3,-9},{-1,-9},{3,-9},{7,-8},{10,-7},{12,-6},{11,-7},{14,-10},{15,-12},{18,-15},{18,-15},{21,-10},{21,-6},{21,-1},{-11,-8},{-13,-11},{-17,-14},{-19,-16},{-20,-13},{-21,-8},{-22,-3},{-21,-2},{-21,0},{-23,5},{-24,10},{-23,15},{-20,18},{21,1},{22,9},{22,12},{19,17},{16,19},{6,5},{8,5},{13,5},{13,5},{-8,4},{-11,4},{-15,4},{-15,4},{-5,10},{-7,12},{-7,14},{-5,15},{-3,14},{-1,11},{-2,13},{-1,15},{3,15},{5,15},{5,13},{5,11},{4,9},{11,10},{13,10},{16,11},{11,13},{13,13},{17,13},{-13,9},{-16,10},{-18,11},{-13,13},{-16,14},{-17,14}}
  119. -- here the beard
  120. --ASCII_TABLE[string.byte('b')] = {{-20,-13},{-19,-10},{-17,-9},{-15,-8},{-14,-6},{-11,-5},{-10,-7},{-8,-10},{-5,-7},{-1,-7},{2,-8},{5,-8},{9,-8},{11,-7},{12,-7},{14,-9},{17,-10},{18,-12},{19,-15},{20,-9},{20,-7},{21,-4},{21,-2},{19,-1},{20,1},{21,2},{21,8},{19,8},{19,9},{18,13},{19,15},{19,16},{19,18},{19,19},{16,20},{12,21},{7,19},{5,19},{2,16},{-1,15},{-3,14},{-3,10},{-3,10},{-8,8},{-10,6},{-10,3},{-12,3},{-18,4},{-14,3},{-19,2},{-20,0},{-21,-2},{-23,-5},{-23,-9},{-22,-12},{-21,-14},{-9,-4},{-6,-1},{-4,-2},{-1,1},{1,1},{4,0},{5,-2},{8,-2},{12,-2},{15,-4},{17,-4},{18,-5},{20,-7},{-5,8},{21,4},{-16,4}}
  121.  
  122. spawnPoints = {
  123.     -- {x, y, chance, speed, progress, imageX, imageY, imageId, activateDist}
  124.     {138, 327, 0.6, 2.5, 0.5, 130, 333, -1, 60},
  125.     {371, 332, 0.6, 2.5, 0.5, 348, 336, -1, 80},
  126.     {603, 248, 0.4, 1.5, 0.5, 604, 232, -1, 80}
  127. }
  128.  
  129. progressBar = {
  130.     {'EOrEVag','87mhCpM','73bbnyB','aVmxoAp','PFPlg6F','Sdi1sYn','kPidpoF','W9XtCSg','sWrpZ34','EPMFLbm'},
  131.     {'ds8x5O8','NzStPko','ifPHNrw','eO27MmL','P7ENw2t','wmOiu6a','sznK1Y6','IEjKbx0','oL3j80f','Nm4ycAx'},
  132.     {'fADvU4o','yoM0vq1','X3nOVBu','4eh6fL7','n3tZ6DN','vAPnHQR','D9KQ0Q0','7UFeYVS','mF1cHX6','exzhslj'}
  133. }
  134.  
  135. campfire = {695, 376, false, {2, 13}}
  136. players = {}
  137. amountOfPlayers = 0
  138. stage = 0
  139. doNotPlayWithFire = {'qb61bSY.png', 480, 370}
  140.  
  141. explosionData = {
  142.     --[[ FORMAT START
  143.     {
  144.         function(trailParticleId,extraParticles,centerX,centerY)
  145.             -- trailParticleId is the particle id from the trail
  146.             -- extraParticles gets passed on from this table to this function
  147.             -- centerX is the center X coordinate from the explosion
  148.             -- centerY ............. Y .............................
  149.             -- do stuff here
  150.         end,
  151.         extraParticles,
  152.         timeBeforeExplosion
  153.     }
  154.     FORMAT END ]]--
  155.     {function(id,p,x,y) -- Star shaped, same color as trail
  156.         drawParam2({x, y, 7.0, 0.4, 10, {id}})
  157.     end, {}, 1000},
  158.     {function(id,p,x,y) -- Spirit
  159.         tfm.exec.displayParticle(10, x, y, 0, 0, 0, 0, nil)
  160.     end, {}, 1000},
  161.     {function(id,p,x,y) -- Explosion causes more trails of same color
  162.         local ax = 0
  163.         local ay = 0.15
  164.         local magnitude = 4
  165.         local length = 10
  166.         for vx = -3, 3 do
  167.             local vy = (math.random(1, 5) / 10) - 2
  168.             firework(id, x, y, vx, vy, ax, ay, magnitude, length, nil)
  169.         end
  170.     end, {}, 1000},
  171.     {function(id,p,x,y) -- Star shaped, same color as trail with a second star which may not share a similar color
  172.         local randomParticle = p[math.random(#p)]
  173.         drawParam2({x, y, 6.0, 0.4, 7, {id}})
  174.         drawParam2({x, y, 6.0, 0.4, 10, {randomParticle}})
  175.     end, GLITTERS, 1000},
  176.     {function(id,p,x,y) -- i have no idea what this will end up kay
  177.         local randomParticle = p[math.random(#p)]
  178.         drawParam2({x, y, 6.0, 0.4, 9, {id}})
  179.         drawParam2({x, y, 6.0, 0.4, 10, {randomParticle}})
  180.     end, GLITTERS, 1000},
  181.     {function(id,p,x,y) -- its beautiful
  182.         local randomParticle = p[math.random(#p)]
  183.         roseCurves({x, y, 3,3, {id}})
  184.         roseCurves({x, y, 5,5, {randomParticle}})
  185.     end, GLITTERS, 1000},
  186.     {function(id,p,x,y) -- Default firework, same color as trail
  187.         defaultEffect(id,p,x,y,false)
  188.     end, {}, 1000},
  189.     {function(id,p,x,y) -- Mixed colors default firework
  190.         defaultEffect(id,p,x,y,true)
  191.     end, GLITTERS, 1000},
  192.     {function(id,p,x,y) -- White/golden default firework
  193.         defaultEffect(id,p,x,y,true)
  194.     end, {0,2}, 1000},
  195.     {function(id,p,x,y) -- Red/yellow/orange default firework
  196.         defaultEffect(id,p,x,y,true)
  197.     end, {13,11,2}, 1000},
  198.     {function(id,p,x,y) -- Teal/white/purple default firework
  199.         defaultEffect(id,p,x,y,true)
  200.     end, {9,0,1}, 1000},
  201.     {function(id,p,x,y) -- 2014
  202.         textEffect(id,p,x,y,true,'2014',2)
  203.     end, {0, 2}, 1000},
  204.     {function(id,p,x,y) -- face
  205.         textEffect(id,p,x,y,false,'f',1)
  206.     end, GLITTERS, 1000},
  207.     {function(id,p,x,y) -- beard
  208.         textEffect(id,p,x,y,false,'b',1)
  209.     end, GLITTERS, 1000},
  210.     {function(id,p,x,y) -- Explosion causes more trails of same color with spirit
  211.         local ax = 0
  212.         local ay = 0.15
  213.         local magnitude = 4
  214.         local length = 10
  215.         tfm.exec.displayParticle(10, x, y, 0, 0, 0, 0, nil)
  216.         for vx = -3, 3 do
  217.             local vy = (math.random(1, 5) / 10) - 2
  218.             firework(id, x, y, vx, vy, ax, ay, magnitude, length, nil)
  219.         end
  220.     end, {}, 1000},
  221.     --{function(id,p,x,y)
  222.         --system.newTimer(function(t,params)
  223.         --  local id,p,x,y = unpack(params)
  224.     --      local minDist = 1
  225.     --      local outerBorder = 40
  226.     --      local maxDist = 60
  227.     --      local totalParticles = 40
  228.     --      for i = 1, totalParticles do
  229.     --          if rand then
  230.     --              id = p[math.random(#p)]
  231.     --          end
  232.     --          local dist = math.min(math.random(minDist, maxDist), outerBorder)
  233.     --          local angle = math.random(0, 360)
  234.     --          local r = math.rad(angle)
  235.     --          local dx = math.cos(r) * dist
  236.     --          local dy = math.sin(r) * dist
  237.     --          local vx = dx / 50
  238.     --          local vy = dy / 50
  239.     --          local ax = -vx / dist / 25
  240.     --          local ay = (-vy / dist / 25) + 0.05
  241.     --          tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
  242.     --      end
  243.         --end, 1000, false, {id, p, x, y})
  244.     --end, {}, 1000}
  245. }
  246.  
  247. fireworkSets = {
  248.     --[[ FORMAT START
  249.     {
  250.         trailId or {trailId1, trailId2}, -- if it's a number, it will pick that, if it's a table, it will pick a random one
  251.         explosionIndex, -- index in explosionData
  252.         probability
  253.     }
  254.     FORMAT END]]--
  255.     {GLITTERS, 1, 5}, -- Star shaped, same color as trail
  256.     {GLITTERS, 2, 0}, -- Spirit
  257.     {GLITTERS, 3, 5}, -- Explosion causes more trails of same color
  258.     {GLITTERS, 4, 5}, -- Star shaped, same color as trail with a second star which may not share a similar color
  259.     {GLITTERS, 5, 0}, -- Star shaped, same color as trail with a second star which may not share a similar color
  260.     {GLITTERS, 6, 2}, -- roses
  261.     {GLITTERS, 7, 50}, -- default firework same color as trail
  262.     {GLITTERS, 8, 20}, -- all colors default firework
  263.     {{0, 2}, 9, 15}, -- white and gold default firework
  264.     {{13,11,2}, 10, 15}, -- red yellow orange
  265.     {{9,0,1}, 11, 15}, -- teal white purple
  266.     {{0, 2}, 12, 0}, -- 2014
  267.     {GLITTERS, 13, 0}, -- face
  268.     {GLITTERS, 14, 0}, -- beard
  269.     {GLITTERS, 15, 0}, -- omo
  270.     --{GLITTERS, 16, 0}
  271. }
  272.  
  273. function velocityEffect(x,y,dx,dy,particles)
  274.     local dist = math.dist(x, y, dx, dy)
  275.     local angle = math.atan2(dy - y, dx - x)
  276.     local vx = dist * math.cos(angle)
  277.     local vy = dist * math.sin(angle)
  278.     local ax = -vx / dist / 15
  279.     local ay = (-vy / dist / 15) + 0.05 -- +0.05 for gravity
  280.     for _,p in ipairs(particles) do
  281.         tfm.exec.displayParticle(p, dx, dy, vx, vy, ax, ay, nil)
  282.     end
  283. end
  284.  
  285. function drawParam1(arg)
  286.     local x,y,a,b,c,d,particles=arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],arg[7]
  287.     local dx,dy,j,k=0,0,3,3
  288.     for t=0,10,0.1 do
  289.         dx=x+(math.cos(a*t)-math.pow(math.cos(b*t),j))*20
  290.         dy=y+(math.sin(c*t)-math.pow(math.sin(d*t),k))*20
  291.         velocityEffect(x,y,dx,dy,particles)
  292.     end
  293. end
  294.  
  295. function drawParam2(arg)
  296.     local x,y,k,a,m,particles=arg[1],arg[2],arg[3],arg[4],arg[5],arg[6]
  297.     local b=a/k
  298.     local dx,dy=0,0
  299.     for t=0,math.pi*4,math.pi/36 do -- step math.pi/18 is every 10 degrees
  300.         dx=x+((a-b)*math.cos(t)+b*math.cos(t*((a/b)-1)))*m
  301.         dy=y+((a-b)*math.sin(t)-b*math.sin(t*((a/b)-1)))*m
  302.         velocityEffect(x,y,dx,dy,particles)
  303.     end
  304. end
  305.  
  306. function roseCurves(arg)
  307.     local x,y,a,n,particles=arg[1],arg[2],arg[3],arg[4],arg[5]
  308.     local dx,dy=0,0
  309.     local intervalTraced = math.pi
  310.     if a % 2 == 0 then
  311.         intervalTraced = math.pi*2
  312.     end
  313.     for t=0,math.pi*4,math.pi/36 do
  314.         --doing sin
  315.         dx=x+a*(math.sin(n*t))*(math.cos(t))
  316.         dy=y+a*(math.sin(n*t))*(math.sin(t))
  317.         velocityEffect(x,y,dx,dy,particles)
  318.     end
  319. end
  320.  
  321. function defaultEffect(id,p,x,y,rand)
  322.     local minDist = 1
  323.     local outerBorder = 20
  324.     local maxDist = 30
  325.     local totalParticles = 75
  326.     for i = 1, totalParticles do
  327.         if rand then
  328.             id = p[math.random(#p)]
  329.         end
  330.         local dist = math.min(math.random(minDist, maxDist), outerBorder)
  331.         local angle = math.random(0, 360)
  332.         local r = math.rad(angle)
  333.         local dx = math.cos(r)
  334.         local dy = math.sin(r)
  335.         local vx = dist * dx / 10
  336.         local vy = dist * dy / 10
  337.         local ax = -vx / dist / 15
  338.         local ay = (-vy / dist / 15) + 0.05
  339.         tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
  340.     end
  341. end
  342.  
  343. function textEffect(id,p,x,y,rand,txt,spread)
  344.     local half = math.floor(#txt / 2)
  345.     local velocitySlowDown = #txt * 6
  346.     local mod2 = #txt % 2
  347.     local widthLetter = 48 -- predefined resolution width of letter (see ASCII_TABLE)
  348.     local shiftX = (1 - mod2) * (widthLetter / 2) -- if #txt is even, we have to shift it half a letter to the right to center it
  349.     local marginBetweenLetters = 5 -- margin between each letter
  350.     -- say if #txt is 4, then loop from -2 to 1
  351.     -- if #txt is 3, then loop from -1 to 1
  352.     for i = -half, half - (1 - mod2) do
  353.         local charIndex = i + half + 1
  354.         local c = txt:sub(charIndex,charIndex)
  355.         local asciiValue = string.byte(c)
  356.         for _,v in pairs(ASCII_TABLE[asciiValue] or ASCII_TABLE[0]) do
  357.             if rand then
  358.                 id = p[math.random(#p)]
  359.             end
  360.             local dx = shiftX + (i * (widthLetter + marginBetweenLetters)) + v[1]
  361.             local dy = v[2]
  362.             local dist = math.sqrt(dy^2 + dx^2) * spread
  363.             local angle = math.atan2(dy, dx)
  364.             local vx = dist * math.cos(angle) / velocitySlowDown
  365.             local vy = dist * math.sin(angle) / velocitySlowDown
  366.             local ax = -vx / dist / 15
  367.             local ay = (-vy / dist / 15) + 0.05 -- +0.05 for gravity
  368.             for j = 1, 3 do
  369.                 tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
  370.             end
  371.         end
  372.     end
  373. end
  374.  
  375. function selectAndFire(x, y, setI)
  376.     local vx = 0
  377.     if setI == nil then
  378.         vx = math.random(-3, 3)
  379.         -- calculate a random set based on probabilities
  380.         local total = 0
  381.         for _,s in ipairs(fireworkSets) do
  382.             total = total + s[3]
  383.         end
  384.         local r = math.random(0, total - 1)
  385.         total = 0
  386.         for i,s in ipairs(fireworkSets) do
  387.             total = total + s[3]
  388.             if total > r then
  389.                 setI = i
  390.                 break
  391.             end
  392.         end
  393.     end
  394.     local fireworkSet = fireworkSets[setI]
  395.     if fireworkSet ~= nil then
  396.         local id = fireworkSet[1]
  397.         if type(id) == 'table' then
  398.             id = id[math.random(#id)]  
  399.         end
  400.         firework(id, x, y, vx, -20, 0, math.random(8, 9) / 10, 5, 30, explosionData[fireworkSet[2]])
  401.     end
  402. end
  403.  
  404. function fireIt(spI)
  405.     local sp = spawnPoints[spI]
  406.     if math.random() < sp[3] * sp[5] then
  407.         selectAndFire(sp[1], sp[2])
  408.     end
  409. end
  410.  
  411. function firework(id, initX, initY, vx, vy, ax, ay, magnitude, length, explosion)
  412.     local params = nil
  413.     local xMultiplier = 3
  414.     if explosion == nil then
  415.         xMultiplier = 5
  416.     end
  417.     -- Launch firework
  418.     for i = magnitude, 1, -1 do
  419.         local timeT = xMultiplier * (-i / magnitude)
  420.         local velX = timeT * ax + vx
  421.         local velY = timeT * ay + vy
  422.         local x = initX + (velX + vx) / 2 * timeT
  423.         local y = initY + (velY + vy) / 2 * timeT
  424.         if params == nil then
  425.             params = {x, y, velX, velY, ax, ay, id} -- we use these to calculate our explosion position
  426.         end
  427.         for j = 1, magnitude - i do
  428.             tfm.exec.displayParticle(id, x, y, velX, velY, ax, ay, nil)
  429.         end
  430.     end
  431.     if explosion ~= nil then
  432.         system.newTimer(function(timerId, expl, params)
  433.             -- local tx = expl[3] / (math.pi * 10) -- guesstimation
  434.             local t = expl[3] / (math.pi * 10)
  435.             local dx = params[3] * t + 0.5 * params[5] * t^2 -- change in x = vxi*changeintime+0.5*ax*t^2
  436.             local x = params[1] + dx
  437.             local dy = params[4] * t + 0.5 * params[6] * t^2 -- change in y = vyi*changeintime+0.5*ay*t^2
  438.             local y = params[2] + dy
  439.  
  440.             local f = expl[1]
  441.             local particles = expl[2]
  442.             f(params[7], particles, x, y)
  443.             system.removeTimer(timerId)
  444.         end, math.max(explosion[3], 1000), false, explosion, params)
  445.     end
  446. end
  447.  
  448. function eventEmotePlayed(n, e)
  449.     local p = tfm.get.room.playerList[n]
  450.     if p ~= nil and not p.isDead and e == 9 then -- confetti
  451.         local x,y = p.x,p.y
  452.         local playerDist = math.dist(x, y, campfire[1], campfire[2])
  453.         if playerDist <= 120 then
  454.             if (x < campfire[1] and p.isFacingRight) or (x >= campfire[1] and not p.isFacingRight) then
  455.                 showFireSparkles(n)
  456.             end
  457.         end
  458.     end
  459. end
  460.  
  461. function showFireSparkles(n)
  462.     players[n].campfireClicks = players[n].campfireClicks + 1
  463.     if players[n].campfireClicks == 5 then
  464.         -- Show image
  465.         local imageId = tfm.exec.addImage(
  466.                 doNotPlayWithFire[1], '!0',
  467.                 (800 - doNotPlayWithFire[2]) / 2,
  468.                 (400 - doNotPlayWithFire[3]) / 2, n)
  469.         system.newTimer(function(t,i) tfm.exec.removeImage(i) end, 15000, false, imageId)
  470.         tfm.exec.killPlayer(n)
  471.     elseif not campfire[3] then
  472.         campfire[3] = true
  473.         system.newTimer(function() campfire[3] = false end, 2000, false)
  474.     end
  475. end
  476.  
  477. function eventMouse(n,x,y)
  478.     local p = tfm.get.room.playerList[n]
  479.     if p ~= nil and not p.isDead then
  480.         if players[n].quote == 0 or os.time() - players[n].quote > 10000 then
  481.             local mouseDist = math.dist(x, y, 725, 278)
  482.             if mouseDist <= 10 then
  483.                 players[n].quote = os.time()
  484.                 tfm.exec.chatMessage('"Fish can mean anything, but in the end, it remains just fish." - Impuredeath', n)
  485.             end
  486.         end
  487.     end
  488. end
  489.  
  490. function eventNewPlayer(n)
  491.     amountOfPlayers = amountOfPlayers + 1
  492.     players[n] = {campfireClicks = 0, quote = 0}
  493.  
  494.     system.bindMouse(n, true)
  495.     addBackground(n)
  496.     local locale = tfm.get.room.community
  497.     local tr = translations[locale] or translations.EN
  498.     tfm.exec.setUIMapName(string.format('%s ~~!', tr.HNY))
  499.     tfm.exec.chatMessage(SCROLLING_TXT, n)
  500.     eventMessage(HELP_MSG, n)
  501.  
  502.     tfm.exec.respawnPlayer(n)
  503. end
  504.  
  505. function addBackground(n)
  506.     tfm.exec.addImage('iyOBqNB.png', '?0', 0, 0, n)
  507. end
  508.  
  509. function eventPlayerLeft(n)
  510.     amountOfPlayers = amountOfPlayers - 1
  511.     players[n] = nil   
  512. end
  513.  
  514. function enable2014()
  515.     -- Enable 2014 and disable specials
  516.     fireworkSets[1][3] = 0
  517.     fireworkSets[3][3] = 0
  518.     fireworkSets[4][3] = 0
  519.     fireworkSets[6][3] = 0
  520.     fireworkSets[7][3] = 0
  521.     fireworkSets[8][3] = 0
  522.     fireworkSets[10][3] = 0
  523.     fireworkSets[11][3] = 0
  524.     fireworkSets[15][3] = 0
  525. end
  526.  
  527. function startAutoFirework()
  528.     local tick = 10 -- back-timers every 100ms
  529.     local s = 1000 / tick
  530.     for t = 0, 1000 - s, s do
  531.         system.newTimer(function()
  532.             system.newTimer(loop, 1000, true)
  533.         end, 1000 + t, false)
  534.     end
  535. end
  536.  
  537. function unpack2(t,i,j) local i,j=i or 1,j or #t if i<=j then return t[i],unpack2(t,i+1,j) end end
  538.  
  539. timedEvents = {}
  540.  
  541. -- timedEvent(milliseconds_to_timeout,repeat,function_to_call,arguments)
  542. function timedEvent(ms, r, f, ...)
  543.     timedEvents[#timedEvents + 1] = {os.time()+ms,r,f,arg,ms}
  544. end
  545.  
  546. function loop()
  547.     local tR = {}
  548.     for i,t in pairs(timedEvents) do
  549.         if t[1] < os.time() then
  550.             t[3](unpack2(t[4]))
  551.             if t[2] == true then
  552.                 t[1] = t[1] + t[5]
  553.             else
  554.                 tR[i] = true
  555.             end
  556.         end
  557.     end
  558.     for i in pairs(tR) do
  559.         timedEvents[i] = nil
  560.     end
  561. end
  562.  
  563. function eventNewGame()
  564.     foreachPlayer(function(n,p)
  565.         eventNewPlayer(n)
  566.     end)
  567.  
  568.     startAutoFirework()
  569.  
  570.     -- Preload all images so it doesn't blink
  571.     for _,i in ipairs(progressBar) do
  572.         for _,j in ipairs(i) do
  573.             tfm.exec.addImage(j .. '.png', '#-1', 0, 0)
  574.         end
  575.     end
  576. end
  577.  
  578. counter = 0
  579.  
  580. function eventLoop(timeElapsed, timeRemaining)
  581.     -- Plan the next 3s fireworks based on SPEED
  582.     if counter % 3 == 0 and counter <= MAX_TIME - 23 then
  583.         local b = 2000
  584.         local e = b + 3000
  585.         for i,sp in pairs(spawnPoints) do
  586.             for j = b, e, 1000 / (sp[4] + (sp[5] - 0.5) * 3) do
  587.                 timedEvent(j, false, function(i)
  588.                     fireIt(i)
  589.                 end, i)
  590.             end
  591.         end
  592.     end
  593.     -- Increase progress bars
  594.     for i,sp in pairs(spawnPoints) do
  595.         local x,y = sp[1],sp[2]
  596.         local nearbyPlayers = 0
  597.         for _,p in pairs(tfm.get.room.playerList) do
  598.             if not p.isDead and math.dist(x, y, p.x, p.y) < sp[9] then
  599.                 nearbyPlayers = nearbyPlayers + 1
  600.             end
  601.         end
  602.         local decr = 0
  603.         if counter % 1 == 0 then
  604.             decr = 0.02
  605.         end
  606.         local incr = nearbyPlayers * 0.025
  607.         local progress = math.max(math.min(sp[5] + incr - decr, 0.99), 0.5)
  608.         -- Show the correct bar
  609.         local imgIndex = math.floor((progress - 0.5) / 0.05) + 1
  610.         if sp[8] >= 0 then
  611.             tfm.exec.removeImage(sp[8])
  612.         end
  613.         local img = progressBar[i][imgIndex] .. '.png'
  614.         sp[8] = tfm.exec.addImage(img, '?' .. i, sp[6], sp[7], nil)
  615.         sp[5] = progress
  616.     end
  617.     -- Show campfire particles
  618.     if campfire[3] then
  619.         local ids = campfire[4]
  620.         for i = 1, 5 do
  621.             local x = campfire[1] + math.random(-15, 15)
  622.             local y = campfire[2] - math.random(0, 10) - 5
  623.             local vx = math.random(-1, 1) / 10
  624.             local vy = -(math.random(50, 100) / 100)
  625.             for j = 1, 2 do
  626.                 tfm.exec.displayParticle(ids[math.random(#ids)], x, y, vx, vy, 0, 0, nil)
  627.             end
  628.         end
  629.     end
  630.     -- Switch stages
  631.     if stage == 2 and timeRemaining < 0 then
  632.         system.exit(0)
  633.     elseif stage == 1 and timeRemaining < 4000 then
  634.         -- Fire 2014
  635.         selectAndFire(138, 327, 9)
  636.         selectAndFire(371, 332, 12)
  637.         selectAndFire(603, 248, 9)
  638.         stage = 2
  639.     elseif stage == 0 and timeRemaining < 17000 then
  640.         enable2014()
  641.         stage = 1
  642.     end
  643.     counter = counter + 0.5
  644. end
  645.  
  646. function eventMessage(msg,n)
  647.     local locale = tfm.get.room.community
  648.     local tr = translations[locale] or translations.EN
  649.     tfm.exec.chatMessage(string.format('<J>&#8226; [%s] %s', tr.EVENT or translations.EN.EVENT, msg), n)
  650. end
  651.  
  652. function main()
  653.     math.randomseed(os.time())
  654.     local locale = tfm.get.room.community
  655.     local tr = translations[locale] or translations.EN
  656.     SCROLLING_TXT = string.format(SCROLLING_TXT, tr.EVENT, tr.HNY, string.format(tr.BTYB, string.format(NAMES, tr.AND)))
  657.     HELP_MSG = tr.HELP or translations.EN.HELP
  658.  
  659.     tfm.exec.disableAutoNewGame(true)
  660.     tfm.exec.disableAfkDeath(true)
  661.     tfm.exec.disableAutoTimeLeft(true)
  662.     tfm.exec.disableAutoShaman(true)
  663.     debug.disableEventLog(true)
  664.     debug.disableTimerLog(true)
  665.  
  666.     tfm.exec.newGame('@4628876')
  667.     tfm.exec.setGameTime(MAX_TIME, true)
  668. end
  669.  
  670. -- HELP FUNCTIONS
  671.  
  672. function math.dist(x1, y1, x2, y2)
  673.     return math.sqrt((y2 - y1)^2 + (x2 - x1)^2)
  674. end
  675.  
  676. function split(input, sep)
  677.     local res = {}
  678.     for part in string.gmatch(input, "[^" .. sep .. "]+") do
  679.         table.insert(res, part)
  680.     end
  681.     return res
  682. end
  683.  
  684. function unpack(t, i)
  685.     i = i or 1
  686.     if t[i] ~= nil then
  687.         return t[i], unpack(t, i + 1)
  688.     end
  689. end
  690.  
  691. function foreachPlayer(f, ...)
  692.     for n,p in pairs(tfm.get.room.playerList) do
  693.         f(n,p,arg) 
  694.     end
  695. end
  696.  
  697. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement