Announcement: Be excellent to each other.


Caravel Forum : DROD RPG Boards : RPG Architecture : True Pseudorandom Number Generator (Some people will hate me for that ^^)
New Topic New Poll Post Reply
Poster Message
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged

File: PRNG.drh (115.9 KB)
Downloaded 69 times.
License: Public Domain
icon True Pseudorandom Number Generator (+3)  
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

The other RND_RANDOMIZE:
Click here to view the secret text


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]
12-30-2008 at 07:47 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
Kwakstur
Level: Smiter
Avatar
Rank Points: 385
Registered: 05-05-2006
IP: Logged
icon Re: True Pseudorandom Number Generator (+1)  
I can't get your test hold to work.

Edit: Ahah, the problem is that calculations use a mistyped variable (RNDDANDOM), while preplaced NPCs use what would technically be the correct name (RNDRANDOM). I tried changing all to use Dandom (since that's the one used in calculations) and they started moving. Still no text.

Edit again: Ahah, there's typos in the speech. You're have "$RNDRANOM$" instead of "$RNDDANDOM$".

Edit again: Please add a "Flush Speech On" after the speech command so that it updates immediately.
And place the speech before the Wait 0.


____________________________
Also known as ExpHP everywhere else.

[Last edited by Kwakstur at 12-31-2008 12:18 AM]
12-30-2008 at 11:53 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged
icon Re: True Pseudorandom Number Generator (+1)  
That's overall pretty strange thing. I don't remember changing it to RNDDANDOM and since the beginning it was RNDRANDOM, so I can't really find out when the change occured. I'll fix it right away.

____________________________
My website | Facebook | Twitter
12-31-2008 at 12:05 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
Kwakstur
Level: Smiter
Avatar
Rank Points: 385
Registered: 05-05-2006
IP: Logged
icon Re: True Pseudorandom Number Generator (+1)  
Okay, your updated version works well (except for a 1 turn speech delay and no flush speech), and also has a max number appropriate for the number of NPCs there. Nice.

____________________________
Also known as ExpHP everywhere else.

[Last edited by Kwakstur at 12-31-2008 12:18 AM]
12-31-2008 at 12:17 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD RPG Boards : RPG Architecture : True Pseudorandom Number Generator (Some people will hate me for that ^^)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.