How do I make mobs slowly respawn up to a certain cap?

[BACK]
How do I make mobs slowly respawn up to a certain cap?
Posted On: January 27, 2023

I am currently making a Legend of Zelda themed adventure map. I am struggling to make it, so enemies spawn every few minutes but not spawn large amounts over time. I have tried using things like hopper clocks to time when enemies spawn but after a while it turns into a large swarm of unwanted enemies. I am looking to make it so if an enemy has already spawned another will not spawn.


Example: if there are 5 enemies in a room, there will never be more than 5. So even if a few are killed, a few minutes later more will respawn, but no more than 5 in total.


Question from user Opllusion at gaming.stackexchange.com.


Answer:

You can store the result of the execute if entity subcommand to count how many entities there are and then execute based on that.


You will need a dummy scoreboard objective (let's say count) and a fakeplayer to store the amount in (let's say $zombies).


Now we can count the amount of zombies and only summon another one if there are 4 or less zombies in total:.


execute store result score $zombies count if entity @e[type=zombie].


execute if score $zombies count matches ..4 run summon zombie.


Answer from user Plagiatus at gaming.stackexchange.com.


[BACK]
How do I make mobs slowly respawn up to a certain cap?
Posted On: January 27, 2023

I am currently making a Legend of Zelda themed adventure map. I am struggling to make it, so enemies spawn every few minutes but not spawn large amounts over time. I have tried using things like hopper clocks to time when enemies spawn but after a while it turns into a large swarm of unwanted enemies. I am looking to make it so if an enemy has already spawned another will not spawn.


Example: if there are 5 enemies in a room, there will never be more than 5. So even if a few are killed, a few minutes later more will respawn, but no more than 5 in total.


Question from user Opllusion at gaming.stackexchange.com.


Answer:

You can store the result of the execute if entity subcommand to count how many entities there are and then execute based on that.


You will need a dummy scoreboard objective (let's say count) and a fakeplayer to store the amount in (let's say $zombies).


Now we can count the amount of zombies and only summon another one if there are 4 or less zombies in total:.


execute store result score $zombies count if entity @e[type=zombie].


execute if score $zombies count matches ..4 run summon zombie.


Answer from user Plagiatus at gaming.stackexchange.com.


[BACK]

What is this treasure in Lara’s trophy collection? What is this treasure in Lara’s trophy collection?

Posted On: March 3, 2024
In the Croft Manor section of Tomb Raider 3, there is a hidden trophy room containing relics from Lara’s previous adventures. Most of these are references to previous games - fragments of the Scion ...[More]


Does router speed affect ping? Does router speed affect ping?

Posted On: June 11, 2023
I currently own a 150 Mbps router, and I am playing MW3 on PS3 with about 75ms to 100ms ping. Does getting a new 300 Mbps router make a big difference? Would it reduce my lag? Question from user...[More]


Is BG3 worth playing if I wouldn't like the combat? Is BG3 worth playing if I wouldn't like the combat?

Posted On: August 5, 2025
I prefer games to have as little luck involved in possible, I want everything to be within the player's control. Mechanics like hit chance and random critical hits are annoying to me. Are the other as...[More]


What do the stars under can produce mean in against the storm What do the stars under can produce mean in against the storm

Posted On: February 7, 2023
Does it mean it can produce those goods faster, higher quality or what? Is it worth it to replace buildings with higher starred versions or prioritize going for buildings with new stuff?So for example...[More]


Hogwarts Legacy, What the hell was that? Hogwarts Legacy, What the hell was that?

Posted On: June 9, 2023
Okay.. I was just running around doing some easy side quests (or so I thought) and saw a cute little house elf selling a shop. Fast forward a few minutes and I suddenly end up in a literal HORROR G...[More]


Where should I sell exploration data for the most benefit? Where should I sell exploration data for the most benefit?

Posted On: June 15, 2023
I spend a LOT of time outside the bubble. (Both the Solar bubble and Colonia area.) Sometimes, I'll be out for months at a stretch and come back with tens of millions of CR worth of exploration da...[More]


Marked as a quest item. Reading it never updated my journal? Marked as a quest item. Reading it never updated my journal?

Posted On: March 13, 2026
I've had sooo many playthroughs and this quest item never made sense. I think I have a memory of it working in early patches - lately I haven't triggered anything from it. Not even dialogue reactions....[More]


What are the requirements of these Steam specific achievements? What are the requirements of these Steam specific achievements?

Posted On: September 24, 2023
Most of the hidden achievements in KoA seem to resolve themselves through normal game play (defeat this guy, complete on hard, etc) so I imagine the answer to this one is going to be along the same li...[More]


Has anyone done an absolutist run? Has anyone done an absolutist run?

Posted On: March 12, 2025
Not killing the mind flayer in the very beginning. Having compassion for it lol. Siding with Minthara. Pick all absolute dialogue options. Let Marcus take Isobel. Get branded. Lol.I was just wondering...[More]


how exactly did nocturne become a woman? how exactly did nocturne become a woman?

Posted On: December 11, 2024
Not to be rude but im a divinity player interested in baulders gate so how exactly did it happen is it kinda like elder scrolls where a necromancer goes into a thingy becomes immoble eventually and th...[More]