Headcannon Game Engine Script Commands - Random Numbers
Index:
Random Number Generation:
(D) (E) | _Reg=Rand(Const) |
(D) (E) | _Chr=Rand(Const) |
(D) (E) | _Obj=Rand(Const) |
(D) (E) | _Reg=Rand(Reg) |
(D) (E) | _Chr=Rand(Reg) |
(D) (E) | _Obj=Rand(Reg) |
Random Number Generator Seeding:
(D) (E) | _SeedRand(Reg) |
(D) (E) | _Reg=GetTime |
Descriptions:
Random Number Generation:
_Reg=Rand(Const)
_Chr=Rand(Const)
_Obj=Rand(Const)
_Reg=Rand(Reg)
_Chr=Rand(Reg)
_Obj=Rand(Reg)
(All) (Example)
Generates a Random Number within the given range, specified by Constant Values, or Registers, and places it
into the given Variable.
Parameters:
- Lowest Value
- Highest Value
The highest and lowest values within the range that should be generated. Values returned can be between, or equal to these
In the case of Constant Values, these Parameters specify the lowest and highest values to generate
In the case of Registers, these Parameters specify ID numbers of the Registers whose values are equal to the lowest and highest values to generate. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
- Var ID
In the case of "Registers", "Var ID" is the ID of the "Register" that should receive the generated value. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
In the case of Player Variables, "Var ID" is the ID of the Player Variable for the Player that is "Fetched" to "Reference 2" that should receive the generated value. The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, "Var ID" is the ID of the Object Variable for the Object that is "Fetched" to "Reference 2" that should receive the generated value. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
Random Number Generator Seeding:
_SeedRand(Reg)
(All) (Example)
"Seeds" the Random Number Generator with the value stored in the given Register.
Seeding with the same value will cause the same series numbers to be generated every time. Seeding with a different value each
time will produce different sequences.
Seeding with the value returned from _Reg=GetTime can be an easy way to "randomize" the number sequence.
Parameters:
- Var ID
the ID of the "Register" that contains the desired "seed" value. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
_Reg=GetTime
(All) (Example)
Retrieves the amount of time that the host computer system has been active (in milliseconds) and stores it in the given Register.
Parameters:
- Var ID
the ID of the "Register" that should recieve the timer value. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
Examples:
Random Number Generation:
#_Reg=Rand(Const) ;Reg = Rand Const (Generate a Random number no less than -48 and no greater than 48, and store it in "User Register" 7)
: -48 ;(Lower) -48 is the lowest value that it should be possible to generate
: 48 ;(Upper) 48 is the highest value that it should be possible to generate
: U7 ;(Dest) "User Register" 7
; ----------
#_Chr=Rand(Reg) ;Chr2 = Rand Reg (Generate a Random number no less than the value stored in "User Register" 4 and no greater than the value stored in "User Register" 5, and store it in User-created "Active Variable" 2 of the Player "Fetched" to "Reference 2")
: U4 ;(Lower) The lowest value that it should be possible to generate is stored in "User Register 4"
: U5 ;(Upper) The highest value that it should be possible to generate is stored in "User Register 5"
: a2 ;(Dest) User-created "Active Variable" 2 of the Player "Fetched" to "Reference 2"
; ----------
#_Obj=Rand(Const) ;Obj2 = Rand Const (Generate a Random number no less than 0 and no greater than 32, and store it in "Extra Variable" 0 of the Object "Fetched" to "Reference 2")
: 0 ;(Lower) 0 is the lowest value that it should be possible to generate
: 32 ;(Upper) 32 is the highest value that it should be possible to generate
: E0 ;(Dest) "Extra Variable" 0 of the Object "Fetched" to "Reference 2"
Random Number Generator Seeding:
#_SeedRand(Reg) ;SeedRand Reg (Use the value stored in "User Register" 20 to "seed" the Random Number Generator)
: U20 ;(Seed) "User Register" 20
_Reg=GetTime
(Description)
#_Reg=GetTime ;Reg GetTime (Obtain the amount of time the host computer system has been running [in milliseconds] and place it in "User Register 13")
: U13 ;"User Register" 13