Jump to content

d20 script


Wolfe Deckard
 Share

You are about to reply to a thread that has been inactive for 528 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Generating a random number with a specific probability in 'dice format' is not too hard:

integer n;
// n = 1d20 +4
n = (integer)llFrand(20) +5; // (integer)llFrand(n) ranges from [0,n-1] so add 1 extra.
// 3d6 +2
integer l;
for(n=0;l<3;++l)
{   n+=(integer)llFrand(6); // under counts by 1.
}
n+=5; // n == 3d6+2 at this point.

Adding a UI and making those numbers and rolls 'mean something' in the context of an interactive system is something entirely different.

(integer)llFrand(n) works well enough in most situations, but if you need something "better" there's a whole rabbit hole of pseudo-random number generation theory to fall into. One method that sometimes "feels better" than actual random number generation in some contexts is to take a few copies of the list 1,2,3...n added together and llListRandomize it. then step through and re-randomize when you reach the end.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 528 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...