summaryrefslogtreecommitdiff
path: root/npc/commands/titulate.txt
blob: c3679648479e7a3aa7be06ded13a5df99af81dbc (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// TMW2 Script
//
// @titulate <username>
// Grants a title to <username>. Cannot be undone.
// @cassate
// Opens a prompt to strip someone from their titles.
// Can also ban from titles. Grandmasters only.

-	script	@titulate	32767,{
    end;

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

    // 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 || .@them < 0) {
        mesc l("You can only concede or vouch a title for people of academic rank inferior than 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 vouched 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);
    }

    attachrid(.@ori);
    // Inform everyone
    kamibroadcast(sprintf("%s has vouched %s for the title of %s.",
                  strcharinfo(0), .@request$, academicrank(.@them+1)));
    // Log in a special log file as well
    logmes(sprintf("%s has vouched %s for the title of %s.",
                  strcharinfo(0), .@request$, academicrank(.@them+1)));

    close;

OnCassate:
    if (ACADEMIC_RANK < ACADEMIC_GM) {
        mesc l("Only Academy Grand Masters may cassate someone.");
        close;
    }
    mes ("To revoke someone's title and optionally apply a ban on them.");
    mes ("Please insert the nickname of person to cassate (they must be online)");
    input .@request$;
    if (.@request$ == "")
        close;
    mes ("Ban them from the Magic Academy as well?");
    .@ban=(askyesno() == ASK_YES);
    next;
    .@ori = getcharid(3);
    .@id = getcharid(3, .@request$);
    if (.@id < 1 || .@ori < 1) {
        Exception("Player not found.", RB_ISFATAL|RB_DISPBOTTOM);
    }

    // Execute the banishment
    if (attachrid(.@id)) {
        ACADEMIC_RANK=(.@ban ? -1 : ACADEMIC_LAYMAN);
        skill TMW2_STUDY, 0, 0;
        dispbottom l("Your academy titles have been rescinded%s",
            (.@ban ? l(", and you have been banned from the Academy.") : "."));
    } else {
        Exception("Player not found.", RB_ISFATAL|RB_DISPBOTTOM);
    }

    attachrid(.@ori);
    // Inform everyone
    kamibroadcast(sprintf("%s (A.GM) has stripped %s from their academic titles.",
                  strcharinfo(0), .@request$));
    // Log in a special log file as well
    logmes(sprintf("%s (Grandmaster) has stripped %s from their academic titles.",
                  strcharinfo(0), .@request$));

    close;

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

function	script	AutoTitulate	{
    .@ori = gettimetick(2); // Will never duplicate
    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:
        getexp 5000000, 150000;
        mesc "+500,000 exp";
        mesc "+150,000 job";
        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|RB_PLEASEREPORT);
    }

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

    // Inform everyone
    .@r = ACADEMIC_RANK + 1;
    kamibroadcast(sprintf("%s has vouched %s for the title of %s.",
                  "Hocus Pocus the Fidibus", strcharinfo(0), academicrank(.@r)));
    // Log in a special log file as well
    logmes(sprintf("%s has vouched %s for the title of %s.",
                  "Hocus Pocus the Fidibus", strcharinfo(0), academicrank(.@r)));

    // Continue
    return;
}