From 20df2abc1aca00d6aa5dc78347133890f36b32f3 Mon Sep 17 00:00:00 2001 From: Saulc Date: Sat, 13 Jan 2018 20:50:42 +0100 Subject: Initial commit --- npc/functions/math.txt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 npc/functions/math.txt (limited to 'npc/functions/math.txt') diff --git a/npc/functions/math.txt b/npc/functions/math.txt new file mode 100644 index 000000000..004125c7b --- /dev/null +++ b/npc/functions/math.txt @@ -0,0 +1,40 @@ +// Evol functions. +// Authors: +// 4144 +// Reid +// Description: +// Math functions + + +// abs() +// returns the absolute value of the passed integer + +function script abs { + .@n = getarg(0); + return .@n >= 0 ? .@n : -.@n; +} + + + +// lognbaselvl({{, }}) +// 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; +} -- cgit v1.2.3-60-g2f50