Project Alice
Loading...
Searching...
No Matches
fif_triggers.cpp
Go to the documentation of this file.
1#include "triggers.hpp"
2#include "system_state.hpp"
3#include "demographics.hpp"
6#include "prng.hpp"
10#include "fif.hpp"
11#include "fif_common.hpp"
12
13namespace fif_trigger {
14using namespace fif;
15
16#ifdef WIN32
17#define CALLTYPE __vectorcall
18#else
19#define CALLTYPE
20#endif
21
22[[nodiscard]] std::string compare_values(uint16_t trigger_code) {
23 switch(trigger_code & trigger::association_mask) {
25 return " = ";
27 return " > ";
29 return " < ";
31 return " <= ";
33 return " <> ";
35 return " >= ";
36 default:
37 return " >= ";
38 }
39}
40
41[[nodiscard]] std::string compare_values_eq(uint16_t trigger_code) {
42 switch(trigger_code & trigger::association_mask) {
44 return " = ";
46 return " <> ";
48 return " <> ";
50 return " = ";
52 return " <> ";
54 return " = ";
55 default:
56 return " = ";
57 }
58}
59[[nodiscard]] std::string truth_inversion(uint16_t trigger_code) {
60 switch(trigger_code & trigger::association_mask) {
62 return "";
64 return "not ";
66 return "not ";
68 return "";
70 return "not ";
72 return "";
73 default:
74 return "";
75 }
76}
77
78float read_float_from_payload(uint16_t const* data) {
79 union {
80 struct {
81 uint16_t low;
82 uint16_t high;
83 } v;
84 float f;
85 } pack_float;
86
87 pack_float.v.low = data[0];
88 pack_float.v.high = data[1];
89
90 return pack_float.f;
91}
92int32_t read_int32_t_from_payload(uint16_t const* data) {
93 union {
94 struct {
95 uint16_t low;
96 uint16_t high;
97 } v;
98 int32_t f;
99 } pack_float;
100
101 pack_float.v.low = data[0];
102 pack_float.v.high = data[1];
103
104 return pack_float.f;
105}
106
107std::string CALLTYPE test_trigger_generic(uint16_t const* tval, sys::state& ws);
108#define TRIGGER_FUNCTION(function_name) std::string CALLTYPE function_name(uint16_t const* tval, sys::state& ws)
109
110TRIGGER_FUNCTION(apply_disjuctively) {
111 auto const source_size = 1 + trigger::get_trigger_scope_payload_size(tval);
112 auto sub_units_start = tval + 2 + trigger::trigger_scope_data_payload(tval[0]);
113
114 std::string result = "false >r ";
115 while(sub_units_start < tval + source_size) {
116 result += test_trigger_generic(sub_units_start, ws);
117 result += "r> or >r ";
118 sub_units_start += 1 + trigger::get_trigger_payload_size(sub_units_start);
119 }
120 result += "r> ";
121 return result;
122}
123
124TRIGGER_FUNCTION(apply_conjuctively) {
125 auto const source_size = 1 + trigger::get_trigger_scope_payload_size(tval);
126 auto sub_units_start = tval + 2 + trigger::trigger_scope_data_payload(tval[0]);
127
128 std::string result = "true >r ";
129 while(sub_units_start < tval + source_size) {
130 result += test_trigger_generic(sub_units_start, ws);
131 result += "r> and >r ";
132 sub_units_start += 1 + trigger::get_trigger_payload_size(sub_units_start);
133 }
134 result += "r> ";
135 return result;
136}
137
138TRIGGER_FUNCTION(apply_subtriggers) {
139 if((*tval & trigger::is_disjunctive_scope) != 0)
140 return apply_disjuctively(tval, ws);
141 else
142 return apply_conjuctively(tval, ws);
143}
144
146 return "true ";
147}
148TRIGGER_FUNCTION(tf_unused_1) {
149 return "true ";
150}
151
152TRIGGER_FUNCTION(tf_generic_scope) {
153 return apply_subtriggers(tval, ws);
154}
155
156TRIGGER_FUNCTION(tf_x_neighbor_province_scope) {
157 if(*tval & trigger::is_existence_scope) {
158 return "dup >r false >r make-ap-it "
159 "while more? r@ not and "
160 "loop "
161 "next " // ap on top
162 "if "
163 "swap >r " // hide it
164 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
165 "r> drop >r " // replace bool value with new bool
166 "swap drop "
167 "else "
168 "drop "
169 "end-if "
170 "end-while "
171 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
172 ;
173 } else {
174 return "dup >r true >r make-ap-it "
175 "while more? r@ and "
176 "loop "
177 "next " // ap on top
178 "if "
179 "swap >r " // hide it
180 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
181 "r> drop >r " // replace bool value with new bool
182 "swap drop "
183 "else "
184 "drop "
185 "end-if "
186 "end-while "
187 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
188 ;
189 }
190}
191TRIGGER_FUNCTION(tf_x_neighbor_province_scope_state) {
192 if(*tval & trigger::is_existence_scope) {
193 return "dup >r false >r make-sp-it "
194 "while more? r@ not and "
195 "loop "
196 "next " // it ap on top
197 "if " // [it ap] [SI bool]
198 "swap r> swap >r >r " // [p] [si it bool]
199 "make-ap-it " // [apit] [si it bool]
200 "while more? r@ not and "
201 "loop "
202 "next " // [apit p2] [si it bool]
203 "dup state_membership @ r> r> .parent@ swap >r swap >r = not "
204 "if "
205 "swap >r " // hide it
206 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
207 "r> drop >r " // replace bool value with new bool
208 "swap drop "
209 "else "
210 "drop "
211 "end-if "
212 "end-while "
213 "drop r> r> swap >r " // drop pop-iterator [bool IT], [IT, bool}, {IT], [bool]
214 "else "
215 "drop "
216 "end-if "
217 "end-while "
218 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
219 ;
220 } else {
221 return "dup >r true >r make-sp-it "
222 "while more? r@ and "
223 "loop "
224 "next " // it ap on top
225 "if " // [it ap] [SI bool]
226 "swap r> swap >r >r " // [p] [si it bool]
227 "make-ap-it " // [apit] [si it bool]
228 "while more? r@ and "
229 "loop "
230 "next " // [apit p2] [si it bool]
231 "dup state_membership @ r> r> .parent@ swap >r swap >r = not "
232 "if "
233 "swap >r " // hide it
234 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
235 "r> drop >r " // replace bool value with new bool
236 "swap drop "
237 "else "
238 "drop "
239 "end-if "
240 "end-while "
241 "drop r> r> swap >r " // drop pop-iterator [bool IT], [IT, bool}, {IT], [bool]
242 "else "
243 "drop "
244 "end-if "
245 "end-while "
246 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
247 ;
248 }
249}
250TRIGGER_FUNCTION(tf_x_neighbor_country_scope_nation) {
251 if(*tval & trigger::is_existence_scope) {
252 return "dup >r false >r make-an-it "
253 "while more? r@ not and "
254 "loop "
255 "next " // ap on top
256 "swap >r " // hide it
257 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
258 "r> drop >r " // replace bool value with new bool
259 "swap drop "
260 "end-while "
261 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
262 ;
263 } else {
264 return "dup >r true >r make-an-it "
265 "while more? r@ and "
266 "loop "
267 "next " // ap on top
268 "swap >r " // hide it
269 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
270 "r> drop >r " // replace bool value with new bool
271 "swap drop "
272 "end-while "
273 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
274 ;
275 }
276}
277TRIGGER_FUNCTION(tf_x_neighbor_country_scope_pop) {
278 if(*tval & trigger::is_existence_scope) {
279 return "dup >r " + pop_to_owner() + "false >r make-an-it "
280 "while more? r@ not and "
281 "loop "
282 "next " // ap on top
283 "swap >r " // hide it
284 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
285 "r> drop >r " // replace bool value with new bool
286 "swap drop "
287 "end-while "
288 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
289 ;
290 } else {
291 return "dup >r " + pop_to_owner() + "true >r make-an-it "
292 "while more? r@ and "
293 "loop "
294 "next " // ap on top
295 "swap >r " // hide it
296 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
297 "r> drop >r " // replace bool value with new bool
298 "swap drop "
299 "end-while "
300 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
301 ;
302 }
303}
304TRIGGER_FUNCTION(tf_x_war_countries_scope_nation) {
305 if(*tval & trigger::is_existence_scope) {
306 return "false >r dup >r " // note : removes nation from stack entirely
307 "nation_adjacency-connected_nations dup size " // R bool, nation
308 "while 1 - dup 0 >= r> swap r@ not and swap >r " //war_participant_id
309 "loop "
310 "2dup index @ dup is_attacker @ >r " //war_participant_id on stack, R bool, nation, is attacker
311 "war @ war_participant-war dup size"
312 "while 1 - dup 0 >= r> swap r> swap r@ not and swap >r swap >r "
313 "loop "
314 "2dup index @ dup is_attacker @ r@ <> "
315 "if "
316 "nation @ "
317 "swap >r swap >r swap >r swap >r " // hide array and index (x2)
318 + apply_subtriggers(tval, ws) + " r> swap r> swap r> swap r> swap" // bool result on top
319 "r> swap r> swap r> drop >r >r >r " // replace bool value with new bool
320 "else "
321 "drop "
322 "end-if "
323 "end-while "
324 "drop drop r> drop " // drop array, index, is attacker
325 "end-while "
326 "drop drop r> r> " // drop array, index, move stored self nation to stack, move bool to stack
327 ;
328 } else {
329 return "true >r dup >r " // note : removes nation from stack entirely
330 "nation_adjacency-connected_nations dup size " // R bool, nation
331 "while 1 - dup 0 >= r> swap r@ and swap >r " //war_participant_id
332 "loop "
333 "2dup index @ dup is_attacker @ >r " //war_participant_id on stack, R bool, nation, is attacker
334 "war @ war_participant-war dup size"
335 "while 1 - dup 0 >= r> swap r> swap r@ and swap >r swap >r "
336 "loop "
337 "2dup index @ dup is_attacker @ r@ <> "
338 "if "
339 "nation @ "
340 "swap >r swap >r swap >r swap >r " // hide array and index (x2)
341 + apply_subtriggers(tval, ws) + " r> swap r> swap r> swap r> swap" // bool result on top
342 "r> swap r> swap r> drop >r >r >r " // replace bool value with new bool
343 "else "
344 "drop "
345 "end-if "
346 "end-while "
347 "drop drop r> drop " // drop array, index, is attacker
348 "end-while "
349 "drop drop r> r> " // drop array, index, move stored self nation to stack, move bool to stack
350 ;
351 }
352}
353TRIGGER_FUNCTION(tf_x_war_countries_scope_pop) {
354 if(*tval & trigger::is_existence_scope) {
355 return ">r r@ " + pop_to_owner() + "false >r dup >r " // note : removes nation from stack entirely
356 "nation_adjacency-connected_nations dup size " // R bool, nation
357 "while 1 - dup 0 >= r> swap r@ not and swap >r " //war_participant_id
358 "loop "
359 "2dup index @ dup is_attacker @ >r " //war_participant_id on stack, R bool, nation, is attacker
360 "war @ war_participant-war dup size"
361 "while 1 - dup 0 >= r> swap r> swap r@ not and swap >r swap >r "
362 "loop "
363 "2dup index @ dup is_attacker @ r@ <> "
364 "if "
365 "nation @ "
366 "swap >r swap >r swap >r swap >r " // hide array and index (x2)
367 + apply_subtriggers(tval, ws) + " r> swap r> swap r> swap r> swap" // bool result on top
368 "r> swap r> swap r> drop >r >r >r " // replace bool value with new bool
369 "else "
370 "drop "
371 "end-if "
372 "end-while "
373 "drop drop r> drop " // drop array, index, is attacker
374 "end-while "
375 "drop drop r> drop r> r> swap "// drop array, index, move stored self nation to stack, move bool to stack
376 ;
377 } else {
378 return ">r r@ " + pop_to_owner() + "true >r dup >r " // note : removes nation from stack entirely
379 "nation_adjacency-connected_nations dup size " // R bool, nation
380 "while 1 - dup 0 >= r> swap r@ and swap >r " //war_participant_id
381 "loop "
382 "2dup index @ dup is_attacker @ >r " //war_participant_id on stack, R bool, nation, is attacker
383 "war @ war_participant-war dup size"
384 "while 1 - dup 0 >= r> swap r> swap r@ and swap >r swap >r "
385 "loop "
386 "2dup index @ dup is_attacker @ r@ <> "
387 "if "
388 "nation @ "
389 "swap >r swap >r swap >r swap >r " // hide array and index (x2)
390 + apply_subtriggers(tval, ws) + " r> swap r> swap r> swap r> swap" // bool result on top
391 "r> swap r> swap r> drop >r >r >r " // replace bool value with new bool
392 "else "
393 "drop "
394 "end-if "
395 "end-while "
396 "drop drop r> drop " // drop array, index, is attacker
397 "end-while "
398 "drop drop r> drop r> r> swap " // drop array, index, move stored self nation to stack, move bool to stack
399 ;
400 }
401}
402TRIGGER_FUNCTION(tf_x_country_scope) {
403 if(*tval & trigger::is_existence_scope) {
404 return ">r false >r nation-size @ " // note : removes nation from stack entirely
405 "while 1 - dup 0 >= r@ not and "
406 "loop "
407 "dup >nation_id " // adjacent nation on top
408 "swap >r " // hide index
409 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
410 "r> drop >r " // replace bool value with new bool
411 "swap drop "
412 "end-while "
413 "drop r> r> swap " // drop index, move stored self nation to stack, move bool to stack
414 ;
415 } else {
416 return ">r true >r nation-size @ " // note : removes nation from stack entirely
417 "while 1 - dup 0 >= r@ and "
418 "loop "
419 "dup >nation_id " // adjacent nation on top
420 "swap >r " // hide index
421 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
422 "r> drop >r " // replace bool value with new bool
423 "swap drop "
424 "end-while "
425 "drop r> r> swap " // drop index, move stored self nation to stack, move bool to stack
426 ;
427 }
428}
429TRIGGER_FUNCTION(tf_x_greater_power_scope) {
430 if(*tval & trigger::is_existence_scope) {
431 return ">r false >r make-gp-it "
432 "while more? r@ not and "
433 "loop "
434 "next " // nation on top
435 "dup is_great_power @ "
436 "if "
437 "swap inc-gp >r " // hide it
438 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
439 "r> drop >r " // replace bool value with new bool
440 "swap drop "
441 "else "
442 "drop "
443 "end-if "
444 "end-while "
445 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
446 ;
447 } else {
448 return ">r true >r make-gp-it "
449 "while more? r@ and "
450 "loop "
451 "next " // nation on top
452 "dup is_great_power @ "
453 "if "
454 "swap inc-gp >r " // hide it
455 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
456 "r> drop >r " // replace bool value with new bool
457 "swap drop "
458 "else "
459 "drop "
460 "end-if "
461 "end-while "
462 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
463 ;
464 }
465}
466TRIGGER_FUNCTION(tf_x_owned_province_scope_state) {
467 if(*tval & trigger::is_existence_scope) {
468 return "dup >r false >r make-sp-it "
469 "while more? r@ not and "
470 "loop "
471 "next " // prov + properly in state on top
472 "if "
473 "swap >r " // hide it
474 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
475 "r> drop >r " // replace bool value with new bool
476 "swap drop "
477 "else "
478 "drop "
479 "end-if "
480 "end-while "
481 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
482 ;
483 } else {
484 return "dup >r true >r make-sp-it "
485 "while more? r@ and "
486 "loop "
487 "next " // prov + properly in state on top
488 "if "
489 "swap >r " // hide it
490 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
491 "r> drop >r " // replace bool value with new bool
492 "swap drop "
493 "else "
494 "drop "
495 "end-if "
496 "end-while "
497 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
498 ;
499 }
500}
501TRIGGER_FUNCTION(tf_x_owned_province_scope_nation) {
502 if(*tval & trigger::is_existence_scope) {
503 return "dup >r false >r make-n-it "
504 "while more? r@ not and "
505 "loop "
506 "next " // prov on top
507 "swap >r " // hide it
508 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
509 "r> drop >r " // replace bool value with new bool
510 "swap drop "
511 "end-while "
512 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
513 ;
514 } else {
515 return "dup >r true >r make-n-it "
516 "while more? r@ and "
517 "loop "
518 "next " // prov on top
519 "swap >r " // hide it
520 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
521 "r> drop >r " // replace bool value with new bool
522 "swap drop "
523 "end-while "
524 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
525 ;
526 }
527}
528TRIGGER_FUNCTION(tf_x_core_scope_province) {
529 if(*tval & trigger::is_existence_scope) {
530 return "dup >r false >r make-pc-it "
531 "while more? r@ not and "
532 "loop "
533 "next " // n on top
534 "swap >r " // hide it
535 "dup valid? if "
536 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
537 "r> drop >r " // replace bool value with new bool
538 "swap drop "
539 "else "
540 "drop r> "
541 "end-if "
542 "end-while "
543 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
544 ;
545 } else {
546 return "dup >r true >r make-pc-it "
547 "while more? r@ and "
548 "loop "
549 "next " // n on top
550 "swap >r " // hide it
551 "dup valid? if "
552 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
553 "r> drop >r " // replace bool value with new bool
554 "swap drop "
555 "else "
556 "drop r> "
557 "end-if "
558 "end-while "
559 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
560 ;
561 }
562}
563TRIGGER_FUNCTION(tf_x_core_scope_nation) {
564 if(*tval & trigger::is_existence_scope) {
565 return "dup >r false >r make-nc-it "
566 "while more? r@ not and "
567 "loop "
568 "next " // n on top
569 "swap >r " // hide it
570 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
571 "r> drop >r " // replace bool value with new bool
572 "swap drop "
573 "end-while "
574 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
575 ;
576 } else {
577 return "dup >r true >r make-nc-it "
578 "while more? r@ and "
579 "loop "
580 "next " // n on top
581 "swap >r " // hide it
582 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
583 "r> drop >r " // replace bool value with new bool
584 "swap drop "
585 "end-while "
586 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
587 ;
588 }
589}
590
591TRIGGER_FUNCTION(tf_x_state_scope) {
592 if(*tval & trigger::is_existence_scope) {
593 return "dup >r false >r make-ns-it "
594 "while more? r@ not and "
595 "loop "
596 "next " // n on top
597 "swap >r " // hide it
598 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
599 "r> drop >r " // replace bool value with new bool
600 "swap drop "
601 "end-while "
602 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
603 ;
604 } else {
605 return "dup >r true >r make-ns-it "
606 "while more? r@ and "
607 "loop "
608 "next " // n on top
609 "swap >r " // hide it
610 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
611 "r> drop >r " // replace bool value with new bool
612 "swap drop "
613 "end-while "
614 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
615 ;
616 }
617}
618TRIGGER_FUNCTION(tf_x_substate_scope) {
619 if(*tval & trigger::is_existence_scope) {
620 return "dup >r false >r make-nv-it "
621 "while more? r@ not and "
622 "loop "
623 "next " // n on top
624 "dup is_substate @ "
625 "if "
626 "swap >r " // hide it
627 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
628 "r> drop >r " // replace bool value with new bool
629 "swap drop "
630 "else "
631 "drop "
632 "end-if "
633 "end-while "
634 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
635 ;
636 } else {
637 return "dup >r true >r make-nv-it "
638 "while more? r@ and "
639 "loop "
640 "next " // n on top
641 "dup is_substate @ "
642 "if "
643 "swap >r " // hide it
644 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
645 "r> drop >r " // replace bool value with new bool
646 "swap drop "
647 "else "
648 "drop "
649 "end-if "
650 "end-while "
651 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
652 ;
653 }
654}
655TRIGGER_FUNCTION(tf_x_sphere_member_scope) {
656 if(*tval & trigger::is_existence_scope) {
657 return "dup >r false >r make-ngp-it "
658 "while more? r@ not and "
659 "loop "
660 "next " // n on top
661 "if "
662 "swap >r " // hide it
663 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
664 "r> drop >r " // replace bool value with new bool
665 "swap drop "
666 "else "
667 "drop "
668 "end-if "
669 "end-while "
670 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
671 ;
672 } else {
673 return "dup >r true >r make-ngp-it "
674 "while more? r@ and "
675 "loop "
676 "next " // n on top
677 "if "
678 "swap >r " // hide it
679 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
680 "r> drop >r " // replace bool value with new bool
681 "swap drop "
682 "else "
683 "drop "
684 "end-if "
685 "end-while "
686 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
687 ;
688 }
689}
690TRIGGER_FUNCTION(tf_x_pop_scope_province) {
691 if(*tval & trigger::is_existence_scope) {
692 return "dup >r false >r make-pp-it "
693 "while more? r@ not and "
694 "loop "
695 "next " // n on top
696 "swap >r " // hide it
697 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
698 "r> drop >r " // replace bool value with new bool
699 "swap drop "
700 "end-while "
701 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
702 ;
703 } else {
704 return "dup >r true >r make-pp-it "
705 "while more? r@ and "
706 "loop "
707 "next " // n on top
708 "swap >r " // hide it
709 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
710 "r> drop >r " // replace bool value with new bool
711 "swap drop "
712 "end-while "
713 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
714 ;
715 }
716}
717TRIGGER_FUNCTION(tf_x_pop_scope_state) {
718 if(*tval & trigger::is_existence_scope) {
719 return "dup >r false >r make-sp-it "
720 "while more? r@ not and "
721 "loop "
722 "next " // v on top
723 "if "
724 "swap r> swap >r >r " // hide it [IT bool]
725 "make-pp-it " // state -> it
726 "while more? r@ not and "
727 "loop "
728 "next " // p on top
729 "swap >r " // hide it
730 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
731 "r> drop >r " // replace bool value with new bool
732 "swap drop "
733 "end-while "
734 "drop r> r> swap >r " // drop pop-iterator [bool IT], [IT, bool}, {IT], [bool]
735 "else "
736 "drop "
737 "end-if "
738 "end-while "
739 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
740 ;
741 } else {
742 return "dup >r true >r make-sp-it "
743 "while more? r@ and "
744 "loop "
745 "next " // v on top
746 "if "
747 "swap r> swap >r >r " // hide it [IT bool]
748 "make-pp-it " // state -> it
749 "while more? r@ and "
750 "loop "
751 "next " // p on top
752 "swap >r " // hide it
753 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
754 "r> drop >r " // replace bool value with new bool
755 "swap drop "
756 "end-while "
757 "drop r> r> swap >r " // drop pop-iterator [bool IT], [IT, bool}, {IT], [bool]
758 "else "
759 "drop "
760 "end-if "
761 "end-while "
762 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
763 ;
764 }
765}
766TRIGGER_FUNCTION(tf_x_pop_scope_nation) {
767 if(*tval & trigger::is_existence_scope) {
768 return "dup >r false >r make-n-it "
769 "while more? r@ not and "
770 "loop "
771 "next " // v on top
772 "if "
773 "swap r> swap >r >r " // hide it [IT bool]
774 "make-pp-it " // state -> it
775 "while more? r@ not and "
776 "loop "
777 "next " // p on top
778 "swap >r " // hide it
779 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
780 "r> drop >r " // replace bool value with new bool
781 "swap drop "
782 "end-while "
783 "drop r> r> swap >r " // drop pop-iterator [bool IT], [IT, bool}, {IT], [bool]
784 "else "
785 "drop "
786 "end-if "
787 "end-while "
788 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
789 ;
790 } else {
791 return "dup >r true >r make-n-it "
792 "while more? r@ and "
793 "loop "
794 "next " // v on top
795 "if "
796 "swap r> swap >r >r " // hide it [IT bool]
797 "make-pp-it " // state -> it
798 "while more? r@ and "
799 "loop "
800 "next " // p on top
801 "swap >r " // hide it
802 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
803 "r> drop >r " // replace bool value with new bool
804 "swap drop "
805 "end-while "
806 "drop r> r> swap >r " // drop pop-iterator [bool IT], [IT, bool}, {IT], [bool]
807 "else "
808 "drop "
809 "end-if "
810 "end-while "
811 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
812 ;
813 }
814}
815TRIGGER_FUNCTION(tf_x_provinces_in_variable_region) {
816 if(*tval & trigger::is_existence_scope) {
817 return ">r false >r " + std::to_string(trigger::payload(*(tval + 2)).state_id.index()) + " >state_definition_id make-asp-it "
818 "while more? r@ not and "
819 "loop "
820 "next " // n on top
821 "swap >r " // hide it
822 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
823 "r> drop >r " // replace bool value with new bool
824 "swap drop "
825 "end-while "
826 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
827 ;
828 } else {
829 return ">r true >r " + std::to_string(trigger::payload(*(tval + 2)).state_id.index()) + " >state_definition_id make-asp-it "
830 "while more? r@ and "
831 "loop "
832 "next " // n on top
833 "swap >r " // hide it
834 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
835 "r> drop >r " // replace bool value with new bool
836 "swap drop "
837 "end-while "
838 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
839 ;
840 }
841}
842TRIGGER_FUNCTION(tf_x_provinces_in_variable_region_proper) {
843 if(*tval & trigger::is_existence_scope) {
844 return ">r false >r " + std::to_string(trigger::payload(*(tval + 2)).reg_id.index()) + " >region_id make-arp-it "
845 "while more? r@ not and "
846 "loop "
847 "next " // n on top
848 "swap >r " // hide it
849 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
850 "r> drop >r " // replace bool value with new bool
851 "swap drop "
852 "end-while "
853 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
854 ;
855 } else {
856 return ">r true >r " + std::to_string(trigger::payload(*(tval + 2)).reg_id.index()) + " >region_id make-arp-it "
857 "while more? r@ and "
858 "loop "
859 "next " // n on top
860 "swap >r " // hide it
861 + apply_subtriggers(tval, ws) + " r> swap " // bool result on top
862 "r> drop >r " // replace bool value with new bool
863 "swap drop "
864 "end-while "
865 "drop r> r> swap " // drop it, move stored to stack, move bool to stack
866 ;
867 }
868}
869
870
871TRIGGER_FUNCTION(tf_owner_scope_state) {
872 std::string result;
873 result += "dup >r " + state_to_owner();
874 result += apply_subtriggers(tval, ws);
875 result += "swap drop r> swap ";
876 return result;
877}
878TRIGGER_FUNCTION(tf_owner_scope_province) {
879 std::string result;
880 result += "dup >r " + province_to_owner();
881 result += apply_subtriggers(tval, ws);
882 result += "swap drop r> swap ";
883 return result;
884}
885TRIGGER_FUNCTION(tf_controller_scope) {
886 std::string result;
887 result += "dup >r " + province_to_controller();
888 result += apply_subtriggers(tval, ws);
889 result += "swap drop r> swap ";
890 return result;
891}
892
893TRIGGER_FUNCTION(tf_location_scope) {
894 std::string result;
895 result += "dup >r " + pop_to_location();
896 result += apply_subtriggers(tval, ws);
897 result += "swap drop r> swap ";
898 return result;
899}
900TRIGGER_FUNCTION(tf_country_scope_state) {
901 std::string result;
902 result += "dup >r " + state_to_owner();
903 result += apply_subtriggers(tval, ws);
904 result += "swap drop r> swap ";
905 return result;
906}
907TRIGGER_FUNCTION(tf_country_scope_pop) {
908 std::string result;
909 result += "dup >r " + pop_to_owner();
910 result += apply_subtriggers(tval, ws);
911 result += "swap drop r> swap ";
912 return result;
913}
914TRIGGER_FUNCTION(tf_capital_scope) {
915 std::string result;
916 result += "dup >r capital @ ";
917 result += apply_subtriggers(tval, ws);
918 result += "swap drop r> swap ";
919 return result;
920}
921TRIGGER_FUNCTION(tf_capital_scope_province) {
922 std::string result;
923 result += "dup >r " + province_to_owner() + "capital @ ";
924 result += apply_subtriggers(tval, ws);
925 result += "swap drop r> swap ";
926 return result;
927}
928TRIGGER_FUNCTION(tf_capital_scope_pop) {
929 std::string result;
930 result += "dup >r " + pop_to_owner() + "capital @ ";
931 result += apply_subtriggers(tval, ws);
932 result += "swap drop r> swap ";
933 return result;
934}
935TRIGGER_FUNCTION(tf_this_scope) {
936 std::string result;
937 result += ">r dup ";
938 result += apply_subtriggers(tval, ws);
939 result += "swap drop r> swap ";
940 return result;
941}
942TRIGGER_FUNCTION(tf_from_scope) {
943 std::string result;
944 result += ">r >r dup r> swap ";
945 result += apply_subtriggers(tval, ws);
946 result += "swap drop r> swap ";
947 return result;
948}
949
950TRIGGER_FUNCTION(tf_sea_zone_scope) {
951 std::string result;
952 result += "dup >r port_to @ "; // F T port -- source province on R
953 result += apply_subtriggers(tval, ws);
954 result += "swap drop r> swap "; // put original province back under result value
955 return result;
956}
957
959 return "culture_group_membership-member group @ "
960 "cultural_union_of-culture_group identity @ identity_holder-identity nation @ ";
961}
963 return "primary_culture @ " + culture_to_union_holder();
964}
965
966
967TRIGGER_FUNCTION(tf_cultural_union_scope) {
968 std::string result;
969 result += "dup >r " + nation_to_union_holder();
970 result += apply_subtriggers(tval, ws);
971 result += "swap drop r> swap "; // put original under result value
972 return result;
973}
975 return "overlord-subject ruler @ ";
976}
977TRIGGER_FUNCTION(tf_overlord_scope) {
978 std::string result;
979 result += "dup >r " + overlord_from_subject();
980 result += apply_subtriggers(tval, ws);
981 result += "swap drop r> swap "; // put original under result value
982 return result;
983}
984TRIGGER_FUNCTION(tf_sphere_owner_scope) {
985 std::string result;
986 result += "dup >r in_sphere_of @ ";
987 result += apply_subtriggers(tval, ws);
988 result += "swap drop r> swap "; // put original under result value
989 return result;
990}
991TRIGGER_FUNCTION(tf_independence_scope) {
992 std::string result;
993 result += ">r >r dup defection_target @ identity_holder-identity nation @ r> swap ";
994 result += apply_subtriggers(tval, ws);
995 result += "swap drop r> swap "; // put original under result value
996 return result;
997}
998TRIGGER_FUNCTION(tf_flashpoint_tag_scope) {
999 std::string result;
1000 result += "dup >r flashpoint_tag @ identity_holder-identity nation @ ";
1001 result += apply_subtriggers(tval, ws);
1002 result += "swap drop r> swap "; // put original under result value
1003 return result;
1004}
1005TRIGGER_FUNCTION(tf_crisis_state_scope) {
1006 std::string result;
1007 result += ">r crisis-state @ ";
1008 result += apply_subtriggers(tval, ws);
1009 result += "swap drop r> swap "; // put original under result value
1010 return result;
1011}
1012TRIGGER_FUNCTION(tf_state_scope_province) {
1013 std::string result;
1014 result += "dup >r state_membership @ ";
1015 result += apply_subtriggers(tval, ws);
1016 result += "swap drop r> swap "; // put original under result value
1017 return result;
1018}
1019TRIGGER_FUNCTION(tf_state_scope_pop) {
1020 std::string result;
1021 result += "dup >r " + pop_to_location() + "state_membership @ ";
1022 result += apply_subtriggers(tval, ws);
1023 result += "swap drop r> swap "; // put original under result value
1024 return result;
1025}
1026TRIGGER_FUNCTION(tf_tag_scope) {
1027 auto tag = trigger::payload(tval[2]).tag_id;
1028
1029 std::string result;
1030 result += ">r " + std::to_string(tag.index()) + " >national_identity_id identity_holder-identity nation @ ";
1031 result += apply_subtriggers(tval, ws);
1032 result += "swap drop r> swap "; // put original under result value
1033 return result;
1034}
1035TRIGGER_FUNCTION(tf_integer_scope) {
1036 auto wprov = trigger::payload(tval[2]).prov_id;
1037
1038 std::string result;
1039 result += ">r " + std::to_string(wprov.index()) + " >province_id ";
1040 result += apply_subtriggers(tval, ws);
1041 result += "swap drop r> swap "; // put original under result value
1042 return result;
1043}
1044TRIGGER_FUNCTION(tf_country_scope_nation) {
1045 return apply_subtriggers(tval, ws);
1046}
1047TRIGGER_FUNCTION(tf_country_scope_province) {
1048 std::string result;
1049 result += "dup >r " + province_to_owner();
1050 result += apply_subtriggers(tval, ws);
1051 result += "swap drop r> swap "; // put original under result value
1052 return result;
1053}
1054TRIGGER_FUNCTION(tf_cultural_union_scope_pop) {
1055 std::string result;
1056 result += "dup >r culture @ " + culture_to_union_holder();
1057 result += apply_subtriggers(tval, ws);
1058 result += "swap drop r> swap "; // put original under result value
1059 return result;
1060}
1061
1062//
1063// non scope trigger functions
1064//
1065
1067 return "start-date @ current-date @ >i64 -1 >i64 + + current-year " + std::to_string(int32_t(tval[1])) + compare_values(tval[0]);
1068}
1070 return "start-date @ current-date @ >i64 -1 >i64 + + current-month " + std::to_string(int32_t(tval[1])) + compare_values(tval[0]);
1071}
1073 return "dup is_coast @ ";
1074}
1076 // note: comparison reversed since rank 1 is "greater" than rank 1 + N
1077 return "dup get_rank @ >i32 " + std::to_string(int32_t(tval[1])) + " swap " + compare_values(tval[0]);
1078}
1079TRIGGER_FUNCTION(tf_technology) {
1080 return "dup " + std::to_string(trigger::payload(tval[1]).tech_id.index()) + " >technology_id active_technologies @ " + truth_inversion(tval[0]);
1081}
1082TRIGGER_FUNCTION(tf_technology_province) {
1083 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).tech_id.index()) + " >technology_id active_technologies @ " + truth_inversion(tval[0]);
1084}
1085TRIGGER_FUNCTION(tf_technology_pop) {
1086 return "dup " + pop_to_owner() + std::to_string(trigger::payload(tval[1]).tech_id.index()) + " >technology_id active_technologies @ " + truth_inversion(tval[0]);
1087}
1088TRIGGER_FUNCTION(tf_strata_rich) {
1089 return "dup poptype @ strata @ " + std::to_string(int32_t(culture::pop_strata::rich)) + " >u8 " + compare_values_eq(tval[0]);
1090}
1091TRIGGER_FUNCTION(tf_strata_middle) {
1092 return "dup poptype @ strata @ " + std::to_string(int32_t(culture::pop_strata::middle)) + " >u8 " + compare_values_eq(tval[0]);
1093}
1094TRIGGER_FUNCTION(tf_strata_poor) {
1095 return "dup poptype @ strata @ " + std::to_string(int32_t(culture::pop_strata::poor)) + " >u8 " + compare_values_eq(tval[0]);
1096}
1097TRIGGER_FUNCTION(tf_life_rating_province) {
1098 return "dup life_rating @ " + std::to_string(trigger::payload(tval[1]).signed_value) + " >u8 " + compare_values(tval[0]);
1099}
1100TRIGGER_FUNCTION(tf_life_rating_state) {
1101 return "dup capital @ life_rating @ " + std::to_string(trigger::payload(tval[1]).signed_value) + " >u8 " + compare_values(tval[0]);
1102}
1103
1104TRIGGER_FUNCTION(tf_has_empty_adjacent_state_province) {
1105 return "dup >index state-ptr @ empty-a-province " + truth_inversion(tval[0]);
1106 /*
1107 return "dup false >r >r province_adjacency-connected_provinces dup size "
1108 "while 1 - dup 0 >= loop "
1109 "2dup nth-adjacent dup sea-province? not swap " + province_to_owner() + "valid? not and "
1110 "r> swap r> or >r >r "
1111 "end-while "
1112 "drop drop "
1113 " r> r> " + truth_inversion(tval[0]);
1114 ;
1115 */
1116}
1117
1118TRIGGER_FUNCTION(tf_has_empty_adjacent_state_state) {
1119 return "dup >index state-ptr @ empty-a-state " + truth_inversion(tval[0]);
1120 /*
1121 return
1122 "dup dup dup " + state_to_owner() + ">r false >r definition @ abstract_state_membership-state dup size "
1123 "while 1 - dup 0 >= loop "
1124 "2dup index @ province " // now have a province in scope, just need to iterate over it ...
1125 "dup " + province_to_owner() + "r> swap r@ = swap >r " //
1126 " if "
1127 "dup >r province_adjacency-connected_provinces dup size "
1128 "while 1 - dup 0 >= loop " // R: owner BOOL SOURCE-PROV
1129 "2dup nth-adjacent dup sea-province? not swap " + province_to_owner() + "valid? not and " // proxy - index - bool
1130 "r> swap r> or >r >r "
1131 "end-while "
1132 "drop drop " // drop proxy and index
1133 "r> drop " // discard saved province
1134 " else "
1135 " drop " // drop province
1136 " end-if "
1137 "end-while "
1138 "drop drop " // drop proxy and index
1139 " r> r> swap drop " + truth_inversion(tval[0]);
1140 ;
1141 */
1142}
1143TRIGGER_FUNCTION(tf_state_id_province) {
1144 return "dup abstract_state_membership-province state @ "
1145 + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id abstract_state_membership-province state @ = " + truth_inversion(tval[0]);
1146}
1147TRIGGER_FUNCTION(tf_state_id_state) {
1148 return "dup definition @ "
1149 + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id abstract_state_membership-province state @ = " + truth_inversion(tval[0]);
1150}
1151TRIGGER_FUNCTION(tf_cash_reserves) {
1152 return "true " + truth_inversion(tval[0]);
1153 // commented out because desired_needs_spending is not implemented
1154 //auto ratio = read_float_from_payload(tval + 1);
1155 //auto target = economy::desired_needs_spending(ws, to_pop(primary_slot));
1156 //auto savings_qnty = ws.world.pop_get_savings(to_pop(primary_slot));
1157 //return compare_values(tval[0], ve::select(target != 0.0f, savings_qnty * 100.0f / target, 100.0f), ratio);
1158}
1159
1160
1161TRIGGER_FUNCTION(tf_unemployment_nation) {
1162 return "dup " + std::to_string(demographics::employable.index()) + " >demographics_key demographics @ >r "
1163 "dup " + std::to_string(demographics::employed.index()) + " >demographics_key demographics @ 1.0 swap r@ / - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + compare_values(tval[0]);
1164 //auto total_employable = ws.world.nation_get_demographics(to_nation(primary_slot), demographics::employable);
1165 //auto total_employed = ws.world.nation_get_demographics(to_nation(primary_slot), demographics::employed);
1166 //return compare_values(tval[0], ve::select(total_employable > 0.0f, 1.0f - (total_employed / total_employable), 0.0f),
1167 // read_float_from_payload(tval + 1));
1168}
1169TRIGGER_FUNCTION(tf_unemployment_state) {
1170 return "dup " + std::to_string(demographics::employable.index()) + " >demographics_key demographics @ >r "
1171 "dup " + std::to_string(demographics::employed.index()) + " >demographics_key demographics @ 1.0 swap r@ / - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + compare_values(tval[0]);
1172}
1173TRIGGER_FUNCTION(tf_unemployment_province) {
1174 return "dup " + std::to_string(demographics::employable.index()) + " >demographics_key demographics @ >r "
1175 "dup " + std::to_string(demographics::employed.index()) + " >demographics_key demographics @ 1.0 swap r@ / - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + compare_values(tval[0]);
1176}
1177TRIGGER_FUNCTION(tf_unemployment_pop) {
1178 return "dup poptype @ has_unemployment @ not >r "
1179 "dup uemployment @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * 1.0 swap - 0.0 r> select "
1180 + std::to_string(read_float_from_payload(tval + 1)) + compare_values(tval[0]);
1181}
1182TRIGGER_FUNCTION(tf_is_slave_nation) {
1183 return "dup combined_issue_rules @ >i32 " + std::to_string(issue_rule::slavery_allowed) + " and 0 <> " + truth_inversion(tval[0]);
1184}
1185TRIGGER_FUNCTION(tf_is_slave_state) {
1186 return "dup capital @ is_slave @ " + truth_inversion(tval[0]);
1187}
1188TRIGGER_FUNCTION(tf_is_slave_province) {
1189 return "dup is_slave @ " + truth_inversion(tval[0]);
1190}
1191TRIGGER_FUNCTION(tf_is_slave_pop) {
1192 return "dup poptype @ >index " + std::to_string(ws.culture_definitions.slaves.index()) + " " + compare_values_eq(tval[0]);
1193}
1194TRIGGER_FUNCTION(tf_is_independant) {
1195 return "dup overlord-subject ruler @ valid? not " + truth_inversion(tval[0]);
1196}
1197
1199 return ">index " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " + >demographics_key ";
1200}
1201TRIGGER_FUNCTION(tf_has_national_minority_province) {
1202 return "dup dup " + province_to_owner() + " primary_culture @ " + demo_culture_key(ws) + "demographics @ >r "
1203 "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ r> <> " + truth_inversion(tval[0]);
1204}
1205TRIGGER_FUNCTION(tf_has_national_minority_state) {
1206 return "dup dup " + state_to_owner() + " primary_culture @ " + demo_culture_key(ws) + "demographics @ >r "
1207 "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ r> <> " + truth_inversion(tval[0]);
1208}
1209TRIGGER_FUNCTION(tf_has_national_minority_nation) {
1210 return "dup dup primary_culture @ " + demo_culture_key(ws) + "demographics @ >r "
1211 "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ r> <> " + truth_inversion(tval[0]);
1212}
1213TRIGGER_FUNCTION(tf_government_nation) {
1214 return "dup government_type @ >index " + std::to_string(trigger::payload(tval[1]).gov_id.index()) + " " + compare_values_eq(tval[0]);
1215}
1216TRIGGER_FUNCTION(tf_government_pop) {
1217 return "dup " + pop_to_owner() + "government_type @ >index " + std::to_string(trigger::payload(tval[1]).gov_id.index()) + " " + compare_values_eq(tval[0]);
1218}
1219TRIGGER_FUNCTION(tf_capital) {
1220 return "dup capital @ >index " + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " " + compare_values_eq(tval[0]);
1221}
1222TRIGGER_FUNCTION(tf_tech_school) {
1223 return "dup tech_school @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1224}
1225TRIGGER_FUNCTION(tf_primary_culture) {
1226 return "dup primary_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " " + compare_values_eq(tval[0]);
1227}
1228TRIGGER_FUNCTION(tf_primary_culture_pop) {
1229 return "dup " + pop_to_owner() + "primary_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " " + compare_values_eq(tval[0]);
1230}
1231TRIGGER_FUNCTION(tf_accepted_culture) {
1232 return "dup " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " >culture_id accepted_cultures @ " + truth_inversion(tval[0]);
1233}
1234TRIGGER_FUNCTION(tf_culture_pop) {
1235 return "dup culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " " + compare_values_eq(tval[0]);
1236}
1237TRIGGER_FUNCTION(tf_culture_state) {
1238 return "dup dominant_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " " + compare_values_eq(tval[0]);
1239}
1240TRIGGER_FUNCTION(tf_culture_province) {
1241 return "dup dominant_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " " + compare_values_eq(tval[0]);
1242}
1243TRIGGER_FUNCTION(tf_culture_nation) {
1244 return "dup primary_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " = >r "
1245 "dup " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " >culture_id accepted_cultures @ r> or " + truth_inversion(tval[0]);
1246}
1247TRIGGER_FUNCTION(tf_culture_pop_reb) {
1248 return ">r >r dup primary_culture @ >index r> swap r> swap >r dup culture @ >index r> " + compare_values_eq(tval[0]);
1249}
1250TRIGGER_FUNCTION(tf_culture_state_reb) {
1251 return ">r >r dup primary_culture @ >index r> swap r> swap >r dup dominant_culture @ >index r> " + compare_values_eq(tval[0]);
1252}
1253TRIGGER_FUNCTION(tf_culture_province_reb) {
1254 return ">r >r dup primary_culture @ >index r> swap r> swap >r dup dominant_culture @ >index r> " + compare_values_eq(tval[0]);
1255}
1256TRIGGER_FUNCTION(tf_culture_nation_reb) {
1257 return ">r >r dup primary_culture @ r> swap r> swap >r dup primary_culture @ r@ = >r "
1258 "dup r> r> swap >r accepted_cultures @ r> or " + truth_inversion(tval[0]);
1259}
1260TRIGGER_FUNCTION(tf_culture_this_nation) {
1261 return "dup culture @ swap >r >r dup primary_culture @ r@ = >r " // R[pop C bool]
1262 "dup r> r> swap >r accepted_cultures @ r> or " + truth_inversion(tval[0]) + "r> swap ";
1263}
1264TRIGGER_FUNCTION(tf_culture_from_nation) {
1265 return "dup culture @ swap >r swap >r >r dup primary_culture @ r@ = >r "
1266 "dup r> r> swap >r accepted_cultures @ r> or " + truth_inversion(tval[0]) + "r> swap r> swap ";
1267}
1268TRIGGER_FUNCTION(tf_culture_this_state) {
1269 return "dup culture @ swap >r >r dup " + state_to_owner() + "dup primary_culture @ r@ = >r "
1270 "r> r> swap >r accepted_cultures @ r> or " + truth_inversion(tval[0]) + "r> swap ";
1271}
1272TRIGGER_FUNCTION(tf_culture_this_pop) {
1273 return "dup culture @ swap >r >r dup " + pop_to_owner() + "dup primary_culture @ r@ = >r "
1274 "r> r> swap >r accepted_cultures @ r> or " + truth_inversion(tval[0]) + "r> swap ";
1275}
1276TRIGGER_FUNCTION(tf_culture_this_province) {
1277 return "dup culture @ swap >r >r dup " + province_to_owner() + "dup primary_culture @ r@ = >r "
1278 "r> r> swap >r accepted_cultures @ r> or " + truth_inversion(tval[0]) + "r> swap ";
1279}
1280TRIGGER_FUNCTION(tf_culture_group_nation) {
1281 return "dup primary_culture @ culture_group_membership-member group @ >index " + std::to_string(trigger::payload(tval[1]).culgrp_id.index()) + " " + compare_values_eq(tval[0]);
1282}
1283TRIGGER_FUNCTION(tf_culture_group_pop) {
1284 return "dup culture @ culture_group_membership-member group @ >index " + std::to_string(trigger::payload(tval[1]).culgrp_id.index()) + " " + compare_values_eq(tval[0]);
1285}
1286TRIGGER_FUNCTION(tf_culture_group_province) {
1287 return "dup dominant_culture @ culture_group_membership-member group @ >index " + std::to_string(trigger::payload(tval[1]).culgrp_id.index()) + " " + compare_values_eq(tval[0]);
1288}
1289TRIGGER_FUNCTION(tf_culture_group_state) {
1290 return "dup dominant_culture @ culture_group_membership-member group @ >index " + std::to_string(trigger::payload(tval[1]).culgrp_id.index()) + " " + compare_values_eq(tval[0]);
1291}
1292TRIGGER_FUNCTION(tf_culture_group_reb_nation) {
1293 return "dup primary_culture @ culture_group_membership-member group @ >r >r >r dup primary_culture @ culture_group_membership-member group @ r> swap r> swap r> = " + truth_inversion(tval[0]);
1294}
1295TRIGGER_FUNCTION(tf_culture_group_reb_pop) {
1296 return "dup culture @ culture_group_membership-member group @ >r >r >r dup primary_culture @ culture_group_membership-member group @ r> swap r> swap r> = " + truth_inversion(tval[0]);
1297}
1298TRIGGER_FUNCTION(tf_culture_group_nation_this_nation) {
1299 return "dup primary_culture @ culture_group_membership-member group @ >r >r dup primary_culture @ culture_group_membership-member group @ r> swap r> = " + truth_inversion(tval[0]);
1300}
1301TRIGGER_FUNCTION(tf_culture_group_pop_this_nation) {
1302 return "dup culture @ culture_group_membership-member group @ >r >r dup primary_culture @ culture_group_membership-member group @ r> swap r> = " + truth_inversion(tval[0]);
1303}
1304TRIGGER_FUNCTION(tf_culture_group_nation_from_nation) {
1305 return "dup primary_culture @ culture_group_membership-member group @ >r >r >r dup primary_culture @ culture_group_membership-member group @ r> swap r> swap r> = " + truth_inversion(tval[0]);
1306}
1307TRIGGER_FUNCTION(tf_culture_group_pop_from_nation) {
1308 return "dup culture @ culture_group_membership-member group @ >r >r >r dup primary_culture @ culture_group_membership-member group @ r> swap r> swap r> = " + truth_inversion(tval[0]);
1309}
1310TRIGGER_FUNCTION(tf_culture_group_nation_this_province) {
1311 return "dup primary_culture @ culture_group_membership-member group @ >r >r dup " + province_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap r> = " + truth_inversion(tval[0]);
1312}
1313TRIGGER_FUNCTION(tf_culture_group_pop_this_province) {
1314 return "dup culture @ culture_group_membership-member group @ >r >r dup " + province_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap r> = " + truth_inversion(tval[0]);
1315}
1316TRIGGER_FUNCTION(tf_culture_group_nation_this_state) {
1317 return "dup primary_culture @ culture_group_membership-member group @ >r >r dup " + state_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap r> = " + truth_inversion(tval[0]);
1318}
1319TRIGGER_FUNCTION(tf_culture_group_pop_this_state) {
1320 return "dup culture @ culture_group_membership-member group @ >r >r dup " + state_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap r> = " + truth_inversion(tval[0]);
1321}
1322TRIGGER_FUNCTION(tf_culture_group_nation_this_pop) {
1323 return "dup primary_culture @ culture_group_membership-member group @ >r >r dup " + pop_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap r> = " + truth_inversion(tval[0]);
1324}
1325TRIGGER_FUNCTION(tf_culture_group_pop_this_pop) {
1326 return "dup culture @ culture_group_membership-member group @ >r >r dup " + pop_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap r> = " + truth_inversion(tval[0]);
1327}
1328TRIGGER_FUNCTION(tf_religion) {
1329 return "dup religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " " + compare_values_eq(tval[0]);
1330}
1331TRIGGER_FUNCTION(tf_religion_reb) {
1332 return ">r >r dup religion @ >index r> swap r> swap >r dup religion @ >index r> " + compare_values_eq(tval[0]);
1333}
1334TRIGGER_FUNCTION(tf_religion_from_nation) {
1335 return ">r >r dup religion @ >index r> swap r> swap >r dup religion @ >index r> " + compare_values_eq(tval[0]);
1336}
1337TRIGGER_FUNCTION(tf_religion_this_nation) {
1338 return ">r dup religion @ >index r> swap >r dup religion @ >index r> " + compare_values_eq(tval[0]);
1339}
1340TRIGGER_FUNCTION(tf_religion_this_state) {
1341 return ">r dup " + state_to_owner() + "religion @ >index r> swap >r dup religion @ >index r> " + compare_values_eq(tval[0]);
1342}
1343TRIGGER_FUNCTION(tf_religion_this_province) {
1344 return ">r dup " + province_to_owner() + "religion @ >index r> swap >r dup religion @ >index r> " + compare_values_eq(tval[0]);
1345}
1346TRIGGER_FUNCTION(tf_religion_this_pop) {
1347 return ">r dup " + pop_to_owner() + "religion @ >index r> swap >r dup religion @ >index r> " + compare_values_eq(tval[0]);
1348}
1349TRIGGER_FUNCTION(tf_terrain_province) {
1350 return "dup terrain @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1351}
1352TRIGGER_FUNCTION(tf_terrain_pop) {
1353 return "dup " + pop_to_location() + "terrain @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1354}
1355TRIGGER_FUNCTION(tf_trade_goods) {
1356 return "dup rgo @ >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " " + compare_values_eq(tval[0]);
1357}
1358
1359TRIGGER_FUNCTION(tf_is_secondary_power_nation) {
1360 return "dup rank @ >i32 " + std::to_string(int32_t(ws.defines.colonial_rank)) + " <= " + truth_inversion(tval[0]);
1361}
1362TRIGGER_FUNCTION(tf_is_secondary_power_pop) {
1363 return "dup " + pop_to_owner() + "rank @ >i32 " + std::to_string(int32_t(ws.defines.colonial_rank)) + " <= " + truth_inversion(tval[0]);
1364}
1365TRIGGER_FUNCTION(tf_has_faction_nation) {
1366 return "false >r dup rebellion_within-ruler dup size "
1367 "while 1 - dup 0 >= loop "
1368 "2dup index @ rebels type @ >index " + std::to_string(trigger::payload(tval[1]).reb_id.index()) + " = r> or >r "
1369 "end-while "
1370 "drop drop "
1371 "r> " + truth_inversion(tval[0]);
1372 ;
1373}
1374TRIGGER_FUNCTION(tf_has_faction_pop) {
1375 return "dup pop_rebellion_membership-pop type @ >index " + std::to_string(trigger::payload(tval[1]).reb_id.index()) + " " + compare_values_eq(tval[0]);
1376}
1377
1378TRIGGER_FUNCTION(tf_has_unclaimed_cores) {
1379 return "dup >index state-ptr @ unowned-core " + truth_inversion(tval[0]);
1380}
1381TRIGGER_FUNCTION(tf_have_core_in_nation_tag) {
1382 return "dup identity_holder-nation @ identity >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id identity_holder-identity nation @ >index state-ptr @ core-in-nation " + truth_inversion(tval[0]);
1383}
1384TRIGGER_FUNCTION(tf_have_core_in_nation_this) {
1385 return "dup identity_holder-nation @ identity >index >r >r dup >index r> swap r> swap state-ptr @ core-in-nation " + truth_inversion(tval[0]);
1386}
1387TRIGGER_FUNCTION(tf_have_core_in_nation_from) {
1388 return "dup identity_holder-nation @ identity >index >r >r >r dup >index r> swap r> swap r> swap state-ptr @ core-in-nation " + truth_inversion(tval[0]);
1389}
1390
1391TRIGGER_FUNCTION(tf_is_cultural_union_bool) {
1392 return "dup identity_holder-nation @ identity cultural_union_of-identity @ valid? " + truth_inversion(tval[0]);
1393}
1394TRIGGER_FUNCTION(tf_is_cultural_union_this_self_pop) {
1395 return "dup culture @ culture_group_membership-member group @ >r >r "
1396 "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group r> swap r> = " + truth_inversion(tval[0]);
1397}
1398TRIGGER_FUNCTION(tf_is_cultural_union_pop_this_pop) {
1399 return "dup culture @ culture_group_membership-member group @ >r >r "
1400 "dup " + pop_to_owner() + "identity_holder-nation @ identity cultural_union_of-identity @ culture_group r> swap r> = " + truth_inversion(tval[0]);
1401}
1402TRIGGER_FUNCTION(tf_is_cultural_union_this_nation) {
1403 return "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group >r >r "
1404 "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group r> swap r> = " + truth_inversion(tval[0]);
1405}
1406TRIGGER_FUNCTION(tf_is_cultural_union_this_pop) {
1407 return "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group >r >r "
1408 "dup " + pop_to_owner() + "identity_holder-nation @ identity cultural_union_of-identity @ culture_group r> swap r> = " + truth_inversion(tval[0]);
1409}
1410TRIGGER_FUNCTION(tf_is_cultural_union_this_state) {
1411 return "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group >r >r "
1412 "dup " + state_to_owner() + "identity_holder-nation @ identity cultural_union_of-identity @ culture_group r> swap r> = " + truth_inversion(tval[0]);
1413}
1414TRIGGER_FUNCTION(tf_is_cultural_union_this_province) {
1415 return "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group >r >r "
1416 "dup " + province_to_owner() + "identity_holder-nation @ identity cultural_union_of-identity @ culture_group r> swap r> = " + truth_inversion(tval[0]);
1417}
1418TRIGGER_FUNCTION(tf_is_cultural_union_this_rebel) {
1419 return "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group >r >r >r "
1420 "dup primary_culture @ culture_group_membership-member group @ r> swap r> swap r> = " + truth_inversion(tval[0]);
1421}
1422TRIGGER_FUNCTION(tf_is_cultural_union_tag_nation) {
1423 return "dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ >index "
1424 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " = >r "
1425 "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group "
1426 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id cultural_union_of-identity @ culture_group = "
1427 "r> or " + truth_inversion(tval[0]);
1428}
1429TRIGGER_FUNCTION(tf_is_cultural_union_tag_this_pop) {
1430 return ">r dup culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ >index "
1431 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " = r> swap " + truth_inversion(tval[0]);
1432}
1433TRIGGER_FUNCTION(tf_is_cultural_union_tag_this_state) {
1434 return ">r dup " + state_to_owner() + "primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ >index "
1435 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " = >r "
1436 "dup " + state_to_owner() + "identity_holder-nation @ identity cultural_union_of-identity @ culture_group "
1437 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id cultural_union_of-identity @ culture_group = "
1438 "r> or r> swap" + truth_inversion(tval[0]);
1439}
1440TRIGGER_FUNCTION(tf_is_cultural_union_tag_this_province) {
1441 return ">r dup " + state_to_owner() + "primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ >index "
1442 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " = >r "
1443 "dup " + state_to_owner() + "identity_holder-nation @ identity cultural_union_of-identity @ culture_group "
1444 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id cultural_union_of-identity @ culture_group = "
1445 "r> or r> swap" + truth_inversion(tval[0]);
1446}
1447TRIGGER_FUNCTION(tf_is_cultural_union_tag_this_nation) {
1448 return ">r dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ >index "
1449 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " = >r "
1450 "dup identity_holder-nation @ identity cultural_union_of-identity @ culture_group "
1451 + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id cultural_union_of-identity @ culture_group = "
1452 "r> or r> swap" + truth_inversion(tval[0]);
1453}
1454TRIGGER_FUNCTION(tf_can_build_factory_nation) {
1455 return "dup combined_issue_rules @ >i32 " + std::to_string(issue_rule::pop_build_factory) + " and 0 <> " + truth_inversion(tval[0]);
1456}
1457TRIGGER_FUNCTION(tf_can_build_factory_province) {
1458 return "dup " + province_to_owner() + "combined_issue_rules @ >i32 " + std::to_string(issue_rule::pop_build_factory) + " and 0 <> " + truth_inversion(tval[0]);
1459}
1460TRIGGER_FUNCTION(tf_can_build_factory_pop) {
1461 return "dup " + pop_to_owner() + "combined_issue_rules @ >i32 " + std::to_string(issue_rule::pop_build_factory) + " and 0 <> " + truth_inversion(tval[0]);
1462}
1463TRIGGER_FUNCTION(tf_war_nation) {
1464 return "dup is_at_war @ " + truth_inversion(tval[0]);
1465}
1466TRIGGER_FUNCTION(tf_war_pop) {
1467 return "dup " + pop_to_owner() + "is_at_war @ " + truth_inversion(tval[0]);
1468}
1469TRIGGER_FUNCTION(tf_war_exhaustion_nation) {
1470 return "dup war_exhaustion @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1471}
1472TRIGGER_FUNCTION(tf_war_exhaustion_province) {
1473 return "dup " + province_to_owner() + "war_exhaustion @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1474}
1475TRIGGER_FUNCTION(tf_war_exhaustion_pop) {
1476 return "dup " + pop_to_owner() + "war_exhaustion @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1477}
1478TRIGGER_FUNCTION(tf_blockade) {
1479 return "dup central_ports @ >f32 >r dup central_blockaded @ >f32 r@ / 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1480}
1481TRIGGER_FUNCTION(tf_diplo_points) {
1482 return "dup diplomatic_points @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1483}
1485 return "dup " + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + province_to_owner() + " = " + truth_inversion(tval[0]);
1486}
1487TRIGGER_FUNCTION(tf_owns_province) {
1488 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + province_to_owner() + " = " + truth_inversion(tval[0]);
1489}
1490TRIGGER_FUNCTION(tf_controls) {
1491 return "dup " + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + province_to_controller() + " = " + truth_inversion(tval[0]);
1492}
1493TRIGGER_FUNCTION(tf_is_core_integer) {
1494 return "dup " + nation_to_tag() + ">index " + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " state-ptr @ core-in-province " + truth_inversion(tval[0]);
1495}
1496TRIGGER_FUNCTION(tf_is_core_this_nation) {
1497 return "dup >index >r >r dup " + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-province " + truth_inversion(tval[0]);
1498}
1499TRIGGER_FUNCTION(tf_is_core_this_state) {
1500 return "dup >index >r >r dup " + state_to_owner() + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-province " + truth_inversion(tval[0]);
1501}
1502TRIGGER_FUNCTION(tf_is_core_this_province) {
1503 return "dup >index >r >r dup " + province_to_owner() + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-province " + truth_inversion(tval[0]);
1504}
1505TRIGGER_FUNCTION(tf_is_core_this_pop) {
1506 return "dup >index >r >r dup " + pop_to_owner() + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-province " + truth_inversion(tval[0]);
1507}
1508TRIGGER_FUNCTION(tf_is_core_from_nation) {
1509 return "dup >index >r >r >r dup " + nation_to_tag() + ">index r> swap r> swap r> state-ptr @ core-in-province " + truth_inversion(tval[0]);
1510}
1511TRIGGER_FUNCTION(tf_is_core_reb) {
1512 return "dup >index >r >r >r dup defection_target @ >index r> swap r> swap r> state-ptr @ core-in-province " + truth_inversion(tval[0]);
1513}
1514TRIGGER_FUNCTION(tf_is_core_state_from_nation) {
1515 return "dup >index >r >r >r dup " + nation_to_tag() + ">index r> swap r> swap r> state-ptr @ core-in-state " + truth_inversion(tval[0]);
1516}
1517TRIGGER_FUNCTION(tf_is_core_state_this_nation) {
1518 return "dup >index >r >r dup " + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-state " + truth_inversion(tval[0]);
1519}
1520TRIGGER_FUNCTION(tf_is_core_state_this_province) {
1521 return "dup >index >r >r dup " + province_to_owner() + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-state " + truth_inversion(tval[0]);
1522}
1523TRIGGER_FUNCTION(tf_is_core_state_this_pop) {
1524 return "dup >index >r >r dup " + pop_to_owner() + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-state " + truth_inversion(tval[0]);
1525}
1526TRIGGER_FUNCTION(tf_is_core_boolean) {
1527 return "dup is_owner_core @ " + truth_inversion(tval[0]);
1528}
1529TRIGGER_FUNCTION(tf_is_core_tag) {
1530 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " swap state-ptr @ core-in-province " + truth_inversion(tval[0]);
1531}
1532TRIGGER_FUNCTION(tf_is_core_pop_tag) {
1533 return "dup " + pop_to_location() + ">index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " swap state-ptr @ core-in-province " + truth_inversion(tval[0]);
1534}
1535TRIGGER_FUNCTION(tf_is_core_state_tag) {
1536 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " swap state-ptr @ core-fully-state " + truth_inversion(tval[0]);
1537}
1538TRIGGER_FUNCTION(tf_num_of_revolts) {
1539 return "dup rebel_controlled_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1540}
1541TRIGGER_FUNCTION(tf_revolt_percentage) {
1542 return "dup central_province_count @ >f32 >r dup central_rebel_controlled @ >f32 r@ / 0.0 r> 0.0 <= select "
1543 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1544}
1545TRIGGER_FUNCTION(tf_num_of_cities_int) {
1546 return "dup owned_province_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1547}
1548TRIGGER_FUNCTION(tf_num_of_cities_from_nation) {
1549 return ">r >r dup owned_province_count @ r> swap r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1550}
1551TRIGGER_FUNCTION(tf_num_of_cities_this_nation) {
1552 return ">r dup owned_province_count @ r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1553}
1554TRIGGER_FUNCTION(tf_num_of_cities_this_state) {
1555 return ">r dup " + state_to_owner() + "owned_province_count @ r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1556}
1557TRIGGER_FUNCTION(tf_num_of_cities_this_province) {
1558 return ">r dup " + province_to_owner() + "owned_province_count @ r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1559}
1560TRIGGER_FUNCTION(tf_num_of_cities_this_pop) {
1561 return ">r dup " + pop_to_owner() + "owned_province_count @ r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1562}
1563TRIGGER_FUNCTION(tf_num_of_ports) {
1564 return "dup central_ports @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1565}
1566TRIGGER_FUNCTION(tf_num_of_allies) {
1567 return "dup allies_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1568}
1569TRIGGER_FUNCTION(tf_num_of_vassals) {
1570 return "dup vassals_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1571}
1572TRIGGER_FUNCTION(tf_owned_by_tag) {
1573 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "= " + truth_inversion(tval[0]);
1574}
1575TRIGGER_FUNCTION(tf_owned_by_this_nation) {
1576 return ">r dup r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1577}
1578TRIGGER_FUNCTION(tf_owned_by_from_nation) {
1579 return ">r >r dup r> swap r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1580}
1581TRIGGER_FUNCTION(tf_owned_by_this_province) {
1582 return ">r dup " + province_to_owner() + "r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1583}
1584TRIGGER_FUNCTION(tf_owned_by_this_state) {
1585 return ">r dup " + state_to_owner() + "r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1586}
1587TRIGGER_FUNCTION(tf_owned_by_this_pop) {
1588 return ">r dup " + pop_to_owner() + "r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1589}
1590TRIGGER_FUNCTION(tf_owned_by_state_tag) {
1591 return "dup " + state_to_owner() + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "= " + truth_inversion(tval[0]);
1592}
1593TRIGGER_FUNCTION(tf_owned_by_state_this_nation) {
1594 return ">r dup r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1595}
1596TRIGGER_FUNCTION(tf_owned_by_state_from_nation) {
1597 return ">r >r dup r> swap r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1598}
1599TRIGGER_FUNCTION(tf_owned_by_state_this_province) {
1600 return ">r dup " + province_to_owner() + "r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1601}
1602TRIGGER_FUNCTION(tf_owned_by_state_this_state) {
1603 return ">r dup " + state_to_owner() + "r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1604}
1605TRIGGER_FUNCTION(tf_owned_by_state_this_pop) {
1606 return ">r dup " + pop_to_owner() + "r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1607}
1608TRIGGER_FUNCTION(tf_exists_bool) {
1609 return "dup owned_province_count @ >i32 0 <> " + truth_inversion(tval[0]);
1610}
1611TRIGGER_FUNCTION(tf_exists_tag) {
1612 return std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "owned_province_count @ >i32 0 <> " + truth_inversion(tval[0]);
1613}
1614TRIGGER_FUNCTION(tf_has_country_flag) {
1615 return "dup " + std::to_string(trigger::payload(tval[1]).natf_id.index()) + " >national_flag_id flag_variables @ " + truth_inversion(tval[0]);
1616}
1617TRIGGER_FUNCTION(tf_has_country_flag_pop) {
1618 return "dup " + pop_to_owner() + std::to_string(trigger::payload(tval[1]).natf_id.index()) + " >national_flag_id flag_variables @ " + truth_inversion(tval[0]);
1619}
1620TRIGGER_FUNCTION(tf_has_country_flag_province) {
1621 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).natf_id.index()) + " >national_flag_id flag_variables @ " + truth_inversion(tval[0]);
1622}
1623TRIGGER_FUNCTION(tf_has_country_flag_state) {
1624 return "dup " + state_to_owner() + std::to_string(trigger::payload(tval[1]).natf_id.index()) + " >national_flag_id flag_variables @ " + truth_inversion(tval[0]);
1625}
1626TRIGGER_FUNCTION(tf_continent_province) {
1627 return "dup continent @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1628}
1629TRIGGER_FUNCTION(tf_continent_state) {
1630 return "dup capital @ continent @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1631}
1632TRIGGER_FUNCTION(tf_continent_nation) {
1633 return "dup capital @ continent @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1634}
1635TRIGGER_FUNCTION(tf_continent_pop) {
1636 return "dup " + pop_to_location() + "continent @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1637}
1638TRIGGER_FUNCTION(tf_continent_nation_this) {
1639 return ">r dup capital @ continent @ r> swap >r dup capital @ continent @ r> = " + truth_inversion(tval[0]);
1640}
1641TRIGGER_FUNCTION(tf_continent_state_this) {
1642 return ">r dup capital @ continent @ r> swap >r dup capital @ continent @ r> = " + truth_inversion(tval[0]);
1643}
1644TRIGGER_FUNCTION(tf_continent_province_this) {
1645 return ">r dup capital @ continent @ r> swap >r dup continent @ r> = " + truth_inversion(tval[0]);
1646}
1647TRIGGER_FUNCTION(tf_continent_pop_this) {
1648 return ">r dup capital @ continent @ r> swap >r dup " + pop_to_location() + "continent @ r> = " + truth_inversion(tval[0]);
1649}
1650TRIGGER_FUNCTION(tf_continent_nation_from) {
1651 return ">r >r dup capital @ continent @ r> swap r> swap >r dup capital @ continent @ r> = " + truth_inversion(tval[0]);
1652}
1653TRIGGER_FUNCTION(tf_continent_state_from) {
1654 return ">r >r dup capital @ continent @ r> swap r> swap >r dup capital @ continent @ r> = " + truth_inversion(tval[0]);
1655}
1656TRIGGER_FUNCTION(tf_continent_province_from) {
1657 return ">r >r dup capital @ continent @ r> swap r> swap >r dup continent @ r> = " + truth_inversion(tval[0]);
1658}
1659TRIGGER_FUNCTION(tf_continent_pop_from) {
1660 return ">r >r dup capital @ continent @ r> swap r> swap >r dup " + pop_to_location() + "continent @ r> = " + truth_inversion(tval[0]);
1661}
1662TRIGGER_FUNCTION(tf_casus_belli_tag) {
1663 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + ">index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1664}
1665TRIGGER_FUNCTION(tf_casus_belli_from) {
1666 return ">r >r dup r> swap r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1667}
1668TRIGGER_FUNCTION(tf_casus_belli_this_nation) {
1669 return ">r >dup r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1670}
1671TRIGGER_FUNCTION(tf_casus_belli_this_state) {
1672 return ">r >dup " + state_to_owner() + "r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1673}
1674TRIGGER_FUNCTION(tf_casus_belli_this_province) {
1675 return ">r >dup " + province_to_owner() + "r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1676}
1677TRIGGER_FUNCTION(tf_casus_belli_this_pop) {
1678 return ">r >dup " + pop_to_owner() + "r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1679}
1680TRIGGER_FUNCTION(tf_military_access_tag) {
1681 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + ">index state-ptr @ has-access-with " + truth_inversion(tval[0]);
1682}
1683TRIGGER_FUNCTION(tf_military_access_from) {
1684 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1685}
1686TRIGGER_FUNCTION(tf_military_access_this_nation) {
1687 return ">r dup >index r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1688}
1689TRIGGER_FUNCTION(tf_military_access_this_state) {
1690 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1691}
1692TRIGGER_FUNCTION(tf_military_access_this_province) {
1693 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1694}
1695TRIGGER_FUNCTION(tf_military_access_this_pop) {
1696 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1697}
1698TRIGGER_FUNCTION(tf_prestige_value) {
1699 return "dup prestige @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1700}
1701TRIGGER_FUNCTION(tf_prestige_from) {
1702 return ">r >r dup prestige @ r> swap r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1703}
1704TRIGGER_FUNCTION(tf_prestige_this_nation) {
1705 return ">r dup prestige @ r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1706}
1707TRIGGER_FUNCTION(tf_prestige_this_state) {
1708 return ">r dup " + state_to_owner() + "prestige @ r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1709}
1710TRIGGER_FUNCTION(tf_prestige_this_province) {
1711 return ">r dup " + province_to_owner() + "prestige @ r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1712}
1713TRIGGER_FUNCTION(tf_prestige_this_pop) {
1714 return ">r dup " + pop_to_owner() + "prestige @ r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1715}
1717 return "dup infamy @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1718}
1719TRIGGER_FUNCTION(tf_has_building_fort) {
1720 return "dup " + std::to_string(int32_t(economy::province_building_type::fort)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
1721}
1722TRIGGER_FUNCTION(tf_has_building_railroad) {
1723 return "dup " + std::to_string(int32_t(economy::province_building_type::railroad)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
1724}
1725TRIGGER_FUNCTION(tf_has_building_naval_base) {
1726 return "dup " + std::to_string(int32_t(economy::province_building_type::naval_base)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
1727}
1728TRIGGER_FUNCTION(tf_has_building_factory) {
1729 return "dup >index state-ptr @ has-any-factory " + truth_inversion(tval[0]);
1730}
1731TRIGGER_FUNCTION(tf_has_building_state) {
1732 return "dup >index " + std::to_string(trigger::payload(tval[1]).fac_id.index()) + " state-ptr @ has-factory " + truth_inversion(tval[0]);
1733}
1734TRIGGER_FUNCTION(tf_has_building_state_from_province) {
1735 return "dup state_membership @ >index " + std::to_string(trigger::payload(tval[1]).fac_id.index()) + " state-ptr @ has-factory " + truth_inversion(tval[0]);
1736}
1737TRIGGER_FUNCTION(tf_has_building_factory_from_province) {
1738 return "dup state_membership @ >index state-ptr @ has-any-factory " + truth_inversion(tval[0]);
1739}
1741 return "dup " + province_to_owner() + "make nation_id = " + truth_inversion(tval[0]);
1742}
1743TRIGGER_FUNCTION(tf_empty_state) {
1744 return "dup make state_instance_id = " + truth_inversion(tval[0]);
1745}
1746TRIGGER_FUNCTION(tf_is_blockaded) {
1747 return "dup is_blockaded @ " + truth_inversion(tval[0]);
1748}
1749TRIGGER_FUNCTION(tf_has_country_modifier) {
1750 return "dup >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " state-ptr @ has-nmod " + truth_inversion(tval[0]);
1751}
1752TRIGGER_FUNCTION(tf_has_country_modifier_province) {
1753 return "dup " + province_to_owner() + ">index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " state-ptr @ has-nmod " + truth_inversion(tval[0]);
1754}
1755TRIGGER_FUNCTION(tf_has_province_modifier) {
1756 return "dup >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " state-ptr @ has-pmod " + truth_inversion(tval[0]);
1757}
1759 return "dup abstract_state_membership-province state @ >index " + std::to_string(trigger::payload(tval[1]).state_id.index()) + " " + compare_values_eq(tval[0]);
1760}
1761TRIGGER_FUNCTION(tf_region_state) {
1762 return "dup definition @ >index " + std::to_string(trigger::payload(tval[1]).state_id.index()) + " " + compare_values_eq(tval[0]);
1763}
1764TRIGGER_FUNCTION(tf_region_pop) {
1765 return "dup " + pop_to_location() + "abstract_state_membership-province state @ >index " + std::to_string(trigger::payload(tval[1]).state_id.index()) + " " + compare_values_eq(tval[0]);
1766}
1767
1768TRIGGER_FUNCTION(tf_region_proper) {
1769 return "dup >index " + std::to_string(trigger::payload(tval[1]).reg_id.index()) + " state-ptr @ in-region " + truth_inversion(tval[0]);
1770}
1771TRIGGER_FUNCTION(tf_region_proper_state) {
1772 return "dup capital @ >index " + std::to_string(trigger::payload(tval[1]).reg_id.index()) + " state-ptr @ in-region " + truth_inversion(tval[0]);
1773}
1774TRIGGER_FUNCTION(tf_region_proper_pop) {
1775 return "dup " + pop_to_location() + ">index " + std::to_string(trigger::payload(tval[1]).reg_id.index()) + " state-ptr @ in-region " + truth_inversion(tval[0]);
1776}
1777TRIGGER_FUNCTION(tf_owns_region_proper) {
1778 return "dup >index " + std::to_string(trigger::payload(tval[1]).reg_id.index()) + " state-ptr @ owns-region " + truth_inversion(tval[0]);
1779}
1780TRIGGER_FUNCTION(tf_owns_region) {
1781 return "dup >index " + std::to_string(trigger::payload(tval[1]).state_id.index()) + " state-ptr @ owns-state " + truth_inversion(tval[0]);
1782}
1783TRIGGER_FUNCTION(tf_tag_tag) {
1784 return "dup " + nation_to_tag() + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id = " + truth_inversion(tval[0]);
1785}
1786TRIGGER_FUNCTION(tf_tag_this_nation) {
1787 return "2dup = " + truth_inversion(tval[0]);
1788}
1789TRIGGER_FUNCTION(tf_tag_this_province) {
1790 return ">r dup " + province_to_owner() + " r> swap >r dup r> = " + truth_inversion(tval[0]);
1791}
1792TRIGGER_FUNCTION(tf_tag_from_nation) {
1793 return ">r >r dup r> swap r> swap >r dup r> = " + truth_inversion(tval[0]);
1794}
1795TRIGGER_FUNCTION(tf_tag_from_province) {
1796 return ">r >r dup " + province_to_owner() + " r> swap r> swap >r dup r> = " + truth_inversion(tval[0]);
1797}
1798TRIGGER_FUNCTION(tf_tag_pop) {
1799 return "dup " + pop_to_owner() + nation_to_tag() + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id = " + truth_inversion(tval[0]);
1800}
1801TRIGGER_FUNCTION(tf_stronger_army_than_tag) {
1802 return "dup active_regiments @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "active_regiments @ " + compare_values(tval[0]);
1803}
1804TRIGGER_FUNCTION(tf_stronger_army_than_this_nation) {
1805 return ">r dup active_regiments @ r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1806}
1807TRIGGER_FUNCTION(tf_stronger_army_than_this_state) {
1808 return ">r dup " + state_to_owner() + "active_regiments @ r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1809}
1810TRIGGER_FUNCTION(tf_stronger_army_than_this_province) {
1811 return ">r dup " + province_to_owner() + "active_regiments @ r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1812}
1813TRIGGER_FUNCTION(tf_stronger_army_than_this_pop) {
1814 return ">r dup " + pop_to_owner() + "active_regiments @ r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1815}
1816TRIGGER_FUNCTION(tf_stronger_army_than_from_nation) {
1817 return ">r >r dup active_regiments @ r> swap r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1818}
1819TRIGGER_FUNCTION(tf_stronger_army_than_from_province) {
1820 return ">r >r dup " + province_to_owner() + "active_regiments @ r> swap r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1821}
1822TRIGGER_FUNCTION(tf_neighbour_tag) {
1823 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + " >index state-ptr @ nation-a " + truth_inversion(tval[0]);
1824}
1825TRIGGER_FUNCTION(tf_neighbour_this) {
1826 return ">r dup >index r> swap >r dup >index r> state-ptr @ nation-a " + truth_inversion(tval[0]);
1827}
1828TRIGGER_FUNCTION(tf_neighbour_from) {
1829 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ nation-a " + truth_inversion(tval[0]);
1830}
1831TRIGGER_FUNCTION(tf_neighbour_this_province) {
1832 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ nation-a " + truth_inversion(tval[0]);
1833}
1834TRIGGER_FUNCTION(tf_neighbour_from_province) {
1835 return ">r >r dup " + province_to_owner() + ">index r> swap r> swap >r dup >index r> state-ptr @ nation-a " + truth_inversion(tval[0]);
1836}
1837TRIGGER_FUNCTION(tf_country_units_in_state_from) {
1838 return ">r >r dup >index r> swap r> swap >r dup >index r> swap state-ptr @ units-in-state " + truth_inversion(tval[0]);
1839}
1840TRIGGER_FUNCTION(tf_country_units_in_state_this_nation) {
1841 return ">r dup >index r> swap >r dup >index r> swap state-ptr @ units-in-state " + truth_inversion(tval[0]);
1842}
1843TRIGGER_FUNCTION(tf_country_units_in_state_this_province) {
1844 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> swap state-ptr @ units-in-state " + truth_inversion(tval[0]);
1845}
1846TRIGGER_FUNCTION(tf_country_units_in_state_this_state) {
1847 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> swap state-ptr @ units-in-state " + truth_inversion(tval[0]);
1848}
1849TRIGGER_FUNCTION(tf_country_units_in_state_this_pop) {
1850 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> swap state-ptr @ units-in-state " + truth_inversion(tval[0]);
1851}
1852TRIGGER_FUNCTION(tf_country_units_in_state_tag) {
1853 return std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + ">index >r dup >index r> swap state-ptr @ units-in-state " + truth_inversion(tval[0]);
1854}
1855TRIGGER_FUNCTION(tf_units_in_province_value) {
1856 return "dup >index state-ptr @ count-p-units " + std::to_string(int32_t(tval[1])) + " " + compare_values(tval[0]);
1857}
1858TRIGGER_FUNCTION(tf_units_in_province_tag) {
1859 return "dup >index >r " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + ">index r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1860}
1861
1862TRIGGER_FUNCTION(tf_units_in_province_from) {
1863 return "dup >index >r >r >r dup >index r> swap r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1864}
1865TRIGGER_FUNCTION(tf_units_in_province_this_nation) {
1866 return "dup >index >r >r dup >index r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1867}
1868TRIGGER_FUNCTION(tf_units_in_province_this_province) {
1869 return "dup >index >r >r dup " + province_to_owner() + ">index r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1870}
1871TRIGGER_FUNCTION(tf_units_in_province_this_state) {
1872 return "dup >index >r >r dup " + state_to_owner() + ">index r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1873}
1874TRIGGER_FUNCTION(tf_units_in_province_this_pop) {
1875 return "dup >index >r >r dup " + pop_to_owner() + ">index r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1876}
1877TRIGGER_FUNCTION(tf_war_with_tag) {
1878 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + ">index state-ptr @ at-war? " + truth_inversion(tval[0]);
1879}
1880TRIGGER_FUNCTION(tf_war_with_from) {
1881 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1882}
1883TRIGGER_FUNCTION(tf_war_with_this_nation) {
1884 return ">r dup >index r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1885}
1886TRIGGER_FUNCTION(tf_war_with_this_province) {
1887 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1888}
1889TRIGGER_FUNCTION(tf_war_with_this_state) {
1890 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1891}
1892TRIGGER_FUNCTION(tf_war_with_this_pop) {
1893 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1894}
1895TRIGGER_FUNCTION(tf_unit_in_battle) {
1896 return "dup land_battle_location-location size 0 <> " + truth_inversion(tval[0]);
1897}
1898TRIGGER_FUNCTION(tf_unit_has_leader) {
1899 return "dup >index state-ptr @ general-in-province? " + truth_inversion(tval[0]);
1900}
1901TRIGGER_FUNCTION(tf_has_national_focus_state) {
1902 return "dup owner_focus @ >index " + std::to_string(trigger::payload(tval[1]).nf_id.index()) + " " + compare_values_eq(tval[0]);
1903}
1904TRIGGER_FUNCTION(tf_has_national_focus_province) {
1905 return "dup state_membership @ owner_focus @ >index " + std::to_string(trigger::payload(tval[1]).nf_id.index()) + " " + compare_values_eq(tval[0]);
1906}
1907TRIGGER_FUNCTION(tf_total_amount_of_divisions) {
1908 return "dup active_regiments @ >i32 " + std::to_string(int32_t(tval[1])) + " " + compare_values(tval[0]);
1909}
1911 return "dup 0 >commodity_id @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1912}
1913TRIGGER_FUNCTION(tf_money_province) {
1914 return "dup " + province_to_owner() + "0 >commodity_id @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1915}
1916TRIGGER_FUNCTION(tf_lost_national) {
1917 return "dup revanchism @ 1.0 swap - " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1918}
1919TRIGGER_FUNCTION(tf_is_vassal) {
1920 return "dup overlord-subject ruler @ valid? " + truth_inversion(tval[0]);
1921}
1922TRIGGER_FUNCTION(tf_ruling_party_ideology_nation) {
1923 return "dup ruling_party @ ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " " + compare_values_eq(tval[0]);
1924}
1925TRIGGER_FUNCTION(tf_ruling_party_ideology_pop) {
1926 return "dup " + pop_to_owner() + "ruling_party @ ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " " + compare_values_eq(tval[0]);
1927}
1928TRIGGER_FUNCTION(tf_ruling_party_ideology_province) {
1929 return "dup " + province_to_owner() + "ruling_party @ ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " " + compare_values_eq(tval[0]);
1930}
1931TRIGGER_FUNCTION(tf_ruling_party) {
1932 return "dup ruling_party @ name @ >index " + std::to_string(read_int32_t_from_payload(tval + 1)) + " " + compare_values_eq(tval[0]);
1933}
1934TRIGGER_FUNCTION(tf_is_ideology_enabled) {
1935 return std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " >ideology_id enabled @ " + truth_inversion(tval[0]);
1936}
1937TRIGGER_FUNCTION(tf_political_reform_want_nation) {
1938 return "dup dup >r " + std::to_string(demographics::political_reform_desire.index()) + " >demographics_key demographics @ " + std::to_string(ws.defines.movement_support_uh_factor) + " * r> non_colonial_population @ / " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1939}
1940TRIGGER_FUNCTION(tf_political_reform_want_pop) {
1941 return "dup upolitical_reform_desire @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1942}
1943TRIGGER_FUNCTION(tf_social_reform_want_nation) {
1944 return "dup dup >r " + std::to_string(demographics::social_reform_desire.index()) + " >demographics_key demographics @ " + std::to_string(ws.defines.movement_support_uh_factor) + " * r> non_colonial_population @ / " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1945}
1946TRIGGER_FUNCTION(tf_social_reform_want_pop) {
1947 return "dup usocial_reform_desire @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1948}
1949TRIGGER_FUNCTION(tf_total_amount_of_ships) {
1950 return "dup >index state-ptr @ count-ships " + std::to_string(int32_t(tval[1])) + " " + compare_values(tval[0]);
1951}
1952TRIGGER_FUNCTION(tf_plurality) {
1953 return "dup plurality @ " + std::to_string(read_float_from_payload(tval + 1)) + " 100.0 / " + compare_values(tval[0]);
1954}
1955TRIGGER_FUNCTION(tf_plurality_pop) {
1956 return "dup " + pop_to_owner() + "plurality @ " + std::to_string(read_float_from_payload(tval + 1)) + " 100.0 / " + compare_values(tval[0]);
1957}
1958TRIGGER_FUNCTION(tf_corruption) {
1959 return "dup central_province_count @ >f32 >r dup central_crime_count @ >f32 r@ / 0.0 r> 0.0 <= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1960}
1961TRIGGER_FUNCTION(tf_is_state_religion_pop) {
1962 return " dup >r r@ " + pop_to_owner() + "religion @ r> religion @ = " + truth_inversion(tval[0]);
1963}
1964TRIGGER_FUNCTION(tf_is_state_religion_province) {
1965 return " dup >r r@ " + province_to_owner() + "religion @ r> dominant_religion @ = " + truth_inversion(tval[0]);
1966}
1967TRIGGER_FUNCTION(tf_is_state_religion_state) {
1968 return " dup >r r@ " + state_to_owner() + "religion @ r> dominant_religion @ = " + truth_inversion(tval[0]);
1969}
1970TRIGGER_FUNCTION(tf_is_primary_culture_pop) {
1971 return " dup >r r@ " + pop_to_owner() + "primary_culture @ r> culture @ = " + truth_inversion(tval[0]);
1972}
1973TRIGGER_FUNCTION(tf_is_primary_culture_province) {
1974 return " dup >r r@ " + province_to_owner() + "primary_culture @ r> dominant_culture @ = " + truth_inversion(tval[0]);
1975}
1976TRIGGER_FUNCTION(tf_is_primary_culture_state) {
1977 return " dup >r r@ " + state_to_owner() + "primary_culture @ r> dominant_culture @ = " + truth_inversion(tval[0]);
1978}
1979TRIGGER_FUNCTION(tf_primary_culture_from_nation) {
1980 return ">r >r dup r> swap r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1981}
1982TRIGGER_FUNCTION(tf_primary_culture_from_province) {
1983 return ">r >r dup " + province_to_owner() + "r> swap r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1984}
1985TRIGGER_FUNCTION(tf_is_primary_culture_nation_this_nation) {
1986 return ">r dup r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1987}
1988TRIGGER_FUNCTION(tf_is_primary_culture_nation_this_pop) {
1989 return ">r dup culture @ r> swap >r dup primary_culture @ r> = " + truth_inversion(tval[0]);
1990}
1991TRIGGER_FUNCTION(tf_is_primary_culture_nation_this_state) {
1992 return ">r dup " + state_to_owner() + "r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1993}
1994TRIGGER_FUNCTION(tf_is_primary_culture_nation_this_province) {
1995 return ">r dup " + province_to_owner() + "r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1996}
1997TRIGGER_FUNCTION(tf_is_primary_culture_state_this_nation) {
1998 return ">r dup r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1999}
2000TRIGGER_FUNCTION(tf_is_primary_culture_state_this_pop) {
2001 return ">r dup " + pop_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2002}
2003TRIGGER_FUNCTION(tf_is_primary_culture_state_this_state) {
2004 return ">r dup " + state_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2005}
2006TRIGGER_FUNCTION(tf_is_primary_culture_state_this_province) {
2007 return ">r dup " + province_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2008}
2009TRIGGER_FUNCTION(tf_is_primary_culture_province_this_nation) {
2010 return ">r dup r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2011}
2012TRIGGER_FUNCTION(tf_is_primary_culture_province_this_pop) {
2013 return ">r dup " + pop_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2014}
2015TRIGGER_FUNCTION(tf_is_primary_culture_province_this_state) {
2016 return ">r dup " + state_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2017}
2018TRIGGER_FUNCTION(tf_is_primary_culture_province_this_province) {
2019 return ">r dup " + province_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2020}
2021TRIGGER_FUNCTION(tf_is_primary_culture_pop_this_nation) {
2022 return ">r dup r> swap >r dup culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2023}
2024TRIGGER_FUNCTION(tf_is_primary_culture_pop_this_pop) {
2025 return ">r dup " + pop_to_owner() + "r> swap >r dup culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2026}
2027TRIGGER_FUNCTION(tf_is_primary_culture_pop_this_state) {
2028 return ">r dup " + state_to_owner() + "r> swap >r dup culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2029}
2030TRIGGER_FUNCTION(tf_is_primary_culture_pop_this_province) {
2031 return ">r dup " + province_to_owner() + "r> swap >r dup culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2032}
2033
2034TRIGGER_FUNCTION(tf_is_accepted_culture_nation_this_nation) {
2035 return ">r dup primary_culture @ r> swap >r dup r> accepted_cultures @ " + truth_inversion(tval[0]);
2036}
2037TRIGGER_FUNCTION(tf_is_accepted_culture_nation_this_pop) {
2038 return ">r dup culture @ r> swap >r dup r> accepted_cultures @ " + truth_inversion(tval[0]);
2039}
2040TRIGGER_FUNCTION(tf_is_accepted_culture_nation_this_state) {
2041 return ">r dup " + state_to_owner() + "primary_culture @ r> swap >r dup r> accepted_cultures @ " + truth_inversion(tval[0]);
2042}
2043TRIGGER_FUNCTION(tf_is_accepted_culture_nation_this_province) {
2044 return ">r dup " + province_to_owner() + "primary_culture @ r> swap >r dup r> accepted_cultures @ " + truth_inversion(tval[0]);
2045}
2046TRIGGER_FUNCTION(tf_is_accepted_culture_state_this_nation) {
2047 return ">r dup primary_culture @ r> swap >r dup " + state_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2048}
2049TRIGGER_FUNCTION(tf_is_accepted_culture_state_this_pop) {
2050 return ">r dup " + pop_to_owner() + "primary_culture @ r> swap >r dup " + state_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2051}
2052TRIGGER_FUNCTION(tf_is_accepted_culture_state_this_state) {
2053 return ">r dup " + state_to_owner() + "primary_culture @ r> swap >r dup " + state_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2054}
2055TRIGGER_FUNCTION(tf_is_accepted_culture_state_this_province) {
2056 return ">r dup " + province_to_owner() + "primary_culture @ r> swap >r dup " + state_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2057}
2058TRIGGER_FUNCTION(tf_is_accepted_culture_province_this_nation) {
2059 return ">r dup primary_culture @ r> swap >r dup " + province_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2060}
2061TRIGGER_FUNCTION(tf_is_accepted_culture_province_this_pop) {
2062 return ">r dup " + pop_to_owner() + "primary_culture @ r> swap >r dup " + province_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2063}
2064TRIGGER_FUNCTION(tf_is_accepted_culture_province_this_state) {
2065 return ">r dup " + state_to_owner() + "primary_culture @ r> swap >r dup " + province_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2066}
2067TRIGGER_FUNCTION(tf_is_accepted_culture_province_this_province) {
2068 return ">r dup " + province_to_owner() + "primary_culture @ r> swap >r dup " + province_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2069}
2070TRIGGER_FUNCTION(tf_is_accepted_culture_pop_this_nation) {
2071 return ">r dup r> swap >r dup culture r> swap accepted_cultures @ " + truth_inversion(tval[0]);
2072}
2073TRIGGER_FUNCTION(tf_is_accepted_culture_pop_this_pop) {
2074 return ">r dup " + pop_to_owner() + "r> swap >r dup culture r> swap accepted_cultures @ " + truth_inversion(tval[0]);
2075}
2076TRIGGER_FUNCTION(tf_is_accepted_culture_pop_this_state) {
2077 return ">r dup " + state_to_owner() + "r> swap >r dup culture r> swap accepted_cultures @ " + truth_inversion(tval[0]);
2078}
2079TRIGGER_FUNCTION(tf_is_accepted_culture_pop_this_province) {
2080 return ">r dup " + province_to_owner() + "r> swap >r dup culture r> swap accepted_cultures @ " + truth_inversion(tval[0]);
2081}
2082
2083TRIGGER_FUNCTION(tf_is_accepted_culture_pop) {
2084 return "dup dup culture @ >r " + pop_to_owner() + " r> accepted_cultures @ " + truth_inversion(tval[0]);
2085}
2086TRIGGER_FUNCTION(tf_is_accepted_culture_province) {
2087 return "dup dup dominant_culture @ >r " + province_to_owner() + " r> accepted_cultures @ " + truth_inversion(tval[0]);
2088}
2089TRIGGER_FUNCTION(tf_is_accepted_culture_state) {
2090 return "dup dup dominant_culture @ >r " + state_to_owner() + " r> accepted_cultures @ " + truth_inversion(tval[0]);
2091}
2092TRIGGER_FUNCTION(tf_is_coastal_province) {
2093 return "dup is_coast @ " + truth_inversion(tval[0]);
2094}
2095TRIGGER_FUNCTION(tf_is_coastal_state) {
2096 return "dup >index state-ptr @ coastal-s? @ " + truth_inversion(tval[0]);
2097}
2098TRIGGER_FUNCTION(tf_in_sphere_tag) {
2099 return "dup in_sphere_of @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "= " + truth_inversion(tval[0]);
2100}
2101TRIGGER_FUNCTION(tf_in_sphere_from) {
2102 return ">r >r dup r> swap r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2103}
2104TRIGGER_FUNCTION(tf_in_sphere_this_nation) {
2105 return ">r dup r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2106}
2107TRIGGER_FUNCTION(tf_in_sphere_this_province) {
2108 return ">r dup " + province_to_owner() + "r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2109}
2110TRIGGER_FUNCTION(tf_in_sphere_this_state) {
2111 return ">r dup " + state_to_owner() + "r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2112}
2113TRIGGER_FUNCTION(tf_in_sphere_this_pop) {
2114 return ">r dup " + pop_to_owner() + "r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2115}
2116TRIGGER_FUNCTION(tf_produces_nation) {
2117 // TODO: adjust to local economy
2118 return "dup " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " >commodity_id domestic_market_pool 0.0 > " + truth_inversion(tval[0]);
2119}
2120TRIGGER_FUNCTION(tf_produces_province) {
2121 return "dup rgo @ >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " " + compare_values_eq(tval[0]);
2122}
2123TRIGGER_FUNCTION(tf_produces_state) {
2124 return "dup >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " state-ptr @ state-produces? " + truth_inversion(tval[0]);
2125}
2126TRIGGER_FUNCTION(tf_produces_pop) {
2127 return "false " + truth_inversion(tval[0]);
2128}
2129TRIGGER_FUNCTION(tf_average_militancy_nation) {
2130 return "dup dup >r " + std::to_string(demographics::militancy.index()) + " >demographics_key demographics @ r> " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ dup >r / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2131}
2132TRIGGER_FUNCTION(tf_average_militancy_state) {
2133 return "dup dup >r " + std::to_string(demographics::militancy.index()) + " >demographics_key demographics @ r> " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ dup >r / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2134}
2135TRIGGER_FUNCTION(tf_average_militancy_province) {
2136 return "dup dup >r " + std::to_string(demographics::militancy.index()) + " >demographics_key demographics @ r> " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ dup >r / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2137}
2138TRIGGER_FUNCTION(tf_average_consciousness_nation) {
2139 return "dup dup >r " + std::to_string(demographics::consciousness.index()) + " >demographics_key demographics @ r> " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ dup >r / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2140}
2141TRIGGER_FUNCTION(tf_average_consciousness_state) {
2142 return "dup dup >r " + std::to_string(demographics::consciousness.index()) + " >demographics_key demographics @ r> " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ dup >r / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2143}
2144TRIGGER_FUNCTION(tf_average_consciousness_province) {
2145 return "dup dup >r " + std::to_string(demographics::consciousness.index()) + " >demographics_key demographics @ r> " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ dup >r / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2146}
2147TRIGGER_FUNCTION(tf_is_next_reform_nation) {
2148 return "dup " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " >issue_option_id parent_issue @ issues @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index() - 1) + " " + compare_values_eq(tval[0]);
2149}
2150TRIGGER_FUNCTION(tf_is_next_reform_pop) {
2151 return "dup " + pop_to_owner() + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " >issue_option_id parent_issue @ issues @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index() - 1) + " " + compare_values_eq(tval[0]);
2152}
2153TRIGGER_FUNCTION(tf_is_next_rreform_nation) {
2154 return "dup " + std::to_string(trigger::payload(tval[1]).ropt_id.index()) + " >reform_option_id parent_reform @ reforms @ >index " + std::to_string(trigger::payload(tval[1]).ropt_id.index() - 1) + " " + compare_values_eq(tval[0]);
2155}
2156TRIGGER_FUNCTION(tf_is_next_rreform_pop) {
2157 return "dup " + pop_to_owner() + std::to_string(trigger::payload(tval[1]).ropt_id.index()) + " >reform_option_id parent_reform @ reforms @ >index " + std::to_string(trigger::payload(tval[1]).ropt_id.index() - 1) + " " + compare_values_eq(tval[0]);
2158}
2159TRIGGER_FUNCTION(tf_rebel_power_fraction) {
2160 return "false " + truth_inversion(tval[0]);
2161 // note: virtually unused
2162}
2163TRIGGER_FUNCTION(tf_recruited_percentage_nation) {
2164 return "dup dup >r active_regiments @ >f32 r> recruitable_regiments @ >f32 dup >r / 1.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2165}
2166TRIGGER_FUNCTION(tf_recruited_percentage_pop) {
2167 return "dup " + pop_to_owner() + "dup >r active_regiments @ >f32 r> recruitable_regiments @ >f32 dup >r / 1.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2168}
2169TRIGGER_FUNCTION(tf_has_culture_core) {
2170 return "dup dup >r " + pop_to_location() + ">index r> culture >index state-ptr @ has-culture-core? " + truth_inversion(tval[0]);
2171}
2172TRIGGER_FUNCTION(tf_has_culture_core_province_this_pop) {
2173 return ">r dup culture @ >index r> swap >r dup >index r> state-ptr @ has-culture-core? " + truth_inversion(tval[0]);
2174}
2175TRIGGER_FUNCTION(tf_nationalism) {
2176 return "dup nationalism @ " + std::to_string(float(tval[1])) + " " + compare_values(tval[0]);
2177}
2178TRIGGER_FUNCTION(tf_is_overseas) {
2179 return "dup dup >r " + province_to_owner() + "capital @ dup continent @ r@ continent @ = not r> swap >r >r "
2180 "connected_region_id @ r> connected_region_id @ <> r> and " + truth_inversion(tval[0]);
2181}
2182TRIGGER_FUNCTION(tf_is_overseas_pop) {
2183 return "dup " + pop_to_location() + "dup >r " + province_to_owner() + "capital @ dup continent @ r@ continent @ = not r> swap >r >r "
2184 "connected_region_id @ r> connected_region_id @ <> r> and " + truth_inversion(tval[0]);
2185}
2186TRIGGER_FUNCTION(tf_is_overseas_state) {
2187 return "dup capital @ dup >r " + province_to_owner() + "capital @ dup continent @ r@ continent @ = not r> swap >r >r "
2188 "connected_region_id @ r> connected_region_id @ <> r> and " + truth_inversion(tval[0]);
2189}
2190TRIGGER_FUNCTION(tf_controlled_by_rebels) {
2191 return "dup province_rebel_control-province rebel_faction @ valid? " + truth_inversion(tval[0]);
2192}
2193TRIGGER_FUNCTION(tf_controlled_by_tag) {
2194 return "dup " + province_to_controller() + nation_to_tag() + ">index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " " + compare_values_eq(tval[0]);
2195}
2196TRIGGER_FUNCTION(tf_controlled_by_from) {
2197 return ">r >r dup r> swap r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2198}
2199TRIGGER_FUNCTION(tf_controlled_by_this_nation) {
2200 return ">r dup r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2201}
2202TRIGGER_FUNCTION(tf_controlled_by_this_province) {
2203 return ">r dup " + province_to_owner() + "r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2204}
2205TRIGGER_FUNCTION(tf_controlled_by_this_state) {
2206 return ">r dup " + state_to_owner() + "r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2207}
2208TRIGGER_FUNCTION(tf_controlled_by_this_pop) {
2209 return ">r dup " + pop_to_owner() + "r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2210}
2211TRIGGER_FUNCTION(tf_controlled_by_owner) {
2212 return "dup dup >r " + province_to_owner() + "r> " + province_to_controller() + " = " + truth_inversion(tval[0]);
2213}
2214TRIGGER_FUNCTION(tf_controlled_by_reb) {
2215 return ">r >r dup r> swap r> swap >r dup province_rebel_control-province rebel_faction @ r> = " + truth_inversion(tval[0]);
2216}
2217TRIGGER_FUNCTION(tf_is_canal_enabled) {
2218 return std::to_string(tval[1] - 1) + " state-ptr @ canal-enabled? " + truth_inversion(tval[0]);
2219}
2220TRIGGER_FUNCTION(tf_is_state_capital) {
2221 return "dup dup >r state_membership @ capital @ r> = " + truth_inversion(tval[0]);
2222}
2223TRIGGER_FUNCTION(tf_is_state_capital_pop) {
2224 return "dup " + pop_to_location() + "dup >r state_membership @ capital @ r> = " + truth_inversion(tval[0]);
2225}
2226TRIGGER_FUNCTION(tf_truce_with_tag) {
2227 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + ">index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2228}
2229TRIGGER_FUNCTION(tf_truce_with_from) {
2230 return ">r >r dup r> swap r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2231}
2232TRIGGER_FUNCTION(tf_truce_with_this_nation) {
2233 return ">r dup r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2234}
2235TRIGGER_FUNCTION(tf_truce_with_this_province) {
2236 return ">r dup " + province_to_owner() + "r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2237}
2238TRIGGER_FUNCTION(tf_truce_with_this_state) {
2239 return ">r dup " + state_to_owner() + "r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2240}
2241TRIGGER_FUNCTION(tf_truce_with_this_pop) {
2242 return ">r dup " + pop_to_owner() + "r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2243}
2244TRIGGER_FUNCTION(tf_total_pops_nation) {
2245 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2246}
2247TRIGGER_FUNCTION(tf_total_pops_state) {
2248 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2249}
2250TRIGGER_FUNCTION(tf_total_pops_province) {
2251 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2252}
2253TRIGGER_FUNCTION(tf_total_pops_pop) {
2254 return "dup " + pop_to_location() + std::to_string(demographics::total.index()) + " >demographics_key demographics @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2255}
2256TRIGGER_FUNCTION(tf_has_pop_type_nation) {
2257 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[1]).popt_id.index()) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2258}
2259TRIGGER_FUNCTION(tf_has_pop_type_state) {
2260 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[1]).popt_id.index()) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2261}
2262TRIGGER_FUNCTION(tf_has_pop_type_province) {
2263 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[1]).popt_id.index()) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2264}
2265TRIGGER_FUNCTION(tf_has_pop_type_pop) {
2266 return "dup poptype @ >index " + std::to_string(trigger::payload(tval[1]).popt_id.index()) + " = " + truth_inversion(tval[0]);
2267}
2268TRIGGER_FUNCTION(tf_has_empty_adjacent_province) {
2269 return "dup >index state-ptr @ empty-a-province " + truth_inversion(tval[0]);
2270}
2271TRIGGER_FUNCTION(tf_has_leader) {
2272 return "dup >index " + std::to_string(read_int32_t_from_payload(tval + 1)) + " state-ptr @ has-named-leader? " + truth_inversion(tval[0]);
2273}
2275 return "dup is_player_controlled @ not " + truth_inversion(tval[0]);
2276}
2277//can-release?
2278//national_identity-size
2279TRIGGER_FUNCTION(tf_can_create_vassals) {
2280 return "dup >index >r false 0"
2281 "while "
2282 ">r dup not r> swap >r "
2283 "dup national_identity-size < r> and "
2284 "loop "
2285 "dup r@ swap state-ptr @ can-release? "
2286 ">r swap drop r> swap "
2287 "1 + "
2288 "end-while "
2289 "r> drop drop "
2290 + truth_inversion(tval[0]);
2291}
2292TRIGGER_FUNCTION(tf_is_possible_vassal) {
2293 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " state-ptr @ can-release? " + truth_inversion(tval[0]);
2294}
2295TRIGGER_FUNCTION(tf_province_id) {
2296 return "dup >index " + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " " + compare_values_eq(tval[0]);
2297}
2298TRIGGER_FUNCTION(tf_vassal_of_tag) {
2299 return "dup overlord-subject ruler @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "= " + truth_inversion(tval[0]);
2300}
2301TRIGGER_FUNCTION(tf_vassal_of_from) {
2302 return ">r >r dup r> swap r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2303}
2304TRIGGER_FUNCTION(tf_vassal_of_this_nation) {
2305 return ">r dup r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2306}
2307TRIGGER_FUNCTION(tf_vassal_of_this_province) {
2308 return ">r dup " + province_to_owner() + "r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2309}
2310TRIGGER_FUNCTION(tf_vassal_of_this_state) {
2311 return ">r dup " + state_to_owner() + "r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2312}
2313TRIGGER_FUNCTION(tf_vassal_of_this_pop) {
2314 return ">r dup " + pop_to_owner() + "r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2315}
2316TRIGGER_FUNCTION(tf_vassal_of_province_tag) {
2317 return "dup " + province_to_owner() + "overlord-subject ruler @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "= " + truth_inversion(tval[0]);
2318}
2319TRIGGER_FUNCTION(tf_vassal_of_province_from) {
2320 return ">r >r dup r> swap r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2321}
2322TRIGGER_FUNCTION(tf_vassal_of_province_this_nation) {
2323 return ">r dup r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2324}
2325TRIGGER_FUNCTION(tf_vassal_of_province_this_province) {
2326 return ">r dup " + province_to_owner() + "r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2327}
2328TRIGGER_FUNCTION(tf_vassal_of_province_this_state) {
2329 return ">r dup " + state_to_owner() + "r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2330}
2331TRIGGER_FUNCTION(tf_vassal_of_province_this_pop) {
2332 return ">r dup " + pop_to_owner() + "r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2333}
2334
2335TRIGGER_FUNCTION(tf_substate_of_tag) {
2336 return "dup overlord-subject ruler @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "= "
2337 ">r dup is_substate @ r> and " + truth_inversion(tval[0]);
2338}
2339TRIGGER_FUNCTION(tf_substate_of_from) {
2340 return ">r >r dup r> swap r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2341}
2342TRIGGER_FUNCTION(tf_substate_of_this_nation) {
2343 return ">r dup r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2344}
2345TRIGGER_FUNCTION(tf_substate_of_this_province) {
2346 return ">r dup " + province_to_owner() + "r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2347}
2348TRIGGER_FUNCTION(tf_substate_of_this_state) {
2349 return ">r dup " + state_to_owner() + "r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2350}
2351TRIGGER_FUNCTION(tf_substate_of_this_pop) {
2352 return ">r dup " + pop_to_owner() + "r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2353}
2354TRIGGER_FUNCTION(tf_alliance_with_tag) {
2355 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity " + tag_to_nation() + "state-ptr @ are-allied? " + truth_inversion(tval[0]);
2356}
2357TRIGGER_FUNCTION(tf_alliance_with_from) {
2358 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2359}
2360TRIGGER_FUNCTION(tf_alliance_with_this_nation) {
2361 return ">r dup >index r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2362}
2363TRIGGER_FUNCTION(tf_alliance_with_this_province) {
2364 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2365}
2366TRIGGER_FUNCTION(tf_alliance_with_this_state) {
2367 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2368}
2369TRIGGER_FUNCTION(tf_alliance_with_this_pop) {
2370 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2371}
2372TRIGGER_FUNCTION(tf_has_recently_lost_war) {
2373 return "dup last_war_loss ptr-cast ptr(u16) @ >i32 dup 0 <> >r 365 5 * + current-date @ >i32 >= r> and " + truth_inversion(tval[0]);
2374}
2375TRIGGER_FUNCTION(tf_has_recently_lost_war_pop) {
2376 return "dup " + pop_to_owner() + "last_war_loss ptr-cast ptr(u16) @ >i32 dup 0 <> >r 365 5 * + current-date @ >i32 >= r> and " + truth_inversion(tval[0]);
2377}
2378TRIGGER_FUNCTION(tf_is_mobilised) {
2379 return "dup is_mobilized @ " + truth_inversion(tval[0]);
2380}
2381TRIGGER_FUNCTION(tf_mobilisation_size) {
2382 return "dup " + std::to_string(sys::national_mod_offsets::mobilization_size.index()) + " >national_modifier_value modifier_values @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2383}
2384TRIGGER_FUNCTION(tf_crime_higher_than_education_nation) {
2385 return "dup dup >r administrative_spending @ r> education_spending @ >= " + truth_inversion(tval[0]);
2386}
2387TRIGGER_FUNCTION(tf_crime_higher_than_education_state) {
2388 return "dup " + state_to_owner() + "dup >r administrative_spending @ r> education_spending @ >= " + truth_inversion(tval[0]);
2389}
2390TRIGGER_FUNCTION(tf_crime_higher_than_education_province) {
2391 return "dup " + province_to_owner() + "dup >r administrative_spending @ r> education_spending @ >= " + truth_inversion(tval[0]);
2392}
2393TRIGGER_FUNCTION(tf_crime_higher_than_education_pop) {
2394 return "dup " + pop_to_owner() + "dup >r administrative_spending @ r> education_spending @ >= " + truth_inversion(tval[0]);
2395}
2396TRIGGER_FUNCTION(tf_agree_with_ruling_party) {
2397 return "dup dup >r " + pop_to_owner() + "ruling_party @ ideology @ dup valid? if >index " + std::to_string(pop_demographics::count_special_keys) + " + >pop_demographics_key "
2398 "r> dup size @ >r swap udemographics @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * r@ / 0.0 0.0 r> >= select else drop r> drop 0.0 end-if " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2399}
2400TRIGGER_FUNCTION(tf_is_colonial_state) {
2401 return "dup capital @ is_colonial @ " + truth_inversion(tval[0]);
2402}
2403TRIGGER_FUNCTION(tf_is_colonial_province) {
2404 return "dup is_colonial @ " + truth_inversion(tval[0]);
2405}
2406TRIGGER_FUNCTION(tf_is_colonial_pop) {
2407 return "dup " + pop_to_location() + "is_colonial @ " + truth_inversion(tval[0]);
2408}
2409TRIGGER_FUNCTION(tf_has_factories_state) {
2410 return "dup >index state-ptr @ has-any-factory " + truth_inversion(tval[0]);
2411}
2412TRIGGER_FUNCTION(tf_has_factories_nation) {
2413 return "dup >index state-ptr @ nation-has-any-factory " + truth_inversion(tval[0]);
2414}
2415TRIGGER_FUNCTION(tf_in_default_bool) {
2416 return "dup is_bankrupt @ " + truth_inversion(tval[0]);
2417}
2418//bankrupt-debtor-to?
2419TRIGGER_FUNCTION(tf_in_default_tag) {
2420 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2421}
2422TRIGGER_FUNCTION(tf_in_default_from) {
2423 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2424}
2425TRIGGER_FUNCTION(tf_in_default_this_nation) {
2426 return ">r dup >index r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2427}
2428TRIGGER_FUNCTION(tf_in_default_this_province) {
2429 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2430}
2431TRIGGER_FUNCTION(tf_in_default_this_state) {
2432 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2433}
2434TRIGGER_FUNCTION(tf_in_default_this_pop) {
2435 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2436}
2437TRIGGER_FUNCTION(tf_total_num_of_ports) {
2438 return "dup total_ports @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2439}
2441 return "true " + truth_inversion(tval[0]);
2442}
2443TRIGGER_FUNCTION(tf_election) {
2444 return "dup election_ends ptr-cast ptr(u16) @ >i32 dup 0 <> swap current-date @ >i32 > and " + truth_inversion(tval[0]);
2445}
2446TRIGGER_FUNCTION(tf_has_global_flag) {
2447 return std::to_string(trigger::payload(tval[1]).glob_id.index()) + " state-ptr @ global-flag-set? " + truth_inversion(tval[0]);
2448}
2449TRIGGER_FUNCTION(tf_is_capital) {
2450 return "dup dup " + province_to_owner() + "capital @ = " + truth_inversion(tval[0]);
2451}
2452TRIGGER_FUNCTION(tf_nationalvalue_nation) {
2453 return "dup national_value @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]) ;
2454}
2455TRIGGER_FUNCTION(tf_nationalvalue_pop) {
2456 return "dup " + pop_to_owner() + "national_value @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
2457}
2458TRIGGER_FUNCTION(tf_nationalvalue_province) {
2459 return "dup " + province_to_owner() + "national_value @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
2460}
2461TRIGGER_FUNCTION(tf_industrial_score_value) {
2462 return "dup industrial_score @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2463}
2464TRIGGER_FUNCTION(tf_industrial_score_tag) {
2465 return "dup industrial_score @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "industrial_score @ " + compare_values(tval[0]);
2466}
2467TRIGGER_FUNCTION(tf_industrial_score_from_nation) {
2468 return ">r >r dup industrial_score @ r> swap r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2469}
2470TRIGGER_FUNCTION(tf_industrial_score_this_nation) {
2471 return ">r dup industrial_score @ r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2472}
2473TRIGGER_FUNCTION(tf_industrial_score_this_pop) {
2474 return ">r dup " + pop_to_owner() + "industrial_score @ r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2475}
2476TRIGGER_FUNCTION(tf_industrial_score_this_state) {
2477 return ">r dup " + state_to_owner() + "industrial_score @ r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2478}
2479TRIGGER_FUNCTION(tf_industrial_score_this_province) {
2480 return ">r dup " +province_to_owner() + "industrial_score @ r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2481}
2482TRIGGER_FUNCTION(tf_military_score_value) {
2483 return "dup military_score @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2484}
2485TRIGGER_FUNCTION(tf_military_score_tag) {
2486 return "dup military_score @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "military_score @ " + compare_values(tval[0]);
2487}
2488TRIGGER_FUNCTION(tf_military_score_from_nation) {
2489 return ">r >r dup military_score @ r> swap r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2490}
2491TRIGGER_FUNCTION(tf_military_score_this_nation) {
2492 return ">r dup military_score @ r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2493}
2494TRIGGER_FUNCTION(tf_military_score_this_pop) {
2495 return ">r dup " + pop_to_owner() + "military_score @ r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2496}
2497TRIGGER_FUNCTION(tf_military_score_this_state) {
2498 return ">r dup " + state_to_owner() + "military_score @ r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2499}
2500TRIGGER_FUNCTION(tf_military_score_this_province) {
2501 return ">r dup " + province_to_owner() + "military_score @ r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2502}
2503TRIGGER_FUNCTION(tf_civilized_nation) {
2504 return "dup is_civilized @ " + truth_inversion(tval[0]);
2505}
2506TRIGGER_FUNCTION(tf_civilized_pop) {
2507 return "dup " + pop_to_owner() + "is_civilized @ " + truth_inversion(tval[0]);
2508}
2509TRIGGER_FUNCTION(tf_civilized_province) {
2510 return "dup " + province_to_owner() + "is_civilized @ " + truth_inversion(tval[0]);
2511}
2512TRIGGER_FUNCTION(tf_national_provinces_occupied) {
2513 return "dup owned_province_count @ >f32 >r dup occupied_count @ >f32 r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2514}
2515TRIGGER_FUNCTION(tf_is_greater_power_nation) {
2516 return "dup is_great_power @ " + truth_inversion(tval[0]);
2517}
2518TRIGGER_FUNCTION(tf_is_greater_power_pop) {
2519 return "dup " + pop_to_owner() + "is_great_power @ " + truth_inversion(tval[0]);
2520}
2521TRIGGER_FUNCTION(tf_is_greater_power_province) {
2522 return "dup " + province_to_owner() + "is_great_power @ " + truth_inversion(tval[0]);
2523}
2524TRIGGER_FUNCTION(tf_rich_tax) {
2525 return "dup rich_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2526}
2527TRIGGER_FUNCTION(tf_middle_tax) {
2528 return "dup middle_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2529}
2530TRIGGER_FUNCTION(tf_poor_tax) {
2531 return "dup poor_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2532}
2533TRIGGER_FUNCTION(tf_rich_tax_pop) {
2534 return "dup " + pop_to_owner() + "rich_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2535}
2536TRIGGER_FUNCTION(tf_middle_tax_pop) {
2537 return "dup " + pop_to_owner() + "middle_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2538}
2539TRIGGER_FUNCTION(tf_poor_tax_pop) {
2540 return "dup " + pop_to_owner() + "poor_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2541}
2542TRIGGER_FUNCTION(tf_social_spending_nation) {
2543 return "dup dup >r social_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2544}
2545TRIGGER_FUNCTION(tf_social_spending_pop) {
2546 return "dup " + pop_to_owner() + "dup >r social_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2547}
2548TRIGGER_FUNCTION(tf_social_spending_province) {
2549 return "dup " + province_to_owner() + "dup >r social_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2550}
2551TRIGGER_FUNCTION(tf_military_spending_nation) {
2552 return "dup dup >r military_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2553}
2554TRIGGER_FUNCTION(tf_military_spending_pop) {
2555 return "dup " + pop_to_owner() + "dup >r military_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2556}
2557TRIGGER_FUNCTION(tf_military_spending_province) {
2558 return "dup " + province_to_owner() + "dup >r military_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2559}
2560TRIGGER_FUNCTION(tf_military_spending_state) {
2561 return "dup " + state_to_owner() + "dup >r military_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2562}
2563TRIGGER_FUNCTION(tf_administration_spending_nation) {
2564 return "dup dup >r administrative_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2565}
2566TRIGGER_FUNCTION(tf_administration_spending_pop) {
2567 return "dup " + pop_to_owner() + "dup >r administrative_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2568}
2569TRIGGER_FUNCTION(tf_administration_spending_province) {
2570 return "dup " + province_to_owner() + "dup >r administrative_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2571}
2572TRIGGER_FUNCTION(tf_administration_spending_state) {
2573 return "dup " + state_to_owner() + "dup >r administrative_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2574}
2575TRIGGER_FUNCTION(tf_education_spending_nation) {
2576 return "dup dup >r education_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2577}
2578TRIGGER_FUNCTION(tf_education_spending_pop) {
2579 return "dup " + pop_to_owner() + "dup >r education_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2580}
2581TRIGGER_FUNCTION(tf_education_spending_province) {
2582 return "dup " + province_to_owner() + "dup >r education_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2583}
2584TRIGGER_FUNCTION(tf_education_spending_state) {
2585 return "dup " + state_to_owner() + "dup >r education_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2586}
2587TRIGGER_FUNCTION(tf_colonial_nation) {
2588 return "dup is_colonial_nation @ " + truth_inversion(tval[0]);
2589}
2590TRIGGER_FUNCTION(tf_pop_majority_religion_nation) {
2591 return "dup dominant_religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " = " + truth_inversion(tval[0]);
2592}
2593TRIGGER_FUNCTION(tf_pop_majority_religion_nation_this_nation) {
2594 return ">r dup religion @ r> swap >r dup dominant_religion @ r> = " + truth_inversion(tval[0]);
2595}
2596TRIGGER_FUNCTION(tf_pop_majority_religion_state) {
2597 return "dup dominant_religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " = " + truth_inversion(tval[0]);
2598}
2599TRIGGER_FUNCTION(tf_pop_majority_religion_province) {
2600 return "dup dominant_religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " = " + truth_inversion(tval[0]);
2601}
2602TRIGGER_FUNCTION(tf_pop_majority_culture_nation) {
2603 return "dup dominant_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " = " + truth_inversion(tval[0]);
2604}
2605TRIGGER_FUNCTION(tf_pop_majority_culture_state) {
2606 return "dup dominant_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " = " + truth_inversion(tval[0]);
2607}
2608TRIGGER_FUNCTION(tf_pop_majority_culture_province) {
2609 return "dup dominant_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " = " + truth_inversion(tval[0]);
2610}
2611TRIGGER_FUNCTION(tf_pop_majority_issue_nation) {
2612 return "dup dominant_issue_option @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " = " + truth_inversion(tval[0]);
2613}
2614TRIGGER_FUNCTION(tf_pop_majority_issue_state) {
2615 return "dup dominant_issue_option @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " = " + truth_inversion(tval[0]);
2616}
2617TRIGGER_FUNCTION(tf_pop_majority_issue_province) {
2618 return "dup dominant_issue_option @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " = " + truth_inversion(tval[0]);
2619}
2620TRIGGER_FUNCTION(tf_pop_majority_issue_pop) {
2621 return "dup dominant_issue_option @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " = " + truth_inversion(tval[0]);
2622}
2623TRIGGER_FUNCTION(tf_pop_majority_ideology_nation) {
2624 return "dup dominant_ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " = " + truth_inversion(tval[0]);
2625}
2626TRIGGER_FUNCTION(tf_pop_majority_ideology_state) {
2627 return "dup dominant_ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " = " + truth_inversion(tval[0]);
2628}
2629TRIGGER_FUNCTION(tf_pop_majority_ideology_province) {
2630 return "dup dominant_ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " = " + truth_inversion(tval[0]);
2631}
2632TRIGGER_FUNCTION(tf_pop_majority_ideology_pop) {
2633 return "dup dominant_ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " = " + truth_inversion(tval[0]);
2634}
2635TRIGGER_FUNCTION(tf_poor_strata_militancy_nation) {
2636 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r "
2637 "dup " + std::to_string(demographics::poor_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2638 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2639}
2640TRIGGER_FUNCTION(tf_poor_strata_militancy_state) {
2641 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r "
2642 "dup " + std::to_string(demographics::poor_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2643 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2644}
2645TRIGGER_FUNCTION(tf_poor_strata_militancy_province) {
2646 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r "
2647 "dup " + std::to_string(demographics::poor_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2648 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2649}
2650TRIGGER_FUNCTION(tf_poor_strata_militancy_pop) {
2651 return "dup poptype @ strata @ >i32 " + std::to_string(uint8_t(culture::pop_strata::poor)) + " <> >r "
2652 "dup umilitancy @ >f32 " + std::to_string(10.0f / float(std::numeric_limits<uint16_t>::max())) + " * 0.0 r> select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2653}
2654TRIGGER_FUNCTION(tf_middle_strata_militancy_nation) {
2655 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r "
2656 "dup " + std::to_string(demographics::middle_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2657 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2658}
2659TRIGGER_FUNCTION(tf_middle_strata_militancy_state) {
2660 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r "
2661 "dup " + std::to_string(demographics::middle_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2662 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2663}
2664TRIGGER_FUNCTION(tf_middle_strata_militancy_province) {
2665 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r "
2666 "dup " + std::to_string(demographics::middle_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2667 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2668}
2669TRIGGER_FUNCTION(tf_middle_strata_militancy_pop) {
2670 return "dup poptype @ strata @ >i32 " + std::to_string(uint8_t(culture::pop_strata::middle)) + " <> >r "
2671 "dup umilitancy @ >f32 " + std::to_string(10.0f / float(std::numeric_limits<uint16_t>::max())) + " * 0.0 r> select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2672}
2673TRIGGER_FUNCTION(tf_rich_strata_militancy_nation) {
2674 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r "
2675 "dup " + std::to_string(demographics::rich_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2676 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2677}
2678TRIGGER_FUNCTION(tf_rich_strata_militancy_state) {
2679 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r "
2680 "dup " + std::to_string(demographics::rich_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2681 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2682}
2683TRIGGER_FUNCTION(tf_rich_strata_militancy_province) {
2684 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r "
2685 "dup " + std::to_string(demographics::rich_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2686 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2687}
2688TRIGGER_FUNCTION(tf_rich_strata_militancy_pop) {
2689 return "dup poptype @ strata @ >i32 " + std::to_string(uint8_t(culture::pop_strata::rich)) + " <> >r "
2690 "dup umilitancy @ >f32 " + std::to_string(10.0f / float(std::numeric_limits<uint16_t>::max())) + " * 0.0 r> select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2691}
2692TRIGGER_FUNCTION(tf_rich_tax_above_poor) {
2693 return "dup dup >r rich_tax @ r> poor_tax @ > " + truth_inversion(tval[0]);
2694}
2695TRIGGER_FUNCTION(tf_culture_has_union_tag_pop) {
2696 return "dup culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ valid? " + truth_inversion(tval[0]);
2697}
2698TRIGGER_FUNCTION(tf_culture_has_union_tag_nation) {
2699 return "dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ valid? " + truth_inversion(tval[0]);
2700}
2701TRIGGER_FUNCTION(tf_this_culture_union_tag) {
2702 return "dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " = " + truth_inversion(tval[0]);
2703}
2704TRIGGER_FUNCTION(tf_this_culture_union_from) {
2705 return ">r >r dup " + nation_to_tag() + "r> swap r> swap >r dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ r> = " + truth_inversion(tval[0]);
2706}
2707TRIGGER_FUNCTION(tf_this_culture_union_this_nation) {
2708 return ">r dup " + nation_to_tag() + "r> swap >r dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ r> = " + truth_inversion(tval[0]);
2709}
2710TRIGGER_FUNCTION(tf_this_culture_union_this_province) {
2711 return ">r dup " + province_to_owner() + nation_to_tag() + "r> swap >r dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ r> = " + truth_inversion(tval[0]);
2712}
2713TRIGGER_FUNCTION(tf_this_culture_union_this_state) {
2714 return ">r dup " + state_to_owner() + nation_to_tag() + "r> swap >r dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ r> = " + truth_inversion(tval[0]);
2715}
2716TRIGGER_FUNCTION(tf_this_culture_union_this_pop) {
2717 return ">r dup " + pop_to_owner() + nation_to_tag() + "r> swap >r dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ r> = " + truth_inversion(tval[0]);
2718}
2719TRIGGER_FUNCTION(tf_this_culture_union_this_union_nation) {
2720 return ">r dup primary_culture @ culture_group_membership-member group @ r> swap >r dup primary_culture @ culture_group_membership-member group @ r> = " + truth_inversion(tval[0]);
2721}
2722TRIGGER_FUNCTION(tf_this_culture_union_this_union_province) {
2723 return ">r dup " + province_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap >r dup primary_culture @ culture_group_membership-member group @ r> = " + truth_inversion(tval[0]);
2724}
2725TRIGGER_FUNCTION(tf_this_culture_union_this_union_state) {
2726 return ">r dup " + state_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap >r dup primary_culture @ culture_group_membership-member group @ r> = " + truth_inversion(tval[0]);
2727}
2728TRIGGER_FUNCTION(tf_this_culture_union_this_union_pop) {
2729 return ">r dup " + pop_to_owner() + "primary_culture @ culture_group_membership-member group @ r> swap >r dup primary_culture @ culture_group_membership-member group @ r> = " + truth_inversion(tval[0]);
2730}
2731TRIGGER_FUNCTION(tf_minorities_nation) {
2732 return "dup dup >r " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ "
2733 "r@ " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r@ primary_culture @ >index + >demographics_key demographics @ - "
2734 "0 "
2735 "while "
2736 "dup culture-size < "
2737 "loop "
2738 "dup >culture_id r@ swap accepted_cultures @ "
2739 "if "
2740 "dup r@ swap >r "
2741 + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r> + >demographics_key demographics @ "
2742 ">r swap r> - swap "
2743 "then "
2744 "1 + "
2745 "end-while "
2746 "drop r> drop 0.0 > "
2747 + truth_inversion(tval[0]);
2748}
2749TRIGGER_FUNCTION(tf_minorities_state) {
2750 return "dup dup >r " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ "
2751 "r@ " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r@ " + state_to_owner() + "primary_culture @ >index + >demographics_key demographics @ - "
2752 "0 "
2753 "while "
2754 "dup culture-size < "
2755 "loop "
2756 "dup >culture_id r@ " + state_to_owner() + "swap accepted_cultures @ "
2757 "if "
2758 "dup r@ swap >r "
2759 + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r> + >demographics_key demographics @ "
2760 ">r swap r> - swap "
2761 "then "
2762 "1 + "
2763 "end-while "
2764 "drop r> drop 0.0 > "
2765 + truth_inversion(tval[0]);
2766}
2767TRIGGER_FUNCTION(tf_minorities_province) {
2768 return "dup dup >r " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ "
2769 "r@ " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r@ " + province_to_owner() + "primary_culture @ >index + >demographics_key demographics @ - "
2770 "0 "
2771 "while "
2772 "dup culture-size < "
2773 "loop "
2774 "dup >culture_id r@ " + province_to_owner() + "swap accepted_cultures @ "
2775 "if "
2776 "dup r@ swap >r "
2777 + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r> + >demographics_key demographics @ "
2778 ">r swap r> - swap "
2779 "then "
2780 "1 + "
2781 "end-while "
2782 "drop r> drop 0.0 > "
2783 + truth_inversion(tval[0]);
2784}
2785TRIGGER_FUNCTION(tf_revanchism_nation) {
2786 return "dup revanchism @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2787}
2788TRIGGER_FUNCTION(tf_revanchism_pop) {
2789 return "dup " + pop_to_owner() + "revanchism @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2790}
2791TRIGGER_FUNCTION(tf_has_crime) {
2792 return "dup crime @ valid? " + truth_inversion(tval[0]);
2793}
2794TRIGGER_FUNCTION(tf_num_of_substates) {
2795 return "dup substates_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2796}
2797TRIGGER_FUNCTION(tf_num_of_vassals_no_substates) {
2798 return "dup dup >r vassals_count @ >i32 r> substates_count @ >i32 - " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2799}
2800TRIGGER_FUNCTION(tf_brigades_compare_this) {
2801 return ">r dup active_regiments >f32 r> swap >r dup active_regiments >f32 r@ / 1000000.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2802}
2803TRIGGER_FUNCTION(tf_brigades_compare_from) {
2804 return ">r >r dup active_regiments >f32 r> swap r> swap >r dup active_regiments >f32 r@ / 1000000.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2805}
2806TRIGGER_FUNCTION(tf_brigades_compare_province_this) {
2807 return ">r dup active_regiments >f32 r> swap >r dup " + province_to_owner() + "active_regiments >f32 r@ / 1000000.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2808}
2809TRIGGER_FUNCTION(tf_brigades_compare_province_from) {
2810 return ">r >r dup active_regiments >f32 r> swap r> swap >r dup " + province_to_owner() + "active_regiments >f32 r@ / 1000000.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2811}
2812TRIGGER_FUNCTION(tf_constructing_cb_tag) {
2813 return "dup constructing_cb_target @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + " = " + truth_inversion(tval[0]);
2814}
2815TRIGGER_FUNCTION(tf_constructing_cb_from) {
2816 return ">r >r dup r> swap r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2817}
2818TRIGGER_FUNCTION(tf_constructing_cb_this_nation) {
2819 return ">r dup r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2820}
2821TRIGGER_FUNCTION(tf_constructing_cb_this_province) {
2822 return ">r dup " + province_to_owner() + "r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2823}
2824TRIGGER_FUNCTION(tf_constructing_cb_this_state) {
2825 return ">r dup " + state_to_owner() + "r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2826}
2827TRIGGER_FUNCTION(tf_constructing_cb_this_pop) {
2828 return ">r dup " + pop_to_owner() + "r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2829}
2830TRIGGER_FUNCTION(tf_constructing_cb_discovered) {
2831 return "dup constructing_cb_is_discovered @ " + truth_inversion(tval[0]);
2832}
2833TRIGGER_FUNCTION(tf_constructing_cb_progress) {
2834 return "dup constructing_cb_progress @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2835}
2836TRIGGER_FUNCTION(tf_civilization_progress) {
2837 return "dup " + std::to_string(sys::national_mod_offsets::civilization_progress_modifier.index()) + " >national_modifier_value modifier_values @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2838}
2839TRIGGER_FUNCTION(tf_constructing_cb_type) {
2840 return "dup constructing_cb_type @ >index " + std::to_string(trigger::payload(tval[1]).cb_id.index()) + " " + compare_values_eq(tval[0]);
2841}
2842TRIGGER_FUNCTION(tf_is_our_vassal_tag) {
2843 return std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "overlord-subject ruler @ >r dup r> = " + truth_inversion(tval[0]);
2844}
2845TRIGGER_FUNCTION(tf_is_our_vassal_from) {
2846 return ">r >r dup overlord-subject ruler @ r> swap r> swap >r dup r> = " + truth_inversion(tval[0]);
2847}
2848TRIGGER_FUNCTION(tf_is_our_vassal_this_nation) {
2849 return ">r dup overlord-subject ruler @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2850}
2851TRIGGER_FUNCTION(tf_is_our_vassal_this_province) {
2852 return ">r dup " + province_to_owner() + "overlord-subject ruler @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2853}
2854TRIGGER_FUNCTION(tf_is_our_vassal_this_state) {
2855 return ">r dup " + state_to_owner() + "overlord-subject ruler @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2856}
2857TRIGGER_FUNCTION(tf_is_our_vassal_this_pop) {
2858 return ">r dup " + pop_to_owner() + "overlord-subject ruler @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2859}
2860TRIGGER_FUNCTION(tf_is_our_vassal_province_tag) {
2861 return ">r >r dup overlord-subject ruler @ r> swap r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2862}
2863TRIGGER_FUNCTION(tf_is_our_vassal_province_from) {
2864 return ">r >r dup overlord-subject ruler @ r> swap r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2865}
2866TRIGGER_FUNCTION(tf_is_our_vassal_province_this_nation) {
2867 return ">r dup overlord-subject ruler @ r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2868}
2869TRIGGER_FUNCTION(tf_is_our_vassal_province_this_province) {
2870 return ">r dup " + province_to_owner() + "overlord-subject ruler @ r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2871}
2872TRIGGER_FUNCTION(tf_is_our_vassal_province_this_state) {
2873 return ">r dup " + state_to_owner() + "overlord-subject ruler @ r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2874}
2875TRIGGER_FUNCTION(tf_is_our_vassal_province_this_pop) {
2876 return ">r dup " + pop_to_owner() + "overlord-subject ruler @ r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2877}
2878TRIGGER_FUNCTION(tf_is_substate) {
2879 return "dup is_substate @ " + truth_inversion(tval[0]);
2880}
2881TRIGGER_FUNCTION(tf_great_wars_enabled) {
2882 return std::to_string(offsetof(sys::state, military_definitions) + offsetof(military::global_military_state, great_wars_enabled)) + " state-ptr @ buf-add ptr-cast ptr(i8) @ 0 >i8 <> " + truth_inversion(tval[0]);
2883}
2884TRIGGER_FUNCTION(tf_can_nationalize) {
2885 return "dup >index state-ptr @ can-nationalize? " + truth_inversion(tval[0]);
2886}
2887TRIGGER_FUNCTION(tf_part_of_sphere) {
2888 return "dup in_sphere_of @ valid? " + truth_inversion(tval[0]);
2889}
2890TRIGGER_FUNCTION(tf_is_sphere_leader_of_tag) {
2891 return std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "in_sphere_of @ >r dup r> = " + truth_inversion(tval[0]);
2892}
2893TRIGGER_FUNCTION(tf_is_sphere_leader_of_from) {
2894 return ">r >r dup in_sphere_of @ r> swap r> swap >r dup r> = " + truth_inversion(tval[0]);
2895}
2896TRIGGER_FUNCTION(tf_is_sphere_leader_of_this_nation) {
2897 return ">r dup in_sphere_of @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2898}
2899TRIGGER_FUNCTION(tf_is_sphere_leader_of_this_province) {
2900 return ">r " + province_to_owner() + "dup in_sphere_of @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2901}
2902TRIGGER_FUNCTION(tf_is_sphere_leader_of_this_state) {
2903 return ">r " + state_to_owner() + "dup in_sphere_of @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2904}
2905TRIGGER_FUNCTION(tf_is_sphere_leader_of_this_pop) {
2906 return ">r " + pop_to_owner() + "dup in_sphere_of @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2907}
2908TRIGGER_FUNCTION(tf_number_of_states) {
2909 return "dup owned_state_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2910}
2911TRIGGER_FUNCTION(tf_war_score) {
2912 return "dup >index state-ptr @ avg-warscore " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2913}
2914TRIGGER_FUNCTION(tf_is_releasable_vassal_from) {
2915 return ">r >r dup " + nation_to_tag() + "is_not_releasable @ not r> swap r> swap" + truth_inversion(tval[0]);
2916}
2917TRIGGER_FUNCTION(tf_is_releasable_vassal_other) {
2918 return ">r >r dup " + nation_to_tag() + "is_not_releasable @ not r> swap r> swap" + truth_inversion(tval[0]);
2919}
2920TRIGGER_FUNCTION(tf_has_recent_imigration) {
2921 return "dup last_immigration ptr-cast ptr(u16) @ >i32 " + std::to_string(tval[1]) + " + current-date @ >i32 " + compare_values(tval[0]);
2922}
2923TRIGGER_FUNCTION(tf_province_control_days) {
2924 return "dup last_control_change ptr-cast ptr(u16) @ >i32 " + std::to_string(tval[1]) + " + current-date @ >i32 " + compare_values(tval[0]);
2925}
2926TRIGGER_FUNCTION(tf_is_disarmed) {
2927 return "dup disarmed_until ptr-cast ptr(u16) @ >i32 dup 0 <> swap current-date @ >i32 > and " + truth_inversion(tval[0]);
2928}
2929TRIGGER_FUNCTION(tf_is_disarmed_pop) {
2930 return "dup " + pop_to_owner() + "disarmed_until ptr-cast ptr(u16) @ >i32 dup 0 <> swap current-date @ >i32 > and " + truth_inversion(tval[0]);
2931}
2932TRIGGER_FUNCTION(tf_big_producer) {
2933 return "false " + truth_inversion(tval[0]);
2934}
2935TRIGGER_FUNCTION(tf_someone_can_form_union_tag_from) {
2936 return "false " + truth_inversion(tval[0]);
2937}
2938TRIGGER_FUNCTION(tf_someone_can_form_union_tag_other) {
2939 return "false " + truth_inversion(tval[0]);
2940}
2941TRIGGER_FUNCTION(tf_social_movement_strength) {
2942 return "dup >index true state-ptr @ movement-str " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2943}
2944TRIGGER_FUNCTION(tf_political_movement_strength) {
2945 return "dup >index false state-ptr @ movement-str " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2946}
2947TRIGGER_FUNCTION(tf_can_build_factory_in_capital_state) {
2948 return "true " + truth_inversion(tval[0]);
2949}
2950TRIGGER_FUNCTION(tf_social_movement) {
2951 return "dup pop_movement_membership-pop movement @ get_associated_issue_option @ dup >r valid? r> parent_issue @ issue_type @ >i32 " + std::to_string(int32_t(culture::issue_type::social)) + " = and " + truth_inversion(tval[0]);
2952}
2953TRIGGER_FUNCTION(tf_political_movement) {
2954 return "dup pop_movement_membership-pop movement @ get_associated_issue_option @ dup >r valid? r> parent_issue @ issue_type @ >i32 " + std::to_string(int32_t(culture::issue_type::political)) + " = and " + truth_inversion(tval[0]);
2955}
2956TRIGGER_FUNCTION(tf_political_movement_from_reb) {
2957 // returns false because I'm not sure exactly what it is supposed to do (applies to the below as well)
2958 // it is called in nation scope while modifying chances for a rebel faction to spawn
2959 // perhaps reducing the chance if there is an "appropriate" movement (because there is almost always some movement)
2960 // however, the logic from working backwards from rebel factions to movements is not clear to me
2961 return "false " + truth_inversion(tval[0]);
2962}
2963TRIGGER_FUNCTION(tf_social_movement_from_reb) {
2964 return "false " + truth_inversion(tval[0]);
2965}
2966TRIGGER_FUNCTION(tf_has_cultural_sphere) {
2967 return "dup >index state-ptr @ has-union-sphere? " + truth_inversion(tval[0]);
2968}
2969TRIGGER_FUNCTION(tf_world_wars_enabled) {
2970 return std::to_string(offsetof(sys::state, military_definitions) + offsetof(military::global_military_state, world_wars_enabled)) + " state-ptr @ buf-add ptr-cast ptr(i8) @ 0 >i8 <> " + truth_inversion(tval[0]);
2971}
2972TRIGGER_FUNCTION(tf_has_pop_culture_pop_this_pop) {
2973 return ">r dup culture @ r> swap >r dup culture r> = " + truth_inversion(tval[0]);
2974}
2975TRIGGER_FUNCTION(tf_has_pop_culture_state_this_pop) {
2976 return ">r dup culture @ >index r> swap >r dup r> " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " + >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2977}
2978TRIGGER_FUNCTION(tf_has_pop_culture_province_this_pop) {
2979 return ">r dup culture @ >index r> swap >r dup r> " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " + >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2980}
2981TRIGGER_FUNCTION(tf_has_pop_culture_nation_this_pop) {
2982 return ">r dup culture @ >index r> swap >r dup r> " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " + >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2983}
2984TRIGGER_FUNCTION(tf_has_pop_culture_pop) {
2985 return "dup culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " " + compare_values_eq(tval[0]);
2986}
2987TRIGGER_FUNCTION(tf_has_pop_culture_state) {
2988 return "dup " + std::to_string(trigger::payload(tval[1]).cul_id.index() + demographics::count_special_keys + ws.world.pop_type_size() * 2) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2989}
2990TRIGGER_FUNCTION(tf_has_pop_culture_province) {
2991 return "dup " + std::to_string(trigger::payload(tval[1]).cul_id.index() + demographics::count_special_keys + ws.world.pop_type_size() * 2) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2992}
2993TRIGGER_FUNCTION(tf_has_pop_culture_nation) {
2994 return "dup " + std::to_string(trigger::payload(tval[1]).cul_id.index() + demographics::count_special_keys + ws.world.pop_type_size() * 2) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
2995}
2996TRIGGER_FUNCTION(tf_has_pop_religion_pop_this_pop) {
2997 return ">r dup religion @ r> swap >r dup religion r> = " + truth_inversion(tval[0]);
2998}
2999TRIGGER_FUNCTION(tf_has_pop_religion_state_this_pop) {
3000 return ">r dup religion @ >index r> swap >r dup r> " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2 + ws.world.culture_size() + ws.world.ideology_size() + ws.world.issue_option_size()) + " + >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
3001}
3002TRIGGER_FUNCTION(tf_has_pop_religion_province_this_pop) {
3003 return ">r dup religion @ >index r> swap >r dup r> " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2 + ws.world.culture_size() + ws.world.ideology_size() + ws.world.issue_option_size()) + " + >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
3004}
3005TRIGGER_FUNCTION(tf_has_pop_religion_nation_this_pop) {
3006 return ">r dup religion @ >index r> swap >r dup r> " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2 + ws.world.culture_size() + ws.world.ideology_size() + ws.world.issue_option_size()) + " + >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
3007}
3008TRIGGER_FUNCTION(tf_has_pop_religion_pop) {
3009 return "dup religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " " + compare_values_eq(tval[0]);
3010}
3011TRIGGER_FUNCTION(tf_has_pop_religion_state) {
3012 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).rel_id).index()) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
3013}
3014TRIGGER_FUNCTION(tf_has_pop_religion_province) {
3015 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).rel_id).index()) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
3016}
3017TRIGGER_FUNCTION(tf_has_pop_religion_nation) {
3018 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).rel_id).index()) + " >demographics_key demographics @ 0.0 > " + truth_inversion(tval[0]);
3019}
3020TRIGGER_FUNCTION(tf_life_needs) {
3021 return "dup ulife_needs_satisfaction @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3022}
3023TRIGGER_FUNCTION(tf_everyday_needs) {
3024 return "dup ueveryday_needs_satisfaction @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3025}
3026TRIGGER_FUNCTION(tf_luxury_needs) {
3027 return "dup uluxury_needs_satisfaction @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3028}
3029TRIGGER_FUNCTION(tf_consciousness_pop) {
3030 return "dup uconsciousness @ >f32 " + std::to_string(10.0f / float(std::numeric_limits<uint16_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3031}
3032TRIGGER_FUNCTION(tf_consciousness_province) {
3033 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::consciousness.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3034}
3035TRIGGER_FUNCTION(tf_consciousness_state) {
3036 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::consciousness.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3037}
3038TRIGGER_FUNCTION(tf_consciousness_nation) {
3039 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::consciousness.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3040}
3041TRIGGER_FUNCTION(tf_literacy_pop) {
3042 return "dup uliteracy @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint16_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3043}
3044TRIGGER_FUNCTION(tf_literacy_province) {
3045 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::literacy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3046}
3047TRIGGER_FUNCTION(tf_literacy_state) {
3048 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::literacy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3049}
3050TRIGGER_FUNCTION(tf_literacy_nation) {
3051 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::literacy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3052}
3053TRIGGER_FUNCTION(tf_militancy_pop) {
3054 return "dup umilitancy @ >f32 " + std::to_string(10.0f / float(std::numeric_limits<uint16_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3055}
3056TRIGGER_FUNCTION(tf_militancy_province) {
3057 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3058}
3059TRIGGER_FUNCTION(tf_militancy_state) {
3060 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3061}
3062TRIGGER_FUNCTION(tf_militancy_nation) {
3063 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3064}
3065TRIGGER_FUNCTION(tf_trade_goods_in_state_state) {
3066 return "dup >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " state-ptr @ state-has-rgo? " + truth_inversion(tval[0]);
3067}
3068TRIGGER_FUNCTION(tf_trade_goods_in_state_province) {
3069 return "dup state_membership @ >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " state-ptr @ state-has-rgo? " + truth_inversion(tval[0]);
3070}
3071TRIGGER_FUNCTION(tf_has_flashpoint) {
3072 return "dup flashpoint_tag @ valid? " + truth_inversion(tval[0]);
3073}
3074TRIGGER_FUNCTION(tf_flashpoint_tension) {
3075 return "dup flashpoint_tension @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3076}
3077TRIGGER_FUNCTION(tf_flashpoint_tension_province) {
3078 return "dup state_membership @ flashpoint_tension @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3079}
3080TRIGGER_FUNCTION(tf_crisis_exist) {
3081 return std::to_string(offsetof(sys::state, current_crisis_state)) + " state-ptr @ buf-add ptr-cast ptr(i32) @ " + std::to_string(int32_t(sys::crisis_state::inactive)) + " = " + truth_inversion(tval[0]);
3082}
3083TRIGGER_FUNCTION(tf_is_liberation_crisis) {
3084 return "state-ptr @ liberation-crisis? " + truth_inversion(tval[0]);
3085}
3086TRIGGER_FUNCTION(tf_is_claim_crisis) {
3087 return " false " + truth_inversion(tval[0]);
3088}
3089TRIGGER_FUNCTION(tf_crisis_temperature) {
3090 return std::to_string(offsetof(sys::state, crisis_temperature)) + " state-ptr @ buf-add ptr-cast ptr(f32) @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3091}
3092TRIGGER_FUNCTION(tf_involved_in_crisis_nation) {
3093 return "dup >index state-ptr @ in-crisis? " + truth_inversion(tval[0]);
3094}
3095TRIGGER_FUNCTION(tf_involved_in_crisis_pop) {
3096 return "dup " + pop_to_owner() + ">index state-ptr @ in-crisis? " + truth_inversion(tval[0]);
3097}
3098TRIGGER_FUNCTION(tf_rich_strata_life_needs_nation) {
3099 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3100}
3101TRIGGER_FUNCTION(tf_rich_strata_life_needs_state) {
3102 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3103}
3104TRIGGER_FUNCTION(tf_rich_strata_life_needs_province) {
3105 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3106}
3107TRIGGER_FUNCTION(tf_rich_strata_life_needs_pop) {
3108 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::rich_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3109}
3110TRIGGER_FUNCTION(tf_rich_strata_everyday_needs_nation) {
3111 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3112}
3113TRIGGER_FUNCTION(tf_rich_strata_everyday_needs_state) {
3114 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3115}
3116TRIGGER_FUNCTION(tf_rich_strata_everyday_needs_province) {
3117 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3118}
3119TRIGGER_FUNCTION(tf_rich_strata_everyday_needs_pop) {
3120 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::rich_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3121}
3122TRIGGER_FUNCTION(tf_rich_strata_luxury_needs_nation) {
3123 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3124}
3125TRIGGER_FUNCTION(tf_rich_strata_luxury_needs_state) {
3126 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3127}
3128TRIGGER_FUNCTION(tf_rich_strata_luxury_needs_province) {
3129 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::rich_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3130}
3131TRIGGER_FUNCTION(tf_rich_strata_luxury_needs_pop) {
3132 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::rich_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3133}
3134TRIGGER_FUNCTION(tf_middle_strata_life_needs_nation) {
3135 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3136}
3137TRIGGER_FUNCTION(tf_middle_strata_life_needs_state) {
3138 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3139}
3140TRIGGER_FUNCTION(tf_middle_strata_life_needs_province) {
3141 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3142}
3143TRIGGER_FUNCTION(tf_middle_strata_life_needs_pop) {
3144 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::middle_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3145}
3146TRIGGER_FUNCTION(tf_middle_strata_everyday_needs_nation) {
3147 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3148}
3149TRIGGER_FUNCTION(tf_middle_strata_everyday_needs_state) {
3150 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3151}
3152TRIGGER_FUNCTION(tf_middle_strata_everyday_needs_province) {
3153 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3154}
3155TRIGGER_FUNCTION(tf_middle_strata_everyday_needs_pop) {
3156 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::middle_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3157}
3158TRIGGER_FUNCTION(tf_middle_strata_luxury_needs_nation) {
3159 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3160}
3161TRIGGER_FUNCTION(tf_middle_strata_luxury_needs_state) {
3162 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3163}
3164TRIGGER_FUNCTION(tf_middle_strata_luxury_needs_province) {
3165 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::middle_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3166}
3167TRIGGER_FUNCTION(tf_middle_strata_luxury_needs_pop) {
3168 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::middle_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3169}
3170TRIGGER_FUNCTION(tf_poor_strata_life_needs_nation) {
3171 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3172}
3173TRIGGER_FUNCTION(tf_poor_strata_life_needs_state) {
3174 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3175}
3176TRIGGER_FUNCTION(tf_poor_strata_life_needs_province) {
3177 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3178}
3179TRIGGER_FUNCTION(tf_poor_strata_life_needs_pop) {
3180 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::poor_life_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3181}
3182TRIGGER_FUNCTION(tf_poor_strata_everyday_needs_nation) {
3183 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3184}
3185TRIGGER_FUNCTION(tf_poor_strata_everyday_needs_state) {
3186 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3187}
3188TRIGGER_FUNCTION(tf_poor_strata_everyday_needs_province) {
3189 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3190}
3191TRIGGER_FUNCTION(tf_poor_strata_everyday_needs_pop) {
3192 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::poor_everyday_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3193}
3194TRIGGER_FUNCTION(tf_poor_strata_luxury_needs_nation) {
3195 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3196}
3197TRIGGER_FUNCTION(tf_poor_strata_luxury_needs_state) {
3198 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3199}
3200TRIGGER_FUNCTION(tf_poor_strata_luxury_needs_province) {
3201 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r dup " + std::to_string(demographics::poor_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3202}
3203TRIGGER_FUNCTION(tf_poor_strata_luxury_needs_pop) {
3204 return "dup " + pop_to_location() + "state_membership @ dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r " + std::to_string(demographics::poor_luxury_needs.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3205}
3206TRIGGER_FUNCTION(tf_diplomatic_influence_tag) {
3207 return "dup >index " + std::to_string(trigger::payload(tval[2]).tag_id.index()) +" >national_identity_id " + tag_to_nation() + ">index state-ptr @ influence-on " + std::to_string(tval[1]) + ".0 " + compare_values(tval[0]);
3208}
3209TRIGGER_FUNCTION(tf_diplomatic_influence_this_nation) {
3210 return ">r dup r> swap >r dup >index r> >index state-ptr @ influence-on " + std::to_string(tval[1]) + ".0 " + compare_values(tval[0]);
3211}
3212TRIGGER_FUNCTION(tf_diplomatic_influence_this_province) {
3213 return ">r dup " + province_to_owner() + "r> swap >r dup >index r> >index state-ptr @ influence-on " + std::to_string(tval[1]) + ".0 " + compare_values(tval[0]);
3214}
3215TRIGGER_FUNCTION(tf_diplomatic_influence_from_nation) {
3216 return ">r >r dup r> swap r> swap >r dup >index r> >index state-ptr @ influence-on " + std::to_string(tval[1]) + ".0 " + compare_values(tval[0]);
3217}
3218TRIGGER_FUNCTION(tf_diplomatic_influence_from_province) {
3219 return ">r >r dup " + province_to_owner() + "r> swap r> swap >r dup >index r> >index state-ptr @ influence-on " + std::to_string(tval[1]) + ".0 " + compare_values(tval[0]);
3220}
3221TRIGGER_FUNCTION(tf_pop_unemployment_nation) {
3222 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3223 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3224 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3225}
3226TRIGGER_FUNCTION(tf_pop_unemployment_state) {
3227 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3228 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3229 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3230}
3231TRIGGER_FUNCTION(tf_pop_unemployment_province) {
3232 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3233 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3234 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3235}
3236TRIGGER_FUNCTION(tf_pop_unemployment_pop) {
3237 return "dup uemployment @ >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * 1.0 swap - " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3238}
3239TRIGGER_FUNCTION(tf_pop_unemployment_nation_this_pop) {
3240 return
3241 ">r dup poptype @ >index r> swap >r "
3242 "dup " + std::to_string(demographics::count_special_keys) + " r@ + >demographics_key demographics @ >r "
3243 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size()) + " r> r> swap >r + >demographics_key demographics @ "
3244 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3245}
3246TRIGGER_FUNCTION(tf_pop_unemployment_state_this_pop) {
3247 return
3248 ">r dup poptype @ >index r> swap >r "
3249 "dup " + std::to_string(demographics::count_special_keys) + " r@ + >demographics_key demographics @ >r "
3250 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size()) + " r> r> swap >r + >demographics_key demographics @ "
3251 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3252}
3253TRIGGER_FUNCTION(tf_pop_unemployment_province_this_pop) {
3254 return
3255 ">r dup poptype @ >index r> swap >r "
3256 "dup " + std::to_string(demographics::count_special_keys) + " r@ + >demographics_key demographics @ >r "
3257 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size()) + " r> r> swap >r + >demographics_key demographics @ "
3258 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3259}
3260TRIGGER_FUNCTION(tf_relation_tag) {
3261 return "dup >index " +std::to_string(trigger::payload(tval[2]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + ">index state-ptr @ relations " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3262}
3263TRIGGER_FUNCTION(tf_relation_this_nation) {
3264 return ">r dup >index r> swap >r dup >index r> state-ptr @ relations " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3265}
3266TRIGGER_FUNCTION(tf_relation_this_province) {
3267 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ relations " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3268}
3269TRIGGER_FUNCTION(tf_relation_this_pop) {
3270 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ relations " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3271}
3272TRIGGER_FUNCTION(tf_relation_from_nation) {
3273 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ relations " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3274}
3275TRIGGER_FUNCTION(tf_relation_from_province) {
3276 return ">r >r dup " + province_to_owner() + ">index r> swap r> swap >r dup >index r> state-ptr @ relations " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3277}
3278TRIGGER_FUNCTION(tf_check_variable) {
3279 return "dup " + std::to_string(trigger::payload(tval[3]).natv_id.index()) + " >national_variable_id variables @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3280}
3281TRIGGER_FUNCTION(tf_upper_house) {
3282 return "dup " + std::to_string(trigger::payload(tval[3]).ideo_id.index()) + " >ideology_id upper_house @ " + std::to_string(100.0f * read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3283}
3284TRIGGER_FUNCTION(tf_unemployment_by_type_nation) {
3285 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3286 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3287 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3288}
3289TRIGGER_FUNCTION(tf_unemployment_by_type_state) {
3290 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3291 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3292 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3293}
3294TRIGGER_FUNCTION(tf_unemployment_by_type_province) {
3295 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3296 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3297 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3298}
3299TRIGGER_FUNCTION(tf_unemployment_by_type_pop) {
3300 return "dup " + pop_to_location() + "state_membership @ dup "
3301 + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3302 + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3303 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3304}
3305TRIGGER_FUNCTION(tf_party_loyalty_nation_province_id) {
3306 return std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + std::to_string(trigger::payload(tval[3]).ideo_id.index()) + " >ideology_id party_loyalty @" + std::to_string(trigger::payload(tval[2]).signed_value) + ".0 " + compare_values(tval[0]);
3307}
3308TRIGGER_FUNCTION(tf_party_loyalty_from_nation_province_id) {
3309 return std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + std::to_string(trigger::payload(tval[3]).ideo_id.index()) + " >ideology_id party_loyalty @" + std::to_string(trigger::payload(tval[2]).signed_value) + ".0 " + compare_values(tval[0]);
3310}
3311TRIGGER_FUNCTION(tf_party_loyalty_province_province_id) {
3312 return std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + std::to_string(trigger::payload(tval[3]).ideo_id.index()) + " >ideology_id party_loyalty @" + std::to_string(trigger::payload(tval[2]).signed_value) + ".0 " + compare_values(tval[0]);
3313}
3314TRIGGER_FUNCTION(tf_party_loyalty_from_province_province_id) {
3315 return std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + std::to_string(trigger::payload(tval[3]).ideo_id.index()) + " >ideology_id party_loyalty @" + std::to_string(trigger::payload(tval[2]).signed_value) + ".0 " + compare_values(tval[0]);
3316}
3317TRIGGER_FUNCTION(tf_party_loyalty_nation_from_province) {
3318 return ">r >r dup r> swap r> swap " + std::to_string(trigger::payload(tval[2]).ideo_id.index()) + " >ideology_id party_loyalty @" + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
3319}
3320TRIGGER_FUNCTION(tf_party_loyalty_generic) {
3321 return "dup " + std::to_string(trigger::payload(tval[2]).ideo_id.index()) + " >ideology_id party_loyalty @" + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
3322}
3323TRIGGER_FUNCTION(tf_party_loyalty_from_nation_scope_province) {
3324 return "dup " + std::to_string(trigger::payload(tval[2]).ideo_id.index()) + " >ideology_id party_loyalty @" + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
3325}
3326TRIGGER_FUNCTION(tf_party_loyalty_from_province_scope_province) {
3327 return "dup " + std::to_string(trigger::payload(tval[2]).ideo_id.index()) + " >ideology_id party_loyalty @" + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
3328}
3329TRIGGER_FUNCTION(tf_can_build_in_province_railroad_no_limit_from_nation) {
3330 return ">r >r dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 max_building_level @ >f32 r> swap r> swap >r "
3331 "dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 building_level @ >f32 >r "
3332 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_railroad.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3333}
3334TRIGGER_FUNCTION(tf_can_build_in_province_railroad_yes_limit_from_nation) {
3335 return ">r >r dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 max_building_level @ >f32 r> swap r> swap >r "
3336 "dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 building_level @ >f32 >r "
3337 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_railroad.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3338}
3339TRIGGER_FUNCTION(tf_can_build_in_province_railroad_no_limit_this_nation) {
3340 return ">r dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 max_building_level @ >f32 r> swap >r "
3341 "dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 building_level @ >f32 >r "
3342 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_railroad.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3343}
3344TRIGGER_FUNCTION(tf_can_build_in_province_railroad_yes_limit_this_nation) {
3345 return ">r dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 max_building_level @ >f32 r> swap >r "
3346 "dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 building_level @ >f32 >r "
3347 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_railroad.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3348}
3349TRIGGER_FUNCTION(tf_can_build_in_province_fort_no_limit_from_nation) {
3350 return ">r >r dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 max_building_level @ >f32 r> swap r> swap >r "
3351 "dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 building_level @ >f32 >r "
3352 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_fort.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3353}
3354TRIGGER_FUNCTION(tf_can_build_in_province_fort_yes_limit_from_nation) {
3355 return ">r >r dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 max_building_level @ >f32 r> swap r> swap >r "
3356 "dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 building_level @ >f32 >r "
3357 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_fort.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3358}
3359TRIGGER_FUNCTION(tf_can_build_in_province_fort_no_limit_this_nation) {
3360 return ">r dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 max_building_level @ >f32 r> swap >r "
3361 "dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 building_level @ >f32 >r "
3362 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_fort.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3363}
3364TRIGGER_FUNCTION(tf_can_build_in_province_fort_yes_limit_this_nation) {
3365 return ">r dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 max_building_level @ >f32 r> swap >r "
3366 "dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 building_level @ >f32 >r "
3367 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_fort.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3368}
3369TRIGGER_FUNCTION(tf_can_build_in_province_naval_base_no_limit_from_nation) {
3370 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ can-build-naval-base? " + truth_inversion(tval[0]);
3371}
3372TRIGGER_FUNCTION(tf_can_build_in_province_naval_base_yes_limit_from_nation) {
3373 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ can-build-naval-base? " + truth_inversion(tval[0]);
3374}
3375TRIGGER_FUNCTION(tf_can_build_in_province_naval_base_no_limit_this_nation) {
3376 return ">r dup >index r> swap >r dup >index r> state-ptr @ can-build-naval-base? " + truth_inversion(tval[0]);
3377}
3378TRIGGER_FUNCTION(tf_can_build_in_province_naval_base_yes_limit_this_nation) {
3379 return ">r dup >index r> swap >r dup >index r> state-ptr @ can-build-naval-base? " + truth_inversion(tval[0]);
3380}
3381TRIGGER_FUNCTION(tf_can_build_railway_in_capital_yes_whole_state_yes_limit) {
3382 return "true " + truth_inversion(tval[0]);
3383}
3384TRIGGER_FUNCTION(tf_can_build_railway_in_capital_yes_whole_state_no_limit) {
3385 return "true " + truth_inversion(tval[0]);
3386}
3387TRIGGER_FUNCTION(tf_can_build_railway_in_capital_no_whole_state_yes_limit) {
3388 return "true " + truth_inversion(tval[0]);
3389}
3390TRIGGER_FUNCTION(tf_can_build_railway_in_capital_no_whole_state_no_limit) {
3391 return "true " + truth_inversion(tval[0]);
3392}
3393TRIGGER_FUNCTION(tf_can_build_fort_in_capital_yes_whole_state_yes_limit) {
3394 return "true " + truth_inversion(tval[0]);
3395}
3396TRIGGER_FUNCTION(tf_can_build_fort_in_capital_yes_whole_state_no_limit) {
3397 return "true " + truth_inversion(tval[0]);
3398}
3399TRIGGER_FUNCTION(tf_can_build_fort_in_capital_no_whole_state_yes_limit) {
3400 return "true " + truth_inversion(tval[0]);
3401}
3402TRIGGER_FUNCTION(tf_can_build_fort_in_capital_no_whole_state_no_limit) {
3403 return "true " + truth_inversion(tval[0]);
3404}
3405TRIGGER_FUNCTION(tf_work_available_nation) {
3406 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ >r "
3407 "dup " + std::to_string(demographics::to_employment_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3408 " r> >= " + truth_inversion(tval[0]);
3409}
3410TRIGGER_FUNCTION(tf_work_available_state) {
3411 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ >r "
3412 "dup " + std::to_string(demographics::to_employment_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3413 " r> >= " + truth_inversion(tval[0]);
3414}
3415TRIGGER_FUNCTION(tf_work_available_province) {
3416 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ >r "
3417 "dup " + std::to_string(demographics::to_employment_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3418 " r> >= " + truth_inversion(tval[0]);
3419}
3420TRIGGER_FUNCTION(tf_variable_ideology_name_nation) {
3421 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3422 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).ideo_id).index()) + " >demographics_key demographics @ "
3423 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3424}
3425TRIGGER_FUNCTION(tf_variable_ideology_name_state) {
3426 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3427 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).ideo_id).index()) + " >demographics_key demographics @ "
3428 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3429}
3430TRIGGER_FUNCTION(tf_variable_ideology_name_province) {
3431 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3432 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).ideo_id).index()) + " >demographics_key demographics @ "
3433 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3434}
3435TRIGGER_FUNCTION(tf_variable_ideology_name_pop) {
3436 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).ideo_id).index()) + " >pop_demographics_key udemographics @ "
3437 " >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3438}
3439TRIGGER_FUNCTION(tf_variable_issue_name_nation) {
3440 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3441 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).opt_id).index()) + " >demographics_key demographics @ "
3442 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3443}
3444TRIGGER_FUNCTION(tf_variable_issue_name_state) {
3445 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3446 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).opt_id).index()) + " >demographics_key demographics @ "
3447 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3448}
3449TRIGGER_FUNCTION(tf_variable_issue_name_province) {
3450 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3451 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).opt_id).index()) + " >demographics_key demographics @ "
3452 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3453}
3454TRIGGER_FUNCTION(tf_variable_issue_name_pop) {
3455 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).opt_id).index()) + " >pop_demographics_key udemographics @ "
3456 " >f32 " + std::to_string(1.0f / float(std::numeric_limits<uint8_t>::max())) + " * " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3457}
3458TRIGGER_FUNCTION(tf_variable_issue_group_name_nation) {
3459 return "dup " + std::to_string(trigger::payload(tval[1]).iss_id.index()) + " >issue_id issues @ >index " + std::to_string(trigger::payload(tval[2]).opt_id.index()) + " " + compare_values_eq(tval[0]);
3460}
3461TRIGGER_FUNCTION(tf_variable_issue_group_name_state) {
3462 return "dup " + state_to_owner() + std::to_string(trigger::payload(tval[1]).iss_id.index()) + " >issue_id issues @ >index " + std::to_string(trigger::payload(tval[2]).opt_id.index()) + " " + compare_values_eq(tval[0]);
3463}
3464TRIGGER_FUNCTION(tf_variable_issue_group_name_province) {
3465 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).iss_id.index()) + " >issue_id issues @ >index " + std::to_string(trigger::payload(tval[2]).opt_id.index()) + " " + compare_values_eq(tval[0]);
3466}
3467TRIGGER_FUNCTION(tf_variable_issue_group_name_pop) {
3468 return "dup " + pop_to_owner() + std::to_string(trigger::payload(tval[1]).iss_id.index()) + " >issue_id issues @ >index " + std::to_string(trigger::payload(tval[2]).opt_id.index()) + " " + compare_values_eq(tval[0]);
3469}
3470TRIGGER_FUNCTION(tf_variable_reform_group_name_nation) {
3471 return "dup " + std::to_string(trigger::payload(tval[1]).ref_id.index()) + " >reform_id issues @ >index " + std::to_string(trigger::payload(tval[2]).ropt_id.index()) + " " + compare_values_eq(tval[0]);
3472}
3473TRIGGER_FUNCTION(tf_variable_reform_group_name_state) {
3474 return "dup " + state_to_owner() + std::to_string(trigger::payload(tval[1]).ref_id.index()) + " >reform_id issues @ >index " + std::to_string(trigger::payload(tval[2]).ropt_id.index()) + " " + compare_values_eq(tval[0]);
3475}
3476TRIGGER_FUNCTION(tf_variable_reform_group_name_province) {
3477 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).ref_id.index()) + " >reform_id issues @ >index " + std::to_string(trigger::payload(tval[2]).ropt_id.index()) + " " + compare_values_eq(tval[0]);
3478}
3479TRIGGER_FUNCTION(tf_variable_reform_group_name_pop) {
3480 return "dup " + pop_to_owner() + std::to_string(trigger::payload(tval[1]).ref_id.index()) + " >reform_id issues @ >index " + std::to_string(trigger::payload(tval[2]).ropt_id.index()) + " " + compare_values_eq(tval[0]);
3481}
3482TRIGGER_FUNCTION(tf_variable_pop_type_name_nation) {
3483 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3484 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3485 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3486}
3487TRIGGER_FUNCTION(tf_variable_pop_type_name_state) {
3488 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3489 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3490 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3491}
3492TRIGGER_FUNCTION(tf_variable_pop_type_name_province) {
3493 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3494 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3495 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3496}
3497TRIGGER_FUNCTION(tf_variable_pop_type_name_pop) {
3498 return "dup " + pop_to_location() + "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3499 + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3500 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3501}
3502TRIGGER_FUNCTION(tf_variable_good_name) {
3503 return "dup " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " >commodity_id stockpiles @ " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3504}
3505TRIGGER_FUNCTION(tf_religion_nation) {
3506 return "dup religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " " + compare_values_eq(tval[0]);
3507}
3508TRIGGER_FUNCTION(tf_religion_nation_reb) {
3509 return ">r >r dup religion @ r> swap r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3510}
3511TRIGGER_FUNCTION(tf_religion_nation_from_nation) {
3512 return ">r >r dup religion @ r> swap r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3513}
3514TRIGGER_FUNCTION(tf_religion_nation_this_nation) {
3515 return ">r dup religion @ r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3516}
3517TRIGGER_FUNCTION(tf_religion_nation_this_state) {
3518 return ">r dup " + state_to_owner() + "religion @ r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3519}
3520TRIGGER_FUNCTION(tf_religion_nation_this_province) {
3521 return ">r dup " + province_to_owner() + "religion @ r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3522}
3523TRIGGER_FUNCTION(tf_religion_nation_this_pop) {
3524 return ">r dup " + pop_to_owner() + "religion @ r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3525}
3526TRIGGER_FUNCTION(tf_invention) {
3527 return "dup " + std::to_string(trigger::payload(tval[1]).invt_id.index()) + " >invention_id active_inventions @ " + truth_inversion(tval[0]);
3528}
3529TRIGGER_FUNCTION(tf_invention_province) {
3530 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).invt_id.index()) + " >invention_id active_inventions @ " + truth_inversion(tval[0]);
3531}
3532TRIGGER_FUNCTION(tf_invention_pop) {
3533 return "dup " + pop_to_owner() + std::to_string(trigger::payload(tval[1]).invt_id.index()) + " >invention_id active_inventions @ " + truth_inversion(tval[0]);
3534}
3536 auto sid = trigger::payload(tval[1]).str_id;
3537 auto tid = ws.world.stored_trigger_get_function(sid);
3538 return test_trigger_generic(ws.trigger_data.data() + ws.trigger_data_indices[tid.index() + 1], ws) + truth_inversion(tval[0]);
3539}
3540
3541TRIGGER_FUNCTION(tf_has_building_bank) {
3542 return "dup " + std::to_string(int32_t(economy::province_building_type::bank)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
3543}
3544TRIGGER_FUNCTION(tf_has_building_university) {
3545 return "dup " + std::to_string(int32_t(economy::province_building_type::university)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
3546}
3547
3548TRIGGER_FUNCTION(tf_party_name) {
3549 auto ideo = trigger::payload(tval[1]).ideo_id;
3550 dcon::text_key new_name{ dcon::text_key::value_base_t(trigger::read_int32_t_from_payload(tval + 2)) };
3551
3552 if(ideo) {
3553 return "dup >index >r " + std::to_string(new_name.index()) + " " + std::to_string(ideo.index()) + " r> state-ptr @ has-named-party? " + truth_inversion(tval[0]);
3554 } else {
3555 return "dup ruling_party @ name @ " + std::to_string(new_name.index()) + " >text_key = " + truth_inversion(tval[0]);
3556 }
3557}
3558
3559TRIGGER_FUNCTION(tf_party_position) {
3560 auto ideo = trigger::payload(tval[1]).ideo_id;
3561 dcon::issue_option_id new_opt = trigger::payload(tval[2]).opt_id;
3562
3563 if(ideo) {
3564 return "dup >index >r " + std::to_string(new_opt.index()) + " " + std::to_string(ideo.index()) + " r> state-ptr @ has-positioned-party? " + truth_inversion(tval[0]);
3565 } else {
3566 auto popt = ws.world.issue_option_get_parent_issue(new_opt);
3567 return "dup ruling_party @ " + std::to_string(popt.id.index()) + " >issue_id party_issues @ " + std::to_string(new_opt.index()) + " >issue_option_id = " + truth_inversion(tval[0]);
3568 }
3569}
3570
3572 constexpr static std::string (
3573 CALLTYPE* trigger_functions[])(uint16_t const* tval, sys::state& ws) = {
3574 tf_none,
3575#define TRIGGER_BYTECODE_ELEMENT(code, name, arg) tf_##name ,
3577#undef TRIGGER_BYTECODE_ELEMENT
3578 //
3579 // scopes
3580 //
3581 tf_generic_scope, // constexpr uint16_t generic_scope = 0x0000; // or & and
3582 tf_x_neighbor_province_scope, // constexpr uint16_t x_neighbor_province_scope = 0x0001;
3583 tf_x_neighbor_country_scope_nation, // constexpr uint16_t x_neighbor_country_scope_nation = 0x0002;
3584 tf_x_neighbor_country_scope_pop, // constexpr uint16_t x_neighbor_country_scope_pop = 0x0003;
3585 tf_x_war_countries_scope_nation, // constexpr uint16_t x_war_countries_scope_nation = 0x0004;
3586 tf_x_war_countries_scope_pop, // constexpr uint16_t x_war_countries_scope_pop = 0x0005;
3587 tf_x_greater_power_scope, // constexpr uint16_t x_greater_power_scope = 0x0006;
3588 tf_x_owned_province_scope_state, // constexpr uint16_t x_owned_province_scope_state = 0x0007;
3589 tf_x_owned_province_scope_nation, // constexpr uint16_t x_owned_province_scope_nation = 0x0008;
3590 tf_x_core_scope_province, // constexpr uint16_t x_core_scope_province = 0x0009;
3591 tf_x_core_scope_nation, // constexpr uint16_t x_core_scope_nation = 0x000A;
3592 tf_x_state_scope, // constexpr uint16_t x_state_scope = 0x000B;
3593 tf_x_substate_scope, // constexpr uint16_t x_substate_scope = 0x000C;
3594 tf_x_sphere_member_scope, // constexpr uint16_t x_sphere_member_scope = 0x000D;
3595 tf_x_pop_scope_province, // constexpr uint16_t x_pop_scope_province = 0x000E;
3596 tf_x_pop_scope_state, // constexpr uint16_t x_pop_scope_state = 0x000F;
3597 tf_x_pop_scope_nation, // constexpr uint16_t x_pop_scope_nation = 0x0010;
3598 tf_x_provinces_in_variable_region, // constexpr uint16_t x_provinces_in_variable_region = 0x0011; // variable name
3599 tf_owner_scope_state, // constexpr uint16_t owner_scope_state = 0x0012;
3600 tf_owner_scope_province, // constexpr uint16_t owner_scope_province = 0x0013;
3601 tf_controller_scope, // constexpr uint16_t controller_scope = 0x0014;
3602 tf_location_scope, // constexpr uint16_t location_scope = 0x0015;
3603 tf_country_scope_state, // constexpr uint16_t country_scope_state = 0x0016;
3604 tf_country_scope_pop, // constexpr uint16_t country_scope_pop = 0x0017;
3605 tf_capital_scope, // constexpr uint16_t capital_scope = 0x0018;
3606 tf_this_scope, // constexpr uint16_t this_scope_pop = 0x0019;
3607 tf_this_scope, // constexpr uint16_t this_scope_nation = 0x001A;
3608 tf_this_scope, // constexpr uint16_t this_scope_state = 0x001B;
3609 tf_this_scope, // constexpr uint16_t this_scope_province = 0x001C;
3610 tf_from_scope, // constexpr uint16_t from_scope_pop = 0x001D;
3611 tf_from_scope, // constexpr uint16_t from_scope_nation = 0x001E;
3612 tf_from_scope, // constexpr uint16_t from_scope_state = 0x001F;
3613 tf_from_scope, // constexpr uint16_t from_scope_province = 0x0020;
3614 tf_sea_zone_scope, // constexpr uint16_t sea_zone_scope = 0x0021;
3615 tf_cultural_union_scope, // constexpr uint16_t cultural_union_scope = 0x0022;
3616 tf_overlord_scope, // constexpr uint16_t overlord_scope = 0x0023;
3617 tf_sphere_owner_scope, // constexpr uint16_t sphere_owner_scope = 0x0024;
3618 tf_independence_scope, // constexpr uint16_t independence_scope = 0x0025;
3619 tf_flashpoint_tag_scope, // constexpr uint16_t flashpoint_tag_scope = 0x0026;
3620 tf_crisis_state_scope, // constexpr uint16_t crisis_state_scope = 0x0027;
3621 tf_state_scope_pop, // constexpr uint16_t state_scope_pop = 0x0028;
3622 tf_state_scope_province, // constexpr uint16_t state_scope_province = 0x0029;
3623 tf_tag_scope, // constexpr uint16_t tag_scope = 0x002A; // variable name
3624 tf_integer_scope, // constexpr uint16_t integer_scope = 0x002B; // variable name
3625 tf_country_scope_nation, // constexpr uint16_t country_scope_nation = 0x002C;
3626 tf_country_scope_province, // constexpr uint16_t country_scope_province = 0x002D;
3627 tf_cultural_union_scope_pop, // constexpr uint16_t cultural_union_scope_pop = 0x002E;
3628 tf_capital_scope_province, // constexpr uint16_t capital_scope_province = 0x002F;
3629 tf_capital_scope_pop, //constexpr inline uint16_t capital_scope_pop = first_scope_code + 0x0030;
3630 tf_x_country_scope, //constexpr inline uint16_t x_country_scope = first_scope_code + 0x0031;
3631 tf_x_neighbor_province_scope_state, //constexpr inline uint16_t x_neighbor_province_scope_state = first_scope_code + 0x0032;
3632 tf_x_provinces_in_variable_region_proper, //constexpr inline uint16_t x_provinces_in_variable_region_proper = first_scope_code + 0x0033;
3633 };
3634};
3635
3636
3637std::string CALLTYPE test_trigger_generic(uint16_t const* tval, sys::state& ws) {
3638 return trigger_container::trigger_functions[*tval & trigger::code_mask](tval, ws);
3639}
3640
3641std::string multiplicative_modifier(sys::state& state, dcon::value_modifier_key modifier) {
3642 auto base = state.value_modifiers[modifier];
3643 std::string result;
3644 result += std::to_string(base.factor) + " >r ";
3645
3646 for(uint32_t i = 0; i < base.segments_count; ++i) {
3647 auto seg = state.value_modifier_segments[base.first_segment_offset + i];
3648 if(seg.condition) {
3649 result += test_trigger_generic(state.trigger_data.data() + state.trigger_data_indices[seg.condition.index() + 1], state);
3650 result += "1.0 swap " + std::to_string(seg.factor) + " swap select r> * >r "; // multiply by either 1.0 or the segement factor depending on bool result
3651 }
3652 }
3653 return result;
3654}
3655std::string additive_modifier(sys::state& state, dcon::value_modifier_key modifier) {
3656 auto base = state.value_modifiers[modifier];
3657 std::string result;
3658 result += std::to_string(base.base) + " >r ";
3659
3660 for(uint32_t i = 0; i < base.segments_count; ++i) {
3661 auto seg = state.value_modifier_segments[base.first_segment_offset + i];
3662 if(seg.condition) {
3663 result += test_trigger_generic(state.trigger_data.data() + state.trigger_data_indices[seg.condition.index() + 1], state);
3664 result += "0.0 swap " + std::to_string(seg.factor) + " swap select r> + >r "; // multiply by either 1.0 or the segement factor depending on bool result
3665 }
3666 }
3667 result += "r> " + std::to_string(base.factor) + " * >r ";
3668 return result;
3669}
3670
3671std::string evaluate(sys::state& state, dcon::trigger_key key) {
3672 return test_trigger_generic(state.trigger_data.data() + state.trigger_data_indices[key.index() + 1], state);
3673}
3674
3675#undef CALLTYPE
3676#undef TRIGGER_FUNCTION
3677
3678} // namespace trigger
#define CALLTYPE
#define TRIGGER_FUNCTION(function_name)
constexpr dcon::demographics_key rich_life_needs(13)
constexpr dcon::demographics_key poor_luxury_needs(17)
constexpr dcon::demographics_key middle_life_needs(12)
constexpr dcon::demographics_key rich_militancy(10)
constexpr dcon::demographics_key middle_total(21)
constexpr dcon::demographics_key middle_luxury_needs(18)
constexpr dcon::demographics_key political_reform_desire(6)
constexpr dcon::demographics_key total(0)
constexpr dcon::demographics_key rich_everyday_needs(16)
constexpr dcon::demographics_key poor_militancy(8)
constexpr dcon::demographics_key rich_luxury_needs(19)
constexpr dcon::demographics_key poor_everyday_needs(14)
constexpr dcon::demographics_key middle_militancy(9)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr uint32_t count_special_keys
constexpr dcon::demographics_key employable(1)
constexpr dcon::demographics_key consciousness(3)
constexpr dcon::demographics_key rich_total(22)
constexpr dcon::demographics_key poor_total(20)
constexpr dcon::demographics_key poor_life_needs(11)
constexpr dcon::demographics_key employed(2)
dcon::demographics_key to_employment_key(sys::state const &state, dcon::pop_type_id v)
constexpr dcon::demographics_key social_reform_desire(7)
constexpr dcon::demographics_key literacy(5)
constexpr dcon::demographics_key middle_everyday_needs(15)
constexpr dcon::demographics_key militancy(4)
int32_t read_int32_t_from_payload(uint16_t const *data)
float read_float_from_payload(uint16_t const *data)
std::string nation_to_union_holder()
std::string culture_to_union_holder()
std::string CALLTYPE test_trigger_generic(uint16_t const *tval, sys::state &ws)
std::string evaluate(sys::state &state, dcon::trigger_key key)
std::string multiplicative_modifier(sys::state &state, dcon::value_modifier_key modifier)
std::string compare_values_eq(uint16_t trigger_code)
std::string additive_modifier(sys::state &state, dcon::value_modifier_key modifier)
std::string compare_values(uint16_t trigger_code)
std::string overlord_from_subject()
std::string demo_culture_key(sys::state &ws)
std::string truth_inversion(uint16_t trigger_code)
Definition: fif.hpp:44
std::string province_to_controller()
std::string tag_to_nation()
std::string nation_to_tag()
std::string province_to_owner()
std::string pop_to_location()
std::string pop_to_owner()
std::string state_to_owner()
constexpr uint32_t slavery_allowed
Definition: culture.hpp:27
constexpr uint32_t pop_build_factory
Definition: culture.hpp:14
constexpr uint32_t count_special_keys
Definition: demographics.hpp:7
constexpr uint16_t code_mask
int32_t get_trigger_scope_payload_size(uint16_t const *data)
constexpr uint16_t is_disjunctive_scope
int32_t read_int32_t_from_payload(uint16_t const *data)
Definition: triggers.cpp:133
constexpr uint16_t association_gt
constexpr uint16_t association_le
constexpr uint16_t association_ge
constexpr uint16_t association_mask
constexpr uint16_t association_lt
constexpr uint16_t is_existence_scope
int32_t trigger_scope_data_payload(uint16_t code)
int32_t get_trigger_payload_size(uint16_t const *data)
constexpr uint16_t association_ne
constexpr uint16_t association_eq
uint uint32_t
uchar uint8_t
#define TRIGGER_BYTECODE_LIST
static constexpr sys::state & ws
static constexpr std::string(CALLTYPE *trigger_functions[])(uint16_t const *tval
Holds important data about the game world, state, and other data regarding windowing,...
dcon::data_container world
dcon::national_identity_id tag_id
dcon::stored_trigger_id str_id
dcon::province_id prov_id
dcon::ideology_id ideo_id
dcon::pop_type_id popt_id
dcon::issue_option_id opt_id