Project Alice
Loading...
Searching...
No Matches
military.hpp
Go to the documentation of this file.
1#pragma once
2#include "dcon_generated.hpp"
3#include "container_types.hpp"
4#include "modifiers.hpp"
5
6namespace military {
7namespace cb_flag {
8
9inline constexpr uint32_t is_civil_war = 0x00000001;
10inline constexpr uint32_t always = 0x00000002;
11inline constexpr uint32_t is_triggered_only = 0x00000004;
12inline constexpr uint32_t is_not_constructing_cb = 0x00000008;
13inline constexpr uint32_t great_war_obligatory = 0x00000010;
14inline constexpr uint32_t all_allowed_states = 0x00000020;
15inline constexpr uint32_t not_in_crisis = 0x00000040;
16inline constexpr uint32_t po_clear_union_sphere = 0x00000080;
17inline constexpr uint32_t po_gunboat = 0x00000100;
18inline constexpr uint32_t po_annex = 0x00000200;
19inline constexpr uint32_t po_demand_state = 0x00000400;
20inline constexpr uint32_t po_add_to_sphere = 0x00000800;
21inline constexpr uint32_t po_disarmament = 0x00001000;
22inline constexpr uint32_t po_reparations = 0x00002000;
23inline constexpr uint32_t po_transfer_provinces = 0x00004000;
24inline constexpr uint32_t po_remove_prestige = 0x00008000;
25inline constexpr uint32_t po_make_puppet = 0x00010000;
26inline constexpr uint32_t po_release_puppet = 0x00020000;
27inline constexpr uint32_t po_status_quo = 0x00040000;
28inline constexpr uint32_t po_install_communist_gov_type = 0x00080000;
29inline constexpr uint32_t po_uninstall_communist_gov_type = 0x00100000;
30inline constexpr uint32_t po_remove_cores = 0x00200000;
31inline constexpr uint32_t po_colony = 0x00400000;
32inline constexpr uint32_t po_destroy_forts = 0x00800000;
33inline constexpr uint32_t po_destroy_naval_bases = 0x01000000;
34
35} // namespace cb_flag
36
38 static constexpr uint16_t distance_mask = 0x03FF;
39
40 static constexpr uint16_t mode_mask = 0x1C00;
41 static constexpr uint16_t mode_seeking = 0x0400;
42 static constexpr uint16_t mode_approaching = 0x0800;
43 static constexpr uint16_t mode_engaged = 0x0C00;
44 static constexpr uint16_t mode_retreating = 0x1000;
45 static constexpr uint16_t mode_retreated = 0x1400;
46 static constexpr uint16_t mode_sunk = 0x0000;
47
48 static constexpr uint16_t is_attacking = 0x2000;
49
50 static constexpr uint16_t type_mask = 0xC000;
51 static constexpr uint16_t type_big = 0x4000;
52 static constexpr uint16_t type_small = 0x8000;
53 static constexpr uint16_t type_transport = 0x0000;
54
55 dcon::ship_id ship;
56 uint16_t target_slot = 0;
57 uint16_t flags = 0;
58};
59static_assert(sizeof(ship_in_battle) ==
62 + sizeof(ship_in_battle::flags));
63
66 dcon::province_id where; //2
67};
68static_assert(sizeof(mobilization_order) ==
70 + sizeof(mobilization_order::when));
71
73 static constexpr uint16_t is_attacking = 0x0001;
74
75 static constexpr uint16_t type_mask = 0x0006;
76 static constexpr uint16_t type_infantry = 0x0000;
77 static constexpr uint16_t type_cavalry = 0x0002;
78 static constexpr uint16_t type_support = 0x0004;
79
80 dcon::regiment_id regiment;
81 uint16_t flags = 0;
82};
83static_assert(sizeof(reserve_regiment) ==
85 + sizeof(reserve_regiment::flags));
86
87constexpr inline uint8_t defender_bonus_crossing_mask = 0xC0;
88constexpr inline uint8_t defender_bonus_crossing_none = 0x00;
89constexpr inline uint8_t defender_bonus_crossing_river = 0x40;
90constexpr inline uint8_t defender_bonus_crossing_sea = 0x80;
91constexpr inline uint8_t defender_bonus_dig_in_mask = 0x3F;
92
94
98
99 float maneuver = 0.0f;
100 int32_t colonial_points = 0;
101 int32_t min_port_level = 0;
103
104 int32_t icon = 0;
105 int32_t naval_icon = 0;
106
107 dcon::text_key name;
108
109 bool is_land = true;
110 bool capital = false;
112 bool primary_culture = false;
113 bool active = true;
114
116 uint16_t padding = 0;
117
119};
120static_assert(sizeof(unit_definition) ==
128 + sizeof(unit_definition::icon)
130 + sizeof(unit_definition::name)
136 + sizeof(unit_definition::type)
137 + sizeof(unit_definition::padding));
138
141
142 dcon::leader_trait_id first_background_trait;
143
144 bool great_wars_enabled = false;
145 bool world_wars_enabled = false;
146
147 dcon::unit_type_id base_army_unit;
148 dcon::unit_type_id base_naval_unit;
149
150 dcon::cb_type_id standard_civil_war;
151 dcon::cb_type_id standard_great_war;
152
153 dcon::cb_type_id standard_status_quo;
154
155 dcon::cb_type_id liberate;
156 dcon::cb_type_id uninstall_communist_gov;
157
158 dcon::cb_type_id crisis_colony;
159 dcon::cb_type_id crisis_liberate;
160
161 dcon::unit_type_id irregular;
162 dcon::unit_type_id infantry;
163 dcon::unit_type_id artillery;
164
166};
167
170 dcon::nation_id target; //2
171 dcon::cb_type_id cb_type; //2
172};
173static_assert(sizeof(available_cb) ==
174 + sizeof(available_cb::target)
176 + sizeof(available_cb::cb_type));
177
179 dcon::nation_id secondary_nation;
180 dcon::national_identity_id wg_tag;
181 dcon::state_definition_id state;
182 dcon::cb_type_id cb;
183};
184struct full_wg {
185 dcon::nation_id added_by;
186 dcon::nation_id target_nation;
187 dcon::nation_id secondary_nation;
188 dcon::national_identity_id wg_tag;
189 dcon::state_definition_id state;
190 dcon::cb_type_id cb;
191};
192
194 float warscore_effect = 0.0f;
195 float prestige_effect = 0.0f;
196
200
204
208
212
213 dcon::leader_id attacking_admiral;
214 dcon::leader_id defending_admiral;
215
216 dcon::nation_id attacking_nation;
217 dcon::nation_id defending_nation;
218
219 dcon::province_id location;
220
223};
224
226 float warscore_effect = 0.0f;
227 float prestige_effect = 0.0f;
228
232
236
240
244
245 dcon::leader_id attacking_general;
246 dcon::leader_id defending_general;
247
248 dcon::nation_id attacking_nation;
249 dcon::nation_id defending_nation;
250
251 dcon::province_id location;
252
255};
256
257constexpr inline int32_t days_before_retreat = 11;
258
260
261void reset_unit_stats(sys::state& state);
263void restore_unsaved_values(sys::state& state); // must run after determining connectivity
264
265bool are_at_war(sys::state const& state, dcon::nation_id a, dcon::nation_id b);
266bool are_allied_in_war(sys::state const& state, dcon::nation_id a, dcon::nation_id b);
267bool are_in_common_war(sys::state const& state, dcon::nation_id a, dcon::nation_id b);
268void remove_from_common_allied_wars(sys::state& state, dcon::nation_id a, dcon::nation_id b);
269dcon::war_id find_war_between(sys::state const& state, dcon::nation_id a, dcon::nation_id b);
270bool has_truce_with(sys::state& state, dcon::nation_id attacker, dcon::nation_id target);
271bool can_use_cb_against(sys::state& state, dcon::nation_id from, dcon::nation_id target);
272bool leader_is_in_combat(sys::state& state, dcon::leader_id l);
273dcon::leader_id make_new_leader(sys::state& state, dcon::nation_id n, bool is_general);
274void kill_leader(sys::state& state, dcon::leader_id l);
275
276// tests whether joining the war would violate the constraint that you can't both be in a war with and
277// fighting against the same nation or fighting against them twice
278bool joining_war_does_not_violate_constraints(sys::state const& state, dcon::nation_id a, dcon::war_id w, bool as_attacker);
279
280bool is_civil_war(sys::state const& state, dcon::war_id w);
281bool standard_war_joining_is_possible(sys::state& state, dcon::war_id wfor, dcon::nation_id n, bool as_attacker);
282bool joining_as_attacker_would_break_truce(sys::state& state, dcon::nation_id a, dcon::war_id w);
283bool defenders_have_non_status_quo_wargoal(sys::state const& state, dcon::war_id w);
284bool defenders_have_status_quo_wargoal(sys::state const& state, dcon::war_id w);
285bool attackers_have_status_quo_wargoal(sys::state const& state, dcon::war_id w);
286bool can_add_always_cb_to_war(sys::state& state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::war_id w);
287bool is_attacker(sys::state& state, dcon::war_id w, dcon::nation_id n);
288bool war_goal_would_be_duplicate(sys::state& state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation);
289bool state_claimed_in_war(sys::state& state, dcon::war_id w, dcon::nation_id from, dcon::nation_id target, dcon::state_definition_id cb_state);
291std::string get_war_name(sys::state& state, dcon::war_id war);
292
293// war score from the perspective of the primary attacker offering a peace deal to the primary defender; -100 to 100
294float primary_warscore(sys::state& state, dcon::war_id w);
295float primary_warscore_from_occupation(sys::state& state, dcon::war_id w);
296float primary_warscore_from_battles(sys::state& state, dcon::war_id w);
297float primary_warscore_from_war_goals(sys::state& state, dcon::war_id w);
298float primary_warscore_from_blockades(sys::state& state, dcon::war_id w);
299
300// war score from the perspective of the primary nation offering peace to the secondary nation; 0 to 100
301// DO NOT use this when calculating the overall score of the war or when looking at a peace deal between primary attacker and
302// defender
303float directed_warscore(sys::state& state, dcon::war_id w, dcon::nation_id primary, dcon::nation_id secondary);
304
305bool is_defender_wargoal(sys::state const& state, dcon::war_id w, dcon::wargoal_id wg);
306
308war_role get_role(sys::state const& state, dcon::war_id w, dcon::nation_id n);
309
310bool province_is_blockaded(sys::state const& state, dcon::province_id ids);
311bool province_is_under_siege(sys::state const& state, dcon::province_id ids);
313
314float recruited_pop_fraction(sys::state const& state, dcon::nation_id n);
315bool state_has_naval_base(sys::state const& state, dcon::state_instance_id di);
316
317int32_t supply_limit_in_province(sys::state& state, dcon::nation_id n, dcon::province_id p);
318int32_t regiments_possible_from_pop(sys::state& state, dcon::pop_id p);
319int32_t regiments_created_from_province(sys::state& state, dcon::province_id p); // does not include mobilized regiments
320int32_t regiments_max_possible_from_province(sys::state& state, dcon::province_id p);
321int32_t main_culture_regiments_created_from_province(sys::state& state, dcon::province_id p);
322int32_t main_culture_regiments_max_possible_from_province(sys::state& state, dcon::province_id p);
323int32_t regiments_under_construction_in_province(sys::state& state, dcon::province_id p);
324int32_t main_culture_regiments_under_construction_in_province(sys::state& state, dcon::province_id p);
325int32_t mobilized_regiments_created_from_province(sys::state& state, dcon::province_id p);
326int32_t mobilized_regiments_possible_from_province(sys::state& state, dcon::province_id p);
327dcon::pop_id find_available_soldier(sys::state& state, dcon::province_id p, bool require_accepted);
328dcon::pop_id find_available_soldier(sys::state& state, dcon::province_id p, dcon::culture_id pop_culture);
329int32_t mobilized_regiments_pop_limit(sys::state& state, dcon::nation_id n);
331
332int32_t total_regiments(sys::state& state, dcon::nation_id n);
333int32_t total_ships(sys::state& state, dcon::nation_id n);
334
335dcon::regiment_id create_new_regiment(sys::state& state, dcon::nation_id n, dcon::unit_type_id t);
336dcon::ship_id create_new_ship(sys::state& state, dcon::nation_id n, dcon::unit_type_id t);
337
338void update_recruitable_regiments(sys::state& state, dcon::nation_id n);
341
344
345int32_t naval_supply_points(sys::state& state, dcon::nation_id n);
346int32_t naval_supply_points_used(sys::state& state, dcon::nation_id n);
347
348float mobilization_size(sys::state const& state, dcon::nation_id n);
349float mobilization_impact(sys::state const& state, dcon::nation_id n);
350
351uint32_t naval_supply_from_naval_base(sys::state& state, dcon::province_id prov, dcon::nation_id nation);
352void update_naval_supply_points(sys::state& state); // must run after determining connectivity
353void update_cbs(sys::state& state);
356
357bool cb_conditions_satisfied(sys::state& state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb);
358bool cb_instance_conditions_satisfied(sys::state& state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::state_definition_id st, dcon::national_identity_id tag, dcon::nation_id secondary);
359void add_cb(sys::state& state, dcon::nation_id n, dcon::cb_type_id cb, dcon::nation_id target); // do not call this function directly unless you know what you are doing
360void execute_cb_discovery(sys::state& state, dcon::nation_id n);
361
362void give_military_access(sys::state& state, dcon::nation_id accessing_nation, dcon::nation_id target);
363void remove_military_access(sys::state& state, dcon::nation_id accessing_nation, dcon::nation_id target);
364void end_wars_between(sys::state& state, dcon::nation_id a, dcon::nation_id b);
365
366dcon::war_id create_war(sys::state& state, dcon::nation_id primary_attacker, dcon::nation_id primary_defender,
367 dcon::cb_type_id primary_wargoal, dcon::state_definition_id primary_wargoal_state,
368 dcon::national_identity_id primary_wargoal_tag, dcon::nation_id primary_wargoal_secondary);
369void call_defender_allies(sys::state& state, dcon::war_id wfor);
370void call_attacker_allies(sys::state& state, dcon::war_id wfor);
371void add_wargoal(sys::state& state, dcon::war_id wfor, dcon::nation_id added_by, dcon::nation_id target, dcon::cb_type_id type,
372 dcon::state_definition_id sd, dcon::national_identity_id tag, dcon::nation_id secondary_nation);
373void add_to_war(sys::state& state, dcon::war_id w, dcon::nation_id n, bool as_attacker, bool on_war_creation = false);
374
375float truce_break_cb_prestige_cost(sys::state& state, dcon::cb_type_id type);
376float truce_break_cb_militancy(sys::state& state, dcon::cb_type_id type);
377float truce_break_cb_infamy(sys::state& state, dcon::cb_type_id type);
378
379int32_t peace_cost(sys::state& state, dcon::war_id war, dcon::cb_type_id wargoal, dcon::nation_id from, dcon::nation_id target,
380 dcon::nation_id secondary_nation, dcon::state_definition_id wargoal_state, dcon::national_identity_id wargoal_t);
381int32_t cost_of_peace_offer(sys::state& state, dcon::peace_offer_id offer);
382int32_t peace_offer_truce_months(sys::state& state, dcon::peace_offer_id offer);
383int32_t attacker_peace_cost(sys::state& state, dcon::war_id war);
384int32_t defender_peace_cost(sys::state& state, dcon::war_id war);
385
386float successful_cb_prestige(sys::state& state, dcon::cb_type_id type, dcon::nation_id actor);
387float cb_infamy(sys::state const& state, dcon::cb_type_id t); // the fabrication cost in infamy
388float cb_addition_infamy_cost(sys::state& state, dcon::war_id war, dcon::cb_type_id type, dcon::nation_id from,
389 dcon::nation_id target); // the cost of adding a particular cb to the war -- does NOT check if the CB is valid to add
390float crisis_cb_addition_infamy_cost(sys::state& state, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target);
391
392bool cb_requires_selection_of_a_valid_nation(sys::state const& state, dcon::cb_type_id t);
393bool cb_requires_selection_of_a_liberatable_tag(sys::state const& state, dcon::cb_type_id t);
394bool cb_requires_selection_of_a_state(sys::state const& state, dcon::cb_type_id t);
395
396void remove_from_war(sys::state& state, dcon::war_id w, dcon::nation_id n, bool as_loss);
398void cleanup_war(sys::state& state, dcon::war_id w, war_result result);
399
400void cleanup_army(sys::state& state, dcon::army_id n);
401void cleanup_navy(sys::state& state, dcon::navy_id n);
402
403void implement_war_goal(sys::state& state, dcon::war_id war, dcon::cb_type_id wargoal, dcon::nation_id from,
404 dcon::nation_id target, dcon::nation_id secondary_nation, dcon::state_definition_id wargoal_state,
405 dcon::national_identity_id wargoal_t);
406void implement_peace_offer(sys::state& state, dcon::peace_offer_id offer);
407void reject_peace_offer(sys::state& state, dcon::peace_offer_id offer);
408void add_truce(sys::state& state, dcon::nation_id a, dcon::nation_id b, int32_t days);
409
411
412void start_mobilization(sys::state& state, dcon::nation_id n);
413void end_mobilization(sys::state& state, dcon::nation_id n);
415
416int32_t transport_capacity(sys::state& state, dcon::navy_id n);
417int32_t free_transport_capacity(sys::state& state, dcon::navy_id n);
418bool can_embark_onto_sea_tile(sys::state& state, dcon::nation_id n, dcon::province_id p, dcon::army_id a);
419dcon::navy_id find_embark_target(sys::state& state, dcon::nation_id from, dcon::province_id p, dcon::army_id a);
420float effective_army_speed(sys::state& state, dcon::army_id a);
421float effective_navy_speed(sys::state& state, dcon::navy_id n);
422bool will_recieve_attrition(sys::state& state, dcon::navy_id a);
423bool will_recieve_attrition(sys::state& state, dcon::army_id a);
424float attrition_amount(sys::state& state, dcon::navy_id a);
425float attrition_amount(sys::state& state, dcon::army_id a);
426float relative_attrition_amount(sys::state& state, dcon::navy_id a, dcon::province_id prov);
427float relative_attrition_amount(sys::state& state, dcon::army_id a, dcon::province_id prov);
428float local_army_weight(sys::state& state, dcon::province_id prov);
429float local_army_weight_max(sys::state& state, dcon::province_id prov);
430float local_enemy_army_weight_max(sys::state& state, dcon::province_id prov, dcon::nation_id nation);
431float attrition_amount(sys::state& state, dcon::navy_id a);
432float attrition_amount(sys::state& state, dcon::army_id a);
433float peacetime_attrition_limit(sys::state& state, dcon::nation_id n, dcon::province_id prov);
434float reinforce_amount(sys::state& state, dcon::army_id a);
435
436sys::date arrival_time_to(sys::state& state, dcon::army_id a, dcon::province_id p);
437sys::date arrival_time_to(sys::state& state, dcon::navy_id n, dcon::province_id p);
438float fractional_distance_covered(sys::state& state, dcon::army_id a);
439float fractional_distance_covered(sys::state& state, dcon::navy_id a);
440
441enum class crossing_type { none, river, sea };
442void army_arrives_in_province(sys::state& state, dcon::army_id a, dcon::province_id p, crossing_type crossing, dcon::land_battle_id from = dcon::land_battle_id{}); // only for land provinces
443void navy_arrives_in_province(sys::state& state, dcon::navy_id n, dcon::province_id p, dcon::naval_battle_id from = dcon::naval_battle_id{}); // only for sea provinces
444void end_battle(sys::state& state, dcon::naval_battle_id b, battle_result result);
445void end_battle(sys::state& state, dcon::land_battle_id b, battle_result result);
446
448void update_blackflag_status(sys::state& state, dcon::province_id p);
449void eject_ships(sys::state& state, dcon::province_id p);
450void update_movement(sys::state& state);
451bool siege_potential(sys::state& state, dcon::nation_id army_controller, dcon::nation_id province_controller);
456void apply_attrition(sys::state& state);
457void increase_dig_in(sys::state& state);
458economy::commodity_set get_required_supply(sys::state& state, dcon::nation_id owner, dcon::army_id army);
459economy::commodity_set get_required_supply(sys::state& state, dcon::nation_id owner, dcon::navy_id navy);
460void recover_org(sys::state& state);
462void repair_ships(sys::state& state);
463void run_gc(sys::state& state);
465void send_rebel_hunter_to_next_province(sys::state& state, dcon::army_id ar, dcon::province_id prov);
466
467bool can_retreat_from_battle(sys::state& state, dcon::naval_battle_id battle);
468bool can_retreat_from_battle(sys::state& state, dcon::land_battle_id battle);
469
470dcon::nation_id get_land_battle_lead_attacker(sys::state& state, dcon::land_battle_id b);
471dcon::nation_id get_land_battle_lead_defender(sys::state& state, dcon::land_battle_id b);
472dcon::nation_id get_naval_battle_lead_defender(sys::state& state, dcon::naval_battle_id b);
473dcon::nation_id get_naval_battle_lead_attacker(sys::state& state, dcon::naval_battle_id b);
474
475float get_leader_select_score(sys::state& state, dcon::leader_id l);
476void update_battle_leaders(sys::state& state, dcon::land_battle_id b);
477void update_battle_leaders(sys::state& state, dcon::naval_battle_id b);
478
479bool rebel_army_in_province(sys::state& state, dcon::province_id p);
480dcon::province_id find_land_rally_pt(sys::state& state, dcon::nation_id by, dcon::province_id start);
481dcon::province_id find_naval_rally_pt(sys::state& state, dcon::nation_id by, dcon::province_id start);
482void move_land_to_merge(sys::state& state, dcon::nation_id by, dcon::army_id a, dcon::province_id start, dcon::province_id dest);
483void move_navy_to_merge(sys::state& state, dcon::nation_id by, dcon::navy_id a, dcon::province_id start, dcon::province_id dest);
484bool pop_eligible_for_mobilization(sys::state& state, dcon::pop_id p);
485
486void disband_regiment_w_pop_death(sys::state& state, dcon::regiment_id reg_id);
487
488} // namespace military
constexpr uint32_t po_transfer_provinces
Definition: military.hpp:23
constexpr uint32_t po_destroy_naval_bases
Definition: military.hpp:33
constexpr uint32_t po_reparations
Definition: military.hpp:22
constexpr uint32_t po_add_to_sphere
Definition: military.hpp:20
constexpr uint32_t po_demand_state
Definition: military.hpp:19
constexpr uint32_t po_install_communist_gov_type
Definition: military.hpp:28
constexpr uint32_t all_allowed_states
Definition: military.hpp:14
constexpr uint32_t po_annex
Definition: military.hpp:18
constexpr uint32_t po_status_quo
Definition: military.hpp:27
constexpr uint32_t is_triggered_only
Definition: military.hpp:11
constexpr uint32_t po_disarmament
Definition: military.hpp:21
constexpr uint32_t po_remove_prestige
Definition: military.hpp:24
constexpr uint32_t is_not_constructing_cb
Definition: military.hpp:12
constexpr uint32_t great_war_obligatory
Definition: military.hpp:13
constexpr uint32_t not_in_crisis
Definition: military.hpp:15
constexpr uint32_t po_remove_cores
Definition: military.hpp:30
constexpr uint32_t po_gunboat
Definition: military.hpp:17
constexpr uint32_t is_civil_war
Definition: military.hpp:9
constexpr uint32_t po_destroy_forts
Definition: military.hpp:32
constexpr uint32_t po_release_puppet
Definition: military.hpp:26
constexpr uint32_t po_clear_union_sphere
Definition: military.hpp:16
constexpr uint32_t po_make_puppet
Definition: military.hpp:25
constexpr uint32_t always
Definition: military.hpp:10
constexpr uint32_t po_colony
Definition: military.hpp:31
constexpr uint32_t po_uninstall_communist_gov_type
Definition: military.hpp:29
void execute_cb_discovery(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1812
bool province_is_under_siege(sys::state const &state, dcon::province_id ids)
Definition: military.cpp:453
bool are_allied_in_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:486
float truce_break_cb_prestige_cost(sys::state &state, dcon::cb_type_id t)
Definition: military.cpp:1328
bool cb_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb)
Definition: military.cpp:254
int32_t naval_supply_points_used(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1074
float primary_warscore(sys::state &state, dcon::war_id w)
Definition: military.cpp:3628
float mobilization_size(sys::state const &state, dcon::nation_id n)
Definition: military.cpp:1156
void run_gc(sys::state &state)
Definition: military.cpp:3014
float truce_break_cb_infamy(sys::state &state, dcon::cb_type_id t)
Definition: military.cpp:1450
void update_naval_supply_points(sys::state &state)
Definition: military.cpp:1096
void send_rebel_hunter_to_next_province(sys::state &state, dcon::army_id ar, dcon::province_id prov)
Definition: military.cpp:6457
void army_arrives_in_province(sys::state &state, dcon::army_id a, dcon::province_id p, crossing_type crossing, dcon::land_battle_id from)
Definition: military.cpp:3992
int32_t free_transport_capacity(sys::state &state, dcon::navy_id n)
Definition: military.cpp:6446
void add_to_war(sys::state &state, dcon::war_id w, dcon::nation_id n, bool as_attacker, bool on_war_creation)
Definition: military.cpp:2109
float recruited_pop_fraction(sys::state const &state, dcon::nation_id n)
Definition: military.cpp:457
int32_t total_regiments(sys::state &state, dcon::nation_id n)
Definition: military.cpp:24
void eject_ships(sys::state &state, dcon::province_id p)
Definition: military.cpp:6771
uint8_t make_dice_rolls(sys::state &state, uint32_t seed)
Definition: military.cpp:6106
float directed_warscore(sys::state &state, dcon::war_id w, dcon::nation_id primary, dcon::nation_id secondary)
Definition: military.cpp:3685
void disband_regiment_w_pop_death(sys::state &state, dcon::regiment_id reg_id)
Definition: military.cpp:7458
constexpr uint8_t defender_bonus_crossing_none
Definition: military.hpp:88
bool rebel_army_in_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:7333
int32_t defender_peace_cost(sys::state &state, dcon::war_id war)
Definition: military.cpp:1693
constexpr uint8_t defender_bonus_crossing_river
Definition: military.hpp:89
void end_battle(sys::state &state, dcon::land_battle_id b, battle_result result)
Definition: military.cpp:4523
bool can_use_cb_against(sys::state &state, dcon::nation_id from, dcon::nation_id target)
Definition: military.cpp:95
void remove_from_common_allied_wars(sys::state &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:507
void navy_arrives_in_province(sys::state &state, dcon::navy_id n, dcon::province_id p, dcon::naval_battle_id from)
Definition: military.cpp:6113
int32_t peace_offer_truce_months(sys::state &state, dcon::peace_offer_id offer)
Definition: military.cpp:1675
dcon::pop_id find_available_soldier(sys::state &state, dcon::province_id p, dcon::culture_id pop_culture)
Definition: military.cpp:831
float reinforce_amount(sys::state &state, dcon::army_id a)
Definition: military.cpp:6928
void apply_base_unit_stat_modifiers(sys::state &state)
Definition: military.cpp:45
void update_blockade_status(sys::state &state)
Definition: military.cpp:447
void end_wars_between(sys::state &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:2084
bool has_truce_with(sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
Definition: military.cpp:2037
int32_t regiments_under_construction_in_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:810
float mobilization_impact(sys::state const &state, dcon::nation_id n)
Definition: military.cpp:1160
void reject_peace_offer(sys::state &state, dcon::peace_offer_id offer)
Definition: military.cpp:3446
void update_ticking_war_score(sys::state &state)
Definition: military.cpp:3486
bool standard_war_joining_is_possible(sys::state &state, dcon::war_id wfor, dcon::nation_id n, bool as_attacker)
Definition: military.cpp:2344
dcon::nation_id get_naval_battle_lead_defender(sys::state &state, dcon::naval_battle_id b)
Definition: military.cpp:4259
void increase_dig_in(sys::state &state)
Definition: military.cpp:6796
war_role get_role(sys::state const &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2242
constexpr uint8_t defender_bonus_dig_in_mask
Definition: military.hpp:91
int32_t main_culture_regiments_under_construction_in_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:820
bool can_retreat_from_battle(sys::state &state, dcon::naval_battle_id battle)
Definition: military.cpp:7203
void apply_attrition(sys::state &state)
Definition: military.cpp:5083
void reset_unit_stats(sys::state &state)
Definition: military.cpp:36
float effective_army_speed(sys::state &state, dcon::army_id a)
Definition: military.cpp:3848
int32_t attacker_peace_cost(sys::state &state, dcon::war_id war)
Definition: military.cpp:1682
void update_land_battles(sys::state &state)
Definition: military.cpp:5217
void update_battle_leaders(sys::state &state, dcon::land_battle_id b)
Definition: military.cpp:4362
float attrition_amount(sys::state &state, dcon::navy_id a)
Definition: military.cpp:5076
void remove_from_war(sys::state &state, dcon::war_id w, dcon::nation_id n, bool as_loss)
Definition: military.cpp:2500
void update_cbs(sys::state &state)
Definition: military.cpp:1168
void cleanup_war(sys::state &state, dcon::war_id w, war_result result)
Definition: military.cpp:2589
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2234
float local_enemy_army_weight_max(sys::state &state, dcon::province_id prov, dcon::nation_id nation)
Definition: military.cpp:5022
dcon::ship_id create_new_ship(sys::state &state, dcon::nation_id n, dcon::unit_type_id t)
Definition: military.cpp:2058
void cleanup_navy(sys::state &state, dcon::navy_id n)
Definition: military.cpp:4467
void add_cb(sys::state &state, dcon::nation_id n, dcon::cb_type_id cb, dcon::nation_id target)
Definition: military.cpp:1261
bool joining_as_attacker_would_break_truce(sys::state &state, dcon::nation_id a, dcon::war_id w)
Definition: military.cpp:607
bool is_defender_wargoal(sys::state const &state, dcon::war_id w, dcon::wargoal_id wg)
Definition: military.cpp:575
void regenerate_land_unit_average(sys::state &state)
Definition: military.cpp:1024
dcon::nation_id get_land_battle_lead_attacker(sys::state &state, dcon::land_battle_id b)
Definition: military.cpp:4279
void recover_org(sys::state &state)
Definition: military.cpp:6874
void update_recruitable_regiments(sys::state &state, dcon::nation_id n)
Definition: military.cpp:997
float primary_warscore_from_blockades(sys::state &state, dcon::war_id w)
Definition: military.cpp:3589
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)
Definition: military.cpp:2409
float cb_infamy(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1266
constexpr uint8_t defender_bonus_crossing_mask
Definition: military.hpp:87
bool cb_requires_selection_of_a_valid_nation(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1798
economy::commodity_set get_required_supply(sys::state &state, dcon::nation_id owner, dcon::army_id army)
Definition: military.cpp:6813
int32_t mobilized_regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:657
bool are_in_common_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:497
bool can_embark_onto_sea_tile(sys::state &state, dcon::nation_id from, dcon::province_id p, dcon::army_id a)
Definition: military.cpp:3822
sys::date arrival_time_to(sys::state &state, dcon::army_id a, dcon::province_id p)
Definition: military.cpp:3889
dcon::war_id find_war_between(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:542
void advance_mobilizations(sys::state &state)
Definition: military.cpp:7128
void update_movement(sys::state &state)
Definition: military.cpp:6183
bool will_recieve_attrition(sys::state &state, dcon::navy_id a)
Definition: military.cpp:4945
uint32_t naval_supply_from_naval_base(sys::state &state, dcon::province_id prov, dcon::nation_id nation)
Definition: military.cpp:1078
int32_t regiments_possible_from_pop(sys::state &state, dcon::pop_id p)
Definition: military.cpp:675
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)
Definition: military.cpp:2250
void reinforce_regiments(sys::state &state)
Definition: military.cpp:6954
bool state_has_naval_base(sys::state const &state, dcon::state_instance_id si)
Definition: military.cpp:463
void move_land_to_merge(sys::state &state, dcon::nation_id by, dcon::army_id a, dcon::province_id start, dcon::province_id dest)
Definition: military.cpp:7377
float crisis_cb_addition_infamy_cost(sys::state &state, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target)
Definition: military.cpp:1771
void add_truce(sys::state &state, dcon::nation_id a, dcon::nation_id b, int32_t days)
Definition: military.cpp:3193
dcon::nation_id get_naval_battle_lead_attacker(sys::state &state, dcon::naval_battle_id b)
Definition: military.cpp:4239
int32_t regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:647
void give_military_access(sys::state &state, dcon::nation_id accessing_nation, dcon::nation_id target)
Definition: military.cpp:2070
void apply_regiment_damage(sys::state &state)
Definition: military.cpp:5142
void monthly_leaders_update(sys::state &state)
Definition: military.cpp:1945
float local_army_weight_max(sys::state &state, dcon::province_id prov)
Definition: military.cpp:5010
bool cb_instance_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::state_definition_id st, dcon::national_identity_id tag, dcon::nation_id secondary)
Definition: military.cpp:321
float truce_break_cb_militancy(sys::state &state, dcon::cb_type_id t)
Definition: military.cpp:1389
void update_naval_battles(sys::state &state)
Definition: military.cpp:5753
float primary_warscore_from_battles(sys::state &state, dcon::war_id w)
Definition: military.cpp:3667
dcon::province_id find_land_rally_pt(sys::state &state, dcon::nation_id by, dcon::province_id start)
Definition: military.cpp:7340
dcon::regiment_id create_new_regiment(sys::state &state, dcon::nation_id n, dcon::unit_type_id t)
Definition: military.cpp:2047
void update_siege_progress(sys::state &state)
Definition: military.cpp:6523
void move_navy_to_merge(sys::state &state, dcon::nation_id by, dcon::navy_id a, dcon::province_id start, dcon::province_id dest)
Definition: military.cpp:7414
void start_mobilization(sys::state &state, dcon::nation_id n)
Definition: military.cpp:7030
void update_all_recruitable_regiments(sys::state &state)
Definition: military.cpp:1003
float effective_navy_speed(sys::state &state, dcon::navy_id n)
Definition: military.cpp:3873
float local_army_weight(sys::state &state, dcon::province_id prov)
Definition: military.cpp:4998
void call_attacker_allies(sys::state &state, dcon::war_id wfor)
Definition: military.cpp:2389
bool leader_is_in_combat(sys::state &state, dcon::leader_id l)
Definition: military.cpp:1847
float primary_warscore_from_occupation(sys::state &state, dcon::war_id w)
Definition: military.cpp:3636
int32_t mobilized_regiments_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:959
void remove_military_access(sys::state &state, dcon::nation_id accessing_nation, dcon::nation_id target)
Definition: military.cpp:2077
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:475
void set_initial_leaders(sys::state &state)
Definition: military.cpp:2618
bool defenders_have_non_status_quo_wargoal(sys::state const &state, dcon::war_id w)
Definition: military.cpp:584
void invalidate_unowned_wargoals(sys::state &state)
Definition: military.cpp:63
int32_t main_culture_regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:753
void regenerate_total_regiment_counts(sys::state &state)
Definition: military.cpp:1012
int32_t supply_limit_in_province(sys::state &state, dcon::nation_id n, dcon::province_id p)
Definition: military.cpp:618
float primary_warscore_from_war_goals(sys::state &state, dcon::war_id w)
Definition: military.cpp:3671
void end_mobilization(sys::state &state, dcon::nation_id n)
Definition: military.cpp:7101
bool attackers_have_status_quo_wargoal(sys::state const &state, dcon::war_id w)
Definition: military.cpp:599
int32_t transport_capacity(sys::state &state, dcon::navy_id n)
Definition: military.cpp:6438
dcon::leader_id make_new_leader(sys::state &state, dcon::nation_id n, bool is_general)
Definition: military.cpp:1857
void cleanup_army(sys::state &state, dcon::army_id n)
Definition: military.cpp:4417
void repair_ships(sys::state &state)
Definition: military.cpp:6997
constexpr uint8_t defender_bonus_crossing_sea
Definition: military.hpp:90
int32_t total_ships(sys::state &state, dcon::nation_id n)
Definition: military.cpp:27
void daily_leaders_update(sys::state &state)
Definition: military.cpp:1999
void kill_leader(sys::state &state, dcon::leader_id l)
Definition: military.cpp:1891
float relative_attrition_amount(sys::state &state, dcon::navy_id a, dcon::province_id prov)
Definition: military.cpp:4994
bool joining_war_does_not_violate_constraints(sys::state const &state, dcon::nation_id a, dcon::war_id w, bool as_attacker)
Definition: military.cpp:546
void restore_unsaved_values(sys::state &state)
Definition: military.cpp:83
constexpr int32_t days_before_retreat
Definition: military.hpp:257
void implement_peace_offer(sys::state &state, dcon::peace_offer_id offer)
Definition: military.cpp:3205
void call_defender_allies(sys::state &state, dcon::war_id wfor)
Definition: military.cpp:2358
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)
Definition: military.cpp:2678
float get_leader_select_score(sys::state &state, dcon::leader_id l)
Definition: military.cpp:4341
bool is_civil_war(sys::state const &state, dcon::war_id w)
Definition: military.cpp:567
bool pop_eligible_for_mobilization(sys::state &state, dcon::pop_id p)
Definition: military.cpp:7450
int32_t regiments_max_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:709
int32_t naval_supply_points(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1071
bool cb_requires_selection_of_a_liberatable_tag(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1802
bool state_claimed_in_war(sys::state &state, dcon::war_id w, dcon::nation_id from, dcon::nation_id target, dcon::state_definition_id cb_state)
Definition: military.cpp:7210
dcon::nation_id get_land_battle_lead_defender(sys::state &state, dcon::land_battle_id b)
Definition: military.cpp:4310
dcon::province_id find_naval_rally_pt(sys::state &state, dcon::nation_id by, dcon::province_id start)
Definition: military.cpp:7360
void regenerate_ship_scores(sys::state &state)
Definition: military.cpp:1049
void update_blackflag_status(sys::state &state, dcon::province_id p)
Definition: military.cpp:6762
float peacetime_attrition_limit(sys::state &state, dcon::nation_id n, dcon::province_id prov)
Definition: military.cpp:4949
int32_t peace_cost(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_tag)
Definition: military.cpp:1540
std::string get_war_name(sys::state &, dcon::war_id)
Definition: military.cpp:2316
int32_t main_culture_regiments_max_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:763
bool can_add_always_cb_to_war(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::war_id w)
Definition: military.cpp:110
bool defenders_have_status_quo_wargoal(sys::state const &state, dcon::war_id w)
Definition: military.cpp:592
bool siege_potential(sys::state &state, dcon::nation_id army_controller, dcon::nation_id province_controller)
Definition: military.cpp:6508
float fractional_distance_covered(sys::state &state, dcon::army_id a)
Definition: military.cpp:6395
bool war_goal_would_be_duplicate(sys::state &state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
Definition: military.cpp:7251
float successful_cb_prestige(sys::state &state, dcon::cb_type_id t, dcon::nation_id actor)
Definition: military.cpp:1705
int32_t cost_of_peace_offer(sys::state &state, dcon::peace_offer_id offer)
Definition: military.cpp:1665
bool province_is_blockaded(sys::state const &state, dcon::province_id ids)
Definition: military.cpp:422
bool cb_requires_selection_of_a_state(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1806
float cb_addition_infamy_cost(sys::state &state, dcon::war_id war, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target)
Definition: military.cpp:1779
dcon::navy_id find_embark_target(sys::state &state, dcon::nation_id from, dcon::province_id p, dcon::army_id a)
Definition: military.cpp:3834
int32_t mobilized_regiments_pop_limit(sys::state &state, dcon::nation_id n)
Definition: military.cpp:988
uint uint32_t
uchar uint8_t
dcon::cb_type_id cb_type
Definition: military.hpp:171
dcon::nation_id target
Definition: military.hpp:170
dcon::cb_type_id cb
Definition: military.hpp:190
dcon::state_definition_id state
Definition: military.hpp:189
dcon::nation_id target_nation
Definition: military.hpp:186
dcon::nation_id secondary_nation
Definition: military.hpp:187
dcon::nation_id added_by
Definition: military.hpp:185
dcon::national_identity_id wg_tag
Definition: military.hpp:188
dcon::cb_type_id standard_civil_war
Definition: military.hpp:150
dcon::cb_type_id uninstall_communist_gov
Definition: military.hpp:156
dcon::unit_type_id base_army_unit
Definition: military.hpp:147
dcon::unit_type_id irregular
Definition: military.hpp:161
tagged_vector< unit_definition, dcon::unit_type_id > unit_base_definitions
Definition: military.hpp:140
dcon::unit_type_id infantry
Definition: military.hpp:162
dcon::cb_type_id standard_status_quo
Definition: military.hpp:153
dcon::cb_type_id crisis_liberate
Definition: military.hpp:159
dcon::cb_type_id crisis_colony
Definition: military.hpp:158
dcon::cb_type_id standard_great_war
Definition: military.hpp:151
dcon::unit_type_id base_naval_unit
Definition: military.hpp:148
dcon::unit_type_id artillery
Definition: military.hpp:163
dcon::leader_trait_id first_background_trait
Definition: military.hpp:142
dcon::nation_id defending_nation
Definition: military.hpp:249
dcon::leader_id attacking_general
Definition: military.hpp:245
dcon::leader_id defending_general
Definition: military.hpp:246
dcon::province_id location
Definition: military.hpp:251
dcon::nation_id attacking_nation
Definition: military.hpp:248
dcon::province_id where
Definition: military.hpp:66
dcon::nation_id attacking_nation
Definition: military.hpp:216
dcon::nation_id defending_nation
Definition: military.hpp:217
dcon::leader_id defending_admiral
Definition: military.hpp:214
dcon::leader_id attacking_admiral
Definition: military.hpp:213
dcon::province_id location
Definition: military.hpp:219
static constexpr uint16_t type_infantry
Definition: military.hpp:76
static constexpr uint16_t type_support
Definition: military.hpp:78
dcon::regiment_id regiment
Definition: military.hpp:80
static constexpr uint16_t is_attacking
Definition: military.hpp:73
static constexpr uint16_t type_cavalry
Definition: military.hpp:77
static constexpr uint16_t type_mask
Definition: military.hpp:75
dcon::ship_id ship
Definition: military.hpp:55
static constexpr uint16_t mode_engaged
Definition: military.hpp:43
static constexpr uint16_t type_mask
Definition: military.hpp:50
static constexpr uint16_t type_big
Definition: military.hpp:51
static constexpr uint16_t mode_retreated
Definition: military.hpp:45
static constexpr uint16_t mode_sunk
Definition: military.hpp:46
static constexpr uint16_t type_transport
Definition: military.hpp:53
static constexpr uint16_t distance_mask
Definition: military.hpp:38
static constexpr uint16_t mode_approaching
Definition: military.hpp:42
static constexpr uint16_t mode_seeking
Definition: military.hpp:41
static constexpr uint16_t mode_retreating
Definition: military.hpp:44
static constexpr uint16_t mode_mask
Definition: military.hpp:40
static constexpr uint16_t is_attacking
Definition: military.hpp:48
static constexpr uint16_t type_small
Definition: military.hpp:52
economy::commodity_set supply_cost
Definition: military.hpp:97
economy::commodity_set build_cost
Definition: military.hpp:96
dcon::national_identity_id wg_tag
Definition: military.hpp:180
dcon::nation_id secondary_nation
Definition: military.hpp:179
dcon::state_definition_id state
Definition: military.hpp:181
dcon::cb_type_id cb
Definition: military.hpp:182