What is the implementation for Starcraft II's RandomInt() function?

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 ...

Results 1 to 8 of 8
  1. #1
    RueBlaja is offline Member
    Array
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    3
    Reputation
    18

    What is the implementation for Starcraft II's RandomInt() function?

    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?


  2. #2
    Beaving's Avatar
    Beaving is offline Терпение, мой друг



    Array
    Join Date
    Dec 2008
    Location
    Russia
    Posts
    689
    Rep Power
    9
    Reputation
    848
    Find any variable with constant random integers and just BP it for write access.

  3. The Following User Says Thank You to Beaving For This Useful Post:


  4. #3
    Mr Nukealizer's Avatar
    Mr Nukealizer is offline I ♥ ¡ǝʞɐↄǝZǝǝчƆ

    Array
    Join Date
    Jan 2011
    Posts
    860
    Rep Power
    5
    Reputation
    498
    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.

  5. #4
    RueBlaja is offline Member
    Array
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    3
    Reputation
    18
    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.

  6. #5
    Mr Nukealizer's Avatar
    Mr Nukealizer is offline I ♥ ¡ǝʞɐↄǝZǝǝчƆ

    Array
    Join Date
    Jan 2011
    Posts
    860
    Rep Power
    5
    Reputation
    498
    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.

  7. The Following User Says Thank You to Mr Nukealizer For This Useful Post:


  8. #6
    RueBlaja is offline Member
    Array
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    3
    Reputation
    18
    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.

  9. The Following User Says Thank You to RueBlaja For This Useful Post:


  10. #7
    Mr Nukealizer's Avatar
    Mr Nukealizer is offline I ♥ ¡ǝʞɐↄǝZǝǝчƆ

    Array
    Join Date
    Jan 2011
    Posts
    860
    Rep Power
    5
    Reputation
    498
    Quote Originally Posted by RueBlaja View Post
    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!
    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.

  11. The Following User Says Thank You to Mr Nukealizer For This Useful Post:


  12. #8
    RueBlaja is offline Member
    Array
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    3
    Reputation
    18
    Quote Originally Posted by Mr Nukealizer View Post
    it only took about 45 seconds
    poker_face_meme.jpg

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

Similar Threads

  1. Is there on/off function maphack?
    By dyuwntlr in forum Warcraft 3 Hacks
    Replies: 3
    Last Post: 02-17-2012, 08:17 PM
  2. One function Key
    By Likesoftair in forum CoD 4 forum
    Replies: 6
    Last Post: 07-20-2010, 10:51 PM
  3. how does -AH function
    By forsakenshaman in forum Warcraft 3 forum
    Replies: 2
    Last Post: 04-10-2010, 04:49 PM
  4. [CODE] [VB6] Bit XOR Function
    By Kalbintion in forum Development
    Replies: 1
    Last Post: 01-30-2009, 01:28 PM
  5. [Function] Fog of War (MiniMap)
    By Nowa in forum Warcraft 3 Hacks
    Replies: 2
    Last Post: 01-03-2008, 10:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •