Advertisement
Rawoas13

[Event] Christmas

Jan 19th, 2020
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.40 KB | None | 0 0
  1. --[[ Titles ]]--
  2. title = {
  3.     [1] = "titre_noel_elfette",
  4. }
  5.  
  6. --[[ Lib ]]--
  7. math.pythag = function(x1,y1,x2,y2,range)
  8.     return ((x1-x2)^2+(y1-y2)^2<range^2)
  9. end
  10. math.percent = function(x,of,total)
  11.     return (x/of)*total
  12. end
  13. math.isNegative = function(x,iN,iP)
  14.     return (x<0 and iN or iP)
  15. end
  16.  
  17. table.random = function(t)
  18.     return t[math.random(#t)]
  19. end
  20. table.destroy=function(list,value)
  21.     for k,v in next,list do
  22.         if v == value then
  23.             table.remove(list,k);break
  24.         end
  25.     end
  26. end
  27.  
  28. system.players = function()
  29.     local p = 0
  30.     for k,v in next,tfm.get.room.playerList do
  31.         p = p + 1
  32.     end
  33.     return p
  34. end
  35.  
  36. system.looping = function(f,tk)
  37.     local s = 1000 / tk
  38.     local t = {}
  39.     for timer = 0,1000-s,s do
  40.         system.newTimer(function() t[#t+1] = system.newTimer(f,1000,true) end,1000+timer,false)
  41.     end
  42.     return t
  43. end
  44.  
  45. --[[ Database ]]--
  46. info = {}
  47.  
  48. serialization = function(x)
  49.     if type(x) == "table" then
  50.         local t = x
  51.         local str = ""
  52.         for index,value in next,t do
  53.             local prefix,tbOption = (type(value)=="string" and "_@" or type(value)=="boolean" and "_!" or type(value)=="number" and "_#" or type(value)=="table" and "_%" or ""),(type(value)~="table" and tostring(value) or "+&"..serialization(value):gsub(";","?").."&-")
  54.             str = str .. ':' .. tostring(index) .. prefix .. tbOption .. ";"
  55.         end
  56.         return str
  57.     elseif type(x) == "string" then
  58.         local s = x
  59.         local list = {}
  60.         for str in s:gmatch("(.-);") do
  61.             local varName,valueType,value = str:match(':(.-)_(%p)(.+)')
  62.             if varName~=nil then
  63.                 varName = tonumber(varName) or varName
  64.                 if valueType == "@" then
  65.                     list[varName] = tostring(value)
  66.                 elseif valueType == "!" then
  67.                     list[varName] = value=="true"
  68.                 elseif valueType == "#" then
  69.                     list[varName] = tonumber(value)
  70.                 elseif valueType == "%" then
  71.                     list[varName] = serialization(value:gsub("+&",""):gsub("&-",""):gsub("%?",";"))
  72.                 end
  73.             end
  74.         end
  75.         return list
  76.     end
  77. end
  78.  
  79. eventPlayerDataLoaded = function(n,d)
  80.     if d ~= "" and d:find(":eventNoelGifts") then
  81.         info[n].db = serialization(d)
  82.     else
  83.         system.savePlayerData(n,serialization(info[n].db))
  84.     end
  85.     info[n].dataLoaded = true
  86.     system.updateBar(n)
  87. end
  88.  
  89. --[[ Sets ]]--
  90. for i,f in next,{"AutoShaman","AfkDeath","MortCommand","AutoTimeLeft"} do
  91.     tfm.exec["disable"..f]()
  92. end
  93.  
  94. local santaMessage = "<V><B>[^_^]</B></V> <BV>%s</BV>\n<V><B>[S4NT4 M4U5]</B></V> <R>%s</R>"
  95. local langue = {
  96.     en = {"Merry Christmas & Happy New Year!","Christmas is approaching and S4nt4 has a lot to do on his <I>paws</I>. He wants to give all the gifts on time, but he must be fast! Since our dear S4nt4 is clumsy, some gifts will fall and you will have to <CE>collect</CE> them by pressing the <I>space bar</I>! Give the gifts back to S4nt4 when he feels <CE>dizzy</CE> by pressing the <I>space bar</I>!"},
  97.     fr = {"Joyeux Noël et Bonne Année!","Noël approche et S4nt4 en a plein les <I>pattes</I>. Il veut donner tous les cadeaux à temps, mais il doit être rapide ! Puisque notre cher S4nt4 est maladroix, certains cadeaux tombent et vous devrez les, <CE>collecter</CE> en appuyant sur la <I>barre d'espace</I>! Donnez les cadeaux à S4nt4 quand il se sent <CE>étourdi</CE> en appuyant sur la <I>barre d'espace</I>!"},
  98.     br = {"Feliz Natal & Feliz Ano Novo!","O Natal está chegando e S4nt4 tem em suas <I>patas</I> muito o que fazer. Ele quer entregar todos os presentes a tempo, mas ele deve ser rápido! Uma vez que nosso querido S4NT4 é desajeitado, alguns presentes cairão e você terá que <CE>coletá-los</CE> pressionando a <I>barra de espaço</I>! Devolva os presentes ao S4nt4, pressionando a <I>barra de espaço</I>, quando ele se sentir <CE>tonto</CE>!"},
  99.     es = {"¡Feliz Navidad y Próspero Año Nuevo!","La Navidad se está acercando y S4nt4 tiene muchas cosas que hacer con sus <I>patas</I>. Él quiere dar todos los regalos a tiempo, pero debe ser rápido! Puesto que nuestro querido S4nt4 es torpe, algunos regalos caerán y tendrás que <CE>recogerlos</CE> pulsando la <I>barra espaciadora</I>! Regrese los regalos a S4nt4 cuando se sienta <CE>mareado</CE> presionando la <I>barra de espacio</I>!"},
  100.     tr = {"Mutlu Noeller & Mutlu Yıllar!","Noel geliyor ve S4nt4'nın <I>patilerinde</I> yapacağı çok işi var. Bütün hediyeleri zamanında vermek istiyor ama hızlı olması gerek! Sevgili S4nt4'mız sakar olduğu için, bazı hediyeler düşecek ve <I>boşluk tuşuna</I> basarak onları <CE>toplamanız</CE> gerekecek! S4nt4'nın <CE>başı döndüğünde</CE> <I>boşluk tuşuna</I> basarak hediyeleri ona geri verin!"},
  101.     pl = {"Wesołych Świąt i Wesołego Nowego Roku!","Święta nadchodzą, a S4nt4 ma <I>łapki</I> pełne roboty. On chce dać wszystkim prezenty na czas, ale musi się pośpieszyć! Od kiedy nasz S4nt4 jest niezdarny, gubi prezenty, które musicie <CE>pozbierać</CE> wciskając <I>spację</I>! Oddajcie prezenty S4nt4 kiedy jest <CE>oszołomiony</CE> wciskając <I>spację</I>!"},
  102.     ar = {"عيد ميلاد مجيدا و كل عام و أنتم بخير","عيد الميلاد اقترب و<I> يدى </I> سانتا مليئة. يريد سانتا تسليم جميع الهدايا على الوقت, ولكن يجب ان يكون سريعا! ولكن صديقنا العزيز سانتا غير بارع في تسليم الهدايا, بعض الهدايا ستسقط وعليك ان تقوم <CE> بجمع</CE>  الهدايا التي سقطت عن طريق الضغط على المسطرة ! وارجاع الهدايا الى صديقنا العزيز سانتا عندما يشعر <CE> بالدوار</CE> عن طريق الضغط على زر المسطرة!"},
  103.     hu = {"Boldog Karácsonyt & Boldog Új Évet!","A Karácsony közeleg, és a Mikulásra pedig <I>rengeteg munka vár<I>. Oda akarja adni az összes ajándékot időben, de muszáj gyorsnak lennie! Mivel a mi Mikulásunk kétbalkezes, néhány ajándék lepottyan és Neked kell <CE>összegyűjteni</CE> azokat, a <I>Szóköz</I> megnyomásával! Vidd vissza a Mikulásnak az ajándékot a <I>Szóköz</I> megnyomásával, amikor Mikulás <CE>megszédül</CE>!"},
  104.     ru = {"С новым годом и Рождеством!","Рождество приближается и S4nt4 направляется к вам! Он очень спешит, чтобы раздать все подарки вовремя! Но так как наш дорогой S4nt4 неуклюж, то некоторые подарки будут падать. Вы должны <CE>собрать</CE> их, нажимая клавишу <I>пробел</I>! Помогите S4nta. <CE>Верните</CE> ему подарки обратно с помощью <I>пробела</I>!"},
  105. }
  106. langue.pt = langue.br
  107. local communityMessage = langue.en
  108. for k,v in next,langue do
  109.     if k == tfm.get.room.community then
  110.         communityMessage = v
  111.         break
  112.     end
  113. end
  114.  
  115. --[[ Map ]]--
  116. system.start = false
  117. system.aim = 8
  118. amountPlayers = 20
  119. currentTime,leftTime = 0,150
  120. local xml = '<C><P DS="y;310" /><Z><S><S H="10" L="50" X="275" c="2" Y="165" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="200" X="100" H="80" Y="360" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="200" X="109" H="80" Y="379" T="12" P="0,0,0.3,0.2,-10,0,0,0" /><S X="391" L="230" H="80" c="3" Y="354" T="12" P="0,0,0.3,0.2,-2,0,0,0" /><S H="100" L="230" X="430" c="3" Y="411" T="12" P="0,0,0.3,0.2,-30,0,0,0" /><S H="80" L="180" X="705" c="3" Y="397" T="12" P="0,0,0.3,0.2,-2,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="44" H="10" c="3" Y="361" T="13" X="237" /><S X="-5" L="10" H="3000" c="3" Y="100" T="12" P="0,0,0,0,0,0,0,0" /><S H="3000" L="10" X="805" c="3" Y="101" T="12" P="0,0,0,0,0,0,0,0" /><S L="10" X="400" H="3000" Y="-5" T="12" P="0,0,0,0,90,0,0,0" /><S L="80" H="10" X="96" Y="158" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,.9,0,0,0,0" L="50" X="275" c="3" Y="165" T="12" H="10" /><S L="130" X="527" H="10" Y="128" T="12" P="0,0,0.3,0.2,10,0,0,0" /><S L="90" H="10" X="632" Y="131" T="12" P="0,0,0.3,0.2,-10,0,0,0" /><S H="3000" L="10" o="23E9E9" X="805" c="2" Y="100" T="12" m="" P="0,0,0,2,0,0,0,0" /><S X="-5" L="10" o="23E9E9" H="3000" c="2" Y="100" T="12" m="" P="0,0,0,2,0,0,0,0" /><S P="0,0,0.3,0.2,-35,0,0,0" L="230" X="549" c="3" Y="467" T="12" H="100" /><S P="0,0,0.3,0.2,-55,0,0,0" L="230" H="100" c="3" Y="441" T="12" X="250" /><S L="230" X="125" H="100" Y="422" T="12" P="0,0,0.3,0.2,-30,0,0,0" /><S X="510" L="230" H="100" c="3" Y="477" T="12" P="0,0,0.3,0.2,-65,0,0,0" /><S L="50" X="91" H="50" Y="339" T="12" P="0,0,0.3,0.2,-45,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="30" X="164" c="2" Y="325" T="12" H="50" /><S P="0,0,0.3,1.1,0,0,0,0" L="30" H="50" c="3" Y="325" T="12" X="164" /><S L="50" X="240" H="10" Y="158" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="50" H="10" X="443" Y="125" T="12" P="0,0,0.3,0.2,-20,0,0,0" /><S H="80" L="220" o="23E9E9" X="393" c="1" Y="359" T="12" m="" P="0,0,0.3,0.2,-2,0,0,0" /><S L="230" o="23E9E9" X="427" H="100" Y="416" T="12" m="" P="0,0,0.3,0.2,-30,0,0,0" /><S P="0,0,0.3,0.2,-65,0,0,0" L="230" o="23E9E9" H="100" Y="481" T="12" m="" X="501" /><S P="0,0,0.3,0.2,-35,0,0,0" L="230" o="23E9E9" H="100" Y="474" T="12" m="" X="550" /><S P="0,0,0.3,0.2,-2,0,0,0" L="180" o="23E9E9" X="706" Y="404" T="12" m="" H="80" /><S P="0,0,0.3,0.2,1,0,0,0" L="230" o="23E9E9" X="314" c="2" Y="373" T="12" m="" H="100" /></S><D><P X="241" Y="507" T="51" P="0,1" /><P X="566" Y="449" T="46" P="0,0" /></D><O /></Z></C>'
  121. tfm.exec.newGame(xml)
  122.  
  123. --[[ Player ]]--
  124. system.displayBar = function(id,player,value,nvalue,color,sig,size,height)
  125.     sig = sig or ""
  126.     size = size or 100
  127.     height = height or 20
  128.  
  129.     ui.addTextArea(id,"",player,5,(height+8) * id,size + 4,height,0xC7CED2,1,1,true)
  130.     if value ~= 0 then
  131.         ui.addTextArea(id.."0","",player,6,(height+8) * id + 2,nvalue + 2,height - 4,color,color,1,true)
  132.     end
  133.     ui.addTextArea(id.."00","<B><font color='#0'>"..value..sig,player,(size-30)/2,(height+8) * id + 1,50,height,1,1,0,true)
  134. end
  135. system.updateBar = function(n,giftColor)
  136.     giftColor = giftColor or info[n].lastColor
  137.     system.displayBar(1,n,math.floor(info[n].db.eventNoelGifts[2]) .. " / "..system.aim,(info[n].db.eventNoelGifts[2] > system.aim and 100 or math.percent(info[n].db.eventNoelGifts[2],system.aim,100)),0xFF0000)
  138.     system.displayBar(2,n,info[n].db.eventNoelGifts[1],(info[n].db.eventNoelGifts[1] > 50 and 50 or math.percent(info[n].db.eventNoelGifts[1],50,50)),giftColor,"G",50,20)
  139. end
  140.  
  141. eventNewGame = function()
  142.     system.start = true
  143.     amountPlayers = system.players()
  144.     currentTime,leftTime = 0,150
  145.     tfm.exec.setGameTime(60 * 2.5)
  146.     tfm.exec.snow(60 * 2.5)
  147.     tfm.exec.addImage("158c1feaf90.png","?0",0,0)
  148.     ui.setMapName("<J>"..table.random({"Nöel","Christmas","Bolodefchoco","Lua event","#xmas","Bogkitty"}).." <G>- @"..table.random({666,404,801,os.date("%Y"),0,1}))
  149.     ui.setShamanName("<R>S4NT4 M4U5")
  150.     for k,v in next,tfm.get.room.playerList do
  151.         info[k] = {
  152.             db = {
  153.                 eventNoelGifts = {0,0},
  154.                 eventNoelTitle = false,
  155.             },
  156.             catch = 0,
  157.             lastColor = 0xB73535,
  158.             dataLoaded = false
  159.         }
  160.         system.loadPlayerData(k)
  161.         if not v.isDead then
  162.             system.bindKeyboard(k,32,true,true)
  163.         end
  164.         system.updateBar(k)
  165.     end
  166.     tfm.exec.chatMessage(santaMessage:format(communityMessage[2],communityMessage[1]:upper()))
  167. end
  168.  
  169. eventPlayerDied = function(n)
  170.     if system.start then
  171.         system.bindKeyboard(n,32,true,false)
  172.     end
  173. end
  174.  
  175. eventNewPlayer = function(n)
  176.     tfm.exec.addImage("158c1feaf90.png","?0",0,0,n)
  177. end
  178.  
  179. eventPlayerLeft = function(n)
  180.     if info[n] then
  181.         system.savePlayerData(n,serialization(info[n].db))
  182.     end
  183. end
  184.  
  185. --[[ AI ]]--
  186. local despawnObjects = {}
  187.  
  188. local currentGifts = {}
  189. local gifts = {
  190.     [1] = {
  191.         [1] = "158bb1db61b",
  192.         [2] = 20000,
  193.     };
  194.     [2] = {
  195.         [1] = "158bb1c95e0",
  196.         [2] = 15000,
  197.     };
  198.     [3] = {
  199.         [1] = "158bb1cc6ec",
  200.         [2] = 10000,
  201.     };
  202.     [4] = {
  203.         [1] = "158bb1ce1aa",
  204.         [2] = 8000,
  205.     };
  206.     [5] = {
  207.         [1] = "1591c9b3123",
  208.         [2] = 6000,
  209.     };
  210. }
  211.  
  212. local noel = {}
  213. local initx,inity = 240,140
  214. noel.x = initx
  215. noel.y = inity
  216. noel.id = -1
  217.  
  218. noel.isEscaping = false
  219. noel.isDizzy = {0,false}
  220.  
  221. noel.timers = {
  222.     teleport = 0,
  223.     prize = 0
  224. }
  225.  
  226. noel.img = {
  227.     dizzy = {"158bb1dccb6","158bb1cf9a8","158bb1d6489","158bb1e2518"},
  228.     right = "158bb1d8069",
  229.     left = "158bb1e0daf",
  230.     jumping = "158bb1d470a",
  231.     stop = "158bb1d9b67",
  232. }
  233.  
  234. noel.updateImage = function(img)
  235.     tfm.exec.removeImage(noel.imgId)
  236.     noel.imgId = tfm.exec.addImage(img..".png","#"..noel.id,-23,-32)
  237. end
  238. noel.particles = function(id)
  239.     for i = 1,5 do
  240.         tfm.exec.displayParticle(id,noel.x + math.random(-50,50),noel.y + math.random(-50,50),table.random({-.2,.2}),table.random({-.2,.2}))
  241.     end
  242. end
  243. noel.move = function(x,y)
  244.     tfm.exec.moveObject(noel.id,0,0,false,x,y,false)
  245. end
  246.  
  247. noel.nearMouse = function(range)
  248.     local player = {"",{dist=math.random(800),x=0,y=0}}
  249.     for k,v in next,tfm.get.room.playerList do
  250.         if not v.isDead then
  251.             if math.pythag(v.x,v.y,noel.x,noel.y,range) then
  252.                 local m = v.x-noel.x
  253.                 if math.abs(m) < player[2].dist then
  254.                     player = {k,{dist=m,x=v.x,y=v.y}}
  255.                 end
  256.             end
  257.         end
  258.     end
  259.     noel.isEscaping = player[1] ~= ""
  260.     return player
  261. end
  262.  
  263. noel.escape = function(id)
  264.     local player = noel.nearMouse(math.random(80,100))
  265.     local mul = (player[1] ~= "" and math.isNegative(player[2].dist,1,-1) or table.random({-1,1}))
  266.     local img = math.isNegative(mul,"left","right")
  267.     local rand = 9 - math.random(0,9)
  268.     if id == 0 or (rand < 6) then
  269.         noel.move(mul * math.random(50,80),-math.random(1,10))
  270.         noel.updateImage(noel.img[img])
  271.     elseif id == 1 or (rand < 9) then
  272.         noel.move(mul * math.random(60,70),-80)
  273.         noel.updateImage(table.random({noel.img[img],noel.img.jumping}))
  274.     elseif id == 2 or rand == 9 then
  275.         noel.move(mul * math.random(10,20),-math.random(70,100))
  276.         noel.updateImage(noel.img.jumping)
  277.     end
  278. end
  279. noel.meep = function()
  280.     tfm.exec.displayParticle(20,noel.x,noel.y)
  281.     tfm.exec.explosion(noel.x,noel.y,20,50)
  282. end
  283. noel.cannon = function()
  284.     local player = noel.nearMouse(100)
  285.     if player[1] ~= "" then
  286.         local x = noel.x + (noel.x > player[2].x and -40 or 40)
  287.         local y = noel.y + (noel.y > player[2].y and -40 or 40)
  288.         local angle = math.deg(math.atan2(player[2].y-noel.y,player[2].x-noel.x)) + 90
  289.         table.insert(despawnObjects,{
  290.             [1] = tfm.exec.addShamanObject(1703,x,y,angle),
  291.             [2] = os.time() + 2500
  292.         })
  293.         local effect = function(id,sx,sy,xs,ys,e)
  294.             for i = 1,2 do
  295.                 tfm.exec.displayParticle(id[i] and id[i] or id[1],x + sx * e,y - sy * e,xs/1.5,ys/1.5)
  296.             end
  297.         end
  298.         for i = 1,20 do
  299.             effect({9,11},math.cos(i),math.sin(i),math.cos(i),-math.sin(i),22)
  300.             effect({13},math.cos(i),math.sin(i),math.sin(i),math.cos(i),19)
  301.         end
  302.     end
  303. end
  304. noel.teleport = function()
  305.     if os.time() > noel.timers.teleport then
  306.         noel.timers.teleport = os.time() + 8000
  307.         tfm.exec.displayParticle(37,noel.x,noel.y)
  308.         local x,y = math.random(20,780),math.random(50,300)
  309.         tfm.exec.moveObject(noel.id,x,y)
  310.         tfm.exec.displayParticle(37,x,y)
  311.     else
  312.         noel.escape(2)
  313.     end
  314. end
  315.  
  316. noel.gift = function()
  317.     if os.time() > noel.timers.prize then
  318.         noel.timers.prize = os.time() + 5000
  319.         noel.updateImage(noel.img.stop)
  320.         local giftsAmount = amountPlayers < 10 and 1 or math.floor(amountPlayers/10)
  321.         if tonumber(os.date("%Y")) == 2017 then
  322.             giftsAmount = giftsAmount * 2
  323.         end
  324.         for i = 1,giftsAmount do
  325.             local gift = table.random({2,4,3,1,1,2,3,5,2,4})
  326.             for k,v in next,gifts do
  327.                 if gift == k then
  328.                     gift = k
  329.                     break
  330.                 end
  331.             end
  332.             local gen = {}
  333.             gen[1] = tfm.exec.addShamanObject(6300,noel.x,noel.y,0,table.random({-13,-10,-5,5,10,13}))
  334.             gen[2] = os.time() + gifts[gift][2]
  335.             gen[3] = tfm.exec.addImage(gifts[gift][1]..".png","#"..gen[1],-15,-15)
  336.             gen[4] = gift
  337.             table.insert(currentGifts,gen)
  338.         end
  339.     else
  340.         noel.escape(0)
  341.     end
  342. end
  343. noel.dizzy = function(timer)
  344.     if os.time() > noel.timers.prize then
  345.         noel.isDizzy[1] = os.time() + 9500
  346.     else
  347.         noel.escape(2)
  348.     end
  349. end
  350.  
  351. eventLoop = function()
  352.     if system.start then
  353.         currentTime = currentTime + .5
  354.         leftTime = leftTime - .5
  355.         if currentTime > 4 then
  356.             if noel.id == -1 then
  357.                 noel.id = tfm.exec.addShamanObject(6300,noel.x,noel.y)
  358.                 noel.updateImage(noel.img.stop)
  359.             end
  360.  
  361.             local ox,oy
  362.             if tfm.get.room.objectList[noel.id] then
  363.                 ox,oy = tfm.get.room.objectList[noel.id].x,tfm.get.room.objectList[noel.id].y
  364.             else
  365.                 ox,oy = noel.x,noel.y
  366.             end
  367.  
  368.             if (ox < -10 or ox > 810) or (oy > 400 or oy < -50) then
  369.                 tfm.exec.removeObject(noel.id)
  370.                 noel.x,noel.y = initx,inity
  371.                 noel.id = nil
  372.             end
  373.  
  374.             if noel.id then
  375.                 noel.x = ox
  376.                 noel.y = oy
  377.             end
  378.  
  379.             for k,v in ipairs(despawnObjects) do
  380.                 if os.time() > v[2] then
  381.                     tfm.exec.removeObject(v[1])
  382.                 end
  383.             end
  384.             for k,v in ipairs(currentGifts) do
  385.                 if os.time() > v[2] then
  386.                     tfm.exec.removeObject(v[1])
  387.                     tfm.exec.removeImage(v[3])
  388.                 end
  389.             end
  390.  
  391.             if os.time() > noel.isDizzy[1] and currentTime > 5 then
  392.                 noel.particles(13)
  393.                 if currentTime % 60 == 0 then
  394.                     noel.dizzy()
  395.                 elseif currentTime % 5 == 0 then
  396.                     noel.gift()
  397.                     noel.escape(1)
  398.                 elseif math.floor(currentTime) % 2 == 0 then
  399.                     local option = math.random((noel.isEscaping and 15 or 12))
  400.                     if option > 3 then
  401.                         noel.escape()
  402.                     else
  403.                         noel.updateImage(noel.img.stop)
  404.                         if currentTime > 7 and math.random(1,2) == 1 then
  405.                             if option == 3 then
  406.                                 noel.cannon()
  407.                             elseif option == 2 then
  408.                                 noel.teleport()
  409.                             elseif option == 1 then
  410.                                 noel.meep()
  411.                             end
  412.                         end
  413.                     end
  414.                 else
  415.                     noel.updateImage(noel.img.stop)
  416.                 end
  417.             else
  418.                 noel.particles(1)
  419.                 if not noel.isDizzy[2] then
  420.                     noel.isDizzy[2] = true
  421.                     noel.timers.prize = os.time() + 5000
  422.                     local imgId = #noel.img.dizzy
  423.                     local animation = {}
  424.                     local numb = 1
  425.                     animation = system.looping(function()
  426.                         noel.updateImage(noel.img.dizzy[imgId])
  427.  
  428.                         if imgId == #noel.img.dizzy or imgId == 1 then
  429.                             numb = -numb
  430.                         end
  431.  
  432.                         imgId = imgId + numb
  433.  
  434.                         if (os.time()+250) > noel.isDizzy[1] then
  435.                             for k,v in next,animation do
  436.                                 system.removeTimer(v)
  437.                             end
  438.                             noel.isDizzy = {0,false}
  439.                         end
  440.                     end,10)
  441.                 end
  442.             end
  443.         end
  444.         if leftTime < 2 then
  445.             for k,v in next,tfm.get.room.playerList do
  446.                 if info[k] then
  447.                     system.savePlayerData(k,serialization(info[k].db))
  448.                 end
  449.             end
  450.             system.exit()
  451.         end
  452.     end
  453. end
  454.  
  455. eventKeyboard = function(n,k,d,x,y)
  456.     if system.start then
  457.         if os.time() > info[n].catch and k == 32 and info[n].dataLoaded then
  458.             if os.time() < noel.isDizzy[1] then
  459.                 if math.pythag(x,y,noel.x,noel.y,32) then
  460.                     info[n].db.eventNoelGifts[2] = (info[n].db.eventNoelGifts[1]/10) + info[n].db.eventNoelGifts[2]
  461.                     info[n].db.eventNoelGifts[1] = 0
  462.  
  463.                     if not info[n].db.eventNoelTitle then
  464.                         if info[n].db.eventNoelGifts[2] >= system.aim then
  465.                             info[n].db.eventNoelTitle = true
  466.                             system.giveEventGift(n,title[1])
  467.                         end
  468.                     end
  469.  
  470.                     system.savePlayerData(n,serialization(info[n].db))
  471.  
  472.                     system.updateBar(n)
  473.                 end
  474.             else
  475.                 for k,v in next,currentGifts do
  476.                     local o = tfm.get.room.objectList[v[1]]
  477.                     if o and math.pythag(x,y,o.x,o.y,25) then
  478.                         if (info[n].db.eventNoelGifts[1]+v[4]) <= 50 then
  479.                             tfm.exec.removeObject(v[1])
  480.                             tfm.exec.removeImage(v[3])
  481.  
  482.                             currentGifts[k][2] = 0
  483.                             info[n].db.eventNoelGifts[1] = info[n].db.eventNoelGifts[1] + v[4]
  484.  
  485.                             system.savePlayerData(n,serialization(info[n].db))
  486.  
  487.                             system.updateBar(n,({0xB73535,0x358CB7,0x35B765,0xB7B735,0xB73487})[v[4]])
  488.                             break
  489.                         end
  490.                     end
  491.                 end
  492.             end
  493.             info[n].catch = os.time() + 1000
  494.         end
  495.     end
  496. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement