# INSTRUCTIONS:
# -------------
# is_triggered_only - Triggered from within the code or by event effects. DO NOT REMOVE THE STOCK ONES.
# months - The number of months this CB will be valid. Only works for triggered CBs.
# prerequisites - A condition that automatically activates a CB. Does not work for triggered CBs.
# no_opinion_hit - If yes you get no negative opinion from this
#
# ROOT = attacker
# FROM = target
#
# NOTE: The order in which the peace options are listed is the order in which the AI will normally prioritize them in peace treaties
#
# TRIGGERED - Triggered from within the code or by event effects
# --------------------------------------------------------------

# Restoration of recently broken PU
cb_restore_personal_union = {
	
	is_triggered_only = yes
	months = 120
	
	prerequisites = {
		OR = {
			government = monarchy
			government = dutch_republic
		}
		is_revolution_target = no
	}
	
	war_goal = take_capital_personal_union
}

# Defected province
cb_defection = {

	is_triggered_only = yes
	months = 12
	
	war_goal = take_core_defection
}

# Cancelled loan
cb_loan_cancelled = {

	is_triggered_only = yes
	months = 12
	
	war_goal = superiority_loan
}

# Hostile spy discovered
cb_spy_discovered = {

	is_triggered_only = yes
	months = 12
	
	war_goal = superiority_spy
}

# Vassal that broke free
cb_disloyal_vassal = {

	is_triggered_only = yes
	months = 120
	
	war_goal = take_capital_disloyal
}

# A HRE prince has been annexed
cb_hre_attacked = {

	is_triggered_only = yes
	months = 60
	
	war_goal = take_province_hre	
}

# War of Honor
cb_insult = {

	is_triggered_only = yes
	
	months = 12
	
	war_goal = superiority_insult_mutual	
}

# Dishonored an alliance
cb_dishonored_call = {

	is_triggered_only = yes
	months = 36
	
	war_goal = superiority_insult	
}

# CB for vassalization missions
cb_vassalize_mission = {
	
	is_triggered_only = yes
	months = 120
	
	war_goal = take_capital_vassalize
}

# CB for fabricated claim on throne. (from events)
cb_fabricated_claims = {
	
	is_triggered_only = yes
	months = 12
	
	war_goal = take_capital_fabricated_claims		
}

# CB for Emperor against HRE members that refuse religious conformance
cb_religious_conformance = {
	
	is_triggered_only = yes
	months = 24
	
	war_goal = take_capital_conformance
}

# Friction along a border
cb_border_war = {

	is_triggered_only = yes
	months = 12
	
	war_goal = take_border	
}

# Trade War (from events and others)
cb_trade_war_triggered = {
	is_triggered_only = yes
	months = 24

	war_goal = superiority_trade	
}

cb_trade_conflict = {
	is_triggered_only = yes
	months = 24

	war_goal = blockade_ports	
}

cb_annex = {
	is_triggered_only = yes
	months = 24

	war_goal = annex_country	
}

cb_change_government = {
	is_triggered_only = yes
	months = 120

	war_goal = war_goal_change_government	
}

# AUTOMATIC - Constantly in effect while 'prerequisites' is true
# --------------------------------------------------------------

# One OPM can try to humiliate another OPM.
cb_humiliate = {
	valid_for_subject = no
	
	prerequisites = {
		has_dlc = "Conquest of Paradise"
		government = native_council
		NOT = {
			truce_with = FROM
			num_of_cities = 2
			FROM = {
				num_of_cities = 2
			}
		}
		is_neighbor_of = FROM
		is_revolution_target = no
	}
	
	war_goal = humiliate	
}

# Temporary claim CB (mostly used by missions)
cb_conquest = {
	
	prerequisites = {
		claim = FROM
		is_revolution_target = no
	}
	
	war_goal = take_claim
}

# We can take core provinces at no badboy
cb_core = {

	prerequisites = {
		core_claim = FROM
		is_revolution_target = no
	}
		
	war_goal = take_core
}

# Independence War
cb_independence_war = {
	exclusive = yes
	independence = yes
	
	prerequisites = {
		is_subject = yes
		is_subject_of = FROM
		NOT = { is_colonial_nation_of = FROM }
		OR = {
			NOT = { government = daimyo }
			NOT = { from = { government = shogunate } }
		}
		is_revolution_target = no
	}

	war_goal = defend_capital_independence
}

# Colonial Independance
cb_colonial_independance_war = {
	exclusive = yes
	independence = yes
	
	prerequisites = {
		is_subject = yes
		is_colonial_nation_of = FROM
		is_revolution_target = no
	}
		
	war_goal = defend_capital_independence
}

# Nationalism
cb_nationalist = {
	
	prerequisites = {
		dip_tech = 68
		is_subject = no
		culture_group_claim = FROM
		is_revolution_target = no
		NOT = {
			AND = {
				has_country_modifier = european_union
				FROM = { has_country_modifier = european_union }
			}
		}
	}
	
	war_goal = take_province_nationalist
}

# Napoleonic era imperialism
cb_imperial = {
	valid_for_subject = no
	
	prerequisites = {
		OR = {
			dip_tech = 68
			invasion_nation = yes
		}
		is_subject = no
		is_revolution_target = no
		NOT = {
			AND = {
				has_country_modifier = european_union
				FROM = { has_country_modifier = european_union }
			}
		}
	}
	
	war_goal = take_capital_imperial
}

# Daimyo on Japan
cb_daimyo_annex = {
	valid_for_subject = no
	exclusive = yes
	independence = yes

	prerequisites = {
		is_subject = yes
		OR = {
			vassal_of = FROM
			junior_union_with = FROM
		}	
		government = daimyo
		from = { government = shogunate }
		is_revolution_target = no
	}
	
	war_goal = annex_country	
}

cb_independent_daimyo_annex = {
	valid_for_subject = no
	exclusive = yes

	prerequisites = {
		is_subject = no
		NOT = {
			vassal_of = FROM
			junior_union_with = FROM
		}	
		government = daimyo
		from = { government = shogunate }
		is_revolution_target = no
	}
	
	war_goal = annex_country	
}

cb_shogun_annex = {
	valid_for_subject = no

	prerequisites = {
		government = shogunate
		from = { 
			government = daimyo 
			OR = {
				num_of_cities = 10
				is_subject = no
			}			
		}
		is_revolution_target = no
	}
	
	war_goal = annex_country	
}

# Sengoku - Daimyo infighting
cb_sengoku = {
	valid_for_subject = no

	prerequisites = {
		government = daimyo
		is_neighbor_of = FROM
		is_subject = yes
		from = { 
			government = daimyo
			is_subject = yes
		}
		is_revolution_target = no
	}
	
	war_goal = annex_country	
}

# Revolutionary CB
cb_revolutionary = {
	valid_for_subject = no
	
	prerequisites = {
		is_neighbor_of = FROM
		cb_on_government_enemies = yes
		NOT = {
			government = papal_government
			government = steppe_horde
			government = dutch_republic
			government = archduchy
			government = celestial_empire
			government = iqta
			government = daimyo
			government = shogunate
			government = imperial_government
			government = american_republic
			government = federal_republic
			government = colonial_government
			government = native_council
			government = caliphate
		}
		FROM = {
			NOT = {
				government = papal_government
				government = steppe_horde
				government = dutch_republic
				government = archduchy
				government = celestial_empire
				government = iqta
				government = daimyo
				government = shogunate
				government = imperial_government
				government = american_republic
				government = federal_republic
				government = colonial_government
				government = native_council
				government = caliphate
			}
		}
		OR = {
			AND = {
				government = monarchy
				FROM = { government = republic }
			}
			AND = {
				government = republic
				NOT = { FROM = { government = republic } }
			}
			AND = {
				NOT = { government = communist_dictatorship }
				NOT = { government = socialist_republic }
				OR = {
					FROM = { government = communist_dictatorship }
					FROM = { government = socialist_republic }
				}
			}
			AND = {
				OR = {
					government = communist_dictatorship
					government = socialist_republic
				}
				FROM = { NOT = { government = communist_dictatorship } }
				FROM = { NOT = { government = socialist_republic } }
			}
			AND = {
				government = fascist_dictatorship
				FROM = { government = fascist_dictatorship }
			}
			AND = {
				NOT = { government = fascist_dictatorship }
				FROM = { government = fascist_dictatorship }
			}
		}
		is_revolution_target = no
	}
	
	war_goal = war_goal_change_government_mutual	
}

# Colonialist CB
cb_colonial = {
	
	prerequisites = {
		colony_claim = FROM
		is_revolution_target = no
	}
	
	war_goal = take_colony	
}

# Liberation CB
cb_liberation = {
	
	prerequisites = {
		#always = no		#just for some historical wars.
		has_country_modifier = european_union
		FROM = {
			AND = {
				NOT = { has_country_modifier = european_union }
				OR = {
					any_owned_province = {
						is_part_of_hre = yes
					}
					any_subject_country = {
						has_country_modifier = european_union
					}
				}
			}
		}
	}
	
	war_goal = take_capital_liberation
}

# Holy War
cb_crusade = {
	valid_for_subject = no

	prerequisites = {
		is_neighbor_of = FROM
		NOT = { religion_group = FROM }
		OR = {
			AND = {
				FROM = { is_crusade_target = yes }
				religion = catholic
			}
			cb_on_religious_enemies = yes
		}
		is_revolution_target = no
	}
	
	war_goal = superiority_crusade
}

# Defender of the Faith
cb_defender_of_the_faith = {
	valid_for_subject = no
	
	prerequisites = {
		is_defender_of_faith = yes
		is_neighbor_of = FROM
		NOT = {	religion = FROM }
		cb_on_religious_enemies = yes
		is_revolution_target = no
		OR = {
			hre_religion_treaty = no
			capital_scope = { is_part_of_hre = no }
			FROM = { capital_scope = { is_part_of_hre = no } }
		}		
	}
	
	war_goal = defend_country_faith
}

# Liberation of same-faith provinces
cb_religious_liberation = {
	valid_for_subject = no
	
	prerequisites = {
		always = no
		NOT = { religion_group = christian } # Christians and Muslims get Holy War instead
		NOT = { religion_group = muslim }
		NOT = { religion_group = FROM }
		religion_group_claim = FROM
		OR = {
			cb_on_religious_enemies = yes
		}
		OR = {
			hre_religion_treaty = no
			capital_scope = { is_part_of_hre = no }
			FROM = { capital_scope = { is_part_of_hre = no } }
		}	
		is_revolution_target = no		
	}
	
	war_goal = take_province_religion
}

# Purging of Heresy
cb_heretic = {
	valid_for_subject = no
	
	prerequisites = {
		is_neighbor_of = FROM
		cb_on_religious_enemies = yes
		religion_group = from
		NOT = { religion = from }
		OR = {
			NOT = { has_dlc = "Art of War" }
			hre_religion_treaty = no
			capital_scope = { is_part_of_hre = no }
			FROM = { capital_scope = { is_part_of_hre = no } }
		}		
		is_revolution_target = no	
	}
	
	allowed_provinces = {
		always = yes
	}

	war_goal = superiority_heretic
}

# Excommunication War
cb_excommunication = {
	valid_for_subject = no	
	
	prerequisites = {
		FROM = {
			is_excommunicated = yes
			religion = catholic
		}
		religion = catholic
		is_excommunicated = no
		FROM = {
			is_neighbor_of = ROOT
			any_owned_province = {
				OR = {
					is_core = ROOT
					is_claim = ROOT
					any_neighbor_province = {
						owned_by = ROOT
					}				
				}			
			}
		}
		OR = {
			hre_religion_treaty = no
			capital_scope = { is_part_of_hre = no }
			FROM = { capital_scope = { is_part_of_hre = no } }
		}		
		is_revolution_target = no
	}

	war_goal = take_province_excommunication
}

# Trade War
cb_trade_war = {
	
	prerequisites = {
		
		OR = {
			AND = {
				trade_embargo_by = FROM
				NOT = { FROM = { trade_embargo_by = ROOT } }
			}
			AND = {
				government = merchant_republic
				FROM = { government = merchant_republic }
			}
		}
		is_revolution_target = no
	}
	
	war_goal = superiority_trade_mutual
}

# Imperial Ban
cb_imperial_ban = {
	valid_for_subject = no

	prerequisites = {
		is_emperor = yes
		is_imperial_ban_allowed = yes	
		FROM = {
			capital_scope = { is_part_of_hre = no }
			any_owned_province = {
				is_part_of_hre = yes
			}
		}
		is_revolution_target = no
	}
	
	war_goal = take_province_ban	
}

# Liberate Elector
cb_liberate_elector = {
	valid_for_subject = no

	prerequisites = {
		is_emperor = yes
		FROM = {
			any_subject_country = {
				is_elector = yes
			}			
		}
		is_revolution_target = no
	}
	
	war_goal = superiority_liberation
}

# Coalition CB
cb_super_badboy = {
	coalition = yes

	prerequisites = {	
		coalition_target = FROM
		NOT = { FROM = { is_in_coalition_war = yes } }
		num_of_coalition_members = 3
		has_opinion_modifier = {
			modifier = aggressive_expansion
			who = FROM
		}
		is_revolution_target = no
	}
	
	war_goal = superiority_punitive
}

# War on "primitives" (annexable religion)
cb_primitives = {
	valid_for_subject = no
	
	prerequisites = {
		OR = {
			cb_on_primitives = yes
			AND = {
				is_colonial_nation = yes
				is_neighbor_of = FROM
			}
		}
		NOT = { has_country_modifier = the_proclamation_of_year_timer } # Used from event
		FROM = { 
			primitives = yes
			OR = {
				is_subject = no
				AND = {
					is_subject = yes
					overlord = { primitives = yes }
				}
			}
		}
		is_revolution_target = no
	}
	
	war_goal = superiority_primitives	
}

cb_overseas = {
	valid_for_subject = no

	prerequisites = {
		cb_on_overseas = yes
		OR = {
			technology_group = western
			technology_group = eastern
			technology_group = ottoman
		}

		FROM = { 
			primitives = no
			is_subject = no
			capital_scope = {
				OR = {
					continent = asia
					continent = africa
				}
			}
			OR = {
				technology_group = indian
				technology_group = sub_saharan
				technology_group = chinese
				technology_group = nomad_group
			}
		}
		is_subject = no
		is_revolution_target = no
	}
	
	war_goal = superiority_overseas	
}

# Claim Throne
cb_claim_throne = {
	valid_for_subject = no
	
	prerequisites = {
		succession_claim = FROM
		is_revolution_target = no
	}
	
	war_goal = take_capital_throne
}

# Horde vs Civilized
cb_horde_vs_civ = {
	valid_for_subject = no

	prerequisites = {
		is_neighbor_of = FROM
		FROM = {
			is_nomad = no
		}
		is_nomad = yes
		is_revolution_target = no
	}
	
	war_goal = superiority_horde
}

# Tribal vs Tribal Feud
cb_tribal_feud = {
	valid_for_subject = no

	prerequisites = {
		is_nomad = yes
		FROM = {
			is_nomad = yes
		}
		is_neighbor_of = FROM
		is_revolution_target = no
	}
	
	war_goal = take_province_tribal_feud
}

# Revoke electorate
cb_revoke_electorate = {
	no_opinion_hit = yes

	prerequisites = {
		NOT = { has_dlc = "Common Sense" } # replaced by revoke elector diploaction
		NOT = { has_dlc = "Art of War" } # breaks league system
		FROM = {
			is_elector = yes
		}
		is_emperor = yes
		NOT = { religion = FROM }
		is_revolution_target = no
	}
	
	war_goal = revoke_elector
}

# When someone is privateering in a node that you trade and have some power in.
cb_privateers = {
	
	prerequisites = {
		FROM = {
			has_privateers = yes
		}
		or = {
			home_trade_node = {
				trade_share = {
					country = ROOT
					share = 10
				}
				privateer_power = {
					country = FROM
					share = 1
				}
			}
			any_active_trade_node = {
				trade_share = {
					country = ROOT
					share = 10
				}
				privateer_power = {
					country = FROM
					share = 1
				}
			}
		}
		is_revolution_target = no
	}
	
	war_goal = blockade_ports
}

# War in support of rebels
cb_support_rebels = {
	support_rebels = yes
	valid_for_subject = no
	
	prerequisites = {
		has_dlc = "Art of War"
		has_spawned_supported_rebels = FROM
		is_revolution_target = no
	}
	
	war_goal = take_capital_support_rebels
}

# Revolution
cb_crush_the_revolution = {
	ai_peace_desire = -50
	valid_for_subject = no
	

	prerequisites = {
		OR = {	
			capital_scope = { continent = europe }
			is_neighbor_of = FROM
		}
		revolution_target_exists = yes
		is_revolution_target = no
		is_subject = no
		OR = {
			government = absolute_monarchy
			government = enlightened_despotism
			government = despotic_monarchy
			government = feudal_monarchy
			government = administrative_monarchy
			government = constitutional_monarchy
			government = bureaucratic_despotism
		}
		NOT = {
			revolution_target = {
				war_with = ROOT
			}
			revolution_target = {
				truce_with = ROOT
			}
			revolution_target = {
				alliance_with = ROOT
			}  
		}
		FROM = {
			is_revolution_target = yes
		}
	}
	
	war_goal = take_capital_revolution
}

cb_spread_the_revolution = {
	valid_for_subject = no

	prerequisites = {
		is_revolution_target = yes
		OR = {	
			ai = no
			capital_scope = { continent = europe }		
		}		
		FROM = { 
			NOT = { is_subject_of = ROOT } 		
			NOT = { government = revolutionary_republic }
		}
	}
	
	war_goal = superiority_revolution
}

cb_religious_league = {
	league = yes
	ai_peace_desire = -50
	
	valid_for_subject = no

	prerequisites = {
		has_dlc = "Art of War"
		is_in_league_war = no
		FROM = { 
			is_emperor = yes 
			is_in_league_war = no
		}
		is_league_leader = yes
		hre_heretic_religion = ROOT
		is_league_enemy = FROM
		is_revolution_target = no
	}
	
	war_goal = superiority_religious_league
}

cb_flower_wars = {
	
	valid_for_subject = no

	prerequisites = {
		has_dlc = "El Dorado"
		religion = nahuatl
		is_subject = no
		is_religion_reformed = no
		FROM = { 
			NOT = { is_subject_of = ROOT } 		
		}
		is_neighbor_of = FROM
	}
	
	war_goal = take_capital_vassalize
}

cb_maya_expansion = {
	
	valid_for_subject = no

	prerequisites = {
		has_dlc = "El Dorado"
		religion = mesoamerican_religion
		is_subject = no
		is_religion_reformed = no
		FROM = { 
			NOT = { is_subject_of = ROOT }
			religion_group = pagan
		}
		is_neighbor_of = FROM
	}
	
	war_goal = take_capital_imperial
}

# Reunification of China
cb_chinese_unification = {
	valid_for_subject = no
	
	prerequisites = {
		culture_group = east_asian #Chinese
		is_subject = no
		OR = {	#Manchus won't get this unless they unify
			tag = MCH
			tag = QNG
			NOT = { primary_culture = manchu }
		}
		FROM = { #Applies against other powers in China unless they have the Mandate of Heaven
			NOT = { is_subject_of = ROOT }
			culture_group = east_asian #Chinese
			any_owned_province = {
				region = chinese_region
			}
			NOT = { has_country_modifier = the_mandate_of_heaven }
		}
		is_neighbor_of = FROM
	}
	
	war_goal = superiority_chinese_unification
}