Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- au--[[ Titles ]]--
- title = {
- [1] = "Snowglobe",
- [2] = "Reindeer",
- [3] = "Santa's Bag",
- }
- --[[ Lib ]]--
- math.pythag = function(x1,y1,x2,y2,range)
- return ((x1-x2)^2+(y1-y2)^2<range^2)
- end
- math.percent = function(x,of,total)
- return (x/of)*total
- end
- table.random = function(t,r)
- local i = math.random(#t)
- if r then return t[i],i else return t[i] end
- end
- table.destroy=function(list,value)
- for k,v in next,list do
- if v == value then
- table.remove(list,k);break
- end
- end
- end
- system.looping = function(f,tk)
- local s = 1000 / tk
- local t = {}
- for timer = 0,1000-s,s do
- system.newTimer(function() t[#t+1] = system.newTimer(f,1000,true) end,1000+timer,false)
- end
- return t
- end
- base64 = {}
- base64.base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
- base64.to = function(str)
- local str = {str:byte(1,#str)}
- local code = {}
- local bs
- for i = 1,#str,3 do
- bs = bit32.rshift(str[i] % 0xFD,2)
- code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
- bs = bit32.lshift(str[i] % 0x04,4)
- if (i + 1 <= #str) then
- bs = bit32.bor(bs,bit32.rshift(str[i + 1] % 0xF1,4))
- code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
- bs = bit32.lshift(str[i + 1] % 0x10,2)
- if (i + 2 <= #str) then
- bs = bit32.bor(bs,bit32.rshift(str[i + 2] % 0xC1,6))
- code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
- bs = str[i + 2] % 0x40
- code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
- else
- code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
- code[#code + 1] = "="
- end
- else
- code[#code + 1] = base64.base:sub(bs + 1, bs + 1)
- code[#code + 1] = "=="
- end
- end
- return table.concat(code)
- end
- morse = {}
- morse.code = {a=".-",b="-...",c="-.-.",d="-..",e=".",f="..-.",g="--.",h="....",i="..",j=".---",k="-.-",l=".-..",m="--",n="-.",o="---",p=".--.",q="--.-",r=".-.",s="...",t="-",u="..-",v="...-",w=".--",x="-..-",y="-.--",z="--..",[1]=".----",[2]="..---",[3]="...--",[4]="....-",[5]=".....",[6]="-....",[7]="--...",[8]="---..",[9]="----.",[0]="-----"}
- morse.to = function(str)
- str = str:lower()
- str = str:gsub(" +"," / ")
- for i,v in next,morse.code do
- str = str:gsub(tostring(i),v.." ")
- end
- return str
- end
- enigma = {}
- enigma.words = {
- "Li4uIC4uLi4tIC0uIC0gLi4uLi0gIC8gLS0gLS0tLS0gLi4tIC4uLi4uIC4uLi0tIA==", -- s4nt4 m0u53
- "LS0gLi4uLS0gLi0uIC4tLiAtLi0tICAvIC0uLS4gLi4uLiAuLS4gLi0tLS0gLi4uLi4gLSAtLSAuLi4uLSAuLi4uLiA=", -- m3rry chr15tm45
- "Li4uLS0gLi0uLiAuLi0uICAvIC0tIC0tLS0tIC4uLSAuLi4uLiAuLi4tLSA=", -- 3lf m0u53
- "Li4uLi4gLS4gLS0tLS0gLi0tIC0tIC4uLi4tIC0uIA==", --5n0wm4n
- "LS4tLiAuLi4uIC4tLS0tIC0tIC0uIC4uLi0tIC0uLS0g", -- ch1mn3y
- "Li4uLi4gLS4gLS0tLS0gLi0tICAvIC4uLS4gLi0uLiAuLi4uLSAtLi0gLi4uLS0gLi4uLi4g", -- 5n0w fl4k35
- }
- enigma.verify = function(player,word)
- if not info[player].db.titles[3] then
- if info[player].db.enigma == base64.to(morse.to(word)) then
- info[player].db.titles[3] = true
- --system.giveEventGift(player,title[3])
- end
- end
- end
- --[[ Database ]]--
- info = {}
- serialization = {table={},string={}}
- serialization.table.tostring = function(t)
- local str = ""
- for index,value in next,t do
- 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.table.tostring(value):gsub(";","?").."&-")
- str = str .. ':' .. tostring(index) .. prefix .. tbOption .. ";"
- end
- return str
- end
- serialization.string.totable = function(s)
- local list = {}
- for str in s:gmatch("(.-);") do
- local varName,valueType,value = str:match(':(.-)_(%p)(.+)')
- if varName~=nil then
- varName = tonumber(varName) or varName
- if valueType == "@" then
- list[varName] = tostring(value)
- elseif valueType == "!" then
- list[varName] = value=="true"
- elseif valueType == "#" then
- list[varName] = tonumber(value)
- elseif valueType == "%" then
- list[varName] = serialization.string.totable(value:gsub("+&",""):gsub("&-",""):gsub("%?",";"))
- end
- end
- end
- return list
- end
- --[[
- eventPlayerDataLoaded = function(n,d)
- if d ~= "" then
- info[n].db = serialization.string.totable(d)
- end
- end
- ]]
- --[[ Sets ]]--
- for i,f in next,{"AutoNewGame","AutoShaman","AfkDeath","DebugCommand","MinimalistMode","MortCommand"} do
- tfm.exec["disable"..f]()
- end
- local santaMessage = "<V><B>[S4NT4]</B> <R>%s!</R>\n<V><B>[S4NT4]</B> <VP>%s</VP>"
- local langue = {
- en = "Merry Christmas",
- fr = "Joyeux Noel",
- br = "Feliz Natal",
- es = "Feliz navidad",
- tr = "Mutlu Noeller",
- pl = "Wesołych Świąt",
- hu = "Boldog Karácsonyt",
- ro = "Craciun Fericit",
- ar = "عيد ميلاد سعيد",
- vk = "God Jul",
- nl = "Vrolijk Kerstfeest",
- id = "Selamat Natal",
- de = "Fröhliche Weihnachten",
- ru = "С Рождеством",
- cn = "聖誕快樂",
- ph = "Maligayang Pasko",
- lt = "Linksmų Kalėdų",
- jp = "メリークリスマス",
- fi = "Hyvää Joulua",
- it = "Buon Natale",
- cz = "Veselé Vánoce",
- hr = "Sretan Božić",
- bg = "Весела Коледа",
- lv = "Priecīgus Ziemassvētkus",
- et = "Häid Jõule",
- }
- langue.pt = langue.br
- local communityMessage = langue.en
- for k,v in next,langue do
- if k == tfm.get.room.community then
- communityMessage = v
- break
- end
- end
- --[[ Map ]]--
- system.start = false
- 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>'
- tfm.exec.newGame(xml)
- --[[ Player ]]--
- system.displayBar = function(id,player,value,nvalue,color,sig,size,height)
- sig = sig or ""
- size = size or 100
- height = height or 20
- ui.addTextArea(id,"",player,5,(height+8) * id,size + 4,height,0xC7CED2,1,1,true)
- if value ~= 0 then
- ui.addTextArea(id.."0","",player,6,(height+8) * id + 2,nvalue + 2,height - 4,color,color,1,true)
- end
- ui.addTextArea(id.."00","<B><font color='#0'>"..value..sig,player,(size-20)/2,(height+8) * id + 1,50,height,1,1,0,true)
- end
- system.updateBar = function(n,giftColor)
- giftColor = giftColor or info[n].lastColor
- system.displayBar(1,n,(type(info[n].db.aim)=="number" and math.floor(info[n].db.gifts[2]) .. " / "..info[n].db.aim or info[n].db.aim),math.percent(info[n].db.gifts[2],(type(info[n].db.aim)=="number" and info[n].db.aim or 10),100),0xFF0000)
- system.displayBar(2,n,info[n].db.gifts[1],math.percent(info[n].db.gifts[1],50,50),giftColor,"G",50,20)
- end
- eventNewGame = function()
- if system.start then
- system.exit()
- else
- system.start = true
- tfm.exec.snow(60 * 2.5)
- tfm.exec.addImage("158c1feaf90.png","?0",0,0)
- tfm.exec.setGameTime(60 * 2.5)
- ui.setMapName("<J>#Christmas")
- ui.setShamanName("<R>S4NT4 M4U5")
- for k,v in next,tfm.get.room.playerList do
- info[k] = {
- db = {
- gifts = {0,0},
- aim = 5,
- titles = {false,false,false},
- enigma = table.random(enigma.words),
- }
- }
- --system.loadPlayerData(k)
- info[k].catch = 0
- info[k].duck = {0,0}
- info[k].lastColor = 0xB73535
- if not v.isDead then
- system.bindKeyboard(k,32,true,true)
- system.bindKeyboard(k,3,true,true)
- end
- system.updateBar(k)
- tfm.exec.chatMessage(santaMessage:format(communityMessage:upper(),"@"..info[k].db.enigma),k)
- end
- end
- end
- eventPlayerDied = function(n)
- if system.start then
- system.bindKeyboard(n,32,true,false)
- system.bindKeyboard(n,3,true,false)
- end
- end
- eventNewPlayer = function(n)
- tfm.exec.addImage("158c1feaf90.png","?0",0,0,n)
- end
- --[[ AI ]]---
- local despawnObjects = {}
- local currentGifts = {}
- local gifts = {
- [1] = {
- [1] = "158bb1db61b",
- [2] = 15000,
- };
- [2] = {
- [1] = "158bb1c95e0",
- [2] = 10000,
- };
- [3] = {
- [1] = "158bb1cc6ec",
- [2] = 6000,
- };
- [4] = {
- [1] = "158bb1ce1aa",
- [2] = 3000,
- };
- }
- local noel = {}
- local initx,inity = 240,140
- noel.x = initx
- noel.y = inity
- noel.isEscaping = false
- noel.isTired = {0,false}
- noel.timers = {
- teleport = 0,
- prize = 0
- }
- noel.img = {
- tired = {"158bb1dccb6","158bb1cf9a8","158bb1d6489","158bb1e2518"},
- right = "158bb1d8069",
- left = "158bb1e0daf",
- flying = "158bb1d470a",
- stop = "158bb1d9b67",
- }
- noel.updateImage = function(img)
- tfm.exec.removeImage(noel.imgId)
- noel.imgId = tfm.exec.addImage(img..".png","#"..noel.id,-23,-32)
- end
- noel.particles = function(id)
- for i = 1,5 do
- tfm.exec.displayParticle(id,noel.x + math.random(-50,50),noel.y + math.random(-50,50),table.random({-.2,.2}),table.random({-.2,.2}))
- end
- end
- noel.move = function(x,y)
- tfm.exec.moveObject(noel.id,0,0,false,x,y,false)
- end
- noel.nearMouse = function(range)
- local player = {"",{dist=math.random(800),x=0,y=0}}
- for k,v in next,tfm.get.room.playerList do
- if not v.isDead then
- if math.pythag(v.x,v.y,noel.x,noel.y,range) then
- local m = v.x-noel.x
- if math.abs(m) < player[2].dist then
- player = {k,{dist=m,x=v.x,y=v.y}}
- end
- end
- end
- end
- noel.isEscaping = player[1] ~= ""
- return player
- end
- noel.escape = function(id)
- local player = noel.nearMouse(math.random(80,100))
- local mul = (player[1] ~= "" and (player[2].dist < 0 and 1 or -1) or table.random({-1,1}))
- local img = (mul < 0 and "left" or "right")
- local rand = 9 - math.random(0,9)
- if id == 0 or (rand < 6) then
- noel.move(mul * math.random(50,80),0)
- noel.updateImage(noel.img[img])
- elseif id == 1 or (rand < 9) then
- noel.move(mul * math.random(60,70),-80)
- noel.updateImage(table.random({noel.img[img],noel.img.flying}))
- elseif id == 2 or rand == 9 then
- noel.move(mul * math.random(10,20),-math.random(70,100))
- noel.updateImage(noel.img.flying)
- end
- end
- noel.meep = function()
- tfm.exec.displayParticle(20,noel.x,noel.y)
- tfm.exec.explosion(noel.x,noel.y,20,50)
- end
- noel.cannon = function()
- local player = noel.nearMouse(100)
- if player[1] ~= "" then
- local x = noel.x + (noel.x > player[2].x and -40 or 40)
- local y = noel.y + (noel.y > player[2].y and -40 or 40)
- local angle = math.deg(math.atan2(player[2].y-noel.y,player[2].x-noel.x)) + 90
- table.insert(despawnObjects,{
- [1] = tfm.exec.addShamanObject(1703,x,y,angle),
- [2] = os.time() + 3000
- })
- local effect = function(id,sx,sy,xs,ys,e)
- for i = 1,2 do
- tfm.exec.displayParticle(id[i] and id[i] or id[1],x + sx * e,y - sy * e,xs/1.5,ys/1.5)
- end
- end
- for i = 1,20 do
- effect({9,11},math.cos(i),math.sin(i),math.cos(i),-math.sin(i),22)
- effect({13},math.cos(i),math.sin(i),math.sin(i),math.cos(i),19)
- end
- end
- end
- noel.teleport = function()
- if os.time() > noel.timers.teleport then
- noel.timers.teleport = os.time() + 8000
- tfm.exec.displayParticle(37,noel.x,noel.y)
- local x,y = math.random(10,790),math.random(50,300)
- tfm.exec.moveObject(noel.id,x,y)
- tfm.exec.displayParticle(37,x,y)
- else
- noel.escape(2)
- end
- end
- noel.gift = function()
- if os.time() > noel.timers.prize then
- noel.timers.prize = os.time() + 5000
- noel.updateImage(noel.img.stop)
- local gift = table.random({2,4,3,1})
- for k,v in next,gifts do
- if gift == k then
- gift = k
- break
- end
- end
- local gen = {}
- gen[1] = tfm.exec.addShamanObject(6300,noel.x,noel.y)
- gen[2] = os.time() + gifts[gift][2]
- gen[3] = tfm.exec.addImage(gifts[gift][1]..".png","#"..gen[1],-15,-15)
- gen[4] = gift
- table.insert(currentGifts,gen)
- else
- noel.escape(0)
- end
- end
- noel.tired = function(timer)
- if os.time() > noel.timers.prize then
- noel.isTired[1] = os.time() + 8000
- else
- noel.escape(2)
- end
- end
- eventLoop = function(currentTime)
- if system.start and (currentTime/1000)>4 then
- if not noel.id then
- noel.id = tfm.exec.addShamanObject(6300,noel.x,noel.y)
- noel.updateImage(noel.img.stop)
- end
- local ox,oy
- if tfm.get.room.objectList[noel.id] then
- ox,oy = tfm.get.room.objectList[noel.id].x,tfm.get.room.objectList[noel.id].y
- else
- ox,oy = noel.x,noel.y
- end
- if (ox < -10 or ox > 810) or (oy > 400 or oy < -50) then
- tfm.exec.removeObject(noel.id)
- noel.x,noel.y = initx,inity
- noel.id = nil
- end
- if noel.id then
- noel.x = ox
- noel.y = oy
- end
- for k,v in ipairs(despawnObjects) do
- if os.time() > v[2] then
- tfm.exec.removeObject(v[1])
- end
- end
- for k,v in ipairs(currentGifts) do
- if os.time() > v[2] then
- tfm.exec.removeObject(v[1])
- tfm.exec.removeImage(v[3])
- end
- end
- if os.time() > noel.isTired[1] then
- noel.particles(13)
- if math.floor(currentTime/1000) % 24 == 0 then
- noel.tired()
- elseif math.floor(currentTime/1000) % 10 == 0 then
- noel.gift()
- noel.escape(1)
- elseif math.floor(currentTime/1000) % 2 == 0 then
- local option = math.random((noel.isEscaping and 15 or 10))
- if option > 3 then
- noel.escape()
- else
- noel.updateImage(noel.img.stop)
- if (currentTime/1000)>7 and math.random(1,2) == 1 then
- if option == 3 then
- noel.cannon()
- elseif option == 2 then
- noel.teleport()
- elseif option == 1 then
- noel.meep()
- end
- end
- end
- else
- noel.updateImage(noel.img.stop)
- end
- else
- noel.particles(1)
- if not noel.isTired[2] then
- noel.isTired[2] = true
- noel.timers.prize = os.time() + 5000
- local imgId = #noel.img.tired
- local animation = {}
- local numb = 1
- animation = system.looping(function()
- noel.updateImage(noel.img.tired[imgId])
- if imgId == #noel.img.tired or imgId == 1 then
- numb = -numb
- end
- imgId = imgId + numb
- if (os.time()+250) > noel.isTired[1] then
- for k,v in next,animation do
- system.removeTimer(v)
- end
- noel.isTired[2] = false
- end
- end,9)
- end
- end
- end
- end
- eventKeyboard = function(n,k,d,x,y)
- if system.start then
- if os.time() > info[n].catch and k == 32 then
- if os.time() < noel.isTired[1] then
- if math.pythag(x,y,noel.x,noel.y,32) then
- info[n].db.gifts[2] = (info[n].db.gifts[1]/10) + info[n].db.gifts[2]
- info[n].db.gifts[1] = 0
- if not info[n].db.titles[1] then
- if info[n].db.gifts[2] >= 5 then
- info[n].db.aim = 10
- info[n].db.titles[1] = true
- --system.giveEventGift(n,title[1])
- end
- end
- if not info[n].db.titles[2] then
- if info[n].db.gifts[2] >= 10 then
- info[n].db.aim = "<font letterSpacing='5'>!!!!!!"
- info[n].db.titles[2] = true
- --system.giveEventGift(n,title[2])
- end
- end
- --system.savePlayerData(n,serialization.table.tostring(info[n].db))
- system.updateBar(n)
- end
- else
- for k,v in next,currentGifts do
- local o = tfm.get.room.objectList[v[1]]
- if o and math.pythag(x,y,o.x,o.y,25) then
- if (info[n].db.gifts[1]+v[4]) <= 50 then
- tfm.exec.removeObject(v[1])
- tfm.exec.removeImage(v[3])
- currentGifts[k][2] = 0
- info[n].db.gifts[1] = info[n].db.gifts[1] + v[4]
- --system.savePlayerData(n,serialization.table.tostring(info[n].db))
- system.updateBar(n,({0xB73535,0x358CB7,0x35B765,0xB7B735})[v[4]])
- break
- end
- end
- end
- end
- info[n].catch = os.time() + 1500
- end
- if k == 3 then
- if y > 294 then
- if os.time() > (info[n].duck[1]+3500) then
- info[n].duck = {os.time() + 600,0}
- else
- if os.time() > info[n].duck[1] then
- info[n].duck[1] = os.time() + 600
- info[n].duck[2] = info[n].duck[2] + 1
- if info[n].duck[2] % 30 == 0 then
- --tfm.exec.giveConsumables(n,4)
- end
- end
- end
- end
- end
- end
- end
- eventChatMessage = function(n,c)
- if system.start and c:sub(1,1) == "@" then
- if os.time() > noel.isTired[1] then
- if math.pythag(tfm.get.room.playerList[n].x,tfm.get.room.playerList[n].y,noel.x,noel.y,32) then
- enigma.verify(n,c)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment