subroutine zz_InitRnd( bReset ) /* Author : Mr C, Sprezzatura Ltd Date : 29 July 2010 Purpose : Simple function to call initRnd with with a more varied seed value, and to also ensure we only call it once per session. Parameters ========== bReset : If TRUE$ then call initRnd regardless of whether or not it's been called before. */ declare function getTickCount, getEngineWindow $insert logical if assigned( bReset ) else bReset = "" common /%%_ZZ_INITRND_%%/ zzInitRndSeed@ * // Check to see if we've already been called this session. if zzInitRndSeed@ then * // We've called it already - are we asking for a reset? if bReset else * // Nope! return end end * // Start off with the tickcount (ms) and the * // OE hwnd ... seed = getTickCount() + GetEngineWindow() * // Now adjust this slightly to help avoid the time * // factor if mod( seed, 2 ) then b = seed[-1,1] if b then seed = int( seed / b ) end else seed = int( seed / 3 ) end end * // Right - run it through some more mods to keep it * // within range of a short int if it's not already... loop while ( seed > 0x7FFF ) if mod( seed, 2 ) then seed -= 0x7FFF end else b = seed[-1,1] if b then seed = int( seed / b ) end else seed = int( seed / 3 ) end end repeat initRnd seed * // Flag that we've already called this... zzInitRndSeed@ = seed return