Wolfe Deckard Posted April 22, 2023 Share Posted April 22, 2023 Good evening, Im trying to write a randomizer dice script that will roll a d20 that is assigned to one of 5 stats and the ability to customize the Hud for specific players and their attribute modifier, like roll 1d20 + 4 in the script itself. is this possible?? Link to comment Share on other sites More sharing options...
Quistess Alpha Posted April 22, 2023 Share Posted April 22, 2023 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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