Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. --[[
  2. Underground Warefare [REMASTERED]
  3. --]]
  4.  
  5. --// Services
  6. local players = game:GetService("Players")
  7. local runService = game:GetService("RunService")
  8. local httpService = game:GetService("HttpService")
  9. local replicatedStorage = game:GetService("ReplicatedStorage")
  10.  
  11. --// Constants
  12. local databases = replicatedStorage:WaitForChild("Databases")
  13. local remotes = replicatedStorage:WaitForChild("Remotes")
  14.  
  15. --// Variables
  16. local mapSize = 70
  17. local mapHeight = 6
  18. local blockSize = 10
  19.  
  20. local newBlockBalancing = {
  21. Soil = 45,
  22. Stone = 10,
  23. Iron = 2,
  24. }
  25.  
  26. --// Modules
  27. local playerModule = require(script:WaitForChild("PlayerModule"))
  28. local dataModule = require(script:WaitForChild("DataModule"))
  29.  
  30. local gameModesModule = require(databases:WaitForChild("GameModes"))
  31.  
  32. --// Init
  33. players.PlayerAdded:Connect(playerModule.onPlayerJoin)
  34. players.PlayerRemoving:Connect(playerModule.onPlayerLeave)
  35.  
  36. pcall(dataModule.queueSet)
  37.  
  38. --// Map Generation
  39. local function generateMap()
  40. local grid = {}
  41. print("Creating map")
  42. local mapComponents = workspace:FindFirstChild("GeneratedMap") or Instance.new("Folder")
  43. mapComponents.Name = "GeneratedMap"
  44. mapComponents.Parent = workspace
  45. mapComponents:ClearAllChildren()
  46.  
  47. for h = 1, mapHeight do
  48. grid[h] = {}
  49. --runService.Heartbeat:Wait()
  50. for l = 1, mapSize + (mapSize/3) do
  51. grid[h][l] = {}
  52. for w = 1, mapSize do
  53. grid[h][l][w] = {}
  54. local newBlock = Instance.new("Part")
  55. newBlock.Anchored = true
  56. newBlock.Size = Vector3.new(blockSize, blockSize, blockSize)
  57. table.insert(grid[h][l][w], newBlock)
  58. if (h == mapHeight) then
  59. -- NOTE: We know it's a top layer
  60. newBlock.Size = Vector3.new(blockSize, 1, blockSize)
  61. newBlock.CFrame = CFrame.new(l * newBlock.Size.X,((h * blockSize) - blockSize/2) + .5, w * newBlock.Size.Z)
  62. newBlock.Material = Enum.Material.Grass
  63. newBlock.Color = Color3.fromRGB(106, 127, 63)
  64. newBlock.Name = "Grass"
  65. elseif (h == 1) then
  66. -- NOTE: We know it's a bottom layer
  67. newBlock.Size = Vector3.new(blockSize, 1, blockSize)
  68. newBlock.CFrame = CFrame.new(l * newBlock.Size.X,((h * blockSize) + blockSize/2) - .5, w * newBlock.Size.Z)
  69. newBlock.Material = Enum.Material.Slate
  70. newBlock.BrickColor = BrickColor.new("Dark stone grey")
  71. newBlock.Name = "Bedrock"
  72. else
  73. newBlock.CFrame = CFrame.new(l * newBlock.Size.X, h * newBlock.Size.Y, w * newBlock.Size.Z)
  74. local randomNumber = math.random(1, newBlockBalancing.Stone * (h-1))
  75. newBlock.Material = (randomNumber <= newBlockBalancing.Iron and Enum.Material.Metal or (randomNumber > newBlockBalancing.Iron and randomNumber <= newBlockBalancing.Stone) and Enum.Material.Slate or Enum.Material.Grass)
  76. newBlock.BrickColor = (newBlock.Material == Enum.Material.Grass and BrickColor.new("Brown") or newBlock.Material == Enum.Material.Metal and BrickColor.new("Fawn brown") or BrickColor.new("Medium stone grey"))
  77. newBlock.Name = (newBlock.Material == Enum.Material.Grass and "Soil" or newBlock.Material == Enum.Material.Metal and "Ore" or "Stone")
  78. end
  79. newBlock.Parent = mapComponents
  80. end
  81. end
  82. end
  83.  
  84. local spawnPoint = Instance.new('SpawnLocation')
  85. spawnPoint.Anchored = true
  86. spawnPoint.CFrame = CFrame.new((mapSize*blockSize)/2, ((mapHeight * blockSize) - blockSize/2) + .5, (mapSize*blockSize)/2)
  87. spawnPoint.Parent = mapComponents
  88.  
  89. print("Map Generated")
  90. end
  91.  
  92. --// Game Loop
  93. while (true) do
  94. if (#players:GetPlayers() >= 2 or runService:IsStudio()) then
  95. print("Picking gamemode")
  96.  
  97. local gameMode = gameModesModule[math.random(1, #gameModesModule)]
  98. generateMap()
  99.  
  100. end
  101.  
  102. wait(300)
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement