- Joined
- Jul 10, 2007
- Messages
- 6,306
Tired of having random numbers that are the same for each game, so I dev'd this to change it up. The only way they will be the same now is if the players do things at the same exact instant >: P.
Essentially, update random seed every time you are getting something random and you will ensure very unique randomness : O.
JASS:
library RandomNumber
globals
private integer seconds = 0
private timer t
endglobals
function UpdateSeed takes nothing returns nothing
call SetRandomSeed(R2I((seconds+TimerGetElapsed(t))*1000)+GetRandomInt(-2147483648, 2147483647))
endfunction
private module Init
private static method inc takes nothing returns nothing
set seconds = seconds + 1
endmethod
private static method onInit takes nothing returns nothing
set t = CreateTimer()
call TimerStart(t, 1, true, function thistype.inc)
endmethod
endmodule
private struct Inits extends array
implement Init
endstruct
endlibrary
Essentially, update random seed every time you are getting something random and you will ensure very unique randomness : O.