Not to be rude, but that
is random. People often make the mistake and expect a random number sequence to be a different number each time, but it's certainly possible to get the same number several times in a row (otherwise it's not random, it's removed on purpose). The pseudorandom generator could be bad too of course. We've already moved away from the one in HL2.
To prevent this, ZR give players immunity from mother zombie infection if they were selected. It's only for one round so it's still possible to become mother zombie every odd round (especially if there are few players on the server).
In addition I discovered that ZR ignores immunity when it's passing on mother zombie infection if the last zombie disconnects. I'm not sure whether it's a good idea or not. At least it could be a config setting.
I actually have a thread for discussing a solution to this issue, where you would get immunity for several rounds:
https://forums.alliedmods.net/showthread.php?t=180188
I'm trying to make something that performs well and is scalable, but for use in ZR it should be good enough since it's less than 64 elements. Note that my idea in that thread has an issue. There's a group of players that will never be selected in the beginning of the list. It could be simplified by just getting a random player instead of adding at the end.
Edit:
Made a O(1) solution for removing a certain element from an array that should be portable to SourcePawn. My old idea mentioned above did rely on the position in the array to avoid array shifting, but now we don't need to worry about that:
Java snippet:
PHP Code:
/**
* <p>Removes and returns an element from a list in a O(1) operation.</p>
*
* <p>The last element is moved to replace the element at the specified
* index, space so elements after the index doesn't need to be shifted
* up.</p>
*
* @param list Source list to remove element from.
* @param index Index of element to remove.
* @return Element at the specified index.
* @throws IndexOutOfBoundsException List is empty or index is invalid.
*/
public static <E> E removeFromListWithoutShifting(List<E> list, int index)
{
if (list.isEmpty())
{
throw new IndexOutOfBoundsException("List is empty.");
}
int lastElementIndex = list.size() - 1;
E elementAtIndex = list.get(index);
E lastElement = list.get(lastElementIndex);
list.set(index, lastElement);
list.remove(lastElementIndex);
return elementAtIndex;
}
This snippet can be used to remove a random element from a list in a O(1) operation, which is just what we need. New players that are no longer immune to infection are just added at the end of the list. It doesn't matter where in the list they're added.
__________________