summaryrefslogtreecommitdiff
path: root/npc/functions/honor.txt
blob: 0d1c0138d05842f50d5444dd3be2721e60e73cfc (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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)
    // Or rather: battleparam()
    if (attachrid(.@rid)) {
        // 1 BR per allocated status point
        .@br+=battleparam(UDT_STR);
        .@br+=battleparam(UDT_AGI);
        .@br+=battleparam(UDT_VIT);
        .@br+=battleparam(UDT_DEX);
        .@br+=battleparam(UDT_INT);
        .@br+=battleparam(UDT_LUK);

        // 6 BR per level
        .@br+=BaseLevel*6;
    } 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;
}