Nerf vex summoning so evoker doesnt spawn infinite vexes

This commit is contained in:
cora 2022-11-18 02:54:16 +01:00
parent e5515ed119
commit 8564a12398

View file

@ -11,6 +11,8 @@ local S = minetest.get_translator("mobs_mc")
local pr = PseudoRandom(os.time()*666) local pr = PseudoRandom(os.time()*666)
local spawned_vexes = {} --this is stored locally so the mobs engine doesn't try to store it in staticdata
mcl_mobs:register_mob("mobs_mc:evoker", { mcl_mobs:register_mob("mobs_mc:evoker", {
description = S("Evoker"), description = S("Evoker"),
type = "monster", type = "monster",
@ -42,16 +44,24 @@ mcl_mobs:register_mob("mobs_mc:evoker", {
attack_type = "dogfight", attack_type = "dogfight",
-- Summon vexes -- Summon vexes
custom_attack = function(self, to_attack) custom_attack = function(self, to_attack)
local r = pr:next(2,4) if not spawned_vexes[self] then spawned_vexes[self] = {} end
if #spawned_vexes[self] >= 7 then return end
for k,v in pairs(spawned_vexes[self]) do
if not v or v.health <= 0 then table.remove(spawned_vexes[self],k) end
end
local r = pr:next(1,4)
local basepos = self.object:get_pos() local basepos = self.object:get_pos()
basepos.y = basepos.y + 1 basepos.y = basepos.y + 1
for i=1, r do for i=1, r do
local spawnpos = vector.add(basepos, minetest.yaw_to_dir(pr:next(0,360))) local spawnpos = vector.add(basepos, minetest.yaw_to_dir(pr:next(0,360)))
local vex = minetest.add_entity(spawnpos, "mobs_mc:vex") local vex = minetest.add_entity(spawnpos, "mobs_mc:vex")
local ent = vex:get_luaentity() local ent = vex:get_luaentity()
-- Mark vexes as summoned and start their life clock (they take damage it reaches 0) -- Mark vexes as summoned and start their life clock (they take damage it reaches 0)
ent._summoned = true ent._summoned = true
ent._lifetimer = pr:next(33, 108) ent._lifetimer = pr:next(33, 108)
table.insert(spawned_vexes[self],ent)
end end
end, end,
shoot_interval = 15, shoot_interval = 15,