summaryrefslogtreecommitdiff
path: root/npc/commands/titulate.txt
blob: ee3031837f29f3b37fb82e9542a00183831656f5 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// TMW2 Script
//
// @grantpower <username>
// Grants a legendary weapon to <username>. Cannot be undone.
// Only way to bypass restrictions on legendary weapons.

-	script	@titulate	32767,{
    end;

OnCall:
    .@request$ = "";
	.@request$ += implode(.@atcmd_parameters$, " ");

    // No argument supplied
    if (.@request$ == "") {
        Exception("Usage: @titulate <target charname>", RB_ISFATAL|RB_DISPBOTTOM);
    }

    // Player is not attached
    .@ori = getcharid(3);
    .@id = getcharid(3, .@request$);
    if (.@id < 1 || .@ori < 1) {
        Exception("Player not found.", RB_ISFATAL|RB_DISPBOTTOM);
    }

    // Obtain your own title
    .@mine=ACADEMIC_RANK;
    .@them=getvariableofpc(ACADEMIC_RANK, .@id, 99);

    mes ".:: " + l("Titulation") + " ::.";
    if (.@mine <= .@them) {
        mesc l("You can only concede or vouch a title for people of academic rank smaller or equal to your own.");
        close;
    }

    mesc l("You're about to concede an academic title to \"@@\".", .@request$), 1;
    mesc l("If this is found out to be a fraudulent titulation, both you as target will have their titles cased by the Academic Council, or by the Alliance High Council."), 1;
    mesc l("This action CANNOT BE UNDONE."), 1;
    mes l("Are you sure?");
    if (askyesno() == ASK_NO)
        close;

    // Grant the title
    if (attachrid(.@id)) {
        switch (ACADEMIC_RANK) {
        case ACADEMIC_LAYMAN:
        case ACADEMIC_STUDENT:
        case ACADEMIC_TECHNIC:
            // Instant promotion
            ACADEMIC_RANK+=1;
            .@upgrade=true;
            break;
        case ACADEMIC_BACHELOR:
        case ACADEMIC_MASTER:
            // Two-Man rule
            if (array_find(ACADEMIC_VOUCH, .@ori)) {
                end;
            }
            array_push(ACADEMIC_VOUCH, .@ori);
            if (array_entries(ACADEMIC_VOUCH) >= 2) {
                ACADEMIC_RANK+=1;
                deletearray(ACADEMIC_VOUCH);
                .@upgrade=true;
            }
            break;
        case ACADEMIC_DOCTOR:
        case ACADEMIC_PHD:
            // Three-Man rule
            if (array_find(ACADEMIC_VOUCH, .@ori)) {
                end;
            }
            array_push(ACADEMIC_VOUCH, .@ori);
            if (array_entries(ACADEMIC_VOUCH) >= 3) {
                ACADEMIC_RANK+=1;
                deletearray(ACADEMIC_VOUCH);
                .@upgrade=true;
            }
            break;
        // Invalid
        case ACADEMIC_SAGE:
            Exception("The Grand Master title can only be issued by the president of the Alliance High Council.", RB_ISFATAL|RB_SPEECH);
        default:
            Exception("Invalid titulation rank: "+ACADEMIC_RANK, RB_ISFATAL|RB_SPEECH);
        }

        // Message
        if (.@upgrade) {
            dispbottom l("You received the %s title from %s.",
                         academicrank(), strcharinfo(0, "someone", .@ori));
        } else {
            dispbottom l("You were vouced to the %s title by %s. You still need %d more vouches to be promoted.",
                        academicrank(ACADEMIC_RANK+1), strcharinfo(0, "someone", .@ori),
                        (ACADEMIC_RANK >= ACADEMIC_DOCTOR ? 3 : 2) - array_entries(ACADEMIC_VOUCH));
        }

    // Oops, player disconnected
    } else {
        Exception("Player not found.", RB_ISFATAL|RB_SPEECH);
    }

    // Inform everyone
    kamibroadcast(sprintf("%s has vouched %s for the title of %s.",
                  strcharinfo(0), .@request$, academicrank(.@them+1)));

    close;

OnInit:
    bindatcmd "titulate", "@titulate::OnCall", 0, 100, 1;
}