1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-01-09 17:30:21 +01:00

disable node hearing by default

This commit is contained in:
tenplus1 2024-10-10 10:37:47 +01:00
parent 219db764bf
commit a35afc8299
3 changed files with 23 additions and 12 deletions

28
api.lua
View File

@ -18,7 +18,7 @@ end
mobs = { mobs = {
mod = "redo", mod = "redo",
version = "20241002", version = "20241010",
spawning_mobs = {}, spawning_mobs = {},
translate = S, translate = S,
invis = minetest.global_exists("invisibility") and invisibility or {}, invis = minetest.global_exists("invisibility") and invisibility or {},
@ -4737,6 +4737,7 @@ minetest.register_chatcommand("clear_mobs", {
if settings:get_bool("mobs_can_hear") ~= false then if settings:get_bool("mobs_can_hear") ~= false then
local node_hear = settings:get_bool("mobs_can_hear_node")
local old_sound_play = minetest.sound_play local old_sound_play = minetest.sound_play
minetest.sound_play = function(spec, param, eph) minetest.sound_play = function(spec, param, eph)
@ -4798,22 +4799,25 @@ if settings:get_bool("mobs_can_hear") ~= false then
end end
-- find nodes that can hear up to 8 blocks away -- find nodes that can hear up to 8 blocks away
local dist = min(def.max_hear_distance, 8) if node_hear then
local ps = minetest.find_nodes_in_area(
vector.subtract(def.pos, dist),
vector.add(def.pos, dist), {"group:on_sound"})
if #ps > 0 then local dist = min(def.max_hear_distance, 8)
local ps = minetest.find_nodes_in_area(
vector.subtract(def.pos, dist),
vector.add(def.pos, dist), {"group:on_sound"})
for n = 1, #ps do if #ps > 0 then
local ndef = minetest.registered_nodes[minetest.get_node(ps[n]).name] for n = 1, #ps do
def.distance = get_distance(def.pos, ps[n]) local ndef = minetest.registered_nodes[minetest.get_node(ps[n]).name]
def.loudness = def.gain - (bit * def.distance)
if def.loudness > 0 and ndef and ndef.on_sound then def.distance = get_distance(def.pos, ps[n])
ndef.on_sound(ps[n], def) def.loudness = def.gain - (bit * def.distance)
if def.loudness > 0 and ndef and ndef.on_sound then
ndef.on_sound(ps[n], def)
end
end end
end end
end end

View File

@ -857,6 +857,10 @@ External Settings for "minetest.conf"
'mob_pathfinding_searchdistance' max search distance from search positions (default 16) 'mob_pathfinding_searchdistance' max search distance from search positions (default 16)
'mob_pathfinding_max_jump' max jump height for pathfinding (default 4) 'mob_pathfinding_max_jump' max jump height for pathfinding (default 4)
'mob_pathfinding_max_drop' max drop height for pathfinding (default 6) 'mob_pathfinding_max_drop' max drop height for pathfinding (default 6)
'mobs_can_hear' Enabled by default, overrides minetest.sound_play and enables
nearby mobs to run a custom on_sound function.
'mobs_can_hear_node' Disabled by default, allows nearby nodes to hear and run a
custom on_sound function.
Players can override the spawn chance for each mob registered by adding a line 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 to their minetest.conf file with a new value, the lower the value the more each

View File

@ -63,6 +63,9 @@ mob_log_spawn (Log Mob Spawning) bool false
# Mob hearing, when enabled will override minetest.sound_play for mobs to hear # Mob hearing, when enabled will override minetest.sound_play for mobs to hear
mobs_can_hear (Enable Mob hearing) bool true mobs_can_hear (Enable Mob hearing) bool true
# Node hearing, when enabled will allow nodes to hear nearby sounds
mobs_can_hear_node (Enable Node hearing) bool false
[Pathfinding] [Pathfinding]
# Enable pathfinding (default Enabled) # Enable pathfinding (default Enabled)
mob_pathfinding_enable (Enable pathfinding) bool true mob_pathfinding_enable (Enable pathfinding) bool true