|
G1R AngelScript
Scripting reference for the Gothic 1 Remake
|
Functions | |
Functions | |
| int | WeightedRandomIndex (TArray< float32 > Weights) |
| Given an array of weights, returns a randomly chosen index where those with higher weights are more likely to be chosen. | |
| int WeightedRandomIndex | ( | TArray< float32 > | Weights | ) |
Given an array of weights, returns a randomly chosen index where those with higher weights are more likely to be chosen.
To randomly choose an element of an array, make another array (of the same size) containing the weights of your elements. This function will then return a random index into that weight array. Since both arrays are of the same size, you can use that index on your original array.
Note: Weights cannot be negative!