MapGenerator: add peat_bog (Багно) biome. Add allwhere & marentine tree-schemes

This commit is contained in:
Van
2026-10-02 21:44:59 +03:00
parent 7ef96bd434
commit 02f7ca2894
4 changed files with 197 additions and 16 deletions

View File

@@ -1,2 +1,2 @@
name = smc__core__map_generator name = smc__core__map_generator
depends = smc__core__map_gen, smc__game__items__rocks, smc__game__items__liquids, smc__game__items__soils, smc__game__items__clays, smc__game__items__sands depends = smc__core__map_gen, smc__game__items__rocks, smc__game__items__liquids, smc__game__items__soils, smc__game__items__clays, smc__game__items__sands, smc__game__items__plants

View File

@@ -25,6 +25,11 @@ local MapGen = mapGenRequire('MapGen')
}, },
}) })
-- --- Layers ---
local LAYERS_NAMES = {
[1] = 'videre'
}
local function calcTemp(layer, value, height) local function calcTemp(layer, value, height)
return value return value
end end
@@ -33,7 +38,7 @@ local function calcHumidity(layer, value, height)
return value return value
end end
mapGenerator:registerLayer('videre', { mapGenerator:registerLayer(LAYERS_NAMES[1], {
minY = -256, minY = -256,
maxY = 256, maxY = 256,
minTemp = -100, minTemp = -100,
@@ -146,7 +151,7 @@ local coldOcean = {
local tropicalSoutheast = { local tropicalSoutheast = {
['landscape'] = { ['landscape'] = {
offset = 20, offset = 2,
scale = 5, scale = 5,
spread = {x = 15, y = 15, z = 15}, spread = {x = 15, y = 15, z = 15},
seed = 11611411111210599971088311111711610410197115116, seed = 11611411111210599971088311111711610410197115116,
@@ -357,20 +362,196 @@ local icyNorthernMMountains = {
local v = vector.new local v = vector.new
for _, c in ipairs({'landscape', 'temp', 'humidity'}) do for _, c in ipairs({'landscape', 'temp', 'humidity'}) do
mapGenerator:registerLayerNoiseColor('videre', c, '#5792ce', warmOcean[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#5792ce', warmOcean[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#4978c6', temperateOcean[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#4978c6', temperateOcean[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#4763b1', coldOcean[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#4763b1', coldOcean[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#a0ab72', tropicalSoutheast[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#a0ab72', tropicalSoutheast[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#dcd492', steppeSouthwest[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#dcd492', steppeSouthwest[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#a3c27c', temperateCentralZone[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#a3c27c', temperateCentralZone[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#999d8f', lowMountains[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#999d8f', lowMountains[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#569574', subarcticNorth[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#569574', subarcticNorth[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#76c2b6', arcticNorth[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#76c2b6', arcticNorth[c])
mapGenerator:registerLayerNoiseColor('videre', c, '#bac0ad', icyNorthernMMountains[c]) mapGenerator:registerLayerNoiseColor(LAYERS_NAMES[1], c, '#bac0ad', icyNorthernMMountains[c])
end end
-- --- Biomes --- -- --- Videre biomes ---
-- Chalybeate bog (Оржавинь)
--[[
mapGenerator:registerBiome(LAYERS_NAMES[1], 'chalybeate_bog', {
tempPoint = 30,
humidityPoint = 90,
minY = -10,
maxY = 15,
groundNodes = {
soil = 'soils:mud',
turf = 'soils:turf_bog',
rock = 'rocks:basalt',
bottom = 'soils:mud',
},
soilHeight = 5
})--]]
---@type NoiseParams
local peatBogTurfNoiseParams = {
offset = 0,
scale = 0.5,
spread = {x = 10, y = 10, z = 10},
seed = 42,
octaves = 6,
persistence = 0.4,
lacunarity = 2,
}
---@type ValueNoise?
local peatBogTurfNoise = nil
local peatBogPlantsNoiseParams = {
offset = 0,
scale = 10,
spread = {x = 10, y = 10, z = 10},
seed = 24,
octaves = 6,
persistence = 0.4,
lacunarity = 2,
}
---@type ValueNoise?
local peatBogPlantsNoise = nil
local placeParam2 = {
2,
3,
4,
34,
35,
36
}
local ID_BOG_GRASS_1 = id('plants:bog_grass_1')
local ID_BOG_GRASS_2 = id('plants:bog_grass_2')
local ID_BOG_GRASS_3 = id('plants:bog_grass_3')
local ID_TURF_BOG = id('soils:turf_bog')
local ID_MUD = id('soils:mud')
-- Peat bog (Багно)
mapGenerator:registerBiome(LAYERS_NAMES[1], 'peat_bog', {
tempPoint = 25,
humidityPoint = 95,
minY = -10,
maxY = 15,
groundNodes = {
soil = 'soils:mud',
turf = 'soils:mud',
rock = 'rocks:basalt',
bottom = 'soils:mud',
},
soilHeight = 5,
generateTurf = function (self, mapGenerator, factors, data, data2, index, x, y, z)
if peatBogTurfNoise == nil then
peatBogTurfNoise = core.get_value_noise(peatBogTurfNoiseParams)
end
local value = peatBogTurfNoise:get_3d({x=x, y=y, z=z})
if value >= 0 then
data[index] = ID_TURF_BOG
local colorIndex = 0
if value < 0.1 then
colorIndex = 3
elseif value < 0.25 then
colorIndex = 2
else
colorIndex = 1
end
data2[index] = mapGenerator:random(x, y, z, 0, 3) + (colorIndex << 2)
else
data[index] = ID_MUD
local colorIndex = 0
if value > -0.1 then
colorIndex = 3
elseif value > -0.25 then
colorIndex = 2
else
colorIndex = 1
end
data2[index] = mapGenerator:random(x, y, z, 0, 3) + (colorIndex << 2)
end
end,
--[[
generateSoil = function (self, mapGenerator, factors, data, data2, index, x, y, z)
-- TODO
end,
generateBottom = function (self, mapGenerator, factors, data, data2, index, x, y, z)
-- TODO
end,
--]]
dataPostProcessing = function (self, mapGenerator, factors, data, data2, index, x, y, z, nodeType, area)
if nodeType ~= 'TURF' then
return
end
if peatBogPlantsNoise == nil then
peatBogPlantsNoise = core.get_value_noise(peatBogPlantsNoiseParams)
end
local grassValue = peatBogPlantsNoise:get_3d({x=x, y=0, z=z}) + mapGenerator:random(x, y, z, 0, 2)
local i = area:index(x,y+1,z)
if grassValue > 8 then
data[i] = ID_BOG_GRASS_1
data2[i] = 8 + placeParam2[mapGenerator:random(x, y, z, 1, #placeParam2)]
elseif grassValue > 5 then
data[i] = ID_BOG_GRASS_2
data2[i] = 8 + placeParam2[mapGenerator:random(x, y, z, 1, #placeParam2)]
elseif grassValue > 3 then
data[i] = ID_BOG_GRASS_3
data2[i] = 8 + placeParam2[mapGenerator:random(x, y, z, 1, #placeParam2)]
end
end,
vmPostProcessing = function(self, mapGenerator, factors, voxelManip, x, y, z, nodeType, area)
if nodeType ~= 'TURF' then
return
end
if peatBogPlantsNoise == nil then
peatBogPlantsNoise = core.get_value_noise(peatBogPlantsNoiseParams)
end
local grassValue = peatBogPlantsNoise:get_3d({x=x, y=0, z=z}) + mapGenerator:random(x, y, z, 0, 2)
if grassValue <= 3 then
return
end
local treeValue = mapGenerator:random(x, y, z, 1, 1000)
if treeValue >= 990 then
local pos = v(x, y-mapGenerator:random(x, y-1, z, 0, 1), z) --[[@as MapVector]]
mapGenerator:getTree('allwhere_tree_a'):placeOnVM(voxelManip, pos)
elseif treeValue >= 950 then
local pos = v(x, y-mapGenerator:random(x, y-1, z, 0, 2), z) --[[@as MapVector]]
mapGenerator:getTree('marentine_tree_a'):placeOnVM(voxelManip, pos)
end
end
})
mapGenerator:registerTree('allwhere_tree_a', {
path = core.get_modpath(core.get_current_modname())..'/schems/allwhere_tree_a.mts',
})
mapGenerator:registerTree('marentine_tree_a', {
path = core.get_modpath(core.get_current_modname())..'/schems/marentine_tree_a.mts',
})
-- Debug:
---@type ValueNoise ---@type ValueNoise
local rocksNoise local rocksNoise
@@ -435,10 +616,10 @@ mapGenerator:registerBiome('videre', 'green_meadow', {
minY = -50, minY = -50,
maxY = 100, maxY = 100,
groundNodes = { groundNodes = {
soil = 'soils:humus', soil = 'soils:chernozem',
turf = 'soils:turf_meadow', turf = 'soils:turf_meadow',
rock = 'rocks:basalt', rock = 'rocks:basalt',
bottom = 'soils:humus', bottom = 'soils:chernozem',
}, },
soilHeight = 5, soilHeight = 5,
dataPostProcessing = meadowPostProcessing, dataPostProcessing = meadowPostProcessing,