Project Alice
Loading...
Searching...
No Matches
culture.cpp
Go to the documentation of this file.
1#include "culture.hpp"
2#include "dcon_generated.hpp"
3#include "demographics.hpp"
5#include "prng.hpp"
7#include "system_state.hpp"
8#include "triggers.hpp"
9
10namespace culture {
11
13 switch(t) {
15 return "army_tech";
17 return "navy_tech";
19 return "commerce_tech";
21 return "culture_tech";
23 return "industry_tech";
24 //non-vanilla
26 return "military_theory_tech";
28 return "population_tech";
30 return "diplomacy_tech";
32 return "flavor_tech";
33 default:
34 break;
35 }
36 return "none";
37}
38
40 state.world.nation_resize_issues(state.world.issue_size());
41
42 state.world.for_each_issue([&](dcon::issue_id i) {
43 auto def_option = state.world.issue_get_options(i)[0];
44 state.world.execute_serial_over_nation([&](auto ids) { state.world.nation_set_issues(ids, i, def_option); });
45 });
46
47 state.world.nation_resize_reforms(state.world.reform_size());
48
49 state.world.for_each_reform([&](dcon::reform_id i) {
50 auto def_option = state.world.reform_get_options(i)[0];
51 state.world.execute_serial_over_nation([&](auto ids) { state.world.nation_set_reforms(ids, i, def_option); });
52 });
53}
54
57 state.world.execute_serial_over_nation([&](auto nation_indices) {
58 state.world.nation_set_max_building_level(nation_indices, uint8_t(t), 0);
59 });
60
61 }
62 state.world.for_each_factory_type([&](dcon::factory_type_id id) {
63 state.world.execute_serial_over_nation([&](auto nation_indices) {
64 state.world.nation_set_active_building(nation_indices, id, ve::vbitfield_type{0});
65 });
66 });
67 for(uint32_t i = 0; i < state.military_definitions.unit_base_definitions.size(); ++i) {
68 dcon::unit_type_id uid = dcon::unit_type_id{ dcon::unit_type_id::value_base_t(i) };
69 state.world.execute_serial_over_nation([&](auto nation_indices) {
70 state.world.nation_set_active_unit(nation_indices, uid, ve::vbitfield_type{ 0 });
71 });
72 }
73 for(uint32_t i = 0; i < state.culture_definitions.crimes.size(); ++i) {
74 dcon::crime_id uid = dcon::crime_id{ dcon::crime_id::value_base_t(i) };
75 state.world.execute_serial_over_nation([&](auto nation_indices) {
76 state.world.nation_set_active_crime(nation_indices, uid, ve::vbitfield_type{ 0 });
77 });
78 }
79
80 for(auto cmod : state.world.in_commodity) {
81 state.world.execute_serial_over_nation([&](auto nation_indices) {
82 state.world.nation_set_rgo_goods_output(nation_indices, cmod, 0.0f);
83 });
84 }
85 for(auto cmod : state.world.in_commodity) {
86 state.world.execute_serial_over_nation([&](auto nation_indices) {
87 state.world.nation_set_factory_goods_output(nation_indices, cmod, 0.0f);
88 });
89 }
90 for(auto cmod : state.world.in_commodity) {
91 state.world.execute_serial_over_nation([&](auto nation_indices) {
92 state.world.nation_set_rgo_size(nation_indices, cmod, 0.0f);
93 });
94 }
95 for(auto cmod : state.world.in_commodity) {
96 state.world.execute_serial_over_nation([&](auto nation_indices) {
97 state.world.nation_set_factory_goods_throughput(nation_indices, cmod, 0.0f);
98 });
99 }
100 for(auto cmod : state.world.in_rebel_type) {
101 state.world.execute_serial_over_nation([&](auto nation_indices) {
102 state.world.nation_set_rebel_org_modifier(nation_indices, cmod, 0.0f);
103 });
104 }
105 state.world.execute_serial_over_nation([&](auto nation_indices) {
106 state.world.nation_set_has_gas_attack(nation_indices, ve::vbitfield_type{ 0 });
107 });
108 state.world.execute_serial_over_nation([&](auto nation_indices) {
109 state.world.nation_set_has_gas_defense(nation_indices, ve::vbitfield_type{ 0 });
110 });
112}
113
115 state.world.for_each_technology([&](dcon::technology_id t_id) {
116 auto tech_id = fatten(state.world, t_id);
117
118 // apply modifiers from active technologies
119 /*
120 auto tech_mod = tech_id.get_modifier();
121 if(tech_mod) {
122 auto& tech_nat_values = tech_mod.get_national_values();
123 for(uint32_t i = 0; i < sys::national_modifier_definition::modifier_definition_size; ++i) {
124 if(!(tech_nat_values.offsets[i]))
125 break; // no more modifier values attached to this tech
126
127 state.world.execute_serial_over_nation([&,
128 fixed_offset = tech_nat_values.offsets[i],
129 modifier_amount = tech_nat_values.values[i]
130 ](auto nation_indices) {
131 auto has_tech_mask = state.world.nation_get_active_technologies(nation_indices, t_id);
132 auto old_mod_value = state.world.nation_get_modifier_values(nation_indices, fixed_offset);
133 state.world.nation_set_modifier_values(nation_indices, fixed_offset,
134 ve::select(has_tech_mask, old_mod_value + modifier_amount, old_mod_value));
135 });
136 }
137 }
138 */
139
141 if(tech_id.get_increase_building(t)) {
142 state.world.execute_serial_over_nation([&](auto nation_indices) {
143 auto has_tech_mask = state.world.nation_get_active_technologies(nation_indices, t_id);
144 auto old_rr_value = state.world.nation_get_max_building_level(nation_indices, uint8_t(t));
145 state.world.nation_set_max_building_level(nation_indices, uint8_t(t), ve::select(has_tech_mask, old_rr_value + 1, old_rr_value));
146 });
147 }
148 }
149
150 //if(tech_id.get_colonial_points() != 0.0f) {
151 // auto amount = tech_id.get_colonial_points();
152 // state.world.execute_serial_over_nation([&](auto nation_indices) {
153 // auto has_tech_mask = state.world.nation_get_active_technologies(nation_indices, t_id);
154 // auto old_cp_value = state.world.nation_get_permanent_colonial_points(nation_indices);
155 // state.world.nation_set_permanent_colonial_points(nation_indices, ve::select(has_tech_mask, old_cp_value + amount, old_cp_value));
156 // });
157 //}
158
159 state.world.for_each_factory_type([&](dcon::factory_type_id id) {
160 if(tech_id.get_activate_building(id)) {
161 state.world.execute_serial_over_nation([&](auto nation_indices) {
162 auto has_tech_mask = state.world.nation_get_active_technologies(nation_indices, t_id);
163 auto old_value = state.world.nation_get_active_building(nation_indices, id);
164 state.world.nation_set_active_building(nation_indices, id, old_value | has_tech_mask);
165 });
166 }
167 });
168 for(uint32_t i = 0; i < state.military_definitions.unit_base_definitions.size(); ++i) {
169 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
170 if(tech_id.get_activate_unit(uid)) {
171 state.world.execute_serial_over_nation([&](auto nation_indices) {
172 auto has_tech_mask = state.world.nation_get_active_technologies(nation_indices, t_id);
173 auto old_value = state.world.nation_get_active_unit(nation_indices, uid);
174 state.world.nation_set_active_unit(nation_indices, uid, old_value | has_tech_mask);
175 });
176 }
177 }
178
179 for(auto cmod : tech_id.get_rgo_goods_output()) {
180 state.world.execute_serial_over_nation([&](auto nation_indices) {
181 auto has_tech_mask = state.world.nation_get_active_technologies(nation_indices, t_id);
182 auto old_value = state.world.nation_get_rgo_goods_output(nation_indices, cmod.type);
183 state.world.nation_set_rgo_goods_output(nation_indices, cmod.type,
184 ve::select(has_tech_mask, old_value + cmod.amount, old_value));
185 });
186 }
187 for(auto cmod : tech_id.get_factory_goods_output()) {
188 state.world.execute_serial_over_nation([&](auto nation_indices) {
189 auto has_tech_mask = state.world.nation_get_active_technologies(nation_indices, t_id);
190 auto old_value = state.world.nation_get_factory_goods_output(nation_indices, cmod.type);
191 state.world.nation_set_factory_goods_output(nation_indices, cmod.type,
192 ve::select(has_tech_mask, old_value + cmod.amount, old_value));
193 });
194 }
195 for(auto cmod : tech_id.get_rgo_size()) {
196 state.world.execute_serial_over_nation([&](auto nation_indices) {
197 auto has_tech_mask = state.world.nation_get_active_technologies(nation_indices, t_id);
198 auto old_value = state.world.nation_get_rgo_size(nation_indices, cmod.type);
199 state.world.nation_set_rgo_size(nation_indices, cmod.type, ve::select(has_tech_mask, old_value + cmod.amount, old_value));
200 });
201 }
202 for(auto& umod : tech_id.get_modified_units()) {
203 state.world.for_each_nation([&](dcon::nation_id nid) {
204 if(state.world.nation_get_active_technologies(nid, t_id)) {
205 state.world.nation_get_unit_stats(nid, umod.type) += umod;
206 }
207 });
208 }
209 });
210}
211
213 state.world.for_each_invention([&](dcon::invention_id i_id) {
214 auto inv_id = fatten(state.world, i_id);
215
216 // apply modifiers from active inventions
217 /*
218 auto inv_mod = inv_id.get_modifier();
219 if(inv_mod) {
220 auto& inv_nat_values = inv_mod.get_national_values();
221 for(uint32_t i = 0; i < sys::national_modifier_definition::modifier_definition_size; ++i) {
222 if(!(inv_nat_values.offsets[i]))
223 break; // no more modifier values attached to this invention
224
225 state.world.execute_serial_over_nation([&,
226 fixed_offset = inv_nat_values.offsets[i],
227 modifier_amount = inv_nat_values.values[i]
228 ](auto nation_indices) {
229 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
230 auto old_mod_value = state.world.nation_get_modifier_values(nation_indices, fixed_offset);
231 state.world.nation_set_modifier_values(nation_indices, fixed_offset,
232 ve::select(has_inv_mask, old_mod_value + modifier_amount, old_mod_value));
233 });
234 }
235 }
236 */
237
239 if(inv_id.get_increase_building(t)) {
240 state.world.execute_serial_over_nation([&](auto nation_indices) {
241 auto has_tech_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
242 auto old_rr_value = state.world.nation_get_max_building_level(nation_indices, uint8_t(t));
243 state.world.nation_set_max_building_level(nation_indices, uint8_t(t), ve::select(has_tech_mask, old_rr_value + 1, old_rr_value));
244 });
245 }
246 }
247
248 if(inv_id.get_enable_gas_attack()) {
249 state.world.execute_serial_over_nation([&](auto nation_indices) {
250 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
251 auto old_value = state.world.nation_get_has_gas_attack(nation_indices);
252 state.world.nation_set_has_gas_attack(nation_indices, old_value | has_inv_mask);
253 });
254 }
255 if(inv_id.get_enable_gas_defense()) {
256 state.world.execute_serial_over_nation([&](auto nation_indices) {
257 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
258 auto old_value = state.world.nation_get_has_gas_defense(nation_indices);
259 state.world.nation_set_has_gas_defense(nation_indices, old_value | has_inv_mask);
260 });
261 }
262
263 //if(inv_id.get_colonial_points() != 0.0f) {
264 // auto amount = inv_id.get_colonial_points();
265 // state.world.execute_serial_over_nation([&](auto nation_indices) {
266 // auto has_tech_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
267 // auto old_cp_value = state.world.nation_get_permanent_colonial_points(nation_indices);
268 // state.world.nation_set_permanent_colonial_points(nation_indices, ve::select(has_tech_mask, old_cp_value + amount, old_cp_value));
269 // });
270 //}
271
272 state.world.for_each_factory_type([&](dcon::factory_type_id id) {
273 if(inv_id.get_activate_building(id)) {
274 state.world.execute_serial_over_nation([&](auto nation_indices) {
275 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
276 auto old_value = state.world.nation_get_active_building(nation_indices, id);
277 state.world.nation_set_active_building(nation_indices, id, old_value | has_inv_mask);
278 });
279 }
280 });
281 for(uint32_t i = 0; i < state.military_definitions.unit_base_definitions.size(); ++i) {
282 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
283 if(inv_id.get_activate_unit(uid)) {
284 state.world.execute_serial_over_nation([&](auto nation_indices) {
285 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
286 auto old_value = state.world.nation_get_active_unit(nation_indices, uid);
287 state.world.nation_set_active_unit(nation_indices, uid, old_value | has_inv_mask);
288 });
289 }
290 }
291 for(uint32_t i = 0; i < state.culture_definitions.crimes.size(); ++i) {
292 dcon::crime_id uid = dcon::crime_id{dcon::crime_id::value_base_t(i)};
293 if(inv_id.get_activate_crime(uid)) {
294 state.world.execute_serial_over_nation([&](auto nation_indices) {
295 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
296 auto old_value = state.world.nation_get_active_crime(nation_indices, uid);
297 state.world.nation_set_active_crime(nation_indices, uid, old_value | has_inv_mask);
298 });
299 }
300 }
301
302 for(auto cmod : inv_id.get_rgo_goods_output()) {
303 state.world.execute_serial_over_nation([&](auto nation_indices) {
304 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
305 auto old_value = state.world.nation_get_rgo_goods_output(nation_indices, cmod.type);
306 state.world.nation_set_rgo_goods_output(nation_indices, cmod.type,
307 ve::select(has_inv_mask, old_value + cmod.amount, old_value));
308 });
309 }
310 for(auto cmod : inv_id.get_rgo_size()) {
311 state.world.execute_serial_over_nation([&](auto nation_indices) {
312 auto has_tech_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
313 auto old_value = state.world.nation_get_rgo_size(nation_indices, cmod.type);
314 state.world.nation_set_rgo_size(nation_indices, cmod.type, ve::select(has_tech_mask, old_value + cmod.amount, old_value));
315 });
316 }
317 for(auto cmod : inv_id.get_factory_goods_output()) {
318 state.world.execute_serial_over_nation([&](auto nation_indices) {
319 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
320 auto old_value = state.world.nation_get_factory_goods_output(nation_indices, cmod.type);
321 state.world.nation_set_factory_goods_output(nation_indices, cmod.type,
322 ve::select(has_inv_mask, old_value + cmod.amount, old_value));
323 });
324 }
325 for(auto cmod : inv_id.get_factory_goods_throughput()) {
326 state.world.execute_serial_over_nation([&](auto nation_indices) {
327 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
328 auto old_value = state.world.nation_get_factory_goods_throughput(nation_indices, cmod.type);
329 state.world.nation_set_factory_goods_throughput(nation_indices, cmod.type,
330 ve::select(has_inv_mask, old_value + cmod.amount, old_value));
331 });
332 }
333 for(auto cmod : inv_id.get_rebel_org()) {
334 state.world.execute_serial_over_nation([&](auto nation_indices) {
335 auto has_inv_mask = state.world.nation_get_active_inventions(nation_indices, i_id);
336 if(cmod.type) {
337 auto old_value = state.world.nation_get_rebel_org_modifier(nation_indices, cmod.type);
338 state.world.nation_set_rebel_org_modifier(nation_indices, cmod.type,
339 ve::select(has_inv_mask, old_value + cmod.amount, old_value));
340 } else if(has_inv_mask.v != 0) {
341 state.world.for_each_rebel_type([&](dcon::rebel_type_id rt) {
342 auto old_value = state.world.nation_get_rebel_org_modifier(nation_indices, rt);
343 state.world.nation_set_rebel_org_modifier(nation_indices, rt,
344 ve::select(has_inv_mask, old_value + cmod.amount, old_value));
345 });
346 }
347 });
348 }
349 for(auto& umod : inv_id.get_modified_units()) {
350 state.world.for_each_nation([&](dcon::nation_id nid) {
351 if(state.world.nation_get_active_inventions(nid, i_id)) {
352 auto& existing_stats = state.world.nation_get_unit_stats(nid, umod.type);
353 existing_stats += umod;
354 }
355 });
356 }
357 });
358}
359
360void apply_technology(sys::state& state, dcon::nation_id target_nation, dcon::technology_id t_id) {
361 auto tech_id = fatten(state.world, t_id);
362
363 state.world.nation_set_active_technologies(target_nation, t_id, true);
364
365 auto tech_mod = tech_id.get_modifier();
366 if(tech_mod) {
367 auto& tech_nat_values = tech_mod.get_national_values();
369 if(!(tech_nat_values.offsets[i]))
370 break; // no more modifier values attached to this tech
371
372 auto fixed_offset = tech_nat_values.offsets[i];
373 auto modifier_amount = tech_nat_values.values[i];
374
375 state.world.nation_get_modifier_values(target_nation, fixed_offset) += modifier_amount;
376 }
377 }
378
379 auto& plur = state.world.nation_get_plurality(target_nation);
380 plur = std::clamp(plur + tech_id.get_plurality() * 100.0f, 0.0f, 100.0f);
381
383 if(tech_id.get_increase_building(t)) {
384 state.world.nation_get_max_building_level(target_nation, uint8_t(t)) += 1;
385 }
386 }
387 state.world.nation_get_permanent_colonial_points(target_nation) += tech_id.get_colonial_points();
388 state.world.for_each_factory_type([&](dcon::factory_type_id id) {
389 if(tech_id.get_activate_building(id)) {
390 state.world.nation_set_active_building(target_nation, id, true);
391 }
392 });
393 for(uint32_t i = 0; i < state.military_definitions.unit_base_definitions.size(); ++i) {
394 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
395 if(tech_id.get_activate_unit(uid)) {
396 state.world.nation_set_active_unit(target_nation, uid, true);
397 }
398 }
399
400 for(auto cmod : tech_id.get_rgo_goods_output()) {
401 state.world.nation_get_rgo_goods_output(target_nation, cmod.type) += cmod.amount;
402 }
403 for(auto cmod : tech_id.get_factory_goods_output()) {
404 state.world.nation_get_factory_goods_output(target_nation, cmod.type) += cmod.amount;
405 }
406 for(auto cmod : tech_id.get_rgo_size()) {
407 state.world.nation_get_rgo_size(target_nation, cmod.type) += cmod.amount;
408 }
409 for(auto& umod : tech_id.get_modified_units()) {
410 if(umod.type == state.military_definitions.base_army_unit) {
411 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size(); ++i) {
412 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
413 if(state.military_definitions.unit_base_definitions[uid].is_land) {
414 state.world.nation_get_unit_stats(target_nation, uid) += umod;
415 }
416 }
417 } else if(umod.type == state.military_definitions.base_naval_unit) {
418 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size(); ++i) {
419 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
420 if(!state.military_definitions.unit_base_definitions[uid].is_land) {
421 state.world.nation_get_unit_stats(target_nation, uid) += umod;
422 }
423 }
424 } else {
425 state.world.nation_get_unit_stats(target_nation, umod.type) += umod;
426 }
427 }
428}
429
430void remove_technology(sys::state& state, dcon::nation_id target_nation, dcon::technology_id t_id) {
431 auto tech_id = fatten(state.world, t_id);
432
433 state.world.nation_set_active_technologies(target_nation, t_id, false);
434
435 auto tech_mod = tech_id.get_modifier();
436 if(tech_mod) {
437 auto& tech_nat_values = tech_mod.get_national_values();
439 if(!(tech_nat_values.offsets[i]))
440 break; // no more modifier values attached to this tech
441
442 auto fixed_offset = tech_nat_values.offsets[i];
443 auto modifier_amount = tech_nat_values.values[i];
444
445 state.world.nation_get_modifier_values(target_nation, fixed_offset) -= modifier_amount;
446 }
447 }
448
449 auto& plur = state.world.nation_get_plurality(target_nation);
450 plur = std::clamp(plur - tech_id.get_plurality() * 100.0f, 0.0f, 100.0f);
451
453 if(tech_id.get_increase_building(t)) {
454 state.world.nation_get_max_building_level(target_nation, uint8_t(t)) -= 1;
455 }
456 }
457 state.world.nation_get_permanent_colonial_points(target_nation) -= tech_id.get_colonial_points();
458 state.world.for_each_factory_type([&](dcon::factory_type_id id) {
459 if(tech_id.get_activate_building(id)) {
460 state.world.nation_set_active_building(target_nation, id, false);
461 }
462 });
463 for(uint32_t i = 0; i < state.military_definitions.unit_base_definitions.size(); ++i) {
464 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
465 if(tech_id.get_activate_unit(uid)) {
466 state.world.nation_set_active_unit(target_nation, uid, false);
467 }
468 }
469
470 for(auto cmod : tech_id.get_rgo_goods_output()) {
471 state.world.nation_get_rgo_goods_output(target_nation, cmod.type) -= cmod.amount;
472 }
473 for(auto cmod : tech_id.get_factory_goods_output()) {
474 state.world.nation_get_factory_goods_output(target_nation, cmod.type) -= cmod.amount;
475 }
476 for(auto cmod : tech_id.get_rgo_size()) {
477 state.world.nation_get_rgo_size(target_nation, cmod.type) -= cmod.amount;
478 }
479 for(auto& umod : tech_id.get_modified_units()) {
480 if(umod.type == state.military_definitions.base_army_unit) {
481 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size(); ++i) {
482 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
483 if(state.military_definitions.unit_base_definitions[uid].is_land) {
484 state.world.nation_get_unit_stats(target_nation, uid) -= umod;
485 }
486 }
487 } else if(umod.type == state.military_definitions.base_naval_unit) {
488 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size(); ++i) {
489 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
490 if(!state.military_definitions.unit_base_definitions[uid].is_land) {
491 state.world.nation_get_unit_stats(target_nation, uid) -= umod;
492 }
493 }
494 } else {
495 state.world.nation_get_unit_stats(target_nation, umod.type) -= umod;
496 }
497 }
498}
499
500void apply_invention(sys::state& state, dcon::nation_id target_nation, dcon::invention_id i_id) { // TODO: shared prestige effect
501 auto inv_id = fatten(state.world, i_id);
502
503 state.world.nation_set_active_inventions(target_nation, i_id, true);
504
505 // apply modifiers from active inventions
506 auto inv_mod = inv_id.get_modifier();
507 if(inv_mod) {
508 auto& inv_nat_values = inv_mod.get_national_values();
510 if(!(inv_nat_values.offsets[i]))
511 break; // no more modifier values attached to this tech
512
513 auto fixed_offset = inv_nat_values.offsets[i];
514 auto modifier_amount = inv_nat_values.values[i];
515
516 state.world.nation_get_modifier_values(target_nation, fixed_offset) += modifier_amount;
517 }
518 }
519
521 if(inv_id.get_increase_building(t)) {
522 state.world.nation_get_max_building_level(target_nation, uint8_t(t)) += 1;
523 }
524 }
525
526 state.world.nation_get_permanent_colonial_points(target_nation) += inv_id.get_colonial_points();
527 if(inv_id.get_enable_gas_attack()) {
528 state.world.nation_set_has_gas_attack(target_nation, true);
529 }
530 if(inv_id.get_enable_gas_defense()) {
531 state.world.nation_set_has_gas_defense(target_nation, true);
532 }
533
534 auto& plur = state.world.nation_get_plurality(target_nation);
535 plur = std::clamp(plur + inv_id.get_plurality() * 100.0f, 0.0f, 100.0f);
536
537 state.world.for_each_factory_type([&](dcon::factory_type_id id) {
538 if(inv_id.get_activate_building(id)) {
539 state.world.nation_set_active_building(target_nation, id, true);
540 }
541 });
542 for(uint32_t i = 0; i < state.military_definitions.unit_base_definitions.size(); ++i) {
543 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
544 if(inv_id.get_activate_unit(uid)) {
545 state.world.nation_set_active_unit(target_nation, uid, true);
546 }
547 }
548 for(uint32_t i = 0; i < state.culture_definitions.crimes.size(); ++i) {
549 dcon::crime_id uid = dcon::crime_id{dcon::crime_id::value_base_t(i)};
550 if(inv_id.get_activate_crime(uid)) {
551 state.world.nation_set_active_crime(target_nation, uid, true);
552 }
553 }
554
555 for(auto cmod : inv_id.get_rgo_goods_output()) {
556 state.world.nation_get_rgo_goods_output(target_nation, cmod.type) += cmod.amount;
557 }
558 for(auto cmod : inv_id.get_rgo_size()) {
559 state.world.nation_get_rgo_size(target_nation, cmod.type) += cmod.amount;
560 }
561 for(auto cmod : inv_id.get_factory_goods_output()) {
562 state.world.nation_get_factory_goods_output(target_nation, cmod.type) += cmod.amount;
563 }
564 for(auto cmod : inv_id.get_factory_goods_throughput()) {
565 state.world.nation_get_factory_goods_throughput(target_nation, cmod.type) += cmod.amount;
566 }
567 for(auto cmod : inv_id.get_rebel_org()) {
568 if(cmod.type) {
569 state.world.nation_get_rebel_org_modifier(target_nation, cmod.type) += cmod.amount;
570 } else {
571 state.world.for_each_rebel_type(
572 [&](dcon::rebel_type_id rt) { state.world.nation_get_rebel_org_modifier(target_nation, rt) += cmod.amount; });
573 }
574 }
575 for(auto& umod : inv_id.get_modified_units()) {
576 if(umod.type == state.military_definitions.base_army_unit) {
577 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size(); ++i) {
578 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
579 if(state.military_definitions.unit_base_definitions[uid].is_land) {
580 state.world.nation_get_unit_stats(target_nation, uid) += umod;
581 }
582 }
583 } else if(umod.type == state.military_definitions.base_naval_unit) {
584 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size(); ++i) {
585 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
586 if(!state.military_definitions.unit_base_definitions[uid].is_land) {
587 state.world.nation_get_unit_stats(target_nation, uid) += umod;
588 }
589 }
590 } else {
591 state.world.nation_get_unit_stats(target_nation, umod.type) += umod;
592 }
593 }
594
595 if(auto p = inv_id.get_shared_prestige(); p > 0) {
596 int32_t total = 0;
597 for(auto n : state.world.in_nation) {
598 if(n.get_active_inventions(i_id)) {
599 ++total;
600 }
601 }
602 nations::adjust_prestige(state, target_nation, p / float(total));
603 }
604}
605
606void remove_invention(sys::state& state, dcon::nation_id target_nation,
607 dcon::invention_id i_id) { // TODO: shared prestige effect
608 auto inv_id = fatten(state.world, i_id);
609
610 state.world.nation_set_active_inventions(target_nation, i_id, false);
611
612 // apply modifiers from active inventions
613 auto inv_mod = inv_id.get_modifier();
614 if(inv_mod) {
615 auto& inv_nat_values = inv_mod.get_national_values();
617 if(!(inv_nat_values.offsets[i]))
618 break; // no more modifier values attached to this tech
619
620 auto fixed_offset = inv_nat_values.offsets[i];
621 auto modifier_amount = inv_nat_values.values[i];
622
623 state.world.nation_get_modifier_values(target_nation, fixed_offset) -= modifier_amount;
624 }
625 }
626
628 if(inv_id.get_increase_building(t)) {
629 state.world.nation_get_max_building_level(target_nation, uint8_t(t)) -= 1;
630 }
631 }
632
633 state.world.nation_get_permanent_colonial_points(target_nation) -= inv_id.get_colonial_points();
634 if(inv_id.get_enable_gas_attack()) {
635 state.world.nation_set_has_gas_attack(target_nation, false);
636 }
637 if(inv_id.get_enable_gas_defense()) {
638 state.world.nation_set_has_gas_defense(target_nation, false);
639 }
640
641 auto& plur = state.world.nation_get_plurality(target_nation);
642 plur = std::clamp(plur - inv_id.get_plurality() * 100.0f, 0.0f, 100.0f);
643
644 state.world.for_each_factory_type([&](dcon::factory_type_id id) {
645 if(inv_id.get_activate_building(id)) {
646 state.world.nation_set_active_building(target_nation, id, false);
647 }
648 });
649 for(uint32_t i = 0; i < state.military_definitions.unit_base_definitions.size(); ++i) {
650 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
651 if(inv_id.get_activate_unit(uid)) {
652 state.world.nation_set_active_unit(target_nation, uid, false);
653 }
654 }
655 for(uint32_t i = 0; i < state.culture_definitions.crimes.size(); ++i) {
656 dcon::crime_id uid = dcon::crime_id{dcon::crime_id::value_base_t(i)};
657 if(inv_id.get_activate_crime(uid)) {
658 state.world.nation_set_active_crime(target_nation, uid, false);
659 }
660 }
661
662 for(auto cmod : inv_id.get_rgo_goods_output()) {
663 state.world.nation_get_rgo_goods_output(target_nation, cmod.type) -= cmod.amount;
664 }
665 for(auto cmod : inv_id.get_rgo_size()) {
666 state.world.nation_get_rgo_size(target_nation, cmod.type) -= cmod.amount;
667 }
668 for(auto cmod : inv_id.get_factory_goods_output()) {
669 state.world.nation_get_factory_goods_output(target_nation, cmod.type) -= cmod.amount;
670 }
671 for(auto cmod : inv_id.get_factory_goods_throughput()) {
672 state.world.nation_get_factory_goods_throughput(target_nation, cmod.type) -= cmod.amount;
673 }
674 for(auto cmod : inv_id.get_rebel_org()) {
675 if(cmod.type) {
676 state.world.nation_get_rebel_org_modifier(target_nation, cmod.type) -= cmod.amount;
677 } else {
678 state.world.for_each_rebel_type(
679 [&](dcon::rebel_type_id rt) { state.world.nation_get_rebel_org_modifier(target_nation, rt) -= cmod.amount; });
680 }
681 }
682 for(auto& umod : inv_id.get_modified_units()) {
683 if(umod.type == state.military_definitions.base_army_unit) {
684 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size(); ++i) {
685 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
686 if(state.military_definitions.unit_base_definitions[uid].is_land) {
687 state.world.nation_get_unit_stats(target_nation, uid) -= umod;
688 }
689 }
690 } else if(umod.type == state.military_definitions.base_naval_unit) {
691 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size(); ++i) {
692 dcon::unit_type_id uid = dcon::unit_type_id{dcon::unit_type_id::value_base_t(i)};
693 if(!state.military_definitions.unit_base_definitions[uid].is_land) {
694 state.world.nation_get_unit_stats(target_nation, uid) -= umod;
695 }
696 }
697 } else {
698 state.world.nation_get_unit_stats(target_nation, umod.type) -= umod;
699 }
700 }
701
702 if(auto p = inv_id.get_shared_prestige(); p > 0) {
703 int32_t total = 0;
704 for(auto n : state.world.in_nation) {
705 if(n.get_active_inventions(i_id)) {
706 ++total;
707 }
708 }
709 nations::adjust_prestige(state, target_nation, -(p / float(total + 1)));
710 }
711}
712
714 return state.flag_type_map[static_cast<size_t>(type)];
715}
716
717flag_type get_current_flag_type(sys::state const& state, dcon::nation_id target_nation) {
718 if(state.world.nation_get_owned_province_count(target_nation) == 0)
719 return flag_type::default_flag;
720
721 auto gov_type = state.world.nation_get_government_type(target_nation);
722 if(!gov_type)
723 return flag_type::default_flag;
724
725 auto id = state.world.national_identity_get_government_flag_type(state.world.nation_get_identity_from_identity_holder(target_nation), gov_type);
726 if(id != 0)
727 return flag_type(id - 1);
728
729 return flag_type(state.world.government_type_get_flag(gov_type));
730}
731
732flag_type get_current_flag_type(sys::state const& state, dcon::national_identity_id identity) {
733 auto holder = state.world.national_identity_get_nation_from_identity_holder(identity);
734 if(holder) {
735 return get_current_flag_type(state, holder);
736 } else {
737 return flag_type::default_flag;
738 }
739}
740void fix_slaves_in_province(sys::state& state, dcon::nation_id owner, dcon::province_id p) {
741 auto rules = state.world.nation_get_combined_issue_rules(owner);
742 if(!owner || (rules & issue_rule::slavery_allowed) == 0) {
743 state.world.province_set_is_slave(p, false);
744 bool mine = state.world.commodity_get_is_mine(state.world.province_get_rgo(p));
745 for(auto pop : state.world.province_get_pop_location(p)) {
746 if(pop.get_pop().get_poptype() == state.culture_definitions.slaves) {
747 pop.get_pop().set_poptype(mine ? state.culture_definitions.laborers : state.culture_definitions.farmers);
748 }
749 }
750 } else if(state.world.province_get_is_slave(p) == false) { // conversely, could become a slave state if slaves are found
751 bool found_slave = false;
752 for(auto pop : state.world.province_get_pop_location(p)) {
753 if(pop.get_pop().get_poptype() == state.culture_definitions.slaves) {
754 found_slave = true;
755 break;
756 }
757 }
758 if(found_slave) {
759 province::for_each_province_in_state_instance(state, state.world.province_get_state_membership(p), [&](dcon::province_id p2) {
760 state.world.province_set_is_slave(p2, true);
761 });
762 }
763 }
764}
765
766void update_nation_issue_rules(sys::state& state, dcon::nation_id n_id) {
767 auto old_rules = state.world.nation_get_combined_issue_rules(n_id);
768 uint32_t combined = 0;
769 state.world.for_each_issue([&](dcon::issue_id i_id) {
770 auto current_opt = state.world.nation_get_issues(n_id, i_id);
771 auto rules_for_opt = state.world.issue_option_get_rules(current_opt);
772 combined |= rules_for_opt;
773 });
774 state.world.for_each_reform([&](dcon::reform_id i_id) {
775 auto current_opt = state.world.nation_get_reforms(n_id, i_id);
776 auto rules_for_opt = state.world.reform_option_get_rules(current_opt);
777 combined |= rules_for_opt;
778 });
779 state.world.nation_set_combined_issue_rules(n_id, combined);
780
781 if((old_rules & issue_rule::slavery_allowed) != 0 && (combined & issue_rule::slavery_allowed) == 0) {
782
783 for(auto p : state.world.nation_get_province_ownership(n_id)) {
784 state.world.province_set_is_slave(p.get_province(), false);
785 bool mine = state.world.commodity_get_is_mine(state.world.province_get_rgo(p.get_province()));
786 for(auto pop : state.world.province_get_pop_location(p.get_province())) {
787 if(pop.get_pop().get_poptype() == state.culture_definitions.slaves) {
788 pop.get_pop().set_poptype(mine ? state.culture_definitions.laborers : state.culture_definitions.farmers);
789 }
790 }
791 }
792 }
793 if((old_rules & issue_rule::can_subsidise) != 0 && (combined & issue_rule::can_subsidise) == 0) {
794 for(auto p : state.world.nation_get_province_ownership(n_id)) {
795 for(auto f : p.get_province().get_factory_location()) {
796 f.get_factory().set_subsidized(false);
797 }
798 }
799 }
800}
802 state.world.execute_serial_over_nation([&](auto n_id) {
803 ve::int_vector combined;
804 state.world.for_each_issue([&](dcon::issue_id i_id) {
805 auto current_opt = state.world.nation_get_issues(n_id, i_id);
806 auto rules_for_opt = state.world.issue_option_get_rules(current_opt);
807 combined = combined | rules_for_opt;
808 });
809 state.world.for_each_reform([&](dcon::reform_id i_id) {
810 auto current_opt = state.world.nation_get_reforms(n_id, i_id);
811 auto rules_for_opt = state.world.reform_option_get_rules(current_opt);
812 combined = combined | rules_for_opt;
813 });
814 state.world.nation_set_combined_issue_rules(n_id, combined);
815 });
816}
817
819 state.world.for_each_pop([&state](dcon::pop_id pid) {
820 float total = 0.0f;
821 float pol_sup = 0.0f;
822 float soc_sup = 0.0f;
823 state.world.for_each_issue_option([&](dcon::issue_option_id i) {
824 auto sup = pop_demographics::get_demo(state, pid, pop_demographics::to_key(state, i));
825 total += sup;
826
827 auto par = state.world.issue_option_get_parent_issue(i);
828 if(state.world.issue_get_issue_type(par) == uint8_t(culture::issue_type::political)) {
829 pol_sup += sup;
830 } else if(state.world.issue_get_issue_type(par) == uint8_t(culture::issue_type::social)) {
831 soc_sup += sup;
832 }
833 });
834 if(total > 0) {
835 pop_demographics::set_political_reform_desire(state, pid, pol_sup / total);
836 pop_demographics::set_social_reform_desire(state, pid, soc_sup / total);
837 }
838 });
839}
840
842 state.world.for_each_pop([&state](dcon::pop_id pid) {
843 auto ptype = state.world.pop_get_poptype(pid);
844 auto owner = nations::owner_of_pop(state, pid);
845 auto psize = state.world.pop_get_size(pid);
846 if(psize <= 0)
847 return;
848
849 { // ideologies
850 static auto buf = state.world.ideology_make_vectorizable_float_buffer();
851 float total = 0.0f;
852 state.world.for_each_ideology([&](dcon::ideology_id iid) {
853 buf.set(iid, 0.0f);
854 if(state.world.ideology_get_enabled(iid) &&
855 (!state.world.ideology_get_is_civilized_only(iid) || state.world.nation_get_is_civilized(owner))) {
856 auto ptrigger = state.world.pop_type_get_ideology(ptype, iid);
857 if(ptrigger) {
858 auto amount = trigger::evaluate_multiplicative_modifier(state, ptrigger, trigger::to_generic(pid),
859 trigger::to_generic(pid), 0);
860 buf.set(iid, amount);
861 total += amount;
862 }
863 }
864 });
865 if(total != 0) {
866 float adjustment_factor = 1.0f / total;
867 state.world.for_each_ideology([&state, pid, adjustment_factor](dcon::ideology_id iid) {
868 auto normalized_amount = buf.get(iid) * adjustment_factor;
869 pop_demographics::set_demo(state, pid, pop_demographics::to_key(state, iid), normalized_amount);
870 });
871 }
872 }
873 { // issues
874 static auto buf = state.world.issue_option_make_vectorizable_float_buffer();
875 float total = 0.0f;
876 state.world.for_each_issue_option([&](dcon::issue_option_id iid) {
877 auto opt = fatten(state.world, iid);
878 auto allow = opt.get_allow();
879 auto parent_issue = opt.get_parent_issue();
880 auto co = state.world.nation_get_issues(owner, parent_issue);
881 buf.set(iid, 0.0f);
882 if((state.world.nation_get_is_civilized(owner) || state.world.issue_get_issue_type(parent_issue) == uint8_t(issue_type::party))
883 && (state.world.issue_get_is_next_step_only(parent_issue) == false || co.id.index() == iid.index() || co.id.index() + 1 == iid.index() || co.id.index() - 1 == iid.index())) {
884
885 if(auto mtrigger = state.world.pop_type_get_issues(ptype, iid); mtrigger) {
886 auto amount = trigger::evaluate_multiplicative_modifier(state, mtrigger, trigger::to_generic(pid),
887 trigger::to_generic(pid), 0);
888 buf.set(iid, amount);
889 total += amount;
890 }
891 }
892 });
893 if(total != 0) {
894 float adjustment_factor = 1.0f / total;
895 state.world.for_each_issue_option([&state, pid, adjustment_factor](dcon::issue_option_id iid) {
896 auto normalized_amount = buf.get(iid) * adjustment_factor;
897 pop_demographics::set_demo(state, pid, pop_demographics::to_key(state, iid), normalized_amount);
898 });
899 }
900 }
901 });
902}
903
904float effective_technology_cost(sys::state& state, uint32_t current_year, dcon::nation_id target_nation,
905 dcon::technology_id tech_id) {
906 /*
907 The effective amount of research points a tech costs = base-cost x 0v(1 - (current-year - tech-availability-year) /
908 define:TECH_YEAR_SPAN) x define:TECH_FACTOR_VASSAL(if your overlord has the tech) / (1 + tech-category-research-modifier)
909 */
910 auto base_cost = state.world.technology_get_cost(tech_id);
911 auto availability_year = state.world.technology_get_year(tech_id);
912 auto folder = state.world.technology_get_folder_index(tech_id);
913 auto category = state.culture_definitions.tech_folders[folder].category;
914 auto research_mod = [&]() {
915 switch(category) {
916 case tech_category::army:
917 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::army_tech_research_bonus) + 1.0f;
918 case tech_category::navy:
919 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::navy_tech_research_bonus) + 1.0f;
920 case tech_category::commerce:
921 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::commerce_tech_research_bonus) + 1.0f;
922 case tech_category::culture:
923 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::culture_tech_research_bonus) + 1.0f;
924 case tech_category::industry:
925 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::industry_tech_research_bonus) + 1.0f;
926 //non vanilla
927 case tech_category::military_theory:
928 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::military_theory_tech_research_bonus) + 1.0f;
929 case tech_category::population:
930 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::population_tech_research_bonus) + 1.0f;
931 case tech_category::diplomacy:
932 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::diplomacy_tech_research_bonus) + 1.0f;
933 case tech_category::flavor:
934 return state.world.nation_get_modifier_values(target_nation, sys::national_mod_offsets::flavor_tech_research_bonus) + 1.0f;
935 default:
936 return 1.0f;
937 }
938 }();
939 auto ol_mod = state.world.nation_get_active_technologies(
940 state.world.overlord_get_ruler(state.world.nation_get_overlord_as_subject(target_nation)), tech_id)
941 ? state.defines.tech_factor_vassal
942 : 1.0f;
943 return float(base_cost) * ol_mod * (1.0f / research_mod) *
944 (1.0f - std::max(0.0f, float(int32_t(current_year) - availability_year) / state.defines.tech_year_span));
945}
946
947void update_research(sys::state& state, uint32_t current_year) {
948 for(auto n : state.world.in_nation) {
949 if(n.get_owned_province_count() != 0 && n.get_current_research()) {
950 if(n.get_active_technologies(n.get_current_research())) {
951 n.set_current_research(dcon::technology_id{});
952 } else {
953 auto cost = effective_technology_cost(state, current_year, n, n.get_current_research());
954 if(n.get_research_points() >= cost) {
955 n.get_research_points() -= cost;
956 apply_technology(state, n, n.get_current_research());
957
959 [t = n.get_current_research()](sys::state& state, text::layout_base& contents) {
960 text::add_line(state, contents, "msg_tech_1", text::variable_type::x, state.world.technology_get_name(t));
961 ui::technology_description(state, contents, t);
962 },
963 "msg_tech_title",
964 n, dcon::nation_id{}, dcon::nation_id{},
966 });
967
968 n.set_current_research(dcon::technology_id{});
969 }
970 }
971 }
972 }
973}
974
976 /*
977 Inventions have a chance to be discovered on the 1st of every month. The invention chance modifier is computed additively, and
978 the result is the chance out of 100 that the invention will be discovered. When an invention with shared prestige is
979 discovered, the discoverer gains that amount of shared prestige / the number of times it has been discovered (including the
980 current time).
981 */
982 for(auto inv : state.world.in_invention) {
983 auto lim = inv.get_limit();
984 auto odds = inv.get_chance();
985 if(lim) {
986 ve::execute_serial_fast<dcon::nation_id>(state.world.nation_size(), [&](auto nids) {
987 auto may_discover = !state.world.nation_get_active_inventions(nids, inv)
988 && (state.world.nation_get_owned_province_count(nids) != 0)
989 && trigger::evaluate(state, lim, trigger::to_generic(nids), trigger::to_generic(nids), 0);
990
991 if(ve::compress_mask(may_discover).v != 0) {
992 auto chances = odds
993 ? trigger::evaluate_additive_modifier(state, odds, trigger::to_generic(nids), trigger::to_generic(nids), 0)
994 : 1.f;
995 ve::apply([&](dcon::nation_id n, float chance, bool allow_discovery) {
996 if(allow_discovery) {
997 auto random = rng::get_random(state, uint32_t(inv.id.index()) << 5 ^ uint32_t(n.index()));
998 if(int32_t(random % 100) < int32_t(chance)) {
999 apply_invention(state, n, inv);
1000
1001 notification::post(state, notification::message{
1002 [inv](sys::state& state, text::layout_base& contents) {
1003 text::add_line(state, contents, "msg_inv_1", text::variable_type::x, state.world.invention_get_name(inv));
1004 ui::invention_description(state, contents, inv, 0);
1005 },
1006 "msg_inv_title",
1007 n, dcon::nation_id{}, dcon::nation_id{},
1008 sys::message_base_type::invention
1009 });
1010 }
1011 }
1012 }, nids, chances, may_discover);
1013 }
1014 });
1015 } else {
1016 ve::execute_serial_fast<dcon::nation_id>(state.world.nation_size(), [&](auto nids) {
1017 auto may_not_discover =
1018 state.world.nation_get_active_inventions(nids, inv) || (state.world.nation_get_owned_province_count(nids) == 0);
1019 if(ve::compress_mask(may_not_discover).v != 0) {
1020 auto chances = odds
1021 ? trigger::evaluate_additive_modifier(state, odds, trigger::to_generic(nids), trigger::to_generic(nids), 0)
1022 : 1.f;
1023 ve::apply([&](dcon::nation_id n, float chance, bool block_discovery) {
1024 if(!block_discovery) {
1025 auto random = rng::get_random(state, uint32_t(inv.id.index()) << 5 ^ uint32_t(n.index()));
1026 if(int32_t(random % 100) < int32_t(chance)) {
1027 apply_invention(state, n, inv);
1028
1029 notification::post(state, notification::message{
1030 [inv](sys::state& state, text::layout_base& contents) {
1031 text::add_line(state, contents, "msg_inv_1", text::variable_type::x, state.world.invention_get_name(inv));
1032 ui::invention_description(state, contents, inv, 0);
1033 },
1034 "msg_inv_title",
1035 n, dcon::nation_id{}, dcon::nation_id{},
1036 sys::message_base_type::invention
1037 });
1038 }
1039 }
1040 }, nids, chances, may_not_discover);
1041 }
1042 });
1043 }
1044 }
1045}
1046
1047void replace_cores(sys::state& state, dcon::national_identity_id old_tag, dcon::national_identity_id new_tag) {
1048 if(new_tag) {
1049 for(auto cores_of : state.world.national_identity_get_core(old_tag)) {
1050 state.world.try_create_core(cores_of.get_province(), new_tag);
1051 }
1052 }
1053 auto core_list = state.world.national_identity_get_core(old_tag);
1054 while(core_list.begin() != core_list.end()) {
1055 state.world.delete_core((*core_list.begin()).id);
1056 }
1057}
1058
1059} // namespace culture
uint32_t get_remapped_flag_type(sys::state const &state, flag_type type)
Definition: culture.cpp:713
void discover_inventions(sys::state &state)
Definition: culture.cpp:975
void apply_invention(sys::state &state, dcon::nation_id target_nation, dcon::invention_id i_id)
Definition: culture.cpp:500
float effective_technology_cost(sys::state &state, uint32_t current_year, dcon::nation_id target_nation, dcon::technology_id tech_id)
Definition: culture.cpp:904
void fix_slaves_in_province(sys::state &state, dcon::nation_id owner, dcon::province_id p)
Definition: culture.cpp:740
void replace_cores(sys::state &state, dcon::national_identity_id old_tag, dcon::national_identity_id new_tag)
Definition: culture.cpp:1047
void clear_existing_tech_effects(sys::state &state)
Definition: culture.cpp:55
void repopulate_technology_effects(sys::state &state)
Definition: culture.cpp:114
void update_all_nations_issue_rules(sys::state &state)
Definition: culture.cpp:801
void set_default_issue_and_reform_options(sys::state &state)
Definition: culture.cpp:39
void remove_invention(sys::state &state, dcon::nation_id target_nation, dcon::invention_id i_id)
Definition: culture.cpp:606
void repopulate_invention_effects(sys::state &state)
Definition: culture.cpp:212
void update_research(sys::state &state, uint32_t current_year)
Definition: culture.cpp:947
flag_type get_current_flag_type(sys::state const &state, dcon::nation_id target_nation)
Definition: culture.cpp:717
void restore_unsaved_values(sys::state &state)
Definition: culture.cpp:818
void remove_technology(sys::state &state, dcon::nation_id target_nation, dcon::technology_id t_id)
Definition: culture.cpp:430
void create_initial_ideology_and_issues_distribution(sys::state &state)
Definition: culture.cpp:841
void apply_technology(sys::state &state, dcon::nation_id target_nation, dcon::technology_id t_id)
Definition: culture.cpp:360
std::string get_tech_category_name(tech_category t)
Definition: culture.cpp:12
void update_nation_issue_rules(sys::state &state, dcon::nation_id n_id)
Definition: culture.cpp:766
tech_category
Definition: culture.hpp:106
province_building_type
Definition: constants.hpp:578
constexpr uint32_t can_subsidise
Definition: culture.hpp:13
constexpr uint32_t slavery_allowed
Definition: culture.hpp:27
void reset_unit_stats(sys::state &state)
Definition: military.cpp:36
void adjust_prestige(sys::state &state, dcon::nation_id n, float delta)
Definition: nations.cpp:1330
dcon::nation_id owner_of_pop(sys::state const &state, dcon::pop_id pop_ids)
Definition: nations.cpp:69
void post(sys::state &state, message &&m)
void set_political_reform_desire(sys::state &state, dcon::pop_id p, float v)
void set_social_reform_desire(sys::state &state, dcon::pop_id p, float v)
void set_demo(sys::state &state, dcon::pop_id p, dcon::pop_demographics_key k, float v)
dcon::pop_demographics_key to_key(sys::state const &state, dcon::ideology_id v)
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)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
int32_t to_generic(dcon::province_id v)
Definition: triggers.hpp:12
float evaluate_multiplicative_modifier(sys::state &state, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
Definition: triggers.cpp:5782
void technology_description(sys::state &state, text::layout_base &contents, dcon::technology_id tech_id) noexcept
T select(bool v, T a, T b)
uint uint32_t
uchar uint8_t
static constexpr uint32_t modifier_definition_size
Definition: modifiers.hpp:231