diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-05-24 13:47:28 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-05-24 13:47:28 -0300 |
commit | 9c322449ade0d1952f6ca4dd73cc92413f61ca69 (patch) | |
tree | 1bff0731c4db0790ef57a2d524d739b1241ffa2c /npc/functions/RNGesus.txt | |
parent | 9c649056dc45d39e88036bdb2bb373c477f8571f (diff) | |
parent | 255cf7c47f76a6e2f12fc809473ce513c294dfa4 (diff) | |
download | serverdata-jesusalva/inns.tar.gz serverdata-jesusalva/inns.tar.bz2 serverdata-jesusalva/inns.tar.xz serverdata-jesusalva/inns.zip |
Merge branch 'master' into jesusalva/innsjesusalva/inns
Diffstat (limited to 'npc/functions/RNGesus.txt')
-rw-r--r-- | npc/functions/RNGesus.txt | 20 |
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) { |