Add natural raidcaptain spawning
This commit is contained in:
parent
3600bc8066
commit
af0c718538
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user