From f98d769e15f9b7e01b91115b1522b3e325237cec Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 1 May 2020 19:30:29 +0100 Subject: [PATCH] added 'mob_nospawn_range' setting --- api.lua | 6 ++++-- api.txt | 1 + readme.MD | 2 +- settingtypes.txt | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api.lua b/api.lua index 1b7947e..816d20e 100644 --- a/api.lua +++ b/api.lua @@ -52,6 +52,7 @@ local remove_far = minetest.settings:get_bool("remove_far_mobs") ~= false local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0 local show_health = minetest.settings:get_bool("mob_show_health") ~= false local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99) +local mob_nospawn_range = tonumber(minetest.settings:get("mob_nospawn_range") or 12) local mob_chance_multiplier = tonumber(minetest.settings:get("mob_chance_multiplier") or 1) -- Peaceful mode message so players will know there are no monsters @@ -3654,8 +3655,9 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, return end - -- only spawn away from player - local objs = minetest.get_objects_inside_radius(pos, 12) + -- only spawn a set distance away from player + local objs = minetest.get_objects_inside_radius( + pos, mob_nospawn_range) for n = 1, #objs do diff --git a/api.txt b/api.txt index 840de8e..06ba531 100644 --- a/api.txt +++ b/api.txt @@ -632,6 +632,7 @@ External Settings for "minetest.conf" 'mobs_griefing' when false mobs cannot break blocks when using either pathfinding level 2, replace functions or mobs:boom function. + 'mob_nospawn_range' Minimum range a mob can spawn near player (def: 12) Players can override the spawn chance for each mob registered by adding a line to their minetest.conf file with a new value, the lower the value the more each diff --git a/readme.MD b/readme.MD index 73d68e0..614bab9 100644 --- a/readme.MD +++ b/readme.MD @@ -23,7 +23,7 @@ Lucky Blocks: 9 Changelog: -- 1.51 - Added some node checks for dangerous nodes, jumping and falling tweaks, spawn area check (thx for idea wuzzy), re-enabled mob suffocation +- 1.51 - Added some node checks for dangerous nodes, jumping and falling tweaks, spawn area check (thx for idea wuzzy), re-enabled mob suffocation, add 'mob_nospawn_range' setting - 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found, (thanks Astrobe), dont spawn mobs if world anchor nearby (technic or simple_anchor mods), chinese local added - 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07 - 1.48- Add mobs:set_velocity(self, velocity) global function diff --git a/settingtypes.txt b/settingtypes.txt index 0821437..938827c 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -27,3 +27,6 @@ mob_chance_multiplier (Mob chance multiplier) float 1.0 # When false Mob no longer drop items when killed mobs_drop_items (Mob drops) bool true + +#....Sets minimum distance around player that mobs cannot spawn +mob_nospawn_range (Mob no-spawn range) float 12.0