summaryrefslogblamecommitdiff
path: root/npc/functions/honor.txt
blob: e09f6b02f25aab3f0128a2c1a4d908fca2259a8d (plain) (tree)



























































                                                                                                  
// TMW2 Script
// Author:
//  Jesusalva
// Description:
//  PvP Honor Rank system

// Numerical representation of player strength
// get_BR( getcharid(3) )
function	script	get_BR	{
    .@oid=getcharid(3);
    .@rid=getarg(0, .@oid);
    .@br=0;

    // attachrid() and detachrid()
    // readbattleparam(.@rid)
    // Load
    if (attachrid(.@rid)) {
        .@br+=BaseLevel;
    } else {
        Exception("GET_BR INVALID RID "+.@rid, RB_DEBUGMES|RB_IRCBROADCAST);
    }

    // Restore
    detachrid();
    if (!attachrid(.@oid))
        Exception("::FATAL :: GET_BR INVALID OID "+.@oid, RB_DEBUGMES|RB_IRCBROADCAST|RB_ISFATAL);

    return .@br;
}

// Calculate the Honor Points which are due
// calc_HR( get_BR(getcharid(3)), get_BR(killedrid) )
function	script	calc_HR	{
    .@atk_br=getarg(0);
    .@def_br=getarg(1);
    .@cbase=10000;

    // Dishonorable
    if (.@atk_br > .@def_br) {
        .@overpower=.@atk_br*.@cbase/.@def_br;
    // Honorable
    } else if (.@def_br > .@atk_br) {
        .@overpower=.@atk_br*.@cbase/.@def_br;
    // Neutral
    } else {
        .@overpower=0;
    }

    return 0;
}

// getvariableofpc(HONOR, .@rid, 0) < 0 → determine if other player is bandit
// is_bandit( account id )
function	script	is_bandit	{
    .@oid=getcharid(3);
    .@rid=getarg(0, .@oid);

    return getvariableofpc(HONOR, .@rid, 0) < 0;
}