diff --git a/api.lua b/api.lua index 16a64eb..29a4115 100644 --- a/api.lua +++ b/api.lua @@ -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 diff --git a/api.txt b/api.txt index cc6514a..cf04172 100644 --- a/api.txt +++ b/api.txt @@ -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 diff --git a/readme.MD b/readme.MD index aba1f0b..ef69acb 100644 --- a/readme.MD +++ b/readme.MD @@ -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