mental.lua
130 KB
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
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2019 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
local Stats = require "engine.interface.ActorStats"
local Particles = require "engine.Particles"
local Entity = require "engine.Entity"
local Chat = require "engine.Chat"
local Map = require "engine.Map"
local Level = require "engine.Level"
local Astar = require "engine.Astar"
-- Item specific
newEffect{
name = "ITEM_EXPOSED", image = "talents/curse_of_the_meek.png", -- Re-used icon
desc = _t"Exposed",
long_desc = function(self, eff) return ("Mind and body exposed to effects and attacks, reducing all saves and defense by %d."):tformat(eff.reduce) end,
charges = function(self, eff) return (tostring(math.floor(eff.reduce))) end,
type = "mental",
subtype = { },
status = "detrimental",
parameters = {reduce=0},
on_gain = function(self, err) return _t"#Target#'s is vulnerable to attacks and effects!" end,
on_lose = function(self, err) return _t"#Target# is less vulnerable." end,
activate = function(self, eff)
self:effectTemporaryValue(eff, "combat_physresist", -eff.reduce)
self:effectTemporaryValue(eff, "combat_spellresist", -eff.reduce)
self:effectTemporaryValue(eff, "combat_mentalresist", -eff.reduce)
self:effectTemporaryValue(eff, "combat_def", -eff.reduce)
end,
deactivate = function(self, eff)
end,
}
newEffect{
name = "ITEM_NUMBING_DARKNESS", image = "effects/bane_blinded.png",
desc = _t"Numbing Darkness",
long_desc = function(self, eff) return ("The target is losing hope, all damage it does is reduced by %d%%."):tformat(eff.reduce) end,
charges = function(self, eff) return (tostring(math.floor(eff.reduce))) end,
type = "mental",
subtype = { darkness=true,}, no_ct_effect = true,
status = "detrimental",
parameters = {power=10, reduce=5},
on_gain = function(self, err) return _t"#Target# is weakened by the darkness!", _t"+Numbing Darkness" end,
on_lose = function(self, err) return _t"#Target# regains their energy.", _t"-Numbing Darkness" end,
on_timeout = function(self, eff)
end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("numbed", eff.reduce)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("numbed", eff.tmpid)
end,
}
newEffect{
name = "SILENCED", image = "effects/silenced.png",
desc = _t"Silenced",
long_desc = function(self, eff) return _t"The target is silenced, preventing it from casting spells and using some vocal talents." end,
type = "mental",
subtype = { silence=true },
status = "detrimental",
parameters = {},
on_gain = function(self, err) return _t"#Target# is silenced!", _t"+Silenced" end,
on_lose = function(self, err) return _t"#Target# is not silenced anymore.", _t"-Silenced" end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("silence", 1)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("silence", eff.tmpid)
end,
}
newEffect{
name = "SUMMON_CONTROL", image = "talents/summon_control.png", --Backwards compatibility
desc = _t"Pheromones",
long_desc = function(self, eff) return ("The target has been marked as the focus for all nature summons within %d radius, receiving %d%% increased damage from nature summons."):tformat(eff.range, eff.power) end,
type = "mental",
subtype = { focus=true },
status = "detrimental",
parameters = { power = 10 },
on_gain = function(self, err) return _t"Summons flock towards #Target#.", true end,
on_lose = function(self, err) return _t"#Target# is no longer being targeted by summons.", true end,
on_timeout = function(self, eff)
self:project({type="ball", range=0, friendlyfire=false, radius=eff.range}, self.x, self.y, function(px, py)
local target = game.level.map(px, py, Map.ACTOR)
if not target then return end
if target.summoner == eff.src then
target:setTarget(self)
end
end)
end,
activate = function(self, eff)
self:effectTemporaryValue(eff, "inc_nature_summon", eff.power)
self:project({type="ball", range=0, friendlyfire=false, radius=eff.range}, self.x, self.y, function(px, py)
local target = game.level.map(px, py, Map.ACTOR)
if not target then return end
if target.summoner == eff.src then
target:setTarget(self)
end
end)
end,
deactivate = function(self, eff)
end,
}
newEffect{
name = "CONFUSED", image = "effects/confused.png",
desc = _t"Confused",
long_desc = function(self, eff) return ("The target is confused, acting randomly (chance %d%%) and unable to perform complex actions."):tformat(eff.power) end,
charges = function(self, eff) return (tostring(math.floor(eff.power)).."%") end,
type = "mental",
subtype = { confusion=true },
status = "detrimental",
parameters = { power=30 },
on_gain = function(self, err) return _t"#Target# wanders around!", _t"+Confused" end,
on_lose = function(self, err) return _t"#Target# seems more focused.", _t"-Confused" end,
activate = function(self, eff)
eff.power = math.floor(util.bound(eff.power, 0, 50))
eff.tmpid = self:addTemporaryValue("confused", eff.power)
if eff.power <= 0 then eff.dur = 0 end
end,
deactivate = function(self, eff)
self:removeTemporaryValue("confused", eff.tmpid)
if self == game.player and self.updateMainShader then self:updateMainShader() end
end,
}
newEffect{
name = "DOMINANT_WILL", image = "talents/yeek_will.png",
desc = _t"Mental Domination",
long_desc = function(self, eff) return ("The target's mind has been shattered. Its body remains as a thrall to %s."):tformat(eff.src:getName():capitalize()) end,
type = "mental",
subtype = { dominate=true },
status = "detrimental",
parameters = { },
on_gain = function(self, err) return _t"#Target#'s mind is shattered." end,
activate = function(self, eff)
eff.pid = self:addTemporaryValue("inc_damage", {all=-15})
self.ai_state = self.ai_state or {}
eff.oldstate = {
faction = self.faction,
ai_state = table.clone(self.ai_state, true),
remove_from_party_on_death = self.remove_from_party_on_death,
no_inventory_access = self.no_inventory_access,
move_others = self.move_others,
summoner = self.summoner,
summoner_gain_exp = self.summoner_gain_exp,
ai = self.ai,
}
self.faction = eff.src.faction
self.ai_state.tactic_leash = 100
self.remove_from_party_on_death = true
self.no_inventory_access = true
self.move_others = true
self.summoner = eff.src
self.summoner_gain_exp = true
if self.dead then return end
game:onTickEnd(function()
game.party:addMember(self, {
control="full",
type="thrall",
title=_t"Thrall",
orders = {leash=true, follow=true},
on_control = function(self)
self:hotkeyAutoTalents()
end,
leave_level = function(self, party_def) -- Cancel control and restore previous actor status.
local eff = self:hasEffect(self.EFF_DOMINANT_WILL)
if not eff then return end
local uid = self.uid
eff.survive_domination = true
self:removeTemporaryValue("inc_damage", eff.pid)
game.party:removeMember(self)
self:replaceWith(require("mod.class.NPC").new(self))
self.uid = uid
__uids[uid] = self
self.faction = eff.oldstate.faction
self.ai_state = eff.oldstate.ai_state
self.ai = eff.oldstate.ai
self.remove_from_party_on_death = eff.oldstate.remove_from_party_on_death
self.no_inventory_access = eff.oldstate.no_inventory_access
self.move_others = eff.oldstate.move_others
self.summoner = eff.oldstate.summoner
self.summoner_gain_exp = eff.oldstate.summoner_gain_exp
self:removeEffect(self.EFF_DOMINANT_WILL)
end,
})
end)
end,
deactivate = function(self, eff)
if eff.survive_domination then
game.logSeen(self, "%s's mind recovers from the domination.",self:getName():capitalize())
else
game.logSeen(self, "%s collapses.",self:getName():capitalize())
self:die(eff.src)
end
end,
}
newEffect{
name = "DOMINANT_WILL_BOSS", image = "talents/yeek_will.png",
desc = _t"Mental Domination",
long_desc = function(self, eff) return ("The target's mind has been shaken. It is temporarily aligned with %s and immune to all damage."):tformat(eff.src:getName():capitalize()) end,
type = "mental",
subtype = { dominate=true },
status = "detrimental",
parameters = { },
on_gain = function(self, err) return _t"#Target#'s mind is dominated.", _t"+Dominant Will" end,
on_lose = function(self, err) return _t"#Target# is free from the domination.", "-Dominant Will" end,
activate = function(self, eff)
self:setTarget() -- clear ai target
eff.old_faction = self.faction
self.faction = eff.src.faction
self:effectTemporaryValue(eff, "never_anger", 1)
self:effectTemporaryValue(eff, "invulnerable", 1)
self:effectTemporaryValue(eff, "hostile_for_level_change", 1)
end,
deactivate = function(self, eff)
if eff.particle then self:removeParticles(eff.particle) end
self.faction = eff.old_faction
self:setTarget(eff.src)
end,
}
newEffect{
name = "BATTLE_SHOUT", image = "talents/battle_shout.png",
desc = _t"Battle Shout",
long_desc = function(self, eff) return ("Increases maximum life and stamina by %d%%. When the effect ends, the extra life and stamina will be lost."):tformat(eff.power) end,
type = "mental",
subtype = { morale=true },
status = "beneficial",
parameters = { power=10 },
activate = function(self, eff)
local lifeb = self.max_life * eff.power/100
local stamb = self.max_stamina * eff.power/100
eff.max_lifeID = self:addTemporaryValue("max_life", lifeb) --Avoid healing effects
eff.lifeID = self:addTemporaryValue("life",lifeb)
eff.max_stamina = self:addTemporaryValue("max_stamina", stamb)
self:incStamina(stamb)
eff.stamina = stamb
end,
deactivate = function(self, eff)
self:removeTemporaryValue("life", eff.lifeID)
self:removeTemporaryValue("max_life", eff.max_lifeID)
self:removeTemporaryValue("max_stamina", eff.max_stamina)
self:incStamina(-eff.stamina)
end,
}
newEffect{
name = "BATTLE_CRY", image = "talents/battle_cry.png",
desc = _t"Battle Cry",
long_desc = function(self, eff) return ("The target's will to defend itself is shattered by the powerful battle cry, reducing defense by %d."):tformat(eff.power) end,
type = "mental",
subtype = { morale=true },
status = "detrimental",
parameters = { power=10 },
on_gain = function(self, err) return _t"#Target#'s will is shattered.", _t"+Battle Cry" end,
on_lose = function(self, err) return _t"#Target# regains some of its will.", _t"-Battle Cry" end,
activate = function(self, eff)
self:effectTemporaryValue(eff, "combat_def", -eff.power)
self:effectTemporaryValue(eff, "no_evasion", 1)
self:effectTemporaryValue(eff, "blind_fighted", 1)
end,
}
newEffect{
name = "WILLFUL_COMBAT", image = "talents/willful_combat.png",
desc = _t"Willful Combat",
long_desc = function(self, eff) return ("The target puts all its willpower into its blows, improving physical power by %d."):tformat(eff.power) end,
type = "mental",
subtype = { focus=true },
status = "beneficial",
parameters = { power=10 },
on_gain = function(self, err) return _t"#Target# lashes out with pure willpower." end,
on_lose = function(self, err) return _t"#Target#'s willpower rush ends." end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("combat_dam", eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("combat_dam", eff.tmpid)
end,
}
newEffect{
name = "GLOOM_WEAKNESS", image = "effects/gloom_weakness.png",
desc = _t"Gloom Weakness",
long_desc = function(self, eff) return ("The gloom reduces damage the target inflicts by %d%%."):tformat(eff.incDamageChange) end,
type = "mental",
subtype = { gloom=true },
status = "detrimental",
parameters = { atk=10, dam=10 },
on_gain = function(self, err) return _t"#F53CBE##Target# is weakened by the gloom." end,
on_lose = function(self, err) return _t"#F53CBE##Target# is no longer weakened." end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("gloom_weakness", 1))
eff.incDamageId = self:addTemporaryValue("inc_damage", {all = -eff.incDamageChange})
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
self:removeTemporaryValue("inc_damage", eff.incDamageId)
end,
}
newEffect{
name = "GLOOM_SLOW", image = "effects/gloom_slow.png",
desc = _t"Slowed by the gloom",
long_desc = function(self, eff) return ("The gloom reduces the target's global speed by %d%%."):tformat(eff.power * 100) end,
type = "mental",
subtype = { gloom=true, slow=true },
status = "detrimental",
parameters = { power=0.1 },
on_gain = function(self, err) return _t"#F53CBE##Target# moves reluctantly!", _t"+Slow" end,
on_lose = function(self, err) return _t"#Target# overcomes the gloom.", _t"-Slow" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("gloom_slow", 1))
eff.tmpid = self:addTemporaryValue("global_speed_add", -eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("global_speed_add", eff.tmpid)
self:removeParticles(eff.particle)
end,
}
newEffect{
name = "GLOOM_STUNNED", image = "effects/gloom_stunned.png",
desc = _t"Stunned by the gloom",
long_desc = function(self, eff) return ("The gloom has stunned the target, reducing damage by 50%%, putting 4 random talents on cooldown and reducing movement speed by 50%%. While stunned talents cooldown twice as slow."):tformat() end,
type = "mental",
subtype = { gloom=true, stun=true },
status = "detrimental",
parameters = {},
on_gain = function(self, err) return _t"#F53CBE##Target# is stunned with fear!", _t"+Stunned" end,
on_lose = function(self, err) return _t"#Target# overcomes the gloom", _t"-Stunned" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("gloom_stunned", 1))
eff.tmpid = self:addTemporaryValue("stunned", 1)
eff.speedid = self:addTemporaryValue("movement_speed", -0.5)
eff.lockid = self:addTemporaryValue("half_talents_cooldown", 1)
local tids = {}
for tid, lev in pairs(self.talents) do
local t = self:getTalentFromId(tid)
if t and not self.talents_cd[tid] and t.mode == "activated" and not t.innate and util.getval(t.no_energy, self, t) ~= true then tids[#tids+1] = t end
end
for i = 1, 4 do
local t = rng.tableRemove(tids)
if not t then break end
self.talents_cd[t.id] = 1
end
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
self:removeTemporaryValue("stunned", eff.tmpid)
self:removeTemporaryValue("movement_speed", eff.speedid)
self:removeTemporaryValue("half_talents_cooldown", eff.lockid)
end,
}
newEffect{
name = "GLOOM_CONFUSED", image = "effects/gloom_confused.png",
desc = _t"Confused by the gloom",
long_desc = function(self, eff) return ("The gloom has confused the target, making it act randomly (%d%% chance) and unable to perform complex actions."):tformat(eff.power) end,
type = "mental",
charges = function(self, eff) return (tostring(eff.power).."%") end,
subtype = { gloom=true, confusion=true },
status = "detrimental",
parameters = { power = 10 },
on_gain = function(self, err) return _t"#F53CBE##Target# is lost in despair!", _t"+Confused" end,
on_lose = function(self, err) return _t"#Target# overcomes the gloom", _t"-Confused" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("gloom_confused", 1))
eff.power = math.floor(util.bound(eff.power, 0, 50))
eff.tmpid = self:addTemporaryValue("confused", eff.power)
if eff.power <= 0 then eff.dur = 0 end
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
self:removeTemporaryValue("confused", eff.tmpid)
if self == game.player then self:updateMainShader() end
end,
}
newEffect{
name = "DISMAYED", image = "talents/dismay.png",
desc = _t"Dismayed",
long_desc = function(self, eff) return (_t"The target is dismayed. The next melee attack against the target will be a guaranteed critical hit.") end,
type = "mental",
subtype = { gloom=true, confusion=true },
status = "detrimental",
parameters = {},
on_gain = function(self, err) return _t"#F53CBE##Target# is dismayed!", _t"+Dismayed" end,
on_lose = function(self, err) return _t"#Target# overcomes the dismay", _t"-Dismayed" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("dismayed", 1))
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
end,
}
newEffect{
name = "STALKER", image = "talents/stalk.png",
desc = _t"Stalking",
display_desc = function(self, eff)
return ([[Stalking %d/%d +%d ]]):tformat(eff.target.life, eff.target.max_life, eff.bonus)
end,
long_desc = function(self, eff)
local t = self:getTalentFromId(self.T_STALK)
local effStalked = eff.target:hasEffect(eff.target.EFF_STALKED)
local desc = ([[Stalking %s. Bonus level %d: +%d accuracy, +%d%% melee damage, +%0.2f hate/turn prey was hit.]]):tformat(
eff.target.name, eff.bonus, t.getAttackChange(self, t, eff.bonus), t.getStalkedDamageMultiplier(self, t, eff.bonus) * 100 - 100, t.getHitHateChange(self, t, eff.bonus))
if effStalked and effStalked.damageChange and effStalked.damageChange > 0 then
desc = desc..("Prey damage modifier: %d%%."):tformat(effStalked.damageChange)
end
return desc
end,
type = "mental",
subtype = { veil=true },
status = "beneficial",
parameters = {},
activate = function(self, eff)
self:logCombat(eff.target, "#F53CBE##Target# is being stalked by #Source#!")
end,
deactivate = function(self, eff)
self:logCombat(eff.target, "#F53CBE##Target# is no longer being stalked by #Source#.")
end,
on_timeout = function(self, eff)
if not eff.target or eff.target.dead or not eff.target:hasEffect(eff.target.EFF_STALKED) then
self:removeEffect(self.EFF_STALKER)
end
end,
}
newEffect{
name = "STALKED", image = "effects/stalked.png",
desc = _t"Stalked",
long_desc = function(self, eff)
local effStalker = eff.src:hasEffect(eff.src.EFF_STALKER)
if not effStalker then return _t"Being stalked." end
local t = self:getTalentFromId(eff.src.T_STALK)
local desc = ([[Being stalked by %s. Stalker bonus level %d: +%d accuracy, +%d%% melee damage, +%0.2f hate/turn prey was hit.]]):tformat(
eff.src:getName(), effStalker.bonus, t.getAttackChange(eff.src, t, effStalker.bonus), t.getStalkedDamageMultiplier(eff.src, t, effStalker.bonus) * 100 - 100, t.getHitHateChange(eff.src, t, effStalker.bonus))
if eff.damageChange and eff.damageChange > 0 then
desc = desc..(" Prey damage modifier: %d%%."):tformat(eff.damageChange)
end
return desc
end,
type = "mental",
subtype = { veil=true },
status = "detrimental",
no_stop_enter_worlmap = true, cancel_on_level_change = true,
parameters = {},
activate = function(self, eff)
local effStalker = eff.src:hasEffect(eff.src.EFF_STALKER)
if not effStalker then game:onTickEnd(function() self:removeEffect(self.EFF_STALKED, true, true) end) return end
eff.particleBonus = effStalker.bonus
eff.particle = self:addParticles(Particles.new("stalked", 1, { bonus = eff.particleBonus }))
end,
deactivate = function(self, eff)
if eff.particle then self:removeParticles(eff.particle) end
if eff.damageChangeId then self:removeTemporaryValue("inc_damage", eff.damageChangeId) end
end,
on_timeout = function(self, eff)
if not eff.src or eff.src.dead or not eff.src:hasEffect(eff.src.EFF_STALKER) then
self:removeEffect(self.EFF_STALKED)
else
local effStalker = eff.src:hasEffect(eff.src.EFF_STALKER)
if eff.particleBonus ~= effStalker.bonus then
eff.particleBonus = effStalker.bonus
self:removeParticles(eff.particle)
eff.particle = self:addParticles(Particles.new("stalked", 1, { bonus = eff.particleBonus }))
end
end
end,
updateDamageChange = function(self, eff)
if eff.damageChangeId then
self:removeTemporaryValue("inc_damage", eff.damageChangeId)
eff.damageChangeId = nil
end
if eff.damageChange and eff.damageChange > 0 then
eff.damageChangeId = eff.target:addTemporaryValue("inc_damage", {all=eff.damageChange})
end
end,
}
newEffect{
name = "BECKONED", image = "talents/beckon.png",
desc = _t"Beckoned",
long_desc = function(self, eff)
local message = ("The target has been beckoned by %s and is heeding the call. There is a %d%% chance of moving towards the beckoner each turn."):tformat(eff.src:getName(), eff.chance)
if eff.spellpowerChangeId and eff.mindpowerChangeId then
message = message..(" (spellpower: %d, mindpower: %d"):tformat(eff.spellpowerChange, eff.mindpowerChange)
end
return message
end,
type = "mental",
subtype = { dominate=true },
status = "detrimental",
parameters = { speedChange=0.5 },
on_gain = function(self, err) return _t"#Target# has been beckoned.", _t"+Beckoned" end,
on_lose = function(self, err) return _t"#Target# is no longer beckoned.", _t"-Beckoned" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("beckoned", 1))
eff.spellpowerChangeId = self:addTemporaryValue("combat_spellpower", eff.spellpowerChange)
eff.mindpowerChangeId = self:addTemporaryValue("combat_mindpower", eff.mindpowerChange)
end,
deactivate = function(self, eff)
if eff.particle then self:removeParticles(eff.particle) end
if eff.spellpowerChangeId then
self:removeTemporaryValue("combat_spellpower", eff.spellpowerChangeId)
eff.spellpowerChangeId = nil
end
if eff.mindpowerChangeId then
self:removeTemporaryValue("combat_mindpower", eff.mindpowerChangeId)
eff.mindpowerChangeId = nil
end
end,
on_timeout = function(self, eff)
end,
do_act = function(self, eff)
if eff.src.dead then
self:removeEffect(self.EFF_BECKONED)
return
end
if not self:enoughEnergy() then return nil end
-- apply periodic timer instead of random chance
if not eff.timer then
eff.timer = rng.float(0, 100)
end
if not self:checkHit(eff.src:combatMindpower(), self:combatMentalResist(), 0, 95, 5) then
eff.timer = eff.timer + eff.chance * 0.5
game.logSeen(self, "#F53CBE#%s struggles against the beckoning.", self:getName():capitalize())
else
eff.timer = eff.timer + eff.chance
end
if eff.timer > 100 then
eff.timer = eff.timer - 100
local distance = self.x and eff.src.x and core.fov.distance(self.x, self.y, eff.src.x, eff.src.y) or 1000
if math.floor(distance) > 1 and distance <= eff.range then
-- in range but not adjacent
-- add debuffs
if not eff.spellpowerChangeId then eff.spellpowerChangeId = self:addTemporaryValue("combat_spellpower", eff.spellpowerChange) end
if not eff.mindpowerChangeId then eff.mindpowerChangeId = self:addTemporaryValue("combat_mindpower", eff.mindpowerChange) end
-- custom pull logic (adapted from move_dmap; forces movement, pushes others aside, custom particles)
if not self:attr("never_move") then
local source = eff.src
local moveX, moveY = source.x, source.y -- move in general direction by default
if not self:hasLOS(source.x, source.y) then
local a = Astar.new(game.level.map, self)
local path = a:calc(self.x, self.y, source.x, source.y)
if path then
moveX, moveY = path[1].x, path[1].y
end
end
if moveX and moveY then
local old_move_others, old_x, old_y = self.move_others, self.x, self.y
self.move_others = true
local old = rawget(self, "aiCanPass")
self.aiCanPass = mod.class.NPC.aiCanPass
mod.class.NPC.moveDirection(self, moveX, moveY, false)
self.aiCanPass = old
self.move_others = old_move_others
if old_x ~= self.x or old_y ~= self.y then
game.level.map:particleEmitter(self.x, self.y, 1, "beckoned_move", {power=power, dx=self.x - source.x, dy=self.y - source.y})
end
end
end
else
-- adjacent or out of range..remove debuffs
if eff.spellpowerChangeId then
self:removeTemporaryValue("combat_spellpower", eff.spellpowerChangeId)
eff.spellpowerChangeId = nil
end
if eff.mindpowerChangeId then
self:removeTemporaryValue("combat_mindpower", eff.mindpowerChangeId)
eff.mindpowerChangeId = nil
end
end
end
end,
do_onTakeHit = function(self, eff, dam)
eff.resistChance = (eff.resistChance or 0) + math.min(100, math.max(0, dam / self.max_life * 100))
if rng.percent(eff.resistChance) then
game.logSeen(self, "#F53CBE#%s is jolted to attention by the damage and is no longer being beckoned.", self:getName():capitalize())
self:removeEffect(self.EFF_BECKONED)
end
return dam
end,
}
newEffect{
name = "OVERWHELMED", image = "talents/frenzy.png",
desc = _t"Overwhelmed",
long_desc = function(self, eff) return ("The target has been overwhemed by a furious assault, reducing defence by %d."):tformat( -eff.defenseChange) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = { damageChange=0.1 },
on_gain = function(self, err) return _t"#Target# has been overwhelmed.", _t"+Overwhelmed" end,
on_lose = function(self, err) return _t"#Target# is no longer overwhelmed.", _t"-Overwhelmed" end,
parameters = { chance=5 },
activate = function(self, eff)
eff.defenseChangeId = self:addTemporaryValue("combat_def", -eff.defenseChange)
eff.particle = self:addParticles(Particles.new("overwhelmed", 1))
end,
deactivate = function(self, eff)
self:removeTemporaryValue("combat_def", eff.defenseChangeId)
self:removeParticles(eff.particle)
end,
}
newEffect{
name = "CURSED_MIASMA", image = "talents/savage_hunter.png",
desc = _t"Cursed Miasma",
long_desc = function(self, eff) return ("The target is enveloped in a cursed miasma."):tformat(eff.sight) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = { chance=5 },
on_gain = function(self, err) return _t"#Target# is surrounded by a cursed miasma.", _t"+Cursed Miasma" end,
on_lose = function(self, err) return _t"The cursed miasma around #target# dissipates.", _t"-Cursed Miasma" end,
activate = function(self, eff)
local target = self.ai_target and self.ai_target.actor
self:setTarget(nil) -- Reset target to grab a random new one
self:effectTemporaryValue(eff, "hates_everybody", 1)
if core.shader.active() then
self:effectParticles(eff, {type="shader_shield", args={size_factor=1.5, img="shadow_shot_debuff_tentacles"}, shader={type="tentacles", wobblingType=0, appearTime=0.8, time_factor=2000, noup=0.0}})
end
if self.player then return end
if target and not (target.dead or not game.level:hasEntity(target)) then
eff.target = target
end
end,
on_timeout = function(self, eff)
if self.player then return end
local target = eff.target
if target and (target.dead or not game.level:hasEntity(target)) then
eff.target = nil
end
end,
deactivate = function(self, eff)
if self.player then return end
local target = self.ai_target and self.ai_target.actor
if not target then
self:setTarget(eff.target)
end
end,
}
newEffect{
name = "HARASSED", image = "talents/harass_prey.png",
desc = _t"Harassed",
long_desc = function(self, eff) return ("The target has been harassed by its stalker, reducing damage by %d%%."):tformat( -eff.damageChange) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = { damageChange=0.1 },
on_gain = function(self, err) return _t"#Target# has been harassed.", _t"+Harassed" end,
on_lose = function(self, err) return _t"#Target# is no longer harassed.", _t"-Harassed" end,
activate = function(self, eff)
eff.damageChangeId = self:addTemporaryValue("inc_damage", {all=eff.damageChange})
eff.particle = self:addParticles(Particles.new("harassed", 1))
end,
deactivate = function(self, eff)
self:removeTemporaryValue("inc_damage", eff.damageChangeId)
self:removeParticles(eff.particle)
end,
}
newEffect{
name = "DOMINATED", image = "talents/dominate.png",
desc = _t"Dominated",
long_desc = function(self, eff) return ("The target has been dominated. It is unable to move and has lost %d armor and %d defense. Attacks from %s gain %d%% damage penetration."):tformat(-eff.armorChange, -eff.defenseChange, eff.src:getName():capitalize(), eff.resistPenetration) end,
type = "mental",
subtype = { dominate=true },
status = "detrimental",
on_gain = function(self, err) return _t"#F53CBE##Target# has been dominated!", _t"+Dominated" end,
on_lose = function(self, err) return _t"#F53CBE##Target# is no longer dominated.", _t"-Dominated" end,
parameters = { armorChange = -3, defenseChange = -3, physicalResistChange = -0.1 },
activate = function(self, eff)
eff.neverMoveId = self:addTemporaryValue("never_move", 1)
eff.armorId = self:addTemporaryValue("combat_armor", eff.armorChange)
eff.defenseId = self:addTemporaryValue("combat_def", eff.armorChange)
eff.particle = self:addParticles(Particles.new("dominated", 1))
end,
deactivate = function(self, eff)
self:removeTemporaryValue("never_move", eff.neverMoveId)
self:removeTemporaryValue("combat_armor", eff.armorId)
self:removeTemporaryValue("combat_def", eff.defenseId)
self:removeParticles(eff.particle)
end,
}
newEffect{
name = "AGONY", image = "talents/agony.png",
desc = _t"Agony",
long_desc = function(self, eff) return ("%s is writhing in agony, suffering from %d to %d damage over %d turns."):tformat(self:getName():capitalize(), eff.damage / eff.duration, eff.damage, eff.duration) end,
type = "mental",
subtype = { pain=true, psionic=true },
status = "detrimental",
parameters = { damage=10, mindpower=10, range=10, minPercent=10 },
on_gain = function(self, err) return _t"#Target# is writhing in agony!", _t"+Agony" end,
on_lose = function(self, err) return _t"#Target# is no longer writhing in agony.", _t"-Agony" end,
activate = function(self, eff)
eff.power = 0
end,
deactivate = function(self, eff)
if eff.particle then self:removeParticles(eff.particle) end
end,
on_timeout = function(self, eff)
eff.turn = (eff.turn or 0) + 1
local damage = math.floor(eff.damage * (eff.turn / eff.duration))
if damage > 0 then
DamageType:get(DamageType.MIND).projector(eff.src, self.x, self.y, DamageType.MIND, { dam=damage, crossTierChance=25 })
game:playSoundNear(self, "talents/fire")
end
if self.dead then
if eff.particle then self:removeParticles(eff.particle) eff.particle = nil end
return
end
if eff.particle then self:removeParticles(eff.particle) end
eff.particle = nil
eff.particle = self:addParticles(Particles.new("agony", 1, { power = 5 * eff.turn / eff.duration }))
end,
}
newEffect{
name = "HATEFUL_WHISPER", image = "talents/hateful_whisper.png",
desc = _t"Hateful Whisper",
long_desc = function(self, eff) return ("%s has heard the hateful whisper."):tformat(self:getName():capitalize()) end,
type = "mental",
subtype = { madness=true, psionic=true },
status = "detrimental",
parameters = { },
on_gain = function(self, err) return _t"#Target# has heard the hateful whisper!", _t"+Hateful Whisper" end,
on_lose = function(self, err) return _t"#Target# no longer hears the hateful whisper.", _t"-Hateful Whisper" end,
activate = function(self, eff)
if not eff.src.dead and eff.src:knowTalent(eff.src.T_HATE_POOL) then
eff.src:incHate(eff.hateGain)
end
DamageType:get(DamageType.MIND).projector(eff.src, self.x, self.y, DamageType.MIND, { dam=eff.damage, crossTierChance=25 })
if self.dead then
-- only spread on activate if the target is dead
if eff.jumpCount > 0 then
eff.jumpCount = eff.jumpCount - 1
self.tempeffect_def[self.EFF_HATEFUL_WHISPER].doSpread(self, eff)
end
else
eff.particle = self:addParticles(Particles.new("hateful_whisper", 1, { }))
end
game:playSoundNear(self, "talents/fire")
eff.firstTurn = true
end,
deactivate = function(self, eff)
if eff.particle then self:removeParticles(eff.particle) end
end,
on_timeout = function(self, eff)
if self.dead then return false end
if eff.firstTurn then
-- pause a turn before infecting others
eff.firstTurn = false
elseif eff.jumpDuration > 0 then
-- limit the total duration of all spawned effects
eff.jumpDuration = eff.jumpDuration - 1
if eff.jumpCount > 0 then
-- guaranteed jump
eff.jumpCount = eff.jumpCount - 1
self.tempeffect_def[self.EFF_HATEFUL_WHISPER].doSpread(self, eff)
elseif rng.percent(eff.jumpChance) then
-- per turn chance of a jump
self.tempeffect_def[self.EFF_HATEFUL_WHISPER].doSpread(self, eff)
end
end
end,
doSpread = function(self, eff)
local targets = {}
local grids = core.fov.circle_grids(self.x, self.y, eff.jumpRange, true)
for x, yy in pairs(grids) do
for y, _ in pairs(grids[x]) do
local a = game.level.map(x, y, game.level.map.ACTOR)
if a and eff.src:reactionToward(a) < 0 and self:hasLOS(a.x, a.y) then
if not a:hasEffect(a.EFF_HATEFUL_WHISPER) then
targets[#targets+1] = a
end
end
end
end
if #targets > 0 then
local target = rng.table(targets)
target:setEffect(target.EFF_HATEFUL_WHISPER, eff.duration, {
src = eff.src,
duration = eff.duration,
damage = eff.damage,
mindpower = eff.mindpower,
jumpRange = eff.jumpRange,
jumpCount = 0, -- secondary effects do not get automatic spreads
jumpChance = eff.jumpChance,
jumpDuration = eff.jumpDuration,
hateGain = eff.hateGain
})
game.level.map:particleEmitter(target.x, target.y, 1, "reproach", { dx = self.x - target.x, dy = self.y - target.y })
end
end,
}
newEffect{
name = "MADNESS_SLOW", image = "effects/madness_slowed.png",
desc = _t"Slowed by madness",
long_desc = function(self, eff) return ("Madness reduces the target's global speed by %d%% and lowers mind resistance by %d%%."):tformat(eff.power * 100, -eff.mindResistChange) end,
type = "mental",
subtype = { madness=true, slow=true },
status = "detrimental",
parameters = { power=0.1 },
on_gain = function(self, err) return _t"#F53CBE##Target# slows in the grip of madness!", _t"+Slow" end,
on_lose = function(self, err) return _t"#Target# overcomes the madness.", _t"-Slow" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("gloom_slow", 1))
eff.mindResistChangeId = self:addTemporaryValue("resists", { [DamageType.MIND]=eff.mindResistChange })
eff.tmpid = self:addTemporaryValue("global_speed_add", -eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("resists", eff.mindResistChangeId)
self:removeTemporaryValue("global_speed_add", eff.tmpid)
self:removeParticles(eff.particle)
end,
}
newEffect{
name = "MADNESS_STUNNED", image = "effects/madness_stunned.png",
desc = _t"Stunned by madness",
long_desc = function(self, eff) return ("Madness has stunned the target, reducing damage by 50%%, lowering mind resistance by %d%%, putting 4 random talents on cooldown and reducing movement speed by 50%%. While stunned talents cooldown twice as slow."):tformat(eff.mindResistChange) end,
type = "mental",
subtype = { madness=true, stun=true },
status = "detrimental",
parameters = {mindResistChange = -10},
on_gain = function(self, err) return _t"#F53CBE##Target# is stunned by madness!", _t"+Stunned" end,
on_lose = function(self, err) return _t"#Target# overcomes the madness", _t"-Stunned" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("gloom_stunned", 1))
eff.mindResistChangeId = self:addTemporaryValue("resists", { [DamageType.MIND]=eff.mindResistChange })
eff.tmpid = self:addTemporaryValue("stunned", 1)
eff.speedid = self:addTemporaryValue("movement_speed", -0.5)
eff.lockid = self:addTemporaryValue("half_talents_cooldown", 1)
local tids = {}
for tid, lev in pairs(self.talents) do
local t = self:getTalentFromId(tid)
if t and not self.talents_cd[tid] and t.mode == "activated" and not t.innate then tids[#tids+1] = t end
end
for i = 1, 4 do
local t = rng.tableRemove(tids)
if not t then break end
self.talents_cd[t.id] = 1
end
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
self:removeTemporaryValue("resists", eff.mindResistChangeId)
self:removeTemporaryValue("stunned", eff.tmpid)
self:removeTemporaryValue("movement_speed", eff.speedid)
self:removeTemporaryValue("half_talents_cooldown", eff.lockid)
end,
}
newEffect{
name = "MADNESS_CONFUSED", image = "effects/madness_confused.png",
desc = _t"Confused by madness",
long_desc = function(self, eff) return ("Madness has confused the target, lowering mind resistance by %d%% and making it act randomly (%d%% chance)"):tformat(eff.mindResistChange, eff.power) end,
type = "mental",
subtype = { madness=true, confusion=true, power=50 },
status = "detrimental",
charges = function(self, eff) return (tostring(eff.power).."%") end,
parameters = { power=10 },
on_gain = function(self, err) return _t"#F53CBE##Target# is lost in madness!", _t"+Confused" end,
on_lose = function(self, err) return _t"#Target# overcomes the madness", _t"-Confused" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("gloom_confused", 1))
eff.mindResistChangeId = self:addTemporaryValue("resists", { [DamageType.MIND]=eff.mindResistChange })
eff.power = math.floor(util.bound(eff.power, 0, 50))
eff.tmpid = self:addTemporaryValue("confused", eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("resists", eff.mindResistChangeId)
self:removeParticles(eff.particle)
self:removeTemporaryValue("confused", eff.tmpid)
if self == game.player and self.updateMainShader then self:updateMainShader() end
end,
}
newEffect{
name = "MALIGNED", image = "talents/gesture_of_malice.png",
desc = _t"Maligned",
long_desc = function(self, eff) return ("The target is under a malign influence. All resists have been lowered by %d%%."):tformat(-eff.resistAllChange) end,
type = "mental",
subtype = { curse=true },
status = "detrimental",
parameters = {},
on_gain = function(self, err) return _t"#F53CBE##Target# has been maligned!", _t"+Maligned" end,
on_lose = function(self, err) return _t"#Target# is no longer maligned", _t"-Maligned" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("maligned", 1))
eff.resistAllChangeId = self:addTemporaryValue("resists", { all=eff.resistAllChange })
end,
deactivate = function(self, eff)
self:removeTemporaryValue("resists", eff.resistAllChangeId)
self:removeParticles(eff.particle)
end,
on_merge = function(self, old_eff, new_eff)
old_eff.dur = new_eff.dur
return old_eff
end,
}
local function updateFearParticles(self)
local hasParticles = false
if self:hasEffect(self.EFF_PARANOID) then hasParticles = true end
if self:hasEffect(self.EFF_DISPAIR) then hasParticles = true end
if self:hasEffect(self.EFF_TERRIFIED) then hasParticles = true end
if self:hasEffect(self.EFF_DISTRESSED) then hasParticles = true end
if self:hasEffect(self.EFF_HAUNTED) then hasParticles = true end
if self:hasEffect(self.EFF_TORMENTED) then hasParticles = true end
if not self.fearParticlesId and hasParticles then
self.fearParticlesId = self:addParticles(Particles.new("fear_blue", 1))
elseif self.fearParticlesId and not hasParticles then
self:removeParticles(self.fearParticlesId)
self.fearParticlesId = nil
end
end
newEffect{
name = "HEIGHTEN_FEAR", image = "talents/heighten_fear.png",
desc = _t"Heighten Fear",
long_desc = function(self, eff) return ("The target is in a state of growing fear. If they spend %d more turns within range %d and in sight of the source of this fear (%s), they will take %d mind and darkness damage and be subjected to a new fear."):
tformat(eff.turns_left, eff.range, eff.src:getName(), eff.damage) end,
type = "other",
charges = function(self, eff) return _t"#ORANGE#"..eff.turns_left.."#LAST#" end,
subtype = { },
status = "detrimental",
cancel_on_level_change = true,
parameters = { },
on_timeout = function(self, eff)
local tInstillFear = self:getTalentFromId(self.T_INSTILL_FEAR)
-- if tInstillFear.hasEffect(eff.src, tInstillFear, self) then
if core.fov.distance(self.x, self.y, eff.src.x, eff.src.y) <= eff.range and eff.src:hasLOS(self.x, self.y) then
eff.turns_left = eff.turns_left - 1
end
if eff.turns_left <= 0 then
eff.turns_left = eff.turns
if rng.percent(eff.chance or 100) then
game.logSeen(self, "%s succumbs to heightening fears!", self:getName():capitalize())
DamageType:get(DamageType.MIND).projector(eff.src, self.x, self.y, DamageType.MIND, { dam=eff.damage, crossTierChance=25 })
DamageType:get(DamageType.DARKNESS).projector(eff.src, self.x, self.y, DamageType.DARKNESS, eff.damage)
tInstillFear.applyEffect(eff.src, tInstillFear, self, true)
else
game.logSeen(self, "%s feels a little less afraid!", self:getName():capitalize())
end
end
end,
activate = function(self, eff)
end,
deactivate = function(self, eff)
end,
}
newEffect{
name = "Tyrant", image = "talents/tyrant.png",
desc = _t"Tyrant",
long_desc = function(self, eff) return ("Your tyranny is increasing your Mindpower and Physicalpower by 2 for each fear applied, for a total of %d"):tformat(eff.tyrantPower * eff.stacks) end,
type = "mental",
subtype = { },
status = "beneficial",
parameters = { stacks=1 },
activate = function(self, eff)
eff.mpower = self:addTemporaryValue("combat_mindpower", eff.tyrantPower * eff.stacks)
eff.ppower = self:addTemporaryValue("combat_dam", eff.tyrantPower * eff.stacks)
end,
on_merge = function(self, old_eff, new_eff)
old_eff.dur = new_eff.dur
old_eff.stacks = util.bound(old_eff.stacks + 1, 1, new_eff.maxStacks)
self:removeTemporaryValue("combat_mindpower", old_eff.mpower)
self:removeTemporaryValue("combat_dam", old_eff.ppower)
old_eff.mpower = self:addTemporaryValue("combat_mindpower", old_eff.tyrantPower * old_eff.stacks)
old_eff.ppower = self:addTemporaryValue("combat_dam", old_eff.tyrantPower * old_eff.stacks)
return old_eff
end,
deactivate = function(self, eff)
self:removeTemporaryValue("combat_mindpower", eff.mpower)
self:removeTemporaryValue("combat_dam", eff.ppower)
end,
}
newEffect{
name = "PARANOID", image = "effects/paranoid.png",
desc = _t"Paranoid",
long_desc = function(self, eff) return ("Paranoia has gripped the target, causing a %d%% chance they will physically attack anyone nearby, friend or foe. Targets of the attack may become paranoid themselves."):tformat(eff.attackChance) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = { tyrantDur=5, tyrantPower=2, maxStacks=7 },
on_gain = function(self, err) return _t"#F53CBE##Target# becomes paranoid!", _t"+Paranoid" end,
on_lose = function(self, err) return _t"#Target# is no longer paranoid", _t"-Paranoid" end,
activate = function(self, eff)
--fear effect for each fear effect in mental.lua to give caster a buff
if eff.src and eff.src.knowTalent and eff.src:knowTalent(eff.src.T_TYRANT) then
eff.src:setEffect(eff.src.EFF_TYRANT, eff.tyrantDur, { tyrantPower = eff.tyrantPower, maxStacks = eff.maxStacks })
end
updateFearParticles(self)
end,
deactivate = function(self, eff)
updateFearParticles(self)
end,
do_act = function(self, eff)
if not self:enoughEnergy() then return nil end
-- apply periodic timer instead of random chance
if not eff.timer then
eff.timer = rng.float(0, 100)
end
if not self:checkHit(eff.src:combatMindpower(), self:combatMentalResist(), 0, 95, 5) then
eff.timer = eff.timer + eff.attackChance * 0.5
game.logSeen(self, "#F53CBE#%s struggles against the paranoia.", self:getName():capitalize())
else
eff.timer = eff.timer + eff.attackChance
end
if eff.timer > 100 then
eff.timer = eff.timer - 100
local start = rng.range(0, 8)
for i = start, start + 8 do
local x = self.x + (i % 3) - 1
local y = self.y + math.floor((i % 9) / 3) - 1
if (self.x ~= x or self.y ~= y) then
local target = game.level.map(x, y, Map.ACTOR)
if target then
self:logCombat(target, "#F53CBE##Source# attacks #Target# in a fit of paranoia.")
if self:attackTarget(target, nil, 1, false) and target ~= eff.src then
if not target:canBe("fear") then
game.logSeen(target, "#F53CBE#%s ignores the fear!", target:getName():capitalize())
elseif not target:checkHit(eff.mindpower, target:combatMentalResist()) then
game.logSeen(target, "%s resists the fear!", target:getName():capitalize())
else
target:setEffect(target.EFF_PARANOID, eff.duration, {src=eff.src, attackChance=eff.attackChance, mindpower=eff.mindpower, duration=eff.duration, tyrantDur = eff.tyrantDur, tyrantPower = eff.tyrantPower, maxStacks = eff.maxStacks })
end
end
return
end
end
end
end
end,
}
newEffect{
name = "DISPAIR", image = "effects/despair.png",
desc = _t"Despair",
long_desc = function(self, eff) return ("The target is in despair, reducing their armour, defence, mindsave and mind resist by %d."):tformat(-eff.statChange) end,
charges = function(self, eff) return math.floor(-eff.statChange) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = {tyrantDur=5, tyrantPower=2},
on_gain = function(self, err) return _t"#F53CBE##Target# is in despair!", _t"+Despair" end,
on_lose = function(self, err) return _t"#Target# is no longer in despair", _t"-Despair" end,
activate = function(self, eff)
--fear effect for each fear effect in mental.lua to give caster a buff
if eff.src and eff.src.knowTalent and eff.src:knowTalent(eff.src.T_TYRANT) then
eff.src:setEffect(eff.src.EFF_TYRANT, eff.tyrantDur, { tyrantPower = eff.tyrantPower, maxStacks = eff.maxStacks })
end
eff.despairRes = self:addTemporaryValue("resists", { [DamageType.MIND]=eff.statChange })
eff.despairSave = self:addTemporaryValue("combat_mentalresist", eff.statChange)
eff.despairArmor = self:addTemporaryValue("combat_armor", eff.statChange)
eff.despairDef = self:addTemporaryValue("combat_def", eff.statChange)
updateFearParticles(self)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("resists", eff.despairRes)
self:removeTemporaryValue("combat_mentalresist", eff.despairSave)
self:removeTemporaryValue("combat_armor", eff.despairArmor)
self:removeTemporaryValue("combat_def", eff.despairDef)
updateFearParticles(self)
end,
}
newEffect{
name = "TERRIFIED", image = "effects/terrified.png",
desc = _t"Terrified",
long_desc = function(self, eff) return ("The target is terrified taking %d mind and darkness damage per turn and increasing all their cooldowns by %d%%."):tformat(eff.damage, eff.cooldownPower * 100) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = {tyrantDur=5, tyrantPower=2},
charges = function(self, eff) return (tostring(math.floor(eff.cooldownPower * 100)).."%") end,
on_gain = function(self, err) return _t"#F53CBE##Target# becomes terrified!", _t"+Terrified" end,
on_lose = function(self, err) return _t"#Target# is no longer terrified", _t"-Terrified" end,
activate = function(self, eff) --cooldown increase handled in class.actor.lua
--fear effect for each fear effect in mental.lua to give caster a buff
if eff.src and eff.src.knowTalent and eff.src:knowTalent(eff.src.T_TYRANT) then
eff.src:setEffect(eff.src.EFF_TYRANT, eff.tyrantDur, { tyrantPower = eff.tyrantPower, maxStacks = eff.maxStacks })
end
updateFearParticles(self)
end,
on_timeout = function(self, eff)
eff.src:project({type="hit", x=self.x,y=self.y}, self.x, self.y, DamageType.MIND, eff.damage)
eff.src:project({type="hit", x=self.x,y=self.y}, self.x, self.y, DamageType.DARKNESS, eff.damage)
end,
deactivate = function(self, eff)
updateFearParticles(self)
end,
}
-- distressed fear for prosperity
--[[
newEffect{
name = "DISTRESSED", image = "effects/distressed.png",
desc = _t"Distressed",
long_desc = function(self, eff) return ("The target is distressed, reducing all saves by %d."):tformat(-eff.saveChange) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = {},
on_gain = function(self, err) return _t"#F53CBE##Target# becomes distressed!", _t"+Distressed" end,
on_lose = function(self, err) return _t"#Target# is no longer distressed", _t"-Distressed" end,
activate = function(self, eff)
eff.physicalId = self:addTemporaryValue("combat_physresist", eff.saveChange)
eff.mentalId = self:addTemporaryValue("combat_mentalresist", eff.saveChange)
eff.spellId = self:addTemporaryValue("combat_spellresist", eff.saveChange)
updateFearParticles(self)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("combat_physresist", eff.physicalId)
self:removeTemporaryValue("combat_mentalresist", eff.mentalId)
self:removeTemporaryValue("combat_spellresist", eff.spellId)
updateFearParticles(self)
local tInstillFear = self:getTalentFromId(self.T_INSTILL_FEAR)
tInstillFear.endEffect(self, tInstillFear)
end,
}
]]
newEffect{
name = "HAUNTED", image = "effects/haunted.png",
desc = _t"Haunted",
long_desc = function(self, eff) return ("The target is haunted by a feeling of dread, causing each detrimental mental effect to inflict %d mind and darkness damage every turn."):tformat(eff.damage) end, --perhaps add total.
charges = function(self, eff) return (math.floor(eff.damage)) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = {damage=10, tyrantDur=5, tyrantPower=2},
on_gain = function(self, err) return _t"#F53CBE##Target# becomes haunted!", _t"+Haunted" end,
on_lose = function(self, err) return _t"#Target# is no longer haunted", _t"-Haunted" end,
activate = function(self, eff)
--fear effect for each fear effect in mental.lua to give caster a buff
if eff.src and eff.src.knowTalent and eff.src:knowTalent(eff.src.T_TYRANT) then
eff.src:setEffect(eff.src.EFF_TYRANT, eff.tyrantDur, { tyrantPower = eff.tyrantPower, maxStacks = eff.maxStacks })
end
updateFearParticles(self)
end,
on_timeout = function(self, eff)
local nb = 0
for e, p in pairs(self.tmp) do
local def = self.tempeffect_def[e]
if def.type == "mental" and def.status == "detrimental" then
nb = nb + 1
end
end
if nb > 0 and not self.dead then
eff.src:project({type="hit", x=self.x,y=self.y}, self.x, self.y, DamageType.MIND, { dam=nb * eff.damage,alwaysHit=true,crossTierChance=0 })
eff.src:project({type="hit", x=self.x,y=self.y}, self.x, self.y, DamageType.DARKNESS, nb * eff.damage)
end
end,
deactivate = function(self, eff)
updateFearParticles(self)
end,
on_setFearEffect = function(self, e)
local eff = self:hasEffect(self.EFF_HAUNTED)
end,
}
--tormented for prosperity
--[[
newEffect{
name = "TORMENTED", image = "effects/tormented.png",
desc = _t"Tormented",
long_desc = function(self, eff) return ("The target's mind is being tormented, causing %d apparitions to manifest and attack the target, inflicting %d mind damage each before disappearing."):tformat(eff.count, eff.damage) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = {count=1, damage=10},
on_gain = function(self, err) return _t"#F53CBE##Target# becomes tormented!", _t"+Tormented" end,
on_lose = function(self, err) return _t"#Target# is no longer tormented", _t"-Tormented" end,
activate = function(self, eff)
updateFearParticles(self)
end,
deactivate = function(self, eff)
updateFearParticles(self)
local tInstillFear = self:getTalentFromId(self.T_INSTILL_FEAR)
tInstillFear.endEffect(self, tInstillFear)
end,
npcTormentor = {
name = "tormentor",
display = "h", color=colors.DARK_GREY, image="npc/horror_eldritch_nightmare_horror.png",
blood_color = colors.BLACK,
desc = _t"A vision of terror that wracks the mind.",
type = "horror", subtype = "eldritch",
rank = 2,
size_category = 2,
body = { INVEN = 10 },
no_drops = true,
autolevel = "summoner",
level_range = {1, nil}, exp_worth = 0,
ai = "summoned", ai_real = "dumb_talented_simple", ai_state = { talent_in=2, ai_move="move_ghoul", },
stats = { str=10, dex=20, wil=20, con=10, cun=30 },
infravision = 10,
can_pass = {pass_wall=20},
resists = { all = 100, [DamageType.MIND]=-100 },
no_breath = 1,
fear_immune = 1,
blind_immune = 1,
infravision = 10,
see_invisible = 80,
max_life = resolvers.rngavg(50, 80),
combat_armor = 1, combat_def = 50,
combat = { dam=1 },
resolvers.talents{
},
on_act = function(self)
local target = self.ai_target.actor
if not target or target.dead then
self:die()
else
game.logSeen(self, "%s is tormented by a vision!", target:getName():capitalize())
self:project({type="hit", x=target.x,y=target.y}, target.x, target.y, engine.DamageType.MIND, { dam=self.tormentedDamage,alwaysHit=true,crossTierChance=75 })
self:die()
end
end,
},
on_timeout = function(self, eff)
if eff.src.dead then return true end
-- tormentors per turn are pre-calculated in a table, but ordered, so take a random one
local count = rng.tableRemove(eff.counts)
for c = 1, count do
local start = rng.range(0, 8)
for i = start, start + 8 do
local x = self.x + (i % 3) - 1
local y = self.y + math.floor((i % 9) / 3) - 1
if game.level.map:isBound(x, y) and not game.level.map(x, y, Map.ACTOR) then
local def = self.tempeffect_def[self.EFF_TORMENTED]
local m = require("mod.class.NPC").new(def.npcTormentor)
m.faction = eff.src.faction
m.summoner = eff.src
m.summoner_gain_exp = true
m.summon_time = 3
m.tormentedDamage = eff.damage
m:resolve() m:resolve(nil, true)
m:forceLevelup(self.level)
m:setTarget(self)
game.zone:addEntity(game.level, m, "actor", x, y)
break
end
end
end
end,
}
]]
newEffect{
name = "PANICKED", image = "talents/panic.png",
desc = _t"Panicked",
long_desc = function(self, eff) return ("The target has been panicked by %s, causing them to have a %d%% chance of fleeing in terror instead of acting."):tformat(eff.src:getName(), eff.chance) end,
type = "mental",
subtype = { fear=true },
status = "detrimental",
parameters = {},
on_gain = function(self, err) return _t"#F53CBE##Target# becomes panicked!", _t"+Panicked" end,
on_lose = function(self, err) return _t"#Target# is no longer panicked", _t"-Panicked" end,
activate = function(self, eff)
eff.particlesId = self:addParticles(Particles.new("fear_violet", 1))
end,
deactivate = function(self, eff)
self:removeParticles(eff.particlesId)
local tInstillFear = self:getTalentFromId(self.T_INSTILL_FEAR)
tInstillFear.endEffect(self, tInstillFear)
end,
do_act = function(self, eff)
if not self:enoughEnergy() then return nil end
if eff.src.dead then return true end
-- apply periodic timer instead of random chance
if not eff.timer then
eff.timer = rng.float(0, 100)
end
if not self:checkHit(eff.src:combatMindpower(), self:combatMentalResist(), 0, 95, 5) then
eff.timer = eff.timer + eff.chance * 0.5
game.logSeen(self, "#F53CBE#%s struggles against the panic.", self:getName():capitalize())
else
eff.timer = eff.timer + eff.chance
end
if eff.timer > 100 then
eff.timer = eff.timer - 100
local distance = core.fov.distance(self.x, self.y, eff.src.x, eff.src.y)
if distance <= eff.range then
-- in range
if not self:attr("never_move") then
local sourceX, sourceY = eff.src.x, eff.src.y
local bestX, bestY
local bestDistance = 0
local start = rng.range(0, 8)
for i = start, start + 8 do
local x = self.x + (i % 3) - 1
local y = self.y + math.floor((i % 9) / 3) - 1
if x ~= self.x or y ~= self.y then
local distance = core.fov.distance(x, y, sourceX, sourceY)
if distance > bestDistance
and game.level.map:isBound(x, y)
and not game.level.map:checkAllEntities(x, y, "block_move", self)
and not game.level.map(x, y, Map.ACTOR) then
bestDistance = distance
bestX = x
bestY = y
end
end
end
if bestX then
self:move(bestX, bestY, false)
game.logPlayer(self, "#F53CBE#You panic and flee from %s.", eff.src:getName())
else
self:logCombat(eff.src, "#F53CBE##Source# panics but fails to flee from #Target#.")
self:useEnergy(game.energy_to_act * self:combatMovementSpeed(bestX, bestY))
end
end
end
end
end,
}
newEffect{
name = "QUICKNESS", image = "effects/quickness.png",
desc = _t"Quick",
long_desc = function(self, eff) return ("Increases global speed by %d%%."):tformat(eff.power * 100) end,
type = "mental",
subtype = { telekinesis=true, speed=true },
status = "beneficial",
parameters = { power=0.1 },
on_gain = function(self, err) return _t"#Target# speeds up.", _t"+Quick" end,
on_lose = function(self, err) return _t"#Target# slows down.", _t"-Quick" end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("global_speed_add", eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("global_speed_add", eff.tmpid)
end,
}
newEffect{
name = "PSIFRENZY", image = "talents/frenzied_focus.png",
desc = _t"Frenzied Focus",
long_desc = function(self, eff) return (_t"This creatures psionic focus item is supercharged!") end,
type = "mental",
subtype = { telekinesis=true, frenzy=true },
status = "beneficial",
parameters = {dam=10},
on_gain = function(self, err) return _t"#Target# enters a frenzy!", _t"+Frenzy" end,
on_lose = function(self, err) return _t"#Target# is no longer frenzied.", _t"-Frenzy" end,
}
newEffect{
name = "KINSPIKE_SHIELD", image = "talents/kinetic_shield.png",
desc = _t"Spiked Kinetic Shield",
long_desc = function(self, eff)
local tl = self:getTalentLevel(self.T_ABSORPTION_MASTERY)
local xs = (tl>=3 and _t", nature" or "")..(tl>=6 and _t", temporal" or "")
return ("The target erects a powerful kinetic shield capable of absorbing %d/%d physical%s or acid damage before it crumbles."):tformat(self.kinspike_shield_absorb, eff.power, xs)
end,
type = "mental",
subtype = { telekinesis=true, shield=true },
status = "beneficial",
parameters = { power=100 },
on_gain = function(self, err) return _t"A powerful kinetic shield forms around #target#.", _t"+Shield" end,
on_lose = function(self, err) return _t"The powerful kinetic shield around #target# crumbles.", _t"-Shield" end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("kinspike_shield", eff.power)
self.kinspike_shield_absorb = eff.power
if core.shader.active(4) then
eff.particle = self:addParticles(Particles.new("shader_shield", 1, {size_factor=1.4, img="shield5"}, {type="runicshield", ellipsoidalFactor=1, time_factor=-10000, llpow=1, aadjust=7, bubbleColor={1, 0, 0.3, 0.6}, auraColor={1, 0, 0.3, 1}}))
else
eff.particle = self:addParticles(Particles.new("generic_shield", 1, {r=1, g=0, b=0.3, a=1}))
end
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
self:removeTemporaryValue("kinspike_shield", eff.tmpid)
self.kinspike_shield_absorb = nil
end,
}
newEffect{
name = "THERMSPIKE_SHIELD", image = "talents/thermal_shield.png",
desc = _t"Spiked Thermal Shield",
long_desc = function(self, eff)
local tl = self:getTalentLevel(self.T_ABSORPTION_MASTERY)
local xs = (tl>=3 and _t", light" or "")..(tl>=6 and _t", arcane" or "")
return ("The target erects a powerful thermal shield capable of absorbing %d/%d fire%s or cold damage before it crumbles."):tformat(self.thermspike_shield_absorb, eff.power, xs)
end,
type = "mental",
subtype = { telekinesis=true, shield=true },
status = "beneficial",
parameters = { power=100 },
on_gain = function(self, err) return _t"A powerful thermal shield forms around #target#.", _t"+Shield" end,
on_lose = function(self, err) return _t"The powerful thermal shield around #target# crumbles.", _t"-Shield" end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("thermspike_shield", eff.power)
self.thermspike_shield_absorb = eff.power
if core.shader.active(4) then
eff.particle = self:addParticles(Particles.new("shader_shield", 1, {size_factor=1.4, img="shield5"}, {type="runicshield", ellipsoidalFactor=1, time_factor=-10000, llpow=1, aadjust=7, bubbleColor={0.3, 1, 1, 0.6}, auraColor={0.3, 1, 1, 1}}))
else
eff.particle = self:addParticles(Particles.new("generic_shield", 1, {r=0.3, g=1, b=1, a=1}))
end
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
self:removeTemporaryValue("thermspike_shield", eff.tmpid)
self.thermspike_shield_absorb = nil
end,
}
newEffect{
name = "CHARGESPIKE_SHIELD", image = "talents/charged_shield.png",
desc = _t"Spiked Charged Shield",
long_desc = function(self, eff)
local tl = self:getTalentLevel(self.T_ABSORPTION_MASTERY)
local xs = (tl>=3 and _t", darkness" or "")..(tl>=6 and _t", mind" or "")
return ("The target erects a powerful charged shield capable of absorbing %d/%d lightning%s or blight damage before it crumbles."):tformat(self.chargespike_shield_absorb, eff.power, xs)
end,
type = "mental",
subtype = { telekinesis=true, shield=true },
status = "beneficial",
parameters = { power=100 },
on_gain = function(self, err) return _t"A powerful charged shield forms around #target#.", _t"+Shield" end,
on_lose = function(self, err) return _t"The powerful charged shield around #target# crumbles.", _t"-Shield" end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("chargespike_shield", eff.power)
self.chargespike_shield_absorb = eff.power
if core.shader.active(4) then
eff.particle = self:addParticles(Particles.new("shader_shield", 1, {size_factor=1.4, img="shield5"}, {type="runicshield", ellipsoidalFactor=1, time_factor=-10000, llpow=1, aadjust=7, bubbleColor={0.8, 1, 0.2, 0.6}, auraColor={0.8, 1, 0.2, 1}}))
else
eff.particle = self:addParticles(Particles.new("generic_shield", 1, {r=0.8, g=1, b=0.2, a=1}))
end
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
self:removeTemporaryValue("chargespike_shield", eff.tmpid)
self.chargespike_shield_absorb = nil
end,
}
newEffect{
name = "CONTROL", image = "talents/perfect_control.png",
desc = _t"Perfect control",
long_desc = function(self, eff) return ("The target's combat attack and crit chance are improved by %d and %d%%, respectively."):tformat(eff.power, 0.5*eff.power) end,
type = "mental",
subtype = { telekinesis=true, focus=true },
status = "beneficial",
parameters = { power=10 },
activate = function(self, eff)
eff.attack = self:addTemporaryValue("combat_atk", eff.power)
eff.crit = self:addTemporaryValue("combat_physcrit", 0.5*eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("combat_atk", eff.attack)
self:removeTemporaryValue("combat_physcrit", eff.crit)
end,
}
newEffect{
name = "PSI_REGEN", image = "talents/matter_is_energy.png",
desc = _t"Matter is energy",
long_desc = function(self, eff) return ("The gem's matter gradually transforms, granting %0.2f psi per turn."):tformat(eff.power) end,
type = "mental",
subtype = { psychic_drain=true },
status = "beneficial",
parameters = { power=10 },
on_gain = function(self, err) return _t"Energy starts pouring from the gem into #Target#.", _t"+Energy" end,
on_lose = function(self, err) return _t"The flow of energy from #Target#'s gem ceases.", _t"-Energy" end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("psi_regen", eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("psi_regen", eff.tmpid)
end,
}
newEffect{
name = "MASTERFUL_TELEKINETIC_ARCHERY", image = "talents/masterful_telekinetic_archery.png",
desc = _t"Telekinetic Archery",
long_desc = function(self, eff) return (_t"Your telekinetically-wielded bow automatically attacks the nearest target each turn.") end,
type = "mental",
subtype = { telekinesis=true },
status = "beneficial",
parameters = {dam=10},
on_gain = function(self, err) return _t"#Target# enters a telekinetic archer's trance!", _t"+Telekinetic archery" end,
on_lose = function(self, err) return _t"#Target# is no longer in a telekinetic archer's trance.", _t"-Telekinetic archery" end,
}
newEffect{
name = "WEAKENED_MIND", image = "talents/taint__telepathy.png",
desc = _t"Receptive Mind",
long_desc = function(self, eff) return ("Decreases mind save by %d and increases mindpower by %d."):tformat(eff.save, eff.power) end,
type = "mental",
subtype = { morale=true },
status = "detrimental",
parameters = { power=10, save=10 },
activate = function(self, eff)
eff.mindid = self:addTemporaryValue("combat_mentalresist", -eff.save)
eff.powdid = self:addTemporaryValue("combat_mindpower", eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("combat_mentalresist", eff.mindid)
self:removeTemporaryValue("combat_mindpower", eff.powdid)
end,
}
newEffect{
name = "VOID_ECHOES", image = "talents/echoes_from_the_void.png",
desc = _t"Void Echoes",
long_desc = function(self, eff) return ("The target is seeing echoes from the void and will take %0.2f mind damage as well as some resource damage each turn it fails a mental save."):tformat(eff.power) end,
type = "mental",
subtype = { madness=true, psionic=true },
status = "detrimental",
parameters = { power=10 },
on_gain = function(self, err) return _t"#Target# is being driven mad by the void.", _t"+Void Echoes" end,
on_lose = function(self, err) return _t"#Target# has survived the void madness.", _t"-Void Echoes" end,
on_timeout = function(self, eff)
local drain = DamageType:get(DamageType.MIND).projector(eff.src or self, self.x, self.y, DamageType.MIND, eff.power) / 2
self:incMana(-drain)
self:incVim(-drain * 0.5)
self:incPositive(-drain * 0.25)
self:incNegative(-drain * 0.25)
self:incStamina(-drain * 0.65)
self:incHate(-drain * 0.2)
self:incPsi(-drain * 0.2)
end,
}
newEffect{
name = "WAKING_NIGHTMARE", image = "talents/waking_nightmare.png",
desc = _t"Waking Nightmare",
long_desc = function(self, eff) return ("The target is lost in a nightmare that deals %0.2f darkness damage each turn and has a %d%% chance to cause a random detrimental effect."):tformat(eff.dam, eff.chance) end,
type = "mental",
subtype = { nightmare=true, darkness=true },
status = "detrimental",
parameters = { chance=10, dam = 10 },
on_gain = function(self, err) return _t"#F53CBE##Target# is lost in a nightmare.", _t"+Night Terrors" end,
on_lose = function(self, err) return _t"#Target# is free from the nightmare.", _t"-Night Terrors" end,
on_timeout = function(self, eff)
DamageType:get(DamageType.DARKNESS).projector(eff.src or self, self.x, self.y, DamageType.DARKNESS, eff.dam)
local chance = eff.chance
if self:attr("sleep") then chance = 100-(100-chance)/2 end -- Half normal chance to avoid effect
if rng.percent(chance) then
-- Pull random effect
chance = rng.range(1, 3)
if chance == 1 then
if self:canBe("blind") then
self:setEffect(self.EFF_BLINDED, 3, {})
end
elseif chance == 2 then
if self:canBe("stun") then
self:setEffect(self.EFF_STUNNED, 3, {})
end
elseif chance == 3 then
if self:canBe("confusion") then
self:setEffect(self.EFF_CONFUSED, 3, {power=30})
end
end
game.logSeen(self, "#F53CBE#%s succumbs to the nightmare!", self:getName():capitalize())
end
end,
}
newEffect{
name = "INNER_DEMONS", image = "talents/inner_demons.png",
desc = _t"Inner Demons",
long_desc = function(self, eff) return ("The target is plagued by inner demons and each turn there's a %d%% chance that one will appear. If the caster is killed or the target resists setting his demons loose the effect will end early."):tformat(eff.chance) end,
type = "mental",
subtype = { nightmare=true },
status = "detrimental",
remove_on_clone = true,
parameters = {chance=0},
on_gain = function(self, err) return _t"#F53CBE##Target# is plagued by inner demons!", _t"+Inner Demons" end,
on_lose = function(self, err) return _t"#Target# is freed from the demons.", _t"-Inner Demons" end,
activate = function(self, eff)
if core.shader.active() then
self:effectParticles(eff, {type="shader_shield", args={size_factor=1.5, img="inner_demons_tentacle_shader"}, shader={type="tentacles", wobblingType=0, appearTime=0.8, time_factor=2000, noup=0.0}})
end
end,
on_timeout = function(self, eff)
if eff.src.dead or not game.level:hasEntity(eff.src) then eff.dur = 0 return true end
local t = eff.src:getTalentFromId(eff.src.T_INNER_DEMONS)
local chance = eff.chance
if self:attr("sleep") then chance = 100-(100-chance)/2 end -- Half normal chance not to manifest
if rng.percent(chance) then
if self:attr("sleep") or self:checkHit(eff.src:combatMindpower(), self:combatMentalResist(), 0, 95, 5) then
t.summon_inner_demons(eff.src, self, t)
self:removeEffectsFilter(self, {subtype={["sleep"] = true}}, 3) -- Allow the player to actually react to one of the biggest threats in the game before 50 more spawn
else
eff.dur = 0
end
end
end,
}
newEffect{
name = "DOMINATE_ENTHRALL", image = "talents/yeek_will.png",
desc = _t"Enthralled",
long_desc = function(self, eff) return (_t"The target is enthralled, temporarily changing its faction.") end,-- to %s.")--:tformat(engine.Faction.factions[eff.faction].name) end,
type = "mental",
subtype = { dominate=true },
status = "detrimental",
parameters = {},
on_gain = function(self, err) return _t"#Target# is entralled.", _t"+Enthralled" end,
on_lose = function(self, err) return _t"#Target# is free from the domination.", _t"-Enthralled" end,
activate = function(self, eff)
eff.olf_faction = self.faction
self.faction = eff.src.faction
end,
deactivate = function(self, eff)
self.faction = eff.olf_faction
end,
}
newEffect{
name = "HALFLING_LUCK", image = "talents/halfling_luck.png",
desc = _t"Halflings's Luck",
long_desc = function(self, eff) return ("The target's luck and cunning combine to grant it %d%% higher critical chance and %d saves."):tformat(eff.crit, eff.save) end,
type = "mental",
subtype = { focus=true },
status = "beneficial",
parameters = { crit=10, save=10 },
on_gain = function(self, err) return _t"#Target# seems more aware." end,
on_lose = function(self, err) return _t"#Target#'s awareness returns to normal." end,
activate = function(self, eff)
self:effectTemporaryValue(eff, "combat_generic_crit", eff.crit)
self:effectTemporaryValue(eff, "combat_physresist", eff.save)
self:effectTemporaryValue(eff, "combat_spellresist", eff.save)
self:effectTemporaryValue(eff, "combat_mentalresist", eff.save)
end,
}
newEffect{
name = "ATTACK", image = "talents/perfect_strike.png",
desc = _t"Perfect Accuracy",
long_desc = function(self, eff) return ("The target's accuracy is improved by %d."):tformat(eff.power) end,
type = "mental",
subtype = { focus=true },
status = "beneficial",
parameters = { power=10 },
on_gain = function(self, err) return _t"#Target# aims carefully." end,
on_lose = function(self, err) return _t"#Target# aims less carefully." end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("combat_atk", eff.power)
eff.bid = self:addTemporaryValue("blind_fight", 1)
self:effectParticles(eff, {type="perfect_strike", args={radius=1}})
end,
deactivate = function(self, eff)
self:removeTemporaryValue("combat_atk", eff.tmpid)
self:removeTemporaryValue("blind_fight", eff.bid)
end,
}
newEffect{
name = "DEADLY_STRIKES", image = "talents/deadly_strikes.png",
desc = _t"Deadly Strikes",
long_desc = function(self, eff) return ("The target's armour penetration is increased by %d."):tformat(eff.power) end,
type = "mental",
subtype = { focus=true },
status = "beneficial",
parameters = { power=10 },
on_gain = function(self, err) return _t"#Target# aims carefully." end,
on_lose = function(self, err) return _t"#Target# aims less carefully." end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("combat_apr", eff.power)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("combat_apr", eff.tmpid)
end,
}
newEffect{
name = "FRENZY", image = "effects/frenzy.png",
desc = _t"Frenzy",
long_desc = function(self, eff) return ("Increases global action speed by %d%% and physical crit by %d%%.\nAdditionally the target will continue to fight until its Life reaches -%d%%."):tformat(eff.power * 100, eff.crit, eff.dieat * 100) end,
type = "mental",
subtype = { frenzy=true, speed=true },
status = "beneficial",
parameters = { power=0.1 },
on_gain = function(self, err) return _t"#Target# goes into a killing frenzy.", _t"+Frenzy" end,
on_lose = function(self, err) return _t"#Target# calms down.", _t"-Frenzy" end,
on_merge = function(self, old_eff, new_eff)
-- use on merge so reapplied frenzy doesn't kill off creatures with negative life
old_eff.dur = new_eff.dur
old_eff.power = new_eff.power
old_eff.crit = new_eff.crit
return old_eff
end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("global_speed_add", eff.power)
eff.critid = self:addTemporaryValue("combat_physcrit", eff.crit)
eff.dieatid = self:addTemporaryValue("die_at", -self.max_life * eff.dieat)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("global_speed_add", eff.tmpid)
self:removeTemporaryValue("combat_physcrit", eff.critid)
self:removeTemporaryValue("die_at", eff.dieatid)
-- check negative life first incase the creature has healing
if self.life <= (self.die_at or 0) then
local sx, sy = game.level.map:getTileToScreen(self.x, self.y, true)
game.flyers:add(sx, sy, 30, (rng.range(0,2)-1) * 0.5, rng.float(-2.5, -1.5), _t"Falls dead!", {255,0,255})
game.logSeen(self, "%s dies when its frenzy ends!", self:getName():capitalize())
self:die(self)
end
end,
}
newEffect{
name = "BLOODBATH", image = "talents/bloodbath.png",
desc = _t"Bloodbath",
long_desc = function(self, eff) return ("The thrill of combat improves the target's maximum life by %d%%, life regeneration by %0.2f, and stamina regeneration by %0.2f."):tformat(eff.hp, eff.cur_regen or eff.regen, eff.cur_regen/5 or eff.regen/5) end,
type = "mental",
subtype = { frenzy=true, heal=true, regeneration=true, },
status = "beneficial",
parameters = { hp=10, regen=10, max=50 },
on_gain = function(self, err) return nil, _t"+Bloodbath" end,
on_lose = function(self, err) return nil, _t"-Bloodbath" end,
on_merge = function(self, old_eff, new_eff)
if old_eff.cur_regen + new_eff.regen < new_eff.max then game.logSeen(self, "%s's blood frenzy intensifies!", self:getName():capitalize()) end
new_eff.templife_id = old_eff.templife_id
self:removeTemporaryValue("max_life", old_eff.life_id)
self:removeTemporaryValue("life_regen", old_eff.life_regen_id)
self:removeTemporaryValue("stamina_regen", old_eff.stamina_regen_id)
new_eff.particle1 = old_eff.particle1
new_eff.particle2 = old_eff.particle2
-- Take the new values, dont heal, otherwise you get a free heal each crit .. which is totaly broken
local v = new_eff.hp * self.max_life / 100
new_eff.life_id = self:addTemporaryValue("max_life", v)
new_eff.cur_regen = math.min(old_eff.cur_regen + new_eff.regen, new_eff.max)
new_eff.life_regen_id = self:addTemporaryValue("life_regen", new_eff.cur_regen)
new_eff.stamina_regen_id = self:addTemporaryValue("stamina_regen", new_eff.cur_regen/5)
return new_eff
end,
activate = function(self, eff)
local v = eff.hp * self.max_life / 100
eff.life_id = self:addTemporaryValue("max_life", v)
eff.templife_id = self:addTemporaryValue("life",v) -- Prevent healing_factor affecting activation
eff.cur_regen = eff.regen
eff.life_regen_id = self:addTemporaryValue("life_regen", eff.regen)
eff.stamina_regen_id = self:addTemporaryValue("stamina_regen", eff.regen /5)
game.logSeen(self, "%s revels in the spilt blood and grows stronger!",self:getName():capitalize())
if core.shader.active(4) then
eff.particle1 = self:addParticles(Particles.new("shader_shield", 1, {toback=true, size_factor=1.5, y=-0.3, img="healarcane"}, {type="healing", time_factor=4000, noup=2.0, beamColor1={0xff/255, 0x22/255, 0x22/255, 1}, beamColor2={0xff/255, 0x60/255, 0x60/255, 1}, circleColor={0,0,0,0}, beamsCount=8}))
eff.particle2 = self:addParticles(Particles.new("shader_shield", 1, {toback=false, size_factor=1.5, y=-0.3, img="healarcane"}, {type="healing", time_factor=4000, noup=1.0, beamColor1={0xff/255, 0x22/255, 0x22/255, 1}, beamColor2={0xff/255, 0x60/255, 0x60/255, 1}, circleColor={0,0,0,0}, beamsCount=8}))
end
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle1)
self:removeParticles(eff.particle2)
self:removeTemporaryValue("max_life", eff.life_id)
self:removeTemporaryValue("life_regen", eff.life_regen_id)
self:removeTemporaryValue("stamina_regen", eff.stamina_regen_id)
self:removeTemporaryValue("life",eff.templife_id) -- remove extra hps to prevent excessive heals at high level
game.logSeen(self, "%s no longer revels in blood quite so much.",self:getName():capitalize())
end,
}
newEffect{
name = "BLOODRAGE", image = "talents/bloodrage.png",
desc = _t"Bloodrage",
long_desc = function(self, eff) return ("The target's strength is increased by %d by the thrill of combat."):tformat(eff.cur_inc) end,
type = "mental",
subtype = { frenzy=true },
status = "beneficial",
parameters = { inc=1, max=10 },
on_merge = function(self, old_eff, new_eff)
self:removeTemporaryValue("inc_stats", old_eff.tmpid)
old_eff.cur_inc = math.min(old_eff.cur_inc + new_eff.inc, new_eff.max)
old_eff.tmpid = self:addTemporaryValue("inc_stats", {[Stats.STAT_STR] = old_eff.cur_inc})
old_eff.dur = new_eff.dur
return old_eff
end,
activate = function(self, eff)
eff.cur_inc = eff.inc
eff.tmpid = self:addTemporaryValue("inc_stats", {[Stats.STAT_STR] = eff.inc})
end,
deactivate = function(self, eff)
self:removeTemporaryValue("inc_stats", eff.tmpid)
end,
}
newEffect{
name = "INCREASED_LIFE", image = "effects/increased_life.png",
desc = _t"Increased Life",
long_desc = function(self, eff) return ("The target's maximum life is increased by %d."):tformat(eff.life) end,
type = "mental",
subtype = { frenzy=true, heal=true },
status = "beneficial",
on_gain = function(self, err) return _t"#Target# gains extra life.", _t"+Life" end,
on_lose = function(self, err) return _t"#Target# loses extra life.", _t"-Life" end,
parameters = { life = 50 },
activate = function(self, eff)
self.max_life = self.max_life + eff.life
self.life = self.life + eff.life
self.changed = true
end,
deactivate = function(self, eff)
self.max_life = self.max_life - eff.life
self.life = self.life - eff.life
self.changed = true
if self.life <= 0 then
self.life = 1
self:setEffect(self.EFF_STUNNED, 3, {})
game.logSeen(self, "%s's increased life fades, leaving it stunned by the loss.", self:getName():capitalize())
end
end,
}
newEffect{
name = "GESTURE_OF_GUARDING", image = "talents/gesture_of_guarding.png",
desc = _t"Guarded",
long_desc = function(self, eff)
local xs = ""
local dam, deflects = eff.dam, eff.deflects
if deflects < 1 then -- Partial deflect has reduced effectiveness
dam = dam*math.max(0,deflects)
deflects = 1
end
if self:isTalentActive(self.T_GESTURE_OF_PAIN) then xs = (" with a %d%% chance to counterattack"):tformat(self:callTalent(self.T_GESTURE_OF_GUARDING,"getCounterAttackChance")) end
return ("Guarding against melee damage: Will dismiss up to %d damage from the next %0.1f attack(s)%s."):tformat(dam, deflects, xs)
end,
charges = function(self, eff) return _t"#LIGHT_GREEN#"..math.ceil(eff.deflects) end,
type = "mental",
subtype = { curse=true },
status = "beneficial",
decrease = 0,
no_stop_enter_worlmap = true, no_stop_resting = true,
parameters = {dam = 1, deflects = 1},
activate = function(self, eff)
eff.dam = self:callTalent(self.T_GESTURE_OF_GUARDING,"getDamageChange")
eff.deflects = self:callTalent(self.T_GESTURE_OF_GUARDING,"getDeflects")
if eff.dam <= 0 or eff.deflects <= 0 then eff.dur = 0 end
end,
deactivate = function(self, eff)
end,
}
newEffect{
name = "RAMPAGE", image = "talents/rampage.png",
desc = _t"Rampaging",
long_desc = function(self, eff)
local desc = ("The target is rampaging! (+%d%% movement speed, +%d%% attack speed, +%d%% mind speed"):tformat(eff.movementSpeedChange * 100, eff.combatPhysSpeedChange * 100, eff.combatMindSpeedChange * 100)
if eff.physicalDamageChange > 0 then
desc = desc..(", +%d%% physical damage, +%d physical save, +%d mental save"):tformat(eff.physicalDamageChange, eff.combatPhysResistChange, eff.combatMentalResistChange)
end
if eff.damageShieldMax > 0 then
desc = desc..(", %d/%d damage shrugged off this turn"):tformat(math.max(0, eff.damageShieldMax - eff.damageShield), eff.damageShieldMax)
end
desc = desc..")"
return desc
end,
type = "mental",
subtype = { frenzy=true, speed=true, evade=true },
status = "beneficial",
parameters = { },
on_gain = function(self, err) return _t"#F53CBE##Target# begins rampaging!", _t"+Rampage" end,
on_lose = function(self, err) return _t"#F53CBE##Target# is no longer rampaging.", _t"-Rampage" end,
activate = function(self, eff)
if eff.movementSpeedChange or 0 > 0 then eff.movementSpeedId = self:addTemporaryValue("movement_speed", eff.movementSpeedChange) end
if eff.combatPhysSpeedChange or 0 > 0 then eff.combatPhysSpeedId = self:addTemporaryValue("combat_physspeed", eff.combatPhysSpeedChange) end
if eff.combatMindSpeedChange or 0 > 0 then eff.combatMindSpeedId = self:addTemporaryValue("combat_mindspeed", eff.combatMindSpeedChange) end
if eff.physicalDamageChange or 0 > 0 then eff.physicalDamageId = self:addTemporaryValue("inc_damage", { [DamageType.PHYSICAL] = eff.physicalDamageChange }) end
if eff.combatPhysResistChange or 0 > 0 then eff.combatPhysResistId = self:addTemporaryValue("combat_physresist", eff.combatPhysResistChange) end
if eff.combatMentalResistChange or 0 > 0 then eff.combatMentalResistId = self:addTemporaryValue("combat_mentalresist", eff.combatMentalResistChange) end
if not self:addShaderAura("rampage", "awesomeaura", {time_factor=5000, alpha=0.7}, "particles_images/bloodwings.png") then
eff.particle = self:addParticles(Particles.new("rampage", 1))
end
end,
deactivate = function(self, eff)
if eff.movementSpeedId then self:removeTemporaryValue("movement_speed", eff.movementSpeedId) end
if eff.combatPhysSpeedId then self:removeTemporaryValue("combat_physspeed", eff.combatPhysSpeedId) end
if eff.combatMindSpeedId then self:removeTemporaryValue("combat_mindspeed", eff.combatMindSpeedId) end
if eff.physicalDamageId then self:removeTemporaryValue("inc_damage", eff.physicalDamageId) end
if eff.combatPhysResistId then self:removeTemporaryValue("combat_physresist", eff.combatPhysResistId) end
if eff.combatMentalResistId then self:removeTemporaryValue("combat_mentalresist", eff.combatMentalResistId) end
self:removeShaderAura("rampage")
self:removeParticles(eff.particle)
end,
on_timeout = function(self, eff)
-- restore damage shield
if eff.damageShieldMax and eff.damageShield ~= eff.damageShieldMax and not self.dead then
eff.damageShieldUsed = (eff.damageShieldUsed or 0) + eff.damageShieldMax - eff.damageShield
game.logSeen(self, "%s has shrugged off %d damage and is ready for more.", self:getName():capitalize(), eff.damageShieldMax - eff.damageShield)
eff.damageShield = eff.damageShieldMax
if eff.damageShieldBonus and eff.damageShieldUsed >= eff.damageShieldBonus and eff.actualDuration < eff.maxDuration then
eff.actualDuration = eff.actualDuration + 1
eff.dur = eff.dur + 1
eff.damageShieldBonus = nil
game.logPlayer(self, "#F53CBE#Your rampage is invigorated by the intense onslaught! (+1 duration)")
end
end
end,
callbackOnHit = function(self, eff, cb, src)
if not eff.damageShieldMax or eff.damageShield <= 0 then return end
local absorb = math.min(eff.damageShield, cb.value)
eff.damageShield = eff.damageShield - absorb
cb.value = cb.value - absorb
game:delayedLogDamage(src, self, 0, ("#RED#(%d rampage shugs off#LAST#)"):tformat(absorb), false)
--game.logSeen(self, "%s shrugs off %d damage.", self:getName():capitalize(), absorb)
return true
end,
do_postUseTalent = function(self, eff)
if eff.dur > 0 then
eff.dur = eff.dur - 1
game.logPlayer(self, "#F53CBE#You feel your rampage slowing down. (-1 duration)")
end
end,
}
newEffect{
name = "ORC_FURY", image = "talents/orc_fury.png",
desc = _t"Orcish Fury",
long_desc = function(self, eff) return ("The target enters a destructive fury, increasing all damage done by %d%%."):tformat(eff.power) end,
type = "mental",
subtype = { frenzy=true },
status = "beneficial",
parameters = { power=10 },
on_gain = function(self, err) return _t"#Target# enters a state of bloodlust." end,
on_lose = function(self, err) return _t"#Target# calms down." end,
activate = function(self, eff)
eff.pid = self:addTemporaryValue("inc_damage", {all=eff.power})
end,
deactivate = function(self, eff)
self:removeTemporaryValue("inc_damage", eff.pid)
end,
}
newEffect{
name = "ORC_TRIUMPH", image = "talents/skirmisher.png",
desc = _t"Orcish Triumph",
long_desc = function(self, eff) return ("Inspired by a recent kill increasing all resistance by %d%%."):tformat(eff.resists) end,
type = "mental",
subtype = { frenzy=true },
status = "beneficial",
parameters = { resists=10 },
on_gain = function(self, err) return _t"#Target# roars triumphantly." end, -- Too spammy?
on_lose = function(self, err) return _t"#Target# is no longer inspired." end,
activate = function(self, eff)
eff.pid = self:addTemporaryValue("resists", {all=eff.resists})
end,
deactivate = function(self, eff)
self:removeTemporaryValue("resists", eff.pid)
end,
}
newEffect{
name = "BRAINLOCKED",
desc = _t"Brainlocked",
long_desc = function(self, eff) return ("Renders a random talent unavailable. Talent cooldown is halved until the effect has worn off."):tformat() end,
type = "mental",
subtype = { ["cross tier"]=true },
status = "detrimental",
parameters = {},
on_gain = function(self, err) return nil, _t"+Brainlocked" end,
on_lose = function(self, err) return nil, _t"-Brainlocked" end,
activate = function(self, eff)
eff.tcdid = self:addTemporaryValue("half_talents_cooldown", 1)
local tids = {}
for tid, lev in pairs(self.talents) do
local t = self:getTalentFromId(tid)
if t and not self.talents_cd[tid] and t.mode == "activated" and not t.innate and not t.no_energy then tids[#tids+1] = t end
end
for i = 1, 1 do
local t = rng.tableRemove(tids)
if not t then break end
self.talents_cd[t.id] = 1
end
end,
deactivate = function(self, eff)
self:removeTemporaryValue("half_talents_cooldown", eff.tcdid)
end,
}
newEffect{
name = "FRANTIC_SUMMONING", image = "talents/frantic_summoning.png",
desc = _t"Frantic Summoning",
long_desc = function(self, eff) return ("Reduces the time taken for summoning by %d%%."):tformat(eff.power) end,
type = "mental",
subtype = { summon=true },
status = "beneficial",
on_gain = function(self, err) return _t"#Target# starts summoning at high speed.", _t"+Frantic Summoning" end,
on_lose = function(self, err) return _t"#Target#'s frantic summoning ends.", _t"-Frantic Summoning" end,
parameters = { power=20 },
activate = function(self, eff)
eff.failid = self:addTemporaryValue("no_equilibrium_summon_fail", 1)
eff.speedid = self:addTemporaryValue("fast_summons", eff.power)
-- Find a cooling down summon talent and enable it
local list = {}
for tid, dur in pairs(self.talents_cd) do
local t = self:getTalentFromId(tid)
if t.is_summon then
list[#list+1] = t
end
end
if #list > 0 then
local t = rng.table(list)
self.talents_cd[t.id] = nil
if self.onTalentCooledDown then self:onTalentCooledDown(t.id) end
end
end,
deactivate = function(self, eff)
self:removeTemporaryValue("no_equilibrium_summon_fail", eff.failid)
self:removeTemporaryValue("fast_summons", eff.speedid)
end,
}
newEffect{
name = "WILD_SUMMON", image = "talents/wild_summon.png",
desc = _t"Wild Summon",
long_desc = function(self, eff) return ("%d%% chance to get a more powerful summon."):tformat(eff.chance) end,
type = "mental",
subtype = { summon=true },
status = "beneficial",
parameters = { chance=100 },
activate = function(self, eff)
eff.tid = self:addTemporaryValue("wild_summon", eff.chance)
end,
on_timeout = function(self, eff)
eff.chance = eff.chance or 100
eff.chance = math.floor(eff.chance * 0.66)
self:removeTemporaryValue("wild_summon", eff.tid)
eff.tid = self:addTemporaryValue("wild_summon", eff.chance)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("wild_summon", eff.tid)
end,
}
newEffect{
name = "LOBOTOMIZED", image = "talents/psychic_lobotomy.png",
desc = _t"Lobotomized (confused)",
long_desc = function(self, eff) return ("The target's mental faculties have been severely impaired, making it act randomly each turn (%d%% chance) and reducing its cunning by %d."):tformat(eff.confuse, eff.power/2) end,
type = "mental",
subtype = { confusion=true },
status = "detrimental",
charges = function(self, eff) return (tostring(math.floor(eff.confuse)).."%") end,
on_gain = function(self, err) return _t"#Target# higher mental functions have been imparied.", _t"+Lobotomized" end,
on_lose = function(self, err) return _t"#Target#'s regains its senses.", _t"-Lobotomized" end,
parameters = { power=1, confuse=10, dam=1 },
activate = function(self, eff)
DamageType:get(DamageType.MIND).projector(eff.src or self, self.x, self.y, DamageType.MIND, {dam=eff.dam, alwaysHit=true})
eff.confuse = math.floor(util.bound(eff.confuse, 0, 50)) -- Confusion cap of 50%
eff.tmpid = self:addTemporaryValue("confused", eff.confuse)
eff.cid = self:addTemporaryValue("inc_stats", {[Stats.STAT_CUN]=-eff.power/2})
if eff.power <= 0 then eff.dur = 0 end
eff.particles = self:addParticles(engine.Particles.new("generic_power", 1, {rm=100, rM=125, gm=100, gM=125, bm=100, bM=125, am=200, aM=255}))
end,
deactivate = function(self, eff)
self:removeTemporaryValue("confused", eff.tmpid)
self:removeTemporaryValue("inc_stats", eff.cid)
if eff.particles then self:removeParticles(eff.particles) end
if self == game.player and self.updateMainShader then self:updateMainShader() end
end,
}
newEffect{
name = "PSIONIC_SHIELD", image = "talents/kinetic_shield.png",
desc = _t"Psionic Shield",
display_desc = function(self, eff) return ("%s Psionic Shield"):tformat(_t(eff.kind):capitalize()) end,
long_desc = function(self, eff) return ("Reduces all incoming %s damage by %d."):tformat(eff.what, eff.power) end,
type = "mental",
subtype = { psionic=true },
status = "beneficial",
parameters = { power=10, kind="kinetic" },
activate = function(self, eff)
if eff.kind == "kinetic" then
eff.sid = self:addTemporaryValue("flat_damage_armor", {
[DamageType.PHYSICAL] = eff.power,
[DamageType.ACID] = eff.power,
[DamageType.NATURE] = eff.power,
[DamageType.TEMPORAL] = eff.power,
})
eff.what = _t"physical, nature, acid, temporal"
elseif eff.kind == "thermal" then
eff.sid = self:addTemporaryValue("flat_damage_armor", {
[DamageType.FIRE] = eff.power,
[DamageType.COLD] = eff.power,
[DamageType.LIGHT] = eff.power,
[DamageType.ARCANE] = eff.power,
})
eff.what = _t"fire, cold, light, arcane"
elseif eff.kind == "charged" then
eff.sid = self:addTemporaryValue("flat_damage_armor", {
[DamageType.LIGHTNING] = eff.power,
[DamageType.BLIGHT] = eff.power,
[DamageType.MIND] = eff.power,
[DamageType.DARKNESS] = eff.power,
})
eff.what = _t"lightning, blight, mind, darkness"
elseif eff.kind == "all" then
eff.sid = self:addTemporaryValue("flat_damage_armor", {
all = eff.power,
})
eff.what = _t"all"
end
end,
deactivate = function(self, eff)
if eff.sid then
self:removeTemporaryValue("flat_damage_armor", eff.sid)
end
end,
}
newEffect{
name = "CLEAR_MIND", image = "talents/mental_shielding.png",
desc = _t"Clear Mind",
long_desc = function(self, eff) return ("Nullifies the next %d detrimental mental effects."):tformat(self.clear_mind_immune) end,
type = "mental",
subtype = { psionic=true, },
status = "beneficial",
parameters = { power=2 },
activate = function(self, eff)
self.clear_mind_immune = eff.power
eff.particles = self:addParticles(engine.Particles.new("generic_power", 1, {rm=0, rM=0, gm=100, gM=180, bm=180, bM=255, am=200, aM=255}))
end,
deactivate = function(self, eff)
self.clear_mind_immune = nil
self:removeParticles(eff.particles)
end,
}
newEffect{
name = "RESONANCE_FIELD", image = "talents/resonance_field.png",
desc = _t"Resonance Field",
long_desc = function(self, eff) return ("The target is surrounded by a psychic field, absorbing 50%% of all damage (up to %d/%d)."):tformat(self.resonance_field_absorb, eff.power) end,
type = "mental",
subtype = { psionic=true, shield=true },
status = "beneficial",
parameters = { power=100 },
on_gain = function(self, err) return _t"A psychic field forms around #target#.", _t"+Resonance Shield" end,
on_lose = function(self, err) return _t"The psychic field around #target# crumbles.", _t"-Resonance Shield" end,
damage_feedback = function(self, eff, src, value)
if eff.particle and eff.particle._shader and eff.particle._shader.shad and src and src.x and src.y then
local r = -rng.float(0.2, 0.4)
local a = math.atan2(src.y - self.y, src.x - self.x)
eff.particle._shader:setUniform("impact", {math.cos(a) * r, math.sin(a) * r})
eff.particle._shader:setUniform("impact_tick", core.game.getTime())
end
end,
activate = function(self, eff)
self.resonance_field_absorb = eff.power
eff.sid = self:addTemporaryValue("resonance_field", eff.power)
if core.shader.active(4) then
eff.particle = self:addParticles(Particles.new("shader_shield", 1, {size_factor=1.1}, {type="shield", time_factor=-8000, llpow=1, aadjust=7, color={1, 1, 0}}))
-- eff.particle = self:addParticles(Particles.new("shader_shield", 1, {img="shield2", size_factor=1.25}, {type="shield", time_factor=6000, color={1, 1, 0}}))
else
eff.particle = self:addParticles(Particles.new("generic_shield", 1, {r=1, g=1, b=0, a=1}))
end
end,
deactivate = function(self, eff)
self.resonance_field_absorb = nil
self:removeParticles(eff.particle)
self:removeTemporaryValue("resonance_field", eff.sid)
end,
}
newEffect{
name = "MIND_LINK_TARGET", image = "talents/mind_link.png",
desc = _t"Mind Link",
long_desc = function(self, eff) return ("The target's mind has been invaded, increasing all mind damage it receives from %s by %d%%."):tformat(eff.src:getName():capitalize(), eff.power) end,
type = "mental",
subtype = { psionic=true },
status = "detrimental",
parameters = {power = 1, range = 5},
remove_on_clone = true, decrease = 0,
on_gain = function(self, err) return _t"#Target#'s mind has been invaded!", _t"+Mind Link" end,
on_lose = function(self, err) return _t"#Target# is free from the mental invasion.", _t"-Mind Link" end,
on_timeout = function(self, eff)
-- Remove the mind link when appropriate
local p = eff.src:isTalentActive(eff.src.T_MIND_LINK)
if not p or p.target ~= self or eff.src.dead or not game.level:hasEntity(eff.src) or core.fov.distance(self.x, self.y, eff.src.x, eff.src.y) > eff.range then
self:removeEffect(self.EFF_MIND_LINK_TARGET)
end
end,
}
newEffect{
name = "FEEDBACK_LOOP", image = "talents/feedback_loop.png",
desc = _t"Feedback Loop",
long_desc = function(self, eff) return _t"The target is gaining feedback." end,
type = "mental",
subtype = { psionic=true },
status = "beneficial",
parameters = { power = 1 },
on_gain = function(self, err) return _t"#Target# is gaining feedback.", _t"+Feedback Loop" end,
on_lose = function(self, err) return _t"#Target# is no longer gaining feedback.", _t"-Feedback Loop" end,
activate = function(self, eff)
eff.particle = self:addParticles(Particles.new("ultrashield", 1, {rm=255, rM=255, gm=180, gM=255, bm=0, bM=0, am=35, aM=90, radius=0.2, density=15, life=28, instop=40}))
end,
deactivate = function(self, eff)
self:removeParticles(eff.particle)
end,
}
newEffect{
name = "FOCUSED_WRATH", image = "talents/focused_wrath.png",
desc = _t"Focused Wrath",
long_desc = function(self, eff) return ("The target's subconscious has focused, increasing Mind resistance penetration by +%d%% and turning its attention on %s."):tformat(eff.pen, eff.target:getName():capitalize()) end,
type = "mental",
subtype = { psionic=true },
status = "beneficial",
parameters = { power = 1 },
on_gain = function(self, err) return _t"#Target#'s subconscious has been focused.", _t"+Focused Wrath" end,
on_lose = function(self, err) return _t"#Target#'s subconscious has returned to normal.", _t"-Focused Wrath" end,
activate = function(self, eff)
self:effectTemporaryValue(eff, "resists_pen", {[DamageType.MIND]=eff.pen})
end,
on_timeout = function(self, eff)
if not eff.target or eff.target.dead or not game.level:hasEntity(eff.target) then
self:removeEffect(self.EFF_FOCUSED_WRATH)
end
end,
}
newEffect{
name = "SLEEP", image = "talents/sleep.png",
desc = _t"Sleep",
long_desc = function(self, eff) return ("The target is asleep and unable to perform most actions. Every %d damage it takes will reduce the duration of the effect by one turn."):tformat(eff.power) end,
type = "mental",
subtype = { sleep=true },
status = "detrimental",
parameters = { power=1, insomnia=1, waking=0, contagious=0 },
on_gain = function(self, err) return _t"#Target# has been put to sleep.", _t"+Sleep" end,
on_lose = function(self, err) return _t"#Target# is no longer sleeping.", _t"-Sleep" end,
on_timeout = function(self, eff)
local dream_prison = false
if eff.src and eff.src.isTalentActive and eff.src:isTalentActive(eff.src.T_DREAM_PRISON) then
local t = eff.src:getTalentFromId(eff.src.T_DREAM_PRISON)
if core.fov.distance(self.x, self.y, eff.src.x, eff.src.y) <= eff.src:getTalentRange(t) then
dream_prison = true
end
end
if dream_prison then
eff.dur = eff.dur + 1
if not eff.particle then
if core.shader.active(4) then
eff.particle = self:addParticles(Particles.new("shader_shield", 1, {img="shield2", size_factor=1.25}, {type="shield", time_factor=6000, aadjust=5, color={0, 1, 1}}))
else
eff.particle = self:addParticles(Particles.new("generic_shield", 1, {r=0, g=1, b=1, a=1}))
end
end
elseif eff.contagious > 0 and eff.dur > 1 then
local t = eff.src:getTalentFromId(eff.src.T_SLEEP)
t.doContagiousSleep(eff.src, self, eff, t)
end
if eff.particle and not dream_prison then
self:removeParticles(eff.particle)
end
-- Incriment Insomnia Duration
if not self:attr("lucid_dreamer") then
self:setEffect(self.EFF_INSOMNIA, 1, {power=eff.insomnia})
end
end,
activate = function(self, eff)
eff.sid = self:addTemporaryValue("sleep", 1)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("sleep", eff.sid)
if not self:attr("sleep") and not self.dead and game.level:hasEntity(self) and eff.waking > 0 then
local t = eff.src:getTalentFromId(self.T_RESTLESS_NIGHT)
t.doRestlessNight(eff.src, self, eff.waking)
end
if eff.particle then
self:removeParticles(eff.particle)
end
end,
}
newEffect{
name = "SLUMBER", image = "talents/slumber.png",
desc = _t"Slumber",
long_desc = function(self, eff) return ("The target is in a deep sleep and unable to perform most actions. Every %d damage it takes will reduce the duration of the effect by one turn."):tformat(eff.power) end,
type = "mental",
subtype = { sleep=true },
status = "detrimental",
parameters = { power=1, insomnia=1, waking=0 },
on_gain = function(self, err) return _t"#Target# is in a deep sleep.", _t"+Slumber" end,
on_lose = function(self, err) return _t"#Target# is no longer sleeping.", _t"-Slumber" end,
on_timeout = function(self, eff)
local dream_prison = false
if eff.src and eff.src.isTalentActive and eff.src:isTalentActive(eff.src.T_DREAM_PRISON) then
local t = eff.src:getTalentFromId(eff.src.T_DREAM_PRISON)
if core.fov.distance(self.x, self.y, eff.src.x, eff.src.y) <= eff.src:getTalentRange(t) then
dream_prison = true
end
end
if dream_prison then
eff.dur = eff.dur + 1
if not eff.particle then
if core.shader.active(4) then
eff.particle = self:addParticles(Particles.new("shader_shield", 1, {img="shield2", size_factor=1.25}, {type="shield", time_factor=6000, aadjust=5, color={0, 1, 1}}))
else
eff.particle = self:addParticles(Particles.new("generic_shield", 1, {r=0, g=1, b=1, a=1}))
end
end
elseif eff.particle and not dream_prison then
self:removeParticles(eff.particle)
end
-- Incriment Insomnia Duration
if not self:attr("lucid_dreamer") then
self:setEffect(self.EFF_INSOMNIA, 1, {power=eff.insomnia})
end
end,
activate = function(self, eff)
eff.sid = self:addTemporaryValue("sleep", 1)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("sleep", eff.sid)
if not self:attr("sleep") and not self.dead and game.level:hasEntity(self) and eff.waking > 0 then
local t = eff.src:getTalentFromId(self.T_RESTLESS_NIGHT)
t.doRestlessNight(eff.src, self, eff.waking)
end
if eff.particle then
self:removeParticles(eff.particle)
end
end,
}
newEffect{
name = "NIGHTMARE", image = "talents/nightmare.png",
desc = _t"Nightmare",
long_desc = function(self, eff) return ("The target is in a nightmarish sleep, suffering %0.2f darkness damage each turn and unable to to perform most actions. Every %d damage it takes will reduce the duration of the effect by one turn."):tformat(eff.dam, eff.power) end,
type = "mental",
subtype = { nightmare=true, sleep=true },
status = "detrimental",
parameters = { power=1, dam=0, insomnia=1, waking=0},
on_gain = function(self, err) return _t"#F53CBE##Target# is lost in a nightmare.", _t"+Nightmare" end,
on_lose = function(self, err) return _t"#Target# is free from the nightmare.", _t"-Nightmare" end,
on_timeout = function(self, eff)
local dream_prison = false
if eff.src and eff.src.isTalentActive and eff.src:isTalentActive(eff.src.T_DREAM_PRISON) then
local t = eff.src:getTalentFromId(eff.src.T_DREAM_PRISON)
if core.fov.distance(self.x, self.y, eff.src.x, eff.src.y) <= eff.src:getTalentRange(t) then
dream_prison = true
end
end
if dream_prison then
eff.dur = eff.dur + 1
if not eff.particle then
if core.shader.active(4) then
eff.particle = self:addParticles(Particles.new("shader_shield", 1, {img="shield2", size_factor=1.25}, {type="shield", aadjust=5, color={0, 1, 1}}))
else
eff.particle = self:addParticles(Particles.new("generic_shield", 1, {r=0, g=1, b=1, a=1}))
end
end
else
-- Store the power for later
local real_power = eff.temp_power or eff.power
-- Temporarily spike the temp_power so the nightmare doesn't break it
eff.temp_power = 10000
DamageType:get(DamageType.DARKNESS).projector(eff.src or self, self.x, self.y, DamageType.DARKNESS, eff.dam)
-- Set the power back to its baseline
eff.temp_power = real_power
end
if eff.particle and not dream_prison then
self:removeParticles(eff.particle)
end
-- Incriment Insomnia Duration
if not self:attr("lucid_dreamer") then
self:setEffect(self.EFF_INSOMNIA, 1, {power=eff.insomnia})
end
end,
activate = function(self, eff)
eff.sid = self:addTemporaryValue("sleep", 1)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("sleep", eff.sid)
if not self:attr("sleep") and not self.dead and game.level:hasEntity(self) and eff.waking > 0 then
local t = eff.src:getTalentFromId(self.T_RESTLESS_NIGHT)
t.doRestlessNight(eff.src, self, eff.waking)
end
if eff.particle then
self:removeParticles(eff.particle)
end
end,
}
newEffect{
name = "RESTLESS_NIGHT", image = "talents/restless_night.png",
desc = _t"Restless Night",
long_desc = function(self, eff) return ("Fatigue from poor sleep, dealing %0.2f mind damage per turn."):tformat(eff.power) end,
type = "mental",
subtype = { psionic=true},
status = "detrimental",
parameters = { power=1 },
on_gain = function(self, err) return _t"#Target# had a restless night.", _t"+Restless Night" end,
on_lose = function(self, err) return _t"#Target# has recovered from poor sleep.", _t"-Restless Night" end,
on_merge = function(self, old_eff, new_eff)
-- Merge the flames!
local olddam = old_eff.power * old_eff.dur
local newdam = new_eff.power * new_eff.dur
local dur = math.ceil((old_eff.dur + new_eff.dur) / 2)
old_eff.dur = dur
old_eff.power = (olddam + newdam) / dur
return old_eff
end,
on_timeout = function(self, eff)
DamageType:get(DamageType.MIND).projector(eff.src or self, self.x, self.y, DamageType.MIND, eff.power)
end,
}
newEffect{
name = "INSOMNIA", image = "effects/insomnia.png",
desc = _t"Insomnia",
long_desc = function(self, eff) return ("The target is wide awake and has %d%% resistance to sleep effects."):tformat(eff.cur_power) end,
type = "mental",
subtype = { psionic=true },
status = "beneficial",
parameters = { power=0 },
on_gain = function(self, err) return _t"#Target# is suffering from insomnia.", _t"+Insomnia" end,
on_lose = function(self, err) return _t"#Target# is no longer suffering from insomnia.", _t"-Insomnia" end,
on_merge = function(self, old_eff, new_eff)
-- Add the durations on merge
local dur = old_eff.dur + new_eff.dur
old_eff<