Paste #9989: Untitled Paste

Date: 2014/09/22 20:48:28 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


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
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390


config:
  type: task
  debug: true
  # Here are a bunch of things you need to fill out
  # for the script to work.
  # Fill this out with two coordinates that mark
  # the entrance of the tower.
  elderTempleEntrance: cu@-181,77,-137,world|-181,83,-143,world
  # Elder temple respawn point
  templeRespawn: -190,77,-140,world
  # Entrance to delkma burial grounds
  burialGroundsEntrance: cu@-38,28,196,world|13,39,265,world
  # The area where player is fighting Rats as a cube
  DockArea: cu@-182,10,254,world|-144,40,299,world
  # Name of the world where quest is.
  nameofworld: world
  # Fill this out with two coordinates that mark
  # the area closer to the thrones, that the player
  # walks to to get more information.
  elderTempleThroneArea: cu@-198,90,-128,world|-204,80,-155,world
  marketEntrance: cu@-172,40,171,world|-199,50,183,world
  # Cost of rat posion
  costOfPoison: 15
  # This is what the healer says the rats coordinates
  # are. DO NOT USE ":" use <&co> instead
  RatCords: "X<&co>-175 Z<&co>250"
  # This is the rat @ the gates cords
  RatCords2: "X<&co>-211 Z<&co>255"
  # Set these with the various hp's of bosses
  BrelinHP: 50
  AldranHP: 30
  GlenHP: 30
  StormHP: 100
  # Elder NPCId's
  estariusNpcId: n@456
  derastanNpcId: n@457
  eledorNpcId: n@458
  TaehlPoints: li@-128.2,46,117.3,world|-130.1,46,131.9,world|-139.1,48,131.9,world|-139.2,50,126,world|-134,52.5,125.8,world|-134,55,132.1,world|-131.6,56,131.9,world
  LythisPoints: li@-242.9,53,223.9,world|-231.9,53,214.1,world|-232,60,204,world|-226,60,191.9,world|-223,58,181.3,world|-214.3,50.5,179.7,world|-205,46,179,world|-184,46,179.4,world|-167.9,46,179.5,world|-143,46,179.8,world|-122.5,46,179.5,world|-103.2,46,179.5,world|-92.8,40.5,179.7,world|-91.2,41,185.6,world|-81.8,40.5,187.9,world|-75.2,40.5,181.6,world|-58.6,30,180.5,world|-56.1,31,212.75,world|-57.3,31,243.7,world|-62.3,29,287,world|-63.2,28,314.4,world|-63.8,26,347.4,world|-63.9,26,369.4,world|-64.4,31,376.6,world|-71.5,31,376.4,world
  # Fill this with the location where Taehl 'afks'
  # and waits for the player
  TaehlHome: -118.7,46,107.3,world
  GiantHome: -160.7,58,-140.6,world
  DaleHome: -166.3,30,293.6,world
  GroundskeeperHome: -5.2,31,229,world
  BroodQueenHome: -71.5,58,368.8,world
  HealerHome: -138,30,279,world
  ArchmageHome: -266,164,186,world
  LythisHome: -250,53,226,world
  LythisGates: -74,40,180,world
  Lythis2Boss: -64,31,376.5,world
  MayorHome: -174,148,174,world
  AliHome: -130,56,128.5,world
  AliBurialGrounds: -35,31,220,world
  BrelinHome: -133,46,129.5,world
  AldranHome: -125.6,46,130.5,world
  GlenHome: -124,46,124.1,world
  AliEquipmentRoom: -128,46,117,world
  AliTrainingGrounds: -123,46,143,world
  AliSparringGrounds: -131,46,146,world
  AliDoor: -130.2,46,135.1,world
  AliWatchFights: -123,46,143,world
  IsaacHome: -197,31,246,world
  # Specify the items in dList format, eg:
  # li@i@firstitemname|i@nextitemname
  # and if you want quantities do
  # li@i@coal[qty=32]|i@charcoal[qty=2]>
  # If you want enchants
  # li@i@diamond_pickaxe[enchantments=dig_speed,3;qty=2]
  MeleeClassItems: li@i@coal|i@wood
  RangedClassItems: li@i@coal|i@wood
  MagicClassItems: li@i@coal|i@wood
  # Dales zombie killing wep
  DaleWeapon: i@diamond_sword[enchantments=DAMAGE_ALL,1]
  # Armor / Weapons the archmage gives you on
  # the town hall roof.
  ArchmageArmor: li@i@coal|i@wood
  # Rewrd from Brood Queen fight
  BroodQueenReward: li@i@coal|i@wood
  # This is the command to be run when you want to assign the class
  MeleeClassSet: "command to set the class here with no / and you can use spaces"
  RangedClassSet: "command to set the class here with no / and you can use spaces"
  MagicClassSet: "command to set the class here with no / and you can use spaces"
  # Commands to add class skills
  MeleeClassSkillCmd: "command to add class here with no / and you can use spaces"
  RangedClassSkillCmd: "command to add class here with no / and you can use spaces"
  MagicClassSkillCmd: "command to add class here with no / and you can use spaces"
  # Level up command
  LevelUpCommand: "level up cmd here"
  # 6 different poitns for looters to spawn @
  LooterSpawn1: -143,30,294,world
  LooterSpawn2: -155,30,288,world
  LooterSpawn3: -142,30,280,world
  LooterSpawn4: -140,30,280,world
  LooterSpawn5: -138,30,258,world
  LooterSpawn6: -137,30,259,world
  # The bandits that protect Faulens house.
  BanditsSpawn1: -141.8,30,297,world
  BanditsSpawn2: -142,42,304,world
  BanditsSpawn3: -148,42,315,world
  BanditsSpawn4: -152,42,314,world
  BanditsSpawn5: -173,39,327,world
  BanditsSpawn6: -175,39,325,world
  # Faulens spawn point
  FaulenHome: -181,39,329,world
  # Burial Grounds Zombies Spawns
  BurialZombieSpawn1: -5,31,210.8,world
  BurialZombieSpawn2: -9,31,218,world
  BurialZombieSpawn3: -12,31,222,world
  BurialZombieSpawn4: -17,31,230,world
  BurialZombieSpawn5: -22,31,238,world
  BurialZombieSpawn6: -30,31,235,world
  # These are the zombies that spwan towards the end
  # They are trying to get into the elder temple
  ZombieSpawn1: -174,71.5,137,world
  ZombieSpawn2: -174,71.5,-142,world
  ZombieSpawn3: -172,69,-138,world
  ZombieSpawn4: -172.4,69,-140,world
  ZombieSpawn5: -172.1,69,-140,world
  ZombieSpawn6: -173,69,-140,world
  ZombieSpawn7: -176,73,-139,world
  ZombieSpawn8: -176,73,-142,world
  ZombieSpawn9: -176,73,-137,world
  ZombieSpawn10: -178,74,-139,world
  # Shoot back point
  # when the above zombies ender the elder temple this is the point they will be shot back too.
  ZombieShootBack: -167,70,-140,world
  # This is the location (must be inside cu@ElderTempleEntrance)
  # that npcs walkto to reach elders
  ZombieWalkto: -181.5,77,-140.3,world
  # This is the cuboid in whicht he player can say the ritual "Abre la puerta"
  # thats open the door in spanish
  IceGates: cu@298,33,-266,world|450,44,-318,world
  # Bed Point 
  BedPoint: -147,46,136,world
  RatsLoc1: -181,30,255,world
  RatsLoc2: -181,30,255,world
  VillagersLoc: -191,43,158,world
  DrokamaLoc: 0,2,250,world
hideNPCs:
  type: task
  debug: false
  script:
  # - queue clear
  - wait 2s
  - foreach <s@config.constant[nameofworld].as_world.players> {
    - define player %value%
    - if "<server.get_npcs_assigned[Taehl] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Taehl]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Rat] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Rat]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Ali] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Ali]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[faulensbandits] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[faulensbandits]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Brelin] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Brelin]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Aldran] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Aldran]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Glen] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Glen]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Dummy] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Dummy]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Dummy2] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Dummy2]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Dummy3] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Dummy3]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Mayor] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Mayor]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Lythis] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Lythis]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Healer] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Healer]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Bandits] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Bandits]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Faulen] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Faulen]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[golem] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[golem]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Archmage] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Archmage]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[BroodQueen] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[BroodQueen]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Minion] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Minion]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Dale] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Dale]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Groundskeeper] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Groundskeeper]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Undead] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Undead]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Giant] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Giant]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[RaidingZombie] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[RaidingZombie]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    - if "<server.get_npcs_assigned[Looter] || li@>" != li@ {
      - foreach <server.get_npcs_assigned[Looter]> {
        - if <def[value].is_spawned> && <def[value].flag[owner]> != %player% adjust %player% hide_entity:%value%
        }
      }
    }

npcManager:
  type: world
  debug: true
  events:
    on player joins:
    - if <player.location.world.name.is[!=].to[<s@config.constant[nameofworld]>]> queue clear
    - potion BLINDNESS duration:10s
    - wait 1s
    - narrate "<&a>Loading Quest State!"
    - foreach <player.flag[e.npcs].as_list> {
      - define loc <def[value].as_npc.flag[loc]>
      - spawn %value% %loc%
      }
    on player quits:
    - execute as_server "denizen save"
    - if <player.location.world.name.is[!=].to[<s@config.constant[nameofworld]>]> queue clear
    - foreach <player.flag[e.npcs].as_list> {
      - if !<def[value].as_npc.is_spawned> {
        - remove %value%
        - flag player e.npcs:<-:%value%
        } else {
        - flag %value% loc:<def[value].as_npc.location>
        - despawn %value%
        }
      }
elderTemple:
  type: world
  debug: true
  events:
    on NPC damaged by FIRE_TICK:
    - if <s@config.constant[nameofworld].is[==].to[<npc.location.world.name>]> determine cancelled
    on server start:
    - note <s@config.constant[elderTempleThroneArea]> as:elderTempleThroneArea
    - note <s@config.constant[elderTempleEntrance]> as:elderTempleEntrance
    - note <s@config.constant[DockArea]> as:DockArea
    - note <s@config.constant[marketEntrance]> as:marketEntrance
    - note <s@config.constant[IceGates]> as:IceGates
    on player enters cu@elderTempleEntrance:
    - ^if !<player.flag[e.entered1]> {
      - ^flag player e.entered1
      - ^run elderTalking1 def:<player>
      }
      else if <player.flag[e.entered3]> {
      - define player <player>
      - ^flag player e.entered3:!
      - ^run objective_remove "def:Enter the Temple|40"
      - ^remove <player.flag[e.raiders].as_list>
      - ^remove <player.flag[e.ally]>
      - ^narrate "<&7>[<&b>Eledor<&7> -> You]<&co> Thank you for your help! I told you all he was the one."
      - ^playeffect <s@config.constant[eledorNpcId].as_npc.location> effect:drip_lava qty:300 targets:%player%
      - ^wait 2s
      - ^narrate "<&7>[<&b>Derastan<&7> -> You]<&co> Hmph. I could have taken down that Giant... if I wanted to."
      - ^playeffect <s@config.constant[derastanNpcId].as_npc.location> effect:drip_lava qty:300 targets:%player%
      - ^wait 2s
      - ^narrate "<&7>[<&b>Estarius<&7> -> You]<&co> Thank you for your assistance, traveler. Or should I call you Hero? After all... it seems the prophecy was speaking of you. However, that is of no importance.. "
      - ^playeffect <s@config.constant[estariusNpcId].as_npc.location> effect:drip_lava qty:300 targets:%player%
      - ^wait 5s
      - ^narrate "<&7>[<&b>Estarius<&7> -> You]<&co> You must put an end to the undead blight once and for all. Travel to the ancient Gate of Frost, and use this ritual to open the gate." 
      - ^playeffect <s@config.constant[estariusNpcId].as_npc.location> effect:drip_lava qty:300 targets:%player%
      - ^narrate "<&8>Say the phrase <&a>Abre la puerta<&8> when you are near the gate"
      - ^run objective_add "def:Use the ritual|42"
      - ^run objective_add "def:Abre la puerta|41"
      - ^run updatecompass "def:Points to the IceGates|Points to the IceGates|<s@config.constant[IceGates]>"
      - ^wait 4s
      - ^narrate "<&7>[<&b>Eledor<&7> -> You]<&co> Once you are inside, you need to obtain the Holy Sigil of the Creator that lies inside. It fell from the heavens long ago, and it is the only thing 
      - ^playeffect <s@config.constant[eledorNpcId].as_npc.location> effect:drip_lava qty:300 targets:%player%
      - ^wait 3s
      - ^narrate "<&7>[<&b>Eledor<&7> -> You]<&co> that can completely stop the creatures of Volcivor... or so the legend says. So far it has come true."
      - ^playeffect <s@config.constant[eledorNpcId].as_npc.location> effect:drip_lava qty:300 targets:%player%
      - ^wait 3s
      - ^narrate "<&7>[<&b>Derastan<&7> -> You]<&co> There is a guardian in those caverns that will protect the relic at any cost. Try to evade it, but obtain that relic at any cost, even if it means destroying the Guardian. Good luck, traveler.8"
      - ^playeffect <s@config.constant[derastanNpcId].as_npc.location> effect:drip_lava qty:300 targets:%player%
      }
    on player enters cu@elderTempleThroneArea:
    - if <player.flag[e.entered2]> queue clear
    - flag player e.entered2
    - run elderTalking2 def:<player>
    on player joins:
    - inject hideNPCs
    on player teleports:
    - inject hideNPCs
    on player dies:
    - if <player.location.world.is[==].to[<s@config.constant[nameofworld]>]> {
      - teleport <player> <s@config.constant[templeRespawn]>
      - potion BLINDNESS duration:10
      - narrate "<&8>Looks like you lost that fight..."
      - determine cancelled
      }
    on player chats:
    - if <player.location.world.name.is[!=].to[<s@config.constant[nameofworld]>]> queue clear
    - define msg <context.message>
    - if %msg% != "Abre la puerta" queue clear
    - if !<player.location.is_within[cu@IceGates]> queue clear
    - teleport <player> <s@config.constant[IceCaverns].as_location>
    - flag player e.npcs:!
    - run objective_remove "def:Use the ritual|42"
    - run objective_remove "def:Abre la puerta|41"
    - remove <player.flag[e.npcs].as_list>
    on player right clicks m@bed_block,1:
    - ^if <player.flag[e.bed]> {
      - announce ran
      - ^flag player e.bed:!
      - ^determine passively cancelled
      - ^potion Blindness duration:10s
      - ^narrate "<&8>That was a good rest"
      - ^run objective_remove "def:Find a bed|11"
      - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Above the marketplace there should be some stairs leading the the city hall. The mayor waits for ye there."
      - ^run objective_add "def:Visit the mayor|12"
      - ^zap step:mayor s@AliSteps
      - ^run updatecompass "def:Points to the Mayor|Points to the Mayor|<s@config.constant[MayorHome]>"
      - ^create player "Ethius Drale" <s@config.constant[MayorHome]> save:mayor
      - ^define mayor <entry[mayor].created_npc>
      - ^flag player e.npcs:->:%Mayor%
      - ^lookclose state:true npc:%mayor%
      - ^assignment set script:mayor npc:%mayor%
      - ^flag %mayor% owner:<player>
      - ^run hideNPCs instantly
      }
    - ^if <player.flag[e.bed2]> {
      - ^determine passively cancelled
      - ^run objective_remove "def:Go to Sleep|28"
      - ^flag player e.bed2:!
      - ^potion BLINDNESS duration:10s
      - ^wait 4s
      - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Morning.  I expect the Mayor will  need you today as well... be about your duties."
      - ^run objective_add "def:Visit the Mayor|29"
      - ^run updatecompass "def:Points to the Mayor|Points to the Mayor|<s@config.constant[MayorHome]>"
      - ^zap step:5 s@MayorSteps
      }
    - ^if <player.flag[e.bed3]> {
      - ^determine passively cancelled
      - ^run objective_remove "def:Sleep|34"
      - ^flag player e.bed3:!
      - ^potion BLINDNESS duration:10s
      - ^wait 4s
      - ^narrate "<&4>Loud yelling and screaming outside"
      - ^narrate "<&7>[<&b>Guard<&7> -> You]<&co> <&4>Call up the guards, the city is in danger"
      - ^run objective_add "def:Go to Ali|35"
      - ^run updatecompass "def:Points to Ali|Points to Ali|<s@config.constant[AliHome]>"
      - ^zap step:11 s@AliSteps
      }
elderTalking1:
  type: task
  script:
  # Define the npc's just for ez reference
  - define estarius <s@config.constant[estariusNpcId].as_npc>
  - define derastan <s@config.constant[derastanNpcId].as_npc>
  - define eledor <s@config.constant[eledorNpcId].as_npc>
  - define player %1%
  # Use look and animate them
  - look %estarius% <def[derastan].location.add[0,1,0]>
  - animate %estarius% animation:ARM_SWING
  - look %derastan% <def[estariusNpcId].location.add[0,1,0]>
  - animate %derastan% animation:ARM_SWING
  - wait .5s
  - lookclose %estarius% state:true range:15
  - lookclose %derastan% state:true range:15
  - lookclose %eledor% state:true range:15
  - narrate "<&7>[<&b>Estarius<&7> -> You]<&co> I dispatched Taehl to the docks yesterday. I trust him to send any travelers he sees to us." targets:%player%
  - playeffect <def[estarius].location> effect:drip_lava qty:300 targets:%player%
  - animate %estarius% animation:ARM_SWING
  - wait 2s
  - narrate "<&7>[<&b>Derastan<&7> -> You]<&co> The sun is setting earlier than usual... the darkness is coming." targets:%player%
  - playeffect <def[derastan].location> effect:drip_lava qty:300 targets:%player%
  - animate %Derastan% animation:ARM_SWING
  - narrate "<&8>Walk up to the thrones"
elderTalking2:
  type: task
  script:
  # Define the npc's just for ez reference
  - define estarius <s@config.constant[estariusNpcId].as_npc>
  - define derastan <s@config.constant[derastanNpcId].as_npc>
  - define eledor <s@config.constant[eledorNpcId].as_npc>
  - define player %1%
  # Make em talk
  - narrate "<&7>[<&b>Eledor<&7> -> You]<&co> This one is a traveler... the prophecy is coming to pass! Call the guards and the warriors!" targets:%player%
  - playeffect <def[eledor].location> effect:drip_lava qty:300 targets:%player%
  - wait 4s
  - narrate "<&7>[<&b>Estarius<&7> -> You]<&co> Eledor<&cm> calm yourself. This is not the first time we have had a visitor on the day of the prophecy." targets:%player%
  - playeffect <def[estarius].location> effect:drip_lava qty:300 targets:%player%
  - animate %estarius% animation:ARM_SWING
  - wait 4s
  - narrate "<&7>[<&b>Eledor<&7> -> You]<&co> Are you blind? The prophecy says that on the day of Volcivan in the second month that a traveler will arrive<&cm> and the forces of Volcivor will awake!" targets:%player%
  - playeffect <def[eledor].location> effect:drip_lava qty:300 targets:%player%
  - wait 5s
  - narrate "<&7>[<&b>Derastan<&7> -> You]<&co> Greetings<&cm> we are the Elders of Aleraden. I am Derastan." targets:%player%
  - playeffect <def[derastan].location> effect:drip_lava qty:300 targets:%player%
  - animate %estarius% animation:ARM_SWING
  - wait 3s
  - narrate "<&7>[<&b>Eledor<&7> -> You]<&co> I am eledor." targets:%player%
  - playeffect <def[eledor].location> effect:drip_lava qty:300 targets:%player%
  - wait 2s
  - narrate "<&7>[<&b>Estarius<&7> -> You]<&co> And I am Estarius. While I am doubtful that you are the one the prophecy speaks of<&cm> I suppose it would be wise to investigate." targets:%player%
  - playeffect <def[Estarius].location> effect:drip_lava qty:300 targets:%player%
  - wait 4s
  - narrate "<&7>[<&b>Eledor<&7> -> You]<&co> The prophecy is clear! In the month of snow<&cm> on the day of two moons<&cm> a friend will arrive in Aleraden<&cm> bringing life and death to many." targets:%player%
  - playeffect <def[Eledor].location> effect:drip_lava qty:300 targets:%player%
  - wait 4s
  - narrate "<&7>[<&b>Derastan<&7> -> You]<&co> Do you honestly think this... 'weakling' could protect or kill anyone?" targets:%player%
  - playeffect <def[Derastan].location> effect:drip_lava qty:300 targets:%player%
  - animate %Derastan% animation:SNEAK
  - wait 4.5s
  - animate %Derastan% animation:STOP_SNEAKING
  - narrate "<&7>[You -> <&b>Elders<&7>]<&co> What are you all talking about!" targets:%player%
  - wait 3s
  - narrate "<&7>[<&b>Estarius<&7> -> You]<&co> An ancient prophecy says that on the day of Volcivan<&cm> in the second month<&cm> a foreigner will arrive and bring both peace and war<&cm> life and death. While you are a doubtful candidate<&cm> it is our duty to be prepared. Prepare yourself to face your first test." targets:%player%
  - playeffect <def[Estarius].location> effect:drip_lava qty:300 targets:%player%
  - wait 6s
  - narrate "<&8>Prepare to fight an iron golem!"
  - wait 2s
  - ^run objective_add "def:Kill the golem|1"
  - ^create player Golem <player.location.add[1,0,1]> save:Golem
  - ^define Golem <entry[Golem].created_npc>
  - ^execute as_server "npc sel <def[golem].id>"
  - ^execute as_server "npc skin MHF_GOLEM"
  - ^equip %golem% chest:i@chainmail_chestplate legs:i@chainmail_leggings boots:i@chainmail_boots
  - ^flag player e.npcs:->:%Golem%
  - ^flag %golem% owner:%player%
  - ^run hideNPCs instantly
  - ^assignment set script:Golem npc:%golem%
golem:
  type: assignment
  actions:
    on assignment:
    - ^trigger name:proximity state:true radius:10
    - ^lookclose <npc> state:true
    - ^trigger name:damage state:true
    - ^vulnerable <npc> state:true
    - ^attack <npc> target:<npc.flag[owner]>
    - ^flag npc attacking duration:2s
    on death:
    - run elderTalking3 def:<player>
    - run locally remove def:<npc> delay:4s
    - run objective_remove "def:Kill the golem|1"
    on move proximity:
    - ^if <player.is[!=].to[<npc.flag[owner].as_player>]> queue clear
    - ^if <npc.flag[attacking]> queue clear
    - ^flag npc attacking
    - ^attack <npc> target:<npc.flag[owner]>
  remove: 
  - remove %1%
elderTalking3:
  type: task
  script:
  # Define the npc's just for ez reference
  - define estarius <s@config.constant[estariusNpcId].as_npc>
  - define derastan <s@config.constant[derastanNpcId].as_npc>
  - define eledor <s@config.constant[eledorNpcId].as_npc>
  - define player %1%
  # Make em talk
  - narrate "<&7>[<&b>Derastan<&7> -> You]<&co> Well<&cm> it seems there is more to you than meets the eye. Shall we send him off to train? Time may be short... " targets:%player%
  - playeffect <def[Derastan].location> effect:drip_lava qty:300 targets:%player%
  - wait 4s
  - narrate "<&7>[<&b>Eledor<&7> -> You]<&co> What did I tell you<&cm> he is the one." targets:%player%
  - playeffect <def[Eledor].location> effect:drip_lava qty:300 targets:%player%
  - wait 5s
  - narrate "<&7>[<&b>Estarius<&7> -> You]<&co> Do not jump to conclusions. However<&cm> Derastan is right. Upon the chance you are the one<&cm> you will need to be prepared. Begin your training immediately. If you truly are the one spoken of in the prophecy<&cm> evil will fall upon this city within the week." targets:%player%
  - playeffect <def[Estarius].location> effect:drip_lava qty:300 targets:%player%
  - wait 5s
  - narrate "<&7>[You -> <&b>Elders<&7>]<&co> As you wish elders" targets:%player%
  - narrate "<&8>Leave the temple and travel to the Trainnig Hall and talk to Taehl" targets:%player%
  - run objective_add "def:Go see Taehl|2"
  - ^run updatecompass "def:Points to Taehl|Points to Taehl|<s@config.constant[TaehlHome]>" as:<player>
  - create player Taehl <s@config.constant[TaehlHome]> save:taehl
  - flag player e.npcs:->:<entry[Taehl].created_npc>
  - assignment set script:s@Taehl npc:<entry[taehl].created_npc>
  - flag <entry[taehl].created_npc> owner:%player%
  - run hideNPCs instantly
objective_compass:
  type: item
  material: compass
  display name: Objective Compass
  lore:
  - Points toward your next
  - quest objective.

Taehl:
  type: assignment
  actions:
    on assignment:
    - trigger name:chat state:true cooldown:1s
    - trigger name:proximity state:true radius:8
    - trigger name:click state:true cooldown:1s
    - lookclose <npc> state:true
    on complete navigation:
    - if !<npc.flag[is_walking]> queue clear
    - inject locally NextWalk
  interact scripts:
  - 10 TaehlSteps
  NextWalk:
  - ^if <npc.location.distance[<s@config.constant[TaehlPoints].as_list.get[<npc.flag[current_number]>]>]> <&gt> 4 {
    - ^define current_number <npc.flag[current_number]>
    - ^define location <s@config.constant[TaehlPoints].as_list.get[%current_number%]>
    - ^flag npc is_walking
    - ^walkto %location%
    }
    else {
    - ^define currentPlus <npc.flag[current_number].add[1].as_int>
    - ^if "<s@config.constant[TaehlPoints].as_list.get[%currentPlus%] || null >" == null {
      - ^flag npc is_walking:!
      - ^narrate "<&7>[<&b>Taehl<&7> -> You]<&co> Here we are!"
      - ^wait 2s
      - ^playeffect <npc.location> effect:cloud data:1 qty:2500
      - ^wait .2s
      - ^flag <npc.flag[owner]> e.npcs:<-:<npc>
      - ^remove <npc>
      - ^queue clear
      }
    - ^define location <s@config.consant[TaehlPoints].as_list.get[%currentPlus%]>
    - ^flag npc current_location:%location%
    - ^flag npc current_number:%currentPlus%
    - ^flag npc is_walking
    - ^walkto %location%
    }
TaehlSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - engage
        - run objective_remove "def:Go see Taehl|2"
        - narrate "<&7>[<&b>Taehl<&7> -> You]<&co> Good<&cm> you're back! I got orders from the Elders to bring you to Master Ali right away. "
        - playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Taehl<&7> -> You]<&co> He will be training you personally. Master Ali is the best warrior we have here. Blades<&cm> bows<&cm> and magic... he is an expert in them all."
        - playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Taehl<&7> -> You]<&co> Don't let his size fool you; that Dwarf could kill you in a flash<&cm> in dozens of ways."
        - playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^zap step:1 s@AliSteps
        - ^create player Ali <s@config.constant[AliHome]> save:Ali
        - ^flag <entry[Ali].created_npc> owner:<player>
        - ^flag player e.npcs:->:<entry[Ali].created_npc>
        - ^flag player e.ali:->:<entry[Ali].created_npc>
        - ^assignment set script:s@Ali npc:<entry[Ali].created_npc>
        - ^flag <entry[Ali].created_npc> owner:<player>
        - ^run hideNPCs instantly
        - ^flag npc current_number:1
        - ^flag npc current_location:<s@config.constant[TaehlPoints].as_list.get[1]>
        - ^disengage
        - ^zap step:walking
        - ^inject locally NextWalk
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&8>Right click Taehl"
    walking:
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - if <npc.flag[is_walking]> flag npc is_walking:!
          - narrate "<&8>Continue following Taehl!"
          - inject locally NextWalk
        exit:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - if <npc.flag[is_walking]> {
            - pause waypoints
            - flag npc is_walking:!
            - narrate "<&8>Stay with Taehl!"
            }
    2:
      click trigger:
        script:
        - narrate "<&7>[<&b>Taehl<&7> -> You]<&co> Nice to see you"
  NextWalk:
  - ^if <npc.location.distance[<s@config.constant[TaehlPoints].as_list.get[<npc.flag[current_number]>]>]> <&gt> 4 {
    - ^define current_number <npc.flag[current_number]>
    - ^define location <s@config.constant[TaehlPoints].as_list.get[%current_number%]>
    - ^flag npc is_walking
    - ^walkto %location%
    }
    else {
    - ^define currentPlus <npc.flag[current_number].add[1].as_int>
    - ^if "<s@config.constant[TaehlPoints].as_list.get[%currentPlus%] || null >" == null {
      - ^flag npc is_walking:!
      - ^narrate "<&7>[<&b>Taehl<&7> -> You]<&co> Here we are!"
      - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      - ^wait 2s
      - ^playeffect <npc.location> effect:cloud data:1 qty:2500
      - ^wait .2s
      - ^flag <npc.flag[owner]> e.npcs:<-:<npc>
      - ^remove <npc>
      - ^queue clear
      }
    - ^define location <s@config.consant[TaehlPoints].as_list.get[%currentPlus%]>
    - ^flag npc current_location:%location%
    - ^flag npc current_number:%currentPlus%
    - ^flag npc is_walking
    - ^walkto %location%
    }
Ali:
  type: assignment
  actions:
    on assignment:
    - trigger name:chat state:true cooldown:1s
    - trigger name:proximity state:true radius:7
    - trigger name:click state:true cooldown:1s
    - lookclose <npc> state:true radius:10
    - execute as_server "npc sel <npc.id>"
    - execute as_server "npc pathrange 30"
  interact scripts:
  - 10 AliSteps
AliSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
        - ^if <npc.flag[clicked] queue clear
        - ^zap step:chose
        - ^flag npc clicked duration:10s
        - ^flag npc queue:<queue.id>
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Greetings! I just received orders to turn you into my finest pupil... as fast as possible. I have to say<&cm> it will be a challenge. Have you any combat experience?"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 2s
        - ^narrate "<&7>[<&b>You -> <&b>Ali<&7>]<&co> I don't have much"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 4s
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> We'll fix that right away. First off<&cm> you'll need to choose what area of combat you wish to focus on."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 4s
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> I can teach you how to use a blade<&cm> a bow<&cm> or magic. Our time is short<&cm> so only pick one."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 4s
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Be sure of yourself. Once you've started training<&cm>? I'm not teaching ye' anything different from your choice."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 2s
        - ^narrate "<&a>Type<&co> Melee Ranged or Magic"
        - ^run objective_add "def:Pick Class|3"
        - ^flag npc queue:!
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&8>Right click Ali"
        exit:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&8>Please do not exit while Ali is talking to you...."
          - queue queue:<npc.flag[queue]> pause
    chose:
      chat trigger:
        Melee:
          trigger: <&7>/Melee/ would be best for me
          script:
          - engage
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - flag npc queue:<queue.id> 
          - zap step:walking
          - run objective_remove "def:Pick Class|3"
          - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Excellent choice! Now<&cm> to begin you will need some equipment. Follow me."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - flag player e.class:Melee
          - ~walkto <npc> <s@config.constant[AliEquipmentRoom].as_location>
          - zap step:3
          - run objective_add "def:Right click Ali|4"
          - narrate "<&8>Right click Ali to get your supplies"
          - disengage
        Ranged:
          trigger: <&7>/Ranged/ would be best for me
          script:
          - engage
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - flag npc queue:<queue.id> 
          - zap step:walking
          - run objective_remove "def:Pick Class|3"
          - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Excellent choice! Now<&cm> to begin you will need some equipment. Follow me."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - flag player e.class:Ranged
          - ~walkto <npc> <s@config.constant[AliEquipmentRoom].as_location>
          - zap step:3
          - run objective_add "def:Right click Ali|4"
          - narrate "<&8>Right click Ali to get your supplies"
          - disengage
        Magic:
          trigger: <&7>/Magic/ would be best for me
          script:
          - engage
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - flag npc queue:<queue.id> 
          - zap step:walking
          - run objective_remove "def:Pick Class|3"7
          - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Excellent choice! Now<&cm> to begin you will need some equipment. Follow me."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - flag player e.class:Magic
          - ~walkto <npc> <s@config.constant[AliEquipmentRoom].as_location>
          - zap step:3
          - run objective_add "def:Right click Ali|4"
          - narrate "<&8>Right click Ali to get your supplies"
          - disengage
    walking:
      proximity trigger:
        exit:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - ^narrate "<&8>Please follow Ali."
          - ^pause waypoints
          - ^queue queue:<npc.flag[queue]> pause
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Good your back."
          - ~walkto <s@config.constant[AliEquipmentRoom].as_location>
          - queue queue:<npc.flag[queue]> resume
    3:
      click trigger:
        script:
        - ^engage
        - ^playeffect -128,46,116,world effect:CLOUD qty:100
        - ^run objective_remove "def:Right click Ali|4"
        - ^give <s@config.constant[<player.flag[e.class]>ClassItems]>
        - ^playsound <player> name:HORSE_ARMOR
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Follow me outside"
        - ^walkto <s@config.constant[AliWatchFights]>
        - ^wait 5s
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Now! Show me what you can do with that weapon on the dummy outside."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^create player Dummy <s@config.constant[AliSparringGrounds]> save:dummy
        - ^flag player e.npcs:->:<entry[dummy].created_npc>
        - ^equip <entry[dummy].created_npc> head:i@zombie_skull
        - ^flag <entry[dummy].created_npc> owner:<player>
        - ^assignment set script:dummy npc:<entry[dummy].created_npc>
        - ^run hideNPCs instantly
        - ^narrate "<&8>Kill the dummy"
        - ^run objective_add "def:Kill the dummy|5"
        - ^zap step:4
        - ^disengage
    4:
      click trigger:
        script:
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Go attack that dummy!"
    5:
      click trigger:
        script:
        - ^engage
        - run objective_remove "def:Right click Ali|7"
        - narrate "<&8>You have reached level 2"
        - execute as_server "<s@config.constant[LevelUpCommand]>"
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> You're a natural fighter. Now<&cm> let us test your skills against something that fights back! Follow me to the sparring ring."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 3.5s
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> But first<&cm> go find your opponent Brelin downstairs."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 1s
        - narrate "<&8>Right click Brelin to start the fight"
        - run objective_add "def:Beat Brelin|8"
        - ^run updatecompass "def:Points to Brelin|Points to Brelin|<s@config.constant[AliSparringGrounds]>"
        - create player Brelin <s@config.constant[BrelinHome]> save:Brelin
        - flag player e.npcs:->:<entry[Brelin].created_npc>
        - flag <entry[Brelin].created_npc> owner:<player>
        - assignment set script:Brelin npc:<entry[Brelin].created_npc>
        - run hideNPCs instantly
        - zap step:6
        - ~walkto <s@config.constant[AliWatchFights]>
        - ^disengage
    6:
      click trigger:
        script:
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> You need to go fight Brelin"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    7:
      click triggeR:
        script:
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Well done against Brelin. It will take more than that to prove yourself. On to the next opponent!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    killedAldran:
      click triggeR:
        script:
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Well done against Aldran. It will take more than that to prove yourself. On to Glen!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    bed:
      click triggeR:
        script:
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Go find a bed and sleep!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    mayor:
      click triggeR:
        script:
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Be about your duties."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    8:
      click trigger:
        script:
        - engage
        - ^zap step:4
        - ^run objective_remove "def:Go to Ali|32"
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Hello, I've given you a new skill, practice it on the dummy on the sparring grounds"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^run hideNPCs instantly
        - ^create player Dummy <s@config.constant[AliSparringGrounds]> save:dummy
        - ^flag player e.npcs:->:<entry[dummy].created_npc>
        - ^equip <entry[dummy].created_npc> head:i@zombie_skull
        - ^flag <entry[dummy].created_npc> owner:<player>
        - ^assignment set script:dummy3 npc:<entry[dummy].created_npc>
        - ^inject hideNPCs
        - ^narrate "<&8>Kill the dummy"
        - ^run objective_add "def:Kill the dummy|33"
        - disengage
    9:
      click trigger:
        script:
        - ^engage
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Good, you learn quickly.. Be sure to get plenty of rest, because you must be well rested to train tomorrow."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 3s
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> The Elders want you fully trained as fast as possible, and that is what I intend to do. Get some sleep."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^run objective_add "def:Sleep|34"
        - ^run updatecompass "def:Points to a Bed|Points to a Bed|<s@config.constant[BedPoint]>"
        - ^flag player e.bed3
        - ^zap step:10
        - ^disengage
    10:
      click trigger:
        script:
        - narrate "<&7>[<&b>Ali<&7> -> You]<&co> hmmm?"
    11:
      click trigger:
        script:
        - ^engage
        - ^run objective_remove "def:Go to Ali|35"
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> It seems the day of Volcivan has not passed without event. Reports of attacks are coming in from all over the city."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 3s
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Skeletons are assaulting the city walls, and the undead are rising all around. I have an old friend by the docks. He was a undead slayer and a champion of the city in the days of his youth."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 4s
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> His name is Dale. Go and find his home; he often shows off the skulls of the monsters he has slain, so you shouldn't be able to miss his dwelling."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 3s
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> He can help you! Go to him and seek aid while I fight off the attacking undead!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^run objective_add "def:Go to Dale|36"
        - ^run updatecompass "def:Points to Dale|Points to Dale|<s@config.constant[DaleHome]>"
        - ^narrate "<&8>Go to Dale @ X<&co>-150 Z<&co>275"
        - ^create Player Dale <s@config.constant[DaleHome]> save:Dale
        - ^define Dale <entry[Dale].created_npc>
        - ^flag player e.npcs:->:%Dale%
        - ^assignment set script:s@Dale npc:%Dale%
        - ^flag %Dale% owner:<player>
        - ^run hideNPCs instantly
        - ^zap step:12
        - ^disengage
    12:
      click trigger:
        script:
        - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Go find dale!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>

dummy:
  type: assignment
  actions:
    on assignment:
    - ^trigger name:proximity state:true
    - ^trigger name:damage state:true
    - ^vulnerable <npc> state:true 
    - ^execute as_server "npc sel <npc.id>"
    - ^execute as_server "npc skin Cow"
    on death:
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Very good. Now<&cm> you're ready for your first skill to use in combat!"
    - run objective_remove "def:Kill the dummy|5"
    - wait 1s
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> I'll spawn another dummy for you to use your new ability on!"
    - run objective_add "def:Kill dummy 2|6"
    - wait 2s
    - create player Dummy <s@config.constant[AliSparringGrounds]> save:dummy2
    - equip <entry[dummy2].created_npc> head:i@zombie_skull
    - flag player e.npcs:->:<entry[dummy2].created_npc>
    - flag <entry[dummy2].created_npc> owner:<player>
    - run hideNPCs instantly
    - assignment set script:dummy2 npc:<entry[dummy2].created_npc>
    - execute as_server "<s@config.constant[<player.flag[e.class]>ClassSkillCmd]>"
    - run locally remove def:<npc>
  remove:
  - wait 5s
  - remove %1%
dummy2:
  type: assignment
  actions:
    on assignment:
    - ^trigger name:damage state:true
    - ^vulnerable state:true
    - ^execute as_server "npc sel <npc.id>"
    - ^execute as_server "npc skin Cow"
    on death:
    - run objective_remove "def:Kill dummy 2|6"
    - zap s@AliSteps step:5
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Good job<&cm> come to talk to me to receive your new level."
    - run objective_add "def:Right click Ali|7"
    - narrate "<&8>Right click Ali"
    - run locally remove def:<npc>
  remove:
  - wait 5s
  - remove %1%
dummy3:
  type: assignment
  actions:
    on assignment:
    - ^trigger name:damage state:true
    - ^vulnerable state:true
    - ^execute as_server "npc sel <npc.id>"
    - ^execute as_server "npc skin Cow"
    on death:
    - ^run objective_remove "def:Kill the dummy|33"
    - zap s@AliSteps step:9
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Good job<&cm> come to talk to me to receive your new level."
    - narrate "<&8>Right click Ali"
    - run locally remove def:<npc>
  remove:
  - wait 5s
  - remove %1%

Brelin:
  type: assignment
  actions:
    on assignment:
    - ^flag npc attacking:!
    - ^trigger name:chat state:true cooldown:1s
    - ^trigger name:proximity state:true radius:20
    - ^trigger name:click state:true cooldown:1s
    - ^trigger name:damage state:false
    - ^vulnerable state:false
    - ^health <npc> <s@config.constant[BrelinHP]> state:true
    - ^heal <npc> <s@config.constant[BrelinHP]>
    - ^equip <npc> hand:i@iron_sword chest:i@iron_chestplate legs:i@iron_pants
    - ^lookclose <npc> state:true radius:10
    - engage
    - ~walkto <s@config.constant[AliSparringGrounds]>
    - disengage
    on death:
    - ^if <npc.flag[deathran]> queue clear
    - ^flag npc deathran duration:5s
    - ^run objective_remove "def:Beat Brelin|8"
    - ^engage
    - ^zap s@BrelinSteps step:3
    - ^queue queue:<npc.flag[queue]> clear
    - ^if <npc.flag[died]> queue clear
    - ^flag npc died duration:10s
    - ^flag npc attacking:!
    - ^narrate "<&7>[<&b>Brelin<&7> -> You]<&co> Aye<&cm> I'm no match for you yet. I'll keep training<&cm> and we'll spar again!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 2s
    - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Well done. It will take more than that to prove yourself. On to the next opponent<&cm> his name is Aldran go talk to him to fight!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 2s
    - ^narrate "<&8>Aldran is waiting for you, right click him"
    - ^run objective_add "def:Beat Aldran|9"
    - ^run updatecompass "def:Points to Aldran|Points to Aldran|<s@config.constant[AliSparringGrounds]>"
    - ^run locally spawn
    - ^trigger name:damage state:false
    - ^vulnerable state:false
    - ^zap s@AliSteps step:7
    - ^run hideNPCs instantly
    - ^create player Aldren <player.location.add[1,0,1]> save:Aldran
    - ^flag player e.npcs:->:<entry[Aldran].created_npc>
    - ^flag <entry[Aldran].created_npc> owner:<npc.flag[owner].as_player>
    - ^assignment set script:s@Aldran npc:<entry[Aldran].created_npc>
    - ^inject hideNPCs
  interact scripts:
  - 10 BrelinSteps
  spawn:
  - wait 5s
  - spawn <npc> <s@config.constant[BrelinHome].as_location>
  - flag npc talking:!
  - disengage
  - vulnerable state:false
  - trigger name:damage state:false
BrelinSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - engage
        - narrate "<&7>[<&b>Brelin<&7> -> You]<&co> How are ye'? The name is Brelin<&cm> a new pupil of Ali. This is my second day in the ring... I see your ready to fight<&cm> I'll see you in the ring."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ~walkto <s@config.constant[AliSparringGrounds]> speed:2
        - ^disengage
        - ^trigger name:damage state:true cooldown:1s
        - ^vulnerable state:true
        - ^flag npc attacking:!
        - ^zap step:2
      proximity trigger:
        entry:
          script:
          - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - ^walkto <npc> <npc.location.add[.1,0,.1]>
          - ^pause waypoints
          - ^attack <npc> target:cancel
          - ^if <player.flag[e.brelin]> queue clear
          - ^narrate "<&8>Right click Brelin"
          - ^flag player e.brelin
    2:
      proximity trigger:
        entry:
          script:
          - if <player.is[!=].to[<npc.flag[owner]>]> queue clear
          - flag npc attacking
          - vulnerable state:true
          - attack <npc> target:<player>
          - if !<npc.flag[talking]> {
            - ^flag npc talking
            - ^inject locally combatdialouge
            }
        exit:
          script:
          - if <player.is[==].to[<npc.flag[owner]>]> {
            - ^walkto <npc> <npc.location.add[.1,0,.1]>
            - flag npc attacking:!
            - attack <npc> target:cancel
            - pause waypoints
            - queue queue:<npc.flag[queue]> clear
            - trigger name:damage state:false cooldown:1s
            - vulnerable state:false
            - narrate "<&a>You exitted Brelin's range the fight is resetting."
            - narrate "<&7>[<&b>Brelin<&7> -> You]<&co> Ugh taking the cowards way out"
            - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
            - teleport <npc> <s@config.constant[BrelinHome]>
            - zap step:1
            }
        move:
          script:
          - if <npc.flag[died]> queue clear
          - if <player.is[!=].to[<npc.flag[owner]>]> queue clear
          - if !<npc.flag[attacking]> {
            - flag npc attacking
            - vulnerable state:true
            - attack <npc> target:<player>
            - if !<npc.flag[talking]> {
              - ^flag npc talking
              - ^inject locally combatdialouge
              }
            }
    3:
      click trigger:
        script:
        - narrate "<&7>[<&b>Brelin<&7> -> You]<&co> That was a good fight laddie."

  combatdialouge:
  - ^if !<npc.flag[attacking]> queue clear
  - ^flag npc queue:<queue.id>
  - ^random {
    - narrate "<&7>[<&b>Brelin<&7> -> You]<&co> You won't get the better of me that easy!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - narrate "<&7>[<&b>Brelin<&7> -> You]<&co> Nice move! You'll have to teach me that one."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - narrate "<&7>[<&b>Brelin<&7> -> You]<&co> Gah<&cm> that hurt!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - narrate "<&7>[<&b>Brelin<&7> -> You]<&co> Master Ali taught me this himself!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    }
  - ^wait 8s
  - ^if !<npc.flag[attacking]> queue clear
  - ^inject locally combatdialouge

Aldran:
  type: assignment
  actions:
    on assignment:
    - ^engage
    - ^adjust <npc> teleport_on_stuck:false
    - ^lookclose <npc> state:true range:25
    - ^trigger name:chat state:true cooldown:1s
    - ^trigger name:proximity state:true radius:30
    - ^trigger name:click state:true cooldown:1s
    - ^trigger name:damage state:true
    - ^vulnerable state:false
    - ^health <npc> <s@config.constant[AldranHP]> state:true
    - ^heal <npc> <s@config.constant[AldranHP]>
    - ^equip <npc> hand:i@bow[enchantments=ARROW_DAMAGE,3;enchantments=DURABILITY,3] chest:i@leather_chestplate legs:i@leatherlegs
    - ~walkto <npc> <s@config.constant[AliSparringGrounds].as_location>
    - ^disengage
    - zap step:Ready2Fight s@AldranSteps
    on death:
    - ^run locally eclear def:<npc>
    - ^if <npc.flag[died]> queue clear
    - ^flag npc died duration:10s
    - ^flag npc fighting:!
    - ^flag npc attacking:!
    - run objective_remove "def:Beat Aldran|9"
    - ^queue queue:<npc.flag[queue]> clear
    - run locally spawn
    - trigger name:damage state:false
    - vulnerable state:false
    - zap step:finished s@AldranSteps 
    - zap s@AliSteps step:killedAldran
    - wait 1s
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> You have one last opponent... His name is glen and he is waiting for you."
    - narrate "<&8>Right click Glen"
    - run objective_add "def:Beat Glen|10"
    - ^run updatecompass "def:Points to Glen|Points to Glen|<s@config.constant[AliSparringGrounds]>"
    - create player Glen <s@config.constant[GlenHome]> save:Glen
    - flag player e.npcs:->:<entry[Glen].created_npc>
    - flag <entry[Glen].created_npc> owner:<npc.flag[owner].as_player>
    - run hideNPCs instantly
    - assignment set script:s@Glen npc:<entry[Glen].created_npc>
  interact scripts:
  - 10 AldranSteps
  spawn:
  - wait 5s
  - spawn <npc> <s@config.constant[AldranHome].as_location>
  eclear:
  - wait 2s
  - queue queue:<def[1].flag[queue]> clear
AldranSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - ^engage
        - ^narrate "<&7>[<&b>Aldran<&7> -> You]<&co> I'm ready to fight!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ~walkto <s@config.constant[AliSparringGrounds]>
        - ^zap step:Ready2Fight s@AldranSteps
        - wait .1s
        - ^trigger name:damage state:true
        - ^vulnerable state:true
        - ^disengage
    Ready2Fight:
      proximity trigger:
        move:
          script:
          - ^narrate "<&7>[<&b>Aldran<&7> -> You]<&co> Hmm. I've fought many souls<&cm> but the way you fight seems unique. I look forward to learning from your fighting style. Prepare yourself!"
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - ^zap step:fighting s@AldranSteps
          - ^flag npc fighting
          - ^vulnerable state:true
          - ^lookclose state:false
          - inject locally attackTarget
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      damage trigger:
        script:
        - ^narrate "<&7>[<&b>Aldran<&7> -> You]<&co> Hmm. I've fought many souls<&cm> but the way you fight seems unique. I look forward to learning from your fighting style. Prepare yourself!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^zap step:fighting s@AldranSteps
        - ^flag npc fighting
        - ^vulnerable state:true
        - ^lookclose state:false
        - inject locally attackTarget
    fighting:
      proximity trigger:
        Exit:
          script:
          - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - ^flag npc fighting:!
          - ^queue queue:<npc.flag[queue]> clear
          - ^zap step:1
          - ^vulnerable state:false
          - ^walkto <s@config.constant[AldranHome]>
          - ^narrate "<&7>[<&b>Aldran<&7> -> You]<&co> Do not run away you coward..."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - ^narrate "<&a>You exitted Aldrans's range the fight is resetting."
        move:
          script:
          - if !<npc.flag[walking]> look <npc> <npc.flag[owner].as_player.location.add[0,2,0]>
    finished:
      click trigger:
        script:
        - narrate "<&7>[<&b>Aldran<&7> -> You]<&co> Good to see you again."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    Waiting2Fight:
      click trigger:
        script:
        - ^narrate "<&7>[<&b>Aldran<&7> -> You]<&co> I'm ready to fight!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^vulnerable state:false
        - ^engage
        - ~walkto <npc> <s@config.constant[AliDoor].as_location>
        - ~walkto <npc> <s@config.constant[AliSparringGrounds].as_location>
        - ^vulnerable state:true
        - ^disengage
        - ^zap step:1
        - ^trigger name:damage state:true
        - ^vulnerable state:true
  attackTarget:
  - ^if !<npc.flag[fighting]> {
    - walkto <npc> <s@config.constant[AldranHome]>
    - flag npc fighting:!
    - zap step:Waiting2Fight
    - ^vulnerable state:false
    - narrate "<&7>[<&b>Aldran<&7> -> You]<&co> Do not run away you coward!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - queue clear
    }
  - ^wait .5s
  - ^flag npc walking:!
  - ^flag <npc> queue:<queue.id>
  - ^if <npc.location.distance[<player.location>].is[LESS].than[3]> {
    - if <util.random.int[1].to[2].is[==].to[1]> {
      - ^inject locally disarm
      }
      else ^inject locally shoot
    }
    else ^inject locally shoot
  - ^inject locally attackTarget

  shoot:
  - ^flag npc walking:!
  - ^animate <npc> animation:START_USE_ITEM
  - ^look <npc> <npc.flag[owner].as_player.location.add[0,2,0]>
  - ^wait 9t
  - ^define range 25 
  - ^look <npc> <npc.flag[owner].as_player.location.add[0,2,0]>
  - ^inject blockListUtil instantly 
  - ^playeffect <def[blockList]> effect:FIREWORKS_SPARK qty:10
  - ^foreach <def[blockList]> {
    - if !<npc.flag[owner].distance[%value%].is[OR_MORE].than[1.2]> {
      - ^hurt <npc.flag[owner].as_player> 3
      - ^foreach stop
      }
    }
  - ^random {
    - narrate "<&7>[<&b>Aldran<&7> -> You]<&co> My arrows fly true."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - narrate "<&7>[<&b>Aldran<&7> -> You]<&co> Hold fast to your weapon!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - narrate "<&7>[<&b>Aldran<&7> -> You]<&co> Brilliant maneuver"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    }
  - ^animate <npc> animation:STOP_USE_ITEM
  - ^flag npc walking:!
  - ^inject locally walk
  disarm:
  - ^animate <npc> animation:SNEAK
  - ^animate <npc> animation:ARM_SWING
  - ^define item <player.item_in_hand>
  - ^take iteminhand
  - ^narrate "<&8>You have been disarmed"
  - ^narrate "<&7>[<&b>Aldran<&7> -> You]<&co> Get away from me!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^wait 3t
  - ^animate <npc> animation:STOP_SNEAKING
  - ^inject locally walk
  - ^wait 10t
  - ^give %item%
  walk:
  - ^flag npc walking
  - ^define location1 <npc.location.sub[<player.location>].div[4].add[<npc.location>]>
  - ^define location2 <npc.location.sub[<player.location>].div[5].add[<npc.location>]>
  - ^define location3 <npc.location.sub[<player.location>].div[6].add[<npc.location>]>
  - ^if <def[location1].material.is[==].to[m@air]> && <def[location1].add[0,1,0].material.is[==].to[m@air]> {
    - ^walkto <npc> %location1% speed:1.5
    }
    else if <def[location2].material.is[==].to[m@air]> && <def[location2].add[0,1,0].material.is[==].to[m@air]> {
    - ^walkto <npc> %location2% speed:1.5
    }
    else ^walkto <npc> %location3% speed:1.5

Glen:
  type: assignment
  actions:
    on assignment:
    - ^engage
    - ^adjust <npc> teleport_on_stuck:false
    - ^lookclose <npc> state:true radius:10
    - ^trigger name:chat state:true cooldown:1s
    - ^trigger name:proximity state:true radius:30
    - ^trigger name:click state:true cooldown:1s
    - ^trigger name:damage state:false
    - ^vulnerable state:false
    - ^health <npc> <s@config.constant[GlenHP]> state:true
    - ^heal <npc> <s@config.constant[GlenHP]>
    - ^equip <npc> hand:i@iron_sword chest:i@iron_chestplate legs:i@ironpants
    - ^walkto <npc> <s@config.constant[AliSparringGrounds]>
    - ^execute as_server "npc sel <npc.id>"
    - ^execute as_server "npc pathrange 30"
    - ^disengage
    on death:
    - ^foreach <npc.flag[queue].as_list> {
        - queue queue:%value% clear
        }
    - ^if <npc.flag[died]> queue clear
    - ^flag npc died duration:10s
    - ^run locally spawn def:<npc>
    - ^run objective_remove "def:Beat Glen|10"
    - ^vulnerable state:false
    - ^trigger name:damage state:false
    - ^zap step:4 s@GlenSteps
    - ^flag npc attacking:!
    - ^flag npc queue:!
    - ^create player Storm <player.location.add[1,0,0]> save:storm
    - ^define storm <entry[storm].created_npc>
    - ^run locally lava def:%storm%
    - ^equip %storm% hand:i@diamond_sword[enchantments=DAMAGE_ALL,1] chest:i@diamond_chestplate[enchantments=DAMAGE_ALL,1]
    - ^flag <npc.flag[owner]> e.npcs:->:%Storm%
    - ^flag %storm% owner:<npc.flag[owner]>
    - ^lookclose %storm% state:true
    - ^run hideNPCs instantly
    - walkto %storm% <npc.flag[owner]> speed:2
    - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Well then, you knocked him cold out! Serves him right in my opinion. Go to bed and get some rest"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> <&8>Interupts<&7> Silence, you old fool. I would like a word with this 'pupil' of yours. So, you think that you are a warrior, scum? "
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 4.5s
    - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> We will see. Tomorrow evening, we will fight... and you will be put in your place."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> Train all you can before then. It will not help you win... but perhaps you will not embarrass yourself too much."
    - wait 4s
    - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Master Storm is a dangerous mage... with a very dangerous temper. If he goes too far, I will be here, just in case. Good luck tomorrow."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> However, you will not be able to spend all your time training. I am now taking you on as my apprentice. As part of your duties, you will be assisting the mayor of Aleraden with various tasks tomorrow."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 4.5s
    - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Part of your training involves helping this city run properly. Go to the city hall first thing in the morning, but first get some sleep. Good fighting out there!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - ^run objective_add "def:Find a bed|11"
    - ^zap step:bed s@AliSteps
    - ^run updatecompass "def:Points to a Bed|Points to a Bed|<s@config.constant[BedPoint]>"
    - ^flag <npc.flag[owner]> e.bed
    - ^look <npc.flag[owner]> <def[storm].location.add[0,2,0]>
    - ^wait .2s
    - ^playeffect <def[storm].as_npc.location> effect:cloud data:1 qty:2500 targets:<npc.flag[owner].as_player>
    - ^wait .1s
    - ^playeffect <def[storm].as_npc.location> effect:flame qty:1000 targets:<npc.flag[owner].as_player>
    - ^remove %storm%
  interact scripts:
  - 10 GlenSteps
  spawn:
  - wait 5s
  - spawn %1% <s@config.constant[GlenHome]>
  lava:
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
  - wait 1s
  - playeffect <def[1].location> effect:lava qty:100
GlenSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - engage
        - narrate "<&7>[<&b>Glen<&7> -> You]<&co> Greetings! It's always good to have fresh meat on the training grounds... to be beaten and smashed by their betters."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Glen<&7> -> You]<&co> Master Storm has taught me himself. To even suggest that one of Master Ali's pupils could defeat me... it is preposterous."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 2s
        - narrate "<&7>[<&b>Glen<&7> -> You]<&co> Let us begin our combat!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ~walkto <s@config.constant[AliSparringGrounds]>
        - zap step:2
        - vulnerable state:true
        - trigger name:damage state:true
        - disengage
      proximity trigger:
        move:
          script:
          - ^if <npc.flag[running]> queue clear
          - ^flag npc running
          - engage
          - narrate "<&7>[<&b>Glen<&7> -> You]<&co> Greetings! It's always good to have fresh meat on the training grounds... to be beaten and smashed by their betters."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - wait 4s
          - narrate "<&7>[<&b>Glen<&7> -> You]<&co> Master Storm has taught me himself. To even suggest that one of Master Ali's pupils could defeat me... it is preposterous."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - wait 2s
          - narrate "<&7>[<&b>Glen<&7> -> You]<&co> Let us begin our combat!"
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - ~walkto <s@config.constant[AliSparringGrounds]>
          - zap step:2
          - vulnerable state:true
          - trigger name:damage state:true
          - disengage
    2:
      proximity trigger:
        move:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue
          - ^if <npc.flag[attacking]> queue clear
          - ^zap step:3
          - ^flag npc attacking
          - ^vulnerable state:true
          - ^flag npc fighting
          - ^inject locally attackTarget
    3:
      proximity trigger:
        exit:
          script:
          - if <npc.flag[owner].is[==].to[<player>]> {
            - narrate "<&a>You exitted Glen's range the fight is resetting."
            - narrate "<&7>[<&b>Glen<&7> -> You]<&co> Ahh taking the cowards way out...."
            - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
            - queue queue:<npc.flag[queue]> clear
            - flag npc fighting:!
            - engage
            - ~walkto <s@config.constant[AliSparringGrounds]>
            - vulnerable state:false
            - trigger name:damage state:false
            - zap step:1
            - flag npc attacking:!
            - flag npc queue:!
            - disengage
            }
    4:
      click trigger:
        script:
        - narrate "<&7>[<&b>Glen<&7> -> You]<&co> Nice to see you again....."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  attackTarget:
  - ^if <npc.flag[died]> queue clear
  - ^if !<npc.flag[attacking]> {
    - ^walkto <npc> <s@config.constant[GlenHome]>
    - ^zap step:Waiting2Fight
    - ^narrate "<&7>[<&b>Glen<&7> -> You]<&co> Do not run away you coward!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - ^queue clear
    }
  - ^flag npc queue:->:<queue.id>
  - ^random {
    - ^inject locally ice
    - ^inject locally fire
    - ^inject locally lighting
    }
  - ^inject locally attackTarget
  ice:
  - ^narrate "<&7>[<&b>Glen<&7> -> You]<&co> Does that sting!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^shoot falling_block,packed_ice o:<npc> d:<player.location> speed:1.5 script:s@IceBall
  - ^wait 2t
  - ^shoot falling_block,packed_ice o:<npc> d:<player.location> speed:1.5 script:s@IceBall
  - ^wait 2t
  - ^shoot falling_block,packed_ice o:<npc> d:<player.location> speed:1.5 script:s@IceBall
  - ^wait 2t
  - ^shoot falling_block,packed_ice o:<npc> d:<player.location> speed:1.5 script:s@IceBall
  - ^wait 2t
  - ^inject locally walk
  fire:
  - ^narrate "<&7>[<&b>Glen<&7> -> You]<&co> The tongues of flame will engluf you!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^shoot fireball o:<npc> d:<player.location.add[0,1,0]> speed:1.5
  - ^wait 2t
  - ^shoot fireball o:<npc> d:<player.location.add[0,1,0]> speed:1.5
  - ^wait 2t
  - ^shoot fireball o:<npc> d:<player.location.add[0,1,0]> speed:1.5
  - ^wait 3t
  - ^inject locally walk
  lighting:
  - ^strike <player.location> no_damage
  - ^hurt <player> 5
  - ^narrate "<&7>[<&b>Glen<&7> -> You]<&co> Feel my wrath!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^inject locally walk
  walk:
  - ^define location1 <npc.location.sub[<player.location>].div[4].add[<npc.location>]>
  - ^define location2 <npc.location.sub[<player.location>].div[5].add[<npc.location>]>
  - ^define location3 <npc.location.sub[<player.location>].div[6].add[<npc.location>]>
  - ^if <def[location1].material.is[==].to[m@air]> && <def[location1].add[0,1,0].material.is[==].to[m@air]> {
    - ^walkto <npc> %location1% speed:1.5
    - ^wait 2s
    - ^pause waypoints
    }
    else if <def[location2].material.is[==].to[m@air]> && <def[location2].add[0,1,0].material.is[==].to[m@air]> {
    - ^walkto <npc> %location2% speed:1.5
    - ^wait 2s
    - ^pause waypoints
    }
    else {
    - ^walkto <npc> %location3% speed:1.5
    - ^wait 2s
    - ^pause waypoints
    }
IceBall:
  type: task
  debug: true
  script:
  - foreach <def[location].find.players.within[4]> {
    - hurt 5 %value%
    }
MageProjectiles:
  type: world
  debug: false
  events:
    on entity explodes:
    - if <context.location.world.name.is[==].to[<s@config.constant[nameofworld]>]> determine cancelled
    on block ignites:
    - if <context.location.world.name.is[==].to[<s@config.constant[nameofworld]>]> determine cancelled
    on e@falling_block changes m@air:
    - determine cancelled
    on m@packed_ice being built:
    - determine cancelled
    on npc damaged by e@FIREBALL:
    - if <context.entity.location.world.name.is[==].to[<s@config.constant[nameofworld]>]> determine cancelled
    on npc damaged by e@lighting:
    - if <context.entity.location.world.name.is[==].to[<s@config.constant[nameofworld]>]> determine cancelled
    on i@packed_ice spawns:
    - determine cancelled
  removeBlockAir:
  - modifyblock %1% m@air
  removeBlockWater:
  - modifyblock %1% m@water

Mayor:
  type: assignment
  actions:
    on assignment:
    - trigger name:damage state:false
    - trigger name:click state:true
    - trigger name:proximity state:true radius:10
    - lookclose <npc> state:true
  interact scripts:
  - 10 MayorSteps
MayorSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - engage
        - zap step:2
        - run objective_remove "def:Visit the mayor|12"
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> Good to meet you! I hope you are ready to work, because there is much to do around here. Go meet my deputy Lythis in the slums. I am sure that he needs some help."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - run objective_add "def:Find Lythis|13"
        - ^run updatecompass "def:Points to Lythis|Points to Lythis|<s@config.constant[LythisHome]>"
        - narrate "<&8>He is at  X<&co>-250 Z<&co>220"
        - ^create player Lythis <s@config.constant[LythisHome]> save:Lythis
        - ^define Lythis <entry[Lythis].created_npc>
        - ^flag player e.npcs:->:%Lythis%
        - ^flag %Lythis% owner:<player>
        - ^assignment set script:Lythis npc:%Lythis%
        - ^run hideNPCs instantly
        - disengage
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> I'm the mayor nice to meet you."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - narrate "<&8>Right click the Mayor"
    2:
      click trigger:
        script:
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> You need to go see Lythis!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    3:
      click trigger:
        script:
        - zap step:4
        - run objective_remove "def:Go to the Mayor|25"
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> Lythis sent a messenger ahead of you to tell me of your deeds... thank you for your service today!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 3s
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> It indeed is a dark day... the two moons rise yet again on the day of Volcivan. For helping us fight this darkness, you will be greatly rewarded."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 3s
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> I've instructed the City Archmage to reward you with some weapons and armor. You'll find him on the roof to this building"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - run objective_add "def:Go 2 the Townhall|26"
        - narrate "<&8>x -270 y 164 z 179"
        - create Player Archmage <s@config.constant[ArchmageHome]> save:Mage
        - define Mage <entry[Mage].created_npc>
        - flag player e.npcs:->:%Mage%
        - flag %Mage% owner:<player>
        - run hideNPCs instantly
        - assignment set script:Archmage npc:%Mage%
    4:
      click trigger:
        script:
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> Nice to see you..."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    5:
      click trigger:
        script:
        - engage
        - run objective_remove "def:Visit the Mayor|29"
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> Yesterday was filled with tragedy... I am sorry to hear about the death of Master Storm. His temper always was his greatest enemy..."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> please give my condolences to Master Ali. There will be time to mourn later, but for now, the city is still in peril from this disease."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Ethius<&7> -> You]<&co> Lythis and his men have scouted the area, and found the Brood Queen of the rats, and her den. Go with them and end the rats at their source... it will not be a simple task, but I wish you the best."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - narrate "<&8>Meet Lythis at the gate."
        - run objective_add "def:Meet Lythis|29"
        - ^run updatecompass "def:Points to Lythis|Points to Lythis|<s@config.constant[LythisHome]>"
        - zap step:6 s@LythisSteps
        - zap step:4
        - disease
    6:
      click trigger:
        script:
        - ^zap step:4
        - ^run objective_remove "def:Go to the Mayor|31"
        - ^narrate "<&7>[<&b>Ethius<&7> -> You]<&co> Thank you for your service killing the BroodQueen you have done our city a great favor!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait s
        - ^narrate "<&7>[<&b>Ethius<&7> -> You]<&co> However there is still much to do."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 2s
        - ^narrate "<&7>[<&b>Ethius<&7> -> You]<&co> I assume that Ali wants to continue your training. I would suggest returning to the Training Hall and training with him... anything to keep his mind off Master Storm"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^zap step:8 s@AliSteps
        - ^run objective_add "def:Go to Ali|32"
        - ^run updatecompass "def:Points to Ali|Points to Ali|<s@config.constant[AliHome]>"

Lythis:
  type: assignment
  debug: false
  actions:
    on assignment:
    - trigger name:damage state:false
    - trigger name:click state:true
    - trigger name:proximity state:true radius:10
    - lookclose <npc> state:true
    - ^execute as_server "npc sel <npc.id>"
    - ^execute as_server "npc pathrange 50"
    on complete navigation:
    - if !<npc.flag[is_walking]> queue clear
    - inject locally NextWalk
  interact scripts:
  - 10 LythisSteps
  NextWalk:
  - ^if <npc.location.distance[<s@config.constant[LythisPoints].as_list.get[<npc.flag[current_number]>]>]> <&gt> 4 {
    - ^define current_number <npc.flag[current_number]>
    - ^define location <s@config.constant[LythisPoints].as_list.get[%current_number%]>
    - ^flag npc is_walking
    - ^walkto %location%
    }
    else {
    - ^define currentPlus <npc.flag[current_number].add[1].as_int>
    - ^if "<s@config.constant[LythisPoints].as_list.get[%currentPlus%] || null >" == null {
      - ^flag npc is_walking:!
      - ^narrate "<&7>[<&b>Lythis<&7> -> You]<&co> Here we are!"
      - ^zap step:11 s@LythisSteps player:<npc.flag[owner]>
      - ^queue clear
      }
    - ^define location <s@config.consant[LythisPoints].as_list.get[%currentPlus%]>
    - ^flag npc current_location:%location%
    - ^flag npc current_number:%currentPlus%
    - ^flag npc is_walking
    - ^walkto %location%
    }
LythisSteps:
  type: interact
  debug: false
  steps:
    1:
      click trigger:
        script:
        - engage
        - run objective_remove "def:Find Lythis|13"
        - narrate "<&7>[<&b>You -> <&b>Lythis<&7>]<&co> Mayor Ethius sent me to help you. Are you Lythis?"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 2s
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> I am. There is much work to be done, and few people to do it. Are you ready?"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 3s
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> I'm going to start you out on something easy. The slums are infested with plague and disease."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 3s
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> One of our healers set up a temporary medical post in the middle of the slums, but he is running out of medicine. Bring this delivery to him as fast as you can!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - give "i@note_block[display_name=<&a>Medicene;lore=Bring to the Healer|@ X<&co>-150 z<&co>275]"
        - run objective_add "def:Find the healer|14"
        - ^run updatecompass "def:Points to Healer|Points to Healer|<s@config.constant[HealerHome]>"
        - narrate "<&8>He is at X<&co>-150 Z<&co>275"
        - ^create Player Healer <s@config.constant[HealerHome]> save:Healer
        - ^define healer <entry[Healer].created_npc>
        - ^flag player e.npcs:->:%Healer%
        - ^assignment set script:Healer npc:%Healer%
        - ^flag %healer% owner:<player>
        - ^inject hideNPCs instantly
        - ^zap step:2
        - ^disengage
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> I'm Lythis, I have work for you."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - narrate "<&8>Right click Lythis"
    2:
      click trigger:
        script:
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> Go away I am busy"
    3:
      click trigger:
        script:
        - ^engage
        - ^run objective_remove "def:Return to Lythis|21"
        - ^narrate "<&7>[<&b>Lythis<&7> -> You]<&co> As grateful as we are that you thinned the rat population, we still are not safe."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 4s
        - ^narrate "<&7>[<&b>Lythis<&7> -> You]<&co> I have dispatched scouts to find the source of these rats, but in the meantime, rogues and thieves are using this chaos as an opportunity to loot and pillage."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 5s
        - ^narrate "<&7>[<&b>Lythis<&7> -> You]<&co> I want you to investigate and find out where these criminals have set up their Headquarters. If you see any looters in the street, put them down."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^run objective_add "def:Find HQ|22"
        - ^flag player e.canfind
        - ^run objective_add "def:Kill 3 Looters|23"
        - ^flag player e.cankill
        - ^flag player e.killedLooters:0
        - ^zap step:4
        - ^disengage
    4:
      click trigger:
        script:
        - engage
        - if <player.flag[e.looters]> && <player.flag[e.hq]> {
          - run objective_remove "def:Find HQ|22"
          - run objective_remove "def:Kill 3 Looters|23"
          - run objective_remove "def:Go to Lythis|70"
          - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> You found their Headquarters? Very good. I haven't many men to spare right now... so tread carefully. Only one ally will go with you. Go to their headquarters, and deal with them."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - wait 4s
          - narrate "<&8>Lythis is sending one medic with you."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - wait 3s
          - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> You've proven yourself deadly; they will not stand a chance. However, they are being led by a very dangerous man by the name of Faulen. The two of you should be able to kill Faulen, but be careful nonetheless."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - wait 5s
          - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> He is an underhanded fighter, willing to use anything at his disposal to win."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - wait 5s
          - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> Potions, magic, bows, or blades... he is trained with them all. Since he used to be an apprentice of Master Storm, use caution in this fight. Good luck!"
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - ^zap step:5
          - ^foreach li@<s@config.constant[BanditsSpawn1]>|<s@config.constant[BanditsSpawn2]>|<s@config.constant[BanditsSpawn3]>|<s@config.constant[BanditsSpawn4]>|<s@config.constant[BanditsSpawn5]>|<s@config.constant[BanditsSpawn6]> {
            - ^create Player Bandit %value% save:Bandit
            - ^define bandit <entry[bandit].created_npc>
            - ^flag player e.npcs:->:%Bandit%
            - ^flag %bandit% owner:<player>
            - ^run hideNPCs instantly
            - ^flag %bandit% home:<def[bandit].location>
            - ^assignment set script:faulensbandits npc:%bandit%
            }
          - ^create player Faulen <s@config.constant[FaulenHome]> save:Faulen
          - ^define faulen <entry[Faulen].created_npc>
          - ^flag player e.npcs:->:%Faulen%
          - ^assignment set script:Faulen npc:%faulen%
          - ^flag %faulen% owner:<player>
          - ^run hideNPCs instantly
          - ^run objective_add "def:Kill Faulen|24"
          - ^run updatecompass "def:Points to Faulen|Points to Faulen|<s@config.constant[FaulenHome]>"
          - ^create player Medic <player.location.add[1,0,1]> save:Medic
          - ^define Medic <entry[Medic].created_npc>
          - ^flag player e.npcs:->:%Medic%
          - ^flag %Medic% owner:<player>
          - ^flag player e.ally:%Medic%
          - ^assignment set script:Medic npc:%Medic%
          - ^inject hideNPCs
          }
          else if <player.flag[e.looters]> narrate "<&7>[<&b>Lythis<&7> -> You]<&co> You still need to find the HQ"
          else if <player.flag[e.hq]> narrate "<&7>[<&b>Lythis<&7> -> You]<&co> You still need to kill 3 looters"
          else narrate "<&7>[<&b>Lythis<&7> -> You]<&co> You still need to kill 3 looters and find the HQ"
        - disengage
    5:
      click trigger:
        script:
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> Go get Faulen!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    6:
      click trigger:
        script:
        - zap step:7
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> I am very impressed... taking on Faulen alone is not a feat to laugh at. "
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 3s
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> You will be greatly reward by the Mayor for your deeds."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 3s
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> Return to him now, and I will send for you when the den of the rats is found. Thank you again!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - run objective_add "def:Go to the Mayor|25"
        - ^run updatecompass "def:Points to the Mayor|Points to Mayor|<s@config.constant[MayorHome]>"
        - zap step:3 s@MayorSteps
        - wait 70s
        - teleport <npc> <s@config.constant[LythisGates]>
    7:
      click trigger:
        script:
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> I'm still impressed you beat Faulen..."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    8:
      click trigger:
        script:
        - run objective_remove "def:Go to Lythis|60"
        - narrate "<&7>[<&b>Lythis<&7> -> You]<&co> Good, you're here! My scouts have found the Brood Queen's den... are you ready?"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - narrate "<&8>Right click Lythis again to begin"
        - zap step:9 duration:5s
    9:
      click trigger:
        script:
        - ^zap step:walking
        - ^run objective_add "def:Kill BroodQueen|30"
        - ^run updatecompass "def:Points to the Brood Queen|Points to the Brood Queen|<s@config.constant[BroodQueenHome]>"
        - ^narrate "<&7>[<&b>Lythis<&7> -> You]<&co> Great lets go."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^create Player "Brood Queen" <s@config.constant[BroodQueenHome]> save:BroodQueen
        - ^define BQ <entry[BroodQueen].created_npc>
        - ^execute as_server "npc sel <def[BQ].id>"
        - ^execute as_server "npc skin MHF_SPIDER"
        - ^flag player e.npcs:->:%BQ%
        - ^flag %BQ% owner:<player>
        - ^assignment set script:s@BroodQueen npc:%BQ%
        - ^flag npc current_location:<s@config.constant[LythisPoints].as_list.get[1]>
        - ^flag npc current_number:1
        - ^run hideNPCs instantly
        - ^inject locally NextWalk
    walking:
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - if <npc.flag[is_walking]> flag npc is_walking:!
          - narrate "<&8>Continue following Lythis!"
          - inject locally NextWalk
        exit:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - if <npc.flag[is_walking]> {
            - pause waypoints
            - flag npc is_walking:!
            - narrate "<&8>Stay with Lythis!"
            }
    11:
      click trigger:
        script:
        - flag player e.ally:<npc>
        - narrate "<&8>Attack the Brood Queen and Lythis will join you."
      proximity trigger:
        move:
          script:
          - ^if <npc.flag[owner].is[!=].to[<player>]> {
            - queue clear
            }
          - ^if <npc.flag[attacking]> {
            - queue clear
            }
          - ^define player <npc.flag[owner].as_player>
          - ^define target <npc.flag[owner].as_player.flag[e.target].as_entity>
          - ^if <def[target].is[!=].to[null]> {
            - ^flag npc attacking duration:4s
            - ^flag npc queue:<queue.id>
            - ^attack <npc> target:%target%
            - ^wait 5s
            - ^attack <npc> target:cancel
            }
            else {
            - walkto <npc> <npc.location.add[<npc.flag[owner].as_player.location>].div[2]> speed:1.5
            }
        exit:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - queue queue:<npc.flag[queue]> clear
          - walkto <npc> <npc.location.add[<npc.flag[owner].as_player.location>].div[2]> speed:1.5
  NextWalk:
  - ^if <npc.location.distance[<s@config.constant[LythisPoints].as_list.get[<npc.flag[current_number]>]>]> <&gt> 4 {
    - ^define current_number <npc.flag[current_number]>
    - ^define location <s@config.constant[LythisPoints].as_list.get[%current_number%]>
    - ^flag npc is_walking
    - ^walkto %location%
    }
    else {
    - ^define currentPlus <npc.flag[current_number].add[1].as_int>
    - ^if "<s@config.constant[LythisPoints].as_list.get[%currentPlus%] || null >" == null {
      - ^flag npc is_walking:!
      - ^narrate "<&7>[<&b>Lythis<&7> -> You]<&co> Here we are!"
      - ^zap step:11
      - ^queue clear
      }
    - ^define location <s@config.consant[LythisPoints].as_list.get[%currentPlus%]>
    - ^flag npc current_location:%location%
    - ^flag npc current_number:%currentPlus%
    - ^flag npc is_walking
    - ^walkto %location%
    }

Healer:
  type: assignment
  actions:
    on assignment:
    - trigger name:damage state:false
    - trigger name:click state:true
    - trigger name:proximity state:true radius:10
    - lookclose <npc> state:true
  interact scripts:
  - 10 HealerSteps
HealerSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - ^engage
        - ^take "i@note_block[display_name=<&a>Medicene;lore=Bring to the Healer|@ X<&co>-150 z<&co>275]"
        - ^run objective_remove "def:Find the healer|14"
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> Thank you ever so much! The diseased keep coming. We've had several casualties so far. I am convinced that the rats are carrying this disease"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> There are swarms of them by the harbor. Thin the ranks of those rats. You should find plenty at the dock to your ship."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> That rats are at <s@config.constant[RatCords]>"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - run objective_add "def:Kill 10 Rats|15"
        - ^run updatecompass "def:Points to the Rats|Points to the Rats|<s@config.constant[RatsLoc1]>"
        - listen kill type:entity target:silverfish qty:1 script:ratkill
        - flag player e.ratskilled:0
        - zap step:2
        - disengage
        # Create looters...
        - foreach li@<s@config.constant[LooterSpawn1]>|<s@config.constant[LooterSpawn2]>|<s@config.constant[LooterSpawn3]>|<s@config.constant[LooterSpawn4]>|<s@config.constant[LooterSpawn5]>|<s@config.constant[LooterSpawn6]> {
          - ^create Player Looter %value% save:Looter
          - ^define Looter <entry[looter].created_npc>
          - ^flag player e.npcs:->:%Looter%
          - ^assignment set script:Looter npc:%looter%
          - ^flag %looter% owner:<player>
          - ^flag %looter% home:<def[looter].location>
          - ^inject hideNPCs 
          }
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&7>[<&b>Healer<&7> -> You]<&co> I'm a healer, I believe Lythis sent you to help me."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - narrate "<&8>Right click the Healer"
    2:
      click trigger:
        script:
        - narrate "<&a>You have killed <player.flag[e.ratskilled].as_int>/10 rats."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    3:
      click trigger:
        script:
        - engage
        - run objective_remove "def:Kill 10 Rats|15"
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> All done? Glad to hear it. Next, make sure that you stop the rats from entering the main city."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> Go to the gate and kill any rats you see there. If they have already moved into the city, check the marketplace as well. Rats would be there because of all the food."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> If you can figure out how to efficiently kill these rats, other than using a sword, feel free to experiment. Ask around for ideas."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> That rats are at <s@config.constant[RatCords]>"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - run objective_add "def:Kill 5 rats|16"
        - ^run updatecompass "def:Points to the Rats|Points to the Rats|<s@config.constant[RatsLoc2]>"
        - listen kill type:entity target:silverfish qty:1 script:ratkill2 
        - flag player e.ratskilled2:0
        - zap step:4
        - disengage
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&7>[<&b>Healer<&7> -> You]<&co> I'm a healer, I believe Lythis sent you to help me."
          - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
          - narrate "<&8>Right click the Healer"
    4:
      click trigger:
        script:
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> Nice to see you"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    5:
      click trigger:
        script:
        - engage
        - run objective_remove "def:Return to Healer|20"
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> It looks like you've pushed the rats out of the main city. However, they will keep coming unless we eliminate them at the source."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Healer<&7> -> You]<&co> Talk to Lythis and track their den down! I can't keep healing these villagers forever, and the death count rises by the hour."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - run objective_add "def:Return to Lythis|21"
        - ^run updatecompass "def:Points to Lythis|Points to Lythis|<s@config.constant[LythisHome]>"
        - narrate "<&8>Right click Lythis"
        - zap step:4
        - zap step:3 s@LythisSteps
        - disengage
ratkill:
  type: task
  script:
  - ^flag <player> e.ratskilled:++
  - ^narrate "<&a>You have killed <player.flag[e.ratskilled].as_int>/10 rats"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^if <player.flag[e.ratskilled].is[OR_MORE].than[10]> {
    - ^narrate "<&8>Return to the healer."
    - ^narrate "<&7>[<&b>You<&7>]<&co> After I return to the healer, I should go to the market."
    - ^zap step:3 s@HealerSteps
    }
    else listen kill type:entity target:silverfish qty:1 script:ratkill
ratkill2:
  type: task
  script:
  - ^flag <player> e.ratskilled2:++
  - ^narrate "<&a>You have killed <player.flag[e.ratskilled2].as_int>/5 rats"
  - ^if <player.flag[e.ratskilled2].is[OR_MORE].than[5]> {
    - ^run objective_remove "def:Kill 5 rats|16"
    - ^flag player e.market
    - ^narrate "<&8>You have killed all the rats you need to continue to the market"
    - ^run objective_add "def:Visit the Market|71"
    - run updatecompass "def:Points to the Market|Points to the Market|-185,50,154.6,<s@config.constant[nameofworld]>"
    }
    else listen kill type:entity target:silverfish qty:1 script:ratkill2
dockRats:
  type: world
  events:
    on e@silverfish damages player:
    - if !<context.entity.location.is_within[cu@DockArea]> queue clear
    - define random <util.random.int[1].to[5]>
    - if %random% == 1 {
      - narrate "<&8>You have been posioned."
      - potion POISON duration:10s power:1 player:<context.entity>
      }
      else if %random% == 2 {
      - narrate "<&8>You have been posioned."
      - potion HUNGER duration:10s power:1 player:<context.entity>
      }

marketEntrance:
  type: world
  events:
    on player enters cu@marketEntrance:
    - if <player.flag[e.market]> {
      - ^run objective_remove "def:Visit the Market|71"
      - flag player e.market:!
      - run objective_add "def:Give out meds|19"
      - ^run updatecompass "def:Points to the Villagers|Points to the Villagers|<s@config.constant[VillagersLoc]>"
      - narrate "<&8>Use the medicene to help some of the villagers..."
      }

villager:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true proximity:15
    - trigger name:clcik state:true
    - lookclose <npc> state:true
    on enter proximity:
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - random {
      - narrate "<&7>[<&b>Villager<&7> -> You]<&co> Ahhh help me!"
      - narrate "<&7>[<&b>Villager<&7> -> You]<&co> We are in need of your help!"
      - narrate "<&7>[<&b>Villager<&7> -> You]<&co> Please help us if you can!"
      - narrate "<&7>[<&b>Villager<&7> -> You]<&co> We are dying out here!"
      - narrate "<&7>[<&b>Villager<&7> -> You]<&co> Do you think you can help us!?"
      - narrate "<&7>[<&b>Villager<&7> -> You]<&co> AHHHhhhhh"
      }
    on click:
    - if <npc.flag[medicene]> queue clear
    - flag npc medicene duration:8s
    - flag player e.healed:++
    - if <player.flag[e.healed].is[OR_MORE].than[3]> {
      - run objective_remove "def:Give out meds|19"
      - narrate "<&8>Go back to the Healer you have healed enough villagers"
      - zap step:5 s@HealerSteps
      - run objective_add "def:Return to Healer|20"
      - ^run updatecompass "def:Points to the Healer|Points to the Healer|<s@config.constant[HealerHome]>"
      - wait 20s
      }
      else {
      - narrate "<&a>You have healed <player.flag[e.healed].as_int>/3 villagers."
      - narrate "<&7>[<&b>Villager<&7> -> You]<&co> Thank you for the medicene!"
      }
    - wait 20s
    - adjust <player> hide_entity:<npc>
sailor:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true radius:7
    - trigger name:click state:true
    - lookclose <npc> state:true
    on click:
    - if <player.money.is[MORE].than[<s@config.constant[costOfPoison]>]> {
      - narrate "<&7>[<&b>Sailor<&7> -> You]<&co> It looks like ye have enough money to buy some rat posion."
      - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      - wait 2s
      - narrate "<&7>[<&b>Sailor<&7> -> You]<&co> Would you like to buy some?"
      - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      - narrate "<&8>Type yes or no"
      }
      else narrate "<&7>[<&b>Sailor<&7> -> You]<&co> Looks like you can't afford my rat posion!"
    on chat:
    - determine passively cancelled
    - define costOfPoison <s@config.constant[costOfPoison]>
    - define message <context.message>
    - if <def[message].is[==].to[yes]> {
      - if <player.money.is[MORE].to[%costOfPoison%]> {
        - narrate "<&7>[<&b>Sailor<&7> -> You]<&co> Ayy sounds good here you go."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - give "i@potion[potion=POISON,1,false,true;display_name=<&a>Rat Poison;lore=Kills rats]"
        - take money qty:%costOfPoison%
        }
        else narrate "<&7>[<&b>Sailor<&7> -> You]<&co> I'm afriad you can't afford it, it costs %costOfPoison%"
      }
      else if <def[message].is[==].to[no]> {
      - narrate "<&7>[<&b>Sailor<&7> -> You]<&co> Well that's too bad.."
      - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      }
      else {
      - narrate "<&8>Type yes or no while facing the Sailor"
      - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      }
    on enter proximity:
    - narrate "<&7>[<&b>Sailor<&7> -> You]<&co> Oy, this stuff works great on those rats. A nasty poison it is, but it's kept m' home safe so far. Ye care for some? Just $<s@config.constant[costOfPoison]>"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
bandits:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true
    - trigger name:click state:true
    on click:
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - narrate "<&7>[<&b>Bandit<&7> -> You]<&co>Go away...."
    on enter proximity:
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - random {
      - narrate "<&7>[<&b>Bandit<&7>]<&co> God I am one sexy bandit..."
      - narrate "<&7>[<&b>Bandit<&7>]<&co> All this chaos makes me love the city even more."
      - narrate "<&7>[<&b>Bandit<&7>]<&co> I'm not sure I could loot any more."
      - narrate "<&7>[<&b>Bandit<&7>]<&co> Gee this city is really falling apart."
      - inject locally intel
      }
  intel:
  - if <player.flag[e.hq]> queue clear
  - if !<player.flag[e.canfind]> queue clear
  - narrate "<&7>[<&b>Bandit<&7>]<&co> I think I'm gonna head back to HQ <&l>x -150 z 300"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - run objective_remove "def:Find HQ|22"
  - narrate "<&8>You discovered the HQ is @ x<&co>150 z<&co>300"
  - flag player e.hq
  - if !<player.flag[e.looters]> queue clear
  - run objective_add "def:Go to Lythis|70"
  - ^run updatecompass "def:Points to Lythis|Points to Lythis|<s@config.constant[LythisHome]>"
tavernVillager:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true radius:10
    - trigger name:click state:true
    on click:
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - random {
      - narrate "<&7>[<&b>Villager<&7>]<&co> God I am one sexy villager..."
      - narrate "<&7>[<&b>Villager<&7>]<&co> All this chaos is making us lots of money."
      - narrate "<&7>[<&b>Villager<&7>]<&co> I'm not sure how long this will last."
      - narrate "<&7>[<&b>Villager<&7>]<&co> Gee this city is really falling apart."
      - inject locally intel
      }
    on enter proximity:
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - random {
      - narrate "<&7>[<&b>Villager<&7>]<&co> God I am one sexy villager..."
      - narrate "<&7>[<&b>Villager<&7>]<&co> All this chaos is making us lots of money."
      - narrate "<&7>[<&b>Villager<&7>]<&co> I'm not sure how long this will last."
      - narrate "<&7>[<&b>Villager<&7>]<&co> Gee this city is really falling apart."
      - inject locally intel
      }
  intel:
  - if !<player.flag[e.canfind]> queue clear
  - if <player.flag[e.hq]> queue clear
  - narrate "<&7>[<&b>Bandit<&7>]<&co> I think I'm gonna head back to HQ <&l>x -150 z 300"
  - run objective_remove "def:Find HQ|22"
  - narrate "<&8>You discovered the HQ is @ x<&co>150 z<&co>300"
  - flag player e.hq
  - if !<player.flag[e.looters]> queue clear
  - run objective_add "def:Go to Lythis|70"
  - ^run updatecompass "def:Points to Lythis|Points to Lythis|<s@config.constant[LythisHome]>"
looter:
  type: assignment
  actions:
    on assignment:
    - trigger name:damage state:true
    - trigger name:proximity state:true radius:18
    - vulnerable state:true
    - equip <npc> hand:i@iron_sword chest:i@iron_chestplate legs:i@ironpants
    on enter proximity:
    - if <npc.flag[owner].is[==].to[<player>]> {
      - attack <npc> target:<player>
      }
    on exit proximity:
    - if <npc.flag[owner].is[==].to[<player>]> {
      - attack <npc> target:cancel
      - walkto <npc> <npc.flag[home]>
      }
    on death:
    - if <player.flag[e.looters]> {
      - run locally respawn def:<npc>
      - queue clear
      }
    - if !<player.flag[e.cankill]> {
      - run locally respawn def:<npc>
      - queue clear
      }
    - flag player e.killedLooters:++
    - if <player.flag[e.killedLooters].is[OR_MORE].than[3]> {
      - flag player e.looters
      - narrate "<&8>You have killed all 3 looters return to Lythis."
      - run objective_remove "def:Kill 3 Looters|23"
      - if !<player.flag[e.hq]> queue clear
      - run objective_add "def:Go to Lythis|70"
      - ^run updatecompass "def:Points to Lythis|Points to Lythis|<s@config.constant[LythisHome]>"
      }
      else narrate "<&8>You have killed <player.flag[e.killedLooters].as_int>/3 looters."
    - run locally respawn def:<npc>
  respawn:
  - wait 40s
  - spawn <npc> <npc.flag[home]>

Medic:
  type: assignment
  actions:
    on assignment:
    - equip <npc> hand:i@potion[potion=INSTANT_HEAL,1,false,true] chest:i@gold_chestplate
    - trigger name:damage state:false
    - trigger name:proximity state:true radius:13
    - vulnerable <npc> state:false
    - lookclose <npc> state:true range:5
    on move proximity:
    - define owner <npc.flag[owner].as_player>
    - if <def[owner].is[!=].to[<player>]> queue clear
    - walkto <npc> <npc.location.add[<player.location>].div[2]> speed:1.5
    - if <npc.flag[healing]> {
      - queue clear 
      }
    - define time <util.random.int[3].to[6]>
    - flag npc healing duration:%time%s
    - if <def[owner].health.is[!=].to[<def[owner].health.max>]> {
      - run locally heal delay:%time%s def:%owner%
      }
  heal:
  - animate <npc> animation:ARM_SWING
  - heal 10 %1% 

faulen:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true radius:13
    - trigger name:damage state:true
    - vulnerable <npc> state:true
    - lookclose <npc> state:true range:13
    - equip <npc> hand:i@bow chest:i@golden_chestplate
    - health <npc> 200 state:true
    - heal <npc> 200
    on enter proximity:
    - if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - if <npc.flag[attacking]> {
      - queue queue:<npc.flag[queue]> clear
      - vulnerable state:true
      - inject attackTarget
      - queue clear
      }
    - ^flag npc attacking
    - ^flag npc started
    - if !<npc.flag[started]> {
      - narrate "<&7>[<&b>Faulen<&7> -> You]<&co> Well, if it isn't the Rat-slayer! You've come awful close to ruining our plans. "
      - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      - wait 3s
      - narrate "<&7>[<&b>Faulen<&7> -> You]<&co> This chaos is perfect for our business... and a weakling like you will not stop us. Face me like a man... alone..."
      - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      - ^animate <npc> animation:START_USE_ITEM
      - ^wait 9t
      - ^shoot e@arrow o:<npc> d:<player.flag[e.ally].as_npc.location.add[0,1,0]> speed:1
      - ^playsound <npc.flag[owner]> name:VILLAGER_HIT
      - ^animate <npc> animation:STOP_USE_ITEM
      - ^animate n@<player.flag[e.ally].as_npc> animation:sleep
      - ^animate n@<player.flag[e.ally].as_npc> animation:hurt
      - ^playsound <player> sound:ARROW_HIT
      - wait 5t
      - ^remove <player.flag[e.ally].as_npc>
      }
    - vulnerable <npc> state:true
    - narrate "<&8>Combat has begun!"
    - inject locally attackTarget
    on exit proximity:
    - if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - narrate "<&a>You exitted Faulen's range the fight is resetting."
    - vulnerable <npc> state:false
    - queue queue:<npc.flag[queue]> clear
    - narrate "<&7>[<&b>Faulen<&7> -> You]<&co> You never had a chance..."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - teleport <npc> <s@config.constant[FaulenHome]>
    - flag npc queue:!
    - flag npc fighting:!
    - flag npc attacking:!
    on death:
    - ^if <npc.flag[died]> queue clear
    - ^flag npc died duration:10s
    - ^queue queue:<npc.flag[queue]> clear
    - ^flag npc queue:!
    - ^run objective_remove "def:Kill Faulen|24" as:<npc.flag[owner].as_player>
    - ^run locally remove def:<npc> delay:5s
    - ^narrate "<&a>Return Faulens head to Lythis!"
    - ^run objective_add "def:Go to Lythis|60"
    - ^run updatecompass "def:Points to Lythis|Points to Lythis|<s@config.constant[LythisHome]>"
    - ^give "i@human_skull[skull_skin=Faulen;lore=Faulen's Head]" qty:1
    - ^zap step:8 s@LythisSteps
    on damaged:
    - if <context.damager.is[==].to[e@LIGHTING]> determine cancelled
    on move proximity:
    - ^if !<npc.flag[started]> queue clear
    - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - ^if !<npc.flag[attacking]> {
      - ^narrate "<&8>Combat has begun!"
      - ^flag npc attacking
      - ^inject locally attackTarget
      }
  attackTarget:
  - ^if <npc.location> == null {
    - ^queue clear
    - ^flag npc attacking:!
    - ^flag npc fighting:!
    - ^pause waypoints
    - ^teleport <npc> <s@config.constant[FaulenHome]>
    - ^walkto <npc.location.add[0,0,.1]>
    }
  - ^wait 1t
  - ^flag <npc> queue:<queue.id>
  - ^if !<npc.flag[attacking]> {
    - queue clear
    }
  - ^teleport <npc> <s@config.constant[FaulenHome]>
  - ^pause waypoints
  - ^walkto <npc> <npc.location.add[.1,0,0]>
  - ^attack <npc> target:cancel
  - random {
    - inject locally potion
    - inject locally lighting
    - inject locally sword
    - inject locally invis
    - inject locally disarm
    }
  - wait 3t
  - inject locally attackTarget
  potion:
  - if <npc.location> == null queue clear
  - narrate "<&7>[<&b>Faulen<&7> -> You]<&co> This is meant to kill rats.. but you'll do!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^equip <npc> "hand:i@potion[potion=POISON,1,false,true]"
  - ^wait .5s
  - ^shoot e@SPLASH_POTION[potion=i@potion[potion=POISON,2,false,true]] o:<npc> d:<player.location.add[0,.5,0]> speed:1.5
  - ^equip <npc> "hand:i@bow"
  - ^wait 5t
  lighting:
  - if <npc.location> == null queue clear
  - narrate "<&7>[<&b>Faulen<&7> -> You]<&co> Burn with the fires of the Nether!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^inject locally walk
  - ^wait 1s
  - ^strike <player.location> no_damage
  - ^hurt <player> 5
  - ^wait 1s
  sword:
  - if <npc.location> == null queue clear
  - narrate "<&7>[<&b>Faulen<&7> -> You]<&co> Flee from my blade!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^equip hand:i@diamond_sword
  - ^attack <npc> target:<player>
  - ^wait 5s
  - ^equip hand:i@bow
  - ^attack <npc> target:cancel
  invis:
  - if <npc.location> == null queue clear
  - narrate "<&7>[<&b>Faulen<&7> -> You]<&co> You cannot attack what you cannot see!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^invisible <npc> state:true
  - ^attack <npc> target:<player>
  - ^equip hand:i@diamond_sword
  - ^wait 4s
  - ^invisible <npc> state:false
  - ^attack <npc> target:cancel
  - ^equip hand:i@bow
  disarm:
  - ^if <npc.location.distance[<player.location>].is[OR_MORE].than[3]> {
    - ^random {
      - ^inject locally potion
      - ^inject locally lighting
      - ^inject locally sword
      - ^inject locally invis
      }
    }
    else {
    - ^random {
      - ^narrate "A child like you shouldn't have a weapon!"
      - ^narrate "You can't even hold your weapon!"
      }
    - if <npc.location> == null queue clear
    - ^animate <npc> animation:SNEAK
    - ^animate <npc> animation:ARM_SWING
    - ^define item <player.item_in_hand>
    - ^take iteminhand
    - ^narrate "<&8>You have been disarmed"
    - ^narrate "<&7>[<&b>Faulen<&7> -> You]<&co> Get away from me!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - ^wait 3t
    - ^animate <npc> animation:STOP_SNEAKING
    - ^inject locally walk
    - ^wait 1s
    - ^give %item%
    }
  walk:
  - ^define location1 <npc.location.sub[<player.location>].div[1].add[<npc.location>]>
  - ^define location2 <npc.location.sub[<player.location>].div[1.5].add[<npc.location>]>
  - ^define location3 <npc.location.sub[<player.location>].div[2].add[<npc.location>]>
  - ^if <def[location1].material.is[==].to[m@air]> && <def[location1].add[0,1,0].material.is[==].to[m@air]> {
    - ^walkto <npc> %location1% speed:1.5
    }
    else if <def[location2].material.is[==].to[m@air]> && <def[location2].add[0,1,0].material.is[==].to[m@air]> {
    - ^walkto <npc> %location2% speed:1.5
    }
    else ^walkto <npc> %location3% speed:1.5
  remove:
  - remove %1%
faulensbandits:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true radius:13
    - trigger name:damage state:true
    - vulnerable <npc> state:true
    - lookclose <npc> state:true range:13
    - random {
      - equip <npc> hand:i@iron_sword chestplate:i@leather_chestplate[enchantments=PROTECTION_ENVIRONMENTAL,3] legs:i@ironpants
      - equip <npc> hand:i@wooden_sword[enchantments=DAMAGE_ALL,1] chestplate:i@chainmail_chestplate legs:i@ironpants
      - equip <npc> hand:i@diamond_sword chestplate:i@diamond_chestplate legs:i@ironpants
      }
    on enter proximity:
    - if <npc.flag[owner].is[==].to[<player>]> {
      - attack <npc> target:<player>
      }
    on exit proximity:
    - if <npc.flag[owner].is[==].to[<player>]> {
      - attack <npc> target:cancel
      - walkto <npc> <npc.flag[home]>
      }
    on death:
    - run locally remove delay:5s def:<npc>
  remove:
  - remove %1%

Archmage:
  type: assignment
  actions:
    on assignment:
    - lookclose <npc> state:true radius:10
    - trigger name:proximity state:true radius:10
    - trigger name:chat state:true
    on enter proximity:
    - if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - if <queue.exists[<npc.flag[queue]>]> {
      - queue queue:<npc.flag[queue]> resume
      - queue clear
      }
    - run objective_remove "def:Go 2 the Townhall|26"
    - flag npc queue:<queue.id>
    - narrate "<&7>[<&b>Archmage<&7> -> You]<&co> I foretold your death at the hand of Master Storm earlier today."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 2s
    - narrate "<&7>[<&b>You -> <&b>Archmage<&7>]<&co> What? How can I decline his challenge now?"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 2s
    - narrate "<&7>[<&b>Archmage<&7> -> You]<&co> You cannot. That is why I must even the tides of battle. You must survive to fulfill the other things that the Elders and I have foreseen. Take this weapon, and this armor."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - narrate "<&7>[<&b>Archmage<&7> -> You]<&co> It will protect you from Storm’s magical attacks. Use it well, friend. The life and death of many will be in your hands. Even my own..."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - give <s@config.constant[ArchmageArmor]>
    - wait 4s
    - narrate "<&7>[<&b>You -> <&b>Archmage<&7>]<&co> Thank you!"
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - narrate "<&7>[<&b>Archmage<&7> -> You]<&co> Do not fail. Go now, your opponent grows impatient at the training hall."
    - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    - run objective_add "def:Beat Storm|27"
    - create Player Storm <s@config.constant[AliSparringGrounds]> save:storm
    - define storm <entry[storm].created_npc>
    - flag player e.npcs:->:%Storm%
    - flag %storm% owner:<player>
    - run hideNPCs instantly
    - assignment set script:Storm npc:%Storm%
    - run locally remove delay:50s def:<npc>
    on exit proximity:
    - if <queue.exists[<npc.flag[queue]>]> {
      - queue queue:<npc.flag[queue]> pause
      - narrate "<&8>Please don't leave while Archmage is talking to you"
      }
  remove:
  - remove %1%
Storm:
  type: assignment
  actions:
    on assignment:
    - lookclose <npc> state:true radius:20
    - trigger name:damage state:true
    - trigger name:proximity state:true radius:20
    - vulnerable <npc> state:false
    - equip hand:i@bow chestplate:i@diamond_chestplate legs:i@diamondpants boots:i@diamond_boots
    - health <npc> 100 state:true
    - heal 100 <npc>
    on damaged:
    - if !<npc.flag[die]> {
      - heal <npc> 100
      }
  interact scripts:
  - 10 StormSteps
StormSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - ^engage
        - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> I'm surprised you showed up. Brave... yet foolish. Let us not delay any longer"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 4s
        - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> the blood of my former apprentice screams out from the grave you put him in. He could have been reformed again! But no... you will pay. Blood for blood. Face me!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^wait 2s
        - ^narrate "<&8>Combat has begun!"
        - ^zap step:2
        - ^vulnerable state:true
        - ^trigger name:damage state:true
        - ^disengage
    2:
      proximity trigger:
        move:
          script:
          - ^if <npc.flag[owner].is[!=].to[<player>]> queue
          - ^if <npc.flag[attacking]> queue clear
          - ^zap step:3
          - ^flag npc attacking
          - ^vulnerable state:true
          - ^run locally endfight def:<npc>|<player>
          - ^zap step:1 s@AliFightSteps
          - ^inject locally attackTarget
    3:
      proximity trigger:
        exit:
          script:
          - if <npc.flag[owner].is[==].to[<player>]> {
            - narrate "<&7>[<&b>Storm<&7> -> You]<&co> Ahh taking the cowards way out...."
            - queue queue:<npc.flag[queue]> clear
            - engage
            - ~walkto <npc> <s@config.constant[AliSparringGrounds]> speed:2
            - vulnerable state:false
            - trigger name:damage state:false
            - zap step:1
            - flag npc attacking:!
            - flag npc queue:!
            - disengage
            }
    4:
      click trigger:
        script:
        - narrate "<&7>[<&b>Storm<&7> -> You]<&co> Nice to see you again....."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  attackTarget:
  - ^flag npc queue:<queue.id>
  - ^random {
    - ^inject locally ice
    - ^inject locally fire
    - ^inject locally lighting
    }
  - ^inject locally attackTarget
  ice:
  - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> You will pay for your sins!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^shoot e@falling_block,packed_ice|e@falling_block,packed_ice o:<npc> d:<player.location> speed:1.5 script:s@IceBall spread:.1
  - ^playsound <player> sound:glass volume:5
  - ^wait 2t
  - ^shoot e@falling_block,packed_ice|e@falling_block,packed_ice o:<npc> d:<player.location> speed:1.5 script:s@IceBall spread:.1
  - ^playsound <player> sound:glass volume:5
  - ^wait 2t
  - ^shoot e@falling_block,packed_ice|e@falling_block,packed_ice o:<npc> d:<player.location> speed:1.5 script:s@IceBall spread:.1
  - ^playsound <player> sound:glass volume:5
  - ^wait 2t
  - ^shoot e@falling_block,packed_ice|e@falling_block,packed_ice o:<npc> d:<player.location> speed:1.5 script:s@IceBall spread:.1
  - ^playsound <player> sound:glass volume:5
  - ^wait 2t
  - ^inject locally walk
  fire:
  - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> You will die by my hand, fool."
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^shoot e@fireball|e@fireball o:<npc> d:<player.location.add[0,1,0]> speed:1.5 spread:.5
  - ^playeffect <npc.location> effect:cloud qty:500
  - ^playsound <npc.flag[owner]> name:BLAZE_HIT
  - ^wait 2t
  - ^shoot e@fireball|e@fireball o:<npc> d:<player.location.add[0,1,0]> speed:1.5 spread:.5
  - ^playeffect <npc.location> effect:cloud qty:500
  - ^playsound <npc.flag[owner]> name:BLAZE_HIT
  - ^wait 2t
  - ^shoot e@fireball|e@fireball o:<npc> d:<player.location.add[0,1,0]> speed:1.5 spread:.5
  - ^playeffect <npc.location> effect:cloud qty:500
  - ^playsound <npc.flag[owner]> name:BLAZE_HIT
  - ^inject locally walk
  lighting:
  - ^strike <player.location>
  - ^wait 5t
  - ^strike <player.location>
  - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> Feel the wrath of the storms!"
  - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
  - ^inject locally walk
  walk:
  - ^define location1 <npc.location.sub[<player.location>].div[1].add[<npc.location>]>
  - ^define location2 <npc.location.sub[<player.location>].div[1.5].add[<npc.location>]>
  - ^define location3 <npc.location.sub[<player.location>].div[2].add[<npc.location>]>
  - ^if <def[location1].material.is[==].to[m@air]> && <def[location1].add[0,1,0].material.is[==].to[m@air]> {
    - ^walkto <npc> %location1% speed:1.5
    - ^wait 2s
    - ^pause waypoints
    }
    else if <def[location2].material.is[==].to[m@air]> && <def[location2].add[0,1,0].material.is[==].to[m@air]> {
    - ^walkto <npc> %location2% speed:1.5
    - ^wait 2s
    - ^pause waypoints
    }
    else {
    - ^walkto <npc> %location3% speed:1.5
    - ^wait 2s
    - ^pause waypoints
    }
  endfight:
  - ^trigger name:proximity state:false npc:%1%
  - ^flag %1% queue2:<queue.id>
  - ^if <def[1].flag[attacking].is[!=].to[true]> queue clear
  - ^wait 60s
  - ^queue queue:<def[1].flag[queue]> pause
  - ^adjust <player> walk_speed:0
  - ^flag %1% die
  - ^vulnerable state:false npc:%1%
  - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> Prepare to be finished!"
  - ^flag %2% nodie duration:120s
  - ^potion BLINDNESS duration:10s player:%2%
  - ^narrate "<&8>You are stuck to the ground."
  - ^hurt <def[2].sub[<def[2].health.sub[.5]>]>
  - ^create Player Ali <def[1].location.add[<def[2].location>].div[2]> save:Ali
  - ^flag <entry[Ali].created_npc> owner:%2%
  - ^flag player e.npcs:->:<entry[Ali].created_npc>
  - ^assignment set script:AliFight npc:<entry[Ali].created_npc>
  - ^lookclose <entry[Ali].created_npc> state:true range:10
  - ^equip <entry[Ali].created_npc> hand:i@diamond_sword chestplate:i@diamond_chestplate legs:i@iron_leggings
  - ^run hideNPCs instantly
  - ^wait 2s
  - ^narrate "<&7>[<&b>Ali<&7> -> You]<&co> Enough, Storm! You can claim your victory, but if you wish to claim his life, you must claim mine as well!"
  - ^wait 2s
  - ^narrate "<&7>[<&b>Storm<&7> -> You]<&co> Bah! So be it!"
  - ^vulnerable state:true npc:%1%
  - ^adjust <player> walk_speed:.2
  - ^wait 2s
  - ^heal %2% <def[2].health.max>
  - ^narrate "<&8>You have been healed by Ali!"
  - ^queue queue:<def[1].flag[queue]> resume
  - ^attack <entry[Ali].created_npc> target:%1%

fightevents:
  type: world
  debug: false
  events:
    on player killed:
    - if <player.flag[e.nodie]> {
      - determine passively cancelled
      - heal <player> <player.health.max>
      - narrate "<&4><&l>You have died"
      - narrate "<&8>You have been healed by Ali"
      }
      else {
      - determine passively cancelled
      - if <player.location.world.name.is[!=].to[<s@config.constant[nameofworld]>]> queue clear
      - if <player.flag[e.ali].is[!=].to[null]> {
        - teleport <player> <player.flag[e.Ali].as_npc.location>
        - potion BLINDNESS duration:4s
        - narrate "<&4><&l>You have died"
        - narrate "<&8>Ali has resuced you"
        - heal 20 <player>
        }
        else {
        - teleport <player> <s@config.constant[templeRespawn].as_location>
        - potion BLINDNESS duration:4s
        - narrate "<&4><&l>You have died"
        - narrate "<&8>The elders have healed you"
        - heal 20 <player>
        }
      }
    on npc dies:
    - if <context.entity.flag[die]> {
      - spawn <context.entity>
      - queue queue:<context.entity.flag[queue]> clear
      - flag <context.entity> attacking:!
      - flag <context.entity> queue:!
      - animate <context.entity> animation:SLEEP
      - zap step:2 s@AliFightSteps player:<context.entity.flag[owner].as_player>
      - wait 10s
      - remove <context.entity>
      }

AliFight:
  type: assignment
  actions:
    on assignment:
    - ^health <npc> 500 state:true
    - ^heal <npc> 500
    - ^trigger name:proximity state:true radius:10 cooldown:1s
    on death:
    - run locally remove delay:10s def:<npc>
  interact scripts:
  - AliFightSteps
  remove:
  - remove %1%
AliFightSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - queue clear
    2:
      proximity trigger:
        move:
          script:
          - ^if <npc.flag[moveran]> queue clear
          - ^flag npc moveran
          - ~walkto <npc> <npc.flag[owner].as_player.location>
          - animate <npc> animation:SNEAK
          - narrate "<&7>[<&b>Ali<&7> -> You]<&co> It indeed is a dark day... Volcivor still haunts us with all these evils plaguing our land... Go to sleep. I need to be alone for a while. *kneels by the body of Storm*. Goodbye, old friend."
          - wait 7s
          - animate <npc> animation:STOP_SNEAKING
          - narrate "<&8>Go to sleep"
          - run objective_remove "def:Beat Storm|27"
          - run objective_add "def:Go to Sleep|28"
          - ^run updatecompass "def:Points to a bed|Points to a bed|<s@config.constant[BedPoint]>"
          - flag player e.bed2
          - ~walkto <npc> <s@config.constant[AliHome]>
          - remove <npc>

BroodQueen:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true radius:15
    - trigger name:damage state:true
    - health <npc> 350 state:true
    - heal <npc> 350 
    - lookclose <npc> state:true radius:15
    on death:
    - playeffect
    - ^if <npc.flag[died]> queue clear
    - ^flag npc died duration:10s
    - ^give <s@config.constant[BroodQueenReward]>
    - ^queue queue:<npc.flag[queue]> clear
    - ^run locally remove def:<npc> delay:5s
    - ^narrate "<&7>[<&b>Lythis<&7> -> You]<&co> *gasps for air* I will never be so proud of the title 'Rat-slayer' than right now... that was brutal fighting! We should report back to the Mayor that the source of the disease has been stopped. Well fought."
    - ^run objective_remove "def:Kill BroodQueen|30" player:<npc.flag[owner]>
    - ^run objective_add "def:Go to the Mayor|31" player:<npc.flag[owner]>
    - ^run updatecompass "def:Points to the Mayor|Points to the Mayor|<s@config.constant[MayorHome]>"
    - ^narrate "<&8>Return to the Mayor"
    - ^potion BLINDNESS duration:3s
    - ^walkto <player.flag[e.ally].as_npc> <s@config.constant[LythisHome]>
    - ^zap step:12 s@LythisSteps
    - ^zap step:6 s@MayorSteps
  interact scripts:
  - 10 BroodQueenSteps
  remove:
  - remove %1%
  - remove <def[1].flag[minions].as_list>
BroodQueenSteps:
  type: interact
  steps:
    1:
      proximity trigger:
        move:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - ^if <npc.flag[attacking]> queue clear
          - ^zap step:2
          - ^flag npc attacking
          - ^flag npc attacking
          - ^vulnerable state:true
          - ^trigger name:damage state:true
          - ^inject locally attackTarget
    2:
      proximity trigger:
        exit:
          script:
          - if <npc.flag[owner].is[==].to[<player>]> {
            - engage
            - queue queue:<npc.flag[queue]> clear
            - ~walkto <npc> <s@config.constant[BroodQueenHome]> speed:2
            - vulnerable state:false
            - trigger name:damage state:false
            - zap step:1
            - flag npc attacking:!
            - flag npc queue:!
            - disengage
            }
  attackTarget:
  - ^flag npc queue:<queue.id>
  - ^random {
    - ^inject locally poison
    - ^inject locally wither
    - ^inject locally HUNGER
    - ^inject locally minions
    - ^inject locally web
    }
  - ^inject locally attackTarget
  poison:
  - ^potion POISON duration:10s
  - ^inject locally attack
  wither:
  - ^potion WITHER duration:10s
  - ^inject locally attack
  HUNGER:
  - ^potion HUNGER duration:10s
  - ^inject locally attack
  minions:
  - ^create e@SilverFish Minion <npc.location.add[1,0,0]> save:M1
  - ^create e@SilverFish Minion <npc.location.add[-1,0,0]> save:M2
  - ^define m1 <entry[M1].created_npc>
  - ^define m2 <entry[M2].created_npc>
  - ^flag player e.npcs:->:%M1%
  - ^flag player e.npcs:->:%M2%
  - ^flag %M1% owner:<player>
  - ^flag %M2% owner:<player>
  - ^flag %M1% bq:<npc>
  - ^flag %M2% bq:<npc>
  - ^flag <npc> minions:->:%M1%
  - ^flag <npc> minions:->:%M2%
  - ^assignment set script:s@Minion npc:%M1%
  - ^assignment set script:s@Minion npc:%M2%
  - ^flag <npc> minions:->:%M1%
  - ^flag <npc> minions:->:%M2%
  - ^attack %M1% target:<npc.flag[owner].as_player>
  - ^attack %M2% target:<npc.flag[owner].as_player>
  - ^run hideNPCs instantly
  web:
  - ^inject locally walk
  - ^shoot e@falling_block,web o:<npc> d:<npc.flag[owner].as_player.location.add[0,2,0]> speed:2 script:webball
  - ^playsound <npc.flag[owner]> sound:fizz
  - ^wait 5t
  - ^shoot e@falling_block,web o:<npc> d:<npc.flag[owner].as_player.location.add[0,2,0]> speed:2 script:webball
  - ^playsound <npc.flag[owner]> sound:fizz
  - ^wait 5t
  - ^shoot e@falling_block,web o:<npc> d:<npc.flag[owner].as_player.location.add[0,2,0]> speed:2 script:webball
  - ^playsound <npc.flag[owner]> sound:fizz
  attack:
  - ^attack <npc> target:<npc.flag[owner]>
  - ^wait 6s

minion:
  type: assignment
  actions:
    on assignment:
    - trigger name:damage state:true
    - vulnerable <npc> state:true
    - health state:true 10 <npc>
    - heal <npc> 10
    on death:
    - flag <npc> owner:!
    - if <npc.flag[bq].as_npc.is_spawned> flag <npc> bq:!
    - run locally remove delay:5s def:<npc>
    on spawn:
    - playsound <player> name:silverfish_idle
  remove:
  - remove %1%
webball:
  type: task
  script:
  - foreach <def[location].find.living_entities.within[2]> {
    - hurt %value% 3
    }

Dale:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true radius:10
    - trigger name:click state:true
    - lookclose <npc> state:true radius:6
  interact scripts:
  - 10 DaleSteps
DaleSteps:
  type: interact
  steps:
    1:
      proximity trigger:
        entry:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - narrate "<&8>Right click Dale"
      click trigger:
        script:
        - zap step:2
        - run objective_remove "def:Go to Dale|36"
        - narrate "<&7>[<&b>Dale<&7> -> You]<&co> This *is* a mighty fine weapon. I used to slay the undead with this. I used to protect this city... but alas, I am too old for such matters anymore."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - give <s@config.constant[DaleWeapon]>
        - wait 4s
        - narrate "<&7>[<&b>Dale<&7> -> You]<&co> If Master Ali sent you, then by all means, take it. Bear it well, and may the undead fall before you!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Dale<&7> -> You]<&co> Also, these potions might do you good. attacking many at once with these beauties is sometimes better than hacking at every zombie."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - give "i@potion[potion=INSTANT_HEAL,2,false,true;lore=Quest Item]" qty:5
        - wait 3s
        - narrate "<&7>[<&b>Dale<&7> -> You]<&co> Now, first things first. From what I've heard, the dead are rising from the old cemetery in the main city. They call it Dro'kma Burial Grounds" 
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - wait 4s
        - narrate "<&7>[<&b>Dale<&7> -> You]<&co> Go there, and cleanse the place of that undead filth. If you succeed, you can keep the weapon. If  not... *chuckles*...  get going, kid."
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - run objective_add "def:Fight at Drokma|37"
        - ^run updatecompass "def:Points to Dro'kama|Points to Dro'kama|<s@config.constant[DrokamaLoc]>"
        - narrate "<&8>Go to X<&co>0 Z<&co>250"
        - flag player e.burialGrounds
    2:
      click trigger:
        script:
        - narrate "<&7>[<&b>Dale<&7> -> You]<&co> hmm?"

burialGrounds:
  type: world
  events:
    on player enters cu@burialGroundsEntrance:
    - ^if !<player.flag[e.burialGrounds]> queue clear
    - ^flag player e.burialGrounds:!
    - ^create player <&4>Groundskeeper <s@config.constant[GroundskeeperHome]> save:GK
    - ^define GK <entry[GK].created_npc>
    - ^equip %GK% head:i@zombie_skull 
    - ^flag player e.npcs:->:%GK%
    - ^flag %GK% owner:<player>
    - ^run hideNPCs instantly
    - ^assignment set script:s@Groundskeeper npc:%GK%
    - ^foreach li@<s@config.constant[BurialZombieSpawn1]>|<s@config.constant[BurialZombieSpawn2]>|<s@config.constant[BurialZombieSpawn3]>|<s@config.constant[BurialZombieSpawn4]>|<s@config.constant[BurialZombieSpawn5]>|<s@config.constant[BurialZombieSpawn6]> {
      - ^create player Undead %value% save:undead
      - ^define undead <entry[undead].created_npc>
      - ^equip %undead% head:i@zombie_skull
      - ^flag player e.npcs:->:%undead%
      - ^flag %undead% owner:<player>
      - ^run hideNPCs instantly
      - ^assignment set script:s@undead npc:%undead%
      }
    - run hideNPCs
Groundskeeper:
  type: assignment
  actions:
    on assignment:
    - ^trigger name:proximity state:true radius:20
    - ^trigger name:damage state:true
    - ^trigger name:click state:true
    - ^vulnerable state:false
    - ^lookclose <npc> state:true
    - ^equip <npc> hand:i@diamondshovel chestplate:i@chainmail_chestplate legs:i@chainmail_leggings boots:i@chainmail_boots
    - ^health <npc> state:true 100
    - ^heal <npc> 100
    on death:
    - playeffect <npc.location> effect:cloud qty:10000 data:1
    - ^if <npc.flag[died]> queue clear
    - ^flag npc died
    - ^run locally remove delay:5s def:<npc>
    - ^run objective_remove "def:Fight at Drokma|37"
    - ^create Player Ali <s@config.constant[AliBurialGrounds]> save:Ali
    - ^define Ali <entry[Ali].created_npc>
    - lookclose state:true npc:%Ali%
    - ^flag player e.npcs:->:%Ali%
    - ^lookclose <npc> state:true range:10
    - ^run hideNPCs instantly
    - ^foreach <server.list_online_players.exclude[<npc.flag[owner].as_player>]> {
      - ^adjust %value% hide_entity:%Ali%
      }
    - ^create Player Isaac <s@config.constant[IsaacHome]> save:Isaac
    - ^define Isaac <entry[Isaac].created_npc>
    - ^flag <npc.flag[owner].as_player> e.npcs:->:%Isaac%
    - ^flag <npc.flag[owner].as_player> e.ally:%Isaac%
    - ^flag %Isaac% owner:<npc.flag[owner].as_player>
    - ^flag %Isaac% owner:<player>
    - ^assignment set script:s@Isaac npc:%Isaac%
    - ^run hideNPCs instantly
    - ~walkto %Ali% <player.location.add[1,0,0]> speed:2
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> The fighting has been hard inside town hall. The city Archmage has been slain... the undead corrupted him with their poison, and he awoke again. "
    - ^playeffect %Ali% effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> He flew away from the Town Hall. An undead sorcerer is a great threat to the entire city... "
    - ^playeffect %Ali% effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Hopefully, he will simply flee and let us be, but there is the chance that he will return. We must be ready."
    - ^playeffect %Ali% effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> As we speak, the Elders are besieged by another horde, and a giant leads them. Go to the Elder Temple, and protect them at all costs!"
    - ^playeffect %Ali% effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> With their guidance, we may yet live to see tomorrow. I must continue to protect the mayor. This responsibility I place in your hands. You have proven to be more than capable, but you will need aid."
    - ^playeffect %Ali% effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> Go to the house of the hermit, Isaac. If you travel due West, past the Town Hall, you will find his abode. Out of all the warriors in Aleraden,"
    - ^playeffect %Ali% effect:drip_lava qty:300 targets:<player>
    - wait 4s
    - narrate "<&7>[<&b>Ali<&7> -> You]<&co> he is the only one who has slain a Giant before. Follow him into battle against the Giant. Good fortune be with you!"
    - ^playeffect %Ali% effect:drip_lava qty:300 targets:<player>
    - ^run objective_add "def:Go to Isaac|38"
    - ^run updatecompass "def:Points to Isaac|Points to Isaac|<s@config.constant[IsaacHome]>"
    - ~walkto %Ali% <s@config.constant[AliBurialGrounds]>
    - remove %Ali%
  remove:
  - remove %1%
  interact scripts:
  - 10 GroundskeeperSteps
GroundskeeperSteps:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - narrate "<&8>You cannot attack him until you kill him minions"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
      damage trigger:
        script:
        - narrate "<&8>You cannot attack him until you kill him minions"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
    2:
      proximity trigger:
        move:
          script:
          - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - ^if <npc.flag[attacking]> queue clear
          - ^flag npc attacking
          - ^vulnerable state:true
          - ^trigger name:damage state:true
          - ^zap step:3
          - ^attack <npc> target:<player>
    3:
      proximity trigger:
        exit:
          script:
          - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - ^flag npc attacking:!
          - ^attack <npc> target:cancel
          - ^zap step:2
          - ^walkto <npc> <s@config.constant[GroundskeeperHome]>
          - ^heal <npc> 100
Undead:
  type: assignment
  actions:
    on assignment:
    - ^vulnerable state:true
    - ^trigger name:proximity state:true radius:20
    - ^trigger name:damage state:true
    - ^lookclose <npc> state:true
    - ^health 10 <npc> state:true
    - ^heal 10 <npc>
    - ^flag npc home:<npc.location>
    - ^flag npc deaths:0
    - ^execute as_server "npc sel <npc.id>"
    - ^execute as_server "npc skin Inzuki"
    on spawn:
    - ^vulnerable state:true
    - ^trigger name:proximity state:true radius:14
    - ^trigger name:damage state:true
    - ^lookclose <npc> state:true
    - ^health 10 <npc> state:true
    - ^heal 10 <npc>
    on enter proximity:
    - if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - attack <npc> target:<player>'
    - playsound <npc.flag[owner]> name:zombie_infect
    on death:
    - ^if <npc.flag[died]> queue clear
    - ^flag npc died duration:10s
    - ^playsound <npc.flag[owner].as_player> name:ZOMBIE_DEATH
    - ^flag npc deaths:++
    - ^flag player e.undeadkills:++
    - ^if <player.flag[e.undeadkills].is[OR_MORE].than[10]> {
      - ^zap step:2 s@GroundskeeperSteps
      }
    - ^if <npc.flag[deaths].is[OR_MORE].than[3]> run locally remove delay:5s def:<npc>
      else run locally respawn def:<npc> delay:10s
  remove:
  - ^remove %1%
  respawn:
  - ^spawn %1% <def[1].as_npc.flag[home].as_location>

Isaac:
  type: assignment
  actions:
    on assignment:
    - ^trigger name:click state:true
    - ^trigger name:proximity staet:true radius:15
    - ^trigger name:damage state:false
    - ^vulnerable state:false
    - ^equip hand:i@diamond_sword[enchantments=DAMAGE_ALL,1] chest:i@chainmail_chestplate legs:i@leather_leggings
    - ^lookclose <npc> state:true
  interact scripts:
  - 10 IsaacSteps
IsaacSteps:
  type: interact
  debug: true
  steps:
    1:
      click trigger:
        script:
        - engage
        - ^run objective_remove "def:Go to Isaac|38"
        - ^narrate "<&7>[<&b>Isaac<&7> -> You]<&co> I believe I know why you are here... the roars... the tramp of undead feet... the stomp of a giant. Allow me to fetch my sword, and I will join you. If the Gods will it, you shall survive to be a giant-slayer as well!"
        - ^playeffect <npc.location> effect:drip_lava qty:300 targets:<player>
        - ^run objective_add "def:Kill the Giant|39"
        - ^run updatecompass "def:Points to the Giant|Points to the Giant|<s@config.constant[GiantHome]>"
        - ^foreach li@<s@config.constant[ZombieSpawn1]>|<s@config.constant[ZombieSpawn2]>|<s@config.constant[ZombieSpawn3]>|<s@config.constant[ZombieSpawn4]>|<s@config.constant[ZombieSpawn5]>|<s@config.constant[ZombieSpawn6]>|<s@config.constant[ZombieSpawn7]>|<s@config.constant[ZombieSpawn8]>|<s@config.constant[ZombieSpawn9]>|<s@config.constant[ZombieSpawn10]> {
          - ^create player Zombie %value% save:Zombie
          - ^define zombie <entry[Zombie].created_npc>
          - ^equip %Zombie% head:i@zombie_skull
          - ^flag player e.npcs:->:%Zombie%
          - ^flag player e.raiders:->:%Zombie%
          - ^flag %zombie% owner:<player>
          - ^assignment set script:s@RaidingZombie npc:%zombie%
          }
        - ^run hideNPCs instantly
        - ^create e@Giant Giant <s@config.constant[GiantHome]> save:Giant
        - ^define giant <entry[Giant].created_npc>
        - ^flag player e.npcs:->:%Giant%
        - ^flag %giant% owner:<player>
        - ^assignment set script:s@Giant npc:%Giant%
        - narrate "<&7>[<&b>Isaac<&7> -> You]<&co> Let's go."
        - zap step:2
        - ^run hideNPCs instantly
        - disengage
    2:
      proximity trigger:
        move:
          script:
          - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - ^if <npc.flag[attacking]> queue clear
          - ^define player <npc.flag[owner].as_player>
          - ^define target <npc.flag[owner].as_player.flag[e.target]>
          - ^if <def[target].is[!=].to[null]> {
            - ^flag npc attacking duration:5s
            - ^flag npc queue:<queue.id>
            - ^attack <npc> target:%target%
            - ^flag %player% e.target:!
            - ^wait 5s
            - ^attack <npc> target:cancel
            }
            else walkto <npc> <npc.location.add[<player.location>].div[2]> speed:1.5
        exit:
          script:
          - if <npc.flag[owner].is[!=].to[<player>]> queue clear
          - queue queue:<npc.flag[queue]> clear
          - walkto <npc> <player.location.add[1,0,0]> speed:1.7
targetManager:
  type: world
  debug: false
  events:
    on player damages entity:
    - ^if <player.location.world.name.is[!=].to[<s@config.constant[nameofworld]>]> queue clear
    - ^flag player e.target:<context.entity> duration:5s

Giant:
  type: assignment
  actions:
    on assignment:
    - trigger name:proximity state:true radius:15
    - lookclose <npc> state:true radius:15
    - trigger name:damage state:true
    - vulnerable state:true
    - adjust <npc> set_entity_type:e@Giant
    on enter proximity:
    - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - ^attack <npc> target:<player>
    on exit proximity:
    - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - attack <npc> target:cancel
    - walkto <s@config.config[GiantHome]>
    on death:
    - ^playsound <player> name:ENDERDRAGON_DEATH
    - ^wait 2s
    - ^run objective_remove "def:Kill the Giant|39" 
    - ^run locally remove delay:5s def:<npc>
    - ^narrate "<&8>Enter the temple"
    - ^narrate "<&7>[<&b>Isaac<&7> -> You]<&co> Truly, well done, however I must go now."
    - ^walkto <player.flag[e.ally].as_npc> <player.flag[e.ally].as_npc.location.add[10,0,0]>
    - ^flag player e.entered3
    - ^wait 5s
    - ^remove <player.flag[e.ally].as_npc>
    - ^run objective_add "def:Enter the Temple|40"
    on attack:
    - playsound <npc.flag[owner]> name:BLAZE_HIT
  remove:
  - remove %1%
RaidingZombie:
  type: assignment
  actions:
    on assignment:
    - ^trigger name:damage state:true
    - ^trigger name:proximity state:true radius:15
    - ^lookclose <npc> state:true
    - ^flag npc home:<npc.location>
    - ^health <npc> 80 state:true
    - ^vulnerable state:true
    - ^heal <npc> 30
    - ^walkto <npc> <s@config.constant[ZombieWalkto]>
    - ^run locally ewalkto def:<npc>
    - ^execute as_server "npc sel <npc.id>"
    - ^execute as_server "npc skin FoidzaFlow"
    on enter proximity:
    - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - ^queue queue:<npc.flag[queue]> clear
    - ^attack <npc> target:<player>
    on exit proximity:
    - ^if <npc.flag[owner].is[!=].to[<player>]> queue clear
    - ^queue queue:<npc.flag[queue]> clear
    - ^walkto <npc> <s@config.constant[ZombieWalkto]>
    on death:
    - ^wait 10s
    - ^run locally spawn delay:5s def:<npc>
    on complete navigation:
    - ^pause waypoints
    - ^look <npc> <s@config.constant[ZombieShootBack]> duration:2s
    - ^shoot <npc> o:<npc> d:<s@config.constant[ZombieShootBack].as_location.add[0,4,0]> speed:2 height:3
    - wait 2s
    - ^walkto <npc> <s@config.constant[ZombieWalkto]>
  ewalkto:
  - wait 4s
  - ^walkto <npc> <s@config.constant[ZombieWalkto]>
  spawn:
  - ^spawn %1% <def[1].flag[home].as_location>
  - ^vulnerable state:true
  - ^trigger name:damage state:true
objective_add:
  type: task
  script:
  - ^playsound <player> sound:SUCCESSFUL_HIT volume:5 pitch:3
  - ^scoreboard add viewers:<player> id:<player.name>_objective objective:Tasks lines:%1% score:%2%
objective_remove:
  type: task
  script:
  - ^playsound <player> sound:SUCCESSFUL_HIT volume:5
  - ^scoreboard remove id:<player.name>_objective objective:Tasks lines:%1% score:%2%
npcclick:
  type: world
  debug: false
  events:
    on player right clicks npc:
    - if <s@config.constant[nameofworld].is[!=].to[<player.world.name>]> queue clear
    - ^playsound <player> sound:VILLAGER_YES volume:5
    on player kills npc:
    - if <s@config.constant[nameofworld].is[!=].to[<player.world.name>]> queue clear
    - playsound <player> name:FIREWORK_LAUNCH
    on npc damaged by POISON:
    - determine cancelled
blockListTester: 
# Change "define range 20" to the amount of blocks 
# you would like the flame to travel. 
  type: world 
  events: 
    on player right clicks with i@stick: 
    - define range 40 
    - ^inject blockListUtil instantly 
    - ^playeffect <def[blockList]> effect:FIREWORKS_SPARK qty:10 targets:<player>

blockListUtil: 
  type: task 
  script: 
  - ^define blockList li@ 
  - ^repeat %range% {
    - ^define currentBlock <npc.location.add[<npc.location.direction.vector.mul[%value%]>]>
    - ^define blockList <def[blockList].include[%currentBlock%]>
    }

updatecompass:
  type: task
  script:
  - ^take <player.flag[e.compass].as_item>
  - ^flag player e.compass:i@compass[display_name=<&a>%1%;lore=%2%]
  - ^give i@compass[display_name=<&a>%1%;lore=%2%]
  - ^compass %3%
  - ^narrate "<&8>Compass Updated"