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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
-- ========== GENERATED BY ClassDef Editor (Ctrl-Alt-F3) DO NOT EDIT MANUALLY! ==========

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "AnimParams",
	PlaceObj('PropertyDefBool', {
		'id', "UseWeapons",
		'name', "Use Weapons",
		'help', "Use weapon animations while executing this behavior.",
	}),
	PlaceObj('PropertyDefBool', {
		'id', "Running",
		'help', "Controls the use of running or walking animations while executing this behavior.",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetAnimParams",
		'code', function (self)
			if self.RestoreDefault then
				return {}
			else
				return {
					move_anim = not self.Running and "Walk" or "Run",
					weapon_anim_prefix = not self.UseWeapons and "civ_" or nil,
					idle_stance = self.IdleStance and self.IdleStance ~= "do not change" and self.IdleStance or nil, 
					idle_action = self.IdleAction and self.IdleAction ~= "do not change" and self.IdleAction or nil
				}
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "OnEditorSetProperty",
		'params', "prop_id, old_value, ged",
		'code', function (self, prop_id, old_value, ged)
			if prop_id == "IdleStance" then
				local actions = GetIdleAnimStanceActions(self.UseWeapons, self.IdleStance)
				if not table.find(actions, self.IdleAction) then
					self:SetProperty("IdleAction", actions[1])
				end
			end
		end,
	}),
	PlaceObj('PropertyDefCombo', {
		'id', "IdleStance",
		'name', "Idle Stance",
		'help', "What to do with the idle stance",
		'default', "do not change",
		'items', function (self) return GetIdleAnimStances(self.UseWeapons) end,
	}),
	PlaceObj('PropertyDefCombo', {
		'id', "IdleAction",
		'name', "Idle Action",
		'help', "What to do with the idle action",
		'default', "do not change",
		'items', function (self) return GetIdleAnimStanceActions(self.UseWeapons, self.IdleStance) end,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "RestoreDefault",
		'name', "Restore Default",
		'help', "Restore to default behavior",
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "BanterLine",
	PlaceObj('PropertyDefText', {
		'id', "Annotation",
		'name', "Annotation",
		'help', 'Extra context for voice actors, e.g. "angry", "sad", etc.',
		'translate', false,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "MultipleTexts",
	}),
	PlaceObj('PropertyDefCombo', {
		'id', "Character",
		'name', "Character",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return self.MultipleTexts end,
		'default', "any",
		'items', function (self) return GetTargetUnitCombo() end,
	}),
	PlaceObj('PropertyDefChoice', {
		'id', "AnimationStyle",
		'name', "Animation Style",
		'items', function (self) return GetIdleStyleCombo(g_Classes[self.Character] and g_Classes[self.Character].gender) end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "Text",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return self.MultipleTexts end,
		'wordwrap', true,
		'lines', 4,
		'max_lines', 6,
		'context', "BanterLineContext()",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "AnyOfTheseCount",
		'name', "Play Any Of List Count",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return not self.MultipleTexts end,
		'default', 1,
	}),
	PlaceObj('PropertyDefNestedList', {
		'id', "AnyOfThese",
		'name', "Play Any Of List",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return not self.MultipleTexts end,
		'base_class', "BanterLineThin",
	}),
	PlaceObj('PropertyDefBool', {
		'id', "Voiced",
		'help', "Whether the banter is voiced.",
		'default', true,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "useSnype",
		'name', "Use Snype",
		'help', "The banter will appear as a UI element on Snype rather than above the character's model.",
	}),
	PlaceObj('PropertyDefBool', {
		'id', "asVR",
		'name', "As VR",
		'help', "The banter will appear as a subtitled VR.",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetPropertyMetadata",
		'params', "prop",
		'code', function (self, prop)
			local prop_meta = PropertyObject.GetPropertyMetadata(self, prop)
			
			--Hide the "voiced T" context when the banter line isn't voiced
			if prop == "Text" and not self.Voiced then
				prop_meta = SubContext(prop_meta, { context = false })
			end
			
			return prop_meta
		end,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "Optional",
		'name', "Optional",
		'help', "Optional lines don't report missing actors and include actors around the source regardless of whether were passed in.",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return self.MultipleTexts end,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "FloatUp",
		'name', "FloatUp",
		'help', "Float up like floating text, rather than staying in place like banter text.",
	}),
	PlaceObj('PropertyDefBool', {
		'id', "playOnce",
		'name', "Once Per Actor",
		'help', "This line will be played only once per unit. If optional this line will be skipped. In banters with no other lines, or if the other lines are disabled, the whole banter will be skipped by the PlayBanterEffect.",
	}),
	PlaceObj('PropertyDefButtons', {
		'id', "btnTestLine",
		'buttons', {
			PlaceObj('PropertyDefPropButton', {
				'Name', "Test Line",
				'FuncName', "EditorTestBanterLine",
			}),
		},
		'template', true,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetWarning",
		'code', function (self)
			if not self.Text and not self.AnyOfThese then
				return "Banter line without text!"
			end
			if self.Voiced then
				if self.MultipleTexts then
					for _, line in ipairs(self.AnyOfThese) do
						if g_AnyUnitGroups[line.Character] then
							return string.format("Banters for '%s' character can't be voiced", line.Character)	
						end
					end
				else
					if g_AnyUnitGroups[self.Character] then
						return string.format("Banters for '%s' character can't be voiced", self.Character)	
					end
				end
			end
			if self.Character == "current unit" then
				return "Current unit is not supported as a banter actor"
			end
			if not self.MultipleTexts and next(self.AnyOfThese) then
				return "Hidden lines in property Play Any Of These won't be played - check MultipleTexts to see (and delete) them"
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetEditorView",
		'code', function (self)
			if self.MultipleTexts then
				local toPlay = self.AnyOfTheseCount
				local total = #(self.AnyOfThese or empty_table)
				
				local chars = {}
				for i, line in ipairs(self.AnyOfThese) do
					chars[#chars + 1] = Untranslated(line.Character)
				end
				chars = table.concat(chars, ", ")
				
				return T{595004298903, "Play <toPlay> of <total> lines. <chars>", toPlay = toPlay, total = total, chars = chars}
			end
			
			if not self.Text then return Untranslated("No Text") end
			
			local text = _InternalTranslate(self.Text)
			local long = #text > 50
			text = text:gsub('%\n', '')
			text = utf8.sub(text, 1, 50)
			if long then text = text .. "..." end
			
			return T{965627915065, "<u(Character)>: <u(Text)>", Character = self.Character, Text = text}
		end,
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "BanterLineThin",
	PlaceObj('PropertyDefCombo', {
		'id', "Character",
		'name', "Character",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return self.IsInterjection end,
		'default', "any",
		'items', function (self) return GetTargetUnitCombo() end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "Text",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return self.IsInterjection end,
		'wordwrap', true,
		'lines', 4,
		'max_lines', 6,
		'context', "BanterLineThinContext()",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetWarning",
		'code', function (self)
			if not self.Text then
				return "Banter line without text!"
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetEditorView",
		'code', function (self)
			if not self.Text then return Untranslated("No Text") end
			
			local text = _InternalTranslate(self.Text)
			local long = #text > 50
			text = text:gsub('%\n', '')
			text = utf8.sub(text, 1, 50)
			if long then text = text .. "..." end
			
			return T{965627915065, "<u(Character)>: <u(Text)>", Character = self.Character, Text = text}
		end,
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "Butterflies",
	PlaceObj('PropertyDefGameStatefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	Night = false,
	RainHeavy = false,
	RainLight = false,
}),
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Butterflies_Blue",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Butterflies",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_Butterflies",
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "CampaignSpecific",
	PlaceObj('PropertyDefChoice', {
		'id', "campaign",
		'name', "Campaign",
		'help', "The relevant campaign for this preset.",
		'default', "HotDiamonds",
		'items', function (self)
			local items = {}
			if not IsKindOf(self, "ModItem") then
				table.insert(items, "<all>")
			end
			table.iappend(items, PresetsCombo("CampaignPreset")())
			return items
		end,
	}),
	PlaceObj('PropertyDefFunc', {
		'id', "IsRelatedToCurrentCampaign",
		'name', "IsRelatedToCurrentCampaign",
		'no_edit', true,
		'default', function (self)
			return self.campaign == GetCurrentCampaignPreset().id or self.campaign == "<all>"
		end,
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "CharacterEffectProperties",
	PlaceObj('PropertyDefNestedList', {
		'category', "Conditions",
		'id', "Conditions",
		'help', "Conditions specifying whether or not the effect can be applied to a given unit at the moment.",
		'template', true,
		'base_class', "Condition",
		'inclusive', true,
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Modifiers",
		'id', "Modifiers",
		'help', "Numerical modifiers applied by the Status Effect to the affected Unit.",
		'template', true,
		'base_class', "UnitModifier",
	}),
	PlaceObj('PropertyDefText', {
		'id', "DisplayName",
		'template', true,
	}),
	PlaceObj('PropertyDefText', {
		'id', "Description",
		'template', true,
		'wordwrap', true,
		'lines', 4,
		'max_lines', 10,
	}),
	PlaceObj('PropertyDefFunc', {
		'id', "GetDescription",
		'template', true,
		'default', function (self)
			return self.Description
		end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "AddEffectText",
		'help', "The merc object will be passed as context, use proper tags",
		'template', true,
	}),
	PlaceObj('PropertyDefText', {
		'id', "RemoveEffectText",
		'help', "The merc object will be passed as context, use proper tags",
		'template', true,
	}),
	PlaceObj('PropertyDefFunc', {
		'category', "Reactions",
		'id', "OnAdded",
		'template', true,
		'params', "self, obj",
	}),
	PlaceObj('PropertyDefFunc', {
		'category', "Reactions",
		'id', "OnRemoved",
		'template', true,
		'params', "self, obj",
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Effect",
		'id', "type",
		'name', "Type",
		'help', '"System" effects are not either Positive or Negative for the sake of other features interacting with only Positive or Negative effects.\n"Buff" - something Positive\n"Debuff" - something Negative',
		'template', true,
		'default', "System",
		'items', function (self) return {"System", "Buff", "Debuff", "AttackBased"} end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Effect",
		'id', "lifetime",
		'name', "Lifetime",
		'template', true,
		'default', "Indefinite",
		'items', function (self) return { "Indefinite", "Until End of Turn", "Until End of Next Turn" } end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Effect",
		'id', "CampaignTimeAdded",
		'read_only', true,
		'no_edit', true,
		'template', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefUIImage', {
		'id', "Icon",
		'template', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Effect",
		'id', "max_stacks",
		'template', true,
		'default', 1,
		'min', 1,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Effect",
		'id', "stacks",
		'read_only', true,
		'no_edit', true,
		'template', true,
		'default', 1,
		'min', 1,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Effect",
		'id', "RemoveOnEndCombat",
		'name', "Auto-remove on combat end",
		'template', true,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Effect",
		'id', "RemoveOnSatViewTravel",
		'name', "Auto-remove on Satellite View Travel",
		'template', true,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Effect",
		'id', "RemoveOnCampaignTimeAdvance",
		'name', "Auto-remove on Campaign Time Advance",
		'help', "For map only effects",
		'template', true,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Effect",
		'id', "dontRemoveOnDeath",
		'name', "Don't Remove On Death",
		'template', true,
	}),
	PlaceObj('PropertyDefNestedList', {
		'id', "InstParameters",
		'base_class', "PresetParam",
	}),
	PlaceObj('PropertyDefBool', {
		'id', "HasParameters",
		'read_only', true,
		'no_edit', true,
		'default', true,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "Shown",
		'help', "Whether the status effect is shown in the UI or it is for internal use only.",
		'template', true,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "ShownSatelliteView",
		'help', "Whether the status effect is shown in the satellite view UI",
		'template', true,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "HideOnBadge",
		'name', "HideOnBadge",
		'help', "Whether the status effect is hidden on the combat badge, beneath the healthbar.",
		'template', true,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "HasFloatingText",
		'help', "Whether the status effects shows floating text when it is added or removed.",
		'template', true,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SetParameter",
		'params', "name, value",
		'code', function (self, name, value)
			self.InstParameters = self.InstParameters or {}
			for _, item in ipairs(self.InstParameters) do
				if item.Name == name then
					item.Value = value
					return
				end 
			end
			
			table.insert(self.InstParameters, {Name = name, Value = value})
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "ClonePropertyValue",
		'params', "value, prop_meta",
		'code', function (self, value, prop_meta)
			if prop_meta.id=="InstParameters" then
					local new_value = table.copy(value, "deep")
					return new_value
			end
			return PropertyObject.ClonePropertyValue(self, value, prop_meta)
		end,
	}),
})

PlaceObj('ClassDef', {
	Comment = "Creates inventory item from id or loottable (presumably multiple)",
	DefParentClassList = {
		"ConditionalSpawn",
	},
	group = "Zulu",
	id = "ConditionalLoot",
	PlaceObj('PropertyDefPresetId', {
		'category', "Spawn Object",
		'id', "ItemId",
		'name', "Inventory Item Id",
		'preset_class', "InventoryItemCompositeDef",
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "Spawn Object",
		'id', "LootTableId",
		'name', "Loot Table Id",
		'preset_class', "LootDef",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SpawnObjects",
		'params', "container",
		'code', function (self, container)
			if not rawget(self,"objects") then rawset(self, "objects", false) end
			
			-- Empty table is not allowed intentionally.
			if self.objects then return end
			self.objects = {}
			
			if self.ItemId and self.ItemId~="" then
				table.insert(self.objects, PlaceInventoryItem(self.ItemId))	
			end
			
			if self.LootTableId then
				local loot_tbl = LootDefs[self.LootTableId]
				if loot_tbl then
					local is_external_seed = (loot_tbl.loot == "cycle") or (loot_tbl.loot =="each then last")
					local init_seed = is_external_seed and GetQuestVar(container.QuestId, container.QuestSeedVariable)
					local seed = loot_tbl:GenerateLootSeed(init_seed)
					if is_external_seed then
						local quest = QuestGetState(container.QuestId or "")
						SetQuestVar(quest, container.QuestSeedVariable, seed)
					end
					loot_tbl:GenerateLoot(self, {}, seed, self.objects)
					if IsGameRuleActive("AmmoScarcity") then
						local percent = GameRuleDefs.AmmoScarcity:ResolveValue("LootDecrease")
						local classes = {"Ammo", "Ordnance", "Grenade", "ThrowableTrapItem", "Flare"}
						for _, item in ipairs( self.objects) do
							if IsKindOf(item, "InventoryStack") and IsKindOfClasses(item, classes) then
								item.Amount =  Max(1, item.Amount - MulDivRound(item.Amount, percent, 100))
							end
						end
					end
				end
			end
			
			if IsKindOf(container, "ItemContainer") then
				for _,o in ipairs(self.objects) do
					if not container:GetItemPos(o) then
						container:AddItem("Inventory", o)
					end	
				end
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "DespawnObjects",
		'params', "container",
		'code', function (self, container)
			if not rawget(self,"objects") then rawset(self, "objects", false) end
			if not self.objects or not next(self.objects) then return end
			local is_container  =  IsKindOf(container, "ItemContainer") 
			
			for i, obj in ipairs(self.objects) do
				if is_container  then 
					container:RemoveItem("Inventory",obj)
				end
				DoneObject(obj)
			end
			table.clear(self.objects)
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetError",
		'code', function (self)
			if self.LootTableId and not LootDefs[self.LootTableId] then
			  return "Invalid LootTableId " .. self.LootTableId
			end
		end,
	}),
})

PlaceObj('ClassDef', {
	Comment = "Virtual class: evaluates conditions, calls spawn/despawn",
	DefParentClassList = {
		"InitDone",
	},
	group = "Zulu",
	id = "ConditionalSpawn",
	PlaceObj('PropertyDefNestedList', {
		'category', "Spawn Object",
		'id', "Spawn_Conditions",
		'name', "Spawn Conditions",
		'base_class', "Condition",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Spawn Object",
		'id', "Despawn_Conditions",
		'name', "Despawn Conditions",
		'base_class', "Condition",
	}),
	PlaceObj('ClassConstDef', {
		'name', "objects",
		'type', "prop_table",
	}),
	PlaceObj('ClassConstDef', {
		'name', "last_spawned_objects",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetSpawnDespawnConditions",
		'params', "marker,spawn_once",
		'code', function (self, marker,spawn_once)
			local bSpawnCond = EvalConditionList(self.Spawn_Conditions, self)
			local bDespawnCond = next(self.Despawn_Conditions) and EvalConditionList(self.Despawn_Conditions, self)
			return bSpawnCond, bDespawnCond
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "Update",
		'params', "marker,spawn_once",
		'code', function (self, marker,spawn_once)
			if ForceDisableSpawnEnemy(self) then
				return
			end
			local bSpawnCond, bDespawnCond = self:GetSpawnDespawnConditions()
			if IgnoreSpawnEnemyConditions(self) then
				self.Side = "enemy1"
			end
			if not rawget(self,"objects") then rawset(self, "objects", false) end
			if bSpawnCond and not bDespawnCond and (not self.objects or not next(self.objects)) and not (spawn_once and rawget(self,"last_spawned_objects")) then
				self:SpawnObjects(marker)
				self.last_spawned_objects = true
			end
			if bDespawnCond and self.objects  then
				self:DespawnObjects(marker)
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SpawnObjects",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "DespawnObjects",
	}),
})

PlaceObj('ClassDef', {
	Comment = "Virtual class: Marker with conditional spawn",
	DefParentClassList = {
		"GridMarker",
		"ConditionalSpawn",
	},
	group = "Zulu",
	id = "ConditionalSpawnMarker",
	PlaceObj('ClassMethodDef', {
		'name', "Init",
		'code', function (self)
			self.editor_text_offset = point(0,0,5*guim/2+300)
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SpawnObjects",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "DespawnObjects",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EditorGetText",
		'code', function (self)
			return  self.class
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EditorEnter",
		'code', function (self)
			GridMarker.EditorEnter(self)
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EditorExit",
		'code', function (self)
			GridMarker.EditorExit(self)
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetExtraEditorText",
		'params', "texts",
		'code', function (self, texts)
			for _, condition in ipairs(self.Spawn_Conditions or empty_table) do
				texts[#texts+1] = "\t\t " .. Untranslated( "spawn: ") .. T{condition:GetEditorView(), condition}
			end
			for _, condition in ipairs(self.Despawn_Conditions or empty_table) do
				texts[#texts+1] = "\t\t " .. Untranslated( "despawn: ") .. T{condition:GetEditorView(), condition}
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetDynamicData",
		'params', "data",
		'code', function (self, data)
			data.last_spawned_objects = self.last_spawned_objects or nil
			data.objects = self.objects and true or nil
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SetDynamicData",
		'params', "data",
		'code', function (self, data)
			self.last_spawned_objects = data.last_spawned_objects or false
		end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "EditorRolloverText",
		'name', "EditorRolloverText",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', "Sets objects in collection visible.",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'id', "EditorIcon",
		'name', "EditorIcon",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', "CommonAssets/UI/Icons/school",
		'translate', false,
	}),
})

PlaceObj('ClassDef', {
	Comment = "Manages two things: a collection of visible objects, visual representation of a container in the world and a logical container",
	DefParentClassList = {
		"ShowHideCollectionMarker",
		"ItemContainer",
	},
	group = "Zulu",
	id = "ContainerMarker",
	PlaceObj('PropertyDefNestedList', {
		'category', "Spawn Object",
		'id', "ItemSpawners",
		'name', "ItemSpawners",
		'base_class', "ConditionalLoot",
		'inclusive', true,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Spawn Object",
		'id', "HideIfEmpty",
		'name', "HideIfEmpty",
		'help', "If the holder is empty the marker becomes uninteractable.",
		'default', true,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Spawn Object",
		'id', "DespawnIfEmpty",
		'name', "DespawnIfEmpty",
		'help', "If the holder is empty the marker objects despawn.",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "AreaHeight",
		'name', "Area Height",
		'read_only', true,
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "AreaWidth",
		'name', "Area Width",
		'read_only', true,
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefText', {
		'id', "Type",
		'name', "Type",
		'read_only', true,
		'no_edit', true,
		'default', "InventoryItemSpawn",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'id', "entity",
		'name', "entity",
		'read_only', true,
		'no_edit', true,
		'default', "WayPoint",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'category', "Spawn Object",
		'id', "DisplayName",
		'name', "Container Display Name",
		'no_edit', true,
		'default', T(499385555106, --[[ClassDef Zulu ContainerMarker default]] "Bag"),
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Spawn Object",
		'id', "Name",
		'name', "Display Name",
		'default', "Bag",
		'items', function (self) return GetContainerNamesCombo() end,
		'translate', true,
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "Spawn Object",
		'id', "QuestId",
		'name', "QuestId",
		'help', "Quest to check.",
		'preset_class', "QuestsDef",
		'preset_filter', function (preset, obj, prop_meta)
			return QuestHasVariable(preset, "QuestVarNum")
		end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Spawn Object",
		'id', "QuestSeedVariable",
		'name', "QuestSeedVariable",
		'help', "Quest variable to check.",
		'items', function (self) return GetQuestsVarsCombo(self.QuestId, "Num") end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "EditorRolloverText",
		'name', "EditorRolloverText",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', "Spawn/despawn Inventory items using id or loot table",
		'translate', false,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "Init",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "Update",
		'code', function (self)
			if self.DespawnIfEmpty and not self:GetItemInSlot("Inventory") and self.objects then
				self:DespawnObjects()
			end
			local spawn_once = self.Trigger == "once" 
			ShowHideCollectionMarker.Update(self)
			for _, spawner in ipairs(self.ItemSpawners)  do
				spawner:Update(self, spawn_once)
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetInteractionCombatAction",
		'params', "unit",
		'code', function (self, unit)
			if self.HideIfEmpty and not self:GetItemInSlot("Inventory") then
				return false
			elseif self.Type == "IntelInventoryItemSpawn" and gv_CurrentSectorId and not gv_Sectors[gv_CurrentSectorId].intel_discovered then
				return false
			end
			if self:IsEmpty("Inventory") then
				local anyVisible
				local efVisible = const.efVisible
				for i, o in ipairs(self.objects) do
					if o:GetEnumFlags(efVisible) ~= 0 then
						anyVisible = true
						break
					end
				end
				if not anyVisible then
					return false
				end
			end
			return ItemContainer.GetInteractionCombatAction(self, unit)
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetDynamicData",
		'params', "data",
		'code', function (self, data)
			for idx, spawner in ipairs(self.ItemSpawners)  do
				data.spawners = data.spawners or {}
				data.spawners[idx] = data.spawners[idx] or {}
				if rawget(spawner,"last_spawned_objects") then
					data.spawners[idx].last_spawned_objects = spawner.last_spawned_objects
				end
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SetDynamicData",
		'params', "data",
		'code', function (self, data)
			if data.spawners then
				for idx, spawner in ipairs(self.ItemSpawners)  do
					spawner.last_spawned_objects = data.spawners[idx] and data.spawners[idx].last_spawned_objects
				end
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EndInteraction",
		'params', "unit",
		'code', function (self, unit)
			ItemContainer.EndInteraction(self, unit)
			self:Update()
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "OnEditorSetProperty",
		'params', "prop_id, old_value, ged",
		'code', function (self, prop_id, old_value, ged)
			if prop_id == "Name"then
				local preset =  Presets.ContainerNames.Default[self.Name] 
				if preset then
					self.DisplayName = preset.DisplayName
				else
					self.DisplayName = T( RandomLocId(),self.Name)
				end
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "CheckDiscovered",
		'params', "unit",
		'code', function (self, unit)
			if not self:IsMarkerEnabled() then return end
			if not self:GetInteractionCombatAction(unit) then return end
			return BoobyTrappable.CheckDiscovered(self, unit)
		end,
	}),
	PlaceObj('ClassConstDef', {
		'name', "reserved_handles",
		'type', "number",
		'value', 1,
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "DamagePredictable",
	PlaceObj('PropertyDefNumber', {
		'id', "PotentialDamage",
		'name', "Potential Damage",
		'help', "used to indicate predicted damage done by attacks",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "PotentialDamageConditional",
		'name', "Potential Damage Conditional",
		'help', "used to indicate predicted damage done by attacks",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "PotentialSecondaryConditional",
		'name', "Potential Secondary Conditional",
		'help', "used to indicate secondary conditional damage doen by attacks",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "StealthKillChance",
		'name', "Stealth Kill Chance",
		'help', "used to indicate chance a unit is instant killed from stealth",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', -1,
		'min', -1,
	}),
	PlaceObj('PropertyDefText', {
		'id', "SmallPotentialDamageIcon",
		'name', "SmallPotentialDamageIcon",
		'help', "used to indicate meta-data about the PotentialDamage",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
	}),
	PlaceObj('PropertyDefText', {
		'id', "LargePotentialDamageIcon",
		'name', "LargePotentialDamageIcon",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
	}),
})

PlaceObj('PresetDef', {
	DefParentClassList = {
		"ListPreset",
	},
	group = "Zulu",
	id = "DebrisList",
	PlaceObj('PropertyDefNestedList', {
		'id', "debris_list",
		'name', "",
		'base_class', "DebrisWeight",
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "EmailAttachment",
	PlaceObj('PropertyDefUIImage', {
		'id', "picture",
		'name', "Picture",
	}),
	PlaceObj('PropertyDefText', {
		'id', "name",
		'name', "Name",
	}),
	PlaceObj('PropertyDefText', {
		'id', "size",
		'name', "Size",
		'default', T(476205954303, --[[ClassDef Zulu EmailAttachment default]] "82kb"),
	}),
	PlaceObj('PropertyDefText', {
		'id', "resolution",
		'name', "Resolution",
		'default', T(485105911401, --[[ClassDef Zulu EmailAttachment default]] "800x420x24bpp"),
	}),
	PlaceObj('PropertyDefText', {
		'id', "scale",
		'name', "Scale",
		'default', T(215258410442, --[[ClassDef Zulu EmailAttachment default]] "100%"),
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FallingDust",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Falling_Dust",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Falling_Dust",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_Falling_Dust",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "Fire_1x1",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	Night = true,
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Molotov_Fire_1x1_Smoldering",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Molotov_Fire_1x1_Smoldering",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_Fire_1x1",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "Fire_1x2",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	Night = true,
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_Fire1x2",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_Fire1x2",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_Fire_1x2",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectWithSound",
	},
	group = "Zulu",
	id = "Flies",
	PlaceObj('PropertyDefGameStatefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	Day = true,
	RainHeavy = false,
	RainLight = false,
}),
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Swarm_Flies",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Swarm_Flies",
	}),
	PlaceObj('ClassConstDef', {
		'name', "sounds_pattern",
		'type', "text",
		'value', "flies",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_Flies",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "CheckUnderground",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectWithSound",
	},
	group = "Zulu",
	id = "Flies_Big",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	Day = true,
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_Flies_Big",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_Flies_Big",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_Flies_Big",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "CheckUnderground",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingCattilSeeds",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	Fog = false,
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_FlyingCattailSeeds",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_FlyingCattailSeeds",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_FlyingCattailSeeds",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingConfetti",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_FlyingConfetti",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_FlyingConfetti",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_FlyingConfetti",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingDust",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set( "DustStorm" ),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_FlyingDust",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_FlyingDust",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_FlyingDust",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingDustRoad",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set(),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Road_dust",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Road_dust",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_DustRoad",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingEmbers",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_FlyingEmbers",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_FlyingEmbers",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_FlyingEmbers",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingGrass",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_FlyingGrass",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_FlyingGrass",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_FlyingGrass",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingGrass_Tropical",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_FlyingGrass_Tropical",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_FlyingGrass_Tropical",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_FlyingGrassTropical",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingMoney",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_FlyingMoney",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_FlyingMoney",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_FlyingMoney",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "FlyingPetals",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	RainHeavy = false,
	RainLight = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_FlyingPetals",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Env_FlyingPetals",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_FlyingPetals",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"CommonGameSettings",
	},
	group = "Zulu",
	id = "GameSettings",
	PlaceObj('PropertyDefPresetId', {
		'id', "Campaign",
		'name', "Campaign",
		'preset_class', "CampaignPreset",
		'default', "HotDiamonds",
	}),
	PlaceObj('PropertyDefText', {
		'id', "playthrough_name",
		'name', "Playthrough Name",
		'lines', 1,
		'max_lines', 1,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "playthrough_time",
		'name', "Playthrough time",
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "isDev",
		'name', "IsDev",
		'help', "Used to flag new playthroughs as developer ones",
	}),
})

PlaceObj('PresetDef', {
	DefParentClassList = {
		"ListPreset",
	},
	group = "Zulu",
	id = "GridMarkerType",
	PlaceObj('PropertyDefText', {
		'id', "Name",
	}),
	PlaceObj('PropertyDefColor', {
		'id', "Color",
	}),
	PlaceObj('PropertyDefCombo', {
		'id', "Entity",
		'items', function (self) return table.keys2(GetAllEntities(), true) end,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "Scale",
		'default', 100,
		'min', 1,
		'max', 2047,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "AreaWidth",
		'default', 1,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "AreaHeight",
		'default', 1,
	}),
	PlaceObj('PropertyDefText', {
		'id', "MarkerGroup",
		'name', "Default Group",
		'help', "Add markers to this group by default",
		'translate', false,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "AreaThickness",
		'name', "AreaThickness",
		'default', 240,
		'min', 1,
		'max', 1000,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "DefenderRole",
		'name', "Defender Role",
		'help', "Is marker used for placing defender units",
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "MercChatBranch",
	PlaceObj('PropertyDefNestedList', {
		'id', "Lines",
		'name', "Lines",
		'extra_code', "sort_order = 100",
		'base_class', "ChatMessage",
	}),
	PlaceObj('PropertyDefNestedList', {
		'id', "Conditions",
		'name', "Conditions",
		'extra_code', "sort_order = 99",
		'base_class', "Condition",
	}),
	PlaceObj('PropertyDefFunc', {
		'id', "GetEditorView",
		'name', "GetEditorView",
		'no_edit', true,
		'default', function (self)
			local firstLine = self.Lines and self.Lines[1] and self.Lines[1].Text or ""
			local firstCond = self.Conditions and self.Conditions[1]
			firstCond = firstCond and _InternalTranslate(firstCond:GetEditorView(), firstCond) or ""
			return Untranslated(firstCond) .. " - " .. firstLine
		end,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "chanceToRoll",
		'name', "chanceToRoll",
		'default', 50,
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"MercChatBranch",
	},
	group = "Zulu",
	id = "MercChatHaggle",
	PlaceObj('ClassMethodDef', {
		'name', "RollRandom",
		'params', "mercId",
		'code', function (self, mercId)
			local dayHash = xxhash(mercId, (Game.CampaignTime / const.Scale.day) / 3, Game.id)
			local roll = 1 + BraidRandom(dayHash, 100)
			if const.DbgHiring then print("Haggle rolled " .. roll .. " / " .. self.chanceToRoll) end
			local successRollHaggle = roll < self.chanceToRoll
			if const.DbgHiring then
				if successRollHaggle then
					CombatLog("debug","haggle ocurred " .. roll .. " / " .. self.chanceToRoll)
				else
					CombatLog("debug","no haggle " .. roll .. " / " .. self.chanceToRoll)
				end
			end
			return successRollHaggle
		end,
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"MercChatBranch",
	},
	group = "Zulu",
	id = "MercChatMitigation",
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"MercChatBranch",
	},
	group = "Zulu",
	id = "MercChatRefusal",
	PlaceObj('PropertyDefChoice', {
		'id', "Type",
		'name', "Type",
		'default', "normal",
		'items', function (self) return { "normal", "duration", "rehire" } end,
	}),
	PlaceObj('PropertyDefChoice', {
		'id', "Duration",
		'name', "Duration",
		'extra_code', 'no_edit = function(self) return self.Type ~= "duration" end',
		'default', "short",
		'items', function (self) return { "short", "long" } end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "CustomBranchCondition",
		'params', "obj, ctx",
		'code', function (self, obj, ctx)
			if self.Type ~= "duration" then return true end
			local duration = ctx.ContractDuration or 0
			if self.Duration == "short" then
				return duration < 7
			elseif self.Duration == "long" then
				return duration >= 7
			end
			return true
		end,
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "MishapProperties",
	PlaceObj('PropertyDefNumber', {
		'category', "Mishap",
		'id', "MinMishapChance",
		'help', "Mishap chance at 100 Explosives attribute",
		'template', true,
		'default', -8,
		'scale', "%",
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Mishap",
		'id', "MaxMishapChance",
		'help', "Mishap chance at 0 Explosives attribute",
		'template', true,
		'default', 12,
		'scale', "%",
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Mishap",
		'id', "MinMishapRange",
		'help', "Minimum range (in tiles) for the random target offest when a Mishap happens",
		'template', true,
		'default', 2,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Mishap",
		'id', "MaxMishapRange",
		'help', "Maximum range (in tiles) for the random target offest when a Mishap happens",
		'template', true,
		'default', 4,
		'modifiable', true,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetMishapChance",
		'params', "unit, target, async",
		'code', function (self, unit, target, async)
			local chance = self.MinMishapChance + MulDivRound(Max(0, 100 - unit.Explosives), Max(0, self.MaxMishapChance - self.MinMishapChance), 100)
			local item = IsKindOf(self, "FirearmBase") and self.parent_weapon or self
			local percent = 100
			if IsKindOf(item, "InventoryItem") then
				percent = item:GetConditionPercent()
				chance = Max(chance, 100 - percent)
			end 
			if GameState.RainHeavy  and IsKindOf(item, "GrenadeProperties") then
				chance = Clamp(MulDivRound(chance, const.EnvEffects.RainMishapMultiplier, 100), const.EnvEffects.RainMishapMinChance, const.EnvEffects.RainMishapMaxChance)
			end
			
			if not async then
				NetUpdateHash("GetMishapChance", unit, target, chance, unit.Explosives, percent, GameState.RainHeavy, self.MinMishapChance, self.MaxMishapChance)
			end
			
			return Max(0, chance)
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetMishapDeviationVector",
		'params', "unit, target",
		'code', function (self, unit, target)
			local deviation = unit:RandRange(self.MinMishapRange * const.SlabSizeX, self.MaxMishapRange * const.SlabSizeX)
			return Rotate(point(deviation, 0, 0), unit:Random(360*60))
		end,
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "Mist",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	RainHeavy = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Ground_Mist",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "Mist",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "entity_scale",
		'name', "Entity Scale",
		'default', 10,
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
})

PlaceObj('PresetDef', {
	DefGlobalMap = "MultiplayerGameFiltersList",
	DefParentClassList = {
		"ListPreset",
	},
	group = "Zulu",
	id = "MultiplayerGameFilters",
	PlaceObj('PropertyDefText', {
		'id', "Name",
	}),
	PlaceObj('PropertyDefFunc', {
		'id', "Condition",
		'default', function (self)
			return true
		end,
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "PerkProperties",
	PlaceObj('PropertyDefCombo', {
		'category', "Perk",
		'id', "Tier",
		'template', true,
		'default', "System",
		'items', function (self) return {"Bronze", "Silver", "Gold", "Personal", "Quirk", "Personality", "Specialization", "System"} end,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Perk",
		'id', "Stat",
		'name', "Related Stat",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return not (self.Tier == "Bronze" or self.Tier == "Silver" or self.Tier == "Gold") end,
		'template', true,
		'items', function (self) return {"Health", "Agility", "Dexterity", "Strength", "Leadership", "Wisdom", "Marksmanship", "Mechanical", "Explosives", "Medical"} end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Perk",
		'id', "StatValue",
		'name', "Stat Requirement",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return not (self.Tier == "Bronze" or self.Tier == "Silver" or self.Tier == "Gold") end,
		'template', true,
		'default', 30,
		'slider', true,
		'min', 0,
		'max', 100,
	}),
	PlaceObj('PropertyDefButtons', {
		'category', "Perk",
		'id', "StartingPerkOf",
		'name', "Starting Perk Of",
		'dont_save', true,
		'read_only', true,
		'template', true,
		'extra_code', "buttons = function(obj) return PersonalPerkStartingOfButtons(obj) end",
	}),
	PlaceObj('PropertyDefUIImage', {
		'id', "Icon",
		'template', true,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "IsLevelUp",
		'code', function (self)
			return self.Tier == "Bronze" or self.Tier == "Silver" or self.Tier == "Gold"
		end,
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "RadioPlaylistTrack",
	PlaceObj('PropertyDefBrowse', {
		'id', "Track",
		'name', "Track",
		'default', "Music",
		'folder', "Music",
		'filter', "WAV or OPUS files|*.opus;*.wav",
		'extension', "",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "Frequency",
		'name', "Weight",
		'default', 100,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "EmptyTrack",
		'name', "Empty Track",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "Duration",
		'name', "Duration",
		'extra_code', "no_edit = function(self) return not self.EmptyTrack end",
		'default', 5000,
		'scale', "sec",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetError",
		'code', function (self)
			if not self.EmptyTrack then
				local path_wav = string.format("%s.wav", self.Track)
				local path_opus = string.format("%s.opus", self.Track)
				if not io.exists(path_wav) and not io.exists(path_opus) then
					return string.format("Missing '%s' (supported extensions are .opus and .wav)", self.Track)
				end
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetEditorView",
		'code', function (self)
			if self.EmptyTrack then
				return Untranslated("Empty Track (<u(Frequency)>) for <FormatScale(Duration, 'sec')>")
			else
				return Untranslated("<u(Track)> (<u(Frequency)>)")
			end
		end,
	}),
})

PlaceObj('ClassDef', {
	Comment = "Works on objects from collection, doesn't actually spawn anything, just shows/hides them",
	DefParentClassList = {
		"ConditionalSpawnMarker",
		"SaveMapCheckMarker",
	},
	group = "Zulu",
	id = "ShowHideCollectionMarker",
	PlaceObj('ClassMethodDef', {
		'name', "GameInit",
		'code', function (self)
			if not IsEditorActive() and not self.objects then
				self:HideObjects()
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetObjects",
		'code', function (self)
			local root_collection = self:GetRootCollection()
			local collection_idx = root_collection and root_collection.Index or 0
			if collection_idx and collection_idx ~= 0 then
				return MapGet(self, self.CollectionRange, "collection", collection_idx, true, function(o)
					return not IsKindOf(o, "EditorMarker")
				end)
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "HideObjects",
		'code', function (self)
			local objects = self.objects or self:GetObjects()
			local enumflags = self.restore_enumflags
			local efCollision = const.efCollision
			local bbox
			for i, o in ipairs(objects) do
				if IsValid(o) and o:GetVisible() then
					o:SetVisible(false)
					if o:GetCollision() then
						o:SetCollision(false)
						if not enumflags then
							enumflags = {}
						end
						enumflags[o] = efCollision
						bbox = bbox and AddRects(bbox, o:GetObjectAttachesBBox()) or o:GetObjectAttachesBBox()
					end
				end
			end
			if enumflags then
				self.restore_enumflags = enumflags
			end
			if bbox then
				RebuildCovers(bbox)
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "ShowObjects",
		'code', function (self)
			local objects = self.objects or self:GetObjects()
			local enumflags = self.restore_enumflags
			self.restore_enumflags = nil
			local efCollision = const.efCollision
			local bbox
			for i, o in ipairs(objects) do
				if IsValid(o) then
					o:SetVisible(true)
					if enumflags then
						local flags = enumflags[o]
						if flags and (flags & efCollision) ~= 0 then
							o:SetCollision(true)
							bbox = bbox and AddRects(bbox, o:GetObjectAttachesBBox()) or o:GetObjectAttachesBBox()
						end
					end
				end
			end
			if bbox then
				RebuildCovers(bbox)
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SpawnObjects",
		'code', function (self)
			if self.objects then
				return
			elseif self.Trigger == "once" and self.last_spawned_objects then
				return
			end
			self.objects = self:GetObjects() or empty_table
			self:ShowObjects()
			local game_flags = self.sync_obj and const.gofSyncObject
			for i, o in ipairs(self.objects) do
				o.spawner = self
				if game_flags then
					o:SetGameFlags(game_flags)
				end
			end
			self.last_spawned_objects = true
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "DespawnObjects",
		'code', function (self)
			if not self.objects then return end
			for _, o in ipairs(self.objects) do
				o.spawner = nil
			end
			if not IsEditorActive() then
				self:HideObjects()
			end
			self.objects = nil
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EditorEnter",
		'code', function (self)
			GridMarker.EditorEnter(self)
			self:ShowObjects()
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EditorExit",
		'code', function (self)
			GridMarker.EditorExit(self)
			if not self.objects then
				self:HideObjects()
			end
			self:Update()
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetDynamicData",
		'params', "data",
		'code', function (self, data)
			data.objects = self.objects and true or nil
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SetDynamicData",
		'params', "data",
		'code', function (self, data)
			if data.objects then
				self.objects = self:GetObjects() or empty_table
				self:ShowObjects()
				for i, o in ipairs(self.objects) do
					o.spawner = self
					if self.sync_obj then
						o:SetGameFlags(const.gofSyncObject)
					end
				end
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetError",
		'code', function (self)
			if not Platform.developer then return end
			local collection_idx = self:GetCollectionIndex()
			if collection_idx and collection_idx ~= 0 then
				local outside_objects = MapGet("map", "collection", collection_idx, true, function(o, self)
					return not IsCloser2D(self, o, self.CollectionRange)
				end, self)
				if outside_objects then
					return string.format("'%s' too far from its '%s'(must be within %d", outside_objects[1]:GetEntity(), self.class, self.CollectionRange)
				end
				
				local nonEssentialObjects = MapGet("map", "collection", collection_idx, true, function(o, self)
					return o:GetDetailClass() ~= "Essential"
				end, self)
				if nonEssentialObjects then
					return "Objects in ShowHideCollectionMarker need to be marked as detail level: 'Essential'"
				end
			end
		end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "EditorRolloverText",
		'name', "EditorRolloverText",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', "Sets objects in collection visible.",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'id', "EditorIcon",
		'name', "EditorIcon",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', "CommonAssets/UI/Icons/school",
		'translate', false,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "CollectionRange",
		'name', "Collection Range",
		'help', "The range in which to gather objects from the collection, warns with VME if further than that",
		'default', 10000,
		'scale', "m",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Spawn Object",
		'id', "sync_obj",
		'name', "SyncObject",
		'help', "",
	}),
	PlaceObj('ClassConstDef', {
		'name', "restore_enumflags",
		'type', "prop_table",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"DecorStateFXObjectNoSound",
	},
	group = "Zulu",
	id = "SunRays",
	PlaceObj('PropertyDefSet', {
		'category', "DecorStateFXObject",
		'id', "ActivationRequiredStates",
		'name', "States Required for Activation",
		'default', set({
	Night = false,
}),
		'items', function (self) return GetGameStateFilter() end,
		'three_state', true,
	}),
	PlaceObj('ClassConstDef', {
		'name', "Preset",
		'type', "text",
		'value', "Env_SunRays",
	}),
	PlaceObj('ClassConstDef', {
		'name', "particles_pattern",
		'type', "text",
		'value', "env_SunRays",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_category",
		'type', "text",
		'value', "Effects",
	}),
	PlaceObj('ClassConstDef', {
		'name', "place_name",
		'type', "text",
		'value', "DecorFX_SunRays",
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "UnitDataSpawnData",
	PlaceObj('PropertyDefPresetId', {
		'id', "UnitDataDefId",
		'name', "UnitDataCompositeDef Id",
		'help', "Choose mercenary, enemy, or NPC from the Unit editor to spawn",
		'preset_class', "UnitDataCompositeDef",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "SpawnWeight",
		'name', "Spawn Weight",
		'help', "Spawn a unit from one of several unit templates using a weighted average.",
		'default', 100,
		'min', 0,
	}),
	PlaceObj('PropertyDefPresetId', {
		'id', "ForcedAppearance",
		'name', "Forced Appearance",
		'help', "Force this template to use this appearance instead of randomly choosing from its own list of appearances",
		'preset_class', "AppearancePreset",
	}),
	PlaceObj('PropertyDefText', {
		'id', "Name",
		'name', "Name Override",
		'help', "Name for the spawned unit that will replace the one from template.",
		'template', true,
		'lines', 1,
		'max_lines', 1,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetEditorView",
		'code', function (self)
			return Untranslated("<UnitDataDefId> <Name> (weight: <SpawnWeight>) ")
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "OnEditorSetProperty",
		'params', "prop_id, old_value, ged",
		'code', function (self, prop_id, old_value, ged)
			local function set_appearance(obj)
				local first = obj:GetAppearenceTemplateId()
				local appearance = ChooseUnitAppearance(first)
				obj:ApplyAppearance(appearance)
				obj.Appearance = appearance
			end
			
			if prop_id=="UnitDataDefId" then
				local parent = ged.selected_object
				if parent:IsKindOf("GedMultiSelectAdapter") then
					for _, obj in ipairs(parent.__objects) do
						set_appearance(obj)
					end
				else
					set_appearance(parent)
				end
			end
		end,
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"ShowHideCollectionMarker",
		"AppearanceObject",
	},
	group = "Zulu",
	id = "UnitMarker",
	PlaceObj('PropertyDefNumber', {
		'id', "AreaHeight",
		'name', "Area Height",
		'default', 1,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "AreaWidth",
		'name', "Area Width",
		'default', 1,
	}),
	PlaceObj('PropertyDefText', {
		'category', "Spawn Object",
		'id', "Appearance",
		'name', "Appearance",
		'no_edit', true,
		'translate', false,
	}),
	PlaceObj('PropertyDefChoice', {
		'id', "anim",
		'name', "Animation",
		'no_edit', true,
		'no_validate', true,
		'default', "idle",
		'items', function (self) return ValidAnimationsCombo end,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Animation",
		'id', "use_weapons",
		'name', "Use weapons",
		'help', "Use weapon animations in idle state.",
		'default', true,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Spawn Object",
		'id', "Suspicious",
		'help', "Set spawned units to Suspicious state",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "Init",
		'code', function (self)
			self.parts = {}
			self.attached_parts = { "Head", "Pants", "Shirt", "Armor", "Hat" }
			self.attach_spot = { ["Hat"] = "Head" }		-- "Origin" by default
			local first = self:GetAppearenceTemplateId()
			local appearance = self.Appearance or ChooseUnitAppearance(first, self.handle)
			self:ApplyAppearance(appearance)
			self.Appearance = appearance
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SpawnObjects",
		'code', function (self)
			if not self.UnitDataSpawnDefs or #self.UnitDataSpawnDefs < 1 then 
				return
			end
			
			-- Empty table is not allowed intentionally to prevent respawning on
			-- deleted unit object as some markers are not setup as "once".
			if self.objects and not self.AlwaysSpawn then return end
			if self.Trigger == "once" and self.last_spawned_objects then return end
			
			local pts =  GetReachablePositionsFromPos(self:GetPos(), 1)
			
			-- prepare template & session ids
			local session_id, template_idx = self:GenerateUnitIds()
			
			if pts and #pts > 0 then
				local idx = template_idx
				local spawnEntry = self.UnitDataSpawnDefs[idx]
				local unit_template_id = spawnEntry.UnitDataDefId
				local name = spawnEntry.Name
				local pos = pts[1]
				
				-- check for existing UnitData for this session_id, if the unit has died skip the spawn
				local unit_data = gv_UnitData and gv_UnitData[session_id]
				
				if unit_data and unit_data.HealPersistentOnSpawn and not unit_data:IsDead() then
					unit_data:RemoveAllStatusEffects()
					--Wounded and unconscious are not removed by Remove all status effect as they are character effects
					if unit_data.StatusEffects["Wounded"] then
						unit_data:RemoveStatusEffect("Wounded", "all")
					end
					if unit_data.StatusEffects["Unconscious"] then
						unit_data:RemoveStatusEffect("Unconscious", "all")
					end
					unit_data.HitPoints = unit_data.MaxHitPoints
				end
			
				if not (unit_data and unit_data:IsDead()) then
					-- If changing the template id of a unit we need to recreate the unit data.
					if unit_data and unit_data.class ~= unit_template_id then
						unit_data:delete()
						gv_UnitData[session_id] = false
					end
				
					pos:SetInvalidZ()
					local unit = SpawnUnit(unit_template_id,
						session_id,
						pos,
						self:GetAngle(),
						self.Groups,
						self)
						
					unit.sequential_banter = self.BantersSequential
					
					local approach_banters = {}
					table.iappend(approach_banters, self.ApproachedBanters)
					table.iappend(approach_banters, table.keys2(Presets.BanterDef[self.ApproachBanterGroup] or {}, "sorted"))
					unit.approach_banters = approach_banters
					unit.approach_banters_distance = self.ApproachRadius
					
					if name and name~="" then
						unit.Name = name
					end
					self.objects = { unit }
					ShowHideCollectionMarker.SpawnObjects(self)
					unit:SetSide(self.Side)
					unit.routine = self.Routine
					unit.routine_area = self.RoutineArea
					unit.routine_spawner = self
					unit.conflict_ignore = self.ConflictIgnore
					if self.Side == "neutral" and GameState.Conflict and unit:CanCower() then
						unit:TeleportToCower()
					end
					if self.kill_on_spawn then
						unit:SetCommand("Die")
					end
				end
			end
			
			if self.Persistent then
				self.unit_template_idx = template_idx
			end
			
			self.last_spawned_objects = true
			return self.objects
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "DespawnObjects",
		'code', function (self)
			if not self.objects or not next(self.objects) then return end
			for i = #self.objects,1,-1 do
				local obj = self.objects[i]
				if IsValid(obj) and IsKindOf(obj, "Unit") and obj:IsNPC() and (not obj:IsDead() or obj.PersistentSessionId) then
					obj.spawner = false
					obj:Despawn()
					table.remove(self.objects, i)
				end	
			end
			ShowHideCollectionMarker.DespawnObjects(self)
			self.objects = false
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GenerateUnitIds",
		'code', function (self)
			local unit_template_idx, session_id
			if not self.Persistent or not self.unit_template_idx then
				-- weighted random
				local accum_weight = 0
				for i=1,#self.UnitDataSpawnDefs do
					accum_weight = accum_weight + self.UnitDataSpawnDefs[i].SpawnWeight
				end
				
				-- weighted random get rnd template
				local target_weight
				target_weight = InteractionRand(accum_weight, "spawn_objects", self)
				local sum_weight = 0
				for i=1,#self.UnitDataSpawnDefs-1 do
					sum_weight = sum_weight + self.UnitDataSpawnDefs[i].SpawnWeight
					if sum_weight > target_weight then
						unit_template_idx = i
						break
					end
				end
				unit_template_idx = unit_template_idx or #self.UnitDataSpawnDefs
			else
				unit_template_idx = self.unit_template_idx
			end
			
			local template = self.UnitDataSpawnDefs[unit_template_idx].UnitDataDefId
			template = template and UnitDataDefs[template]
			
			if template and (template.PersistentSessionId or "") ~= "" then
				session_id = template.PersistentSessionId
			elseif self.Persistent then
				session_id = self.SessionId
			else
				session_id = GenerateUniqueUnitDataId("SpawnerUnit", gv_CurrentSectorId, unit_template_idx)
			end
			
			return session_id, unit_template_idx
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetDynamicData",
		'params', "data",
		'code', function (self, data)
			data.last_spawned_objects = self.last_spawned_objects or nil
			if self.objects then
				data.objects = {}
				for _, obj in ipairs(self.objects) do
					table.insert(data.objects, obj:GetHandle())
				end
			end
			
			data.unit_template_idx = self.unit_template_idx or nil
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SetDynamicData",
		'params', "data",
		'code', function (self, data)
			if data.objects then
				self.objects = {}
				for _, handle in ipairs(data.objects) do
					local obj = HandleToObject[handle]
					if obj then
						table.insert(self.objects, obj)
					end
				end
			end
			self.last_spawned_objects = data.last_spawned_objects or false
			self.unit_template_idx = data.unit_template_idx
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EditorEnter",
		'code', function (self)
			ShowHideCollectionMarker.EditorEnter(self)
			local first = self:GetAppearenceTemplateId()
			local appearance = self.Appearance or ChooseUnitAppearance(first, self.handle)
			self:ApplyAppearance(appearance)
			self.Appearance = appearance
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EditorGetText",
		'code', function (self)
			return self:GetAppearenceTemplateId() or self.class
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetExtraEditorText",
		'params', "texts",
		'code', function (self, texts)
			texts[#texts+1] = "\t\t " .. T{747690717505, "<Side>:",self}
			for _, temp_obj in ipairs(self.UnitDataSpawnDefs or empty_table) do
				texts[#texts+1] = "\t\t\t " .. T{925017903706, "<UnitDataDefId> <Name> (<SpawnWeight>)", temp_obj, Name = temp_obj.Name}
			end
			ShowHideCollectionMarker.GetExtraEditorText(self, texts)
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetAppearenceTemplateId",
		'code', function (self)
			local first =  self.UnitDataSpawnDefs and self.UnitDataSpawnDefs[1] 
			return first and first.UnitDataDefId
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetError",
		'code', function (self)
			if self.Persistent and (self.SessionId or "") == "" then
				return "Persistent units must have a valid Session ID"
			end
			
			local errors = {}
			local spawn_defs = self.UnitDataSpawnDefs
			for _, spawn_def in ipairs(spawn_defs or empty_table) do
				local unitdatadef_id = spawn_def.UnitDataDefId
				local unit_def = unitdatadef_id and UnitDataDefs[unitdatadef_id]
				if not unit_def then
					table.insert(errors, string.format("Invalid UnitDataDefId '%s'", unitdatadef_id or ""))
				else
					local species = unit_def and unit_def.species or "Human"
					if species == "Human" then
						local prefix = not self.use_weapons and "civ" or "ar"
						local stance = self.idle_stance ~= g_StanceActionDefault and self.idle_stance or ".*"
						local action = self.idle_action ~= g_StanceActionDefault and self.idle_action or ".*"
						local anim_regex = string.format("%s_%s_%s", prefix, stance, action)
						local anims = ValidAnimationsCombo(self)
						local anim_match = false
						for _, a in ipairs(anims) do
							if string.match(a, anim_regex) then
								anim_match = true
								break
							end
						end
						if not anim_match then
							table.insert(errors, string.format(
								"These values don't match a valid animation: [%s] Use Weapons - %s; Idle stance - %s; Idle animation action - %s",
								next(anims) and anims[1] or "no anims present",
								self.use_weapons and "Yes" or "No",
								self.idle_stance or "default",
								self.idle_action or "default"
							))
						end
					end
				end
			end
			
			return next(errors) and table.concat(errors, "\n")
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "OnEditorSetProperty",
		'params', "prop_id, old_value, ged",
		'code', function (self, prop_id, old_value, ged)
			if prop_id == "idle_stance" then
				local actions = GetIdleAnimStanceActions(self.use_weapons, self.idle_stance)
				if not table.find(actions, self.idle_action) then
					self:SetProperty("idle_action", actions[1])
				end
			end
		end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "Type",
		'name', "Type",
		'read_only', true,
		'no_edit', true,
		'default', "UnitMarker",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'id', "Entity",
		'name', "Entity",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', "WayPoint",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'id', "EditorIcon",
		'name', "EditorIcon",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', "CommonAssets/UI/Icons/user",
		'translate', false,
	}),
	PlaceObj('PropertyDefPresetIdList', {
		'category', "Banters",
		'id', "SpecificBanters",
		'name', "SpecificBanters",
		'help', "Specific Banters to play when interacted with.",
		'preset_class', "BanterDef",
	}),
	PlaceObj('PropertyDefStringList', {
		'category', "Banters",
		'id', "BanterGroups",
		'name', "Banters from group",
		'help', "Add groups of banters at once",
		'items', function (self) return PresetGroupsCombo("BanterDef") end,
		'arbitrary_value', true,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Banters",
		'id', "BantersSequential",
		'name', "Play all banters one after another",
		'help', "By default on unit interaction one of the banters from the list is played. If this is checked then all the banters will be played in succession.",
	}),
	PlaceObj('PropertyDefPresetIdList', {
		'category', "Banters",
		'id', "ApproachedBanters",
		'name', "ApproachedBanters",
		'help', "Banters to play when the unit is approached within a specified range.",
		'preset_class', "BanterDef",
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Banters",
		'id', "ApproachBanterGroup",
		'name', "Approach Banters from group",
		'help', "Add a group of approach banters at once",
		'items', function (self) return PresetGroupsCombo("BanterDef") end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Banters",
		'id', "ApproachRadius",
		'name', "ApproachRadius",
		'help', "How close a player controled unit has to be to trigger the approached banters.",
		'default', 8,
	}),
	PlaceObj('PropertyDefText', {
		'category', "Interaction",
		'id', "InteractionName",
		'name', "Interaction Name",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Interaction",
		'id', "InteractionConditions",
		'name', "Interaction Enable Conditions",
		'help', "The interaction effects and overwrites will apply if these pass as true.",
		'base_class', "Condition",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Interaction",
		'id', "ExecuteInteractionEffectsSequentially",
		'name', "Execute Sequentially",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Interaction",
		'id', "InteractionEffects",
		'name', "Interaction Effects",
		'base_class', "Effect",
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Interaction",
		'id', "InteractionVisuals",
		'name', "InteractionVisuals",
		'items', function (self) return AllInteractableIcons() end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Spawn Object",
		'id', "Side",
		'default', "neutral",
		'items', function (self) return Sides end,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "kill_on_spawn",
		'dont_save', true,
		'no_edit', true,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Spawn Object",
		'id', "Persistent",
		'help', 'triggering the spawn multiple times will result in the same units, preserving any changes in their data; this is ignored if the template to be spawned has a non-empty "Persistent Session Id" (works as if it is enabled)',
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Spawn Object",
		'id', "AlwaysSpawn",
		'name', "Spawn when gone",
		'help', "Even if the unit is despawned or left, still spawn here",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Spawn Object",
		'id', "ConflictIgnore",
		'name', "Conflict Ignore",
		'help', "The units from this marker are ignoring conflicts and don't use the Cower command.",
	}),
	PlaceObj('PropertyDefText', {
		'category', "Spawn Object",
		'id', "SessionId",
		'name', "Session ID",
		'extra_code', "no_edit = function(self) return not self.Persistent end",
		'translate', false,
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Spawn Object",
		'id', "UnitDataSpawnDefs",
		'name', "UnitData Spawn Templates",
		'help', "Choose mercenary, enemy, or NPC from the Unit editor to spawn, using weighted random.",
		'base_class', "UnitDataSpawnData",
		'inclusive', true,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Animation",
		'id', "idle_stance",
		'name', "Idle stance",
		'default', "do not change",
		'items', function (self) return GetIdleAnimStances(self.use_weapons) end,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Animation",
		'id', "idle_action",
		'name', "Idle Action",
		'default', "do not change",
		'items', function (self) return GetIdleAnimStanceActions(self.use_weapons, self.idle_stance) end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "EditorRolloverText",
		'name', "EditorRolloverText",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'default', "Spawn/despawn Unit from specified TemplateIds when spawn/despawn conditions are met",
		'translate', false,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "",
		'id', "Routine",
		'default', "StandStill",
		'items', function (self) return UnitRoutines end,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "",
		'id', "RoutineArea",
		'default', "self",
		'items', function (self) local g = table.copy(GridMarkerGroupsCombo()) g[1+#g] = "self" return g end,
	}),
	PlaceObj('PropertyDefPresetIdList', {
		'category', "Spawn Object",
		'id', "status_effects",
		'name', "Status Effects",
		'preset_class', "CharacterEffectCompositeDef",
	}),
	PlaceObj('ClassConstDef', {
		'name', "unit_template_idx",
		'type', "string_list",
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"UnitPropertiesStats",
		"ZuluModifiable",
		"DamagePredictable",
	},
	group = "Zulu",
	id = "UnitProperties",
	PlaceObj('PropertyDefBool', {
		'category', "Appearance",
		'id', "Headshot",
		'name', "Headshot",
		'help', "Set a blown out head",
		'template', true,
	}),
	PlaceObj('PropertyDefText', {
		'id', "CurrentSide",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'id', "lastFiringMode",
		'name', "LastFiringMode",
		'translate', false,
	}),
	PlaceObj('PropertyDefUIImage', {
		'category', "Appearance",
		'id', "Portrait",
		'template', true,
		'default', "UI/MercsPortraits/placeholder_portrait",
		'image_preview_size', 100,
	}),
	PlaceObj('PropertyDefUIImage', {
		'category', "Appearance",
		'id', "BigPortrait",
		'template', true,
		'default', "UI/Mercs/placeholder_character",
		'image_preview_size', 100,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "IsMercenary",
		'name', "Is mercenary",
		'help', "Can the player have this unit in their team.",
		'template', true,
	}),
	PlaceObj('PropertyDefText', {
		'category', "General",
		'id', "Name",
		'name', "Full name",
		'help', "The full name of the merc. When the full name is needed this entire string is used and the nickname is ignored.",
		'template', true,
		'lines', 1,
		'max_lines', 1,
	}),
	PlaceObj('PropertyDefText', {
		'category', "General",
		'id', "Nick",
		'name', "Nickname",
		'help', "The nickname or short name of the merc",
		'template', true,
		'extra_code', 'no_edit = function(self) return not IsMerc(self) and self.id ~= "Dummy" end',
		'lines', 1,
		'max_lines', 1,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Stats",
		'id', "Randomization",
		'name', "Randomization",
		'help', "When true any instance of this unit randomizes the stats of the unit by +/- 10 points",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self)  end",
	}),
	PlaceObj('PropertyDefText', {
		'category', "General",
		'id', "AllCapsNick",
		'name', "AllCapsNickname",
		'help', "The nickname or short name of the merc with all caps letters (needed by some UI)",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'lines', 1,
		'max_lines', 1,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "elite",
		'name', "Elite",
		'help', "Give the unit a unique random name.",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "General",
		'id', "eliteCategory",
		'name', "Elite Category",
		'help', "From which group of names to select. If nothing is selected it will pick from any of the groups.",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'items', function (self) return PresetGroupsCombo("EliteEnemyName") end,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "General",
		'id', "Affiliation",
		'template', true,
		'default', "AIM",
		'items', function (self) return Affiliations end,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Hiring",
		'id', "HireStatus",
		'name', "Initial Hire Status",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', "Available",
		'items', function (self) return PresetGroupCombo("MercHireStatus", "Default") end,
	}),
	PlaceObj('PropertyDefText', {
		'category', "Hiring",
		'id', "Bio",
		'name', "Bio",
		'help', "Biography of the merc",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'lines', 4,
		'max_lines', 10,
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "Hiring",
		'id', "Nationality",
		'name', "Nationality",
		'help', "Is shown next to the bio in the hire UI",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'preset_class', "MercNationalities",
	}),
	PlaceObj('PropertyDefText', {
		'category', "Hiring",
		'id', "Title",
		'name', "Title",
		'help', "Is shown next to the bio in the hire UI",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
	}),
	PlaceObj('PropertyDefText', {
		'category', "Hiring",
		'id', "Email",
		'name', "Email",
		'help', "Is shown in the AIM chat.",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
	}),
	PlaceObj('PropertyDefText', {
		'category', "Hiring",
		'id', "snype_nick",
		'name', "snype Nick",
		'help', "Is shown in the AIM chat.",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Conditions",
		'id', "Refusals",
		'name', "Refusals",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "MercChatRefusal",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Conditions",
		'id', "Haggles",
		'name', "Haggles",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "MercChatHaggle",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Conditions",
		'id', "HaggleRehire",
		'name', "Rehire Haggles",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "MercChatHaggle",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Conditions",
		'id', "Mitigations",
		'name', "Mitigations",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "MercChatMitigation",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Conditions",
		'id', "ExtraPartingWords",
		'name', "Parting Words",
		'help', "If any conditional passing remark passes it is played instead of the default one.",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "MercChatBranch",
		'inclusive', true,
		'no_descendants', true,
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Lines",
		'id', "Offline",
		'name', "Offline",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "ChatMessage",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Lines",
		'id', "GreetingAndOffer",
		'name', "Greetings And Offer",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "ChatMessage",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Lines",
		'id', "ConversationRestart",
		'name', "Conversation Restart",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "ChatMessage",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Lines",
		'id', "IdleLine",
		'name', "Idle",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "ChatMessage",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Lines",
		'id', "PartingWords",
		'name', "PartingWords",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "ChatMessage",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Lines",
		'id', "RehireIntro",
		'name', "RehireIntro",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "ChatMessage",
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Hiring - Lines",
		'id', "RehireOutro",
		'name', "RehireOutro",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'base_class', "ChatMessage",
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Hiring - Parameters",
		'id', "MedicalDeposit",
		'name', "Medical Deposit",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', "small",
		'items', function (self) return { "small", "none", "large", "extreme" } end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Hiring - Parameters",
		'id', "DurationDiscount",
		'name', "Duration Discount",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', "normal",
		'items', function (self) return { "normal", "none", "long only" } end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Hiring - Parameters",
		'id', "Haggling",
		'name', "Haggling",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', "normal",
		'items', function (self) return { "normal", "low", "high" } end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Hiring - Parameters",
		'id', "StartingSalary",
		'help', "The salary at the starting level (whichever it is).",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', 1000,
		'min', 0,
		'max', 20000,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Hiring - Parameters",
		'id', "SalaryIncrease",
		'help', "Salary increase factor per level. Doesn't reflect changes by Game Rules.",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', 250,
		'scale', 1000,
		'min', 0,
		'max', 10000,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Hiring - Parameters",
		'id', "SalaryLv1",
		'name', "(To Be Deleted) Salary Lv 1",
		'help', "The amount of money it costs to hire this merc for 1 day at level 1",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', 1000,
		'min', 0,
		'max', 20000,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Hiring - Parameters",
		'id', "SalaryMaxLv",
		'name', "(To Be Deleted) Max Lv Daily Salary",
		'help', "The amount of money it costs to hire this merc for 1 day at max level",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', 10000,
		'min', 0,
		'max', 20000,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Hiring - Parameters",
		'id', "SalaryPreview",
		'name', "Salary Level 10",
		'help', "Expected salary at Level 10. All active game rules are applied.",
		'dont_save', true,
		'read_only', true,
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', 0,
	}),
	PlaceObj('PropertyDefText', {
		'category', "Hiring",
		'id', "LegacyNotes",
		'name', "Legacy Notes",
		'help', "Any info about the merc from previous titles.",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'translate', false,
		'lines', 4,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetMercStartingSalary",
		'code', function (self)
			local stSalary = self:GetProperty("StartingSalary")
			local tier = self:GetProperty("Tier")
			if IsGameRuleActive("CheaperPros") and (tier=="Elite" or tier=="Legendary") then
				local percent = GameRuleDefs.CheaperPros:ResolveValue("StartingSalaryModifier")
				stSalary = MulDivRound(stSalary, percent, 100)
			end
			return stSalary
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetSalaryIncreaseProp",
		'code', function (self)
			local salaryIncrease = self:GetProperty("SalaryIncrease")
			if IsGameRuleActive("Unionization") then
					local additional_salary_increase = GameRuleDefs.Unionization:ResolveValue("AdditionalSalaryIncrease")
					salaryIncrease = salaryIncrease + additional_salary_increase
				end
			return salaryIncrease
		end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "XP",
		'id', "StartingLevel",
		'name', "Starting Level",
		'help', "The level at which this merc starts in a new game",
		'template', true,
		'default', 1,
		'slider', true,
		'min', 1,
		'max', 10,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "immortal",
		'name', "Immortal",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "ImportantNPC",
		'name', "ImportantNPC",
		'help', "Units with this flag have a green badge above them.",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "reincarnate",
		'name', "Reincarnate",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "dummy",
		'name', "Dummy",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "militia",
		'name', "Militia Unit",
		'no_edit', true,
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "villain",
		'name', "Recurring Villain",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "neutral_retaliate",
		'name', "Retaliate",
		'help', "if enabled and the unit is Neutral, they will become hostile when damaged",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "General",
		'id', "max_dead_slot_tiles",
		'name', "max_dead_slot_tiles",
		'help', "Max tiles in InventoryDead slot. It's caclulated on death, when a unit drops its loot.",
		'no_edit', true,
		'template', true,
		'default', 24,
		'min', 1,
		'max', 24,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "VillainHealWoundProgress",
		'help', "Used only for villains",
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefStringList', {
		'category', "AI",
		'id', "AIKeywords",
		'template', true,
		'items', function (self) return AIKeywordsCombo end,
		'arbitrary_value', true,
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "AI",
		'id', "archetype",
		'name', "Archetype",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'preset_class', "AIArchetype",
		'default', "Soldier",
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "AI",
		'id', "script_archetype",
		'name', "Archetype",
		'no_edit', true,
		'no_validate', true,
		'template', true,
		'preset_class', "AIArchetype",
		'default', "",
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "AI",
		'id', "role",
		'name', "Enemy Role",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'preset_class', "EnemyRole",
		'default', "Default",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "AI",
		'id', "CanManEmplacements",
		'name', "Can Man Emplacements",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'default', true,
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "AI",
		'id', "current_archetype",
		'name', "Archetype",
		'read_only', true,
		'no_edit', true,
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'preset_class', "AIArchetype",
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "AI",
		'id', "RepositionArchetype",
		'name', "Reposition Archetype",
		'help', "if not specified the unit will use it's normal archetype for Reposition action",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'preset_class', "AIArchetype",
	}),
	PlaceObj('PropertyDefBool', {
		'category', "AI",
		'id', "AlwaysUseOpeningAttack",
		'name', "Always Use Opening Attack",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "AI",
		'id', "OpeningAttackType",
		'name', "Opening Attack Type",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'default', "Default",
		'items', function (self) return { "Default", "Overwatch", "PinDown" } end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "AI",
		'id', "PinnedDownChance",
		'name', "PinnedDown Chance",
		'help', "chance to use PinnedDown archetype when the unit is pinned down by enemy/enemies",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'default', 50,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "AI",
		'id', "MaxAttacks",
		'help', "max attacks to perform per turn",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'default', 3,
		'min', 1,
	}),
	PlaceObj('PropertyDefFunc', {
		'category', "AI",
		'id', "PickCustomArchetype",
		'help', "implement custom archetype selection logic for this unit; standard retreat/reposition logic overrides this choice",
		'template', true,
		'extra_code', "no_edit = function(self) return IsMerc(self) end",
		'params', "self, proto_context",
	}),
	PlaceObj('PropertyDefFunc', {
		'category', "Equipment",
		'id', "CustomEquipGear",
		'help', "implement custom logic for equipping starting gear for this unit; standard gearing logic is applied after this",
		'template', true,
		'params', "self, items",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SelectArchetype",
		'params', "proto_context",
		'code', function (self, proto_context)
			local archetype
			local func = empty_func
			
			if IsKindOf(self, "Unit") then
				local emplacement = g_Combat and g_Combat:GetEmplacementAssignment(self)
				if self.retreating then
					archetype = "Deserter"
				elseif self:HasStatusEffect("Panicked") then
					archetype = "Panicked"
				elseif self:HasStatusEffect("Berserk") then
					archetype = "Berserk"
				elseif emplacement then
					assert(self.CanManEmplacements)
					archetype = "EmplacementGunner"
					proto_context.target_interactable = emplacement
				elseif self.command == "Reposition" and self.RepositionArchetype then
					archetype = self.RepositionArchetype
				end
				
				-- check for scout archetype first
				local can_scout = not archetype
				can_scout = can_scout and (not g_Encounter or g_Encounter:CanScout())
				can_scout = can_scout and self.script_archetype ~= "GuardArea"
				if can_scout then
					local enemies = self:GetVisibleEnemies()
					if #enemies == 0 then
						self.last_known_enemy_pos = self.last_known_enemy_pos or AIPickScoutLocation(self)
						if self.last_known_enemy_pos then
							archetype = "Scout_LastLocation"
						end
					end
				end
				
				if not archetype then
					for _, descr in pairs(g_Pindown) do
						if descr.target == self then
							if self:Random(100) < self.PinnedDownChance then
								archetype = "PinnedDown"
							end
							break
						end
					end
				end
				local template= UnitDataDefs[self.unitdatadef_id]
				func = template and template.PickCustomArchetype or self.PickCustomArchetype
			end
			
			self.current_archetype = archetype or func(self, proto_context) or self.archetype or "Assault"
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "EquipStartingGear",
		'params', "items",
		'code', function (self, items)
			local func = empty_func
			if IsKindOf(self, "UnitData") then
				local template= UnitDataDefs[self.class]
				func = template and template.CustomEquipGear or self.CustomEquipGear
			end
			
			-- priority custom gearing rules
			func(self, items)
			
			-- default gearing rules:
			-- make sure there's an equipped weapon if possible
			if not self:GetItemInSlot("Handheld A", "BaseWeapon") then
				local has_weapon = self:TryEquip(items, "Handheld A", "Firearm")
				has_weapon = has_weapon or self:TryEquip(items, "Handheld A", "MeleeWeapon")
				has_weapon = has_weapon or self:TryEquip(items, "Handheld A", "HeavyWeapon")
			end
			
			local equipped = {}
			-- locked items that are not weapons add to the first inventory slot
			for i, item in ipairs(items) do
				if item.locked and not item:IsWeapon() and not IsKindOf(item, "Armor") then -- lock to the first inventory slot
					if self:CanAddItem("Inventory", item) then
						self:AddItem("Inventory", item)
						equipped[i] = true
					end
				end				
			end
			-- equip the rest of the equppable items when possible
			
			for i, item in ipairs(items) do
				if not equipped[i] then
					local slot
					if IsKindOf(item, "QuickSlotItem") then
						if self:CanAddItem("Handheld A", item) then
							slot = "Handheld A"
						elseif self:CanAddItem("Handheld B", item) then
							slot = "Handheld B"
						end
					elseif IsKindOf(item, "Armor") and not self:GetItemInSlot(item.Slot) then
						slot = item.Slot
					end
					if slot and self:CanAddItem(slot, item) then
						self:AddItem(slot, item)
						equipped[i] = true
					end
				end
			end
			
			-- make sure all equipped firearms have ammo
			local function reload_weapon(weapon)
				if not weapon.ammo or weapon.ammo.Amount <= 0 then
					local ammo = GetAmmosWithCaliber(weapon.Caliber, "sort")[1]
					if ammo then
						local tempAmmo = PlaceInventoryItem(ammo.id)
						tempAmmo.Amount = tempAmmo.MaxStacks
						weapon:Reload(tempAmmo, "suspend_fx")
						DoneObject(tempAmmo)
					end
				end
			end
			self:ForEachItemInSlot("Handheld A", "Firearm", reload_weapon)
			self:ForEachItemInSlot("Handheld B", "Firearm", reload_weapon)
			
			-- place the rest in Inventory slot
			for i, item in ipairs(items) do
				if not equipped[i] then
					local pos, reason = self:AddItem("Inventory", item)
					if not pos then
						print("Couldn't add starting item \'", item.class, "\' to unit", self.class, "because", reason, "max slots", self:GetMaxTilesInSlot("Inventory"))
					end		
				end
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "TryEquip",
		'params', "items, slot, class",
		'code', function (self, items, slot, class)
			local idx
			for i, item in ipairs(items) do
				local match = class ~= "Firearm" or not IsKindOfClasses(item, "HeavyWeapon", "FlareGun")
				match = match and IsKindOf(item, class) 
				if match and self:CanAddItem(slot, item) then
					idx = i
					break
				end
			end
			
			if idx then
				self:AddItem(slot, items[idx])
				table.remove(items, idx)
			end
			return not not idx
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "TryLoadAmmo",
		'params', "slot, weapon_class, ammo_id",
		'code', function (self, slot, weapon_class, ammo_id)
			local found
			local ammo = g_Classes[ammo_id]
			if not ammo then
				StoreErrorSource(self, string.format("Unit %s trying to load invalid ammo type '%s'", self.unitdatadef_id or self.class, ammo_id))
				return
			end
			self:ForEachItemInSlot(slot, weapon_class, function(weapon, slot_name, left, top, self, ammo_id, caliber)
				if weapon.Caliber ~= caliber then
					StoreErrorSource(self, string.format("Unit %s trying to load incompatible ammo type '%s' in their '%s'", self.unitdatadef_id or self.class, ammo_id, weapon.class))
					return
				end
				local tempAmmo = PlaceInventoryItem(ammo_id)
				tempAmmo.Amount = tempAmmo.MaxStacks
				weapon:Reload(tempAmmo, "suspend_fx")
				DoneObject(tempAmmo)
			end, self, ammo_id, ammo.Caliber)
		end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Villain",
		'id', "Lives",
		'name', "",
		'template', true,
		'extra_code', "no_edit = function(self) return not self.villain end",
		'default', 3,
		'min', 1,
		'max', 5,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "XP",
		'id', "Experience",
		'no_edit', true,
		'template', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "XP",
		'id', "RewardExperience",
		'name', "XP override",
		'help', "The amount of XP the unit will reward its enemies when defeated. If left unset the XPRewardTable table is used.",
		'template', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "XP",
		'id', "statGainingPoints",
		'no_edit', true,
		'template', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "XP",
		'id', "UnitPower",
		'help', "Unit power used in autoresolve: base unitLevel if non merc * basePower const",
		'dont_save', true,
		'read_only', true,
		'template', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "XP",
		'id', "unitPowerModifier",
		'name', "Unit Power Modifier",
		'help', "How effective(%) is the unit power in autoresolve.",
		'template', true,
		'default', 100,
		'min', 0,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Villain",
		'id', "DefeatBehavior",
		'name', "Defeat Behavior",
		'template', true,
		'extra_code', "no_edit = function(self) return not self.villain end",
		'default', "Dead",
		'items', function (self) return { "Dead", "Defeated" } end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Villain",
		'id', "RetreatBehavior",
		'name', "Retreat Behavior",
		'template', true,
		'extra_code', "no_edit = function(self) return not self.villain end",
		'default', "Full Retreat",
		'items', function (self) return { "None", "Individual", "Full Retreat" } end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Derived Stats",
		'id', "ActionPoints",
		'name', "Action Points",
		'help', "This parameters determines how much actions a merc can do in a single round",
		'extra_code', "no_edit = true",
		'scale', "AP",
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Derived Stats",
		'id', "MaxActionPoints",
		'name', "Max Action Points",
		'help', "This parameters determines how much actions a merc can do in a single round",
		'dont_save', true,
		'read_only', true,
		'no_edit', true,
		'template', true,
		'scale', "AP",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetMaxActionPoints",
		'code', function (self)
			local level = self:GetLevel()
			return ((3 + self:GetProperty("Agility") / 10) + (level / 3)) * const.Scale.AP
		end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Derived Stats",
		'id', "Tiredness",
		'read_only', true,
		'no_edit', true,
		'template', true,
		'default', 0,
		'min', -1,
		'max', 3,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "SetTired",
		'params', "value",
		'code', function (self, value)
			value = Clamp(value or 0, -1, 3)
			if self.Tiredness == value then
				return
			end
			
			self:RemoveStatusEffect("WellRested")
			self:RemoveStatusEffect("Tired")
			self:RemoveStatusEffect("Exhausted")
			self:RemoveStatusEffect("Unconscious")
			
			local oldValue = self.Tiredness or 0
			self.Tiredness = value
			if value == 3 then
				self.HitPoints = Max(1, self.HitPoints)
			elseif value~=0 and UnitTirednessEffect[value] then
				self:AddStatusEffect(UnitTirednessEffect[value])
			end
			
			if oldValue <= 0 and value >= 0 then
				Msg("UnitTiredAdded", self)
			elseif oldValue > 0 and value <= 0 then
				Msg("UnitTiredRemoved", self)
			end
			if value - oldValue > 0 then
				Msg("UnitTiredLevelAdded", self, value)	
			end
			
			if value - oldValue < 0 then
				Msg("UnitTiredLevelRemoved", self, value)	
			end
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "ChangeTired",
		'params', "delta",
		'code', function (self, delta)
			self:SetTired(self.Tiredness + delta)
		end,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Derived Stats",
		'id', "RestTimer",
		'read_only', true,
		'no_edit', true,
		'template', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Derived Stats",
		'id', "TravelTimerStart",
		'read_only', true,
		'no_edit', true,
		'template', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Derived Stats",
		'id', "TravelTime",
		'read_only', true,
		'no_edit', true,
		'template', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Derived Stats",
		'id', "HitPoints",
		'name', "Hit Points",
		'extra_code', "no_edit = true",
		'default', -1,
		'min', -1,
		'max', 100,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Derived Stats",
		'id', "MaxHitPoints",
		'name', "Max Hit Points",
		'read_only', true,
		'no_edit', true,
		'template', true,
		'default', 0,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetInitialMaxHitPoints",
		'code', function (self)
			local mod = self:GetProperty("villain") and const.Combat.LieutenantHpMod or 100
			local maxhp = MulDivRound(self:GetProperty("Health"), mod, 100)
			if HasPerk(self, "BeefedUp") then
				maxhp = MulDivRound(maxhp, 100 + CharacterEffectDefs.BeefedUp:ResolveValue("bonus_health"), 100)
			end
			return maxhp
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetModifiedMaxHitPoints",
		'code', function (self)
			local maxhp = self:GetInitialMaxHitPoints()
			local positive_mods_only = maxhp
			
			local idx = self:HasStatusEffect("Wounded")
			local effect = idx and self.StatusEffects[idx]
			if effect then
				local value = effect:ResolveValue("MaxHpReductionPerStack") or 0
				local maxreduce = effect:ResolveValue("MinMaxHp") or 0
				local min = MulDivRound(maxhp, maxreduce, 100)
				maxhp = Max(min, maxhp - effect.stacks * value)
			end
			return maxhp, positive_mods_only
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetInventoryMaxSlots",
		'code', function (self)
			return IsMerc(self) and Max(4, (self.Strength - 30)/5) or self.max_dead_slot_tiles or 20
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "IsDead",
		'code', function (self)
			if self.immortal then return false end
			return self.HitPoints <= 0
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetHealthAsText",
		'code', function (self)
			local max, max_positive = self:GetModifiedMaxHitPoints()
			if self:UIObscured() or self:UIConcealed() then
				return HpToText.Hidden
			elseif self.HitPoints >= 90 then
				return HpToText.Excellent
			elseif self.HitPoints >= 75 then
				return HpToText.Strong
			elseif self.HitPoints >= 60 then
				return HpToText.Healthy
			elseif self.HitPoints >= 45 and self.HitPoints ~= max_positive then
				return HpToText.Poor
			elseif self.HitPoints >= 25 and self.HitPoints ~= max_positive then
				return HpToText.Wounded
			elseif self.HitPoints >= 10 and self.HitPoints ~= max_positive then
				return HpToText.Critical
			elseif self.HitPoints > 0 and self.HitPoints ~= max_positive then
				return HpToText.Dying
			elseif self.HitPoints == 0 then
				return HpToText.Dead
			else 
				return HpToText.Uninjured
			end
		end,
	}),
	PlaceObj('PropertyDefStringList', {
		'category', "Likes And Dislikes",
		'id', "Likes",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'items', function (self) return MercPresetCombo() end,
	}),
	PlaceObj('PropertyDefStringList', {
		'category', "Likes And Dislikes",
		'id', "LearnToLike",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'items', function (self) return MercPresetCombo() end,
	}),
	PlaceObj('PropertyDefStringList', {
		'category', "Likes And Dislikes",
		'id', "Dislikes",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'items', function (self) return MercPresetCombo() end,
	}),
	PlaceObj('PropertyDefStringList', {
		'category', "Likes And Dislikes",
		'id', "LearnToDislike",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'items', function (self) return MercPresetCombo() end,
	}),
	PlaceObj('PropertyDefStringList', {
		'category', "Likes And Dislikes",
		'id', "LikedBy",
		'dont_save', true,
		'read_only', true,
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'items', function (self) return MercPresetCombo() end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetLikedBy",
		'code', function (self)
			local id = IsKindOf(self, "UnitDataCompositeDef") and self.id or self.unitdatadef_id
			local res = {}
			for k, v in pairs(UnitDataDefs) do
				if table.find(v:GetProperty("Likes"), id) then
					res[#res+1] = v.id
				end
			end
			return res
		end,
	}),
	PlaceObj('PropertyDefStringList', {
		'category', "Likes And Dislikes",
		'id', "DislikedBy",
		'dont_save', true,
		'read_only', true,
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'items', function (self) return MercPresetCombo() end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetDislikedBy",
		'code', function (self)
			local id = IsKindOf(self, "UnitDataCompositeDef") and self.id or self.unitdatadef_id
			local res = {}
			for k, v in pairs(UnitDataDefs) do
				if table.find(v:GetProperty("Dislikes"), id) then
					res[#res+1] = v.id
				end
			end
			return res
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetUnitPower",
		'code', function (self)
			return GetPowerOfUnit(self, "noMods")
		end,
	}),
	PlaceObj('PropertyDefPresetIdList', {
		'category', "Perks",
		'id', "StartingPerks",
		'name', "Starting Perks",
		'template', true,
		'extra_code', "editor_preview = true",
		'preset_class', "CharacterEffectCompositeDef",
		'preset_filter', function (preset, obj, prop_meta)
			return preset.object_class == "Perk"
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetStartingPerks",
		'code', function (self)
			return self.StartingPerks
		end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "Operation",
		'name', "Operation",
		'no_edit', true,
		'template', true,
		'default', "Idle",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'id', "OperationProfession",
		'no_edit', true,
		'template', true,
		'default', "Idle",
		'translate', false,
	}),
	PlaceObj('PropertyDefTable', {
		'id', "OperationProfessions",
		'name', "OperationProfessions",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "OperationInitialETA",
		'no_edit', true,
		'template', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "HiredUntil",
		'no_edit', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "Squad",
		'no_edit', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "OldSquad",
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "heal_wound_progress",
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "wounds_being_treated",
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "arriving_progress",
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "traveling_progress",
		'help', "Travelling activity progress",
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "randr_activity_progress",
		'no_edit', true,
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefText', {
		'id', "arrival_dir",
		'no_edit', true,
		'translate', false,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "gather_intel_progress",
		'help', "Intel item is discovered when progress is 1000",
		'no_edit', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', 0,
		'min', 0,
	}),
	PlaceObj('PropertyDefText', {
		'id', "gather_intel_item_id",
		'no_edit', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'translate', false,
	}),
	PlaceObj('PropertyDefText', {
		'id', "gather_intel_sector_id",
		'no_edit', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'translate', false,
	}),
	PlaceObj('PropertyDefTable', {
		'id', "stat_learning",
	}),
	PlaceObj('PropertyDefTable', {
		'id', "training_activity_progress",
	}),
	PlaceObj('PropertyDefBool', {
		'id', "already_spawned_on_map",
		'no_edit', true,
	}),
	PlaceObj('PropertyDefNestedList', {
		'id', "stains",
		'no_edit', true,
		'base_class', "UnitStain",
		'inclusive', true,
	}),
	PlaceObj('PropertyDefText', {
		'id', "retreat_to_sector",
		'no_edit', true,
		'translate', false,
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "Appearance",
		'id', "AppearancesList",
		'name', "Appearances List",
		'template', true,
		'base_class', "AppearanceWeight",
		'inclusive', true,
		'auto_expand', true,
	}),
	PlaceObj('PropertyDefText', {
		'category', "Appearance",
		'id', "ForcedAppearance",
		'no_edit', true,
		'translate', false,
	}),
	PlaceObj('PropertyDefButtons', {
		'category', "Spawn",
		'id', "SpawnAppearancesButton",
		'name', "",
		'buttons', {
			PlaceObj('PropertyDefPropButton', {
				'Name', "Spawn All NPCs",
				'FuncName', "SpawnAll",
			}),
		},
	}),
	PlaceObj('PropertyDefButtons', {
		'category', "Spawn",
		'id', "SpawnButton",
		'name', "",
		'buttons', {
			PlaceObj('PropertyDefPropButton', {
				'Name', "Spawn Random",
				'FuncName', "Spawn",
			}),
		},
	}),
	PlaceObj('PropertyDefFunc', {
		'category', "Spawn",
		'id', "Spawn",
		'name', "",
		'read_only', true,
		'no_edit', true,
		'params', "self, pos",
		'default', function (self, pos)
			local weighted_list = GetAppearancesListTotalWeight(self)
			local slot = AsyncRand(weighted_list.total_weight)
			local appearance = GetWeightedAppearance(weighted_list, slot)
			
			local spawn_pos =  GetTerrainCursorXY(UIL.GetScreenSize()/2)
			local obj = AppearanceObjectAME:new()
			obj:ApplyAppearance(appearance)
			obj:SetPos(spawn_pos)
			obj:SetGameFlags(const.gofRealTimeAnim)
		end,
	}),
	PlaceObj('PropertyDefFunc', {
		'category', "Spawn",
		'id', "SpawnAll",
		'name', "",
		'read_only', true,
		'no_edit', true,
		'default', function (self)
			local characters = {}
			local widths = {}
			local total_width = 0
			for i, descr in ipairs(self.AppearancesList) do
			  characters[i] = AppearanceObjectAME:new()
			  characters[i]:ApplyAppearance(descr.Preset)
			  local width = characters[i]:GetSize():sizex()
			  widths[i] = width
			  total_width =total_width + width + guim
			end
			
			
			local right = camera.GetRight()
			local lookat = camera.GetEye()
			local spawn_pos =  GetTerrainCursorXY(UIL.GetScreenSize()/2)
			spawn_pos = spawn_pos - SetLen(right, total_width / 2)
			for i, character in ipairs(characters) do
			  character:SetPos(spawn_pos)
			  character:Face(lookat)
			  character:SetGameFlags(const.gofRealTimeAnim)
			  spawn_pos = spawn_pos + SetLen(right,  widths[i] + guim)
			end
		end,
	}),
	PlaceObj('PropertyDefFunc', {
		'id', "GetLogName",
		'name', "",
		'read_only', true,
		'no_edit', true,
		'default', function (self)
			return self:GetDisplayName()
		end,
	}),
	PlaceObj('PropertyDefFunc', {
		'id', "GetLevel",
		'name', "",
		'read_only', true,
		'no_edit', true,
		'params', "self, baseLevel",
		'default', function (self, baseLevel)
			local curXp = self:GetProperty("Experience")
			local addLevel = 0
			if not IsMerc(self) and Game and not baseLevel then
				addLevel = GameDifficulties[Game.game_difficulty]:ResolveValue("unitBonusLevel") or 0
			end
			if not curXp then return self:GetProperty("StartingLevel") + addLevel end
			return CalcLevel(curXp) + addLevel
		end,
	}),
	PlaceObj('PropertyDefPresetIdList', {
		'category', "Equipment",
		'id', "Equipment",
		'template', true,
		'extra_code', "editor_preview = true",
		'preset_class', "LootDef",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetDisplayName",
		'code', function (self)
			return self.Nick ~= "" and self.Nick or self.Name
		end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "Group",
		'no_edit', true,
	}),
	PlaceObj('PropertyDefNestedList', {
		'category', "General",
		'id', "AdditionalGroups",
		'name', "Additional Groups",
		'template', true,
		'base_class', "AdditionalGroup",
	}),
	PlaceObj('PropertyDefStringList', {
		'id', "additional_groups",
		'arbitrary_value', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "ControlledBy",
		'read_only', true,
		'no_edit', true,
		'default', 1,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Hiring - Parameters",
		'id', "Tier",
		'name', "Tier",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', "Rookie",
		'items', function (self) return PresetGroupCombo("MercTiers", "Default") end,
	}),
	PlaceObj('PropertyDefCombo', {
		'category', "Hiring - Parameters",
		'id', "Specialization",
		'name', "Specialization",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', "None",
		'items', function (self) return PresetGroupCombo("MercSpecializations", "Default") end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Voice",
		'id', "pollyvoice",
		'name', "Polly Voice",
		'no_edit', "expression",
		'no_edit_expression', function (self, prop_meta) return config.ModdingToolsInUserMode end,
		'template', true,
		'default', "Brian",
		'items', function (self) return g_LocPollyActors end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Appearance",
		'id', "species",
		'name', "Species",
		'template', true,
		'default', "Human",
		'items', function (self) return { "Human", "Crocodile", "Hyena", "Lion", "Hen" } end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Appearance",
		'id', "body_type",
		'name', "Body Type",
		'template', true,
		'default', "Human",
		'items', function (self) return { "Human", "Small animal", "Large animal" } end,
	}),
	PlaceObj('PropertyDefChoice', {
		'category', "Appearance",
		'id', "gender",
		'name', "Gender",
		'template', true,
		'default', "N/A",
		'items', function (self) return { "N/A", "Male", "Female" } end,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "Appearance",
		'id', "infected",
		'name', "Infected",
		'template', true,
	}),
	PlaceObj('PropertyDefSet', {
		'category', "Appearance",
		'id', "blocked_spots",
		'name', "Blocked Spots",
		'template', true,
		'items', function (self) return { "Weaponrs", "Weaponls" } end,
	}),
	PlaceObj('PropertyDefText', {
		'category', "General",
		'id', "PersistentSessionId",
		'name', "Persistent Session Id",
		'help', "optional, all units spawned from this template will use the specified session id",
		'template', true,
		'translate', false,
	}),
	PlaceObj('PropertyDefBool', {
		'category', "General",
		'id', "HealPersistentOnSpawn",
		'name', "Heal Persistent Unit On Spawn",
		'help', "if this unit is a persistent unit, it will be healed once spawned from a unit marker",
		'template', true,
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "Voice",
		'id', "VoiceResponseId",
		'name', "Voice Response Id",
		'help', "The VoiceResponse preset used be this unit; same as the unit Id by default",
		'template', true,
		'preset_class', "VoiceResponse",
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "Voice",
		'id', "FallbackMissingVR",
		'name', "FallbackMissingVR",
		'help', "If no vr is found for this unit. Use this fallback unit for the vr. Applies only for Humans.",
		'template', true,
		'preset_class', "UnitDataCompositeDef",
		'default', "VillagerMale",
	}),
	PlaceObj('PropertyDefPresetId', {
		'category', "Appearance",
		'id', "RoamAnimationSet",
		'name', "Roam Animation Set",
		'help', "The VoiceResponse preset used be this unit; same as the unit Id by default",
		'template', true,
		'preset_class', "AnimationSet",
		'preset_group', "AmbientLife",
		'default', "Roam_Default",
	}),
	PlaceObj('PropertyDefText', {
		'category', "General",
		'id', "session_id",
		'no_edit', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "combat_damage_taken",
		'help', "persistable damage taken, used for determining when to add Wounded status",
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "time_of_death",
		'help', "time of death (satellite time)",
		'no_edit', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "randomization_seed",
		'no_edit', true,
		'default', 0,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Hiring - Parameters",
		'id', "DaysUntilOnline",
		'name', "Days Until Online",
		'help', "If the merc is set as offline at the beginning of the campaign through the randomess roll, it will automatically go online this amount of days after campaign start.",
		'template', true,
		'extra_code', "no_edit = function(self) return not IsMerc(self) end",
		'default', 5,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "AddWounds",
		'params', "wounds",
		'code', function (self, wounds)
			wounds = AdjustWoundsToHP(self, wounds or 1)
			if wounds > 0 then
				self:AddStatusEffect("Wounded", wounds)
			end
		end,
	}),
	PlaceObj('PropertyDefFunc', {
		'id', "AccumulateDamageTaken",
		'name', "",
		'read_only', true,
		'no_edit', true,
		'params', "self, amount",
		'default', function (self, amount)
			local Wounded = CharacterEffectDefs.Wounded
			local wounded_add = Wounded:ResolveValue("HpLossToAddStack")
			-- limit damage carried over from the past to the amount required for a single wound only
			self.combat_damage_taken = Min(self.combat_damage_taken, wounded_add)
			self.combat_damage_taken = self.combat_damage_taken + amount
			local threshold = MulDivRound(self:GetInitialMaxHitPoints(), Wounded:ResolveValue("WoundsImmunityThreshold"), 100)
			local stacks = 0
			while self.HitPoints < threshold and self.combat_damage_taken >= wounded_add do
				stacks = stacks + 1
				self.combat_damage_taken = self.combat_damage_taken - wounded_add
			end
			if stacks > 0 then self:AddWounds(stacks) end
		end,
	}),
	PlaceObj('ClassGlobalCodeDef', {
		'comment', "prop_table property to hold signature skill recharge data",
		'code', function ()
			table.insert(UnitProperties.properties, { id = "signature_recharge", editor = "prop_table", default = false, no_edit = true })
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetBaseCrit",
		'params', "weapon",
		'code', function (self, weapon)
			if not self then
				return weapon.CritChance + weapon.CritChanceScaled
			end
			
			return weapon.CritChance + MulDivRound(weapon.CritChanceScaled, self:GetLevel(), 10)
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "Getbase_BaseCrit",
		'params', "weapon",
		'code', function (self, weapon)
			if not self then
				return weapon.base_CritChance + weapon.base_CritChanceScaled
			end
			
			return weapon.base_CritChance + MulDivRound(weapon.base_CritChanceScaled, self:GetLevel(), 10)
		end,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "perkPoints",
		'name', "Perk Points",
		'help', "Avaliable points to spend on unlocking perks.",
		'default', 0,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "HasPassedTimeAfterDeath",
		'params', "givenTime",
		'code', function (self, givenTime)
			if self.time_of_death then
				local deathTimeH = self.time_of_death / const.Scale.h
				local currentTimeH = Game.CampaignTime / const.Scale.h
				if deathTimeH + givenTime <= currentTimeH then
					return true
				end
			end
			return false
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetToughness",
		'code', function (self)
			local toughness = self:GetLevel() * 1000
			local stats = UnitPropertiesStats:GetProperties()
			for _, stat in ipairs(stats) do
				toughness = toughness + self[stat.id]
			end
			return toughness
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "RechargeSignatures",
		'code', function (self)
			self.signature_recharge = {}
			ObjModified(self)
		end,
	}),
})

PlaceObj('ClassDef', {
	DefParentClassList = {
		"PropertyObject",
		"Modifiable",
	},
	DefPropertyTranslation = true,
	group = "Zulu",
	id = "UnitPropertiesStats",
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Health",
		'name', T(561192724204, --[[ClassDef Zulu UnitPropertiesStats name]] "Health"),
		'help', T(755618869033, --[[ClassDef Zulu UnitPropertiesStats help]] "Represents both the physical well-being of a merc and the amount of damage they can take before becoming downed."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Agility",
		'name', T(427915460935, --[[ClassDef Zulu UnitPropertiesStats name]] "Agility"),
		'help', T(313570226997, --[[ClassDef Zulu UnitPropertiesStats help]] "Measures how well a merc reacts physically to a new situation. Affects the total amount of AP, free movement at start of turn, and how stealthy the merc is."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Dexterity",
		'name', T(460461870476, --[[ClassDef Zulu UnitPropertiesStats name]] "Dexterity"),
		'help', T(485643076124, --[[ClassDef Zulu UnitPropertiesStats help]] "Measures a merc's ability to perform delicate or precise movements correctly. Affects bonus from aiming and Stealth Kill chance."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Strength",
		'name', T(736846833602, --[[ClassDef Zulu UnitPropertiesStats name]] "Strength"),
		'help', T(790754099931, --[[ClassDef Zulu UnitPropertiesStats help]] "Represents muscle and brawn. It's particularly important in Melee combat, affects throwing range and the size of the personal inventory of the character."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Wisdom",
		'name', T(140562214443, --[[ClassDef Zulu UnitPropertiesStats name]] "Wisdom"),
		'help', T(731447408225, --[[ClassDef Zulu UnitPropertiesStats help]] "Affects a merc's ability to learn from experience and training. Affects wilderness survival and the chance to notice hidden items and enemies."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Leadership",
		'name', T(693671613488, --[[ClassDef Zulu UnitPropertiesStats name]] "Leadership"),
		'help', T(396825125419, --[[ClassDef Zulu UnitPropertiesStats help]] "Measures charm, respect and presence. Affects the rate for training militia and other mercs. Affects the chance for getting positive and negative Morale events."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Marksmanship",
		'name', T(616386794188, --[[ClassDef Zulu UnitPropertiesStats name]] "Marksmanship"),
		'help', T(403638137917, --[[ClassDef Zulu UnitPropertiesStats help]] "Reflects a merc's ability to shoot accurately at any given target with a firearm."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Mechanical",
		'name', T(302186486914, --[[ClassDef Zulu UnitPropertiesStats name]] "Mechanical"),
		'help', T(338853681186, --[[ClassDef Zulu UnitPropertiesStats help]] "Rates a merc's ability to repair damaged, worn-out or broken items and equipment. Important for lockpicking, machine handling and hacking electronic devices. Used for detecting and disarming non-explosive traps."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Explosives",
		'name', T(205333258567, --[[ClassDef Zulu UnitPropertiesStats name]] "Explosives"),
		'help', T(767865457232, --[[ClassDef Zulu UnitPropertiesStats help]] "Determines a merc's ability to use grenades and other explosives and affects damage and mishap chance when using thrown items. Used for detecting and disarming explosive traps."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('PropertyDefNumber', {
		'category', "Stats",
		'id', "Medical",
		'name', T(295773259174, --[[ClassDef Zulu UnitPropertiesStats name]] "Medical"),
		'help', T(249121777425, --[[ClassDef Zulu UnitPropertiesStats help]] "Represents a merc's medical knowledge and ability to heal the wounded."),
		'template', true,
		'default', 60,
		'slider', true,
		'min', 0,
		'max', 100,
		'modifiable', true,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetAttributes",
		'code', function (self)
			local result = self:GetProperties()
			result = table.ifilter(result, function(k, v)
				return v.id == "Health" or
							v.id == "Agility" or
							v.id == "Dexterity" or
							v.id == "Strength" or
							v.id == "Wisdom"
			end)
			return result
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetSkills",
		'code', function (self)
			local result = self:GetProperties()
			result = table.ifilter(result, function(k, v)
				return v.id == "Marksmanship" or
							v.id == "Mechanical" or
							v.id == "Explosives" or
							v.id == "Medical"  or
							v.id == "Leadership"
			end)
			return result
		end,
	}),
})

PlaceObj('ClassDef', {
	group = "Zulu",
	id = "UnitTarget",
	PlaceObj('PropertyDefCombo', {
		'id', "TargetUnit",
		'name', "Target Unit",
		'help', "Target unit for match",
		'items', function (self) return GetTargetUnitCombo() end,
	}),
	PlaceObj('PropertyDefBool', {
		'id', "DisableContextModification",
		'help', "Disables modification of the current context units. Use this option when you don't want to affect the context of following conditions/effects.",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "Match",
		'params', "target, unit, context",
		'code', function (self, target, unit, context)
			if Groups[target] then
				if IsKindOfClasses(unit, "Unit", "CheeringDummy") and unit:IsInGroup(target) then
					return true
				end
			end
			
			if UnitDataDefs[target] and IsKindOfClasses(unit, "Unit", "UnitData") then
				return target == unit.unitdatadef_id or target == unit.class
			end
			
			if target == "any" then
				return true
			elseif IsKindOf(unit, "Unit") and target== "any merc" then
			 	return unit:IsMerc()
			elseif IsKindOf(unit, "UnitData") and target == "any merc" then
				return IsMerc(UnitDataDefs[unit.class])
			elseif target ==  "player mercs on map" then
				return IsKindOf(unit, "Unit") and unit.team and unit.team.side == "player1"
			elseif (target == "current unit") then
				return  table.find(context and context.target_units or empty_table, unit)
			end
			return false
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "MatchMapUnit",
		'params', "target, unit, context",
		'code', function (self, target, unit, context)
			if target == "any merc" then
				return unit:IsMerc()
			elseif UnitDataDefs[target] then
				return target == unit.unitdatadef_id or target == unit.class
			elseif Groups[target] and unit:IsInGroup(target) then
				return true
			elseif target == "any" then
				return true
			elseif target == "player mercs on map" then
				return unit.team and unit.team.side == "player1"
			elseif target == "current unit" then
				return  table.find(context and context.target_units or empty_table, unit)
			end
			return false
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetMatchedMapUnits",
		'params', "target, context",
		'code', function (self, target, context)
			local units
			if target == "any merc" then
				units = {}
				local IsMerc = Unit.IsMerc
				for i, unit in ipairs(g_Units) do
					if IsMerc(unit) then
						units[#units + 1] = unit
					end
				end
			elseif target == "any" then
				units = g_Units
			elseif target == "player mercs on map" then
				local idx = table.find(g_Teams, "side", "player1")
				if idx then
					units = g_Teams[idx].units
				end
			elseif target == "current unit" then
				if context then
					units = context.target_units
				end
			elseif UnitDataDefs[target] then
				units = {}
				for i, unit in ipairs(g_Units) do
					if target == unit.unitdatadef_id or target == unit.class then
						units[#units + 1] = unit
					end
				end
			elseif Groups[target] then
				for _, u in ipairs(Groups[target]) do
					if IsKindOf(u, "Unit") then
						units = units or {}
						units[#units+1] = u
					end
				end
			end
			return units
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "MatchMapUnits",
		'params', "obj, context",
		'code', function (self, obj, context)
			local units, new_units, triggered
			local unitsAreClassUnit = true
			local targetUnit = self.TargetUnit
			if targetUnit == "player mercs on map" then
				local team = GetCampaignPlayerTeam()
				if team then
					units = team.units
				end
			end
			
			if context and not units then
				if targetUnit == "current unit" then
					units = context.target_units
				elseif context.is_sector_unit then
					if not obj then return false end
					units = {obj}
				end
				unitsAreClassUnit = false
			end
			
			-- performance optimization
			local matchFunc = unitsAreClassUnit and self.MatchMapUnit or self.Match
			local negate = self.Negate
			local replace_units = not self.DisableContextModification and type(context) == "table"
			
			for _, unit in ipairs(units or g_Units) do
				assert(not unitsAreClassUnit or IsKindOf(unit, "Unit"))
				if matchFunc(self, targetUnit, unit, context) and self:UnitCheck(unit, obj, context) then
					triggered = true
					if not replace_units then
						return true
					end
					if not negate then
						new_units = new_units or {}
						table.insert_unique(new_units, unit)
					end
				elseif negate and replace_units then
					new_units = new_units or {}
					table.insert_unique(new_units, unit)
				end
			end
			
			if replace_units then
				context.target_units = new_units
			end
			
			return triggered
		end,
	}),
	PlaceObj('ClassMethodDef', {
		'name', "UnitCheck",
		'params', "unit, obj,context",
		'code', function (self, unit, obj,context)
			return true
		end,
	}),
})

PlaceObj('ClassDef', {
	Comment = "Used to define multiple unit_types to choose randomly from",
	group = "Zulu",
	id = "UnitTypeListWithWeights",
	PlaceObj('PropertyDefPresetId', {
		'id', "unitType",
		'name', "Unit Type",
		'help', "Type of the unit",
		'preset_class', "UnitDataCompositeDef",
		'extra_item', "empty",
		'default', "",
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "spawnWeight",
		'name', "Spawn Weight",
		'help', "The weight to assign for the given unit that determines the chance of choosing it",
		'default', 100,
		'min', 1,
		'max', 100,
	}),
	PlaceObj('PropertyDefNestedList', {
		'id', "conditions",
		'name', "Conditions",
		'help', "The unit is only added to the weight pool if the conditions pass.",
		'base_class', "Condition",
	}),
	PlaceObj('ClassMethodDef', {
		'name', "GetEditorView",
		'code', function (self)
			return tostring(self.unitType)
		end,
	}),
	PlaceObj('PropertyDefCombo', {
		'id', "visualOverride",
		'name', "Override Visuals",
		'items', function (self) return PresetsCombo("UnitDataCompositeDef") end,
	}),
	PlaceObj('PropertyDefText', {
		'id', "nameOverride",
		'name', "Override Name",
	}),
})

PlaceObj('PresetDef', {
	DefParentClassList = {
		"ListPreset",
	},
	group = "Zulu",
	id = "WeaponColor",
	PlaceObj('PropertyDefText', {
		'id', "name",
	}),
	PlaceObj('PropertyDefText', {
		'id', "Slot",
		'no_edit', true,
		'default', T(898895049831, --[[PresetDef WeaponColor default]] "Color"),
	}),
	PlaceObj('PropertyDefText', {
		'id', "Description",
	}),
	PlaceObj('PropertyDefColor', {
		'id', "color",
		'default', RGBA(255, 255, 255, 255),
	}),
	PlaceObj('PropertyDefRange', {
		'id', "Roughness",
		'name', "Roughness",
		'min', -128,
		'max', 127,
	}),
	PlaceObj('PropertyDefRange', {
		'id', "Metallic",
		'name', "Metallic",
		'min', -256,
		'max', 254,
	}),
	PlaceObj('PropertyDefNumber', {
		'id', "Cost",
		'name', "Cost (Parts)",
		'help', "The cost of the upgrade in parts",
		'default', 0,
	}),
})