|
||
|
|||||||
| General Discussion General discussion for the RunUO community, all off-topic posts will be deleted. This forum is NOT FOR SUPPORT! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Join Date: Jan 2003
Posts: 80
|
how difficult/involved would it be to change
(static) int Random( int from, int count ) to (static) double Random( double from, double count ) ?? my hope is to allow a decimal to be used in the random...also am I reading that this.Skills[SkillName.MagicResist].Base = Utility.Random(20,40); is giving me a value randomly from 20 to 40?? |
|
|
|
|
|
#2 (permalink) |
|
Forum Expert
|
this.Skills[SkillName.MagicResist].Base = Utility.Random(20,40)
the above code produces a random number from 19 - 59 the first number is the minimum the second is the stepping. remember that numbering starts at 0. you can convert an Int to a double but only if that data type in runUO supports it. |
|
|
|
|
|
#7 (permalink) |
|
Join Date: Dec 2002
Posts: 140
|
You always can do fixed point math with integers. To use let's say 2 decimals, multiply all your real values by 100, and convert it to integers.
After all integer calculations, convert to double and divide it by 100. (double) (RandomMinMax( (int) (min*100), (int) (max*100) ) ) / 100 |
|
|
|
|
|
#8 (permalink) |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,870
|
You could also do:
(double)(Utility.Random( 5, 6 )) + Utility.RandomDouble(); this would give you a random from 4 to 9.999999999 Random double returns a random double from 0 to 0.99999999
__________________
Zippy, Razor Creator and RunUO Core Developer The RunUO Software Team "Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal." ~The Cryptonomicon |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|