This commit is contained in:
Elias Fleckenstein 2021-01-05 17:52:27 +01:00
parent e7721b91a0
commit 6f49a3d535
2 changed files with 12 additions and 8 deletions

View file

@ -801,7 +801,7 @@ local check_for_death = function(self, cause, cmi_cause)
if self.on_die then if self.on_die then
local pos = self.object:get_pos() local pos = self.object:get_pos()
local on_die_exit = self.on_die(self, pos) local on_die_exit = self.on_die(self, pos, cmi_cause)
if on_die_exit ~= true then if on_die_exit ~= true then
death_handle(self) death_handle(self)
end end

View file

@ -76,12 +76,16 @@ mobs:register_mob("mobs_mc:creeper", {
end end
end end
end, end,
on_die = function(self, pos) on_die = function(self, pos, cmi_cause)
-- Drop a random music disc -- Drop a random music disc when killed by skeleton or stray
-- TODO: Only do this if killed by skeleton or stray if cmi_cause and cmi_cause.type == "punch" then
if math.random(1, 200) == 1 then local luaentity = cmi_cause.puncher and cmi_cause.puncher:get_luaentity()
local r = math.random(1, #mobs_mc.items.music_discs) if luaentity and luaentity.name:find("arrow") then
minetest.add_item({x=pos.x, y=pos.y+1, z=pos.z}, mobs_mc.items.music_discs[r]) local shooter_luaentity = luaentity._shooter and luaentity._shooter:get_luaentity()
if shooter_luaentity and (shooter_luaentity.name == "mobs_mc:skeleton" or shooter_luaentity.name == "mobs_mc:stray") then
minetest.add_item({x=pos.x, y=pos.y+1, z=pos.z}, mobs_mc.items.music_discs[math.random(1, #mobs_mc.items.music_discs)])
end
end
end end
end, end,
maxdrops = 2, maxdrops = 2,