mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-02-04 22:30:16 +01:00
new special spawning,spawn only if there are no others of the same type(limited with max), fix issue https://github.com/MinetestForFun/server-minetestforfun/issues/524
This commit is contained in:
parent
03bd2fa529
commit
62fbe19f10
@ -2142,6 +2142,62 @@ end -- END mobs:register_mob function
|
|||||||
|
|
||||||
mobs.spawning_mobs = {}
|
mobs.spawning_mobs = {}
|
||||||
|
|
||||||
|
function mobs:spawn_special(name, nodes, neighbors, interval, chance, active_object_count) -- MFF to special mobs
|
||||||
|
mobs.spawning_mobs[name] = true
|
||||||
|
-- chance override in minetest.conf for registered mob
|
||||||
|
local new_chance = tonumber(minetest.setting_get(name .. "_chance"))
|
||||||
|
if new_chance ~= nil then
|
||||||
|
if new_chance == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
chance = new_chance
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = nodes,
|
||||||
|
neighbors = neighbors,
|
||||||
|
interval = interval,
|
||||||
|
chance = chance,
|
||||||
|
action = function(pos, node, _, active_object_count_wider)
|
||||||
|
-- do not spawn if too many active entities in area
|
||||||
|
local count = 0
|
||||||
|
local objs = minetest.get_objects_inside_radius(pos, 60)
|
||||||
|
for k, obj in pairs(objs) do
|
||||||
|
if obj:get_luaentity() ~= nil and obj:get_luaentity().name == name then
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if count > active_object_count then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- spawn above node
|
||||||
|
pos.y = pos.y + 1
|
||||||
|
-- only spawn away from player
|
||||||
|
local objs = minetest.get_objects_inside_radius(pos, 10)
|
||||||
|
for _,oir in pairs(objs) do
|
||||||
|
if oir:is_player() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- are we spawning inside solid nodes?
|
||||||
|
if minetest.registered_nodes[node_ok(pos).name].walkable == true then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
pos.y = pos.y + 1
|
||||||
|
if minetest.registered_nodes[node_ok(pos).name].walkable == true then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- spawn mob half block higher than ground
|
||||||
|
pos.y = pos.y - 0.5
|
||||||
|
minetest.add_entity(pos, name)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
interval, chance, active_object_count, min_height, max_height, spawn_in_area, day_toggle) --MFF crabman "spawn_in_area"
|
interval, chance, active_object_count, min_height, max_height, spawn_in_area, day_toggle) --MFF crabman "spawn_in_area"
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ minetest.register_node("mobs:mese_dragon_spawner", {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
--(name, nodes, neighbors, min_light, max_light, interval, chance, active_object_count, min_height, max_height, spawn_in_area)
|
--(name, nodes, neighbors, interval, chance, active_object_count)
|
||||||
-- spawn on mobs:mese_dragon_spawner between 1 and 20 light, interval 300, 1 chance, 1 mese_dragon_spawner in area up to 31000 in height
|
-- spawn on mobs:mese_dragon_spawner, interval 300, 1 chance, 1 mese_dragon_spawner
|
||||||
mobs:spawn_specific("mobs:mese_dragon", {"mobs:mese_dragon_spawner"}, {"air"}, 1, 20, 300, 1, 100, -31000, 31000, true)
|
mobs:spawn_special("mobs:mese_dragon", {"mobs:mese_dragon_spawner"}, {"air"}, 300, 1, 1)
|
||||||
mobs:register_egg("mobs:mese_dragon", "Mese Dragon", "mobs_mese_dragon_inv.png", 1)
|
mobs:register_egg("mobs:mese_dragon", "Mese Dragon", "mobs_mese_dragon_inv.png", 1)
|
||||||
|
@ -133,6 +133,6 @@ minetest.register_node("mobs:pumpboom_spawner", {
|
|||||||
mobs:spawn_specific("mobs:pumpking", {"mobs:pumpking_spawner"}, {"air"}, 1, 20, 300, 1, 100, -31000, 31000, true)
|
mobs:spawn_specific("mobs:pumpking", {"mobs:pumpking_spawner"}, {"air"}, 1, 20, 300, 1, 100, -31000, 31000, true)
|
||||||
mobs:register_egg("mobs:pumpking", "Pumpking", "mobs_pumpking_inv.png", 1)
|
mobs:register_egg("mobs:pumpking", "Pumpking", "mobs_pumpking_inv.png", 1)
|
||||||
|
|
||||||
-- spawn on mobs:pumpboom_spawner between 1 and 20 light, 4 interval, 1 chance, 100 pumpboom in area up to 31000 in height
|
-- spawn on mobs:pumpboom_spawner, 4 interval, 1 chance, 30 pumpboom in area
|
||||||
mobs:spawn_specific("mobs:pumpboom", {"mobs:pumpboom_spawner"}, {"air"}, 1, 20, 10, 4, 100, -31000, 31000, true)
|
mobs:spawn_special("mobs:pumpboom", {"mobs:pumpboom_spawner"}, {"air"}, 10, 4, 30)
|
||||||
mobs:register_egg("mobs:pumpboom", "Pumpboom", "mobs_pumpboom_inv.png", 1)
|
mobs:register_egg("mobs:pumpboom", "Pumpboom", "mobs_pumpboom_inv.png", 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user