0
0
Fork 0

Add natural raidcaptain spawning

This commit is contained in:
cora 2022-11-08 02:26:37 +01:00
parent 3600bc8066
commit af0c718538
2 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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