summaryrefslogtreecommitdiff
path: root/npc/015-8/sealedshrine.txt
blob: c356d140802d5c4d39b0f88c0880585e1fa94b0d (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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
// TMW2 scripts.
// Author:
//    Jesusalva
// Description:
//    SEALED SHRINE submodule - Sagratha's Cave - 015-8
// Uses setq3 - setq1 stage 3
// NPC_FAKIR + NPC_STATUE_FAFA

// Check for validity
function	script	SaggySealCheck	{
    .@q=getq(HurnscaldQuest_Sagratha);
    .@q3=getq3(HurnscaldQuest_Sagratha);
    // Cheater Detected
    if (!MAGIC_LVL || .@q < 3) { 
        setq HurnscaldQuest_Sagratha, 0, 0, 0;
        sc_end SC_CASH_PLUSEXP;
        sc_end SC_OVERLAPEXPUP;
        sc_start SC_OVERLAPEXPUP, 300000, -20;
        warp "Save", 0, 0;
        closeclientdialog;
        end;
        return false;
    }

    // Okay, if it is not stage 3, we don't need to unseal
    if (.@q != 3)
        return false;
    return true;
}

// Seal Spawn
// (name, seal x, seal y, stageId, {seal map})
function	script	SaggySealInit	{
    .@n$=getarg(0);
    .@x=getarg(1);
    .@y=getarg(2);
    .@z=getarg(3);
    .@m$=getarg(4, "015-8");

    // Do nothing if @SaggySeal$ is busy - we will NOT begin another unsealing.
    if (@SaggySeal$ != "" && !.@z)
        end;
    else
        @SaggySeal$=.@n$;

    // Drain some Mana
    // Max wave is 9... So it should cap at 10%
    .@val=7+(.@z/3);

    if (Sp < MaxSp/100*.@val) {
        npctalk l("You don't have enough mana to continue. The seal remains active.");
        @SaggySeal$="";
        end;
    }
    percentheal 0, -(.@val);

    // BaseLevel: 37
    areamonster .@m$, .@x-1, .@y-1, .@x+1, .@y+1, "Seal Guardian", MagicGoblin, (.@z/3)+1;

    switch (.@z) {
        case 0:
            .@mobId=any(HouseMaggot,SlimeBlast); break;
        case 1:
            .@mobId=AngryScorpion; break;
        case 2:
            .@mobId=AngryBat; break;
        case 3:
            .@mobId=RedSlime; break;
        case 4:
            .@mobId=AngryRedScorpion; break;
        case 5:
            .@mobId=Bandit; break;
        case 6:
            .@mobId=Skeleton; break;
        case 7:
            .@mobId=BlueSlime; break;
        case 8:
            .@mobId=RedMushroom; break;
        case 9:
            .@mobId=BlackSlime; break;
        default:
            Exception("ERROR, INVALID Z VALUE FOR SAGRATHA SEAL: "+.@z, RB_DEFAULT|RB_IRCBROADCAST);
            .@mobId=WickedMushroom; break;
    }

    monster .@m$, .@x, .@y, "Seal Protector", .@mobId, 1;

    // Schedule next sequence
    if (.@z+1 < 10)
        .@nx$="0"+(.@z+1);
    else
        .@nx$=str(.@z+1);
    // 3.5s each wave, giving you ~1s to kill/endure each "boss"
    .@t=3500+(.@z*980);

    addtimer2(.@t, .@n$+"::OnBreakSeal"+.@nx$);
    return;
}

// Main menu - SaggySealTrueInit
// ( .name$, x, y )
function	script	SaggySealTrueInit	{
    // Do nothing if @SaggySeal$ is busy - we will NOT begin another unsealing.
    if (@SaggySeal$ != "")
        end;

    // Okay, we can begin! (variable will be filled on SaggySealInit)
    mesc l("Attempt to break the seal?");
    mesc l("Warning: This will drain mana and spawn monsters. You shall not leave this cave section!");
    if (askyesno() == ASK_YES) {
        npctalk3 l("You started the seal break sequence. Please stand by.");
        SaggySealInit(getarg(0), getarg(1), getarg(2), 0);
    }
    closeclientdialog;
    return;
}














































015-8,0,0,0	script	#SaggySeal1	NPC_SUMMONING_CIRC,0,0,{
    end;

OnTouch:
    .@q=getq(HurnscaldQuest_Sagratha);
    .@q3=getq3(HurnscaldQuest_Sagratha);
    // Check if it can be operated
    if (!SaggySealCheck())
        end;

    // Check if this seal is ok
    if (.@q3 & .sealId) {
        npctalkonce l("This seal was already broken, proceed to the next seal!");
        end;
    }

    // It is stage 3, so we will write to setq3 that the seal is open... Soon.
    SaggySealTrueInit(.name$, .x, .y);
    end;

OnBreakSeal01:
    SaggySealInit(.name$, .x, .y, 1);
    end;

OnBreakSeal02:
    SaggySealInit(.name$, .x, .y, 2);
    end;

OnBreakSeal03:
    SaggySealInit(.name$, .x, .y, 3);
    end;

OnBreakSeal04:
    SaggySealInit(.name$, .x, .y, 4);
    end;

OnBreakSeal05:
    SaggySealInit(.name$, .x, .y, 5);
    end;

OnBreakSeal06:
    SaggySealInit(.name$, .x, .y, 6);
    end;

OnBreakSeal07:
    SaggySealInit(.name$, .x, .y, 7);
    end;

OnBreakSeal08:
    SaggySealInit(.name$, .x, .y, 8);
    end;

OnBreakSeal09:
    SaggySealInit(.name$, .x, .y, 9);
    end;

OnBreakSeal10:
    .@q3=getq3(HurnscaldQuest_Sagratha);
    npctalk3 l("The seal was broken!");
    @SaggySeal$="";
    setq3 HurnscaldQuest_Sagratha, .@q3 | .sealId;
    end;

OnInit:
    .sealId=1;

    setarray .xpos, 115, 119, 116, 121, 126, 125, 137, 136, 115;
    setarray .ypos, 117, 117, 119, 122, 125, 115, 117, 123, 118;
    .@z=rand(getarraysize(.xpos));
    movenpc .name$, .xpos[.@z], .ypos[.@z], 0;
    end;
}














015-8,0,0,0	script	#SaggySeal2	NPC_SUMMONING_CIRC,0,0,{
    end;

OnTouch:
    .@q=getq(HurnscaldQuest_Sagratha);
    .@q3=getq3(HurnscaldQuest_Sagratha);
    // Check if it can be operated
    if (!SaggySealCheck())
        end;

    // Check if this seal is ok
    if (.@q3 & .sealId) {
        npctalkonce l("This seal was already broken, proceed to the next seal!");
        end;
    }

    // It is stage 3, so we will write to setq3 that the seal is open... Soon.
    SaggySealTrueInit(.name$, .x, .y);
    end;

OnBreakSeal01:
    SaggySealInit(.name$, .x, .y, 1);
    end;

OnBreakSeal02:
    SaggySealInit(.name$, .x, .y, 2);
    end;

OnBreakSeal03:
    SaggySealInit(.name$, .x, .y, 3);
    end;

OnBreakSeal04:
    SaggySealInit(.name$, .x, .y, 4);
    end;

OnBreakSeal05:
    SaggySealInit(.name$, .x, .y, 5);
    end;

OnBreakSeal06:
    SaggySealInit(.name$, .x, .y, 6);
    end;

OnBreakSeal07:
    SaggySealInit(.name$, .x, .y, 7);
    end;

OnBreakSeal08:
    SaggySealInit(.name$, .x, .y, 8);
    end;

OnBreakSeal09:
    SaggySealInit(.name$, .x, .y, 9);
    end;

OnBreakSeal10:
    .@q3=getq3(HurnscaldQuest_Sagratha);
    npctalk3 l("The seal was broken!");
    @SaggySeal$="";
    setq3 HurnscaldQuest_Sagratha, .@q3 | .sealId;
    end;

OnInit:
    .sealId=2;

    setarray .xpos,  39,  33,  43,  53,  51,  55,  60,  68,  63,  56;
    setarray .ypos, 120, 130, 134, 132, 119, 121, 122, 120, 129, 124;
    .@z=rand(getarraysize(.xpos));
    movenpc .name$, .xpos[.@z], .ypos[.@z], 0;
    end;
}














015-8,0,0,0	script	#SaggySeal3	NPC_SUMMONING_CIRC,0,0,{
    end;

OnTouch:
    .@q=getq(HurnscaldQuest_Sagratha);
    .@q3=getq3(HurnscaldQuest_Sagratha);
    // Check if it can be operated
    if (!SaggySealCheck())
        end;

    // Check if this seal is ok
    if (.@q3 & .sealId) {
        npctalkonce l("This seal was already broken, proceed to the next seal!");
        end;
    }

    // It is stage 3, so we will write to setq3 that the seal is open... Soon.
    SaggySealTrueInit(.name$, .x, .y);
    end;

OnBreakSeal01:
    SaggySealInit(.name$, .x, .y, 1);
    end;

OnBreakSeal02:
    SaggySealInit(.name$, .x, .y, 2);
    end;

OnBreakSeal03:
    SaggySealInit(.name$, .x, .y, 3);
    end;

OnBreakSeal04:
    SaggySealInit(.name$, .x, .y, 4);
    end;

OnBreakSeal05:
    SaggySealInit(.name$, .x, .y, 5);
    end;

OnBreakSeal06:
    SaggySealInit(.name$, .x, .y, 6);
    end;

OnBreakSeal07:
    SaggySealInit(.name$, .x, .y, 7);
    end;

OnBreakSeal08:
    SaggySealInit(.name$, .x, .y, 8);
    end;

OnBreakSeal09:
    SaggySealInit(.name$, .x, .y, 9);
    end;

OnBreakSeal10:
    .@q3=getq3(HurnscaldQuest_Sagratha);
    npctalk3 l("The seal was broken!");
    @SaggySeal$="";
    setq3 HurnscaldQuest_Sagratha, .@q3 | .sealId;
    end;

OnInit:
    .sealId=4;

    setarray .xpos, 140, 143, 146, 147, 145, 143;
    setarray .ypos, 140, 141, 139, 144, 147, 143;
    .@z=rand(getarraysize(.xpos));
    movenpc .name$, .xpos[.@z], .ypos[.@z], 0;
    end;
}







// Sagratha Seals Eletronic Barriers
015-8,120,130,0	script	#SaggySealBarrier1	NPC_HIDDEN,0,4,{
OnTouch:
    if (@SaggySeal$ != "") {
        npctalk3 l("The seal retaliates! It was super effective. You are dead!");
        @SaggySeal$="";
        percentheal -100, -100;
        end;
    }
    end;
}

015-8,74,142,0	script	#SaggySealBarrier2	NPC_HIDDEN,0,4,{
OnTouch:
    if (@SaggySeal$ != "") {
        npctalk3 l("The seal retaliates! It was super effective. You are dead!");
        @SaggySeal$="";
        percentheal -100, -100;
        end;
    }
    end;
}

015-8,137,154,0	script	#SaggySealBarrier3	NPC_HIDDEN,0,5,{
OnTouch:
    if (@SaggySeal$ != "") {
        npctalk3 l("The seal retaliates! It was super effective. You are dead!");
        @SaggySeal$="";
        percentheal -100, -100;
        end;
    }
    end;
}





// Magic Barrier
015-8,94,104,0	script	Dog Statue#Saggy	NPC_STATUE_FAFA,{
OnDialog:
    mesn;
    mesq l("This is a magical barrier, powered by three seals in your part.");
    next;
    mesn;
    mesq l("You must break all three seals to cross this barrier! For that, walk on them!");
    next;
    mesn;
    mesq l("Breaking a seal is easy, just flow mana on it for enough time to it shatter.");
    next;
    mesn;
    mesq l("I, Fafa, the Magical Statue, grant you this power! Prove your worth! And never run from the seal, or die for your cowardice!");
    close;

OnInit:
    .distance=5;
    end;
}

015-8,93,109,0	script	#SaggyBarrier	NPC_HIDDEN,2,0,{
    end;

OnTouch:
    if (!SaggySealCheck()) {
        slide 93, 106;
        end;
    }
    .@q=getq(HurnscaldQuest_Sagratha);
    .@q3=getq3(HurnscaldQuest_Sagratha);

    // Magic Number
    if (.@q3 == 7) {
        npctalk3 l("The seals having been broken, the barrier was weakened! You did it! The path is now open!");
        setq1 HurnscaldQuest_Sagratha, 4;
        setq3 HurnscaldQuest_Sagratha, 0;
        slide 93, 106;
    } else {
        getmapxy(.@m$, .@x, .@y, 0);
        slide .@x, .@y+3;
        dispbottom l("A powerful magic barrier repels you!");
        addtimer(200, "Dog Statue#Saggy::OnDialog");
    }
    end;

}


015-8,93,107,0	script	#SaggyBarrier2	NPC_HIDDEN,2,0,{
    end;

OnTouch:
    // You should not be on this side of the barrier
    if (SaggySealCheck()) {
        setq HurnscaldQuest_Sagratha, 0, 0, 0;
        sc_end SC_CASH_PLUSEXP;
        sc_end SC_OVERLAPEXPUP;
        sc_start SC_OVERLAPEXPUP, 300000, -20;
        warp "Save", 0, 0;
        closeclientdialog;
        end;
    }
    slide 93, 110;
    end;

}





// Shrine Statue Control
// SaggyShrineStatue( .name$ )
function	script	SaggyShrineStatue	{
    .@n$=getarg(0);

    // Initial check
    if (!MAGIC_LVL || .@q < 4) { 
        setq HurnscaldQuest_Sagratha, 0, 0, 0;
        sc_end SC_CASH_PLUSEXP;
        sc_end SC_OVERLAPEXPUP;
        sc_start SC_OVERLAPEXPUP, 300000, -20;
        warp "Save", 0, 0;
        closeclientdialog;
        end;
        return false;
    }

    mesn l("Guardian Statue");
    .@q=getq(HurnscaldQuest_Sagratha);
    if (.@q != 4) {
        mesq l("...");
        next;
        mesc l("The statue doesn't replies.");
        close;
    }
    mesq l("Decipher me... Or I will devour you...");
    next;
    mesc l("Take the riddle?"), 1;
    mesc l("Time limit for answer: 2 minutes");
    next;
    if (askyesno() == ASK_YES) {
        // You have unlimited time if you don't close the dialog
        addtimer(120000, .@n$+"::OnScheduledDeath");
        if (0158_Riddle_BlackBox()) {
            deltimer(.@n$+"::OnScheduledDeath");
            setq1 HurnscaldQuest_Sagratha, 5;
            mesn;
            mesq l("You shall pass. Beyond this gate, she waits for you.");
            next;
            mesn;
            mesq l("Your worth shall be tested, and from inside, you shall not leave.");
        } else {
            doevent(.@n$+"::OnScheduledDeath");
            closeclientdialog;
        }
    }
    return;
}

// The Sealed Shrine Itself and the guardians
015-8,96,22,0	script	#SaggyShrineRight	NPC_FAKIR,{
    SaggyShrineStatue(.name$);
    close;

OnScheduledDeath:
    npctalk3 l("Be devoured!");
    percentheal -100, -100;
    end;

OnInit:
    .distance=5;
    end;
}

015-8,93,22,0	script	#SaggyShrineLeft	NPC_FAKIR,{
    SaggyShrineStatue(.name$);
    close;

OnScheduledDeath:
    npctalk3 l("Be devoured!");
    percentheal -100, -100;
    end;

OnInit:
    .distance=5;
    end;
}

015-8,94,20,0	script	#ShrineGate	NPC_NO_SPRITE,1,0,{

    .@q=getq(HurnscaldQuest_Sagratha);
    .@q3=getq3(HurnscaldQuest_Sagratha);
    // Cheater Detected
    if (!MAGIC_LVL || .@q < 4) { 
        setq HurnscaldQuest_Sagratha, 0, 0, 0;
        sc_end SC_CASH_PLUSEXP;
        sc_end SC_OVERLAPEXPUP;
        sc_start SC_OVERLAPEXPUP, 300000, -20;
        warp "Save", 0, 0;
        closeclientdialog;
        end;
        return false;
    }

    // Quest Status 4: Riddle pending
    if (.@q == 4) {
        npctalk3 l("The gates are firmly shut, no amount of force will break them.");
    }

    // Quest Status 5: Riddle solved, access granted
    // Quest Status 6: Boss defeated, no instance needed
    dispbottom "ERROR";
    end;
}