3#include "dcon_generated.hpp"
24 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
30template auto nation_accepts_culture<ve::tagged_vector<dcon::nation_id>, dcon::culture_id>(
sys::state const&, ve::tagged_vector<dcon::nation_id>, dcon::culture_id);
31template auto primary_culture_group<ve::tagged_vector<dcon::nation_id>>(
sys::state const&, ve::tagged_vector<dcon::nation_id>);
32template auto owner_of_pop<ve::tagged_vector<dcon::pop_id>>(
sys::state const&, ve::tagged_vector<dcon::pop_id>);
33template auto central_blockaded_fraction<ve::tagged_vector<dcon::nation_id>>(
sys::state const&, ve::tagged_vector<dcon::nation_id>);
34template auto central_reb_controlled_fraction<ve::tagged_vector<dcon::nation_id>>(
sys::state const&, ve::tagged_vector<dcon::nation_id>);
35template auto central_has_crime_fraction<ve::tagged_vector<dcon::nation_id>>(
sys::state const&, ve::tagged_vector<dcon::nation_id>);
36template auto occupied_provinces_fraction<ve::tagged_vector<dcon::nation_id>>(
sys::state const&, ve::tagged_vector<dcon::nation_id>);
44 int64_t estimated_change = 0;
45 for(
auto p : state.world.nation_get_province_ownership(n)) {
46 for(
auto pl : state.world.province_get_pop_location(p.get_province())) {
50 auto total = int64_t(growth) + colonial_migration + emigration;
51 estimated_change += total;
54 return estimated_change;
59 for(uint16_t i = 0; i < uint16_t(state.nations_by_rank.size()); ++i) {
62 return state.nations_by_rank[i];
66 return dcon::nation_id{};
70 auto location = state.world.pop_get_province_from_pop_location(pop_ids);
71 return state.world.province_get_nation_from_province_ownership(location);
75 state.world.for_each_state_instance([&](dcon::state_instance_id sid) {
76 auto owner = state.world.state_instance_get_nation_from_state_ownership(sid);
77 auto base_state = state.world.state_instance_get_definition(sid);
78 for(
auto mprov : state.world.state_definition_get_abstract_state_membership(base_state)) {
79 if(mprov.get_province().get_nation_from_province_ownership() == owner) {
80 mprov.get_province().set_state_membership(sid);
88 state.world.execute_serial_over_nation([&](
auto ids) { state.world.nation_set_allies_count(ids, ve::int_vector()); });
89 state.world.for_each_diplomatic_relation([&](dcon::diplomatic_relation_id
id) {
90 if(state.world.diplomatic_relation_get_are_allied(
id)) {
91 state.world.nation_get_allies_count(state.world.diplomatic_relation_get_related_nations(id, 0)) += uint16_t(1);
92 state.world.nation_get_allies_count(state.world.diplomatic_relation_get_related_nations(id, 1)) += uint16_t(1);
96 state.world.for_each_nation([&](dcon::nation_id n) {
98 int32_t substates_total = 0;
99 for(
auto v : state.world.nation_get_overlord_as_ruler(n)) {
101 if(v.get_subject().get_is_substate())
104 state.world.nation_set_vassals_count(n, uint16_t(total));
105 state.world.nation_set_substates_count(n, uint16_t(substates_total));
110 if(state.diplomatic_cached_values_out_of_date) {
111 state.diplomatic_cached_values_out_of_date =
false;
117 state.world.nation_resize_demand_satisfaction(state.world.commodity_size());
118 state.world.nation_resize_direct_demand_satisfaction(state.world.commodity_size());
120 for(
auto n : state.world.in_nation)
121 n.set_is_great_power(
false);
123 for(
auto& gp : state.great_nations) {
124 state.world.nation_set_is_great_power(gp.nation,
true);
127 state.world.for_each_gp_relationship([&](dcon::gp_relationship_id rel) {
128 if((influence::level_mask & state.world.gp_relationship_get_status(rel)) == influence::level_in_sphere) {
129 auto t = state.world.gp_relationship_get_influence_target(rel);
130 auto gp = state.world.gp_relationship_get_great_power(rel);
131 state.world.nation_set_in_sphere_of(t, gp);
135 state.world.execute_serial_over_nation([&](
auto ids) {
136 auto treasury = state.world.nation_get_stockpiles(ids,
economy::money);
137 state.world.nation_set_last_treasury(ids, treasury);
144 for(int32_t i = 0; i < state.province_definitions.first_sea_province.index(); ++i) {
145 dcon::province_id pid{dcon::province_id::value_base_t(i)};
146 auto owner = state.world.province_get_nation_from_province_ownership(pid);
147 if(owner && !(state.world.province_get_state_membership(pid))) {
148 auto state_instance = fatten(state.world, state.world.create_state_instance());
149 auto abstract_state = state.world.province_get_state_from_abstract_state_membership(pid);
151 state_instance.set_definition(abstract_state);
152 state_instance.set_capital(pid);
153 state.world.force_create_state_ownership(state_instance, owner);
155 for(
auto mprov : state.world.state_definition_get_abstract_state_membership(abstract_state)) {
156 if(mprov.get_province().get_nation_from_province_ownership() == owner) {
157 mprov.get_province().set_state_membership(state_instance);
163 for(
auto si : state.world.in_state_instance) {
164 auto cap = si.get_capital();
166 auto slave = cap.get_is_slave();
167 auto colonial = cap.get_is_colonial();
170 state.world.province_set_is_colonial(p, colonial);
171 state.world.province_set_is_slave(p, slave);
177 auto target_nation = state.world.national_identity_get_nation_from_identity_holder(releasable);
178 if(!state.world.national_identity_get_is_not_releasable(releasable) &&
179 state.world.nation_get_owned_province_count(target_nation) == 0) {
180 bool owns_a_core =
false;
181 bool not_on_capital =
true;
182 state.world.national_identity_for_each_core(releasable, [&](dcon::core_id core) {
183 auto province = state.world.core_get_province(core);
184 owns_a_core |= state.world.province_get_nation_from_province_ownership(
province) == n;
185 not_on_capital &= state.world.nation_get_capital(n) !=
province;
187 return owns_a_core && not_on_capital && !state.world.nation_get_is_at_war(n);
195 return bool(fat_ident.get_nation_from_identity_holder().id);
199 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(a, b);
200 return state.world.diplomatic_relation_get_are_allied(rel);
204 return state.world.nation_get_total_ports(n) == 0;
209 return fat_id.get_related_nations(0) == query ? fat_id.get_related_nations(1) : fat_id.get_related_nations(0);
212bool global_national_state::is_global_flag_variable_set(dcon::global_flag_id
id)
const {
214 return dcon::bit_vector_test(global_flag_variables.data(),
id.index());
218void global_national_state::set_global_flag_variable(dcon::global_flag_id
id,
bool state) {
220 dcon::bit_vector_set(global_flag_variables.data(),
id.index(), state);
224 auto holder = state.world.national_identity_get_nation_from_identity_holder(tag);
228 return state.world.national_identity_get_name(tag);
238 state.world.execute_serial_over_nation([&](
auto ids) {
239 auto admin_mod = state.world.nation_get_modifier_values(ids, sys::national_mod_offsets::administrative_efficiency_modifier);
240 ve::fp_vector issue_sum;
241 for(
auto i : state.culture_definitions.social_issues) {
242 issue_sum = issue_sum + state.world.issue_option_get_administrative_multiplier(state.world.nation_get_issues(ids, i));
244 auto from_issues = issue_sum * state.defines.bureaucracy_percentage_increment + state.defines.max_bureaucracy_percentage;
246 auto non_colonial = state.world.nation_get_non_colonial_population(ids);
248 (admin_mod + 1.0f) * state.world.nation_get_non_colonial_bureaucrats(ids) / (non_colonial * from_issues), 0.0f);
250 state.world.nation_set_administrative_efficiency(ids, ve::min(total, 1.0f));
260 auto rp_mod_mod = state.world.nation_get_modifier_values(n, sys::national_mod_offsets::research_points_modifier);
261 auto rp_mod = state.world.nation_get_modifier_values(n, sys::national_mod_offsets::research_points);
263 float sum_from_pops = 0;
265 if(total_pop <= 0.0f)
268 state.world.for_each_pop_type([&](dcon::pop_type_id t) {
269 auto rp = state.world.pop_type_get_research_points(t);
271 sum_from_pops += rp * std::min(1.0f, state.world.nation_get_demographics(n,
demographics::to_key(state, t)) /
272 (total_pop * state.world.pop_type_get_research_optimum(t)));
276 return std::max(0.0f, (sum_from_pops + rp_mod) * (rp_mod_mod + 1.0f));
285 state.world.execute_serial_over_nation([&](
auto ids) {
286 auto rp_mod_mod = state.world.nation_get_modifier_values(ids, sys::national_mod_offsets::research_points_modifier);
287 auto rp_mod = state.world.nation_get_modifier_values(ids, sys::national_mod_offsets::research_points);
289 ve::fp_vector sum_from_pops;
292 state.world.for_each_pop_type([&](dcon::pop_type_id t) {
293 auto rp = state.world.pop_type_get_research_points(t);
295 sum_from_pops = ve::multiply_and_add(rp,
297 (total_pop * state.world.pop_type_get_research_optimum(t))),
301 auto amount =
ve::select(total_pop > 0.0f && state.world.nation_get_owned_province_count(ids) != 0,
302 ve::max((sum_from_pops + rp_mod) * (rp_mod_mod + 1.0f), 0.0f), 0.0f);
307 auto current_points = state.world.nation_get_research_points(ids);
308 auto capped_value = ve::min(amount + current_points,
309 ve::select(state.world.nation_get_is_civilized(ids),
ve::select(state.world.nation_get_current_research(ids) == dcon::technology_id{}, amount * 365.0f, amount + current_points), state.defines.max_research_points));
310 state.world.nation_set_research_points(ids, capped_value);
316 for(
auto i : state.world.nation_get_unilateral_relationship_as_target(n)) {
317 v += i.get_foreign_investment();
324 for(
auto i : state.world.nation_get_unilateral_relationship_as_source(n)) {
325 v += i.get_foreign_investment();
338 state.world.for_each_nation([&, iweight = state.defines.investment_score_factor](dcon::nation_id n) {
340 if(state.world.nation_get_owned_province_count(n) != 0) {
341 for(auto si : state.world.nation_get_state_ownership(n)) {
342 float total_level = 0;
344 si.get_state().get_demographics(demographics::to_employment_key(state, state.culture_definitions.primary_factory_worker)) +
345 si.get_state().get_demographics(demographics::to_employment_key(state, state.culture_definitions.secondary_factory_worker));
347 float total_factory_capacity = 0;
348 province::for_each_province_in_state_instance(state, si.get_state(), [&](dcon::province_id p) {
349 for(auto f : state.world.province_get_factory_location(p)) {
350 total_factory_capacity +=
351 float(f.get_factory().get_level() * f.get_factory().get_building_type().get_base_workforce());
352 total_level += float(f.get_factory().get_level());
355 if(total_factory_capacity > 0)
356 sum += 4.0f * total_level * std::max(std::min(1.0f, worker_total / total_factory_capacity), 0.05f);
358 sum += nations::get_foreign_investment_as_gp(state, n) * iweight;
361 float old_score = state.world.nation_get_industrial_score(n);
363 state.world.nation_set_industrial_score(n, uint16_t(sum));
365 state.world.nation_set_industrial_score(n, uint16_t(0.1f * sum + 0.9f * old_score));
384 float lp_factor = state.defines.alice_military_score_leadership_factor;
385 state.world.execute_serial_over_nation([&, disarm = state.defines.disarmament_army_hit](
auto n) {
386 auto recruitable = ve::to_float(state.world.nation_get_recruitable_regiments(n));
387 auto active_regs = ve::to_float(state.world.nation_get_active_regiments(n));
388 auto is_disarmed = ve::apply([&](dcon::nation_id i) { return state.world.nation_get_disarmed_until(i) < state.current_date; }, n);
389 auto disarm_factor =
ve::select(is_disarmed, ve::fp_vector(disarm), ve::fp_vector(1.0f));
390 auto supply_mod = ve::max(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::supply_consumption) + 1.0f, 0.1f);
391 auto avg_land_score = state.world.nation_get_averge_land_unit_score(n);
392 state.world.nation_set_military_score(n,
ve::to_int((ve::min(recruitable, active_regs * 4.0f) * avg_land_score) * ((disarm_factor * supply_mod) / 7.0f) + state.world.nation_get_capital_ship_score(n) + active_regs));
397 return std::max(0.0f, state.world.nation_get_prestige(n) +
398 state.world.nation_get_modifier_values(n, sys::national_mod_offsets::permanent_prestige));
403 state.world.for_each_nation([&](dcon::nation_id n) {
404 state.nations_by_rank[to_sort_count] = n;
407 std::sort(state.nations_by_rank.begin(), state.nations_by_rank.begin() + to_sort_count,
408 [&](dcon::nation_id a, dcon::nation_id b) {
409 auto fa = fatten(state.world, a);
410 auto fb = fatten(state.world, b);
411 if((fa.get_owned_province_count() != 0) != (fb.get_owned_province_count() != 0)) {
412 return (fa.get_owned_province_count() != 0);
414 if(fa.get_is_civilized() != fb.get_is_civilized())
415 return fa.get_is_civilized();
416 if(
bool(fa.get_overlord_as_subject().get_ruler()) !=
bool(fa.get_overlord_as_subject().get_ruler()))
417 return !
bool(fa.get_overlord_as_subject().get_ruler());
418 auto a_score = fa.get_military_score() + fa.get_industrial_score() +
prestige_score(state, a);
419 auto b_score = fb.get_military_score() + fb.get_industrial_score() +
prestige_score(state, b);
420 if(a_score != b_score)
421 return a_score > b_score;
422 return a.index() > b.index();
424 if(to_sort_count < state.nations_by_rank.size()) {
425 state.nations_by_rank[to_sort_count] = dcon::nation_id{};
427 for(
uint32_t i = 0; i < to_sort_count; ++i) {
428 state.world.nation_set_rank(
state.nations_by_rank[i], uint16_t(i + 1));
434 state.world.for_each_nation([&](dcon::nation_id n) {
435 if(state.world.nation_get_owned_province_count(n) != 0) {
436 state.nations_by_industrial_score[to_sort_count] = n;
437 state.nations_by_military_score[to_sort_count] = n;
438 state.nations_by_prestige_score[to_sort_count] = n;
442 std::sort(state.nations_by_industrial_score.begin(), state.nations_by_industrial_score.begin() + to_sort_count,
443 [&](dcon::nation_id a, dcon::nation_id b) {
444 auto fa = fatten(state.world, a);
445 auto fb = fatten(state.world, b);
446 if(fa.get_is_civilized() && !fb.get_is_civilized())
448 if(!fa.get_is_civilized() && fb.get_is_civilized())
450 if(bool(fa.get_overlord_as_subject()) && !bool(fa.get_overlord_as_subject()))
452 if(!bool(fa.get_overlord_as_subject()) && bool(fa.get_overlord_as_subject()))
454 auto a_score = fa.get_industrial_score();
455 auto b_score = fb.get_industrial_score();
456 if(a_score != b_score)
457 return a_score > b_score;
458 return a.index() > b.index();
460 std::sort(state.nations_by_military_score.begin(), state.nations_by_military_score.begin() + to_sort_count,
461 [&](dcon::nation_id a, dcon::nation_id b) {
462 auto fa = fatten(state.world, a);
463 auto fb = fatten(state.world, b);
464 if(fa.get_is_civilized() && !fb.get_is_civilized())
466 if(!fa.get_is_civilized() && fb.get_is_civilized())
468 if(bool(fa.get_overlord_as_subject()) && !bool(fa.get_overlord_as_subject()))
470 if(!bool(fa.get_overlord_as_subject()) && bool(fa.get_overlord_as_subject()))
472 auto a_score = fa.get_military_score();
473 auto b_score = fb.get_military_score();
474 if(a_score != b_score)
475 return a_score > b_score;
476 return a.index() > b.index();
478 std::sort(state.nations_by_prestige_score.begin(), state.nations_by_prestige_score.begin() + to_sort_count,
479 [&](dcon::nation_id a, dcon::nation_id b) {
480 auto fa = fatten(state.world, a);
481 auto fb = fatten(state.world, b);
482 if(fa.get_is_civilized() && !fb.get_is_civilized())
484 if(!fa.get_is_civilized() && fb.get_is_civilized())
486 if(bool(fa.get_overlord_as_subject()) && !bool(fa.get_overlord_as_subject()))
488 if(!bool(fa.get_overlord_as_subject()) && bool(fa.get_overlord_as_subject()))
490 auto a_score = prestige_score(state, a);
491 auto b_score = prestige_score(state, b);
492 if(a_score != b_score)
493 return a_score > b_score;
494 return a.index() > b.index();
496 for(
uint32_t i = 0; i < to_sort_count; ++i) {
497 state.world.nation_set_industrial_rank(state.nations_by_industrial_score[i], uint16_t(i + 1));
498 state.world.nation_set_military_rank(state.nations_by_military_score[i], uint16_t(i + 1));
499 state.world.nation_set_prestige_rank(state.nations_by_prestige_score[i], uint16_t(i + 1));
504 return state.world.nation_get_is_great_power(
id);
508 bool at_least_one_added =
false;
510 for(
auto i = state.great_nations.size(); i-- > 0;) {
511 if(state.world.nation_get_rank(state.great_nations[i].nation) <= uint16_t(state.defines.great_nations_count)) {
513 state.great_nations[i].last_greatness = state.current_date;
514 }
else if(state.great_nations[i].last_greatness + int32_t(state.defines.greatness_days) < state.current_date ||
515 state.world.nation_get_owned_province_count(state.great_nations[i].nation) == 0) {
517 auto n = state.great_nations[i].nation;
518 state.great_nations[i] = state.great_nations.back();
519 state.great_nations.pop_back();
520 at_least_one_added =
true;
522 state.world.nation_set_is_great_power(n,
false);
528 auto rels = state.world.nation_get_gp_relationship_as_great_power(n);
529 while(rels.begin() != rels.end()) {
530 auto rel = *(rels.begin());
531 if(rel.get_influence_target().get_in_sphere_of() == n)
532 rel.get_influence_target().set_in_sphere_of(dcon::nation_id{});
533 state.world.delete_gp_relationship(rel);
541 n, dcon::nation_id{}, dcon::nation_id{},
547 for(
uint32_t i = 0; i <
uint32_t(state.defines.great_nations_count) && state.great_nations.size() < size_t(state.defines.great_nations_count); ++i) {
548 auto n = state.nations_by_rank[i];
549 if(n && !state.world.nation_get_is_great_power(n) && state.world.nation_get_owned_province_count(n) > 0) {
550 at_least_one_added =
true;
551 state.world.nation_set_is_great_power(n,
true);
553 state.world.nation_set_state_from_flashpoint_focus(n, dcon::state_instance_id{});
555 state.world.nation_set_in_sphere_of(n, dcon::nation_id{});
556 auto rng = state.world.nation_get_gp_relationship_as_influence_target(n);
557 while(
rng.begin() !=
rng.end()) {
558 state.world.delete_gp_relationship(*(
rng.begin()));
568 n, dcon::nation_id{}, dcon::nation_id{},
573 if(at_least_one_added) {
575 return state.world.nation_get_rank(a.nation) < state.world.nation_get_rank(b.nation);
582 return status::great_power;
583 }
else if(state.world.nation_get_rank(n) <= uint16_t(state.defines.colonial_rank)) {
584 return status::secondary_power;
585 }
else if(state.world.nation_get_is_civilized(n)) {
586 return status::civilized;
588 auto civ_progress = state.world.nation_get_modifier_values(n, sys::national_mod_offsets::civilization_progress_modifier);
589 if(civ_progress < 0.15f) {
590 return status::primitive;
591 }
else if(civ_progress < 0.5f) {
592 return status::uncivilized;
594 return status::westernizing;
602 auto total = int32_t((
culture::effective_technology_cost(state, curr.to_ymd(state.start_date).year, n, tech_id) - state.world.nation_get_research_points(n)) / daily);
607 return state.world.nation_get_current_research(n);
611 return state.world.nation_get_suppression_points(n);
615 return state.world.nation_get_leadership_points(n);
624 state.world.nation_get_demographics(n,
demographics::to_key(state, state.world.nation_get_primary_culture(n)));
625 for(
auto ac : state.world.in_culture) {
626 if(state.world.nation_get_accepted_cultures(n, ac))
630 return std::max(1, std::min(int32_t(relevant_pop / state.defines.national_focus_divider),
631 int32_t(1 + state.world.nation_get_modifier_values(n, sys::national_mod_offsets::max_national_focus))));
636 if(state.world.nation_get_state_from_flashpoint_focus(n))
638 for(
auto si : state.world.nation_get_state_ownership(n)) {
639 if(si.get_state().get_owner_focus())
646 return state.world.nation_get_diplomatic_points(n);
650 auto bmod = state.world.nation_get_modifier_values(n, sys::national_mod_offsets::diplomatic_points_modifier) + 1.0f;
651 auto dmod = bmod * state.defines.base_monthly_diplopoints;
661 int32_t unit_sum = 0;
662 for(
auto nv : state.world.nation_get_navy_control(n)) {
663 for(
auto shp : nv.get_navy().get_navy_membership()) {
664 unit_sum += state.military_definitions.unit_base_definitions[shp.get_ship().get_type()].colonial_points;
669 float pts_factor = used_supply > base_supply ? std::max(0.0f, 2.0f - used_supply / base_supply) : 1.0f;
670 points += unit_sum * pts_factor * state.defines.colonial_points_from_supply_factor;
681 for(
auto p : state.world.nation_get_province_ownership(n)) {
684 if(p.get_province().get_connected_region_id() == state.world.province_get_connected_region_id(state.world.nation_get_capital(n))
685 || p.get_province().get_is_owner_core()) {
686 if(p.get_province().get_is_owner_core()) {
689 points += state.defines.colonial_points_for_non_core_base;
697 for(
auto si : state.world.nation_get_state_ownership(n)) {
698 auto scap = si.get_state().get_capital();
699 if(scap.get_connected_region_id() != state.world.province_get_connected_region_id(state.world.nation_get_capital(n))) {
710 state.world.for_each_technology([&](dcon::technology_id t) {
711 if(state.world.nation_get_active_technologies(n, t))
712 points +=
float(state.world.technology_get_colonial_points(t));
722 for(
auto col : state.world.nation_get_colonization_as_colonizer(n)) {
723 points += float(col.get_points_invested());
729 for(
auto prov : state.world.nation_get_province_ownership(n)) {
730 if(prov.get_province().get_is_colonial()) {
731 points += state.defines.colonization_colony_province_maintainance;
751 if(state.world.nation_get_rank(n) <= state.defines.colonial_rank) {
760 for(
auto cols : state.world.nation_get_colonization_as_colonizer(n)) {
761 auto state_colonization = state.world.state_definition_get_colonization(cols.get_state());
762 auto num_colonizers = state_colonization.end() - state_colonization.begin();
763 if(cols.get_state().get_colonization_stage() ==
uint8_t(3)) {
775 for(
auto cols : state.world.nation_get_colonization_as_colonizer(n)) {
776 auto lvl = cols.get_level();
777 for(
auto ocol : state.world.state_definition_get_colonization(cols.get_state())) {
778 if(lvl < ocol.get_level())
786 for(
auto it : state.world.nation_get_gp_relationship_as_great_power(n)) {
787 if((it.get_status() & influence::is_banned) == 0) {
788 if(it.get_influence() >= state.defines.increaseopinion_influence_cost
789 && (influence::level_mask & it.get_status()) != influence::level_in_sphere
790 && (influence::level_mask & it.get_status()) != influence::level_friendly) {
792 }
else if(!(it.get_influence_target().get_in_sphere_of()) &&
793 it.get_influence() >= state.defines.addtosphere_influence_cost) {
795 }
else if(it.get_influence_target().get_in_sphere_of() &&
796 (influence::level_mask & it.get_status()) == influence::level_friendly &&
797 it.get_influence() >= state.defines.removefromsphere_influence_cost) {
806 for(
auto i : state.culture_definitions.political_issues) {
807 auto current = state.world.nation_get_issues(n, i);
808 for(
auto o : state.world.issue_get_options(i)) {
818 for(
auto i : state.culture_definitions.social_issues) {
819 auto current = state.world.nation_get_issues(n, i);
820 for(
auto o : state.world.issue_get_options(i)) {
832 auto last_date = state.world.nation_get_last_issue_or_reform_change(n);
833 if(
bool(last_date) && (last_date + int32_t(state.defines.min_delay_between_reforms * 30.0f)) > state.current_date)
836 if(state.world.nation_get_is_civilized(n)) {
857 auto stored_rp = state.world.nation_get_research_points(n);
858 for(
auto i : state.culture_definitions.military_issues) {
859 auto current = state.world.nation_get_reforms(n, i);
860 for(
auto o : state.world.reform_get_options(i)) {
866 for(
auto i : state.culture_definitions.economic_issues) {
867 auto current = state.world.nation_get_reforms(n, i);
868 for(
auto o : state.world.reform_get_options(i)) {
878bool has_decision_available(
sys::state& state, dcon::nation_id n) {
879 for(
uint32_t i = state.world.decision_size(); i-- > 0;) {
880 dcon::decision_id did{dcon::decision_id::value_base_t(i)};
881 if(!state.world.decision_get_hide_notification(did)) {
882 auto lim = state.world.decision_get_potential(did);
884 auto allow = state.world.decision_get_allow(did);
894void get_active_political_parties(
sys::state& state, dcon::nation_id n, std::vector<dcon::political_party_id>& parties) {
895 auto identity = state.world.nation_get_identity_from_identity_holder(n);
896 auto start = state.world.national_identity_get_political_party_first(identity).id.index();
897 auto end = start + state.world.national_identity_get_political_party_count(identity);
898 for(int32_t i = start; i < end; i++) {
899 auto pid = dcon::political_party_id(uint16_t(i));
901 parties.push_back(pid);
906void monthly_adjust_relationship(
sys::state& state, dcon::nation_id a, dcon::nation_id b,
float delta) {
907 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(a, b);
909 rel = state.world.force_create_diplomatic_relation(a, b);
911 auto&
val =
state.world.diplomatic_relation_get_value(rel);
912 val = std::clamp(val + delta, -200.0f, std::max(val, 100.0f));
921 for(
auto n : state.world.in_nation) {
922 auto owned = n.get_province_ownership();
923 if(owned.begin() != owned.end()) {
924 auto pc = n.get_primary_culture();
925 int32_t total_num_cores = 0;
927 for(
auto core : n.get_identity_from_identity_holder().get_core()) {
929 if(core.get_province().get_nation_from_province_ownership() != n) {
930 if(core.get_province().get_dominant_culture() == pc)
936 if(total_num_cores > 0) {
937 n.set_revanchism(rpts /
float(total_num_cores));
939 n.set_revanchism(0.0f);
945void update_monthly_points(
sys::state& state) {
962 state.world.execute_serial_over_nation([&](
auto ids) {
963 auto imod = state.world.nation_get_modifier_values(ids, sys::national_mod_offsets::badboy);
964 state.world.nation_set_infamy(ids, ve::max(state.world.nation_get_infamy(ids) + imod, 0.0f));
970 state.world.execute_serial_over_nation([&](
auto ids) {
971 auto wmod =
state.world.nation_get_modifier_values(ids, sys::national_mod_offsets::war_exhaustion);
972 auto wmax_mod =
state.world.nation_get_modifier_values(ids, sys::national_mod_offsets::max_war_exhaustion);
973 state.world.nation_set_war_exhaustion(ids,
974 ve::max(ve::min(
state.world.nation_get_war_exhaustion(ids) + wmod, wmax_mod), 0.0f));
979 state.world.execute_serial_over_nation([&](
auto ids) {
982 state.world.nation_set_plurality(ids, ve::max(ve::min(
state.world.nation_get_plurality(ids) + pmod, 100.0f), 0.f));
988 state.world.execute_serial_over_nation([&](
auto ids) {
989 auto bmod =
state.world.nation_get_modifier_values(ids, sys::national_mod_offsets::diplomatic_points_modifier) + 1.0f;
990 auto dmod = bmod *
state.defines.base_monthly_diplopoints;
992 state.world.nation_set_diplomatic_points(ids, ve::max(ve::min(
state.world.nation_get_diplomatic_points(ids) + dmod, 9.0f), 0.f));
999 state.world.execute_serial_over_nation([&](
auto ids) {
1000 auto bmod = (
state.world.nation_get_modifier_values(ids, sys::national_mod_offsets::suppression_points_modifier) + 1.0f);
1001 auto cmod = (bmod *
state.defines.suppression_points_gain_base) *
1004 state.defines.suppress_bureaucrat_factor);
1006 state.world.nation_set_suppression_points(ids, ve::max(ve::min(
state.world.nation_get_suppression_points(ids) + cmod,
state.defines.max_suppression), 0.f));
1013 for(
auto so :
state.world.in_overlord) {
1016 for(
auto an :
state.world.in_nation_adjacency) {
1017 if(an.get_connected_nations(0).get_is_at_war() ==
false && an.get_connected_nations(1).get_is_at_war() ==
false)
1026 for(
auto i :
state.world.in_unilateral_relationship) {
1027 if(i.get_military_access()) {
1031 for(
auto w :
state.world.in_war) {
1032 for(
auto n : w.get_war_participant()) {
1033 for(
auto m : w.get_war_participant()) {
1034 if(
n.get_is_attacker() !=
m.get_is_attacker()) {
1044float get_treasury(
sys::state& state, dcon::nation_id n) {
1048float get_bank_funds(
sys::state& state, dcon::nation_id n) {
1052float get_debt(
sys::state& state, dcon::nation_id n) {
1054 return v < 0.0f ? -v : 0.0f;
1057float tariff_efficiency(
sys::state& state, dcon::nation_id n) {
1058 auto eff_mod = state.world.nation_get_modifier_values(n, sys::national_mod_offsets::tariff_efficiency_modifier);
1059 auto adm_eff = state.world.nation_get_administrative_efficiency(n);
1060 return std::clamp(state.defines.base_tariff_efficiency + eff_mod + adm_eff, 0.01f, 1.f);
1063float tax_efficiency(
sys::state& state, dcon::nation_id n) {
1064 auto eff_mod = state.world.nation_get_modifier_values(n, sys::national_mod_offsets::tax_efficiency);
1065 return std::clamp(state.defines.base_country_tax_efficiency + eff_mod, 0.1f, 1.f);
1068bool is_involved_in_crisis(
sys::state const& state, dcon::nation_id n) {
1069 if(n == state.primary_crisis_attacker)
1071 if(n == state.primary_crisis_defender)
1073 for(
auto& par : state.crisis_participants) {
1082bool is_committed_in_crisis(
sys::state const& state, dcon::nation_id n) {
1083 if(n == state.primary_crisis_attacker)
1085 if(n == state.primary_crisis_defender)
1087 for(
auto& par : state.crisis_participants) {
1091 return !par.merely_interested;
1096void adjust_relationship(
sys::state& state, dcon::nation_id a, dcon::nation_id b,
float delta) {
1097 if(state.world.nation_get_owned_province_count(a) == 0 || state.world.nation_get_owned_province_count(a) == 0)
1100 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(a, b);
1102 rel = state.world.force_create_diplomatic_relation(a, b);
1104 auto&
val =
state.world.diplomatic_relation_get_value(rel);
1105 val = std::clamp(val + delta, -200.0f, 200.0f);
1108void create_nation_based_on_template(
sys::state& state, dcon::nation_id n, dcon::nation_id base) {
1109 state.world.nation_set_is_civilized(n, state.world.nation_get_is_civilized(base));
1110 state.world.nation_set_national_value(n, state.world.nation_get_national_value(base));
1111 state.world.nation_set_tech_school(n, state.world.nation_get_tech_school(base));
1112 state.world.nation_set_government_type(n, state.world.nation_get_government_type(base));
1113 state.world.nation_set_plurality(n, state.world.nation_get_plurality(base));
1114 state.world.nation_set_prestige(n, 0.0f);
1115 state.world.nation_set_infamy(n, 0.0f);
1116 state.world.nation_set_revanchism(n, 0.0f);
1117 state.world.for_each_technology([&](dcon::technology_id t) {
1118 state.world.nation_set_active_technologies(n, t, state.world.nation_get_active_technologies(base, t));
1120 state.world.for_each_invention([&](dcon::invention_id t) {
1121 state.world.nation_set_active_inventions(n, t,
state.world.nation_get_active_inventions(base, t));
1123 state.world.for_each_issue(
1124 [&](dcon::issue_id t) {
state.world.nation_set_issues(n, t,
state.world.nation_get_issues(base, t)); });
1125 if(!
state.world.nation_get_is_civilized(base)) {
1126 state.world.for_each_reform(
1127 [&](dcon::reform_id t) {
state.world.nation_set_reforms(n, t,
state.world.nation_get_reforms(base, t)); });
1129 state.world.nation_set_last_issue_or_reform_change(n,
sys::date{});
1131 state.world.for_each_ideology(
1132 [&](dcon::ideology_id i) {
state.world.nation_set_upper_house(n, i,
state.world.nation_get_upper_house(base, i)); });
1133 state.world.nation_set_is_substate(n,
false);
1140 state.world.for_each_commodity([&](dcon::commodity_id t) {
1141 state.world.nation_set_rgo_goods_output(n, t,
state.world.nation_get_rgo_goods_output(base, t));
1142 state.world.nation_set_factory_goods_output(n, t,
state.world.nation_get_factory_goods_output(base, t));
1143 state.world.nation_set_rgo_size(n, t,
state.world.nation_get_rgo_size(base, t));
1144 state.world.nation_set_factory_goods_throughput(n, t,
state.world.nation_get_factory_goods_throughput(base, t));
1146 state.world.for_each_rebel_type([&](dcon::rebel_type_id t) {
1147 state.world.nation_set_rebel_org_modifier(n, t,
state.world.nation_get_rebel_org_modifier(base, t));
1149 for(
uint32_t i = 0; i <
state.military_definitions.unit_base_definitions.size(); ++i) {
1150 state.world.nation_set_unit_stats(n, dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)},
1151 state.world.nation_get_unit_stats(base, dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)}));
1152 state.world.nation_set_active_unit(n, dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)},
1153 state.world.nation_get_active_unit(base, dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)}));
1155 for(
uint32_t i = 0; i <
state.culture_definitions.crimes.size(); ++i) {
1156 state.world.nation_set_active_crime(n, dcon::crime_id{dcon::crime_id::value_base_t(i)},
1157 state.world.nation_get_active_crime(base, dcon::crime_id{dcon::crime_id::value_base_t(i)}));
1159 state.world.for_each_factory_type([&](dcon::factory_type_id t) {
1160 state.world.nation_set_active_building(n, t,
state.world.nation_get_active_building(base, t));
1162 state.world.nation_set_has_gas_attack(n,
state.world.nation_get_has_gas_attack(base));
1163 state.world.nation_set_has_gas_defense(n,
state.world.nation_get_has_gas_defense(base));
1165 state.world.nation_set_max_building_level(n,
uint8_t(t),
state.world.nation_get_max_building_level(base,
uint8_t(t)));
1168 state.world.nation_set_education_spending(n, int8_t(100));
1169 state.world.nation_set_military_spending(n, int8_t(100));
1170 state.world.nation_set_administrative_spending(n, int8_t(100));
1171 state.world.nation_set_social_spending(n, int8_t(100));
1172 state.world.nation_set_land_spending(n, int8_t(100));
1173 state.world.nation_set_naval_spending(n, int8_t(100));
1174 state.world.nation_set_construction_spending(n, int8_t(100));
1175 state.world.nation_set_effective_land_spending(n, 1.0f);
1176 state.world.nation_set_effective_naval_spending(n, 1.0f);
1177 state.world.nation_set_effective_construction_spending(n, 1.0f);
1178 state.world.nation_set_spending_level(n, 1.0f);
1179 state.world.nation_set_poor_tax(n, int8_t(50));
1180 state.world.nation_set_middle_tax(n, int8_t(50));
1181 state.world.nation_set_rich_tax(n, int8_t(50));
1182 state.world.nation_set_tariffs(n, int8_t(0));
1184 auto base_ruling_ideology =
state.world.political_party_get_ideology(
state.world.nation_get_ruling_party(base));
1186 auto identity =
state.world.nation_get_identity_from_identity_holder(n);
1187 auto start =
state.world.national_identity_get_political_party_first(identity).id.index();
1188 auto end = start +
state.world.national_identity_get_political_party_count(identity);
1190 for(int32_t i = start; i < end; i++) {
1191 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(i));
1193 state.world.nation_set_ruling_party(n, pid);
1197 if(!
state.world.nation_get_ruling_party(n)) {
1198 for(int32_t i = start; i < end; i++) {
1199 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(i));
1201 state.world.nation_set_ruling_party(n, pid);
1209 state.world.nation_set_primary_culture(n,
tag.get_primary_culture());
1210 state.world.nation_set_religion(n,
tag.get_religion());
1211 if(
auto cg =
tag.get_culture_group_from_cultural_union_of(); cg) {
1212 for(
auto c : cg.get_culture_group_membership()) {
1213 if(c.get_member().id !=
tag.get_primary_culture().id) {
1214 state.world.nation_set_accepted_cultures(n, c.get_member(),
true);
1224 for(
const auto n : state.world.in_nation) {
1225 if(n.get_marked_for_gc()) {
1226 n.set_marked_for_gc(
false);
1227 if(
auto lprovs = n.get_province_ownership(); lprovs.begin() == lprovs.end()) {
1232 if(
state.national_definitions.gc_pending) {
1233 state.national_definitions.gc_pending =
false;
1234 for(
uint32_t i =
state.world.rebel_faction_size(); i-- > 0; ) {
1235 dcon::rebel_faction_id rf{dcon::rebel_faction_id::value_base_t(i) };
1236 auto within =
state.world.rebel_faction_get_ruler_from_rebellion_within(rf);
1238 state.world.delete_rebel_faction(rf);
1243void cleanup_nation(
sys::state& state, dcon::nation_id n) {
1244 auto old_ident = state.world.nation_get_identity_from_identity_holder(n);
1246 auto control = state.world.nation_get_province_control(n);
1247 while(control.begin() != control.end()) {
1251 auto leaders =
state.world.nation_get_leader_loyalty(n);
1252 while(leaders.begin() != leaders.end()) {
1253 state.world.delete_leader((*leaders.begin()).get_leader());
1256 auto ss_range =
state.world.nation_get_overlord_as_ruler(n);
1257 while(ss_range.begin() != ss_range.end()) {
1258 auto subj = (*ss_range.begin()).get_subject();
1259 subj.set_is_substate(
false);
1263 auto ol =
state.world.nation_get_overlord_as_subject(n);
1264 if(
state.world.overlord_get_ruler(ol)) {
1283 auto diprel =
state.world.nation_get_diplomatic_relation(n);
1284 while(diprel.begin() != diprel.end()) {
1285 state.world.delete_diplomatic_relation(*diprel.begin());
1288 auto uni_diprel =
state.world.nation_get_unilateral_relationship_as_source(n);
1289 while(uni_diprel.begin() != uni_diprel.end()) {
1290 state.world.delete_unilateral_relationship(*uni_diprel.begin());
1293 auto uni_diprelb =
state.world.nation_get_unilateral_relationship_as_target(n);
1294 while(uni_diprelb.begin() != uni_diprelb.end()) {
1295 state.world.delete_unilateral_relationship(*uni_diprelb.begin());
1300 state.world.delete_movement((*
movements.begin()).get_movement());
1304 state.world.delete_nation(n);
1305 auto new_ident_holder =
state.world.create_nation();
1306 state.world.try_create_identity_holder(new_ident_holder, old_ident);
1308 for(
auto o :
state.world.in_nation) {
1309 if(o.get_in_sphere_of() == n) {
1314 "msg_rem_sphere_title",
1315 n, o, dcon::nation_id{},
1318 o.set_in_sphere_of(dcon::nation_id{});
1322 state.national_definitions.gc_pending =
true;
1323 state.diplomatic_cached_values_out_of_date =
true;
1326 if(n ==
state.local_player_nation) {
1332void adjust_prestige(
sys::state& state, dcon::nation_id n,
float delta) {
1333 float prestige_multiplier = 1.0f + state.world.nation_get_modifier_values(n, sys::national_mod_offsets::prestige);
1334 float v = state.world.nation_get_prestige(n) + (delta > 0 ? (delta * prestige_multiplier) : delta);
1335 float new_prestige = std::clamp(v, 0.f, max_prestige);
1336 state.world.nation_set_prestige(n, new_prestige);
1339bool destroy_vassal_relationships(
sys::state& state, dcon::nation_id n) {
1340 auto ov_rel = state.world.nation_get_overlord_as_ruler(n);
1341 for(
auto it = ov_rel.begin(); it != ov_rel.end(); ++it) {
1342 if((*it).get_subject().get_is_substate() ==
false) {
1343 release_vassal(state, *it);
1350void destroy_diplomatic_relationships(
sys::state& state, dcon::nation_id n) {
1352 auto gp_relationships = state.world.nation_get_gp_relationship_as_great_power(n);
1353 while(gp_relationships.begin() != gp_relationships.end()) {
1354 auto i = (*gp_relationships.begin()).get_influence_target();
1355 if(i.get_in_sphere_of() == n)
1356 i.set_in_sphere_of(dcon::nation_id{});
1357 state.world.delete_gp_relationship(*(gp_relationships.begin()));
1361 auto gp_relationships =
state.world.nation_get_gp_relationship_as_influence_target(n);
1362 while(gp_relationships.begin() != gp_relationships.end()) {
1363 state.world.delete_gp_relationship(*(gp_relationships.begin()));
1365 state.world.nation_set_in_sphere_of(n, dcon::nation_id{});
1368 for(
auto rel :
state.world.nation_get_diplomatic_relation(n)) {
1373 auto ov_rel =
state.world.nation_get_overlord_as_ruler(n);
1374 bool released_vassal =
true;
1375 while(released_vassal) {
1381 auto vas =
state.world.overlord_get_subject(
rel);
1382 auto ol =
state.world.overlord_get_ruler(
rel);
1384 if(
state.world.nation_get_is_substate(vas)) {
1385 state.world.nation_set_is_substate(vas,
false);
1386 state.world.nation_get_substates_count(ol)--;
1388 state.world.nation_get_vassals_count(ol)--;
1389 state.world.delete_overlord(rel);
1395void make_vassal(
sys::state& state, dcon::nation_id subject, dcon::nation_id overlord) {
1396 if(subject == overlord)
1398 if(state.world.nation_get_owned_province_count(subject) == 0 || state.world.nation_get_owned_province_count(overlord) == 0)
1401 auto current_ol = state.world.nation_get_overlord_as_subject(subject);
1402 auto current_ruler = state.world.overlord_get_ruler(current_ol);
1404 if(current_ruler && current_ruler != overlord) {
1405 release_vassal(state, current_ol);
1407 if(current_ruler == overlord) {
1408 if(
state.world.nation_get_is_substate(subject)) {
1409 state.world.nation_set_is_substate(subject,
false);
1410 state.world.nation_get_substates_count(current_ruler)--;
1413 state.world.force_create_overlord(subject, overlord);
1414 state.world.nation_get_vassals_count(overlord)++;
1421 if(
state.world.nation_get_owned_province_count(subject) == 0 ||
state.world.nation_get_owned_province_count(
overlord) == 0)
1424 auto current_ol =
state.world.nation_get_overlord_as_subject(subject);
1425 auto current_ruler =
state.world.overlord_get_ruler(current_ol);
1427 if(current_ruler && current_ruler !=
overlord) {
1430 if(current_ruler == overlord) {
1431 if(!
state.world.nation_get_is_substate(subject)) {
1432 state.world.nation_set_is_substate(subject,
true);
1433 state.world.nation_get_substates_count(current_ruler)++;
1436 state.world.force_create_overlord(subject, overlord);
1437 state.world.nation_set_is_substate(subject,
true);
1438 state.world.nation_get_vassals_count(overlord)++;
1439 state.world.nation_get_substates_count(current_ruler)++;
1444void break_alliance(
sys::state& state, dcon::diplomatic_relation_id rel) {
1445 if(state.world.diplomatic_relation_get_are_allied(rel)) {
1446 state.world.diplomatic_relation_set_are_allied(rel,
false);
1447 state.world.nation_get_allies_count(state.world.diplomatic_relation_get_related_nations(rel, 0))--;
1448 state.world.nation_get_allies_count(state.world.diplomatic_relation_get_related_nations(rel, 1))--;
1452void break_alliance(
sys::state& state, dcon::nation_id a, dcon::nation_id b) {
1453 if(
auto r = state.world.get_diplomatic_relation_by_diplomatic_pair(a, b); r) {
1454 if(state.world.diplomatic_relation_get_are_allied(r)) {
1455 break_alliance(state, r);
1456 if(a != state.local_player_nation) {
1461 "msg_alliance_ends_title",
1462 a, b, dcon::nation_id{},
1472 auto r =
state.world.get_diplomatic_relation_by_diplomatic_pair(a, b);
1474 r =
state.world.force_create_diplomatic_relation(a, b);
1476 if(!
state.world.diplomatic_relation_get_are_allied(r)) {
1477 state.world.nation_get_allies_count(a)++;
1478 state.world.nation_get_allies_count(b)++;
1479 state.world.diplomatic_relation_set_are_allied(r,
true);
1482 if(a !=
state.local_player_nation && b !=
state.local_player_nation) {
1487 "msg_alliance_starts_title",
1488 a, b, dcon::nation_id{},
1494bool other_nation_is_influencing(
sys::state& state, dcon::nation_id target, dcon::gp_relationship_id rel) {
1495 for(
auto orel : state.world.nation_get_gp_relationship_as_influence_target(target)) {
1496 if(orel != rel && orel.get_influence() > 0.0f)
1502bool can_accumulate_influence_with(
sys::state& state, dcon::nation_id gp, dcon::nation_id target, dcon::gp_relationship_id rel) {
1503 if((state.world.gp_relationship_get_status(rel) & influence::is_banned) != 0)
1509 if(state.world.gp_relationship_get_influence(rel) >= state.defines.max_influence
1510 && !other_nation_is_influencing(state, target, rel))
1515float get_base_shares(
sys::state& state, dcon::gp_relationship_id gp,
float total_gain, int32_t total_influence_shares) {
1516 if(total_influence_shares == 0)
1518 switch(state.world.gp_relationship_get_status(gp) & influence::priority_mask) {
1519 case influence::priority_one:
1520 return total_gain / float(total_influence_shares);
1521 case influence::priority_two:
1522 return 2.0f * total_gain / float(total_influence_shares);
1523 case influence::priority_three:
1524 return 3.0f * total_gain / float(total_influence_shares);
1526 case influence::priority_zero:
1531bool has_sphere_neighbour(
sys::state& state, dcon::nation_id n, dcon::nation_id target) {
1532 for(
auto g : state.world.nation_get_nation_adjacency(target)) {
1533 if(g.get_connected_nations(0) != target && g.get_connected_nations(0).get_in_sphere_of() == n)
1535 if(g.get_connected_nations(1) != target && g.get_connected_nations(1).get_in_sphere_of() == n)
1542 for(
auto rel : state.world.in_gp_relationship) {
1543 if(rel.get_penalty_expires_date() == state.current_date) {
1544 rel.set_status(rel.get_status() & ~(influence::is_banned | influence::is_discredited));
1548 for(
auto& grn :
state.great_nations) {
1549 dcon::nation_fat_id
n =
fatten(
state.world, grn.nation);
1553 int32_t total_influence_shares = 0;
1554 for(
auto rel :
n.get_gp_relationship_as_great_power()) {
1556 switch(
rel.get_status() & influence::priority_mask) {
1557 case influence::priority_one:
1558 total_influence_shares += 1;
1560 case influence::priority_two:
1561 total_influence_shares += 2;
1563 case influence::priority_three:
1564 total_influence_shares += 3;
1567 case influence::priority_zero:
1573 if(total_influence_shares > 0) {
1579 float total_gain =
state.defines.base_greatpower_daily_influence *
1580 (1.0f +
n.get_modifier_values(sys::national_mod_offsets::influence_modifier)) *
1581 (1.0f +
n.get_modifier_values(sys::national_mod_offsets::influence));
1596 float gp_score =
n.get_industrial_score() +
n.get_military_score() +
prestige_score(state, n);
1598 for(
auto rel :
n.get_gp_relationship_as_great_power()) {
1600 float base_shares =
get_base_shares(state, rel, total_gain, total_influence_shares);
1601 if(base_shares <= 0.0f)
1605 auto gp_invest =
state.world.unilateral_relationship_get_foreign_investment(
1606 state.world.get_unilateral_relationship_by_unilateral_pair(
rel.get_influence_target(), n));
1608 float discredit_factor =
1609 (
rel.get_status() & influence::is_discredited) != 0 ?
state.defines.discredit_influence_gain_factor : 0.0f;
1610 float neighbor_factor =
bool(
state.world.get_nation_adjacency_by_nation_adjacency_pair(n,
rel.get_influence_target()))
1611 ?
state.defines.neighbour_bonus_influence_percent
1614 ?
state.defines.sphere_neighbour_bonus_influence_percent
1616 float continent_factor =
n.get_capital().get_continent() !=
rel.get_influence_target().get_capital().get_continent()
1617 ?
state.defines.other_continent_bonus_influence_percent
1619 float puppet_factor =
rel.get_influence_target().get_overlord_as_subject().get_ruler() ==
n
1620 ?
state.defines.puppet_bonus_influence_percent
1622 float relationship_factor =
state.world.diplomatic_relation_get_value(
state.world.get_diplomatic_relation_by_diplomatic_pair(n,
rel.get_influence_target())) /
state.defines.relation_influence_modifier;
1624 float investment_factor = total_fi > 0.0f ?
state.defines.investment_influence_defense * gp_invest / total_fi : 0.0f;
1627 ?
state.defines.large_population_influence_penalty *
1629 state.defines.large_population_influence_penalty_chunk
1631 float score_factor = gp_score > 0.0f
1632 ? std::max(1.0f - (
rel.get_influence_target().get_industrial_score() +
rel.get_influence_target().get_military_score() +
prestige_score(state,
rel.get_influence_target())) / gp_score, 0.0f)
1635 float total_multiplier = 1.0f + discredit_factor + neighbor_factor + sphere_neighbor_factor + continent_factor + puppet_factor + relationship_factor + investment_factor + pop_factor + score_factor;
1637 auto gain_amount = base_shares * total_multiplier;
1644 rel.get_influence() += std::max(0.0f, gain_amount);
1645 if(
rel.get_influence() >
state.defines.max_influence) {
1646 auto overflow =
rel.get_influence() -
state.defines.max_influence;
1647 rel.get_influence() =
state.defines.max_influence;
1649 dcon::gp_relationship_id other_rel;
1650 for(
auto orel :
rel.get_influence_target().get_gp_relationship_as_influence_target()) {
1652 if(orel.get_influence() >
state.world.gp_relationship_get_influence(other_rel)) {
1659 auto& orl_i =
state.world.gp_relationship_get_influence(other_rel);
1660 orl_i = std::max(0.0f, orl_i - overflow);
1669bool can_put_flashpoint_focus_in_state(
sys::state& state, dcon::state_instance_id s, dcon::nation_id fp_nation) {
1670 auto fp_focus_nation = fatten(state.world, fp_nation);
1671 auto si = fatten(state.world, s);
1673 auto fp_ident = fp_focus_nation.get_identity_from_identity_holder();
1675 auto owner = si.get_nation_from_state_ownership();
1677 if(owner == fp_nation)
1682 if(fp_ident.get_is_not_releasable())
1685 if(fp_focus_nation.get_rank() > uint16_t(state.defines.colonial_rank)) {
1686 auto d = si.get_definition();
1687 for(
auto p : state.world.state_definition_get_abstract_state_membership(d)) {
1688 if(p.get_province().get_nation_from_province_ownership() == owner) {
1689 if(state.world.get_core_by_prov_tag_key(p.get_province(), fp_ident))
1698void monthly_flashpoint_update(
sys::state& state) {
1706 for(
auto si : state.world.in_state_instance) {
1707 auto owner = si.get_nation_from_state_ownership();
1708 auto owner_tag = owner.get_identity_from_identity_holder();
1710 auto owner_accepts_culture = [&](dcon::culture_id c) {
1714 if(
auto fp_focus_nation = si.get_nation_from_flashpoint_focus(); fp_focus_nation) {
1715 if(can_put_flashpoint_focus_in_state(state, si, fp_focus_nation)) {
1716 si.set_flashpoint_tag(fp_focus_nation.get_identity_from_identity_holder());
1720 si.set_nation_from_flashpoint_focus(dcon::nation_id{});
1724 dcon::national_identity_id qualifying_tag;
1726 auto d = si.get_definition();
1727 for(
auto p : state.world.state_definition_get_abstract_state_membership(d)) {
1728 if(p.get_province().get_nation_from_province_ownership() == owner) {
1729 for(
auto cores : p.get_province().get_core()) {
1730 if(!cores.get_identity().get_is_not_releasable()
1731 && !owner_accepts_culture(cores.get_identity().get_primary_culture())
1733 || si.get_demographics(
demographics::to_key(state, cores.get_identity().get_primary_culture())) >
1734 si.get_demographics(
demographics::to_key(state, state.world.national_identity_get_primary_culture(qualifying_tag))))) {
1736 qualifying_tag = cores.get_identity();
1742 si.set_flashpoint_tag(qualifying_tag);
1747 state.world.execute_serial_over_nation(
1748 [&](
auto ids) {
state.world.nation_set_has_flash_point_state(ids, ve::mask_vector(
false)); });
1749 for(
auto si :
state.world.in_state_instance) {
1750 if(si.get_flashpoint_tag()) {
1751 si.get_nation_from_state_ownership().set_has_flash_point_state(
true);
1756 state.world.execute_serial_over_nation(
1757 [&](
auto ids) {
state.world.nation_set_is_target_of_some_cb(ids, ve::mask_vector(
false)); });
1759 for(
auto target :
state.world.in_nation) {
1760 if(
target.get_has_flash_point_state()) {
1762 for(
auto actor :
state.world.in_nation) {
1763 auto owned =
actor.get_province_ownership();
1764 if(actor != target && owned.begin() != owned.end()) {
1766 target.set_is_target_of_some_cb(
true);
1775void daily_update_flashpoint_tension(
sys::state& state) {
1776 for(
auto si : state.world.in_state_instance) {
1777 if(si.get_flashpoint_tag()) {
1778 float total_increase = 0.0f;
1783 if(si.get_nation_from_state_ownership().get_is_target_of_some_cb()) {
1784 total_increase += state.defines.tension_from_cb;
1794 auto radicalism = state.world.movement_get_radicalism(mov);
1795 auto support = state.world.movement_get_pop_support(mov);
1797 auto pop_of_culture = si.get_demographics(
demographics::to_key(state, si.get_flashpoint_tag().get_primary_culture()));
1799 total_increase += std::min(state.defines.tension_from_movement_max,
1800 state.defines.tension_from_movement * radicalism * pop_of_culture * support / (state_pop * 4000.0f));
1807 if(si.get_nation_from_flashpoint_focus()) {
1808 total_increase += state.national_definitions.flashpoint_amount;
1814 total_increase += state.defines.tension_decay;
1820 total_increase += state.defines.tension_while_crisis;
1826 if(
auto rank = si.get_nation_from_state_ownership().get_rank();
1827 uint16_t(1) <= rank && rank <= uint16_t(int32_t(state.defines.great_nations_count))) {
1828 static float rank_amounts[8] = {state.defines.rank_1_tension_decay, state.defines.rank_2_tension_decay,
1829 state.defines.rank_3_tension_decay, state.defines.rank_4_tension_decay, state.defines.rank_5_tension_decay,
1830 state.defines.rank_6_tension_decay, state.defines.rank_7_tension_decay, state.defines.rank_8_tension_decay};
1832 total_increase += rank_amounts[rank - 1];
1839 for(
auto& gp : state.great_nations) {
1840 if(state.world.nation_get_is_at_war(gp.nation) ||
1841 (state.world.nation_get_disarmed_until(gp.nation) &&
1842 state.current_date <= state.world.nation_get_disarmed_until(gp.nation))) {
1843 auto continent = state.world.province_get_continent(state.world.nation_get_capital(gp.nation));
1844 if(si.get_capital().get_continent() == continent ||
1845 si.get_nation_from_state_ownership().get_capital().get_continent() == continent) {
1846 total_increase += state.defines.at_war_tension_decay;
1855 si.get_flashpoint_tension() = std::clamp(si.get_flashpoint_tension() + total_increase, 0.0f, 100.0f);
1857 si.set_flashpoint_tension(0.0f);
1863 state.last_crisis_end_date = state.current_date;
1866 state.crisis_last_checked_gp = 0;
1868 for(
auto& par : state.crisis_participants) {
1870 par.id = dcon::nation_id{};
1871 par.merely_interested =
false;
1872 par.supports_attacker =
false;
1873 par.joined_with_offer.target = dcon::nation_id{};
1874 par.joined_with_offer.wargoal_secondary_nation = dcon::nation_id{};
1875 par.joined_with_offer.wargoal_state = dcon::state_definition_id{};
1876 par.joined_with_offer.wargoal_tag = dcon::national_identity_id{};
1877 par.joined_with_offer.wargoal_type = dcon::cb_type_id{};
1883 state.crisis_temperature = 0.0f;
1884 state.crisis_war = dcon::war_id{};
1885 state.primary_crisis_attacker = dcon::nation_id{};
1886 state.primary_crisis_defender = dcon::nation_id{};
1887 state.crisis_state = dcon::state_instance_id{};
1888 state.crisis_colony = dcon::state_definition_id{};
1889 state.crisis_liberation_tag = dcon::national_identity_id{};
1892void add_as_primary_crisis_defender(
sys::state& state, dcon::nation_id n) {
1893 state.primary_crisis_defender = n;
1900 "msg_crisis_defender_title",
1901 n, dcon::nation_id{}, dcon::nation_id{},
1906void add_as_primary_crisis_attacker(
sys::state& state, dcon::nation_id n) {
1907 state.primary_crisis_attacker = n;
1914 "msg_crisis_attacker_title",
1915 n, dcon::nation_id{}, dcon::nation_id{},
1920void ask_to_defend_in_crisis(
sys::state& state, dcon::nation_id n) {
1921 if(state.world.nation_get_is_at_war(n)) {
1922 reject_crisis_participation(state);
1928 if(
state.crisis_state) {
1929 m.from =
state.world.state_instance_get_nation_from_state_ownership(
state.crisis_state);
1935void ask_to_attack_in_crisis(
sys::state& state, dcon::nation_id n) {
1936 if(state.world.nation_get_is_at_war(n)) {
1937 reject_crisis_participation(state);
1943 if(
state.crisis_liberation_tag) {
1944 m.from =
state.world.national_identity_get_nation_from_identity_holder(
state.crisis_liberation_tag);
1950void reject_crisis_participation(
sys::state& state) {
1951 ++state.crisis_last_checked_gp;
1952 if(state.crisis_last_checked_gp < state.great_nations.size() &&
1953 (state.great_nations[state.crisis_last_checked_gp].nation == state.primary_crisis_attacker ||
1954 state.great_nations[state.crisis_last_checked_gp].nation == state.primary_crisis_defender)) {
1955 ++state.crisis_last_checked_gp;
1958 if(
state.crisis_last_checked_gp >=
state.great_nations.size()) {
1965 "msg_crisis_fizzle_title",
1966 state.local_player_nation,dcon::nation_id{}, dcon::nation_id{},
1975 if(
state.crisis_last_checked_gp >=
state.great_nations.size()) {
1983 "msg_crisis_fizzle_title",
1984 state.local_player_nation, dcon::nation_id{}, dcon::nation_id{},
1990 state.primary_crisis_attacker,
state.world.state_instance_get_nation_from_state_ownership(
state.crisis_state),
1991 dcon::nation_id{},
state.world.state_instance_get_definition(
state.crisis_state),
state.crisis_liberation_tag);
1993 auto colonizers =
state.world.state_definition_get_colonization(
state.crisis_colony);
1995 if((colonizers.end() - colonizers.begin()) >= 2) {
1996 auto attacking_colonizer = (*colonizers.begin()).get_colonizer();
1997 auto defending_colonizer = (*(colonizers.begin() + 1)).get_colonizer();
2000 defending_colonizer, dcon::nation_id{},
state.crisis_colony, dcon::national_identity_id{});
2011void cleanup_crisis_peace_offer(
sys::state& state, dcon::peace_offer_id peace) {
2012 auto wg = state.world.peace_offer_get_peace_offer_item(peace);
2013 while(wg.begin() != wg.end()) {
2014 state.world.delete_wargoal((*wg.begin()).get_wargoal());
2016 state.world.delete_peace_offer(peace);
2019void accept_crisis_peace_offer(
sys::state& state, dcon::nation_id from, dcon::nation_id to, dcon::peace_offer_id peace) {
2023 cleanup_crisis_peace_offer(state, peace);
2024 cleanup_crisis(state);
2032 if(state.great_nations.size() <= 2)
2037 auto colonizers = state.world.state_definition_get_colonization(state.crisis_colony);
2038 auto num_colonizers = colonizers.end() - colonizers.begin();
2039 if(num_colonizers < 2) {
2040 cleanup_crisis(state);
2043 auto state_owner =
state.world.state_instance_get_nation_from_state_ownership(
state.crisis_state);
2044 if(state_owner ==
state.primary_crisis_attacker ||
2045 state.world.nation_get_identity_from_identity_holder(state_owner) ==
state.crisis_liberation_tag) {
2051 state.last_crisis_end_date + 31 * int32_t(
state.defines.crisis_cooldown_months) <
state.current_date)) {
2061 std::vector<dcon::state_instance_id> most_likely_states;
2062 for(
auto si :
state.world.in_state_instance) {
2063 auto owner_war = si.get_nation_from_state_ownership().get_is_at_war();
2064 auto ft = si.get_flashpoint_tag();
2065 auto ften = si.get_flashpoint_tension();
2066 auto ihold_at_war = si.get_flashpoint_tag().get_nation_from_identity_holder().get_is_at_war();
2068 if(si.get_nation_from_state_ownership().get_is_at_war() ==
false && si.get_flashpoint_tag() &&
2069 si.get_flashpoint_tension() > 50.0f &&
2070 si.get_flashpoint_tag().get_nation_from_identity_holder().get_is_at_war() ==
false) {
2071 most_likely_states.push_back(si);
2074 std::sort(most_likely_states.begin(), most_likely_states.end(), [&](dcon::state_instance_id a, dcon::state_instance_id b) {
2076 state.world.state_instance_get_flashpoint_tension(a) - state.world.state_instance_get_flashpoint_tension(b);
2077 if(tension_diff != 0.0f) {
2078 return tension_diff > 0.0f;
2080 return a.index() < b.index();
2083 for(
uint32_t i = 0; i < 3 && i < most_likely_states.size(); ++i) {
2085 state.world.state_instance_get_flashpoint_tension(most_likely_states[i]));
2087 if(rvalue < chance) {
2088 state.crisis_state = most_likely_states[i];
2089 state.crisis_liberation_tag =
state.world.state_instance_get_flashpoint_tag(
state.crisis_state);
2090 state.world.state_instance_set_flashpoint_tension(
state.crisis_state, 0.0f);
2092 if(
auto owner =
state.world.state_instance_get_nation_from_state_ownership(
state.crisis_state);
2093 state.world.nation_get_is_great_power(owner)) {
2102 "msg_new_crisis_title",
2103 state.local_player_nation, dcon::nation_id{}, dcon::nation_id{},
2116 for(
auto sd :
state.world.in_state_definition) {
2117 if(sd.get_colonization_temperature() >= 100.0f) {
2118 auto colonizers = sd.get_colonization();
2119 auto num_colonizers = colonizers.end() - colonizers.begin();
2120 if(num_colonizers == 2) {
2121 state.crisis_colony = sd;
2122 sd.set_colonization_temperature(0.0f);
2125 if((*colonizers.begin()).get_colonizer().get_is_great_power()) {
2126 state.primary_crisis_attacker = (*colonizers.begin()).get_colonizer();
2128 if((*(colonizers.begin() + 1)).get_colonizer().get_is_great_power()) {
2129 state.primary_crisis_defender = (*(colonizers.begin() + 1)).get_colonizer();
2136 "msg_new_crisis_title",
2137 state.local_player_nation, dcon::nation_id{}, dcon::nation_id{},
2147 state.last_crisis_end_date =
state.current_date;
2151 state.crisis_temperature = 0.0f;
2152 if(!
state.primary_crisis_attacker) {
2154 state.crisis_last_checked_gp =
state.great_nations[0].nation !=
state.primary_crisis_defender ? 0 : 1;
2156 }
else if(!
state.primary_crisis_defender) {
2158 state.crisis_last_checked_gp =
state.great_nations[0].nation !=
state.primary_crisis_attacker ? 0 : 1;
2164 if(
state.primary_crisis_attacker) {
2165 if(!
state.primary_crisis_defender) {
2167 state.crisis_last_checked_gp =
state.great_nations[0].nation !=
state.primary_crisis_attacker ? 0 : 1;
2171 state.crisis_last_checked_gp = 0;
2175 if(
state.primary_crisis_defender) {
2177 state.crisis_last_checked_gp = 0;
2188 state.crisis_participants[0].id =
state.primary_crisis_attacker;
2189 state.crisis_participants[0].supports_attacker =
true;
2190 state.crisis_participants[0].merely_interested =
false;
2191 state.crisis_participants[1].id =
state.primary_crisis_defender;
2192 state.crisis_participants[1].supports_attacker =
false;
2193 state.crisis_participants[1].merely_interested =
false;
2195 auto crisis_state_continent =
state.crisis_state
2196 ?
state.world.province_get_continent(
state.world.state_instance_get_capital(
state.crisis_state))
2198 if(
auto p =
state.world.state_definition_get_abstract_state_membership(
state.crisis_colony); p.begin() != p.end()) {
2199 return (*p.begin()).get_province().get_continent().id;
2201 return dcon::modifier_id{};
2204 auto crisis_defender_continent =
2205 state.world.province_get_continent(
state.world.nation_get_capital(
state.primary_crisis_defender));
2208 for(
auto& gp :
state.great_nations) {
2209 if(
gp.nation !=
state.primary_crisis_attacker &&
gp.nation !=
state.primary_crisis_defender &&
2210 !
state.world.nation_get_is_at_war(
gp.nation) &&
2211 state.world.nation_get_war_exhaustion(
gp.nation) <
state.defines.crisis_interest_war_exhaustion_limit) {
2212 auto cap_con =
state.world.province_get_continent(
state.world.nation_get_capital(
gp.nation));
2213 if(cap_con ==
state.province_definitions.europe || cap_con == crisis_state_continent ||
2214 cap_con == crisis_defender_continent ||
2215 (cap_con ==
state.province_definitions.north_america &&
2216 crisis_state_continent ==
state.province_definitions.south_america) ||
2217 (cap_con ==
state.province_definitions.north_america &&
2218 crisis_defender_continent ==
state.province_definitions.south_america) ||
2219 (cap_con ==
state.province_definitions.south_america &&
2220 crisis_state_continent ==
state.province_definitions.north_america) ||
2221 (cap_con ==
state.province_definitions.south_america &&
2222 crisis_defender_continent ==
state.province_definitions.north_america)) {
2239 dcon::nation_id secondary_attacker;
2240 dcon::nation_id secondary_defender;
2243 auto colonizers =
state.world.state_definition_get_colonization(
state.crisis_colony);
2244 secondary_defender = (*(colonizers.begin() + 1)).get_colonizer();
2245 secondary_attacker = (*(colonizers.begin())).get_colonizer();
2247 secondary_defender =
state.world.state_instance_get_nation_from_state_ownership(
state.crisis_state);
2248 secondary_attacker =
state.world.national_identity_get_nation_from_identity_holder(
state.crisis_liberation_tag);
2251 for(
auto& i :
state.crisis_participants) {
2252 if(i.id && i.merely_interested ==
true &&
state.world.nation_get_is_player_controlled(i.id) ==
false) {
2253 if(
state.world.nation_get_ai_rival(i.id) ==
state.primary_crisis_attacker
2255 ||
state.world.nation_get_ai_rival(i.id) == secondary_attacker
2257 ||
state.world.nation_get_in_sphere_of(secondary_defender) == i.id) {
2259 i.merely_interested =
false;
2260 i.supports_attacker =
false;
2266 "msg_crisis_vol_join_title",
2267 i.id, dcon::nation_id{}, dcon::nation_id{},
2270 }
else if(
state.world.nation_get_ai_rival(i.id) ==
state.primary_crisis_defender
2272 ||
state.world.nation_get_ai_rival(i.id) == secondary_defender
2274 ||
state.world.nation_get_in_sphere_of(secondary_attacker) == i.id) {
2276 i.merely_interested =
false;
2277 i.supports_attacker =
true;
2283 "msg_crisis_vol_join_title",
2284 i.id, dcon::nation_id{}, dcon::nation_id{},
2301 int32_t participants = 0;
2302 for(
auto& par :
state.crisis_participants) {
2305 if(!par.merely_interested)
2313 state.crisis_temperature +=
state.defines.crisis_temperature_increase *
state.defines.crisis_temperature_participant_factor *
2314 float(participants) / float(total);
2316 if(
state.crisis_temperature >= 100) {
2320 state.world.state_instance_get_nation_from_state_ownership(
state.crisis_state),
2321 state.military_definitions.crisis_liberate,
state.world.state_instance_get_definition(
state.crisis_state),
2322 state.crisis_liberation_tag, dcon::nation_id{});
2323 if(
state.world.state_instance_get_nation_from_state_ownership(
state.crisis_state) !=
state.primary_crisis_defender) {
2325 state.world.war_set_primary_defender(war,
state.primary_crisis_defender);
2328 auto colonizers =
state.world.state_definition_get_colonization(
state.crisis_colony);
2330 auto attacking_colonizer = (*colonizers.begin()).get_colonizer();
2331 auto defending_colonizer = (*(colonizers.begin() + 1)).get_colonizer();
2334 state.crisis_colony, dcon::national_identity_id{}, dcon::nation_id{});
2336 state.crisis_colony, dcon::national_identity_id{}, dcon::nation_id{});
2338 if(
state.primary_crisis_defender != attacking_colonizer &&
state.primary_crisis_defender != defending_colonizer) {
2340 state.world.war_set_primary_defender(war,
state.primary_crisis_defender);
2342 if(
state.primary_crisis_attacker != attacking_colonizer &&
state.primary_crisis_attacker != defending_colonizer) {
2344 state.world.war_set_primary_attacker(war,
state.primary_crisis_attacker);
2348 for(
auto& par :
state.crisis_participants) {
2350 if(!par.merely_interested && par.id !=
state.primary_crisis_attacker && par.id !=
state.primary_crisis_defender) {
2359 for(
auto& par :
state.crisis_participants) {
2361 if(!par.merely_interested && par.id !=
state.primary_crisis_attacker && par.id !=
state.primary_crisis_defender) {
2362 if(par.joined_with_offer.wargoal_type) {
2363 military::add_wargoal(state, war, par.id, par.joined_with_offer.target, par.joined_with_offer.wargoal_type,
2364 par.joined_with_offer.wargoal_state, par.joined_with_offer.wargoal_tag,
2365 par.joined_with_offer.wargoal_secondary_nation);
2379 float p_factor =
state.defines.crisis_did_not_take_side_prestige_factor_base +
2380 state.defines.crisis_did_not_take_side_prestige_factor_year * float(
state.current_date.value) / float(365);
2382 for(
auto& par :
state.crisis_participants) {
2386 if(par.merely_interested) {
2394 state.world.war_set_is_crisis_war(war,
true);
2396 if(
state.military_definitions.great_wars_enabled) {
2397 int32_t gp_attackers = 0;
2398 int32_t gp_defenders = 0;
2400 for(
auto par :
state.world.war_get_war_participant(war)) {
2402 if(par.get_is_attacker())
2409 if(gp_attackers >= 2 && gp_defenders >= 2) {
2410 state.world.war_set_is_great(war,
true);
2411 state.world.war_set_name(war,
state.lookup_key(std::string_view{
"great_war_name" }));
2418 [pa =
state.world.war_get_primary_attacker(war), pd =
state.world.war_get_primary_defender(war), name =
state.world.war_get_name(war), tag =
state.world.war_get_over_tag(war), st =
state.world.war_get_over_state(war)](
sys::state& state,
text::layout_base& contents) {
2420 text::substitution_map sub;
2422 text::add_to_substitution_map(sub, text::variable_type::order, std::string_view(
""));
2423 text::add_to_substitution_map(sub, text::variable_type::second, text::get_adjective(state, pd));
2424 text::add_to_substitution_map(sub, text::variable_type::second_country, pd);
2425 text::add_to_substitution_map(sub, text::variable_type::first, text::get_adjective(state, pa));
2426 text::add_to_substitution_map(sub, text::variable_type::third, tag);
2427 text::add_to_substitution_map(sub, text::variable_type::state, st);
2428 text::add_to_substitution_map(sub, text::variable_type::country_adj, state.world.national_identity_get_adjective(tag));
2430 std::string resolved_war_name = text::resolve_string_substitution(state, name, sub);
2431 text::add_line(state, contents,
"msg_crisis_escalates_1", text::variable_type::x, std::string_view{resolved_war_name});
2433 "msg_crisis_escalates_title",
2434 state.local_player_nation, dcon::nation_id{}, dcon::nation_id{},
2441int32_t num_crisis_wargoals(
sys::state& state) {
2444 for(
auto& par : state.crisis_participants) {
2447 if(par.joined_with_offer.wargoal_type) {
2460bool nth_crisis_war_goal_is_for_attacker(
sys::state& state, int32_t index) {
2466 for(
auto& par : state.crisis_participants) {
2469 if(par.joined_with_offer.wargoal_type) {
2470 if(count == index) {
2471 return par.supports_attacker;
2480 }
else if(index == 1) {
2484 for(
auto& par :
state.crisis_participants) {
2487 if(par.joined_with_offer.wargoal_type) {
2488 if(count == index) {
2489 return par.supports_attacker;
2503 state.primary_crisis_attacker,
2504 state.world.state_instance_get_nation_from_state_ownership(state.crisis_state),
2506 state.crisis_liberation_tag,
2507 state.world.state_instance_get_definition(state.crisis_state),
2508 state.military_definitions.crisis_liberate
2512 for(
auto& par : state.crisis_participants) {
2515 if(par.joined_with_offer.wargoal_type) {
2516 if(count == index) {
2519 par.joined_with_offer.target,
2520 par.joined_with_offer.wargoal_secondary_nation,
2521 par.joined_with_offer.wargoal_tag,
2522 par.joined_with_offer.wargoal_state,
2523 par.joined_with_offer.wargoal_type
2532 auto colonizers =
state.world.state_definition_get_colonization(
state.crisis_colony);
2533 if(colonizers.end() - colonizers.begin() >= 2) {
2534 auto attacking_colonizer = (*colonizers.begin()).get_colonizer();
2535 auto defending_colonizer = (*(colonizers.begin() + 1)).get_colonizer();
2538 attacking_colonizer,
2539 defending_colonizer,
2541 dcon::national_identity_id{},
2542 state.crisis_colony,
2543 state.military_definitions.crisis_colony
2546 }
else if(index == 1) {
2547 auto colonizers =
state.world.state_definition_get_colonization(
state.crisis_colony);
2548 if(colonizers.end() - colonizers.begin() >= 2) {
2549 auto attacking_colonizer = (*colonizers.begin()).get_colonizer();
2550 auto defending_colonizer = (*(colonizers.begin() + 1)).get_colonizer();
2553 defending_colonizer,
2554 attacking_colonizer,
2556 dcon::national_identity_id{},
2557 state.crisis_colony,
2558 state.military_definitions.crisis_colony
2563 for(
auto& par :
state.crisis_participants) {
2566 if(par.joined_with_offer.wargoal_type) {
2567 if(count == index) {
2570 par.joined_with_offer.target,
2571 par.joined_with_offer.wargoal_secondary_nation,
2572 par.joined_with_offer.wargoal_tag,
2573 par.joined_with_offer.wargoal_state,
2574 par.joined_with_offer.wargoal_type
2585void update_pop_acceptance(
sys::state& state, dcon::nation_id n) {
2586 auto pc = state.world.nation_get_primary_culture(n);
2587 for(
auto pr : state.world.nation_get_province_ownership(n)) {
2588 for(
auto pop : pr.get_province().get_pop_location()) {
2590 if(pc == pop.get_pop().get_culture()) {
2591 pop.get_pop().set_is_primary_or_accepted_culture(
true);
2594 if(state.world.nation_get_accepted_cultures(n, pop.get_pop().get_culture()) ==
true) {
2595 pop.get_pop().set_is_primary_or_accepted_culture(
true);
2598 pop.get_pop().set_is_primary_or_accepted_culture(
false);
2604void liberate_nation_from(
sys::state& state, dcon::national_identity_id liberated, dcon::nation_id from) {
2607 auto holder = state.world.national_identity_get_nation_from_identity_holder(liberated);
2609 holder = state.world.create_nation();
2610 state.world.nation_set_identity_from_identity_holder(holder, liberated);
2612 auto lprovs =
state.world.nation_get_province_ownership(holder);
2613 if(lprovs.begin() == lprovs.end()) {
2616 for(
auto c :
state.world.national_identity_get_core(liberated)) {
2617 if(c.get_province().get_nation_from_province_ownership() == from) {
2623 if(
state.world.province_get_nation_from_province_ownership(
state.world.nation_get_capital(from)) != from) {
2628void release_nation_from(
sys::state& state, dcon::national_identity_id liberated, dcon::nation_id from) {
2631 auto holder = state.world.national_identity_get_nation_from_identity_holder(liberated);
2632 auto source_tag = state.world.nation_get_identity_from_identity_holder(from);
2634 holder = state.world.create_nation();
2635 state.world.nation_set_identity_from_identity_holder(holder, liberated);
2637 auto lprovs =
state.world.nation_get_province_ownership(holder);
2638 if(lprovs.begin() == lprovs.end()) {
2641 for(
auto c :
state.world.national_identity_get_core(liberated)) {
2642 if(c.get_province().get_nation_from_province_ownership() == from &&
2643 !(
state.world.get_core_by_prov_tag_key(c.get_province(), source_tag))) {
2647 if(
state.world.province_get_nation_from_province_ownership(
state.world.nation_get_capital(from)) != from) {
2652void remove_cores_from_owned(
sys::state& state, dcon::nation_id n, dcon::national_identity_id tag) {
2653 for(
auto prov : state.world.nation_get_province_ownership(n)) {
2654 if(
auto core = state.world.get_core_by_prov_tag_key(prov.get_province(), tag); core) {
2655 state.world.delete_core(core);
2660void perform_nationalization(
sys::state& state, dcon::nation_id n) {
2661 for(
auto rel : state.world.nation_get_unilateral_relationship_as_target(n)) {
2662 if(rel.get_foreign_investment() > 0.0f) {
2666 rel.set_foreign_investment(0.0f);
2671void adjust_influence(
sys::state& state, dcon::nation_id great_power, dcon::nation_id target,
float delta) {
2672 if(great_power == target)
2675 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, great_power);
2677 rel = state.world.force_create_gp_relationship(target, great_power);
2679 auto&
inf =
state.world.gp_relationship_get_influence(rel);
2680 inf = std::clamp(inf + delta, 0.0f,
state.defines.max_influence);
2683void adjust_influence_with_overflow(
sys::state& state, dcon::nation_id great_power, dcon::nation_id target,
float delta) {
2684 if(state.world.nation_get_owned_province_count(great_power) == 0 || state.world.nation_get_owned_province_count(target) == 0)
2686 if(great_power == target)
2688 if(state.world.nation_get_is_great_power(target) || !state.world.nation_get_is_great_power(great_power))
2691 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, great_power);
2693 rel = state.world.force_create_gp_relationship(target, great_power);
2695 auto&
inf =
state.world.gp_relationship_get_influence(rel);
2699 if(
state.world.nation_get_in_sphere_of(target) == great_power) {
2700 inf +=
state.defines.addtosphere_influence_cost;
2701 state.world.nation_set_in_sphere_of(target, dcon::nation_id{});
2703 auto& l =
state.world.gp_relationship_get_status(rel);
2706 inf +=
state.defines.increaseopinion_influence_cost;
2708 auto& l =
state.world.gp_relationship_get_status(rel);
2713 while(inf >
state.defines.max_influence) {
2714 if(
state.world.nation_get_in_sphere_of(target) != great_power) {
2715 inf -=
state.defines.removefromsphere_influence_cost;
2716 auto affected_gp =
state.world.nation_get_in_sphere_of(target);
2717 state.world.nation_set_in_sphere_of(target, dcon::nation_id{});
2719 auto orel =
state.world.get_gp_relationship_by_gp_influence_pair(target, affected_gp);
2720 auto& l =
state.world.gp_relationship_get_status(orel);
2723 }
else if((
state.world.gp_relationship_get_status(rel) & influence::level_mask) == influence::level_friendly) {
2724 state.world.nation_set_in_sphere_of(target, great_power);
2725 inf -=
state.defines.addtosphere_influence_cost;
2726 auto& l =
state.world.gp_relationship_get_status(rel);
2729 inf -=
state.defines.increaseopinion_influence_cost;
2731 auto& l =
state.world.gp_relationship_get_status(rel);
2737void adjust_foreign_investment(
sys::state& state, dcon::nation_id great_power, dcon::nation_id target,
float delta) {
2738 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, great_power);
2740 rel = state.world.force_create_unilateral_relationship(target, great_power);
2742 auto& invest =
state.world.unilateral_relationship_get_foreign_investment(rel);
2743 invest = std::max(0.0f, invest + delta);
2746float get_yesterday_income(
sys::state& state, dcon::nation_id n) {
2760void make_civilized(
sys::state& state, dcon::nation_id n) {
2761 if(state.world.nation_get_is_civilized(n))
2770 int32_t military_reforms_active_count = 0;
2771 int32_t econ_reforms_active_count = 0;
2772 int32_t total_military_reforms_count = 0;
2773 int32_t total_econ_reforms_count = 0;
2775 for(
auto r : state.world.in_reform) {
2776 auto current_option = state.world.nation_get_reforms(n, r);
2777 auto& opts = state.world.reform_get_options(r);
2778 for(
uint32_t i = 0; i < opts.size(); ++i) {
2781 ++total_military_reforms_count;
2782 if(opts[i] == current_option)
2783 military_reforms_active_count += int32_t(i);
2785 ++total_econ_reforms_count;
2786 if(opts[i] == current_option)
2787 econ_reforms_active_count += int32_t(i);
2793 assert(total_military_reforms_count != 0);
2794 assert(total_econ_reforms_count != 0);
2796 float mil_tech_fraction = std::clamp(
float(military_reforms_active_count) /
float(total_military_reforms_count),
2797 state.defines.unciv_tech_spread_min,
state.defines.unciv_tech_spread_max);
2798 float econ_tech_fraction = std::clamp(
float(econ_reforms_active_count) /
float(total_econ_reforms_count),
2799 state.defines.unciv_tech_spread_min,
state.defines.unciv_tech_spread_max);
2801 dcon::nation_id model =
state.world.nation_get_in_sphere_of(n);
2803 model =
state.nations_by_rank[0];
2805 for(
uint32_t idx = 0; idx <
state.world.technology_size();) {
2807 auto this_group =
state.world.technology_get_folder_index(dcon::technology_id{dcon::technology_id::value_base_t(idx)});
2812 int32_t model_tech_count = 0;
2813 for(
uint32_t sidx = idx; sidx <
state.world.technology_size(); ++sidx) {
2814 auto sid = dcon::technology_id{dcon::technology_id::value_base_t(sidx)};
2815 if(
state.world.technology_get_folder_index(sid) != this_group)
2818 if(
state.world.nation_get_active_technologies(model, sid)) {
2826 float target_amount = float(model_tech_count) * (is_military ? mil_tech_fraction : econ_tech_fraction);
2827 int32_t
target_count = int32_t(std::ceil(target_amount));
2829 for(
uint32_t sidx = idx; sidx <
state.world.technology_size(); ++sidx) {
2830 auto sid = dcon::technology_id{dcon::technology_id::value_base_t(sidx)};
2832 if(
state.world.technology_get_folder_index(sid) != this_group)
2835 if(target_amount > 0) {
2836 if(!
state.world.nation_get_active_technologies(n, sid))
2845 for(; idx <
state.world.technology_size(); ++idx) {
2846 if(
state.world.technology_get_folder_index(dcon::technology_id{dcon::technology_id::value_base_t(idx)}) != this_group)
2851 state.world.nation_set_is_civilized(n,
true);
2852 for(
auto o :
state.culture_definitions.political_issues) {
2853 state.world.nation_set_issues(n, o,
state.world.issue_get_options(o)[0]);
2855 for(
auto o :
state.culture_definitions.social_issues) {
2856 state.world.nation_set_issues(n, o,
state.world.issue_get_options(o)[0]);
2858 for(
auto r :
state.world.in_reform) {
2859 state.world.nation_set_reforms(n, r, dcon::reform_option_id{});
2867void make_uncivilized(
sys::state& state, dcon::nation_id n) {
2868 if(!state.world.nation_get_is_civilized(n))
2871 state.world.nation_set_is_civilized(n,
false);
2873 for(
auto o : state.culture_definitions.military_issues) {
2874 state.world.nation_set_reforms(n, o, state.world.reform_get_options(o)[0]);
2876 for(
auto o :
state.culture_definitions.economic_issues) {
2877 state.world.nation_set_reforms(n, o,
state.world.reform_get_options(o)[0]);
2879 for(
auto o :
state.culture_definitions.political_issues) {
2880 state.world.nation_set_issues(n, o, dcon::issue_option_id{});
2882 for(
auto o :
state.culture_definitions.social_issues) {
2883 state.world.nation_set_issues(n, o, dcon::issue_option_id{});
2885 for(
auto r :
state.world.in_reform) {
2886 state.world.nation_set_reforms(n, r, dcon::reform_option_id{});
2892void enact_reform(
sys::state& state, dcon::nation_id source, dcon::reform_option_id r) {
2897 auto e = state.world.reform_option_get_on_execute_effect(r);
2899 auto t = state.world.reform_option_get_on_execute_trigger(r);
2908 float base_cost = float(
state.world.reform_option_get_technology_cost(r));
2911 state.world.nation_get_research_points(source) -= base_cost * reform_factor;
2913 float base_cost = float(
state.world.reform_option_get_technology_cost(r));
2916 state.world.nation_get_research_points(source) -= base_cost * reform_factor;
2925 for(
auto id :
state.world.in_ideology) {
2926 if(
id ==
state.culture_definitions.conservative) {
2927 state.world.nation_get_upper_house(source,
id) +=
state.defines.conservative_increase_after_reform * 100.0f;
2929 state.world.nation_get_upper_house(source,
id) /= (1.0f +
state.defines.conservative_increase_after_reform);
2931 state.world.nation_set_reforms(source,
state.world.reform_option_get_parent_reform(r), r);
2937void enact_issue(
sys::state& state, dcon::nation_id source, dcon::issue_option_id i) {
2939 auto e = state.world.issue_option_get_on_execute_effect(i);
2941 auto t = state.world.issue_option_get_on_execute_trigger(i);
2954 float winner_support =
winner ?
state.world.movement_get_pop_support(winner) : 1.0f;
2955 for(
auto m :
state.world.nation_get_movement_within(source)) {
2956 if(
m.get_movement().get_associated_issue_option() &&
m.get_movement().get_associated_issue_option() != i &&
2957 m.get_movement().get_pop_support() > winner_support) {
2959 m.get_movement().get_transient_radicalism() +=
2960 std::min(3.0f,
m.get_movement().get_pop_support() / winner_support - 1.0f) *
state.defines.wrong_reform_radical_impact;
2964 state.world.delete_movement(winner);
2972 auto issue =
state.world.issue_option_get_parent_issue(i);
2976 if(
state.world.issue_get_is_next_step_only(issue)) {
2977 for(
auto id :
state.world.in_ideology) {
2978 auto condition = is_social
2979 ? (i.index() >
current.index() ?
state.world.ideology_get_remove_social_reform(
id) :
state.world.ideology_get_add_social_reform(
id))
2980 : (i.index() >
current.index() ?
state.world.ideology_get_remove_political_reform(
id) :
state.world.ideology_get_add_political_reform(
id));
2986 for(
auto pr :
state.world.nation_get_province_ownership(source)) {
2987 for(
auto pop : pr.get_province().get_pop_location()) {
3005 for(
auto pr :
state.world.nation_get_province_ownership(source)) {
3006 for(
auto pop : pr.get_province().get_pop_location()) {
3011 if(
auto m =
pop.get_pop().get_movement_from_pop_movement_membership(); m &&
m.get_pop_support() > winner_support) {
3027 for(
auto id :
state.world.in_ideology) {
3028 if(
id ==
state.culture_definitions.conservative) {
3029 state.world.nation_get_upper_house(source,
id) +=
state.defines.conservative_increase_after_reform * 100.0f;
3031 state.world.nation_get_upper_house(source,
id) /= (1.0f +
state.defines.conservative_increase_after_reform);
3034 state.world.nation_set_issues(source, issue, i);
3039 state.world.nation_set_last_issue_or_reform_change(source,
state.current_date);
#define assert(condition)
float effective_technology_cost(sys::state &state, uint32_t current_year, dcon::nation_id target_nation, dcon::technology_id tech_id)
void apply_technology(sys::state &state, dcon::nation_id target_nation, dcon::technology_id t_id)
void update_nation_issue_rules(sys::state &state, dcon::nation_id n_id)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
float get_estimated_colonial_migration(sys::state &state, dcon::pop_id ids)
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr dcon::demographics_key consciousness(3)
float get_monthly_pop_increase(sys::state &state, dcon::pop_id ids)
float get_estimated_emigration(sys::state &state, dcon::pop_id ids)
@ be_crisis_primary_attacker
@ be_crisis_primary_defender
void post(sys::state &state, message const &m)
constexpr dcon::commodity_id money(0)
float estimate_tax_income_by_strata(sys::state &state, dcon::nation_id n, culture::pop_strata ps)
float estimate_gold_income(sys::state &state, dcon::nation_id n)
void execute(sys::state &state, dcon::effect_key key, int32_t primary, int32_t this_slot, int32_t from_slot, uint32_t r_lo, uint32_t r_hi)
void fire_fixed_event(sys::state &state, std::vector< nations::fixed_event > const &v, int32_t primary_slot, slot_type pt, dcon::nation_id this_slot, int32_t from_slot, slot_type ft)
void switch_scene(sys::state &state, scene_id ui_scene)
int32_t naval_supply_points_used(sys::state &state, dcon::nation_id n)
void add_to_war(sys::state &state, dcon::war_id w, dcon::nation_id n, bool as_attacker, bool on_war_creation)
bool can_use_cb_against(sys::state &state, dcon::nation_id from, dcon::nation_id target)
bool has_truce_with(sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
void add_wargoal(sys::state &state, dcon::war_id wfor, dcon::nation_id added_by, dcon::nation_id target, dcon::cb_type_id type, dcon::state_definition_id sd, dcon::national_identity_id tag, dcon::nation_id secondary_nation)
dcon::war_id create_war(sys::state &state, dcon::nation_id primary_attacker, dcon::nation_id primary_defender, dcon::cb_type_id primary_wargoal, dcon::state_definition_id primary_wargoal_state, dcon::national_identity_id primary_wargoal_tag, dcon::nation_id primary_wargoal_secondary)
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
void implement_peace_offer(sys::state &state, dcon::peace_offer_id offer)
void implement_war_goal(sys::state &state, dcon::war_id war, dcon::cb_type_id wargoal, dcon::nation_id from, dcon::nation_id target, dcon::nation_id secondary_nation, dcon::state_definition_id wargoal_state, dcon::national_identity_id wargoal_t)
int32_t naval_supply_points(sys::state &state, dcon::nation_id n)
uint8_t decrease_level(uint8_t v)
uint8_t increase_level(uint8_t v)
constexpr uint8_t level_mask
int32_t get_level(sys::state &state, dcon::nation_id gp, dcon::nation_id target)
float colonial_points_from_naval_bases(sys::state &state, dcon::nation_id n)
status get_status(sys::state &state, dcon::nation_id n)
bool is_great_power(sys::state const &state, dcon::nation_id id)
int32_t free_colonial_points(sys::state &state, dcon::nation_id n)
void break_alliance(sys::state &state, dcon::diplomatic_relation_id rel)
bool is_losing_colonial_race(sys::state &state, dcon::nation_id n)
bool can_release_as_vassal(sys::state const &state, dcon::nation_id n, dcon::national_identity_id releasable)
void adjust_prestige(sys::state &state, dcon::nation_id n, float delta)
bool has_political_reform_available(sys::state &state, dcon::nation_id n)
constexpr float max_prestige
void monthly_adjust_relationship(sys::state &state, dcon::nation_id a, dcon::nation_id b, float delta)
float get_foreign_investment(sys::state &state, dcon::nation_id n)
bool identity_has_holder(sys::state const &state, dcon::national_identity_id ident)
void update_administrative_efficiency(sys::state &state)
void release_vassal(sys::state &state, dcon::overlord_id rel)
bool are_allied(sys::state &state, dcon::nation_id a, dcon::nation_id b)
void ask_to_attack_in_crisis(sys::state &state, dcon::nation_id n)
bool destroy_vassal_relationships(sys::state &state, dcon::nation_id n)
void make_alliance(sys::state &state, dcon::nation_id a, dcon::nation_id b)
float used_colonial_points(sys::state &state, dcon::nation_id n)
float get_base_shares(sys::state &state, dcon::gp_relationship_id gp, float total_gain, int32_t total_influence_shares)
bool has_sphere_neighbour(sys::state &state, dcon::nation_id n, dcon::nation_id target)
bool can_expand_colony(sys::state &state, dcon::nation_id n)
float diplomatic_points(sys::state const &state, dcon::nation_id n)
bool has_social_reform_available(sys::state &state, dcon::nation_id n)
void update_military_scores(sys::state &state)
float suppression_points(sys::state const &state, dcon::nation_id n)
void cleanup_nation(sys::state &state, dcon::nation_id n)
void ask_to_defend_in_crisis(sys::state &state, dcon::nation_id n)
dcon::nation_id get_nth_great_power(sys::state const &state, uint16_t n)
bool is_landlocked(sys::state &state, dcon::nation_id n)
float prestige_score(sys::state const &state, dcon::nation_id n)
float colonial_points_from_technology(sys::state &state, dcon::nation_id n)
void generate_initial_state_instances(sys::state &state)
void update_cached_values(sys::state &state)
void make_substate(sys::state &state, dcon::nation_id subject, dcon::nation_id overlord)
float leadership_points(sys::state const &state, dcon::nation_id n)
float monthly_diplomatic_points(sys::state const &state, dcon::nation_id n)
float daily_research_points(sys::state &state, dcon::nation_id n)
dcon::nation_id get_relationship_partner(sys::state const &state, dcon::diplomatic_relation_id rel_id, dcon::nation_id query)
void restore_cached_values(sys::state &state)
dcon::text_key name_from_tag(sys::state &state, dcon::national_identity_id tag)
void update_revanchism(sys::state &state)
int64_t get_monthly_pop_increase_of_nation(sys::state &state, dcon::nation_id n)
bool sphereing_progress_is_possible(sys::state &state, dcon::nation_id n)
sys::date get_research_end_date(sys::state &state, dcon::technology_id tech_id, dcon::nation_id n)
void create_nation_based_on_template(sys::state &state, dcon::nation_id n, dcon::nation_id base)
void update_industrial_scores(sys::state &state)
void update_research_points(sys::state &state)
void restore_state_instances(sys::state &state)
int32_t national_focuses_in_use(sys::state &state, dcon::nation_id n)
bool has_reform_available(sys::state &state, dcon::nation_id n)
float get_foreign_investment_as_gp(sys::state &state, dcon::nation_id n)
void update_great_powers(sys::state &state)
void cleanup_crisis(sys::state &state)
dcon::nation_id owner_of_pop(sys::state const &state, dcon::pop_id pop_ids)
dcon::technology_id current_research(sys::state const &state, dcon::nation_id n)
bool can_accumulate_influence_with(sys::state &state, dcon::nation_id gp, dcon::nation_id target, dcon::gp_relationship_id rel)
int32_t max_national_focuses(sys::state &state, dcon::nation_id n)
void update_ui_rankings(sys::state &state)
void update_rankings(sys::state &state)
int32_t max_colonial_points(sys::state &state, dcon::nation_id n)
float colonial_points_from_ships(sys::state &state, dcon::nation_id n)
auto nation_accepts_culture(sys::state const &state, T ids, U cul_ids)
void post(sys::state &state, message &&m)
bool can_enact_social_reform(sys::state &state, dcon::nation_id n, dcon::issue_option_id o)
float get_military_reform_multiplier(sys::state &state, dcon::nation_id n)
bool can_enact_political_reform(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
float get_economic_reform_multiplier(sys::state &state, dcon::nation_id n)
bool political_party_is_active(sys::state &state, dcon::nation_id n, dcon::political_party_id p)
void update_displayed_identity(sys::state &state, dcon::nation_id id)
bool can_enact_military_reform(sys::state &state, dcon::nation_id n, dcon::reform_option_id o)
bool can_enact_economic_reform(sys::state &state, dcon::nation_id n, dcon::reform_option_id o)
void set_militancy(sys::state &state, dcon::pop_id p, float v)
void set_consciousness(sys::state &state, dcon::pop_id p, float v)
dcon::pop_demographics_key to_key(sys::state const &state, dcon::ideology_id v)
float get_consciousness(sys::state const &state, dcon::pop_id p)
float get_militancy(sys::state const &state, dcon::pop_id p)
float get_demo(sys::state const &state, dcon::pop_id p, dcon::pop_demographics_key k)
void for_each_province_in_state_instance(sys::state &state, dcon::state_instance_id s, F const &func)
bool can_invest_in_colony(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
void set_province_controller(sys::state &state, dcon::province_id p, dcon::nation_id n)
bool state_is_coastal_non_core_nb(sys::state &state, dcon::state_instance_id s)
void change_province_owner(sys::state &state, dcon::province_id id, dcon::nation_id new_owner)
dcon::province_id pick_capital(sys::state &state, dcon::nation_id n)
dcon::movement_id get_movement_by_independence(sys::state &state, dcon::nation_id n, dcon::national_identity_id i)
dcon::movement_id get_movement_by_position(sys::state &state, dcon::nation_id n, dcon::issue_option_id o)
uint64_t get_random(sys::state const &state, uint32_t value_in)
MOD_PROV_LIST constexpr uint32_t count
void update_single_nation_modifiers(sys::state &state, dcon::nation_id n)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
int32_t to_generic(dcon::province_id v)
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
float evaluate_additive_modifier(sys::state &state, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
T select(bool v, T a, T b)
int32_t to_int(int32_t a)