diff --git a/mods/ENVIRONMENT/mcl_raids/init.lua b/mods/ENVIRONMENT/mcl_raids/init.lua index 32e372eeb2..2b5e2874fa 100644 --- a/mods/ENVIRONMENT/mcl_raids/init.lua +++ b/mods/ENVIRONMENT/mcl_raids/init.lua @@ -105,6 +105,27 @@ function mcl_raids.promote_to_raidcaptain(c) -- object end end +function mcl_raids.is_raidcaptain_near(pos) + for k,v in pairs(minetest.get_objects_inside_radius(pos,128)) do + local l = v:get_luaentity() + if l and l._raidcaptain then return true end + end +end + +function mcl_raids.register_possible_raidcaptain(mob) + local old_on_spawn = minetest.registered_entities[mob].on_spawn + minetest.registered_entities[mob].on_spawn = function(self) + if not mcl_raids.is_raidcaptain_near(self.object:get_pos()) then + mcl_raids.promote_to_raidcaptain(self.object) + end + if old_on_spawn then return old_on_spawn(self) end + end +end + +mcl_raids.register_possible_raidcaptain("mobs_mc:pillager") +mcl_raids.register_possible_raidcaptain("mobs_mc:vindicator") +mcl_raids.register_possible_raidcaptain("mobs_mc:evoker") + function mcl_raids.spawn_raid(event) local pos = event.pos local wave = event.stage diff --git a/mods/ENVIRONMENT/mcl_raids/mod.conf b/mods/ENVIRONMENT/mcl_raids/mod.conf index 39f752ed72..b4616e56b7 100644 --- a/mods/ENVIRONMENT/mcl_raids/mod.conf +++ b/mods/ENVIRONMENT/mcl_raids/mod.conf @@ -1,3 +1,3 @@ name = mcl_raids author = PrairieWind -depends = mcl_events, mcl_mobs, mcl_potions, mcl_bells, mcl_achievements +depends = mcl_events, mobs_mc, mcl_potions, mcl_bells, mcl_achievements