Mousetat

Bafflua old version(with trivia and simonsays)(bugged)

Jan 9th, 2017
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.64 KB | None | 0 0
  1. --[[ BAFFLUA MINIGAMES
  2. Vampire - A quick vampire survivor round, where vampires can fly.
  3. Dynamic Maze - A maze is made up of moving boxes, that mice have to try and maneuver around to get the cheese.
  4. Cheese Hunt - (You know what it is, it just doesn't seem to be doing well as its own room so making it a minigame might be good.)
  5. Dodge - Random items are shot from the ground upwards with a little warning, getting faster. Mice have to doge them so they don't die.
  6. Auto-survivor - Mice have to dodge the cannons that the shaman shoots at them (Baffbot style).
  7. Dive - The opposite of fly, tapping space will launch downards (think water maps).
  8. Shaman Fly - Whenever the shaman taps space, every mouse in the room gets launched up a little.
  9. Box Building - Pick up a box and place it down to build to the cheese (Baffbot style).
  10. Shooting Mice - Clicking on a mouse with an arrow will launch them in that direction.
  11. Bloon - Mice duck to get a balloon spawned which they can ride across.
  12.  
  13. Simon - simon says use an emote!
  14. ]]
  15. --when u dont want something just press !skip
  16. --FFA and Push box dont work for some reason...
  17.  
  18. --Prepwork
  19. debug.disableEventLog(true)
  20. tfm.exec.disableAutoNewGame(true)
  21. tfm.exec.setRoomMaxPlayers(5)
  22. admins={
  23. "Shamousey", --noob girl
  24. "Reshman", --im a noob
  25. "Mousetat", --im #1
  26. "Destinyruiz" --im also a noob
  27. }
  28. greets={
  29. "Hey qt *-*",
  30. "What's shakin bacon?",
  31. "Hey hot stuff, ready for a good time? ;)",
  32. "Go lick a duck and call yourself Shirley.",
  33. "OMG it's you!! kan i get your autografph?!",
  34. "If you touch my walrus one more time, I swear to god...",
  35. "Who are you and why are you sitting there?",
  36. "How you doin'? ;)"
  37. }
  38. games={
  39. --------------------------------------------------
  40. { name="Balance",
  41. time=15,
  42. shaman=false,
  43. intro="Don't rock the boat baby!",
  44. maps={"@3997635"},
  45. loop=function(time,remaining)
  46. if remaining<=1000 then
  47. tfm.exec.giveWinAll()
  48. end
  49. end
  50. },
  51. --------------------------------------------------
  52. { name="Bomb",
  53. time=30,
  54. delay=3,
  55. shaman=false,
  56. intro="Everyone is a bomb! KO the other team before they make it to your side of the map by pressing <VP>SPACE<J> to explode!",
  57. maps={"111"},
  58. prep=function()
  59. minigame.teams=makeTeams()
  60. for name,team in pairs(minigame.teams) do
  61. local red=name=="red"
  62. for i=1,#team,1 do
  63. tfm.exec.setNameColor(team[i],red and "0xEB1D51" or "0x2F7FCC")
  64. tfm.exec.movePlayer(team[i],red and 40 or 760,360,false,0,0,false)
  65. end
  66. end
  67. end,
  68. loop=function()
  69. for name,team in pairs(minigame.teams) do
  70. local red=name=="red"
  71. for i=1,#team,1 do
  72. local x=getPlayer(team[i]).x
  73. if (red and x>600) or (not red and x<200) then
  74. minigame.won=true
  75. tfm.exec.setGameTime(5)
  76. tfm.exec.chatMessage((red and "<R><b>Red" or "<BV><b>Blue").." team won thanks to "..team[i].."!</b>")
  77. for i=1,#team,1 do
  78. tfm.exec.giveWin(team[i])
  79. end
  80. end
  81. end
  82. end
  83. end,
  84. keys={
  85. SPACE=function(name,x,y)
  86. tfm.exec.killPlayer(name)
  87. tfm.exec.explosion(x,y,40,125,false)
  88. end
  89. }
  90. },
  91. --------------------------------------------------
  92. { name="Climb",
  93. time=60,
  94. shaman=false,
  95. intro="Reach the top of the map!",
  96. maps={"111"},
  97. prep=function()
  98. minigame.clouds={}
  99. end,
  100. loop=function()
  101. if minigame.clouds then
  102. local x=math.random(50,750)
  103. local y=math.random(75,300)
  104. local cloud=tfm.exec.addShamanObject(57,x,y)
  105. table.insert(minigame.clouds,cloud)
  106. if #minigame.clouds>=20 then
  107. tfm.exec.removeObject(minigame.clouds[1])
  108. table.remove(minigame.clouds,1)
  109. end
  110. end
  111. for name,player in pairs(tfm.get.room.playerList) do
  112. if player.y>5 and player.y<=75 then
  113. tfm.exec.giveCheese(name)
  114. end
  115. end
  116. end
  117. },
  118. --------------------------------------------------
  119. { name="Dance",
  120. time=60,
  121. delay=5,
  122. shaman=true,
  123. intro="The shaman will give you a new direction every second! Keep up!",
  124. maps={"@580702"},
  125. prep=function()
  126. minigame.change=0
  127. minigame.dance=nil
  128. minigame.shaman=tfm.exec.getShaman()
  129. minigame.players={}
  130. for name,player in pairs(tfm.get.room.playerList) do
  131. minigame.players[name]={
  132. won=false,
  133. wrong=0,
  134. right=0
  135. }
  136. end
  137. end,
  138. loop=function()
  139. tfm.exec.movePlayer(minigame.shaman,400,140,false,0,-1,false)
  140. end,
  141. keys={
  142. DOWN=function(name,x,y)
  143. minigame.move(name,"DOWN",x,y)
  144. end,
  145. LEFT=function(name,x,y)
  146. minigame.move(name,"LEFT",x,y)
  147. end,
  148. RIGHT=function(name,x,y)
  149. minigame.move(name,"RIGHT",x,y)
  150. end
  151. },
  152. move=function(name,direction,x,y)
  153. if name==minigame.shaman then
  154. local timestamp=tonumber(os.time())
  155. if timestamp-minigame.change>2000 then
  156. minigame.change=timestamp
  157. minigame.dance=direction
  158. local rotate=direction=="DOWN" and 0 or direction=="LEFT" and 90 or direction=="RIGHT" and 270
  159. tfm.exec.addShamanObject(0,200,140,rotate)
  160. tfm.exec.addShamanObject(0,400,80,rotate)
  161. tfm.exec.addShamanObject(0,600,140,rotate)
  162. end
  163. elseif not minigame.players[name].won then
  164. if minigame.dance==direction then
  165. tfm.exec.setPlayerScore(name,1,true)
  166. minigame.players[name].right=minigame.players[name].right+1
  167. elseif minigame.players[name].right>=15 then
  168. minigame.players[name].won=true
  169. tfm.exec.chatMessage("<J><b>You got 15 right!</b> <VP>DUCK<J> to spawn a balloon!",name)
  170. else
  171. minigame.players[name].wrong=minigame.players[name].wrong+1
  172. if minigame.players[name].wrong<3 then
  173. tfm.exec.chatMessage("<R>Way off!",name)
  174. else
  175. tfm.exec.killPlayer(name)
  176. tfm.exec.chatMessage("<R>Three strikes, you're out!",name)
  177. end
  178. end
  179. elseif direction=="DOWN" then
  180. tfm.exec.addShamanObject(28,x,y-90)
  181. tfm.exec.movePlayer(name,0,-120,true,0,-1,false)
  182. end
  183. end
  184. },
  185. --------------------------------------------------
  186. { name="Disco",
  187. time=15,
  188. shaman=false,
  189. intro="<ROSE>It's <b>party</b> time!!",
  190. maps={"@3926952"},
  191. prep=function()
  192. minigame.party={}
  193. end,
  194. loop=function()
  195. for name,player in pairs(tfm.get.room.playerList) do
  196. local colors={"0","4","8","C","F"}
  197. local currentColor="0x"
  198. for i=1,6,1 do
  199. currentColor=currentColor..table.random(colors)
  200. end
  201. tfm.exec.setNameColor(name,currentColor)
  202.  
  203. tfm.exec.setPlayerScore(name,1,true)
  204.  
  205. end
  206. end,
  207. emote=function(name,emote)
  208. minigame.party[name]=emote==0 or nil
  209. end
  210. },
  211. --------------------------------------------------
  212. --[[
  213. { name="Fallout",
  214. time=60,
  215. shaman=false,
  216. intro="Random objects are falling from the sky! Look out!",
  217. maps={0}
  218. },
  219. ]]--
  220. --------------------------------------------------
  221. { name="FFA",
  222. time=60,
  223. delay=3,
  224. shaman=false,
  225. intro="You can shoot cannons by <VP>ducking<J>! Last mouse standing wins!",
  226. maps={521833,401421,541917,541928,541936,541943,527935,559634,559644,888052,878047,885641,770600,770656,772172,891472,589736,589800,589708,900012,901062,754380,901337,901411,892660,907870,910078,1190467,1252043,1124380,1016258,1252299,1255902,1256808,986790,1285380,1271249,1255944,1255983,1085344,1273114,1276664,1279258,1286824,1280135,1280342,1284861,1287556,1057753,1196679,1288489,1292983,1298164,1298521,1293189,1296949,1308378,1311136,1314419,1314982,1318248,1312411,1312589,1312845,1312933,1313969,1338762,1339474,1349878,1297154,644588,1351237,1354040,1354375,1362386,1283234,1370578,1306592,1360889,1362753,1408124,1407949,1407849,1343986,1408028,1441370,1443416,1389255,1427349,1450527,1424739,869836,1459902,1392993,1426457,1542824,1533474,1561467,1563534,1566991,1587241,1416119,1596270,1601580,1525751,1582146,1558167,1420943,1466487,1642575,1648013,1646094,1393097,1643446,1545219,1583484,1613092,1627981,1633374,1633277,1633251,1585138,1624034,1616785,1625916,1667582,1666996,1675013,1675316,1531316,1665413,1681719,1699880,1688696,623770,1727243,1531329,1683915,1689533,1738601,3756146},
  227. prep=function()
  228. minigame.lava=nil
  229. minigame.players={}
  230. for name,player in pairs(tfm.get.room.playerList) do
  231. minigame.players[name]={
  232. facing=1,
  233. cooldown=0
  234. }
  235. end
  236. end,
  237. loop=function(time,remaining)
  238. if alive==1 then
  239. local survivor=getAlivePlayers()[1]
  240. tfm.exec.chatMessage("<J><b>"..survivor.."</b> kicked butt!")
  241. tfm.exec.giveWin(survivor)
  242. elseif remaining<15000 then
  243. if not minigame.lava then
  244. minigame.lava=true
  245. tfm.exec.chatMessage("<J><b>Sudden death!!</b> Stay on screen!")
  246. else
  247. for name,player in pairs(tfm.get.room.playerList) do
  248. if player.y<0 or player.x<0 or player.x>800 then
  249. tfm.exec.killPlayer(name)
  250. end
  251. end
  252. end
  253. end
  254. end,
  255. keys={
  256. LEFT=function(name)
  257. minigame.players[name].facing=0
  258. end,
  259. RIGHT=function(name)
  260. minigame.players[name].facing=1
  261. end,
  262. DOWN=function(name,x,y)
  263. local timestamp=tonumber(os.time())
  264. if timestamp-minigame.players[name].cooldown>=1000 then
  265. minigame.players[name].cooldown=timestamp
  266. if minigame.players[name].facing==0 then
  267. tfm.exec.addShamanObject(20,x+10,y+15)
  268. else
  269. tfm.exec.addShamanObject(19,x-10,y+15)
  270. end
  271. end
  272. end
  273. }
  274. },
  275. --------------------------------------------------
  276. { name="Fly",
  277. time=60,
  278. shaman=false,
  279. intro="You can fly! Tap <VP>SPACE<J> to fly!",
  280. maps={'@1586626','@17944016','@871739','@1970001','@2439335','@367747','@3060750','@431721','@423670','@1578737','@923878','@1714548','@1578909','@1578851','@1578868','@1501237','@1224534','@1134543','@896157','@1134474','@999125','@999585','@891035','@926203','@764026','@717845','@577496','@573527','@197503','@2227644','@3054424','@436128','@1196336','@3008334','@1622242','@2113338','@379805','@187088','@421185','@164663','@335361','@146615','@186695','@181261','@201606','@155415','@455094','@433483','@294500','@318970','@211248','@180035','@3731774','@3599104','@3494281'},
  281. keys={
  282. SPACE=function(name)
  283. tfm.exec.movePlayer(name,0,0,true,0,-50,true)
  284. end
  285. }
  286. },
  287. --------------------------------------------------
  288. { name="Hill",
  289. time=30,
  290. shaman=false,
  291. intro="Don't fall off!",
  292. maps={"@3998037","@4025101"},
  293. loop=function(time,remaining)
  294. if alive==1 or remaining<=1000 then
  295. tfm.exec.giveWinAll()
  296. end
  297. end
  298. },
  299. --------------------------------------------------
  300. { name="Launch",
  301. time=60,
  302. shaman=true,
  303. intro="Click on mice with rotated arrows to launch them!",
  304. maps={"#4"},
  305. summoned=function(name,object,x,y,angle)
  306. if object==0 then
  307. for name,player in pairs(tfml.get.room.playerList) do
  308. if pythag(x,y,30,player.x,player.y,30) then
  309. local xv=Math.cos(angle)*10
  310. local yv=Math.sin(angle)*10
  311. tfm.exec.movePlayer(name,0,0,false,xv,yv,true)
  312. end
  313. end
  314. end
  315. end
  316. },
  317. --------------------------------------------------
  318. { name="Push",
  319. time=45,
  320. shaman=false,
  321. intro="Push the box off of the map!",
  322. maps={"@3995576","@425860","@3997537","@3997576"},
  323. boxes={{735,290},{91,194},{91,302},{118,212}},
  324. prep=function()
  325. local box=minigame.boxes[minigame.mapIndex]
  326. minigame.box=tfm.exec.addShamanObject(1,box[1],box[2])
  327. end,
  328. loop=function()
  329. local box=tfm.get.room.objectList[minigame.box]
  330. if box then
  331. minigame.won=true
  332. tfm.exec.setGameTime(15)
  333. tfm.exec.chatMessage("<J>You sure showed that box!")
  334. for name,player in pairs(tfm.get.room.playerList) do
  335. minigame.box=nil
  336. if math.abs(box.x-player.x)<90 then
  337. tfm.exec.giveCheese(name)
  338. else
  339. tfm.exec.killPlayer(name)
  340. end
  341. end
  342. end
  343. end
  344. },
  345. --------------------------------------------------
  346. { name="Simon",
  347. time=30,
  348. shaman=false,
  349. intro="Simon says...",
  350. maps={"0"},
  351. prep=function()
  352. minigame.simon=nil
  353. minigame.switch=0
  354. end,
  355. loop=function(time,remaining)
  356. local timestamp=tonumber(os.time())
  357. if timestamp-minigame.switch>=2000 then
  358. minigame.switch=timestamp
  359. local says={"Dance","Laugh","Cry","Kiss","Rage","Clap","Sleep","Facepaw","Sit","Throw confetti"}
  360. minigame.simon=math.random(1,#says)-1
  361. tfm.exec.chatMessage("<V>[Simon] <CH><b>"..says[minigame.simon+1].."!</b>")
  362. end
  363. end,
  364. emote=function(name,emote)
  365. if emote==minigame.simon then
  366. tfm.exec.setPlayerScore(name,1,true)
  367. else
  368. tfm.exec.killPlayer(name)
  369. tfm.exec.chatMessage("<span color='#F0A78E'>[<b>Simon</b>] I didn't say do that!</span>",name)
  370. end
  371. end
  372. },
  373. --------------------------------------------------
  374. { name="Smash",
  375. time=60,
  376. shaman=true,
  377. intro="The shaman can throw mice! Beware, little girls!",
  378. maps={"#10"},
  379. loop=function(time,remaining)
  380. if remaining<=1000 then
  381. minigame.won=true
  382. for name,player in pairs(tfm.get.room.playerList) do
  383. if not player.isDead and not player.isShaman then
  384. tfm.exec.giveWin(name)
  385. end
  386. end
  387. elseif alive==1 then
  388. tfm.exec.giveWinAll()
  389. end
  390. end,
  391. summon=function(name,object,x,y,angle)
  392. if object==24 then
  393. if minigame.selected then
  394. local xOffset=x-minigame.xClick
  395. local yOffset=y-minigame.yClick
  396. tfm.exec.movePlayer(minigame.selected,0,0,true,xOffset,yOffset,true)
  397. minigame.selected=nil
  398. else
  399. for name,player in pairs(tfm.get.room.playerList) do
  400. if pythag(x,y,30,player.x,player.y,30) then
  401. minigame.selected=name
  402. minigame.xClick=x
  403. minigame.yClick=y
  404. break
  405. end
  406. end
  407. end
  408. end
  409. end
  410. },
  411. --------------------------------------------------
  412. { name="Spiritjump",
  413. time=30,
  414. shaman=false,
  415. intro="<VP>DUCK<J> to spiritjump!",
  416. maps={"#7"},
  417. keys={
  418. DOWN=function(name,x,y)
  419. tfm.exec.addShamanObject(24,x,y+15)
  420. end
  421. }
  422. },
  423. --------------------------------------------------
  424. { name="Teleport",
  425. time=60,
  426. shaman=true,
  427. intro="The shaman can spawn portals anywhere with arrows!",
  428. maps={"#4"},
  429. prep=function()
  430. minigame.portal=-1
  431. end,
  432. summoned=function(name,object,x,y,angle)
  433. if object==0 then
  434. minigame.portal=minigame.portal*-1
  435. tfm.exec.addShamanObject(minigame.portal==1 and 26 or 27,x,y)
  436. end
  437. end
  438. },
  439. --------------------------------------------------
  440. { name="Trivia",
  441. time=30,
  442. shaman=false,
  443. intro="Choices will appear every 5 seconds, <VP>DUCK<J> to choose the current one!",
  444. maps={0},
  445. trivia={
  446. { q="Who created Transformice?",
  447. a={ "Humans",
  448. "Mice",
  449. "Someone",
  450. "Nobody"
  451. }
  452. },
  453. { q="Who made Bafflua?",
  454. a={ "Fxie and her sidekick Shamousey",
  455. "Fxie",
  456. "Shamousey",
  457. "Baffler"
  458. }
  459. },
  460. { q="What is Lua?",
  461. q={ "A language from Brazil",
  462. "The thing Transformice uses for minigames",
  463. "The Earth's moon",
  464. "A good scripting language"
  465. }
  466. },
  467. { q="Would you consider this a question.",
  468. a={ "No",
  469. "Yes",
  470. "There is no question and therefor no answer",
  471. "<no answer>"
  472. }
  473. },
  474. { q="What sound does a mouse make?",
  475. a={ "Squeak",
  476. "Meep",
  477. "*-*",
  478. "Moo"
  479. }
  480. },
  481. { q="Did Baffbot wear an afro?",
  482. a={ "He wore glasses",
  483. "No",
  484. "Yes",
  485. "It depends on your definition of afro"
  486. }
  487. },
  488. { q="Which answer is the correct one?",
  489. a={ "Every answer is both right and wrong",
  490. "This one!",
  491. "This one, the others are false",
  492. "Either A, B, C, or D."
  493. }
  494. },
  495. { q="How long is a week?",
  496. a={ "Weeks do not have a length",
  497. "7 days",
  498. "5 days",
  499. "It depends if it's a work week"
  500. }
  501. },
  502. { q="What color are my socks?",
  503. a={ "What socks?",
  504. "Pink polka-dot",
  505. "Translucent",
  506. "I don't know!"
  507. }
  508. },
  509. { q="Choose your answer.",
  510. a={ "<no answer>",
  511. "No",
  512. "The answer is yes",
  513. "This is the correct answer"
  514. }
  515. },
  516. { q="Is the cup half full or half empty?",
  517. a={ "The cup is entirely empty",
  518. "It's half full",
  519. "It's half empty",
  520. "I'm not playing your mind games"
  521. }
  522. },
  523. { q="If a tree falls in a forest and no one is around to hear it, does it make a sound?",
  524. a={ "It depends",
  525. "No, because someone must exist to decide what is and is not sound",
  526. "Yes, because the mice can hear it",
  527. "Maybe, depending if less self-important animals are around"
  528. }
  529. }
  530. },
  531. prep=function()
  532. local q=table.random(minigame.trivia)
  533. local aTemp={}
  534. minigame.a=q.a[1]
  535. minigame.on=nil
  536. for i=1,#q.a,1 do
  537. table.insert(aTemp,q.a[i])
  538. end
  539. minigame.aList={}
  540. for i=1,#aTemp,1 do
  541. local index=math.random(#aTemp)
  542. table.insert(minigame.aList,aTemp[index])
  543. table.remove(aTemp,index)
  544. end
  545. tfm.exec.chatMessage("<ROSE>[<b>Question</b>] "..q.q)
  546. timer=system.newTimer(function()
  547. minigame.on=minigame.aList[1]
  548. tfm.exec.chatMessage("<J><b>A.</b> "..minigame.on)
  549. timer=system.newTimer(function()
  550. minigame.on=minigame.aList[2]
  551. tfm.exec.chatMessage("<J><b>B.</b> "..minigame.on)
  552. timer=system.newTimer(function()
  553. minigame.on=minigame.aList[3]
  554. tfm.exec.chatMessage("<J><b>C.</b> "..minigame.on)
  555. timer=system.newTimer(function()
  556. minigame.on=minigame.aList[4]
  557. tfm.exec.chatMessage("<J><b>D.</b> "..minigame.on)
  558. end,5000)
  559. end,5000)
  560. end,5000)
  561. end,5000)
  562. end,
  563. keys={
  564. DOWN=function(name,x,y)
  565. if minigame.on==minigame.a then
  566. tfm.exec.chatMessage("<J><b>"..name.."</b> knew the answer!</J>")
  567. tfm.exec.giveWin(name)
  568. for name,player in pairs(tfm.get.room.playerList) do
  569. tfm.exec.killPlayer(name)
  570. end
  571. else
  572. tfm.exec.chatMessage("<R>WRONG!",name)
  573. tfm.exec.killPlayer(name)
  574. end
  575. end
  576. }
  577. },
  578. --------------------------------------------------
  579. { name="Walljump",
  580. time=60,
  581. shaman=false,
  582. intro="Walljump to stay alive!",
  583. maps={"@4025303"},
  584. loop=function(time,remaining)
  585. if time>5000 then
  586. local gravity=(time-5000)/5000
  587. for name,player in pairs(tfm.get.room.playerList) do
  588. tfm.exec.movePlayer(name,0,0,false,0,gravity,true)
  589. end
  590. elseif alive==1 or remaining<=1000 then
  591. tfm.exec.giveWinAll()
  592. end
  593. end,
  594. }
  595. }
  596.  
  597. --Readable keys to playable keys
  598. for i=1,#games,1 do
  599. local mini=games[i]
  600. if mini.keys then
  601. local newKeys={}
  602. for key,fnc in pairs(mini.keys) do
  603. if key=="SPACE" then
  604. newKeys[32]=fnc
  605. elseif key=="UP" then
  606. newKeys[38]=fnc
  607. newKeys[87]=fnc
  608. elseif key=="DOWN" then
  609. newKeys[40]=fnc
  610. newKeys[83]=fnc
  611. elseif key=="LEFT" then
  612. newKeys[37]=fnc
  613. newKeys[64]=fnc
  614. newKeys[81]=fnc
  615. elseif key=="RIGHT" then
  616. newKeys[39]=fnc
  617. newKeys[68]=fnc
  618. end
  619. end
  620. mini.keys=newKeys
  621. end
  622. end
  623.  
  624. --Useful.lua
  625. function table.random(table)
  626. return table[math.random(1,#table)]
  627. end
  628. function table.contains(table,element)
  629. for key,value in pairs(table) do
  630. if value==element then
  631. return true
  632. end
  633. end
  634. return false
  635. end
  636.  
  637. --Useful.tfm
  638. function tfm.exec.giveWin(name)
  639. tfm.exec.giveCheese(name)
  640. tfm.exec.playerVictory(name)
  641. end
  642. function tfm.exec.giveWinAll()
  643. for name,player in pairs(tfm.get.room.playerList) do
  644. if not player.isDead then
  645. tfm.exec.giveWin(name)
  646. end
  647. end
  648. end
  649. function tfm.exec.getShaman()
  650. for name,player in pairs(tfm.get.room.playerList) do
  651. if player.isShaman then
  652. return name
  653. end
  654. end
  655. end
  656. function getPlayer(name)
  657. return tfm.get.room.playerList[name]
  658. end
  659. function getAlivePlayers()
  660. local alivePlayers={}
  661. for name,player in pairs(tfm.get.room.playerList) do
  662. if not player.isDead then
  663. table.insert(alivePlayers,name)
  664. end
  665. end
  666. return alivePlayers
  667. end
  668. function makeTeams(fncRed,fncBlue)
  669. local players={}
  670. local teams={
  671. red={},
  672. blue={}
  673. }
  674. for name,player in pairs(tfm.get.room.playerList) do
  675. table.insert(players,name)
  676. end
  677. for i=1,#players,1 do
  678. local index=math.random(#players)
  679. local player=players[index]
  680. if i%2==0 then
  681. if fncRed then fncRed() end
  682. table.insert(teams.red,player)
  683. else
  684. if fncBlue then fncBlue() end
  685. table.insert(teams.blue,player)
  686. end
  687. table.remove(players,index)
  688. end
  689. return teams
  690. end
  691.  
  692. --Collision detection (circles)
  693. function pythag(x1,y1,r1,x2,y2,r2)
  694. local x=x2-x1
  695. local y=y2-y1
  696. local r=r2+r1
  697. return x*x+y*y<r*r
  698. end
  699.  
  700. --Marblecake AKA The Game
  701. lastmode=-1
  702. function switchGame(mode,map)
  703. if timer then
  704. system.removeTimer(timer)
  705. timer=nil
  706. end
  707. setAllKeys(false)
  708. while not mode do
  709. mode=math.random(#games)
  710. if mode==lastmode then mode=nil end
  711. end
  712. lastmode=mode
  713. minigame=games[mode]
  714. if minigame.delay then
  715. minigame.ready=false
  716. else
  717. setAllKeys(true)
  718. end
  719. minigame.won=false
  720. tfm.exec.disableAutoShaman(not minigame.shaman)
  721. minigame.mapIndex=math.random(#minigame.maps)
  722. minigame.mapCode=map or minigame.maps[minigame.mapIndex]
  723. tfm.exec.newGame(minigame.mapCode)
  724. end
  725.  
  726. --New game initialisation
  727. function eventNewGame()
  728. tfm.exec.setGameTime(minigame.time)
  729. tfm.exec.chatMessage("<J>"..minigame.intro)
  730. alive=0
  731. for name,player in pairs(tfm.get.room.playerList) do
  732. alive=alive+1
  733. if not player.isShaman then
  734. tfm.exec.setNameColor(name,0)
  735. end
  736. end
  737. if minigame.prep then minigame.prep() end
  738. end
  739.  
  740. --Events
  741. function eventLoop(time,remaining)
  742. if minigame.delay and not minigame.ready and time>minigame.delay*1000 then
  743. minigame.ready=true
  744. setAllKeys(true)
  745. elseif not minigame.won and minigame.loop and (not minigame.delay or minigame.ready) then
  746. minigame.loop(time,remaining)
  747. end
  748. if remaining<=0 or alive==0 then
  749. switchGame()
  750. end
  751. end
  752. --Keyboard functions
  753. function setAllKeys(active)
  754. if minigame and minigame.keys then
  755. for key,fnc in pairs(minigame.keys) do
  756. for name,player in pairs(tfm.get.room.playerList) do
  757. tfm.exec.bindKeyboard(name,key,true,active)
  758. end
  759. end
  760. end
  761. end
  762.  
  763. function eventKeyboard(name,key,down,x,y)
  764. if not getPlayer(name).isDead and minigame.keys then
  765. for code,fnc in pairs(minigame.keys) do
  766. if key==code then
  767. fnc(name,x,y)
  768. end
  769. end
  770. end
  771. end
  772.  
  773. --Emotional
  774. function eventEmotePlayed(name,emote)
  775. if minigame.emote then
  776. minigame.emote(name,emote)
  777. end
  778. end
  779.  
  780. --Summoning functions
  781. function eventSummoningStart(name,object,x,y,angle)
  782. if minigame.summon then
  783. minigame.summon(name,object,x,y,angle)
  784. end
  785. end
  786. function eventSummoningEnd(name,object,x,y,angle)
  787. if minigame.summoned then
  788. minigame.summoned(name,object,x,y,angle)
  789. end
  790. end
  791.  
  792. function eventPlayerDied(name)
  793. alive=alive-1
  794. end
  795.  
  796. function eventPlayerWon(name)
  797. alive=alive-1
  798. end
  799.  
  800. --Chat commands
  801. system.disableChatCommandDisplay("help")
  802. system.disableChatCommandDisplay("games")
  803. system.disableChatCommandDisplay("skip")
  804. system.disableChatCommandDisplay("cheese")
  805. system.disableChatCommandDisplay("kill")
  806. system.disableChatCommandDisplay("play")
  807. function eventChatCommand(name,message)
  808. local split=string.find(message," ") or #message+1
  809. local cmd=string.sub(message,1,split-1)
  810. local args=string.sub(message,split+1)
  811. if cmd=="help" then
  812. tfm.exec.chatMessage("U NEED SUM HELP?!",name)
  813. elseif cmd=="games" then
  814. local list="<J>Current minigames: "
  815. for i=1,#games,1 do
  816. list=list.."<b>"..games[i].name.."</b>, "
  817. end
  818. tfm.exec.chatMessage(list.."and who knows what else!",name)
  819. elseif table.contains(admins,name) then
  820. if cmd=="skip" or cmd=="next" then
  821. switchGame()
  822. elseif cmd=="cheese" then
  823. tfm.exec.giveCheese(name)
  824. elseif cmd=="kill" then
  825. tfm.exec.killPlayer(args)
  826. elseif cmd=="play" then
  827. for i=1,#games,1 do
  828. if games[i].name==args then
  829. tfm.exec.setPlayerScore(name,100,true)
  830. switchGame(i)
  831. break
  832. end
  833. end
  834. end
  835. end
  836. end
  837.  
  838. --Geral á minha humilde morada
  839. function eventNewPlayer(name)
  840. tfm.exec.chatMessage("<ROSE><b>"..table.random(greets).."</b>",name)
  841. end
  842.  
  843. --Bafflua é online!
  844. for name,player in pairs(tfm.get.room.playerList) do
  845. eventNewPlayer(name)
  846. end
  847. switchGame()
Advertisement
Add Comment
Please, Sign In to add comment