Add cursed island, improve deep ocean schem placing

This commit is contained in:
Juraj Vajda 2024-01-28 11:22:28 -05:00
parent 62ce3d9fde
commit 9c89429a52
8 changed files with 13375 additions and 15 deletions

File diff suppressed because it is too large Load Diff

25
chat_commands.lua Normal file
View File

@ -0,0 +1,25 @@
local S = minetest.get_translator(minetest.get_current_modname())
minetest.register_chatcommand('everness:getbiomename', {
description = S('Get biome name where you are standing.'),
params = '',
privs = { creative = true },
func = function(name, param)
local player = minetest.get_player_by_name(name)
if not player then
return false, S('This command can only be executed in-game!')
end
local p_pos = player:get_pos()
local biome_data = minetest.get_biome_data(p_pos)
if not biome_data then
return false
end
local biome_name = minetest.get_biome_name(biome_data.biome)
minetest.chat_send_player(name, 'Biome name: ' .. biome_name)
end,
})

View File

@ -214,9 +214,14 @@ if Everness.settings.features.everness_feature_sneak_pickup then
end
dofile(path .. '/privileges.lua')
dofile(path .. '/chat_commands.lua')
Everness:encyclopedia_init()
minetest.register_on_mods_loaded(function()
Everness.set_loot_chest_items()
end)
--
-- Mod Support
--
@ -245,11 +250,6 @@ end
-- Minetest Game
dofile(path .. '/mod_support_mtg.lua')
minetest.register_on_mods_loaded(function()
Everness.set_loot_chest_items()
end)
local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000
print('[Mod] everness loaded.. [' .. mod_end_time .. 's]')

View File

@ -15,6 +15,7 @@
--]]
-- Get the content IDs for the nodes used.
local c_water_source = minetest.get_content_id('mapgen_water_source')
local c_dirt_with_grass_1 = minetest.get_content_id('everness:dirt_with_grass_1')
local c_dirt_with_grass_extras_1 = minetest.get_content_id('everness:dirt_with_grass_extras_1')
local c_dirt_with_grass_extras_2 = minetest.get_content_id('everness:dirt_with_grass_extras_2')
@ -33,16 +34,20 @@ local c_frosted_snowblock = minetest.get_content_id('everness:frosted_snowblock'
local c_frosted_ice = minetest.get_content_id('everness:frosted_ice')
local c_everness_mineral_water_source = minetest.get_content_id('everness:mineral_water_source')
local c_everness_mineral_sand = minetest.get_content_id('everness:mineral_sand')
-- Biome IDs
local biome_id_everness_cursed_lands_dunes = minetest.get_biome_id('everness:cursed_lands_dunes')
local biome_id_everness_cursed_lands_swamp = minetest.get_biome_id('everness:cursed_lands_swamp')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
local chance = 15
local chance = 20
local disp = 16
local water_level = tonumber(minetest.settings:get('water_level'))
local water_level = tonumber(minetest.settings:get('water_level')) or 1
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
local biomemap = minetest.get_mapgen_object('biomemap')
-- Load the voxelmanip with the result of engine mapgen
local vm, emin, emax = minetest.get_mapgen_object('voxelmanip')
-- 'area' is used later to get the voxelmanip indexes for positions
@ -63,7 +68,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local s_pos = area:position(vi)
if maxp.y >= water_level then
-- Above sea level
-- Above sea level or at water level
if
(
data[vi] == c_dirt_with_grass_1
@ -219,7 +224,6 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
minetest.log('action', '[Everness] Jungle Temple was placed at ' .. schem_pos:to_string())
end
elseif
data[vi] == c_dirt_with_cursed_grass
and rand:next(0, 100) < chance
@ -588,6 +592,85 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
minetest.log('action', '[Everness] Mineral Waters Tower was placed at ' .. schem_pos:to_string())
end
elseif
water_level >= minp.y
and water_level <= maxp.y
and data[vi] == c_water_source
then
--
-- Water Level
--
if
(
table.indexof(biomemap, biome_id_everness_cursed_lands_dunes) ~= -1
or table.indexof(biomemap, biome_id_everness_cursed_lands_swamp) ~= -1
)
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_cursed_lands_deep_ocean_island.mts'
--
-- Cursed Lands Deep Ocean Island
--
local size = { x = 25, y = 23, z = 23 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
-- add Y displacement
local y_dis = 7
local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z)
-- find floor big enough
local indexes = Everness.find_content_in_vm_area(
vector.new(s_pos.x - size_x, s_pos.y - 1, s_pos.z - size_z),
vector.new(s_pos.x + size_x, s_pos.y + 1, s_pos.z + size_z),
{
c_water_source,
minetest.CONTENT_AIR
},
data,
area
)
if #indexes < size.x * size.z then
-- not enough space
return
end
-- enough space to place structure ?
local space_indexes = Everness.find_content_in_vm_area(
vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z),
{
c_water_source,
minetest.CONTENT_AIR
},
data,
area
)
if #space_indexes > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
schem_positions.everness_cursed_lands_deep_ocean_island = schem_positions.everness_cursed_lands_deep_ocean_island or {}
table.insert(schem_positions.everness_cursed_lands_deep_ocean_island, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y - y_dis, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y - y_dis + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Cursed Lands Deep Ocean Island was placed at ' .. schem_pos:to_string())
end
end
end
else
-- Under sea level (Caves)

View File

@ -336,7 +336,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_coral_forest_deep_ocean) ~= -1 then
if table.indexof(biomemap, biome_id_everness_coral_forest_deep_ocean) ~= -1 and rand:next(0, 100) < chance then
-- Load the voxelmanip with the result of engine mapgen
local vm, emin, emax = minetest.get_mapgen_object('voxelmanip')
-- 'area' is used later to get the voxelmanip indexes for positions
@ -354,7 +354,6 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
data[vi] == c_everness_coral_forest_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
and not schem_placed
and rand:next(0, 100) < chance
then
local s_pos = area:position(vi)

View File

@ -205,7 +205,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_crystal_forest_deep_ocean) ~= -1 then
if table.indexof(biomemap, biome_id_everness_crystal_forest_deep_ocean) ~= -1 and rand:next(0, 100) < chance then
-- Load the voxelmanip with the result of engine mapgen
local vm, emin, emax = minetest.get_mapgen_object('voxelmanip')
-- 'area' is used later to get the voxelmanip indexes for positions
@ -223,7 +223,6 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
data[vi] == c_everness_crystal_forest_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
and not schem_placed
and rand:next(0, 100) < chance
then
local s_pos = area:position(vi)

View File

@ -205,7 +205,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_cursed_lands_deep_ocean) ~= -1 then
if table.indexof(biomemap, biome_id_everness_cursed_lands_deep_ocean) ~= -1 and rand:next(0, 100) < chance then
-- Load the voxelmanip with the result of engine mapgen
local vm, emin, emax = minetest.get_mapgen_object('voxelmanip')
-- 'area' is used later to get the voxelmanip indexes for positions
@ -223,7 +223,6 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
data[vi] == c_everness_cursed_lands_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
and not schem_placed
and rand:next(0, 100) < chance
then
local s_pos = area:position(vi)

Binary file not shown.