Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GLITTERS = {0, 1, 2, 9, 11, 13}
- SCROLLING_TXT = '<J>• [%s] %s~~! %s'
- HELP_MSG = ''
- NAMES = '<V>Impuredeath<J>, <V>Evilsantah<J>, <V>Paperonaruto<J>, <V>Fierying<J> %s <V>Thewav<J>'
- MAX_TIME = 90
- translations = {
- EN={
- EVENT='Event',
- HNY='Happy New Year',
- BTYB='Greetings from %s.',
- AND='and',
- HELP='Gather around the barrels to ignite more fireworks!'
- },
- BR={
- EVENT='Evento',
- HNY='Feliz ano novo',
- BTYB='Saudações %s.',
- AND='e',
- HELP='Fique perto dos barrís para acender mais fogos de artifício!'
- },
- ES={
- EVENT='Evento',
- HNY='¡Feliz año nuevo',
- BTYB='Saludos de %s.',
- AND='y',
- HELP='Reúnanse alrededor de los barriles para encender más fuegos artificiales!'
- },
- NL={
- EVENT='Evenement',
- HNY='Gelukkig nieuwjaar',
- BTYB='Groeten van %s.',
- AND='en',
- HELP='Kom bijeen rond de tonnen om meer vuurwerk af te schieten!'
- },
- DE={
- EVENT='Ereignis',
- HNY='Frohes neues Jahr',
- BTYB='Die besten Wünsche von %s.',
- AND='und',
- HELP='Versammelt euch sich um die Fässer, um mehr Feuerwerk zu zünden!'
- },
- FR={
- EVENT='Événement',
- HNY='Bonne année',
- BTYB='Salutations de %s.',
- AND='et',
- HELP="Rassemblez-vous autour des tonneaux pour allumer plus de feux d'artifice!"
- },
- TR={
- EVENT='Etkinlik',
- HNY='Mutlu Yıllar',
- BTYB="%s'dan sevgiler.",
- AND='ve',
- HELP='Daha fazla havai fişek toplamak için varil etrafında toplanın!'
- },
- RU={
- EVENT='Событие',
- HNY='С Новым Годом',
- BTYB='Вас приветствует %s.',
- AND='и',
- HELP='Подойди к бочкам, чтобы зажечь больше фейерверков!'
- },
- RO={
- EVENT='Evenimentului',
- HNY='An nou fericit',
- BTYB='Salutări din partea %s.',
- AND='și',
- HELP='Aduna-ți pe lângă butoaie pentru a câștiga mai multe petarde!'
- },
- CN={
- EVENT='活动',
- HNY='新年快樂',
- BTYB='來自 %s 的祝賀.',
- AND='和',
- HELP='聚集到到桶边上点燃更多的烟花!'
- },
- VK={
- EVENT='Event',
- HNY='Godt nyttår',
- BTYB='Hilsener fra %s.',
- AND='og',
- HELP='Stå i nærheten av fatene for å tenne flere fyrverkerier!'
- },
- ID={
- EVENT='Event',
- HNY='Selamat tahun baru',
- BTYB='Salam dari %s.',
- AND='dan',
- HELP='Berkumpul di sekitar barel untuk membuat lebih banyak kembang api!'
- },
- PL={
- EVENT='Event',
- HNY='Szczęśliwego nowego roku',
- BTYB='Pozdrowienia od %s.',
- AND='i',
- HELP='Zbieraj beczki aby zapalić więcej fajerwerków!'
- },
- HU={
- EVENT='Event',
- HNY='Boldog új évet',
- BTYB='Üdvözlettel %s',
- AND='és',
- HELP='Gyűljetek a hordók köré, hogy minél több tűzijátékot gyújtsatok meg!'
- }
- }
- ASCII_TABLE = {}
- ASCII_TABLE[0] = {{0,0}} -- null / unknown
- 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}}
- 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}}
- 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}}
- 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}}
- -- kitten face
- --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}}
- -- here the beard
- --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}}
- spawnPoints = {
- -- {x, y, chance, speed, progress, imageX, imageY, imageId, activateDist}
- {138, 327, 0.6, 2.5, 0.5, 130, 333, -1, 60},
- {371, 332, 0.6, 2.5, 0.5, 348, 336, -1, 80},
- {603, 248, 0.4, 1.5, 0.5, 604, 232, -1, 80}
- }
- progressBar = {
- {'EOrEVag','87mhCpM','73bbnyB','aVmxoAp','PFPlg6F','Sdi1sYn','kPidpoF','W9XtCSg','sWrpZ34','EPMFLbm'},
- {'ds8x5O8','NzStPko','ifPHNrw','eO27MmL','P7ENw2t','wmOiu6a','sznK1Y6','IEjKbx0','oL3j80f','Nm4ycAx'},
- {'fADvU4o','yoM0vq1','X3nOVBu','4eh6fL7','n3tZ6DN','vAPnHQR','D9KQ0Q0','7UFeYVS','mF1cHX6','exzhslj'}
- }
- campfire = {695, 376, false, {2, 13}}
- players = {}
- amountOfPlayers = 0
- stage = 0
- doNotPlayWithFire = {'qb61bSY.png', 480, 370}
- explosionData = {
- --[[ FORMAT START
- {
- function(trailParticleId,extraParticles,centerX,centerY)
- -- trailParticleId is the particle id from the trail
- -- extraParticles gets passed on from this table to this function
- -- centerX is the center X coordinate from the explosion
- -- centerY ............. Y .............................
- -- do stuff here
- end,
- extraParticles,
- timeBeforeExplosion
- }
- FORMAT END ]]--
- {function(id,p,x,y) -- Star shaped, same color as trail
- drawParam2({x, y, 7.0, 0.4, 10, {id}})
- end, {}, 1000},
- {function(id,p,x,y) -- Spirit
- tfm.exec.displayParticle(10, x, y, 0, 0, 0, 0, nil)
- end, {}, 1000},
- {function(id,p,x,y) -- Explosion causes more trails of same color
- local ax = 0
- local ay = 0.15
- local magnitude = 4
- local length = 10
- for vx = -3, 3 do
- local vy = (math.random(1, 5) / 10) - 2
- firework(id, x, y, vx, vy, ax, ay, magnitude, length, nil)
- end
- end, {}, 1000},
- {function(id,p,x,y) -- Star shaped, same color as trail with a second star which may not share a similar color
- local randomParticle = p[math.random(#p)]
- drawParam2({x, y, 6.0, 0.4, 7, {id}})
- drawParam2({x, y, 6.0, 0.4, 10, {randomParticle}})
- end, GLITTERS, 1000},
- {function(id,p,x,y) -- i have no idea what this will end up kay
- local randomParticle = p[math.random(#p)]
- drawParam2({x, y, 6.0, 0.4, 9, {id}})
- drawParam2({x, y, 6.0, 0.4, 10, {randomParticle}})
- end, GLITTERS, 1000},
- {function(id,p,x,y) -- its beautiful
- local randomParticle = p[math.random(#p)]
- roseCurves({x, y, 3,3, {id}})
- roseCurves({x, y, 5,5, {randomParticle}})
- end, GLITTERS, 1000},
- {function(id,p,x,y) -- Default firework, same color as trail
- defaultEffect(id,p,x,y,false)
- end, {}, 1000},
- {function(id,p,x,y) -- Mixed colors default firework
- defaultEffect(id,p,x,y,true)
- end, GLITTERS, 1000},
- {function(id,p,x,y) -- White/golden default firework
- defaultEffect(id,p,x,y,true)
- end, {0,2}, 1000},
- {function(id,p,x,y) -- Red/yellow/orange default firework
- defaultEffect(id,p,x,y,true)
- end, {13,11,2}, 1000},
- {function(id,p,x,y) -- Teal/white/purple default firework
- defaultEffect(id,p,x,y,true)
- end, {9,0,1}, 1000},
- {function(id,p,x,y) -- 2014
- textEffect(id,p,x,y,true,'2014',2)
- end, {0, 2}, 1000},
- {function(id,p,x,y) -- face
- textEffect(id,p,x,y,false,'f',1)
- end, GLITTERS, 1000},
- {function(id,p,x,y) -- beard
- textEffect(id,p,x,y,false,'b',1)
- end, GLITTERS, 1000},
- {function(id,p,x,y) -- Explosion causes more trails of same color with spirit
- local ax = 0
- local ay = 0.15
- local magnitude = 4
- local length = 10
- tfm.exec.displayParticle(10, x, y, 0, 0, 0, 0, nil)
- for vx = -3, 3 do
- local vy = (math.random(1, 5) / 10) - 2
- firework(id, x, y, vx, vy, ax, ay, magnitude, length, nil)
- end
- end, {}, 1000},
- --{function(id,p,x,y)
- --system.newTimer(function(t,params)
- -- local id,p,x,y = unpack(params)
- -- local minDist = 1
- -- local outerBorder = 40
- -- local maxDist = 60
- -- local totalParticles = 40
- -- for i = 1, totalParticles do
- -- if rand then
- -- id = p[math.random(#p)]
- -- end
- -- local dist = math.min(math.random(minDist, maxDist), outerBorder)
- -- local angle = math.random(0, 360)
- -- local r = math.rad(angle)
- -- local dx = math.cos(r) * dist
- -- local dy = math.sin(r) * dist
- -- local vx = dx / 50
- -- local vy = dy / 50
- -- local ax = -vx / dist / 25
- -- local ay = (-vy / dist / 25) + 0.05
- -- tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
- -- end
- --end, 1000, false, {id, p, x, y})
- --end, {}, 1000}
- }
- fireworkSets = {
- --[[ FORMAT START
- {
- trailId or {trailId1, trailId2}, -- if it's a number, it will pick that, if it's a table, it will pick a random one
- explosionIndex, -- index in explosionData
- probability
- }
- FORMAT END]]--
- {GLITTERS, 1, 5}, -- Star shaped, same color as trail
- {GLITTERS, 2, 0}, -- Spirit
- {GLITTERS, 3, 5}, -- Explosion causes more trails of same color
- {GLITTERS, 4, 5}, -- Star shaped, same color as trail with a second star which may not share a similar color
- {GLITTERS, 5, 0}, -- Star shaped, same color as trail with a second star which may not share a similar color
- {GLITTERS, 6, 2}, -- roses
- {GLITTERS, 7, 50}, -- default firework same color as trail
- {GLITTERS, 8, 20}, -- all colors default firework
- {{0, 2}, 9, 15}, -- white and gold default firework
- {{13,11,2}, 10, 15}, -- red yellow orange
- {{9,0,1}, 11, 15}, -- teal white purple
- {{0, 2}, 12, 0}, -- 2014
- {GLITTERS, 13, 0}, -- face
- {GLITTERS, 14, 0}, -- beard
- {GLITTERS, 15, 0}, -- omo
- --{GLITTERS, 16, 0}
- }
- function velocityEffect(x,y,dx,dy,particles)
- local dist = math.dist(x, y, dx, dy)
- local angle = math.atan2(dy - y, dx - x)
- local vx = dist * math.cos(angle)
- local vy = dist * math.sin(angle)
- local ax = -vx / dist / 15
- local ay = (-vy / dist / 15) + 0.05 -- +0.05 for gravity
- for _,p in ipairs(particles) do
- tfm.exec.displayParticle(p, dx, dy, vx, vy, ax, ay, nil)
- end
- end
- function drawParam1(arg)
- local x,y,a,b,c,d,particles=arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],arg[7]
- local dx,dy,j,k=0,0,3,3
- for t=0,10,0.1 do
- dx=x+(math.cos(a*t)-math.pow(math.cos(b*t),j))*20
- dy=y+(math.sin(c*t)-math.pow(math.sin(d*t),k))*20
- velocityEffect(x,y,dx,dy,particles)
- end
- end
- function drawParam2(arg)
- local x,y,k,a,m,particles=arg[1],arg[2],arg[3],arg[4],arg[5],arg[6]
- local b=a/k
- local dx,dy=0,0
- for t=0,math.pi*4,math.pi/36 do -- step math.pi/18 is every 10 degrees
- dx=x+((a-b)*math.cos(t)+b*math.cos(t*((a/b)-1)))*m
- dy=y+((a-b)*math.sin(t)-b*math.sin(t*((a/b)-1)))*m
- velocityEffect(x,y,dx,dy,particles)
- end
- end
- function roseCurves(arg)
- local x,y,a,n,particles=arg[1],arg[2],arg[3],arg[4],arg[5]
- local dx,dy=0,0
- local intervalTraced = math.pi
- if a % 2 == 0 then
- intervalTraced = math.pi*2
- end
- for t=0,math.pi*4,math.pi/36 do
- --doing sin
- dx=x+a*(math.sin(n*t))*(math.cos(t))
- dy=y+a*(math.sin(n*t))*(math.sin(t))
- velocityEffect(x,y,dx,dy,particles)
- end
- end
- function defaultEffect(id,p,x,y,rand)
- local minDist = 1
- local outerBorder = 20
- local maxDist = 30
- local totalParticles = 75
- for i = 1, totalParticles do
- if rand then
- id = p[math.random(#p)]
- end
- local dist = math.min(math.random(minDist, maxDist), outerBorder)
- local angle = math.random(0, 360)
- local r = math.rad(angle)
- local dx = math.cos(r)
- local dy = math.sin(r)
- local vx = dist * dx / 10
- local vy = dist * dy / 10
- local ax = -vx / dist / 15
- local ay = (-vy / dist / 15) + 0.05
- tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
- end
- end
- function textEffect(id,p,x,y,rand,txt,spread)
- local half = math.floor(#txt / 2)
- local velocitySlowDown = #txt * 6
- local mod2 = #txt % 2
- local widthLetter = 48 -- predefined resolution width of letter (see ASCII_TABLE)
- local shiftX = (1 - mod2) * (widthLetter / 2) -- if #txt is even, we have to shift it half a letter to the right to center it
- local marginBetweenLetters = 5 -- margin between each letter
- -- say if #txt is 4, then loop from -2 to 1
- -- if #txt is 3, then loop from -1 to 1
- for i = -half, half - (1 - mod2) do
- local charIndex = i + half + 1
- local c = txt:sub(charIndex,charIndex)
- local asciiValue = string.byte(c)
- for _,v in pairs(ASCII_TABLE[asciiValue] or ASCII_TABLE[0]) do
- if rand then
- id = p[math.random(#p)]
- end
- local dx = shiftX + (i * (widthLetter + marginBetweenLetters)) + v[1]
- local dy = v[2]
- local dist = math.sqrt(dy^2 + dx^2) * spread
- local angle = math.atan2(dy, dx)
- local vx = dist * math.cos(angle) / velocitySlowDown
- local vy = dist * math.sin(angle) / velocitySlowDown
- local ax = -vx / dist / 15
- local ay = (-vy / dist / 15) + 0.05 -- +0.05 for gravity
- for j = 1, 3 do
- tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
- end
- end
- end
- end
- function selectAndFire(x, y, setI)
- local vx = 0
- if setI == nil then
- vx = math.random(-3, 3)
- -- calculate a random set based on probabilities
- local total = 0
- for _,s in ipairs(fireworkSets) do
- total = total + s[3]
- end
- local r = math.random(0, total - 1)
- total = 0
- for i,s in ipairs(fireworkSets) do
- total = total + s[3]
- if total > r then
- setI = i
- break
- end
- end
- end
- local fireworkSet = fireworkSets[setI]
- if fireworkSet ~= nil then
- local id = fireworkSet[1]
- if type(id) == 'table' then
- id = id[math.random(#id)]
- end
- firework(id, x, y, vx, -20, 0, math.random(8, 9) / 10, 5, 30, explosionData[fireworkSet[2]])
- end
- end
- function fireIt(spI)
- local sp = spawnPoints[spI]
- if math.random() < sp[3] * sp[5] then
- selectAndFire(sp[1], sp[2])
- end
- end
- function firework(id, initX, initY, vx, vy, ax, ay, magnitude, length, explosion)
- local params = nil
- local xMultiplier = 3
- if explosion == nil then
- xMultiplier = 5
- end
- -- Launch firework
- for i = magnitude, 1, -1 do
- local timeT = xMultiplier * (-i / magnitude)
- local velX = timeT * ax + vx
- local velY = timeT * ay + vy
- local x = initX + (velX + vx) / 2 * timeT
- local y = initY + (velY + vy) / 2 * timeT
- if params == nil then
- params = {x, y, velX, velY, ax, ay, id} -- we use these to calculate our explosion position
- end
- for j = 1, magnitude - i do
- tfm.exec.displayParticle(id, x, y, velX, velY, ax, ay, nil)
- end
- end
- if explosion ~= nil then
- system.newTimer(function(timerId, expl, params)
- -- local tx = expl[3] / (math.pi * 10) -- guesstimation
- local t = expl[3] / (math.pi * 10)
- local dx = params[3] * t + 0.5 * params[5] * t^2 -- change in x = vxi*changeintime+0.5*ax*t^2
- local x = params[1] + dx
- local dy = params[4] * t + 0.5 * params[6] * t^2 -- change in y = vyi*changeintime+0.5*ay*t^2
- local y = params[2] + dy
- local f = expl[1]
- local particles = expl[2]
- f(params[7], particles, x, y)
- system.removeTimer(timerId)
- end, math.max(explosion[3], 1000), false, explosion, params)
- end
- end
- function eventEmotePlayed(n, e)
- local p = tfm.get.room.playerList[n]
- if p ~= nil and not p.isDead and e == 9 then -- confetti
- local x,y = p.x,p.y
- local playerDist = math.dist(x, y, campfire[1], campfire[2])
- if playerDist <= 120 then
- if (x < campfire[1] and p.isFacingRight) or (x >= campfire[1] and not p.isFacingRight) then
- showFireSparkles(n)
- end
- end
- end
- end
- function showFireSparkles(n)
- players[n].campfireClicks = players[n].campfireClicks + 1
- if players[n].campfireClicks == 5 then
- -- Show image
- local imageId = tfm.exec.addImage(
- doNotPlayWithFire[1], '!0',
- (800 - doNotPlayWithFire[2]) / 2,
- (400 - doNotPlayWithFire[3]) / 2, n)
- system.newTimer(function(t,i) tfm.exec.removeImage(i) end, 15000, false, imageId)
- tfm.exec.killPlayer(n)
- elseif not campfire[3] then
- campfire[3] = true
- system.newTimer(function() campfire[3] = false end, 2000, false)
- end
- end
- function eventMouse(n,x,y)
- local p = tfm.get.room.playerList[n]
- if p ~= nil and not p.isDead then
- if players[n].quote == 0 or os.time() - players[n].quote > 10000 then
- local mouseDist = math.dist(x, y, 725, 278)
- if mouseDist <= 10 then
- players[n].quote = os.time()
- tfm.exec.chatMessage('"Fish can mean anything, but in the end, it remains just fish." - Impuredeath', n)
- end
- end
- end
- end
- function eventNewPlayer(n)
- amountOfPlayers = amountOfPlayers + 1
- players[n] = {campfireClicks = 0, quote = 0}
- system.bindMouse(n, true)
- addBackground(n)
- local locale = tfm.get.room.community
- local tr = translations[locale] or translations.EN
- tfm.exec.setUIMapName(string.format('%s ~~!', tr.HNY))
- tfm.exec.chatMessage(SCROLLING_TXT, n)
- eventMessage(HELP_MSG, n)
- tfm.exec.respawnPlayer(n)
- end
- function addBackground(n)
- tfm.exec.addImage('iyOBqNB.png', '?0', 0, 0, n)
- end
- function eventPlayerLeft(n)
- amountOfPlayers = amountOfPlayers - 1
- players[n] = nil
- end
- function enable2014()
- -- Enable 2014 and disable specials
- fireworkSets[1][3] = 0
- fireworkSets[3][3] = 0
- fireworkSets[4][3] = 0
- fireworkSets[6][3] = 0
- fireworkSets[7][3] = 0
- fireworkSets[8][3] = 0
- fireworkSets[10][3] = 0
- fireworkSets[11][3] = 0
- fireworkSets[15][3] = 0
- end
- function startAutoFirework()
- local tick = 10 -- back-timers every 100ms
- local s = 1000 / tick
- for t = 0, 1000 - s, s do
- system.newTimer(function()
- system.newTimer(loop, 1000, true)
- end, 1000 + t, false)
- end
- end
- 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
- timedEvents = {}
- -- timedEvent(milliseconds_to_timeout,repeat,function_to_call,arguments)
- function timedEvent(ms, r, f, ...)
- timedEvents[#timedEvents + 1] = {os.time()+ms,r,f,arg,ms}
- end
- function loop()
- local tR = {}
- for i,t in pairs(timedEvents) do
- if t[1] < os.time() then
- t[3](unpack2(t[4]))
- if t[2] == true then
- t[1] = t[1] + t[5]
- else
- tR[i] = true
- end
- end
- end
- for i in pairs(tR) do
- timedEvents[i] = nil
- end
- end
- function eventNewGame()
- foreachPlayer(function(n,p)
- eventNewPlayer(n)
- end)
- startAutoFirework()
- -- Preload all images so it doesn't blink
- for _,i in ipairs(progressBar) do
- for _,j in ipairs(i) do
- tfm.exec.addImage(j .. '.png', '#-1', 0, 0)
- end
- end
- end
- counter = 0
- function eventLoop(timeElapsed, timeRemaining)
- -- Plan the next 3s fireworks based on SPEED
- if counter % 3 == 0 and counter <= MAX_TIME - 23 then
- local b = 2000
- local e = b + 3000
- for i,sp in pairs(spawnPoints) do
- for j = b, e, 1000 / (sp[4] + (sp[5] - 0.5) * 3) do
- timedEvent(j, false, function(i)
- fireIt(i)
- end, i)
- end
- end
- end
- -- Increase progress bars
- for i,sp in pairs(spawnPoints) do
- local x,y = sp[1],sp[2]
- local nearbyPlayers = 0
- for _,p in pairs(tfm.get.room.playerList) do
- if not p.isDead and math.dist(x, y, p.x, p.y) < sp[9] then
- nearbyPlayers = nearbyPlayers + 1
- end
- end
- local decr = 0
- if counter % 1 == 0 then
- decr = 0.02
- end
- local incr = nearbyPlayers * 0.025
- local progress = math.max(math.min(sp[5] + incr - decr, 0.99), 0.5)
- -- Show the correct bar
- local imgIndex = math.floor((progress - 0.5) / 0.05) + 1
- if sp[8] >= 0 then
- tfm.exec.removeImage(sp[8])
- end
- local img = progressBar[i][imgIndex] .. '.png'
- sp[8] = tfm.exec.addImage(img, '?' .. i, sp[6], sp[7], nil)
- sp[5] = progress
- end
- -- Show campfire particles
- if campfire[3] then
- local ids = campfire[4]
- for i = 1, 5 do
- local x = campfire[1] + math.random(-15, 15)
- local y = campfire[2] - math.random(0, 10) - 5
- local vx = math.random(-1, 1) / 10
- local vy = -(math.random(50, 100) / 100)
- for j = 1, 2 do
- tfm.exec.displayParticle(ids[math.random(#ids)], x, y, vx, vy, 0, 0, nil)
- end
- end
- end
- -- Switch stages
- if stage == 2 and timeRemaining < 0 then
- system.exit(0)
- elseif stage == 1 and timeRemaining < 4000 then
- -- Fire 2014
- selectAndFire(138, 327, 9)
- selectAndFire(371, 332, 12)
- selectAndFire(603, 248, 9)
- stage = 2
- elseif stage == 0 and timeRemaining < 17000 then
- enable2014()
- stage = 1
- end
- counter = counter + 0.5
- end
- function eventMessage(msg,n)
- local locale = tfm.get.room.community
- local tr = translations[locale] or translations.EN
- tfm.exec.chatMessage(string.format('<J>• [%s] %s', tr.EVENT or translations.EN.EVENT, msg), n)
- end
- function main()
- math.randomseed(os.time())
- local locale = tfm.get.room.community
- local tr = translations[locale] or translations.EN
- SCROLLING_TXT = string.format(SCROLLING_TXT, tr.EVENT, tr.HNY, string.format(tr.BTYB, string.format(NAMES, tr.AND)))
- HELP_MSG = tr.HELP or translations.EN.HELP
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.disableAutoShaman(true)
- debug.disableEventLog(true)
- debug.disableTimerLog(true)
- tfm.exec.newGame('@4628876')
- tfm.exec.setGameTime(MAX_TIME, true)
- end
- -- HELP FUNCTIONS
- function math.dist(x1, y1, x2, y2)
- return math.sqrt((y2 - y1)^2 + (x2 - x1)^2)
- end
- function split(input, sep)
- local res = {}
- for part in string.gmatch(input, "[^" .. sep .. "]+") do
- table.insert(res, part)
- end
- return res
- end
- function unpack(t, i)
- i = i or 1
- if t[i] ~= nil then
- return t[i], unpack(t, i + 1)
- end
- end
- function foreachPlayer(f, ...)
- for n,p in pairs(tfm.get.room.playerList) do
- f(n,p,arg)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement