Improve loot chests and schematics placement

This commit is contained in:
Juraj Vajda 2024-01-27 17:27:14 -05:00
parent ef94b866ef
commit 9900db15f7
42 changed files with 6776 additions and 6694 deletions

69
api.lua
View File

@ -15,6 +15,7 @@
--]]
local S = minetest.get_translator(minetest.get_current_modname())
local rand_global = PcgRandom(tonumber(tostring(os.time()):reverse():sub(1, 9)))
--- Base class
---@class Everness
@ -1155,6 +1156,54 @@ function Everness.set_loot_chest_items()
Everness.loot_chest.default = table.copy(loot_items)
end
function Everness.populate_loot_chests(self, positions, loot_chest_items_group)
local _loot_chest_items_group = loot_chest_items_group or 'default'
-- Get inventories
local string_positions = '';
local inventories = {}
for i, pos in ipairs(positions) do
local chest_def = minetest.registered_nodes['everness:chest']
chest_def.on_construct(pos)
local inv = minetest.get_inventory({ type = 'node', pos = pos })
if inv then
table.insert(inventories, inv)
string_positions = string_positions .. ' ' .. pos:to_string()
else
minetest.log('action', '[Everness] FAILED to populate loot chests inventory at ' .. pos:to_string())
end
end
if #inventories > 0 then
for index, value in ipairs(inventories[1]:get_list('main')) do
local rand_idx = rand_global:next(1, #self.loot_chest[_loot_chest_items_group])
local item_def = self.loot_chest[_loot_chest_items_group][rand_idx]
if not minetest.registered_items[item_def.name] then
return
end
if rand_global:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand_global:next(1, 65535))
else
stack:set_count(rand_global:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
local rand_inv = inventories[rand_global:next(1, #inventories)]
rand_inv:set_stack('main', index, stack)
end
end
minetest.log('action', '[Everness] Loot chests inventory populated at ' .. string_positions)
end
end
--
-- Hammer
-- Modified version of default:tnt from MT
@ -2063,3 +2112,23 @@ function Everness.encyclopedia_sfinv_register_page(self)
end
})
end
function Everness.find_content_in_vm_area(minp, maxp, contentIds, data, area)
local indexes = {}
local id_count = {}
for y = minp.y, maxp.y do
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
local ai = area:index(x, y, z)
if table.indexof(contentIds, data[ai]) ~= -1 then
id_count[data[ai]] = (id_count[data[ai]] or 0) + 1
table.insert(indexes, ai)
end
end
end
end
return indexes, id_count
end

View File

@ -729,7 +729,7 @@ schematic = {
{name="air", prob=0, param2=0},
{name="everness:coral_deep_ocean_sandstone_block", prob=254, param2=0},
{name="everness:coral_deep_ocean_sandstone_block", prob=254, param2=0},
{name="everness:coral_forest_deep_ocean_house_marker", prob=254, param2=2},
{name="everness:chest", prob=254, param2=2},
{name="everness:coral_deep_ocean_sandstone_block", prob=254, param2=0},
{name="everness:coral_deep_ocean_sandstone_block", prob=254, param2=0},
{name="air", prob=0, param2=0},

View File

@ -704,7 +704,7 @@ schematic = {
{name="air", prob=0, param2=0},
{name="everness:crystal_forest_deep_ocean_sandstone_block", prob=254, param2=0},
{name="everness:crystal_forest_deep_ocean_sandstone_block", prob=254, param2=0},
{name="everness:crystal_forest_deep_ocean_ruins_marker", prob=254, param2=3},
{name="everness:chest", prob=254, param2=3},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
@ -815,7 +815,7 @@ schematic = {
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:crystal_forest_deep_ocean_sandstone_brick", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:chest", prob=254, param2=3},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},

View File

@ -596,7 +596,7 @@ schematic = {
{name="air", prob=0, param2=0},
{name="everness:bone", prob=254, param2=23},
{name="everness:bone", prob=254, param2=1},
{name="everness:cursed_lands_deep_ocean_skull_marker", prob=254, param2=3},
{name="everness:chest", prob=254, param2=3},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},

View File

@ -610,7 +610,7 @@ schematic = {
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:forsaken_desert_temple_marker", prob=254, param2=1},
{name="everness:chest", prob=254, param2=1},
{name="everness:forsaken_desert_brick", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},

File diff suppressed because it is too large Load Diff

View File

@ -2493,7 +2493,7 @@ schematic = {
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:frosted_icesheet_igloo_marker", prob=254, param2=0},
{name="everness:chest", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},

View File

@ -22,81 +22,81 @@ schematic = {
{ypos=18, prob=254},
},
data = {
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:frosted_icicle_large_ceiling_marker", prob=254, param2=2},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:marker", prob=254, param2=3},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
},
}

View File

@ -23,85 +23,85 @@ schematic = {
{ypos=19, prob=254},
},
data = {
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:frosted_cave_ice_illuminating", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:frosted_icicle_large_floor_marker", prob=254, param2=2},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="everness:marker", prob=254, param2=3},
{name="air", prob=0, param2=0},
},
}

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@ schematic = {
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -42,8 +43,7 @@ schematic = {
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -242,7 +242,7 @@ schematic = {
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -252,7 +252,7 @@ schematic = {
{name="air", prob=254, param2=0},
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:fence_bamboo_wood", prob=254, param2=0},
@ -451,6 +451,7 @@ schematic = {
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -460,8 +461,7 @@ schematic = {
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -660,6 +660,7 @@ schematic = {
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -669,8 +670,7 @@ schematic = {
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -869,7 +869,7 @@ schematic = {
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -879,7 +879,7 @@ schematic = {
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=0, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -2348,7 +2348,7 @@ schematic = {
{name="everness:forsaken_tundra_brick", prob=254, param2=0},
{name="everness:sequoia_tree", prob=254, param2=2},
{name="air", prob=254, param2=0},
{name="everness:japanese_shrine_lootchest_marker", prob=254, param2=0},
{name="everness:chest", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:sequoia_tree", prob=254, param2=3},
{name="everness:forsaken_tundra_brick", prob=254, param2=0},

View File

@ -536,7 +536,7 @@ schematic = {
{name="everness:crystal_mossy_cobble", prob=254, param2=0},
{name="everness:crystal_mossy_cobble", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:jungle_temple_lootchest_marker", prob=254, param2=3},
{name="everness:chest", prob=254, param2=3},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
@ -1711,7 +1711,7 @@ schematic = {
{name="everness:crystal_cobble", prob=254, param2=0},
{name="everness:crystal_mossy_cobble", prob=254, param2=0},
{name="everness:crystal_cobble", prob=254, param2=0},
{name="everness:jungle_temple_lootchest_marker", prob=254, param2=0},
{name="everness:chest", prob=254, param2=0},
{name="everness:crystal_mossy_cobble", prob=254, param2=0},
{name="everness:crystal_cobble", prob=254, param2=0},
{name="air", prob=254, param2=0},

View File

@ -336,7 +336,7 @@ schematic = {
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:mineral_sandstone_brick", prob=254, param2=0},
{name="everness:mineral_waters_tower_marker", prob=254, param2=3},
{name="everness:chest", prob=254, param2=3},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:mineral_sandstone_brick", prob=254, param2=0},
@ -504,7 +504,7 @@ schematic = {
{name="air", prob=0, param2=0},
{name="air", prob=0, param2=0},
{name="everness:mineral_sandstone_brick", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:chest", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="air", prob=254, param2=0},
{name="everness:mineral_sandstone_brick", prob=254, param2=0},

File diff suppressed because it is too large Load Diff

View File

@ -202,7 +202,6 @@ end
dofile(path .. '/tools.lua')
dofile(path .. '/craftitems.lua')
dofile(path .. '/crafting.lua')
dofile(path .. '/loot_chests.lua')
if Everness.settings.features.everness_feature_skybox then
dofile(path .. '/skybox.lua')

View File

@ -1,277 +0,0 @@
--[[
Everness. Never ending discovery in Everness mapgen.
Copyright (C) 2024 SaKeL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
--]]
Everness:register_lbm({
label = 'Replace markers with loot chests',
name = 'everness:loot_chests_marker_replace',
nodenames = {
'everness:japanese_shrine_lootchest_marker',
'everness:jungle_temple_lootchest_marker',
'everness:haunted_house_lootchest_marker',
'everness:quartz_temple_lootchest_marker',
'everness:forsaken_desert_temple_marker',
'everness:forsaken_desert_temple_2_marker',
'everness:coral_forest_deep_ocean_house_marker',
'everness:cursed_lands_deep_ocean_skull_marker',
'everness:frosted_icesheet_igloo_marker',
'everness:crystal_forest_deep_ocean_ruins_marker',
'everness:mineral_waters_tower_marker'
},
run_at_every_load = true,
action = function(pos, node)
minetest.set_node(pos, { name = 'everness:chest', param2 = minetest.get_node(pos).param2 })
local rand = PcgRandom(pos.x * pos.y * pos.z)
local inv = minetest.get_inventory({ type = 'node', pos = pos })
for index, value in ipairs(inv:get_list('main')) do
if node.name == 'everness:japanese_shrine_lootchest_marker' then
--
-- Japanese Shrine
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:jungle_temple_lootchest_marker' then
--
-- Jungle Temple
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:haunted_house_lootchest_marker' then
--
-- Haunted House
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:quartz_temple_lootchest_marker' then
--
-- Quartz Temple
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:forsaken_desert_temple_marker' then
--
-- Forsaken Desert Temple
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:forsaken_desert_temple_2_marker' then
--
-- Forsaken Desert Temple 2 (under)
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:coral_forest_deep_ocean_house_marker' then
--
-- Deep Ocean House
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:cursed_lands_deep_ocean_skull_marker' then
--
-- Deep Ocean Skull
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:frosted_icesheet_igloo_marker' then
--
-- Igloo
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:crystal_forest_deep_ocean_ruins_marker' then
--
-- Crystal Forest Deep Ocean Ruins
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
elseif node.name == 'everness:mineral_waters_tower_marker' then
--
-- Mineral Waters Tower
--
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
end
end
minetest.log('action', '[Everness] Loot chests inventory populated at ' .. pos:to_string())
end,
})

View File

@ -16,6 +16,8 @@
-- Get the content IDs for the nodes used.
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')
local c_dirt_with_rainforest_litter = minetest.get_content_id('default:dirt_with_rainforest_litter')
local c_dirt_with_cursed_grass = minetest.get_content_id('everness:dirt_with_cursed_grass')
local c_dirt_with_crystal_grass = minetest.get_content_id('everness:dirt_with_crystal_grass')
@ -32,7 +34,6 @@ 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')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
@ -53,52 +54,74 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local sidelength = maxp.x - minp.x + 1
local x_disp = rand:next(0, disp)
local z_disp = rand:next(0, disp)
if maxp.y >= water_level then
-- Above sea level
local schem_positions = {}
for y = minp.y, maxp.y do
local vi = area:index(minp.x + sidelength / 2 + x_disp, y, minp.z + sidelength / 2 + z_disp)
if data[vi + area.ystride] == minetest.CONTENT_AIR
and (
data[vi] == c_dirt_with_grass_1
or data[vi] == c_dirt_with_rainforest_litter
or data[vi] == c_dirt_with_cursed_grass
or data[vi] == c_dirt_with_crystal_grass
or data[vi] == c_crystal_sand
or data[vi] == c_forsaken_desert_sand
or data[vi] == c_dry_ocean_dirt
or data[vi] == c_dirt_with_snow
or data[vi] == c_dirt_with_coniferous_litter
or data[vi] == c_frosted_snowblock
or data[vi] == c_frosted_ice
or data[vi] == c_everness_mineral_water_source
or data[vi] == c_everness_mineral_sand
)
then
if data[vi + area.ystride] == minetest.CONTENT_AIR then
local s_pos = area:position(vi)
local biome_data = minetest.get_biome_data(s_pos)
if not biome_data then
return
end
local biome_name = minetest.get_biome_name(biome_data.biome)
if not biome_name then
return
end
if biome_name == 'everness:bamboo_forest' and rand:next(0, 100) < chance then
if maxp.y >= water_level then
-- Above sea level
if
(
data[vi] == c_dirt_with_grass_1
or data[vi] == c_dirt_with_grass_extras_1
or data[vi] == c_dirt_with_grass_extras_2
)
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_japanese_shrine.mts'
--
-- Japanese Shrine
--
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local size = { x = 11, y = 19, z = 15 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local schem_pos = vector.new(s_pos)
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
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),
{
'everness:dirt_with_grass_1'
}
)
-- Can force over these blocks
local force_positions = minetest.find_nodes_in_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),
{
'everness:dirt_with_grass_extras_1',
'everness:dirt_with_grass_extras_2',
'group:bamboo',
'group:flower',
'group:leaves'
}
)
if #positions + #force_positions < size.x * size.z then
-- not enough space
return
end
-- enough air to place structure ?
local air_positions = minetest.find_nodes_in_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),
{
'air',
'group:bamboo',
'group:flower',
'group:leaves'
}
)
if #air_positions > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
@ -109,17 +132,73 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'place_center_x, place_center_z'
)
schem_positions.everness_japanese_shrine = schem_positions.everness_japanese_shrine or {}
table.insert(schem_positions.everness_japanese_shrine, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Japanese Shrine was placed at ' .. schem_pos:to_string())
elseif biome_name == 'rainforest' and rand:next(0, 100) < chance then
end
elseif
data[vi] == c_dirt_with_rainforest_litter
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_jungle_temple.mts'
--
-- Jungle Temple
--
local size = { x = 12, y = 14, z = 15 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
-- add Y displacement
local schem_pos = vector.new(s_pos.x, s_pos.y - 3, s_pos.z)
local y_dis = 3
local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z)
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
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),
{
'default:dirt_with_rainforest_litter'
}
)
-- Can force over these blocks
local force_positions = minetest.find_nodes_in_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),
{
'group:tree',
'group:flower',
'group:flora',
'group:leaves',
'fireflies:firefly',
'fireflies:hidden_firefly',
}
)
if #positions + #force_positions < size.x * size.z then
-- not enough space
return
end
-- enough air to place structure ?
local air_positions = minetest.find_nodes_in_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),
{
'air',
'group:tree',
'group:flora',
'group:leaves'
}
)
if #air_positions > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
@ -130,17 +209,58 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'place_center_x, place_center_z'
)
schem_positions.everness_jungle_temple = schem_positions.everness_jungle_temple or {}
table.insert(schem_positions.everness_jungle_temple, {
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] Jungle Temple was placed at ' .. schem_pos:to_string())
elseif biome_name == 'everness:cursed_lands' and rand:next(0, 100) < chance then
end
elseif
data[vi] == c_dirt_with_cursed_grass
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_haunted_house.mts'
--
-- Haunted House
--
local size = { x = 11, y = 22, z = 10 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
-- add Y displacement
local schem_pos = vector.new(s_pos.x, s_pos.y - 1, s_pos.z)
local y_dis = 1
local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z)
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
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),
{
'everness:dirt_with_cursed_grass'
}
)
if #positions < size.x * size.z then
-- not enough space
return
end
-- enough air to place structure ?
local air_positions = minetest.find_nodes_in_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),
{
'air'
}
)
if #air_positions > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
@ -151,17 +271,59 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'place_center_x, place_center_z'
)
schem_positions.everness_haunted_house = schem_positions.everness_haunted_house or {}
table.insert(schem_positions.everness_haunted_house, {
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] Haunted House was placed at ' .. schem_pos:to_string())
elseif biome_name == 'everness:crystal_forest' and rand:next(0, 100) < chance then
end
elseif
(
data[vi] == c_dirt_with_crystal_grass
or data[vi] == c_crystal_sand
)
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_quartz_temple.mts'
--
-- Quartz Temple
--
-- add Y displacement
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local size = { x = 16, y = 13, z = 16 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local schem_pos = vector.new(s_pos)
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
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),
{
'everness:dirt_with_crystal_grass',
'everness:crystal_sand'
}
)
if #positions < size.x * size.z then
-- not enough space
return
end
-- enough air to place structure ?
local air_positions = minetest.find_nodes_in_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),
{
'air'
}
)
if #air_positions > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
@ -172,8 +334,22 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'place_center_x, place_center_z'
)
schem_positions.everness_quartz_temple = schem_positions.everness_quartz_temple or {}
table.insert(schem_positions.everness_quartz_temple, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Quartz Temple was placed at ' .. schem_pos:to_string())
elseif (biome_name == 'everness:forsaken_desert' or biome_name == 'everness:forsaken_desert_ocean')
end
elseif
(
data[vi] == c_forsaken_desert_sand
or data[vi] == c_dry_ocean_dirt
)
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_forsaken_desert_temple.mts'
@ -182,9 +358,36 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
-- Forsaken Desert Temple
--
-- add Y displacement
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local size = { x = 9, y = 16, z = 9 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local schem_pos = vector.new(s_pos)
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
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),
{
'everness:forsaken_desert_sand',
'everness:dry_ocean_dirt'
}
)
if #positions < size.x * size.z then
-- not enough space
return
end
-- enough air to place structure ?
local air_positions = minetest.find_nodes_in_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),
{
'air'
}
)
if #air_positions > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
@ -195,8 +398,21 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'place_center_x, place_center_z'
)
schem_positions.everness_forsaken_desert_temple = schem_positions.everness_forsaken_desert_temple or {}
table.insert(schem_positions.everness_forsaken_desert_temple, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Forsaken Desert Temple was placed at ' .. schem_pos:to_string())
elseif (biome_name == 'coniferous_forest' or biome_name == 'taiga' or biome_name == 'MegaSpruceTaiga')
end
elseif
(
data[vi] == c_dirt_with_snow
or data[vi] == c_dirt_with_coniferous_litter
)
and rand:next(0, 100) < 100
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_giant_sequoia_tree.mts'
@ -205,27 +421,30 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
-- Giant Sequoia
--
-- add Y displacement
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local size = { x = 25, y = 75, z = 25 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local schem_pos = vector.new(s_pos)
minetest.emerge_area(
vector.new(s_pos.x - 12, s_pos.y, s_pos.z - 12),
vector.new(s_pos.x + 12, s_pos.y + 75, s_pos.z + 12),
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),
function(blockpos, action, calls_remaining, param)
Everness:emerge_area(blockpos, action, calls_remaining, param)
end,
{
callback = function()
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
vector.new(s_pos.x - 6, s_pos.y - 1, s_pos.z - 6),
vector.new(s_pos.x + 6, s_pos.y + 1, s_pos.z + 6),
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),
{
'default:dirt_with_snow',
'default:dirt_with_coniferous_litter',
'default:snow'
})
if #positions < 137 then
if #positions < size.x * size.z then
-- not enough space
return
end
@ -243,7 +462,11 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end
}
)
elseif (biome_name == 'everness:frosted_icesheet' or biome_name == 'everness:frosted_icesheet_ocean')
elseif
(
data[vi] == c_frosted_snowblock
or data[vi] == c_frosted_ice
)
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_frosted_icesheet_igloo.mts'
@ -252,9 +475,38 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
-- Igloo
--
local size = { x = 16, y = 13, z = 16 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
-- add Y displacement
local schem_pos = vector.new(s_pos.x, s_pos.y - 8, s_pos.z)
local y_dis = 8
local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z)
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
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),
{
'everness:frosted_snowblock',
'everness:frosted_ice'
}
)
if #positions < size.x * size.z then
-- not enough space
return
end
-- enough air to place structure ?
local air_positions = minetest.find_nodes_in_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),
{
'air'
}
)
if #air_positions > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
@ -265,8 +517,21 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'place_center_x, place_center_z'
)
schem_positions.everness_frosted_icesheet_igloo = schem_positions.everness_frosted_icesheet_igloo or {}
table.insert(schem_positions.everness_frosted_icesheet_igloo, {
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] Igloo was placed at ' .. schem_pos:to_string())
elseif biome_name == 'everness:mineral_waters'
end
elseif
(
data[vi] == c_everness_mineral_water_source
or data[vi] == c_everness_mineral_sand
)
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_mineral_waters_tower.mts'
@ -278,7 +543,6 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local size = { x = 7, y = 16, z = 9 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
-- add Y displacement
local schem_pos = vector.new(s_pos)
-- find floor big enough
@ -288,7 +552,8 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
{
'everness:mineral_sand',
'everness:mineral_water_source'
})
}
)
if #positions < size.x * size.z then
-- not enough space
@ -299,9 +564,10 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local air_positions = minetest.find_nodes_in_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),
'air', true)
{ 'air' }
)
if air_positions.air and #air_positions.air > (size.x * size.y * size.z) / 2 then
if #air_positions > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
@ -312,63 +578,51 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'place_center_x, place_center_z'
)
schem_positions.everness_mineral_waters_tower = schem_positions.everness_mineral_waters_tower or {}
table.insert(schem_positions.everness_mineral_waters_tower, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Mineral Waters Tower was placed at ' .. schem_pos:to_string())
end
end
end
end
vm:write_to_map(true)
minetest.fix_light(minp, maxp)
else
-- Under sea level
for y = minp.y, maxp.y do
local vi = area:index(minp.x + sidelength / 2 + x_disp, y, minp.z + sidelength / 2 + z_disp)
if data[vi + area.ystride] == minetest.CONTENT_AIR
and (
data[vi] == c_dirt_with_grass_1
or data[vi] == c_forsaken_desert_sand
-- Under sea level (Caves)
if
(
data[vi] == c_forsaken_desert_sand
or data[vi] == c_forsaken_desert_chiseled_stone
or data[vi] == c_forsaken_desert_brick
or data[vi] == c_forsaken_desert_engraved_stone
)
and rand:next(0, 100) < chance
then
local s_pos = area:position(vi)
local biome_data = minetest.get_biome_data(s_pos)
if not biome_data then
return
end
local biome_name = minetest.get_biome_name(biome_data.biome)
if not biome_name then
return
end
if biome_name == 'everness:forsaken_desert_under' and rand:next(0, 100) < chance then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_forsaken_desert_temple_2.mts'
--
-- Forsaken Desert Temple 2
--
-- add Y displacement
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local size = { x = 16, y = 17, z = 15 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local schem_pos = vector.new(s_pos)
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
vector.new(s_pos.x - 7, s_pos.y - 1, s_pos.z - 7),
vector.new(s_pos.x + 7, s_pos.y + 1, s_pos.z + 7),
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),
{
'everness:forsaken_desert_sand',
'everness:forsaken_desert_chiseled_stone',
'everness:forsaken_desert_brick',
'everness:forsaken_desert_engraved_stone',
'default:stone',
'default:sand',
'group:stone',
'group:sand',
'group:everness_sand',
'default:gravel',
'default:stone_with_coal',
'default:stone_with_iron',
@ -378,21 +632,27 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'default:stone_with_diamond',
'everness:cave_barrel_cactus',
'everness:venus_trap',
'everness:illumi_root',
})
'group:flora',
'everness:quartz_ore',
'everness:stone_with_pyrite',
}
)
if #positions < 49 then
if #positions < size.x * size.z then
-- not enough space
return
end
-- enough air to place structure ?
local air_positions = minetest.find_nodes_in_area(
vector.new(s_pos.x - 7, s_pos.y, s_pos.z - 7),
vector.new(s_pos.x + 7, s_pos.y + 17, s_pos.z + 7),
'air', true)
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),
{
'air'
}
)
if air_positions.air and #air_positions.air > (16 * 15 * 16) / 2 then
if #air_positions > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
@ -403,13 +663,45 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
'place_center_x, place_center_z'
)
schem_positions.everness_forsaken_desert_temple_2 = schem_positions.everness_forsaken_desert_temple_2 or {}
table.insert(schem_positions.everness_forsaken_desert_temple_2, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Forsaken Desert Temple 2 was placed at ' .. schem_pos:to_string())
end
end
end
end
end
vm:write_to_map(true)
-- Set the lighting within the `VoxelManip` to a uniform value
vm:set_lighting({ day = 0, night = 0 }, minp, maxp)
-- Calculate lighting for what has been created.
vm:calc_lighting()
-- Liquid nodes were placed so set them flowing.
vm:update_liquids()
-- Write what has been created to the world.
vm:write_to_map()
minetest.fix_light(minp, maxp)
-- Populate loot chests
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
local chest_positions = minetest.find_nodes_in_area(
v.minp,
v.maxp,
{ 'everness:chest' }
)
if #chest_positions > 0 then
Everness:populate_loot_chests(chest_positions)
end
end
end
end
end)

View File

@ -94,7 +94,7 @@ Everness:register_decoration({
deco_type = 'simple',
place_on = { 'everness:moss_block' },
sidelen = 16,
fill_ratio = 0.05,
fill_ratio = 0.07,
decoration = {
'everness:vine_cave',
'everness:vine_cave_with_mese_leaves'

View File

@ -309,100 +309,148 @@ Everness:register_decoration({
-- On Generated
--
local c_water_source = minetest.get_content_id('default:water_source')
local c_coral_forest_deep_ocean_sand = minetest.get_content_id('everness:coral_forest_deep_ocean_sand')
local c_water_source = minetest.get_content_id('mapgen_water_source')
local c_everness_coral_forest_deep_ocean_sand = minetest.get_content_id('everness:coral_forest_deep_ocean_sand')
local c_everness_coral_forest_deep_ocean_coral_plant_1 = minetest.get_content_id('everness:coral_forest_deep_ocean_coral_plant_1')
local c_everness_coral_forest_deep_ocean_coral_plant_2 = minetest.get_content_id('everness:coral_forest_deep_ocean_coral_plant_2')
local c_everness_coral_forest_deep_ocean_coral_plant_3 = minetest.get_content_id('everness:coral_forest_deep_ocean_coral_plant_3')
local c_everness_coral_forest_deep_ocean_coral_1 = minetest.get_content_id('everness:coral_forest_deep_ocean_coral_1')
local c_everness_coral_forest_deep_ocean_coral_2 = minetest.get_content_id('everness:coral_forest_deep_ocean_coral_2')
local c_everness_coral_forest_deep_ocean_coral_3 = minetest.get_content_id('everness:coral_forest_deep_ocean_coral_3')
local c_everness_coral_forest_deep_ocean_coral_4 = minetest.get_content_id('everness:coral_forest_deep_ocean_coral_4')
-- Biome IDs
local biome_id_everness_coral_forest_deep_ocean = minetest.get_biome_id('everness:coral_forest_deep_ocean')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
local chance = 25
-- size = { x = 11, y = 17, z = 12 }
local house_volume = 11 * 17 * 12
local house_schem = minetest.get_modpath('everness') .. '/schematics/everness_coral_forest_deep_ocean_house.mts'
local schem = minetest.get_modpath('everness') .. '/schematics/everness_coral_forest_deep_ocean_house.mts'
local size = { x = 11, y = 17, z = 12 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
local biomemap = minetest.get_mapgen_object('biomemap')
local schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_coral_forest_deep_ocean) ~= -1 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
local area = VoxelArea:new({ MinEdge = emin, MaxEdge = emax })
-- Get the content ID data from the voxelmanip in the form of a flat array.
-- Set the buffer parameter to use and reuse 'data' for this.
vm:get_data(data)
if y_min < maxp.y and maxp.y < y_max then
local already_placed = false
-- Process the content IDs in 'data'.
-- The most useful order is a ZYX loop because:
-- 1. This matches the order of the 3D noise flat array.
-- 2. This allows a simple +1 incrementing of the voxelmanip index along x
-- rows.
for y = maxp.y, minp.y, -1 do
for z = minp.z, maxp.z do
if already_placed then
break
end
for y = minp.y, maxp.y do
if already_placed then
break
end
for x = minp.x, maxp.x do
if already_placed then
break
end
-- Voxelmanip index for the flat array of content IDs.
-- Initialise to first node in this x row.
local vi = area:index(x, y, z)
if data[vi + area.ystride] == c_water_source and data[vi] == c_coral_forest_deep_ocean_sand then
if
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)
local biome_data = minetest.get_biome_data(s_pos)
if not biome_data then
return
end
local biome_name = minetest.get_biome_name(biome_data.biome)
if not biome_name then
return
end
if biome_name == 'everness:coral_forest_deep_ocean' and rand:next(0, 100) < chance then
--
-- Coral Forest Deep Ocean House
--
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local water_source_positions = minetest.find_nodes_in_area(
vector.new(s_pos.x - 5, s_pos.y, s_pos.z - 6),
vector.new(s_pos.x + 5, s_pos.y + 17, s_pos.z + 6),
{ 'default:water_source' }
local schem_pos = vector.new(s_pos)
-- 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_everness_coral_forest_deep_ocean_sand,
c_everness_coral_forest_deep_ocean_coral_plant_1,
c_everness_coral_forest_deep_ocean_coral_plant_2,
c_everness_coral_forest_deep_ocean_coral_plant_3,
c_everness_coral_forest_deep_ocean_coral_1,
c_everness_coral_forest_deep_ocean_coral_2,
c_everness_coral_forest_deep_ocean_coral_3,
c_everness_coral_forest_deep_ocean_coral_4
},
data,
area
)
if #water_source_positions > (house_volume - house_volume / 3) then
if #indexes < size.x * size.z then
-- not enough space
return
end
-- enough water to place structure ?
local water_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
},
data,
area
)
if #water_indexes > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
house_schem,
schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
schem_placed = true
schem_positions.everness_coral_forest_deep_ocean_house = schem_positions.everness_coral_forest_deep_ocean_house or {}
table.insert(schem_positions.everness_coral_forest_deep_ocean_house, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Coral Forest Deep Ocean House was placed at ' .. schem_pos:to_string())
already_placed = true
end
end
end
end
end
end
vm:write_to_map(true)
-- Set the lighting within the `VoxelManip` to a uniform value
vm:set_lighting({ day = 0, night = 0 }, minp, maxp)
-- Calculate lighting for what has been created.
vm:calc_lighting()
-- Liquid nodes were placed so set them flowing.
vm:update_liquids()
-- Write what has been created to the world.
vm:write_to_map()
minetest.fix_light(minp, maxp)
-- Populate loot chests
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
local chest_positions = minetest.find_nodes_in_area(
v.minp,
v.maxp,
{ 'everness:chest' }
)
if #chest_positions > 0 then
Everness:populate_loot_chests(chest_positions)
end
end
end
end
end
end)

View File

@ -171,7 +171,7 @@ Everness:register_decoration({
deco_type = 'simple',
place_on = { 'everness:moss_block' },
sidelen = 16,
fill_ratio = 0.05,
fill_ratio = 0.07,
biomes = { 'everness:coral_forest_under' },
param2 = 8,
decoration = {

View File

@ -179,99 +179,146 @@ Everness:register_decoration({
-- On Generated
--
local c_water_source = minetest.get_content_id('default:water_source')
local c_crystal_forest_deep_ocean_sand = minetest.get_content_id('everness:crystal_forest_deep_ocean_sand')
local c_water_source = minetest.get_content_id('mapgen_water_source')
local c_everness_crystal_forest_deep_ocean_sand = minetest.get_content_id('everness:crystal_forest_deep_ocean_sand')
local c_everness_crystal_forest_deep_ocean_coral_plant_1 = minetest.get_content_id('everness:crystal_forest_deep_ocean_coral_plant_1')
local c_everness_crystal_forest_deep_ocean_coral_plant_2 = minetest.get_content_id('everness:crystal_forest_deep_ocean_coral_plant_2')
local c_everness_crystal_forest_deep_ocean_coral_plant_3 = minetest.get_content_id('everness:crystal_forest_deep_ocean_coral_plant_3')
local c_everness_crystal_forest_deep_ocean_coral_1 = minetest.get_content_id('everness:crystal_forest_deep_ocean_coral_1')
local c_everness_crystal_forest_deep_ocean_coral_2 = minetest.get_content_id('everness:crystal_forest_deep_ocean_coral_2')
local c_everness_crystal_forest_deep_ocean_coral_3 = minetest.get_content_id('everness:crystal_forest_deep_ocean_coral_3')
-- Biome IDs
local biome_id_everness_crystal_forest_deep_ocean = minetest.get_biome_id('everness:crystal_forest_deep_ocean')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
local chance = 25
local ruins_size = { x = 14, y = 12, z = 9 }
local ruins_volume = ruins_size.x * ruins_size.z * ruins_size.y
local ruins_schem = minetest.get_modpath('everness') .. '/schematics/everness_crystal_forest_deep_ocean_ruins.mts'
local schem = minetest.get_modpath('everness') .. '/schematics/everness_crystal_forest_deep_ocean_ruins.mts'
local size = { x = 14, y = 12, z = 9 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
local biomemap = minetest.get_mapgen_object('biomemap')
local schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_crystal_forest_deep_ocean) ~= -1 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
local area = VoxelArea:new({ MinEdge = emin, MaxEdge = emax })
-- Get the content ID data from the voxelmanip in the form of a flat array.
-- Set the buffer parameter to use and reuse 'data' for this.
vm:get_data(data)
if y_min < maxp.y and maxp.y < y_max then
local already_placed = false
-- Process the content IDs in 'data'.
-- The most useful order is a ZYX loop because:
-- 1. This matches the order of the 3D noise flat array.
-- 2. This allows a simple +1 incrementing of the voxelmanip index along x
-- rows.
for y = maxp.y, minp.y, -1 do
for z = minp.z, maxp.z do
if already_placed then
break
end
for y = minp.y, maxp.y do
if already_placed then
break
end
for x = minp.x, maxp.x do
if already_placed then
break
end
-- Voxelmanip index for the flat array of content IDs.
-- Initialise to first node in this x row.
local vi = area:index(x, y, z)
if data[vi + area.ystride] == c_water_source and data[vi] == c_crystal_forest_deep_ocean_sand then
if
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)
local biome_data = minetest.get_biome_data(s_pos)
if not biome_data then
return
end
local biome_name = minetest.get_biome_name(biome_data.biome)
if not biome_name then
return
end
if biome_name == 'everness:crystal_forest_deep_ocean' and rand:next(0, 100) < chance then
--
-- Crystal Forest Deep Ocean Ruins
--
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local water_source_positions = minetest.find_nodes_in_area(
vector.new(s_pos.x - (ruins_size.x / 2), s_pos.y, s_pos.z - (ruins_size.z / 2)),
vector.new(s_pos.x + (ruins_size.x / 2), s_pos.y + ruins_size.y, s_pos.z + (ruins_size.z / 2)),
{ 'default:water_source' }
local schem_pos = vector.new(s_pos)
-- 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_everness_crystal_forest_deep_ocean_sand,
c_everness_crystal_forest_deep_ocean_coral_plant_1,
c_everness_crystal_forest_deep_ocean_coral_plant_2,
c_everness_crystal_forest_deep_ocean_coral_plant_3,
c_everness_crystal_forest_deep_ocean_coral_1,
c_everness_crystal_forest_deep_ocean_coral_2,
c_everness_crystal_forest_deep_ocean_coral_3
},
data,
area
)
if #water_source_positions > (ruins_volume - ruins_volume / 3) then
if #indexes < size.x * size.z then
-- not enough space
return
end
-- enough water to place structure ?
local water_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
},
data,
area
)
if #water_indexes > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
ruins_schem,
schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
minetest.log('action', '[Everness] Crystal Forest Deep Ocean Ruins were placed at ' .. schem_pos:to_string())
schem_placed = true
already_placed = true
end
schem_positions.everness_crystal_forest_deep_ocean_ruins = schem_positions.everness_crystal_forest_deep_ocean_ruins or {}
table.insert(schem_positions.everness_crystal_forest_deep_ocean_ruins, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Crystal Forest Deep Ocean Ruins was placed at ' .. schem_pos:to_string())
end
end
end
end
end
vm:write_to_map(true)
-- Set the lighting within the `VoxelManip` to a uniform value
vm:set_lighting({ day = 0, night = 0 }, minp, maxp)
-- Calculate lighting for what has been created.
vm:calc_lighting()
-- Liquid nodes were placed so set them flowing.
vm:update_liquids()
-- Write what has been created to the world.
vm:write_to_map()
minetest.fix_light(minp, maxp)
-- Populate loot chests
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
local chest_positions = minetest.find_nodes_in_area(
v.minp,
v.maxp,
{ 'everness:chest' }
)
if #chest_positions > 0 then
Everness:populate_loot_chests(chest_positions)
end
end
end
end
end
end)

View File

@ -76,7 +76,7 @@ Everness:register_decoration({
deco_type = 'simple',
place_on = { 'everness:crystal_moss_block' },
sidelen = 16,
fill_ratio = 0.05,
fill_ratio = 0.07,
biomes = { 'everness:crystal_forest_under' },
param2 = 8,
decoration = {

View File

@ -179,100 +179,146 @@ Everness:register_decoration({
-- On Generated
--
local c_water_source = minetest.get_content_id('default:water_source')
local c_cursed_lands_deep_ocean_sand = minetest.get_content_id('everness:cursed_lands_deep_ocean_sand')
local c_water_source = minetest.get_content_id('mapgen_water_source')
local c_everness_cursed_lands_deep_ocean_sand = minetest.get_content_id('everness:cursed_lands_deep_ocean_sand')
local c_everness_cursed_lands_deep_ocean_coral_plant_anemone = minetest.get_content_id('everness:cursed_lands_deep_ocean_coral_plant_anemone')
local c_everness_cursed_lands_deep_ocean_coral_plant_darkilluma = minetest.get_content_id('everness:cursed_lands_deep_ocean_coral_plant_darkilluma')
local c_everness_cursed_lands_deep_ocean_coral_plant_demon = minetest.get_content_id('everness:cursed_lands_deep_ocean_coral_plant_demon')
local c_everness_cursed_lands_deep_ocean_coral_alcyonacea = minetest.get_content_id('everness:cursed_lands_deep_ocean_coral_alcyonacea')
local c_everness_cursed_lands_deep_ocean_coral_ostracod = minetest.get_content_id('everness:cursed_lands_deep_ocean_coral_ostracod')
local c_everness_cursed_lands_deep_ocean_coral_octocurse = minetest.get_content_id('everness:cursed_lands_deep_ocean_coral_octocurse')
-- Biome IDs
local biome_id_everness_cursed_lands_deep_ocean = minetest.get_biome_id('everness:cursed_lands_deep_ocean')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
local chance = 25
local skull_size = { x = 10, y = 11, z = 11 }
local skull_volume = skull_size.x * skull_size.z * skull_size.y
local skull_schem = minetest.get_modpath('everness') .. '/schematics/everness_cursed_lands_deep_ocean_skull.mts'
local schem = minetest.get_modpath('everness') .. '/schematics/everness_cursed_lands_deep_ocean_skull.mts'
local size = { x = 10, y = 11, z = 11 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
local biomemap = minetest.get_mapgen_object('biomemap')
local schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_cursed_lands_deep_ocean) ~= -1 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
local area = VoxelArea:new({ MinEdge = emin, MaxEdge = emax })
-- Get the content ID data from the voxelmanip in the form of a flat array.
-- Set the buffer parameter to use and reuse 'data' for this.
vm:get_data(data)
if y_min < maxp.y and maxp.y < y_max then
local already_placed = false
-- Process the content IDs in 'data'.
-- The most useful order is a ZYX loop because:
-- 1. This matches the order of the 3D noise flat array.
-- 2. This allows a simple +1 incrementing of the voxelmanip index along x
-- rows.
for y = maxp.y, minp.y, -1 do
for z = minp.z, maxp.z do
if already_placed then
break
end
for y = minp.y, maxp.y do
if already_placed then
break
end
for x = minp.x, maxp.x do
if already_placed then
break
end
-- Voxelmanip index for the flat array of content IDs.
-- Initialise to first node in this x row.
local vi = area:index(x, y, z)
if data[vi + area.ystride] == c_water_source and data[vi] == c_cursed_lands_deep_ocean_sand then
if
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)
local biome_data = minetest.get_biome_data(s_pos)
if not biome_data then
return
end
local biome_name = minetest.get_biome_name(biome_data.biome)
if not biome_name then
return
end
if biome_name == 'everness:cursed_lands_deep_ocean' and rand:next(0, 100) < chance then
--
-- Skull
-- Cursed Lands Deep Ocean Skull
--
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local water_source_positions = minetest.find_nodes_in_area(
vector.new(s_pos.x - 5, s_pos.y, s_pos.z - 5),
vector.new(s_pos.x + 5, s_pos.y + 11, s_pos.z + 5),
{ 'default:water_source' }
local schem_pos = vector.new(s_pos)
-- 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_everness_cursed_lands_deep_ocean_sand,
c_everness_cursed_lands_deep_ocean_coral_plant_anemone,
c_everness_cursed_lands_deep_ocean_coral_plant_darkilluma,
c_everness_cursed_lands_deep_ocean_coral_plant_demon,
c_everness_cursed_lands_deep_ocean_coral_alcyonacea,
c_everness_cursed_lands_deep_ocean_coral_ostracod,
c_everness_cursed_lands_deep_ocean_coral_octocurse
},
data,
area
)
if #water_source_positions > skull_volume / 3 then
if #indexes < size.x * size.z then
-- not enough space
return
end
-- enough water to place structure ?
local water_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
},
data,
area
)
if #water_indexes > (size.x * size.y * size.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
skull_schem,
schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
schem_placed = true
schem_positions.everness_cursed_lands_deep_ocean_skull = schem_positions.everness_cursed_lands_deep_ocean_skull or {}
table.insert(schem_positions.everness_cursed_lands_deep_ocean_skull, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z),
maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z)
})
minetest.log('action', '[Everness] Cursed Lands Deep Ocean Skull was placed at ' .. schem_pos:to_string())
already_placed = true
end
end
end
end
end
end
vm:write_to_map(true)
-- Set the lighting within the `VoxelManip` to a uniform value
vm:set_lighting({ day = 0, night = 0 }, minp, maxp)
-- Calculate lighting for what has been created.
vm:calc_lighting()
-- Liquid nodes were placed so set them flowing.
vm:update_liquids()
-- Write what has been created to the world.
vm:write_to_map()
minetest.fix_light(minp, maxp)
-- Populate loot chests
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
local chest_positions = minetest.find_nodes_in_area(
v.minp,
v.maxp,
{ 'everness:chest' }
)
if #chest_positions > 0 then
Everness:populate_loot_chests(chest_positions)
end
end
end
end
end
end)

View File

@ -96,7 +96,7 @@ Everness:register_decoration({
deco_type = 'simple',
place_on = { 'everness:moss_block' },
sidelen = 16,
fill_ratio = 0.05,
fill_ratio = 0.07,
biomes = { 'everness:cursed_lands_under' },
param2 = 8,
decoration = {

View File

@ -158,7 +158,7 @@ Everness:register_decoration({
deco_type = 'simple',
place_on = { 'everness:moss_block' },
sidelen = 16,
fill_ratio = 0.05,
fill_ratio = 0.07,
biomes = { 'everness:forsaken_desert_under' },
param2 = 8,
decoration = {

View File

@ -181,7 +181,7 @@ Everness:register_decoration({
deco_type = 'simple',
place_on = { 'everness:moss_block' },
sidelen = 16,
fill_ratio = 0.05,
fill_ratio = 0.07,
biomes = { 'everness:forsaken_tundra_under' },
param2 = 8,
decoration = {

View File

@ -182,7 +182,7 @@ Everness:register_decoration({
'everness:frosted_ice_translucent',
},
sidelen = 16,
fill_ratio = 0.05,
fill_ratio = 0.07,
biomes = { 'everness:frosted_icesheet_under' },
param2 = 8,
decoration = {
@ -316,25 +316,35 @@ Everness:register_decoration({
local deco_id_frosted_icicle_large_ceiling = minetest.get_decoration_id('everness:frosted_icicle_large_ceiling')
local deco_id_frosted_icicle_large_floor = minetest.get_decoration_id('everness:frosted_icicle_large_floor')
minetest.set_gen_notify({ decoration = true }, { deco_id_frosted_icicle_large_ceiling, deco_id_frosted_icicle_large_floor })
minetest.set_gen_notify(
{ decoration = true },
{
deco_id_frosted_icicle_large_ceiling,
deco_id_frosted_icicle_large_floor
}
)
minetest.register_on_generated(function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object('gennotify')
local size_ceiling = { x = 2, y = 19, z = 2 }
local size_ceiling_x = math.round(size_ceiling.x / 2)
local size_ceiling_z = math.round(size_ceiling.z / 2)
local size_floor = { x = 2, y = 20, z = 2 }
local size_floor_x = math.round(size_floor.x / 2)
local size_floor_z = math.round(size_floor.z / 2)
if y_min < maxp.y and maxp.y < y_max then
--
-- Frosted Large Icicle Ceiling
--
for _, pos in ipairs(gennotify['decoration#' .. deco_id_frosted_icicle_large_ceiling] or {}) do
local markers = minetest.find_nodes_in_area(
vector.new(pos.x - 1, pos.y - 18, pos.z - 1),
vector.new(pos.x + 1, pos.y - 20, pos.z + 1),
{'everness:frosted_icicle_large_ceiling_marker'}
vector.new(pos.x - size_ceiling_x, pos.y - size_ceiling.y + 2, pos.z - size_ceiling_z),
vector.new(pos.x + size_ceiling_x, pos.y - size_ceiling.y, pos.z + size_ceiling_z),
{ 'everness:marker' }
)
if #markers > 0 then
local pos_marker = markers[1]
local air_below = minetest.find_nodes_in_area(
vector.new(pos_marker.x, pos_marker.y, pos_marker.z),
vector.new(pos_marker.x, pos_marker.y - 7, pos_marker.z),
@ -359,20 +369,20 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
--
for _, pos in ipairs(gennotify['decoration#' .. deco_id_frosted_icicle_large_floor] or {}) do
local markers = minetest.find_nodes_in_area(
vector.new(pos.x - 1, pos.y + 18, pos.z - 1),
vector.new(pos.x + 1, pos.y + 20, pos.z + 1),
{'everness:frosted_icicle_large_floor_marker'}
vector.new(pos.x - size_floor_x, pos.y + size_floor.y - 2, pos.z - size_floor_z),
vector.new(pos.x + size_floor_x, pos.y + size_floor.y, pos.z + size_floor_z),
{ 'everness:marker' }
)
if #markers > 0 then
local pos_marker = markers[1]
local air_above = minetest.find_nodes_in_area(
vector.new(pos_marker.x, pos_marker.y, pos_marker.z),
vector.new(pos_marker.x, pos_marker.y + 7, pos_marker.z),
{'air'}
)
-- Replace marker
minetest.set_node(pos_marker, { name = 'everness:frosted_cave_ice_illuminating' })
-- Make sure we have some space
@ -385,5 +395,4 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end
end
end
end
end)

View File

@ -833,39 +833,8 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
-- Populate loot chest inventory
local chest_def = minetest.registered_nodes['everness:chest']
if chest_def then
for i, p in ipairs(chest_positions) do
chest_def.on_construct(p)
local inv = minetest.get_inventory({ type = 'node', pos = p })
if not inv then
minetest.log('action', '[Everness] FAILED to populate loot chests inventory at ' .. p:to_string())
return
end
for index, value in ipairs(inv:get_list('main')) do
local item_def = Everness.loot_chest.default[rand:next(1, #Everness.loot_chest.default)]
if not minetest.registered_items[item_def.name] then
return
end
if rand:next(0, 100) <= item_def.chance then
local stack = ItemStack(item_def.name)
if minetest.registered_tools[item_def.name] then
stack:set_wear(rand:next(1, 65535))
else
stack:set_count(rand:next(1, math.min(item_def.max_count, stack:get_stack_max())))
end
inv:set_stack('main', index, stack)
end
end
minetest.log('action', '[Everness] Loot chests inventory populated at ' .. p:to_string())
end
if chest_def and next(chest_positions) then
Everness:populate_loot_chests(chest_positions)
end
end

130
nodes.lua
View File

@ -2622,133 +2622,13 @@ Everness:register_node('everness:flame_permanent_blue', {
end
})
-- Loot Chest / Icicle Markers
-- Mapgen Marker
Everness:register_node('everness:japanese_shrine_lootchest_marker', {
drawtype = 'airlike',
description = 'Japanese Shrine Loot Chest Spawn Marker',
Everness:register_node('everness:marker', {
-- drawtype = 'airlike',
description = 'Marker for mapgen',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:jungle_temple_lootchest_marker', {
drawtype = 'airlike',
description = 'Jungle Temple Loot Chest Spawn Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:haunted_house_lootchest_marker', {
drawtype = 'airlike',
description = 'Haunted House Loot Chest Spawn Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:quartz_temple_lootchest_marker', {
drawtype = 'airlike',
description = 'Quartz Temple Loot Chest Spawn Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:forsaken_desert_temple_marker', {
drawtype = 'airlike',
description = 'Forsaken Temple Loot Chest Spawn Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:forsaken_desert_temple_2_marker', {
drawtype = 'airlike',
description = 'Forsaken Temple 2 Loot Chest Spawn Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:frosted_icicle_large_ceiling_marker', {
drawtype = 'airlike',
description = 'Frosted Icicle Large Ceiling Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:frosted_icicle_large_floor_marker', {
drawtype = 'airlike',
description = 'Frosted Icicle Large Floor Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:coral_forest_deep_ocean_house_marker', {
drawtype = 'airlike',
description = 'Coral Forest Deep Ocean House Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:cursed_lands_deep_ocean_skull_marker', {
drawtype = 'airlike',
description = 'Cursed Lands Deep Ocean Skull Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:frosted_icesheet_igloo_marker', {
drawtype = 'airlike',
description = 'Frosted Icesheet Igloo Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:crystal_forest_deep_ocean_ruins_marker', {
drawtype = 'airlike',
description = 'Crystal Forest Deep Ocean Ruins Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''
})
Everness:register_node('everness:mineral_waters_tower_marker', {
drawtype = 'airlike',
description = 'Mineral Waters Tower Marker',
tiles = { 'everness_lootchest_marker_top.png', 'everness_lootchest_marker_side.png' },
groups = { dig_immediate = 2, not_in_creative_inventory = 1 },
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
_mcl_hardness = 0.2,
paramtype2 = 'facedir',
drop = ''