Obsidian volcanos, stacked realm/singlenode options, bugfixes

This commit is contained in:
paramat 2014-04-01 10:12:30 +01:00
parent d5097935cf
commit 6a49a77032
4 changed files with 158 additions and 139 deletions

View File

@ -1,4 +1,4 @@
watershed 0.3.0 by paramat watershed 0.3.1 by paramat
For latest stable Minetest back to 0.4.8 For latest stable Minetest back to 0.4.8
Depends default Depends default
Licenses: code WTFPL Licenses: code WTFPL

View File

@ -249,137 +249,143 @@ minetest.register_abm({
end, end,
}) })
-- Set mapgen parameters -- Singlenode mapgen option
minetest.register_on_mapgen_init(function(mgparams) local SINGLENODE = true
minetest.set_mapgen_params({mgname="singlenode", flags = "nolight", flagmask = "nolight"})
end)
-- Spawn player if SINGLENODE then
-- Set mapgen parameters
function spawnplayer(player) minetest.register_on_mapgen_init(function(mgparams)
local TERCEN = -160 -- Terrain 'centre', average seabed level minetest.set_mapgen_params({mgname="singlenode", flags = "nolight", flagmask = "nolight"})
local TERSCA = 512 -- Vertical terrain scale end)
local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floatlands above ridges
local XLSAMP = 0.2 -- Extra large scale height variation amplitude
local BASAMP = 0.4 -- Base terrain amplitude
local CANAMP = 0.4 -- Canyon terrain amplitude
local CANEXP = 1.33 -- Canyon shape exponent
local xsp
local ysp
local zsp
local np_rough = {
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
seed = 593,
octaves = 6,
persist = 0.63
}
local np_smooth = {
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
seed = 593,
octaves = 6,
persist = 0.3
}
local np_fault = {
offset = 0,
scale = 1,
spread = {x=512, y=1024, z=512},
seed = 14440002,
octaves = 6,
persist = 0.5
}
local np_base = {
offset = 0,
scale = 1,
spread = {x=4096, y=4096, z=4096},
seed = 8890,
octaves = 4,
persist = 0.4
}
local np_xlscale = {
offset = 0,
scale = 1,
spread = {x=8192, y=8192, z=8192},
seed = -72,
octaves = 3,
persist = 0.4
}
for chunk = 1, 32 do
print ("[watershed] chunk "..chunk)
local x0 = 80 * math.random(-24, 24) - 32
local z0 = 80 * math.random(-24, 24) - 32
local y0 = -32
local x1 = x0 + 79
local z1 = z0 + 79
local y1 = 47
local sidelen = 80 -- Spawn player
local chulens = {x=sidelen, y=sidelen, z=sidelen}
local minposxyz = {x=x0, y=y0, z=z0}
local minposxz = {x=x0, y=z0}
local nvals_rough = minetest.get_perlin_map(np_rough, chulens):get3dMap_flat(minposxyz) function spawnplayer(player)
local nvals_smooth = minetest.get_perlin_map(np_smooth, chulens):get3dMap_flat(minposxyz) local TERCEN = -160 -- Terrain 'centre', average seabed level
local nvals_fault = minetest.get_perlin_map(np_fault, chulens):get3dMap_flat(minposxyz) local TERSCA = 512 -- Vertical terrain scale
local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floatlands above ridges
local XLSAMP = 0.2 -- Extra large scale height variation amplitude
local BASAMP = 0.4 -- Base terrain amplitude
local CANAMP = 0.4 -- Canyon terrain amplitude
local CANEXP = 1.33 -- Canyon shape exponent
local xsp
local ysp
local zsp
local np_rough = {
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
seed = 593,
octaves = 6,
persist = 0.63
}
local np_smooth = {
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
seed = 593,
octaves = 6,
persist = 0.3
}
local np_fault = {
offset = 0,
scale = 1,
spread = {x=512, y=1024, z=512},
seed = 14440002,
octaves = 6,
persist = 0.5
}
local np_base = {
offset = 0,
scale = 1,
spread = {x=4096, y=4096, z=4096},
seed = 8890,
octaves = 4,
persist = 0.4
}
local np_xlscale = {
offset = 0,
scale = 1,
spread = {x=8192, y=8192, z=8192},
seed = -72,
octaves = 3,
persist = 0.4
}
for chunk = 1, 32 do
print ("[watershed] chunk "..chunk)
local x0 = 80 * math.random(-24, 24) - 32
local z0 = 80 * math.random(-24, 24) - 32
local y0 = -32
local x1 = x0 + 79
local z1 = z0 + 79
local y1 = 47
local nvals_base = minetest.get_perlin_map(np_base, chulens):get2dMap_flat(minposxz) local sidelen = 80
local nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz) local chulens = {x=sidelen, y=sidelen, z=sidelen}
local minposxyz = {x=x0, y=y0, z=z0}
local minposxz = {x=x0, y=z0}
local nixz = 1 local nvals_rough = minetest.get_perlin_map(np_rough, chulens):get3dMap_flat(minposxyz)
local nixyz = 1 local nvals_smooth = minetest.get_perlin_map(np_smooth, chulens):get3dMap_flat(minposxyz)
for z = z0, z1 do local nvals_fault = minetest.get_perlin_map(np_fault, chulens):get3dMap_flat(minposxyz)
for y = y0, y1 do
for x = x0, x1 do local nvals_base = minetest.get_perlin_map(np_base, chulens):get2dMap_flat(minposxz)
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP local nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz)
local n_base = nvals_base[nixz]
local terblen = math.max(1 - math.abs(n_base), 0) local nixz = 1
local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad local nixyz = 1
local density for z = z0, z1 do
if nvals_fault[nixyz] >= 0 then for y = y0, y1 do
density = densitybase for x = x0, x1 do
+ math.abs(nvals_rough[nixyz] * terblen local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP local n_base = nvals_base[nixz]
else local terblen = math.max(1 - math.abs(n_base), 0)
density = densitybase local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad
+ math.abs(nvals_rough[nixyz] * terblen local density
- nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP if nvals_fault[nixyz] >= 0 then
density = densitybase
+ math.abs(nvals_rough[nixyz] * terblen
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP
else
density = densitybase
+ math.abs(nvals_rough[nixyz] * terblen
- nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP
end
if y >= 1 and density > -0.01 and density < 0 then
ysp = y
xsp = x
zsp = z
break
end
nixz = nixz + 1
nixyz = nixyz + 1
end end
if y >= 1 and density > -0.01 and density < 0 then if ysp then
ysp = y
xsp = x
zsp = z
break break
end end
nixz = nixz + 1 nixz = nixz - 80
nixyz = nixyz + 1
end end
if ysp then if ysp then
break break
end end
nixz = nixz - 80 nixz = nixz + 80
end end
if ysp then if ysp then
break break
end end
nixz = nixz + 80
end
if ysp then
break
end end
print ("[watershed] spawn player ("..xsp.." "..ysp.." "..zsp..")")
player:setpos({x=xsp, y=ysp, z=zsp})
end end
print ("[watershed] spawn player ("..xsp.." "..ysp.." "..zsp..")")
player:setpos({x=xsp, y=ysp, z=zsp}) minetest.register_on_newplayer(function(player)
spawnplayer(player)
end)
minetest.register_on_respawnplayer(function(player)
spawnplayer(player)
return true
end)
end end
minetest.register_on_newplayer(function(player)
spawnplayer(player)
end)
minetest.register_on_respawnplayer(function(player)
spawnplayer(player)
return true
end)

View File

@ -1,11 +1,14 @@
-- watershed 0.3.0 by paramat -- watershed 0.3.1 by paramat
-- For latest stable Minetest and back to 0.4.8 -- For latest stable Minetest and back to 0.4.8
-- Depends default -- Depends default
-- License: code WTFPL -- License: code WTFPL
-- add snowy plains biome -- bugfixes
-- optional mod clouds
-- stacked realm / singlenode option
-- volcanoes
-- TODO -- TODO
-- lava at surface: volcanic cone? -- check river continuous over faults
-- tree heights vary -- tree heights vary
-- fog -- fog
@ -16,6 +19,7 @@ local YMAX = 33000 -- Approximate top of atmosphere / mountains / floatlands
local TERCEN = -160 -- Terrain 'centre', average seabed level local TERCEN = -160 -- Terrain 'centre', average seabed level
local YWAT = 1 -- Sea surface y local YWAT = 1 -- Sea surface y
local YCLOUD = 128 -- Cloud level local YCLOUD = 128 -- Cloud level
local CLOUDS = false
local TERSCA = 512 -- Vertical terrain scale local TERSCA = 512 -- Vertical terrain scale
local XLSAMP = 0.2 -- Extra large scale height variation amplitude local XLSAMP = 0.2 -- Extra large scale height variation amplitude
@ -24,7 +28,7 @@ local CANAMP = 0.4 -- Canyon terrain amplitude
local CANEXP = 1.33 -- Canyon shape exponent local CANEXP = 1.33 -- Canyon shape exponent
local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floatlands above ridges local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floatlands above ridges
local TSTONE = 0.01 -- Density threshold for stone, depth of soil at TERCEN local TSTONE = 0.02 -- Density threshold for stone, depth of soil at TERCEN
local TRIV = -0.015 -- Maximum densitybase threshold for river water local TRIV = -0.015 -- Maximum densitybase threshold for river water
local TSAND = -0.018 -- Maximum densitybase threshold for river sand local TSAND = -0.018 -- Maximum densitybase threshold for river sand
local TLAVA = 2 -- Maximum densitybase threshold for lava local TLAVA = 2 -- Maximum densitybase threshold for lava
@ -34,16 +38,16 @@ local ORETHI = 0.001 -- Ore seam thickness tuner
local ORET = 0.02 -- Ore threshold for seam local ORET = 0.02 -- Ore threshold for seam
local TCLOUD = 0.5 -- Cloud threshold local TCLOUD = 0.5 -- Cloud threshold
local HITET = 0.4 -- High temperature threshold local HITET = 0.35 -- High temperature threshold
local LOTET = -0.4 -- Low .. local LOTET = -0.35 -- Low ..
local ICETET = -0.8 -- Ice .. local ICETET = -0.7 -- Ice ..
local HIHUT = 0.4 -- High humidity threshold local HIHUT = 0.35 -- High humidity threshold
local LOHUT = -0.4 -- Low .. local LOHUT = -0.35 -- Low ..
local CLOHUT = 0 -- Cloud humidity threshold local CLOHUT = 0 -- Cloud humidity threshold
local DCLOHUT = 1 -- Dark cloud .. local DCLOHUT = 1 -- Dark cloud ..
local PINCHA = 47 -- Pine tree 1/x chance per node local PINCHA = 49 -- Pine tree 1/x chance per node
local APTCHA = 47 -- Appletree local APTCHA = 49 -- Appletree
local FLOCHA = 36 -- Flower local FLOCHA = 36 -- Flower
local FOGCHA = 9 -- Forest grass local FOGCHA = 9 -- Forest grass
local GRACHA = 3 -- Grassland grasses local GRACHA = 3 -- Grassland grasses
@ -52,7 +56,7 @@ local JUGCHA = 9 -- Junglegrass
local CACCHA = 841 -- Cactus local CACCHA = 841 -- Cactus
local DRYCHA = 169 -- Dry shrub local DRYCHA = 169 -- Dry shrub
local PAPCHA = 3 -- Papyrus local PAPCHA = 3 -- Papyrus
local ACACHA = 841 -- Acacia tree local ACACHA = 529 -- Acacia tree
local GOGCHA = 3 -- Golden grass local GOGCHA = 3 -- Golden grass
-- 3D noise for rough terrain -- 3D noise for rough terrain
@ -183,7 +187,7 @@ local np_magma = {
scale = 1, scale = 1,
spread = {x=128, y=128, z=128}, spread = {x=128, y=128, z=128},
seed = -13, seed = -13,
octaves = 1, octaves = 2,
persist = 0.5 persist = 0.5
} }
@ -264,6 +268,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_gravel = minetest.get_content_id("default:gravel") local c_gravel = minetest.get_content_id("default:gravel")
local c_clay = minetest.get_content_id("default:clay") local c_clay = minetest.get_content_id("default:clay")
local c_grass5 = minetest.get_content_id("default:grass_5") local c_grass5 = minetest.get_content_id("default:grass_5")
local c_obsidian = minetest.get_content_id("default:obsidian")
local c_wswater = minetest.get_content_id("watershed:water") local c_wswater = minetest.get_content_id("watershed:water")
local c_wsstone = minetest.get_content_id("watershed:stone") local c_wsstone = minetest.get_content_id("watershed:stone")
@ -316,10 +321,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
local terblen = math.max(1 - math.abs(n_base), 0) local terblen = math.max(1 - math.abs(n_base), 0)
local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad
local altprop = (y - YWAT) / (TERCEN + TERSCA - YWAT) local altprop = (y - YWAT) / (TERCEN + TERSCA - YWAT)
local triv = TRIV * (1 - altprop * 1.1) local triv = TRIV * (1 - terblen)
local tsand = TSAND * (1 - altprop * 1.1) local tsand = TSAND * (1 - terblen * 1.1)
local tstone = TSTONE * (1 - math.atan(altprop) * 0.6) -- 1 to 0.05 local tstone = TSTONE * (1 - math.atan(altprop) * 0.6) -- 1 to 0.05
local tlava = TLAVA * (0.9 - nvals_magma[nixz] ^ 4 * terblen ^ 16) local tlava = TLAVA * (1 - nvals_magma[nixz] ^ 4 * terblen ^ 16)
local density local density
if nvals_fault[nixyz] >= 0 then if nvals_fault[nixyz] >= 0 then
density = densitybase density = densitybase
@ -389,10 +394,16 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
if density >= tstone and densitybase >= tlava then if densitybase >= tlava then
data[vi] = c_wslava if densitybase >= -0.05 then
data[vi] = c_wslava
end
stable[si] = 0 stable[si] = 0
under[si] = 0 under[si] = 0
elseif densitybase >= tlava - 0.5 and densitybase >= -0.1 then
data[vi] = c_obsidian
stable[si] = 1
under[si] = 0
elseif density >= tstone and nofis -- stone cut by fissures elseif density >= tstone and nofis -- stone cut by fissures
or (density >= tstone and density < TSTONE * 3 and y <= YWAT) -- stone around water or (density >= tstone and density < TSTONE * 3 and y <= YWAT) -- stone around water
or (density >= tstone and density < TSTONE * 3 and densitybase >= triv ) then -- stone around river or (density >= tstone and density < TSTONE * 3 and densitybase >= triv ) then -- stone around river
@ -495,7 +506,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
stable[si] = 0 stable[si] = 0
under[si] = 0 under[si] = 0
elseif y == YCLOUD then -- clouds elseif CLOUDS and y == YCLOUD then -- clouds
local xrq = 16 * math.floor((x - x0) / 16) -- quantise to 16x16 lattice local xrq = 16 * math.floor((x - x0) / 16) -- quantise to 16x16 lattice
local zrq = 16 * math.floor((z - z0) / 16) local zrq = 16 * math.floor((z - z0) / 16)
local qixz = zrq * 80 + xrq + 1 -- quantised index local qixz = zrq * 80 + xrq + 1 -- quantised index
@ -604,16 +615,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
elseif under[si] == 2 then elseif under[si] == 2 then
data[viu] = c_dirtsnow data[viu] = c_dirtsnow
elseif under[si] == 3 then
data[viu] = c_dirtsnow
elseif under[si] == 4 then
data[viu] = c_wsdrygrass
elseif under[si] == 5 then elseif under[si] == 5 then
data[viu] = c_wsgrass data[viu] = c_wsgrass
elseif under[si] == 3 then elseif under[si] == 6 then
data[viu] = c_wsdrygrass
elseif under[si] == 4 then
data[viu] = c_wsgrass data[viu] = c_wsgrass
elseif under[si] == 8 then elseif under[si] == 8 then
data[viu] = c_wsgrass
elseif under[si] == 7 then
data[viu] = c_wsdrygrass data[viu] = c_wsdrygrass
elseif under[si] == 9 then
data[viu] = c_wsgrass
end end
end end
end end

View File

@ -274,7 +274,7 @@ minetest.register_node("watershed:lava", {
liquid_alternative_source = "watershed:lava", liquid_alternative_source = "watershed:lava",
liquid_viscosity = LAVA_VISC, liquid_viscosity = LAVA_VISC,
liquid_renewable = false, liquid_renewable = false,
liquid_range = 2, liquid_range = 0,
damage_per_second = 8, damage_per_second = 8,
post_effect_color = {a=192, r=255, g=64, b=0}, post_effect_color = {a=192, r=255, g=64, b=0},
groups = {lava=3, liquid=2, hot=3, igniter=1}, groups = {lava=3, liquid=2, hot=3, igniter=1},
@ -313,7 +313,7 @@ minetest.register_node("watershed:lavaflow", {
liquid_alternative_source = "watershed:lava", liquid_alternative_source = "watershed:lava",
liquid_viscosity = LAVA_VISC, liquid_viscosity = LAVA_VISC,
liquid_renewable = false, liquid_renewable = false,
liquid_range = 2, liquid_range = 0,
damage_per_second = 8, damage_per_second = 8,
post_effect_color = {a=192, r=255, g=64, b=0}, post_effect_color = {a=192, r=255, g=64, b=0},
groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1}, groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1},