added new amogus spawning system, tweaked sussy imposter spawning system

This commit is contained in:
Looki2000 2023-02-23 19:03:25 +01:00
parent adefaaf592
commit 02a7044e19

View File

@ -447,10 +447,27 @@ minetest.register_decoration({
rotation = "random",
})
amogus_spawn_random_spread = 2
minetest.register_on_generated(function(minp, maxp, seed)
for i = 1, math.random(10, 25) do
minetest.add_entity({x = minp.x + math.random(16), y = minp.y + 1, z = minp.z + math.random(16)}, "amogus_entities:amogus")
if math.random(0, 100) < 75 then -- percentage chance of spawning group of amoguses in a chunk
-- spawn random amount of amoguses around random point in chunk
local spawn_position = {x = minp.x + math.random(0, 79), y = minp.y + math.random(0, 10), z = minp.z + math.random(0, 79)}
for i = 1, math.random(5, 15) do
math.randomseed(seed + i)
minetest.add_entity({
x = spawn_position.x + math.random(-amogus_spawn_random_spread, amogus_spawn_random_spread),
y = spawn_position.y + math.random(-amogus_spawn_random_spread, amogus_spawn_random_spread),
z = spawn_position.z + math.random(-amogus_spawn_random_spread, amogus_spawn_random_spread)
}, "amogus_entities:amogus")
end
end
end)
@ -513,14 +530,17 @@ minetest.register_abm({
nodenames = {"air"},
neighbors = {"group:stone"},
interval = 10,
-- IMPORTANT !! spawning chance is actualy interpreted as 1 / chance so the bigger the number the lower the actual chance of imposter being spawned
chance = 200,
action = function(pos)
-- DEBUG
--imposters_spawned = imposters_spawned + 1
--minetest.chat_send_all("Imposters spawned: " .. imposters_spawned)
-- only spawn on solid blocks AND in the dark
if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name].walkable and minetest.get_node_light(pos) <= 12 then
if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name].walkable and minetest.get_node_light(pos) < 10 then
-- do not spawn if there is already an sussy imposter nearby
local nearby_entities = minetest.get_objects_inside_radius(pos, 10)
local imposter_nearby = false