It isn't equivalent to any of the standard rand() functions, as far as I can tell. Has anyone been able to figure out how it's implemented?
This is a discussion on What is the implementation for Starcraft II's RandomInt() function? within the Starcraft 2 Coding board part of the Starcraft 2 forum category; It isn't equivalent to any of the standard rand() functions, as far as I can tell. Has anyone been able ...

It isn't equivalent to any of the standard rand() functions, as far as I can tell. Has anyone been able to figure out how it's implemented?
Find any variable with constant random integers and just BP it for write access.
So, are you talking about the Galaxy function that gets a random number in a range, or something else?
I'm here to learn, have fun, and help others learn and have fun.

Yeah, the Galaxyscript function (if anyone could find the ASM I'd be content, I could reverse engineer it from there. I'm just having trouble finding the actual code)
Last edited by RueBlaja; 04-29-2012 at 07:28 PM.
The main code is at 0x00DDED40. It calls 0x00E21590, and 0x0093D2C0 which calls 0x0093D170 and 0x01069120.
Last edited by Mr Nukealizer; 06-08-2012 at 02:10 AM.
I'm here to learn, have fun, and help others learn and have fun.

Awesome, thanks! I had just figured that out when you posted it, but it took me literally about 6 hours. Out of curiosity, how did you find that so quickly?
I got it all implemented now, but because it uses the assembly code directly from the game, I can't publish it. However, if anyone in the future wants help figuring it out for themselves, I'd be more than happy to help, just shoot me a message.
Thanks again Mr. Nukealizer!
Last edited by RueBlaja; 04-30-2012 at 04:39 AM.
I managed to find it so fast by opening the program in IDA Pro and running the script for finding and renaming all the Galaxy functions (it's on Blizzhackers somewhere...), then opening the Goto window and typing in Galaxy_RandomInt.
And by the way, I wasn't working on it the whole 3 hours between our posts, it only took about 45 seconds to find it and another 5 minutes to find the addresses it calls and write my post.
Last edited by Mr Nukealizer; 04-30-2012 at 09:42 PM.
I'm here to learn, have fun, and help others learn and have fun.

poker_face_meme.jpg
For future reference for everyone else, apparently that script can be found here.