summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-06-16 23:31:22 -0300
committerJesusaves <cpntb1@ymail.com>2019-06-16 23:31:22 -0300
commitae22105e139fa53a8e3b6da12d53e819bcb2fb55 (patch)
treeabec1c792138cb9d1ad8e5eb98244b60bdbcc6f2
parentdda858e0a477a5f84848acaf3fce06c1bea45418 (diff)
downloadserverdata-ae22105e139fa53a8e3b6da12d53e819bcb2fb55.tar.gz
serverdata-ae22105e139fa53a8e3b6da12d53e819bcb2fb55.tar.bz2
serverdata-ae22105e139fa53a8e3b6da12d53e819bcb2fb55.tar.xz
serverdata-ae22105e139fa53a8e3b6da12d53e819bcb2fb55.zip
Fix bugs on rand2()
-rw-r--r--npc/functions/main.txt9
1 files changed, 3 insertions, 6 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt
index 9d8c331d6..c0fa64282 100644
--- a/npc/functions/main.txt
+++ b/npc/functions/main.txt
@@ -249,7 +249,7 @@ function script rand2 {
.@max=getarg(1)*10+9;
} else {
.@min=0;
- .@max=getarg(0)*10+9;
+ .@max=getarg(0)*10-1;
}
return rand(.@min, .@max)/10;
}
@@ -257,16 +257,13 @@ function script rand2 {
// returns one argument randomly
// any( <arg>{, ...<arg>} )
function script any {
- return getarg(rand2(getargcount()-1));
+ return getarg(rand2(getargcount()));
}
// returns any member of the array
// any_of( <array> )
function script any_of {
- .@rand=rand2(getarraysize(getarg(0)) - getarrayindex(getarg(0)) + 1);
- return getelementofarray(getarg(0),
- getarrayindex(getarg(0)) +
- max(0, .@rand-1));
+ return getelementofarray(getarg(0), getarrayindex(getarg(0)) + rand(getarraysize(getarg(0)) - getarrayindex(getarg(0))));
}
// TMW2 Custom Functions