mobs longer reach, mummy teleports to attacker
parent
eb97641e72
commit
7d8d7e7f96
|
@ -6,7 +6,7 @@ local bunny_evil_def = {
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
group_attack = true,
|
group_attack = true,
|
||||||
pathfinding = false,
|
pathfinding = false,
|
||||||
reach = 2,
|
reach = 3,
|
||||||
damage = 3,
|
damage = 3,
|
||||||
hp_min = 35,
|
hp_min = 35,
|
||||||
hp_max = 65,
|
hp_max = 65,
|
||||||
|
|
|
@ -70,6 +70,57 @@ local mummy_def = {
|
||||||
max_hear_distance = 8
|
max_hear_distance = 8
|
||||||
})
|
})
|
||||||
end,
|
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)
|
-- on_rightclick = function(self, clicker)
|
||||||
|
|
||||||
-- if mobs:feed_tame(self, clicker, 8, true, true) then
|
-- if mobs:feed_tame(self, clicker, 8, true, true) then
|
||||||
|
|
|
@ -9,7 +9,7 @@ local uruk_hai_def = {
|
||||||
pathfinding = false,
|
pathfinding = false,
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
group_attack = true,
|
group_attack = true,
|
||||||
reach = 2,
|
reach = 3,
|
||||||
damage = 6,
|
damage = 6,
|
||||||
armor = 100,
|
armor = 100,
|
||||||
collisionbox = {-0.3,-1.0,-0.3, 0.3,0.8,0.3},
|
collisionbox = {-0.3,-1.0,-0.3, 0.3,0.8,0.3},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--
|
--
|
||||||
-- CREATE ALL SPAWNERS NODES
|
-- CREATE ALL SPAWNERS NODES
|
||||||
--
|
--
|
||||||
function spawners_mobs.create(mob_table, idx)
|
function spawners_mobs.create(mob_table, idx)
|
||||||
local mob_name = mob_table.name
|
local mob_name = mob_table.name
|
||||||
local mod_prefix = mob_table.mod_prefix
|
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 mesh = mob_table.dummy_mesh
|
||||||
local texture = mob_table.dummy_texture
|
local texture = mob_table.dummy_texture
|
||||||
|
|
||||||
--
|
--
|
||||||
-- DUMMY INSIDE THE SPAWNER
|
-- DUMMY INSIDE THE SPAWNER
|
||||||
--
|
--
|
||||||
minetest.register_entity("spawners_mobs:dummy_"..mod_prefix.."_"..mob_name, {
|
minetest.register_entity("spawners_mobs:dummy_"..mod_prefix.."_"..mob_name, {
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
@ -30,9 +30,9 @@ function spawners_mobs.create(mob_table, idx)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
--
|
--
|
||||||
-- DEFAULT SPAWNER
|
-- DEFAULT SPAWNER
|
||||||
--
|
--
|
||||||
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", {
|
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", {
|
||||||
description = mod_prefix.."_"..mob_name.." spawner",
|
description = mod_prefix.."_"..mob_name.." spawner",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -73,9 +73,9 @@ function spawners_mobs.create(mob_table, idx)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
--
|
--
|
||||||
-- WAITING SPAWNER
|
-- WAITING SPAWNER
|
||||||
--
|
--
|
||||||
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting", {
|
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting", {
|
||||||
description = mod_prefix.."_"..mob_name.." spawner waiting",
|
description = mod_prefix.."_"..mob_name.." spawner waiting",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -103,9 +103,9 @@ function spawners_mobs.create(mob_table, idx)
|
||||||
on_timer = spawners_mobs.on_timer
|
on_timer = spawners_mobs.on_timer
|
||||||
})
|
})
|
||||||
|
|
||||||
--
|
--
|
||||||
-- RUSTY SPAWNER
|
-- RUSTY SPAWNER
|
||||||
--
|
--
|
||||||
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_rusty", {
|
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_rusty", {
|
||||||
description = mod_prefix.."_"..mob_name.." spawner rusty",
|
description = mod_prefix.."_"..mob_name.." spawner rusty",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -120,9 +120,9 @@ function spawners_mobs.create(mob_table, idx)
|
||||||
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner"
|
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner"
|
||||||
})
|
})
|
||||||
|
|
||||||
--
|
--
|
||||||
-- replacement LBM for pre-nodetimer spawners
|
-- replacement LBM for pre-nodetimer spawners
|
||||||
--
|
--
|
||||||
minetest.register_lbm({
|
minetest.register_lbm({
|
||||||
name = "spawners_mobs:start_nodetimer_"..mod_prefix.."_"..mob_name.."_spawner",
|
name = "spawners_mobs:start_nodetimer_"..mod_prefix.."_"..mob_name.."_spawner",
|
||||||
nodenames = "spawners_mobs:"..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,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
--
|
--
|
||||||
-- COMPATIBILITY
|
-- COMPATIBILITY
|
||||||
--
|
--
|
||||||
minetest.register_alias("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active", "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner")
|
minetest.register_alias("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active", "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- INIT 'CREATE' FOR ALL SPAWNERS
|
-- INIT 'CREATE' FOR ALL SPAWNERS
|
||||||
--
|
--
|
||||||
for i, mob_table in ipairs(spawners_mobs.mob_tables) do
|
for i, mob_table in ipairs(spawners_mobs.mob_tables) do
|
||||||
spawners_mobs.create(mob_table, i)
|
spawners_mobs.create(mob_table, i)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue