summaryrefslogtreecommitdiff
path: root/npc/guild2/schg_cas01.txt
blob: 46dbcda48999f441e4148167e90366505e1e015a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
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
//===== eAthena Script =======================================
//= War of Emperium Second Edition
//===== By: ==================================================
//= L0ne_W0lf
//===== Current Version: =====================================
//= 2.0
//===== Compatible With: =====================================
//= eAthena SVN
//===== Description: =========================================
//= WoE SE Schwaltzvalt Castle 1
//===== Additional Comments: =================================
//= 1.0 First Version [L0ne_W0lf]
//= 1.1 Swaped an end for a close in eco investing. [L0ne_W0lf]
//= 1.2 Fixed take-over lowering schg_cas04's eco. [L0ne_W0lf]
//= 1.3 Fixed double message in defense investing. [L0ne_W0lf]
//=     Corrected a minor typo in the guild steward.
//= 1.4 Fixed a guardian spawning NPCs. [L0ne_W0lf]
//= 1.5 Fixed investment period not resetting. [L0ne_W0lf]
//=     Made it so treasure won't spawn if castle is empty.
//=     Treasure will now be killed before spawning.
//= 1.6 Corrected a typo with treasure spawning. [L0ne_W0lf]
//= 1.7 Replaced effect numerics with constants. [L0ne_W0lf]
//= 1.8 Corrected wrong treasure spawn position. [zapbomb]
//= 1.9 Applied updated eco/def systems. [L0ne_W0lf]
//= 2.0 Fixed eco/def not actually incrementing. [L0ne_W0lf]
//=     Can no longer gain eco/def higher than 100.
//============================================================

schg_cas01,1,1,0	script	Manager#sch01_02	111,{
	end;

OnInterIfInitOnce:
	GetCastleData "schg_cas01",0,"::OnRecvCastleSc01";
	end;

OnRecvCastleSc01:
	RequestGuildInfo GetCastleData("schg_cas01",1);
	if (GetCastleData("schg_cas01",1) == 0) {
		donpcevent "Manager#sch01_02::Onstart";
	}
	end;

OnAgitStart2:
	if (agitcheck2()) {
		MapRespawnGuildID "schg_cas01",GetCastleData("schg_cas01",1),2;
		GvgOn "schg_cas01";
		donpcevent "Manager#sch01_02::Onstart";
	}
	else {
		donpcevent "#sch01_RL00::OnDisable";
		donpcevent "#sch01_RL01::OnDisable";
		donpcevent "#sch01_RL02::OnDisable";
		donpcevent "#sch01_RL03::OnDisable";
	}
	end;

OnAgitEnd2:
	GvgOff "schg_cas01";
	if (GetCastleData("schg_cas01",1)) {
		KillMonster "schg_cas01","Steward#sch01::OnStartArena";
		donpcevent "Manager#sch01_02::Onreset";
		donpcevent "Steward#sch01::Onstop";
	}
	end;

Onstart:
	// 1st Guardian stone, 2nd Guardian stone, Barrier 1, Barrier 2, Barrier 3, Summon Guardians
	// Settings for all but Summon Guardians
	// 0 = Okay; 1 = Destroyed; 2 = Repairing
	// Summon Guardians
	// 0 = Do not Summon; 1 = Summon
	if (GetCastleData("schg_cas01",1)) {
		setarray $agit_sc01[0],0,0,0,0,0,0;
		donpcevent "#sch01_df01::OnEnable";
		donpcevent "#sch01_df02::OnEnable";
		donpcevent "#sch01_RL00::OnEnable";
		donpcevent "#sch01_RL01::OnEnable";
		donpcevent "#sch01_RL02::OnEnable";
		donpcevent "#sch01_RL03::OnEnable";
	}
	monster "schg_cas01",120,272,"Emperium",1288,1,"Steward#sch01::OnStartArena";
	end;

Onreset:
	donpcevent "#sch01_df01::OnDisable";
	donpcevent "#sch01_df02::OnDisable";
	donpcevent "#sch01_gard01::Onreset";
	donpcevent "#sch01_gard02::Onreset";
	donpcevent "#sch01_RL00::OnDisable";
	donpcevent "#sch01_RL01::OnDisable";
	donpcevent "#sch01_RL02::OnDisable";
	donpcevent "#sch01_RL03::OnDisable";
	donpcevent "1st Guardian Stone#sch01::OnDisable";
	donpcevent "2nd Guardian Stone#sch01::OnDisable";
	donpcevent "Control Device01#sch01::OnDisable";
	donpcevent "Control Device02#sch01::OnDisable";
	donpcevent "Control Device03#sch01::OnDisable";
	if (agitcheck2()) {
		setarray $agit_sc01[0],0,0,1,1,1,0;
	}
	end;

Onchange:
	setarray $agit_sc01[0],2,2,1,1,2,0;
	monster "schg_cas01",120,272,"Emperium",1288,1,"Steward#sch01::OnStartArena";
	donpcevent "Control Device03#sch01::OnEnable";
	donpcevent "1st Guardian Stone#sch01::OnEnable";
	donpcevent "2nd Guardian Stone#sch01::OnEnable";
	end;

OnClock0001:
	if (!GetCastleData("schg_cas01",1)) end;
	killmonster "schg_cas01","Manager#sch01_02::OnTreasureDied";

	if (GetCastleData("schg_cas01",4)) {
		set .@Economy,GetCastleData("schg_cas01",2);
		SetCastleData "schg_cas01",2,.@Economy + GetCastleData("schg_cas01",4) + (rand(2) && getgdskilllv(.@GID,10014));
		if (GetCastleData("schg_cas01",2) > 100) SetCastleData "schg_cas01",2,100;
		setcastledata "schg_cas01",4,0;
	}
	if (GetCastleData("schg_cas01",5)) {
		set .@Defence,GetCastleData("schg_cas01",3);
		SetCastleData "schg_cas01",3,.@Defence + GetCastleData("schg_cas01",5);
		if (GetCastleData("schg_cas01",3) > 100) SetCastleData "schg_cas01",3,100;
		setcastledata "schg_cas01",5,0;
	}

	set .@Treasure,GetCastleData("schg_cas01",2)/5+4;
	if (.@Treasure) {
		monster "schg_cas01",388,388,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		monster "schg_cas01",388,389,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		monster "schg_cas01",388,390,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		monster "schg_cas01",387,390,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 5) end;
		monster "schg_cas01",386,390,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 6) end;
		monster "schg_cas01",385,390,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 7) end;
		monster "schg_cas01",384,389,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 8) end;
		monster "schg_cas01",384,388,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 9) end;
		monster "schg_cas01",384,387,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 10) end;
		monster "schg_cas01",384,386,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 11) end;
		monster "schg_cas01",384,385,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 12) end;
		monster "schg_cas01",384,384,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 13) end;
		monster "schg_cas01",385,384,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 14) end;
		monster "schg_cas01",386,384,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 15) end;
		monster "schg_cas01",387,384,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 16) end;
		monster "schg_cas01",388,384,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 17) end;
		monster "schg_cas01",389,384,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 18) end;
		monster "schg_cas01",390,384,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 19) end;
		monster "schg_cas01",390,385,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 20) end;
		monster "schg_cas01",390,386,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 21) end;
		monster "schg_cas01",389,386,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 22) end;
		monster "schg_cas01",388,386,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 23) end;
		monster "schg_cas01",387,386,"Treasure Chest",1938,1,"Manager#sch01_02::OnTreasureDied";
		if (.@Treasure < 24) end;
		monster "schg_cas01",386,386,"Treasure Chest",1324,1,"Manager#sch01_02::OnTreasureDied";
	}
	end;

OnTreasureDied:
	end;
}

schg_cas01,123,306,3	script	Ef#sch01_01	868,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (.@GID == 0) {
		mes "[Ef]";
		mes "Great job. Now, all you";
		mes "need to do is destroy this";
		mes "Emperium to gain ownership";
		mes "over this stronghold.";
		close;
	}
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) != getguildmaster(.@GID)) {
			mes "[Ef]";
			mes "As guardian of this";
			mes "stronghold, I answer only";
			mes "to the master of the guild";
			mes "that controls this place.";
			close;
		}
		else {
			if (agitcheck2() == 0) {
				mes "[Ef]";
				mes "I am Ef, guardian of";
				mes "this stronghold. For now,";
				mes "all is quiet in this place.";
				next;
				switch(select("Converse:Cancel")) {
				case 1:
					mes "[Ef]";
					mes "Do you have any questions";
					mes "about this stronghold?";
					next;
					switch(select("Guardian Stones:Fortress Gates:Link Flags:Battle Strategy:Cancel")) {
					case 1:
						mes "[Ef]";
						mes "There is one Emperium";
						mes "and two Guardian Stones in";
						mes "each fortress. These stones";
						mes "are the first line of defense,";
						mes "and must be destroyed before";
						mes "enemies can even enter.";
						next;
						mes "[Ef]";
						mes "The stones are located in";
						mes "^4D4DFFGate Houses^000000 which must be";
						mes "protected to prevent enemies";
						mes "from reaching the Emperium.";
						mes "Guardian Stones can ^4D4DFFrecall";
						mes "your Guardians^000000 for protection.";
						next;
						mes "[Ef]";
						mes "Fortresses with higher levels";
						mes "of defense can summon more";
						mes "Guardians: this is why it is";
						mes "so important for guilds to";
						mes "invest in Defense Growth.";
						next;
						mes "[Ef]";
						mes "Guardian Stones that have";
						mes "been destroyed can be revived";
						mes "after a certain time, but one of^FFFFFF ^000000 the guild members must give";
						mes "me the order. I can also report^FFFFFF ^000000 the status of the Guardian Stones.";
						close;
					case 2:
						mes "[Ef]";
						mes "^4D4DFFFortress Gates^000000 are the second ^FFFFFF ^000000 line of guild stronghold defense,";
						mes "and are protected by extra barricades activated by the Guardian Stones.";
						mes "These gates are located in three different parts of the fortress.";
						next;
						mes "[Ef]";
						mes "Barricades are protected by";
						mes "Guardian Stones, and are";
						mes "restored when the Guardian";
						mes "Stones are retrieved. However,";
						mes "it is not as easy to restore";
						mes "destroyed Fortress Gates.";
						next;
						mes "[Ef]";
						mes "Fortress Gates can only be";
						mes "restored when the ^4D4DFFguild";
						mes "master of a stronghold";
						mes "changes^000000, or if ^4D4DFFrestoration";
						mes "is requested by the guild";
						mes "master of the stronghold^000000.";
						close;
					case 3:
						mes "[Ef]";
						mes "Strongholds have many";
						mes "Link Flags that allow you";
						mes "to access vital areas within";
						mes "restrictions placed by the";
						mes "Barricades. Usually, ^4D4DFFFlag 1";
						mes "links to the Gate House^000000.";
						next;
						mes "[Ef]";
						mes "Many flags link directly to";
						mes "the flag near the Emperium.";
						mes "The final numbered flag is";
						mes "linked to the Convenience";
						mes "Facility of the stronghold's";
						mes "owner. Keep this in mind.";
						close;
					case 4:
						mes "[Ef]";
						mes "Strategy? It would be better";
						mes "to develop your battle plan to";
						mes "exploit your guild's advantages";
						mes "and your enemies' weaknesses.";
						mes "Use the Gate Houses and Barricades, and rebuild as quickly as you can!";
						close;
					case 5:
						mes "[Ef]";
						mes "You have no questions";
						mes "to ask of me? Well, I'm";
						mes "here to serve your needs.";
						close;
					}
				case 2:
					mes "[Ef]";
					mes "I'm always here, so";
					mes "feel free to request my";
					mes "assistance whenever";
					mes "the need arises.";
					close;
				}
			}
			else {
				mes "[Ef]";
				mes "Greetings, "+strcharinfo(0)+".";
				mes "What are your orders?";
				next;
				switch(select("Increase Stronghold Defense:Situational Briefing:Cancel")) {
				case 1:
					if ($agit_sc01[5] == 0) {
						if (getgdskilllv(.@GID,10002) == 0) {
							mes "[Ef]";
							mes "I'm sorry, but the Guardian";
							mes "Stones aren't powerful enough";
							mes "to summon Guardians yet. We";
							mes "need to accumulate more";
							mes "knowledge before they can";
							mes "summon any Guardians.";
							close;
						}
						else {
							mes "[Ef]";
							mes "I shall endeavor to summon";
							mes "a Guardian through a Guardian";
							mes "Stone. However, keep in mind";
							mes "that this will not work if the";
							mes "Guardian Stone is destroyed.";
							setarray $agit_sc01[5],1;
							if ($agit_sc01[0] == 0) {
								donpcevent "#sch01_gard01::OnEnable";
							}
							if ($agit_sc01[1] == 0) {
								donpcevent "#sch01_gard02::OnEnable";
							}
							close;
						}
					}
					else {
						mes "[Ef]";
						mes "You've already commanded";
						mes "me to summon a Guardian";
						mes "to defend the stronghold.";
						close;
					}
				case 2:
					mes "[Ef]";
					mes "Our defense status is...";
					if ($agit_sc01[0] == 1) {
						mes "1st Guardian Stone: ^FF0000Destroyed^000000";
					}
					else if ($agit_sc01[0] == 2) {
						mes "1st Guardian Stone: ^008000Repairing^000000";
					}
					else {
						mes "1st Guardian Stone: ^4D4DFFOperational^000000";
					}
					if ($agit_sc01[1] == 1) {
						mes "2nd Guardian Stone: ^FF0000Destroyed^000000";
					}
					else if ($agit_sc01[1] == 2) {
						mes "2nd Guardian Stone: ^008000Repairing^000000";
					}
					else {
						mes "2nd Guardian Stone: ^4D4DFFOperational^000000";
					}
					if ($agit_sc01[2] == 1) {
						mes "1st Fortress Gate: ^FF0000Destroyed^000000";
					}
					else if ($agit_sc01[2] == 2) {
						mes "1st Fortress Gate: ^008000Repairing^000000";
					}
					else {
						mes "1st Fortress Gate: ^4D4DFFOperational^000000";
					}
					if ($agit_sc01[3] == 1) {
						mes "2nd Fortress Gate: ^FF0000Destroyed^000000";
					}
					else if ($agit_sc01[3] == 2) {
						mes "2nd Fortress Gate: ^008000Repairing^000000";
					}
					else {
						mes "2nd Fortress Gate: ^4D4DFFOperational^000000";
					}
					if ($agit_sc01[4] == 1) {
						mes "3rd Fortress Gate: ^FF0000Destroyed^000000";
					}
					else if ($agit_sc01[4] == 2) {
						mes "3rd Fortress Gate: ^008000Repairing^000000";
					}
					else {
						mes "3rd Fortress Gate: ^4D4DFFOperational^000000";
					}
					close;
				case 3:
					mes "[Ef]";
					mes "I'll be standing by,";
					mes "awaiting your orders.";
					close;
				}
			}
		}
	}
	else {
		mes "[Ef]";
		mes "Who are you? Scoundrel!";
		mes "Leave this stronghold now!";
		close;
	}

OnInit:
	setarray $agit_sc01[0],0,0,0,0,0,0;
	end;
}

schg_cas01,1,1,0	script	#sch01_gard01	-1,{
OnEnable:
	set .@defence,GetCastleData("schg_cas01",3);
	guardian "schg_cas01",111,18,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //0;
	if ((.@defence > 10) && (.@defence < 31)) {
		set .MyMobCount,2;
		guardian "schg_cas01",109,44,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //1;
	}
	else if ((.@defence > 30) && (.@defence < 51)) {
		set .MyMobCount,3;
		guardian "schg_cas01",109,44,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //1;
		guardian "schg_cas01",65,22,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //2;
	}
	else if ((.@defence > 50) && (.@defence < 71)) {
		set .MyMobCount,4;
		guardian "schg_cas01",109,44,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //1;
		guardian "schg_cas01",65,22,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //2;
		guardian "schg_cas01",110,40,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //3;
	}
	else if (.@defence > 70) {
		set .MyMobCount,5;
		guardian "schg_cas01",109,44,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //1;
		guardian "schg_cas01",65,22,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //2;
		guardian "schg_cas01",110,40,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //3;
		guardian "schg_cas01",88,20,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //4;
	}
	else {
		set .MyMobCount,2;
		guardian "schg_cas01",108,32,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //1;
	}
	initnpctimer;
	end;

OnTimer300000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",64,40,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //5;
	mapannounce "schg_cas01","The 1st Guardian has been summoned from the Gate House.",bc_map,"0xff4500";
	end;

OnTimer900000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",47,43,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //6;
	mapannounce "schg_cas01","The 2nd Guardian has been summoned from the Gate House.",bc_map,"0xff4500";
	end;

OnTimer1800000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",109,48,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //7;
	mapannounce "schg_cas01","The 3rd Guardian has been summoned from the Gate House.",bc_map,"0xff4500";
	end;

OnTimer2700000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",111,18,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //8;
	mapannounce "schg_cas01","The 4th Guardian has been summoned from the Gate House.",bc_map,"0xff4500";
	end;

OnTimer3600000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",112,32,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //9;
	mapannounce "schg_cas01","The 5th Guardian has been summoned from the Gate House.",bc_map,"0xff4500";
	stopnpctimer;
	end;

OnGuardianDied:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount < 2) {
		set .MyMobCount,.MyMobCount+1;
		guardian "schg_cas01",120,37,"Guardian Soldier",1899,"#sch01_gard01::OnGuardianDied"; //10;
	}
	end;

Onreset:
	stopnpctimer;
	killmonster "schg_cas01","#sch01_gard01::OnGuardianDied";
	end;
}

schg_cas01,1,2,0	script	#sch01_gard02	-1,{
OnEnable:
	set .@defence,GetCastleData("schg_cas01",3);
	guardian "schg_cas01",130,22,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //11;
	if ((.@defence > 10) && (.@defence < 31)) {
		set .MyMobCount,2;
		guardian "schg_cas01",187,15,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //12;
	}
	else if ((.@defence > 30) && (.@defence < 51)) {
		set .MyMobCount,3;
		guardian "schg_cas01",129,47,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //12;
		guardian "schg_cas01",151,18,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //13;
	}
	else if ((.@defence > 50) && (.@defence < 71)) {
		set .MyMobCount,4;
		guardian "schg_cas01",129,47,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //12;
		guardian "schg_cas01",151,18,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //13;
		guardian "schg_cas01",187,15,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //14;
	}
	else if (.@defence > 70) {
		set .MyMobCount,5;
		guardian "schg_cas01",129,47,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //12;
		guardian "schg_cas01",151,18,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //13;
		guardian "schg_cas01",187,15,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //14;
		guardian "schg_cas01",128,42,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //15;
	}
	else {
		set .MyMobCount,2;
		guardian "schg_cas01",128,42,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //12;
	}
	initnpctimer;
	end;

OnTimer600000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",152,43,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //16;
	end;

OnTimer1200000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",187,15,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //17;
	end;

OnTimer2100000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",128,42,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //18;
	end;

OnTimer3000000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",130,22,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //19;
	end;

OnTimer3900000:
	set .MyMobCount,.MyMobCount+1;
	guardian "schg_cas01",130,28,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //20;
	stopnpctimer;
	end;

OnGuardianDied:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount < 2) {
		set .MyMobCount,.MyMobCount+1;
		guardian "schg_cas01",151,18,"Guardian Soldier",1899,"#sch01_gard02::OnGuardianDied"; //21;
	}
	end;

Onreset:
	stopnpctimer;
	killmonster "schg_cas01","#sch01_gard02::OnGuardianDied";
	end;
}

schg_cas01,1,3,0	script	#sch01_df01	-1,{
OnEnable:
	guardian "schg_cas01",27,35,"1st Guardian Stone",1907,"#sch01_df01::OnGuardianStoneDied"; //22;
	end;

OnDisable:
	killmonster "schg_cas01","#sch01_df01::OnGuardianStoneDied";
	setarray $agit_sc01[0],1; //Global Variable
	stopnpctimer;
	end;

OnGuardianStoneDied:
	// 1st Guardian Stone is Destroyed
	setarray $agit_sc01[0],1;
	if (($agit_sc01[0] == 1) || ($agit_sc01[0] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (($agit_sc01[1] == 1) || ($agit_sc01[1] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (.@destroyed == 2) {
		mapannounce "schg_cas01","All of the Guardian Stones have been destroyed!",bc_map,"0x00ff00";
		donpcevent "#sch01_RL00::OnDisable";
		donpcevent "#sch01_gard01::Onreset";
	}
	else {
		mapannounce "schg_cas01","The 1st Guardian Stone has been destroyed!",bc_map,"0x00ff00";
		donpcevent "#sch01_gard01::Onreset";
	}
	initnpctimer;
	end;

OnTimer300000:
	donpcevent "1st Guardian Stone#sch01::OnEnable";
	setarray $agit_sc01[0],2; //Global Variable
	stopnpctimer;
	end;
}

schg_cas01,27,36,0	script	1st Guardian Stone#sch01	844,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFYou will need the";
		mes "following materials to";
		mes "rebuild a destroyed";
		mes "Guardian Stone.^000000";
		next;
		mes "1 Oridecon";
		mes "1 Elunium";
		mes "30 Stones";
		mes "5 Blue Gemstones";
		mes "5 Yellow Gemstones";
		mes "5 Red Gemstones";
		next;
		mes "^3355FFDo you want to continue?^000000";
		switch(select("No:Continue")) {
		case 1:
			mes "^3355FFWork canceled.^000000";
			close;
		case 2:
			if ((countitem(984) > 0) && (countitem(985) > 0) && (countitem(7049) > 29) && (countitem(717) > 4) && (countitem(715) > 4) && (countitem(716) > 4)) {
				mes "^3355FFArrange Stones, Elunium, and";
				mes "Oridecon, in that order, in the";
				mes "center. Then you must arrange";
				mes "the enchanted Gemstones to";
				mes "rebuild the Guardian Stone.^000000";
				next;
				switch(select("Elunium:Oridecon:Stone")) {
				case 1:
					mes "^3355FFElunium has been";
					mes "placed in the center.^000000";
					next;
					break;
				case 2:
					mes "^3355FFOridecon has been";
					mes "placed in the center.^000000";
					next;
					break;
				case 3:
					mes "^3355FFStones have been";
					mes "placed in the center.^000000";
					set .@nice,.@nice+10;
					next;
					break;
				}
				switch(select("Elunium:Oridecon:Stone")) {
				case 1:
					mes "^3355FFYou have lined the";
					mes "outside of the center";
					mes "with some Elunium.^000000";
					set .@nice,.@nice+10;
					next;
					break;
				case 2:
					mes "^3355FFYou have lined the";
					mes "outside of the center";
					mes "with some Oridecon.^000000";
					next;
					break;
				case 3:
					mes "^3355FFYou have lined the";
					mes "outside of the center";
					mes "with some Stones.^000000";
					next;
					break;
				}
				switch(select("Elunium:Oridecon:Stone")) {
				case 1:
					mes "^3355FFYou covered the";
					mes "rest of the materials";
					mes "with some Elunium.^000000";
					next;
					break;
				case 2:
					mes "^3355FFYou covered the";
					mes "rest of the materials";
					mes "with some Oridecon.^000000";
					set .@nice,.@nice+10;
					next;
					break;
				case 3:
					mes "^3355FFYou covered the";
					mes "rest of the materials";
					mes "with some Stones.^000000";
					next;
					break;
				}
				mes "^3355FFNow you need to arrange";
				mes "the enchanted Gemstones";
				mes "accordingly. You can identify";
				mes "their Magic properties by";
				mes "their casting effect.^000000";
				next;
				while(1) {
					if (.@roof0 > 7) {
						break;
					}
					else {
						switch(rand(1,3)) {
						case 1:
							specialeffect EF_BEGINSPELL2;
							mes "^3355FFThe Gemstones must";
							mes "be arranged in the correct";
							mes "order according to their";
							mes "magic properties and power.^000000";
							next;
							switch(select("Red Gemstone:Yellow Gemstone:Blue Gemstone")) {
							case 1:
								mes "^3355FFYou placed the Red Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							case 2:
								mes "^3355FFYou placed the Yellow Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							case 3:
								mes "^3355FFYou placed the Blue Gemstone.^000000";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							}
							break;
						case 2:
							specialeffect EF_VOLCANO;
							mes "^3355FFThe Gemstones must";
							mes "be arranged in the correct";
							mes "order according to their";
							mes "magic properties and power.^000000";
							next;
							switch(select("Red Gemstone:Yellow Gemstone:Blue Gemstone")) {
							case 1:
								mes "^3355FFYou placed the Red Gemstone.^000000";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL; 
								next;
								break;
							case 2:
								mes "^3355FFYou placed the Yellow Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							case 3:
								mes "^3355FFYou placed the Blue Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							}
							break;
						case 3:
							specialeffect EF_BEGINSPELL4;
							mes "^3355FFThe Gemstones must";
							mes "be arranged in the correct";
							mes "order according to their";
							mes "magic properties and power.^000000";
							next;
							switch(select("Red Gemstone:Yellow Gemstone:Blue Gemstone")) {
							case 1:
								mes "^3355FFYou placed the Red Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							case 2:
								mes "^3355FFYou placed the Yellow Gemstone.^000000";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 3:
								mes "^3355FFYou placed the Blue Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							}
						}
					}
				}
				if (.@nice > 90) {
					if ($agit_sc01[0] == 0) {
						mes "^3355FFThe Guardian Stone";
						mes "Repair System has";
						mes "already completed.^000000";
						close;
					}
					else {
						if (agitcheck2() == 0) {
							mes "^3355FFIt is impossible to";
							mes "rebuild the Guardian";
							mes "Stone because the";
							mes "Emperium is not present.^000000";
							close;
						}
						else {
							mes "^3355FFThe Gemstones have been";
							mes "arranged, and the Guardian";
							mes "Stone is successfully repaired.^000000";
							delitem 984,1; //Oridecon
							delitem 985,1; //Elunium
							delitem 7049,30; //Stone
							delitem 717,5; //Blue_Gemstone
							delitem 715,5; //Yellow_Gemstone
							delitem 716,5; //Red_Gemstone
							close2;
							donpcevent "#sch01_df01::OnEnable";
							specialeffect EF_ICECRASH;
							disablenpc "1st Guardian Stone#sch01";
							setarray $agit_sc01[0],0;
							set .@df_all,$agit_sc01[0]+$agit_sc01[1];
							if (.@df_all == 0) {
								mapannounce "schg_cas01","Both Guardian Stones have been erected, bolstering this stronghold's defenses!",bc_map,"0x00ff00";
								donpcevent "#sch01_RL00::OnEnable";
							}
							else {
								mapannounce "schg_cas01","The 1st Guardian Stone has been repaired successfully.",bc_map,"0x00ff00";
							}
							if ($agit_sc01[5] == 1) {
								donpcevent "#sch01_gard01::OnEnable";
							}
							end;
						}
					}
				}
				else {
					mes "^3355FFAfter all of that work...";
					mes "It looks like you failed";
					mes "to fix the Guardian Stone,";
					mes "and lost some materials.^000000";
					delitem 7049,10; //Stone
					delitem 717,2; //Blue_Gemstone
					delitem 715,2; //Yellow_Gemstone
					delitem 716,2; //Red_Gemstone
					close;
				}
			}
			else {
				mes "^3355FFYou don't have enough";
				mes "materials to repair";
				mes "the Guardian Stone.^000000";
				close;
			}
		}
	}
	end;

OnInit:
	disablenpc "1st Guardian Stone#sch01";
	end;

OnEnable:
	enablenpc "1st Guardian Stone#sch01";
	specialeffect EF_MAPPILLAR2;
	end;

OnDisable:
	disablenpc "1st Guardian Stone#sch01";
	end;
}

schg_cas01,1,4,0	script	#sch01_df02	-1,{
OnEnable:
	guardian "schg_cas01",207,75,"2nd Guardian Stone",1908,"#sch01_df02::OnGuardianStoneDied"; //23;
	end;

OnDisable:
	killmonster "schg_cas01","#sch01_df02::OnGuardianStoneDied";
	setarray $agit_sc01[1],1; //Global Variable
	stopnpctimer;
	end;

OnGuardianStoneDied:
	// 2nd Guardian Stone is Destroyed
	setarray $agit_sc01[1],1;
	if (($agit_sc01[0] == 1) || ($agit_sc01[0] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (($agit_sc01[1] == 1) || ($agit_sc01[1] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (.@destroyed == 2) {
		mapannounce "schg_cas01","All of the Guardian Stones have been destroyed!",bc_map,"0x00ff00";
		donpcevent "#sch01_RL00::OnDisable";
		donpcevent "#sch01_gard02::Onreset";
	}
	else {
		mapannounce "schg_cas01","The 2nd Guardian Stone has been destroyed!",bc_map,"0x00ff00";
		donpcevent "#sch01_gard02::Onreset";
	}
	initnpctimer;
	end;

OnTimer300000:
	donpcevent "2nd Guardian Stone#sch01::OnEnable";
	setarray $agit_sc01[1],2; //Global Variable
	stopnpctimer;
	end;
}

schg_cas01,208,75,0	script	2nd Guardian Stone#sch01	844,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFYou will need the";
		mes "following materials to";
		mes "rebuild a destroyed";
		mes "Guardian Stone.^000000";
		next;
		mes "1 Oridecon";
		mes "1 Elunium";
		mes "30 Stones";
		mes "5 Blue Gemstones";
		mes "5 Yellow Gemstones";
		mes "5 Red Gemstones";
		next;
		mes "^3355FFDo you want to continue?^000000";
		switch(select("No:Continue")) {
		case 1:
			mes "^3355FFWork canceled.^000000";
			close;
		case 2:
			if ((countitem(984) > 0) && (countitem(985) > 0) && (countitem(7049) > 29) && (countitem(717) > 4) && (countitem(715) > 4) && (countitem(716) > 4)) {
				mes "^3355FFArrange Stones, Elunium, and";
				mes "Oridecon, in that order, in the";
				mes "center. Then you must arrange";
				mes "the enchanted Gemstones to";
				mes "rebuild the Guardian Stone.^000000";
				next;
				switch(select("Elunium:Oridecon:Stone")) {
				case 1:
					mes "^3355FFElunium has been";
					mes "placed in the center.^000000";
					next;
					break;
				case 2:
					mes "^3355FFOridecon has been";
					mes "placed in the center.^000000";
					next;
					break;
				case 3:
					mes "^3355FFStones have been";
					mes "placed in the center.^000000";
					set .@nice,.@nice+10;
					next;
					break;
				}
				switch(select("Elunium:Oridecon:Stone")) {
				case 1:
					mes "^3355FFYou have lined the";
					mes "outside of the center";
					mes "with some Elunium.^000000";
					set .@nice,.@nice+10;
					next;
					break;
				case 2:
					mes "^3355FFYou have lined the";
					mes "outside of the center";
					mes "with some Oridecon.^000000";
					next;
					break;
				case 3:
					mes "^3355FFYou have lined the";
					mes "outside of the center";
					mes "with some Stones.^000000";
					next;
					break;
				}
				switch(select("Elunium:Oridecon:Stone")) {
				case 1:
					mes "^3355FFYou covered the";
					mes "rest of the materials";
					mes "with some Elunium.^000000";
					next;
					break;
				case 2:
					mes "^3355FFYou covered the";
					mes "rest of the materials";
					mes "with some Oridecon.^000000";
					set .@nice,.@nice+10;
					next;
					break;
				case 3:
					mes "^3355FFYou covered the";
					mes "rest of the materials";
					mes "with some Stones.^000000";
					next;
					break;
				}
				mes "^3355FFNow you need to arrange";
				mes "the enchanted Gemstones";
				mes "accordingly. You can identify";
				mes "their Magic properties by";
				mes "their casting effect.^000000";
				next;
				while(1) {
					if (.@roof0 > 7) {
						break;
					}
					else {
						switch(rand(1,3)) {
						case 1:
							specialeffect EF_BEGINSPELL2;
							mes "^3355FFThe Gemstones must";
							mes "be arranged in the correct";
							mes "order according to their";
							mes "magic properties and power.^000000";
							next;
							switch(select("Red Gemstone:Yellow Gemstone:Blue Gemstone")) {
							case 1:
								mes "^3355FFYou placed the Red Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							case 2:
								mes "^3355FFYou placed the Yellow Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							case 3:
								mes "^3355FFYou placed the Blue Gemstone.^000000";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							}
							break;
						case 2:
							specialeffect EF_VOLCANO;
							mes "^3355FFThe Gemstones must";
							mes "be arranged in the correct";
							mes "order according to their";
							mes "magic properties and power.^000000";
							next;
							switch(select("Red Gemstone:Yellow Gemstone:Blue Gemstone")) {
							case 1:
								mes "^3355FFYou placed the Red Gemstone.^000000";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 2:
								mes "^3355FFYou placed the Yellow Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							case 3:
								mes "^3355FFYou placed the Blue Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							}
							break;
						case 3:
							specialeffect EF_BEGINSPELL4;
							mes "^3355FFThe Gemstones must";
							mes "be arranged in the correct";
							mes "order according to their";
							mes "magic properties and power.^000000";
							next;
							switch(select("Red Gemstone:Yellow Gemstone:Blue Gemstone")) {
							case 1:
								mes "^3355FFYou placed the Red Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							case 2:
								mes "^3355FFYou placed the Yellow Gemstone.^000000";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 3:
								mes "^3355FFYou placed the Blue Gemstone.";
								mes "However, the Guardian Stone";
								mes "Repair System failed because";
								mes "of a magic power conflict.^000000";
								close;
							}
						}
					}
				}
				if (.@nice > 90) {
					if ($agit_sc01[1] == 0) {
						mes "^3355FFThe Guardian Stone";
						mes "Repair System has";
						mes "successfully completed.^000000";
						close;
					}
					else {
						if (agitcheck2() == 0) {
							mes "^3355FFIt is impossible to";
							mes "rebuild the Guardian";
							mes "Stone because the";
							mes "Emperium is not present.^000000";
							close;
						}
						else {
							mes "^3355FFThe Gemstones have been";
							mes "arranged, and the Guardian";
							mes "Stone is successfully repaired.^000000";
							delitem 984,1; //Oridecon
							delitem 985,1; //Elunium
							delitem 7049,30; //Stone
							delitem 717,5; //Blue_Gemstone
							delitem 715,5; //Yellow_Gemstone
							delitem 716,5; //Red_Gemstone
							close2;
							donpcevent "#sch01_df02::OnEnable";
							specialeffect EF_ICECRASH;
							disablenpc "2nd Guardian Stone#sch01";
							setarray $agit_sc01[1],0;
							set .@df_all,$agit_sc01[0]+$agit_sc01[1];
							if (.@df_all == 0) {
								mapannounce "schg_cas01","Both Guardian Stones have been erected, bolstering this stronghold's defenses!",bc_map,"0x00ff00";
								donpcevent "#sch01_RL00::OnEnable";
							}
							else {
								mapannounce "schg_cas01","The 2nd Guardian Stone has been repaired successfully.",bc_map,"0x00ff00";
							}
							if ($agit_sc01[5] == 1) {
								donpcevent "#sch01_gard02::OnEnable";
							}
							end;
						}
					}
				}
				else {
					mes "^3355FFAfter all of that work...";
					mes "It looks like you failed";
					mes "to fix the Guardian Stone,";
					mes "and lost some materials.^000000";
					delitem 7049,10; //Stone
					delitem 717,2; //Blue_Gemstone
					delitem 715,2; //Yellow_Gemstone
					delitem 716,2; //Red_Gemstone
					close;
				}
			}
			else {
				mes "^3355FFYou don't have enough";
				mes "materials to repair";
				mes "the Guardian Stone.^000000";
				close;
			}
		}
	}
	end;

OnInit:
	disablenpc "2nd Guardian Stone#sch01";
	end;

OnEnable:
	enablenpc "2nd Guardian Stone#sch01";
	specialeffect EF_MAPPILLAR2;
	end;

OnDisable:
	disablenpc "2nd Guardian Stone#sch01";
	end;
}

// Barrier Summoners
schg_cas01,2,1,0	script	#sch01_RL00	-1,{
OnEnable:
	setcell "schg_cas01",114,48,126,48,cell_walkable,0;
	setcell "schg_cas01",114,48,126,48,cell_shootable,0;
	guardian "schg_cas01",115,49," ",1905,"#sch01_RL00::OnBarrierDestroyed"; //24;
	guardian "schg_cas01",117,49," ",1905,"#sch01_RL00::OnBarrierDestroyed"; //25;
	guardian "schg_cas01",119,49," ",1905,"#sch01_RL00::OnBarrierDestroyed"; //26;
	guardian "schg_cas01",121,49," ",1905,"#sch01_RL00::OnBarrierDestroyed"; //27;
	guardian "schg_cas01",123,49," ",1905,"#sch01_RL00::OnBarrierDestroyed"; //28;
	guardian "schg_cas01",125,49," ",1905,"#sch01_RL00::OnBarrierDestroyed"; //29;
	end;

OnDisable:
	setcell "schg_cas01",114,48,126,48,cell_walkable,1;
	setcell "schg_cas01",114,48,126,48,cell_shootable,1;
	killmonster "schg_cas01","#sch01_RL00::OnBarrierDestroyed";
	end;

OnBarrierDestroyed:
	end;
}

schg_cas01,2,2,0	script	#sch01_RL01	-1,{
OnEnable:
	set .MyMobCount,6;
	setcell "schg_cas01",114,51,126,51,cell_walkable,0;
	guardian "schg_cas01",115,50," ",1905,"#sch01_RL01::OnBarrierDestroyed"; //30;
	guardian "schg_cas01",117,50," ",1905,"#sch01_RL01::OnBarrierDestroyed"; //31;
	guardian "schg_cas01",119,50," ",1905,"#sch01_RL01::OnBarrierDestroyed"; //32;
	guardian "schg_cas01",121,50," ",1905,"#sch01_RL01::OnBarrierDestroyed"; //33;
	guardian "schg_cas01",123,50," ",1905,"#sch01_RL01::OnBarrierDestroyed"; //34;
	guardian "schg_cas01",125,50," ",1905,"#sch01_RL01::OnBarrierDestroyed"; //35;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_sc01[2],1;
		mapannounce "schg_cas01","The 1st Fortress Gate is destroyed.",bc_map,"0x00ff00";
		setcell "schg_cas01",114,51,126,51,cell_walkable,1;
	}
	end;

OnDisable:
	setcell "schg_cas01",114,51,126,51,cell_walkable,1;
	killmonster "schg_cas01","#sch01_RL01::OnBarrierDestroyed";
	end;
}

schg_cas01,2,3,0	script	#sch01_RL02	-1,{
OnEnable:
	set .MyMobCount,6;
	setcell "schg_cas01",114,154,126,154,cell_walkable,0;
	guardian "schg_cas01",115,153," ",1905,"#sch01_RL02::OnBarrierDestroyed"; //36;
	guardian "schg_cas01",117,153," ",1905,"#sch01_RL02::OnBarrierDestroyed"; //37;
	guardian "schg_cas01",119,153," ",1905,"#sch01_RL02::OnBarrierDestroyed"; //38;
	guardian "schg_cas01",121,153," ",1905,"#sch01_RL02::OnBarrierDestroyed"; //39;
	guardian "schg_cas01",123,153," ",1905,"#sch01_RL02::OnBarrierDestroyed"; //40;
	guardian "schg_cas01",125,153," ",1905,"#sch01_RL02::OnBarrierDestroyed"; //41;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_sc01[3],1;
		mapannounce "schg_cas01","The 2nd Fortress Gate is destroyed.",bc_map,"0x00ff00";
		setcell "schg_cas01",114,154,126,154,cell_walkable,1;
	}
	end;

OnDisable:
	setcell "schg_cas01",114,154,126,154,cell_walkable,1;
	killmonster "schg_cas01","#sch01_RL02::OnBarrierDestroyed";
	end;
}

schg_cas01,2,4,0	script	#sch01_RL03	-1,{
OnEnable:
	set .MyMobCount,4;
	setcell "schg_cas01",116,241,126,241,cell_walkable,0;
	guardian "schg_cas01",116,240," ",1905,"#sch01_RL03::OnBarrierDestroyed"; //42;
	guardian "schg_cas01",118,240," ",1905,"#sch01_RL03::OnBarrierDestroyed"; //43;
	guardian "schg_cas01",120,240," ",1905,"#sch01_RL03::OnBarrierDestroyed"; //44;
	guardian "schg_cas01",122,240," ",1905,"#sch01_RL03::OnBarrierDestroyed"; //45;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_sc01[4],1;
		mapannounce "schg_cas01","The 3rd Fortress Gate is destroyed!",bc_map,"0x00ff00";
		setcell "schg_cas01",116,241,126,241,cell_walkable,1;
	}
	end;

OnDisable:
	setcell "schg_cas01",116,241,126,241,cell_walkable,1;
	killmonster "schg_cas01","#sch01_RL03::OnBarrierDestroyed";
	end;
}

schg_cas01,124,52,0	script	Control Device01#sch01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_sc01[2] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "^4D4DFF10 Steel^000000,";
				mes "^4D4DFF30 Trunks^000000,";
				mes "^4D4DFF5 Oridecon^000000, and";
				mes "^4D4DFF10 Emveretarcon^000000.";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#sch01_RL01::OnEnable";
							disablenpc "Control Device01#sch01";
							mapannounce "schg_cas01","The 1st Fortress Gate has been reconstructed!",bc_map,"0x00ff00";
							setarray $agit_sc01[2],0;
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "Control Device01#sch01";
	end;

OnEnable:
	enablenpc "Control Device01#sch01";
	end;

OnDisable:
	disablenpc "Control Device01#sch01";
	end;
}

schg_cas01,128,157,0	script	Control Device02#sch01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_sc01[3] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "^4D4DFF10 Steel^000000,";
				mes "^4D4DFF30 Trunks^000000,";
				mes "^4D4DFF5 Oridecon^000000, and";
				mes "^4D4DFF10 Emveretarcon^000000.";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#sch01_RL02::OnEnable";
							disablenpc "Control Device02#sch01";
							mapannounce "schg_cas01","The 2nd Fortress Gate has been reconstructed!",bc_map,"0x00ff00";
							setarray $agit_sc01[3],0; //Global Variable
							setarray $agit_sc01[2],2; //Global Variable
							donpcevent "Control Device01#sch01::OnEnable";
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "Control Device02#sch01";
	end;

OnEnable:
	enablenpc "Control Device02#sch01";
	end;

OnDisable:
	disablenpc "Control Device02#sch01";
	end;
}

schg_cas01,109,247,0	script	Control Device03#sch01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_sc01[4] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "^4D4DFF10 Steel^000000,";
				mes "^4D4DFF30 Trunks^000000,";
				mes "^4D4DFF5 Oridecon^000000, and";
				mes "^4D4DFF10 Emveretarcon^000000.";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("Trunk:Steel:Emveretarcon:Oridecon")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#sch01_RL03::OnEnable";
							disablenpc "Control Device03#sch01";
							mapannounce "schg_cas01","The 3rd Fortress Gate has been reconstructed!",bc_map,"0x00ff00";
							setarray $agit_sc01[4],0;
							setarray $agit_sc01[3],2;
							donpcevent "Control Device02#sch01::OnEnable";
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "Control Device03#sch01";
	end;

OnEnable:
	enablenpc "Control Device03#sch01";
	end;

OnDisable:
	disablenpc "Control Device03#sch01";
	end;
}

// Link Flags
schg_cas01,106,302,0	script	LF-01#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("First Gate House:Second Gate House:Cancel")) {
		case 1:
			warp "schg_cas01",19,26;
			end;
		case 2:
			warp "schg_cas01",219,90;
			end;
		case 3:
			close;
		}
	}
	end;
}

schg_cas01,109,302,0	script	LF-02#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("Defense Area 1-1:Defense Area 1-2:Cancel")) {
		case 1:
			warp "schg_cas01",89,43;
			end;
		case 2:
			warp "schg_cas01",141,45;
			end;
		case 3:
			close;
		}
	}
	end;
}

schg_cas01,112,302,0	script	LF-03#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("Defense Area 2-1:Defense Area 2-2:Cancel")) {
		case 1:
			warp "schg_cas01",137,54;
			end;
		case 2:
			warp "schg_cas01",102,54;
			end;
		case 3:
			close;
		}
	}
	end;
}

schg_cas01,115,302,0	script	LF-04#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("Defense Area 2-3:Defense Area 2-4:Cancel")) {
		case 1:
			warp "schg_cas01",94,147;
			end;
		case 2:
			warp "schg_cas01",163,140;
			end;
		case 3:
			close;
		}
	}
	end;
}

schg_cas01,118,302,0	script	LF-05#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("Defense Area 2-3:Defense Area 2-4:Cancel")) {
		case 1:
			warp "schg_cas01",87,220;
			end;
		case 2:
			warp "schg_cas01",151,220;
			end;
		case 3:
			close;
		}
	}
	end;
}

schg_cas01,121,302,0	script	LF-06#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("Defense Area 3-1:Defense Area 3-2:Cancel")) {
		case 1:
			warp "schg_cas01",100,242;
			end;
		case 2:
			warp "schg_cas01",136,242;
			end;
		case 3:
			close;
		}
	}
	end;
}

schg_cas01,124,302,0	script	LF-07#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("Center 1 Area:Center 2 Area:Cancel")) {
		case 1:
			warp "schg_cas01",120,168;
			end;
		case 2:
			warp "schg_cas01",119,211;
			end;
		case 3:
			close;
		}
	}
	end;
}

schg_cas01,127,302,0	script	LF-08#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("Area 1-1:Area 2-1:Area 3-1:Cancel")) {
		case 1:
			warp "schg_cas01",89,43;
			end;
		case 2:
			warp "schg_cas01",94,147;
			end;
		case 3:
			warp "schg_cas01",100,242;
			end;
		case 4:
			close;
		}
	}
	end;
}

schg_cas01,130,302,0	script	LF-09#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Please";
		mes "choose a destination";
		mes "within the stronghold.^000000";
		switch(select("Area 1-2:Area 2-3:Area 3-2:Cancel")) {
		case 1:
			warp "schg_cas01",141,45;
			end;
		case 2:
			warp "schg_cas01",163,140;
			end;
		case 3:
			warp "schg_cas01",136,243;
			end;
		case 4:
			close;
		}
	}
	end;
}

schg_cas01,133,302,0	script	LF-10#schg_cas01	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Would";
		mes "you like to teleport to the";
		mes "Convenience Facility for";
		mes "guild members?^000000";
		switch(select("Go to Convenience Facility:Cancel")) {
		case 1:
			warp "schg_cas01",275,244;
			end;
		case 2:
			close;
		}
	}
	end;
}

schg_cas01,17,45,0	script	Himinn#LF_sc01_1::LF_sc01_1	111,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Would";
		mes "you like to teleport to";
		mes "the Emperium Center?^000000";
		switch(select("Teleport:Cancel")) {
		case 1:
			warp "schg_cas01",120,290;
			end;
		case 2:
			close;
		}
	}
	end;
}

schg_cas01,207,95,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_2	111

schg_cas01,111,46,4	script	Himinn#LF_sc01_3::LF_sc01_2	722,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "^3355FFThis is the Stronghold";
		mes "Teleport Service. Would";
		mes "you like to teleport to";
		mes "the Emperium Center?^000000";
		switch(select("Teleport:Cancel")) {
		case 1:
			warp "schg_cas01",120,290;
			end;
		case 2:
			close;
		}
	}
	end;

OnRecvCastleSc01:
	FlagEmblem GetCastleData("schg_cas01",1);
	end;
}

schg_cas01,129,46,4	duplicate(LF_sc01_2)	Himinn#LF_sc01_4	722
schg_cas01,99,77,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_5	111
schg_cas01,140,77,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_6	111
schg_cas01,109,150,4	duplicate(LF_sc01_2)	Himinn#LF_sc01_7	722
schg_cas01,130,150,4	duplicate(LF_sc01_2)	Himinn#LF_sc01_8	722
schg_cas01,112,212,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_9	111
schg_cas01,127,212,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_10	111
schg_cas01,113,238,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_11	111
schg_cas01,126,238,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_12	111
schg_cas01,95,247,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_13	111
schg_cas01,144,247,0	duplicate(LF_sc01_1)	Himinn#LF_sc01_14	111

// Guild Manager
schg_cas01,247,305,3	script	Steward#sch01	55,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (.@GID == 0) {
		mes "[ Steward ]";
		mes "I await for the master";
		mes "whom destiny will choose";
		mes "for me. Do you think you";
		mes "have to courage and strength";
		mes "to conquer this stronghold?";
		close;
	}
	if (getcharid(2) != .@GID || strcharinfo(0) != getguildmaster(.@GID)) {
		mes "[ Steward ]";
		mes "Hmpf. Your threats don't";
		mes "scare me! Guardians, drive";
		mes "this infidel away from here!";
		mes "I will always be loyal to the";
		mes "master of this stronghold,";
		mes "the one and only ^FF0000" + getguildmaster(.@GID) + "^000000.";
		close;
	}
	mes "[ Steward ]";
	mes "Ah, Master ^FF0000" + getguildmaster(.@GID) + "^000000...";
	mes "How shall I serve you today?";
	mes "Was there an aspect of this";
	mes "stronghold's maintenance";
	mes "you wanted to discuss?";
	next;
	switch(select("Stronghold Briefing:Invest in Commercial Growth:Invest in Defense growth:Hire/Fire Storage Staff:Go to Master's room")) {
	case 1:
		mes "[ Steward ]";
		mes "The Commercial Growth";
		mes "Level of the stronghold is ^0000ff" + GetCastleData("schg_cas01",2) + ".";
		if (GetCastleData("schg_cas01",4) > 0) {
			mes "Last time, you invested in";
			mes "Commercial Growth " + GetCastleData("schg_cas01",4) + ".";
		}
		next;
		mes "[ Steward ]";
		mes "Our stronghold's";
		mes "safeguard level is " + GetCastleData("schg_cas01",3) + ".";
		if (GetCastleData("schg_cas01",5) > 0) {
			mes "Last time, you invested";
			mes "in defense " + GetCastleData("schg_cas01",5) + " times.";
		}
		mes " ";
		mes "That is all, master.";
		close;
	case 2:
		set .@Economy,GetCastleData("schg_cas01",2);
		if (.@Economy < 6) { set .@eco_invest,5000; }
		else if ((.@Economy >= 6) && (.@Economy <= 10)) { set .@eco_invest,10000; }
		else if ((.@Economy >= 11) && (.@Economy <= 15)) { set .@eco_invest,20000; }
		else if ((.@Economy >= 16) && (.@Economy <= 20)) { set .@eco_invest,35000; }
		else if ((.@Economy >= 21) && (.@Economy <= 25)) { set .@eco_invest,55000; }
		else if ((.@Economy >= 26) && (.@Economy <= 30)) { set .@eco_invest,80000; }
		else if ((.@Economy >= 31) && (.@Economy <= 35)) { set .@eco_invest,110000; }
		else if ((.@Economy >= 36) && (.@Economy <= 40)) { set .@eco_invest,145000; }
		else if ((.@Economy >= 41) && (.@Economy <= 45)) { set .@eco_invest,185000; }
		else if ((.@Economy >= 46) && (.@Economy <= 50)) { set .@eco_invest,230000; }
		else if ((.@Economy >= 51) && (.@Economy <= 55)) { set .@eco_invest,280000; }
		else if ((.@Economy >= 56) && (.@Economy <= 60)) { set .@eco_invest,335000; }
		else if ((.@Economy >= 61) && (.@Economy <= 65)) { set .@eco_invest,395000; }
		else if ((.@Economy >= 66) && (.@Economy <= 70)) { set .@eco_invest,460000; }
		else if ((.@Economy >= 71) && (.@Economy <= 75)) { set .@eco_invest,530000; }
		else if ((.@Economy >= 76) && (.@Economy <= 80)) { set .@eco_invest,605000; }
		else if ((.@Economy >= 81) && (.@Economy <= 85)) { set .@eco_invest,685000; }
		else if ((.@Economy >= 86) && (.@Economy <= 90)) { set .@eco_invest,770000; }
		else if ((.@Economy >= 91) && (.@Economy <= 95)) { set .@eco_invest,860000; }
		else if ((.@Economy >= 96) && (.@Economy <= 100)) { set .@eco_invest,955000; }
		//Quadruple the cost of investing if you've already invested once.
		if (GetCastleData("schg_cas01",4)) {
			set .@eco_invest,.@eco_invest*4;
		}
		mes "[ Steward ]";
		mes "Raising the stronghold's";
		mes "commercial growth will";
		mes "increase the quantity of";
		mes "goods produced for the guild.";
		mes "Investing in commercial growth";
		mes "will help the guild's future.";
		next;
		mes "[ Steward ]";
		mes "You can make one investment";
		mes "each day, but if you can make";
		mes "two investments if you pay";
		mes "more zeny: this will speed";
		mes "up commercial development,";
		mes "but can be quite expensive.";
		next;
		if (.@Economy == 100) {
			mes "[ Steward ]";
			mes "However, our stronghold's";
			mes "commerical growth level is";
			mes "at 100%. It's not possible to";
			mes "develop commercial growth";
			mes "any further than that.";
			close;
		}
		if (GetCastleData("schg_cas01",4) == 2) {
			mes "[ Steward ]";
			mes "You've already made two";
			mes "investments today, so you'll";
			mes "have to wait until tomorrow";
			mes "to make another investment.";
			close;
		}
		if (GetCastleData("schg_cas01",4) == 0) {
			mes "[ Steward ]";
			mes "You must pay ^FF0000" + .@eco_invest + "^000000 zeny";
			mes "to make an investment";
			mes "Will you invest in this";
			mes "stronghold's commerical";
			mes "development now?";
		}
		else {
			mes "[ Steward ]";
			mes "You must pay ^FF0000" + .@eco_invest + "^000000";
			mes "more zeny to make a second";
			mes "investment today. Will you";
			mes "invest one more time?";
		}
		next;
		switch(select("Invest in Commercial Growth:Cancel")) {
		case 1:
			if (Zeny < .@eco_invest) {
				mes "[ Steward ]";
				mes "I'm sorry, Master, but";
				mes "you do not have enough";
				mes "zeny to make an investment";
				mes "for the guild today.";
				close;
			}
			set zeny,zeny-.@eco_invest;
			SetCastleData "schg_cas01",4,GetCastleData("schg_cas01",4)+1;
			mes "[ Steward ]";
			mes "A wise use of the guild's";
			mes "funds, Master. We can expect";
			mes "to see the results of this";
			mes "investment by tomorrow.";
			close;
		case 2:
			mes "[ Steward ]";
			mes "As you command, Master.";
			close;
		}
	case 3:
		set .@Defence,GetCastleData("schg_cas01",3);
		if (.@Defence < 6) { set .@def_invest,10000; }
		else if ((.@Defence >= 6) && (.@Defence <= 10)) { set .@def_invest,20000; }
		else if ((.@Defence >= 11) && (.@Defence <= 15)) { set .@def_invest,40000; }
		else if ((.@Defence >= 16) && (.@Defence <= 20)) { set .@def_invest,70000; }
		else if ((.@Defence >= 21) && (.@Defence <= 25)) { set .@def_invest,110000; }
		else if ((.@Defence >= 26) && (.@Defence <= 30)) { set .@def_invest,160000; }
		else if ((.@Defence >= 31) && (.@Defence <= 35)) { set .@def_invest,220000; }
		else if ((.@Defence >= 36) && (.@Defence <= 40)) { set .@def_invest,290000; }
		else if ((.@Defence >= 41) && (.@Defence <= 45)) { set .@def_invest,370000; }
		else if ((.@Defence >= 46) && (.@Defence <= 50)) { set .@def_invest,460000; }
		else if ((.@Defence >= 51) && (.@Defence <= 55)) { set .@def_invest,560000; }
		else if ((.@Defence >= 56) && (.@Defence <= 60)) { set .@def_invest,670000; }
		else if ((.@Defence >= 61) && (.@Defence <= 65)) { set .@def_invest,790000; }
		else if ((.@Defence >= 66) && (.@Defence <= 70)) { set .@def_invest,920000; }
		else if ((.@Defence >= 71) && (.@Defence <= 75)) { set .@def_invest,1060000; }
		else if ((.@Defence >= 76) && (.@Defence <= 80)) { set .@def_invest,1210000; }
		else if ((.@Defence >= 81) && (.@Defence <= 85)) { set .@def_invest,1370000; }
		else if ((.@Defence >= 86) && (.@Defence <= 90)) { set .@def_invest,1540000; }
		else if ((.@Defence >= 91) && (.@Defence <= 95)) { set .@def_invest,1720000; }
		else if ((.@Defence >= 96) && (.@Defence <= 100)) { set .@def_invest,1910000; }
		//Quadruple the cost of investing if you've already invested once.
		if (GetCastleData("schg_cas01",5)) {
			set .@def_invest,.@def_invest*4;
		}
		mes "[ Steward ]";
		mes "Investing in our stronghold's";
		mes "defense will enhance the";
		mes "durability of our Guardians";
		mes "and the Emperium. We'll need";
		mes "every advantage to protect";
		mes "ourselves from our enemies.";
		next;
		mes "[ Steward ]";
		mes "You can invest in defense";
		mes "once per day, but if you pay";
		mes "more zeny, you can invest";
		mes "a maximum of two times daily.";
		next;
		mes "[ Steward ]";
		if (GetCastleData("schg_cas01",3) == 100) {
			mes "The Defense Level of this";
			mes "stronghold is 100%, and";
			mes "cannot be increased further.";
			close;
		}
		if (GetCastleData("schg_cas01",5) == 2) {
			mes "Master, you've already";
			mes "invested in Defense twice";
			mes "today. You'll need to wait";
			mes "until tomorrow if you really";
			mes "want to increase our defenses.";
			close;
		}
		if (GetCastleData("schg_cas01",5) == 0) {
			mes "We need ^FF0000" + .@def_invest + "^000000";
			mes "zeny to invest in our";
			mes "stronghold's defenses.";
			mes "Will you invest now?";
		}
		else {
			mes "We need ^FF0000" + .@def_invest + "^000000";
			mes "zeny to invest in our";
			mes "stronghold's defenses";
			mes "a second time today.";
			mes "Will you invest now?";
		}
		next;
		switch(select("Invest in Defense:Cancel")) {
		case 1:
			if (Zeny < .@def_invest) {
				mes "[ Steward ]";
				mes "I'm sorry, Master, but";
				mes "you do not have enough";
				mes "zeny to make an investment";
				mes "for the guild today.";
				close;
			}
			set zeny,zeny-.@def_invest;
			SetCastleData "schg_cas01",5,GetCastleData("schg_cas01",5)+1;
			mes "[ Steward ]";
			mes "A wise use of the guild's";
			mes "funds, Master. Increasing";
			mes "the frequency of treasure";
			mes "procured by the guild will";
			mes "definitely help us all.";
			close;
		case 2:
			mes "[ Steward ]";
			mes "As you command, Master.";
			close;
		}
	case 4:
		if (GetCastleData("schg_cas01",9) == 1) {
			mes "[ Steward ]";
			mes "Do you wish to dismiss";
			mes "the Kafra Employee that";
			mes "we've hired for the guild?";
			next;
			switch(select("Dismiss:Cancel")) {
			case 1:
				cutin "kafra_01",2;
				mes "[ Hired Kafra Employee ]";
				mes "Master, please reconsider!";
				mes "I've been working very hard";
				mes "for the success of the guild!";
				mes "I'll try harder to serve the";
				mes "guild members of this";
				mes "stronghold, I promise!";
				next;
				switch(select("Dismiss:Cancel")) {
				case 1:
					mes "[ Hired Kafra Employee ]";
					mes "Why?! What have I done";
					mes "to deserve this? Waaah~!";
					next;
					cutin "kafra_01",255;
					break;
				case 2:
					mes "[ Hired Kafra Employee ]";
					mes "Thank you, Master!";
					mes "I'll obey your every";
					mes "command as best I can!";
					mes "You won't regret this!";
					close;
				}
				break;
			case 2:
				mes "[ Steward ]";
				mes "She works very hard,";
				mes "in my opinion. It was in";
				mes "all of our best interests to";
				mes "allow her to stay with us.";
				close;
			}
			disablenpc "Kafra Employee#sch01";
			SetCastleData "schg_cas01",9,0;
			mes "[ Steward ]";
			mes "That Kafra Employee";
			mes "has been dismissed.";
			mes "Were really dissatisfied";
			mes "by the quality of her service?";
			close;
		}
		else {
			mes "[ Steward ]";
			mes "Will you hire a";
			mes "Kafra Employee to serve";
			mes "our stronghold? You must";
			mes "pay ^FF000010,000 zeny^000000 to hire one.";
			next;
			switch(select("Hire:Cancel")) {
			case 1:
				if (getgdskilllv(.@GID,10001) == 0) {
					mes "[ Steward ]";
					mes "Master, we cannot hire a";
					mes "Kafra Employee because";
					mes "you have not yet attained";
					mes "the ^FF0000Contract with Kafra^000000";
					mes "guild skill.";
					close;
				}
				if (Zeny < 10000) {
					mes "[ Steward ]";
					mes "Master, we cannot hire a";
					mes "Kafra Employee because";
					mes "we do not have enough";
					mes "funds to pay the contract fee.";
					close;
				}
				set zeny,zeny-10000;
				enablenpc "Kafra Employee#sch01";
				SetCastleData "schg_cas01",9,1;
				mes "[ Steward ]";
				mes "Very well. We have formed";
				mes "a contract with the Kafra";
				mes "Head Office, and hired a";
				mes "Kafra Employee for our";
				mes "stronghold. Here she is~";
				next;
				cutin "kafra_01",2;
				mes "[ Hired Kafra Employee ]";
				mes "How do you do? I've";
				mes "been dispatched by the";
				mes "Kafra Head Office to";
				mes "serve your guild's needs.";
				mes "I'll do my best to follow";
				mes "your every command, Master.";
				next;
				cutin "kafra_01",255;
				mes "[ Steward ]";
				mes "Our contract will expire";
				mes "after one month, so we must";
				mes "pay additional fees to keep";
				mes "this Kafra Employee in";
				mes "the service of our guild.";
				close;
			case 2:
				mes "[ Steward ]";
				mes "As you command, Master.";
				mes "However, I suggest hiring";
				mes "a Kafra Employee as soon";
				mes "as possible since our guild";
				mes "would greatly benefit from";
				mes "the convenient Kafra services.";
				close;
			}
		}
	case 5:
		mes "[ Steward ]";
		mes "Do you wish to enter the";
		mes "Guild Treasure Room?";
		mes "Only you, the Guild Master,";
		mes "are permitted to enter.";
		next;
		mes "[ Steward ]";
		mes "Please remember to open";
		mes "the Treasure Boxes at the";
		mes "proper time. Otherwise, the";
		mes "treasure may disappear if";
		mes "something unexpected happens.";
		next;
		switch(select("Go to Treasure Room:Cancel")) {
		case 1:
			mes "[ Steward ]";
			mes "Allow me to guide you";
			mes "on the secret path to";
			mes "the Treasure Room.";
			mes "Press the secret switch";
			mes "when you wish to return here.";
			close2;
			warp "schg_cas01",381,381;
			end;
		case 2:
			mes "[ Steward ]";
			mes "Items in the Treasure Room";
			mes "are produced once each day.";
			mes "Therefore, you must obtain";
			mes "the treasure items everyday.";
			mes "For the sake of the guild,";
			mes "prioritize treasure harvesting!";
			close;
		}
	}

Onstop:
	stopnpctimer;
	end;

OnStartArena:
	set .@GID,getcharid(2);
	// Lower castle Economy
	set .@Economy,GetCastleData("schg_cas01",2) - 5;
	if (.@Economy < 0) set .@Economy, 0;
	SetCastleData "schg_cas01", 2, .@Economy;
	// Lower Castle Defence
	set .@Defence,GetCastleData("schg_cas01",3) - 5;
	if (.@Defence < 0) set .@Defence, 0;
	SetCastleData "schg_cas01", 3, .@Defence;
	// Set new owner
	SetCastleData "schg_cas01",1, .@GID;
	// Clear castle's data.
	for( set .@i, 4; .@i <= 9; set .@i, .@i+1 )
		SetCastleData "schg_cas01", .@i, 0;
	// Disable Kafra
	disablenpc "Kafra Employee#sch01";

	set .msg,2;
	if (.msg == 1) {
		announce "Fortress [" + GetCastleName("schg_cas01") + "]'s 'Nithafjoll' was captured by [" + getguildname(.@gid) + "] Guild.",bc_all;
		donpcevent "Manager#sch01_02::Onstart";
	}
	else if (.msg == 2) {
		announce "The [" + getguildname(.@gid) + "] conquered the [Nithafjoll 1] stronghold of "+GetCastleName("schg_cas01"),bc_all;
		mapannounce "schg_cas01","The emperium has been shattered!",bc_map,"0x00FF00";
		if (agitcheck2()) {
			donpcevent "Manager#sch01_02::Onreset";
			initnpctimer;
		}
		else {
			donpcevent "Manager#sch01_02::Onreset";
			stopnpctimer;
		}
	}
	else if (.msg == 0) {
		announce "Fortress [" + GetCastleName("schg_cas01") + "]'s 'Nithafjoll' was captured by [" + getguildname(.@gid) + "] Guild.",bc_all;
		donpcevent "Manager#sch01_02::Onreset";
		stopnpctimer;
		end;
	}
	MapRespawnGuildID "schg_cas01",GetCastleData("schg_cas01",1),2;
	GetCastleData "schg_cas01",0,"::OnRecvCastlesc01";
	end;

OnTimer10000:
	donpcevent "Manager#sch01_02::Onchange";
	mapannounce "schg_cas01","Rebuild this stonghold's Guardian Stones and Fortress Gates to secure your guild's new aquisition!",bc_map,"0x00FF00";
	end;
}

// Guild Kafra
schg_cas01,300,287,5	script	Kafra Employee#sch01	117,{
	cutin "kafra_01",2;
	set .@GID, GetCastleData("schg_cas01",1);
	if (getcharid(2) == .@GID && getgdskilllv(.@GID,10001)) {
		mes "[Kafra Employee]";
		mes "Welcome, proud member";
		mes "of the ^FF0000" + GetGuildName(.@GID) + "^000000 Guild!";
		mes "The Kafra Corporation is ready";
		mes "to assist you wherever you go!";
		next;
		switch(select("Use Storage:Use Warp Service:Rent Pushcart:Cancel")) {
		case 1:
			if (basicskillcheck() && getskilllv("NV_BASIC") < 6) {
				mes "[Kafra Employee]";
				mes "I'm so sorry, but you must";
				mes "have at least Novice Skill";
				mes "Lv.6 to use the Storage.";
			}
			else {
				openstorage;
			}
			break;
		case 2:
			mes "[Kafra Employee]";
			mes "Please tell me your";
			mes "Warp destination.";
			next;
			switch(select("Juno -> 200 z:Cancel")) {
			case 1:
				if (Zeny < 200) {
					mes "[Kafra Employee]";
					mes "I'm sorry, but you don't";
					mes "have enough zeny to pay";
					mes "the warp fee. Would you";
					mes "please check your funds again?";
					close2;
					cutin "kafra_01",255;
					end;
				}
				set zeny,zeny-200;
				warp "yuno",158,125;
				end;
			case 2:
				cutin "kafra_01",255;
			}
			break;
		case 3:
			if (BaseClass != Job_Merchant) {
				mes "[Kafra Employee]";
				mes "I'm sorry, but the Pushcart";
				mes "rental service can only be";
				mes "used by Merchant, Blacksmith,";
				mes "and Alchemist class characters.";
			}
			else if (checkcart() == 1) {
				mes "[Kafra Employee]";
				mes "Hm? You've already";
				mes "rented a Pushcart.";
			}
			else {
				mes "[Kafra Employee]";
				mes "The Pushcart rental fee";
				mes "is 800 zeny. Would you";
				mes "like to rent a Pushcart?";
				next;
				switch(select("Rent Pushcart:Cancel")) {
				case 1:
					if (Zeny < 800) {
						mes "[Kafra Employee]";
						mes "I'm sorry, but you don't";
						mes "have enough zeny to rent";
						mes "one of our Pushcarts.";
						close2;
						cutin "kafra_01",255;
						end;
					}
					set zeny,zeny-800;
					setcart;
					break;
				case 2:
					break;
				}
			}
			break;
		case 4:
			mes "[Kafra Employee]";
			mes "Thank you for using the";
			mes "Kafra Service. Wherever";
			mes "you go, Kafra will be";
			mes "there to support you!";
			close2;
			cutin "kafra_01",255;
			end;
		}
		close2;
		cutin "kafra_01",255;
		end;
	}
	else {
		mes "[Kafra Employee]";
		mes "I'm sorry, but I've been";
		mes "exclusively contracted";
		mes "to the members of the";
		mes "^FF0000" + GetGuildName(.@GID) + "^000000 Guild.";
		mes "You'll have to ask another";
		mes "Kafra Employee to help you...";
		close2;
		cutin "kafra_01",255;
		end;
	}

OnRecvCastlesc01:
	if (GetCastleData("schg_cas01",1) == 0) {
		monster "schg_cas01",0,0,"Evil Druid",1117,10;
		monster "schg_cas01",0,0,"Khalitzburg",1132,4;
		monster "schg_cas01",0,0,"Abysmal Knight",1219,3;
		monster "schg_cas01",0,0,"Executioner",1205,1;
		monster "schg_cas01",0,0,"Penomena",1216,10;
		monster "schg_cas01",0,0,"Alarm",1193,18;
		monster "schg_cas01",0,0,"Clock",1269,9;
		monster "schg_cas01",0,0,"Raydric Archer",1276,12;
		monster "schg_cas01",0,0,"Wanderer",1208,3;
		monster "schg_cas01",0,0,"Alice",1275,1;
		monster "schg_cas01",0,0,"Bloody Knight",1268,2;
		monster "schg_cas01",0,0,"Dark Lord",1272,2;
		monster "schg_cas01",0,0,"Tower Keeper",1270,4;
	}
	if (GetCastleData("schg_cas01",9) < 1) {
		disablenpc "Kafra Employee#sch01";
	}
	end;
}

schg_cas01,391,391,0	script	 #sch01_switch	111,{
	mes " ";
	mes "^3355FFWill you pull";
	mes "this small lever?^000000";
	next;
	switch(select("Pull Lever:Cancel")) {
	case 1:
		warp "schg_cas01",275,244;
		end;
	case 2:
		close;
	}
}

sch_gld,290,90,0	script	Himinn#flag_sc01_1::Sc01_Flag	722,{
	set .@GID, GetCastleData("schg_cas01",1);
	if (.@GID == 0) {
		mes "[ Schwaltzvalt Royal Edict ]";
		mes "The Holy Kingdom of";
		mes "Schwaltzvalt declares that";
		mes "one has yet to claim lordship";
		mes "over this stronghold. The one";
		mes "that breaks the Emperium will";
		mes "be recognized as its new owner.";
		close;
	}
	else {
		if (getcharid(2) == .@GID) {
			mes "[ Ringing Voice ]";
			mes "Courageous one,";
			mes "do you wish to return";
			mes "to your stronghold?";
			next;
			switch(select("Return to the Stronghold:Cancel")) {
			case 1:
				set .@GID, GetCastleData("schg_cas01",1);
				if (getcharid(2) == .@GID) {
					warp "schg_cas01",120,290;
					end;
				}
				close;
			case 2:
				close;
			}
		}
		mes "[ Schwaltzvalt Royal Edict ]";
		mes "The Holy Kingdom of";
		mes "Schwaltzvalt decrees that";
		mes "this stronghold is owned";
		mes "by the ^FF0000" + GetGuildName(.@GID) + "^000000 Guild.";
		next;
		mes "[ Schwaltzvalt Royal Edict ]";
		mes "^FF0000" + GetGuildMaster(.@GID) + "^000000 is";
		mes "Guild Master of ^FF0000" + GetGuildName(.@GID) + "^000000.";
		mes "Any that object must claim this";
		mes "stronghold through strength of";
		mes "steel and magic during the";
		mes "appointed Guild Siege times.";
		close;
	}

OnRecvCastlesc01:
	FlagEmblem GetCastleData("schg_cas01",1);
	end;
}

sch_gld,297,90,0	duplicate(Sc01_Flag)	Himinn#flag_sc01_2	722