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

View File

@ -154,8 +154,8 @@ functions needed for the mob to work properly which contains the following:
'friendly_fire` when set to false, mobs will not be able to harm other
mobs of the same type with friendly fire arrows.
Defaults to true.
'runaway_from' contains a table with mob names to run away from, add
"player" to list to runaway from player also.
'runaway_from' contains a table with mob names or nodesto run away
from, add "player" to list to runaway from player also.
'ignore_invisibility' When true mob will still be able to see and attack
player even if invisible (invisibility mod only).
'blood_amount' contains the number of blood droplets to appear when

View File

@ -33,6 +33,7 @@ https://forum.minetest.net/viewtopic.php?f=11&t=9917
* Refactored do_jump and added get_nodes function
* Many bug fixes and tweaks to improve performance
* Added 'mobs_attack_creatura' setting so that monsters can attack Creatura mobs
* Nodes can be added to 'runaway_from' table
### Version 1.56