Count instances of object type by ID

How do I…

count the total of bullets that are shoot for one enemy

What is the expected result

I have two enemies of custom object, and I want to limit the bullets they shoot on scene, in this case 5 per enemy.
The bullets they shoot have an ID that link the enemy where they shoot before.
And when the enemy shoot, I start counting the bullets on scene to check if he can shoot again or wait until all the bullets are deleted.

What is the actual result

I still not get how to count correctly the bullets, and the enemy shoot like a rifle.

Related screenshots

Here I have one loop for PurpleEnemy, and inside If the conditions are true to shoot, I insert one loop for PurpleBullet (the type of projectile).
The logic is that if the bullet have the enemy id (that its set on creation, one step before) add one to the count.
And after finish set the variable BulletsCount.

It’s a little bit fiddly, because if you select all the bullets in the scene that have a specific Id and there are none, then GDevelop won’t process the event any further and jumps to the next event. So you can’t determine no bullets in one event with a couple of conditions.

Unless someone has a better method, I’d suggest you use:

In this example, bulletCount and maxBullets are scene variables.

You can also use an object timer to control the rate of fire and to create different types of weapons. The events are basically the same as what MrMen described above.
Bullets

Thanks it work; with that example of PIckedInstancesCount, I think I start to understand the part that says that gdevelop already loop by default on all the instances.

Well its still confusing but its a begining.

This is the final code: