So it seems that “Random” (i.e. nValue = Random(4);) will provide a random number that will necessarily start from 0.
Can’t I choose a random range instead? I’d like my random range to be between 30-90…is that possible? I’d imagine it should be but I couldn’t find it in the nwn lexicon
Add the randomized number to the base, and you’ve got your random range between 30 and 90:
int nValue = 30+Random(61);
Be aware that the first number that can be returned is a zero; so to have a range from (0-60) you need to give Random() a sixty-one as a parameter rather than a sixty. (otherwise, possible results would be 0-59, not 0-60).
Be also aware that while being a tremendous resource, the Lexicon is not error-free. For example, the Random() page states:
Returns an integer between 0 and nMaxInteger - 1. The maximum value this can return is 65,534 (one less than the maximum value of a signed integer, 65,535).
While in fact Random() can only return values from [0, 32767) or (-32767, 0] ranges. Square bracket means inclusion, parenthesis - exclusion.
Check my projects if you require some more sophisticated random functions.