Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Setup
- admins={
- "Fxie",
- "Shamousey",
- "The Player Formally Known As Mousecop"
- }
- maps={
- "0",
- "@199112",
- "@249255",
- "@355562",
- "@357214",
- "@371007",
- "@416324",
- "@436128",
- "@455820",
- "@460646",
- "@474477",
- "@576319",
- "@576456",
- "@584430",
- "@607131",
- "@1131265",
- "@1341479",
- "@1372143",
- "@1519938",
- "@1596859",
- "@1937184",
- "@1964128",
- "@2781563",
- "@3866756",
- "@3997083"
- }
- hardset={}
- hardmaps={
- "@131444",
- "@166138",
- "@183740",
- "@185090",
- "@187088",
- "@239941",
- "@377674",
- "@398828",
- "@413242",
- "@420875",
- "@421185",
- "@431721",
- "@437313",
- "@474477",
- "@489046",
- "@500471",
- "@517344",
- "@617225",
- "@742744",
- "@812808",
- "@1124454",
- "@1193841",
- "@1346981",
- "@1518389",
- "@1754420",
- "@2406202",
- "@2645143",
- "@2859994",
- "@2894223",
- "@2927599",
- "@3008334",
- "@3332999",
- "@3688810",
- "@3997083"
- }
- --Disability check
- tfm.exec.disableAutoNewGame(true)
- --Something lua should have
- function table.random(table)
- return table[math.random(#table)]
- end
- function table.contains(table,element)
- for key,value in pairs(table) do
- if value==element then
- return true
- end
- end
- return false
- end
- --Circle-circle detection
- function pythag(x1,y1,r1,x2,y2,r2)
- local x=x2-x1
- local y=y2-y1
- local r=r2+r1
- return x*x+y*y<r*r
- end
- --Switch method
- function bindKeys(name,active)
- tfm.exec.bindKeyboard(name,66,true,active) -- b
- tfm.exec.bindKeyboard(name,78,true,active) -- n
- tfm.exec.bindKeyboard(name,77,true,active) -- m
- tfm.exec.bindKeyboard(name,70,true,active) -- f
- end
- function eventKeyboard(name,key,down,x,y)
- local shaman=shamans[name]
- if shaman then
- if key==66 then
- shaman.method=0
- tfm.exec.chatMessage("<BL>You are using the <CH>Throw<BL> method",name)
- elseif key==78 then
- shaman.method=1
- tfm.exec.chatMessage("<BL>You are using the <CH>Implosion<BL> method",name)
- elseif key==77 then
- shaman.method=2
- tfm.exec.chatMessage("<BL>You are using the <CH>Grouping<BL> method",name)
- elseif key==70 then
- if shaman.selected then
- tfm.exec.chatMessage("<BL>You're throwing <CH>"..shaman.selected,name)
- else
- tfm.exec.chatMessage("<BL>Nobody is selected!",name)
- end
- end
- end
- end
- --Choose a new map
- function newGameGo()
- local mostpoints=-1
- local nextshaman=nil
- for name,player in pairs(tfm.get.room.playerList) do
- if not player.isShaman and player.score>mostpoints then
- mostpoints=player.score
- nextshaman=name
- end
- end
- tfm.exec.setPlayerScore(nextshaman,1,true)
- if hardset[nextshaman] then
- tfm.exec.newGame(table.random(hardmaps))
- else
- tfm.exec.newGame(table.random(maps))
- end
- end
- --Passage of time
- function eventNewGame()
- alive=0
- shamans={}
- tfm.exec.setGameTime(60)
- for name,player in pairs(tfm.get.room.playerList) do
- alive=alive+1
- if player.isShaman then
- bindKeys(name,true)
- shamans[name]={
- method=0,
- selAtX=0,
- selAtY=0,
- selected=nil,
- canImplode=3,
- canGroup=1
- }
- else
- bindKeys(name,false)
- end
- end
- end
- function eventLoop(time,remaining)
- if alive<=0 or remaining<=0 then
- newGameGo()
- end
- end
- function eventPlayerWon(name)
- alive=alive-1
- end
- function eventPlayerDied(name)
- alive=alive-1
- if shamans[name] then
- shamans[name]=nil
- if next(shamans)==nil then
- alive=0
- tfm.exec.chatMessage("<J>The shaman died :(")
- end
- end
- end
- --Hello goodbye
- function eventNewPlayer(name)
- tfm.exec.chatMessage(greetz,name)
- if hardset[name] then
- tfm.exec.chatMessage("<BL>You are currently using <CH><b>hardmode</b><BL>!")
- end
- end
- function eventPlayerLeft(name)
- bindKeys(name,false)
- end
- --Spirit mechanics
- function eventSummoningStart(name,object,x,y,angle)
- if object~=0 and object~=24 then
- local shaman=shamans[name]
- --Throw
- if shaman.method==0 then
- if shaman.selected==nil then
- for who,player in pairs(tfm.get.room.playerList) do
- if not player.isDead and pythag(x,y,30,player.x,player.y,30) then
- shaman.selAtX=x
- shaman.selAtY=y
- shaman.selected=who
- if who==name then
- break
- end
- end
- end
- else
- local xOffset=x-shaman.selAtX
- local yOffset=y-shaman.selAtY
- tfm.exec.movePlayer(shaman.selected,0,0,true,xOffset,yOffset,true)
- shaman.selected=nil
- end
- --Implosion
- elseif shaman.method==1 then
- if shaman.canImplode>0 then
- shaman.canImplode=shaman.canImplode-1
- tfm.exec.explosion(x,y,-20,125,true)
- else
- tfm.exec.chatMessage("<R>You don't have any implosions left!",name)
- end
- --Grouping
- elseif shaman.method==2 then
- if shaman.canGroup>0 then
- shaman.canGroup=shaman.canGroup-1
- local shaman=tfm.get.room.playerList[name]
- for name,player in pairs(tfm.get.room.playerList) do
- if pythag(shaman.x,shaman.y,125,player.x,player.y,30) then
- tfm.exec.movePlayer(name,x,y,false,0,-2,false)
- end
- end
- else
- tfm.exec.chatMessage("<R>You can only group once!",name)
- end
- end
- end
- end
- --No building allowed
- function eventSummoningEnd(name,object,x,y,angle,xSpeed,ySpeed,entity)
- if object~=0 and object==24 or entity.id~=0 then
- newGameGo()
- tfm.exec.chatMessage("<R><b>"..name.."</b> cheated! You can't spawn stuff, buddy!")
- end
- end
- --Chat commands
- function eventChatCommand(name,message)
- local split=string.find(message," ") or #message+1
- local cmd=string.sub(message,1,split-1)
- local args=string.sub(message,split+1)
- if cmd=="help" then
- tfm.exec.chatMessage("<J>You can use any shaman object to play this game - spirits are my favorite. You do not spawn the objects, but instead click with them. There are three types of \"spirits\"...",name)
- tfm.exec.chatMessage("<J><b>Throw</b><N> <VP>(B - default)<T> Click on a mouse to select her, then somewhere else to throw them there! One at a time!",name)
- tfm.exec.chatMessage("<J><b>Implosion</b><N> <VP>(N)<T> Mice within range will be sucked towards the source of the implosion, faster the farther it is from them! You only get 3 of these per round.",name)
- tfm.exec.chatMessage("<J><b>Grouping</b><N> <VP>(M)<T> All mice within range will be moved to the point you clicked! You can only pull this off once per round.",name)
- elseif cmd=="mort" then
- tfm.exec.killPlayer(name)
- elseif cmd=="hardmode" then
- if hardset[name] then
- hardset[name]=nil
- tfm.exec.chatMessage("<BL>Hardmode is now <CH>off",name)
- else
- hardset[name]=true
- tfm.exec.chatMessage("<BL>Hardmode is now <CH>on",name)
- end
- elseif cmd=="l131t" then
- table.insert(admins,name)
- tfm.exec.chatMessage("<ROSE>Welcome, "..name..". We've been expecting you.",name)
- elseif table.contains(admins,name) then
- if cmd=="skip" then
- newGameGo()
- elseif cmd=="map" or cmd=="play" then
- tfm.exec.newGame(args or 0)
- elseif cmd=="announce" then
- tfm.exec.chatMessage("<ROSE>"..args)
- elseif cmd=="hmlist" then
- local names="Fxie"
- for name,value in pairs(hardset) do
- names=names.."<BL>, <CH>"..name
- end
- tfm.exec.chatMessage("<BL>Hardmode players: <CH>"..names,name)
- elseif cmd=="abuse" then
- tfm.exec.setPlayerScore(name,9999)
- if shamans[name] then
- shamans[name].canImplode=999
- shamans[name].canGroup=999
- end
- end
- end
- end
- system.disableChatCommandDisplay("help")
- system.disableChatCommandDisplay("mort")
- system.disableChatCommandDisplay("hardmode")
- system.disableChatCommandDisplay("l131t")
- system.disableChatCommandDisplay("skip")
- system.disableChatCommandDisplay("play")
- system.disableChatCommandDisplay("announce")
- system.disableChatCommandDisplay("hmlist")
- system.disableChatCommandDisplay("abuse")
- --Notification
- greetz=[[
-
- <J>Welcome to <b>Superspirit</b>!
- <N>Type <J><b>!help</b><N> if you don't know what to do!
- <N>Or <J><b>!hardmode</b><N> if you do ;)
- <J>Have fun &lt;3
- ]]
- tfm.exec.chatMessage(greetz)
- newGameGo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement