mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-25 02:00:21 +01:00
add 'mob_node_timer_interval' and 'mob_main_timer_interval' settings to handle function timings
This commit is contained in:
parent
29bc2f27f2
commit
b16eefa0ec
14
api.lua
14
api.lua
@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230518",
|
version = "20230519",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
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 mob_height_fix = settings:get_bool("mob_height_fix") ~= false
|
||||||
local active_mobs = 0
|
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
|
-- pathfinding settings
|
||||||
local pathfinding_enable = settings:get_bool("mob_pathfinding_enable") or true
|
local pathfinding_enable = settings:get_bool("mob_pathfinding_enable") or true
|
||||||
-- Use pathfinder mod if available
|
-- 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
|
self.node_timer = (self.node_timer or 0) + dtime
|
||||||
|
|
||||||
-- get nodes every 1/4 second
|
-- 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
|
-- get nodes above, below, in front and front-above
|
||||||
self:get_nodes()
|
self:get_nodes()
|
||||||
@ -3402,7 +3406,7 @@ function mob_class:on_step(dtime, moveresult)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- has mob expired (0.25 instead of dtime since were in a timer)
|
-- 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.
|
-- check if mob can jump or is blocked facing fence/gate etc.
|
||||||
self:do_jump()
|
self:do_jump()
|
||||||
@ -3498,7 +3502,7 @@ function mob_class:on_step(dtime, moveresult)
|
|||||||
-- one second timed calls
|
-- one second timed calls
|
||||||
self.timer1 = (self.timer1 or 0) + dtime
|
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
|
-- mob plays random sound at times
|
||||||
if random(100) == 1 then
|
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)
|
-- when not attacking call do_states every second (return if dead)
|
||||||
if self.state ~= "attack" then
|
if self.state ~= "attack" then
|
||||||
if self:do_states(dtime) then return end
|
if self:do_states(main_timer_interval) then return end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:do_runaway_from(self)
|
self:do_runaway_from(self)
|
||||||
|
4
api.txt
4
api.txt
@ -744,6 +744,10 @@ the tools own meta to override the default.
|
|||||||
External Settings for "minetest.conf"
|
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)
|
'enable_damage' if true monsters will attack players (default is true)
|
||||||
'only_peaceful_mobs' if true only animals will spawn in game (default is
|
'only_peaceful_mobs' if true only animals will spawn in game (default is
|
||||||
false)
|
false)
|
||||||
|
@ -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
|
# If false then mobs no longer spawn in world without spawner or spawn egg
|
||||||
mobs_spawn (Spawn Mobs) bool true
|
mobs_spawn (Spawn Mobs) bool true
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user