Added soft dependency for 3d_armor

This commit is contained in:
npx 2016-11-08 23:36:13 +01:00
parent 8b6385f502
commit 7d1e81b8cb
2 changed files with 200 additions and 156 deletions

View File

@ -95,6 +95,7 @@ mobs:register_mob("nssm:morlu", {
local m = 1
if self.attack:is_player() then
if minetest.get_modpath("3d_armor") then
local pname, player_inv, armor_inv, ppos = armor:get_valid_player(self.attack, "[set_player_armor]")
local pname = self.attack:get_player_name()
local player_inv = minetest.get_inventory({type='player', name = pname})
@ -195,6 +196,27 @@ mobs:register_mob("nssm:morlu", {
end,self)
end
end
else
local s = self.object:getpos()
local p = self.attack:getpos()
set_animation(self, "punch")
if minetest.line_of_sight({x = p.x, y = p.y +1.5, z = p.z}, {x = s.x, y = s.y +1.5, z = s.z}) == true then
-- play attack sound
if self.sounds.attack then
minetest.sound_play(self.sounds.attack, {
object = self.object,
max_hear_distance = self.sounds.distance
})
end
-- punch player
self.attack:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups = {fleshy=self.damage}
}, nil)
end
end
end
end
end,

View File

@ -83,6 +83,7 @@ mobs:register_mob("nssm:morvalar", {
local m = 1
if self.attack:is_player() then
if minetest.get_modpath("3d_armor") then
local pname, player_inv, armor_inv, ppos = armor:get_valid_player(self.attack, "[set_player_armor]")
local pname = self.attack:get_player_name()
local player_inv = minetest.get_inventory({type='player', name = pname})
@ -152,6 +153,27 @@ mobs:register_mob("nssm:morvalar", {
end,self)
end
end
else
local s = self.object:getpos()
local p = self.attack:getpos()
set_animation(self, "punch")
if minetest.line_of_sight({x = p.x, y = p.y +1.5, z = p.z}, {x = s.x, y = s.y +1.5, z = s.z}) == true then
-- play attack sound
if self.sounds.attack then
minetest.sound_play(self.sounds.attack, {
object = self.object,
max_hear_distance = self.sounds.distance
})
end
-- punch player
self.attack:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups = {fleshy=self.damage}
}, nil)
end
end
end
end
end,