summaryrefslogtreecommitdiff
path: root/npc/functions/math.txt
blob: 004125c7b08acbefcd9b13ed23a6bc430ad016fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
}