update mapgen_v6, e.g. put snow onto icesheets

This commit is contained in:
HybridDog 2015-06-12 23:21:43 +02:00
parent ead65ab164
commit acb5141cbe
2 changed files with 83 additions and 59 deletions

View File

@ -103,7 +103,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local pr = PseudoRandom(seed+57) local pr = PseudoRandom(seed+57)
-- Land biomes -- Land biomes
local biome = pr:next(1, 5) local biome = pr:next(1, 5)
local snowy = biome == 1 -- spawns alot of snow local snowy = biome == 1 -- spawns snow
local alpine = biome == 3 -- rocky terrain local alpine = biome == 3 -- rocky terrain
-- Misc biome settings -- Misc biome settings
local icy = pr:next(1, 2) == 2 -- if enabled spawns ice in sand instead of snow blocks local icy = pr:next(1, 2) == 2 -- if enabled spawns ice in sand instead of snow blocks
@ -119,15 +119,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
for x = x0, x1 do for x = x0, x1 do
local in_biome = false local in_biome = false
local test = math.min(nvals_cold[ni], 1) local test = math.min(nvals_cold[ni], 1)
if smooth and (not snowy) if smooth
and (test > 0.73 or (test > 0.43 and pr:next(0,29) > (0.73 - test) * 100 )) then and not snowy then
if (test > 0.73 or (test > 0.43 and pr:next(0,29) > (0.73 - test) * 100 )) then
in_biome = true in_biome = true
elseif (not smooth or snowy) and test > 0.53 then end
elseif test > 0.53 then
in_biome = true in_biome = true
end end
if not in_biome then if not in_biome then
if alpine and test > 0.43 then if alpine and test > 0.43 then
-- remove trees near alpine
local ground_y = nil local ground_y = nil
for y = maxp.y, minp.y, -1 do for y = maxp.y, minp.y, -1 do
local nodid = data[area:index(x, y, z)] local nodid = data[area:index(x, y, z)]
@ -140,7 +143,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
if ground_y then if ground_y then
local vi = area:index(x, ground_y, z) local vi = area:index(x, ground_y, z)
if data[vi] == c_leaves or data[vi] == c_jungleleaves then if data[vi] == c_leaves
or data[vi] == c_jungleleaves then
for y = ground_y, -16, -1 do for y = ground_y, -16, -1 do
local vi = area:index(x, y, z) local vi = area:index(x, y, z)
local id = data[vi] local id = data[vi]
@ -158,7 +162,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
end end
elseif in_biome then else
write_to_map = true write_to_map = true
local icetype = nvals_ice[ni] local icetype = nvals_ice[ni]
local cool = icetype > 0 -- only spawns ice on edge of water local cool = icetype > 0 -- only spawns ice on edge of water
@ -167,7 +171,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local icesheet = icetype > -0.6 and icetype <= -0.4 local icesheet = icetype > -0.6 and icetype <= -0.4
local icecave = icetype <= -0.6 local icecave = icetype <= -0.6
local ground_y = nil local ground_y
for y = maxp.y, minp.y, -1 do for y = maxp.y, minp.y, -1 do
local nodid = data[area:index(x, y, z)] local nodid = data[area:index(x, y, z)]
if nodid ~= c_air and nodid ~= c_ignore then if nodid ~= c_air and nodid ~= c_ignore then
@ -178,86 +182,92 @@ minetest.register_on_generated(function(minp, maxp, seed)
if ground_y then if ground_y then
local node = area:index(x, ground_y, z) local node = area:index(x, ground_y, z)
local c_ground = data[node]
local abovenode = area:index(x, ground_y+1, z) local abovenode = area:index(x, ground_y+1, z)
local belownode = area:index(x, ground_y-1, z)
if ground_y and data[node] == c_dirt_with_grass then if c_ground == c_dirt_with_grass then
if alpine and test > 0.53 then if alpine
and test > 0.53 then
snow_tab[num] = {abovenode, z, x, test} snow_tab[num] = {abovenode, z, x, test}
num = num+1 num = num+1
for y = ground_y, -6, -1 do -- generate stone ground
for y = ground_y, math.max(-6, minp.y-6), -1 do
local vi = area:index(x, y, z) local vi = area:index(x, y, z)
if data[vi] == c_stone then if data[vi] == c_stone then
break break
else end
data[vi] = c_stone data[vi] = c_stone
end end
end elseif shrubs
elseif (shrubs and pr:next(1,28) == 1) then and pr:next(1,28) == 1 then
data[node] = c_dirt_with_snow data[node] = c_dirt_with_snow
data[abovenode] = c_dry_shrub data[abovenode] = c_dry_shrub
elseif pines and pr:next(1,36) == 1 then elseif pines
and pr:next(1,36) == 1 then
data[node] = c_dirt_with_snow data[node] = c_dirt_with_snow
spawn_pine({x=x, y=ground_y+1, z=z}, area, data) spawn_pine({x=x, y=ground_y+1, z=z}, area, data)
elseif snowy and test > 0.63 then
data[abovenode] = c_snow_block
else else
data[node] = c_dirt_with_snow data[node] = c_dirt_with_snow
snow_tab[num] = {abovenode, z, x, test} snow_tab[num] = {abovenode, z, x, test}
num = num+1 num = num+1
end end
elseif ground_y and data[node] == c_sand then elseif c_ground == c_sand then
if not icy then if icy then
snow_tab[num] = {abovenode, z, x, test}
num = num+1
else
data[node] = c_ice data[node] = c_ice
end end
elseif ground_y and data[node] == c_leaves snow_tab[num] = {abovenode, z, x, test}
or data[node] == c_jungleleaves or data[node] == c_apple then num = num+1
elseif c_ground == c_leaves
or c_ground == c_jungleleaves
or c_ground == c_apple then
if alpine then if alpine then
snow_tab[num] = {abovenode, z, x, test} snow_tab[num] = {abovenode, z, x, test}
num = num+1 num = num+1
for y = ground_y, -6, -1 do -- make stone pillars out of trees
for y = ground_y, math.max(-6, minp.y-6), -1 do
local stone = area:index(x, y, z) local stone = area:index(x, y, z)
if data[stone] == c_stone then if data[stone] == c_stone then
break break
else end
data[stone] = c_stone data[stone] = c_stone
end end
end
else else
-- put snow onto leaves
snow_tab[num] = {abovenode, z, x, test} snow_tab[num] = {abovenode, z, x, test}
num = num+1 num = num+1
end end
elseif ground_y elseif c_ground == c_junglegrass then
and data[node] == c_junglegrass then
data[node] = c_dry_shrub data[node] = c_dry_shrub
elseif ground_y elseif c_ground == c_papyrus then
and data[node] == c_papyrus then snow_tab[num] = {abovenode, z, x, test}
for y = ground_y, ground_y-4, -1 do num = num+1
-- replace papyrus plants with snowblocks
local y = ground_y
for _ = 1,7 do
local vi = area:index(x, y, z) local vi = area:index(x, y, z)
if data[vi] == c_papyrus then if data[vi] == c_papyrus then
snow_tab[num] = {area:index(x, ground_y, z), z, x, test}
num = num+1
data[vi] = c_snow_block data[vi] = c_snow_block
y = y-1
else
break
end end
end end
elseif ground_y elseif c_ground == c_water then
and data[node] == c_water then
if not icesheet if not icesheet
and not icecave and not icecave
and not icehole then and not icehole then
local x1 = data[area:index(x+1, ground_y, z)] local nds = {
local z1 = data[area:index(x, ground_y, z+1)] data[area:index(x+1, ground_y, z)],
local xz1 = data[area:index(x+1, ground_y, z+1)] data[area:index(x, ground_y, z+1)],
local xz2 = data[area:index(x-1, ground_y, z-1)] data[area:index(x+1, ground_y, z+1)],
local x2 = data[area:index(x-1, ground_y, z)] data[area:index(x-1, ground_y, z-1)],
local z2 = data[area:index(x, ground_y, z-1)] data[area:index(x-1, ground_y, z)],
local rand = (pr:next(1,4) == 1) and (cool or icebergs) data[area:index(x, ground_y, z-1)],
}
local ice local ice
if rand then if pr:next(1,4) == 1
for _,i in ipairs({x1,z1,xz1,xz2,x2,z2}) do and (cool or icebergs) then
for _,i in ipairs(nds) do
if i == c_ice then if i == c_ice then
ice = true ice = true
break break
@ -265,7 +275,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
if not ice then if not ice then
for _,i in ipairs({x1,z1,xz1,xz2,x2,z2}) do for _,i in ipairs(nds) do
if i ~= c_water if i ~= c_water
and i ~= c_ice and i ~= c_ice
and i ~= c_air and i ~= c_air
@ -282,9 +292,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
data[node] = c_ice data[node] = c_ice
end end
else else
if (icehole and pr:next(1,10) > 1) if icesheet
or icecave or icecave
or icesheet then or (icehole and pr:next(1,10) > 1) then
data[node] = c_ice data[node] = c_ice
end end
if icecave then if icecave then
@ -292,10 +302,14 @@ minetest.register_on_generated(function(minp, maxp, seed)
local vi = area:index(x, y, z) local vi = area:index(x, y, z)
if data[vi] ~= c_water then if data[vi] ~= c_water then
break break
else end
data[vi] = c_air data[vi] = c_air
end end
end end
if icesheet then
-- put snow onto icesheets
snow_tab[num] = {abovenode, z, x, test}
num = num+1
end end
end end
end end
@ -310,28 +324,38 @@ minetest.register_on_generated(function(minp, maxp, seed)
local wsz, wsx local wsz, wsx
for _,i in pairs(snow_tab) do for _,i in pairs(snow_tab) do
local p,z,x,test = unpack(i) local p,z,x,test = unpack(i)
-- snow is set
data[p] = c_snow data[p] = c_snow
test = (test-0.73)/0.27 -- /(1-0.73) test = (test-0.73)/0.27 -- /(1-0.73)
if test > 0 then if test > 0 then
local maxh = math.floor(test*9)%9+1 local maxh = math.floor(test*10)%10+1
if maxh ~= 1 then if maxh ~= 1 then
if not wsz then if not wsz then
wsz = get_ws_list(5, z0) wsz = get_ws_list(5, z0)
wsx = get_ws_list(2, x0) wsx = get_ws_list(2, x0)
param2s = vm:get_param2_data()
end end
local h = math.floor(wsx[x]+wsz[z]*5)%9+1 local h = math.floor(wsx[x]+wsz[z]*5)%10+1
if h ~= 1 then if h ~= 1 then
if h == 9 then if h == 10 then
h = 4 -- make snowdrifts walkable
h = 5
end end
h = math.min(maxh, h) h = math.min(maxh, h)
if h == 9 then
-- replace the snow with a snowblock because its a full node
data[p] = c_snow_block
else
-- set a specific snow height
if not param2s then
param2s = vm:get_param2_data()
end
param2s[p] = h*7 param2s[p] = h*7
end end
end end
end end
end end
end end
end
vm:set_data(data) vm:set_data(data)
if param2s then if param2s then

View File

@ -98,7 +98,7 @@ local function leave_sled(self, player)
local name = player:get_player_name() local name = player:get_player_name()
players_sled[name] = false players_sled[name] = false
self.driver = nil self.driver = nil
player:set_detach() self.object:set_detach()
default.player_attached[name] = false default.player_attached[name] = false
default.player_set_animation(player, "stand" , 30) default.player_set_animation(player, "stand" , 30)