Can somebody please tell me how to put a stop in this function so that mob won't spawn endless guards ?
Code: Select all
do_custom = function(self)
local pos = self.object:getpos()
pos.y = pos.y + 3
if self.health < 450 then
self.object:set_properties({visual_size = {x=1.8, y=1.8},})
self.damage = 50
end
if self.health < 400 then
self.object:set_properties({ visual_size = {x=2.7, y=2.7}, collisionbox = {-1.2,-1.2,-0.9, 1.2,1.2,0.9} })
self.damage = 100
end
if self.health < 350 then
self.object:set_properties({reach = 2.8, visual_size = {x=3.6, y=3.6},collisionbox = {-1.8,-1.8,-1.3, 1.8,1.8,1.3},})
self.damage = 200
end
if self.health < 250 then
self.object:set_properties({reach = 3.3, visual_size = {x=4.8, y=4.8},collisionbox = {-2.4,-2.4,-2, 2.4,2.4,2},})
self.damage = 400
end
if self.health < 100 then
self.armor = 25
end
if self.health < 99 then
self.runaway = true
end
if self.health > 5 and self.health < 51 and self.state == "attack" then
minetest.add_entity(pos, "mobs_medieval:TBgua")
self.object:set_hp(self.health + 40)
self.object:set_properties({health = 90})
return
end
if self.health > 11 and self.health < 91 then
self.object:set_hp(99)
self.object:set_properties({health = 99})
end
if self.health > 6 and self.health < 90 then
self.object:set_hp(self.health + 9)
self.object:set_properties({health = 99})
end
end,
Code: Select all
if self.health > 5 and self.health < 51 and self.state == "attack" then
minetest.add_entity(pos, "mobs_medieval:TBgua")
self.object:set_hp(self.health + 40)
self.object:set_properties({health = 90})
return
end
I have already tried to end the spawning by giving the mob health back but that doesnt seem to work aswell,
so I also limited it on the mob's attack state which doesnt really help either until every enemy in range has been destroyed.. (that doeant take really long but until then i still have like 50-100 guards already in most cases )
:{
Please only show me examples, I can't program
Maybe a timer, or how to propperly end that, or how to use return, or something..