summaryrefslogtreecommitdiff
path: root/npc/081-2/logic.txt
blob: 6059197163eb206bc68bd34f7836c2160445874d (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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
// TMW Script.
// Author:
//    Jesusalva
// Notes:
//    Christmas 2021 - Northen Lights Dungeon

081-2,90,20,0	script	#0812Nexit	NPC_HIDDEN,0,0,{
    end;
OnTouch:
    if (!isChristmas21()) end;
    if (!'XMAS21AMBUSH) end;
    if (!'XMAS21CANDLE) end;
    if (!'XMAS21TREE) end;
    /* We need to determine if instance exists and is needed */
    X21INIT();

	.@mapn$="0813@"+X21ID2();

    /* Boss Chamber may be... unique */
    if ('LOCKD) {
        if (getmapusers(.@mapn$) > 0) {
            dispbottom l("Northern Lights")+" : "+l("This chamber is full.");
            end;
        } else {
            // Cleanup the chamber
            doevent instance_npcname("Pentagram#Xmas21A", instance_id())+"::OnClean";
        }
    }

    warp .@mapn$, 44, 49;
    end;
}

/* *************************************************************************** */
/* Candle Puzzle */
081-2,130,255,0	script	#X21Candle_0	NPC_NO_SPRITE,{
    if (!countitem(ThermalNapalm)) { dispbottom(l("I don't have anything to lit this candle.")); end; }
    if ('XMAS21CANDLE) end;
    // Extract ID
    .@n$=strnpcinfo(2, "_-1");
    explode(.@ni$, .@n$, "_");
    .@id=atoi(.@ni$[1]);
    if (.@id < 0) { consolemes(CONSOLEMES_ERROR, "ERROR, X21 Invalid Candle"); end; }
    .@c = 'X21_CANDLE[.@id];
    .@c$ = (.@c == 0 ? l("No") : (.@c == 1 ? l("Regular") : l("Magic")));

    mes l("This candle is using %s Fire.", .@c$);
    mes l("Do you want to change it?");
    mesc l("Cost: 1x %s", getitemlink(ThermalNapalm)), 1;
    next;
    menuint
        l("No, leave it alone."), -1,
        rif(.@c != 1, l("Lit a regular fire.")), 1,
        rif(.@c != 2, l("Lit a magic fire.")), 2,
        rif(.@c != 0, l("Remove the fire.")), 0;
    mes "";
    if (@menuret < 0) { closeclientdialog; close; }
    delitem ThermalNapalm, 1;
    'X21_CANDLE[.@id] = @menuret;
    // Modify the flame sprite
    setnpcdisplay(instance_npcname(strnpcinfo(0)), (@menuret ? (@menuret == 1 ? NPC436 : NPC437) : NPC_NO_SPRITE));
    //debugmes "Sprite %s (%s) to %d", strnpcinfo(0), instance_npcname(strnpcinfo(0)), (@menuret ? (@menuret == 1 ? NPC436 : NPC437) : NPC_NO_SPRITE);
    // What about 374 instead of 437?
    // Unlock the gate once the puzzle is complete
    if (X21CANDLE_CHECK()) {
        delcells("X21L1@"+X21ID());
        specialeffect(FX_MAGIC_WICKED_SPAWN, AREA, getcharid(3));
        mapannounce getmap(), "Puzzle solved by "+strcharinfo(0), 0;
        getexp X21_EXP_PUZZLE, 0;
        getitem XmasTicket, X21_TICKET_PUZZLE;
        X21INIT();
    }
    closeclientdialog;
    close;
OnInit:
    .distance=1;
    end;
}

081-2,131,257,0	duplicate(#X21Candle_0)	#X21Candle_1	NPC_NO_SPRITE
081-2,132,249,0	duplicate(#X21Candle_0)	#X21Candle_2	NPC_NO_SPRITE
081-2,133,253,0	duplicate(#X21Candle_0)	#X21Candle_3	NPC_NO_SPRITE
081-2,134,258,0	duplicate(#X21Candle_0)	#X21Candle_4	NPC_NO_SPRITE
081-2,135,251,0	duplicate(#X21Candle_0)	#X21Candle_5	NPC_NO_SPRITE

081-2,79,279,0	script	Hint#X21C0	NPC_NO_SPRITE,{
    .@c = 0;
    .@c += ('COLORCODE[0] ? 0 : 1);
    .@c += ('COLORCODE[1] ? 0 : 1);
    .@c += ('COLORCODE[2] ? 0 : 1);
    .@c += ('COLORCODE[3] ? 0 : 1);
    .@c += ('COLORCODE[4] ? 0 : 1);
    .@c += ('COLORCODE[5] ? 0 : 1);
    dispbottom l("%d candles should always be off.", .@c);
    end;
OnInit:
    .distance=1;
    end;
}

081-2,65,274,0	script	Hint#X21C1	NPC_NO_SPRITE,{
    .@c = 0;
    .@c += ('COLORCODE[0] == 1 ? 1 : 0);
    .@c += ('COLORCODE[1] == 1 ? 1 : 0);
    .@c += ('COLORCODE[2] == 1 ? 1 : 0);
    .@c += ('COLORCODE[3] == 1 ? 1 : 0);
    .@c += ('COLORCODE[4] == 1 ? 1 : 0);
    .@c += ('COLORCODE[5] == 1 ? 1 : 0);
    dispbottom l("%d candles should use regular fire.", .@c);
    end;
OnInit:
    .distance=1;
    end;
}

081-2,51,271,0	script	Hint#X21C2	NPC_NO_SPRITE,{
    if ('COLORCODE[0] == 2)
        dispbottom l("The leftmost candle is magical.");
    else if ('COLORCODE[5] == 2)
        dispbottom l("The rightmost candle is magical.");
    else
        dispbottom l("Neither extremes are magical.");
OnInit:
    .distance=1;
    end;
}

081-2,41,267,0	script	Hint#X21C3	NPC_NO_SPRITE,{
    if ('COLORCODE[0] == 'COLORCODE[5])
        dispbottom l("The leftmost and the rightmost candle are identical.");
    else
        dispbottom l("The left-right extremes are different.");
OnInit:
    .distance=1;
    end;
}

081-2,51,247,0	script	Hint#X21C4	NPC_NO_SPRITE,{
    .@n$ = ('COLORCODE[2] ? ('COLORCODE[2] == 1 ? "Regular" : "Magical") : "No");
    dispbottom l("The northmost candle should use %s Fire.", .@n$);
OnInit:
    .distance=1;
    end;
}

081-2,63,236,0	script	Hint#X21C5	NPC_NO_SPRITE,{
    .@n$="";
    if (!'COLORCODE[3])
        .@n$=('OBSCURECOLOR ? "Regular" : "Magical");
    else if ('COLORCODE[3] == 1)
        .@n$=('OBSCURECOLOR ? "No" : "Magical");
    else
        .@n$=('OBSCURECOLOR ? "Regular" : "No");

    dispbottom l("The central candle should NOT use %s Fire.", .@n$);
OnInit:
    .distance=1;
    end;
}

081-2,88,257,0	script	Hint#X21C6	NPC_NO_SPRITE,{
    .@c=('COLORCODE[1]+'COLORCODE[4]);
    if (.@c <= 1)
        .@n$="Bleakness, at best Regular Fire";
    else if (.@c >= 3)
        .@n$="Brightness, probably Magical Fire";
    else
        .@n$="either Regular Fire, or they may diverge";

    dispbottom l("The two southern candles lean towards %s.", .@n$);
OnInit:
    .distance=1;
    end;
}

081-2,103,213,0	script	#X21Barrier1	NPC_HIDDEN,4,1,{
    @inst = instance_id() + 1;
    if (!'XMAS21CANDLE) {
        dispbottom l("Northern Lights")+" : "+l("The strong shall yield the %s to enlighten the way, according to the established sequence.", b(l("powder")));
        slide 105, 214;
        if (checkcell(getmap(), 105, 212, cell_chkpass))
            setcells getmap(), 103, 211, 107, 212, 1, "X21L1@"+X21ID();
    }
    end;
OnInit:
    .distance=1;
    end;
}

/* *************************************************************************** */
/* Seeds Puzzle - See 2021.txt */

081-2,127,129,0	script	#X21Barrier2	NPC_HIDDEN,4,0,{
    if (!'XMAS21TREE) {
        npctalkonce l("In this year Christmas, kids shall play ball. Once the Christmas Tree is set, the festivities may proceed.");
        slide 127, 130;
        if (checkcell(getmap(), 127, 128, cell_chkpass))
            setcells getmap(), 124, 127, 131, 128, 1, "X21L2@"+X21ID();
    }
    end;
OnInit:
    .distance=1;
    end;
}

081-2,118,169,0	script	#X21SeedFlag	NPC_NO_SPRITE,{
    @inst = instance_id() + 1;
    if (!'XMAS21TREE)
        npctalkonce l("Tiny leaves in a room, the objects from the other; When they merge together, the festivities shall proceed.");
    end;
OnPlant:
    getmapxy(.@m$, .@x, .@y, 0);
    // Should never happen, so nuke everything
    if (instance_id() < 0) end;
    // Already planted this spot
    if ('XMAS21TREE_X[.@x] && 'XMAS21TREE_Y[.@y]) end;
    // Record the success planting it
    'XMAS21TREE_X[.@x] = true;
    'XMAS21TREE_Y[.@y] = true;
    // Sprout a Christmas Tree IF position was not already filled
    monster(.@m$, .@x, .@y, strmobinfo(1, ChristmasTree), ChristmasTree, 1, "#XMAS21Core::OnX1164");
    // Unlock the gate once the puzzle is complete
    if (X21SEED_CHECK()) {
        delcells("X21L2@"+X21ID());
        specialeffect(FX_MAGIC_WICKED_SPAWN, AREA, getcharid(3));
        mapannounce getmap(), "Puzzle solved by "+strcharinfo(0), 0;
        getexp X21_EXP_PUZZLE, 0;
        getitem XmasTicket, X21_TICKET_PUZZLE;
        X21INIT();
    }
    end;
OnInit:
    .distance=2;
    end;
}

/* *************************************************************************** */
/* Ambush Puzzle */

081-2,49,73,0	script	#X21Barrier3	NPC_HIDDEN,2,0,{
    if (!'XMAS21AMBUSH) {
        npctalkonce l("One room, Seventeen buttons, Three truths, and a lever to bring joy to the children.");
        slide 49, 74;
        if (checkcell(getmap(), 49, 72, cell_chkpass))
            setcells getmap(),  47,  71,  51,  72, 1, "X21L3@"+X21ID();
    }
    end;
OnInit:
    .distance=1;
    end;
}

081-2,112,90,0	script	Nutcracker O'Panel#X21	NPC_NO_SPRITE,{
    if ('XMAS21AMBUSH)
        end;
    mes l("This Nutcracker has a lever on it.");
    mesc l("Do you flip it?"), 1;
    next;
    if (askyesno() == ASK_NO) {
        closeclientdialog;
        close;
    }

    .@goal = (2**'AMBUSHTRI[0]) + (2**'AMBUSHTRI[1]) + (2**'AMBUSHTRI[2]);
    if ('AMBUSH_BMASK == .@goal) {
        npctalk l("*beep*");
        delcells("X21L3@"+X21ID());
        'XMAS21AMBUSH = true;
        specialeffect(FX_MAGIC_WICKED_SPAWN, AREA, getcharid(3));
        mapannounce getmap(), "Puzzle solved by "+strcharinfo(0), 0;
        getexp X21_EXP_PUZZLE, 0;
        getitem XmasTicket, X21_TICKET_PUZZLE;
        X21INIT();
    } else {
        npctalk l("*click*");
    }
    'AMBUSH_BMASK = 0;
    .@amb = any(ManaGuardian, ManaGuardian, ManaSlayer, (X21TYPE() == IOT_PARTY ? ManaTyrant : ManaGuardian), Tengu, Sasquatch);
    areamonster getmap(), 108, 82, 128, 102, strmobinfo(1, .@amb), .@amb, 1;
    closeclientdialog;
    close;
OnInit:
    .distance=1;
    end;
}

081-2,117,87,0	script	Star of Bethlem#X21_0	NPC_NO_SPRITE,{
    if ('XMAS21AMBUSH)
        end;
    // Extract ID
    .@n$=strnpcinfo(2, "_-1");
    explode(.@ni$, .@n$, "_");
    .@id=atoi(.@ni$[1]);
    if (.@id < 0) { consolemes(CONSOLEMES_ERROR, "ERROR, X21 Invalid Ambush Hint"); end; }

    .@n='AMBUSHTRI[.@id]+2; // Account for the invisible frame
    .@c=(.@n % 5 == 0) ? 5 : (.@n % 5);
    .@r=(.@n / 5)+((.@n % 5 == 0) ? 0 : 1);
    npctalkonce l("%s column, %s row", X21SRLZ(.@c), X21SRLZ(.@r));
    end;
OnInit:
    .distance=1;
    end;
}
081-2,124,94,0	duplicate(Star of Bethlem#X21_0)	Canes#X21_1	NPC_NO_SPRITE
081-2,120,100,0	duplicate(Star of Bethlem#X21_0)	Crown#X21_2	NPC_NO_SPRITE

081-2,60,118,0	script	Switch#X21AB_1	NPC_NO_SPRITE,{
    if ('XMAS21AMBUSH)
        end;
    // Extract ID
    .@n$=strnpcinfo(2, "_0");
    explode(.@ni$, .@n$, "_");
    .@id=atoi(.@ni$[1]);
    if (.@id < 1) { consolemes(CONSOLEMES_ERROR, "ERROR, X21 Invalid Ambush Switch"); end; }

    // Already flipped
    .@bit=(2**.@id);
    if ('AMBUSH_BMASK & .@bit)
        end;

    mesc l("There is a switch here.");
    mesc l("Do you flip it?"), 1;
    next;
    if (askyesno() == ASK_YES) {
        'AMBUSH_BMASK = 'AMBUSH_BMASK | .@bit;
        npctalk l("*click*");
    }

    closeclientdialog;
    close;
OnInit:
    .distance=1;
    end;
}
081-2,65,118,0	duplicate(Switch#X21AB_1)	Switch#X21AB_2	NPC_NO_SPRITE
081-2,70,118,0	duplicate(Switch#X21AB_1)	Switch#X21AB_3	NPC_NO_SPRITE
081-2,50,123,0	duplicate(Switch#X21AB_1)	Switch#X21AB_4	NPC_NO_SPRITE
081-2,55,123,0	duplicate(Switch#X21AB_1)	Switch#X21AB_5	NPC_NO_SPRITE
081-2,60,123,0	duplicate(Switch#X21AB_1)	Switch#X21AB_6	NPC_NO_SPRITE
081-2,65,123,0	duplicate(Switch#X21AB_1)	Switch#X21AB_7	NPC_NO_SPRITE
081-2,70,123,0	duplicate(Switch#X21AB_1)	Switch#X21AB_8	NPC_NO_SPRITE
081-2,50,128,0	duplicate(Switch#X21AB_1)	Switch#X21AB_9	NPC_NO_SPRITE
081-2,55,128,0	duplicate(Switch#X21AB_1)	Switch#X21AB_10	NPC_NO_SPRITE
081-2,60,128,0	duplicate(Switch#X21AB_1)	Switch#X21AB_11	NPC_NO_SPRITE
081-2,65,128,0	duplicate(Switch#X21AB_1)	Switch#X21AB_12	NPC_NO_SPRITE
081-2,70,128,0	duplicate(Switch#X21AB_1)	Switch#X21AB_13	NPC_NO_SPRITE
081-2,50,133,0	duplicate(Switch#X21AB_1)	Switch#X21AB_14	NPC_NO_SPRITE
081-2,55,133,0	duplicate(Switch#X21AB_1)	Switch#X21AB_15	NPC_NO_SPRITE
081-2,60,133,0	duplicate(Switch#X21AB_1)	Switch#X21AB_16	NPC_NO_SPRITE
081-2,65,133,0	duplicate(Switch#X21AB_1)	Switch#X21AB_17	NPC_NO_SPRITE

/* *************************************************************************** */
/* The Enigma */

/*
// FIXME (137,68 and 130,56 and 120,69) (no sprite) (no code)
081-2,137,68,0	script	Enigma#X21A1	NPC_NO_SPRITE,{
    mes l("Three Enigmas, one always say the truth, one always says a lie, and the third may either say the truth or a lie.");
    mes "";
    if ('TRUTHSTAT[0])
        mesc l("The truth"), 1;
    else
        mesc l("A lie"), 1;
    close;
OnInit:
    .distance=2;
    end;
}
*/