Don't generate terrain before dungeon.
This commit is contained in:
parent
77a6129e00
commit
be7d7a1976
4 changed files with 65 additions and 20 deletions
7
abms.lua
7
abms.lua
|
@ -409,7 +409,6 @@ minetest.register_abm({
|
|||
------------------------------------------------------------
|
||||
|
||||
if fun_caves.dungeon_spawns and #fun_caves.dungeon_spawns > 0 then
|
||||
print('go monster')
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:dungeon_floor_1"},
|
||||
neighbors = {'air'},
|
||||
|
@ -471,7 +470,6 @@ if fun_caves.dungeon_spawns and #fun_caves.dungeon_spawns > 0 then
|
|||
})
|
||||
end
|
||||
|
||||
if false then
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:dungeon_floor_1"},
|
||||
neighbors = {'air'},
|
||||
|
@ -496,8 +494,8 @@ minetest.register_abm({
|
|||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:dungeon_wall_1"},
|
||||
neighbors = {'air'},
|
||||
interval = 4 * time_factor,
|
||||
chance = 250,
|
||||
interval = 25 * time_factor,
|
||||
chance = 2000,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
|
@ -533,7 +531,6 @@ minetest.register_abm({
|
|||
minetest.set_node(pos, {name = 'default:torch', param2 = p2})
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
-- This puts the burdon on fires, which shouldn't be happening much.
|
||||
minetest.register_abm({
|
||||
|
|
43
dungeon.lua
43
dungeon.lua
|
@ -196,7 +196,9 @@ newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|||
|
||||
local ready = meta:get_string('formspec')
|
||||
if treasures and ready == '' then
|
||||
meta:set_string("formspec", '0')
|
||||
if math.random(10) == 1 and fun_caves.dungeon_spawns and #fun_caves.dungeon_spawns > 0 then
|
||||
meta:set_string("formspec", '')
|
||||
minetest.remove_node(pos)
|
||||
|
||||
local desc = fun_caves.dungeon_spawns[math.random(#fun_caves.dungeon_spawns)]
|
||||
|
@ -205,7 +207,9 @@ newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|||
return
|
||||
end
|
||||
|
||||
local obj = minetest.add_entity(pos, desc.name)
|
||||
local mpos = table.copy(pos)
|
||||
mpos.y = mpos.y + 1
|
||||
local obj = minetest.add_entity(mpos, desc.name)
|
||||
if not obj then
|
||||
return
|
||||
end
|
||||
|
@ -234,8 +238,10 @@ newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|||
end
|
||||
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'You\'ve been poisoned!'))
|
||||
fun_caves.set_status(player_name, 'poisoned', 2 ^ math.random(8), {damage = 1})
|
||||
meta:set_string("formspec", '')
|
||||
return
|
||||
elseif minetest.get_modpath('tnt') and math.random(20) == 1 then
|
||||
meta:set_string("formspec", '')
|
||||
minetest.set_node(pos, {name = 'tnt:tnt_burning'})
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if timer then
|
||||
|
@ -536,7 +542,7 @@ fun_caves.dungeon = function(minp_in, maxp_in, data, p2data, area, node, heightm
|
|||
elseif ry == (cell_size - 1) and (cy < (cells_y - 1) or not centered_in) then
|
||||
data[ivm] = node['fun_caves:dungeon_floor_2']
|
||||
elseif content[cx][cy][cz] == 'room' then
|
||||
if math.random(1000) == 1 and data[ivm - area.ystride] == node['fun_caves:dungeon_floor_1'] then
|
||||
if ry == 1 and math.random(50) == 1 and data[ivm - area.ystride] == node['fun_caves:dungeon_floor_1'] then
|
||||
data[ivm] = node['fun_caves:coffer']
|
||||
else
|
||||
data[ivm] = node['air']
|
||||
|
@ -557,6 +563,39 @@ fun_caves.dungeon = function(minp_in, maxp_in, data, p2data, area, node, heightm
|
|||
end
|
||||
end
|
||||
|
||||
for z = minp.z + 1, maxp.z - 1 do
|
||||
for y = minp.y + 1, maxp.y - 1 do
|
||||
local ivm = area:index(minp.x + 1, y, z)
|
||||
for x = minp.x + 1, maxp.x - 1 do
|
||||
local height = (y - minp.y) % cell_size
|
||||
if data[ivm] == node['fun_caves:dungeon_wall_1'] and (x - minp.x) % 2 == 0 and (z - minp.z) % 2 == 0 and (height == 4 or (height == 2 and math.random(5) == 1)) then
|
||||
local dir = math.random(4)
|
||||
local ivm2 = ivm
|
||||
local p2 = 3
|
||||
if dir == 1 then
|
||||
ivm2 = ivm2 + 1
|
||||
elseif dir == 2 then
|
||||
ivm2 = ivm2 - 1
|
||||
p2 = 2
|
||||
elseif dir == 3 then
|
||||
ivm2 = ivm2 + area.zstride
|
||||
p2 = 5
|
||||
elseif dir == 4 then
|
||||
ivm2 = ivm2 - area.zstride
|
||||
p2 = 4
|
||||
end
|
||||
|
||||
if data[ivm2] == node['air'] then
|
||||
data[ivm2] = node['default:torch']
|
||||
p2data[ivm2] = p2
|
||||
end
|
||||
end
|
||||
|
||||
ivm = ivm + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i = 0, #data do
|
||||
if data[i] == 'stairway' then
|
||||
data[i] = node['air']
|
||||
|
|
26
mapgen.lua
26
mapgen.lua
|
@ -429,6 +429,16 @@ local function generate(p_minp, p_maxp, seed)
|
|||
break
|
||||
end
|
||||
|
||||
if not underzone and fun_caves.dungeon and not (fun_caves.is_tree and fun_caves.is_tree(minp)) then
|
||||
local write_dungeon, write_p4
|
||||
write_dungeon, write_p4 = fun_caves.dungeon(minp, maxp, data, p2data, area, node, heightmap)
|
||||
if write_dungeon then
|
||||
write = true
|
||||
write_p2 = write_p2 or write_p4
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local biomemap
|
||||
if fun_caves.cavegen and fun_caves.decogen then
|
||||
local h2, write_cave
|
||||
|
@ -455,16 +465,6 @@ local function generate(p_minp, p_maxp, seed)
|
|||
end
|
||||
end
|
||||
|
||||
if not underzone and fun_caves.dungeon then
|
||||
local write_dungeon, write_p4
|
||||
write_dungeon, write_p4 = fun_caves.dungeon(minp, maxp, data, p2data, area, node, heightmap)
|
||||
if write_dungeon then
|
||||
write = true
|
||||
write_p2 = write_p2 or write_p4
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if fun_caves.pyramid then
|
||||
local write_pyr, write_p4 = fun_caves.pyramid(minp, maxp, data, p2data, area, biomemap, biome_ids, node, heightmap)
|
||||
if write_pyr then
|
||||
|
@ -521,9 +521,9 @@ end
|
|||
|
||||
|
||||
local function pgenerate(...)
|
||||
--local status, err = pcall(generate, ...)
|
||||
local status, err = true
|
||||
generate(...)
|
||||
local status, err = pcall(generate, ...)
|
||||
--local status, err = true
|
||||
--generate(...)
|
||||
if not status then
|
||||
print('Fun Caves: Could not generate terrain:')
|
||||
print(dump(err))
|
||||
|
|
|
@ -287,6 +287,15 @@ local wood_noise = {offset = 0, scale = 1, seed = -4640, spread = {x = 32, y = 3
|
|||
--interest['fun_caves:tree_mineral'] = true
|
||||
|
||||
|
||||
fun_caves.is_tree = function(minp)
|
||||
local tree_n = minetest.get_perlin(tree_noise_1):get2d({x=math.floor((minp.x + 32) / 160) * 80, y=math.floor((minp.z + 32) / 160) * 80})
|
||||
if not tree_n or minp.y < -112 or minp.y > 208 or (not fun_caves.DEBUG and tree_n < 1.5) then
|
||||
return
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
fun_caves.treegen = function(minp, maxp, data, p2data, area, node)
|
||||
if not (minp and maxp and data and p2data and area and node and type(data) == 'table' and type(p2data) == 'table') then
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue