Random number with exceptions?

Hello. Is there a way, for example, to generate a number between 0 and 9, without the chance to roll 3? Can I add an exception for the 3? Would the best way be just adding the range 0-9 but re-doing the function whenever the outcome is 3?

Or if I have several exceptions, 2, 5 and 7? The function re-flowing chance increases as more exceptions appear. Imagine if I need a number between 0-999 except 800 non-uniform ones. Is there such an implementation or do I need to get around it by hard-coding?

ON A SIDE NOTE: I’m just working for an MMORPG company in a parallel universe, where this pimple-faced loser teenager gets a new Mighty Axe with 1250-1600 damage and is about to hit seven 1337’s in a row. I know he won’t notice it while sipping on his parent-provided sugary drink with electrolytes, but I still don’t want him the blessing of luck. I have all the time in the world(s), because when time is bent - so is the sanity.

Looking around a bit, there doesn’t appear to be any specific means of doing that. I think you would probably just want to assemble a List<> of any values you don’t want included in the number generation, then consult that List<> after number generation to determine whether it should be excluded (and, therefore, generate a new number in its place).

Edit: Working around HTML issues in the post

Simply re-rolling is highly inadvisible, especially with lots of exceptions; it can lead to large, random performance drops or stack overflows, and in theory, the function could never return.

One easy way implement to implement this is to create a list, fill it with the full range of numbers in consideration, then remove any disallowed numbers from the list. After that, it’s just a matter of selecting a random element from the list. This also happens to be the best way to handle large numbers of exceptions.

If the range of numbers is large and there are few exceptions, there is a better way to do it, but I’d still recommend trying the list first.