Difference between revisions of "GetRandomPercent"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Kkuhlmann
 
imported>Odessa
(Added see also link to script extender random function)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Link to TES4 Construction Set Wiki: [http://cs.elderscrolls.com/constwiki/index.php/GetRandomPercent GetRandomPercent].
{{Function
|CSWikiPage = GetRandomPercent
|origin = GECK1
|summary = Returns a random integer between 0 and 99 inclusive.
|name = GetRandomPercent
|returnVal = 0 to 99
|returnType = int


|example = <pre>short rnd
set rnd to GetRandomPercent</pre>
This will set the variable "rnd" to an integer between 0 and 99, inclusive
}}
==Notes==
*To generate a random number between 1 and max:
<pre>set randVal to 1 + GetRandomPercent * max / 100</pre>
To generate a random number between min and max:
<pre>set randVal to min + GetRandomPercent * (max-min+1) / 100</pre>
==See Also==
*[[Rand]]


[[Category:Functions]]
[[Category:Functions]]
[[Category:Functions (GECK 1.1)]]
[[Category:Math Functions]]
[[Category:Math Functions]]
[[Category:Math Functions (GECK 1.1)]]
[[Category:Condition Functions]]
[[Category:Condition Functions]]
[[Category:Condition Functions (GECK 1.1)]]

Latest revision as of 08:52, 14 April 2014

< [[::Category:Functions|Category:Functions]]

Link to TES4 Construction Set Wiki: GetRandomPercent.

A function included in the GECK version 1.1.0.36.

Description

Returns a random integer between 0 and 99 inclusive.

Syntax

[help]
(0 to 99:int) GetRandomPercent

Example

short rnd
set rnd to GetRandomPercent

This will set the variable "rnd" to an integer between 0 and 99, inclusive

Notes

  • To generate a random number between 1 and max:
set randVal to 1 + GetRandomPercent * max / 100

To generate a random number between min and max:

set randVal to min + GetRandomPercent * (max-min+1) / 100

See Also