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}
1482 return "dup " + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + province_to_owner() + " = " + truth_inversion(tval[0]);
1483}
1484TRIGGER_FUNCTION(tf_owns_province) {
1485 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + province_to_owner() + " = " + truth_inversion(tval[0]);
1486}
1487TRIGGER_FUNCTION(tf_controls) {
1488 return "dup " + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " >province_id " + province_to_controller() + " = " + truth_inversion(tval[0]);
1489}
1490TRIGGER_FUNCTION(tf_is_core_integer) {
1491 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]);
1492}
1493TRIGGER_FUNCTION(tf_is_core_this_nation) {
1494 return "dup >index >r >r dup " + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-province " + truth_inversion(tval[0]);
1495}
1496TRIGGER_FUNCTION(tf_is_core_this_state) {
1497 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]);
1498}
1499TRIGGER_FUNCTION(tf_is_core_this_province) {
1500 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]);
1501}
1502TRIGGER_FUNCTION(tf_is_core_this_pop) {
1503 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]);
1504}
1505TRIGGER_FUNCTION(tf_is_core_from_nation) {
1506 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]);
1507}
1508TRIGGER_FUNCTION(tf_is_core_reb) {
1509 return "dup >index >r >r >r dup defection_target @ >index r> swap r> swap r> state-ptr @ core-in-province " + truth_inversion(tval[0]);
1510}
1511TRIGGER_FUNCTION(tf_is_core_state_from_nation) {
1512 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]);
1513}
1514TRIGGER_FUNCTION(tf_is_core_state_this_nation) {
1515 return "dup >index >r >r dup " + nation_to_tag() + ">index r> swap r> state-ptr @ core-in-state " + truth_inversion(tval[0]);
1516}
1517TRIGGER_FUNCTION(tf_is_core_state_this_province) {
1518 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]);
1519}
1520TRIGGER_FUNCTION(tf_is_core_state_this_pop) {
1521 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]);
1522}
1523TRIGGER_FUNCTION(tf_is_core_boolean) {
1524 return "dup is_owner_core @ " + truth_inversion(tval[0]);
1525}
1526TRIGGER_FUNCTION(tf_is_core_tag) {
1527 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " swap state-ptr @ core-in-province " + truth_inversion(tval[0]);
1528}
1529TRIGGER_FUNCTION(tf_is_core_pop_tag) {
1530 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]);
1531}
1532TRIGGER_FUNCTION(tf_is_core_state_tag) {
1533 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " swap state-ptr @ core-fully-state " + truth_inversion(tval[0]);
1534}
1535TRIGGER_FUNCTION(tf_num_of_revolts) {
1536 return "dup rebel_controlled_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1537}
1538TRIGGER_FUNCTION(tf_revolt_percentage) {
1539 return "dup central_province_count @ >f32 >r dup central_rebel_controlled @ >f32 r@ / 0.0 r> 0.0 <= select "
1540 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1541}
1542TRIGGER_FUNCTION(tf_num_of_cities_int) {
1543 return "dup owned_province_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1544}
1545TRIGGER_FUNCTION(tf_num_of_cities_from_nation) {
1546 return ">r >r dup owned_province_count @ r> swap r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1547}
1548TRIGGER_FUNCTION(tf_num_of_cities_this_nation) {
1549 return ">r dup owned_province_count @ r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1550}
1551TRIGGER_FUNCTION(tf_num_of_cities_this_state) {
1552 return ">r dup " + state_to_owner() + "owned_province_count @ r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1553}
1554TRIGGER_FUNCTION(tf_num_of_cities_this_province) {
1555 return ">r dup " + province_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_pop) {
1558 return ">r dup " + pop_to_owner() + "owned_province_count @ r> swap >r dup owned_province_count @ r> " + compare_values(tval[0]);
1559}
1560TRIGGER_FUNCTION(tf_num_of_ports) {
1561 return "dup central_ports @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1562}
1563TRIGGER_FUNCTION(tf_num_of_allies) {
1564 return "dup allies_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1565}
1566TRIGGER_FUNCTION(tf_num_of_vassals) {
1567 return "dup vassals_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
1568}
1569TRIGGER_FUNCTION(tf_owned_by_tag) {
1570 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]);
1571}
1572TRIGGER_FUNCTION(tf_owned_by_this_nation) {
1573 return ">r dup r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1574}
1575TRIGGER_FUNCTION(tf_owned_by_from_nation) {
1576 return ">r >r dup r> swap r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1577}
1578TRIGGER_FUNCTION(tf_owned_by_this_province) {
1579 return ">r dup " + province_to_owner() + "r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1580}
1581TRIGGER_FUNCTION(tf_owned_by_this_state) {
1582 return ">r dup " + state_to_owner() + "r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1583}
1584TRIGGER_FUNCTION(tf_owned_by_this_pop) {
1585 return ">r dup " + pop_to_owner() + "r> swap >r dup " + province_to_owner() + " r> = " + truth_inversion(tval[0]);
1586}
1587TRIGGER_FUNCTION(tf_owned_by_state_tag) {
1588 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]);
1589}
1590TRIGGER_FUNCTION(tf_owned_by_state_this_nation) {
1591 return ">r dup r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1592}
1593TRIGGER_FUNCTION(tf_owned_by_state_from_nation) {
1594 return ">r >r dup r> swap r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1595}
1596TRIGGER_FUNCTION(tf_owned_by_state_this_province) {
1597 return ">r dup " + province_to_owner() + "r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1598}
1599TRIGGER_FUNCTION(tf_owned_by_state_this_state) {
1600 return ">r dup " + state_to_owner() + "r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1601}
1602TRIGGER_FUNCTION(tf_owned_by_state_this_pop) {
1603 return ">r dup " + pop_to_owner() + "r> swap >r dup " + state_to_owner() + " r> = " + truth_inversion(tval[0]);
1604}
1605TRIGGER_FUNCTION(tf_exists_bool) {
1606 return "dup owned_province_count @ >i32 0 <> " + truth_inversion(tval[0]);
1607}
1608TRIGGER_FUNCTION(tf_exists_tag) {
1609 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]);
1610}
1611TRIGGER_FUNCTION(tf_has_country_flag) {
1612 return "dup " + std::to_string(trigger::payload(tval[1]).natf_id.index()) + " >national_flag_id flag_variables @ " + truth_inversion(tval[0]);
1613}
1614TRIGGER_FUNCTION(tf_has_country_flag_pop) {
1615 return "dup " + pop_to_owner() + 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_province) {
1618 return "dup " + province_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_state) {
1621 return "dup " + state_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_continent_province) {
1624 return "dup continent @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1625}
1626TRIGGER_FUNCTION(tf_continent_state) {
1627 return "dup capital @ continent @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1628}
1629TRIGGER_FUNCTION(tf_continent_nation) {
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_pop) {
1633 return "dup " + pop_to_location() + "continent @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
1634}
1635TRIGGER_FUNCTION(tf_continent_nation_this) {
1636 return ">r dup capital @ continent @ r> swap >r dup capital @ continent @ r> = " + truth_inversion(tval[0]);
1637}
1638TRIGGER_FUNCTION(tf_continent_state_this) {
1639 return ">r dup capital @ continent @ r> swap >r dup capital @ continent @ r> = " + truth_inversion(tval[0]);
1640}
1641TRIGGER_FUNCTION(tf_continent_province_this) {
1642 return ">r dup capital @ continent @ r> swap >r dup continent @ r> = " + truth_inversion(tval[0]);
1643}
1644TRIGGER_FUNCTION(tf_continent_pop_this) {
1645 return ">r dup capital @ continent @ r> swap >r dup " + pop_to_location() + "continent @ r> = " + truth_inversion(tval[0]);
1646}
1647TRIGGER_FUNCTION(tf_continent_nation_from) {
1648 return ">r >r dup capital @ continent @ r> swap r> swap >r dup capital @ continent @ r> = " + truth_inversion(tval[0]);
1649}
1650TRIGGER_FUNCTION(tf_continent_state_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_province_from) {
1654 return ">r >r dup capital @ continent @ r> swap r> swap >r dup continent @ r> = " + truth_inversion(tval[0]);
1655}
1656TRIGGER_FUNCTION(tf_continent_pop_from) {
1657 return ">r >r dup capital @ continent @ r> swap r> swap >r dup " + pop_to_location() + "continent @ r> = " + truth_inversion(tval[0]);
1658}
1659TRIGGER_FUNCTION(tf_casus_belli_tag) {
1660 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]);
1661}
1662TRIGGER_FUNCTION(tf_casus_belli_from) {
1663 return ">r >r dup r> swap r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1664}
1665TRIGGER_FUNCTION(tf_casus_belli_this_nation) {
1666 return ">r >dup r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1667}
1668TRIGGER_FUNCTION(tf_casus_belli_this_state) {
1669 return ">r >dup " + state_to_owner() + "r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1670}
1671TRIGGER_FUNCTION(tf_casus_belli_this_province) {
1672 return ">r >dup " + province_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_pop) {
1675 return ">r >dup " + pop_to_owner() + "r> swap >r dup >index r> >index state-ptr @ has-cb-against " + truth_inversion(tval[0]);
1676}
1677TRIGGER_FUNCTION(tf_military_access_tag) {
1678 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]);
1679}
1680TRIGGER_FUNCTION(tf_military_access_from) {
1681 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1682}
1683TRIGGER_FUNCTION(tf_military_access_this_nation) {
1684 return ">r dup >index r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1685}
1686TRIGGER_FUNCTION(tf_military_access_this_state) {
1687 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1688}
1689TRIGGER_FUNCTION(tf_military_access_this_province) {
1690 return ">r dup " + province_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_pop) {
1693 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ has-access-with " + truth_inversion(tval[0]);
1694}
1695TRIGGER_FUNCTION(tf_prestige_value) {
1696 return "dup prestige @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1697}
1698TRIGGER_FUNCTION(tf_prestige_from) {
1699 return ">r >r dup prestige @ r> swap r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1700}
1701TRIGGER_FUNCTION(tf_prestige_this_nation) {
1702 return ">r dup prestige @ r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1703}
1704TRIGGER_FUNCTION(tf_prestige_this_state) {
1705 return ">r dup " + state_to_owner() + "prestige @ r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1706}
1707TRIGGER_FUNCTION(tf_prestige_this_province) {
1708 return ">r dup " + province_to_owner() + "prestige @ r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1709}
1710TRIGGER_FUNCTION(tf_prestige_this_pop) {
1711 return ">r dup " + pop_to_owner() + "prestige @ r> swap >r dup prestige @ r> " + compare_values(tval[0]);
1712}
1714 return "dup infamy @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1715}
1716TRIGGER_FUNCTION(tf_has_building_fort) {
1717 return "dup " + std::to_string(int32_t(economy::province_building_type::fort)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
1718}
1719TRIGGER_FUNCTION(tf_has_building_railroad) {
1720 return "dup " + std::to_string(int32_t(economy::province_building_type::railroad)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
1721}
1722TRIGGER_FUNCTION(tf_has_building_naval_base) {
1723 return "dup " + std::to_string(int32_t(economy::province_building_type::naval_base)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
1724}
1725TRIGGER_FUNCTION(tf_has_building_factory) {
1726 return "dup >index state-ptr @ has-any-factory " + truth_inversion(tval[0]);
1727}
1728TRIGGER_FUNCTION(tf_has_building_state) {
1729 return "dup >index " + std::to_string(trigger::payload(tval[1]).fac_id.index()) + " state-ptr @ has-factory " + truth_inversion(tval[0]);
1730}
1731TRIGGER_FUNCTION(tf_has_building_state_from_province) {
1732 return "dup state_membership @ >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_factory_from_province) {
1735 return "dup state_membership @ >index state-ptr @ has-any-factory " + truth_inversion(tval[0]);
1736}
1738 return "dup " + province_to_owner() + "make nation_id = " + truth_inversion(tval[0]);
1739}
1740TRIGGER_FUNCTION(tf_empty_state) {
1741 return "dup make state_instance_id = " + truth_inversion(tval[0]);
1742}
1743TRIGGER_FUNCTION(tf_is_blockaded) {
1744 return "dup is_blockaded @ " + truth_inversion(tval[0]);
1745}
1746TRIGGER_FUNCTION(tf_has_country_modifier) {
1747 return "dup >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " state-ptr @ has-nmod " + truth_inversion(tval[0]);
1748}
1749TRIGGER_FUNCTION(tf_has_country_modifier_province) {
1750 return "dup " + province_to_owner() + ">index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " state-ptr @ has-nmod " + truth_inversion(tval[0]);
1751}
1752TRIGGER_FUNCTION(tf_has_province_modifier) {
1753 return "dup >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " state-ptr @ has-pmod " + truth_inversion(tval[0]);
1754}
1756 return "dup abstract_state_membership-province state @ >index " + std::to_string(trigger::payload(tval[1]).state_id.index()) + " " + compare_values_eq(tval[0]);
1757}
1758TRIGGER_FUNCTION(tf_region_state) {
1759 return "dup definition @ >index " + std::to_string(trigger::payload(tval[1]).state_id.index()) + " " + compare_values_eq(tval[0]);
1760}
1761TRIGGER_FUNCTION(tf_region_pop) {
1762 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]);
1763}
1764
1765TRIGGER_FUNCTION(tf_region_proper) {
1766 return "dup >index " + std::to_string(trigger::payload(tval[1]).reg_id.index()) + " state-ptr @ in-region " + truth_inversion(tval[0]);
1767}
1768TRIGGER_FUNCTION(tf_region_proper_state) {
1769 return "dup capital @ >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_pop) {
1772 return "dup " + pop_to_location() + ">index " + std::to_string(trigger::payload(tval[1]).reg_id.index()) + " state-ptr @ in-region " + truth_inversion(tval[0]);
1773}
1774TRIGGER_FUNCTION(tf_owns_region_proper) {
1775 return "dup >index " + std::to_string(trigger::payload(tval[1]).reg_id.index()) + " state-ptr @ owns-region " + truth_inversion(tval[0]);
1776}
1777TRIGGER_FUNCTION(tf_owns_region) {
1778 return "dup >index " + std::to_string(trigger::payload(tval[1]).state_id.index()) + " state-ptr @ owns-state " + truth_inversion(tval[0]);
1779}
1780TRIGGER_FUNCTION(tf_tag_tag) {
1781 return "dup " + nation_to_tag() + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id = " + truth_inversion(tval[0]);
1782}
1783TRIGGER_FUNCTION(tf_tag_this_nation) {
1784 return "2dup = " + truth_inversion(tval[0]);
1785}
1786TRIGGER_FUNCTION(tf_tag_this_province) {
1787 return ">r dup " + province_to_owner() + " r> swap >r dup r> = " + truth_inversion(tval[0]);
1788}
1789TRIGGER_FUNCTION(tf_tag_from_nation) {
1790 return ">r >r dup r> swap r> swap >r dup r> = " + truth_inversion(tval[0]);
1791}
1792TRIGGER_FUNCTION(tf_tag_from_province) {
1793 return ">r >r dup " + province_to_owner() + " r> swap r> swap >r dup r> = " + truth_inversion(tval[0]);
1794}
1795TRIGGER_FUNCTION(tf_tag_pop) {
1796 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]);
1797}
1798TRIGGER_FUNCTION(tf_stronger_army_than_tag) {
1799 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]);
1800}
1801TRIGGER_FUNCTION(tf_stronger_army_than_this_nation) {
1802 return ">r dup active_regiments @ r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1803}
1804TRIGGER_FUNCTION(tf_stronger_army_than_this_state) {
1805 return ">r dup " + state_to_owner() + "active_regiments @ r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1806}
1807TRIGGER_FUNCTION(tf_stronger_army_than_this_province) {
1808 return ">r dup " + province_to_owner() + "active_regiments @ r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1809}
1810TRIGGER_FUNCTION(tf_stronger_army_than_this_pop) {
1811 return ">r dup " + pop_to_owner() + "active_regiments @ r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1812}
1813TRIGGER_FUNCTION(tf_stronger_army_than_from_nation) {
1814 return ">r >r dup active_regiments @ r> swap r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1815}
1816TRIGGER_FUNCTION(tf_stronger_army_than_from_province) {
1817 return ">r >r dup " + province_to_owner() + "active_regiments @ r> swap r> swap >r dup active_regiments @ r> " + compare_values(tval[0]);
1818}
1819TRIGGER_FUNCTION(tf_neighbour_tag) {
1820 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]);
1821}
1822TRIGGER_FUNCTION(tf_neighbour_this) {
1823 return ">r dup >index r> swap >r dup >index r> state-ptr @ nation-a " + truth_inversion(tval[0]);
1824}
1825TRIGGER_FUNCTION(tf_neighbour_from) {
1826 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ nation-a " + truth_inversion(tval[0]);
1827}
1828TRIGGER_FUNCTION(tf_neighbour_this_province) {
1829 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ nation-a " + truth_inversion(tval[0]);
1830}
1831TRIGGER_FUNCTION(tf_neighbour_from_province) {
1832 return ">r >r dup " + province_to_owner() + ">index r> swap r> swap >r dup >index r> state-ptr @ nation-a " + truth_inversion(tval[0]);
1833}
1834TRIGGER_FUNCTION(tf_country_units_in_state_from) {
1835 return ">r >r dup >index r> swap r> swap >r dup >index r> swap state-ptr @ units-in-state " + truth_inversion(tval[0]);
1836}
1837TRIGGER_FUNCTION(tf_country_units_in_state_this_nation) {
1838 return ">r dup >index 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_province) {
1841 return ">r dup " + province_to_owner() + ">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_state) {
1844 return ">r dup " + state_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_pop) {
1847 return ">r dup " + pop_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_tag) {
1850 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]);
1851}
1852TRIGGER_FUNCTION(tf_units_in_province_value) {
1853 return "dup >index state-ptr @ count-p-units " + std::to_string(int32_t(tval[1])) + " " + compare_values(tval[0]);
1854}
1855TRIGGER_FUNCTION(tf_units_in_province_tag) {
1856 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]);
1857}
1858
1859TRIGGER_FUNCTION(tf_units_in_province_from) {
1860 return "dup >index >r >r >r dup >index r> swap r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1861}
1862TRIGGER_FUNCTION(tf_units_in_province_this_nation) {
1863 return "dup >index >r >r dup >index r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1864}
1865TRIGGER_FUNCTION(tf_units_in_province_this_province) {
1866 return "dup >index >r >r dup " + province_to_owner() + ">index r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1867}
1868TRIGGER_FUNCTION(tf_units_in_province_this_state) {
1869 return "dup >index >r >r dup " + state_to_owner() + ">index r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1870}
1871TRIGGER_FUNCTION(tf_units_in_province_this_pop) {
1872 return "dup >index >r >r dup " + pop_to_owner() + ">index r> swap r> state-ptr @ units-in-province " + truth_inversion(tval[0]);
1873}
1874TRIGGER_FUNCTION(tf_war_with_tag) {
1875 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]);
1876}
1877TRIGGER_FUNCTION(tf_war_with_from) {
1878 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1879}
1880TRIGGER_FUNCTION(tf_war_with_this_nation) {
1881 return ">r dup >index r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1882}
1883TRIGGER_FUNCTION(tf_war_with_this_province) {
1884 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1885}
1886TRIGGER_FUNCTION(tf_war_with_this_state) {
1887 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1888}
1889TRIGGER_FUNCTION(tf_war_with_this_pop) {
1890 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ at-war? " + truth_inversion(tval[0]);
1891}
1892TRIGGER_FUNCTION(tf_unit_in_battle) {
1893 return "dup land_battle_location-location size 0 <> " + truth_inversion(tval[0]);
1894}
1895TRIGGER_FUNCTION(tf_unit_has_leader) {
1896 return "dup >index state-ptr @ general-in-province? " + truth_inversion(tval[0]);
1897}
1898TRIGGER_FUNCTION(tf_has_national_focus_state) {
1899 return "dup owner_focus @ >index " + std::to_string(trigger::payload(tval[1]).nf_id.index()) + " " + compare_values_eq(tval[0]);
1900}
1901TRIGGER_FUNCTION(tf_has_national_focus_province) {
1902 return "dup state_membership @ owner_focus @ >index " + std::to_string(trigger::payload(tval[1]).nf_id.index()) + " " + compare_values_eq(tval[0]);
1903}
1904TRIGGER_FUNCTION(tf_total_amount_of_divisions) {
1905 return "dup active_regiments @ >i32 " + std::to_string(int32_t(tval[1])) + " " + compare_values(tval[0]);
1906}
1908 return "dup 0 >commodity_id @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1909}
1910TRIGGER_FUNCTION(tf_money_province) {
1911 return "dup " + province_to_owner() + "0 >commodity_id @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1912}
1913TRIGGER_FUNCTION(tf_lost_national) {
1914 return "dup revanchism @ 1.0 swap - " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
1915}
1916TRIGGER_FUNCTION(tf_is_vassal) {
1917 return "dup overlord-subject ruler @ valid? " + truth_inversion(tval[0]);
1918}
1919TRIGGER_FUNCTION(tf_ruling_party_ideology_nation) {
1920 return "dup ruling_party @ ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " " + compare_values_eq(tval[0]);
1921}
1922TRIGGER_FUNCTION(tf_ruling_party_ideology_pop) {
1923 return "dup " + pop_to_owner() + "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_province) {
1926 return "dup " + province_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) {
1929 return "dup ruling_party @ name @ >index " + std::to_string(read_int32_t_from_payload(tval + 1)) + " " + compare_values_eq(tval[0]);
1930}
1931TRIGGER_FUNCTION(tf_is_ideology_enabled) {
1932 return std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " >ideology_id enabled @ " + truth_inversion(tval[0]);
1933}
1934TRIGGER_FUNCTION(tf_political_reform_want_nation) {
1935 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]);
1936}
1937TRIGGER_FUNCTION(tf_political_reform_want_pop) {
1938 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]);
1939}
1940TRIGGER_FUNCTION(tf_social_reform_want_nation) {
1941 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]);
1942}
1943TRIGGER_FUNCTION(tf_social_reform_want_pop) {
1944 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]);
1945}
1946TRIGGER_FUNCTION(tf_total_amount_of_ships) {
1947 return "dup >index state-ptr @ count-ships " + std::to_string(int32_t(tval[1])) + " " + compare_values(tval[0]);
1948}
1949TRIGGER_FUNCTION(tf_plurality) {
1950 return "dup plurality @ " + std::to_string(read_float_from_payload(tval + 1)) + " 100.0 / " + compare_values(tval[0]);
1951}
1952TRIGGER_FUNCTION(tf_plurality_pop) {
1953 return "dup " + pop_to_owner() + "plurality @ " + std::to_string(read_float_from_payload(tval + 1)) + " 100.0 / " + compare_values(tval[0]);
1954}
1955TRIGGER_FUNCTION(tf_corruption) {
1956 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]);
1957}
1958TRIGGER_FUNCTION(tf_is_state_religion_pop) {
1959 return " dup >r r@ " + pop_to_owner() + "religion @ r> religion @ = " + truth_inversion(tval[0]);
1960}
1961TRIGGER_FUNCTION(tf_is_state_religion_province) {
1962 return " dup >r r@ " + province_to_owner() + "religion @ r> dominant_religion @ = " + truth_inversion(tval[0]);
1963}
1964TRIGGER_FUNCTION(tf_is_state_religion_state) {
1965 return " dup >r r@ " + state_to_owner() + "religion @ r> dominant_religion @ = " + truth_inversion(tval[0]);
1966}
1967TRIGGER_FUNCTION(tf_is_primary_culture_pop) {
1968 return " dup >r r@ " + pop_to_owner() + "primary_culture @ r> culture @ = " + truth_inversion(tval[0]);
1969}
1970TRIGGER_FUNCTION(tf_is_primary_culture_province) {
1971 return " dup >r r@ " + province_to_owner() + "primary_culture @ r> dominant_culture @ = " + truth_inversion(tval[0]);
1972}
1973TRIGGER_FUNCTION(tf_is_primary_culture_state) {
1974 return " dup >r r@ " + state_to_owner() + "primary_culture @ r> dominant_culture @ = " + truth_inversion(tval[0]);
1975}
1976TRIGGER_FUNCTION(tf_primary_culture_from_nation) {
1977 return ">r >r dup r> swap r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1978}
1979TRIGGER_FUNCTION(tf_primary_culture_from_province) {
1980 return ">r >r dup " + province_to_owner() + "r> swap r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1981}
1982TRIGGER_FUNCTION(tf_is_primary_culture_nation_this_nation) {
1983 return ">r dup r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1984}
1985TRIGGER_FUNCTION(tf_is_primary_culture_nation_this_pop) {
1986 return ">r dup culture @ r> swap >r dup primary_culture @ r> = " + truth_inversion(tval[0]);
1987}
1988TRIGGER_FUNCTION(tf_is_primary_culture_nation_this_state) {
1989 return ">r dup " + state_to_owner() + "r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1990}
1991TRIGGER_FUNCTION(tf_is_primary_culture_nation_this_province) {
1992 return ">r dup " + province_to_owner() + "r> swap >r dup primary_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1993}
1994TRIGGER_FUNCTION(tf_is_primary_culture_state_this_nation) {
1995 return ">r dup r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1996}
1997TRIGGER_FUNCTION(tf_is_primary_culture_state_this_pop) {
1998 return ">r dup " + pop_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
1999}
2000TRIGGER_FUNCTION(tf_is_primary_culture_state_this_state) {
2001 return ">r dup " + state_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2002}
2003TRIGGER_FUNCTION(tf_is_primary_culture_state_this_province) {
2004 return ">r dup " + province_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2005}
2006TRIGGER_FUNCTION(tf_is_primary_culture_province_this_nation) {
2007 return ">r dup r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2008}
2009TRIGGER_FUNCTION(tf_is_primary_culture_province_this_pop) {
2010 return ">r dup " + pop_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2011}
2012TRIGGER_FUNCTION(tf_is_primary_culture_province_this_state) {
2013 return ">r dup " + state_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2014}
2015TRIGGER_FUNCTION(tf_is_primary_culture_province_this_province) {
2016 return ">r dup " + province_to_owner() + "r> swap >r dup dominant_culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2017}
2018TRIGGER_FUNCTION(tf_is_primary_culture_pop_this_nation) {
2019 return ">r dup r> swap >r dup culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2020}
2021TRIGGER_FUNCTION(tf_is_primary_culture_pop_this_pop) {
2022 return ">r dup " + pop_to_owner() + "r> swap >r dup culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2023}
2024TRIGGER_FUNCTION(tf_is_primary_culture_pop_this_state) {
2025 return ">r dup " + state_to_owner() + "r> swap >r dup culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2026}
2027TRIGGER_FUNCTION(tf_is_primary_culture_pop_this_province) {
2028 return ">r dup " + province_to_owner() + "r> swap >r dup culture @ r> primary_culture @ = " + truth_inversion(tval[0]);
2029}
2030
2031TRIGGER_FUNCTION(tf_is_accepted_culture_nation_this_nation) {
2032 return ">r dup primary_culture @ r> swap >r dup r> accepted_cultures @ " + truth_inversion(tval[0]);
2033}
2034TRIGGER_FUNCTION(tf_is_accepted_culture_nation_this_pop) {
2035 return ">r dup culture @ r> swap >r dup r> accepted_cultures @ " + truth_inversion(tval[0]);
2036}
2037TRIGGER_FUNCTION(tf_is_accepted_culture_nation_this_state) {
2038 return ">r dup " + state_to_owner() + "primary_culture @ r> swap >r dup r> accepted_cultures @ " + truth_inversion(tval[0]);
2039}
2040TRIGGER_FUNCTION(tf_is_accepted_culture_nation_this_province) {
2041 return ">r dup " + province_to_owner() + "primary_culture @ r> swap >r dup r> accepted_cultures @ " + truth_inversion(tval[0]);
2042}
2043TRIGGER_FUNCTION(tf_is_accepted_culture_state_this_nation) {
2044 return ">r dup primary_culture @ r> swap >r dup " + state_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2045}
2046TRIGGER_FUNCTION(tf_is_accepted_culture_state_this_pop) {
2047 return ">r dup " + pop_to_owner() + "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_state) {
2050 return ">r dup " + state_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_province) {
2053 return ">r dup " + province_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_province_this_nation) {
2056 return ">r dup primary_culture @ r> swap >r dup " + province_to_owner() + "r> accepted_cultures @ " + truth_inversion(tval[0]);
2057}
2058TRIGGER_FUNCTION(tf_is_accepted_culture_province_this_pop) {
2059 return ">r dup " + pop_to_owner() + "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_state) {
2062 return ">r dup " + state_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_province) {
2065 return ">r dup " + province_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_pop_this_nation) {
2068 return ">r dup r> swap >r dup culture r> swap accepted_cultures @ " + truth_inversion(tval[0]);
2069}
2070TRIGGER_FUNCTION(tf_is_accepted_culture_pop_this_pop) {
2071 return ">r dup " + pop_to_owner() + "r> swap >r dup culture r> swap accepted_cultures @ " + truth_inversion(tval[0]);
2072}
2073TRIGGER_FUNCTION(tf_is_accepted_culture_pop_this_state) {
2074 return ">r dup " + state_to_owner() + "r> swap >r dup culture r> swap accepted_cultures @ " + truth_inversion(tval[0]);
2075}
2076TRIGGER_FUNCTION(tf_is_accepted_culture_pop_this_province) {
2077 return ">r dup " + province_to_owner() + "r> swap >r dup culture r> swap accepted_cultures @ " + truth_inversion(tval[0]);
2078}
2079
2080TRIGGER_FUNCTION(tf_is_accepted_culture_pop) {
2081 return "dup dup culture @ >r " + pop_to_owner() + " r> accepted_cultures @ " + truth_inversion(tval[0]);
2082}
2083TRIGGER_FUNCTION(tf_is_accepted_culture_province) {
2084 return "dup dup dominant_culture @ >r " + province_to_owner() + " r> accepted_cultures @ " + truth_inversion(tval[0]);
2085}
2086TRIGGER_FUNCTION(tf_is_accepted_culture_state) {
2087 return "dup dup dominant_culture @ >r " + state_to_owner() + " r> accepted_cultures @ " + truth_inversion(tval[0]);
2088}
2089TRIGGER_FUNCTION(tf_is_coastal_province) {
2090 return "dup is_coast @ " + truth_inversion(tval[0]);
2091}
2092TRIGGER_FUNCTION(tf_is_coastal_state) {
2093 return "dup >index state-ptr @ coastal-s? @ " + truth_inversion(tval[0]);
2094}
2095TRIGGER_FUNCTION(tf_in_sphere_tag) {
2096 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]);
2097}
2098TRIGGER_FUNCTION(tf_in_sphere_from) {
2099 return ">r >r dup r> swap r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2100}
2101TRIGGER_FUNCTION(tf_in_sphere_this_nation) {
2102 return ">r dup r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2103}
2104TRIGGER_FUNCTION(tf_in_sphere_this_province) {
2105 return ">r dup " + province_to_owner() + "r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2106}
2107TRIGGER_FUNCTION(tf_in_sphere_this_state) {
2108 return ">r dup " + state_to_owner() + "r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2109}
2110TRIGGER_FUNCTION(tf_in_sphere_this_pop) {
2111 return ">r dup " + pop_to_owner() + "r> swap >r dup in_sphere_of @ r> = " + truth_inversion(tval[0]);
2112}
2113TRIGGER_FUNCTION(tf_produces_nation) {
2114 return "dup " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " >commodity_id domestic_market_pool 0.0 > " + truth_inversion(tval[0]);
2115}
2116TRIGGER_FUNCTION(tf_produces_province) {
2117 return "dup rgo @ >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " " + compare_values_eq(tval[0]);
2118}
2119TRIGGER_FUNCTION(tf_produces_state) {
2120 return "dup >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " state-ptr @ state-produces? " + truth_inversion(tval[0]);
2121}
2122TRIGGER_FUNCTION(tf_produces_pop) {
2123 return "false " + truth_inversion(tval[0]);
2124}
2125TRIGGER_FUNCTION(tf_average_militancy_nation) {
2126 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]);
2127}
2128TRIGGER_FUNCTION(tf_average_militancy_state) {
2129 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]);
2130}
2131TRIGGER_FUNCTION(tf_average_militancy_province) {
2132 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]);
2133}
2134TRIGGER_FUNCTION(tf_average_consciousness_nation) {
2135 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]);
2136}
2137TRIGGER_FUNCTION(tf_average_consciousness_state) {
2138 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]);
2139}
2140TRIGGER_FUNCTION(tf_average_consciousness_province) {
2141 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]);
2142}
2143TRIGGER_FUNCTION(tf_is_next_reform_nation) {
2144 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]);
2145}
2146TRIGGER_FUNCTION(tf_is_next_reform_pop) {
2147 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]);
2148}
2149TRIGGER_FUNCTION(tf_is_next_rreform_nation) {
2150 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]);
2151}
2152TRIGGER_FUNCTION(tf_is_next_rreform_pop) {
2153 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]);
2154}
2155TRIGGER_FUNCTION(tf_rebel_power_fraction) {
2156 return "false " + truth_inversion(tval[0]);
2157 // note: virtually unused
2158}
2159TRIGGER_FUNCTION(tf_recruited_percentage_nation) {
2160 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]);
2161}
2162TRIGGER_FUNCTION(tf_recruited_percentage_pop) {
2163 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]);
2164}
2165TRIGGER_FUNCTION(tf_has_culture_core) {
2166 return "dup dup >r " + pop_to_location() + ">index r> culture >index state-ptr @ has-culture-core? " + truth_inversion(tval[0]);
2167}
2168TRIGGER_FUNCTION(tf_has_culture_core_province_this_pop) {
2169 return ">r dup culture @ >index r> swap >r dup >index r> state-ptr @ has-culture-core? " + truth_inversion(tval[0]);
2170}
2171TRIGGER_FUNCTION(tf_nationalism) {
2172 return "dup nationalism @ " + std::to_string(float(tval[1])) + " " + compare_values(tval[0]);
2173}
2174TRIGGER_FUNCTION(tf_is_overseas) {
2175 return "dup dup >r " + province_to_owner() + "capital @ dup continent @ r@ continent @ = not r> swap >r >r "
2176 "connected_region_id @ r> connected_region_id @ <> r> and " + truth_inversion(tval[0]);
2177}
2178TRIGGER_FUNCTION(tf_is_overseas_pop) {
2179 return "dup " + pop_to_location() + "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_state) {
2183 return "dup capital @ 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_controlled_by_rebels) {
2187 return "dup province_rebel_control-province rebel_faction @ valid? " + truth_inversion(tval[0]);
2188}
2189TRIGGER_FUNCTION(tf_controlled_by_tag) {
2190 return "dup " + province_to_controller() + nation_to_tag() + ">index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " " + compare_values_eq(tval[0]);
2191}
2192TRIGGER_FUNCTION(tf_controlled_by_from) {
2193 return ">r >r dup r> swap r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2194}
2195TRIGGER_FUNCTION(tf_controlled_by_this_nation) {
2196 return ">r dup r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2197}
2198TRIGGER_FUNCTION(tf_controlled_by_this_province) {
2199 return ">r dup " + province_to_owner() + "r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2200}
2201TRIGGER_FUNCTION(tf_controlled_by_this_state) {
2202 return ">r dup " + state_to_owner() + "r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2203}
2204TRIGGER_FUNCTION(tf_controlled_by_this_pop) {
2205 return ">r dup " + pop_to_owner() + "r> swap >r dup " + province_to_controller() + "r> = " + truth_inversion(tval[0]);
2206}
2207TRIGGER_FUNCTION(tf_controlled_by_owner) {
2208 return "dup dup >r " + province_to_owner() + "r> " + province_to_controller() + " = " + truth_inversion(tval[0]);
2209}
2210TRIGGER_FUNCTION(tf_controlled_by_reb) {
2211 return ">r >r dup r> swap r> swap >r dup province_rebel_control-province rebel_faction @ r> = " + truth_inversion(tval[0]);
2212}
2213TRIGGER_FUNCTION(tf_is_canal_enabled) {
2214 return std::to_string(tval[1] - 1) + " state-ptr @ canal-enabled? " + truth_inversion(tval[0]);
2215}
2216TRIGGER_FUNCTION(tf_is_state_capital) {
2217 return "dup dup >r state_membership @ capital @ r> = " + truth_inversion(tval[0]);
2218}
2219TRIGGER_FUNCTION(tf_is_state_capital_pop) {
2220 return "dup " + pop_to_location() + "dup >r state_membership @ capital @ r> = " + truth_inversion(tval[0]);
2221}
2222TRIGGER_FUNCTION(tf_truce_with_tag) {
2223 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]);
2224}
2225TRIGGER_FUNCTION(tf_truce_with_from) {
2226 return ">r >r dup r> swap r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2227}
2228TRIGGER_FUNCTION(tf_truce_with_this_nation) {
2229 return ">r dup r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2230}
2231TRIGGER_FUNCTION(tf_truce_with_this_province) {
2232 return ">r dup " + province_to_owner() + "r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2233}
2234TRIGGER_FUNCTION(tf_truce_with_this_state) {
2235 return ">r dup " + state_to_owner() + "r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2236}
2237TRIGGER_FUNCTION(tf_truce_with_this_pop) {
2238 return ">r dup " + pop_to_owner() + "r> swap >r dup >index r> >index state-ptr @ truce-with? " + truth_inversion(tval[0]);
2239}
2240TRIGGER_FUNCTION(tf_total_pops_nation) {
2241 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2242}
2243TRIGGER_FUNCTION(tf_total_pops_state) {
2244 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2245}
2246TRIGGER_FUNCTION(tf_total_pops_province) {
2247 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2248}
2249TRIGGER_FUNCTION(tf_total_pops_pop) {
2250 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]);
2251}
2252TRIGGER_FUNCTION(tf_has_pop_type_nation) {
2253 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]);
2254}
2255TRIGGER_FUNCTION(tf_has_pop_type_state) {
2256 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]);
2257}
2258TRIGGER_FUNCTION(tf_has_pop_type_province) {
2259 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]);
2260}
2261TRIGGER_FUNCTION(tf_has_pop_type_pop) {
2262 return "dup poptype @ >index " + std::to_string(trigger::payload(tval[1]).popt_id.index()) + " = " + truth_inversion(tval[0]);
2263}
2264TRIGGER_FUNCTION(tf_has_empty_adjacent_province) {
2265 return "dup >index state-ptr @ empty-a-province " + truth_inversion(tval[0]);
2266}
2267TRIGGER_FUNCTION(tf_has_leader) {
2268 return "dup >index " + std::to_string(read_int32_t_from_payload(tval + 1)) + " state-ptr @ has-named-leader? " + truth_inversion(tval[0]);
2269}
2271 return "dup is_player_controlled @ not " + truth_inversion(tval[0]);
2272}
2273//can-release?
2274//national_identity-size
2275TRIGGER_FUNCTION(tf_can_create_vassals) {
2276 return "dup >index >r false 0"
2277 "while "
2278 ">r dup not r> swap >r "
2279 "dup national_identity-size < r> and "
2280 "loop "
2281 "dup r@ swap state-ptr @ can-release? "
2282 ">r swap drop r> swap "
2283 "1 + "
2284 "end-while "
2285 "r> drop drop "
2286 + truth_inversion(tval[0]);
2287}
2288TRIGGER_FUNCTION(tf_is_possible_vassal) {
2289 return "dup >index " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " state-ptr @ can-release? " + truth_inversion(tval[0]);
2290}
2291TRIGGER_FUNCTION(tf_province_id) {
2292 return "dup >index " + std::to_string(trigger::payload(tval[1]).prov_id.index()) + " " + compare_values_eq(tval[0]);
2293}
2294TRIGGER_FUNCTION(tf_vassal_of_tag) {
2295 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]);
2296}
2297TRIGGER_FUNCTION(tf_vassal_of_from) {
2298 return ">r >r dup r> swap r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2299}
2300TRIGGER_FUNCTION(tf_vassal_of_this_nation) {
2301 return ">r dup r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2302}
2303TRIGGER_FUNCTION(tf_vassal_of_this_province) {
2304 return ">r dup " + province_to_owner() + "r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2305}
2306TRIGGER_FUNCTION(tf_vassal_of_this_state) {
2307 return ">r dup " + state_to_owner() + "r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2308}
2309TRIGGER_FUNCTION(tf_vassal_of_this_pop) {
2310 return ">r dup " + pop_to_owner() + "r> swap >r dup overlord-subject ruler @ = " + truth_inversion(tval[0]);
2311}
2312TRIGGER_FUNCTION(tf_vassal_of_province_tag) {
2313 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]);
2314}
2315TRIGGER_FUNCTION(tf_vassal_of_province_from) {
2316 return ">r >r dup r> swap r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2317}
2318TRIGGER_FUNCTION(tf_vassal_of_province_this_nation) {
2319 return ">r dup r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2320}
2321TRIGGER_FUNCTION(tf_vassal_of_province_this_province) {
2322 return ">r dup " + province_to_owner() + "r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2323}
2324TRIGGER_FUNCTION(tf_vassal_of_province_this_state) {
2325 return ">r dup " + state_to_owner() + "r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2326}
2327TRIGGER_FUNCTION(tf_vassal_of_province_this_pop) {
2328 return ">r dup " + pop_to_owner() + "r> swap >r dup " + province_to_owner() + "overlord-subject ruler @ = " + truth_inversion(tval[0]);
2329}
2330
2331TRIGGER_FUNCTION(tf_substate_of_tag) {
2332 return "dup overlord-subject ruler @ " + std::to_string(trigger::payload(tval[1]).tag_id.index()) + " >national_identity_id " + tag_to_nation() + "= "
2333 ">r dup is_substate @ r> and " + truth_inversion(tval[0]);
2334}
2335TRIGGER_FUNCTION(tf_substate_of_from) {
2336 return ">r >r dup r> swap r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2337}
2338TRIGGER_FUNCTION(tf_substate_of_this_nation) {
2339 return ">r dup r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2340}
2341TRIGGER_FUNCTION(tf_substate_of_this_province) {
2342 return ">r dup " + province_to_owner() + "r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2343}
2344TRIGGER_FUNCTION(tf_substate_of_this_state) {
2345 return ">r dup " + state_to_owner() + "r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2346}
2347TRIGGER_FUNCTION(tf_substate_of_this_pop) {
2348 return ">r dup " + pop_to_owner() + "r> swap >r dup overlord-subject ruler @ = >r dup is_substate @ r> and " + truth_inversion(tval[0]);
2349}
2350TRIGGER_FUNCTION(tf_alliance_with_tag) {
2351 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]);
2352}
2353TRIGGER_FUNCTION(tf_alliance_with_from) {
2354 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2355}
2356TRIGGER_FUNCTION(tf_alliance_with_this_nation) {
2357 return ">r dup >index r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2358}
2359TRIGGER_FUNCTION(tf_alliance_with_this_province) {
2360 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2361}
2362TRIGGER_FUNCTION(tf_alliance_with_this_state) {
2363 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2364}
2365TRIGGER_FUNCTION(tf_alliance_with_this_pop) {
2366 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ are-allied? " + truth_inversion(tval[0]);
2367}
2368TRIGGER_FUNCTION(tf_has_recently_lost_war) {
2369 return "dup last_war_loss ptr-cast ptr(u16) @ >i32 dup 0 <> >r 365 5 * + current-date @ >i32 >= r> and " + truth_inversion(tval[0]);
2370}
2371TRIGGER_FUNCTION(tf_has_recently_lost_war_pop) {
2372 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]);
2373}
2374TRIGGER_FUNCTION(tf_is_mobilised) {
2375 return "dup is_mobilized @ " + truth_inversion(tval[0]);
2376}
2377TRIGGER_FUNCTION(tf_mobilisation_size) {
2378 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]);
2379}
2380TRIGGER_FUNCTION(tf_crime_higher_than_education_nation) {
2381 return "dup dup >r administrative_spending @ r> education_spending @ >= " + truth_inversion(tval[0]);
2382}
2383TRIGGER_FUNCTION(tf_crime_higher_than_education_state) {
2384 return "dup " + state_to_owner() + "dup >r administrative_spending @ r> education_spending @ >= " + truth_inversion(tval[0]);
2385}
2386TRIGGER_FUNCTION(tf_crime_higher_than_education_province) {
2387 return "dup " + province_to_owner() + "dup >r administrative_spending @ r> education_spending @ >= " + truth_inversion(tval[0]);
2388}
2389TRIGGER_FUNCTION(tf_crime_higher_than_education_pop) {
2390 return "dup " + pop_to_owner() + "dup >r administrative_spending @ r> education_spending @ >= " + truth_inversion(tval[0]);
2391}
2392TRIGGER_FUNCTION(tf_agree_with_ruling_party) {
2393 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 "
2394 "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]);
2395}
2396TRIGGER_FUNCTION(tf_is_colonial_state) {
2397 return "dup capital @ is_colonial @ " + truth_inversion(tval[0]);
2398}
2399TRIGGER_FUNCTION(tf_is_colonial_province) {
2400 return "dup is_colonial @ " + truth_inversion(tval[0]);
2401}
2402TRIGGER_FUNCTION(tf_is_colonial_pop) {
2403 return "dup " + pop_to_location() + "is_colonial @ " + truth_inversion(tval[0]);
2404}
2405TRIGGER_FUNCTION(tf_has_factories_state) {
2406 return "dup >index state-ptr @ has-any-factory " + truth_inversion(tval[0]);
2407}
2408TRIGGER_FUNCTION(tf_has_factories_nation) {
2409 return "dup >index state-ptr @ nation-has-any-factory " + truth_inversion(tval[0]);
2410}
2411TRIGGER_FUNCTION(tf_in_default_bool) {
2412 return "dup is_bankrupt @ " + truth_inversion(tval[0]);
2413}
2414//bankrupt-debtor-to?
2415TRIGGER_FUNCTION(tf_in_default_tag) {
2416 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]);
2417}
2418TRIGGER_FUNCTION(tf_in_default_from) {
2419 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2420}
2421TRIGGER_FUNCTION(tf_in_default_this_nation) {
2422 return ">r dup >index r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2423}
2424TRIGGER_FUNCTION(tf_in_default_this_province) {
2425 return ">r dup " + province_to_owner() + ">index r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2426}
2427TRIGGER_FUNCTION(tf_in_default_this_state) {
2428 return ">r dup " + state_to_owner() + ">index r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2429}
2430TRIGGER_FUNCTION(tf_in_default_this_pop) {
2431 return ">r dup " + pop_to_owner() + ">index r> swap >r dup >index r> state-ptr @ bankrupt-debtor-to? " + truth_inversion(tval[0]);
2432}
2433TRIGGER_FUNCTION(tf_total_num_of_ports) {
2434 return "dup total_ports @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2435}
2437 return "true " + truth_inversion(tval[0]);
2438}
2439TRIGGER_FUNCTION(tf_election) {
2440 return "dup election_ends ptr-cast ptr(u16) @ >i32 dup 0 <> swap current-date @ >i32 > and " + truth_inversion(tval[0]);
2441}
2442TRIGGER_FUNCTION(tf_has_global_flag) {
2443 return std::to_string(trigger::payload(tval[1]).glob_id.index()) + " state-ptr @ global-flag-set? " + truth_inversion(tval[0]);
2444}
2445TRIGGER_FUNCTION(tf_is_capital) {
2446 return "dup dup " + province_to_owner() + "capital @ = " + truth_inversion(tval[0]);
2447}
2448TRIGGER_FUNCTION(tf_nationalvalue_nation) {
2449 return "dup national_value @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]) ;
2450}
2451TRIGGER_FUNCTION(tf_nationalvalue_pop) {
2452 return "dup " + pop_to_owner() + "national_value @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
2453}
2454TRIGGER_FUNCTION(tf_nationalvalue_province) {
2455 return "dup " + province_to_owner() + "national_value @ >index " + std::to_string(trigger::payload(tval[1]).mod_id.index()) + " " + compare_values_eq(tval[0]);
2456}
2457TRIGGER_FUNCTION(tf_industrial_score_value) {
2458 return "dup industrial_score @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2459}
2460TRIGGER_FUNCTION(tf_industrial_score_tag) {
2461 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]);
2462}
2463TRIGGER_FUNCTION(tf_industrial_score_from_nation) {
2464 return ">r >r dup industrial_score @ r> swap r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2465}
2466TRIGGER_FUNCTION(tf_industrial_score_this_nation) {
2467 return ">r dup industrial_score @ r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2468}
2469TRIGGER_FUNCTION(tf_industrial_score_this_pop) {
2470 return ">r dup " + pop_to_owner() + "industrial_score @ r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2471}
2472TRIGGER_FUNCTION(tf_industrial_score_this_state) {
2473 return ">r dup " + state_to_owner() + "industrial_score @ r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2474}
2475TRIGGER_FUNCTION(tf_industrial_score_this_province) {
2476 return ">r dup " +province_to_owner() + "industrial_score @ r> swap >r dup industrial_score @ r> " + compare_values(tval[0]);
2477}
2478TRIGGER_FUNCTION(tf_military_score_value) {
2479 return "dup military_score @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2480}
2481TRIGGER_FUNCTION(tf_military_score_tag) {
2482 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]);
2483}
2484TRIGGER_FUNCTION(tf_military_score_from_nation) {
2485 return ">r >r dup military_score @ r> swap r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2486}
2487TRIGGER_FUNCTION(tf_military_score_this_nation) {
2488 return ">r dup military_score @ r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2489}
2490TRIGGER_FUNCTION(tf_military_score_this_pop) {
2491 return ">r dup " + pop_to_owner() + "military_score @ r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2492}
2493TRIGGER_FUNCTION(tf_military_score_this_state) {
2494 return ">r dup " + state_to_owner() + "military_score @ r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2495}
2496TRIGGER_FUNCTION(tf_military_score_this_province) {
2497 return ">r dup " + province_to_owner() + "military_score @ r> swap >r dup military_score @ r> " + compare_values(tval[0]);
2498}
2499TRIGGER_FUNCTION(tf_civilized_nation) {
2500 return "dup is_civilized @ " + truth_inversion(tval[0]);
2501}
2502TRIGGER_FUNCTION(tf_civilized_pop) {
2503 return "dup " + pop_to_owner() + "is_civilized @ " + truth_inversion(tval[0]);
2504}
2505TRIGGER_FUNCTION(tf_civilized_province) {
2506 return "dup " + province_to_owner() + "is_civilized @ " + truth_inversion(tval[0]);
2507}
2508TRIGGER_FUNCTION(tf_national_provinces_occupied) {
2509 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]);
2510}
2511TRIGGER_FUNCTION(tf_is_greater_power_nation) {
2512 return "dup is_great_power @ " + truth_inversion(tval[0]);
2513}
2514TRIGGER_FUNCTION(tf_is_greater_power_pop) {
2515 return "dup " + pop_to_owner() + "is_great_power @ " + truth_inversion(tval[0]);
2516}
2517TRIGGER_FUNCTION(tf_is_greater_power_province) {
2518 return "dup " + province_to_owner() + "is_great_power @ " + truth_inversion(tval[0]);
2519}
2520TRIGGER_FUNCTION(tf_rich_tax) {
2521 return "dup rich_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2522}
2523TRIGGER_FUNCTION(tf_middle_tax) {
2524 return "dup middle_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2525}
2526TRIGGER_FUNCTION(tf_poor_tax) {
2527 return "dup poor_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2528}
2529TRIGGER_FUNCTION(tf_rich_tax_pop) {
2530 return "dup " + pop_to_owner() + "rich_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2531}
2532TRIGGER_FUNCTION(tf_middle_tax_pop) {
2533 return "dup " + pop_to_owner() + "middle_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2534}
2535TRIGGER_FUNCTION(tf_poor_tax_pop) {
2536 return "dup " + pop_to_owner() + "poor_tax @ >i32 " + std::to_string(trigger::payload(tval[1]).signed_value) + " " + compare_values(tval[0]);
2537}
2538TRIGGER_FUNCTION(tf_social_spending_nation) {
2539 return "dup dup >r social_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2540}
2541TRIGGER_FUNCTION(tf_social_spending_pop) {
2542 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]);
2543}
2544TRIGGER_FUNCTION(tf_social_spending_province) {
2545 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]);
2546}
2547TRIGGER_FUNCTION(tf_military_spending_nation) {
2548 return "dup dup >r military_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2549}
2550TRIGGER_FUNCTION(tf_military_spending_pop) {
2551 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]);
2552}
2553TRIGGER_FUNCTION(tf_military_spending_province) {
2554 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]);
2555}
2556TRIGGER_FUNCTION(tf_military_spending_state) {
2557 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]);
2558}
2559TRIGGER_FUNCTION(tf_administration_spending_nation) {
2560 return "dup dup >r administrative_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2561}
2562TRIGGER_FUNCTION(tf_administration_spending_pop) {
2563 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]);
2564}
2565TRIGGER_FUNCTION(tf_administration_spending_province) {
2566 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]);
2567}
2568TRIGGER_FUNCTION(tf_administration_spending_state) {
2569 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]);
2570}
2571TRIGGER_FUNCTION(tf_education_spending_nation) {
2572 return "dup dup >r education_spending @ >f32 r> spending_level @ * " + std::to_string(trigger::payload(tval[1]).signed_value) + ".0 " + compare_values(tval[0]);
2573}
2574TRIGGER_FUNCTION(tf_education_spending_pop) {
2575 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]);
2576}
2577TRIGGER_FUNCTION(tf_education_spending_province) {
2578 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]);
2579}
2580TRIGGER_FUNCTION(tf_education_spending_state) {
2581 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]);
2582}
2583TRIGGER_FUNCTION(tf_colonial_nation) {
2584 return "dup is_colonial_nation @ " + truth_inversion(tval[0]);
2585}
2586TRIGGER_FUNCTION(tf_pop_majority_religion_nation) {
2587 return "dup dominant_religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " = " + truth_inversion(tval[0]);
2588}
2589TRIGGER_FUNCTION(tf_pop_majority_religion_nation_this_nation) {
2590 return ">r dup religion @ r> swap >r dup dominant_religion @ r> = " + truth_inversion(tval[0]);
2591}
2592TRIGGER_FUNCTION(tf_pop_majority_religion_state) {
2593 return "dup dominant_religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " = " + truth_inversion(tval[0]);
2594}
2595TRIGGER_FUNCTION(tf_pop_majority_religion_province) {
2596 return "dup dominant_religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " = " + truth_inversion(tval[0]);
2597}
2598TRIGGER_FUNCTION(tf_pop_majority_culture_nation) {
2599 return "dup dominant_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " = " + truth_inversion(tval[0]);
2600}
2601TRIGGER_FUNCTION(tf_pop_majority_culture_state) {
2602 return "dup dominant_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " = " + truth_inversion(tval[0]);
2603}
2604TRIGGER_FUNCTION(tf_pop_majority_culture_province) {
2605 return "dup dominant_culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " = " + truth_inversion(tval[0]);
2606}
2607TRIGGER_FUNCTION(tf_pop_majority_issue_nation) {
2608 return "dup dominant_issue_option @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " = " + truth_inversion(tval[0]);
2609}
2610TRIGGER_FUNCTION(tf_pop_majority_issue_state) {
2611 return "dup dominant_issue_option @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " = " + truth_inversion(tval[0]);
2612}
2613TRIGGER_FUNCTION(tf_pop_majority_issue_province) {
2614 return "dup dominant_issue_option @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " = " + truth_inversion(tval[0]);
2615}
2616TRIGGER_FUNCTION(tf_pop_majority_issue_pop) {
2617 return "dup dominant_issue_option @ >index " + std::to_string(trigger::payload(tval[1]).opt_id.index()) + " = " + truth_inversion(tval[0]);
2618}
2619TRIGGER_FUNCTION(tf_pop_majority_ideology_nation) {
2620 return "dup dominant_ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " = " + truth_inversion(tval[0]);
2621}
2622TRIGGER_FUNCTION(tf_pop_majority_ideology_state) {
2623 return "dup dominant_ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " = " + truth_inversion(tval[0]);
2624}
2625TRIGGER_FUNCTION(tf_pop_majority_ideology_province) {
2626 return "dup dominant_ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " = " + truth_inversion(tval[0]);
2627}
2628TRIGGER_FUNCTION(tf_pop_majority_ideology_pop) {
2629 return "dup dominant_ideology @ >index " + std::to_string(trigger::payload(tval[1]).ideo_id.index()) + " = " + truth_inversion(tval[0]);
2630}
2631TRIGGER_FUNCTION(tf_poor_strata_militancy_nation) {
2632 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r "
2633 "dup " + std::to_string(demographics::poor_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2634 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2635}
2636TRIGGER_FUNCTION(tf_poor_strata_militancy_state) {
2637 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r "
2638 "dup " + std::to_string(demographics::poor_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2639 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2640}
2641TRIGGER_FUNCTION(tf_poor_strata_militancy_province) {
2642 return "dup " + std::to_string(demographics::poor_total.index()) + " >demographics_key demographics @ >r "
2643 "dup " + std::to_string(demographics::poor_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2644 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2645}
2646TRIGGER_FUNCTION(tf_poor_strata_militancy_pop) {
2647 return "dup poptype @ strata @ >i32 " + std::to_string(uint8_t(culture::pop_strata::poor)) + " <> >r "
2648 "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]);
2649}
2650TRIGGER_FUNCTION(tf_middle_strata_militancy_nation) {
2651 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r "
2652 "dup " + std::to_string(demographics::middle_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2653 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2654}
2655TRIGGER_FUNCTION(tf_middle_strata_militancy_state) {
2656 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r "
2657 "dup " + std::to_string(demographics::middle_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2658 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2659}
2660TRIGGER_FUNCTION(tf_middle_strata_militancy_province) {
2661 return "dup " + std::to_string(demographics::middle_total.index()) + " >demographics_key demographics @ >r "
2662 "dup " + std::to_string(demographics::middle_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2663 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2664}
2665TRIGGER_FUNCTION(tf_middle_strata_militancy_pop) {
2666 return "dup poptype @ strata @ >i32 " + std::to_string(uint8_t(culture::pop_strata::middle)) + " <> >r "
2667 "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]);
2668}
2669TRIGGER_FUNCTION(tf_rich_strata_militancy_nation) {
2670 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r "
2671 "dup " + std::to_string(demographics::rich_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2672 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2673}
2674TRIGGER_FUNCTION(tf_rich_strata_militancy_state) {
2675 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r "
2676 "dup " + std::to_string(demographics::rich_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2677 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2678}
2679TRIGGER_FUNCTION(tf_rich_strata_militancy_province) {
2680 return "dup " + std::to_string(demographics::rich_total.index()) + " >demographics_key demographics @ >r "
2681 "dup " + std::to_string(demographics::rich_militancy.index()) + " >demographics_key demographics @ r@ / 0.0 0.0 r> >= select "
2682 + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2683}
2684TRIGGER_FUNCTION(tf_rich_strata_militancy_pop) {
2685 return "dup poptype @ strata @ >i32 " + std::to_string(uint8_t(culture::pop_strata::rich)) + " <> >r "
2686 "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]);
2687}
2688TRIGGER_FUNCTION(tf_rich_tax_above_poor) {
2689 return "dup dup >r rich_tax @ r> poor_tax @ > " + truth_inversion(tval[0]);
2690}
2691TRIGGER_FUNCTION(tf_culture_has_union_tag_pop) {
2692 return "dup culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ valid? " + truth_inversion(tval[0]);
2693}
2694TRIGGER_FUNCTION(tf_culture_has_union_tag_nation) {
2695 return "dup primary_culture @ culture_group_membership-member group @ cultural_union_of-culture_group identity @ valid? " + truth_inversion(tval[0]);
2696}
2697TRIGGER_FUNCTION(tf_this_culture_union_tag) {
2698 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]);
2699}
2700TRIGGER_FUNCTION(tf_this_culture_union_from) {
2701 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]);
2702}
2703TRIGGER_FUNCTION(tf_this_culture_union_this_nation) {
2704 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]);
2705}
2706TRIGGER_FUNCTION(tf_this_culture_union_this_province) {
2707 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]);
2708}
2709TRIGGER_FUNCTION(tf_this_culture_union_this_state) {
2710 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]);
2711}
2712TRIGGER_FUNCTION(tf_this_culture_union_this_pop) {
2713 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]);
2714}
2715TRIGGER_FUNCTION(tf_this_culture_union_this_union_nation) {
2716 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]);
2717}
2718TRIGGER_FUNCTION(tf_this_culture_union_this_union_province) {
2719 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]);
2720}
2721TRIGGER_FUNCTION(tf_this_culture_union_this_union_state) {
2722 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]);
2723}
2724TRIGGER_FUNCTION(tf_this_culture_union_this_union_pop) {
2725 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]);
2726}
2727TRIGGER_FUNCTION(tf_minorities_nation) {
2728 return "dup dup >r " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ "
2729 "r@ " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r@ primary_culture @ >index + >demographics_key demographics @ - "
2730 "0 "
2731 "while "
2732 "dup culture-size < "
2733 "loop "
2734 "dup >culture_id r@ swap accepted_cultures @ "
2735 "if "
2736 "dup r@ swap >r "
2737 + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r> + >demographics_key demographics @ "
2738 ">r swap r> - swap "
2739 "then "
2740 "1 + "
2741 "end-while "
2742 "drop r> drop 0.0 > "
2743 + truth_inversion(tval[0]);
2744}
2745TRIGGER_FUNCTION(tf_minorities_state) {
2746 return "dup dup >r " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ "
2747 "r@ " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r@ " + state_to_owner() + "primary_culture @ >index + >demographics_key demographics @ - "
2748 "0 "
2749 "while "
2750 "dup culture-size < "
2751 "loop "
2752 "dup >culture_id r@ " + state_to_owner() + "swap accepted_cultures @ "
2753 "if "
2754 "dup r@ swap >r "
2755 + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r> + >demographics_key demographics @ "
2756 ">r swap r> - swap "
2757 "then "
2758 "1 + "
2759 "end-while "
2760 "drop r> drop 0.0 > "
2761 + truth_inversion(tval[0]);
2762}
2763TRIGGER_FUNCTION(tf_minorities_province) {
2764 return "dup dup >r " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ "
2765 "r@ " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r@ " + province_to_owner() + "primary_culture @ >index + >demographics_key demographics @ - "
2766 "0 "
2767 "while "
2768 "dup culture-size < "
2769 "loop "
2770 "dup >culture_id r@ " + province_to_owner() + "swap accepted_cultures @ "
2771 "if "
2772 "dup r@ swap >r "
2773 + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() * 2) + " r> + >demographics_key demographics @ "
2774 ">r swap r> - swap "
2775 "then "
2776 "1 + "
2777 "end-while "
2778 "drop r> drop 0.0 > "
2779 + truth_inversion(tval[0]);
2780}
2781TRIGGER_FUNCTION(tf_revanchism_nation) {
2782 return "dup revanchism @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2783}
2784TRIGGER_FUNCTION(tf_revanchism_pop) {
2785 return "dup " + pop_to_owner() + "revanchism @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2786}
2787TRIGGER_FUNCTION(tf_has_crime) {
2788 return "dup crime @ valid? " + truth_inversion(tval[0]);
2789}
2790TRIGGER_FUNCTION(tf_num_of_substates) {
2791 return "dup substates_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2792}
2793TRIGGER_FUNCTION(tf_num_of_vassals_no_substates) {
2794 return "dup dup >r vassals_count @ >i32 r> substates_count @ >i32 - " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2795}
2796TRIGGER_FUNCTION(tf_brigades_compare_this) {
2797 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]);
2798}
2799TRIGGER_FUNCTION(tf_brigades_compare_from) {
2800 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]);
2801}
2802TRIGGER_FUNCTION(tf_brigades_compare_province_this) {
2803 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]);
2804}
2805TRIGGER_FUNCTION(tf_brigades_compare_province_from) {
2806 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]);
2807}
2808TRIGGER_FUNCTION(tf_constructing_cb_tag) {
2809 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]);
2810}
2811TRIGGER_FUNCTION(tf_constructing_cb_from) {
2812 return ">r >r dup r> swap r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2813}
2814TRIGGER_FUNCTION(tf_constructing_cb_this_nation) {
2815 return ">r dup r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2816}
2817TRIGGER_FUNCTION(tf_constructing_cb_this_province) {
2818 return ">r dup " + province_to_owner() + "r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2819}
2820TRIGGER_FUNCTION(tf_constructing_cb_this_state) {
2821 return ">r dup " + state_to_owner() + "r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2822}
2823TRIGGER_FUNCTION(tf_constructing_cb_this_pop) {
2824 return ">r dup " + pop_to_owner() + "r> swap >r dup constructing_cb_target @ r> = " + truth_inversion(tval[0]);
2825}
2826TRIGGER_FUNCTION(tf_constructing_cb_discovered) {
2827 return "dup constructing_cb_is_discovered @ " + truth_inversion(tval[0]);
2828}
2829TRIGGER_FUNCTION(tf_constructing_cb_progress) {
2830 return "dup constructing_cb_progress @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2831}
2832TRIGGER_FUNCTION(tf_civilization_progress) {
2833 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]);
2834}
2835TRIGGER_FUNCTION(tf_constructing_cb_type) {
2836 return "dup constructing_cb_type @ >index " + std::to_string(trigger::payload(tval[1]).cb_id.index()) + " " + compare_values_eq(tval[0]);
2837}
2838TRIGGER_FUNCTION(tf_is_our_vassal_tag) {
2839 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]);
2840}
2841TRIGGER_FUNCTION(tf_is_our_vassal_from) {
2842 return ">r >r dup overlord-subject ruler @ r> swap r> swap >r dup r> = " + truth_inversion(tval[0]);
2843}
2844TRIGGER_FUNCTION(tf_is_our_vassal_this_nation) {
2845 return ">r dup overlord-subject ruler @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2846}
2847TRIGGER_FUNCTION(tf_is_our_vassal_this_province) {
2848 return ">r dup " + province_to_owner() + "overlord-subject ruler @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2849}
2850TRIGGER_FUNCTION(tf_is_our_vassal_this_state) {
2851 return ">r dup " + state_to_owner() + "overlord-subject ruler @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2852}
2853TRIGGER_FUNCTION(tf_is_our_vassal_this_pop) {
2854 return ">r dup " + pop_to_owner() + "overlord-subject ruler @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2855}
2856TRIGGER_FUNCTION(tf_is_our_vassal_province_tag) {
2857 return ">r >r dup overlord-subject ruler @ r> swap r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2858}
2859TRIGGER_FUNCTION(tf_is_our_vassal_province_from) {
2860 return ">r >r dup overlord-subject ruler @ r> swap r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2861}
2862TRIGGER_FUNCTION(tf_is_our_vassal_province_this_nation) {
2863 return ">r dup overlord-subject ruler @ r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2864}
2865TRIGGER_FUNCTION(tf_is_our_vassal_province_this_province) {
2866 return ">r dup " + province_to_owner() + "overlord-subject ruler @ r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2867}
2868TRIGGER_FUNCTION(tf_is_our_vassal_province_this_state) {
2869 return ">r dup " + state_to_owner() + "overlord-subject ruler @ r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2870}
2871TRIGGER_FUNCTION(tf_is_our_vassal_province_this_pop) {
2872 return ">r dup " + pop_to_owner() + "overlord-subject ruler @ r> swap >r dup " + province_to_owner() + "r> = " + truth_inversion(tval[0]);
2873}
2874TRIGGER_FUNCTION(tf_is_substate) {
2875 return "dup is_substate @ " + truth_inversion(tval[0]);
2876}
2877TRIGGER_FUNCTION(tf_great_wars_enabled) {
2878 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]);
2879}
2880TRIGGER_FUNCTION(tf_can_nationalize) {
2881 return "dup >index state-ptr @ can-nationalize? " + truth_inversion(tval[0]);
2882}
2883TRIGGER_FUNCTION(tf_part_of_sphere) {
2884 return "dup in_sphere_of @ valid? " + truth_inversion(tval[0]);
2885}
2886TRIGGER_FUNCTION(tf_is_sphere_leader_of_tag) {
2887 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]);
2888}
2889TRIGGER_FUNCTION(tf_is_sphere_leader_of_from) {
2890 return ">r >r dup in_sphere_of @ r> swap r> swap >r dup r> = " + truth_inversion(tval[0]);
2891}
2892TRIGGER_FUNCTION(tf_is_sphere_leader_of_this_nation) {
2893 return ">r dup in_sphere_of @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2894}
2895TRIGGER_FUNCTION(tf_is_sphere_leader_of_this_province) {
2896 return ">r " + province_to_owner() + "dup in_sphere_of @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2897}
2898TRIGGER_FUNCTION(tf_is_sphere_leader_of_this_state) {
2899 return ">r " + state_to_owner() + "dup in_sphere_of @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2900}
2901TRIGGER_FUNCTION(tf_is_sphere_leader_of_this_pop) {
2902 return ">r " + pop_to_owner() + "dup in_sphere_of @ r> swap >r dup r> = " + truth_inversion(tval[0]);
2903}
2904TRIGGER_FUNCTION(tf_number_of_states) {
2905 return "dup owned_state_count @ >i32 " + std::to_string(tval[1]) + " " + compare_values(tval[0]);
2906}
2907TRIGGER_FUNCTION(tf_war_score) {
2908 return "true " + truth_inversion(tval[0]);
2909}
2910TRIGGER_FUNCTION(tf_is_releasable_vassal_from) {
2911 return ">r >r dup " + nation_to_tag() + "is_not_releasable @ not r> swap r> swap" + truth_inversion(tval[0]);
2912}
2913TRIGGER_FUNCTION(tf_is_releasable_vassal_other) {
2914 return ">r >r dup " + nation_to_tag() + "is_not_releasable @ not r> swap r> swap" + truth_inversion(tval[0]);
2915}
2916TRIGGER_FUNCTION(tf_has_recent_imigration) {
2917 return "dup last_immigration ptr-cast ptr(u16) @ >i32 " + std::to_string(tval[1]) + " + current-date @ >i32 " + compare_values(tval[0]);
2918}
2919TRIGGER_FUNCTION(tf_province_control_days) {
2920 return "dup last_control_change ptr-cast ptr(u16) @ >i32 " + std::to_string(tval[1]) + " + current-date @ >i32 " + compare_values(tval[0]);
2921}
2922TRIGGER_FUNCTION(tf_is_disarmed) {
2923 return "dup disarmed_until ptr-cast ptr(u16) @ >i32 dup 0 <> swap current-date @ >i32 > and " + truth_inversion(tval[0]);
2924}
2925TRIGGER_FUNCTION(tf_is_disarmed_pop) {
2926 return "dup " + pop_to_owner() + "disarmed_until ptr-cast ptr(u16) @ >i32 dup 0 <> swap current-date @ >i32 > and " + truth_inversion(tval[0]);
2927}
2928TRIGGER_FUNCTION(tf_big_producer) {
2929 return "false " + truth_inversion(tval[0]);
2930}
2931TRIGGER_FUNCTION(tf_someone_can_form_union_tag_from) {
2932 return "false " + truth_inversion(tval[0]);
2933}
2934TRIGGER_FUNCTION(tf_someone_can_form_union_tag_other) {
2935 return "false " + truth_inversion(tval[0]);
2936}
2937TRIGGER_FUNCTION(tf_social_movement_strength) {
2938 return "dup >index true state-ptr @ movement-str " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2939}
2940TRIGGER_FUNCTION(tf_political_movement_strength) {
2941 return "dup >index false state-ptr @ movement-str " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
2942}
2943TRIGGER_FUNCTION(tf_can_build_factory_in_capital_state) {
2944 return "true " + truth_inversion(tval[0]);
2945}
2946TRIGGER_FUNCTION(tf_social_movement) {
2947 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]);
2948}
2949TRIGGER_FUNCTION(tf_political_movement) {
2950 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]);
2951}
2952TRIGGER_FUNCTION(tf_political_movement_from_reb) {
2953 // returns false because I'm not sure exactly what it is supposed to do (applies to the below as well)
2954 // it is called in nation scope while modifying chances for a rebel faction to spawn
2955 // perhaps reducing the chance if there is an "appropriate" movement (because there is almost always some movement)
2956 // however, the logic from working backwards from rebel factions to movements is not clear to me
2957 return "false " + truth_inversion(tval[0]);
2958}
2959TRIGGER_FUNCTION(tf_social_movement_from_reb) {
2960 return "false " + truth_inversion(tval[0]);
2961}
2962TRIGGER_FUNCTION(tf_has_cultural_sphere) {
2963 return "dup >index state-ptr @ has-union-sphere? " + truth_inversion(tval[0]);
2964}
2965TRIGGER_FUNCTION(tf_world_wars_enabled) {
2966 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]);
2967}
2968TRIGGER_FUNCTION(tf_has_pop_culture_pop_this_pop) {
2969 return ">r dup culture @ r> swap >r dup culture r> = " + truth_inversion(tval[0]);
2970}
2971TRIGGER_FUNCTION(tf_has_pop_culture_state_this_pop) {
2972 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]);
2973}
2974TRIGGER_FUNCTION(tf_has_pop_culture_province_this_pop) {
2975 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]);
2976}
2977TRIGGER_FUNCTION(tf_has_pop_culture_nation_this_pop) {
2978 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]);
2979}
2980TRIGGER_FUNCTION(tf_has_pop_culture_pop) {
2981 return "dup culture @ >index " + std::to_string(trigger::payload(tval[1]).cul_id.index()) + " " + compare_values_eq(tval[0]);
2982}
2983TRIGGER_FUNCTION(tf_has_pop_culture_state) {
2984 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]);
2985}
2986TRIGGER_FUNCTION(tf_has_pop_culture_province) {
2987 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]);
2988}
2989TRIGGER_FUNCTION(tf_has_pop_culture_nation) {
2990 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]);
2991}
2992TRIGGER_FUNCTION(tf_has_pop_religion_pop_this_pop) {
2993 return ">r dup religion @ r> swap >r dup religion r> = " + truth_inversion(tval[0]);
2994}
2995TRIGGER_FUNCTION(tf_has_pop_religion_state_this_pop) {
2996 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]);
2997}
2998TRIGGER_FUNCTION(tf_has_pop_religion_province_this_pop) {
2999 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]);
3000}
3001TRIGGER_FUNCTION(tf_has_pop_religion_nation_this_pop) {
3002 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]);
3003}
3004TRIGGER_FUNCTION(tf_has_pop_religion_pop) {
3005 return "dup religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " " + compare_values_eq(tval[0]);
3006}
3007TRIGGER_FUNCTION(tf_has_pop_religion_state) {
3008 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]);
3009}
3010TRIGGER_FUNCTION(tf_has_pop_religion_province) {
3011 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]);
3012}
3013TRIGGER_FUNCTION(tf_has_pop_religion_nation) {
3014 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]);
3015}
3016TRIGGER_FUNCTION(tf_life_needs) {
3017 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]);
3018}
3019TRIGGER_FUNCTION(tf_everyday_needs) {
3020 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]);
3021}
3022TRIGGER_FUNCTION(tf_luxury_needs) {
3023 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]);
3024}
3025TRIGGER_FUNCTION(tf_consciousness_pop) {
3026 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]);
3027}
3028TRIGGER_FUNCTION(tf_consciousness_province) {
3029 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]);
3030}
3031TRIGGER_FUNCTION(tf_consciousness_state) {
3032 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]);
3033}
3034TRIGGER_FUNCTION(tf_consciousness_nation) {
3035 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]);
3036}
3037TRIGGER_FUNCTION(tf_literacy_pop) {
3038 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]);
3039}
3040TRIGGER_FUNCTION(tf_literacy_province) {
3041 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]);
3042}
3043TRIGGER_FUNCTION(tf_literacy_state) {
3044 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]);
3045}
3046TRIGGER_FUNCTION(tf_literacy_nation) {
3047 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]);
3048}
3049TRIGGER_FUNCTION(tf_militancy_pop) {
3050 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]);
3051}
3052TRIGGER_FUNCTION(tf_militancy_province) {
3053 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]);
3054}
3055TRIGGER_FUNCTION(tf_militancy_state) {
3056 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]);
3057}
3058TRIGGER_FUNCTION(tf_militancy_nation) {
3059 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]);
3060}
3061TRIGGER_FUNCTION(tf_trade_goods_in_state_state) {
3062 return "dup >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " state-ptr @ state-has-rgo? " + truth_inversion(tval[0]);
3063}
3064TRIGGER_FUNCTION(tf_trade_goods_in_state_province) {
3065 return "dup state_membership @ >index " + std::to_string(trigger::payload(tval[1]).com_id.index()) + " state-ptr @ state-has-rgo? " + truth_inversion(tval[0]);
3066}
3067TRIGGER_FUNCTION(tf_has_flashpoint) {
3068 return "dup flashpoint_tag @ valid? " + truth_inversion(tval[0]);
3069}
3070TRIGGER_FUNCTION(tf_flashpoint_tension) {
3071 return "dup flashpoint_tension @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3072}
3073TRIGGER_FUNCTION(tf_flashpoint_tension_province) {
3074 return "dup state_membership @ flashpoint_tension @ " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3075}
3076TRIGGER_FUNCTION(tf_crisis_exist) {
3077 return std::to_string(offsetof(sys::state, current_crisis)) + " state-ptr @ buf-add ptr-cast ptr(i32) @ " + std::to_string(int32_t(sys::crisis_type::none)) + " <> " + truth_inversion(tval[0]);
3078}
3079TRIGGER_FUNCTION(tf_is_liberation_crisis) {
3080 return std::to_string(offsetof(sys::state, current_crisis)) + " state-ptr @ buf-add ptr-cast ptr(i32) @ " + std::to_string(int32_t(sys::crisis_type::liberation)) + " " + compare_values_eq(tval[0]);
3081}
3082TRIGGER_FUNCTION(tf_is_claim_crisis) {
3083 return std::to_string(offsetof(sys::state, current_crisis)) + " state-ptr @ buf-add ptr-cast ptr(i32) @ " + std::to_string(int32_t(sys::crisis_type::claim)) + " " + compare_values_eq(tval[0]);
3084}
3085TRIGGER_FUNCTION(tf_crisis_temperature) {
3086 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]);
3087}
3088TRIGGER_FUNCTION(tf_involved_in_crisis_nation) {
3089 return "dup >index state-ptr @ in-crisis? " + truth_inversion(tval[0]);
3090}
3091TRIGGER_FUNCTION(tf_involved_in_crisis_pop) {
3092 return "dup " + pop_to_owner() + ">index state-ptr @ in-crisis? " + truth_inversion(tval[0]);
3093}
3094TRIGGER_FUNCTION(tf_rich_strata_life_needs_nation) {
3095 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]);
3096}
3097TRIGGER_FUNCTION(tf_rich_strata_life_needs_state) {
3098 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]);
3099}
3100TRIGGER_FUNCTION(tf_rich_strata_life_needs_province) {
3101 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]);
3102}
3103TRIGGER_FUNCTION(tf_rich_strata_life_needs_pop) {
3104 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]);
3105}
3106TRIGGER_FUNCTION(tf_rich_strata_everyday_needs_nation) {
3107 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]);
3108}
3109TRIGGER_FUNCTION(tf_rich_strata_everyday_needs_state) {
3110 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]);
3111}
3112TRIGGER_FUNCTION(tf_rich_strata_everyday_needs_province) {
3113 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]);
3114}
3115TRIGGER_FUNCTION(tf_rich_strata_everyday_needs_pop) {
3116 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]);
3117}
3118TRIGGER_FUNCTION(tf_rich_strata_luxury_needs_nation) {
3119 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]);
3120}
3121TRIGGER_FUNCTION(tf_rich_strata_luxury_needs_state) {
3122 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]);
3123}
3124TRIGGER_FUNCTION(tf_rich_strata_luxury_needs_province) {
3125 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]);
3126}
3127TRIGGER_FUNCTION(tf_rich_strata_luxury_needs_pop) {
3128 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]);
3129}
3130TRIGGER_FUNCTION(tf_middle_strata_life_needs_nation) {
3131 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]);
3132}
3133TRIGGER_FUNCTION(tf_middle_strata_life_needs_state) {
3134 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]);
3135}
3136TRIGGER_FUNCTION(tf_middle_strata_life_needs_province) {
3137 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]);
3138}
3139TRIGGER_FUNCTION(tf_middle_strata_life_needs_pop) {
3140 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]);
3141}
3142TRIGGER_FUNCTION(tf_middle_strata_everyday_needs_nation) {
3143 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]);
3144}
3145TRIGGER_FUNCTION(tf_middle_strata_everyday_needs_state) {
3146 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]);
3147}
3148TRIGGER_FUNCTION(tf_middle_strata_everyday_needs_province) {
3149 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]);
3150}
3151TRIGGER_FUNCTION(tf_middle_strata_everyday_needs_pop) {
3152 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]);
3153}
3154TRIGGER_FUNCTION(tf_middle_strata_luxury_needs_nation) {
3155 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]);
3156}
3157TRIGGER_FUNCTION(tf_middle_strata_luxury_needs_state) {
3158 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]);
3159}
3160TRIGGER_FUNCTION(tf_middle_strata_luxury_needs_province) {
3161 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]);
3162}
3163TRIGGER_FUNCTION(tf_middle_strata_luxury_needs_pop) {
3164 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]);
3165}
3166TRIGGER_FUNCTION(tf_poor_strata_life_needs_nation) {
3167 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]);
3168}
3169TRIGGER_FUNCTION(tf_poor_strata_life_needs_state) {
3170 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]);
3171}
3172TRIGGER_FUNCTION(tf_poor_strata_life_needs_province) {
3173 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]);
3174}
3175TRIGGER_FUNCTION(tf_poor_strata_life_needs_pop) {
3176 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]);
3177}
3178TRIGGER_FUNCTION(tf_poor_strata_everyday_needs_nation) {
3179 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]);
3180}
3181TRIGGER_FUNCTION(tf_poor_strata_everyday_needs_state) {
3182 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]);
3183}
3184TRIGGER_FUNCTION(tf_poor_strata_everyday_needs_province) {
3185 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]);
3186}
3187TRIGGER_FUNCTION(tf_poor_strata_everyday_needs_pop) {
3188 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]);
3189}
3190TRIGGER_FUNCTION(tf_poor_strata_luxury_needs_nation) {
3191 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]);
3192}
3193TRIGGER_FUNCTION(tf_poor_strata_luxury_needs_state) {
3194 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]);
3195}
3196TRIGGER_FUNCTION(tf_poor_strata_luxury_needs_province) {
3197 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]);
3198}
3199TRIGGER_FUNCTION(tf_poor_strata_luxury_needs_pop) {
3200 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]);
3201}
3202TRIGGER_FUNCTION(tf_diplomatic_influence_tag) {
3203 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]);
3204}
3205TRIGGER_FUNCTION(tf_diplomatic_influence_this_nation) {
3206 return ">r dup r> swap >r dup >index r> >index state-ptr @ influence-on " + std::to_string(tval[1]) + ".0 " + compare_values(tval[0]);
3207}
3208TRIGGER_FUNCTION(tf_diplomatic_influence_this_province) {
3209 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]);
3210}
3211TRIGGER_FUNCTION(tf_diplomatic_influence_from_nation) {
3212 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]);
3213}
3214TRIGGER_FUNCTION(tf_diplomatic_influence_from_province) {
3215 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]);
3216}
3217TRIGGER_FUNCTION(tf_pop_unemployment_nation) {
3218 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3219 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3220 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3221}
3222TRIGGER_FUNCTION(tf_pop_unemployment_state) {
3223 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3224 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3225 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3226}
3227TRIGGER_FUNCTION(tf_pop_unemployment_province) {
3228 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3229 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3230 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3231}
3232TRIGGER_FUNCTION(tf_pop_unemployment_pop) {
3233 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]);
3234}
3235TRIGGER_FUNCTION(tf_pop_unemployment_nation_this_pop) {
3236 return
3237 ">r dup poptype @ >index r> swap >r "
3238 "dup " + std::to_string(demographics::count_special_keys) + " r@ + >demographics_key demographics @ >r "
3239 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size()) + " r> r> swap >r + >demographics_key demographics @ "
3240 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3241}
3242TRIGGER_FUNCTION(tf_pop_unemployment_state_this_pop) {
3243 return
3244 ">r dup poptype @ >index r> swap >r "
3245 "dup " + std::to_string(demographics::count_special_keys) + " r@ + >demographics_key demographics @ >r "
3246 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size()) + " r> r> swap >r + >demographics_key demographics @ "
3247 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3248}
3249TRIGGER_FUNCTION(tf_pop_unemployment_province_this_pop) {
3250 return
3251 ">r dup poptype @ >index r> swap >r "
3252 "dup " + std::to_string(demographics::count_special_keys) + " r@ + >demographics_key demographics @ >r "
3253 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size()) + " r> r> swap >r + >demographics_key demographics @ "
3254 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3255}
3256TRIGGER_FUNCTION(tf_relation_tag) {
3257 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]);
3258}
3259TRIGGER_FUNCTION(tf_relation_this_nation) {
3260 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]);
3261}
3262TRIGGER_FUNCTION(tf_relation_this_province) {
3263 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]);
3264}
3265TRIGGER_FUNCTION(tf_relation_this_pop) {
3266 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]);
3267}
3268TRIGGER_FUNCTION(tf_relation_from_nation) {
3269 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]);
3270}
3271TRIGGER_FUNCTION(tf_relation_from_province) {
3272 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]);
3273}
3274TRIGGER_FUNCTION(tf_check_variable) {
3275 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]);
3276}
3277TRIGGER_FUNCTION(tf_upper_house) {
3278 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]);
3279}
3280TRIGGER_FUNCTION(tf_unemployment_by_type_nation) {
3281 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3282 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3283 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3284}
3285TRIGGER_FUNCTION(tf_unemployment_by_type_state) {
3286 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3287 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3288 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3289}
3290TRIGGER_FUNCTION(tf_unemployment_by_type_province) {
3291 return "dup " + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3292 "dup " + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3293 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3294}
3295TRIGGER_FUNCTION(tf_unemployment_by_type_pop) {
3296 return "dup " + pop_to_location() + "state_membership @ dup "
3297 + std::to_string(demographics::count_special_keys + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ >r "
3298 + std::to_string(demographics::count_special_keys + ws.world.pop_type_size() + trigger::payload(tval[3]).popt_id.index()) + " >demographics_key demographics @ "
3299 "r@ / 1.0 swap - 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 1)) + " " + compare_values(tval[0]);
3300}
3301TRIGGER_FUNCTION(tf_party_loyalty_nation_province_id) {
3302 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]);
3303}
3304TRIGGER_FUNCTION(tf_party_loyalty_from_nation_province_id) {
3305 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]);
3306}
3307TRIGGER_FUNCTION(tf_party_loyalty_province_province_id) {
3308 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]);
3309}
3310TRIGGER_FUNCTION(tf_party_loyalty_from_province_province_id) {
3311 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]);
3312}
3313TRIGGER_FUNCTION(tf_party_loyalty_nation_from_province) {
3314 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]);
3315}
3316TRIGGER_FUNCTION(tf_party_loyalty_generic) {
3317 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]);
3318}
3319TRIGGER_FUNCTION(tf_party_loyalty_from_nation_scope_province) {
3320 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]);
3321}
3322TRIGGER_FUNCTION(tf_party_loyalty_from_province_scope_province) {
3323 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]);
3324}
3325TRIGGER_FUNCTION(tf_can_build_in_province_railroad_no_limit_from_nation) {
3326 return ">r >r dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 max_building_level @ >f32 r> swap r> swap >r "
3327 "dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 building_level @ >f32 >r "
3328 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_railroad.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3329}
3330TRIGGER_FUNCTION(tf_can_build_in_province_railroad_yes_limit_from_nation) {
3331 return ">r >r dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 max_building_level @ >f32 r> swap r> swap >r "
3332 "dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 building_level @ >f32 >r "
3333 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_railroad.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3334}
3335TRIGGER_FUNCTION(tf_can_build_in_province_railroad_no_limit_this_nation) {
3336 return ">r dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 max_building_level @ >f32 r> swap >r "
3337 "dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 building_level @ >f32 >r "
3338 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_railroad.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3339}
3340TRIGGER_FUNCTION(tf_can_build_in_province_railroad_yes_limit_this_nation) {
3341 return ">r dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 max_building_level @ >f32 r> swap >r "
3342 "dup " + std::to_string(uint8_t(economy::province_building_type::railroad)) + " >u8 building_level @ >f32 >r "
3343 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_railroad.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3344}
3345TRIGGER_FUNCTION(tf_can_build_in_province_fort_no_limit_from_nation) {
3346 return ">r >r dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 max_building_level @ >f32 r> swap r> swap >r "
3347 "dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 building_level @ >f32 >r "
3348 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_fort.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3349}
3350TRIGGER_FUNCTION(tf_can_build_in_province_fort_yes_limit_from_nation) {
3351 return ">r >r dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 max_building_level @ >f32 r> swap r> swap >r "
3352 "dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 building_level @ >f32 >r "
3353 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_fort.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3354}
3355TRIGGER_FUNCTION(tf_can_build_in_province_fort_no_limit_this_nation) {
3356 return ">r dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 max_building_level @ >f32 r> swap >r "
3357 "dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 building_level @ >f32 >r "
3358 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_fort.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3359}
3360TRIGGER_FUNCTION(tf_can_build_in_province_fort_yes_limit_this_nation) {
3361 return ">r dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 max_building_level @ >f32 r> swap >r "
3362 "dup " + std::to_string(uint8_t(economy::province_building_type::fort)) + " >u8 building_level @ >f32 >r "
3363 "dup " + std::to_string(sys::provincial_mod_offsets::min_build_fort.index()) + " >provincial_modifier_value modifier_values @ r> + r> < " + truth_inversion(tval[0]);
3364}
3365TRIGGER_FUNCTION(tf_can_build_in_province_naval_base_no_limit_from_nation) {
3366 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ can-build-naval-base? " + truth_inversion(tval[0]);
3367}
3368TRIGGER_FUNCTION(tf_can_build_in_province_naval_base_yes_limit_from_nation) {
3369 return ">r >r dup >index r> swap r> swap >r dup >index r> state-ptr @ can-build-naval-base? " + truth_inversion(tval[0]);
3370}
3371TRIGGER_FUNCTION(tf_can_build_in_province_naval_base_no_limit_this_nation) {
3372 return ">r dup >index r> swap >r dup >index r> state-ptr @ can-build-naval-base? " + truth_inversion(tval[0]);
3373}
3374TRIGGER_FUNCTION(tf_can_build_in_province_naval_base_yes_limit_this_nation) {
3375 return ">r dup >index r> swap >r dup >index r> state-ptr @ can-build-naval-base? " + truth_inversion(tval[0]);
3376}
3377TRIGGER_FUNCTION(tf_can_build_railway_in_capital_yes_whole_state_yes_limit) {
3378 return "true " + truth_inversion(tval[0]);
3379}
3380TRIGGER_FUNCTION(tf_can_build_railway_in_capital_yes_whole_state_no_limit) {
3381 return "true " + truth_inversion(tval[0]);
3382}
3383TRIGGER_FUNCTION(tf_can_build_railway_in_capital_no_whole_state_yes_limit) {
3384 return "true " + truth_inversion(tval[0]);
3385}
3386TRIGGER_FUNCTION(tf_can_build_railway_in_capital_no_whole_state_no_limit) {
3387 return "true " + truth_inversion(tval[0]);
3388}
3389TRIGGER_FUNCTION(tf_can_build_fort_in_capital_yes_whole_state_yes_limit) {
3390 return "true " + truth_inversion(tval[0]);
3391}
3392TRIGGER_FUNCTION(tf_can_build_fort_in_capital_yes_whole_state_no_limit) {
3393 return "true " + truth_inversion(tval[0]);
3394}
3395TRIGGER_FUNCTION(tf_can_build_fort_in_capital_no_whole_state_yes_limit) {
3396 return "true " + truth_inversion(tval[0]);
3397}
3398TRIGGER_FUNCTION(tf_can_build_fort_in_capital_no_whole_state_no_limit) {
3399 return "true " + truth_inversion(tval[0]);
3400}
3401TRIGGER_FUNCTION(tf_work_available_nation) {
3402 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ >r "
3403 "dup " + std::to_string(demographics::to_employment_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3404 " r> >= " + truth_inversion(tval[0]);
3405}
3406TRIGGER_FUNCTION(tf_work_available_state) {
3407 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ >r "
3408 "dup " + std::to_string(demographics::to_employment_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3409 " r> >= " + truth_inversion(tval[0]);
3410}
3411TRIGGER_FUNCTION(tf_work_available_province) {
3412 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ >r "
3413 "dup " + std::to_string(demographics::to_employment_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3414 " r> >= " + truth_inversion(tval[0]);
3415}
3416TRIGGER_FUNCTION(tf_variable_ideology_name_nation) {
3417 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3418 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).ideo_id).index()) + " >demographics_key demographics @ "
3419 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3420}
3421TRIGGER_FUNCTION(tf_variable_ideology_name_state) {
3422 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3423 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).ideo_id).index()) + " >demographics_key demographics @ "
3424 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3425}
3426TRIGGER_FUNCTION(tf_variable_ideology_name_province) {
3427 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3428 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).ideo_id).index()) + " >demographics_key demographics @ "
3429 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3430}
3431TRIGGER_FUNCTION(tf_variable_ideology_name_pop) {
3432 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).ideo_id).index()) + " >pop_demographics_key udemographics @ "
3433 " >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]);
3434}
3435TRIGGER_FUNCTION(tf_variable_issue_name_nation) {
3436 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3437 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).opt_id).index()) + " >demographics_key demographics @ "
3438 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3439}
3440TRIGGER_FUNCTION(tf_variable_issue_name_state) {
3441 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3442 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).opt_id).index()) + " >demographics_key demographics @ "
3443 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3444}
3445TRIGGER_FUNCTION(tf_variable_issue_name_province) {
3446 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3447 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).opt_id).index()) + " >demographics_key demographics @ "
3448 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3449}
3450TRIGGER_FUNCTION(tf_variable_issue_name_pop) {
3451 return "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).opt_id).index()) + " >pop_demographics_key udemographics @ "
3452 " >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]);
3453}
3454TRIGGER_FUNCTION(tf_variable_issue_group_name_nation) {
3455 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]);
3456}
3457TRIGGER_FUNCTION(tf_variable_issue_group_name_state) {
3458 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]);
3459}
3460TRIGGER_FUNCTION(tf_variable_issue_group_name_province) {
3461 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]);
3462}
3463TRIGGER_FUNCTION(tf_variable_issue_group_name_pop) {
3464 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]);
3465}
3466TRIGGER_FUNCTION(tf_variable_reform_group_name_nation) {
3467 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]);
3468}
3469TRIGGER_FUNCTION(tf_variable_reform_group_name_state) {
3470 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]);
3471}
3472TRIGGER_FUNCTION(tf_variable_reform_group_name_province) {
3473 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]);
3474}
3475TRIGGER_FUNCTION(tf_variable_reform_group_name_pop) {
3476 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]);
3477}
3478TRIGGER_FUNCTION(tf_variable_pop_type_name_nation) {
3479 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3480 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3481 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3482}
3483TRIGGER_FUNCTION(tf_variable_pop_type_name_state) {
3484 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3485 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3486 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3487}
3488TRIGGER_FUNCTION(tf_variable_pop_type_name_province) {
3489 return "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3490 "dup " + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3491 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3492}
3493TRIGGER_FUNCTION(tf_variable_pop_type_name_pop) {
3494 return "dup " + pop_to_location() + "dup " + std::to_string(demographics::total.index()) + " >demographics_key demographics @ >r "
3495 + std::to_string(demographics::to_key(ws, trigger::payload(tval[1]).popt_id).index()) + " >demographics_key demographics @ "
3496 " r@ / 0.0 0.0 r> >= select " + std::to_string(read_float_from_payload(tval + 2)) + " " + compare_values(tval[0]);
3497}
3498TRIGGER_FUNCTION(tf_variable_good_name) {
3499 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]);
3500}
3501TRIGGER_FUNCTION(tf_religion_nation) {
3502 return "dup religion @ >index " + std::to_string(trigger::payload(tval[1]).rel_id.index()) + " " + compare_values_eq(tval[0]);
3503}
3504TRIGGER_FUNCTION(tf_religion_nation_reb) {
3505 return ">r >r dup religion @ r> swap r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3506}
3507TRIGGER_FUNCTION(tf_religion_nation_from_nation) {
3508 return ">r >r dup religion @ r> swap r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3509}
3510TRIGGER_FUNCTION(tf_religion_nation_this_nation) {
3511 return ">r dup religion @ r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3512}
3513TRIGGER_FUNCTION(tf_religion_nation_this_state) {
3514 return ">r dup " + state_to_owner() + "religion @ r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3515}
3516TRIGGER_FUNCTION(tf_religion_nation_this_province) {
3517 return ">r dup " + province_to_owner() + "religion @ r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3518}
3519TRIGGER_FUNCTION(tf_religion_nation_this_pop) {
3520 return ">r dup " + pop_to_owner() + "religion @ r> swap >r dup religion @ r> = " + truth_inversion(tval[0]);
3521}
3522TRIGGER_FUNCTION(tf_invention) {
3523 return "dup " + std::to_string(trigger::payload(tval[1]).invt_id.index()) + " >invention_id active_inventions @ " + truth_inversion(tval[0]);
3524}
3525TRIGGER_FUNCTION(tf_invention_province) {
3526 return "dup " + province_to_owner() + std::to_string(trigger::payload(tval[1]).invt_id.index()) + " >invention_id active_inventions @ " + truth_inversion(tval[0]);
3527}
3528TRIGGER_FUNCTION(tf_invention_pop) {
3529 return "dup " + pop_to_owner() + std::to_string(trigger::payload(tval[1]).invt_id.index()) + " >invention_id active_inventions @ " + truth_inversion(tval[0]);
3530}
3532 auto sid = trigger::payload(tval[1]).str_id;
3533 auto tid = ws.world.stored_trigger_get_function(sid);
3534 return test_trigger_generic(ws.trigger_data.data() + ws.trigger_data_indices[tid.index() + 1], ws) + truth_inversion(tval[0]);
3535}
3536
3537TRIGGER_FUNCTION(tf_has_building_bank) {
3538 return "dup " + std::to_string(int32_t(economy::province_building_type::bank)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
3539}
3540TRIGGER_FUNCTION(tf_has_building_university) {
3541 return "dup " + std::to_string(int32_t(economy::province_building_type::university)) + " >ui8 building_level 0 <> " + truth_inversion(tval[0]);
3542}
3543
3544TRIGGER_FUNCTION(tf_party_name) {
3545 auto ideo = trigger::payload(tval[1]).ideo_id;
3546 dcon::text_key new_name{ dcon::text_key::value_base_t(trigger::read_int32_t_from_payload(tval + 2)) };
3547
3548 if(ideo) {
3549 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]);
3550 } else {
3551 return "dup ruling_party @ name @ " + std::to_string(new_name.index()) + " >text_key = " + truth_inversion(tval[0]);
3552 }
3553}
3554
3555TRIGGER_FUNCTION(tf_party_position) {
3556 auto ideo = trigger::payload(tval[1]).ideo_id;
3557 dcon::issue_option_id new_opt = trigger::payload(tval[2]).opt_id;
3558
3559 if(ideo) {
3560 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]);
3561 } else {
3562 auto popt = ws.world.issue_option_get_parent_issue(new_opt);
3563 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]);
3564 }
3565}
3566
3568 constexpr static std::string (
3569 CALLTYPE* trigger_functions[])(uint16_t const* tval, sys::state& ws) = {
3570 tf_none,
3571#define TRIGGER_BYTECODE_ELEMENT(code, name, arg) tf_##name ,
3573#undef TRIGGER_BYTECODE_ELEMENT
3574 //
3575 // scopes
3576 //
3577 tf_generic_scope, // constexpr uint16_t generic_scope = 0x0000; // or & and
3578 tf_x_neighbor_province_scope, // constexpr uint16_t x_neighbor_province_scope = 0x0001;
3579 tf_x_neighbor_country_scope_nation, // constexpr uint16_t x_neighbor_country_scope_nation = 0x0002;
3580 tf_x_neighbor_country_scope_pop, // constexpr uint16_t x_neighbor_country_scope_pop = 0x0003;
3581 tf_x_war_countries_scope_nation, // constexpr uint16_t x_war_countries_scope_nation = 0x0004;
3582 tf_x_war_countries_scope_pop, // constexpr uint16_t x_war_countries_scope_pop = 0x0005;
3583 tf_x_greater_power_scope, // constexpr uint16_t x_greater_power_scope = 0x0006;
3584 tf_x_owned_province_scope_state, // constexpr uint16_t x_owned_province_scope_state = 0x0007;
3585 tf_x_owned_province_scope_nation, // constexpr uint16_t x_owned_province_scope_nation = 0x0008;
3586 tf_x_core_scope_province, // constexpr uint16_t x_core_scope_province = 0x0009;
3587 tf_x_core_scope_nation, // constexpr uint16_t x_core_scope_nation = 0x000A;
3588 tf_x_state_scope, // constexpr uint16_t x_state_scope = 0x000B;
3589 tf_x_substate_scope, // constexpr uint16_t x_substate_scope = 0x000C;
3590 tf_x_sphere_member_scope, // constexpr uint16_t x_sphere_member_scope = 0x000D;
3591 tf_x_pop_scope_province, // constexpr uint16_t x_pop_scope_province = 0x000E;
3592 tf_x_pop_scope_state, // constexpr uint16_t x_pop_scope_state = 0x000F;
3593 tf_x_pop_scope_nation, // constexpr uint16_t x_pop_scope_nation = 0x0010;
3594 tf_x_provinces_in_variable_region, // constexpr uint16_t x_provinces_in_variable_region = 0x0011; // variable name
3595 tf_owner_scope_state, // constexpr uint16_t owner_scope_state = 0x0012;
3596 tf_owner_scope_province, // constexpr uint16_t owner_scope_province = 0x0013;
3597 tf_controller_scope, // constexpr uint16_t controller_scope = 0x0014;
3598 tf_location_scope, // constexpr uint16_t location_scope = 0x0015;
3599 tf_country_scope_state, // constexpr uint16_t country_scope_state = 0x0016;
3600 tf_country_scope_pop, // constexpr uint16_t country_scope_pop = 0x0017;
3601 tf_capital_scope, // constexpr uint16_t capital_scope = 0x0018;
3602 tf_this_scope, // constexpr uint16_t this_scope_pop = 0x0019;
3603 tf_this_scope, // constexpr uint16_t this_scope_nation = 0x001A;
3604 tf_this_scope, // constexpr uint16_t this_scope_state = 0x001B;
3605 tf_this_scope, // constexpr uint16_t this_scope_province = 0x001C;
3606 tf_from_scope, // constexpr uint16_t from_scope_pop = 0x001D;
3607 tf_from_scope, // constexpr uint16_t from_scope_nation = 0x001E;
3608 tf_from_scope, // constexpr uint16_t from_scope_state = 0x001F;
3609 tf_from_scope, // constexpr uint16_t from_scope_province = 0x0020;
3610 tf_sea_zone_scope, // constexpr uint16_t sea_zone_scope = 0x0021;
3611 tf_cultural_union_scope, // constexpr uint16_t cultural_union_scope = 0x0022;
3612 tf_overlord_scope, // constexpr uint16_t overlord_scope = 0x0023;
3613 tf_sphere_owner_scope, // constexpr uint16_t sphere_owner_scope = 0x0024;
3614 tf_independence_scope, // constexpr uint16_t independence_scope = 0x0025;
3615 tf_flashpoint_tag_scope, // constexpr uint16_t flashpoint_tag_scope = 0x0026;
3616 tf_crisis_state_scope, // constexpr uint16_t crisis_state_scope = 0x0027;
3617 tf_state_scope_pop, // constexpr uint16_t state_scope_pop = 0x0028;
3618 tf_state_scope_province, // constexpr uint16_t state_scope_province = 0x0029;
3619 tf_tag_scope, // constexpr uint16_t tag_scope = 0x002A; // variable name
3620 tf_integer_scope, // constexpr uint16_t integer_scope = 0x002B; // variable name
3621 tf_country_scope_nation, // constexpr uint16_t country_scope_nation = 0x002C;
3622 tf_country_scope_province, // constexpr uint16_t country_scope_province = 0x002D;
3623 tf_cultural_union_scope_pop, // constexpr uint16_t cultural_union_scope_pop = 0x002E;
3624 tf_capital_scope_province, // constexpr uint16_t capital_scope_province = 0x002F;
3625 tf_capital_scope_pop, //constexpr inline uint16_t capital_scope_pop = first_scope_code + 0x0030;
3626 tf_x_country_scope, //constexpr inline uint16_t x_country_scope = first_scope_code + 0x0031;
3627 tf_x_neighbor_province_scope_state, //constexpr inline uint16_t x_neighbor_province_scope_state = first_scope_code + 0x0032;
3628 tf_x_provinces_in_variable_region_proper, //constexpr inline uint16_t x_provinces_in_variable_region_proper = first_scope_code + 0x0033;
3629 };
3630};
3631
3632
3633std::string CALLTYPE test_trigger_generic(uint16_t const* tval, sys::state& ws) {
3634 return trigger_container::trigger_functions[*tval & trigger::code_mask](tval, ws);
3635}
3636
3637std::string multiplicative_modifier(sys::state& state, dcon::value_modifier_key modifier) {
3638 auto base = state.value_modifiers[modifier];
3639 std::string result;
3640 result += std::to_string(base.factor) + " >r ";
3641
3642 for(uint32_t i = 0; i < base.segments_count; ++i) {
3643 auto seg = state.value_modifier_segments[base.first_segment_offset + i];
3644 if(seg.condition) {
3645 result += test_trigger_generic(state.trigger_data.data() + state.trigger_data_indices[seg.condition.index() + 1], state);
3646 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
3647 }
3648 }
3649 return result;
3650}
3651std::string additive_modifier(sys::state& state, dcon::value_modifier_key modifier) {
3652 auto base = state.value_modifiers[modifier];
3653 std::string result;
3654 result += std::to_string(base.base) + " >r ";
3655
3656 for(uint32_t i = 0; i < base.segments_count; ++i) {
3657 auto seg = state.value_modifier_segments[base.first_segment_offset + i];
3658 if(seg.condition) {
3659 result += test_trigger_generic(state.trigger_data.data() + state.trigger_data_indices[seg.condition.index() + 1], state);
3660 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
3661 }
3662 }
3663 result += "r> " + std::to_string(base.factor) + " * >r ";
3664 return result;
3665}
3666
3667std::string evaluate(sys::state& state, dcon::trigger_key key) {
3668 return test_trigger_generic(state.trigger_data.data() + state.trigger_data_indices[key.index() + 1], state);
3669}
3670
3671#undef CALLTYPE
3672#undef TRIGGER_FUNCTION
3673
3674} // 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
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