summaryrefslogblamecommitdiff
path: root/npc/functions/math.txt
blob: 357407dadc11d1a62814ebf35a63f189e9394794 (plain) (tree)
1
2
3
4
5



                  
               



































                                                      








                                                     
// Evol functions.
// Authors:
//    4144
//    Reid
//    Jesusalva
// 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;
}


// result is: lower < target <= higher
// is_between ( lower, higher, target)
function	script	is_between	{
    .@val=getarg(2);
    return (getarg(0) < .@val && getarg(1) >= .@val);
}