Merge pull request 'Turn villagers to zombie villagers when killed by zombies half the time' (#2962) from villagers_to_zs into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2962
Reviewed-by: PrairieWind <prairie.astronomer1@gmail.com>
This commit is contained in:
PrairieWind 2022-11-15 22:30:41 +00:00
commit e0419f3568

View file

@ -2045,7 +2045,7 @@ mcl_mobs:register_mob("mobs_mc:villager", {
self._id=minetest.sha1(minetest.get_gametime()..minetest.pos_to_string(self.object:get_pos())..tostring(math.random())) self._id=minetest.sha1(minetest.get_gametime()..minetest.pos_to_string(self.object:get_pos())..tostring(math.random()))
set_textures(self) set_textures(self)
end, end,
on_die = function(self, pos) on_die = function(self, pos, cmi_cause)
-- Close open trade formspecs and give input back to players -- Close open trade formspecs and give input back to players
local trading_players = self._trading_players local trading_players = self._trading_players
if trading_players then if trading_players then
@ -2070,6 +2070,14 @@ mcl_mobs:register_mob("mobs_mc:villager", {
jobsite_meta:set_string("villager", nil) jobsite_meta:set_string("villager", nil)
mcl_log("Died, so bye bye jobsite") mcl_log("Died, so bye bye jobsite")
end end
if cmi_cause and cmi_cause.puncher then
local l = cmi_cause.puncher:get_luaentity()
if l and math.random(2) == 1 and( l.name == "mobs_mc:zombie" or l.name == "mobs_mc:baby_zombie" or l.name == "mobs_mc:villager_zombie" or l.name == "mobs_mc:husk") then
mcl_util.replace_mob(self.object,"mobs_mc:villager_zombie")
return true
end
end
end, end,
on_lightning_strike = function(self, pos, pos2, objects) on_lightning_strike = function(self, pos, pos2, objects)
mcl_util.replace_mob(self.object, "mobs_mc:witch") mcl_util.replace_mob(self.object, "mobs_mc:witch")