Advertisement
extremq

Untitled

Dec 11th, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.50 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 = 80
  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. local maplength = n * 200 + 400
  56. local gap = 160
  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. xml = xml .. s
  70. local oTag = ''
  71.  
  72. for i = 0,n-1,1 do
  73. -- Pick a random number
  74. r = math.random(100)
  75.  
  76. -- X value of this ground
  77. X = 300 + (i * 200)
  78.  
  79. -- Upper ground:
  80. -- Height
  81. H1 = r + 100
  82. Y1 = H1 / 2
  83.  
  84. -- Lower ground:
  85. H2 = 400 - (H1+100)
  86. Y2 = H1 + gap + H2/2
  87.  
  88. -- hmm, nudge up
  89. Y1 = Y1 - 20
  90. Y2 = Y2 - 20
  91.  
  92. -- nudge height to make it easier towards the start
  93. H1 = H1 - (n-i)
  94. H2 = H2 - (n-i)
  95.  
  96. local bonus = string.format('<O C="6" X="%d" Y="%d" P="0" />',X,Y1 + H1/2 + (Y2 - H2/2 - Y1 - H1/2)/2)
  97. oTag = oTag .. bonus
  98.  
  99. -- Generate angle, and add upper ground (NOT NEEDED ANYMORE)
  100. a = 180
  101.  
  102. --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)
  103. --xml = xml .. s
  104. fg = fg..string.format('x_transformice/x_maps/x_halloween2015/ronces'..math.random(1,2)..'.png,%d,%d;',X-25, Y1 + H1/2 - 407)
  105.  
  106. -- add acid underneath
  107. 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)
  108. xml = xml .. s
  109.  
  110. -- Generate angle, and add lower ground
  111. a = 0
  112.  
  113. -- Last ground, rest and angle 0
  114. --if i==n-1 then
  115. -- rst = 0
  116. -- a = 0
  117. -- T = 6
  118. -- fr = 0.3
  119. -- end
  120.  
  121.  
  122. fg = fg..string.format('x_transformice/x_maps/x_halloween2015/ronces'..math.random(1,2)..'.png,%d,%d;',X-25, Y2 - H2/2)
  123. -- 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)
  124. -- xml = xml .. s
  125. -- add acid underneath
  126. 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)
  127. xml = xml .. s
  128.  
  129.  
  130. L = L + 1.5
  131.  
  132. -- textarea width
  133. local taw = 12;
  134. if i+1>=10 then
  135. taw = 20
  136. end
  137.  
  138. gap = gap - 1
  139. if gap < 120 then gap = 120 end
  140. --ui.addTextArea(100+i, tostring(i+1), nil, X-taw/2, 26, taw, 16, 0x010101, 0xffffff, 0.5, false)
  141.  
  142. -- table.insert(R,r)
  143. end
  144. fg = fg..'" '
  145. xml = string.gsub(xml,'replaceMe',fg)
  146. xml = xml .. '</S><D>'
  147.  
  148. -- mouse spawn
  149. xml = xml .. '<DS X="50" Y="300" />'
  150.  
  151. -- holes and cheeses
  152. for i = 0,19,1 do
  153. xml = xml .. string.format('<T X="%d" Y="%d" />', maplength-100, 30 + i*20)
  154. end
  155. for i = 0,18,1 do
  156. xml = xml .. string.format('<F X="%d" Y="%d" />', maplength-100, 20 + i*21)
  157. end
  158.  
  159. xml = xml .. '</D><O>'..oTag
  160.  
  161. -- for i = 0,n-1,1 do
  162. -- X = 300 + (i * 200)
  163. -- Y =
  164.  
  165. -- xml = xml .. s
  166. -- end
  167.  
  168. xml = xml .. '</O></Z></C>'
  169.  
  170. return xml
  171. end
  172. -- Finished counts
  173. FINISHED = {}
  174. MOVED = {}
  175. BONUSES = {}
  176.  
  177. SEED = math.random(100000)
  178. math.randomseed(SEED)
  179.  
  180. function Bind(p)
  181. tfm.exec.bindKeyboard(p,32, true,true)
  182. tfm.exec.bindKeyboard(p,37, true,true)
  183. tfm.exec.bindKeyboard(p,38, true,true)
  184. tfm.exec.bindKeyboard(p,39, true,true)
  185. tfm.exec.bindKeyboard(p,40, true,true)
  186. tfm.exec.bindKeyboard(p,1, true,true)
  187. tfm.exec.bindKeyboard(p,string.byte('A',1),true,true)
  188. tfm.exec.bindKeyboard(p,string.byte('S',1),true,true)
  189. tfm.exec.bindKeyboard(p,string.byte('D',1),true,true)
  190. tfm.exec.bindKeyboard(p,string.byte('Q',1),true,true)
  191. tfm.exec.bindKeyboard(p,string.byte('Z',1),true,true)
  192. system.bindMouse(p,true)
  193. end
  194.  
  195. function SetPlayerSpeedX(p)
  196. tfm.exec.movePlayer(p,0,0,true,45,0,false)
  197. end
  198.  
  199. function Reset(p)
  200. Bind(p)
  201. tfm.exec.setPlayerScore(p,FINISHED[p] * 50 + BONUSES[p])
  202. end
  203.  
  204.  
  205. function eventNewGame()
  206. local topPlayers = {}
  207. for p,_ in pairs(tfm.get.room.playerList) do
  208. topPlayers[#topPlayers + 1] = {p, FINISHED[p] * 50 + BONUSES[p]}
  209. Reset(p)
  210. tfm.exec.freezePlayer(p)
  211. FINISHED[p] = 0
  212. BONUSES[p] = 0
  213. tfm.exec.setPlayerScore(p, 0, false)
  214. end
  215.  
  216. table.sort(topPlayers, function(a, b)
  217. return a[2] > b[2]
  218. end)
  219.  
  220. if topPlayers[1][2] ~= 0 then
  221. tfm.exec.chatMessage('<i><R>Congratulations, winners!</r></i>')
  222. local colorTags = {"font color='#ffd700'", "font color='#c0c0c0'", "font color='#cd7f32'"}
  223. for i = 1, 3 do
  224. if topPlayers[i] then
  225. if topPlayers[i][2] ~= 0 then
  226. tfm.exec.chatMessage('<'..colorTags[i]..'>'..i..'. '..topPlayers[i][1]..' - '..topPlayers[i][2]..'</'..colorTags[i]..'>')
  227. 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])
  228. end
  229. end
  230. end
  231. end
  232.  
  233. tfm.exec.setGameTime(5 * 60,true)
  234. tfm.exec.setUIMapName('<R>Flappymouse: #' .. tostring(SEED))
  235. end
  236.  
  237. function fly(p,x,y)
  238. tfm.exec.movePlayer(p,0,0,true,0,-100,false)
  239. end
  240.  
  241. function eventMouse(p,x,y)
  242. fly(p,nil,nil)
  243. SetPlayerSpeedX(p)
  244. end
  245.  
  246.  
  247. local frozenEveryone = false
  248. function eventKeyboard(p,k,d,x,y)
  249. if frozenEveryone == false then
  250. for p, _ in pairs(tfm.get.room.playerList) do
  251. tfm.exec.freezePlayer(p)
  252. end
  253. frozenEveryone = true
  254. end
  255. if not tfm.get.room.playerList[p].isDead then
  256. if k==32 or k == 1 then
  257. fly(p,x,y)
  258. SetPlayerSpeedX(p)
  259. else
  260. if x < 300 then
  261. tfm.exec.chatMessage("<J>You can only press <VP>SPACE, CLICK or UP</vp><J>!",p)
  262. end
  263. end
  264. MOVED[p] = true;
  265. end
  266. end
  267.  
  268. function eventLoop(t,r)
  269. if r < 3 then
  270. SEED = math.random(100000)
  271. tfm.exec.newGame(GenerateXML())
  272. end
  273. for p,P in pairs(tfm.get.room.playerList) do
  274. if P.isDead==false then
  275. if MOVED[p] == true then
  276. SetPlayerSpeedX(p)
  277. end
  278. if P.y<0 then
  279. tfm.exec.killPlayer(p)
  280. end
  281. tfm.exec.respawnPlayer(p)
  282. end
  283. end
  284. end
  285.  
  286. function eventPlayerDied(p)
  287. tfm.exec.respawnPlayer(p)
  288. MOVED[p] = false
  289. end
  290.  
  291. function eventPlayerWon(p)
  292. if not FINISHED[p] then FINISHED[p] = 1 else FINISHED[p] = FINISHED[p] + 1 end
  293. tfm.exec.chatMessage('<J>' .. p .. '<VP> finished the map!')
  294. tfm.exec.respawnPlayer(p)
  295. Reset(p)
  296. end
  297.  
  298. system.disableChatCommandDisplay(nil, true)
  299. function eventNewPlayer(p)
  300. tfm.exec.setUIMapName('<R>Flappymouse: #' .. tostring(SEED))
  301. tfm.exec.chatMessage('<J>Welcome to <VP>Flappymouse - Christmas edition<J>! Write !help for instructions. Made by Sharpiepoops#0020, edited by Extremq#0000.', p)
  302. tfm.exec.chatMessage("<J>Fly using <VP>SPACE, CLICK or UP</VP>.", p)
  303. tfm.exec.respawnPlayer(p)
  304. tfm.exec.freezePlayer(p)
  305. FINISHED[p] = 0
  306. BONUSES[p] = 0
  307. Reset(p)
  308. end
  309.  
  310. function eventPlayerRespawn(player)
  311. tfm.exec.freezePlayer(player)
  312. end
  313.  
  314. function eventChatCommand(p,s)
  315. local a = split(s,' ')
  316. local cmd = 'command_' .. string.lower(a[1])
  317. if _G[cmd] then
  318. _G[cmd](p,a)
  319. end
  320. end
  321.  
  322. function command_help(p,a)
  323. tfm.exec.chatMessage("<J>Type <VP>/watch YOUR NAME<J> if it's difficult to see your mouse!", p)
  324. end
  325.  
  326. for p, _ in pairs(tfm.get.room.playerList) do
  327. eventNewPlayer(p)
  328. end
  329.  
  330. function eventPlayerBonusGrabbed(p, bonusId)
  331. BONUSES[p] = BONUSES[p] + 1
  332. tfm.exec.setPlayerScore(p, FINISHED[p] * 50 + BONUSES[p])
  333. end
  334.  
  335. tfm.exec.disableAutoTimeLeft(true)
  336. tfm.exec.disableAutoNewGame(true)
  337. tfm.exec.disableAutoShaman(true)
  338. tfm.exec.disableAutoScore(true)
  339. tfm.exec.disableAfkDeath(true)
  340. tfm.exec.setRoomMaxPlayers(60)
  341. tfm.exec.newGame(GenerateXML())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement