summaryrefslogtreecommitdiff
path: root/npc/functions/RNGesus.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/functions/RNGesus.txt')
-rw-r--r--npc/functions/RNGesus.txt20
1 files changed, 17 insertions, 3 deletions
diff --git a/npc/functions/RNGesus.txt b/npc/functions/RNGesus.txt
index 6883f8f1..7224977c 100644
--- a/npc/functions/RNGesus.txt
+++ b/npc/functions/RNGesus.txt
@@ -1,16 +1,30 @@
// Evol functions.
// Authors:
// gumi
+// jesusalva
// Description:
// Randomization helper functions.
+// pseudo-fix randomness
+// rand2( min, max )
+function script rand2 {
+ if (getargcount() == 2) {
+ .@min=getarg(0)*100;
+ .@max=getarg(1)*100+99;
+ } else {
+ .@min=0;
+ .@max=getarg(0)*100-1;
+ }
+ return rand(.@min, .@max)/100;
+}
+
// any(<arg>{, ...<arg>})
// returns one argument randomly
function script any {
- return getarg(rand(getargcount()));
+ return getarg(rand2(getargcount()));
}
@@ -19,7 +33,7 @@ function script any {
// returns any member of the array
function script any_of {
- return getelementofarray(getarg(0), getarrayindex(getarg(0)) + rand(getarraysize(getarg(0)) - getarrayindex(getarg(0))));
+ return getelementofarray(getarg(0), getarrayindex(getarg(0)) + rand2(getarraysize(getarg(0)) - getarrayindex(getarg(0))));
}
@@ -54,7 +68,7 @@ function script relative_array_random {
set(getelementofarray(getarg(0), 0), .@total_prob);
}
- .@target_sum = rand(0, .@total_prob);
+ .@target_sum = rand2(0, .@total_prob);
for (.@i = .@initial_index; .@sum < .@target_sum; .@i += 2) {
if (.@is_str) {