establish_fief_subject = {
	category = influence

	alert_index = 6
	alert_tooltip = establish_fief_subject_alert_tooltip

	require_acceptance = yes

	is_visible = {
		can_create_subject_type = {
			subject = FROM
			subject_type = fief_subject
		}
	}

	is_allowed = {
		can_create_subject_type = {
			subject = FROM
			subject_type = fief_subject
		}
		is_at_war = no
		FROM = {
			is_at_war = no
		}
		if = {
			limit = {
				FROM = {
					NOT = { is_subject_of = ROOT }
				}
			}
			FROM = {
				has_opinion = {
					who = ROOT
					value = 150
				}
			}
			alliance_with = FROM
			FROM = {
				NOT = { total_development = 100 }
			}
		}
		else = {
			FROM = {
				NOT = { liberty_desire = 50 }
			}
		}
	}

	on_accept = {
		if = {
			limit = {
				can_create_subject_type = {
					subject = FROM
					subject_type = fief_subject
				}
				is_at_war = no
				FROM = {
					is_at_war = no
				}
				if = {
					limit = {
						FROM = {
							NOT = { is_subject_of = ROOT }
						}
					}
					FROM = {
						has_opinion = {
							who = ROOT
							value = 150
						}
					}
					alliance_with = FROM
					FROM = {
						NOT = { total_development = 100 }
					}
				}
				else = {
					FROM = {
						NOT = { liberty_desire = 50 }
					}
				}
			}
			create_subject = {
				subject = FROM
				subject_type = fief_subject
				keep_liberty_desire = yes
			}
		}
	}

	on_decline = {
		if = {
			limit = {
				can_create_subject_type = {
					subject = FROM
					subject_type = fief_subject
				}
				is_at_war = no
				FROM = {
					is_at_war = no
				}
				if = {
					limit = {
						FROM = {
							NOT = { is_subject_of = ROOT }
						}
					}
					FROM = {
						has_opinion = {
							who = ROOT
							value = 150
						}
					}
					alliance_with = FROM
					FROM = {
						NOT = { total_development = 100 }
					}
				}
				else = {
					FROM = {
						NOT = { liberty_desire = 50 }
					}
				}
			}
			FROM = {
				clr_country_flag = declined_establish_fief_subject_@ROOT
				set_country_flag = declined_establish_fief_subject_@ROOT
			}
			add_opinion = {
				who = FROM
				modifier = declined_establish_fief_subject_opinion
			}
		}
	}

	ai_acceptance = {
		add_entry = {
			name = FROM_IS_VASSAL_OF_ROOT
			limit = {
				overlord_of = FROM
			}
			export_to_variable = {
				which = ai_value
				value = 100
			}
		}
		add_entry = {
			name = FROM_LIBERTY_DESIRE_TOO_HIGH
			limit = {
				overlord_of = FROM
				FROM = {
					liberty_desire = 50
				}
			}
			export_to_variable = {
				which = ai_value
				value = 1000
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_ATTITUDE_TOWARDS_ROOT
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					OR = {
						ai_attitude = { who = ROOT attitude = attitude_allied }
						ai_attitude = { who = ROOT attitude = attitude_friendly }
						ai_attitude = { who = ROOT attitude = attitude_threatened }
					}
				}
			}
			export_to_variable = {
				which = ai_value
				value = 10
			}
		}
		add_entry = {
			name = FROM_ATTITUDE_TOWARDS_ROOT
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					ai_attitude = { who = ROOT attitude = attitude_neutral }
				}
			}
			export_to_variable = {
				which = ai_value
				value = 20
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_ATTITUDE_TOWARDS_ROOT
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					OR = {
						ai_attitude = { who = ROOT attitude = attitude_hostile }
						ai_attitude = { who = ROOT attitude = attitude_outraged }
					}
				}
			}
			export_to_variable = {
				which = ai_value
				value = 100
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_HAS_MARRIAGE_WITH_ROOT
			limit = {
				NOT = { overlord_of = FROM }
				marriage_with = FROM
			}
			export_to_variable = {
				which = ai_value
				value = 10
			}
		}
		add_entry = {
			name = TRUST
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					trust = {
						who = ROOT
						value = 50
					}
				}
			}
			export_to_variable = {
				which = ai_value
				value = trust
				who = FROM
				with = ROOT
			}
			subtract_variable = { which = ai_value value = 50 }
			divide_variable = { which = ai_value value = 5 }
		}
		add_entry = {
			name = TRUST
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					trust = {
						who = ROOT
						value = 30
					}
					NOT = {
						trust = {
							who = ROOT
							value = 50
						}
					}
				}
			}
			export_to_variable = {
				which = ai_value
				value = trust
				who = FROM
				with = ROOT
			}
			subtract_variable = { which = ai_value value = 50 }
			multiply_variable = { which = ai_value value = 2 }
		}
		add_entry = {
			name = TRUST
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					NOT = {
						trust = {
							who = ROOT
							value = 30
						}
					}
				}
			}
			export_to_variable = {
				which = ai_value
				value = 2000
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = MODIFIER_DIPLO_SKILL
			limit = {
				NOT = { overlord_of = FROM }
			}
			export_to_variable = {
				which = ai_value
				value = modifier:diplomatic_reputation
			}
			multiply_variable = { which = ai_value value = 3 }
		}
		add_entry = {
			name = ROOT_FROM_DIFF_OF_GOV_RANKS
			limit = {
				NOT = { overlord_of = FROM }
			}
			export_to_variable = {
				which = ai_value
				value = trigger_value:government_rank
			}
			export_to_variable = {
				which = ai_value_2
				value = trigger_value:government_rank
				who = FROM
			}
			subtract_variable = { which = ai_value which = ai_value_2 }
			multiply_variable = { which = ai_value value = 10 }
		}
		add_entry = {
			name = ROOT_FROM_NOT_SAME_RELIGION_GROUP
			limit = {
				NOT = { overlord_of = FROM }
				NOT = { religion_group = FROM }
			}
			export_to_variable = {
				which = ai_value
				value = 20
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = ROOT_FROM_NOT_SAME_RELIGION
			limit = {
				NOT = { overlord_of = FROM }
				religion_group = FROM
				NOT = { religion = FROM }
			}
			export_to_variable = {
				which = ai_value
				value = 10
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_IS_MERCHANT_REPUBLIC
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					has_reform = merchants_reform
				}
			}
			export_to_variable = {
				which = ai_value
				value = 30
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = ROOT_IS_MERCHANT_REPUBLIC
			limit = {
				NOT = { overlord_of = FROM }
				has_reform = merchants_reform
			}
			export_to_variable = {
				which = ai_value
				value = 10
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = ROOT_FROM_MILITARY_POWER_COMPARED
			limit = {
				NOT = { overlord_of = FROM }
				variable_arithmetic_trigger = {
					export_to_variable = {
						which = our_mil_tech
						value = trigger_value:mil_tech
					}
					export_to_variable = {
						which = their_mil_tech
						value = trigger_value:mil_tech
						who = FROM
					}
					export_to_variable = {
						which = our_army_size
						value = trigger_value:army_size
					}
					export_to_variable = {
						which = their_army_size
						value = trigger_value:army_size
						who = FROM
					}
					export_to_variable = {
						which = military_power
						value = 0
					}
					divide_variable = { which = our_army_size value = 10 }
					divide_variable = { which = their_army_size value = -10 }
					change_variable = { which = our_army_size which = their_army_size }
					multiply_variable = { which = their_mil_tech value = -1 }
					change_variable = { which = our_mil_tech which = their_mil_tech }
					multiply_variable = { which = our_mil_tech value = 3 }
					change_variable = { which = military_power which = our_army_size }
					change_variable = { which = military_power which = our_mil_tech }

					NOT = { check_variable = { which = military_power value = -39 } }
				}
			}
			export_to_variable = {
				which = ai_value
				value = 40
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = ROOT_FROM_MILITARY_POWER_COMPARED
			limit = {
				NOT = { overlord_of = FROM }
				variable_arithmetic_trigger = {
					export_to_variable = {
						which = our_mil_tech
						value = trigger_value:mil_tech
					}
					export_to_variable = {
						which = their_mil_tech
						value = trigger_value:mil_tech
						who = FROM
					}
					export_to_variable = {
						which = our_army_size
						value = trigger_value:army_size
					}
					export_to_variable = {
						which = their_army_size
						value = trigger_value:army_size
						who = FROM
					}
					export_to_variable = {
						which = military_power
						value = 0
					}
					divide_variable = { which = our_army_size value = 10 }
					divide_variable = { which = their_army_size value = -10 }
					change_variable = { which = our_army_size which = their_army_size }
					multiply_variable = { which = their_mil_tech value = -1 }
					change_variable = { which = our_mil_tech which = their_mil_tech }
					multiply_variable = { which = our_mil_tech value = 3 }
					change_variable = { which = military_power which = our_army_size }
					change_variable = { which = military_power which = our_mil_tech }

					check_variable = { which = military_power value = -39 }
					NOT = { check_variable = { which = military_power value = 30 } }
				}
			}
			export_to_variable = {
				which = ai_value
				value = 0
			}
			export_to_variable = {
				which = our_mil_tech
				value = trigger_value:mil_tech
			}
			export_to_variable = {
				which = their_mil_tech
				value = trigger_value:mil_tech
				who = FROM
			}
			export_to_variable = {
				which = our_army_size
				value = trigger_value:army_size
			}
			export_to_variable = {
				which = their_army_size
				value = trigger_value:army_size
				who = FROM
			}
			divide_variable = { which = our_army_size value = 10 }
			divide_variable = { which = their_army_size value = -10 }
			change_variable = { which = our_army_size which = their_army_size }
			multiply_variable = { which = their_mil_tech value = -1 }
			change_variable = { which = our_mil_tech which = their_mil_tech }
			multiply_variable = { which = our_mil_tech value = 3 }
			change_variable = { which = ai_value which = our_army_size }
			change_variable = { which = ai_value which = our_mil_tech }
		}
		add_entry = {
			name = ROOT_FROM_MILITARY_POWER_COMPARED
			limit = {
				NOT = { overlord_of = FROM }
				variable_arithmetic_trigger = {
					export_to_variable = {
						which = our_mil_tech
						value = trigger_value:mil_tech
					}
					export_to_variable = {
						which = their_mil_tech
						value = trigger_value:mil_tech
						who = FROM
					}
					export_to_variable = {
						which = our_army_size
						value = trigger_value:army_size
					}
					export_to_variable = {
						which = their_army_size
						value = trigger_value:army_size
						who = FROM
					}
					export_to_variable = {
						which = military_power
						value = 0
					}
					divide_variable = { which = our_army_size value = 10 }
					divide_variable = { which = their_army_size value = -10 }
					change_variable = { which = our_army_size which = their_army_size }
					multiply_variable = { which = their_mil_tech value = -1 }
					change_variable = { which = our_mil_tech which = their_mil_tech }
					multiply_variable = { which = our_mil_tech value = 3 }
					change_variable = { which = military_power which = our_army_size }
					change_variable = { which = military_power which = our_mil_tech }
					check_variable = { which = military_power value = 30 }
				}
			}
			export_to_variable = {
				which = ai_value
				value = 30
			}
		}
		add_entry = {
			name = FROM_IS_HRE_MEMBER
			limit = {
				NOT = { overlord_of = FROM }
				is_part_of_hre = no
				FROM = {
					is_part_of_hre = yes
				}
			}
			export_to_variable = {
				which = ai_value
				value = 75
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_IS_HRE_MEMBER
			limit = {
				NOT = { overlord_of = FROM }
				is_part_of_hre = yes
				FROM = {
					is_part_of_hre = yes
				}
			}
			export_to_variable = {
				which = ai_value
				value = 25
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_IS_HRE_ELECTOR
			limit = {
				NOT = { overlord_of = FROM }
				NOT = { hre_reform_passed = erbkaisertum }
				NOT = { hre_reform_passed = emperor_erbkaisertum }
				FROM = {
					is_elector = yes
				}
			}
			export_to_variable = {
				which = ai_value
				value = 1000
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_HAS_SUBJECTS
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					num_of_subjects = 1
				}
			}
			export_to_variable = {
				which = ai_value
				value = 1000
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_IS_PAPAL_STATE
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					tag = PAP
				}
			}
			export_to_variable = {
				which = ai_value
				value = 1000
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = FROM_HAS_MORE_THAN_100_TOTAL_DEVELOPMENT
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					total_development = 100
				}
			}
			export_to_variable = {
				which = ai_value
				value = 1000
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = ROOT_OWNS_FROM_CORE_PROVINCES
			limit = {
				NOT = { overlord_of = FROM }
				any_owned_province = {
					is_core = FROM
				}
			}
			export_to_variable = {
				which = ai_value
				value = 1000
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = BORDER_DISTANCE
			limit = {
				NOT = { overlord_of = FROM }
			}
			export_to_variable = {
				which = ai_value
				value = border_distance
				who = FROM
				with = ROOT
			}
			divide_variable = { which = ai_value value = -2 }
		}
		add_entry = {
			name = ROOT_FROM_ECONOMIC_POWER_COMPARED
			limit = {
				NOT = { overlord_of = FROM }
				variable_arithmetic_trigger = {
					export_to_variable = {
						which = eco_power
						value = 60
					}
					export_to_variable = {
						which = our_total_development
						value = trigger_value:total_development
					}
					export_to_variable = {
						which = their_total_development
						value = trigger_value:total_development
						who = FROM
					}
					multiply_variable = { which = their_total_development which = their_total_development }
					divide_variable = { which = our_total_development which = their_total_development }
					multiply_variable = { which = eco_power which = our_total_development }
					change_variable = { which = eco_power value = -90 }

					check_variable = { which = eco_power value = -89 }
					NOT = { check_variable = { which = eco_power value = 30 } }
				}
			}
			export_to_variable = {
				which = ai_value
				value = 60
			}
			export_to_variable = {
				which = our_total_development
				value = trigger_value:total_development
			}
			export_to_variable = {
				which = their_total_development
				value = trigger_value:total_development
				who = FROM
			}
			multiply_variable = { which = their_total_development which = their_total_development }
			divide_variable = { which = our_total_development which = their_total_development }
			multiply_variable = { which = ai_value which = our_total_development }
			change_variable = { which = ai_value value = -90 }
		}
		add_entry = {
			name = ROOT_FROM_ECONOMIC_POWER_COMPARED
			limit = {
				NOT = { overlord_of = FROM }
				variable_arithmetic_trigger = {
					export_to_variable = {
						which = eco_power
						value = 60
					}
					export_to_variable = {
						which = our_total_development
						value = trigger_value:total_development
					}
					export_to_variable = {
						which = their_total_development
						value = trigger_value:total_development
						who = FROM
					}
					multiply_variable = { which = their_total_development which = their_total_development }
					divide_variable = { which = our_total_development which = their_total_development }
					multiply_variable = { which = eco_power which = our_total_development }
					change_variable = { which = eco_power value = -90 }

					NOT = { check_variable = { which = eco_power value = -89 } }
				}
			}
			export_to_variable = {
				which = ai_value
				value = 90
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = ROOT_FROM_ECONOMIC_POWER_COMPARED
			limit = {
				NOT = { overlord_of = FROM }
				variable_arithmetic_trigger = {
					export_to_variable = {
						which = eco_power
						value = 60
					}
					export_to_variable = {
						which = our_total_development
						value = trigger_value:total_development
					}
					export_to_variable = {
						which = their_total_development
						value = trigger_value:total_development
						who = FROM
					}
					multiply_variable = { which = their_total_development which = their_total_development }
					divide_variable = { which = our_total_development which = their_total_development }
					multiply_variable = { which = eco_power which = our_total_development }
					change_variable = { which = eco_power value = -90 }

					check_variable = { which = eco_power value = 30 }
				}
			}
			export_to_variable = {
				which = ai_value
				value = 30
			}
		}
		add_entry = {
			name = ROOT_FROM_HAVE_SAME_PRIMARY_CULTURE
			limit = {
				NOT = { overlord_of = FROM }
				primary_culture = FROM
			}
			export_to_variable = {
				which = ai_value
				value = 25
			}
		}
		add_entry = {
			name = FROM_IS_IMPERIAL_CITY
			limit = {
				NOT = { overlord_of = FROM }
				FROM = {
					has_reform = free_city
				}
			}
			export_to_variable = {
				which = ai_value
				value = 1000
			}
			multiply_variable = { which = ai_value value = -1 }
		}
		add_entry = {
			name = ROOT_HAS_CLAIMED_CULTURAL_HEGEMONY
			limit = {
				is_expanded_mod_active = { mod = peace_treaties }
				has_country_modifier = pte_culture_group_hegemony_modifier
				NOT = { is_variable_equal = { which = pte_culture_group_hegemony_var value = 0 } }
				FROM = {
					culture_group = variable:Root:pte_culture_group_hegemony_var
				}
			}
			export_to_variable = {
				which = ai_value
				value = 25
			}
		}
	}

	ai_will_do = {
		is_emperor = no
		NOT = { calc_true_if = { all_subject_country = { is_subject_of_type = fief_subject } amount = 5 } }
		num_of_free_diplomatic_relations = 1
		FROM = {
			OR = {
				NOT = { has_country_flag = declined_establish_fief_subject_@ROOT }
				had_country_flag = { flag = declined_establish_fief_subject_@ROOT days = 1825 }
			}
			NOT = { is_subject_of = ROOT }
		}
	}
}

cancel_fief_subject = {
	category = influence

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_subject_of_type = fief_subject
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = fief_subject
			}
		}
		NOT = { truce_with = FROM }
		prestige = 0
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = fief_subject
				}
				NOT = { truce_with = FROM }
				prestige = 0
			}
			FROM = {
				if = {
					limit = {
						NOT = { liberty_desire = 50 }
					}
					add_opinion = {
						who = ROOT
						modifier = vassal_abandoned
					}
				}
				grant_independence = yes
				add_truce_with = ROOT
			}
			add_truce_with = FROM
			add_prestige = -25
		}
	}

	ai_will_do = {
		FROM = {
			liberty_desire = 100
			years_in_vassalage_under = {
				who = ROOT
				years = 25
				all_subject_country = yes
			}
		}
	}
}

demand_troops_from_fief_subject = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_subject_of_type = fief_subject
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = fief_subject
			}
		}
		FROM = {
			is_at_war = no
		}
		FROM = {
			num_of_infantry = 10
		}
		FROM = { NOT = { liberty_desire = 50 } }
		FROM = {
			custom_trigger_tooltip = {
				tooltip = DID_NOT_DEMAND_TROOPS_OF_FIEF_WITHIN_LAST_10_YEARS
				NOT = { has_country_modifier = cooldown_demand_troops_from_fief_subject }
			}
		}
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = fief_subject
				}
				FROM = {
					is_at_war = no
				}
				FROM = {
					num_of_infantry = 10
				}
				FROM = { NOT = { liberty_desire = 50 } }
				FROM = {
					NOT = { has_country_modifier = cooldown_demand_troops_from_fief_subject }
				}
			}
			capital_scope = {
				infantry = ROOT
				infantry = ROOT
				infantry = ROOT
				infantry = ROOT
				infantry = ROOT
			}
			FROM = {
				add_liberty_desire = 10
				add_country_modifier = {
					name = cooldown_demand_troops_from_fief_subject
					duration = 1825
					hidden = yes
				}
				country_event = { id = subjects_expanded_fief_subject_events.1 }
			}
			random_province = {
				limit = {
					infantry_in_province = FROM
				}
				kill_units = {
					who = FROM
					type = infantry
					amount = 1
				}
			}
			random_province = {
				limit = {
					infantry_in_province = FROM
				}
				kill_units = {
					who = FROM
					type = infantry
					amount = 1
				}
			}
			random_province = {
				limit = {
					infantry_in_province = FROM
				}
				kill_units = {
					who = FROM
					type = infantry
					amount = 1
				}
			}
			random_province = {
				limit = {
					infantry_in_province = FROM
				}
				kill_units = {
					who = FROM
					type = infantry
					amount = 1
				}
			}
			random_province = {
				limit = {
					infantry_in_province = FROM
				}
				kill_units = {
					who = FROM
					type = infantry
					amount = 1
				}
			}
		}
	}

	ai_will_do = {
		always = no
	}
}

enforce_call_to_arms_from_fief_subject = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_subject_of_type = fief_subject
		}
		is_at_war = yes
		OR = {
			is_in_war = {
				attacker_leader = ROOT
			}
			is_in_war = {
				defender_leader = ROOT
			}
		}
		any_country = {
			OR = {
				is_in_war = {
					attacker_leader = ROOT
					defender_leader = THIS
				}
				is_in_war = {
					attacker_leader = THIS
					defender_leader = ROOT
				}
			}
			NOT = { war_with = FROM }
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = fief_subject
			}
			is_at_war = yes
			OR = {
				is_in_war = {
					attacker_leader = ROOT
				}
				is_in_war = {
					defender_leader = ROOT
				}
			}
			any_country = {
				OR = {
					is_in_war = {
						attacker_leader = ROOT
						defender_leader = THIS
					}
					is_in_war = {
						attacker_leader = THIS
						defender_leader = ROOT
					}
				}
				NOT = { war_with = FROM }
			}
		}
		if = {
			limit = {
				OR = {
					AND = {
						NOT = { has_dlc = "Conquest of Paradise" }
						NOT = { has_dlc = "El Dorado" }
					}
					NOT = {
						any_war_enemy_country = {
							is_supporting_independence_of = FROM
						}
					}
				}
			}
			FROM = { NOT = { liberty_desire = 50 } }
		}
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = fief_subject
				}
				is_at_war = yes
				OR = {
					is_in_war = {
						attacker_leader = ROOT
					}
					is_in_war = {
						defender_leader = ROOT
					}
				}
				any_country = {
					OR = {
						is_in_war = {
							attacker_leader = ROOT
							defender_leader = THIS
						}
						is_in_war = {
							attacker_leader = THIS
							defender_leader = ROOT
						}
					}
					NOT = { war_with = FROM }
				}
				if = {
					limit = {
						OR = {
							AND = {
								NOT = { has_dlc = "Conquest of Paradise" }
								NOT = { has_dlc = "El Dorado" }
							}
							NOT = {
								any_war_enemy_country = {
									is_supporting_independence_of = FROM
								}
							}
						}
					}
					FROM = { NOT = { liberty_desire = 50 } }
				}
			}
			FROM = {
				add_liberty_desire = 25
				join_all_defensive_wars_of = ROOT
				join_all_offensive_wars_of = ROOT
				country_event = { id = subjects_expanded_fief_subject_events.2 }
			}
		}
	}

	ai_will_do = {
		is_at_war = yes
		NOT = { war_score = -10 }
		FROM = {
			army_size = 5
			NOT = { liberty_desire = 30 }
		}
	}
}