1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-11-13 05:50:17 +01:00

add support for MarkBu's pathfinder mod

This commit is contained in:
TenPlus1 2021-07-22 09:34:21 +01:00
parent 2d014a75c4
commit 2535b5636e
4 changed files with 15 additions and 7 deletions

17
api.lua
View File

@ -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,

View File

@ -7,3 +7,4 @@ intllib?
lucky_block?
cmi?
toolranks?
pathfinder?

View File

@ -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.

View File

@ -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,