summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--npc/functions/main.txt17
1 files changed, 15 insertions, 2 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt
index 075142e12..2aa670ca4 100644
--- a/npc/functions/main.txt
+++ b/npc/functions/main.txt
@@ -241,16 +241,29 @@ function script npctalkonce {
// Randomizer functions
/////////////////////////////////////////////
+// pseudo-fix randomness
+// rand2( min, max )
+function script rand2 {
+ if (getargcount() == 2) {
+ .@min=getarg(0)*10;
+ .@max=getarg(1)*10+9;
+ } else {
+ .@min=0;
+ .@max=getarg(0)*10+9;
+ }
+ return rand(.@min, .@max)/10;
+}
+
// returns one argument randomly
// any( <arg>{, ...<arg>} )
function script any {
- return getarg(rand(getargcount()));
+ return getarg(rand2(getargcount()));
}
// returns any member of the array
// any_of( <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))));
}
// TMW2 Custom Functions