Add setting to chance spawn mapblock limit

This commit is contained in:
Jordan Irwin 2021-05-08 14:57:58 -07:00
parent 94c22a5406
commit 0cb069edeb
4 changed files with 30 additions and 20 deletions

@ -20,28 +20,32 @@ An explosive nuisance for [Minetest](http://minetest.net/).
Settings:
- ***sneeker.spawn_chance***
- Sets possibility for spawn.
- type: int
- default: 10000
- type: int
- default: 10000
- ***sneeker.spawn_interval***
- Sets frequency of spawn chance.
- type: int
- default: 240 (4 minutes)
- type: int
- default: 240 (4 minutes)
- ***sneeker.spawn_minlight***
- Sets the minimum light that a node must have for spawn to occur.
- type: int
- default: 0
- type: int
- default: 0
- ***sneeker.spawn_maxlight***
- Sets the maximum light that a node can have for spawn to occur.
- type: int
- default: 9
- type: int
- default: 9
- ***sneeker.spawn_minheight***
- Sets the maximum light that a node can have for spawn to occur.
- type: int
- default: -31000
- type: int
- default: -31000
- ***sneeker.spawn_maxheight***
- Sets the lowest position at which sneeker can spawn.
- type: int
- default 31000
- type: int
- default 31000
- ***sneeker.spawn_mapblock_limit***
- Limits the number of entities that can spawn per mapblock (16x16x16).
- type: int
- default: 1
---
### Links:

@ -44,3 +44,8 @@ sneeker.spawn_minheight = tonumber(core.settings:get("sneeker.spawn_minheight")
--
-- @setting sneeker.spawn_maxheight
sneeker.spawn_maxheight = tonumber(core.settings:get("sneeker.spawn_maxheight") or 31000)
--- Limits the number of entities that can spawn per mapblock (16x16x16).
--
-- Default: 1
sneeker.spawn_mapblock_limit = tonumber(core.settings:get("sneeker.spawn_mapblock_limit") or 1)

@ -21,3 +21,6 @@ sneeker.spawn_minheight (Sneeker min spawn height) int -31000
# Sets the highest position at which sneeker can spawn.
sneeker.spawn_maxheight (Sneeker max spawn height) int 31000
# Limits the number of entities that can spawn per mapblock (16x16x16).
sneeker.spawn_mapblock_limit (Sneeker spawn limit) int 1

@ -22,15 +22,13 @@ core.register_abm({
neighbors = {"air"},
interval = sneeker.spawn_interval,
chance = sneeker.spawn_chance,
action = function(pos, node, _, active_object_count_wider)
if active_object_count_wider > 5 then
return
end
action = function(pos, node, aoc, aocw)
if aoc >= sneeker.spawn_mapblock_limit then return end
if pos.y > sneeker.spawn_maxheight then
return
end
if pos.y < sneeker.spawn_minheight then
-- check above target node
pos.y = pos.y+1
if pos.y > sneeker.spawn_maxheight or pos.y < sneeker.spawn_minheight then
return
end