Project Alice
Loading...
Searching...
No Matches
military.cpp File Reference
#include "military.hpp"
#include "military_templates.hpp"
#include "dcon_generated.hpp"
#include "prng.hpp"
#include "effects.hpp"
#include "events.hpp"
#include "ai.hpp"
#include "demographics.hpp"
#include "politics.hpp"
#include "province_templates.hpp"
#include "rebels.hpp"
#include "triggers.hpp"
#include "container_types.hpp"
Include dependency graph for military.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  military::participation
 
struct  military::leader_counts
 

Namespaces

namespace  military
 

Functions

template auto military::province_is_blockaded< ve::tagged_vector< dcon::province_id > > (sys::state const &, ve::tagged_vector< dcon::province_id >)
 
template auto military::province_is_under_siege< ve::tagged_vector< dcon::province_id > > (sys::state const &, ve::tagged_vector< dcon::province_id >)
 
template auto military::battle_is_ongoing_in_province< ve::tagged_vector< dcon::province_id > > (sys::state const &, ve::tagged_vector< dcon::province_id >)
 
int32_t military::total_regiments (sys::state &state, dcon::nation_id n)
 
int32_t military::total_ships (sys::state &state, dcon::nation_id n)
 
void military::reset_unit_stats (sys::state &state)
 
void military::apply_base_unit_stat_modifiers (sys::state &state)
 
void military::invalidate_unowned_wargoals (sys::state &state)
 
void military::restore_unsaved_values (sys::state &state)
 
bool military::can_use_cb_against (sys::state &state, dcon::nation_id from, dcon::nation_id target)
 
bool military::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)
 
bool military::cb_conditions_satisfied (sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb)
 
bool military::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)
 
bool military::province_is_blockaded (sys::state const &state, dcon::province_id ids)
 
bool military::compute_blockade_status (sys::state &state, dcon::province_id p)
 
void military::update_blockade_status (sys::state &state)
 
bool military::province_is_under_siege (sys::state const &state, dcon::province_id ids)
 
float military::recruited_pop_fraction (sys::state const &state, dcon::nation_id n)
 
bool military::state_has_naval_base (sys::state const &state, dcon::state_instance_id si)
 
bool military::are_at_war (sys::state const &state, dcon::nation_id a, dcon::nation_id b)
 
bool military::are_allied_in_war (sys::state const &state, dcon::nation_id a, dcon::nation_id b)
 
bool military::are_in_common_war (sys::state const &state, dcon::nation_id a, dcon::nation_id b)
 
void military::remove_from_common_allied_wars (sys::state &state, dcon::nation_id a, dcon::nation_id b)
 
participation military::internal_find_war_between (sys::state const &state, dcon::nation_id a, dcon::nation_id b)
 
dcon::war_id military::find_war_between (sys::state const &state, dcon::nation_id a, dcon::nation_id b)
 
bool military::joining_war_does_not_violate_constraints (sys::state const &state, dcon::nation_id a, dcon::war_id w, bool as_attacker)
 
bool military::is_civil_war (sys::state const &state, dcon::war_id w)
 
bool military::is_defender_wargoal (sys::state const &state, dcon::war_id w, dcon::wargoal_id wg)
 
bool military::defenders_have_non_status_quo_wargoal (sys::state const &state, dcon::war_id w)
 
bool military::defenders_have_status_quo_wargoal (sys::state const &state, dcon::war_id w)
 
bool military::attackers_have_status_quo_wargoal (sys::state const &state, dcon::war_id w)
 
bool military::joining_as_attacker_would_break_truce (sys::state &state, dcon::nation_id a, dcon::war_id w)
 
int32_t military::supply_limit_in_province (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
int32_t military::regiments_created_from_province (sys::state &state, dcon::province_id p)
 
int32_t military::mobilized_regiments_created_from_province (sys::state &state, dcon::province_id p)
 
int32_t military::regiments_possible_from_pop (sys::state &state, dcon::pop_id p)
 
int32_t military::regiments_max_possible_from_province (sys::state &state, dcon::province_id p)
 
int32_t military::main_culture_regiments_created_from_province (sys::state &state, dcon::province_id p)
 
int32_t military::main_culture_regiments_max_possible_from_province (sys::state &state, dcon::province_id p)
 
int32_t military::regiments_under_construction_in_province (sys::state &state, dcon::province_id p)
 
int32_t military::main_culture_regiments_under_construction_in_province (sys::state &state, dcon::province_id p)
 
dcon::pop_id military::find_available_soldier (sys::state &state, dcon::province_id p, dcon::culture_id pop_culture)
 
dcon::pop_id military::find_available_soldier (sys::state &state, dcon::province_id p, bool require_accepted)
 
int32_t military::mobilized_regiments_possible_from_province (sys::state &state, dcon::province_id p)
 
int32_t military::mobilized_regiments_pop_limit (sys::state &state, dcon::nation_id n)
 
void military::update_recruitable_regiments (sys::state &state, dcon::nation_id n)
 
void military::update_all_recruitable_regiments (sys::state &state)
 
void military::regenerate_total_regiment_counts (sys::state &state)
 
void military::regenerate_land_unit_average (sys::state &state)
 
void military::regenerate_ship_scores (sys::state &state)
 
int32_t military::naval_supply_points (sys::state &state, dcon::nation_id n)
 
int32_t military::naval_supply_points_used (sys::state &state, dcon::nation_id n)
 
uint32_t military::naval_supply_from_naval_base (sys::state &state, dcon::province_id prov, dcon::nation_id nation)
 
void military::update_naval_supply_points (sys::state &state)
 
float military::mobilization_size (sys::state const &state, dcon::nation_id n)
 
float military::mobilization_impact (sys::state const &state, dcon::nation_id n)
 
void military::update_cbs (sys::state &state)
 
void military::add_cb (sys::state &state, dcon::nation_id n, dcon::cb_type_id cb, dcon::nation_id target)
 
float military::cb_infamy (sys::state const &state, dcon::cb_type_id t)
 
float military::truce_break_cb_prestige_cost (sys::state &state, dcon::cb_type_id t)
 
float military::truce_break_cb_militancy (sys::state &state, dcon::cb_type_id t)
 
float military::truce_break_cb_infamy (sys::state &state, dcon::cb_type_id t)
 
int32_t military::province_point_cost (sys::state &state, dcon::province_id p, dcon::nation_id n)
 
int32_t military::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)
 
int32_t military::cost_of_peace_offer (sys::state &state, dcon::peace_offer_id offer)
 
int32_t military::peace_offer_truce_months (sys::state &state, dcon::peace_offer_id offer)
 
int32_t military::attacker_peace_cost (sys::state &state, dcon::war_id war)
 
int32_t military::defender_peace_cost (sys::state &state, dcon::war_id war)
 
float military::successful_cb_prestige (sys::state &state, dcon::cb_type_id t, dcon::nation_id actor)
 
float military::crisis_cb_addition_infamy_cost (sys::state &state, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target)
 
float military::cb_addition_infamy_cost (sys::state &state, dcon::war_id war, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target)
 
bool military::cb_requires_selection_of_a_valid_nation (sys::state const &state, dcon::cb_type_id t)
 
bool military::cb_requires_selection_of_a_liberatable_tag (sys::state const &state, dcon::cb_type_id t)
 
bool military::cb_requires_selection_of_a_state (sys::state const &state, dcon::cb_type_id t)
 
void military::execute_cb_discovery (sys::state &state, dcon::nation_id n)
 
bool military::leader_is_in_combat (sys::state &state, dcon::leader_id l)
 
dcon::leader_id military::make_new_leader (sys::state &state, dcon::nation_id n, bool is_general)
 
void military::kill_leader (sys::state &state, dcon::leader_id l)
 
leader_counts military::count_leaders (sys::state &state, dcon::nation_id n)
 
int32_t military::count_armies (sys::state &state, dcon::nation_id n)
 
int32_t military::count_navies (sys::state &state, dcon::nation_id n)
 
void military::monthly_leaders_update (sys::state &state)
 
void military::daily_leaders_update (sys::state &state)
 
bool military::has_truce_with (sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
 
dcon::regiment_id military::create_new_regiment (sys::state &state, dcon::nation_id n, dcon::unit_type_id t)
 
dcon::ship_id military::create_new_ship (sys::state &state, dcon::nation_id n, dcon::unit_type_id t)
 
void military::give_military_access (sys::state &state, dcon::nation_id accessing_nation, dcon::nation_id target)
 
void military::remove_military_access (sys::state &state, dcon::nation_id accessing_nation, dcon::nation_id target)
 
void military::end_wars_between (sys::state &state, dcon::nation_id a, dcon::nation_id b)
 
void military::populate_war_text_subsitutions (sys::state &state, dcon::war_id w, text::substitution_map &sub)
 
void military::add_to_war (sys::state &state, dcon::war_id w, dcon::nation_id n, bool as_attacker, bool on_war_creation)
 
bool military::is_attacker (sys::state &state, dcon::war_id w, dcon::nation_id n)
 
war_role military::get_role (sys::state const &state, dcon::war_id w, dcon::nation_id n)
 
dcon::war_id military::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)
 
std::string military::get_war_name (sys::state &, dcon::war_id)
 
bool military::standard_war_joining_is_possible (sys::state &state, dcon::war_id wfor, dcon::nation_id n, bool as_attacker)
 
void military::call_defender_allies (sys::state &state, dcon::war_id wfor)
 
void military::call_attacker_allies (sys::state &state, dcon::war_id wfor)
 
void military::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)
 
void military::remove_from_war (sys::state &state, dcon::war_id w, dcon::nation_id n, bool as_loss)
 
void military::cleanup_war (sys::state &state, dcon::war_id w, war_result result)
 
void military::set_initial_leaders (sys::state &state)
 
void military::take_from_sphere (sys::state &state, dcon::nation_id member, dcon::nation_id new_gp)
 
void military::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)
 
void military::run_gc (sys::state &state)
 
void military::add_truce_between_sides (sys::state &state, dcon::war_id w, int32_t months)
 
void military::add_truce_from_nation (sys::state &state, dcon::war_id w, dcon::nation_id n, int32_t months)
 
void military::add_truce (sys::state &state, dcon::nation_id a, dcon::nation_id b, int32_t days)
 
void military::implement_peace_offer (sys::state &state, dcon::peace_offer_id offer)
 
void military::reject_peace_offer (sys::state &state, dcon::peace_offer_id offer)
 
void military::update_ticking_war_score (sys::state &state)
 
float military::primary_warscore_from_blockades (sys::state &state, dcon::war_id w)
 
float military::primary_warscore (sys::state &state, dcon::war_id w)
 
float military::primary_warscore_from_occupation (sys::state &state, dcon::war_id w)
 
float military::primary_warscore_from_battles (sys::state &state, dcon::war_id w)
 
float military::primary_warscore_from_war_goals (sys::state &state, dcon::war_id w)
 
float military::directed_warscore (sys::state &state, dcon::war_id w, dcon::nation_id primary, dcon::nation_id secondary)
 
bool military::can_embark_onto_sea_tile (sys::state &state, dcon::nation_id from, dcon::province_id p, dcon::army_id a)
 
dcon::navy_id military::find_embark_target (sys::state &state, dcon::nation_id from, dcon::province_id p, dcon::army_id a)
 
float military::effective_army_speed (sys::state &state, dcon::army_id a)
 
float military::effective_navy_speed (sys::state &state, dcon::navy_id n)
 
sys::date military::arrival_time_to (sys::state &state, dcon::army_id a, dcon::province_id p)
 
sys::date military::arrival_time_to (sys::state &state, dcon::navy_id n, dcon::province_id p)
 
void military::add_army_to_battle (sys::state &state, dcon::army_id a, dcon::land_battle_id b, war_role r)
 
void military::army_arrives_in_province (sys::state &state, dcon::army_id a, dcon::province_id p, crossing_type crossing, dcon::land_battle_id from)
 
void military::add_navy_to_battle (sys::state &state, dcon::navy_id n, dcon::naval_battle_id b, war_role r)
 
bool military::retreat (sys::state &state, dcon::navy_id n)
 
bool military::retreat (sys::state &state, dcon::army_id n)
 
dcon::nation_id military::get_naval_battle_lead_attacker (sys::state &state, dcon::naval_battle_id b)
 
dcon::nation_id military::get_naval_battle_lead_defender (sys::state &state, dcon::naval_battle_id b)
 
dcon::nation_id military::get_land_battle_lead_attacker (sys::state &state, dcon::land_battle_id b)
 
dcon::nation_id military::get_land_battle_lead_defender (sys::state &state, dcon::land_battle_id b)
 
float military::get_leader_select_score (sys::state &state, dcon::leader_id l)
 
void military::update_battle_leaders (sys::state &state, dcon::land_battle_id b)
 
void military::update_battle_leaders (sys::state &state, dcon::naval_battle_id b)
 
void military::cleanup_army (sys::state &state, dcon::army_id n)
 
void military::cleanup_navy (sys::state &state, dcon::navy_id n)
 
void military::adjust_leader_prestige (sys::state &state, dcon::leader_id l, float value)
 
void military::adjust_regiment_experience (sys::state &state, dcon::nation_id n, dcon::regiment_id l, float value)
 
void military::adjust_ship_experience (sys::state &state, dcon::nation_id n, dcon::ship_id r, float value)
 
void military::end_battle (sys::state &state, dcon::land_battle_id b, battle_result result)
 
void military::end_battle (sys::state &state, dcon::naval_battle_id b, battle_result result)
 
dcon::nation_id military::tech_nation_for_regiment (sys::state &state, dcon::regiment_id r)
 
bool military::will_recieve_attrition (sys::state &state, dcon::navy_id a)
 
float military::peacetime_attrition_limit (sys::state &state, dcon::nation_id n, dcon::province_id prov)
 
bool military::will_recieve_attrition (sys::state &state, dcon::army_id a)
 
float military::relative_attrition_amount (sys::state &state, dcon::navy_id a, dcon::province_id prov)
 
float military::local_army_weight (sys::state &state, dcon::province_id prov)
 
float military::local_army_weight_max (sys::state &state, dcon::province_id prov)
 
float military::local_enemy_army_weight_max (sys::state &state, dcon::province_id prov, dcon::nation_id nation)
 
float military::relative_attrition_amount (sys::state &state, dcon::army_id a, dcon::province_id prov)
 
float military::attrition_amount (sys::state &state, dcon::navy_id a)
 
float military::attrition_amount (sys::state &state, dcon::army_id a)
 
void military::apply_attrition (sys::state &state)
 
void military::apply_regiment_damage (sys::state &state)
 
void military::update_land_battles (sys::state &state)
 
void military::update_naval_battles (sys::state &state)
 
uint8_t military::make_dice_rolls (sys::state &state, uint32_t seed)
 
void military::navy_arrives_in_province (sys::state &state, dcon::navy_id n, dcon::province_id p, dcon::naval_battle_id from)
 
void military::update_movement (sys::state &state)
 
float military::fractional_distance_covered (sys::state &state, dcon::army_id a)
 
float military::fractional_distance_covered (sys::state &state, dcon::navy_id a)
 
int32_t military::transport_capacity (sys::state &state, dcon::navy_id n)
 
int32_t military::free_transport_capacity (sys::state &state, dcon::navy_id n)
 
void military::send_rebel_hunter_to_next_province (sys::state &state, dcon::army_id ar, dcon::province_id prov)
 
bool military::siege_potential (sys::state &state, dcon::nation_id army_controller, dcon::nation_id province_controller)
 
void military::update_siege_progress (sys::state &state)
 
void military::update_blackflag_status (sys::state &state, dcon::province_id p)
 
void military::eject_ships (sys::state &state, dcon::province_id p)
 
void military::increase_dig_in (sys::state &state)
 
economy::commodity_set military::get_required_supply (sys::state &state, dcon::nation_id owner, dcon::army_id army)
 
economy::commodity_set military::get_required_supply (sys::state &state, dcon::nation_id owner, dcon::navy_id navy)
 
void military::recover_org (sys::state &state)
 
float military::reinforce_amount (sys::state &state, dcon::army_id a)
 
void military::reinforce_regiments (sys::state &state)
 
void military::repair_ships (sys::state &state)
 
void military::start_mobilization (sys::state &state, dcon::nation_id n)
 
void military::end_mobilization (sys::state &state, dcon::nation_id n)
 
void military::advance_mobilizations (sys::state &state)
 
bool military::can_retreat_from_battle (sys::state &state, dcon::naval_battle_id battle)
 
bool military::can_retreat_from_battle (sys::state &state, dcon::land_battle_id battle)
 
bool military::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)
 
bool military::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)
 
void military::update_blackflag_status (sys::state &state)
 
bool military::rebel_army_in_province (sys::state &state, dcon::province_id p)
 
dcon::province_id military::find_land_rally_pt (sys::state &state, dcon::nation_id by, dcon::province_id start)
 
dcon::province_id military::find_naval_rally_pt (sys::state &state, dcon::nation_id by, dcon::province_id start)
 
void military::move_land_to_merge (sys::state &state, dcon::nation_id by, dcon::army_id a, dcon::province_id start, dcon::province_id dest)
 
void military::move_navy_to_merge (sys::state &state, dcon::nation_id by, dcon::navy_id a, dcon::province_id start, dcon::province_id dest)
 
bool military::pop_eligible_for_mobilization (sys::state &state, dcon::pop_id p)
 
void military::disband_regiment_w_pop_death (sys::state &state, dcon::regiment_id reg_id)
 

Variables

constexpr float military::org_dam_mul = 0.18f
 
constexpr float military::str_dam_mul = 0.14f
 
constexpr float military::combat_modifier_table []
 
constexpr float military::siege_speed_mul = 1.0f / 50.0f