File size: 195,819 Bytes
b6a38d7 |
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 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 |
-- ========== GENERATED BY ClassDef Editor (Ctrl-Alt-F3) DO NOT EDIT MANUALLY! ==========
DefineClass.ApplyGuiltyOrRighteous = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "effectType", name = "effectType", help = "Whether the effect is possive or negative (proud or guilty)",
editor = "combo", default = "positive", items = function (self) return { "positive", "negative" } end, },
},
EditorView = Untranslated("Apply guilty or righteous effect on unit"),
Documentation = "Apply guilty or righteous effect on unit",
}
function ApplyGuiltyOrRighteous:__exec(obj, context)
ApplyGuiltyOrRighteousEffect(self.effectType)
end
function ApplyGuiltyOrRighteous:GetUIText(effect)
if self.effectType == "positive" then
return T(235589045798, "Some mercs may <em>approve</em> of this.")
else
return T(596690068964, "Some mercs may <em>regret</em> this.")
end
end
function ApplyGuiltyOrRighteous:GetEditorView()
local helperText = self.effectType == "positive" and "positive(righteous)" or "negative(guilty)"
return Untranslated("Apply " .. helperText .. " effect on unit" )
end
DefineClass.BanterSetUnitInteraction = {
__parents = { "Effect", "UnitTarget", "BanterFunctionObjectBase", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Banters", name = "Banters", help = "List of banters to play.",
editor = "preset_id_list", default = {}, preset_class = "BanterDef", item_default = "", },
{ id = "Enabled", name = "Enabled", help = "Whether the banter is enabled.",
editor = "bool", default = true, },
},
EditorView = Untranslated("Set banters to play when interacting with unit."),
Documentation = "Set banters to play when interacting with unit.",
EditorNestedObjCategory = "Interactions",
}
function BanterSetUnitInteraction:GetError()
if not self.Banters then
return "No banters"
end
for i,banter_id in ipairs(self.Banters) do
if not Banters[banter_id] then
return "Invalid banter ID " .. banter_id
end
end
end
function BanterSetUnitInteraction:__exec(obj, context)
context = type(context) == "table" and context or {}
local triggered = self:MatchMapUnits(obj, context)
if not triggered or not context.target_units then return end
for i,unit in ipairs(context.target_units) do
unit.banters = self.Enabled and table.copy(self.Banters)
end
end
DefineClass.BobbyRayConsumeStock = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ItemConsumeProbability", help = "Probability of each item to get picked for consumption",
editor = "number", default = 13,
default = const.BobbyRay.FakePurchase_PickProbability, scale = "%", slider = true, min = 0, max = 100, modifiable = true, },
{ id = "MinimumStockConsumption", help = "Minimum percentage of available stock consumed",
editor = "number", default = 25,
default = const.BobbyRay.FakePurchase_StockConsumedMin, scale = "%", slider = true, min = 0, max = 100, modifiable = true, },
{ id = "MaximumStockConsumption", help = "Maximum percentage of available stock consumed (if only one unit is available, it is always consumed)",
editor = "number", default = 50,
default = const.BobbyRay.FakePurchase_StockConsumedMax, scale = "%", slider = true, min = 0, max = 100, modifiable = true, },
},
EditorNestedObjCategory = "Bobby Ray",
EditorView = Untranslated("Consumes some of Bobby Ray's stock"),
Documentation = "Consumes some of Bobby Ray's stock to simulate other buyers.\n\nEach item is evaluated independently.\nA roll with ItemConsumeProbability change determines whether an item will be purchased or not.\nIf chosen, a percentage of its stock is consumed (at least one unit is always consumed), between Min and Max StockConsumption values.",
}
function BobbyRayConsumeStock:__exec(obj, context)
BobbyRayStoreConsumeRandomStock(self.ItemConsumeProbability, self.MinimumStockConsumption, self.MaximumStockConsumption)
end
DefineClass.BobbyRayRestockShop = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "RestockModifier_Standard", help = "Modifier to the number of standard items chosen for restock per event (applied to the Restock_StandardPercentage variables defined in the const editor).\n\n100 causes no change.",
editor = "number", default = 100, scale = "%", slider = true, min = 10, max = 500, modifiable = true, },
{ id = "RestockModifier_Used", help = "Modifier to the number of used items chosen for restock per event (applied to the Restock_UsedPercentage variables defined in the const editor).\n\n100 causes no change.",
editor = "number", default = 100, scale = "%", slider = true, min = 10, max = 500, modifiable = true, },
},
EditorNestedObjCategory = "Bobby Ray",
EditorView = Untranslated("Restocks Bobby Ray's Shop"),
Documentation = "Restocks Bobby Ray's Shop\n\nFrom the whole pool of items that can appear in the shop (with respect to tier), a percentage between Restock_PercentageMin and Restock_PercentageMax (see the const editor, with separate variables controlling standard and used items) is restocked.\n\nThe above values are further multiplied by this effect's RestockModifier. Values below 100 decrease the number of items picked for restocking, values above 100 increase it.\n\nItems already present in the shop get their stock recalculated (never decreased, but restocking may have no effect), otherwise a new entry is created.",
}
function BobbyRayRestockShop:__exec(obj, context)
BobbyRayStoreRestock(self.RestockModifier_Standard, self.RestockModifier_Used)
end
DefineClass.BobbyRaySetState = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "State",
editor = "combo", default = "Closed", items = function (self) return {"Closed", 1, 2, 3, 4, 5, 6, 7, 8} end, },
},
EditorNestedObjCategory = "Bobby Ray",
EditorView = Untranslated("Sets shop tier availability"),
Documentation = "Possible values are:\nClosed (default, 0)\nTier-i unlocked (i>=1)",
}
function BobbyRaySetState:__exec(obj, context)
SetQuestVar(QuestGetState("BobbyRayQuest"), "UnlockedTier", self.State == "Closed" and 0 or self.State)
end
DefineClass.ChangeTiredness = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "delta", name = "Delta",
editor = "number", default = 0, },
},
RequiredObjClasses = {
"Unit",
"UnitData",
},
EditorView = Untranslated("Changes a unit's Energy"),
Documentation = "Changes a unit's Energy",
EditorNestedObjCategory = "Units",
}
function ChangeTiredness:__exec(obj, context)
if IsKindOfClasses(obj, "Unit", "UnitData") and not obj:IsDead() then
obj:ChangeTired(self.delta)
end
end
DefineClass.CityGrantLoyalty = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "City", help = "Change loyalty of the specified city",
editor = "choice", default = false, items = function (self) return table.map(GetCurrentCampaignPreset().Cities, "Id") end, },
{ id = "Amount", help = "Amount of loyalty to change with.",
editor = "number", default = 0, },
{ id = "SpecialConversationMessage", name = "Special Conversation Message", help = "The message to display in the log when the effect is executed from a conversation phrase.",
editor = "text", default = false, translate = true, },
},
EditorView = Untranslated("Add <Amount> to city <u(City)> loyalty."),
Documentation = "Grants a given value of loyalty to a given city. The loyalty can be negative.",
}
function CityGrantLoyalty:GetError()
if not self.City then
return "Missing City"
end
end
function CityGrantLoyalty:__exec(obj, context)
local msgPrefix = false
if IsKindOf(obj, "QuestsDef") and QuestIsBoolVar(obj,"Completed",true) then
msgPrefix = T{858740141061, "Mission <DisplayName> completed", DisplayName = obj.DisplayName}
else
msgPrefix = self.SpecialConversationMessage or ""
end
CityModifyLoyalty(self.City, self.Amount, msgPrefix)
end
function CityGrantLoyalty:GetPhraseTopRolloverText(negative, template, game)
local city = gv_Cities and gv_Cities[self.City]
local city_name =city and city.DisplayName or Untranslated(self.City)
if self.Amount>0 then
return T{571842717111, "Gained <em><Amount> Loyalty</em> with <em><City></em>",Amount = self.Amount, City = city_name}
elseif self.Amount<0 then
return T{749649970601, "Lost <em><Amount> Loyalty</em> with <em><City></em>",Amount = -self.Amount, City = city_name}
end
end
DefineClass.CompleteGuardpostObjective = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "GuardpostObjective", name = "GuardpostObjective",
editor = "preset_id", default = false, preset_class = "GuardpostObjective", },
},
EditorView = Untranslated("Complete guardpost objective <u(GuardpostObjective)>"),
Documentation = "Complete a guardpost objective, weakening the guardpost.",
EditorNestedObjCategory = "Sectors",
}
function CompleteGuardpostObjective:__exec(obj, context)
SetGuardpostObjectiveCompleted(self.GuardpostObjective)
end
DefineClass.ConversateWithUnit = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Group", name = "Group", help = "The group to affect. If left as default (empty) the interactable the effect is attached to will be affected.",
editor = "combo", default = "", items = function (self) return GridMarkerGroupsCombo() end, },
},
EditorView = Untranslated("Start a conversation with the unit of group"),
Documentation = "Start a conversation with the unit of group",
EditorNestedObjCategory = "Interactions",
}
function ConversateWithUnit:GetError()
if not self.Group then
return "No group"
end
end
function ConversateWithUnit:__exec(obj, context)
local interactable = false
local allInGroup = Groups[self.Group]
for i, obj in ipairs(allInGroup) do
if IsKindOf(obj, "Interactable") then
interactable = obj
break
end
end
if not interactable then return end
local unitsOnMap = GetAllPlayerUnitsOnMap()
local closestUnit = false
local closestDistance = false
for i, u in ipairs(unitsOnMap) do
if not CanInteractWith_SyncHelper(u, interactable) then goto continue end
local dist = IsValid(u) and u:GetDist(interactable)
if not closestDistance or dist < closestDistance then
closestDistance = dist
closestUnit = u
end
::continue::
end
if closestUnit then
local conversation = FindEnabledConversation(interactable)
if conversation then
OpenConversationDialog(closestUnit, conversation, false, "interaction", interactable)
end
end
end
DefineClass.CustomCodeEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "custom_code", name = "Custom Code", help = "Runs this code.",
editor = "text", default = false, },
},
EditorView = Untranslated("Execute custom code"),
Documentation = "Executes custom code",
}
function CustomCodeEffect:__exec(obj, context)
if not self.custom_code then return end
local custom_code_func, err = load(self.custom_code)
if custom_code_func then
-- Procall to ensure there isnt a yield (it cant be saved)
procall(custom_code_func)
else
assert(custom_code_func)
print(err)
end
end
function CustomCodeEffect:GetError()
if self.custom_code then
local func, err = load(self.custom_code)
if not func then
return err
end
end
end
DefineClass.DisableInteractionMarkerEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Group", name = "Group", help = "The group to affect. If left as default (empty) the interactable the effect is attached to will be affected.",
editor = "combo", default = "", items = function (self) return GridMarkerGroupsCombo() end, },
{ id = "Negate", name = "Negate", help = "Enable interaction markers instead.",
editor = "bool", default = false, },
},
Documentation = "Disable interaction markers of a specific group.",
EditorNestedObjCategory = "Interactable",
}
function DisableInteractionMarkerEffect:__exec(obj, context)
local groupName = self.Group
if groupName == "" then
if context and context.interactable and IsKindOf(context.interactable, "Interactable") then
context.interactable.enabled = self.Negate
elseif IsKindOf(obj, "Interactable") then
obj.enabled = self.Negate
else
assert(not "Non interactable object with DisableInteractionMarker effect and no group.")
end
return
end
MapForEach("map", "Interactable", function(m)
if table.find(m.Groups, groupName) then
m.enabled = self.Negate
end
end)
end
function DisableInteractionMarkerEffect:GetEditorView()
if self.Group == "" then
if self.Negate then
return T(299761711576, "Enable attached interaction marker.")
else
return T(311484226676, "Disable attached interaction marker.")
end
end
if self.Negate then
return T{697268621451, "Enable interaction markers of group <u(Group)>", self}
else
return T{571476004863, "Disable interaction markers of group <u(Group)>", self}
end
end
DefineClass.EndSectorWarningState = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
EditorView = Untranslated("End the current sector's Warning State"),
Documentation = "End the Warning State for the current sector.",
EditorNestedObjCategory = "Sector effects",
}
function EndSectorWarningState:__exec(obj, context)
if gv_SatelliteView then return end
EndWarningState()
end
DefineClass.ExecForEachUnitInSector = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Sector", help = "Sector id",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "Effects", name = "Effects", help = "Effects to execute.",
editor = "nested_list", default = false, base_class = "Effect", },
},
Documentation = 'Executes effects for all units in all squads in the given sector. Target unit effects must be with TargetUnit = "current unit"',
EditorView = Untranslated("For each unit from sector '<u(Sector)>' execute all nested effects."),
EditorNestedObjCategory = "Units",
}
function ExecForEachUnitInSector:__exec(obj, context)
local effects = self.Effects
if not effects or #effects == 0 then return true end
if not context then context = {} end
context.is_sector_unit = true
context.target_units = {}
local squads = GetSquadsInSector(self.Sector)
for i, squad in ipairs(squads) do
for j, unit_id in ipairs(squad.units) do
local unit = gv_UnitData[unit_id]
context.target_units[1] = unit
for _, effect in ipairs(effects) do
effect:__exec(unit, context)
end
end
end
context.is_sector_unit = false
end
DefineClass.Explosion = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "LocationGroup", name = "Location Group", help = "Object group defining the location of the effect.",
editor = "combo", default = false, items = function (self) return table.keys2(Groups) end, },
{ id = "ExplosionType", help = "What kind of grenade/mine is the explosion caused by.",
editor = "combo", default = "Landmine", items = function (self) return GrenadesComboItems({"Landmine"}) end, },
{ id = "Damage", help = "Damage to be done.",
editor = "number", default = 30, min = 0, max = 200, },
{ id = "AreaOfEffect", name = "Area of Effect", help = "the blast range (radius) in number of tiles.",
editor = "number", default = 3, min = 0, max = 20, },
{ id = "Noise", name = "Noise", help = "Range (in tiles) in which the explosion alerts unaware enemies.",
editor = "number", default = 20, template = true, min = 0, max = 100, modifiable = true, },
{ id = "AppliedEffect", name = "Applied Effect", help = "What effect to be applied on the victim when the damage is dealt.",
editor = "preset_id", default = false, preset_class = "CharacterEffectCompositeDef", preset_group = "Default", },
{ id = "aoeType", name = "AOE Type", help = "additional effect that happens after the explosion (optional)",
editor = "choice", default = "none", template = true, items = function (self) return {"none", "fire", "smoke", "teargas", "toxicgas"} end, },
},
EditorView = T(892386429862, --[[EffectDef Effects Explosion value]] "Create an explosion"),
Documentation = "Create an explosion",
}
function Explosion:GetError()
if not self.LocationGroup then
return "Set the Location Group"
end
end
function Explosion:__exec(obj, context)
local objs = Groups and self.LocationGroup and Groups[self.LocationGroup] or empty_table
if #objs <= 0 then
return
end
local pos = AveragePoint(objs)
local weapon = PlaceObject((self.ExplosionType == "Landmine") and "Landmine" or "Grenade")
weapon.AreaOfEffect = self.AreaOfEffect
weapon.BaseDamage = self.Damage
weapon.Noise = self.Noise
weapon.AppliedEffect = self.AppliedEffect
weapon.aoeType = self.aoeType
local proj = PlaceObject("FXGrenade")
proj:SetPos(pos)
proj.fx_actor_class = self.ExplosionType
CreateGameTimeThread(function()
ExplosionDamage(nil, weapon, pos, proj)
DoneObject(proj)
DoneObject(weapon)
end)
end
DefineClass.FailGuardpostObjective = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "GuardpostObjective", name = "GuardpostObjective",
editor = "preset_id", default = false, preset_class = "GuardpostObjective", },
},
EditorView = Untranslated("Fail guardpost objective <u(GuardpostObjective)>"),
Documentation = "Fail a guardpost objective",
EditorNestedObjCategory = "Sectors",
}
function FailGuardpostObjective:__exec(obj, context)
SetGuardpostObjectiveFailed(self.GuardpostObjective)
end
DefineClass.ForceResetAmbientLife = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
EditorView = Untranslated("Forces Reset of Ambient Life Behavior(Alt-Shift-A cheat)"),
Documentation = "Does the same thing as the Alt + Shift + A which resets the Ambient life",
}
function ForceResetAmbientLife:__exec(obj, context)
Msg("AmbientLifeDespawn")
Msg("WallVisibilityChanged")
g_AmbientLifeSpawn = true
Msg("AmbientLifeSpawn")
end
function ForceResetAmbientLife:__waitexec(obj, context)
self:__exec(obj, context)
WaitMsg("AmbientLifeSpawned")
end
function ForceResetAmbientLife:__skip(obj, context)
self:__exec(obj, context)
end
DefineClass.GoBerserk = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
RequiredObjClasses = {
"Unit",
},
EditorView = Untranslated("Go Berserk"),
Documentation = "Go Berserk",
EditorNestedObjCategory = "Units",
}
function GoBerserk:__exec(obj, context)
if IsKindOf(obj, "Unit") and not obj:IsDead() then
end
end
DefineClass.GrantExperienceEffect = {
__parents = { "UnitTarget", "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Amount", name = "Amount", help = "Choose one of the predefined amounts",
editor = "combo", default = "XPQuestReward_Small", items = function (self) return GetQuestRewardConstItems() end, },
{ id = "logImportant", name = "Log as Important", help = "Whther to show the XP gain as important message in the combat log.",
editor = "bool", default = false, },
},
EditorView = T(785742586188, --[[EffectDef Effects GrantExperienceEffect value]] "Grant <u(Amount)> to unit <u(TargetUnit)>"),
Documentation = "Grant experience to units. This is to be used when a map is loaded, for satellite view use GrantExperienceSector",
EditorNestedObjCategory = "Units",
}
function GrantExperienceEffect:__exec(obj, context)
if not context then context = {} end
local units = self:MatchMapUnits(obj, context)
if units and context.target_units then
local amount = self.Amount
if type(amount) == "string" then
if const[amount] then
amount = const[amount]
else
amount = tonumber(amount)
end
end
RewardTeamExperience({ RewardExperience = amount }, { units = context.target_units }, self.logImportant)
end
end
function GrantExperienceEffect:UnitCheck(unit, obj, context)
return true
end
DefineClass.GrantExperienceSector = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Sector", name = "Sector", help = "Sector",
editor = "combo", default = "current", items = function (self) return table.iappend({{text="current",value="current"}}, GetCampaignSectorsCombo()) end, },
{ id = "Amount", name = "Amount", help = "Choose one of the predefined amounts",
editor = "combo", default = "XPQuestReward_Small", items = function (self) return GetQuestRewardConstItems() end, },
{ id = "logImportant", name = "Log as Important", help = "Whther to show the XP gain as important message in the combat log.",
editor = "bool", default = false, },
},
EditorView = T(990833526031, --[[EffectDef Effects GrantExperienceSector value]] "Grant <u(Amount)> to all player units on sector <u(Sector)>"),
Documentation = "Grant experience to all player mercs on the specified sector.",
EditorNestedObjCategory = "Units",
}
function GrantExperienceSector:__exec(obj, context)
local sector_id
local getUnits = false
if self.Sector == "current" then
sector_id = gv_CurrentSectorId
getUnits = not gv_SatelliteView
else
sector_id = self.Sector
end
local units = GetPlayerSectorUnits(sector_id, getUnits)
if units then
local amount = self.Amount
if type(amount) == "string" then
if const[amount] then
amount = const[amount]
else
amount = tonumber(amount)
end
end
RewardTeamExperience({ RewardExperience = amount }, { units = units, sector = sector_id }, self.logImportant)
end
end
function GrantExperienceSector:GetError()
local amount = self.Amount
if type(amount) == "string" and not const[amount] and not tonumber(amount) then
return "Invalid amount " .. tostring(amount) .. " - should be a number or a const"
end
end
function GrantExperienceSector:UnitCheck(unit, obj, context)
return true
end
function GrantExperienceSector:GetPhraseTopRolloverText(negative, template, game)
local sector_id
local getUnits = false
if self.Sector == "current" then
sector_id = gv_CurrentSectorId
getUnits = not gv_SatelliteView
else
sector_id = self.Sector
end
local units = game and GetPlayerSectorUnits(sector_id, getUnits) or T(111137020067, "[Mercs]")
local names = game and ConcatListWithAnd(table.map(units, function(o) return o.Nick; end)) or units
local amount = self.Amount
if type(amount) == "string" then
if const[amount] then
amount = const[amount]
else
amount = tonumber(amount)
end
end
if amount>0 then
return T{894599074999, "Gained XP: <unit> (<Amount>)",Amount = amount, unit = names}
elseif amount<0 then
return T{955913519115, "Lost XP: <unit> (<Amount>)",Amount = amount, unit = names}
end
end
DefineClass.GroupAddStatusEffect = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Status", name = "Status",
editor = "preset_id", default = false, preset_class = "CharacterEffectCompositeDef", },
},
EditorView = Untranslated("Add <u(Status)> effect to units in group <u(TargetUnit)>"),
Documentation = "Add status effect to units in group",
EditorNestedObjCategory = "Units",
}
function GroupAddStatusEffect:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
for _, unit in ipairs(context.target_units) do
if IsKindOf(unit, "StatusEffectObject") then
unit:AddStatusEffect(self.Status)
end
end
if not next(context.target_units) then
print("GroupAddStatusEffect couldn't find group", self.TargetUnit)
return
end
end
DefineClass.GroupAlert = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
EditorView = Untranslated("Alert units from <u(TargetUnit)>"),
Documentation = "Alert units from given group",
EditorNestedObjCategory = "Units",
}
function GroupAlert:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local units = {}
for _, unit in ipairs(context.target_units) do
if IsKindOf(unit, "Unit") then
units[#units + 1] = unit
end
end
if not next(units) then
print("GroupAlert couldn't find group", self.TargetUnit)
return
end
CreateGameTimeThread(function()
gv_CombatStartFromConversation = true
TriggerUnitAlert("script", units, "aware")
end, units)
end
DefineClass.GroupAssignToArea = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Mode", name = "Assign Mode",
editor = "combo", default = "overwrite", items = function (self) return { "overwrite", "add", "clear" } end, },
{ id = "IndividualAreas",
editor = "string_list", default = {},
no_edit = function(self) return self.Mode == "clear" end, no_validate = true, item_default = "", items = function (self) return GridMarkerFightAreaCombo("") end, max_items = 64, },
},
EditorView = Untranslated("Assign units from <u(TargetUnit)> to tactical area(s)"),
Documentation = "Assigns units from given group to tactical area(s)",
EditorNestedObjCategory = "Units",
}
function GroupAssignToArea:__exec(obj, context)
if not g_TacticalMap then return end
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local reset = self.Mode == "overwrite"
local area
if self.Mode ~= "clear" and (#(self.IndividualAreas or empty_table) > 0) then
area = self.IndividualAreas
end
for _, unit in ipairs(context.target_units) do
if IsKindOf(unit, "Unit") then
g_TacticalMap:AssignUnit(unit, area, reset)
end
end
end
function GroupAssignToArea:GetEditorView()
if self.Mode == "clear" or #(self.IndividualAreas or empty_table) == 0 then
return Untranslated("Clear assignment for units from <u(TargetUnit)>")
else
local areas = ""
for _, area in ipairs(self.IndividualAreas) do
if #areas == 0 then
areas = area
else
areas = areas .. ", " .. area
end
end
if self.Mode == "add" then
return Untranslated(string.format("Add areas to assignement for units from <u(TargetUnit)>: [%s]", areas))
end
return Untranslated(string.format("Assign units from <u(TargetUnit)> to areas [%s]", areas))
end
return self.EditorView
end
DefineClass.GroupChangeName = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ChangeName", name = "Change Name", help = "Name to be changed to",
editor = "text", default = false, translate = true, },
},
EditorView = Untranslated("Change the name for units from <u(TargetUnit)> to <u(ChangeName)>"),
Documentation = "Change the name of units from given group",
EditorNestedObjCategory = "Units",
}
function GroupChangeName:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
for _, unit in ipairs(context.target_units) do
if IsKindOf(unit, "Unit") then
unit.Name = self.ChangeName
ObjModified(unit)
end
end
if not next(context.target_units) then
print(self.id, " couldn't find any units of: ", self.TargetUnit)
return
end
end
function GroupChangeName:GetError()
if not self.ChangeName then
return "Set Change Name"
end
end
DefineClass.GroupChangeTiredness = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Mode",
editor = "choice", default = "Absolute", items = function (self) return { "Absolute", "Delta" } end, },
{ id = "Level",
editor = "choice", default = 0,
no_edit = function(self) return self.Mode ~= "Absolute" end, items = function (self) return UnitTirednessComboItems end, },
{ id = "Delta",
editor = "number", default = 1,
no_edit = function(self) return self.Mode == "Absolute" end, },
},
EditorView = Untranslated("Change Energy for units from <u(TargetUnit)>"),
Documentation = "Change Energy for units from given group",
EditorNestedObjCategory = "Units",
}
function GroupChangeTiredness:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
for _, unit in ipairs(context.target_units) do
if IsKindOf(unit, "Unit") then
if self.Mode == "Absolute" then
unit:SetTired(self.Level)
else
unit:ChangeTired(self.Delta)
end
end
end
if not next(context.target_units) then
print("GroupChangeTiredness couldn't find any units of: ", self.TargetUnit)
return
end
end
function GroupChangeTiredness:GetError()
if self.Mode == "Delta" and self.Delta == 0 then
return "No effect"
end
end
DefineClass.GroupRemoveStatusEffect = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Status", name = "Status",
editor = "preset_id", default = false, preset_class = "CharacterEffectCompositeDef", },
},
EditorView = Untranslated("Remove <u(Status)> effect from units in group <u(TargetUnit)>"),
Documentation = "Remove status effect from units in group",
EditorNestedObjCategory = "Units",
}
function GroupRemoveStatusEffect:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "StatusEffectObject") then
o:RemoveStatusEffect(self.Status)
end
end
if not next(context.target_units) then
print("GroupRemoveStatusEffect couldn't find any units of: ", self.TargetUnit)
return
end
end
DefineClass.GroupSetAITargetModifier = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Group", name = "Group", help = "Unit group that will receive the modifier",
editor = "combo", default = "false", items = function (self) return GetUnitGroups() end, },
{ id = "Target", help = "Target unit group subject to the modifier",
editor = "combo", default = "false", items = function (self) return GetUnitGroups() end, },
{ id = "Modifier", help = "Modifier value, 100% means no modification (reset to default)",
editor = "number", default = 100, scale = "%", },
},
EditorView = Untranslated("AI target modifier for <u(Group)> against <u(Target)> <Modifier>%"),
Documentation = "Set AI Targeting modifier of a group of units against another group",
EditorNestedObjCategory = "Units",
}
function GroupSetAITargetModifier:__exec(obj, context)
if self.Modifier == 100 then
if gv_AITargetModifiers[self.Group] then
gv_AITargetModifiers[self.Group][self.Target] = nil
if next(gv_AITargetModifiers[self.Group]) == nil then
gv_AITargetModifiers[self.Group] = nil
end
end
else
gv_AITargetModifiers[self.Group] = gv_AITargetModifiers[self.Group] or {}
gv_AITargetModifiers[self.Group][self.Target] = self.Modifier
end
end
DefineClass.GroupSetArchetype = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Archetype",
editor = "choice", default = "<default>", items = function (self) return table.keys2(Archetypes, true, "<default>") end, },
},
EditorView = Untranslated("Change archetype for units from <u(TargetUnit)>"),
Documentation = "Change archetype for units from given group",
EditorNestedObjCategory = "Units",
}
function GroupSetArchetype:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local units = {}
local archetype = self.Archetype
if archetype == "<default>" then
archetype = nil
end
for _, unit in ipairs(context.target_units) do
if IsKindOf(unit, "Unit") then
unit.script_archetype = archetype
end
end
end
DefineClass.GroupSetBehaviorAdvanceTo = {
__parents = { "Effect", "AnimParams", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "MarkerId", help = "Marker description: can specify an id.",
editor = "text", default = false, },
{ id = "MarkerGroup", help = "Marker description: marker group.",
editor = "combo", default = "", items = function (self) return GetBehaviorGroups end, },
{ id = "MarkerType", help = "Marker description: markers type.",
editor = "combo", default = "Position", items = function (self) return GetGridMarkerTypesCombo end, },
{ id = "PropagateAnimParams", help = "AdvanceTo behavior passes the control to Roam behavior on finish and if this checked all the AnimParams here will be propagated to Roam",
editor = "bool", default = false, },
},
EditorView = Untranslated("<u(TargetUnit)> Advance(s) to the marker"),
Documentation = "Set units behavior to Advance towar a map marker.",
EditorNestedObjCategory = "Units",
}
function GroupSetBehaviorAdvanceTo:__exec(obj, context)
local markers = MapGetMarkers(self.MarkerType, self.MarkerGroup, function(o)
return o:IsMarkerEnabled() and ((self.MarkerId or "" == "") or o.ID == self.MarkerID)
end)
if #(markers or empty_table) == 0 then
printf("SetBehaviorAdvanceTo didn't find any markers (type %s, group %s, id %s)", tostring(self.MarkerType), tostring(self.MarkerGroup), tostring(self.MarkerId))
return
end
if g_Combat then return end
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local params = self:GetAnimParams()
params.PropagateAnimParams = self.PropagateAnimParams
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "Unit") and not o:IsDead() then
local marker = table.interaction_rand(markers, "GridMarker", o)
o:SetCommandParams("AdvanceTo", params)
o:SetCommand("AdvanceTo", marker:GetHandle())
end
end
end
DefineClass.GroupSetBehaviorExit = {
__parents = { "Effect", "AnimParams", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "MarkerGroup", help = "Exit marker group.",
editor = "combo", default = "",
no_edit = function(self) return self.closest end, items = function (self) return GetBehaviorGroups end, },
{ id = "closest", name = "Closest Available",
editor = "bool", default = false, },
{ id = "delay", name = "Delay",
editor = "number", default = 0, scale = "sec", min = 0, },
},
EditorView = Untranslated("<u(TargetUnit)> exit the map via <u(MarkerGroup)> marker"),
Documentation = "Units exit the map using a specified marker",
EditorNestedObjCategory = "Units",
}
function GroupSetBehaviorExit:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local units = context.target_units or empty_table
for i = #units, 1, -1 do
if not IsKindOf(units[i], "Unit") then
table.remove(units, i)
end
end
if #units == 0 then
return
end
local marker_group = not self.closest and self.MarkerGroup or ""
local markers = MapGetMarkers("Entrance", marker_group)
if not markers or #markers == 0 then
return
end
local marker
if marker_group == "" then
-- pick nearest
local ucenter = AveragePoint2D(units)
marker = ChooseClosestObject(markers, ucenter)
else
-- pick random
marker = table.interaction_rand(markers, "GridMarker")
end
local start_time = self.delay + GameTime()
if g_Combat then
for _, unit in ipairs(units) do
if not unit:IsDead() then
unit:SetBehavior("ExitMap", { marker, start_time })
end
end
else
local params = self:GetAnimParams()
for _, unit in ipairs(units) do
if unit.command == "ExplosionFly" then
unit:SetCommandParams("ExitMap", params)
unit:SetBehavior("ExitMap", { marker, start_time })
elseif not unit:IsDead() then
unit:SetCommandParams("ExitMap", params)
unit:SetCommand("ExitMap", marker, start_time)
end
end
end
end
function GroupSetBehaviorExit:GetEditorView()
return Untranslated("Set behavior of <u(TargetUnit)> to ExitMap at <u(MarkerGroup)>")
end
DefineClass.GroupSetBehaviorIdle = {
__parents = { "Effect", "AnimParams", "UnitTarget", },
__generated_by_class = "EffectDef",
EditorView = Untranslated("Set behavior of <u(TargetUnit)> to Idle"),
Documentation = "Set units behavior to Idle",
EditorNestedObjCategory = "Units",
}
function GroupSetBehaviorIdle:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local params = self:GetAnimParams()
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "Unit") and not o:IsDead() then
o:SetBehavior()
o:SetCommandParams("Idle", params)
o:SetCommand("Idle")
end
end
end
DefineClass.GroupSetBehaviorPatrol = {
__parents = { "Effect", "AnimParams", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "MarkerGroup", help = "Patrol markers group",
editor = "combo", default = "", items = function (self) return GetBehaviorGroups end, },
{ id = "Repeat", name = "Repeat Route", help = "Repeat route?",
editor = "bool", default = false, },
{ id = "Orient", name = "End Orient", help = "Use marker orientation on the end",
editor = "bool", default = true, },
},
EditorView = Untranslated("<u(TargetUnit)> patrol(s) between <u(MarkerGroup)> markers"),
Documentation = "Set unit behavior to Patrol between markers",
EditorNestedObjCategory = "Units",
}
function GroupSetBehaviorPatrol:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local params = self:GetAnimParams()
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "Unit") and not o:IsDead() then
o:SetCommandParams("Patrol", params)
local behaviorParams = {self.MarkerGroup, 1, self.Repeat, self.Orient}
if g_Combat then
o:SetBehavior("Patrol", behaviorParams)
elseif o.being_interacted_with then
o:QueueCommand("Patrol", unpack_params(behaviorParams))
else
o:SetCommand("Patrol", unpack_params(behaviorParams))
end
end
end
end
DefineClass.GroupSetBehaviorRoam = {
__parents = { "Effect", "AnimParams", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "MarkerId", help = "Marker description: can specify an id.",
editor = "text", default = false, },
{ id = "MarkerGroup", help = "Marker description: marker group.",
editor = "combo", default = "", items = function (self) return GetBehaviorGroups end, },
{ id = "MarkerType", help = "Marker description: markers type.",
editor = "combo", default = "Position", items = function (self) return GetGridMarkerTypesCombo end, },
{ id = "Orient", name = "End Orient", help = "Use marker orientation on the end",
editor = "bool", default = true, },
},
EditorView = Untranslated("<u(TargetUnit)> roam(s) around marker"),
Documentation = "Set units behavior to Roam around a map's marker.",
EditorNestedObjCategory = "Units",
}
function GroupSetBehaviorRoam:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local markers = MapGetMarkers(self.MarkerType, self.MarkerGroup, function(o)
return o:IsMarkerEnabled() and ((self.MarkerId or "" == "") or o.ID == self.MarkerID)
end)
if #(markers or empty_table) == 0 then
printf("SetBehaviorRoam didn't find any markers (type %s, group %s, id %s)", tostring(self.MarkerType), tostring(self.MarkerGroup), tostring(self.MarkerId))
return
end
local params = self:GetAnimParams()
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "Unit") and not o:IsDead() then
local marker = table.interaction_rand(markers, "GridMarker", o)
o:SetCommandParams("Roam", params)
if g_Combat then
o:SetBehavior("Roam", { marker, self.Orient })
elseif o.being_interacted_with then
o:QueueCommand("Roam", marker, self.Orient)
else
o:SetCommand("Roam", marker, self.Orient)
end
end
end
end
DefineClass.GroupSetImmortal = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "setImmortal", name = "Set immortal to",
editor = "bool", default = false, },
},
EditorView = Untranslated("Set the immortal property of units from <u(TargetUnit)> to <select(setImmortal, 'false', 'true')>"),
Documentation = "Set the immortal property of units from a given group.",
EditorNestedObjCategory = "Units",
}
function GroupSetImmortal:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
for _, unit in ipairs(context.target_units) do
if IsKindOf(unit, "Unit") then
unit.immortal = self.setImmortal
ObjModified(unit)
end
end
if not next(context.target_units) then
print(self.id, " couldn't find any units of: ", self.TargetUnit)
return
end
end
DefineClass.GroupSetInfected = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "setInfected", name = "Set infected to",
editor = "bool", default = false, },
},
EditorView = Untranslated("Set the infected property of units from <u(TargetUnit)> to <select(setInfected, 'false', 'true')>"),
Documentation = "Set the infected property of units from a given group. (Some animations change based on this property)",
EditorNestedObjCategory = "Units",
}
function GroupSetInfected:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
for _, unit in ipairs(context.target_units) do
if IsKindOf(unit, "Unit") then
unit.infected = self.setInfected
ObjModified(unit)
end
end
if not next(context.target_units) then
print(self.id, " couldn't find any units of: ", self.TargetUnit)
return
end
end
DefineClass.GroupSetRoutine = {
__parents = { "Effect", "AnimParams", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Routine", help = "Set units of group to particular routine, or the one from their spawner.",
editor = "combo", default = "spawner", items = function (self) local r = table.copy(UnitRoutines) r[#r+1] = "spawner" return r end, },
{ id = "RoutineArea", help = "Area to play the routine in, or use the one from the spawner.",
editor = "combo", default = "spawner", items = function (self) local g = table.copy(GridMarkerGroupsCombo()) g[1+#g] = "spawner" return g end, },
{ id = "PropagateAnimParams", help = "AdvanceTo behavior passes the control to Roam behavior on finish and if this checked all the AnimParams here will be propagated to Roam",
editor = "bool", default = false, },
},
EditorView = Untranslated("Set routine of <u(TargetUnit)> to <u(Routine)>"),
Documentation = "Set routine of units",
EditorNestedObjCategory = "Units",
}
function GroupSetRoutine:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local params = self:GetAnimParams()
params.PropagateAnimParams = self.PropagateAnimParams
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "Unit") then
o.routine = self.Routine == "spawner" and o.routine_spawner.Routine or self.Routine
o.routine_area = self.RoutineArea == "spawner" and "self" or self.RoutineArea
o.behavior = false
o:SetCommandParams("Idle", params)
o:SetCommand("Idle")
end
end
end
DefineClass.GroupSetSide = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Side", help = "The new side of group.",
editor = "choice", default = false, items = function (self) return Sides end, },
{ id = "CreateSquad", help = "If set to false the units will not create a new squad. Keep in mind they will be ejected from their old squad so they will despawn on the next presence check.",
editor = "bool", default = true, },
},
EditorView = Untranslated("Change the side of <u(TargetUnit)> to <u(Side)>"),
Documentation = "Change groups side",
EditorNestedObjCategory = "Units",
}
function GroupSetSide:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
if not next(context.target_units) then
print("GroupSetSide couldn't find group", self.TargetUnit)
return
end
if self.CreateSquad then
local squads = {}
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "Unit") and o.Squad then
table.insert_unique(squads, o.Squad)
local memberArrayName = "members" .. o.Squad
local memberArray = squads[memberArrayName]
if not memberArray then
memberArray = {}
squads[memberArrayName] = memberArray
end
memberArray[#memberArray + 1] = o.session_id
end
end
for i, s in ipairs(squads) do
local squadObj = gv_Squads[s]
local createNew = false
if squadObj.Side ~= self.Side then -- If squad is not of this side already
-- Check all units in the squad.
local units = squadObj.units
for _, u in ipairs(units) do
-- If any of the units in the squad are not part of the group,
-- they must remain on their old side in the old squad.
local unit = g_Units[u]
if not table.find(context.target_units, unit) then
createNew = true
break
end
end
end
if createNew then
local unitsToChangeSide = squads["members" .. s]
CreateNewSatelliteSquad({
Side = self.Side,
CurrentSector = squadObj.CurrentSector,
Name = SquadName:GetNewSquadName(self.Side, unitsToChangeSide)
}, unitsToChangeSide)
else
SetSatelliteSquadSide(s, self.Side)
end
end
else
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "Unit") then
local ud = gv_UnitData[o.session_id]
RemoveUnitFromSquad(ud, "script")
-- Dirty hack to prevent instant despawn when setting side to neutral.
if self.Side == "neutral" then
o.IsMerc = function() return false end
end
end
end
end
for _, o in ipairs(context.target_units) do
if IsKindOf(o, "Unit") then
o:SetSide(self.Side)
end
end
Msg("GroupChangeSide", self.TargetUnit, self.Side, context.target_units)
CheckGameOver()
end
function GroupSetSide:__waitexec(obj, context)
self:__exec(obj, context)
end
function GroupSetSide:GetError()
if not self.Side then
return "Set the new side!"
end
end
DefineClass.GroupTeleport = {
__parents = { "Effect", "AnimParams", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "MarkerGroup", help = "Marker group where the units should be teleported to.",
editor = "combo", default = "", items = function (self) return GetBehaviorGroups end, },
},
EditorView = Untranslated("<u(TargetUnit)> will be teleported to <u(MarkerGroup)> marker"),
Documentation = "Units group teleports to a specified marker",
EditorNestedObjCategory = "Units",
}
function GroupTeleport:__exec(obj, context)
context = type(context) == "table" and context or {}
self:MatchMapUnits(obj, context)
local units = context.target_units or empty_table
for i = #units, 1, -1 do
if not IsKindOf(units[i], "Unit") then
table.remove(units, i)
end
end
if #(units or empty_table) == 0 then
return string.format("No units from group '%s' to teleport", self.TargetUnit)
end
local markers = MapGetMarkers(nil, self.MarkerGroup)
if not markers or #markers == 0 then
return string.format("No markets in '%s' to teleport group '%s' to", self.MarkerGroup, self.TargetUnit)
end
local unit_pos, units_left = {}
for _, marker in ipairs(markers) do
units_left = {}
local dest = GetUnitsDestinations(units, marker)
for idx, unit in ipairs(units) do
if dest[idx] then
table.insert(unit_pos, unit)
unit_pos[unit] = point(point_unpack(dest[idx]))
else
table.insert(units_left, unit)
end
end
if #units_left == 0 then break end
units = units_left
end
if #units_left > 0 then
for _, unit in ipairs(units_left) do
StoreErrorSource(unit, string.format("No position found for group '%s' teleport to markers '%s'!", self.TargetUnit, self.MarkerGroup))
end
end
for _, unit in ipairs(unit_pos) do
NetSyncEvent("StartCombatAction", netUniqueId, "Teleport", unit, g_Combat and 0 or false, unit_pos[unit])
end
return string.format("%d unit(s) from '%s' teleported to '%s'", #units, self.TargetUnit, self.MarkerGroup)
end
function GroupTeleport:GetEditorView()
return Untranslated("Teleport <u(TargetUnit)> to <u(MarkerGroup)>")
end
DefineClass.Heal = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
RequiredObjClasses = {
"Unit",
"UnitData",
},
EditorView = Untranslated("Restore unit's health"),
Documentation = "Restores unit's health",
EditorNestedObjCategory = "Units",
}
function Heal:__exec(obj, context)
if IsKindOf(obj, "UnitData") then
HealUnitData(obj)
else
obj:ReviveOnHealth()
end
end
DefineClass.HealWounds = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
RequiredObjClasses = {
"Unit",
},
EditorView = Untranslated("Heal unit's wounds"),
Documentation = "Heals unit's wounds",
EditorNestedObjCategory = "Units",
}
function HealWounds:__exec(obj, context)
obj:RemoveStatusEffect("Wounded", "all")
end
DefineClass.HerbalMedicineEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "berserkChance", name = "Berserk Chance",
editor = "number", default = 15, },
{ id = "apChance", name = "AP Chance",
editor = "number", default = 15, },
},
RequiredObjClasses = {
"Unit",
"UnitData",
},
EditorView = Untranslated("Grant AP or Go Berserk"),
Documentation = "Grant AP or Go Berserk",
EditorNestedObjCategory = "Units",
}
function HerbalMedicineEffect:__exec(obj, context)
if IsKindOf(obj, "Unit") and not obj:IsDead() then
local berserkRoll = InteractionRand(100, "HerbalMedicine")
local apRoll = InteractionRand(100, "HerbalMedicine")
if berserkRoll < self.berserkChance then
end
if apRoll < self.apChance then
end
end
end
DefineClass.HideQuestBadge = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Show", help = "Show the badge instead. (if it was hidden with this effect)",
editor = "bool", default = false, },
{ id = "Quest", name = "Quest", help = "Which quest to associate this badge with. If the effect is placed on a quest it will attempt to find it itself.",
editor = "preset_id", default = false, preset_class = "QuestsDef", },
{ id = "BadgeIdx", name = "Badge Id",
editor = "number", default = 1,
sort_order = 9, min = 1, },
{ id = "Preview",
editor = "text", default = false, dont_save = true, read_only = true,
sort_order = 10, },
{ id = "LogLine", name = "Log Line", help = "Change the state of that line.",
editor = "choice", default = false, items = function (self) return GetQuestNoteLinesCombo(self.Quest) end, },
},
Documentation = "Hide a quest badge",
EditorNestedObjCategory = "Units",
}
function HideQuestBadge:__exec(obj, context)
local questState = (self.Quest and gv_Quests[self.Quest]) or (IsKindOf(obj, "QuestsDef") and obj) or false
assert(questState)
if not questState then return end
local magicParam = badgeHideIdentifierNote
local preset, index = self:GetLinePreset()
assert(preset) -- Missing quest probably
if not preset then return end
magicParam = magicParam .. tostring(index) .. "@" .. tostring(self.BadgeIdx)
if self.Show then
questState[magicParam] = nil
else
questState[magicParam] = true
end
UpdateQuestBadges(questState)
if g_SatelliteUI then
local badge = preset.Badges[self.BadgeIdx]
if badge and badge.Sector then
g_SatelliteUI:UpdateSectorVisuals(badge.Sector)
end
end
end
function HideQuestBadge:GetError()
if not self.Quest or self.Quest=="" then
return "Specify the quest!"
end
if not Quests[self.Quest] then
return "Missing quest!"
end
if not self.LogLine then
return "Specify the line!"
end
local preset = self:GetLinePreset()
if not preset then
return "Invalid line!"
end
if not preset.Badges or #preset.Badges == 0 then
return "This line doesn't place badges."
end
if self.BadgeIdx > #preset.Badges then
return "Badge id out of range"
end
end
function HideQuestBadge:GetLinePreset()
local line = self.LogLine
local quest = Quests[self.Quest]
if not quest or not line then return end
local notePreset = table.find_value(quest.NoteDefs, "Idx", line)
if not notePreset then return end
return notePreset, line
end
function HideQuestBadge:GetEditorView()
local actionWord = self.Show and "Show " or "Hide "
actionWord = actionWord .. self.BadgeIdx .. " "
--Hide quest badge placed by <LogLine>
if self.LogLine then
local linePreset = self:GetLinePreset()
if not linePreset then
return Untranslated("Hide Badge: Missing quest!")
end
local text = linePreset and linePreset.Text or "log line not found"
if linePreset.Badges then
local badge = linePreset.Badges[self.BadgeIdx]
self.Preview = "Badge on " .. (badge.BadgeUnit or "") .. " in " .. (badge.Sector or "")
return Untranslated(actionWord .. "badge placed by <u(Quest)>: ").. Untranslated(text)
else
self.Preview = "Invalid badge"
return Untranslated("Invalid badge")
end
else
self.Preview = ""
return Untranslated(actionWord .. "badge placed by <u(Quest)>: invalid log line specified")
end
end
DefineClass.InteractingMercReduceItemCondition = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ItemId",
editor = "combo", default = false, items = function (self) return ClassDescendantsCombo("InventoryItem") end, },
{ id = "Equipped",
editor = "bool", default = false, },
{ id = "ReduceAmount",
editor = "number", default = 1, min = 1, },
},
Documentation = "Reduce the condition of an interaction merc's item",
EditorView = Untranslated("Reduce the condition of interaction merc's <u(ItemId)> by <ReduceAmount>"),
}
function InteractingMercReduceItemCondition:__exec(obj, context)
local unit = context and context.target_units
unit = unit and unit[1]
if not unit then return end
local item = false
if self.Equipped then
item = unit:GetItemInSlot("Handheld A", self.ItemId) or
unit:GetItemInSlot("Handheld B", self.ItemId)
else
item = unit:GetItemInSlot("Inventory", self.ItemId)
end
if not item then return end
unit:ItemModifyCondition(item, -self.ReduceAmount)
CombatLog("short", T{597332256786, "<DisplayName> condition decreased by <dmg>.", DisplayName = item.DisplayName, dmg = self.ReduceAmount})
end
function InteractingMercReduceItemCondition:GetError()
if not self.ItemId then
return "Set Item!"
end
end
DefineClass.KillTimer = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Name", name = "Name", help = "Name of the timer.",
editor = "text", default = false, },
{ id = "StopTCE", name = "Stop TCE", help = "Wether to execute the effects after the timer or not.",
editor = "bool", default = false, },
},
EditorView = Untranslated("Kill timer <Name>"),
Documentation = "Kills the visual UI timer displayed in the upper center of the screen",
EditorNestedObjCategory = "UI & Log",
}
function KillTimer:__exec(quest, context, TCE)
local data = TimerGetData(self.Name)
if data then
data.time = 0
data.StopTCE = self.StopTCE
Msg("TimerFinished", data.id)
end
end
function KillTimer:GetError()
if not self.Name then
return "KillTimer needs a name!"
end
if GetParentTableOfKindNoCheck(self, "TestHarness") then
return
end
end
DefineClass.LightsSetState = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "MarkerId", help = "Marker description: can specify an id.",
editor = "text", default = false, },
{ id = "MarkerGroup", help = "Marker description: marker group.",
editor = "combo", default = "", items = function (self) return LightsMarkerGroups end, },
{ id = "MarkerType", help = "Marker description: markers type.",
editor = "combo", default = "Position", items = function (self) return GetGridMarkerTypesCombo end, },
{ id = "TurnOn",
editor = "bool", default = true, },
{ id = "EssentialLights",
editor = "bool", default = true, },
{ id = "OptionalLights",
editor = "bool", default = true, },
{ id = "AttachedLights",
editor = "bool", default = true, },
},
Documentation = "Turns ON/OFF Lights inside marker's area",
EditorNestedObjCategory = "Interactions",
}
function LightsSetState:GetEditorView()
return string.format("Turns Lights %s in %s marker(s) area(s)", self.TurnOn and "ON" or "OFF", self.MarkerGroup)
end
function LightsSetState:__exec(obj, context)
local markers = MapGetLightsMarkers(self.MarkerType, self.MarkerGroup, function(o)
return o:IsMarkerEnabled() and ((self.MarkerId or "" == "") or o.ID == self.MarkerID)
end)
if #(markers or empty_table) == 0 then
printf("%s didn't find any markers (type %s, group %s, id %s)", self.class, tostring(self.MarkerType), tostring(self.MarkerGroup), tostring(self.MarkerId))
return
end
local lights = GetLights(function(light)
local detail = light:GetDetailClass()
if not self.EssentialLights and detail == "Essential" then
return false
end
if not self.OptionalLights and detail == "Optional" then
return false
end
if not self.AttachedLights and light:GetParent() then
return false
end
return true
end)
for _, marker in ipairs(markers) do
marker.lights_off = not self.TurnOn
for _, light in ipairs(lights) do
if marker:IsInsideArea2D(light) then
if marker.lights_off then
marker:TurnLightOff(light)
else
marker:TurnLightOn(light)
end
end
end
end
Msg("LightsStateUpdated")
end
DefineClass.LockpickableSetState = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Group", name = "Group", help = "The group in which the lockpick resides.",
editor = "combo", default = false, items = function (self) return GridMarkerGroupsCombo() end, },
{ id = "State", help = "The state to set the locking in.",
editor = "choice", default = false, items = function (self) return { "unlocked", "locked", "change-difficulty" } end, },
{ id = "NewDifficulty", name = "New Difficulty", help = 'The difficulty to change to if the state is "change-difficulty".',
editor = "choice", default = "None", items = function (self) return const.DifficultyPresetsNew end, },
},
EditorView = Untranslated("Change the state of lockpickables in <u(Group)> to <u(State)>"),
Documentation = "Change lockpickable (containers, doors) state.",
}
function LockpickableSetState:__exec(obj, context)
for _, o in ipairs(Groups[self.Group]) do
if o:IsKindOf("Lockpickable") then
if self.State == "change-difficulty" then
o.lockpickDifficulty = self.NewDifficulty
else
o:SetLockpickState(self.State == "unlocked" and "closed" or self.State)
end
end
end
end
function LockpickableSetState:GetError()
if not self.State then
return "Set the new state!"
end
if not self.Group then
return "Set the group"
end
end
DefineClass.LogMessageAdd = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "message", name = "Message", help = "The message to display.",
editor = "text", default = false, translate = true, },
},
EditorView = Untranslated("Log:<message>"),
Documentation = "Add a short message in game log",
EditorNestedObjCategory = "UI & Log",
}
function LogMessageAdd:__exec(obj, context)
CombatLog("important", self.message)
end
function LogMessageAdd:GetError()
if not self.message or self.message == "" then
return "Add a message"
end
end
DefineClass.ModifySatelliteAggro = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Halt", help = "Stop passive aggro increase",
editor = "bool", default = false, },
{ id = "AggroAmount",
editor = "number", default = 0, },
{ id = "HaltDays",
editor = "number", default = false, },
{ id = "AmountIsPercent",
editor = "bool", default = true, },
},
Documentation = "Modify Satellite aggro",
}
function ModifySatelliteAggro:GetEditorView()
if self.Halt then
if self.HaltDays then
return Untranslated("Halt satellite aggro for " .. self.HaltDays .. " days.")
end
return Untranslated("Halt satellite aggro")
elseif self.AggroAmount == 0 and not self.Halt then
return Untranslated("Unhalt satellite aggro")
elseif self.AmountIsPercent then
return Untranslated("Add " .. self.AggroAmount / 100 .. "% satellite aggro")
else
return Untranslated("Add " .. self.AggroAmount .. " satellite aggro")
end
end
function ModifySatelliteAggro:__exec(obj, context)
gv_SatelliteAttacksHalted = self.Halt
-- When halting reset.
if gv_SatelliteAttacksHalted then
gv_SatelliteAggro = 0
gv_SatelliteAttacksHaltedFor = self.HaltDays
return
end
ModifySatelliteAggression(self.AggroAmount, self.AmountIsPercent)
end
function ModifySatelliteAggro:GetError()
if not self.AggroAmount then
return "No amount specified"
end
end
DefineClass.ModifyTrapSpawnersEffect = {
__parents = { "Effect", "TrapSpawnProperties", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Group", name = "Spawner Group", help = "The spawner group to affect.",
editor = "combo", default = "", items = function (self) return GridMarkerGroupsCombo() end, },
{ category = "Spawner", id = "SpawnActive", name = "Override Spawner Status", help = "Override whether the spawner is active. If disabled any spawned traps will be despawned.",
editor = "combo", default = "don't change", items = function (self) return {"don't change", "enable", "disable"} end, },
},
EditorView = Untranslated("Change trap spawners of group <u(Group)>"),
Documentation = "Change the properties of trap spawners in a specific group.",
EditorNestedObjCategory = "Traps",
}
function ModifyTrapSpawnersEffect:__exec(obj, context)
local props = self:GetPropertyList()
for i, s in ipairs(Groups[self.Group]) do
if s:IsKindOf("TrapSpawnMarker") then
s:ApplyPropertyList(props)
end
end
if self.SpawnActive ~= "dont change" then
for i, s in ipairs(Groups[self.Group]) do
if s:IsKindOf("TrapSpawnMarker") then
s:SetActive(self.SpawnActive == "enable")
end
end
end
end
DefineClass.MusicSetPlaylist = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Playlist", name = "Playlist",
editor = "combo", default = false, items = function (self) return PresetsCombo("RadioStationPreset", "Default") end, },
},
EditorView = Untranslated("Changes the current playlist"),
Documentation = "Changes the current playlist",
}
function MusicSetPlaylist:__exec(obj, context)
StartRadioStation(self.Playlist)
end
DefineClass.MusicSetSectorPlaylist = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "SectorID", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "MusicExploration", name = "Exploration Music",
editor = "combo", default = false, items = function (self) return PresetsCombo("RadioStationPreset", "Default") end, },
{ id = "MusicConflict", name = "Conflict Music",
editor = "combo", default = false, items = function (self) return PresetsCombo("RadioStationPreset", "Default") end, },
{ id = "MusicCombat", name = "Combat Music",
editor = "combo", default = false, items = function (self) return PresetsCombo("RadioStationPreset", "Default") end, },
},
EditorView = Untranslated("Changes the playlists of a sector"),
Documentation = "Changes the playlists of a sector",
}
function MusicSetSectorPlaylist:__exec(obj, context)
if GetSectorMusicOverride("MusicExploration") ~= self.MusicExploration then
SetSectorMusicOverride(self.SectorID, "MusicExploration", self.MusicExploration)
end
if GetSectorMusicOverride("MusicConflict") ~= self.MusicConflict then
SetSectorMusicOverride(self.SectorID, "MusicConflict", self.MusicConflict)
end
if GetSectorMusicOverride("MusicCombat") ~= self.MusicCombat then
SetSectorMusicOverride(self.SectorID, "MusicCombat", self.MusicCombat)
end
ResetSectorStation()
end
DefineClass.MusicSetTrack = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Playlist", name = "Playlist",
editor = "combo", default = false, items = function (self) return PresetsCombo("RadioStationPreset", "Default") end, },
{ id = "Track", name = "Track",
editor = "combo", default = false, items = function (self) return RadioPlaylistCombo(self.Playlist) end, },
},
EditorView = Untranslated("Plays a track and then continues with the current playlist(radio station)"),
Documentation = "Plays a track and then continues with the current playlist(radio station)",
}
function MusicSetTrack:__exec(obj, context)
local _, playlist = RadioPlaylistCombo(self.Playlist)
local track = table.find_value(playlist, "path", self.Track)
MusicPlayTrack(track)
end
DefineClass.NeutralNPCDontMove = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "TargetUnit", name = "NPC Name", help = "The name of the NPC to associate.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
},
EditorView = Untranslated("Prevent neutral unit from moving in combat."),
Documentation = "Prevents neutral unit from moving in combat.",
EditorNestedObjCategory = "",
EditorNestedObjCategory = "Units",
}
function NeutralNPCDontMove:__exec(obj, context)
local units = Groups[self.TargetUnit] or empty_table
for _, unit in ipairs(units) do
unit.neutral_ai_dont_move = true
end
end
function NeutralNPCDontMove:GetError()
if not self.TargetUnit then
return "Specify Target Unit"
end
end
DefineClass.NpcUnitGiveItem = {
__parents = { "Effect", "LootTableFunctionObjectBase", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ItemId", name = "Item",
editor = "preset_id", default = false, preset_class = "InventoryItemCompositeDef", },
{ id = "LootTableId", name = "LootTable",
editor = "preset_id", default = false, preset_class = "LootDef", },
{ id = "DontDrop",
editor = "bool", default = false, },
{ id = "TargetUnit", name = "NPC Name", help = "The name of the NPC to associate.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
},
EditorView = Untranslated("Give <u(ItemId)>/<u(LootTableId)> to <u(TargetUnit)>"),
Documentation = "Give an item to an npc, and have them equip items",
EditorNestedObjCategory = "Units",
}
function NpcUnitGiveItem:__exec(obj, context)
local units = empty_table
local group = Groups[self.TargetUnit]
if group then
local unitClass = {}
for i, obj in ipairs(group) do
if IsKindOf(obj, "Unit") then
unitClass[#unitClass + 1] = obj
end
end
units = unitClass
else
units = context.target_units or units
end
if not units or not units[1] then return end
local items = {}
if self.ItemId and self.ItemId~="" then
table.insert(items, PlaceInventoryItem(self.ItemId))
end
if self.LootTableId then
local loot_tbl = LootDefs[self.LootTableId]
if loot_tbl then
loot_tbl:GenerateLoot(self, {}, InteractionRand(nil, "NpcGive"), items)
end
end
local unit = units[1]
for i, item in ipairs(items) do
item.drop_chance = self.DontDrop and 0 or 100
if unit:CanAddItem("Handheld A", item) then
unit:AddItem("Handheld A", item)
elseif unit:CanAddItem("Head", item) then
unit:AddItem("Head", item)
elseif unit:CanAddItem("Torso", item) then
unit:AddItem("Torso", item)
elseif unit:CanAddItem("Legs", item) then
unit:AddItem("Legs", item)
else
unit:AddItem("Inventory", item)
end
end
unit:UpdateOutfit()
end
function NpcUnitGiveItem:GetError()
if not self.ItemId and not self.LootTableId then
return "No items set"
end
if not self.TargetUnit then
return "No target unit"
end
end
DefineClass.NpcUnitTakeItem = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ItemId", name = "Item",
editor = "preset_id", default = false, preset_class = "InventoryItemCompositeDef", },
{ id = "TargetUnit", name = "NPC Name", help = "The name of the NPC to associate.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
},
EditorView = Untranslated("Take <u(ItemId)> from <u(TargetUnit)>"),
Documentation = "Take an item from an NPC",
EditorNestedObjCategory = "Units",
}
function NpcUnitTakeItem:__exec(obj, context)
local units = empty_table
local group = Groups[self.TargetUnit]
if group then
local unitClass = {}
for i, obj in ipairs(group) do
if IsKindOf(obj, "Unit") then
unitClass[#unitClass + 1] = obj
end
end
units = unitClass
else
units = context.target_units or units
end
if not units or not units[1] then return end
local unit = units[1]
local itemsToRemove = {}
local itemsToRemoveSlots = {}
unit:ForEachItem(false, function(item, slot)
if item.class == self.ItemId then
itemsToRemove[#itemsToRemove + 1] = item
itemsToRemoveSlots[#itemsToRemoveSlots + 1] = slot
end
end)
for i, item in ipairs(itemsToRemove) do
unit:RemoveItem(itemsToRemoveSlots[i], item)
end
unit:UpdateOutfit()
end
function NpcUnitTakeItem:GetError()
if not self.ItemId then
return "No items set"
end
if not self.TargetUnit then
return "No target unit"
end
end
DefineClass.PhraseSetEnabled = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Conversation", help = "The conversation the phrase is in.",
editor = "preset_id", default = false, preset_class = "Conversation", },
{ id = "PhraseId", help = "The Id of the phrase to enable/disable.",
editor = "choice", default = false, items = function (self) return GetPhraseIdsCombo(self.Conversation) end, },
{ id = "Enabled", help = "Enable or disable the phrase.",
editor = "bool", default = true, },
},
Documentation = "Enables or disables a particular conversation phrase.",
EditorNestedObjCategory = "Interactions",
}
function PhraseSetEnabled:GetEditorView()
local enable = self.Enabled and Untranslated("Enable phrase ") or Untranslated("Disable phrase ")
return Untranslated("<u(Conversation)>: ") .. enable .. Untranslated("<u(PhraseId)>")
end
function PhraseSetEnabled:__exec(obj, context)
SetPhraseEnabledState(self.Conversation .. "." .. self.PhraseId, self.Enabled)
end
function PhraseSetEnabled:OnAfterEditorNew(parent, ged, is_paste)
local preset = GetParentTableOfKind(self, "Conversation")
if preset:IsKindOf("Conversation") then
self.Conversation = preset.id
end
end
DefineClass.PhraseSetSeen = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Conversation", help = "The conversation the phrase is in.",
editor = "preset_id", default = false, preset_class = "Conversation", },
{ id = "PhraseId", help = "The Id of the phrase to enable/disable.",
editor = "choice", default = false, items = function (self) return GetPhraseIdsCombo(self.Conversation) end, },
{ id = "Seen", help = "Sets the phrase as not seen (highlighted) by default; check the box to set the phrase as seen (dimmed) instead.",
editor = "bool", default = false, },
},
Documentation = "Changes a conversation's phrase \"seen\" (dimmed) status.",
EditorNestedObjCategory = "Interactions",
}
function PhraseSetSeen:GetEditorView()
local seen = self.Seen and Untranslated("seen") or Untranslated("not seen")
return Untranslated("<u(Conversation)>: Set phrase<u(PhraseId)> as ") .. seen
end
function PhraseSetSeen:__exec(obj, context)
SetPhraseSeen(self.Conversation .. "." .. self.PhraseId, self.Seen)
end
function PhraseSetSeen:OnAfterEditorNew(parent, ged, is_paste)
local preset = GetParentTableOfKind(self, "Conversation")
if preset:IsKindOf("Conversation") then
self.Conversation = preset.id
end
end
DefineClass.PlayBanterEffect = {
__parents = { "Effect", "BanterFunctionObjectBase", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Banters", name = "Banters", help = "List of banters to play.",
editor = "preset_id_list", default = {}, preset_class = "BanterDef", item_default = "", },
{ id = "searchInMarker", name = "Include Marker Units", help = "The only valid actors for a banter are the units passed by the previous conditions. By setting this on units inside a GridMarker will also be included as valid actors.",
editor = "bool", default = true, },
{ id = "banterSequentialWaitFor", name = "Wait For", help = "The banter event to wait for (if executing sequentially).",
editor = "choice", default = "BanterDone", items = function (self) return {"", "BanterStart", "BanterDone", "BanterLineStart", "BanterLineDone"} end, },
{ id = "searchInMap", name = "Include Whole Map", help = "The only valid actors for a banter are the units passed by the previous conditions. By setting this on units from the whole map will be considered. Your banter might spawn on a unit off screen.",
editor = "bool", default = false, },
{ id = "FallbackToMerc", name = "Radio", help = "If enabled the banter will appear over the first merc on map if the banter actor is not present on the map.",
editor = "bool", default = false, },
{ id = "WaitSetpieceEnd", help = "if enabled the banter will wait for the setpiece to end",
editor = "bool", default = false, },
{ id = "anyFallback", name = "Use any unit as fallback for Radio.", help = "Use this if the Radio banter is not played.",
editor = "bool", default = false, },
{ id = "AnyActorOverrideGroup", name = "Any Actor Override Group", help = 'Banter lines with actor "any" will be played by the first /object/ from the group.',
editor = "text", default = false, },
},
Documentation = "An effect to play a banter.",
EditorNestedObjCategory = "Interactions",
}
function PlayBanterEffect:GetError()
if not self.Banters then
return "No banters"
end
for i,banter_id in ipairs(self.Banters) do
if not Banters[banter_id] then
return "Invalid banter ID " .. banter_id
end
end
end
function PlayBanterEffect:GetEditorView()
return Untranslated("Play banter(s): ").. Untranslated(table.concat(self.Banters, ", "))
end
function PlayBanterEffect:__exec(obj, context)
local is_marker = IsKindOf(obj, "GridMarker")
local context_is_table = context and type(context)=="table"
local targetUnitsTable = context_is_table and rawget(context, "target_units")
targetUnitsTable = targetUnitsTable and table.icopy(targetUnitsTable)
local units = targetUnitsTable or (is_marker and { obj } or {})
if self.searchInMarker and is_marker then
MapForEach("map", "Unit", function(u)
if obj:IsInsideArea(u:GetPos()) then
units[#units + 1] = u
end
end)
elseif self.searchInMap then
MapForEach("map", "Unit", function(u)
units[#units + 1] = u
end)
MapForEach("map", "CheeringDummy", function(u)
units[#units + 1] = u
end)
end
if context_is_table and rawget(context, "interactable") then
units = table.copy(units)
table.insert(units, 1, context.interactable)
end
local fallback = false
if self.FallbackToMerc then
for _, unit in ipairs(g_Units) do
if unit:IsPlayerAlly() and not unit:IsDead() then
fallback = unit
break
end
end
-- search for any actor also
if not fallback and self.anyFallback then
for _, unit in ipairs(g_Units) do
if not unit:IsDead() then
fallback = unit
break
end
end
end
end
local banters, banterActors = FilterAvailableBanters(self.Banters, context, units, fallback)
if not banters then
CombatLog("debug","No banters can be played with the selected actors")
return
end
local idx = InteractionRand(#banters, "PlayBanterEffect") + 1
local banterToPlay = banters[idx]
local actorsToPlayWith = banterActors[idx]
local anyActorOverride = self.AnyActorOverrideGroup
-- Support for banter from conversation
if context_is_table and context and context.found_merc then
anyActorOverride = context.found_merc
end
local banterObj = PlayBanter(banterToPlay, actorsToPlayWith, fallback, anyActorOverride, self.WaitSetpieceEnd)
if banterObj then
local playerPos = IsValid(obj) and obj:GetPos()
if playerPos then
banterObj:SetPos(playerPos)
end
local resumeData = {}
resumeData.preset = banterObj.preset.id
local banterUnits = {}
for i, u in ipairs(banterObj.associated_units) do
banterUnits[#banterUnits + 1] = u.handle
end
resumeData.units = banterUnits
resumeData.fallbackUnit = banterObj.fallback_actor and banterObj.fallback_actor.handle
resumeData.any_actor_override = banterObj.any_actor_override and banterObj.any_actor_override.handle
resumeData.playerHandle = banterObj.handle
if playerPos then resumeData.player_pos = playerPos end
g_PlayingBanterEffects[self] = resumeData
end
return banterObj
end
function PlayBanterEffect:__skip(obj, context)
for i, banterId in ipairs(self.Banters) do
SkipBanterFromUI(banterId)
end
end
function PlayBanterEffect:__waitexec(obj, context)
local banterObj = self:__exec(obj, context)
local event = self.banterSequentialWaitFor
if banterObj and event ~= "" then
local notTimedOut, preset_id
while preset_id ~= banterObj.preset.id do
notTimedOut, preset_id = WaitMsg(event)
end
end
end
function PlayBanterEffect:GetError()
if #self.Banters == 0 then
return "Add at least one banter"
end
if self.searchInMarker and self.searchInMap then
return "Don't select both search in marker and search in map."
end
end
function PlayBanterEffect:GetResumeData()
local resumeData = g_PlayingBanterEffects[self]
if resumeData and resumeData.playerHandle then
local player = HandleToObject[resumeData.playerHandle]
if IsValid(player) then
resumeData.current_line = (player.current_line and player.current_line + 1) or 1
return "PlayBanterEffect", resumeData
end
end
end
DefineClass.PlayNotNowVR = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
EditorView = Untranslated('Unit plays "NotNow" VR'),
Documentation = 'Unit plays "NotNow" VR.',
EditorNestedObjCategory = "Units",
}
function PlayNotNowVR:__exec(obj, context)
PlayVoiceResponse(obj, "NotNow")
end
DefineClass.PlaySetpiece = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "setpiece", name = "Setpiece", help = "The id of the set piece preset to play.",
editor = "preset_id", default = false, preset_class = "SetpiecePrg", },
},
EditorView = Untranslated("Play <setpiece> setpiece"),
Documentation = "Play a Set-piece.",
EditorNestedObjCategory = "",
EditorNestedObjCategory = "Interactions",
}
function PlaySetpiece:__exec(obj, context)
local triggerUnits = false
if type(context) == "table" and rawget(context, "target_units") then
triggerUnits = rawget(context, "target_units")
elseif Groups[obj] then
triggerUnits = Groups[obj]
elseif gv_CurrentSectorId then
triggerUnits = table.map(GetPlayerMercsInSector(gv_CurrentSectorId), function(o) return g_Units[o] end)
end
local foundMerc = false
if type(context) == "table" and rawget(context, "found_merc") then
foundMerc = rawget(context, "found_merc")
foundMerc = g_Units[foundMerc]
end
local setpiece = Setpieces[self.setpiece]
if setpiece.TakePlayerControl then
local dlg = OpenDialog("XSetpieceDlg", false, {
setpiece = self.setpiece,
setpiece_seed = InteractionRand(nil, "Setpiece"),
triggerUnits = triggerUnits,
extra_params = foundMerc and { {foundMerc} }
})
if GameState.entering_sector then
dlg:FadeOut(0) -- immediate black screen to hide any stray frames if we are started upon entering a sector (with a loading screen)
end
else
CreateGameTimeThread(function()
StartSetpiece(self.setpiece, false, InteractionRand(nil, "Setpiece"), triggerUnits, foundMerc)
end)
end
end
function PlaySetpiece:__waitexec(obj, context)
self:__exec(obj, context)
local setpiece = Setpieces[self.setpiece]
if setpiece.TakePlayerControl then
WaitMsg("SetpieceEnded")
else
WaitMsg("SetpieceEndExecution")
end
end
function PlaySetpiece:GetError()
if not self.setpiece then return "No setpiece set." end
end
DefineClass.PlayUnitVoiceResponse = {
__parents = { "UnitTarget", "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "VoiceResponse", name = "Voice Response", help = "Voice response type to choose a phrase from; the phrases of the current unit will be used.",
editor = "combo", default = false, items = function (self) return GetVoiceResponseCombo(self, self.TargetUnit) end, },
},
EditorView = Untranslated("<u(TargetUnit)> plays '<u(VoiceResponse)>'"),
Documentation = "Target unit plays voice response",
EditorNestedObjCategory = "Units",
}
function PlayUnitVoiceResponse:__exec(obj, context)
if not self.VoiceResponse then return end
if not context then context = {} end
local units = self:MatchMapUnits(obj, context)
if units and context.target_units then
local unit = context.target_units[ AsyncRand(# context.target_units) +1]
if not unit or not self.VoiceResponse then return end
PlayVoiceResponse(unit, self.VoiceResponse, true)
end
end
function PlayUnitVoiceResponse:GetError()
if not self.TargetUnit then
return "Choose target unit"
end
if not self.VoiceResponse then
return "Choose voice response id"
end
end
function PlayUnitVoiceResponse:UnitCheck(unit, obj, context)
return true
end
DefineClass.PlayerGrantMoney = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Amount", name = "Amount", help = "Amount of money to grant.",
editor = "number", default = 0, min = 0, },
},
EditorView = Untranslated("Grant <money(Amount)>"),
Documentation = "Give money to player.",
}
function PlayerGrantMoney:__exec(obj, context)
AddMoney(self.Amount, "deposit")
end
function PlayerGrantMoney:GetPhraseTopRolloverText(negative, template, game)
local amount = self.Amount
if amount>0 then
return T{666348317447, "<money(Amount)> acquired",Amount = amount}
elseif amount<0 then
return T{194741866993, "Paid <money(Amount)>",Amount = amount}
end
end
function PlayerGrantMoney:GetPhraseFX()
return "ConversationMoneyGained"
end
DefineClass.PlayerPayMoney = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Amount", name = "Amount", help = "Amount of money to pay.",
editor = "number", default = 0, min = 0, },
},
EditorView = Untranslated("Pay <money(Amount)>"),
Documentation = "Take money from player.",
}
function PlayerPayMoney:__exec(obj, context)
AddMoney(-self.Amount, "expense")
end
function PlayerPayMoney:GetPhraseTopRolloverText(negative, template, game)
local amount = self.Amount
return T{194741866993, "Paid <money(Amount)>",Amount = amount}
end
function PlayerPayMoney:GetUIText(context)
return T{982094780061, "Give <money(Amount)>", Amount = self.Amount}
end
DefineClass.QuestEffectBase = {
__parents = { "Effect", "QuestFunctionObjectBase", },
__generated_by_class = "ClassDef",
EditorNestedObjCategory = "Quests",
}
function QuestEffectBase:OnAfterEditorNew(obj, socket, paste, old_id)
if not paste then
local quest_def = GetParentTableOfKindNoCheck(obj, "QuestsDef")
if quest_def then
self.QuestId = quest_def.id
end
end
end
DefineClass.QuestKillTCE = {
__parents = { "QuestEffectBase", },
__generated_by_class = "EffectDef",
properties = {
{ id = "QuestId", name = "Quest id", help = "Quest to change.",
editor = "preset_id", default = false, preset_class = "QuestsDef", },
{ id = "TCE", name = "TCE", help = "Quest TCE to kill",
editor = "choice", default = false, items = function (self) return GetQuestsVarsCombo(self.QuestId, "TCEState") end, },
},
EditorView = Untranslated("Kills '<u(TCE)>' TCE from '<u(QuestId)>' quest"),
Documentation = "Kills specific TCE from a given quest",
}
function QuestKillTCE:__exec(obj, context)
if not RunningSequentialEffects then return false end
if not self.QuestId or self.QuestId == "" or not self.TCE or self.TCE == "" then return false end
for i = #RunningSequentialEffects, 1, -1 do
local run_state = RunningSequentialEffects[i]
if run_state[5] == self.QuestId and run_state[6] == self.TCE then
DeleteThread(run_state[1])
table.remove(RunningSequentialEffects, i)
return
end
end
end
function QuestKillTCE:GetError()
if not self.QuestId or self.QuestId=="" then
return "Specify the quest!"
end
end
DefineClass.QuestSetVariableBool = {
__parents = { "QuestEffectBase", },
__generated_by_class = "EffectDef",
properties = {
{ category = "General", id = "QuestId", name = "Quest id", help = "Quest to change.",
editor = "preset_id", default = false, preset_class = "QuestsDef", preset_filter = function (preset, obj, prop_meta)
return QuestHasVariable(preset, "QuestVarBool")
end,
},
{ category = "General", id = "Prop", name = "Quest Variable", help = "Quest variable to change.",
editor = "choice", default = false, items = function (self) return GetQuestsVarsCombo(self.QuestId,"Bool") end, },
{ category = "General", id = "Toggle", name = "Toggle Current Value", help = "Toggles the current flag value (changes it from 'true' to 'false' and vice versa).",
editor = "bool", default = false, },
{ category = "General", id = "Set", name = "Change to", help = "Value to set.",
editor = "bool", default = true,
no_edit = function(self) return self.Toggle end, },
},
Documentation = "A way to change the quest's flag. If not 'Toggle' then changes the flag to 'Set' value, else toggle the flag's value.",
}
function QuestSetVariableBool:__exec(obj, context)
local quest = QuestGetState(self.QuestId or "")
if not quest then return end
if self.Toggle then
SetQuestVar(quest, self.Prop, not rawget(quest, self.Prop))
else
SetQuestVar(quest, self.Prop, self.Set)
end
end
function QuestSetVariableBool:GetError()
if not self.QuestId or self.QuestId=="" then
return "Specify the quest!"
end
if not self.Prop then
return "Specify the param to change!"
end
end
function QuestSetVariableBool:GetEditorView()
if self.Toggle then
return Untranslated("Quest <u(QuestId)>: toggle <u(Prop)>")
else
return Untranslated("Quest <u(QuestId)>: <u(Prop)> = " .. tostring(self.Set))
end
end
DefineClass.QuestSetVariableNum = {
__parents = { "QuestEffectBase", },
__generated_by_class = "EffectDef",
properties = {
{ category = "General", id = "QuestId", name = "Quest id", help = "Quest to change.",
editor = "preset_id", default = false, preset_class = "QuestsDef", preset_filter = function (preset, obj, prop_meta)
return QuestHasVariable(preset, "QuestVarNum")
end,
},
{ category = "General", id = "Prop", name = "Quest Variable", help = "Quest variable to change.",
editor = "choice", default = false, items = function (self) return GetQuestsVarsCombo(self.QuestId,"Num") end, },
{ category = "General", id = "Amount", name = "Amount", help = "Value to set.",
editor = "number", default = 0, },
{ category = "General", id = "RandomRangeMax", name = "Random Amount Max", help = 'If set, the amount will be a random number between "Amount" and this number. Both values are inclusive.',
editor = "number", default = false, },
{ category = "General", id = "Percent", name = "Percent", help = "Percent change to current value, if operation is modify.",
editor = "number", default = 100, },
{ category = "General", id = "Operation", name = "Operation", help = "Modify the current value with amount/percent or set a new one.",
editor = "combo", default = "modify", items = function (self) return {"set", "modify"} end, },
},
Documentation = "Change a quest variable's value. Modifies the current value wiyh amount/percent or sets a new amount.",
}
function QuestSetVariableNum:__exec(obj, context)
local quest = QuestGetState(self.QuestId or "")
if not quest then return end
local prev_val = rawget(quest,self.Prop)
local new_val
local mod_amount = self.Amount
if self.RandomRangeMax then
mod_amount = mod_amount + InteractionRand(self.RandomRangeMax - mod_amount + 1, "QuestVariableNum")
end
if self.Operation=="set" then
new_val = mod_amount
elseif self.Operation=="modify" then
new_val = (prev_val or 0) + mod_amount
if self.Percent~=0 then
new_val = MulDivRound(new_val, self.Percent, 100)
end
end
SetQuestVar(quest, self.Prop, new_val)
end
function QuestSetVariableNum:GetError()
if not self.QuestId or self.QuestId=="" then
return "Specify the quest!"
end
if not self.Prop then
return "Specify the param to change!"
end
if self.RandomRangeMax and self.RandomRangeMax < self.Amount then
return "Max cannot be smaller than min (Amount)."
end
if self.Operation~="set" then
local quest = QuestGetState(self.QuestId or "")
local prev_val = rawget(quest,self.Prop)
if not prev_val then
return "This prop has not set any value and can not be changed"
end
end
end
function QuestSetVariableNum:GetEditorView()
local printValue = "<Amount>"
if self.RandomRangeMax then
printValue = printValue .. "-<RandomRangeMax>"
end
if self.Operation=="set" then
return Untranslated("Quest <u(QuestId)>:<u(Prop)> = " .. printValue)
elseif self.Operation=="modify" then
return Untranslated("Quest <u(QuestId)>:<u(Prop)> = <Percent>% from (<u(Prop)> + " .. printValue .. ")")
end
end
DefineClass.QuestSetVariableSpecialValue = {
__parents = { "QuestEffectBase", },
__generated_by_class = "EffectDef",
properties = {
{ category = "General", id = "QuestId", name = "Quest id", help = "Quest to change.",
editor = "preset_id", default = false, preset_class = "QuestsDef", preset_filter = function (preset, obj, prop_meta)
return QuestHasVariable(preset, "QuestVarNum")
end,
},
{ category = "General", id = "Prop", name = "Quest Variable", help = "Quest variable to change.",
editor = "choice", default = false, no_validate = true, items = function (self) return GetQuestsVarsCombo(self.QuestId,"Num") end, },
{ category = "General", id = "Special", name = "Special value type", help = "Value to set.",
editor = "combo", default = "current campaign time", items = function (self) return {"current campaign time"} end, },
},
Documentation = "Set a quest number variable to a special value, chosen from the Special property.",
}
function QuestSetVariableSpecialValue:__exec(obj, context)
local quest = QuestGetState(self.QuestId or "")
if not quest then return end
local new_val
if self.Special == "current campaign time" then
new_val = Game.CampaignTime
end
SetQuestVar(quest, self.Prop, new_val)
end
function QuestSetVariableSpecialValue:GetError()
if not self.QuestId or self.QuestId=="" then
return "Specify the quest!"
end
end
function QuestSetVariableSpecialValue:GetEditorView()
if self.Special == "current campaign time" then
return Untranslated("Quest <u(QuestId)>:<u(Prop)> = current campaign time")
end
end
DefineClass.QuestSetVariableText = {
__parents = { "QuestEffectBase", },
__generated_by_class = "EffectDef",
properties = {
{ category = "General", id = "QuestId", name = "Quest id", help = "Quest to change.",
editor = "preset_id", default = false, preset_class = "QuestsDef", preset_filter = function (preset, obj, prop_meta)
return QuestHasVariable(preset, "QuestVarText")
end,
},
{ category = "General", id = "Prop", name = "Quest Variable", help = "Quest variable to change",
editor = "choice", default = false, items = function (self) return GetQuestsVarsCombo(self.QuestId, "Text") end, },
{ category = "General", id = "Text", name = "Text", help = "Value to set.",
editor = "text", default = '""', },
},
EditorView = Untranslated("Quest <u(QuestId)>:<u(Prop)> = '<u(Text)>'"),
Documentation = "Change a quest's text variable.",
}
function QuestSetVariableText:__exec(obj, context)
local quest = QuestGetState(self.QuestId or "")
if not quest then return end
SetQuestVar(quest, self.Prop, self.Text)
end
function QuestSetVariableText:GetError()
if not self.QuestId or self.QuestId=="" then
return "Specify the quest!"
end
if not self.Prop then
return "Specify the param to change!"
end
end
DefineClass.QuestSetVariableTimer = {
__parents = { "QuestEffectBase", },
__generated_by_class = "EffectDef",
properties = {
{ category = "General", id = "QuestId", name = "Quest id", help = "Quest to change.",
editor = "preset_id", default = false, preset_class = "QuestsDef", preset_filter = function (preset, obj, prop_meta)
return QuestHasVariable(preset, "QuestVarNum")
end,
},
{ category = "General", id = "Prop", name = "Quest Variable", help = "Quest variable to change.",
editor = "choice", default = false, items = function (self) return GetQuestsVarsCombo(self.QuestId,"Num") end, },
{ category = "General", id = "TimeAmount",
editor = "number", default = 0, },
{ category = "General", id = "TimeAmountRangeMax", help = "If set the time amount will be randomed between TimeAmount and this value.",
editor = "number", default = 0, },
{ category = "General", id = "Timescale",
editor = "choice", default = "h", items = function (self) return GetTimeScalesCombo() end, },
},
Documentation = "Set a timer to a quest variable.",
}
function QuestSetVariableTimer:__exec(obj, context)
local quest = QuestGetState(self.QuestId or "")
if not quest then return end
local prev_val = rawget(quest, self.Prop)
local timeAmount = self.TimeAmount
if self.TimeAmountRangeMax ~= 0 then
timeAmount = timeAmount + InteractionRand(self.TimeAmountRangeMax - timeAmount + 1, "QuestVariableTimer")
end
timeAmount = timeAmount * (const.Scale[self.Timescale] or const.Scale.h)
local triggerTime = Game.CampaignTime + timeAmount
SetQuestVar(quest, self.Prop, triggerTime)
end
function QuestSetVariableTimer:GetError()
if not self.QuestId or self.QuestId=="" then
return "Specify the quest!"
end
if not self.Prop then
return "Specify the param to change!"
end
if (self.TimeAmountRangeMax or 0) ~= 0 and self.TimeAmountRangeMax < self.TimeAmount then
return "Max cannot be smaller than min (TimeAmount)."
end
end
function QuestSetVariableTimer:GetEditorView()
local printValue = "<TimeAmount>"
if (self.TimeAmountRangeMax or 0) ~= 0 then
printValue = printValue .. "-<TimeAmountRangeMax>"
end
return Untranslated("Set quest timer in <u(QuestId)>:<u(Prop)> for after " .. printValue .. " " .. self.Timescale)
end
DefineClass.RadioStartConversation = {
__parents = { "Effect", "ConversationFunctionObjectBase", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Conversation", name = "Conversation", help = "Conversation to start.",
editor = "preset_id", default = false, preset_class = "Conversation", },
{ id = "Icon",
editor = "combo", default = "UI/Hud/radio", items = function (self) return GetRadioConversationIconsCombo end, },
},
EditorView = Untranslated("Start radio conversation <u(Conversation)>."),
Documentation = "Starts a specific radio conversation - no groups or conditions are checked.",
EditorNestedObjCategory = "Interactions",
}
function RadioStartConversation:__exec(obj, context)
StartConversationEffect(self.Conversation, {radio = true, icon = self.Icon})
end
function RadioStartConversation:__waitexec(obj, context)
StartConversationEffect(self.Conversation, {radio = true, icon = self.Icon}, "wait")
end
function RadioStartConversation:GetError()
if not self.Conversation then
return "Please specify conversation"
end
end
function RadioStartConversation:GetResumeData(thread, stack, stack_index)
return "RadioStartConversation", self.Conversation, self.Icon
end
DefineClass.RandomEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Effects", name = "Effects",
editor = "nested_list", default = false, base_class = "Effect", },
},
ReturnClass = "",
EditorView = Untranslated("Play a random effect from a list."),
Documentation = "Play a random effect from a list.",
EditorNestedObjCategory = "",
}
function RandomEffect:__exec(obj, context)
local num = #self.Effects
if num > 0 then
local roll = InteractionRand(num, "RandomEffect") + 1
self.Effects[roll]:__exec()
end
end
function RandomEffect:GetError()
if not self.Effects or #self.Effects < 1 then
return "Please specify some effects"
end
end
DefineClass.RandomEffectWithCondition = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Effects", name = "Effects",
editor = "nested_list", default = false, base_class = "ConditionalEffect", },
},
ReturnClass = "",
EditorView = Untranslated("Play a random effect from a list whose conditions evaluate to true."),
Documentation = "Play a random effect from a list whose conditions evaluate to true.",
EditorNestedObjCategory = "",
}
function RandomEffectWithCondition:__exec(obj, context)
local valid = {}
for i, eff in ipairs(self.Effects) do
if EvalConditionList(eff.Conditions, obj, context) then
valid[#valid + 1] = eff
end
end
local num = #valid
if num > 0 then
local roll = InteractionRand(num, "RandomEffect") + 1
local effRolled = valid[roll]
local effects = effRolled.Effects
for _, effect in ipairs(effects) do
effect:__exec(obj, context)
end
end
end
function RandomEffectWithCondition:GetError()
if not self.Effects or #self.Effects < 1 then
return "Please specify some effects"
end
end
DefineClass.RechargeCDs = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
RequiredObjClasses = {
"Unit",
"UnitData",
},
EditorView = Untranslated("Recharge a unit's CDs"),
Documentation = "Recharge a unit's CDs",
EditorNestedObjCategory = "Units",
}
function RechargeCDs:__exec(obj, context)
if IsKindOfClasses(obj, "Unit", "UnitData") and not obj:IsDead() then
obj:RechargeSignatures()
end
end
DefineClass.RegenerateGuardpostObjective = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "GuardpostObjective", name = "GuardpostObjective",
editor = "preset_id", default = false, preset_class = "GuardpostObjective", },
},
EditorView = Untranslated("Regenerate guardpost objective <u(GuardpostObjective)>"),
Documentation = "Regenerate a completed guardpost objective.",
EditorNestedObjCategory = "Sectors",
}
function RegenerateGuardpostObjective:__exec(obj, context)
SetGuardpostObjectiveRegenerated(self.GuardpostObjective)
end
DefineClass.ReplaceMercEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ExistingMerc", name = "Existing Merc", help = "Existing merc to replace.",
editor = "combo", default = false, items = function (self) return MercPresetCombo() end, },
{ id = "NewMercDef", name = "New Merc Definition", help = "New merc definition to use for replacement.",
editor = "combo", default = false, items = function (self) return MercPresetCombo() end, },
},
EditorView = Untranslated("Replace <u(ExistingMerc)> with <u(NewMercDef)> keeping his progress."),
Documentation = "Replace a merc with another definition while keeping his progress. Example use: switch Larry to Larry_Clean.",
EditorNestedObjCategory = "Units",
}
function ReplaceMercEffect:__exec(obj, context)
ReplaceMerc(self.ExistingMerc, self.NewMercDef, "keepInventory")
end
function ReplaceMercEffect:GetError()
if not self.ExistingMerc then
return "Choose an existing merc to replace"
end
if not self.NewMercDef then
return "Choose a new merc definition to replace the existing one with"
end
end
function ReplaceMercEffect:GetUIText(context,template, game)
local merc = gv_UnitData and gv_UnitData[self.Merc]
local name
if not merc then
name = game and "" or Untranslated("[MercName]")
else
name = merc.Nick or merc.Name
end
return T{246469241790, "Recruit merc (<em><name></em>)", name= name}
end
DefineClass.ResetAmbientLife = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Ephemeral", name = "Ephemeral Only", help = "All ambient life units or just ephemeral ones.",
editor = "bool", default = true, },
{ id = "KickPerpetualUnits", name = "Kick Perpetual Units", help = "If checked perpetual units will be reset too, otherwise they will stay in their markers.",
editor = "bool", default = false, },
{ id = "ForceImmediateKick", name = "Force Immediate Kick", help = "Forces immedite kick so the marker and the unit can be used right away - usually clearing the marker happens after playing exit animation. Anyway if UnitsStealForPerpetualMarkers effect is scheduled right after this one it can not work as expected since it will be called before the destructors and the units/marker will be still busy",
editor = "bool", default = false, },
},
EditorView = Untranslated("Reset Ambient Life Behavior"),
Documentation = "Forces all units in ambient life behavior to check the condition of the spot they are using and makes them leave if that condition is not met",
}
function ResetAmbientLife:__exec(obj, context)
for _, unit in ipairs(g_Units) do
if (not self.Ephemeral or unit.ephemeral) and unit:IsVisiting() then
unit:ResetAmbientLife(self.KickPerpetualUnits, self.ForceImmediateKick)
end
end
end
DefineClass.RestoreHealth = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "amount", name = "Amount",
editor = "number", default = 9999, },
},
RequiredObjClasses = {
"Unit",
"UnitData",
},
EditorView = Untranslated("Restore unit's health"),
Documentation = "Restores unit's health",
EditorNestedObjCategory = "Units",
}
function RestoreHealth:__exec(obj, context)
if IsKindOfClasses(obj, "Unit", "UnitData") and not obj:IsDead() then
obj.HitPoints = Min(obj.MaxHitPoints, obj.HitPoints + self.amount)
end
end
DefineClass.SatelliteShortcutSetSpeed = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "shortcut_id",
editor = "combo", default = false, items = function (self) return PresetsCombo("SatelliteShortcutPreset") end, },
{ id = "speed_const", help = "The constant denoting the shortcut's speed",
editor = "combo", default = "RiverTravelTime", items = function (self) return ConstCategoryToCombo(const.SatelliteShortcut) end, },
},
Documentation = "Set the speed of a satellite shortcut",
EditorNestedObjCategory = "Sector effects",
}
function SatelliteShortcutSetSpeed:__exec(obj, context)
SatelliteShortcutChangeSpeed(self.shortcut_id, self.speed_const)
end
function SatelliteShortcutSetSpeed:GetError()
if not self.shortcut_id then
return "Specify shortcut!"
end
end
function SatelliteShortcutSetSpeed:GetEditorView()
if self.enable then
return Untranslated("Enable satellite shortcut <u(shortcut_id)>", self)
else
return Untranslated("Disable satellite shortcut <u(shortcut_id)>", self)
end
end
DefineClass.SatelliteShortcutUnlockEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "shortcut_id",
editor = "combo", default = false, items = function (self) return PresetsCombo("SatelliteShortcutPreset") end, },
{ id = "enable",
editor = "bool", default = true, },
},
Documentation = "Enable a satellite shortcut",
EditorNestedObjCategory = "Sector effects",
}
function SatelliteShortcutUnlockEffect:__exec(obj, context)
SatelliteShortcutSetEnabled(self.shortcut_id, self.enable)
end
function SatelliteShortcutUnlockEffect:GetError()
if not self.shortcut_id then
return "Specify shortcut!"
end
end
function SatelliteShortcutUnlockEffect:GetEditorView()
if self.enable then
return Untranslated("Enable satellite shortcut <u(shortcut_id)>", self)
else
return Untranslated("Disable satellite shortcut <u(shortcut_id)>", self)
end
end
DefineClass.ScatterAmbientLife = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
EditorView = Untranslated("Scatter Ambient Life"),
Documentation = "orders all of the ambient life units on the map (ones spawned from AmbientZones) to stop what they are doing on the spot and trigger the conflict logic.",
}
function ScatterAmbientLife:__exec(obj, context)
ChangeGameState({ConflictScripted=true})
end
DefineClass.SectorAddOperationProgress = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "operation", name = "Operation", help = "Operation to add progress to.",
editor = "combo", default = false, items = function (self) return table.keys(SectorOperations) end, },
{ id = "perc", name = "Add Perc", help = "Percent of the target progress that will be added.",
editor = "number", default = 0, min = 0, max = 100, },
},
Documentation = "Adds progress to a given operation in a given sector",
EditorView = Untranslated("Adds <percent(perc)> progress to <u(operation)> in sector <u(sector_id)>"),
EditorNestedObjCategory = "Sector effects",
}
function SectorAddOperationProgress:__exec(obj, context)
SectorOperations[self.operation]:BoostProgress(self.perc, gv_Sectors[self.sector_id])
end
function SectorAddOperationProgress:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorDisableAutoResolve = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "value",
editor = "bool", default = true, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Enable/Disable auto-resolve on the sector",
}
function SectorDisableAutoResolve:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if sector then
sector.autoresolve_disabled = not self.value
end
end
function SectorDisableAutoResolve:GetEditorView()
if self.value then
return Untranslated("Enable auto-resolve for sector <u(sector_id)>")
else
return Untranslated("Disable auto-resolve for sector <u(sector_id)>")
end
end
function SectorDisableAutoResolve:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorEnableAutoDeploy = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "deploy", help = "Enable/disable auto-deploy on enter.",
editor = "bool", default = true, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Enable/Disable auto-deploy mode on sector enter",
}
function SectorEnableAutoDeploy:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if sector then
sector.enabled_auto_deploy = self.deploy
end
end
function SectorEnableAutoDeploy:GetEditorView()
if self.deploy then
return Untranslated("Enable auto-deploy for sector <u(sector_id)>")
else
return Untranslated("Disable auto-deploy for sector <u(sector_id)>")
end
end
function SectorEnableAutoDeploy:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorEnableCustomOperation = {
__parents = { "Effect", "LootTableFunctionObjectBase", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "operation", name = "Operation", help = "Custom operation.",
editor = "combo", default = false, items = function (self) return GetCustomOperations() end, },
{ id = "DisplayLog", name = "Display in Log", help = "Whether to display enabling the Operation in the combat log",
editor = "bool", default = false, },
{ category = "Execution", id = "EffectsOnSuccess", name = "On Success", help = "Effects that are executed after the operation is completed.",
editor = "nested_list", default = false, base_class = "Effect", },
{ category = "Execution", id = "LootTableId", name = "Loot Table Id", help = "Loot table to generate items that will be granted after the operation is completed.",
editor = "preset_id", default = false, preset_class = "LootDef", },
{ category = "Execution", id = "GrantItemApply", name = "GrantItemApply", help = 'Loot table roll - "first"(merc) - only once, "all"(mercs) for each merc',
editor = "combo", default = "first", items = function (self) return {"first", "all"} end, },
},
Documentation = "Enables custom operation in the sector",
EditorView = Untranslated("Enables custom Operation <u(operation)> in sector <u(sector_id)>"),
EditorNestedObjCategory = "Sector effects",
}
function SectorEnableCustomOperation:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if not sector then return end
sector.custom_operations = sector.custom_operations or {}
sector.custom_operations[self.operation] = {
status = "enabled",
progress = 0,
EffectsOnSuccess = self.EffectsOnSuccess,
LootTableId = self.LootTableId,
GrantItemApply = self.GrantItemApply
}
ObjModified(sector)
ObjModified(gv_Squads)
if self.DisplayLog then
CombatLog("important",T{537039992460, "New <em>Sector Operation</em> available (<em><SectorId(sector)></em>): <em><ActivityName></em>", ActivityName = SectorOperations[self.operation] and SectorOperations[self.operation].display_name or "", sector = self.sector_id})
end
end
function SectorEnableCustomOperation:GetError()
if not self.sector_id then
return "Specify sector!"
elseif not self.operation then
return "Specify custom operation!"
end
end
function SectorEnableCustomOperation:GetPhraseTopRolloverText(negative, template, game)
return T{588881082990, "Operation is available: <em><ActivityName></em>", ActivityName = SectorOperations[self.operation] and SectorOperations[self.operation].display_name or ""}
end
DefineClass.SectorEnableWarningState = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Enable", name = "Enable", help = "Enable",
editor = "bool", default = true, },
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = "current", items = function (self) return table.iappend({{text="current",value="current"}}, GetCampaignSectorsCombo()) end, },
},
Documentation = "Enable/Disable the Warning State mechanic for sector. (does NOT trigger it)",
EditorView = Untranslated("Change <u(sector_id)> sector's WarningStateEnabled to <Bool(Enable)>. (does NOT trigger it)"),
EditorNestedObjCategory = "Sector effects",
}
function SectorEnableWarningState:__exec(obj, context)
local sector_id = self.sector_id == "current" and gv_CurrentSectorId or self.sector_id
local sector = gv_Sectors[sector_id]
sector.warningStateEnabled = self.Enable
end
DefineClass.SectorEnterConflict = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "conflict_mode", help = "Force or resolve conflict in that sector.",
editor = "bool", default = true, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return table.iappend({{text="current",value="current"}}, GetCampaignSectorsCombo()) end, },
{ id = "disable_travel", help = "Disables all travel zones on the map.",
editor = "bool", default = false, },
{ id = "lock_conflict", help = "Killing all enemies on the map cannot resolve a locked conflict, only scripts can.",
editor = "bool", default = false, },
{ id = "no_exploration_resolve", help = "dont resolve conflict in exploration",
editor = "bool", default = false, },
{ id = "descr_id", help = 'This text is displayed when the "Conflict" text is rolled over and in the description of the conflict window. Define texts in the conflict descriptions editor.',
editor = "combo", default = false, items = function (self) return PresetGroupCombo("ConflictDescription", "Default") end, },
{ id = "spawn_mode",
editor = "combo", default = false, items = function (self) return {"attack", "defend", "explore"} end, },
},
Documentation = "Forces/Resolve conflict mode for the speciafied sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorEnterConflict:__exec(obj, context)
local sector = self.sector_id == "current" and gv_Sectors[gv_CurrentSectorId] or gv_Sectors[self.sector_id]
if not sector then return end
if self.conflict_mode then
ForceEnterConflictEffect(
sector,
self.spawn_mode,
self.disable_travel,
self.lock_conflict,
self.descr_id,
self.no_exploration_resolve and "force-exploration-only" or "force"
)
else
sector.ForceConflict = false
if gv_Sectors[gv_CurrentSectorId] == sector then
if sector.conflict then
sector.conflict.locked = false
end
CheckMapConflictResolved("no voice")
else
ResolveConflict(sector, "no voice")
end
end
end
function SectorEnterConflict:GetEditorView()
if self.conflict_mode then
return Untranslated("Force conflict mode for sector <u(sector_id)>")
else
return Untranslated("Remove forced conflict mode for sector <u(sector_id)>")
end
end
function SectorEnterConflict:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorGrantIntel = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Grants intel for the sector",
EditorView = Untranslated("Grant intel for sector <u(sector_id)>"),
EditorNestedObjCategory = "Sector effects",
}
function SectorGrantIntel:__exec(obj, context)
DiscoverIntelForSector(self.sector_id)
end
function SectorGrantIntel:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
function SectorGrantIntel:GetPhraseTopRolloverText(negative, template, game)
local campaign = CampaignPresets[Game and Game.Campaign or DefaultCampaign]
local sector = gv_Sectors and gv_Sectors[self.sector_id] or table.find_value(campaign.Sectors, "Id", self.sector_id)
if sector and sector.intel_discovered then
return T{903574434021, "<em>Intel</em> is already available for <em><SectorName(sector)></em>", sector = sector}
end
return T{223883822777, "Gained <em>Intel</em> for <em><SectorName(sector)></em>", sector = sector}
end
DefineClass.SectorModifyEnemySquads = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "percent", name = "Percent", help = "Percent for enemy count modification.",
editor = "number", default = 0, },
{ id = "count", name = "Count", help = "Specific count for enemy count modification.",
editor = "number", default = 0, },
{ id = "UnitTemplate", name = "UnitTemplate", help = "Unit template that will be affected or all if false.",
editor = "combo", default = false, items = function (self) return GetEnemySquadsUnitTemplates("all") end, },
},
Documentation = "The spawned enemy squads in that sector get their units or specified type of units decreased or increased by that specified percent. To remove all units from unittype, set pecent to -100",
EditorNestedObjCategory = "Sector effects",
}
function SectorModifyEnemySquads:__exec(obj, context)
local value, valueType = self.percent, "percent"
local count = self.count
if count and count ~= 0 then
value = count
valueType = "count"
end
ModifySectorEnemySquads(self.sector_id, value, valueType, self.UnitTemplate)
end
function SectorModifyEnemySquads:GetEditorView()
local value, valueType = self.percent, "percent"
local count = self.count
if count and count ~= 0 then
value = count
valueType = "count"
end
local valString = valueType == "percent" and (tostring(value) .. "%") or tostring(value)
if value > 0 then
if self.UnitTemplate then
return Untranslated("Increases <u(UnitTemplate)> units in enemy squads force in <u(sector_id)> by " .. valString)
else
return Untranslated("Increases all enemies in <u(sector_id)> by ".. valString)
end
else
if self.UnitTemplate then
return Untranslated("Decreases <u(UnitTemplate)> units in enemy squads force in <u(sector_id)> by " .. valString)
else
return Untranslated("Decreases all enemies in <u(sector_id)> by " .. valString)
end
end
end
function SectorModifyEnemySquads:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorModifyMineProperties = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "DepletionTime", name = "Depletion Income Modifier Percent", help = "% modifier for depletion time",
editor = "number", default = false, min = 1, max = 500, },
{ id = "DailyIncome", name = "Daily Income Modifier Percent", help = "% modifier for profit per day at 100% loyalty. For instance 200 would double, and 50 would halve",
editor = "number", default = false, min = 0, max = 1000, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Modify diamond mine properties for a given sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorModifyMineProperties:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if self.DepletionTime then
if not sector.depletion_mods then sector.depletion_mods = {} end
sector.depletion_mods[#sector.depletion_mods + 1] = self.DepletionTime
end
if self.DailyIncome then
if not sector.income_mods then sector.income_mods = {} end
sector.income_mods[#sector.income_mods + 1] = self.DailyIncome
end
end
function SectorModifyMineProperties:GetEditorView()
return Untranslated("Modify diamond mine related properties on <sector_id>")
end
function SectorModifyMineProperties:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
function SectorModifyMineProperties:GetPhraseTopRolloverText(negative, template, game)
if self.DailyIncome and next(gv_Sectors) then
local name = gv_Sectors[self.sector_id].display_name
if self.DailyIncome > 100 then
return T{830978589245, "<Name> diamond production increased by <(value -100)>%", value = self.DailyIncome, Name = name}
end
if self.DailyIncome<100 then
return T{340934605682, "<Name> diamond production decreased by <(100-value)>%", value = self.DailyIncome, Name = name}
end
end
end
DefineClass.SectorRemoveCustomOperation = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "operation", name = "Operation", help = "Remove custom operation.",
editor = "combo", default = false, items = function (self) return GetCustomOperations() end, },
},
Documentation = "Removes custom operation in the sector, sets operation mercs to Idle",
EditorView = Untranslated("Removes custom Operation <u(operation)> in sector <u(sector_id)>"),
EditorNestedObjCategory = "Sector effects",
}
function SectorRemoveCustomOperation:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if not sector then return end
local operation = self.operation
if sector.custom_operations and sector.custom_operations[operation] then
sector.custom_operations[operation] = nil
end
local mercs = GetPlayerSectorUnits(self.sector_id)
SectorOperation_CancelByGame(mercs, operation, true)
ObjModified(sector)
ObjModified(gv_Squads)
end
function SectorRemoveCustomOperation:GetError()
if not self.sector_id then
return "Specify sector!"
elseif not self.operation then
return "Specify custom operation!"
end
end
function SectorRemoveCustomOperation:GetPhraseTopRolloverText(negative, template, game)
return T{565334741205, "<ActivityName> Operation is unavailable", ActivityName = SectorOperations[self.operation] and SectorOperations[self.operation].display_name or ""}
end
DefineClass.SectorReplaceEnemySquadList = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "EnemySquadsList", name = "Enemy Squads List", help = "A random squad from the list will be chosen on guardpost spawn time.",
editor = "preset_id_list", default = {}, preset_class = "EnemySquads", preset_filter = function (preset, obj, prop_meta)
if preset.group ~= "Test Encounters" then return obj end
end,
item_default = "", },
{ id = "StrongEnemySquadsList", name = "Strong Enemy Squads List",
editor = "preset_id_list", default = {}, preset_class = "EnemySquads", preset_filter = function (preset, obj, prop_meta)
if preset.group ~= "Test Encounters" then return obj end
end,
item_default = "", },
{ id = "ExtraDefenderSquads", name = "Extra Defender Squads",
editor = "preset_id_list", default = {}, preset_class = "EnemySquads", preset_filter = function (preset, obj, prop_meta)
if preset.group ~= "Test Encounters" then return obj end
end,
item_default = "", },
},
EditorView = Untranslated("Overrides EnemySquadList in sector <u(sector_id)>"),
Documentation = "Overrides EnemySquadList in a given sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorReplaceEnemySquadList:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if not sector then return end
if sector.EnemySquadsList and #sector.EnemySquadsList > 0 then
sector.EnemySquadsList = table.copy(self.EnemySquadsList)
end
if sector.StrongEnemySquadsList and #sector.StrongEnemySquadsList > 0 then
sector.StrongEnemySquadsList = table.copy(self.StrongEnemySquadsList)
end
if sector.ExtraDefenderSquads and #sector.ExtraDefenderSquads > 0 then
sector.ExtraDefenderSquads = table.copy(self.ExtraDefenderSquads)
end
end
function SectorReplaceEnemySquadList:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorReplaceTargetSectors = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "TargetSectors", name = "Target Sectors", help = "Target sectors for spawned enemy squads.",
editor = "string_list", default = {}, item_default = "", items = function (self) return GetCampaignSectorsCombo("") end, },
},
EditorView = Untranslated("Overrides TargetSectors in a given sector"),
Documentation = "Overrides TargetSectors in a given sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorReplaceTargetSectors:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if sector then
sector.TargetSectors = table.copy(self.TargetSectors, "deep")
end
end
function SectorReplaceTargetSectors:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetAwarenessSequence = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "awareness_sequence", name = "Awareness Sequence",
editor = "choice", default = "Standard", items = function (self) return { "Standard", "Skip Setpiece", "Skip All" } end, },
},
Documentation = "Enable/Disable auto-deploy mode on sector enter",
}
function SectorSetAwarenessSequence:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if sector then
sector.awareness_sequence = self.awareness_sequence
end
end
function SectorSetAwarenessSequence:GetEditorView()
return Untranslated(string.format("Set Awareness Sequence for for sector <u(sector_id)> to %s", self.awareness_sequence))
end
function SectorSetAwarenessSequence:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetCustomConflictDesc = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "descr_id", help = 'This text is displayed when the "Conflict" text is rolled over and in the description of the conflict window. Define texts in the conflict descriptions editor.',
editor = "combo", default = false, items = function (self) return PresetGroupCombo("ConflictDescription", "Default") end, },
},
Documentation = "Set a custom conflict description for the given sector. Cleared when the conflict is resolved.",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetCustomConflictDesc:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
sector.CustomConflictDescr = self.descr_id
if sector.conflict and not sector.conflict.descr_id then
sector.conflict.descr_id = self.descr_id
end
end
function SectorSetCustomConflictDesc:GetEditorView()
return Untranslated("Set conflict description <u(descr_id)> for <u(sector_id)>")
end
function SectorSetCustomConflictDesc:GetError()
if not self.sector_id then
return "Specify sector!"
end
if not self.descr_id then
return "Specify description preset!"
end
end
DefineClass.SectorSetForceConflict = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "force", name = "Force Conflict", help = "Force conflict value.",
editor = "bool", default = false, },
},
Documentation = "Enable/Disable 'force conflict' for the sector - entering sectors with force conflict set to true results in conflict mode with or without enemy presence in the sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetForceConflict:__exec(obj, context)
if not gv_Sectors[self.sector_id] then return end
gv_Sectors[self.sector_id].ForceConflict = self.force
end
function SectorSetForceConflict:GetEditorView()
if self.force then
return Untranslated("Enable sector <u(sector_id)> force conflict")
else
return Untranslated("Disable sector <u(sector_id)> force conflict")
end
end
function SectorSetForceConflict:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetHospital = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "enable", help = "Add/remove hospital in sector.",
editor = "bool", default = true, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Enable/disable hospital in specified sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetHospital:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
sector.HospitalLocked = not self.enable
sector.Hospital = true -- Legacy
Msg("BuildingLockChanged", self.sector_id)
end
function SectorSetHospital:GetPhraseTopRolloverText(negative, template, game)
return T{588881082990, "Operation is available: <em><ActivityName></em>", ActivityName = SectorOperations["HospitalTreatment"] and SectorOperations["HospitalTreatment"].display_name or ""}
end
function SectorSetHospital:GetEditorView()
if self.enable then
return Untranslated("Enable hospital in sector <u(sector_id)>")
else
return Untranslated("Disable hospital in sector <u(sector_id)>")
end
end
function SectorSetHospital:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetMap = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "MapFile",
editor = "combo", default = "", items = function (self) return ListMaps() end, },
{ id = "image",
editor = "ui_image", default = false, },
{ id = "loading_screen",
editor = "ui_image", default = false, },
},
Documentation = "Change the map of a sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetMap:__exec(obj, context)
local sectorPreset = gv_Sectors[self.sector_id]
if sectorPreset then
sectorPreset.Map = self.MapFile
if self.image and self.image ~= "" then
sectorPreset.image = self.image
end
if self.loading_screen and self.loading_screen ~= "" then
sectorPreset.override_loading_screen = self.loading_screen
end
end
end
function SectorSetMap:GetEditorView()
return Untranslated("Change the sector map of <u(sector_id)> to <u(MapFile)>", self)
end
function SectorSetMap:GetError()
if not self.sector_id then
return "Specify sector!"
elseif self.enable_sticky and self.disable_sticky then
return "You cannot both enable and disable sticky side, choose one"
end
end
DefineClass.SectorSetMilitia = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "enable", help = "Set militia in sector.",
editor = "bool", default = true, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Enable/disable militia in specified sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetMilitia:__exec(obj, context)
gv_Sectors[self.sector_id].Militia = self.enable
end
function SectorSetMilitia:GetEditorView()
if self.enable then
return Untranslated("Enable militia in sector <u(sector_id)>")
else
return Untranslated("Disable militia in sector <u(sector_id)>")
end
end
function SectorSetMilitia:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetMineProperties = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Depletion",
editor = "combo", default = "no-change", items = function (self) return { "no-change", "enabled", "disabled" } end, },
{ id = "HasMine",
editor = "combo", default = "no-change", items = function (self) return { "no-change", "enabled", "disabled" } end, },
{ id = "DepletionTime", help = "In how many days the mine will deplete",
editor = "number", default = false, min = 1, max = 500, },
{ id = "DailyIncome", help = "Profit per day at 100% loyalty",
editor = "number", default = false, min = 0, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Set diamond mine properties for a given sector.",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetMineProperties:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if self.Depletion ~= "no-change" then
sector.Depletion = self.Depletion == "enabled"
end
if self.HasMine ~= "no-change" then
sector.Mine = self.HasMine == "enabled"
end
if self.DepletionTime then
sector.DepletionTime = self.DepletionTime
end
if self.DailyIncome then
sector.DailyIncome = self.DailyIncome
end
end
function SectorSetMineProperties:GetEditorView()
return Untranslated("Set diamond mine related properties on <sector_id>")
end
function SectorSetMineProperties:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetPort = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "enable", help = "Add/remove port in sector.",
editor = "bool", default = true, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Enable/disable port in specified sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetPort:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
sector.PortLocked = not self.enable
sector.Port = true -- Legacy
if sector.Side == "player1" or sector.Side == "player2" then
gv_PlayerSectorCounts["Port"] = gv_PlayerSectorCounts["Port"] + 1
end
Msg("BuildingLockChanged", self.sector_id)
end
function SectorSetPort:GetEditorView()
if self.enable then
return Untranslated("Enable port in sector <u(sector_id)>")
else
return Untranslated("Disable port in sector <u(sector_id)>")
end
end
function SectorSetPort:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetRAndROperation = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "enable", help = "Set RAndR operation in sector.",
editor = "bool", default = true, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Enable/disable RAndR operation in specified sector",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetRAndROperation:__exec(obj, context)
gv_Sectors[self.sector_id].RAndRAllowed = self.enable
end
function SectorSetRAndROperation:GetEditorView()
if self.enable then
return Untranslated("Enable RAndR in sector <u(sector_id)>")
else
return Untranslated("Disable RAndR in sector <u(sector_id)>")
end
end
function SectorSetRAndROperation:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetRepairShopOperation = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "enable",
editor = "bool", default = true, },
{ id = "sector_id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Enable/Disable Repair Shop operations in the specified sector.",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetRepairShopOperation:__exec(obj, context)
gv_Sectors[self.sector_id].RepairShop = self.enable
end
function SectorSetRepairShopOperation:GetEditorView()
if self.enable then
return Untranslated("Enable Repair Shop operations in sector <u(sector_id)>")
else
return Untranslated("Disable Repair Shop operations in sector <u(sector_id)>")
end
end
function SectorSetRepairShopOperation:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorSetSide = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "side", name = "Side", help = "Choose side for sector.",
editor = "combo", default = "player1", items = function (self) return table.iappend(table.map(SideDefs, "Id"), {"dont-change"}) end, },
{ id = "enable_sticky", name = "Enable Sticky Side", help = "This will forcefully set sticky side to true.",
editor = "bool", default = false, },
{ id = "disable_sticky", name = "Disable Sticky Side", help = "This will forcefully set sticky side to false.",
editor = "bool", default = false, },
},
Documentation = "Change sector side and sticky side option (optional)",
EditorNestedObjCategory = "Sector effects",
}
function SectorSetSide:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
if not sector then return end
if self.enable_sticky then
sector.StickySide = true
elseif self.disable_sticky then
sector.StickySide = false
end
if self.side == "dont-change" then
if g_StartingCombat then return end
UpdateSectorControl(self.sector_id)
else
SatelliteSectorSetSide(self.sector_id, self.side, "force")
end
end
function SectorSetSide:GetEditorView()
if self.enable_sticky then
return Untranslated("Set side <u(side)> and enable sticky side in sector <u(sector_id)>")
elseif self.disable_sticky then
return Untranslated("Set side <u(side)> and disable sticky side in sector <u(sector_id)>")
else
return Untranslated("Set side <u(side)> in sector <u(sector_id)>")
end
end
function SectorSetSide:GetError()
if not self.sector_id then
return "Specify sector!"
elseif self.enable_sticky and self.disable_sticky then
return "You cannot both enable and disable sticky side, choose one"
end
end
DefineClass.SectorSpawnSquad = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "squad_def_id", name = "Squad", help = "Pre-defined enemy squad.",
editor = "combo", default = false, items = function (self) return EnemySquadsComboItems("exclude test squads") end, },
{ id = "side", name = "Side",
editor = "combo", default = "enemy1", items = function (self) return {"enemy1", "enemy2", "ally"} end, },
},
Documentation = "Spawns a predefined squad on the sector",
EditorView = Untranslated("Spawn a <u(squad_def_id)> squad in sector <u(sector_id)>"),
EditorNestedObjCategory = "Sector effects",
}
function SectorSpawnSquad:__exec(obj, context)
if not gv_Sectors[self.sector_id] then return end
GenerateEnemySquad(self.squad_def_id, self.sector_id, "Effect", nil, self.side)
end
function SectorSpawnSquad:GetError()
if not self.sector_id then
return "Specify sector!"
elseif not self.squad_def_id then
return "Specify squad!"
end
end
DefineClass.SectorSquadDespawn = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "Militia", name = "Remove militia",
editor = "bool", default = true, },
{ id = "Enemies", name = "Remove enemies",
editor = "bool", default = true, },
},
Documentation = "Removes all enemy and militia squads in that sector.",
EditorView = Untranslated("Removes enemy squads and militia in <u(sector_id)>"),
EditorNestedObjCategory = "Sector effects",
}
function SectorSquadDespawn:__exec(obj, context)
local squads = GetSectorSquads(self.sector_id)
for i = #squads, 1, -1 do
local squad = squads[i]
if self.Enemies and IsEnemySquad(squad.UniqueId) or
self.Militia and squad.militia
then
RemoveSquad(squad)
end
end
if not gv_SatelliteView and self.sector_id == gv_CurrentSectorId then
LocalCheckUnitsMapPresence()
end
end
function SectorSquadDespawn:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SectorTrainMilitia = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "Amount",
editor = "number", default = false,
default = const.Satellite.MilitiaUnitsPerTraining, min = 1, max = 8, },
},
Documentation = "Grants intel for the sector",
EditorView = Untranslated("Train <u(Amount)> militia on <u(sector_id)>"),
EditorNestedObjCategory = "Sector effects",
}
function SectorTrainMilitia:__exec(obj, context)
local sector = gv_Sectors[self.sector_id]
local _, trained =SpawnMilitia(self.Amount, sector)
if trained == 0 then return end
local logText = T{769055535456, "<amount> militia dispatched to <SectorName(sector)>",
amount = trained,
sector = sector
}
CombatLog("important", logText)
end
function SectorTrainMilitia:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
function SectorTrainMilitia:GetPhraseTopRolloverText(negative, template, game)
local campaign = CampaignPresets[Game and Game.Campaign or DefaultCampaign]
local sector = gv_Sectors and gv_Sectors[self.sector_id] or table.find_value(campaign.Sectors, "Id", self.sector_id)
return T{445122419956, "Sent <em>Militia</em> to <em><SectorName(sector)></em>", sector = sector}
end
DefineClass.SectorsGrantIntel = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", help = "Sector id.",
editor = "string_list", default = {}, item_default = "", items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Grants intel for an array of sectors",
EditorView = Untranslated("Grant intel for sectors <list(sector_id, ', ')>"),
EditorNestedObjCategory = "Sector effects",
}
function SectorsGrantIntel:__exec(obj, context)
DiscoverIntelForSectors(self.sector_id)
end
function SectorsGrantIntel:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
function SectorsGrantIntel:GetPhraseTopRolloverText(negative, template, game)
local campaign = CampaignPresets[Game and Game.Campaign or DefaultCampaign]
local knew = {}
local new = {}
for i, s in ipairs(self.sector_id) do
local sector = gv_Sectors and gv_Sectors[s] or table.find_value(campaign.Sectors, "Id", s)
if sector then
if sector.intel_discovered then
knew[#knew + 1] = T{427357563595, "<em><SectorName></em>", SectorName = sector and sector.display_name or "",}
else
new[#new + 1] = T{165345603261, "<em><SectorName></em> (sector <SectorId(sId)>)", SectorName = sector and sector.display_name or "", sId = s}
end
end
end
local textCombined = false
if #new > 0 then
textCombined = T{309239191160, "Gained <em>Intel</em> for <sectors>.", sectors = table.concat(new, ", ")}
end
if #knew > 0 then
local knewText = T{124400089767, "Intel for <sectors> is already available.", sectors = table.concat(knew, ", ")}
if textCombined then
textCombined = textCombined .. T(226690869750, "<newline>") .. knewText
else
textCombined = knewText
end
end
return textCombined
end
DefineClass.SetBadgeEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Remove", help = "Remove the badge instead.",
editor = "bool", default = false, },
{ id = "BadgeUnit", name = "Badge on Unit", help = "The unit/group to place the badge on, if it exists on the current map.",
editor = "combo", default = false, items = function (self) return GridMarkerGroupsCombo() end, },
{ id = "BadgePreset", name = "Badge Preset", help = "The badge preset to spawn.",
editor = "preset_id", default = false, preset_class = "BadgePresetDef", },
{ id = "Quest", name = "Quest", help = "Which quest to associate this badge with. If the effect is placed on a quest it will attempt to find it itself.",
editor = "preset_id", default = false, preset_class = "QuestsDef", },
},
EditorView = T(946118376279, --[[EffectDef Effects SetBadgeEffect value]] "Place a badge of preset <u(BadgePreset)> on unit <u(BadgeUnit)>"),
Documentation = "Place a badge on a unit.",
EditorNestedObjCategory = "Units",
}
function SetBadgeEffect:__exec(obj, context)
local quest = (self.Quest and gv_Quests[self.Quest]) or (IsKindOf(obj, "QuestsDef") and obj) or false
assert(quest)
if not quest then return end
if not self.BadgeUnit then return end
local prefix = ""
if self.Remove then
prefix = badgeRemoveIdentifier
end
quest[badgeParamIdentifier .. self.BadgeUnit] = prefix .. (self.BadgePreset or "")
UpdateQuestBadges(quest)
end
DefineClass.SetBehaviorVisitAL = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ActorGroup", name = "Actor Group", help = "Unit group that will exit the map.",
editor = "combo", default = "", items = function (self) return GetUnitGroups() end, },
{ id = "MarkerGroup", name = "Marker Group", help = "Exit marker group.",
editor = "combo", default = "",
no_edit = function(self) return self.closest end, items = function (self) return GetALMarkersGroups end, },
{ id = "Kick", name = "Kick",
editor = "bool", default = true, },
},
EditorView = Untranslated("<u(ActorGroup)> visits <u(MarkerGroup)> marker"),
Documentation = "Units vists specified Ambient Life marker",
EditorNestedObjCategory = "Units",
}
function SetBehaviorVisitAL:__exec(obj, context)
local group_actors = ValidateUnitGroupForEffectExec(self.ActorGroup, self, obj)
local actors = table.ifilter(group_actors, function(_, actor)
return IsKindOf(actor, "Unit") and not actor.perpetual_marker
end)
if #actors == 0 then return end
local actor = actors[1]
if not IsValid(actor) then return end
local visitables = table.ifilter(g_Visitables, function(_, visitable)
local marker_groups = visitable[1].Groups
local from_group = not not table.find(marker_groups, self.MarkerGroup)
return from_group
end)
if #visitables == 0 then return end
local marker_visitable = visitables[1]
if marker_visitable.reserved == actor.handle then
return -- same unit already visiting
end
local marker = marker_visitable[1]
if marker_visitable.reserved then
if not self.Kick then
return -- can't kick currently visiting unit
end
local unit = HandleToObject[marker_visitable.reserved]
if IsValid(unit) then
unit:FreeVisitable(marker_visitable)
unit:SetCommand("Idle")
end
end
actor:ReserveVisitable(marker_visitable)
if marker:Random(100) < marker.ChanceSpawn then
marker.perpetual_unit = actor
actor.perpetual_marker = marker
end
if GameState and (GameState.entering_sector or GameState.setpiece_playing) and marker.Teleport then
actor.teleport_allowed_once = true
end
actor:SetCommand("Visit", marker_visitable)
end
function SetBehaviorVisitAL:GetEditorView()
return Untranslated("Sets <u(ActorGroup)> to visit <u(MarkerGroup)> marker")
end
DefineClass.SetDeploymentModeEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "DeploymentMode", name = "Deployment Mode", help = "Sector id.",
editor = "combo", default = "defend", items = function (self) return {"defend", "attack"} end, },
{ id = "DeploymentDir", name = "Deployment Direction", help = "Deployment Direction during attack",
editor = "combo", default = "North",
no_edit = function(self) return self.DeploymentMode == "defend" end, items = function (self) return {"North", "East", "South", "West"} end, },
},
Documentation = "Set Deployment Mode(and direction if attacking)r",
EditorView = Untranslated("Set Deployment Mode"),
}
function SetDeploymentModeEffect:__exec(obj, context)
SetDeploymentMode(self.DeploymentMode)
if self.DeploymentMode == "attack" then
gv_DeploymentDir = self.DeploymentDir
end
end
DefineClass.SetSectorAutoResolveDefenderBonus = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "autoResolveDefenderBonus", name = "Auto Resolve Defender Bonus",
editor = "number", default = 0, },
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = "current", items = function (self) return table.iappend({{text="current",value="current"}}, GetCampaignSectorsCombo()) end, },
},
Documentation = "Set a sector's Auto Resolve Defender Bonus.",
EditorView = Untranslated("Set <u(sector_id)> sector's Auto Resolve Defender Bonus to <u(autoResolveDefenderBonus)>"),
EditorNestedObjCategory = "Sector effects",
}
function SetSectorAutoResolveDefenderBonus:__exec(obj, context)
local sector_id = self.sector_id == "current" and gv_CurrentSectorId or self.sector_id
local sector = gv_Sectors[sector_id]
sector.AutoResolveDefenderBonus = self.autoResolveDefenderBonus
end
DefineClass.SetSectorDiscovered = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "sector_id", name = "Sector Id", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
},
Documentation = "Sets a sector to discovered",
EditorNestedObjCategory = "Sector effects",
}
function SetSectorDiscovered:__exec(obj, context)
local sectorPreset = gv_Sectors[self.sector_id]
if sectorPreset then
sectorPreset.discovered = true
if g_SatelliteUI then
g_SatelliteUI:UpdateSectorVisuals(self.sector_id)
end
end
end
function SetSectorDiscovered:GetEditorView()
return Untranslated("Set <u(sector_id)> to discovered", self)
end
function SetSectorDiscovered:GetError()
if not self.sector_id then
return "Specify sector!"
end
end
DefineClass.SetTimer = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Name", name = "Name", help = "Name of the timer.",
editor = "text", default = false, },
{ id = "Label", name = "Label", help = "The label to display on the timer.",
editor = "text", default = false, translate = true, },
{ id = "Time", name = "Time", help = "Time (in secs) to wait.",
editor = "number", default = 60000, scale = "sec", },
},
EditorView = Untranslated("Set timer <Name>"),
Documentation = "The effect set a visual UI timer displayed in the upper center of the screen",
EditorNestedObjCategory = "UI & Log",
}
function SetTimer:__exec(quest, context, TCE)
if not (GameState.Conflict or GameState.ConflictScripted or GameState.Combat) then
-- NOTE: Combat can be started without going through Conflict first, e.g. Stealth Kill
StoreErrorSource("once", "SetTimer running in a sector without Conflict/Combat!")
end
TimerCreate(self.Name, self.Label, self.Time)
end
function SetTimer:__waitexec(quest, context, TCE)
self:__exec(quest, context, TCE)
return TimerWait(self.Name)
end
function SetTimer:__skip(quest, context, TCE)
return self:__exec(quest, context, TCE)
end
function SetTimer:GetError()
if not self.Name then
return "SetTimer needs a name!"
end
if not self.Time then
return "SetTimer needs time specified!"
end
if GetParentTableOfKindNoCheck(self, "TestHarness") then
return
end
local container = GetParentTableOfKind(self, "TriggeredConditionalEvent")
if not container then
return "SetTimer can only be used in TCEs"
end
if not container.SequentialEffects then
return "SetTimer can be used only in TCEs with Sequential Effects execution!"
end
end
function SetTimer:GetResumeData(thread, stack, stack_index)
return "TimerWait", self.Name
end
DefineClass.ShowGuardpostObjective = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "GuardpostObjective", name = "GuardpostObjective",
editor = "preset_id", default = false, preset_class = "GuardpostObjective", },
},
EditorView = Untranslated("Make guardpost objective <u(GuardpostObjective)> visible."),
Documentation = "Make a guardpost objective visible.",
EditorNestedObjCategory = "Sectors",
}
function ShowGuardpostObjective:__exec(obj, context)
SetGuardpostObjectiveSeen(self.GuardpostObjective)
end
DefineClass.ShowPopup = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "PopupId", help = "Popup notification preset id.",
editor = "preset_id", default = false, preset_class = "PopupNotification", },
},
EditorView = Untranslated("Show popup notification <u(PopupId)>"),
Documentation = "Displays popup notification",
EditorNestedObjCategory = "UI & Log",
}
function ShowPopup:GetError()
if not self.PopupId then
return "No PopupId"
end
end
function ShowPopup:__exec(obj, context)
local id = self.PopupId
local preset = PopupNotifications[id]
if not preset then
StoreErrorSource(Presets.PopupNotification[1][1], "Trying to show missing pop-up: " .. id)
return
end
if preset.OnceOnly and gv_DisabledPopups[id] then
return
end
ShowPopupNotification(id)
end
function ShowPopup:__waitexec(obj, context)
self:__exec(obj, context)
Msg("ClosePopup" .. self.PopupId)
end
function ShowPopup:__skip(quest, context, TCE)
return self:__exec(quest, context, TCE)
end
function ShowPopup:GetResumeData(thread, stack, stack_index)
return "ShowPopup", self.PopupId
end
DefineClass.SleepEffect = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Sleep", name = "Sleep", help = "Sleep time in ms.",
editor = "number", default = 1000, },
},
Documentation = "An effect to delay other effects' execution.",
}
function SleepEffect:GetEditorView()
return T(206265192932, "Delay: <u(Sleep)> ms")
end
function SleepEffect:__exec(obj, context)
return
end
function SleepEffect:__waitexec(obj, context)
Sleep(self.Sleep)
end
function SleepEffect:__skip(quest, context, TCE)
end
function SleepEffect:GetResumeData(thread, stack, stack_index)
local remainig = GetThreadStatus(thread) - GameTime()
assert(type(remainig) == "number")
assert(remainig >= 0)
return "Sleep", remainig
end
DefineClass.StartDeploymentInCurrentSector = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "WaitClicked", name = "Wait Clicked", help = "Waits for the button to be clicked before continuing to trigger next effects.",
editor = "bool", default = false, },
{ id = "EntranceZone", name = "EntranceZone", help = "Specific entrance zone",
editor = "choice", default = "custom", items = function (self) return {"attacker", "defender", "custom"} end, },
},
Documentation = "Enter deployment mode if it is valid for the currently loaded sector",
EditorView = Untranslated("Enter deployment mode"),
}
function StartDeploymentInCurrentSector:__exec(obj, context)
if self.EntranceZone and self.EntranceZone ~= "custom" then
SetDeploymentMode(self.EntranceZone)
else
gv_Deployment = "custom"
end
StartDeployment()
end
function StartDeploymentInCurrentSector:__waitexec(obj, context)
self:__exec(obj, context)
if self.WaitClicked then
WaitMsg("DeploymentModeDone")
end
end
function StartDeploymentInCurrentSector:__skip(quest, context, TCE)
return self:__exec(quest, context, TCE)
end
function StartDeploymentInCurrentSector:GetResumeData(thread, stack, stack_index)
return "StartDeploymentInCurrentSector", self.EntranceZone
end
DefineClass.TriggerGuardPostAttack = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "guardpost_sector_id", name = "Guardpost Sector", help = "Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "effect_target_sector_ids", name = "Target Sectors", help = "Attack one of these sectors.",
editor = "string_list", default = {}, item_default = "last captured", items = function (self) return GetCampaignSectorsCombo("last captured") end, },
{ id = "time", name = "Time", help = "Time to pass before spawning the squad.",
editor = "number", default = 43200, scale = "h", },
{ id = "custom_quest_id", name = "Custom Quest Id", help = "This could would be used in quests (ex. to check if the attack squad was defeated - with SquadDefeated condition).",
editor = "text", default = false, },
{ id = "reach_quest_id", name = "Reach Quest Id", help = "Quest to set variables to true when squad reaches it destination sector.",
editor = "preset_id", default = false, preset_class = "QuestsDef", },
{ id = "reach_quest_var", name = "Var to check", help = "Variable in reach quest to set to true when squad reaches it destination sector",
editor = "set", default = false, max_items_in_set = 1, items = function (self) return table.keys2(QuestGetVariables(self.reach_quest_id), "sorted") end, },
},
Documentation = "Spawns enemy squad from guardpost after time.",
EditorNestedObjCategory = "Sector effects",
}
function TriggerGuardPostAttack:GetEditorView()
local targets = Untranslated(table.concat(self.effect_target_sector_ids, ", "))
return T{926384305749, "Spawns enemy squad from guardpost on <u(guardpost_sector_id)> to (<targets>) after <CampaignTime(time)>", self, targets = targets}
end
function TriggerGuardPostAttack:__exec(obj, context)
local gp = g_Guardposts[self.guardpost_sector_id]
if not gp then
StoreErrorSource(self, "TriggerGuardPostAttack - guardpost_sector_id should be sector with guardpost.")
end
if table.find(self.effect_target_sector_ids, "last captured") and not gv_LastSectorTakenByPlayer then
return
end
if gp then
gp:ForceSetNextSpawnTimeAndSector(self.time, self.effect_target_sector_ids, self.custom_quest_id, self.reach_quest_id, self.reach_quest_var)
end
end
function TriggerGuardPostAttack:GetError()
if not self.guardpost_sector_id then
return "Specify Guardpost Sector"
elseif not self.effect_target_sector_ids[1] or self.effect_target_sector_ids[1] == "" then
return "Specify Target Sector!"
end
local sector = gv_Sectors and gv_Sectors[self.guardpost_sector_id]
if sector and not sector.Guardpost then
return "Sector should be a guardpost sector!"
end
end
DefineClass.TriggerSectorWarningState = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
RequiredObjClasses = {
"Unit",
},
EditorView = Untranslated("Trigger the current sector's Warning State"),
Documentation = "Triggers the Warning State for the current sector.",
EditorNestedObjCategory = "Sector effects",
}
function TriggerSectorWarningState:__exec(obj, context)
if gv_SatelliteView then return end
local sector = gv_Sectors[gv_CurrentSectorId]
local alliedUnits = GetPlayerSectorUnits(gv_CurrentSectorId, "getUnits")
local enemyUnits = GetAllEnemyUnits(alliedUnits[1])
local triggeringUnit
if IsKindOf(obj, "Unit") and table.find(alliedUnits, obj) then
triggeringUnit = obj
else
triggeringUnit = alliedUnits[1]
end
EnterWarningState(enemyUnits, alliedUnits, triggeringUnit)
end
DefineClass.TriggerSquadAttack = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "source_sector_id", name = "Source Sector", help = "Source Sector id.",
editor = "combo", default = false, items = function (self) return GetCampaignSectorsCombo() end, },
{ id = "effect_target_sector_ids", name = "Target Sectors", help = "Attack one of these sectors.",
editor = "string_list", default = {}, item_default = "last captured", items = function (self) return GetCampaignSectorsCombo("last captured") end, },
{ id = "reach_quest_id", name = "Reach Quest Id", help = "Quest to set variables to true when squad reaches it destination sector.",
editor = "preset_id", default = false, preset_class = "QuestsDef", },
{ id = "reach_quest_var", name = "Var to check", help = "Variable in reach quest to set to true when squad reaches it destination sector",
editor = "set", default = false, max_items_in_set = 1, items = function (self) return table.keys2(QuestGetVariables(self.reach_quest_id), "sorted") end, },
{ id = "custom_quest_id", name = "Custom Quest Id", help = "This could would be used in quests (ex. to check if the attack squad was defeated - with SquadDefeated condition).",
editor = "text", default = false, },
{ id = "EnemySquadsList", name = "Enemy Squads List", help = "A random squad from the list will be chosen on guardpost spawn time",
editor = "preset_id_list", default = {},
no_edit = function(self) return not self.Guardpost end, preset_class = "EnemySquads", preset_filter = function (preset, obj, prop_meta)
if preset.group ~= "Test Encounters" then return obj end
end,
item_default = "", },
{ id = "Squad", name = "Squad", help = "Squad that will be spawned in the sector on campaign start",
editor = "combo", default = false, items = function (self) return EnemySquadsComboItems("exclude test squads") end, },
},
Documentation = "Spawns specific enemy squad after time.",
EditorNestedObjCategory = "Sector effects",
}
function TriggerSquadAttack:GetEditorView()
local targets = Untranslated(table.concat(self.effect_target_sector_ids, ", "))
return T{768343821287, "Spawns specific enemy squad to (<targets>)", self, targets = targets}
end
function TriggerSquadAttack:__exec(obj, context)
if table.find(self.effect_target_sector_ids, "last captured") and not gv_LastSectorTakenByPlayer then
return
end
local sector = gv_Sectors[self.source_sector_id]
if not sector then return end
local sector_ids = self.effect_target_sector_ids
if gv_LastSectorTakenByPlayer then
table.replace(sector_ids, "last captured", gv_LastSectorTakenByPlayer)
end
local target_sector_id = table.interaction_rand(sector_ids, "TriggerSquadAttack")
--local next_squad = table.interaction_rand(sector.EnemySquadsList or empty_table, "TriggerSquadAttack")
--local next_squad_units = GenerateRandEnemySquadUnits(next_squad)
local squad_id = GenerateEnemySquad(self.Squad, self.source_sector_id, "TriggerSquadAttack")
if squad_id then
gv_CustomQuestIdToSquadId[self.custom_quest_id or self.Squad] = squad_id
local squad = gv_Squads[squad_id]
squad.on_reach_quest = self.reach_quest_id
squad.on_reach_var = self.reach_quest_var
if target_sector_id ~= self.source_sector_id then
SendSatelliteSquadOnRoute(squad, target_sector_id)
local timeToReach = GetTotalRouteTravelTime(squad.CurrentSector, squad.route, squad)
AddTimelineEvent("squad-attack-" .. squad.UniqueId, Game.CampaignTime + timeToReach, "squad-attack", squad.UniqueId)
end
return squad_id
end
StoreErrorSource(sector, string.format("Sector '%s' does not have enemy squad '%s'", self.source_sector_id, self.Squad))
end
function TriggerSquadAttack:GetError()
if not self.Squad then
return "Specify Squad"
elseif not self.effect_target_sector_ids[1] or self.effect_target_sector_ids[1] == "" then
return "Specify Target Sector!"
end
end
DefineClass.UnitAddGrit = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "amount", name = "Amount",
editor = "number", default = 30, },
},
RequiredObjClasses = {
"Unit",
"UnitData",
},
EditorView = Untranslated("Add grit to the unit."),
Documentation = "Add grit to the unit.",
EditorNestedObjCategory = "Units",
}
function UnitAddGrit:__exec(obj, context)
local unit = obj
if IsKindOf(unit, "UnitData") then
unit = g_Units[unit.session_id]
end
if IsKindOf(unit, "Unit") and not unit:IsDead() then
unit:ApplyTempHitPoints(self.amount)
end
end
DefineClass.UnitAddStatusEffect = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Status", name = "Status",
editor = "preset_id", default = false, preset_class = "CharacterEffectCompositeDef", },
},
RequiredObjClasses = {
"Unit",
},
EditorView = Untranslated("Add <u(Status)> effect to the unit"),
Documentation = "Add status effect to a unit",
}
function UnitAddStatusEffect:__exec(obj, context)
if IsKindOf(obj, "Unit") and not obj:IsDead() then
obj:AddStatusEffect(self.Status)
end
if not context then context = {} end
local units = self:MatchMapUnits(obj, context)
if units and context.target_units then
for _, unit in ipairs(context.target_units) do
if self.Status == "Wounded" then
obj:AddWounds(1)
else
obj:AddStatusEffect(self.Status)
end
end
end
end
function UnitAddStatusEffect:UnitCheck(unit, obj, context)
return IsKindOf(unit, "Unit") and not unit:IsDead()
end
function UnitAddStatusEffect:GetEditorView()
return T(237536962390, "Add <u(Status)> to the unit")
end
DefineClass.UnitApplyAppearance = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "TargetUnit", name = "Target Unit", help = "Target unit for match.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
{ id = "Appearance", name = "Appearance", help = "Appearance to set.",
editor = "preset_id", default = false, preset_class = "AppearancePreset", },
},
EditorView = Untranslated("<u(TargetUnit)> changes appearance to <Appearance>"),
Documentation = "Changes the appearance of an unit",
EditorNestedObjCategory = "Units",
}
function UnitApplyAppearance:__exec(obj, context)
local units = Groups[self.TargetUnit] or empty_table
if units[1] then
units[1]:ApplyAppearance(self.Appearance)
end
end
function UnitApplyAppearance:GetError()
if not self.TargetUnit then
return "Choose target unit to die"
end
end
DefineClass.UnitDie = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "TargetGroup", name = "Target Group", help = "Target group for match.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
{ id = "skipAnim", name = "Skip Animation",
editor = "bool", default = false, },
{ id = "killImmortal", name = "Kill Immortal", help = "Makes units mortal and then kills them.",
editor = "bool", default = false, },
},
EditorView = Untranslated("Units from group <u(TargetGroup)> die"),
Documentation = "Kill units from specified group",
EditorNestedObjCategory = "Units",
}
function UnitDie:__exec(obj, context)
local group = Groups[self.TargetGroup] or empty_table
for i, v in ipairs(group) do
if IsKindOf(v, "Unit") and not v:IsDead() then
v.villain = false
if self.killImmortal then
v.immortal = false
end
v:SetCommand("Die", self.skipAnim)
end
end
end
function UnitDie:GetError()
if not self.TargetGroup then
return "Choose target unit to die"
end
end
DefineClass.UnitEnvEffectTick = {
__parents = { "UnitTarget", "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "EffectType",
editor = "choice", default = "Burning", items = function (self) return {"Burning", "ToxicGas", "TearGas", "Smoke", "Darkness"} end, },
{ id = "CombatMoment",
editor = "choice", default = "n/a", items = function (self) return {"start turn", "end turn", "n/a"} end, },
},
EditorView = Untranslated("Trigger <u(EffectType)> tick for <u(TargetUnit)>"),
Documentation = "Trigger environmental effect tick for target unit",
EditorNestedObjCategory = "Units",
}
function UnitEnvEffectTick:__exec(obj, context)
if not context then context = {} end
local units = self:MatchMapUnits(obj, context)
if units and context.target_units then
local moment = (self.CombatMoment ~= "n/a") and self.CombatMoment or nil
local func = EnvEffectBurningTick
if self.EffectType == "ToxicGas" then
func = EnvEffectToxicGasTick
elseif self.EffectType == "TearGas" then
func = EnvEffectTearGasTick
elseif self.EffectType == "Smoke" then
func = EnvEffectSmokeTick
elseif self.EffectType == "Darkness" then
func = EnvEffectDarknessTick
end
for _, unit in ipairs(context.target_units) do
if IsValid(unit) and IsKindOf(unit, "Unit") and not unit:IsDead() then
func(unit, nil, moment)
end
end
end
end
function UnitEnvEffectTick:GetError()
if not self.TargetUnit then
return "Choose target unit"
end
end
function UnitEnvEffectTick:UnitCheck(unit, obj, context)
return true
end
DefineClass.UnitGrantAP = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ap", name = "AP", help = "Action Points to Give",
editor = "number", default = 8, },
},
RequiredObjClasses = {
"Unit",
},
EditorView = Untranslated("Grant <u(ap)> AP to the unit"),
Documentation = "Modify unit's AP",
EditorNestedObjCategory = "Units",
}
function UnitGrantAP:__exec(obj, context)
if IsKindOf(obj, "Unit") and not obj:IsDead() then
if self.ap > 0 then
obj:GainAP(self.ap*const.Scale.AP)
else
obj:ConsumeAP(self.ap*const.Scale.AP)
end
end
end
DefineClass.UnitGrantItem = {
__parents = { "Effect", "LootTableFunctionObjectBase", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ItemId", name = "Item", help = "The id of the item that will be granted.",
editor = "preset_id", default = false, preset_class = "InventoryItemCompositeDef", },
{ id = "Amount", name = "Amount", help = "How many items are granted.",
editor = "number", default = 1, min = 1, },
{ id = "LootTableId", name = "Loot Table Id", help = "Loot table to generate items that will be granted.",
editor = "preset_id", default = false, preset_class = "LootDef", },
{ id = "GrantedItemsTextUI",
editor = "text", default = false, dont_save = true, no_edit = true, translate = true, },
{ id = "GrantedItemsEditorTextUI",
editor = "text", default = false, dont_save = true, no_edit = true, translate = true, },
{ id = "GeneratedItems",
editor = "prop_table", default = false, dont_save = true, no_edit = true, },
{ id = "actor", name = "Log Actor", help = "How to log the received items.",
editor = "choice", default = "important", items = function (self) return {"short", "important"} end, },
},
Documentation = "Give item to a merc or to any from its squad.",
EditorNestedObjCategory = "Units",
}
function UnitGrantItem:GetEditorView()
if self.ItemId and self.LootTableId then
return Untranslated("<u(ItemId)>(<Amount>) and \'<u(LootTableId)>\' loot table items are given to the merc")
end
if self.ItemId then
return Untranslated("<u(ItemId)>(<Amount>) given to the merc")
end
if self.LootTableId then
return Untranslated("Loot table items \'<u(LootTableId)>\' given to the merc")
end
return ""
end
function UnitGrantItem:__exec(obj, context)
-- can work with both unit and a unit session_id
local unit_id = type(obj) == "string" and obj or obj.session_id --please no SelectedObj here, this is sync
local squad = gv_UnitData[unit_id] and gv_UnitData[unit_id].Squad
if not squad then
-- try to give to the first of player squads
local squads = GetSectorSquadsFromSide(gv_CurrentSectorId, "player1")
squad = #squads>0 and squads[1].UniqueId
end
--to any player squad
assert(squad, "There is not unit or player squad on the sector")
if not squad then
if g_PlayerSquads and #g_PlayerSquads>0 then
squad = g_PlayerSquads[1].UniqueId
end
end
assert(squad, "There is not any player squad.The item is not given.")
if not squad then return end
local sector = gv_Squads[squad].CurrentSector
local all_mercs = gv_Squads[squad].units
if unit_id then
all_mercs = table.copy(all_mercs)
table.remove_entry(all_mercs, unit_id)
table.insert(all_mercs, 1, unit_id)
end
unit_id = unit_id or all_mercs[1]
-- loot table
local items = UnitGrantItem.GenerateItems(self, "game") or {}
CombatLogActorOverride = self.actor
AddItemsToSquadBag(squad, items)
for idx, merc in ipairs(all_mercs) do
if #items<=0 then break end
local unit = g_Units[merc] or gv_UnitData[merc]
unit:AddItemsToInventory(items)
end
if #items > 0 then
local unit = g_Units[unit_id]
if unit then
unit:DropItemsInContainer(items,
function(unit, item, amount)
CombatLog("important", T{740183432105, " Inventory full. <amount><em><item></em> dropped by <name>", amount = amount>1 and Untranslated(amount.." x ") or "", item = amount>1 and item.DisplayNamePlural or item.DisplayName, name = unit:GetDisplayName()})
end)
else
local stash = GetSectorInventory(sector)
if stash then
AddItemsToInventory(stash, items, true)
end
end
end
-- items
if self.ItemId then
local amount = self.Amount
local item
if amount > 0 then
amount = AddItemToSquadBag(squad, self.ItemId, amount)
end
for idx, merc in ipairs(all_mercs) do
if amount <= 0 then break end
local unit = g_Units[merc] or gv_UnitData[merc]
amount = unit:AddToInventory(self.ItemId, amount)
end
if amount > 0 then
local unit = g_Units[unit_id]
if unit then
unit:DropItemContainer(self.ItemId, amount,
function(unit, item, amount)
CombatLog("important", T{740183432105, " Inventory full. <amount><em><item></em> dropped by <name>", amount = amount>1 and Untranslated(amount.." x ") or "", item = amount>1 and item.DisplayNamePlural or item.DisplayName, name = unit:GetDisplayName()})
end)
else
local stash = GetSectorInventory(sector)
if stash then
local itm = PlaceInventoryItem(self.ItemId)
AddItemsToInventory(stash, {itm},true)
end
end
end
end
self.GeneratedItems = false
CombatLogActorOverride = false
end
function UnitGrantItem:GetError()
if (not self.ItemId or self.ItemId == "") and not self.LootTableId then
return "Set Item or loot table!"
end
end
function UnitGrantItem:GetPhraseTopRolloverText(negative, template, game)
local item = self.ItemId and InventoryItemDefs[self.ItemId]
if item then
local item_name = item.DisplayName
local item_name_pl = item.DisplayNamePlural
if self.ItemId == "Money" then
return T{283114521154, "<em><money(Amount)></em> obtained", Amount = self.Amount}
else
return T{215465168779, "<Amount> x <em><item></em> obtained", Amount = self.Amount, item = self.Amount<=1 and item_name or item_name_pl}
end
end
self:GenerateItems(game)
if game then
if self.GrantedItemsTextUI and self.GrantedItemsTextUI ~= "" then
return T{871249882862, "<items_list> obtained", items_list = self.GrantedItemsTextUI}
end
else
if self.GrantedItemsEditorTextUI and self.GrantedItemsEditorTextUI ~= "" then
return T{871249882862, "<items_list> obtained", items_list = self.GrantedItemsEditorTextUI}
end
end
end
function UnitGrantItem:GenerateItems(game)
if game and self.GeneratedItems then return self.GeneratedItems end -- items are already generated don't try again.
if not game and self.GrantedItemsEditorTextUI then return end
local items = {}
local loot_tbl = LootDefs[self.LootTableId]
if loot_tbl then
loot_tbl:GenerateLoot(self, {}, InteractionRand(nil, "Loot"), items)
end
if #items > 0 then
if game then
self.GeneratedItems = items
self.GrantedItemsTextUI = GetItemsNamesText(items)
else
self.GrantedItemsEditorTextUI = GetItemsNamesText(items)
end
end
return items
end
function UnitGrantItem:GetPhraseFX()
return "ConversationItemGained"
end
DefineClass.UnitJoinAsMerc = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "TargetUnit", name = "Target Unit", help = "Target unit for match.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
{ id = "Merc", help = "The Merc to join the team.",
editor = "combo", default = false, items = function (self) return MercPresetCombo() end, },
},
RequiredObjClasses = {
"Unit",
},
EditorView = Untranslated("Make <u(TargetUnit)> join team as <u(Merc)>"),
Documentation = "Unit joins as a specified merc.",
EditorNestedObjCategory = "Units",
}
function UnitJoinAsMerc:__exec(obj, context)
local units = Groups[self.TargetUnit] or empty_table
units = table.ifilter(units, function(_, u)
return IsKindOf(u, "Unit")
end)
-- can work with both unit and a unit session_id
local unit_id = type(obj) == "string" and obj or obj.session_id --please no SelectedObj here, this is sync
local squad = gv_UnitData[unit_id] and gv_UnitData[unit_id].Squad
squad = squad and gv_Squads[squad]
if units[1] and squad and self.Merc then
units[1]:JoinSquadAs(self.Merc, squad)
end
end
function UnitJoinAsMerc:GetError()
if not self.TargetUnit then
return "Choose target unit to join"
end
if not self.Merc then
return "Choose merc as which the unit joins"
end
end
function UnitJoinAsMerc:GetUIText(context,template, game)
local merc = gv_UnitData and gv_UnitData[self.Merc]
local name
if not merc then
name = game and "" or Untranslated("[MercName]")
else
name = merc.Nick or merc.Name
end
return T{246469241790, "Recruit merc (<em><name></em>)", name= name}
end
DefineClass.UnitMakeNonVillain = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "UnitId",
editor = "choice", default = false, items = function (self) return GetPersistentSessionIds() end, },
{ id = "HealHP", help = "whether to also heal the unit to full",
editor = "bool", default = false, },
},
EditorView = Untranslated("Make <UnitId> non villain."),
Documentation = "Make all instances of the specified persistant villain unit non-villain (killable)",
EditorNestedObjCategory = "Units",
}
function UnitMakeNonVillain:__exec(obj, context)
local units = g_PersistentUnitData[self.UnitId]
for i, u in ipairs(units) do
MakeUnitNonVillain(u)
-- Heal unit if enabled and exists, dont use
-- standard heal logic to make it invisible.
local mapUnit = g_Units[u.session_id]
if mapUnit and self.HealHP then
mapUnit.HitPoints = mapUnit.Health
end
end
end
DefineClass.UnitSetConflictIgnore = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ConflictIgnore", name = "Conflict Ignore", help = "Whether to be afraid in conflicts or not.",
editor = "bool", default = true, },
{ id = "TargetUnit", name = "Target Unit", help = "Target unit for match.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
},
EditorView = Untranslated("Set <u(TargetUnit)> ConflictIgnore to <if(ConflictIgnore)>true</if><if(not(ConflictIgnore))>false</if>."),
Documentation = "Sets units to be affraid(or not) during confict.",
EditorNestedObjCategory = "Units",
}
function UnitSetConflictIgnore:__exec(obj, context)
local objects = Groups[self.TargetUnit] or empty_table
for _, obj in ipairs(objects) do
if IsKindOf(obj, "Unit") then
obj.conflict_ignore = self.ConflictIgnore
end
end
end
function UnitSetConflictIgnore:GetError()
if not self.TargetUnit then
return "Choose TargetUnit!"
end
end
DefineClass.UnitSetHireStatus = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Status", name = "Hire Status", help = "The hiring status to set.",
editor = "choice", default = "Available", items = function (self) return PresetGroupCombo("MercHireStatus", "Default") end, },
{ id = "TargetUnit", name = "Target Unit", help = "Target unit for match.",
editor = "combo", default = false, items = function (self) return GetTargetUnitCombo() end, },
},
EditorView = Untranslated("Set <u(TargetUnit)> to status <u(Status)>"),
Documentation = "Sets the hiring status of the merc to a specified value.",
EditorNestedObjCategory = "Units",
}
function UnitSetHireStatus:__exec(obj, context)
if not self.Status then return false end
local unit = UnitDataDefs[self.TargetUnit]
local unitData = gv_UnitData[unit.id]
if not unitData then return end
unitData.HireStatus = self.Status
end
function UnitSetHireStatus:GetError()
if not self.Status then
return "Choose unit hiring status to set!"
end
end
DefineClass.UnitSetOnline = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Online", name = "Online", help = "Whether to set it online or offline.",
editor = "bool", default = true, },
{ id = "TargetUnit", name = "Target Unit", help = "Target unit for match.",
editor = "combo", default = false, items = function (self) return GetTargetUnitCombo() end, },
},
EditorView = Untranslated("Set <u(TargetUnit)> messenger availability to <u(Status)>"),
Documentation = "Sets a merc's online/offline status in the PDA messenger. When offline mercs cannot be hired.",
EditorNestedObjCategory = "Units",
}
function UnitSetOnline:__exec(obj, context)
local unit = UnitDataDefs[self.TargetUnit]
local unitData = gv_UnitData[unit.id]
if not unitData then return end
unitData:SetMessengerOnline(self.Online)
end
function UnitSetOnline:GetError()
if not self.TargetUnit then
return "Choose targetunit!"
end
end
DefineClass.UnitSetStatusEffectImmunity = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Status", name = "Status",
editor = "preset_id", default = false, preset_class = "CharacterEffectCompositeDef", },
{ id = "Immune",
editor = "bool", default = false, },
{ id = "Reason", help = "Text label used for keeping track of the different reasons a unit can have for being immune to the specific status effect. All reasons must be cleared in order for the unit to be able to receive the effect again.",
editor = "text", default = "script", },
},
RequiredObjClasses = {
"Unit",
},
ReturnClass = "",
EditorView = Untranslated(""),
Documentation = "Add or remove immunity to specified status effect to a target unit",
EditorNestedObjCategory = "",
}
function UnitSetStatusEffectImmunity:GetEditorView()
if self.Immune then
return Untranslated("Make unit immune to <u(Status)>")
end
return Untranslated("Clear immunity to <u(Status)> from unit")
end
function UnitSetStatusEffectImmunity:__exec(obj, context)
if self.Immune then
obj:AddStatusEffectImmunity(self.Status, self.Reason)
else
obj:RemoveStatusEffectImmunity(self.Status, self.Reason)
end
end
DefineClass.UnitStartConversation = {
__parents = { "Effect", "ConversationFunctionObjectBase", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Conversation", name = "Conversation", help = "Conversation to start.",
editor = "preset_id", default = false, preset_class = "Conversation", },
},
EditorView = Untranslated("Start conversation <u(Conversation)>."),
Documentation = "Starts a specific conversation - no groups or conditions are checked.",
EditorNestedObjCategory = "",
EditorNestedObjCategory = "Interactions",
}
function UnitStartConversation:__exec(obj, context)
StartConversationEffect(self.Conversation, context)
end
function UnitStartConversation:__waitexec(obj, context)
StartConversationEffect(self.Conversation, context, "wait")
end
function UnitStartConversation:GetError()
if not self.Conversation then
return "Please specify conversation"
end
end
function UnitStartConversation:new(...)
-- backward compatibility
local ret = Effect.new(self, ...)
if rawget(ret, "Group") then
ret.Conversation = ret.Group
ret.Group = nil
end
return ret
end
function UnitStartConversation:GetResumeData(thread, stack, stack_index)
return "UnitStartConversation", self.Conversation
end
DefineClass.UnitStatBoost = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Stat", name = "Stat",
editor = "combo", default = false, items = function (self) return GetUnitStatsCombo() end, },
{ id = "Amount", name = "Amount", help = "How much to boost the specified Stat.",
editor = "number", default = false, },
{ id = "source", name = "Source", help = "What kind of source is the thing that provides the stat boost.",
editor = "combo", default = "Book", items = function (self) return {"Book", "Other"} end, },
},
RequiredObjClasses = {
"Unit",
},
EditorView = Untranslated("Boost unit's stat <Stat>"),
Documentation = "Boosts unit's stat",
EditorNestedObjCategory = "Units",
}
function UnitStatBoost:__exec(obj, context)
if not obj.is_clone then
local modId
if self.source == "Book" then
modId = string.format("StatBoostBook-%s-%s-%d", self.Stat, obj.session_id, GetPreciseTicks())
GainStat(obj, self.Stat, self.Amount, modId, "Studying")
else
modId = string.format("StatBoost-%s-%s-%d", self.Stat, obj.session_id, GetPreciseTicks())
GainStat(obj, self.Stat, self.Amount, modId)
end
end
end
function UnitStatBoost:GetError()
if not self.Stat then
return "Choose stat"
elseif not self.Amount then
return "Choose amount"
end
end
DefineClass.UnitTakeDamage = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Damage",
editor = "number", default = 5, min = 0, },
{ id = "FloatingText", help = "Will only be displayed if the target unit is visible for the player; <Damage> parameter will be provided for the text.",
editor = "text", default = T(477545213542, --[[EffectDef Effects UnitTakeDamage default]] "<Damage>"), translate = true, },
{ id = "LogMessage", help = "<Damage> and <Name> parameters will be provided for the text.",
editor = "text", default = T(879191059352, --[[EffectDef Effects UnitTakeDamage default]] "<em><Name></em> takes <em><Damage></em> damage."), translate = true, },
},
RequiredObjClasses = {
"Unit",
},
EditorView = Untranslated("Deal <Damage> damage to the unit"),
Documentation = "Deal damage to the unit",
}
function UnitTakeDamage:__exec(obj, context)
if not context then context = {} end
local units = self:MatchMapUnits(obj, context)
if units and context.target_units then
local floating_text = T{self.FloatingText, Damage = self.Damage}
local pov_team = GetPoVTeam()
for _, unit in ipairs(context.target_units) do
if not unit:IsDead() then
local has_visibility = HasVisibilityTo(pov_team, obj)
local log_msg = T{self.LogMessage, { Name = unit:GetLogName(), Damage = self.Damage}}
unit:TakeDirectDamage(self.Damage, has_visibility and floating_text or false, "short", log_msg)
end
end
end
end
function UnitTakeDamage:UnitCheck(unit, obj, context)
return true
end
DefineClass.UnitTakeItem = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "ItemId", name = "Item", help = "The id of the item that will be taken.",
editor = "preset_id", default = false, preset_class = "InventoryItemCompositeDef", },
{ id = "Amount", name = "Amount", help = "How many items to take.",
editor = "number", default = 1, min = 1, },
{ id = "AnySquad", name = "Any player squad", help = "if true: takes item from any player's squad. if false: takes item from current squad",
editor = "bool", default = false, },
{ id = "AddToLogVar", name = "Add to log", help = "Add message to log.",
editor = "bool", default = true, },
},
EditorView = Untranslated("Take <u(ItemId)>(<Amount>) from merc(s) in squad."),
Documentation = "Removes the first given item from the inventory of a merc in the squad.",
EditorNestedObjCategory = "Units",
}
function UnitTakeItem:AddToLog(unit, item, amount)
if self.AddToLogVar then
local unit_name
if type(unit)=="number" then
unit_name = g_Classes.SquadBag.DisplayName
else
unit_name = unit:GetDisplayName()
end
CombatLog("short", T{795253111432, "<amount> x <em><item></em> taken from <name>", amount = amount>=1 and amount or "", item = amount>1 and item.DisplayNamePlural or item.DisplayName, name = unit_name})
end
end
function UnitTakeItem:__exec(obj, context)
-- can work with both unit and a unit session_id
local unit_id = false
if type(obj) == "string" then
unit_id = obj
elseif IsKindOf(obj, "Unit") then
unit_id = obj.session_id
end
local all_mercs = false
local squad = unit_id and gv_UnitData[unit_id] and gv_UnitData[unit_id].Squad
if squad then
all_mercs = table.copy(gv_Squads[squad].units)
if self.AnySquad then
local side = gv_Squads[squad].Side
if side=="player1" then
table.iappend(all_mercs,GetAllPlayerUnitsOnMapSessionId())
end
for sq_id, sqd in pairs(gv_Squads) do
if sq_id~=squad and (sqd.Side ==side) then
table.iappend(all_mercs, sqd.units )
end
end
all_mercs = table.get_unique(all_mercs)
end
table.remove_entry(all_mercs, unit_id)
table.insert(all_mercs, 1, unit_id) -- prioritize unit_id
else
all_mercs = GetAllPlayerUnitsOnMapSessionId()
end
TakeItemFromMercs(all_mercs, self.ItemId, self.Amount,
function(unit, item, unit_amount, effect)
effect:AddToLog(unit, item, unit_amount)
end,
self)
InventoryUIRespawn()
end
function UnitTakeItem:GetError()
if not self.ItemId then
return "Set Item!"
end
end
function UnitTakeItem:GetUIText(context, template, game)
local item_name = InventoryItemDefs[self.ItemId].DisplayName
local item_name_pl = InventoryItemDefs[self.ItemId].DisplayNamePlural
local unit_id = ConversationGetPlayerMerc()
local has_item = HasItemInSquad(unit_id, self.ItemId, self.Amount)
if self.ItemId=="Money" then
return has_item and T{304179156341, "Give <em><money(Amount)></em>", Amount = self.Amount}
or T{231000532062, "<em><money(Amount)></em> required", Amount = self.Amount}
end
if template then
return T{template, Amount = self.Amount, item = self.Amount<=1 and item_name or item_name_pl}
else
return has_item and T{590581690149, "Give <em><Amount> <item></em>",Amount =self.Amount, item = self.Amount<=1 and item_name or item_name_pl}
or T{635806839384, "<em><Amount> <item></em> required",Amount =self.Amount, item = self.Amount<=1 and item_name or item_name_pl}
end
end
function UnitTakeItem:GetPhraseTopRolloverText(negative, template, game)
local item_name = InventoryItemDefs[self.ItemId].DisplayName
local item_name_pl = InventoryItemDefs[self.ItemId].DisplayNamePlural
if self.ItemId=="Money" then
return T{792302629761, "Delivered <em><money(Amount)></em>",Amount = self.Amount}
else
return T{652398655206, "Delivered <Amount> x <em><item></em>",Amount = self.Amount, item = self.Amount<=1 and item_name or item_name_pl}
end
end
DefineClass.UnitsAddToAmbientLife = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Group", name = "Group", help = "Units Group to add to Ambient Life.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
},
EditorView = Untranslated("Add objects of group to Ambient Zone"),
Documentation = "Add objects of group to Ambient Zone marker's responsibilities.",
}
function UnitsAddToAmbientLife:GetError()
if not self.Group then
return "Choose Units Group!"
end
end
function UnitsAddToAmbientLife:__exec(obj, context)
local group_units = Groups[self.Group] or empty_table
if #group_units == 0 then return end
local zone
MapForEach("map", "AmbientZoneMarker", function(marker)
zone = marker
return false
end)
if zone then
zone:RegisterUnits(table.ifilter(group_units, function(i, u)
return IsKindOf(u, "Unit")
end))
end
end
DefineClass.UnitsDespawnAmbientLife = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Ephemeral", name = "Ephemeral Only", help = "All ambient life units or just ephemeral ones.",
editor = "bool", default = true, },
},
EditorView = Untranslated("Despawn all Ambient Life Units"),
Documentation = "Despawn all ambient units - abrupt, don't wait for exit animations.",
}
function UnitsDespawnAmbientLife:__exec(obj, context)
MapForEach("map", "AmbientZoneMarker", function(zone)
for _, units in ipairs(zone.units) do
for idx = #units, 1, -1 do
local unit = units[idx]
if not self.Ephemeral or unit.ephemeral then
table.remove(units, idx)
DoneObject(unit)
end
end
end
end)
end
DefineClass.UnitsKickAmbientLife = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "AL_Group", name = "AL Group", help = "Target unit for match.",
editor = "combo", default = false, items = function (self) return GetALMarkerGroups() end, },
},
EditorView = Untranslated("Kicks Ambient Life <AL_Group> group from Their Markers"),
Documentation = "Forces all units in ambient life behavior visiting specific group cancel their visit behavior",
EditorNestedObjCategory = "Units",
}
function UnitsKickAmbientLife:__exec(obj, context)
for _, unit in ipairs(g_Units) do
if IsVisitingUnit(unit) then
if unit.last_visit:IsInGroup(self.AL_Group) then
unit:SetBehavior()
unit:SetCommand("Idle")
unit.perpetual_marker = false
end
end
end
end
function UnitsKickAmbientLife:GetError()
if not self.AL_Group then
return "Choose group of AL markers to kick units from"
end
end
function UnitsKickAmbientLife:GetUIText(context,template, game)
local merc = gv_UnitData and gv_UnitData[self.Merc]
local name
if not merc then
name = game and "" or Untranslated("[MercName]")
else
name = merc.Nick or merc.Name
end
return T{246469241790, "Recruit merc (<em><name></em>)", name= name}
end
DefineClass.UnitsKickFromPerpetualMarkers = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
properties = {
{ id = "Ephemeral", name = "Ephemeral Only", help = "All ambient life units or just ephemeral ones.",
editor = "bool", default = true, },
},
EditorView = Untranslated("Kick Units from Perpetual Markers"),
Documentation = "Kicks all Ambient Life units which are in perpetual markers",
}
function UnitsKickFromPerpetualMarkers:__exec(obj, context)
for _, unit in ipairs(g_Units) do
if (not self.Ephemeral or unit.ephemeral) and unit.perpetual_marker then
unit:SetBehavior()
unit:SetCommand("Idle")
unit.perpetual_marker = false
end
end
end
DefineClass.UnitsStealForPerpetualMarkers = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
EditorView = Untranslated("Steal Units for Perpetual Markers"),
Documentation = "Steal units for perpetual markers as if the Ambient Life is respawn",
}
function UnitsStealForPerpetualMarkers:__exec(obj, context)
AmbientLifePerpetualMarkersSteal()
end
DefineClass.UpdateInteractablesHighlight = {
__parents = { "Effect", },
__generated_by_class = "EffectDef",
Documentation = "Disable interaction markers of a specific group.",
EditorNestedObjCategory = "Interactable",
}
function UpdateInteractablesHighlight:__exec(obj, context)
if CurrentMap == "" or IsChangingMap() then return end
if not g_Units then return end
local ui_units = {}
for _, unit in ipairs(g_Units) do
if IsValid(unit) and not unit:IsDead() and unit.team and unit.team.control == "UI" then
table.insert(ui_units, unit)
end
end
if #ui_units == 0 then return end
MapForEach("map", "Interactable", function(interactable)
if not IsValid(interactable) then return end
for _, unit in ipairs(ui_units) do
if not UICanInteractWith(unit, interactable) then
interactable:HighlightIntensely(false, "unit-nearby")
end
end
if not (IsKindOf(interactable, "ContainerMarker") and interactable:IsMarkerEnabled()) then
interactable:HighlightIntensely(false, "cursor")
interactable:HighlightIntensely(false, "unit-nearby")
end
end)
end
function UpdateInteractablesHighlight:GetEditorView()
return T(680362306074, "Forces update of all highlighted interactables")
end
DefineClass.WaitNpcIdle = {
__parents = { "Effect", "UnitTarget", },
__generated_by_class = "EffectDef",
properties = {
{ id = "TargetUnit", name = "NPC Name", help = "The name of the NPC to associate.",
editor = "combo", default = false, items = function (self) return GetUnitGroups() end, },
},
EditorView = Untranslated("Wait for the NPC to become idle"),
Documentation = "Wait for the NPC to become idle (requires sequential execution)",
EditorNestedObjCategory = "Units",
}
function WaitNpcIdle:__exec(obj, context)
assert(false) -- This effect requires sequential execution
end
function WaitNpcIdle:__waitexec(obj, context)
local ctx = {}
local units = self:MatchMapUnits(obj, ctx)
local firstUnit = units and ctx.target_units
firstUnit = firstUnit and firstUnit[1]
if firstUnit then
WaitIdle(firstUnit)
end
end
function WaitNpcIdle:GetResumeData()
return "WaitNpcIdle", self.TargetUnit
end
function WaitNpcIdle:GetError()
if not self.TargetUnit then
return "No target unit"
end
end
|