summaryrefslogtreecommitdiff
path: root/npc/commands/motd.txt
blob: 34af15106da55296d544cd3f63d03c245bbc2480 (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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
// TMW2 Script
function	script	displayMOTD	{
    .@size = getvariableofnpc(.size, "@motd");
    .@dsize = getvariableofnpc(.dsize, "@motd");

    // git stuff and such
    if (debug) {
        for (.@i = 0; .@i < .@dsize; ++.@i) {
            dispbottom $@Debug_Messages$[.@i]; // FIXME: send this to the Debug tab instead
        }

        if (.@dsize > 0)
            dispbottom "---";
    }

    // generic MOTD
    for (.@i = 0; .@i < .@size; ++.@i) {
        dispbottom $MOTD_Messages$[.@i];
    }

    return;
}

function	script	MOTDConfig	{

    function toggleMOTD {
        $MOTD_Disabled = !($MOTD_Disabled);
            logmes "MOTD modified: toogled: enable/disable", LOGMES_ATCOMMAND;
    }

    function addNewLine {
        clear;
        mes l("Please enter the new line.");
        input .@s$;
        .@s$ = strip(.@s$);
        if (.@s$ != "") {
            .@size = getvariableofnpc(.size, "@motd");
            $MOTD_Messages$[.@size] = .@s$;
            set getvariableofnpc(.size, "@motd"), getarraysize($MOTD_Messages$);
            logmes "MOTD modified: line added", LOGMES_ATCOMMAND;
        }
    }

    function modifyLine {

        function removeLine {
            .@l = getarg(0);
            deletearray $MOTD_Messages$[.@l], 1; // remove and shift
            mes l("Line @@ has been removed.", .@l);
            set getvariableofnpc(.size, "@motd"), getarraysize($MOTD_Messages$);
            logmes "MOTD modified: line removed", LOGMES_ATCOMMAND;
        }

        function moveUp {
            .@l = getarg(0);
            .@top$ = $MOTD_Messages$[.@l - 1];
            $MOTD_Messages$[.@l - 1] = $MOTD_Messages$[.@l];
            $MOTD_Messages$[.@l] = .@top$;
        }

        function moveDown {
            .@l = getarg(0);
            .@bottom$ = $MOTD_Messages$[.@l + 1];
            $MOTD_Messages$[.@l + 1] = $MOTD_Messages$[.@l];
            $MOTD_Messages$[.@l] = .@bottom$;
        }

        function editLine {
            .@l = getarg(0);
            clear;
            mes l("Old line:");
            mes "---";
            mes $MOTD_Messages$[.@l];
            mes "---";
            mes "";
            mes l("Enter new line:");
            next;
            input .@s$;
            .@s$ = strip(.@s$);
            if (.@s$ != "") {
                $MOTD_Messages$[.@l] = .@s$;
                logmes "MOTD modified: line edited", LOGMES_ATCOMMAND;
            }
        }

        .@max = (getarg(0) - 1);

        do
        {
            mes l("Enter line number:");
            next;
            input .@n;
            if ($MOTD_Messages$[.@n] != "") {
                clear;
                mes l("line @@: @@", .@n, $MOTD_Messages$[.@n]);
                next;
                select
                    menuimage("actions/back", l("Modify another line")),
                    menuimage("actions/remove", l("Remove this line")),
                    menuimage("actions/edit", l("Modify this line")),
                    rif(.@n > 0, menuimage("actions/raise", l("Move this line up"))),
                    rif(.@n < .@max, menuimage("actions/lower", l("Move this line down"))),
                    menuimage("actions/home", l("Return to main menu"));

                switch (@menu) {
                    case 2: removeLine .@n; return;
                    case 3: editLine .@n; return;
                    case 4: moveUp .@n; return;
                    case 5: moveDown .@n; return;
                    case 6: return;
                }
            }
        } while (1);
    }

    do
    {
        clear;
        setnpcdialogtitle l("MOTD Config");
        mes l("This menu allows you to modify the generic message that is sent to players when they log in.");
        mes "";

        mes "---";
        .@size = getvariableofnpc(.size, "@motd");
        for (.@i = 0; .@i < .@size; ++.@i) {
            mes l("line @@: @@", .@i, $MOTD_Messages$[.@i]);
        }
        if (.@size == 0) {
            mes "(" + l("no active MOTD") + ")";
        }
        mes "---";
        .@d = $MOTD_Disabled;
        mes l("Enabled: @@", (.@d ? l("no") : l("yes")));
        next;

        select
            menuimage("actions/toggle", (.@d ? l("Enable") : l("Disable"))),
            menuimage("actions/add", l("Add a new line")),
            rif(.@size, menuimage("actions/manage", l("Modify, move, or remove a line"))),
            rif(.@size, menuimage("actions/test", l("Test MOTD"))),
            rif(getarg(0,0), menuimage("actions/home", l("Return to Super Menu")));

        switch (@menu) {
            case 1: toggleMOTD; break;
            case 2: addNewLine; break;
            case 3: modifyLine .@size; break;
            case 4: displayMOTD; break;
            default: return;
        }
    } while (1);
}



-	script	@motd	32767,{
    end;

OnCall:
    if (!is_admin()) {
        end;
    }

    MOTDConfig;
    closedialog;
    end;

OnPCLoginEvent:
    if ($MOTD_Disabled < 1) {
        displayMOTD;
    }
    if (debug) {
        dispbottom "##7<<##B @@help://test-server|" + col(l("Click here for instructions on how to use the test server."),6) + "@@ ##7>>";
    }

    // Handle daily login bonus
    // The Strange Coin output wasn't changed, but now it relies on streaks.
    // Variables:
    //  #LOGIN_DAY
    //      Current day
    //  #LOGIN_TABLE
    //      Current month
    //  #LOGIN_STREAK
    //      Number of monthly connections
    //  #LOGIN_ALLTIME
    //      Number of times you claimed the top prize (27 days streak)

    if (#LOGIN_DAY != .login_ref) {
        // Is it a new month?
        if (#LOGIN_TABLE == gettime(6)) {
            #LOGIN_STREAK=#LOGIN_STREAK+1;
        } else {
            #LOGIN_STREAK=1;
            #LOGIN_TABLE=gettime(6);
        }

        // Update last day you've claimed a reward
        #LOGIN_DAY = .login_ref;

        // Handle rewards: Streaks first, daily later. Streak reward prevail over daily reward.
        if (#LOGIN_STREAK > 27) {
            getitem StrangeCoin, 2;
            dispbottom l("##2 @@ Days login bonus: ##B2x @@##b", #LOGIN_STREAK, getitemlink(StrangeCoin));
        } else if (#LOGIN_STREAK == 27) {
            #LOGIN_ALLTIME+=1;
            // Your prize is based on season
            switch (season()) {
                case AUTUMN:
                    .@prize=ChocolateDye; break; // Maybe a LightGreenDiamond? Well, even an ElixirOfLife is better!
                case WINTER:
                    .@prize=SilverGift; break;
                case SPRING:
                    .@prize=Toothbrush; break;
                case SUMMER:
                    .@prize=RightEyePatch; break;
            }
            // Some special cases
            if (#LOGIN_ALLTIME == 3)
                .@prize=GoldenGift;
            if (#LOGIN_ALLTIME == 8)
                .@prize=PrismGift;

            if (#LOGIN_ALLTIME == 12) {
                dispbottom l("CONGRATULATIONS! For a year worth of logins, you're getting a pet!");
                makepet Piou; // we must replace this before August 2019. (r18 probably)
            }

            getitem .@prize, 1;
            dispbottom l("##2 27 Days login bonus: ##B1x @@##b", getitemlink(.@prize));
        } else if (#LOGIN_STREAK == 21) {
            getitem StrangeCoin, 7;
            dispbottom l("##2 21 Days login bonus: ##B7x @@##b", getitemlink(StrangeCoin));
        } else if (#LOGIN_STREAK == 14) {
            getitem StrangeCoin, 5;
            dispbottom l("##2 14 Days login bonus: ##B5x @@##b", getitemlink(StrangeCoin));
        } else if (#LOGIN_STREAK == 7) {
            getitem StrangeCoin, 2;
            dispbottom l("##2 7 Days login bonus: ##B2x @@##b", getitemlink(StrangeCoin));
        } else if (#LOGIN_STREAK == 3) {
            getitem StrangeCoin, 1;
            dispbottom l("##2 3 Days login bonus: ##B1x @@##b", getitemlink(StrangeCoin));
        } else if (.login_ref % 3 == 0) {
            .@value=max(5, rand(0, (#LOGIN_STREAK/4)));
            .@value+=(BaseLevel**2);
            getexp .@value, 0;
            dispbottom l("##2Daily login bonus: ##B@@ EXP##b", .@value);
        } else if (.login_ref % 3 == 1) {
            .@value=max(20, rand(0, (#LOGIN_STREAK*2)));
            .@value+=(BaseLevel+JobLevel);
            Zeny=Zeny+.@value;
            dispbottom l("##2Daily login bonus: ##B@@ GP##b", .@value);
        } else {
            .@value=max(5, rand(0, (#LOGIN_STREAK/4)));
            .@value+=(JobLevel**2);
            getexp 0, .@value;
            dispbottom l("##2Daily login bonus: ##B@@ Job Exp.##b", .@value);
        }
    }

    end;

OnClock0000:
    .login_ref=gettime(5); // Day of moth
    end;

OnInit:
    .login_ref=gettime(5);
    .daylength=(60*60*24);
    MOTD_debug_text;
    .size = getarraysize($MOTD_Messages$);
    .dsize = getarraysize($@Debug_Messages$);
    bindatcmd "motd", "@motd::OnCall", 99, 99, 1;
}