I've been told, probably too many times, to stop whining about the crummy Bioware random number function and post one on the vault.
Well, here it is. I get better results using this system than using the native function in NWN. Hope you do too.
Usage:
RandomF(float fMax=1., float fMin=0., int nSeed=0, object oObject=OBJECT_INVALID)
- Returns a float between fMin and fMax
RandomI(int nMax=1, int nMin=0, int nSeed=0, object oObject = OBJECT_INVALID)
- Retruns an integer between nMin and nMax
Parameters:
-Max/Min = the range you want a random number in (including those numbers)
-nSeed = an optional seed value. If not supplied the game clock milliseconds value will be used.
-oObject = an object to store the history buffer on. If an object is not provided, the module will be used.
1 Feb 2006, Fixed a bug in SY_GetRandomSeed that was generating -10 all the time. Thanks to Gale of the DLA for pointing it out.
Posted by calsailx at 2009-11-28 17:05:55 Voted 10.00 on 11/28/09
Been using this for a couple of years at least, much happier with what it generates then anything else I've used before or since. _________________________ TNI01 Usable Beds || TNI02 Useable Beds || TWC03 Usable Beds
Posted by Blasco-Yang at 2008-10-15 19:48:52 Voted 10.00 on 10/15/08
Very nice.
Tested it with a simple recursive function in the OnEnter of an area to generate a new number between 1 and 100 every 2 seconds.
Very random, and deserving of a "10" if you ask me.
My thanks and gratitude to you for making this. The math of it is far beyond my skills, but luckily that's a non issue as long as generous folks like you continue to provide such excellent content.
Posted by Nihlar at 2008-03-21 06:12:19 Voted 10.00 on 03/21/08