Because DROD RPG is an amazing "
Programming Language"
I have created for you, RPG freaks, a Pseudorandom Number Generator based on some reliable code. In the attachment you have the example, which shows which numbers are generated between 0 (inclusive) and 10 (exclusive).
As for the script.
You need two custom characters. One named RND_INIT:
Click here to view the secret text
×
Label ATTENTION! Set SEED to any value you want
Label other than 0 and RndM!0
Set var "RNDSEED" = 2147483647
Label Initialize Vars. DO NOT CHANGE ANYTHING HERE!!!!
Set var "RNDA" = 48271
Set var "RNDB" = 2147483647
Set var "RNDC" = 44488
Set var "RNDD" = 3399
Set var "RNDTEMP" = 0
Set var "RNDRANDOM" = 0
If ...
Wait until var "RNDSEED" = 0
Set var "RNDSEED" = 1234
If End
If ...
Wait until var "RNDSEED" = RNDB
Set var "RNDSEED" = 1234
If End
End
The other RND_RANDOMIZE:
Click here to view the secret text
× Set var "RNDTEMP" = RNDSEED
Set var "RNDTEMP" / RNDC
Set var "RNDTEMP" * RNDD
Set var "RNDSEED" % RNDC
Set var "RNDSEED" * RNDA
Set var "RNDSEED" - RNDTEMP
If ...
Wait until var "RNDSEED" < 0
Set var "RNDSEED" + RNDB
If End
Set var "RNDTEMP" = 268435456
Set var "RNDTEMP" / RNDRANDOM
Set var "RNDRANDOM" = RNDSEED
Set var "RNDRANDOM" / 16
Set var "RNDRANDOM" * 16
Set var "RNDRANDOM" % 268435456
Set var "RNDRANDOM" / RNDTEMP
End
How to use the code:
1. At the start of the game put ONE instance of RND_INIT. In character script change RNDSEED following the instructions (If you want, you can for example make the game to change the RNDSEED during game from time to time based on eg. KillCount*MovesMade/PlayerDirection)
2. Whenever you want to generate a random number use this code:
Set var "RNDRANDOM" = x
Generate entity RND_RANDOMIZE,0,0,northwest
First line sets the Random value range. The generated variable will be between 0 (Inclusive) and x (Exclusive). Put desired number instead of x.
The second line creates a Randomize character which generates the random number and saves it in RNDRANDOM. So to retrieve the generated value use for example:
Speech "$RNDRANDOM$",Normal,Self,0,.
That would be it. As far as I tested it, it is pretty reliable, though if you encounter any problems don't hesitate to tell me about them
.
Enjoy!
____________________________
My website |
Facebook |
Twitter
[Last edited by skell at 12-31-2008 12:11 AM]