Advertisement
Dudugz-Contistente

Untitled

Feb 27th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.95 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame()
  2. tfm.exec.disableAutoShaman()
  3.  
  4. start=os.time()
  5. _Vento = math.random(1,4)
  6. vento = os.time();
  7.  
  8. vivos=0
  9.  
  10. function sendNewMap()
  11. takeMul = function(x)
  12. return x-(x%5)
  13. end
  14.  
  15.  
  16. math.randomseed = 9
  17.  
  18. xml = {}
  19.  
  20. flipmode = math.random(0,2)
  21.  
  22. if flipmode == 1 then
  23. tfm.exec.setAutoMapFlipMode(false)
  24. else
  25. tfm.exec.setAutoMapFlipMode()
  26. end
  27.  
  28. xml.standard = "<C><P Ca='' H='3000' F=\""..(math.random(0,8)%6).."\" /><Z><S>%s</S><D>%s</D><O /></Z></C>"
  29.  
  30. xml.grounds,xml.decorations = {},{}
  31.  
  32. xml.S,xml.SET,xml.D = '<S c="1" L="%d" H="%d" X="%d" Y="%d" T="%d" P="0,0,%f,%f,%d,0,0,0" o="%d" />','<%s X="%d" Y="%d" />','<P P="0,0" X="%d" Y="%d" T="%d" />'
  33.  
  34. grounds = {{0,1,4},{10,1},{12,13},{1,2},{4,1},{1,10},{10,9,2}}
  35. groundProperties = {{.3,.2},{0,.2},{0,1.2},{0,20},{20,.2},{.3,.2},{.3,.2},{.1,.2},{.3,.2},{0,0},{.3,0},{.05,.1},{.3,.2},{.3,.2},{.3,.2},{0,0}}
  36. decorations = {{0,4,5},{},{},{},{1,42,51},{1,2,4,12,18,20,32,42,46},{0,1,2,3,4,5,11,42},{7,8,9,10},{},{},{42,103,118},{51,106},{},{},{},{}}
  37.  
  38. currentX,currentY = 0,0
  39. mapGrounds = grounds[math.random(#grounds)]
  40. for i = 1,250 do
  41. local ground = mapGrounds[i==1 and i or math.random(#mapGrounds)]
  42. local L = takeMul(ground~=13 and math.random(40,120) or math.random(20,40))
  43. local H = takeMul(math.random(20,35))
  44. if ground == 9 and math.random(10) < 6 then
  45. L,H = H,L
  46. end
  47. local X,Y
  48. repeat
  49. X = takeMul(math.random(0,860) - L - (currentX/8))
  50. Y = takeMul(math.random(100,2500) + (currentY/4))
  51. until X > 0 and X < 800 and Y > 0 and Y < 3001
  52. currentX,currentY = X - X^.5,Y + Y^.5
  53. table.insert(xml.grounds,xml.S:format(L,H,X,Y,ground,groundProperties[ground+1][1],groundProperties[ground+1][2],i==1 and math.random(-10,10) or math.random(0,360),math.random(0,0xFFFFFF)))
  54. if math.random(22) < 3 then
  55. local dec = decorations[ground+1]
  56. table.insert(xml.decorations,xml.D:format(X - math.random(-((L/4)+1),((L/4)+1)),Y - (H/2),#dec>0 and dec[math.random(#dec)] or -1))
  57. end
  58. if i == 1 then
  59. for k,v in next,{"DS","T"} do
  60. table.insert(xml.decorations,xml.SET:format(v,400,2900 - (H/2)))
  61. end
  62. end
  63. end
  64.  
  65. tfm.exec.newGame(xml.standard:format(table.concat(xml.grounds),table.concat(xml.decorations)))
  66. tfm.exec.addPhysicObject(0, 400, 2950, {type=14,width=100,miceCollision=true,friction=0.3,restitution=0.2})
  67. end
  68.  
  69. data={}
  70.  
  71. function eventChatMessage(name,cmd)
  72. if cmd == "!help" or cmd == "!ajuda" then
  73. tfm.exec.chatMessage("<VP>●</VP> <CE>O objetivo do jogo é subir até o topo do mapa para vencer, mas para facilitar um pouco apertando <B>Espaço</B> você da um pulo duplo de acordo com a força indicada na mini-interface abaixo á esquerda, legenda:",name)
  74. tfm.exec.chatMessage("<font color='#00BFFF'>▲</font> - Força de pulo: Fraca ",name)
  75. tfm.exec.chatMessage("<font color='#FFCC00'>▲</font> - Força de pulo: Média ",name)
  76. tfm.exec.chatMessage("<font color='#00FF00'>▲</font> - Força de pulo: Forte ",name)
  77. tfm.exec.chatMessage("<font color='#FF0000'>▲</font> - Força de pulo: Muito Forte ",name)
  78. tfm.exec.chatMessage("<font color='#2C2C2C'>▲</font> - Força de pulo: Null ",name)
  79. tfm.exec.chatMessage(" <font color='#FF0000'>♥</font> - Coração: Ainda não perdido ",name)
  80. tfm.exec.chatMessage(" <font color='#8B0000'>♥</font> - Coração: Perdido ",name)
  81. end
  82. end
  83.  
  84. function eventNewPlayer(name)
  85. if not data[name] then
  86. data[name]={
  87. fly=os.time(),
  88. maxLife=2,
  89. life=2
  90. }
  91. end
  92.  
  93. tfm.exec.chatMessage("<VP>●</VP> <J>Olá "..name.." bem-vindo(a) ao <I>Sky</I>.</J></B>",name)
  94. tfm.exec.chatMessage("<VP>●</VP> <ROSE>Minigame em desenvolvimento, Versão alpha: <B><VI>0.10</VI></B>, Criado por: <VI><B>Contistente</B></VI></ROSE>",name)
  95. if tfm.get.room.playerList[name].isDead then
  96. data[name].life = 0
  97. end
  98.  
  99. system.bindKeyboard(name,32,true)
  100. end
  101.  
  102. function eventPlayerDied(name)
  103. if data[name].life > 0 then
  104. if start < os.time()-3000 then
  105. data[name].life=data[name].life-1;
  106. end
  107. tfm.exec.respawnPlayer(name)
  108. else
  109. tfm.exec.chatMessage("Você perdeu todos seus corações e não pode mais reviver neste mapa.",name)
  110. vivos=vivos-1;
  111. end
  112. end
  113.  
  114. function eventLoop(t,r)
  115. str=""
  116.  
  117. if vento < os.time()-6000 then
  118. _Vento = math.random(1,4)
  119. vento = os.time();
  120. end
  121.  
  122. for i=1,_Vento do
  123. if i <= 1 then
  124. str=str.."<font color='#00BFFF'>▲</font>"
  125. elseif i <= 2 then
  126. str=str.."<font color='#FFCC00'>▲</font>"
  127. elseif i <= 3 then
  128. str=str.."<font color='#00FF00'>▲</font>"
  129. elseif i <= 4 then
  130. str=str.."<font color='#FF0000'>▲</font>"
  131. end
  132. end
  133.  
  134. if _Vento == 3 then
  135. str = str.."<font color='#2C2C2C'>▲</font>"
  136. end
  137.  
  138. if _Vento == 2 then
  139. str = str.."<font color='#2C2C2C'>▲▲</font>"
  140. end
  141.  
  142. if _Vento == 1 then
  143. str = str.."<font color='#2C2C2C'>▲▲▲</font>"
  144. end
  145.  
  146. if r < 1000 or vivos == 0 then
  147. sendNewMap()
  148. end
  149.  
  150. for i,v in pairs(tfm.get.room.playerList) do
  151. if not v.isDead and v.y <= 300 then
  152. tfm.exec.giveCheese(i)
  153. tfm.exec.playerVictory(i)
  154. end
  155.  
  156. ui.addTextArea(0,"",i,4.9,360,45,50,0x1C1C1C,0x1C1C1C,nil,true,true,true)
  157. ui.addTextArea(1,hearts(i),i,5,350,50,40,0,0,0,true)
  158. ui.addTextArea(2,"<B><font size='10'>"..str.."</font><BR><VP><B>"..(3000-v.y).."m",i,5,365,50,40,0,0,0,true)
  159. end
  160. end
  161.  
  162. function hearts(name)
  163. s=""
  164. for i=1,data[name].maxLife do
  165. if data[name].life < i then
  166. s=s.."<font color='#8B0000' size='15'><B>♥</font>"
  167. else
  168. s=s.."<font color='#FF0000' size='15'><B>♥</font>"
  169. end
  170. end
  171.  
  172. return s
  173. end
  174.  
  175. function eventNewGame()
  176. vivos=0
  177. tfm.exec.setGameTime(220)
  178.  
  179. start=os.time()
  180.  
  181. for i in pairs(tfm.get.room.playerList) do
  182. vivos=vivos+1;
  183. data[i].life=2
  184. end
  185. end
  186.  
  187. function eventKeyboard(name,key,down,x,y)
  188. if key == 32 and data[name].fly < os.time()-1800 then
  189. v=_Vento*10
  190.  
  191. tfm.exec.movePlayer(name,0,0,false,0,-v*3,true)
  192. data[name].fly=os.time();
  193. end
  194. end
  195.  
  196. for all in pairs(tfm.get.room.playerList) do
  197. eventNewPlayer(all)
  198. end
  199.  
  200. sendNewMap()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement