scripted_diplomatic_actions = { CPD_offer_conditional_peace = { # will only be possible to have if conditional peace deals are enabled # this will default to being always on allowed = { has_game_rule = { rule = allowed_CPD option = yes } } # only visible if you're actively at war with the diplomatic target visible = { # Hide the Conditional Peace Deals if the target is Zombies or Chimera ROOT = { NOT = { tag = ZOM } NOT = { tag = ALN } } THIS = { NOT = { tag = ZOM } NOT = { tag = ALN } } has_war_with = ROOT CPD_is_a_custom_civil_war = yes } selectable = { # can't have conditional peace with a rival government # (rework this later to allow for frozen conflicts) ROOT = { NOT = { civilwar_target = PREV } if = { limit = { is_subject = yes } CPD_is_an_autonomy_allowed_to_send_deal = yes } } if = { limit = { PREV = { is_subject = yes } } PREV = { CPD_is_an_autonomy_allowed_to_receive_deal = yes } } } requires_acceptance = yes show_acceptance_on_action_button = yes cost = 0 icon = 1 # ROOT will consider the current peace deal as soon as you send it on_sent_effect = { ROOT = { set_country_flag = CPD_considering_peace_deal } } complete_effect = { CPD_clear_victory_points = yes CPD_sign_peace_deal = yes ROOT = { clr_country_flag = CPD_considering_peace_deal clear_variable = CPD_AI_wants_peace_with } CPD_reset_built_peace_deal = yes } reject_effect = { ROOT = { clr_country_flag = CPD_considering_peace_deal clear_variable = CPD_AI_wants_peace_with # Extend the per-target cooldown to 360 days on rejection so the # AI doesn't immediately retry a refused target. (The 180-day # cooldown set on send is overwritten by this longer value.) set_country_flag = { flag = CPD_recently_offered_peace@PREV days = 360 value = 1 } } } send_scripted_gui = CPD_peace_deal_builder reset_send_effect = { ROOT = { clr_country_flag = CPD_giving_concessions } CPD_reset_built_peace_deal = yes } can_be_sent = { # Single source of truth — CPD_deal_is_sendable lives in # 00_peace_deal_triggers.txt and is shared with the send-status # icon and the dummy scripted-GUI element that feeds the [!] # loc formatter. CPD_deal_is_sendable = yes } receive_scripted_gui = CPD_built_peace_deal ai_desire = { base = -25 modifier = { add = 100 ROOT = { has_country_flag = CPD_AI_wants_peace } check_variable = { ROOT.CPD_AI_wants_peace_with = THIS } } # Faction leader modifier = { add = 15 ROOT = { is_faction_leader = yes } } # Power ranking modifier = { add = 10 ROOT = { has_idea = super_power } } modifier = { add = 8 ROOT = { has_idea = great_power } } modifier = { add = 5 ROOT = { has_idea = large_power } } # War contribution (cumulative) modifier = { add = 10 check_variable = { ROOT.CPD_VP@PREV > 10 } } modifier = { add = 10 check_variable = { ROOT.CPD_VP@PREV > 25 } } modifier = { add = 10 check_variable = { ROOT.CPD_VP@PREV > 50 } } # Months at war (cumulative) modifier = { add = 5 check_variable = { ROOT.months_at_war > 6 } } modifier = { add = 5 check_variable = { ROOT.months_at_war > 12 } } modifier = { add = 10 check_variable = { ROOT.months_at_war > 24 } } modifier = { add = 10 check_variable = { ROOT.months_at_war > 36 } } # Economic pressure modifier = { add = 10 check_variable = { ROOT.interest_rate > 9.99 } } modifier = { add = 15 ROOT = { has_active_mission = debt_default_main_mission } } # Enemy near surrender (cumulative) modifier = { add = 20 check_variable = { THIS.surrender_progress > 0.4 } } modifier = { add = 15 check_variable = { THIS.surrender_progress > 0.6 } } # Disable AI if the AI is disabled modifier = { factor = 0 has_game_rule = { rule = allowed_CPD_AI option = no } } } ai_acceptance = { CPD_base_reluctance = { base = -100 } CPD_economic_cost_of_war = { # more likely to surrender if in default or high interest rate base = 0 modifier = { add = 2 check_variable = { interest_rate > 4.99 } } modifier = { add = 2 interest_rate_higher_than_8 = yes } modifier = { add = 2 check_variable = { interest_rate > 9.99 } } modifier = { add = 2 check_variable = { interest_rate > 12.99 } } modifier = { add = 2 check_variable = { interest_rate > 14.99 } } modifier = { add = 15 has_active_mission = debt_default_main_mission } } CPD_support_of_war = { # less likely to surrender if has high war support base = 0 # at base 50 this doesn't change # # for every 10% war support # -20 points towards willingness to sign peace deal modifier = { set_temp_variable = { var = CPD_WS value = { value = var:THIS.has_war_support multiply = -200 round = yes add = 101 } } add = var:CPD_WS } } CPD_relative_strength_of_belligerents = { # more likely to surrender if weaker than sender of peace offer base = 0 modifier = { set_temp_variable = { var = CPD_RSB value = { value = THIS.enemies_strength_ratio@ROOT multiply = 100 round = yes subtract = 100 clamp = { min = -500 max = 200 } } } # Dampen when ROOT has no faction — engine metric includes all # co-belligerents, which massively inflates the ratio for solo senders. if = { limit = { ROOT = { NOT = { is_in_faction = yes } } } multiply_temp_variable = { CPD_RSB = 0.25 } round_temp_variable = CPD_RSB } add = var:CPD_RSB } } CPD_close_to_surrender = { # more likely to surrender if closer to surrender limit; # threshold shifted so 50 % surrender gives +50 instead of 0 base = 0 modifier = { set_temp_variable = { var = CPD_SP value = { value = var:THIS.surrender_progress multiply = 200 round = yes subtract = 50 clamp = { min = 0 max = 100 } } } add = var:CPD_SP } } CPD_battles_won = { # more likely to surrender if receiver has less war score than sender; # clamped to ±150 to prevent runaway numbers from long fronts. base = 0 modifier = { set_temp_variable = { var = CPD_RBW value = { value = ROOT.CPD_VP@PREV subtract = THIS.CPD_VP@ROOT round = yes clamp = { min = -150 max = 150 } } } add = var:CPD_RBW } } CPD_sender_war_contribution = { # penalise sender for making demands with low war contribution base = 0 modifier = { add = -100 NOT = { ROOT = { has_country_flag = CPD_giving_concessions } } check_variable = { ROOT.CPD_total_cost_of_built_peace_deal > 0 } check_variable = { ROOT.CPD_VP@PREV < 1 } } modifier = { add = -50 NOT = { ROOT = { has_country_flag = CPD_giving_concessions } } check_variable = { ROOT.CPD_total_cost_of_built_peace_deal > 5 } check_variable = { ROOT.CPD_VP@PREV > 0 } check_variable = { ROOT.CPD_VP@PREV < 10 } } modifier = { add = -25 NOT = { ROOT = { has_country_flag = CPD_giving_concessions } } check_variable = { ROOT.CPD_total_cost_of_built_peace_deal > 10 } check_variable = { ROOT.CPD_VP@PREV > 9 } check_variable = { ROOT.CPD_VP@PREV < 25 } } } CPD_power_ranking = { # more likely to surrender if receiver is not at least minor power base = 0 modifier = { add = -60 THIS = { has_idea = super_power } } modifier = { add = -45 THIS = { has_idea = great_power } } modifier = { add = -30 THIS = { has_idea = large_power } } modifier = { add = -15 THIS = { has_idea = regional_power } } modifier = { add = 15 THIS = { has_idea = non_power } } } CPD_faction_backing = { # more likely to not surrender if ROOT is in one of the major factions base = 0 modifier = { add = -25 has_idea = NATO_member } modifier = { add = -25 has_idea = CSTO_member } modifier = { add = -25 is_sco = yes } modifier = { add = -25 has_idea = faction_resistance_axis_member } } CPD_months_at_war = { # More likely to surrender if THIS has been at war for a very long time (capped at 120) base = 0 modifier = { set_temp_variable = { var = months_at_war_tmp value = { value = THIS.months_at_war multiply = 2 clamp = { min = 0 max = 120 } } } add = var:months_at_war_tmp } } CPD_difficulty_setting = { base = 0 modifier = { add = 15 difficulty < 1 } modifier = { add = -15 difficulty > 1 } modifier = { add = -15 difficulty > 2 } } # Acceptance from Calculate Peace Deal (capped: concessions bonus maxes at +50) CPD_accepting_peace_deal = { base = 0 modifier = { always = yes set_temp_variable = { var = v value = { value = ROOT.CPD_total_cost_of_built_peace_deal multiply = -5 clamp = { min = -500 max = 50 } } } add = var:v } } CPD_deal_fairness = { # progressive penalty at high deal costs base = 0 modifier = { add = -25 check_variable = { ROOT.CPD_total_cost_of_built_peace_deal > 20 } } modifier = { add = -50 check_variable = { ROOT.CPD_total_cost_of_built_peace_deal > 40 } } modifier = { add = -75 check_variable = { ROOT.CPD_total_cost_of_built_peace_deal > 60 } } modifier = { add = -100 check_variable = { ROOT.CPD_total_cost_of_built_peace_deal > 100 } } } # AI dug-in stubbornness — in long wars the AI grows more reluctant # to accept peace from the offerer, simulating sunk-cost / war fatigue # working against the offerer rather than for them. # Gated on surrender < 50 %: a clearly losing nation drops the # stubbornness and wants out regardless of war length. CPD_war_weariness_rejection = { base = 0 modifier = { add = -15 check_variable = { THIS.months_at_war > 12 } surrender_progress < 0.5 } modifier = { add = -15 check_variable = { THIS.months_at_war > 24 } surrender_progress < 0.5 } modifier = { add = -30 check_variable = { THIS.months_at_war > 48 } surrender_progress < 0.5 } } # Desperation bonus — when surrender passes 50 % the AI becomes # progressively more willing to end the war, offsetting power-rank # pride, faction confidence, and sender-contribution penalties. CPD_desperation_to_end_war = { base = 0 modifier = { add = 25 surrender_progress > 0.5 } modifier = { add = 25 surrender_progress > 0.75 } } # Term-specific aversion — receiver hates accepting country-action demands. # Without these the AI accepts full puppet / regime change as readily as a # token reparations clause; players would exploit this. CPD_full_puppet_aversion = { base = 0 modifier = { add = -200 ROOT = { has_country_flag = CPD_full_puppet_demand } } # Already a subject — being repuppeted is less catastrophic modifier = { add = 100 ROOT = { has_country_flag = CPD_full_puppet_demand } is_subject = yes } } # Full annexation — receiver refuses to sign away its entire country. # Blocks the superpower-annexes-tiny-nation exploit (issue #2733). CPD_full_annexation_aversion = { base = 0 modifier = { set_temp_variable = { CPD_receiver_controlled_states = num_of_controlled_states } } modifier = { add = -200 ROOT = { check_variable = { CPD_annex_state_DEMANDS^num > 0 } } NOT = { check_variable = { ROOT.CPD_annex_state_DEMANDS^num < CPD_receiver_controlled_states } } } } CPD_regime_change_aversion = { base = 0 modifier = { add = -80 ROOT = { has_country_flag = CPD_regime_change_demand } } # Less awful when our ruling party is already weak modifier = { add = 30 ROOT = { has_country_flag = CPD_regime_change_demand } check_variable = { party_pop_array^ruling_party < 0.4 } } } CPD_forced_neutrality_aversion = { # -20 base when neutrality is demanded; +(-40) more if currently # in a faction (total -60). is_in_faction yes/no are complements, # so collapsing avoids a redundant has_country_flag check. base = 0 modifier = { add = -20 ROOT = { has_country_flag = CPD_forced_neutrality_demand } } modifier = { add = -40 ROOT = { has_country_flag = CPD_forced_neutrality_demand } is_in_faction = yes } } CPD_military_basing_aversion = { base = 0 modifier = { add = -25 ROOT = { has_country_flag = CPD_military_basing_demand } } } CPD_resource_rights_aversion = { base = 0 modifier = { add = -15 check_variable = { ROOT.CPD_resource_rights_DEMANDS^num > 0 } } modifier = { add = -25 check_variable = { ROOT.CPD_resource_rights_DEMANDS^num > 3 } } } # Ceasefire is mutually attractive when both sides are stalemated. CPD_ceasefire_acceptance = { base = 0 modifier = { add = 40 ROOT = { has_country_flag = CPD_ceasefire_demand } check_variable = { months_at_war > 18 } surrender_progress < 0.4 } } } } }