summaryrefslogtreecommitdiff
path: root/npc/functions/RNGesus.txt
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-04-09 13:33:57 -0300
committerJesusaves <cpntb1@ymail.com>2021-04-09 13:33:57 -0300
commitcf18ce071c79ae37e14ea38943e0b1d88da70a7b (patch)
treef9159c9b60b3018300dd22ffba0d797bc5e828e5 /npc/functions/RNGesus.txt
parent8a4bf716002a017de77fe7df301ef8e4aaf00a2e (diff)
downloadserverdata-cf18ce071c79ae37e14ea38943e0b1d88da70a7b.tar.gz
serverdata-cf18ce071c79ae37e14ea38943e0b1d88da70a7b.tar.bz2
serverdata-cf18ce071c79ae37e14ea38943e0b1d88da70a7b.tar.xz
serverdata-cf18ce071c79ae37e14ea38943e0b1d88da70a7b.zip
Override
Diffstat (limited to 'npc/functions/RNGesus.txt')
-rw-r--r--npc/functions/RNGesus.txt87
1 files changed, 0 insertions, 87 deletions
diff --git a/npc/functions/RNGesus.txt b/npc/functions/RNGesus.txt
deleted file mode 100644
index 7224977c..00000000
--- a/npc/functions/RNGesus.txt
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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(rand2(getargcount()));
-}
-
-
-
-// any_of(<array>)
-// returns any member of the array
-
-function script any_of {
- return getelementofarray(getarg(0), getarrayindex(getarg(0)) + rand2(getarraysize(getarg(0)) - getarrayindex(getarg(0))));
-}
-
-
-
-// relative_array_random(<array: 0, {[value, probability]..}>)
-// returns a random entry from the array, by relative probability
-// the first key of the array should be 0 and every entries are a tuple
-// of [value, probability]
-
-function script relative_array_random {
- .@is_str = getdatatype(getarg(0)) & DATATYPE_STR;
- .@total_prob = getelementofarray(getarg(0), 0);
- .@initial_index = getarrayindex(getarg(0));
- .@initial_index = .@initial_index ? .@initial_index : 1;
- freeloop(true);
-
- if (.@total_prob < 1 || getarg(1, false))
- {
- // first calculation, or forced re-calculation
- .@total_prob = 0;
- .@size = getarraysize(getarg(0));
-
- for (.@i = .@initial_index + 1; .@i < .@size; .@i += 2) {
- if (.@is_str) {
- .@total_prob += max(1, atoi(getelementofarray(getarg(0), .@i)));
- } else {
- .@total_prob += max(1, getelementofarray(getarg(0), .@i));
- }
- }
-
- // we cache on the first key
- set(getelementofarray(getarg(0), 0), .@total_prob);
- }
-
- .@target_sum = rand2(0, .@total_prob);
-
- for (.@i = .@initial_index; .@sum < .@target_sum; .@i += 2) {
- if (.@is_str) {
- .@sum += atoi(getelementofarray(getarg(0), .@i + 1));
- } else {
- .@sum += getelementofarray(getarg(0), .@i + 1);
- }
-
- if (.@sum >= .@target_sum) {
- break;
- }
- }
-
- freeloop(false);
- return getelementofarray(getarg(0), .@i);
-}