Advertisement
Bolodefchoco_LUAXML

[Script] Gerador de Mapas (Versão Alpha)

Jan 28th, 2017
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.46 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 28/01/2017
  3. --Last update: 28/01/2017
  4.  
  5. takeMul = function(x)
  6.     return x-(x%5)
  7. end
  8. tfm.exec.disableAutoShaman()
  9. tfm.exec.disableAutoNewGame()
  10.  
  11. math.randomseed = 9
  12.  
  13. xml = {}
  14.  
  15. xml.standard = "<C><P F=\""..(math.random(0,8)%6).."\" /><Z><S>%s</S><D>%s</D><O /></Z></C>"
  16. xml.grounds,xml.decorations = {},{}
  17.  
  18. xml.S,xml.SET,xml.D = '<S L="%d" H="%d" X="%d" Y="%d" T="%d" P="0,0,%f,%f,%d,0,0,0" o="'..math.random(0xD2436B,0x43D28B)..'" />','<%s X="%d" Y="%d" />','<P P="0,0" X="%d" Y="%d" T="%d" />'
  19.  
  20. grounds = {{0,1,4},{10,1},{12,13},{1,2},{4,1},{1,10},{10,9,2}}
  21. 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}}
  22. 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},{},{},{},{}}
  23.  
  24. currentX,currentY = 0,0
  25. mapGrounds = grounds[math.random(#grounds)]
  26. for i = 1,math.random(8,25) do
  27.     local ground = mapGrounds[i==1 and i or math.random(#mapGrounds)]
  28.     local L = takeMul(ground~=13 and math.random(40,120) or math.random(20,40))
  29.     local H = takeMul(math.random(20,35))
  30.     if ground == 9 and math.random(10) < 6 then
  31.         L,H = H,L
  32.     end
  33.     local X,Y
  34.     repeat
  35.         X = takeMul(math.random(90,860) - L - (currentX/8))
  36.         Y = takeMul(math.random(100,300) + (currentY/4))
  37.     until X > 0 and X < 800 and Y > 0 and Y < 400
  38.     currentX,currentY = X - X^.5,Y + Y^.5
  39.     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)))
  40.     if math.random(22) < 3 then
  41.         local dec = decorations[ground+1]
  42.         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))
  43.     end
  44.     if i == 1 then
  45.         for k,v in next,{"DS","T"} do
  46.             table.insert(xml.decorations,xml.SET:format(v,X,Y - (H/2)))
  47.         end
  48.     end
  49. end
  50. local cheeses = 1
  51. if math.random(30) == 2 then cheeses = 2 end
  52. for c = 1,cheeses do
  53.     local X,Y
  54.     repeat
  55.         X,Y = takeMul(math.random(90,860) + (currentX/4)),takeMul(math.random(100,300) - (currentY/10))
  56.     until X > 0 and X < 800 and Y > 0 and Y < 400
  57.     table.insert(xml.decorations,xml.SET:format("F",X,Y))
  58. end
  59.  
  60. tfm.exec.newGame(xml.standard:format(table.concat(xml.grounds),table.concat(xml.decorations)))
  61.  
  62. eventPlayerDied = function(n)
  63.     tfm.exec.respawnPlayer(n)
  64. end
  65. eventPlayerWon = function(n)
  66.     tfm.exec.respawnPlayer(n)
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement