summaryrefslogtreecommitdiff
path: root/world/map/npc/annuals/xmas/2020.txt
blob: 0490d1a72944205b2399f7724aa61f020e74f74e (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
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
// The Mana World Scripts
// Christmas 2020
// (C) Jesusalva, Hocus, Ledmitz, toams, monwarez, jak1, Hello=) et. al., 2020
// Licensed under the GPLv2 or later
// XXmas is not a typo, "XX" is twenty and the year is twenty-twenty.

034-1,0,0,0|script|XXmas0341|32767
{
    end;

OnHit2:
    goto OnHit;

OnHit:
    // Not Christmas yet
    if (!$@xmas_time)
        end;
    // Reward time
    if ($@xmas_time == $@xmas_reward_time)
        end;
    // player must be created at least two weeks ago
    if ((BaseLevel < 30) || (gettimetick(2) - TUT_var < 2*7*86400))
        end;

    // Not equipped to hunt Grinchboos
    //if (getequipid(equip_arrow) != 5260)
    //    end;
    if (getequipid(equip_hand1) != 5261)
        end;

    // tell the spells they were discharged
    // XXX: maybe we could make it do area damage when you discharge (release your energy all of a sudden)
    addtimer 0, "::OnDischarge"; // seeks OnDischarge in ALL npcs

    // Magic cheat
    if (@wandspell[4])
        end;
    if (@ingravspell[2])
        end;
    if (@chizaspell[2])
        end;
    if (@flarspell[2])
        end;
    if (@phlexspell[3])
        end;
    if (@chipchipspell[2])
        end;
    if (@upmarmuspell[1])
        end;

    // By last, check for Arrow Hail
    set @nearby, 0;
    foreach 1, getmap(), @away[0] - 14, @away[1] - 14, @away[0] + 14, @away[1] + 14,
            strnpcinfo(0) + "::OnNearbyNpc";
    if (@nearby)
        end;

    // Grinchboo slain
    set XMAS2020, XMAS2020 + 1;
    set $XMAS2020_BOO, $XMAS2020_BOO + 1;
    set @loop, 0;
    set @rank, 0;
    goto L_MaybeInsertNext;

L_MaybeInsertNext:
    if (XMAS2020 > $Record_XXmas_Kills[@rank])
        goto L_InsertScore;
    // you already had a better score
    if (strcharinfo(0) == $Record_XXmas_Name$[@rank])
        goto L_Reward1;
    set @rank, @rank + 1;
    if (@rank == MAX_HIGH_SCORES)
        goto L_Reward1;
    goto L_MaybeInsertNext;

L_InsertScore:
    set @loop, @rank;
    goto L_FindLastScore;

L_FindLastScore:
    // comment this out to allow the player to be in the list more than once
    // though actually, it might be better just to assume the list is full
    if (strcharinfo(0) == $Record_XXmas_Name$[@loop])
        goto L_MoveStuff;

    set @loop, @loop + 1;
    if (@loop == MAX_HIGH_SCORES)
        goto L_MoveStuff;
    goto L_FindLastScore;

L_MoveStuff:
    if (@loop == @rank)
        goto L_FinallyInsertMe;
    set $Record_XXmas_Kills[@loop], $Record_XXmas_Kills[@loop - 1];
    set $Record_XXmas_Name$[@loop], $Record_XXmas_Name$[@loop - 1];
    set $Record_XXmas_Date$[@loop], $Record_XXmas_Date$[@loop - 1];
    set @loop, @loop - 1;
    goto L_MoveStuff;

L_FinallyInsertMe:
    set $Record_XXmas_Kills[@rank], XMAS2020;
    set $Record_XXmas_Name$[@rank], strcharinfo(0);
    callfunc "time_stamp";
    set $Record_XXmas_Date$[@rank], @ts_date$ + " " + @ts_time$;
    set @ts_date$, "";
    set @ts_time$, "";
    goto L_Reward1;

L_Reward1:
    // Maybe we should tell you how many you purified?
    if (XMAS2020 % 10 == 0 || XMAS2020 == 1)
        goto L_Warning;
    end;

L_Warning:
    message strcharinfo(0), "Grinchboos purified: "+XMAS2020;
    end;

OnTimer15000:
    areamonster "034-1", 20, 20, 160, 110, "", 1162, 18, "XXmas0341::OnHit2";
    // Only happens until :15, and every 15 minutes, for a total of 60 cycles.
    if (gettime(2) > 15)
        end;
    initnpctimer;
    end;

L_Abort:
    end;

OnClock1800:
    if (!$@xmas_time)
        goto L_Abort;
    if ($@xmas_time == $@xmas_reward_time)
        goto L_Abort;
    initnpctimer;
    // WARNING: Do not duplicate!!
    announce "Santa : Ho ho ho, I see a huge movement by the grinchboos!", 0;
    end;

OnClock1830:
    killmonster "034-1", "XXmas0341::OnHit2";
    stopnpctimer;
    end;

// Additional timers
OnClock0000:
    goto OnClock1800;
OnClock0030:
    goto OnClock1830;
OnClock0600:
    goto OnClock1800;
OnClock0630:
    goto OnClock1830;

OnNearbyNpc:
    explode .@nearby$[0], strnpcinfo(0,@target_id), "#";
    if(.@nearby$[0] == "arrow-hail" || .@nearby$[1] == "arrow-hail")
        set @nearby, @nearby + 1;
    end;
}

// Scatter the grinchboos
// Nivalis
034-1,0,0,0,0|monster|Grinchboo|1162,14,100000ms,30000ms,XXmas0341::OnHit
//030-1,0,0,0,0|monster|Grinchboo|1162,7,100000ms,30000ms,XXmas0341::OnHit
//031-1,0,0,0,0|monster|Grinchboo|1162,2,100000ms,30000ms,XXmas0341::OnHit
033-1,0,0,0,0|monster|Grinchboo|1162,5,100000ms,30000ms,XXmas0331::OnHit
//019-1,0,0,0,0|monster|Grinchboo|1162,2,100000ms,30000ms,XXmas0341::OnHit
// Thermin
//045-1,0,0,0,0|monster|Grinchboo|1162,10,100000ms,30000ms,XXmas0341::OnHit
046-1,0,0,0,0|monster|Grinchboo|1162,8,100000ms,30000ms,XXmas0461::OnHit
047-1,0,0,0,0|monster|Grinchboo|1162,6,100000ms,30000ms,XXmas0471::OnHit

// Bring Santa back!!! With speeches from all previous events because I'M LAZY
// Same place as he was in 2009, instead of his room in 030-2,197,62
020-1,78,85,0|script|Santa|105
{
    if (Sex)
        set @honorific$, "Young Hero";
    if (!Sex)
        set @honorific$, "Young Heroine";


    // Not Christmas yet
    if (!$@xmas_time)
        goto L_PreXmas;
    // Past Christmas
    if ($@xmas_time == $@xmas_reward_time)
        goto L_Reward;
    // Already equipped, so...
    if (countitem("SnowLauncher") > 0)
        goto L_Doing;

    // Begin exactly like it was in 2009
    mes "[Santa Claus]";
    mes "\"ho-hum ho-hum ho-hum, I'm sorry, "  + @honorific$ +  "  Not really in the Christmas spirit.";
    mes "That Evil Jack Frost has stolen all the Christmas ornaments!";
    mes "He will never get off the Naughty List!";
    mes "How can we have Christmas without a proper Christmas tree?\"";
    mes "\"The Elves are too depressed to work";
    mes "Christmas will be ruined!\"";
    next;
    // But this is not 2009...
    mes "[Santa Claus]";
    mes "\"OOPS! That was Christmas 2009! We are in 2020, how could I forget? Ho! Ho! Ho!\"";
    next;
    mes "[Santa Claus]";
    mes "\"But still! Can you believe Jack Frost turned all my Reinboos into Grinchboos?! Christmas will be ruined!\"";
    next;
    mes "[Santa Claus]";
    mes "\"Say, Why don't you help me?";
    mes "In fact, You are just the "  + @honorific$ + " I am looking for!\"";
    mes "\"What do you say, will you help save Christmas?\"";
    next;
    menu
        "I won't.", L_Close,
        "How can I help?", L_Help;

L_Help:
    // player must be created at least two weeks ago
    if ((BaseLevel < 30) || (gettimetick(2) - TUT_var < 2*7*86400))
        goto L_Young;
	mes "[Santa Claus]";
	mes "\"Oh that is excellent news!";
	mes "Thank you.\"";
	mes "##9Santa shakes your hand with delight.##0";
    next;
    mes "[Santa Claus]";
    mes "\"You see, if you hit the grinchboos with snowballs, they can be purified! (Don't ask me how it works, Christmas is weird this year!)\"";
    next;
    mes "[Santa Claus]";
    mes "\"However, you cannot just throw snowballs at them. But I have the ideal tool for this task!\"";
    next;
    mes "[Santa Claus]";
    mes "\"You can use this super ##BCandy-Caned Anti-Grinch-Rifle 2020™##b! Hit as many as you can! Ho ho ho!\"";
    menu
        "Many thanks, Santa!", L_Item,
        "I already have one, I'll get to work!", L_Close;

L_Young:
    mes "[Santa]";
    mes "\"That's a very friendly offer! But I don't think we need any help.\"";
    goto L_Close;

L_Item:
    getinventorylist;
    if (@inventorylist_count == 100) goto L_Full;
    getitem "SnowLauncher", 1;
    mes "[Santa Claus]";
    mes "\"Ho Ho Ho Merry Christmas!\"";
    close;

L_Close:
    close;

L_Full:
    mes "[Santa Claus]";
    mes "\"Your backpack seems to be full. You should get rid of some unused stuff before you get my gifts, or maybe try one super resistant red bag, my personal favorite! Hoh-hoh!\"";
    close;

L_PreXmas:
    mes "[Santa Claus]";
    mes "\"Ho, Ho... See you later " +@honorific$+ "!\"";
    close;

L_ShowRecord:
    mes "[Santa Claus]";
    mes "You have purified "+XMAS2020+" Grinchboos thus far.";
    mes "All players have purified "+$XMAS2020_BOO+" Grinchboos in total.";
    set @rank, 0;
    set @loop, 0;
    goto L_ShowNextRecord;

L_ShowNextRecord:
    if ($Record_XXmas_Kills[@loop] == 0)
        goto L_Close;
    mes (@loop + 1) + " - " + $Record_XXmas_Name$[@loop] + " - " + $Record_XXmas_Kills[@loop] + " Grinchboos saved at " + $Record_XXmas_Date$[@loop];
    set @loop, @loop + 1;
    if (MAX_HIGH_SCORES > 4 && (@loop % 5) == 0 && $Record_XXmas_Kills[@loop] > 0)
        goto L_NextShowNextRecord;
    goto L_ShowNextRecord;

L_NextShowNextRecord:
    next;
    goto L_ShowNextRecord;

L_Doing:
    mes "[Santa]";
    mes "\"Hello " + strcharinfo(0) + ". I heard about your efforts to help. I'm very happy to hear that.\"";
    next;
    mes "[Santa]";
    mes "\"Be careful at 18:00, 00:00 and 06:00, those are the most active times for my reinboos.\"";
    next;
    menu
        "I'll go back to work.", L_Close,
        "What are current highscores?", L_ShowRecord;

L_Done:
    mes "[Santa]";
    mes "\"Hello " + strcharinfo(0) + ". I heard about your efforts to help. I'm very happy to hear that.\"";
    next;
    menu
        "Santa, you are the best!", L_Close,
        "What were the highscores?", L_ShowRecord;

L_Reward:
    if (XMAS2020 <= 0)
        goto L_Done;
    mes "[Santa Claus]";
    mes "\"You are so generous! I believe I can give you one of the hats from this bag. I know you like these silly hats. Yes, Santa knows this kind of thing... Ho-Ho-Ho! Put your hand here and pick one hat...\"";
    next;
    getinventorylist;
    if (@inventorylist_count > 95) goto L_Full;
    mes "You have purified "+XMAS2020+" Grinchboos thus far.";
    mes "All players have purified "+$XMAS2020_BOO+" Grinchboos in total.";
    set @rank, 0;
    set @loop, 0;
    goto L_FindRank;

L_FindRank:
    if (strcharinfo(0) == $Record_XXmas_Name$[@rank])
        goto L_Continue;
    set @rank, @rank + 1;
    if (@rank == MAX_HIGH_SCORES)
        goto L_Continue;
    goto L_FindRank;

L_Continue:
    getinventorylist;
    if (@inventorylist_count > 95) goto L_Full;
    set XMAS2020, 0;
    setarray @oldstock$, "PlushMouboo", "StickReinboo", "Doll", "LeatherBall", "SantaSnowGlobe", "SnowmanSnowGlobe", "RedOrnament", "YellowOrnament", "GreenOrnament", "AquaOrnament", "BlueOrnament", "MagentaOrnament";
    getitem @oldstock$[rand(getarraysize(@oldstock$))], 1;
    cleararray @oldstock$, "", getarraysize(@oldstock$);
    if (@rank < 15)
        goto L_Extra1;
    close;

// TOP 15 reward
L_Extra1:
    mes "[Santa Claus]";
    mes "\"The official Christmas 2009 headgear!";
    mes "Ho Ho Ho Merry Christmas!\"";
    getitem "SnowGoggles", 1;
    if (@rank < 10)
        goto L_Extra2;
    close;

// TOP 10 reward
L_Extra2:
    setarray @oldstock$, "PlushMouboo", "StickReinboo", "Doll", "LeatherBall", "SantaSnowGlobe", "SnowmanSnowGlobe", "RedOrnament", "YellowOrnament", "GreenOrnament", "AquaOrnament", "BlueOrnament", "MagentaOrnament";
    getitem @oldstock$[rand(getarraysize(@oldstock$))], 1;
    cleararray @oldstock$, "", getarraysize(@oldstock$);
    if (@rank < 5)
        goto L_Extra3;
    close;

// TOP 5 reward
L_Extra3:
    setarray @oldstock$, "MoubooHead", "MushHat", "ChristmasElfHat", "FunkyHat", "ShroomHat", "ElfNightcap", "BowlerHat", "TopHat";
    getitem @oldstock$[rand(getarraysize(@oldstock$))], 1;
    cleararray @oldstock$, "", getarraysize(@oldstock$);
    if (@rank < 2)
        goto L_Extra4;
    close;

// TOP 2 reward
L_Extra4:
    setarray @oldstock$, "SantaBeardHat", "ChristmasTreeHat", "EyePatch", "AntlerHat";
    getitem @oldstock$[rand(getarraysize(@oldstock$))], 1;
    cleararray @oldstock$, "", getarraysize(@oldstock$);
    close;

/* FIXME requires player attached bcz TMWA is crazy, so better not.
// Spawn 10~30 snowballs in Nivalis square
OnClock2359:
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    makeitem 5260, rand(1,3), "020-1", rand(69, 82), rand(78, 91);
    end;

// Duplicates
OnClock0001:
    goto OnClock2359;
OnClock1759:
    goto OnClock2359;
OnClock1801:
    goto OnClock2359;
OnClock0559:
    goto OnClock2359;
OnClock0601:
    goto OnClock2359;
OnClock2124:
    goto OnClock2359;
OnClock0024:
    goto OnClock2359;
*/
}



////////////////////////////////
033-1,0,0,0|script|XXmas0331|32767
{
    end;

OnHit2:
    goto OnHit;

OnHit:
    // Not Christmas yet
    if (!$@xmas_time)
        end;
    // Reward time
    if ($@xmas_time == $@xmas_reward_time)
        end;
    // player must be created at least two weeks ago
    if ((BaseLevel < 30) || (gettimetick(2) - TUT_var < 2*7*86400))
        end;

    // Magic cheat
    if (@wandspell[4])
        end;
    if (@ingravspell[2])
        end;
    if (@chizaspell[2])
        end;
    if (@flarspell[2])
        end;
    if (@phlexspell[3])
        end;
    if (@chipchipspell[2])
        end;
    if (@upmarmuspell[1])
        end;

    // Not equipped to hunt Grinchboos
    //if (getequipid(equip_arrow) != 5260)
    //    end;
    if (getequipid(equip_hand1) != 5261)
        end;

    // By last, check for Arrow Hail
    set @nearby, 0;
    foreach 1, getmap(), @away[0] - 14, @away[1] - 14, @away[0] + 14, @away[1] + 14,
            strnpcinfo(0) + "::OnNearbyNpc";
    if (@nearby)
        end;

    // Grinchboo slain
    set XMAS2020, XMAS2020 + 1;
    set $XMAS2020_BOO, $XMAS2020_BOO + 1;
    set @loop, 0;
    set @rank, 0;
    goto L_MaybeInsertNext;

L_MaybeInsertNext:
    if (XMAS2020 > $Record_XXmas_Kills[@rank])
        goto L_InsertScore;
    // you already had a better score
    if (strcharinfo(0) == $Record_XXmas_Name$[@rank])
        goto L_Reward1;
    set @rank, @rank + 1;
    if (@rank == MAX_HIGH_SCORES)
        goto L_Reward1;
    goto L_MaybeInsertNext;

L_InsertScore:
    set @loop, @rank;
    goto L_FindLastScore;

L_FindLastScore:
    // comment this out to allow the player to be in the list more than once
    // though actually, it might be better just to assume the list is full
    if (strcharinfo(0) == $Record_XXmas_Name$[@loop])
        goto L_MoveStuff;

    set @loop, @loop + 1;
    if (@loop == MAX_HIGH_SCORES)
        goto L_MoveStuff;
    goto L_FindLastScore;

L_MoveStuff:
    if (@loop == @rank)
        goto L_FinallyInsertMe;
    set $Record_XXmas_Kills[@loop], $Record_XXmas_Kills[@loop - 1];
    set $Record_XXmas_Name$[@loop], $Record_XXmas_Name$[@loop - 1];
    set $Record_XXmas_Date$[@loop], $Record_XXmas_Date$[@loop - 1];
    set @loop, @loop - 1;
    goto L_MoveStuff;

L_FinallyInsertMe:
    set $Record_XXmas_Kills[@rank], XMAS2020;
    set $Record_XXmas_Name$[@rank], strcharinfo(0);
    callfunc "time_stamp";
    set $Record_XXmas_Date$[@rank], @ts_date$ + " " + @ts_time$;
    set @ts_date$, "";
    set @ts_time$, "";
    goto L_Reward1;

L_Reward1:
    // Maybe we should tell you how many you purified?
    if (XMAS2020 % 10 == 0 || XMAS2020 == 1)
        goto L_Warning;
    end;

L_Warning:
    message strcharinfo(0), "Grinchboos purified: "+XMAS2020;
    end;

OnTimer15000:
    areamonster "033-1", 20, 20, 120, 110, "", 1162, 18, "XXmas0331::OnHit2";
    // Only happens until :15, and every 15 minutes, for a total of 60 cycles.
    if (gettime(2) > 15)
        end;
    initnpctimer;
    end;

OnClock1800:
    initnpctimer;
    end;

OnClock1830:
    killmonster "033-1", "XXmas0331::OnHit2";
    stopnpctimer;
    end;

// Additional timers
OnClock0000:
    goto OnClock1800;
OnClock0030:
    goto OnClock1830;
OnClock0600:
    goto OnClock1800;
OnClock0630:
    goto OnClock1830;

OnNearbyNpc:
    explode .@nearby$[0], strnpcinfo(0,@target_id), "#";
    if(.@nearby$[0] == "arrow-hail" || .@nearby$[1] == "arrow-hail")
        set @nearby, @nearby + 1;
    end;
}

046-1,0,0,0|script|XXmas0461|32767
{
    end;

OnHit2:
    goto OnHit;

OnHit:
    // Not Christmas yet
    if (!$@xmas_time)
        end;
    // Reward time
    if ($@xmas_time == $@xmas_reward_time)
        end;
    // player must be created at least two weeks ago
    if ((BaseLevel < 30) || (gettimetick(2) - TUT_var < 2*7*86400))
        end;

    // Magic cheat
    if (@wandspell[4])
        end;
    if (@ingravspell[2])
        end;
    if (@chizaspell[2])
        end;
    if (@flarspell[2])
        end;
    if (@phlexspell[3])
        end;
    if (@chipchipspell[2])
        end;
    if (@upmarmuspell[1])
        end;

    // Not equipped to hunt Grinchboos
    //if (getequipid(equip_arrow) != 5260)
    //    end;
    if (getequipid(equip_hand1) != 5261)
        end;

    // By last, check for Arrow Hail
    set @nearby, 0;
    foreach 1, getmap(), @away[0] - 14, @away[1] - 14, @away[0] + 14, @away[1] + 14,
            strnpcinfo(0) + "::OnNearbyNpc";
    if (@nearby)
        end;

    // Grinchboo slain
    set XMAS2020, XMAS2020 + 1;
    set $XMAS2020_BOO, $XMAS2020_BOO + 1;
    set @loop, 0;
    set @rank, 0;
    goto L_MaybeInsertNext;

L_MaybeInsertNext:
    if (XMAS2020 > $Record_XXmas_Kills[@rank])
        goto L_InsertScore;
    // you already had a better score
    if (strcharinfo(0) == $Record_XXmas_Name$[@rank])
        goto L_Reward1;
    set @rank, @rank + 1;
    if (@rank == MAX_HIGH_SCORES)
        goto L_Reward1;
    goto L_MaybeInsertNext;

L_InsertScore:
    set @loop, @rank;
    goto L_FindLastScore;

L_FindLastScore:
    // comment this out to allow the player to be in the list more than once
    // though actually, it might be better just to assume the list is full
    if (strcharinfo(0) == $Record_XXmas_Name$[@loop])
        goto L_MoveStuff;

    set @loop, @loop + 1;
    if (@loop == MAX_HIGH_SCORES)
        goto L_MoveStuff;
    goto L_FindLastScore;

L_MoveStuff:
    if (@loop == @rank)
        goto L_FinallyInsertMe;
    set $Record_XXmas_Kills[@loop], $Record_XXmas_Kills[@loop - 1];
    set $Record_XXmas_Name$[@loop], $Record_XXmas_Name$[@loop - 1];
    set $Record_XXmas_Date$[@loop], $Record_XXmas_Date$[@loop - 1];
    set @loop, @loop - 1;
    goto L_MoveStuff;

L_FinallyInsertMe:
    set $Record_XXmas_Kills[@rank], XMAS2020;
    set $Record_XXmas_Name$[@rank], strcharinfo(0);
    callfunc "time_stamp";
    set $Record_XXmas_Date$[@rank], @ts_date$ + " " + @ts_time$;
    set @ts_date$, "";
    set @ts_time$, "";
    goto L_Reward1;

L_Reward1:
    // Maybe we should tell you how many you purified?
    if (XMAS2020 % 10 == 0 || XMAS2020 == 1)
        goto L_Warning;
    end;

L_Warning:
    message strcharinfo(0), "Grinchboos purified: "+XMAS2020;
    end;

OnTimer15000:
    areamonster "046-1", 20, 20, 160, 115, "", 1162, 18, "XXmas0461::OnHit2";
    // Only happens until :15, and every 15 minutes, for a total of 60 cycles.
    if (gettime(2) > 15)
        end;
    initnpctimer;
    end;

OnClock1800:
    initnpctimer;
    end;

OnClock1830:
    killmonster "046-1", "XXmas0461::OnHit2";
    stopnpctimer;
    end;

// Additional timers
OnClock0000:
    goto OnClock1800;
OnClock0030:
    goto OnClock1830;
OnClock0600:
    goto OnClock1800;
OnClock0630:
    goto OnClock1830;

OnNearbyNpc:
    explode .@nearby$[0], strnpcinfo(0,@target_id), "#";
    if(.@nearby$[0] == "arrow-hail" || .@nearby$[1] == "arrow-hail")
        set @nearby, @nearby + 1;
    end;
}

047-1,0,0,0|script|XXmas0471|32767
{
    end;

OnHit2:
    goto OnHit;

OnHit:
    // Not Christmas yet
    if (!$@xmas_time)
        end;
    // Reward time
    if ($@xmas_time == $@xmas_reward_time)
        end;
    // player must be created at least two weeks ago
    if ((BaseLevel < 30) || (gettimetick(2) - TUT_var < 2*7*86400))
        end;

    // Magic cheat
    if (@wandspell[4])
        end;
    if (@ingravspell[2])
        end;
    if (@chizaspell[2])
        end;
    if (@flarspell[2])
        end;
    if (@phlexspell[3])
        end;
    if (@chipchipspell[2])
        end;
    if (@upmarmuspell[1])
        end;

    // Not equipped to hunt Grinchboos
    //if (getequipid(equip_arrow) != 5260)
    //    end;
    if (getequipid(equip_hand1) != 5261)
        end;

    // By last, check for Arrow Hail
    set @nearby, 0;
    foreach 1, getmap(), @away[0] - 14, @away[1] - 14, @away[0] + 14, @away[1] + 14,
            strnpcinfo(0) + "::OnNearbyNpc";
    if (@nearby)
        end;

    // Grinchboo slain
    set XMAS2020, XMAS2020 + 1;
    set $XMAS2020_BOO, $XMAS2020_BOO + 1;
    set @loop, 0;
    set @rank, 0;
    goto L_MaybeInsertNext;

L_MaybeInsertNext:
    if (XMAS2020 > $Record_XXmas_Kills[@rank])
        goto L_InsertScore;
    // you already had a better score
    if (strcharinfo(0) == $Record_XXmas_Name$[@rank])
        goto L_Reward1;
    set @rank, @rank + 1;
    if (@rank == MAX_HIGH_SCORES)
        goto L_Reward1;
    goto L_MaybeInsertNext;

L_InsertScore:
    set @loop, @rank;
    goto L_FindLastScore;

L_FindLastScore:
    // comment this out to allow the player to be in the list more than once
    // though actually, it might be better just to assume the list is full
    if (strcharinfo(0) == $Record_XXmas_Name$[@loop])
        goto L_MoveStuff;

    set @loop, @loop + 1;
    if (@loop == MAX_HIGH_SCORES)
        goto L_MoveStuff;
    goto L_FindLastScore;

L_MoveStuff:
    if (@loop == @rank)
        goto L_FinallyInsertMe;
    set $Record_XXmas_Kills[@loop], $Record_XXmas_Kills[@loop - 1];
    set $Record_XXmas_Name$[@loop], $Record_XXmas_Name$[@loop - 1];
    set $Record_XXmas_Date$[@loop], $Record_XXmas_Date$[@loop - 1];
    set @loop, @loop - 1;
    goto L_MoveStuff;

L_FinallyInsertMe:
    set $Record_XXmas_Kills[@rank], XMAS2020;
    set $Record_XXmas_Name$[@rank], strcharinfo(0);
    callfunc "time_stamp";
    set $Record_XXmas_Date$[@rank], @ts_date$ + " " + @ts_time$;
    set @ts_date$, "";
    set @ts_time$, "";
    goto L_Reward1;

L_Reward1:
    // Maybe we should tell you how many you purified?
    if (XMAS2020 % 10 == 0 || XMAS2020 == 1)
        goto L_Warning;
    end;

L_Warning:
    message strcharinfo(0), "Grinchboos purified: "+XMAS2020;
    end;

OnTimer15000:
    areamonster "047-1", 20, 20, 200, 180, "", 1162, 48, "XXmas0471::OnHit2";
    // Only happens until :15, and every 15 minutes, for a total of 60 cycles.
    if (gettime(2) > 15)
        end;
    initnpctimer;
    end;

OnClock1800:
    initnpctimer;
    end;

OnClock1830:
    killmonster "047-1", "XXmas0471::OnHit2";
    stopnpctimer;
    end;

// Additional timers
OnClock0000:
    goto OnClock1800;
OnClock0030:
    goto OnClock1830;
OnClock0600:
    goto OnClock1800;
OnClock0630:
    goto OnClock1830;

OnNearbyNpc:
    explode .@nearby$[0], strnpcinfo(0,@target_id), "#";
    if(.@nearby$[0] == "arrow-hail" || .@nearby$[1] == "arrow-hail")
        set @nearby, @nearby + 1;
    end;
}