Advertisement
extremq

Untitled

Dec 23rd, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.00 KB | None | 0 0
  1. -- GOOD MAPS
  2.  
  3. -- #45732
  4. -- #73686
  5. -- #82767
  6. -- #37517
  7. -- #92978
  8. -- #67264
  9. -- #18358
  10. -- #48141
  11. -- #88658
  12. -- #30375
  13. -- #1948
  14. -- #39730
  15. -- #63367
  16. -- #76795
  17. -- #30632 (EDIZ 10)
  18. -- #33281 (EDIZ 10)
  19.  
  20. -- HMM MAPS
  21. -- #43425
  22.  
  23. -- SMALLER GROUNDS: (TEST BIG?)
  24. -- #46494 (10+ me + mak)
  25. -- #78962 (10+ me + mak)
  26. -- #74219 (10+ me + mak)
  27. -- #63839
  28. -- #21317
  29. -- #888
  30. -- #48740
  31. -- #69716 (10)
  32. -- #17908 (10+)
  33.  
  34.  
  35. function split(s,t) local r={}; for p in string.gmatch(s,"[^"..t.."]+") do table.insert(r,p); end;return r;end
  36.  
  37.  
  38. GROUNDS = 140
  39.  
  40. function GenerateXML()
  41.  
  42.  
  43. local n = GROUNDS
  44. local xml = ""
  45. local r = 0
  46. local L = 40;
  47. local X, Y, Y1, Y2, H1, H2;
  48. local s
  49. local TT = { 11}
  50. local T = TT[math.random(table.getn(TT))]
  51. local R = {}
  52. local a
  53. local rst = 0
  54. local fr = 0
  55. maplength = n * 200 + 400
  56. local gap = 180
  57.  
  58. tfm.exec.chatMessage("<R>#" .. tostring(SEED) .. " ground:" .. tostring(T),"sharpiepoops")
  59.  
  60. -- start xml, random bg, with spawn ground,
  61. -- local bg = 'D="'
  62. -- local fg = 'd="'
  63. -- for i = 0, maplength, 800 do
  64. -- bg = bg..string.format('x_transformice/x_maps/x_halloween2015/jardin-citrouilles.jpg,%d,%d;', i, 0)
  65. -- fg = fg..string.format('x_transformice/x_maps/x_halloween2015/jardin-citrouilles-fg.png,%d,%d;',i, 293)
  66. -- end
  67. -- bg = bg .. '"'
  68. -- s = string.format('<C><P replaceMe '..bg..' G="0, 30" Ca="" L="%d" defilante="0,0,0,1" /><Z><S><S X="40" Y="350" H="100" L="80" T="%d" P="0,0,9999,0,0,0,0,0" />', maplength, T)
  69. s = string.format('<C><P replaceMe G="0, 30" Ca="" L="%d" defilante="0,0,0,1" /><Z><S><S X="40" Y="350" H="100" L="80" T="%d" P="0,0,9999,0,0,0,0,0" />', maplength, T)
  70. xml = xml .. s
  71. local oTag = ''
  72.  
  73. bonuses = {}
  74. fg1 = {}
  75. fg2 = {}
  76. for i = 0,n-1,1 do
  77. -- Pick a random number
  78. r = math.random(-100, 100)
  79.  
  80. -- X value of this ground
  81. X = 300 + (i * 150)
  82.  
  83. -- Upper ground:
  84. -- Height
  85. H1 = r + 100
  86. Y1 = H1 / 2
  87.  
  88. -- Lower ground:
  89. H2 = 400 - (H1+100)
  90. print(gap)
  91. Y2 = H1 + gap + H2/2
  92.  
  93. -- hmm, nudge up
  94. Y1 = Y1 - 20
  95. Y2 = Y2 - 20
  96.  
  97. -- nudge height to make it easier towards the start
  98. -- H1 = H1 - (n-i)
  99. -- H2 = H2 - (n-i)
  100.  
  101. bonuses[#bonuses + 1] = {X, Y1 + H1/2 + (Y2 - H2/2 - Y1 - H1/2)/2}
  102. fg1[#fg1 + 1] = {X-25, Y1 + H1/2 - 407}
  103. fg2[#fg2 + 1] = {X-25, Y2 - H2/2}
  104. --local bonus = string.format('<O C="6" X="%d" Y="%d" P="0" />',X,Y1 + H1/2 + (Y2 - H2/2 - Y1 - H1/2)/2)
  105. --oTag = oTag .. bonus
  106.  
  107. -- Generate angle, and add upper ground (NOT NEEDED ANYMORE)
  108. a = 180
  109.  
  110. --s = string.format('<S T="%d" P="0,0,%d,%d,%d,0,0,0" X="%d" Y="%d" L="%d" H="%d" c="2"/>',T,fr,rst,a,X,Y1,math.floor(L/40)*40,H1)
  111. --xml = xml .. s
  112. --fg = fg..string.format('x_transformice/x_maps/x_halloween2015/ronces'..math.random(1,2)..'.png,%d,%d;',X-25, Y1 + H1/2 - 407)
  113.  
  114. -- add acid underneath
  115. s = string.format('<S T="%d" P="0,0,%d,%d,%d,0,0,0" X="%d" Y="%d" L="%d" H="%d" m=""/>',19,fr,rst,a,X,Y1,50,H1)
  116. xml = xml .. s
  117.  
  118. -- Generate angle, and add lower ground
  119. a = 0
  120.  
  121. -- Last ground, rest and angle 0
  122. --if i==n-1 then
  123. -- rst = 0
  124. -- a = 0
  125. -- T = 6
  126. -- fr = 0.3
  127. -- end
  128.  
  129.  
  130. --fg = fg..string.format('x_transformice/x_maps/x_halloween2015/ronces'..math.random(1,2)..'.png,%d,%d;',X-25, Y2 - H2/2)
  131. -- s = string.format('<S T="%d" P="0,0,%d,%d,%d,0,0,0" X="%d" Y="%d" L="%d" H="%d" c="2"/>',T,fr,rst,a,X,Y2,math.floor(L/40)*40,H2)
  132. -- xml = xml .. s
  133. -- add acid underneath
  134. s = string.format('<S T="%d" P="0,0,%d,%d,%d,0,0,0" X="%d" Y="%d" L="%d" H="%d" m=""/>',19,fr,rst,a,X,Y2,50,H2)
  135. xml = xml .. s
  136.  
  137.  
  138. L = L + 1.5
  139.  
  140. -- textarea width
  141. local taw = 12;
  142. if i+1>=10 then
  143. taw = 20
  144. end
  145.  
  146. gap = gap - 1
  147. if gap < 140 then gap = 140 end
  148. --ui.addTextArea(100+i, tostring(i+1), nil, X-taw/2, 26, taw, 16, 0x010101, 0xffffff, 0.5, false)
  149.  
  150. -- table.insert(R,r)
  151. end
  152. --fg = fg..'" '
  153. xml = string.gsub(xml,'replaceMe','')
  154. xml = xml .. '</S><D>'
  155.  
  156. -- mouse spawn
  157. xml = xml .. '<DS X="50" Y="300" />'
  158.  
  159. -- holes and cheeses
  160. for i = 0,19,1 do
  161. xml = xml .. string.format('<T X="%d" Y="%d" />', maplength-100, 30 + i*20)
  162. end
  163. for i = 0,18,1 do
  164. xml = xml .. string.format('<F X="%d" Y="%d" />', maplength-100, 20 + i*21)
  165. end
  166.  
  167. xml = xml .. '</D><O>'..oTag
  168.  
  169. -- for i = 0,n-1,1 do
  170. -- X = 300 + (i * 200)
  171. -- Y =
  172.  
  173. -- xml = xml .. s
  174. -- end
  175.  
  176. xml = xml .. '</O></Z></C>'
  177.  
  178. return xml
  179. end
  180. SCORE = {}
  181. MOVED = {}
  182.  
  183. SEED = math.random(100000)
  184. math.randomseed(SEED)
  185.  
  186. function Bind(p)
  187. tfm.exec.bindKeyboard(p,32, true,true)
  188. tfm.exec.bindKeyboard(p,37, true,true)
  189. tfm.exec.bindKeyboard(p,38, true,true)
  190. tfm.exec.bindKeyboard(p,39, true,true)
  191. tfm.exec.bindKeyboard(p,40, true,true)
  192. tfm.exec.bindKeyboard(p,1, true,true)
  193. tfm.exec.bindKeyboard(p,string.byte('A',1),true,true)
  194. tfm.exec.bindKeyboard(p,string.byte('S',1),true,true)
  195. tfm.exec.bindKeyboard(p,string.byte('D',1),true,true)
  196. tfm.exec.bindKeyboard(p,string.byte('Q',1),true,true)
  197. tfm.exec.bindKeyboard(p,string.byte('Z',1),true,true)
  198. system.bindMouse(p,true)
  199. end
  200.  
  201. function SetPlayerSpeedX(p)
  202. tfm.exec.movePlayer(p,0,0,true,45,0,false)
  203. end
  204.  
  205. function Reset(p)
  206. Bind(p)
  207. tfm.exec.setPlayerScore(p,SCORE[p])
  208. end
  209.  
  210. died = {}
  211. initted = {}
  212. function eventNewGame()
  213. local topPlayers = {}
  214. for p,_ in pairs(SCORE) do
  215. topPlayers[#topPlayers + 1] = {p, SCORE[p]}
  216. SCORE[p] = 0
  217. died[p] = nil
  218. tfm.exec.setPlayerScore(p, 0, false)
  219. if not initted[p] then
  220. init(p)
  221. end
  222. end
  223.  
  224. table.sort(topPlayers, function(a, b)
  225. return a[2] > b[2]
  226. end)
  227.  
  228. if topPlayers[1][2] ~= 0 then
  229. tfm.exec.chatMessage('<i><R>Congratulations, winners!</r></i>')
  230. local colorTags = {"font color='#ffd700'", "font color='#c0c0c0'", "font color='#cd7f32'", "font color='#cd7f32'", "font color='#cd7f32'", "font color='#cd7f32'"}
  231. for i = 1, 6 do
  232. if topPlayers[i] then
  233. if topPlayers[i][2] ~= 0 then
  234. tfm.exec.chatMessage('<'..colorTags[i]..'>'..i..'. '..topPlayers[i][1]..' - '..topPlayers[i][2]..'</'..colorTags[i]..'>')
  235. tfm.exec.chatMessage("Ho ho ho! Congratulations, you've won the event map!\nMake sure you'll check your inbox the next few weeks for the cheese codes.\nWe wish you a merry Christmas and a Happy New Year!", topPlayers[i][1])
  236. end
  237. end
  238. end
  239. end
  240.  
  241. tfm.exec.setGameTime(30 * 60,true)
  242. tfm.exec.setUIMapName('<R>Flappymouse: #' .. tostring(SEED))
  243. end
  244.  
  245.  
  246.  
  247. function fly(p,x,y)
  248. tfm.exec.movePlayer(p,0,0,true,0,-100,false)
  249. end
  250.  
  251. function eventMouse(p,x,y)
  252. fly(p,nil,nil)
  253. SetPlayerSpeedX(p)
  254. end
  255.  
  256.  
  257. local frozenEveryone = false
  258. function eventKeyboard(p,k,d,x,y)
  259. if frozenEveryone == false then
  260. for p, _ in pairs(tfm.get.room.playerList) do
  261. tfm.exec.freezePlayer(p)
  262. end
  263. frozenEveryone = true
  264. end
  265. if not tfm.get.room.playerList[p].isDead then
  266. if k==32 or k == 1 then
  267. fly(p,x,y)
  268. SetPlayerSpeedX(p)
  269. end
  270. MOVED[p] = true;
  271. end
  272. end
  273.  
  274. function eventLoop(t,r)
  275. if r < 3 then
  276. SEED = math.random(100000)
  277. tfm.exec.newGame(GenerateXML())
  278. initted = {}
  279. end
  280.  
  281. end
  282. for p,P in pairs(tfm.get.room.playerList) do
  283. if P.isDead==false then
  284. if MOVED[p] == true then
  285. SetPlayerSpeedX(p)
  286. end
  287. if P.y<0 then
  288. tfm.exec.killPlayer(p)
  289. end
  290. tfm.exec.respawnPlayer(p)
  291. end
  292. end
  293. end
  294.  
  295. function eventPlayerDied(p)
  296. tfm.exec.respawnPlayer(p)
  297. MOVED[p] = false
  298. end
  299.  
  300. function eventPlayerWon(p)
  301. if not SCORE[p] then SCORE[p] = 50 else SCORE[p] = SCORE[p] + 500 end
  302. tfm.exec.chatMessage('<J>' .. p .. '<VP> finished the map!')
  303. tfm.exec.respawnPlayer(p)
  304. Reset(p)
  305. end
  306.  
  307.  
  308. tfm.exec.disableAutoTimeLeft(true)
  309. tfm.exec.disableAutoNewGame(true)
  310. tfm.exec.disableAutoShaman(true)
  311. tfm.exec.disableAutoScore(true)
  312. tfm.exec.disableAfkDeath(true)
  313. tfm.exec.setRoomMaxPlayers(60)
  314. tfm.exec.newGame(GenerateXML())
  315.  
  316. function setupBonuses(player)
  317. for i = 1, #bonuses do
  318. tfm.exec.addBonus(0, bonuses[i][1], bonuses[i][2], i, 0, false, player)
  319. end
  320. end
  321.  
  322. imgBns = {}
  323. function setupImg(p)
  324. if not imgBns[p] then imgBns[p] = {} end
  325. for i = 1, #bonuses do
  326. tfm.exec.removeImage(imgBns[p][i])
  327. imgBns[p][i] = tfm.exec.addImage("1768226c79e.png", '!100', bonuses[i][1] - 10, bonuses[i][2] - 12, p)
  328. end
  329. end
  330.  
  331. local imgs = {"17690e050cf.png", "17690e07927.png"}
  332.  
  333. function init(p)
  334. initted[p] = true
  335. tfm.exec.freezePlayer(p)
  336. setupBonuses(p)
  337. setupImg(p)
  338. for i = 0, maplength, 800 do
  339. tfm.exec.addImage("1768ecb306f.png", "?1", i, 0, p)
  340. end
  341. for i = 1, #fg1 do
  342. tfm.exec.addImage(imgs[math.random(#imgs)], '!100', fg1[i][1], fg1[i][2], p)
  343. tfm.exec.addImage(imgs[math.random(#imgs)], '!100', fg2[i][1], fg2[i][2], p)
  344. end
  345. imgP[p] = tfm.exec.addImage("176820cd5b9.png", "%"..p, -30, -50)
  346. Reset(p)
  347. end
  348.  
  349. firstTime = {}
  350. system.disableChatCommandDisplay(nil, true)
  351. function eventNewPlayer(p)
  352. tfm.exec.setUIMapName('<R>Flappymouse: #' .. tostring(SEED))
  353. tfm.exec.chatMessage('<J>Welcome to <VP>Flappymouse - Christmas edition<J>! Write !help for instructions. Made by Sharpiepoops#0020, edited by Extremq#0000.', p)
  354. tfm.exec.chatMessage("<J>Fly using <VP>SPACE, CLICK or UP</VP>.", p)
  355. if not firstTime[p] then
  356. SCORE[p] = 0
  357. firstTime[p] = 1
  358. end
  359. if not initted[p] then
  360. init(p)
  361. end
  362. tfm.exec.respawnPlayer(p)
  363. Reset(p)
  364. end
  365.  
  366. imgP = {}
  367. function eventPlayerRespawn(player)
  368. tfm.exec.freezePlayer(player)
  369. tfm.exec.removeImage(imgP[player])
  370. imgP[player] = tfm.exec.addImage("176820cd5b9.png", "%"..player, -30, -50)
  371. setupImg(player)
  372. end
  373.  
  374. function eventPlayerLeft(player)
  375. initted[player] = nil
  376. end
  377.  
  378. function eventChatCommand(p,s)
  379. local a = split(s,' ')
  380. local cmd = 'command_' .. string.lower(a[1])
  381. if _G[cmd] then
  382. _G[cmd](p,a)
  383. end
  384. end
  385.  
  386. function command_help(p,a)
  387. tfm.exec.chatMessage("<J>Type <VP>/watch YOUR NAME<J> if it's difficult to see your mouse!", p)
  388. end
  389.  
  390. for p, _ in pairs(tfm.get.room.playerList) do
  391. eventNewPlayer(p)
  392. end
  393.  
  394. function eventPlayerBonusGrabbed(p, bonusId)
  395. SCORE[p] = SCORE[p] + 1
  396. tfm.exec.setPlayerScore(p, SCORE[p])
  397. tfm.exec.removeImage(imgBns[p][bonusId])
  398. end
  399.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement