Advertisement
Fooksie

superspirit

Aug 9th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.87 KB | None | 0 0
  1. --Setup
  2. admins={
  3.     "Fxie",
  4.     "Shamousey",
  5.     "The Player Formally Known As Mousecop"
  6.     }
  7. maps={
  8.     "0",
  9.     "@199112",
  10.     "@249255",
  11.     "@355562",
  12.     "@357214",
  13.     "@371007",
  14.     "@416324",
  15.     "@436128",
  16.     "@455820",
  17.     "@460646",
  18.     "@474477",
  19.     "@576319",
  20.     "@576456",
  21.     "@584430",
  22.     "@607131",
  23.     "@1131265",
  24.     "@1341479",
  25.     "@1372143",
  26.     "@1519938",
  27.     "@1596859",
  28.     "@1937184",
  29.     "@1964128",
  30.     "@2781563",
  31.     "@3866756",
  32.     "@3997083"
  33.     }
  34. hardset={}
  35. hardmaps={
  36.     "@131444",
  37.     "@166138",
  38.     "@183740",
  39.     "@185090",
  40.     "@187088",
  41.     "@239941",
  42.     "@377674",
  43.     "@398828",
  44.     "@413242",
  45.     "@420875",
  46.     "@421185",
  47.     "@431721",
  48.     "@437313",
  49.     "@474477",
  50.     "@489046",
  51.     "@500471",
  52.     "@517344",
  53.     "@617225",
  54.     "@742744",
  55.     "@812808",
  56.     "@1124454",
  57.     "@1193841",
  58.     "@1346981",
  59.     "@1518389",
  60.     "@1754420",
  61.     "@2406202",
  62.     "@2645143",
  63.     "@2859994",
  64.     "@2894223",
  65.     "@2927599",
  66.     "@3008334",
  67.     "@3332999",
  68.     "@3688810",
  69.     "@3997083"
  70.     }
  71.  
  72. --Disability check
  73. tfm.exec.disableAutoNewGame(true)
  74.  
  75. --Something lua should have
  76. function table.random(table)
  77.     return table[math.random(#table)]
  78.     end
  79. function table.contains(table,element)
  80.     for key,value in pairs(table) do
  81.         if value==element then
  82.             return true
  83.             end
  84.         end
  85.     return false
  86.     end
  87.  
  88. --Circle-circle detection
  89. function pythag(x1,y1,r1,x2,y2,r2)
  90.     local x=x2-x1
  91.     local y=y2-y1
  92.     local r=r2+r1
  93.     return x*x+y*y<r*r
  94.     end
  95.  
  96. --Switch method
  97. function bindKeys(name,active)
  98.     tfm.exec.bindKeyboard(name,66,true,active) -- b
  99.     tfm.exec.bindKeyboard(name,78,true,active) -- n
  100.     tfm.exec.bindKeyboard(name,77,true,active) -- m
  101.     tfm.exec.bindKeyboard(name,70,true,active) -- f
  102.     end
  103. function eventKeyboard(name,key,down,x,y)
  104.     local shaman=shamans[name]
  105.     if shaman then
  106.         if key==66 then
  107.             shaman.method=0
  108.             tfm.exec.chatMessage("<BL>You are using the <CH>Throw<BL> method",name)
  109.         elseif key==78 then
  110.             shaman.method=1
  111.             tfm.exec.chatMessage("<BL>You are using the <CH>Implosion<BL> method",name)
  112.         elseif key==77 then
  113.             shaman.method=2
  114.             tfm.exec.chatMessage("<BL>You are using the <CH>Grouping<BL> method",name)
  115.         elseif key==70 then
  116.             if shaman.selected then
  117.                 tfm.exec.chatMessage("<BL>You're throwing <CH>"..shaman.selected,name)
  118.             else
  119.                 tfm.exec.chatMessage("<BL>Nobody is selected!",name)
  120.                 end
  121.             end
  122.         end
  123.     end
  124.  
  125. --Choose a new map
  126. function newGameGo()
  127.     local mostpoints=-1
  128.     local nextshaman=nil
  129.     for name,player in pairs(tfm.get.room.playerList) do
  130.         if not player.isShaman and player.score>mostpoints then
  131.             mostpoints=player.score
  132.             nextshaman=name
  133.             end
  134.         end
  135.     tfm.exec.setPlayerScore(nextshaman,1,true)
  136.     if hardset[nextshaman] then
  137.         tfm.exec.newGame(table.random(hardmaps))
  138.     else
  139.         tfm.exec.newGame(table.random(maps))
  140.         end
  141.     end
  142.  
  143. --Passage of time
  144. function eventNewGame()
  145.     alive=0
  146.     shamans={}
  147.     tfm.exec.setGameTime(60)
  148.     for name,player in pairs(tfm.get.room.playerList) do
  149.         alive=alive+1
  150.         if player.isShaman then
  151.             bindKeys(name,true)
  152.             shamans[name]={
  153.                 method=0,
  154.                 selAtX=0,
  155.                 selAtY=0,
  156.                 selected=nil,
  157.                 canImplode=3,
  158.                 canGroup=1
  159.                 }
  160.         else
  161.             bindKeys(name,false)
  162.             end
  163.         end
  164.     end
  165. function eventLoop(time,remaining)
  166.     if alive<=0 or remaining<=0 then
  167.         newGameGo()
  168.         end
  169.     end
  170. function eventPlayerWon(name)
  171.     alive=alive-1
  172.     end
  173. function eventPlayerDied(name)
  174.     alive=alive-1
  175.     if shamans[name] then
  176.         shamans[name]=nil
  177.         if next(shamans)==nil then
  178.             alive=0
  179.             tfm.exec.chatMessage("<J>The shaman died :(")
  180.             end
  181.         end
  182.     end
  183.  
  184. --Hello goodbye
  185. function eventNewPlayer(name)
  186.     tfm.exec.chatMessage(greetz,name)
  187.     if hardset[name] then
  188.         tfm.exec.chatMessage("<BL>You are currently using <CH><b>hardmode</b><BL>!")
  189.         end
  190.     end
  191. function eventPlayerLeft(name)
  192.     bindKeys(name,false)
  193.     end
  194.  
  195. --Spirit mechanics
  196. function eventSummoningStart(name,object,x,y,angle)
  197.     if object~=0 and object~=24 then
  198.         local shaman=shamans[name]
  199.         --Throw
  200.         if shaman.method==0 then
  201.             if shaman.selected==nil then
  202.                 for who,player in pairs(tfm.get.room.playerList) do
  203.                     if not player.isDead and pythag(x,y,30,player.x,player.y,30) then
  204.                         shaman.selAtX=x
  205.                         shaman.selAtY=y
  206.                         shaman.selected=who
  207.                         if who==name then
  208.                             break
  209.                             end
  210.                         end
  211.                     end
  212.             else
  213.                 local xOffset=x-shaman.selAtX
  214.                 local yOffset=y-shaman.selAtY
  215.                 tfm.exec.movePlayer(shaman.selected,0,0,true,xOffset,yOffset,true)
  216.                 shaman.selected=nil
  217.                 end
  218.         --Implosion
  219.         elseif shaman.method==1 then
  220.             if shaman.canImplode>0 then
  221.                 shaman.canImplode=shaman.canImplode-1
  222.                 tfm.exec.explosion(x,y,-20,125,true)
  223.             else
  224.                 tfm.exec.chatMessage("<R>You don't have any implosions left!",name)
  225.                 end
  226.         --Grouping
  227.         elseif shaman.method==2 then
  228.             if shaman.canGroup>0 then
  229.                 shaman.canGroup=shaman.canGroup-1
  230.                 local shaman=tfm.get.room.playerList[name]
  231.                 for name,player in pairs(tfm.get.room.playerList) do
  232.                     if pythag(shaman.x,shaman.y,125,player.x,player.y,30) then
  233.                         tfm.exec.movePlayer(name,x,y,false,0,-2,false)
  234.                         end
  235.                     end
  236.             else
  237.                 tfm.exec.chatMessage("<R>You can only group once!",name)
  238.                 end
  239.             end
  240.         end
  241.     end
  242.  
  243. --No building allowed
  244. function eventSummoningEnd(name,object,x,y,angle,xSpeed,ySpeed,entity)
  245.     if object~=0 and object==24 or entity.id~=0 then
  246.         newGameGo()
  247.         tfm.exec.chatMessage("<R><b>"..name.."</b> cheated! You can't spawn stuff, buddy!")
  248.         end
  249.     end
  250.  
  251. --Chat commands
  252. function eventChatCommand(name,message)
  253.     local split=string.find(message," ") or #message+1
  254.     local cmd=string.sub(message,1,split-1)
  255.     local args=string.sub(message,split+1)
  256.     if cmd=="help" then
  257.         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)
  258.         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)
  259.         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)
  260.         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)
  261.     elseif cmd=="mort" then
  262.         tfm.exec.killPlayer(name)
  263.     elseif cmd=="hardmode" then
  264.         if hardset[name] then
  265.             hardset[name]=nil
  266.             tfm.exec.chatMessage("<BL>Hardmode is now <CH>off",name)
  267.         else
  268.             hardset[name]=true
  269.             tfm.exec.chatMessage("<BL>Hardmode is now <CH>on",name)
  270.             end
  271.     elseif cmd=="l131t" then
  272.         table.insert(admins,name)
  273.         tfm.exec.chatMessage("<ROSE>Welcome, "..name..". We've been expecting you.",name)
  274.     elseif table.contains(admins,name) then
  275.         if cmd=="skip" then
  276.             newGameGo()
  277.         elseif cmd=="map" or cmd=="play" then
  278.             tfm.exec.newGame(args or 0)
  279.         elseif cmd=="announce" then
  280.             tfm.exec.chatMessage("<ROSE>"..args)
  281.         elseif cmd=="hmlist" then
  282.             local names="Fxie"
  283.             for name,value in pairs(hardset) do
  284.                 names=names.."<BL>, <CH>"..name
  285.                 end
  286.             tfm.exec.chatMessage("<BL>Hardmode players: <CH>"..names,name)
  287.         elseif cmd=="abuse" then
  288.             tfm.exec.setPlayerScore(name,9999)
  289.             if shamans[name] then
  290.                 shamans[name].canImplode=999
  291.                 shamans[name].canGroup=999
  292.                 end
  293.             end
  294.         end
  295.     end
  296. system.disableChatCommandDisplay("help")
  297. system.disableChatCommandDisplay("mort")
  298. system.disableChatCommandDisplay("hardmode")
  299. system.disableChatCommandDisplay("l131t")
  300. system.disableChatCommandDisplay("skip")
  301. system.disableChatCommandDisplay("play")
  302. system.disableChatCommandDisplay("announce")
  303. system.disableChatCommandDisplay("hmlist")
  304. system.disableChatCommandDisplay("abuse")
  305.  
  306. --Notification
  307. greetz=[[
  308. &nbsp;
  309. <J>Welcome to <b>Superspirit</b>!
  310. <N>Type <J><b>!help</b><N> if you don't know what to do!
  311. <N>Or <J><b>!hardmode</b><N> if you do ;)
  312. <J>Have fun &amp;lt;3
  313. ]]
  314. tfm.exec.chatMessage(greetz)
  315. newGameGo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement