Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- #bombsahoy
- -- SETTINGS, leave these alone for defualt gameplay.
- G_MAP = "@6263573" -- The map we will play on.
- B_POWER = 50 -- The amount of force an explosion has.
- B_DISTANCE = 100 -- The distance the explosion will reach.
- B_AIRTIME = 5 -- The amount of time in the air, before a new player gets the bomb.
- B_HELDTIME = 5 -- The amount of time a player can hold the bomb, before it explodes.
- B_TIMER = 20 -- The amount of time until the bomb explodes.
- B_XVELOCITY = 4 -- The amount of force it will go, in the left or right direction, when thrown.
- B_YVELOCITY = -8 -- The amount of force it will go, in the up or down direction, when thrown.
- --
- --
- --
- GameState = "NONE"
- CurrentBomb = {}
- tfm.exec.disableAfkDeath()
- tfm.exec.disableAutoNewGame()
- tfm.exec.disableAutoScore()
- tfm.exec.disableAutoShaman()
- tfm.exec.disableAutoTimeLeft()
- Bomb = {}
- Bomb.__index = Bomb
- function newBomb(x,y)
- b = setmetatable({
- player = "",
- lastPlayer = "",
- id = id,
- timer = 0,
- heldTimer = 0,
- airTimer = 0,
- }, Bomb)
- b:throw(x,y)
- return b
- end
- function Bomb:newPlayer()
- local pl = {}
- for n,p in pairs(tfm.get.room.playerList) do
- if not p.isDead then
- table.insert(pl, n)
- end
- end
- self.player = pl[math.random(#pl)]
- self.airTimer = 0
- self.heldTimer = 0
- tfm.exec.removeObject(self.id)
- tfm.exec.giveCheese(self.player)
- end
- function Bomb:throw(x, y)
- local vx, vy = B_XVELOCITY, B_YVELOCITY
- if x > 400 then vx = -vx end
- self.lastPlayer = self.player
- self.player = ""
- self.heldTimer = 0
- self.id = tfm.exec.addShamanObject(23, x, y, 0, vx, vy, false)
- end
- function Bomb:explode()
- local x, y = 400, 200
- if self.player == "" then
- if self.lastPlayer ~= "" then
- x, y = getPlayerLocation(self.lastPlayer)
- end
- else
- x, y = getPlayerLocation(self.player)
- tfm.exec.killPlayer(self.player)
- end
- tfm.exec.explosion(x, y, B_POWER, B_DISTANCE, false)
- tfm.exec.displayParticle(12, x, y)
- CurrentBomb = newBomb(400,200)
- end
- function getPlayerLocation(playerName)
- return tfm.get.room.playerList[playerName].x, tfm.get.room.playerList[playerName].y
- end
- --
- --
- function eventNewPlayer(playerName)
- if GameState == "MORE PLAYERS" then
- tfm.exec.newGame(G_MAP)
- end
- system.bindKeyboard(playerName, 32, true, true)
- ui.addTextArea(0, "<b><p align='center'>Welcome!", playerName, 300, 370, 200, 50)
- end
- function eventKeyboard(playerName, key, down, x, y)
- if CurrentBomb.player == playerName then
- tfm.exec.killPlayer(playerName)
- tfm.exec.respawnPlayer(playerName)
- tfm.exec.movePlayer(playerName, x, y)
- CurrentBomb:throw(x,y-50)
- end
- end
- function eventNewGame()
- local c = 0
- for n,p in pairs(tfm.get.room.playerList) do
- c = c + 1
- end
- if c < 2 then
- GameState = "MORE PLAYERS"
- print("<R>You need atleast 2 players!")
- ui.updateTextArea(0, "<b><p align='center'><R>You need atleast 2 players!<N>", nil)
- return
- end
- GameState = "START"
- for n,p in pairs(tfm.get.room.playerList) do
- ui.updateTextArea(0, "<b><p align='center'>Get ready!", playerName)
- end
- end
- function eventPlayerDied(playerName)
- if CurrentBomb.lastPlayer == playerName and CurrentBomb.player ~= playerName then
- return false
- end
- local a,pn = 0,""
- ui.updateTextArea(0, "<b><p align='center'>x_x", playerName)
- for n,p in pairs(tfm.get.room.playerList) do
- if not p.isDead then
- a = a + 1
- pn = n
- end
- end
- if a == 0 and GameState == "END" then
- tfm.exec.newGame(G_MAP)
- elseif a == 1 then
- GameState = "END"
- tfm.exec.setGameTime(10)
- ui.updateTextArea(0, "<b><p align='center'>"..pn.." wins!", nil)
- ui.updateTextArea(0, "<b><p align='center'>You win!", pn)
- end
- end
- function eventLoop(t,r)
- if r <= 0 and GameState == "END" then
- tfm.exec.newGame(G_MAP)
- end
- if GameState == "START" then
- if t >= 5000 then
- GameState = "GAME"
- CurrentBomb = newBomb(400+(math.random(2)==1 and 1 or 0), 200)
- end
- end
- if GameState == "GAME" then
- CurrentBomb.timer = CurrentBomb.timer + 500
- ui.updateTextArea(0, "<b><p align='center'>"..(B_TIMER - math.ceil(CurrentBomb.timer/1000)).."s", playerName)
- if CurrentBomb.player ~= "" then
- CurrentBomb.heldTimer = CurrentBomb.heldTimer + 500
- ui.updateTextArea(0, "<b><p align='center'> HURRY! "..(B_HELDTIME - math.ceil(CurrentBomb.heldTimer/1000)).."s!", CurrentBomb.player)
- else
- CurrentBomb.airTimer = CurrentBomb.airTimer + 500
- end
- if CurrentBomb.timer > B_TIMER*1000 or CurrentBomb.heldTimer > B_HELDTIME*1000 then
- CurrentBomb:explode()
- end
- if CurrentBomb.airTimer > B_AIRTIME*1000 then
- CurrentBomb:newPlayer()
- end
- end
- end
- tfm.exec.newGame(G_MAP)
- for n,p in pairs(tfm.get.room.playerList) do eventNewPlayer(n) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement