Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local b = require 'map_gen.shared.builders'
- local math = require "utils.math"
- --Create maltese shape
- local starting_area = 60
- local gradient = 0.05
- local tiles_half = (starting_area) * 0.5
- local function maltese_cross(x,y)
- local abs_x = math.abs(x)
- local abs_y = math.abs(y)
- return not (abs_x > (tiles_half+(abs_y*gradient)) and abs_y > (tiles_half+(abs_x*gradient)))
- end
- -- create water crossings and pattern
- local water_line =
- b.any {
- b.rectangle(10, 2)
- }
- water_line = b.change_tile(water_line, true, 'water')
- local waters = b.single_y_pattern(water_line, 3)
- local bounds = b.rectangle(10, starting_area+1)
- waters = b.choose(bounds, waters, b.empty_shape)
- waters = b.translate(waters,34,-1)
- water_pattern =
- b.any{
- waters,
- b.rotate(waters,degrees(90)),
- b.rotate(waters,degrees(180)),
- b.rotate(waters,degrees(270))
- }
- -- create the starting area as a concrete square
- local starting_square = b.rectangle(60, 60)
- starting_square = b.change_tile(starting_square, true, 'grass-1')
- -- work on the ore generation based on the code in hub_spiral.lua
- -- worm islands
- worm_island = b.rectangle(20,300)
- worm_island_end = b.circle(10)
- worm_island = b.any{
- worm_island_end,
- b.translate(worm_island,0,-150),
- b.translate(worm_island_end,0,-300)
- }
- worm_island = b.change_tile(worm_island, true, 'grass-1')
- local worm_names = {
- 'small-worm-turret',
- 'medium-worm-turret',
- 'big-worm-turret'
- }
- local max_worm_chance = 1 / 128
- local worm_chance_factor = 1 / (192 * 512)
- local function worms(_, _, world)
- local wx, wy = world.x, world.y
- local d = math.sqrt(wx * wx + wy * wy)
- local worm_chance = d - 128
- if worm_chance > 0 then
- worm_chance = worm_chance * worm_chance_factor
- worm_chance = math.min(worm_chance, max_worm_chance)
- if math.random() < worm_chance then
- if d < 256 then
- return {name = 'small-worm-turret'}
- else
- local max_lvl
- local min_lvl
- if d < 512 then
- max_lvl = 2
- min_lvl = 1
- else
- max_lvl = 3
- min_lvl = 2
- end
- local lvl = math.random() ^ (512 / d) * max_lvl
- lvl = math.ceil(lvl)
- lvl = math.clamp(lvl, min_lvl, 3)
- return {name = worm_names[lvl]}
- end
- end
- end
- end
- worm_island = b.apply_entities(worm_island, worms)
- worm_islands = b.any{
- b.rotate(b.translate(worm_island,0,-100),degrees(45)),
- b.rotate(b.translate(worm_island,0,-100),degrees(45+90)),
- b.rotate(b.translate(worm_island,0,-100),degrees(45+180)),
- b.rotate(b.translate(worm_island,0,-100),degrees(45+270))
- }
- -- create the start area using the ore, water and concrete squares
- local start_area =
- b.any {
- water_pattern,
- starting_square
- }
- maltese_cross = b.change_tile(maltese_cross, true, 'grass-1')
- local sea = b.change_tile(b.full_shape, true, 'water')
- sea = b.fish(sea, 0.00125)
- local map = b.any{worm_islands, start_area, maltese_cross,sea}
- return map
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement