Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tid = -1
- ntimer = system.newTimer
- system.newTimer = function(fnc, time, loop, ...)
- tid = tid + 1
- _G["Custom.Timer.ID" .. tostring(tid)] = fnc
- ntimer("Custom.Timer.ID" .. tostring(tid), time, loop, ...)
- end
- if tfm.get.room.name:lower() ~= "*#event0debug" then
- p = 0
- for _, __ in pairs(tfm.get.room.playerList) do
- p = p + 1
- end
- if p < 3 then
- system.exit()
- end
- flyPower = {}
- vampires = {}
- x_vampires = {}
- players = {}
- x_players = {}
- conv = {}
- consumables = {1, 5, 8, 2250, 9, 12, 3}
- amount = {3, 4}
- coordinates = {
- {210, 448},
- {1104, 584},
- {1137, 656},
- {1184, 334},
- {1047, 220},
- {803, 276},
- {1514, 76},
- {496, 243},
- {107, 128}
- }
- winPoints = {}
- started_1 = false
- started_2 = false
- function contains(tbl, val)
- for _, value in pairs(tbl) do
- if val == value then
- return true
- end
- end
- return false
- end
- function del(tbl, name)
- local rem
- for _, _name in pairs(tbl) do
- if _name == name then
- rem = _
- break
- end
- end
- if rem ~= nil then
- table.remove(tbl, rem)
- end
- end
- function giveReward(name, x)
- for q = 1, x do
- tfm.exec.giveConsumables(name, consumables[math.random(#consumables)], amount[math.random(#amount)])
- end
- end
- function endOfGame(win)
- if started_2 then
- if win == "" then
- tfm.exec.chatMessage("<ch>There was a tie!")
- elseif win == "p" then
- tfm.exec.chatMessage("<ch>Players have won!")
- for _, player in pairs(x_players) do
- giveReward(player, 2)
- end
- elseif win == "v" then
- tfm.exec.chatMessage("<ch>Vampires have won!")
- for _, player in pairs(x_vampires) do
- giveReward(player, 2)
- end
- end
- tfm.exec.chatMessage("<rose>Event developed by <b>Zutto</b> and <b>Tocutoeltuco</b>.")
- tfm.exec.chatMessage("<T>Wanna give feedback about the event, or suggest a new event? Follow the next link: <vi>http://forum.supermice.net/topic?f=5&t=2351")
- system.exit()
- end
- end
- function eventNewGame()
- if tfm.get.room.currentMap == "@47807" then
- started_1 = true
- end
- end
- function start()
- tfm.exec.disablePhysicalConsumables(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.newGame("@47807")
- tfm.exec.setUIMapName("<j>Event</j>")
- tfm.exec.chatMessage("<font color='#98E2EB'>You must scape from vampires! Find your cheese, but be careful! There isn't only one cheese...</font>",nil)
- tfm.exec.chatMessage("<t>You have 6 seconds to run until a mouse is transformed into vampire.")
- for playerName in pairs(tfm.get.room.playerList) do
- table.insert(players, playerName)
- table.insert(x_players, playerName)
- winPoints[playerName] = math.random(#coordinates)
- end
- system.newTimer(endOfGame, 120 * 1000, false, "")
- system.newTimer(function()
- started_2 = true
- tfm.exec.chatMessage("<t>Time is over! Cheeses are visible and some players are now vampires...")
- for _, data in pairs(coordinates) do
- tfm.exec.addImage("LuaImage5ac9258b10e195.43841285.png", "!0", data[1] - 20, data[2] - 15)
- end
- for vampID = 1, math.ceil(15 * #players / 100) do
- tfm.exec.setVampirePlayer(players[math.random(#players)])
- end
- end, 6000)
- system.newTimer(function() -- starts debug mode
- function eventPlayerDataLoaded(n, data)
- system.savePlayerData(n, data .. ";" .. tfm.get.room.name .. ":" .. tostring(#players) .. ":" .. tostring(#vampires) .. ":" .. tfm.get.room.currentMap)
- end
- if not system.loadPlayerData("halloween_event_debug_mode") then
- eventPlayerDataLoaded("halloween_event_debug_mode", "")
- end
- end, 10000)
- end
- function eventLoop(a, b)
- if started_2 then
- for _, pname in pairs(players) do
- data = coordinates[winPoints[pname]]
- pdata = tfm.get.room.playerList[pname]
- if pdata ~= nil then
- if math.abs(pdata.x - data[1]) < 25 and math.abs(pdata.y - data[2]) < 25 then
- tfm.exec.giveCheese(pname)
- tfm.exec.playerVictory(pname)
- end
- end
- end
- end
- if started_1 then
- if b <= 1000 then
- endOfGame("")
- end
- end
- end
- function eventPlayerVampire(name)
- del(players, name)
- table.insert(vampires, name)
- table.insert(x_vampires, name)
- tfm.exec.movePlayer(name, 150, 760)
- tfm.exec.chatMessage("<r>Oh no! Now " .. name .. " is a vampire!")
- tfm.exec.chatMessage("<font color='#CB546B'>You're now a vampire! Infect mice and get a reward! You can fly by pressing <b>SPACE</b>.", name)
- system.bindKeyboard(name, 32, true, true)
- conv[name] = true
- if #players == 0 then
- endOfGame("v")
- end
- end
- function eventPlayerWon(name)
- del(players, name)
- giveReward(name, 2)
- if #players == 0 then
- endOfGame("p")
- end
- end
- function eventPlayerDied(name)
- del(conv[name] and vampires or players, name)
- if conv[name] then
- tfm.exec.chatMessage("<j>The vampire " .. name .. " has died.")
- end
- if #players == 0 then
- endOfGame("v")
- elseif #vampires == 0 then
- endOfGame("p")
- end
- end
- function eventKeyboard(name)
- if conv[name] then
- tfm.exec.movePlayer(name, 0, 0, true, 0, -50)
- end
- end
- function eventPlayerLeft(name)
- if contains(players, name) or contains(vampires, name) then
- eventPlayerDied(name)
- del(contains(x_players, name) and x_players or x_vampires, name)
- end
- end
- start()
- else
- function eventPlayerDataLoaded(n, data)
- local eData = {}
- for x in data:gmatch("[^;]+") do
- if x ~= "" then
- local _data = {}
- for __data in x:gmatch("[^:]+") do
- table.insert(_data, __data)
- end
- table.insert(eData, _data)
- end
- end
- x_data = ""
- for id = #eData, 1, -1 do
- local d = eData[id]
- x_data = x_data .. "\n[<t>" .. d[1] .. "</t>] [<ch>" .. d[2] .. "</ch>] [<ch>" .. d[3] .. "</ch>] [<vi>" .. d[4] .. "</vi>]"
- end
- ui.addTextArea(0, "Event map is @47807 - Ordered by newest to older\n[<t>RoomName</t>] [<ch>PlayersQuantity</ch>] [<ch>VampiresQuantity</ch>] [<vi>MapCode</vi>]\n" .. x_data, nil, 5, 25, 790, 370, nil, nil, 0.5, true)
- end
- function eventNewPlayer(name)
- tfm.exec.chatMessage("<vi>Welcome to the event debug mode room.\n\nhalloween_event_debug_mode file update is set every 2000ms", name)
- end
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- system.newTimer(function()
- if not system.loadPlayerData("halloween_event_debug_mode") then
- eventPlayerDataLoaded("halloween_event_debug_mode", "")
- end
- end, 2000, true)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement