With this explanation would I be correct in assuming that if I wanted fewer Friendly NPC's that I would edit the entitygroups.xml in NPCCore/Packs and add the maxcount to each friendly NPC entry like how in spawning.xml maxcount is used for overall zombie count but not the randomness of the zombies as that is decided by entitygroups.xml. Like for an example below:
<entity name="npcBakerEmptyHand" prob="0.05" /> and change to <entity name="npcBakerEmptyHand" prob="0.05" maxcount="1"/>
No, you can't do this. Entity tags in entity groups do not support the "maxcount" attribute at all.
Instead you should do as Arramus suggested, and reduce the probabilities of all the NPCs in each biome group. (Or at least those that you see more than you like.)
In the default entitygroups.xml, Zombie Boe has no probability added, and for the sake of calculating appearance, we can consider that to be a 100% chance.
That's actually not how it works. There is no such thing as a 100% chance unless there is only one entity in the entity group.
In fact, if there is no probability added, then it defaults to a probability value of 1. That's not 100%, that's a probability equal to entities that also have a value of 1.
Here's how the probabilities are actually calculated.
First, the game sums up all the probabilities of all the entities in the entity group (after mods add them, if applicable). Then, it takes each individual probability, and divides it by this sum. Mathematically, this is called
normalization - it means the
total probability for each entity
group will be exactly 1.
Now, each time an entity should be spawned from this group, it chooses a random number between 0 and 1. It goes through each entity in the entity group, in order, using the normalized probabilities. For the first entity, if the random number is less than its probability, that is the entity which is used. Otherwise, it adds that entity's probability to a running total, and moves on to the next entity in the entity group. If the random number is less than that entity's probability
plus the running total, that entity is used. Otherwise... the process repeats until an entity is used.
Also note that there is no "keeping track" of entities. It's all determined by RNG, so the same entity can be chosen multiple times. (Using the terminology of probability theory, choosing an entity is an independent event.)
So, if modlets add a lot of NPCs to the zombie groups, then they can overwhelm zombies, so that there is a higher probability to spawn an NPC than a zombie. This can happen no matter how small each
individual NPC's probability is.
If an entity group has 10 zombies without probabilities (meaning: a probability of 1 per zombie), then this will happen as soon as the
combined probability values of all the NPCs reach 10. If you install a lot of NPC modlets, and they all add their own NPCs into the same biome spawn groups (which they do), then this is almost guaranteed to happen.
This is why I originally advocated that when NPC authors add their NPCs to a biome spawn group, the
combined probabilities of
all NPCs in that pack should add up to 1 in that group. This would mean there is an equal chance to spawn one of their NPCs, as there is to spawn a single zombie in that group. It also would mean that NPC packs with lots of NPCs (and/or weapon variations) wouldn't blow out NPC packs that had fewer NPCs. That didn't happen. C'est la vie.
that's interesting. well i reviewed the gamestage modlets for NPCMod that
@khzmusik created and looks like they only impact the code for sleeper POI spawning.
That's correct. It's because POI spawners are the only ones that are gamestaged, at least in vanilla - biome spawns aren't. (Wandering hordes are too, but you can't spawn
most NPCs into wandering hordes, that will throw exceptions because most NPCs don't descend from the C# EntityEnemy class.)
It's also easier to figure out POI spawning, since NPCs don't spawn in the same groups as zombies, so I didn't have to worry about zombie-vs.-NPC ratios like I would with biome spawns. I still don't know what most people expect that ratio to be (or even if there is any consensus at all).