summaryrefslogtreecommitdiff
path: root/npc/functions/math.txt
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-08-20 11:34:59 -0400
committergumi <mekolat@users.noreply.github.com>2017-08-22 11:26:46 -0400
commite9c90337a6057b66faad6759ff418e8a5f162cfe (patch)
tree28dd5e161c5cf2d188a93b8f128b5d38c27e1004 /npc/functions/math.txt
parent7c7b7cb886290a4b339e15e2f27ce5b5e86aa85a (diff)
downloadserverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.gz
serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.bz2
serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.xz
serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.zip
reorganize the framework functions
Diffstat (limited to 'npc/functions/math.txt')
-rw-r--r--npc/functions/math.txt40
1 files changed, 40 insertions, 0 deletions
diff --git a/npc/functions/math.txt b/npc/functions/math.txt
new file mode 100644
index 00000000..004125c7
--- /dev/null
+++ b/npc/functions/math.txt
@@ -0,0 +1,40 @@
+// Evol functions.
+// Authors:
+// 4144
+// Reid
+// Description:
+// Math functions
+
+
+// abs(<int>)
+// returns the absolute value of the passed integer
+
+function script abs {
+ .@n = getarg(0);
+ return .@n >= 0 ? .@n : -.@n;
+}
+
+
+
+// lognbaselvl({<multiplicator>{, <min value>}})
+// returns BaseLevel * logn (BaseLevel * alpha).
+
+function script lognbaselvl {
+ .@alpha = getarg(0, 1);
+ .@min = getarg(1, 1);
+ .@ret = 0;
+ .@pc_level = BaseLevel * .@alpha;
+
+ while (.@pc_level >>= 1)
+ {
+ ++.@ret;
+ }
+ .@ret *= BaseLevel;
+
+ if (.@ret <= .@min)
+ {
+ .@ret = .@min;
+ }
+
+ return .@ret;
+}