diff --git a/api.lua b/api.lua index 78a8e23..8adfae7 100644 --- a/api.lua +++ b/api.lua @@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi") mobs = { mod = "redo", - version = "20230518", + version = "20230519", intllib = S, invis = minetest.global_exists("invisibility") and invisibility or {} } @@ -86,6 +86,10 @@ local mob_smooth_rotate = settings:get_bool("mob_smooth_rotate") ~= false local mob_height_fix = settings:get_bool("mob_height_fix") ~= false local active_mobs = 0 +-- get loop timers for node and main functions +local node_timer_interval = tonumber(settings:get("mob_node_timer_interval") or 0.25) +local main_timer_interval = tonumber(settings:get("mob_main_timer_interval") or 1.0) + -- pathfinding settings local pathfinding_enable = settings:get_bool("mob_pathfinding_enable") or true -- Use pathfinder mod if available @@ -3381,7 +3385,7 @@ function mob_class:on_step(dtime, moveresult) self.node_timer = (self.node_timer or 0) + dtime -- get nodes every 1/4 second - if self.node_timer > 0.25 then + if self.node_timer > node_timer_interval then -- get nodes above, below, in front and front-above self:get_nodes() @@ -3402,7 +3406,7 @@ function mob_class:on_step(dtime, moveresult) end -- has mob expired (0.25 instead of dtime since were in a timer) - self:mob_expire(pos, 0.25) + self:mob_expire(pos, node_timer_interval) -- check if mob can jump or is blocked facing fence/gate etc. self:do_jump() @@ -3498,7 +3502,7 @@ function mob_class:on_step(dtime, moveresult) -- one second timed calls self.timer1 = (self.timer1 or 0) + dtime - if self.timer1 >= 1 then + if self.timer1 >= main_timer_interval then -- mob plays random sound at times if random(100) == 1 then @@ -3513,7 +3517,7 @@ function mob_class:on_step(dtime, moveresult) -- when not attacking call do_states every second (return if dead) if self.state ~= "attack" then - if self:do_states(dtime) then return end + if self:do_states(main_timer_interval) then return end end self:do_runaway_from(self) diff --git a/api.txt b/api.txt index dd9ebcd..45d8cde 100644 --- a/api.txt +++ b/api.txt @@ -744,6 +744,10 @@ the tools own meta to override the default. External Settings for "minetest.conf" ------------------------------------ + 'mob_node_timer_interval' How often mobs get nodes around them (0.25 is default) + for every 1/4 second. + 'mob_main_timer_interval' How often mobs run main functions (1.0 is default) for + every one second. 'enable_damage' if true monsters will attack players (default is true) 'only_peaceful_mobs' if true only animals will spawn in game (default is false) diff --git a/settingtypes.txt b/settingtypes.txt index f3b36ed..f351c16 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,3 +1,9 @@ +# How often mobs get nodes around them (default is 0.25, 1/4 second) +mob_node_timer_interval (Mob Node Timer Interval) float 0.25 + +# How often mobs run main functions (default is 1.00, 1 second) +mob_main_timer_interval (Mob Node Timer Interval) float 1.00 + # If false then mobs no longer spawn in world without spawner or spawn egg mobs_spawn (Spawn Mobs) bool true