Project Alice
Loading...
Searching...
No Matches
modifiers.cpp
Go to the documentation of this file.
1#include "modifiers.hpp"
2#include "system_state.hpp"
3#include "demographics.hpp"
4#include "military.hpp"
6#include "province.hpp"
8#include "triggers.hpp"
10
11namespace sys {
12
13// NOTE: these functions do not add or remove a modifier from the list of modifiers for an entity
14void apply_modifier_values_to_nation(sys::state& state, dcon::nation_id target_nation, dcon::modifier_id mod_id) {
15 auto& nat_values = state.world.modifier_get_national_values(mod_id);
17 if(!(nat_values.offsets[i]))
18 break; // no more modifier values
19
20 auto fixed_offset = nat_values.offsets[i];
21 auto modifier_amount = nat_values.values[i];
22 state.world.nation_get_modifier_values(target_nation, fixed_offset) += modifier_amount;
23 }
24}
25
26void apply_scaled_modifier_values_to_nation(sys::state& state, dcon::nation_id target_nation, dcon::modifier_id mod_id,
27 float scale) {
28 auto& nat_values = state.world.modifier_get_national_values(mod_id);
30 if(!(nat_values.offsets[i]))
31 break; // no more modifier values
32
33 auto fixed_offset = nat_values.offsets[i];
34 auto modifier_amount = nat_values.values[i];
35 state.world.nation_get_modifier_values(target_nation, fixed_offset) += modifier_amount * scale;
36 }
37}
38
39void apply_modifier_values_to_province(sys::state& state, dcon::province_id target_prov, dcon::modifier_id mod_id) {
40 auto& prov_values = state.world.modifier_get_province_values(mod_id);
41 auto owner = state.world.province_get_nation_from_province_ownership(target_prov);
43 if(!(prov_values.offsets[i]))
44 break; // no more modifier values
45
46 auto fixed_offset = prov_values.offsets[i];
47 auto modifier_amount = prov_values.values[i];
48 state.world.province_get_modifier_values(target_prov, fixed_offset) += modifier_amount;
49 }
50 if(owner) {
51 auto& nat_values = state.world.modifier_get_national_values(mod_id);
53 if(!(nat_values.offsets[i]))
54 break; // no more modifier values
55
56 auto fixed_offset = nat_values.offsets[i];
57 auto modifier_amount = nat_values.values[i];
58 state.world.nation_get_modifier_values(owner, fixed_offset) += modifier_amount;
59 }
60 }
61}
62
63void add_modifier_to_nation(sys::state& state, dcon::nation_id target_nation, dcon::modifier_id mod_id, sys::date expiration) {
64 auto lst = state.world.nation_get_current_modifiers(target_nation);
65 for(auto& m : lst) {
66 if(m.mod_id == mod_id) {
67 if(!expiration || (m.expiration && m.expiration < expiration)) {
68 m.expiration = expiration;
69 }
70 return;
71 }
72 }
73 lst.push_back(sys::dated_modifier{expiration, mod_id});
74}
75void add_modifier_to_province(sys::state& state, dcon::province_id target_prov, dcon::modifier_id mod_id, sys::date expiration) {
76 auto lst = state.world.province_get_current_modifiers(target_prov);
77 for(auto& m : lst) {
78 if(m.mod_id == mod_id) {
79 if(!expiration || (m.expiration && m.expiration < expiration)) {
80 m.expiration = expiration;
81 }
82 return;
83 }
84 }
85 lst.push_back(sys::dated_modifier{expiration, mod_id});
86}
87void remove_modifier_from_nation(sys::state& state, dcon::nation_id target_nation, dcon::modifier_id mod_id) {
88 auto modifiers_range = state.world.nation_get_current_modifiers(target_nation);
89 auto count = modifiers_range.size();
90 for(uint32_t i = count; i-- > 0;) {
91 if(modifiers_range.at(i).mod_id == mod_id) {
92 modifiers_range.remove_at(i);
93 return;
94 }
95 }
96}
97
98void remove_modifier_from_province(sys::state& state, dcon::province_id target_prov, dcon::modifier_id mod_id) {
99 auto modifiers_range = state.world.province_get_current_modifiers(target_prov);
100 auto count = modifiers_range.size();
101 for(uint32_t i = count; i-- > 0;) {
102 if(modifiers_range.at(i).mod_id == mod_id) {
103 modifiers_range.remove_at(i);
104 return;
105 }
106 }
107}
108
109void toggle_modifier_from_province(sys::state& state, dcon::province_id target_prov, dcon::modifier_id mod_id, sys::date expiration) {
110 auto lst = state.world.province_get_current_modifiers(target_prov);
111 auto modifiers_range = state.world.province_get_current_modifiers(target_prov);
112 auto count = modifiers_range.size();
113 for(uint32_t i = count; i-- > 0;) {
114 if(modifiers_range.at(i).mod_id == mod_id) {
115 modifiers_range.remove_at(i);
116 return;
117 }
118 }
119 lst.push_back(sys::dated_modifier{ expiration, mod_id });
120}
121
122template<typename F>
123void bulk_apply_masked_modifier_to_nations(sys::state& state, dcon::modifier_id m, F const& mask_functor) {
124 auto& nat_values = state.world.modifier_get_national_values(m);
126 if(!(nat_values.offsets[i]))
127 break; // no more modifier values attached
128
129 state.world.execute_serial_over_nation(
130 [&, fixed_offset = nat_values.offsets[i], modifier_amount = nat_values.values[i]](auto nation_indices) {
131 auto has_mod_mask = mask_functor(nation_indices);
132 auto old_mod_value = state.world.nation_get_modifier_values(nation_indices, fixed_offset);
133 state.world.nation_set_modifier_values(nation_indices, fixed_offset,
134 ve::select(has_mod_mask, old_mod_value + modifier_amount, old_mod_value));
135 });
136 }
137}
138
139template<typename F>
140void bulk_apply_scaled_modifier_to_nations(sys::state& state, dcon::modifier_id m, F const& scale_functor) {
141 auto& nat_values = state.world.modifier_get_national_values(m);
143 if(!(nat_values.offsets[i]))
144 break; // no more modifier values attached
145
146 state.world.execute_serial_over_nation(
147 [&, fixed_offset = nat_values.offsets[i], modifier_amount = nat_values.values[i]](auto nation_indices) {
148 auto scaling_factor = scale_functor(nation_indices);
149 auto old_mod_value = state.world.nation_get_modifier_values(nation_indices, fixed_offset);
150 state.world.nation_set_modifier_values(nation_indices, fixed_offset, old_mod_value + scaling_factor * modifier_amount);
151 });
152 }
153}
154
155template<typename F>
156void bulk_apply_masked_modifier_to_provinces(sys::state& state, dcon::modifier_id mod_id, F const& mask_functor) {
157 auto& prov_values = state.world.modifier_get_province_values(mod_id);
158
160 if(!(prov_values.offsets[i]))
161 break; // no more modifier values
162
163 auto fixed_offset = prov_values.offsets[i];
164 auto modifier_amount = prov_values.values[i];
165
167 auto has_mod_mask = mask_functor(ids);
168 auto old_value = state.world.province_get_modifier_values(ids, fixed_offset);
169 state.world.province_set_modifier_values(ids, fixed_offset,
170 ve::select(has_mod_mask, old_value + modifier_amount, old_value));
171 });
172 }
173
174 auto& nat_values = state.world.modifier_get_national_values(mod_id);
175
177 if(!(nat_values.offsets[i]))
178 break; // no more modifier values
179
180 auto fixed_offset = nat_values.offsets[i];
181 auto modifier_amount = nat_values.values[i];
182
184 auto owners = state.world.province_get_nation_from_province_ownership(ids);
185 auto has_mod_mask = mask_functor(ids) && (owners != dcon::nation_id{});
186
187 auto old_value = state.world.nation_get_modifier_values(owners, fixed_offset);
188 state.world.nation_set_modifier_values(owners, fixed_offset,
189 ve::select(has_mod_mask, old_value + modifier_amount, old_value));
190 });
191 }
192}
193
194void bulk_apply_modifier_to_provinces(sys::state& state, dcon::modifier_id mod_id) {
195 auto& prov_values = state.world.modifier_get_province_values(mod_id);
196
198 if(!(prov_values.offsets[i]))
199 break; // no more modifier values
200
201 auto fixed_offset = prov_values.offsets[i];
202 auto modifier_amount = prov_values.values[i];
203
205 auto old_value = state.world.province_get_modifier_values(ids, fixed_offset);
206 state.world.province_set_modifier_values(ids, fixed_offset, old_value + modifier_amount);
207 });
208 }
209}
210
211template<typename F>
212void bulk_apply_scaled_modifier_to_provinces(sys::state& state, dcon::modifier_id mod_id, F const& scale_functor) {
213 auto& prov_values = state.world.modifier_get_province_values(mod_id);
214
216 if(!(prov_values.offsets[i]))
217 break; // no more modifier values
218
219 auto fixed_offset = prov_values.offsets[i];
220 auto modifier_amount = prov_values.values[i];
221
223 auto scale = scale_functor(ids);
224 auto old_value = state.world.province_get_modifier_values(ids, fixed_offset);
225 state.world.province_set_modifier_values(ids, fixed_offset, old_value + modifier_amount * scale);
226 });
227 }
228
229 auto& nat_values = state.world.modifier_get_national_values(mod_id);
230
232 if(!(nat_values.offsets[i]))
233 break; // no more modifier values
234
235 auto fixed_offset = nat_values.offsets[i];
236 auto modifier_amount = nat_values.values[i];
237
239 auto owners = state.world.province_get_nation_from_province_ownership(ids);
240 auto scale = ve::select(owners != dcon::nation_id{}, scale_functor(ids), 0.0f);
241
242 auto old_value = state.world.nation_get_modifier_values(owners, fixed_offset);
243 state.world.nation_set_modifier_values(owners, fixed_offset, old_value + modifier_amount * scale);
244 });
245 }
246}
247
249
250 // purge expired triggered modifiers
251 for(auto n : state.world.in_nation) {
252 auto timed_modifiers = n.get_current_modifiers();
253 for(uint32_t i = timed_modifiers.size(); i-- > 0;) {
254 if(bool(timed_modifiers[i].expiration) && timed_modifiers[i].expiration < state.current_date) {
255 timed_modifiers.remove_at(i);
256 }
257 }
258 }
259
260 concurrency::parallel_for(uint32_t(0), sys::national_mod_offsets::count, [&](uint32_t i) {
261 dcon::national_modifier_value mid{dcon::national_modifier_value::value_base_t(i)};
262 state.world.execute_serial_over_nation([&](auto ids) { state.world.nation_set_modifier_values(ids, mid, ve::fp_vector{}); });
263 });
264
265 for(auto n : state.world.in_nation) {
266 if(auto ts = n.get_tech_school(); ts)
268 }
269 for(auto n : state.world.in_nation) {
270 if(auto nv = n.get_national_value(); nv)
272 }
273 for(auto n : state.world.in_nation) {
274 for(auto mpr : state.world.nation_get_current_modifiers(n)) {
276 }
277 }
278 state.world.for_each_technology([&](dcon::technology_id t) {
279 auto tmod = state.world.technology_get_modifier(t);
280 if(tmod) {
282 [&](auto ids) { return state.world.nation_get_active_technologies(ids, t); });
283 }
284 });
285 state.world.for_each_invention([&](dcon::invention_id i) {
286 auto tmod = state.world.invention_get_modifier(i);
287 if(tmod) {
289 [&](auto ids) { return state.world.nation_get_active_inventions(ids, i); });
290 }
291 });
292 state.world.for_each_issue([&](dcon::issue_id i) {
293 for(auto n : state.world.in_nation) {
294 auto iopt = state.world.nation_get_issues(n, i);
295 auto imod = state.world.issue_option_get_modifier(iopt);
296 if(imod && (n.get_is_civilized() || state.world.issue_get_issue_type(i) == uint8_t(culture::issue_type::party))) {
298 }
299 }
300 });
301 state.world.for_each_reform([&](dcon::reform_id i) {
302 for(auto n : state.world.in_nation) {
303 auto iopt = state.world.nation_get_reforms(n, i);
304 auto imod = state.world.reform_option_get_modifier(iopt);
305 if(imod && !n.get_is_civilized()) {
307 }
308 }
309 });
310 for(auto n : state.world.in_nation) {
311 auto in_wars = n.get_war_participant();
312 if(in_wars.begin() != in_wars.end()) {
315 } else {
318 }
319 }
320
323 [&](auto ids) { return state.world.nation_get_infamy(ids); });
324 }
327 [&](auto ids) { return state.world.nation_get_plurality(ids); });
328 }
331 [&](auto ids) { return state.world.nation_get_war_exhaustion(ids); });
332 }
335 auto total = state.world.nation_get_demographics(ids, demographics::total);
336 return ve::select(total > 0, state.world.nation_get_demographics(ids, demographics::literacy) / total, 0.0f);
337 });
338 }
341 auto bc = ve::to_float(state.world.nation_get_central_blockaded(ids));
342 auto c = ve::to_float(state.world.nation_get_central_ports(ids));
343 return ve::select(c > 0.0f, bc / c, 0.0f);
344 });
345 }
348 return ve::apply(
349 [&](dcon::nation_id nid) {
350 auto n = fatten(state.world, nid);
351 auto cap_continent = n.get_capital().get_continent();
352 float total = 0.0f;
353 float occupied = 0.0f;
354 for(auto owned : n.get_province_ownership()) {
355 if(owned.get_province().get_continent() == cap_continent) {
356 total += 1.0f;
357 if(auto c = owned.get_province().get_nation_from_province_control().id; c && c != n.id) {
358 occupied += 1.0f;
359 }
360 }
361 }
362 if(total > 0.0f)
363 return 100.0f * occupied / total;
364 else
365 return 0.0f;
366 },
367 ids);
368 });
369 }
370 for(auto n : state.world.in_nation) {
371 if(n.get_is_civilized() == false) {
372 if(state.national_definitions.unciv_nation)
373 apply_modifier_values_to_nation(state, n, state.national_definitions.unciv_nation);
374 } else if(nations::is_great_power(state, n)) {
375 if(state.national_definitions.great_power)
376 apply_modifier_values_to_nation(state, n, state.national_definitions.great_power);
377 } else if(n.get_rank() <= uint16_t(state.defines.colonial_rank)) {
378 if(state.national_definitions.second_power)
379 apply_modifier_values_to_nation(state, n, state.national_definitions.second_power);
380 } else {
381 if(state.national_definitions.civ_nation)
382 apply_modifier_values_to_nation(state, n, state.national_definitions.civ_nation);
383 }
384 }
385 if(state.national_definitions.disarming) {
386 for(auto n : state.world.in_nation) {
387 if(bool(n.get_disarmed_until()) && n.get_disarmed_until() > state.current_date) {
388 apply_modifier_values_to_nation(state, n, state.national_definitions.disarming);
389 }
390 }
391 }
392 if(state.national_definitions.in_bankrupcy) {
393 bulk_apply_masked_modifier_to_nations(state, state.national_definitions.in_bankrupcy,
394 [&](auto ids) { return state.world.nation_get_is_bankrupt(ids); });
395 }
396 // TODO: debt
397
398 for(auto tm : state.national_definitions.triggered_modifiers) {
399 if(tm.trigger_condition && tm.linked_modifier) {
400 auto& nat_values = state.world.modifier_get_national_values(tm.linked_modifier);
401 auto size_used = state.world.nation_size();
402 ve::execute_serial_fast<dcon::nation_id>(size_used, [&](auto nids) {
403 auto trigger_condition_satisfied =
404 trigger::evaluate(state, tm.trigger_condition, trigger::to_generic(nids), trigger::to_generic(nids), 0) &&
405 ve::apply([size_used](auto n) { return n.index() < int32_t(size_used); }, nids);
406 auto compressed_res = ve::compress_mask(trigger_condition_satisfied);
407 if(compressed_res.v == ve::vbitfield_type::storage(0)) {
408 return;
409 } else {
411 if(!(nat_values.offsets[i]))
412 break; // no more modifier values attached
413
414 auto fixed_offset = nat_values.offsets[i];
415 auto modifier_amount = nat_values.values[i];
416 auto old_mod_value = state.world.nation_get_modifier_values(nids, fixed_offset);
417 state.world.nation_set_modifier_values(nids, fixed_offset,
418 ve::select(trigger_condition_satisfied, old_mod_value + modifier_amount, old_mod_value));
419 }
420 }
421 });
422 }
423 }
424}
425
427
429 dcon::national_modifier_value mid{dcon::national_modifier_value::value_base_t(i)};
430 state.world.nation_set_modifier_values(n, mid, 0.0f);
431 }
432
433 if(auto ts = state.world.nation_get_tech_school(n); ts)
435
436 if(auto nv = state.world.nation_get_national_value(n); nv)
438
439 for(auto mpr : state.world.nation_get_current_modifiers(n)) {
441 }
442
443 state.world.for_each_technology([&](dcon::technology_id t) {
444 auto tmod = state.world.technology_get_modifier(t);
445 if(tmod && state.world.nation_get_active_technologies(n, t)) {
446 apply_modifier_values_to_nation(state, n, tmod);
447 }
448 });
449 state.world.for_each_invention([&](dcon::invention_id i) {
450 auto tmod = state.world.invention_get_modifier(i);
451 if(tmod && state.world.nation_get_active_inventions(n, i)) {
452 apply_modifier_values_to_nation(state, n, tmod);
453 }
454 });
455 state.world.for_each_issue([&](dcon::issue_id i) {
456 auto iopt = state.world.nation_get_issues(n, i);
457 auto imod = state.world.issue_option_get_modifier(iopt);
458 if(imod &&
459 (state.world.nation_get_is_civilized(n) || state.world.issue_get_issue_type(i) == uint8_t(culture::issue_type::party))) {
461 }
462 });
463 if(!state.world.nation_get_is_civilized(n)) {
464 state.world.for_each_reform([&](dcon::reform_id i) {
465 auto iopt = state.world.nation_get_reforms(n, i);
466 auto imod = state.world.reform_option_get_modifier(iopt);
467 if(imod) {
469 }
470 });
471 }
472
473 auto in_wars = state.world.nation_get_war_participant(n);
474 if(in_wars.begin() != in_wars.end()) {
477 } else {
480 }
481
484 }
487 }
490 state.world.nation_get_war_exhaustion(n));
491 }
493 auto total = state.world.nation_get_demographics(n, demographics::total);
495 total > 0 ? state.world.nation_get_demographics(n, demographics::literacy) / total : 0.0f);
496 }
498 auto bc = ve::to_float(state.world.nation_get_central_blockaded(n));
499 auto c = ve::to_float(state.world.nation_get_central_ports(n));
500
502 }
504 auto nid = fatten(state.world, n);
505 auto cap_continent = nid.get_capital().get_continent();
506 float total = 0.0f;
507 float occupied = 0.0f;
508 for(auto owned : nid.get_province_ownership()) {
509 if(owned.get_province().get_continent() == cap_continent) {
510 total += 1.0f;
511 if(auto c = owned.get_province().get_nation_from_province_control().id; c && c != n) {
512 occupied += 1.0f;
513 }
514 }
515 }
516
518 total > 0.0f ? occupied / total : 0.0f);
519 }
520
521 if(state.world.nation_get_is_civilized(n) == false) {
524 } else if(nations::is_great_power(state, n)) {
527 } else if(state.world.nation_get_rank(n) <= uint16_t(state.defines.colonial_rank)) {
530 } else {
533 }
534
536 if(bool(state.world.nation_get_disarmed_until(n)) && state.world.nation_get_disarmed_until(n) > state.current_date) {
538 }
539 }
541 if(bool(state.world.nation_get_is_bankrupt(n))) {
543 }
544 }
545 // TODO: debt
546
548 if(tm.trigger_condition && tm.linked_modifier) {
549
550 auto trigger_condition_satisfied =
551 trigger::evaluate(state, tm.trigger_condition, trigger::to_generic(n), trigger::to_generic(n), 0);
552
553 if(trigger_condition_satisfied) {
554 apply_modifier_values_to_nation(state, n, tm.linked_modifier);
555 }
556 }
557 }
558}
559
561 // purge expired triggered modifiers
562 province::for_each_land_province(state, [&](dcon::province_id p) {
563 auto timed_modifiers = state.world.province_get_current_modifiers(p);
564 for(uint32_t i = timed_modifiers.size(); i-- > 0;) {
565 if(bool(timed_modifiers[i].expiration) && timed_modifiers[i].expiration < state.current_date) {
566 timed_modifiers.remove_at(i);
567 }
568 }
569 });
570
571 concurrency::parallel_for(uint32_t(0), sys::provincial_mod_offsets::count, [&](uint32_t i) {
572 dcon::provincial_modifier_value mid{dcon::provincial_modifier_value::value_base_t(i)};
574 [&](auto ids) { state.world.province_set_modifier_values(ids, mid, ve::fp_vector{}); });
575 });
576
577 if(state.national_definitions.land_province)
578 bulk_apply_modifier_to_provinces(state, state.national_definitions.land_province);
579
580 province::for_each_land_province(state, [&](dcon::province_id p) {
581 for(auto mpr : state.world.province_get_current_modifiers(p)) {
582 apply_modifier_values_to_province(state, p, mpr.mod_id);
583 }
584 });
585
586 province::for_each_land_province(state, [&](dcon::province_id p) {
587 if(auto m = state.world.province_get_terrain(p); m)
589 });
590 province::for_each_land_province(state, [&](dcon::province_id p) {
591 if(auto m = state.world.province_get_climate(p); m)
593 });
594 province::for_each_land_province(state, [&](dcon::province_id p) {
595 if(auto m = state.world.province_get_continent(p); m)
597 });
598 province::for_each_land_province(state, [&](dcon::province_id p) {
599 if(auto m = state.world.province_get_state_membership(p).get_owner_focus(); m)
600 apply_modifier_values_to_province(state, p, m.get_modifier());
601 });
602 province::for_each_land_province(state, [&](dcon::province_id p) {
603 if(auto c = state.world.province_get_crime(p); c) {
604 if(auto m = state.culture_definitions.crimes[c].modifier; m)
605 apply_modifier_values_to_province(state, p, m);
606 }
607 });
608
610 if(state.economy_definitions.building_definitions[int32_t(t)].province_modifier) {
611 bulk_apply_scaled_modifier_to_provinces(state, state.economy_definitions.building_definitions[int32_t(t)].province_modifier,
612 [&](auto ids) { return ve::to_float(state.world.province_get_building_level(ids, uint8_t(t))); });
613 }
614 }
615 if(state.national_definitions.infrastructure) {
616 bulk_apply_scaled_modifier_to_provinces(state, state.national_definitions.infrastructure, [&](auto ids) {
617 return ve::to_float(state.world.province_get_building_level(ids, uint8_t(economy::province_building_type::railroad))) *
618 state.economy_definitions.building_definitions[int32_t(economy::province_building_type::railroad)].infrastructure;
619 });
620 }
621 if(state.national_definitions.nationalism) {
622 bulk_apply_scaled_modifier_to_provinces(state, state.national_definitions.nationalism, [&](auto ids) {
623 return ve::select(state.world.province_get_is_owner_core(ids), 0.0f, state.world.province_get_nationalism(ids));
624 });
625 }
626 if(state.national_definitions.non_coastal) {
627 bulk_apply_masked_modifier_to_provinces(state, state.national_definitions.non_coastal,
628 [&](auto ids) { return !state.world.province_get_is_coast(ids); });
629 }
630 if(state.national_definitions.coastal) {
631 bulk_apply_masked_modifier_to_provinces(state, state.national_definitions.coastal,
632 [&](auto ids) { return state.world.province_get_is_coast(ids); });
633 }
634 if(state.national_definitions.overseas) {
635 bulk_apply_masked_modifier_to_provinces(state, state.national_definitions.overseas,
636 [&](auto ids) { return province::is_overseas(state, ids); });
637 }
638 if(state.national_definitions.core) {
639 bulk_apply_masked_modifier_to_provinces(state, state.national_definitions.core,
640 [&](auto ids) { return state.world.province_get_is_owner_core(ids); });
641 }
642 if(state.national_definitions.has_siege) {
643 bulk_apply_masked_modifier_to_provinces(state, state.national_definitions.has_siege,
644 [&](auto ids) { return military::province_is_under_siege(state, ids); });
645 }
646 if(state.national_definitions.blockaded) {
647 bulk_apply_masked_modifier_to_provinces(state, state.national_definitions.blockaded,
648 [&](auto ids) { return military::province_is_blockaded(state, ids); });
649 }
650}
651
652// restores values after loading a save
656 for(auto n : state.world.in_nation) {
658 }
659}
660
664 for(auto n : state.world.in_nation) {
666 }
667}
668
669} // namespace sys
constexpr dcon::demographics_key total(0)
constexpr dcon::demographics_key literacy(5)
void bound_budget_settings(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:5271
province_building_type
Definition: constants.hpp:578
bool is_great_power(sys::state const &state, dcon::nation_id id)
Definition: nations.cpp:503
void ve_for_each_land_province(sys::state &state, F const &func)
void for_each_land_province(sys::state &state, F const &func)
MOD_NAT_LIST constexpr uint32_t count
Definition: modifiers.hpp:215
MOD_PROV_LIST constexpr uint32_t count
Definition: modifiers.hpp:207
Definition: constants.hpp:4
void recreate_province_modifiers(sys::state &state)
Definition: modifiers.cpp:560
void bulk_apply_masked_modifier_to_nations(sys::state &state, dcon::modifier_id m, F const &mask_functor)
Definition: modifiers.cpp:123
void toggle_modifier_from_province(sys::state &state, dcon::province_id target_prov, dcon::modifier_id mod_id, sys::date expiration)
Definition: modifiers.cpp:109
void apply_modifier_values_to_nation(sys::state &state, dcon::nation_id target_nation, dcon::modifier_id mod_id)
Definition: modifiers.cpp:14
void remove_modifier_from_nation(sys::state &state, dcon::nation_id target_nation, dcon::modifier_id mod_id)
Definition: modifiers.cpp:87
void update_single_nation_modifiers(sys::state &state, dcon::nation_id n)
Definition: modifiers.cpp:426
void repopulate_modifier_effects(sys::state &state)
Definition: modifiers.cpp:653
void recreate_national_modifiers(sys::state &state)
Definition: modifiers.cpp:248
void bulk_apply_scaled_modifier_to_nations(sys::state &state, dcon::modifier_id m, F const &scale_functor)
Definition: modifiers.cpp:140
void update_modifier_effects(sys::state &state)
Definition: modifiers.cpp:661
void apply_modifier_values_to_province(sys::state &state, dcon::province_id target_prov, dcon::modifier_id mod_id)
Definition: modifiers.cpp:39
void add_modifier_to_nation(sys::state &state, dcon::nation_id target_nation, dcon::modifier_id mod_id, sys::date expiration)
Definition: modifiers.cpp:63
void bulk_apply_modifier_to_provinces(sys::state &state, dcon::modifier_id mod_id)
Definition: modifiers.cpp:194
void bulk_apply_masked_modifier_to_provinces(sys::state &state, dcon::modifier_id mod_id, F const &mask_functor)
Definition: modifiers.cpp:156
void add_modifier_to_province(sys::state &state, dcon::province_id target_prov, dcon::modifier_id mod_id, sys::date expiration)
Definition: modifiers.cpp:75
void bulk_apply_scaled_modifier_to_provinces(sys::state &state, dcon::modifier_id mod_id, F const &scale_functor)
Definition: modifiers.cpp:212
void apply_scaled_modifier_values_to_nation(sys::state &state, dcon::nation_id target_nation, dcon::modifier_id mod_id, float scale)
Definition: modifiers.cpp:26
void remove_modifier_from_province(sys::state &state, dcon::province_id target_prov, dcon::modifier_id mod_id)
Definition: modifiers.cpp:98
int32_t to_generic(dcon::province_id v)
Definition: triggers.hpp:12
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
Definition: triggers.cpp:5865
T select(bool v, T a, T b)
bool compress_mask(bool v)
float to_float(int32_t a)
uint uint32_t
uchar uint8_t
dcon::modifier_id total_occupation
Definition: nations.hpp:117
dcon::modifier_id total_blockaded
Definition: nations.hpp:118
dcon::modifier_id badboy
Definition: nations.hpp:107
dcon::modifier_id unciv_nation
Definition: nations.hpp:113
dcon::modifier_id in_bankrupcy
Definition: nations.hpp:119
dcon::modifier_id disarming
Definition: nations.hpp:105
dcon::modifier_id civ_nation
Definition: nations.hpp:112
dcon::modifier_id plurality
Definition: nations.hpp:115
dcon::modifier_id peace
Definition: nations.hpp:104
std::vector< triggered_modifier > triggered_modifiers
Definition: nations.hpp:67
dcon::modifier_id great_power
Definition: nations.hpp:110
dcon::modifier_id war_exhaustion
Definition: nations.hpp:106
dcon::modifier_id average_literacy
Definition: nations.hpp:114
dcon::modifier_id second_power
Definition: nations.hpp:111
static constexpr uint32_t modifier_definition_size
Definition: modifiers.hpp:231
static constexpr uint32_t modifier_definition_size
Definition: modifiers.hpp:219
dcon::data_container world
parsing::defines defines
sys::date current_date
nations::global_national_state national_definitions