1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-07-01 07:50:23 +02:00

can now add nodes to 'runaway_from' table

This commit is contained in:
tenplus1
2023-07-15 08:58:18 +01:00
parent cc0798b617
commit dcc702848f
3 changed files with 19 additions and 3 deletions

17
api.lua
View File

@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20230702",
version = "20230715",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -2051,6 +2051,7 @@ function mob_class:do_runaway_from()
local min_dist = self.view_range + 1
local objs = minetest.get_objects_inside_radius(s, self.view_range)
-- loop through entities surrounding mob
for n = 1, #objs do
if objs[n]:is_player() then
@ -2102,6 +2103,20 @@ function mob_class:do_runaway_from()
self.state = "runaway"
self.runaway_timer = 3
self.following = nil
return
end
-- check for nodes to runaway from
objs = minetest.find_node_near(s, self.view_range, self.runaway_from, true)
if objs then
yaw_to_pos(self, objs, 3)
self.state = "runaway"
self.runaway_timer = 3
self.following = nil
end
end