summaryrefslogtreecommitdiff
path: root/npc/easter/2010/Doctor4.txt
blob: dcbe74812f1dc11f51786359c40a43cff4cb5016 (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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
// Doctor 4, at the fruit trees.

028-1.gat,116,69,0	script	Doctor#who4	184,{
    // States here
    callsub S_Helped_Count;
    if (@Easter_2010_helper >= 2 && !((Easter_2010_QuestState >> E10_FLAG_MID_REWARD_SHIFT) & E10_FLAG_MID_REWARD_MASK))
        goto L_MidReward;
    if (@Easter_2010_helper == 4 && !((Easter_2010_QuestState >> E10_FLAG_RETURN_READY_SHIFT) & E10_FLAG_RETURN_READY_MASK))
        goto L_Defeat_Invader;
    if ((Easter_2010_QuestState >> E10_FLAG_RETURN_READY_SHIFT) & E10_FLAG_RETURN_READY_MASK == E10_FLAG_RETURN_READY && (Easter_2010_QuestState >> E10_STATE_ROSE_SHIFT) & E10_STATE_ROSE_MASK == E10_STATE_ROSE_ROSE_COMPLETE)
        goto L_Return_Ready_Optional;

// =======================
// === Fourth location ===
// =======================

//From Freeyorp on IRC:
//The fourth position is the only position with any serious sign of life - there are quite a lot of living trees there, packed quite densely
//In the middle of this area, atop cliffs overlooking water, is a fruit tree

L_At_Fruit:
    if ((Easter_2010_QuestState >> E10_FLAG_HELPED_DOCTOR_FRUIT_SHIFT) & E10_FLAG_HELPED_DOCTOR_FRUIT_MASK == E10_FLAG_HELPED_DOCTOR_FRUIT)
        goto L_At_Fruit_Helped;
    if ((Easter_2010_QuestState >> E10_FLAG_KNOWS_DOCTOR_SHIFT) & E10_FLAG_KNOWS_DOCTOR_MASK == E10_FLAG_KNOWS_DOCTOR)
        goto L_At_Fruit_Known;

    setarray @responses$, "\"This tree... it bears remarkable signs of life for such a dead world...\"", "\"But this red light here in conjunction with the blue... that means it must be...\"", "\"Oh dear! Pressed the wrong dratted button again. I wish they'd make them just a little larger...\"", "\"But why so alive? It's surprising to find something that isn't long dead...\"";

    callsub S_Update_Knows;
    close;

L_At_Fruit_Known:
    setarray @responses$, "\"Hmm...\" He pauses. \"Ah, hello there. Could you help with a few things for a bit? Might be a bit dangerous, though...\"",
                          "\"Hello again. Mind helping out again for a bit?\"",
                          "He wanders around, apparently lost in thought. \"Hm. Are you able to help with something? Er, but just so that you know, it could be dangerous...\"",
                          "\"Ah, it's you. Thanks for your help back there, by the way. There is something else, though it might be a bit dangerous, that I need help with if you don't mind?\"";
    set @i, rand(getarraysize(@responses$) >> 1) << 1;
    if ((Easter_2010_QuestState >> E10_DOCTOR_HELP_STATES_SHIFT) & E10_DOCTOR_HELP_STATES_MASK) set @i, @i + 1;
    mes @responses$[@i];
    next;

L_lens_main_menu:
    menu "What do I need to do?", L_lens_minigame_explain,
         "Dangerous?", L_lens_minigame_dangers,
         "Let's start!", L_lens_loop_init,
         "I'm just looking to leave this world. Can you help?", L_Warning,
         "Actually, I'd rather not...", -;
    close;

L_lens_minigame_explain:
    mes "[Doctor]";
    mes "";
    mes "\"I need a special sort of lens, one that might be used to detect what's going on around here.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"To do this, I'll need a special concoction... but I'll need an extra set of hands, and some dark crystal - they seem to match the dark presence here quite nicely.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"We'll probably need other items as well, to get the concoction to the right state. Hm...\"";
    next;
    mes "[Doctor]";
    mes "";
    if (countitem("Pearl") < 1) mes "\"If you get some solid, shiny object that could be used in the mix, that would help. A lot.\"";
    if (countitem("Pearl") > 0) mes "\"Your pearl there would be great in the mix, as such things help in removing color. Though adding too much would make the wrong kind of texture, and also make it difficult to see through...\"";
    if (countitem("IronPotion") < 1) mes "\"From what I've heard about potions from your world, one of them would be excellent at removing an unwanted presence while we make this. I can't remember the name right now, but I think it was orange...\"";
    if (countitem("IronPotion") > 0) mes "\"That orange potion there... an Iron Potion, isn't it? It looks like a fairly thick brew, but something that strong should be useful for getting rid of this presence if it gets too much.\"";
    if (countitem("ConcentrationPotion") < 1) mes "\"If you could find some potion to refine the concoction, that should be quite useful.\"";
    if (countitem("ConcentrationPotion") > 0) mes "\"That purple potion there... a Concentration Potion, you say? That's closer to the sort of texture we're looking for, but it might draw the attention of that presence...\"";
    if (countitem("SlowPoisonPotion") < 1) mes "\"And any other potion you can think of, really. I just make it up as I go along, most of the time.\"";
    if (countitem("SlowPoisonPotion") > 0) mes "\"Ah, a potion to slow the effects of poison? Interesting, interesting, perhaps something like that could also protect our mix from this evil influence.\"";
    if (countitem("BottleOfWater") < 1) mes "\"Though you don't seem to have any water... there is water all around in this place, but whenever I try to do anything with it, things never work. I think it might be tainted here. Maybe there are other things from your world that could help?\"";
    if (countitem("BottleOfWater") > 0) mes "\"Ah, water. That will be fantastic for getting rid of unwanted coloration and make the mixture clearer, but of course, too much of it and we'll lose the properties that I was looking for in the first place...\"";
    next;
    goto L_lens_main_menu;

L_lens_minigame_dangers:
    mes "[Doctor]";
    mes "";
    mes "\"Well. There's some sort of malign force around here, and the things I want to do will probably draw its attention.\"";
    next;
    goto L_lens_main_menu;

// ##### Initialise the minigame. #####

L_lens_loop_init:

    // Insert sanity checks here
    if (countitem("DarkCrystal") < 1) goto L_lens_no_crystal;

    set @MAX_LENS_CRYSTAL_ENERGY_INCREASE, 70;

    // Texture:
    setarray @textures$, "finely powdered", "thick", "slightly thick", "slightly thin", "thin";
    set @textureID, rand(3);

    // Coloration is more interesting. 1 for red, 2 for blue, 4 for yellow. So 7 has everything, 0 is clear.
    setarray @tints$, "clear", "red", "blue", "purple", "yellow", "orange", "green", "dark";
    set @tintID, rand(7);

    // Opacity, final explicitly displayed value
    setarray @opacities$, "opaque", "moderately opaque", "moderately transparent", "transparent";
    set @opacityID, rand(2);

    set @crystalEnergy, rand(rand(@MAX_LENS_CRYSTAL_ENERGY_INCREASE) + 1); // Yes, things _can_ go wrong right from the start.
    set @dilution, 4;
    set @rounds, 0; // Things go spectacularly wrong as time goes on.
    set @damage, 0; // When this hits 4, game over.

    mes "The Doctor places the dark crystal in a small metal container. Looking away, and shielding his face with one hand, he uses a small thin metallic device to emit a sharp, piecing sound, shattering the dark crystal.";
    delitem "DarkCrystal", 1;
    mes "There is a cloud of smoke, and purple flames leap from the container.";
    next;

// ----------------------
// ===== Main loop. =====
// ----------------------

L_lens_loop_main:
    set @retloc, 0;
    set @oldtextureID, @textureID;
    set @oldtintID, @tintID;
    set @oldopacityID, @opacityID;

    mes "[Lens concoction]";
    mes "";
    mes "The concoction is currently a " + @textures$[@textureID] + ", " + @tints$[@tintID] + " " + @opacities$[@opacityID] + " concoction.";
    set @mod, 0;
    if (rand(@crystalEnergy) / 3 + rand(@crystalEnergy >> 1) > 30) set @mod, 1;
    if (@mod == 1) mes "The Doctor seems uneasy. \"We seem to have drawn the attention of something. Be careful...\"";
    next;

L_lens_loop_menu:
    set @LENS_CHOICE_PEARL, 0;
    set @LENS_CHOICE_IRON_POTION, 1;
    set @LENS_CHOICE_CONC_POTION, 2;
    set @LENS_CHOICE_SLOW_POISON_POTION, 3;
    set @LENS_CHOICE_WATER, 4;
    set @LENS_CHOICE_WAIT, 5;
    set @LENS_CHOICE_DISCARD, 6;

    setarray @lensmenu$, "", "", "", "", "", "", "";
    set @lensmenuiter, 0;

    if (countitem("Pearl") < 1) goto L_lens_loop_post_pearl_choice;

    set @lensmenu$[@lensmenuiter], "Pearl";
    set @lensmenuID[@lensmenuiter], @LENS_CHOICE_PEARL;
    set @lensmenuiter, @lensmenuiter + 1;

L_lens_loop_post_pearl_choice:
    if (countitem("IronPotion") < 1) goto L_lens_loop_post_iron_potion_choice;

    set @lensmenu$[@lensmenuiter], "Iron potion";
    set @lensmenuID[@lensmenuiter], @LENS_CHOICE_IRON_POTION;
    set @lensmenuiter, @lensmenuiter + 1;

L_lens_loop_post_iron_potion_choice:
    if (countitem("ConcentrationPotion") < 1) goto L_lens_loop_post_conc_potion_choice;

    set @lensmenu$[@lensmenuiter], "Concentration potion";
    set @lensmenuID[@lensmenuiter], @LENS_CHOICE_CONC_POTION;
    set @lensmenuiter, @lensmenuiter + 1;

L_lens_loop_post_conc_potion_choice:
    if (countitem("SlowPoisonPotion") < 1) goto L_lens_loop_post_slow_poison_potion_choice;

    set @lensmenu$[@lensmenuiter], "Slow poison potion";
    set @lensmenuID[@lensmenuiter], @LENS_CHOICE_SLOW_POISON_POTION;
    set @lensmenuiter, @lensmenuiter + 1;

L_lens_loop_post_slow_poison_potion_choice:
    if (countitem("BottleOfWater") < 1) goto L_lens_loop_post_water_choice;

    set @lensmenu$[@lensmenuiter], "Bottle of Water";
    set @lensmenuID[@lensmenuiter], @LENS_CHOICE_WATER;
    set @lensmenuiter, @lensmenuiter + 1;

L_lens_loop_post_water_choice:
    set @lensmenu$[@lensmenuiter], "Wait for a moment";
    set @lensmenuID[@lensmenuiter], @LENS_CHOICE_WAIT;
    set @lensmenuiter, @lensmenuiter + 1;

    set @lensmenu$[@lensmenuiter], "Discard the brew";
    set @lensmenuID[@lensmenuiter], @LENS_CHOICE_DISCARD;
    set @lensmenuiter, @lensmenuiter + 1;

    menu @lensmenu$[0], -,
         @lensmenu$[1], -,
         @lensmenu$[2], -,
         @lensmenu$[3], -,
         @lensmenu$[4], -,
         @lensmenu$[5], -,
         @lensmenu$[6], -;

    set @menu, @menu - 1;
    set @pcmod, 0;
    if (@menu >= @lensmenuiter) goto L_lens_loop_menu_invalid;

    if (@lensmenuID[@menu] == @LENS_CHOICE_PEARL) goto L_lens_pc_use_pearl; // set @pcmod, rand(2);
    if (@lensmenuID[@menu] == @LENS_CHOICE_IRON_POTION) goto L_lens_pc_use_ironpot;
    if (@lensmenuID[@menu] == @LENS_CHOICE_CONC_POTION) goto L_lens_pc_use_concpot;
    if (@lensmenuID[@menu] == @LENS_CHOICE_SLOW_POISON_POTION) goto L_lens_pc_use_slowpoisonpot;
    if (@lensmenuID[@menu] == @LENS_CHOICE_WATER) goto L_lens_pc_use_water;
    if (@lensmenuID[@menu] == @LENS_CHOICE_WAIT) set @pcmod, 6;
    if (@lensmenuID[@menu] == @LENS_CHOICE_DISCARD) goto L_lens_discard_confirm;

L_lens_loop_automodify:
    set @rounds, @rounds + 1;
    if (@crystalEnergy < 0) set @crystalEnergy, 0;
    set @inc, rand(rand(@MAX_LENS_CRYSTAL_ENERGY_INCREASE / (1+(@crystalEnergy >> 2))) + 1);
    if (!(@pcmod & 1)) set @crystalEnergy, @crystalEnergy + @MAX_LENS_CRYSTAL_ENERGY_INCREASE * @inc / (2 + @inc);
    set @crystalEnergy, @crystalEnergy - rand(rand(@MAX_LENS_CRYSTAL_ENERGY_INCREASE) + 1);
    if (@crystalEnergy < 0) set @crystalEnergy, 0;
    set @effects, rand(20 + rand(40 + @crystalEnergy));

    if (!(@effects & 1)) goto L_lens_loop_automodify_post_texture;

// --- Automatically modify the texture ---
    if (@textureID == 0) set @retloc, 1;
    if (@textureID == 0) goto L_lens_auto_alter_texture_dry;
L_lens_loop_automodify_ret:
    set @mod, rand(3);
    if (@mod == 1) goto L_lens_loop_post_automods;
    set @textureID, @textureID - 1 + @mod;
    goto L_lens_loop_automodify_post_texture;

L_lens_loop_automodify_post_texture:
    if (@effects & 2) goto L_lens_auto_alter_color;
L_lens_loop_auto_post_color:
    if (@effects & 4) goto L_lens_auto_alter_transparency;
L_lens_loop_auto_post_transparency:
    if (@effects > 50) goto L_lens_warp_pc_hair;
L_lens_loop_auto_post_warp_hair:
    if (@effects > @crystalEnergy) goto L_lens_autofix_texture;
L_lens_loop_auto_post_fix_texture:
    set @temp, 0;
    if (!(@effects < 65 && rand(@dilution) < 2 && (@effects & 7))) set @temp, 1;
    if (@temp == 1) set @retloc, 2;
    if (@temp == 1) goto L_lens_drydamage;
L_lens_loop_auto_post_drydamage:
    set @temp, 0;
    if ((@effects + @crystalEnergy / 3 > 85 || (@textureID == 0 && rand(@effects + @crystalEnergy) > 30)) && (!(@pcmod & 1) || @pcmod & 2)) set @temp, 1;
    if (@temp == 1) set @retloc, 3;
    if (@temp == 1) goto L_lens_directdamage;
    set @temp, 0;

L_lens_loop_post_automods:
    if (@oldtintID & (@tintID ^ @oldtintID)) mes "The mixture becomes less " + @tints$[@oldtintID & (@tintID ^ @oldtintID)] + ", changing to a " + @tints$[@oldtintID & ~(@oldtintID & (@tintID ^ @oldtintID))] + " tint.";
    if (@tintID & (@tintID ^ @oldtintID)) mes "The mixture becomes more " + @tints$[@tintID & (@tintID ^ @oldtintID)] + ", changing to a " + @tints$[@tintID] + " tint.";
    if (@textureID == @oldtextureID) goto L_lens_nochange_texture;
    if (@textureID < 0) set @textureID, 0;
    if (@textureID > 4) set @textureID, 4;
    if (@oldtextureID == 0) mes "The powder becomes more fluid, changing into a " +   @textures$[@textureID] + " concoction.";
    if (@oldtextureID > @textureID) mes "The concoction thickens, changing into a " + @textures$[@textureID] + " concoction.";
    if (@oldtextureID < @textureID && !(@oldtextureID == 0)) mes "The concoction thins, changing into a " + @textures$[@textureID] + " concoction.";

L_lens_nochange_texture:
    if (@oldopacityID > @opacityID) mes "The concoction becomes more opaque.";
    if (@oldopacityID < @opacityID) mes "The concoction becomes more transparent.";

L_lens_loop_check:
    // Check to whether you finished here
    if ((@textureID == 3 || @textureID == 2) && @tintID == 0 && @opacityID == 0 && @rounds < 3) goto L_lens_early;
    if ((@textureID == 3 || @textureID == 2) && @tintID == 0 && @opacityID == 0) goto L_lens_complete;
    if (@textureID == 0 && (@rounds + 36) / (@dilution + 5) > 4) goto L_lens_dry_destroyed;
    if ((@damage > 3 && @crystalEnergy > 80) || (@damage > 2 && @crystalEnergy > 80 && @textureID == 0)) goto L_lens_violently_destroyed;
    next;
    goto L_lens_loop_main;

L_lens_early:
    mes "[Doctor]";
    mes "";
    mes "\"That's the sort of thing I'm aiming for - too bad that we haven't added enough for it to complete, though.\"";
    next;
    goto L_lens_loop_main;

L_lens_discard_confirm:
    // Make sure that the player really does want to discard the mix.
    mes "[Doctor]";
    mes "";
    if (@mod == 1 && @damage < 2) mes "\"Are you sure? It didn't seem so bad before...\"";
    if (@mod == 0 || @damage > 1) mes "\"If you are sure... there's a lot of dark energy around, so that might be the best option...\"";
    next;
    menu "Yes, get rid of it!", L_lens_really_discard,
         "No, on second thoughts, better not...", -;
    goto L_lens_loop_menu;

L_lens_really_discard:
    mes "The Doctor takes out a curious glass instrument, and carefully moves it over the mixture. The device takes on a sickly purple hue, and the remnants of the mixture crumbles into nothingness as the light fades into the device.";
    close;

L_lens_loop_menu_invalid:
    mes "[Lens concoction]";
    mes "That doesn't seem right, somehow...";
    next;
    goto L_lens_loop_menu;

L_lens_pc_use_pearl:
    if (countitem("Pearl") < 1) goto L_lens_pc_use_missing;
    delitem "Pearl", 1;
    mes "You pass the pearl to the Doctor, who awkwardly takes it with one hand, grinds it into powder with another device, all the while keeping the container firmly in place. After he finishes, you sprinkle the powder evenly over the concoction.";
    if (@textureID > 1) set @textureID, @textureID - 1;
    if (rand(3 * (@rounds + 6) / (@dilution + 2)) > 0) set @tintID, @tintID & ~1; // Remove red
    if (rand(2) > 0) set @tintID, @tintID & ~2; // Remove blue
    if (rand(3) > 0) set @tintID, @tintID & ~4; // Remove yellow
    if (rand(@opacityID) == 0) set @opacityID, @opacityID + 1;
    goto L_lens_loop_automodify;

L_lens_pc_use_ironpot:
    if (countitem("IronPotion") < 1) goto L_lens_pc_use_missing;
    delitem "IronPotion", 1;
    mes "You pour the iron potion into the mix.";
    if (@textureID > 2) set @textureID, @textureID - 1;
    if (@textureID == 1 || (@textureID == 0 && rand(2) == 0)) set @textureID, @textureID + 1;
    set @tintID, @tintID | 4;
    if (rand(3) > 0) set @tintID, @tintID | 1;
    set @crystalEnergy, 10 * (@crystalEnergy + 5) >> 4;
    goto L_lens_loop_automodify;

L_lens_pc_use_concpot:
    if (countitem("ConcentrationPotion") < 1) goto L_lens_pc_use_missing;
    delitem "ConcentrationPotion", 1;
    mes "You pour the concentration potion into the mix.";
    if (@textureID > 1 && rand(5) <= 2) set @textureID, @textureID - 1;
    if (@textureID == 0 && rand(3) > 0) set @textureID, @textureID + 1;
    set @pcmod, rand(2);
    goto L_lens_loop_automodify;

L_lens_pc_use_slowpoisonpot:
    if (countitem("SlowPoisonPotion") < 1) goto L_lens_pc_use_missing;
    delitem "SlowPoisonPotion", 1;
    mes "You pour the slow poison potion into the mix.";
    if ((@textureID < 4 && @textureID > 0 && rand(5) > 2) || (@textureID == 0 && rand(5))) set @textureID, @textureID + 1;
    set @crystalEnergy, @crystalEnergy - rand(rand(10 * (@crystalEnergy + 15) >> 4) + 5);
    set @pcmod, 1;
    goto L_lens_loop_automodify;

L_lens_pc_use_water:
    if (countitem("BottleOfWater") < 1) goto L_lens_pc_use_missing;
    delitem "BottleOfWater", 1;
    mes "You empty the bottle of water into the mix.";
    if ((@textureID < 4 && @textureID > 0) || (@textureID == 0 && rand(5) < 2)) set @textureID, @textureID + 1;
    if (rand(7) < 2) set @tintID, @tintID & ~3;
    if (rand(7) < 2) set @tintID, @tintID & ~5;
    if (rand(7) < 2) set @tintID, @tintID & ~6;
    if (rand(@opacityID + 2) > 1) set @opacityID, @opacityID - 1;
    set @pcmod, rand(3);
    set @dilution, @dilution + 1;
    goto L_lens_loop_automodify;

L_lens_pc_use_missing:
    mes "Odd, you seemed to have it just moments before. Somewhat confused, you go back to consider what to do next.";
    next;
    goto L_lens_loop_menu;

// -----------------------------------------------------------------
// ##### The various automatic subroutines for various effects #####
// -----------------------------------------------------------------

L_lens_auto_alter_color:
    set @mod, 1 << rand(3);
    if (rand(@crystalEnergy) > 40) set @mod, @mod | 4;
    if (@crystalEnergy - rand(@crystalEnergy) < 30) set @mod, @mod | rand(3);
    set @tintID, @tintID | @mod;
    goto L_lens_loop_auto_post_color;

L_lens_auto_alter_transparency:
    set @mod, rand(3);
    if ((@opacityID == 0 && @mod < 1) || (@opacityID == 3 && @mod > 1)) goto L_lens_loop_auto_post_transparency;
    if (@mod == 1) goto L_lens_loop_auto_post_transparency;
    set @opacityID, @opacityID - 1 + @mod;
    if (@mod > 1) mes "The mixture alters, and becomes easier to see through.";
    if (@opacityID == 3) mes "The mixture is now completely clear.";
    if (@mod < 1) mes "The mixture alters, and becomes harder to see through.";
    goto L_lens_loop_auto_post_transparency;

L_lens_warp_pc_hair:
    mes "You feel something around your head change...";
    set @style,rand(6);
    set @color,rand(9);
    setlook 1,@style+1;
    setlook 6,@color;
    goto L_lens_loop_auto_post_warp_hair;

L_lens_autofix_texture:
    set @textureID, @textureID + rand(3) - 1;
    if (@textureID > 3) set @textureID, @textureID -1;
    if (@textureID < 3) set @textureID, @textureID +1;
    goto L_lens_loop_auto_post_fix_texture;

L_lens_directdamage:
    mes "A flash of sickly yellow light blinds you, the mixture distorts for a moment, then reappears.";
    set @textureID, rand(3);
    set @tintID, @tintID | rand(7);
    set @opacityID, 0;

    set @mod, 0;
    if (rand(readparam(bAgi)) > 30) set @mod, 1;
    if (@mod == 1) mes "You barely manage to dive out of the way as the yellow flash sharply hisses through a space which, until a few moments ago, you had occupied...";
    if (@mod == 0) mes "The light burns all around you, with a strong sensation as if you were crushed under a great weight...";
    if (@mod == 0) itemheal readparam(bVit) * readparam(bVit) / 12 - 820, 0;
    if (hp < 1) close;
    set @mod, 1;

L_lens_auto_alter_texture_dry:
    // If the mix dries up, and too much of the mix was water, then the mixture become damaged. However, the chance that it does dry up decreases with the proportion of water used so far
    if (@mod == 0 && rand(2) == 0 && @dilution > 4) set @dilution, @dilution - 1;
    if (rand(3) == 0 && @dilution > 5 && rand(@dilution * @dilution) > 12 && (!@pcmod & 1)) goto L_lens_drydamage;
    goto L_lens_loop_return_fix;

L_lens_drydamage:
    if (@mod == 0 && @pcmod & 1) goto L_lens_loop_return_fix;
    if (@mod == 0) mes "With a flash of purple light, the mixture spontaneously becomes very dry.";
    if (@mod == 0 && rand(2) == 0 && @dilution > 5) set @dilution, @dilution / 2;
    if (@mod == 0) set @textureID, 0;

L_lens_damagelens:
    if (rand(@damage * @damage) >= 6) goto L_lens_loop_return_fix;
    set @damage, @damage + 1;
    if (@damage == 1) mes "The container starts vibrating slightly.";
    if (@damage == 2) mes "The container begins to shake unsteadily.";
    if (@damage == 3 && @textureID == 0) goto L_lens_violently_destroyed;
    if (@damage == 3) mes "The container is now shaking violently. The concoction gives off an acrid smell, and dark purple sparks occasionally fly out of the container. He watches you uneasily.";
    if (@damage == 4) goto L_lens_violently_destroyed;
    goto L_lens_loop_return_fix;

L_lens_loop_return_fix:
    if (@retloc == 0) mes "FATAL ERROR: @retloc undefined in L_lens_loop_return_fix, closing script.";
    if (@retloc == 0) close;
    // Hacky.
    set @temp, 0;
    if (@retloc == 1) set @temp, 1;
    if (@retloc == 2) set @temp, 2;
    if (@retloc == 3) set @temp, 3;
    set @retloc, 0;
    if (@temp == 0) mes "FATAL ERROR: @retloc out of range in L_lens_loop_return_fix, closing script.";
    if (@temp == 0) close;
    if (@temp == 1) goto L_lens_loop_automodify_ret;
    if (@temp == 2) goto L_lens_loop_auto_post_drydamage;
    if (@temp == 3) goto L_lens_loop_post_automods;

L_lens_no_crystal:
    mes "[Doctor]";
    mes "";
    mes "\"Looks like neither of us have a dark crystal. I'll try something else, but if you want to look around for one in the meantime, we could try again later.\"";
    close;

// ---------------------------------
// ##### The possible outcomes #####
// ---------------------------------

L_lens_violently_destroyed:
    mes "A high pitched whine echoes around you. A series of blinding flashes force you to cover your eyes as the container is sent flying into the air. The grass around where the concoction landed takes on a sickly yellow hue.";
    next;
    mes "[Doctor]";
    mes "";
    mes "The Doctor sighs.";
    mes "\"That could have gone better...\"";
    next;
    mes "The Doctor takes out a curious glass device, and carefully moves it over the tainted grass. Purple and black energies are sucked into the device, and the grass gradually returns to its normal color.";
    close;

L_lens_dry_destroyed:
    mes "[Doctor]";
    mes "";
    mes "The Doctor frowns.";
    mes "";
    mes "\"It's has become too dry... I fear that the mix has become damaged beyond repair, at least for the purposes I had in mind...";
    mes "I'll do what I can to salvage what is there, but it would be unrealistic to be expect that the end result will be anything other than deeply flawed.\"";

L_lens_salvage:
    mes "[Doctor]";
    mes "";
    mes "The Doctor takes out a vial containing a crystal clear fluid, an oddly shaped bowl, and a curious glass device. He then tips the remnants of the concoction into the bowl, then moves the device counterclockwise around the bowl five times, while pouring the clear fluid into the bowl";
    mes "A weak yellow glow surrounds the device as it moves around the outside of the bowl, and the concoction slowly fuses together as more of the clear fluid is added to it. But the concoction is still very lumpy, and doesn't fit properly within the bowl.";
    next;
    mes "[Doctor]";
    mes "";
    mes "He mutters distractedly as he moves the device directly over the bowl, then around, twice clockwise then once counterclockwise. \"...all going wrong... shouldn't be yellow...\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "He then holds the device vertically over the bowl, and takes out a vial of bright red fluid, inverts the device, and mixes the red fluid into the dark purple energy that shoots out of the device into the centre of the remnants.";
    mes "The red fluid darkens the energy it comes into contact with, then spreads out over the remnants of the concoction, giving of copious amounts of smoke.";
    next;

    mes "[Doctor]";
    mes "";
    mes "After a few moments, he steps back and puts away the vial and the glass device, which is now completely devoid of any color.";
    mes "The smoke gradually clears, leaving a perceptively warped lump of glass in the middle.";

    mes "[Doctor]";
    mes "";
    mes "\"You might as well take this.\"";
    mes "";
    mes "\"I did what I could, but the lens is still warped beyond use, for me... I'm not sure that there's much that you'll be able to do with that as it is, but perhaps you could find someone that still has a use for it somewhere, or something.\"";
    getitem "FlawedLens", 1;
    close;

L_lens_complete:
    mes "The Doctor grins broadly.";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Yes, yes. That's it, that's just what I need!\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "The Doctor takes out an oddly shaped bowl and a curious glass device. He quickly pours the concoction in, then moves the device over the bowl. A faint blue glow surrounds the bowl as he does so.";
    next;
    mes "[Doctor]";
    mes "";
    mes "He then moves the device around the edges, twice clockwise then once counterclockwise.";
    mes "After this, he holds the device vertically over the bowl. He takes out a vial of bright red fluid, and inverts the device, sending a stream of pure black energy directly downwards into the concoction. He moves with incredible speed as he pours the red fluid evenly over the concoction as the black energy hits the concoction, giving off a tremendous amount of steam.";
    next;
    mes "[Doctor]";
    mes "";
    mes "He stares at the bowl with intense concentration, then abruptly cuts off the stream of red fluid, despite no visible change in the mixture that you can see through the steam.";
    next;
    mes "As the steam clears, you see that the concoction has hardened into a single solid shape, smoothly curving outwards, but completely opaque.";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Nothing to worry about.. it might be opaque now, but give it a moment to cool down first. Ah, there, it's clearing up nicely now.\"";
    mes "";
    mes "He waits a moment, as the lens becomes more and more transparent.";
    next;
    mes "[Doctor]";
    mes "";
    mes "The Doctor carefully picks up the lens and holds it in a small piece of fabric. He turns it over a few times, checking to make sure there aren't any imperfections.";
    mes "";
    mes "\"The glass formed perfectly! The lens is done.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"This is just what I needed. You were a great help, thank you!\"";
    mes "";
    mes "[You gain 150,000 experience points!]";
    getexp 150000, 0;
    callsub S_Update_Helped;
    close;
    // Yay!

L_At_Fruit_Helped:
    mes "As you approach, you see him looking through a collection of devices.";
    next;
    mes "There is an odd humming sound, and a blue glow from somewhere.";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Oh, hello.\" You notice the sound has stopped. \"Ah, and thanks for the help back there, I should be able to get this done in no time now.\"";
    mes "He wanders around, and you can see him do something complicated with yet another of his devices and the lens that you made.";
    next;
    mes "You can't be quite sure, but this area feels healthier already...";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Brilliant! If there's anything else I will let you know, if that's all right?\"";
    next;
    menu "Okay, I'll see you around!", -,
            "Actually, I'd like to go home now. Any chance you could help?", L_Warning;
    close;

// ===================================================================
// Helper portions, duplicated in each script for want of time, sorry.
// ===================================================================

// The player has defeated the invader and helped enough times.
L_Return_Ready_Optional:
    if (!(~(Easter_2010_QuestState >> E10_HELPED_DOCTOR_SHIFT) & E10_HELPED_DOCTOR_MASK) || ((Easter_2010_QuestState >> E10_HELPED_DOCTOR_FRUIT_SHIFT) & E10_HELPED_DOCTOR_FRUIT_MASK))
        goto L_Return_Ready;

    // Player can help one more time, if so desired.
    mes "[Doctor]";
    mes "";
    mes "\"Well... this has been quite an adventure, hasn't it? I'd say it's about timey--er, time for me to go, but I think I can stick around for a little while longer to tie up some loose ends for myself.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Oh, did you want to help again?\"";
    next;
    menu "Sure, that sounds good", L_At_Fruit,
            "Hm, I can't right now, but maybe later.", L_Return_Ready,
            "I was looking for a way to go home.", L_Return_Capable,
            "No, sorry, I don't think so.", L_Return_Ready;
    close;

// Player has done "everything" to do in this world, just talking to the Doctor.
L_Return_Ready:
    set @parting$, "!";
    if (strcharinfo(0) == "Alonso" || strcharinfo(0) == "AlOnS") set @parting$, ", Alonso!";
    mes "[Doctor]";
    mes "";
    mes "\"Well, you have been absolutely brilliant! Brilliant! Very impressive.\" He smiles kindly and shakes your hand. \"It has been a pleasure. Now for the next adventure. Allons-y" + @parting$ + "\"";
    close;

L_Defeat_Invader:
    mes "[Doctor]";
    mes "";
    mes "\"Ah-ha! It's nice to see you again. How goes the battle?\"";
    next;
    menu "I'm having a hard time, actually. I'd like to go home...", -,
            "Regrouping now for the next encounter, actually.", L_Encourage;
    goto L_Warning;

L_Encourage:
    mes "[Doctor]";
    mes "";
    mes "\"Oh, well, I think you'll prevail in the end! If you'll excuse me, I still have some things to see to.\"";
    close;

L_MidReward:
    if (((Easter_2010_QuestState >> E10_FLAG_MID_REWARD_SHIFT) & E10_FLAG_MID_REWARD_MASK)) close;
    mes "[Doctor]";
    mes "";
    mes "\"Fantastic! You have really been quite helpful.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Er, now that I think about it, perhaps I have something you'd be interested in.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"While visiting another dimension--hm, as a matter of fact, it was quite like this one. But their choices in the past seem to have differed from the ones here...\"";
	next;
    mes "[Doctor]";
    mes "";
    mes "The Doctor reflects on his words. \"Interesting how things turn out. Well, I now have a lot of these Valentine's Glasses, if you'd like a pair.\"";
    next;
    getinventorylist;
    if (@inventorylist_count == 100)
        goto L_MidReward_NoRoom;
    mes "[Doctor]";
    mes "";
    mes "He hands you the glasses.";
    mes "\"They're not too brainy, or suited for detecting background radiation, but they are charming.\"";
    set Easter_2010_QuestState, Easter_2010_QuestState & ~(E10_FLAG_MID_REWARD_MASK << E10_FLAG_MID_REWARD_SHIFT) | (E10_FLAG_MID_REWARD << E10_FLAG_MID_REWARD_SHIFT);
    getitem E10_MIDREWARD_ID, 1;
    close;

L_MidReward_NoRoom:
    mes "[Doctor]";
    mes "";
    mes "\"Oh, I don't think you have room for these. Well, I suppose I'll hold on to them for now.\"";
    close;

// Warning about the potential perils ahead, but the player must still want to abort the quest.
L_Warning:
    mes "[Doctor]";
    mes "";
    mes "\"There is no doubt in my mind that what awaits us is both powerful and dangerous, to say the least.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"If this... destruction, this disregard for life isn't an indication, what is?\"";
    mes "He takes a moment, searching your face.";
    next;
    mes "[Doctor]";
    mes "";
    if (((Easter_2010_QuestState >> E10_HELPED_DOCTOR_SHIFT) & E10_HELPED_DOCTOR_MASK))
        mes "\"I do appreciate your help thus far, really. And I did look forward to working with you again in putting an end to this devastation.\"";
    if (!((Easter_2010_QuestState >> E10_HELPED_DOCTOR_SHIFT) & E10_HELPED_DOCTOR_MASK))
        mes "\"Despite the danger, I think pressing on would certainly be a brave choice.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"But if you were to leave now, I'm afraid it would be impossible to return...\"";
    mes "He pauses again. \"There is still time for you to turn back now, while it's relatively easy.\"";
    next;
    menu "N-no, I-I think I will continue... Yes, I'm ready!", -,
            "Now that you mention it, maybe I'd better leave now while I can.", L_Turn_Back,
            "Um, could I have a minute to think it over?", -;
    close;

L_Turn_Back:
    mes "[Doctor]";
    mes "";
    mes "\"You really want to turn back now?\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"I don't think there's any shame in going back. Quite the contrary. You're brave for even being here.\"";
    mes "He hesitates ever so slightly, choosing his words. \"I just wanted to make sure you were certain about your decision.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Once you've left, I don't see how you'll be able to return.\"";
    next;
    menu "On second thought, perhaps I will stick around.", -,
            "No, no, I'm quite sure I want to leave.", L_Really_Return;
    close;

// The player definitely wants to go back, and there's no returning.
L_Really_Return:
    if ((Easter_2010_QuestState >> E10_FLAG_RETURN_READY_SHIFT) & E10_FLAG_RETURN_READY_MASK == E10_FLAG_RETURN_READY && (Easter_2010_QuestState >> E10_STATE_ROSE_SHIFT) & E10_STATE_ROSE_MASK == E10_STATE_ROSE_ROSE_COMPLETE)
        goto L_Return_Capable;
    mes "[Doctor]";
    mes "";
    mes "\"If that is what you want, then consider it done. And good luck.\"";
    next;
    goto L_Return_Player;

L_Return_Player:
    callsub S_Helped_Count;
    if (countitem("DarkPetal") == 0 && @Easter_2010_helper < 3) goto L_Difficult_Return;
    set Easter_2010_QuestState, (Easter_2010_QuestState & ~(E10_STATE_ROSE_MASK << E10_STATE_ROSE_SHIFT)) | (E10_STATE_ROSE_RETURNED << E10_STATE_ROSE_SHIFT);
    if (@Easter_2010_helper < 3)
        delitem "DarkPetal", 1;
    savepoint "009-1", 52, 40;
    warp "009-1", 0, 0;
    close;

L_Difficult_Return:
    mes "[Doctor]";
    mes "";
    mes "\"Hm... you don't seem to have the thing that brought you here, that petal, that I could have used to send you back... assuming you really do want to give up.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Others have been able to battle some darkness directly, which might serve as a substitute.\"";
    mes "\"You could still help me here and elsewhere if you want to try to get this done once and for all, but if you want to go early you will need to fight, somehow.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"Though there are others helping, too. No doubt that soon enough, you'll be able to go anyway...\"";
    close;

L_Return_Capable:
    mes "[Doctor]";
    mes "";
    mes "\"Hm. Oh, it looks like you've learned how to travel between these worlds on your own. Don't you remember the way?\"";
    next;
    menu "Oh, you're right! It was a spell, um..." + getspellinvocation("world-shift") + " was the name!", -;
    mes "[Doctor]";
    mes "";
    mes "\"Excellent! Though I suspect its effects will work best when you are closer to where you started.\"";
    next;
    mes "[Doctor]";
    mes "";
    mes "\"When you came to this world, where did you end up? I trust that is your origin.\"";
    close;

S_Dialogue_Knows:
    mes "[Doctor]";
    mes "";
    mes "\"Oh, hello again... hm...\"";
    next;
    mes "[Doctor]";
    mes "";
    mes @responses$[rand(getarraysize(@responses$))];
    return;

S_Update_Knows:
    // Working "name" for when he hasn't introduced himself (can be changed).
    mes "[Mysterious Man]";
    mes "";
    mes @responses$[rand(getarraysize(@responses$))];
    next;
    set Easter_2010_QuestState, Easter_2010_QuestState & ~(E10_FLAG_KNOWS_DOCTOR_MASK << E10_FLAG_KNOWS_DOCTOR_SHIFT) | (E10_FLAG_KNOWS_DOCTOR << E10_FLAG_KNOWS_DOCTOR_SHIFT);
    mes "[Doctor]";
    mes "";
    mes "\"Oh, excuse me,\" he gestures. \"I'm the Doctor.\"";
    return;

S_Update_Helped:
    set Easter_2010_QuestState, Easter_2010_QuestState & ~(E10_FLAG_HELPED_DOCTOR_FRUIT_MASK << E10_FLAG_HELPED_DOCTOR_FRUIT_SHIFT) | (E10_FLAG_HELPED_DOCTOR_FRUIT << E10_FLAG_HELPED_DOCTOR_FRUIT_SHIFT);
    callsub S_Helped_Count;
    if (@Easter_2010_helper == 3) set Easter_2010_QuestState, (Easter_2010_QuestState & ~(E10_STATE_ROSE_MASK << E10_STATE_ROSE_SHIFT)) | (E10_STATE_ROSE_ROSE_COMPLETE << E10_STATE_ROSE_SHIFT);
    return;

S_Helped_Count:
    set @Easter_2010_helper, 0;
    if ((Easter_2010_QuestState >> E10_FLAG_HELPED_DOCTOR_TREE_SHIFT) & E10_FLAG_HELPED_DOCTOR_TREE_MASK == E10_FLAG_HELPED_DOCTOR_TREE)
        set @Easter_2010_helper, @Easter_2010_helper + 1;
    if ((Easter_2010_QuestState >> E10_FLAG_HELPED_DOCTOR_ISLAND_SHIFT) & E10_FLAG_HELPED_DOCTOR_ISLAND_MASK == E10_FLAG_HELPED_DOCTOR_ISLAND)
        set @Easter_2010_helper, @Easter_2010_helper + 1;
    if ((Easter_2010_QuestState >> E10_FLAG_HELPED_DOCTOR_STONES_SHIFT) & E10_FLAG_HELPED_DOCTOR_STONES_MASK == E10_FLAG_HELPED_DOCTOR_STONES)
        set @Easter_2010_helper, @Easter_2010_helper + 1;
    if ((Easter_2010_QuestState >> E10_FLAG_HELPED_DOCTOR_FRUIT_SHIFT) & E10_FLAG_HELPED_DOCTOR_FRUIT_MASK == E10_FLAG_HELPED_DOCTOR_FRUIT)
        set @Easter_2010_helper, @Easter_2010_helper + 1;
    return;
}