viewing paste Unknown #24526 | C

Posted on the
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
/**
 * a = Attached player rating
 * b = killed / killer rating
 * k = coeficient
 * r = rating
 *
 * return: r = rating.
 */
BUILDIN(calc_rank)
{
    struct map_session_data *sd = script->rid2sd(st);
    int a, b, k, r;
    
    if (sd == NULL)
        return true;
    
    a = script_getnum(st, 2);
    b = script_getnum(st, 3);
    
    if( a > b )
    {
        k = ( a / ( b == 0? 2:b ) );
        r = 1 + ( k > 0? k:1 );
    }
    else if( a < b )
    {
        k = ( b / ( a == 0? 2:a ) );
        r = 2 + ( k > 0? k:2 );     
    }
    else r = 2;
    
    script_pushint( st, r );
    return true;
}
 
 
BUILDIN_DEF(calc_rank,"ii"),
Viewed 687 times, submitted by Guest.