diff --git a/spawners_mobs/mob_bunny_evil.lua b/spawners_mobs/mob_bunny_evil.lua index 5e8bd85..367638c 100644 --- a/spawners_mobs/mob_bunny_evil.lua +++ b/spawners_mobs/mob_bunny_evil.lua @@ -6,7 +6,7 @@ local bunny_evil_def = { attack_type = "dogfight", group_attack = true, pathfinding = false, - reach = 2, + reach = 3, damage = 3, hp_min = 35, hp_max = 65, diff --git a/spawners_mobs/mob_mummy.lua b/spawners_mobs/mob_mummy.lua index c1df8b1..708b80e 100644 --- a/spawners_mobs/mob_mummy.lua +++ b/spawners_mobs/mob_mummy.lua @@ -70,6 +70,57 @@ local mummy_def = { max_hear_distance = 8 }) end, + _timer = 0, + _random_trigger = 5, + do_custom = function(self, dtime) + if not self._timer then + self._timer = 0 + end + + if not self._random_trigger then + self._random_trigger = math.random(5, 20) + end + + self._timer = self._timer + dtime + + if self._timer > self._random_trigger then + self._timer = 0 + self._random_trigger = math.random(5, 20) + + if not self.attack then + return + end + + local mob_pos = self.object:get_pos() + local player_pos = self.attack:get_pos() + local distance = vector.distance(mob_pos, player_pos) + + -- don't teleport when closer than 'reach' distance in mod def + if distance <= 3 then + return + end + + if self.attack:is_player() then + -- health check + if self.attack:get_hp() > 0 then + -- play sound + minetest.sound_play("spawners_mobs_teleport", { + object = self.object, + gain = 1.0, + max_hear_distance = 20 + }) + + local player_look_dir = self.attack:get_look_dir() + player_look_dir.y = 0 + local to_pos = vector.add(player_pos, player_look_dir) + + -- teleport player + self.object:set_pos(to_pos) + end + end + + end + end, -- on_rightclick = function(self, clicker) -- if mobs:feed_tame(self, clicker, 8, true, true) then diff --git a/spawners_mobs/mob_uruk_hai.lua b/spawners_mobs/mob_uruk_hai.lua index 8530eba..ae3b43f 100644 --- a/spawners_mobs/mob_uruk_hai.lua +++ b/spawners_mobs/mob_uruk_hai.lua @@ -9,7 +9,7 @@ local uruk_hai_def = { pathfinding = false, attack_type = "dogfight", group_attack = true, - reach = 2, + reach = 3, damage = 6, armor = 100, collisionbox = {-0.3,-1.0,-0.3, 0.3,0.8,0.3}, diff --git a/spawners_mobs/spawners_mobs.lua b/spawners_mobs/spawners_mobs.lua index c371f29..cad0a2c 100644 --- a/spawners_mobs/spawners_mobs.lua +++ b/spawners_mobs/spawners_mobs.lua @@ -1,6 +1,6 @@ --- +-- -- CREATE ALL SPAWNERS NODES --- +-- function spawners_mobs.create(mob_table, idx) local mob_name = mob_table.name local mod_prefix = mob_table.mod_prefix @@ -8,9 +8,9 @@ function spawners_mobs.create(mob_table, idx) local mesh = mob_table.dummy_mesh local texture = mob_table.dummy_texture - -- + -- -- DUMMY INSIDE THE SPAWNER - -- + -- minetest.register_entity("spawners_mobs:dummy_"..mod_prefix.."_"..mob_name, { hp_max = 1, visual = "mesh", @@ -30,9 +30,9 @@ function spawners_mobs.create(mob_table, idx) end }) - -- + -- -- DEFAULT SPAWNER - -- + -- minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", { description = mod_prefix.."_"..mob_name.." spawner", paramtype = "light", @@ -73,9 +73,9 @@ function spawners_mobs.create(mob_table, idx) end }) - -- + -- -- WAITING SPAWNER - -- + -- minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting", { description = mod_prefix.."_"..mob_name.." spawner waiting", paramtype = "light", @@ -103,9 +103,9 @@ function spawners_mobs.create(mob_table, idx) on_timer = spawners_mobs.on_timer }) - -- + -- -- RUSTY SPAWNER - -- + -- minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_rusty", { description = mod_prefix.."_"..mob_name.." spawner rusty", paramtype = "light", @@ -120,9 +120,9 @@ function spawners_mobs.create(mob_table, idx) drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner" }) - -- + -- -- replacement LBM for pre-nodetimer spawners - -- + -- minetest.register_lbm({ name = "spawners_mobs:start_nodetimer_"..mod_prefix.."_"..mob_name.."_spawner", nodenames = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", @@ -131,15 +131,15 @@ function spawners_mobs.create(mob_table, idx) end, }) - -- + -- -- COMPATIBILITY - -- + -- minetest.register_alias("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active", "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner") end --- +-- -- INIT 'CREATE' FOR ALL SPAWNERS --- +-- for i, mob_table in ipairs(spawners_mobs.mob_tables) do spawners_mobs.create(mob_table, i) end