summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-06-01 21:00:28 -0300
committerJesusaves <cpntb1@ymail.com>2019-06-01 21:00:28 -0300
commitd3c277d189ff513258f290c84680d275c4d05e0c (patch)
treee7686c509ab12777db1a57facb67a84e77772c88 /npc
parentefd4f4a94d351ae1aec3261df2857638b600c08d (diff)
downloadserverdata-d3c277d189ff513258f290c84680d275c4d05e0c.tar.gz
serverdata-d3c277d189ff513258f290c84680d275c4d05e0c.tar.bz2
serverdata-d3c277d189ff513258f290c84680d275c4d05e0c.tar.xz
serverdata-d3c277d189ff513258f290c84680d275c4d05e0c.zip
Improve randomizer functions with rand2() - a fix proposed by 4144.
Diffstat (limited to 'npc')
-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