The code is from RandomEncounters.cs
https://github.com/Interkarma/daggerfal ... s.cs#L1476
First, to those who aren't coders, bear in mind that the first slot on an enemy list is number 0, not 1. (the 20th slot then corresponds to the number 19, not 20)
Okay, so to generate an enemy it essentially "rolls" a number from 1 to 100.
If the rolled number is 1 to 80 (80% chance), it sets a range of numbers from the player level -3 to player level +3.
If the rolled number is from 81 to 95 (15% chance) it sets a range of numbers from 0 to player level +1.
EDIT: This next section is wrong, please ignore it.
If the rolled number is 96 to 100 (5% chance), and if the player level is 5 or less, it sets a range of numbers from 0 to player level +2. If the player level is 6 or higher it sets a range of numbers from 0 to 19. (That means any monster on the list. Hello Vampire Ancients, Ancient Liches, and Daedra Lords. At level 6 )
Then it looks at those max and min numbers. If the minimum or maximum number of the range turn out to be less than 0 or over 19, the ranges become fixed: 0 to 5 if the min went below 0, or 14 to 19 if the max went over 19. (It can't possibly do both.)
Lastly, it picks one number from the range and looks on a list specific to that area to see what monster to place.
EDIT: This next section is wrong, please ignore it.
EDITED: removed unnecessary explanations
EDIT: This next section is now unnecessary, please ignore it.
if (max > 19)
{
max = 19;
}
But this only fixes the level 19+ problem.
The DFU code (lines 1517 to 1524) produces incorrect results to the intended ranges generated by classic code, lines 1477 to 1512.
Now, the DFU code shouldn't normally come into use unless the enemy list is shorter (or possibly: longer) than 20 entries (which, at present, none are).
But in my opinion, at minimum, line 1521 (min = max - 5;) needs to be rewritten anyway, so as to properly set min to reflect the min set by the classic conditions (level -3 (minimum 0) or level 0, depending on which condition between lines 1477 to 1512 was passed).
This naturally increases the frequency of higher level spawns for level 19+ characters when this code comes into use.
Is this a major problem? No, but it is an unintended consequence.
There are several pretty obvious options/solutions, but I won't presume to write the code for you guys. However, if I were doing it, I would re-write the lines from 1477 to 1512 without assuming 20 element lists (both longer and shorter ones) and remove the (now unnecessary) DFU code from lines 1517 to 1524. This would solve all possible issues at present and in future.
My thanks to Jehuty to bringing this to my notice.