From 2535b5636eac88007d0d2d01edc6e9b4329b149d Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Thu, 22 Jul 2021 09:34:21 +0100 Subject: [PATCH] add support for MarkBu's pathfinder mod --- api.lua | 17 ++++++++++++----- depends.txt | 1 + mod.conf | 2 +- readme.MD | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/api.lua b/api.lua index 236bf3b..eb697ea 100644 --- a/api.lua +++ b/api.lua @@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi") mobs = { mod = "redo", - version = "20210721", + version = "20210722", intllib = S, invis = minetest.global_exists("invisibility") and invisibility or {} } @@ -83,7 +83,7 @@ local aoc_range = tonumber(settings:get("active_block_range")) * 16 -- pathfinding settings local enable_pathfinding = true local stuck_timeout = 3 -- how long before stuck mod starts searching -local stuck_path_timeout = 10 -- how long will mob follow path before giving up +local stuck_path_timeout = 5 -- how long will mob follow path before giving up -- default nodes local node_fire = "fire:basic_flame" @@ -1654,6 +1654,8 @@ local can_dig_drop = function(pos) return false end + +local pathfinder_mod = minetest.get_modpath("pathfinder") -- path finding and smart mob routine by rnd, -- line_of_sight and other edits by Elkien3 function mob_class:smart_mobs(s, p, dist, dtime) @@ -1782,13 +1784,18 @@ function mob_class:smart_mobs(s, p, dist, dtime) jumpheight = 1 end - self.path.way = minetest.find_path(s, p1, 16, jumpheight, - dropheight, "Dijkstra") - + if pathfinder_mod then + self.path.way = pathfinder.find_path(s, p1, self, dtime) + else + self.path.way = minetest.find_path(s, p1, 16, jumpheight, + dropheight, "Dijkstra") + end --[[ -- show path using particles if self.path.way and #self.path.way > 0 then + print("-- path length:" .. tonumber(#self.path.way)) + for _,pos in pairs(self.path.way) do minetest.add_particle({ pos = pos, diff --git a/depends.txt b/depends.txt index 2f20802..94516a7 100644 --- a/depends.txt +++ b/depends.txt @@ -7,3 +7,4 @@ intllib? lucky_block? cmi? toolranks? +pathfinder? diff --git a/mod.conf b/mod.conf index 31a27ed..6a6180d 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = mobs depends = default -optional_depends = tnt, dye, farming, invisibility, intllib, lucky_block, cmi, toolranks +optional_depends = tnt, dye, farming, invisibility, intllib, lucky_block, cmi, toolranks, pathfinder description = Adds a mob api for mods to add animals or monsters etc. diff --git a/readme.MD b/readme.MD index d646984..2a57731 100644 --- a/readme.MD +++ b/readme.MD @@ -23,7 +23,7 @@ Lucky Blocks: 9 Changelog: -- 1.55 - Add 'peaceful_player' privelage and setting so mobs don't attack specific players (thanks sfence) +- 1.55 - Add 'peaceful_player' privelage and setting so mobs don't attack specific players (thanks sfence), add support for MarkBu's pathfinder mod. - 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks, on_flop added, air_damage added. - 1.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded. - 1.52 - Added 'mob_active_limit' in settings to set number of mobs in game,