Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- baseXML = [[
- <C><P DS="y;90" Ca="" /><Z><S><S P="0,0,9999,0.2,0,0,0,0" L="800" o="0" H="10" v="3000" Y="110" T="12" X="400" /><S L="800" o="fffffffff" H="10" X="400" v="3000" Y="70" T="12" P="0,0,9999,0.2,0,0,0,0" /><S P="0,0,9999,0.2,0,0,0,0" L="50" o="0" X="400" Y="-200" T="12" H="10" /><S L="50" o="0" X="400" H="10" Y="-240" T="12" P="0,0,9999,0.2,0,0,0,0" /><S P="0,0,9999,0.2,90,0,0,0" L="50" o="0" H="10" Y="-220" T="12" X="430" /><S L="50" o="0" H="10" X="370" Y="-220" T="12" P="0,0,9999,0.2,90,0,0,0" /></S><D><DS Y="90" X="400" /></D><O /></Z></C>
- ]]
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoScore(true)
- tfm.exec.disableAutoTimeLeft(true)
- system.disableChatCommandDisplay("afk")
- system.disableChatCommandDisplay("setdiff")
- -- jour crepuscule aurore nuages collision nocturne noel frommage
- maps = {"@4535536","@4533657","@4535757","@4535960","@4537526","@4537528","@4537632","@4871997"}
- players = {}
- afk = {}
- id = {
- askDifficulty = 42,
- resultDifficulty = 43,
- infoDifficulty = 44
- }
- trigger = {
- askDifficulty = false,
- resultDifficulty = false,
- askDifficultyInShutdown = false
- }
- playerAsked = nil
- playersVotes = {}
- difficultyAsked = nil
- nextDifficulty = nil
- votesCount = 100
- -- Plus frequency proche de 0, plus c'est fréquent
- difficulty = {
- easy = {
- spawnFrequency = 1,
- spiritFrequency = 5,
- cannonFrequency = 6,
- delayUnfrequency = 5,
- spiritTime = 25,
- cannonTime = 45
- },
- medium = {
- -- Fréquence de spawn des bulles au début
- spawnFrequency = 1,
- -- Fréquence de spawn des esprits
- spiritFrequency = 4,
- -- Fréquence de spawn des boulets
- cannonFrequency = 5,
- -- Nombre de secondes avant que la fréquence de spawn des bulles ne baisse
- delayUnfrequency = 5,
- -- Nombre de secondes avant que les esprits n'apparaîssent
- spiritTime = 20,
- -- Nombre de secondes avant que les boulets n'apparaissent
- cannonTime = 40
- },
- hard = {
- spawnFrequency = 1,
- spiritFrequency = 3,
- cannonFrequency = 4,
- delayUnfrequency = 4,
- spiritTime = 15,
- cannonTime = 30
- }
- }
- currentDifficulty = difficulty.easy
- lang = {}
- lang.fr = {
- info = "Bubbles !",
- afk = "<N>Vous êtes <J>AFK<N>. Pour jouer, dites : <ROSE>!afk<N>.",
- welcome = "<N>Bienvenue dans <J>#Bubbles<N> !<br /><T>Vous avez été emprisonnées dans une cage invisible aux parois mortelles. La seule chose que vous pouvez faire est de survivre le plus longtemps possible et être la dernière à vous en sortir !",
- vote_choice_1 = "<N> veut modifier la difficulté à ",
- vote_choice_2 = "<N>. Appuyez sur <J>1<N> si <V>vous êtes d'accord<N>, <R>sinon<N> appuyez sur <J>2<N>. <ROSE>Fin des votes dans <J>",
- vote_choice_3 = "<ROSE> seconde(s).",
- difficulty = "<N>Difficulté",
- easy = "<V>Facile",
- medium = "<J>Moyen",
- hard = "<R>Difficile",
- newDifficulty = "<N>La nouvelle difficulté sera mise en place lors de la prochaine partie.",
- noNewDifficulty = "<N>La nouvelle difficulté n'a pas été adoptée.",
- youVotedYes = "Vous avez voté <V>Pour<N>.",
- youVotedNo = "Vous avez voté <R>Contre<N>."
- }
- lang.en = {
- info = "Bubbles !",
- afk = "<N>You are <J>AFK<N>. To play, say : <ROSE>!afk<N>.",
- welcome = "<N>Welcome to <J>#Bubbles<N> !",
- vote_choice_1 = " <N> want to set the difficulty to ",
- vote_choice_2 = "<N>. <ROSE>Press 1 if you agree, else press 2. Votes will end in ",
- vote_choice_3 = "<ROSE> second(s).",
- difficulty = "<N>Difficulty",
- easy = "<V>Easy",
- medium = "<J>Medium",
- hard = "<R>Hard",
- newDifficulty = "<N>The new difficulty has been instaured.",
- noNewDifficulty = "<N>The new difficulty hasn't been instaured.",
- youVotedYes = "You voted <V>for<N>.",
- youVotedNo = "You voted <R>against<N>."
- }
- text = lang.fr
- timer = {
- start = 0,
- frequence = 0,
- unfrequence = 0,
- askDifficulty = 0,
- resultDifficulty = 0,
- shutdownDifficulty = 0
- }
- bubbles = {}
- function eventNewGame()
- bubbles = {}
- players = {}
- spawnFrequency = 0.5
- timer.start = 0
- timer.frequence = 0
- timer.unfrequence = 0
- for n,p in pairs(tfm.get.room.playerList) do
- table.insert(players, n)
- end
- local bestPlayer = bestPlayer()
- tfm.exec.setUIMapName("<PT>"..text.info.." <font color='#60608F'>|</font> <N>Bubble Master : <VP>"..bestPlayer)
- for _,p in pairs(players) do
- if afk[p] then
- tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
- else
- tfm.exec.movePlayer(p, math.random(100, 700), 90, false, 0, 0, false)
- end
- end
- showAfk()
- end
- function eventNewPlayer(playerName)
- tfm.exec.setPlayerScore(playerName, 0, false)
- table.insert(players, playerName)
- afk[playerName] = false
- tfm.exec.bindKeyboard(playerName, 49, false) -- 1
- tfm.exec.bindKeyboard(playerName, 50, false) -- 2
- tfm.exec.bindKeyboard(playerName, 97, false) -- 1
- tfm.exec.bindKeyboard(playerName, 98, false) -- 2
- end
- function eventPlayerLeft(playerName)
- local toRemove = 0
- for i,p in pairs(players) do
- if p==playerName then
- toRemove = i
- end
- end
- table.remove(players, toRemove)
- afk[playerName] = false
- end
- function eventPlayerDied(playerName)
- if #players > 1 then
- local alive = 0
- local pname = ""
- for _,p in pairs(players) do
- if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
- alive = alive + 1
- pname = p
- end
- end
- if alive == 1 then
- tfm.exec.giveCheese(pname)
- tfm.exec.playerVictory(pname)
- tfm.exec.setGameTime(5)
- elseif alive == 0 then
- newGame()
- end
- else
- newGame()
- end
- end
- function eventPlayerWon(playerName)
- local score = 0
- if currentDifficulty == difficulty.easy then score = 12
- elseif currentDifficulty == difficulty.medium then score = 14
- elseif currentDifficulty == difficulty.hard then score = 16 end
- if playerName == bestPlayer() then score = score - 5 end
- tfm.exec.setPlayerScore(playerName, score, true)
- end
- function eventLoop(currentTime, timeRemaining)
- timer.start = timer.start + 0.5
- if timer.start == 1.5 then
- for p,s in pairs(tfm.get.room.playerList) do
- if not afk[p] then table.insert(bubbles, tfm.exec.addShamanObject(59, s.x, 400, 0, 0, 0, false)) end
- end
- end
- if trigger.askDifficulty then
- timer.askDifficulty = timer.askDifficulty + 0.5
- if difficultyAsked == 1 then
- ui.updateTextArea(id.askDifficulty, "<p align='center'><J>"..playerAsked..text.vote_choice_1..text.easy..text.vote_choice_2..(20 - round(timer.askDifficulty))..text.vote_choice_3.."</p>", nil)
- elseif difficultyAsked == 2 then
- ui.updateTextArea(id.askDifficulty, "<p align='center'><J>"..playerAsked..text.vote_choice_1..text.medium..text.vote_choice_2..(20 - round(timer.askDifficulty))..text.vote_choice_3.."</p>", nil)
- elseif difficultyAsked == 3 then
- ui.updateTextArea(id.askDifficulty, "<p align='center'><J>"..playerAsked..text.vote_choice_1..text.hard..text.vote_choice_2..(20 - round(timer.askDifficulty))..text.vote_choice_3.."</p>", nil)
- end
- if timer.askDifficulty >= 20 then
- local wasNewDifficulty = false
- local yesVotes = 0
- for _,vote in pairs(playersVotes) do
- if vote == "yes" then yesVotes = yesVotes + 1 end
- end
- if yesVotes > #playersVotes - yesVotes then
- nextDifficulty = difficultyAsked
- wasNewDifficulty = true
- end
- ui.removeTextArea(id.askDifficulty)
- trigger.askDifficultyInShutdown = true
- trigger.askDifficulty = false
- timer.askDifficulty = 0
- for i = 0,100 do
- if votesCount > 100 then
- ui.removeTextArea(votesCount)
- votesCount = votesCount - 1
- else
- break
- end
- end
- votesCount = 100
- playerAsked = nil
- playersVotes = {}
- difficultyAsked = nil
- if wasNewDifficulty then ui.addTextArea(id.resultDifficulty, "<p align='center'>"..text.newDifficulty.."</p>", nil, 0, 377, 800, 20, 0x010101, 0x010101, 0.7f)
- else ui.addTextArea(id.resultDifficulty, "<p align='center'>"..text.noNewDifficulty.."</p>", nil, 0, 377, 800, 20, 0x010101, 0x010101, 0.7f) end
- trigger.resultDifficulty = true
- end
- end
- if trigger.resultDifficulty then
- timer.resultDifficulty = timer.resultDifficulty + 0.5
- if timer.resultDifficulty >= 8 then
- ui.removeTextArea(id.resultDifficulty)
- trigger.resultDifficulty = false
- timer.resultDifficulty = 0
- trigger.askDifficultyInShutdown = true
- end
- end
- if trigger.askDifficultyInShutdown then
- timer.shutdownDifficulty = timer.shutdownDifficulty + 0.5
- if timer.shutdownDifficulty >= 120 then
- trigger.askDifficultyInShutdown = false
- timer.shutdownDifficulty = 0
- end
- end
- if timeRemaining <= 0 then
- for _,p in pairs(players) do
- if not tfm.get.room.playerList[p].isDead and not afk[p] then
- tfm.exec.giveCheese(p)
- tfm.exec.playerVictory(p)
- end
- end
- newGame()
- end
- if timer.start > 40 and (timer.start % 52) == 0 and tfm.get.room.currentMap == "@4537632" then
- tfm.exec.snow()
- end
- if timer.start > currentDifficulty.spiritTime then
- if (timer.start % currentDifficulty.spiritFrequency) == 0 then
- local nbAfk = math.random(#bubbles)
- local target = bubbles[nbAfk]
- tfm.exec.addShamanObject(24, tfm.get.room.objectList[target].x, tfm.get.room.objectList[target].y, 0, 0, 0, false)
- tfm.exec.removeObject(target)
- table.remove(bubbles, nbAfk)
- end
- end
- if timer.start > currentDifficulty.cannonTime then
- if (timer.start % currentDifficulty.cannonFrequency) == 0 then
- tfm.exec.addShamanObject(18, math.random(30, 770), 20, 0, 0, 75, false)
- end
- end
- for _,p in pairs(players) do
- if not tfm.get.room.playerList[p].isDead then
- if tfm.get.room.playerList[p].x < 0 or tfm.get.room.playerList[p].x > 800 or tfm.get.room.playerList[p].y < 10 then
- if tfm.get.room.playerList[p].y > -150 then
- tfm.exec.movePlayer(p, 400, 500, false, 0, 0, false)
- end
- end
- end
- end
- timer.frequence = timer.frequence + 0.5
- if timer.frequence >= currentDifficulty.spawnFrequency then
- timer.frequence = 0
- timer.unfrequence = timer.unfrequence + 0.5
- if timer.unfrequence == currentDifficulty.delayUnfrequency and currentDifficulty.spawnFrequency < 2 then
- timer.unfrequence = 0
- currentDifficulty.spawnFrequency = currentDifficulty.spawnFrequency + 0.5
- end
- spawnBubble()
- end
- for i,id in pairs(bubbles)do
- if tfm.get.room.objectList[id] and tfm.get.room.objectList[id].y<=20 then
- tfm.exec.removeObject(id)
- table.remove(bubbles, i)
- end
- end
- end
- function eventChatCommand(playerName, message)
- local args = {}
- for arg in message:gmatch("[^%s]+") do
- table.insert(args, arg:lower())
- end
- if message == "afk" and timer.start > 3 then
- toggleAfk(playerName)
- elseif args[1] == "beafk" and args[2] and playerName == "Deathmatic" then
- toggleAfk(args[2]:gsub("^%l", string.upper))
- elseif args[1] == "setdiff" and args[2] and not trigger.askDifficulty and not trigger.askDifficultyInShutdown then
- askDifficulty(playerName, tonumber(args[2]))
- end
- end
- function eventKeyboard(playerName, code, down, xPos, yPos)
- if trigger.askDifficulty and not playersVotes[playerName] then
- if code == 49 or code == 97 then
- playersVotes[playerName] = "yes"
- votesCount = votesCount + 1
- ui.addTextArea(votesCount, text.youVotedYes, playerName, 665, 343, 140, 21, 0x010101, 0x010101, 0.7f, false)
- elseif code == 50 or code == 98 then
- playersVotes[playerName] = "no"
- votesCount = votesCount + 1
- ui.addTextArea(votesCount, text.youVotedNo, playerName, 665, 343, 140, 21, 0x010101, 0x010101, 0.7f, false)
- end
- end
- end
- function toggleAfk(playerName)
- for p,v in pairs(afk) do
- if p == playerName then
- if v then
- afk[p] = false
- if #players == 1 then
- newGame()
- else
- local diff = 0
- for p,v in pairs(afk) do
- if v then
- diff = diff + 1
- end
- end
- if #players - diff == 1 then
- newGame()
- end
- end
- else
- afk[p] = true
- tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
- if #players > 1 then
- local alive = 0
- local pname = ""
- for _,p in pairs(players) do
- if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
- alive = alive + 1
- pname = p
- end
- end
- if alive == 1 then
- tfm.exec.giveCheese(pname)
- tfm.exec.playerVictory(pname)
- tfm.exec.setGameTime(5)
- elseif alive == 0 then
- newGame()
- end
- else
- newGame()
- end
- end
- end
- end
- showAfk()
- end
- function showAfk()
- local nbAfk = 0
- local nbNonAfk = 0
- local nbPreAfk = 0
- local message = ""
- while nbAfk <= #players do
- ui.removeTextArea(nbAfk)
- nbAfk = nbAfk + 1
- end
- while nbNonAfk <= #players do
- ui.removeTextArea(nbNonAfk)
- nbNonAfk = nbNonAfk + 1
- end
- nbAfk = 0
- nbNonAfk = 0
- for p,v in pairs(afk) do
- if v then nbPreAfk = nbPreAfk + 1 end
- end
- for p,v in pairs(afk) do
- if v then
- ui.addTextArea(nbAfk, "<p align='center'>"..text.afk.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
- nbAfk = nbAfk + 1
- if nbAfk == nbPreAfk then
- if nbAfk == 1 then
- message = message.."<J>"..p.."<N> est AFK."
- else
- message = message.."<N>et <J>"..p.."<N> sont AFK."
- end
- else
- message = message.."<J>"..p.."<N>, "
- end
- end
- end
- for p,v in pairs(afk) do
- if not v and nbAfk > 0 then
- ui.addTextArea(nbNonAfk, "<p align='center'>"..message.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
- nbNonAfk = nbNonAfk + 1
- end
- end
- end
- function spawnBubble()
- table.insert(bubbles, tfm.exec.addShamanObject(59, math.random(30, 770), 400, 0, 0, 0, false))
- end
- function askDifficulty(playerName, difficultyId)
- if #players > 1 then
- if difficultyId == 1 or difficultyId == 2 or difficultyId == 3 then
- playerAsked = playerName
- trigger.askDifficulty = true
- eventKeyboard(playerName, 49, false, tfm.get.room.playerList[playerName].x, tfm.get.room.playerList[playerName].y)
- if difficultyId == 1 then
- ui.addTextArea(id.askDifficulty, "<p align='center'><font size='10px'><J>"..playerName..text.vote_choice_1..text.easy..text.vote_choice_2.."20"..text.vote_choice_3.."</font></p>", nil, 0, 377, 800, 20, 0x010101, 0x010101, 0.7f)
- difficultyAsked = 1
- elseif difficultyId == 2 then
- ui.addTextArea(id.askDifficulty, "<p align='center'><font size='10px'><J>"..playerName..text.vote_choice_1..text.medium..text.vote_choice_2.."20"..text.vote_choice_3.."</font></p>", nil, 0, 377, 800, 20, 0x010101, 0x010101, 0.7f)
- difficultyAsked = 2
- elseif difficultyId == 3 then
- ui.addTextArea(id.askDifficulty, "<p align='center'><font size='10px'><J>"..playerName..text.vote_choice_1..text.hard..text.vote_choice_2.."20"..text.vote_choice_3.."</font></p>", nil, 0, 377, 800, 20, 0x010101, 0x010101, 0.7f)
- difficultyAsked = 3
- end
- end
- else
- if difficultyId == 1 or difficultyId == 2 or difficultyId == 3 then
- nextDifficulty = difficultyId
- ui.addTextArea(id.resultDifficulty, "<p align='center'>"..text.newDifficulty.."</p>", nil, 0, 377, 800, 20, 0x010101, 0x010101, 0.7f)
- trigger.resultDifficulty = true
- end
- end
- end
- function newGame()
- local map = tfm.get.room.currentMap
- tfm.exec.snow(0)
- if #maps > 1 then
- while map == tfm.get.room.currentMap do
- map = maps[math.random(#maps)]
- end
- else
- map = maps[math.random(#maps)]
- end
- if nextDifficulty == 1 then currentDifficulty = difficulty.easy; nextDifficulty = nil
- elseif nextDifficulty == 2 then currentDifficulty = difficulty.medium; nextDifficulty = nil
- elseif nextDifficulty == 3 then currentDifficulty = difficulty.hard; nextDifficulty = nil end
- tfm.exec.newGame(map)
- showDifficulty()
- if map == "@4537632" then -- Map neige
- tfm.exec.snow()
- elseif map == "@4871997" then
- for _,p in pairs(players) do
- tfm.exec.giveCheese(p)
- end
- end
- end
- function showDifficulty()
- if currentDifficulty == difficulty.easy then ui.addTextArea(id.infoDifficulty, text.difficulty.." : "..text.easy, nil, 690, 55, 110, 21, 0x010101, 0x010101, 0.7f, false)
- elseif currentDifficulty == difficulty.medium then ui.addTextArea(id.infoDifficulty, text.difficulty.." : "..text.medium, nil, 685, 55, 115, 21, 0x010101, 0x010101, 0.7f, false)
- elseif currentDifficulty == difficulty.hard then ui.addTextArea(id.infoDifficulty, text.difficulty.." : "..text.hard, nil, 680, 55, 140, 21, 0x010101, 0x010101, 0.7f, false) end
- end
- function bestPlayer()
- local topScore = 16
- local bestPlayer = "-"
- for name,player in pairs(tfm.get.room.playerList) do
- if player.score >= topScore then
- topScore = player.score
- bestPlayer = name
- end
- end
- return bestPlayer
- end
- function round(num)
- local mult = 10^0
- return math.floor(num * mult + 0.5) / mult
- end
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- newGame()
- print(text.welcome)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement