Talk:GetRandomPercent

Revision as of 17:14, 29 July 2006 by imported>JOG

Is this similar to Morrowind's Random100 function, or can it be used in the same manner? The Imperial Dragon 12:58, 11 June 2006 (EDT)


Random100 (as one word) in Morrowind was a global that was set to 0-100 once per frame (in the script "Main")

set variable to GetRandomPercent 

in Oblivion is the same as

set variable to Random 100

in Morrowind and will return a new random number ranging from 0-99 whenever you call it.

--JOG 13:40, 11 June 2006 (EDT)

I see, thank you. The Imperial Dragon 13:44, 11 June 2006 (EDT)


JOG 17:33, 29 July 2006 (EDT): Here's the math behind the first example:

short dice
set dice to 1 + 0.06 * GetRandompercent  


int(1 + 0.06 * 00) = int(1 + 0.00) = int(1.00) = 1

int(1 + 0.06 * 16) = int(1 + 0.96) = int(1.96) = 1 => Chance: 17%

int(1 + 0.06 * 17) = int(1 + 1.02) = int(2.02) = 2

int(1 + 0.06 * 33) = int(1 + 1.98) = int(2.98) = 2 => Chance: 17%

int(1 + 0.06 * 34) = int(1 + 2.02) = int(3.02) = 3

int(1 + 0.06 * 49) = int(1 + 2.94) = int(3.94) = 3 => Chance: 16%

int(1 + 0.06 * 50) = int(1 + 3.00) = int(4.00) = 4

int(1 + 0.06 * 66) = int(1 + 3.96) = int(4.96) = 4 => Chance: 17%

int(1 + 0.06 * 67) = int(1 + 4.02) = int(5.02) = 5

int(1 + 0.06 * 83) = int(1 + 4.98) = int(5.98) = 5 => Chance: 17%

int(1 + 0.06 * 84) = int(1 + 5.04) = int(6.04) = 6

int(1 + 0.06 * 99) = int(1 + 5.94) = int(6.94) = 6 => Chance: 16%


And the Min/Max formula was wrong:

short dice
set dice to 5/99 * GetRandompercent 

would return this:

int(5/99 * 00) = int(0.00) = 0

int(5/99 * 19) = int(0.96) = 0 => Chance: 20%

int(5/99 * 20) = int(1.01) = 1

int(5/99 * 39) = int(1.98) = 1 => Chance: 20%

int(5/99 * 40) = int(2.02) = 2

int(5/99 * 59) = int(2.98) = 2 => Chance: 20%

int(5/99 * 60) = int(3.03) = 3

int(5/99 * 79) = int(3.99) = 3 => Chance: 20%

int(5/99 * 80) = int(4.04) = 4

int(5/99 * 98) = int(4.98) = 4 => Chance: 19%

int(5/99 * 99) = int(5.00) = 5 => Chance: 1%

Return to "GetRandomPercent" page.