increase_colonial_autonomy = {
	category = influence

	require_acceptance = no

	is_visible = {
		OR = {
			AND = {
				FROM = { is_colonial_subject_type = yes }
				OR = {
					can_create_subject_type = {
						subject = FROM
						subject_type = dominion
					}
					can_create_subject_type = {
						subject = FROM
						subject_type = dominion_tc
					}
				}
			}
			AND = {
				FROM = {
					is_dominion_or_similar_subject = yes
				}
				OR = {
					can_create_subject_type = {
						subject = FROM
						subject_type = autonomous_dominion
					}
					can_create_subject_type = {
						subject = FROM
						subject_type = autonomous_dominion_tc
					}
				}
			}
		}
	}

	is_allowed = {
		hidden_trigger = {
			OR = {
				AND = {
					FROM = { is_colonial_subject_type = yes }
					OR = {
						can_create_subject_type = {
							subject = FROM
							subject_type = dominion
						}
						can_create_subject_type = {
							subject = FROM
							subject_type = dominion_tc
						}
					}
				}
				AND = {
					FROM = {
						is_dominion_or_similar_subject = yes
					}
					OR = {
						can_create_subject_type = {
							subject = FROM
							subject_type = autonomous_dominion
						}
						can_create_subject_type = {
							subject = FROM
							subject_type = autonomous_dominion_tc
						}
					}
				}
			}
		}
		num_of_colonists = 1
		FROM = {
			capital_scope = { trade_range = ROOT }
		}
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = {
			liberty_desire = 50
		}
	}

	on_accept = {
		if = {
			limit = {
				num_of_colonists = 1
				OR = {
					AND = {
						FROM = { is_colonial_subject_type = yes }
						OR = {
							can_create_subject_type = {
								subject = FROM
								subject_type = dominion
							}
							can_create_subject_type = {
								subject = FROM
								subject_type = dominion_tc
							}
						}
					}
					AND = {
						FROM = {
							is_dominion_or_similar_subject = yes
						}
						OR = {
							can_create_subject_type = {
								subject = FROM
								subject_type = autonomous_dominion
							}
							can_create_subject_type = {
								subject = FROM
								subject_type = autonomous_dominion_tc
							}
						}
					}
				}
				FROM = {
					capital_scope = { trade_range = ROOT }
				}
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = {
					liberty_desire = 50
				}
			}
			if = {
				limit = {
					FROM = {
						is_any_dominion_subject = yes
					}
				}
				if = {
					limit = {
						FROM = {
							is_any_trade_company_region_dominion_subject = yes
						}
					}
					create_subject = {
						subject = FROM
						subject_type = autonomous_dominion_tc
						keep_liberty_desire = yes
					}
				}
				else = {
					create_subject = {
						subject = FROM
						subject_type = autonomous_dominion
						keep_liberty_desire = yes
					}
				}
			}
			else = {
				create_subject = {
					subject = FROM
					subject_type = dominion
					keep_liberty_desire = yes
				}
			}
			FROM = {
				country_event = { id = subjects_expanded_dominion_events.1 }
				swap_free_idea_group = yes
			}
			add_country_modifier = {
				name = established_autonomous_dominion
				duration = 3650
				hidden = yes
			}
		}
	}

	ai_will_do = {
		NOT = { has_age_ability = ab_industrial_british_empire }
		OR = {
			AND = {
				is_random_new_world = no
				tag = GBR
				FROM = {
					capital_scope = {
						colonial_region = colonial_canada
					}
				}
			}
			AND = {
				FROM = {
					OR = {
						AND = {
							development_of_overlord_fraction = 0.33
							liberty_desire = 75
						}
						liberty_desire = 90
					}
				}
				NOT = { has_country_modifier = established_autonomous_dominion }
				OR = {
					tag = GBR
					tag = ENG
					tag = FRA
					tag = FR2
					tag = SPA
					tag = CAS
					tag = POR
					AND = {
						num_of_colonists = 3
						calc_true_if = {
							all_subject_country = {
								OR = {
									is_colonial_subject_type = yes
									is_any_dominion_subject = yes
								}
							}
							amount = 5
						}
					}
				}
				# FROM is not best paying colony of ROOT (if liberty_desire is smaller than 50)
				OR = {
					FROM = { is_dominion_or_similar_subject = yes }
					FROM = { liberty_desire = 50 }
					any_subject_country = {
						is_colonial_subject_type = yes
						NOT = { is_subject_of_type = viking_settlement }
						NOT = { is_any_dominion_subject = yes }
						NOT = { tag = FROM }
						variable_arithmetic_trigger = {
							custom_tooltip = FROM_TARIFF_VALUE
							# Export Overlord's Global Tariffs
							export_to_variable = {
								which = overlord_global_tariffs
								value = modifier:global_tariffs
								who = ROOT
							}
							# Export FROM's Monthly Income
							export_to_variable = {
								which = FROM_cn_tariff_value
								value = monthly_income
								who = FROM
							}
							# Export FROM's Tariff Percentage
							export_to_variable = {
								which = FROM_cn_tariff_percentage
								value = trigger_value:tariff_value
								who = FROM
							}
							# Calculate Tariff Efficiency
							change_variable = { which = overlord_global_tariffs value = 1 }
							multiply_variable = { which = FROM_cn_tariff_percentage which = overlord_global_tariffs }
							# Calculate Payed Money
							multiply_variable = { which = FROM_cn_tariff_value which = FROM_cn_tariff_percentage }
							divide_variable = { which = FROM_cn_tariff_value value = 10 }
							multiply_variable = { which = FROM_cn_tariff_value value = 10 }

							# Compare to other Colonies
							export_to_variable = {
								which = cn_tariff_value
								value = monthly_income
							}
							export_to_variable = {
								which = cn_tariff_percentage
								value = trigger_value:tariff_value
							}
							multiply_variable = { which = cn_tariff_percentage which = overlord_global_tariffs }
							multiply_variable = { which = cn_tariff_value which = cn_tariff_percentage }
							divide_variable = { which = cn_tariff_value value = 10 }
							multiply_variable = { which = cn_tariff_value value = 10 }

							check_variable = { which = cn_tariff_value which = FROM_cn_tariff_value }
						}
					}
				}
			}
		}
	}
}

decrease_colonial_autonomy = {
	category = influence

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			OR = {
				is_any_colonial_region_dominion_subject = yes
				is_autonomous_dominion_or_similar_subject = yes
			}
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				OR = {
					is_any_colonial_region_dominion_subject = yes
					is_autonomous_dominion_or_similar_subject = yes
				}
			}
		}
		num_of_colonists = 1
		FROM = {
			capital_scope = { trade_range = ROOT }
		}
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = {
			NOT = { liberty_desire = 50 }
		}
	}

	on_accept = {
		if = {
			limit = {
				num_of_colonists = 1
				FROM = {
					is_subject_of = ROOT
					OR = {
						is_any_colonial_region_dominion_subject = yes
						is_autonomous_dominion_or_similar_subject = yes
					}
				}
				FROM = {
					capital_scope = { trade_range = ROOT }
				}
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = {
					NOT = { liberty_desire = 50 }
				}
			}
			if = {
				limit = {
					FROM = { is_autonomous_dominion_or_similar_subject = yes }
				}
				if = {
					limit = {
						FROM = {
							is_any_trade_company_region_dominion_subject = yes
						}
					}
					create_subject = {
						subject = FROM
						subject_type = dominion_tc
						keep_liberty_desire = yes
					}
				}
				else = {
					create_subject = {
						subject = FROM
						subject_type = dominion
						keep_liberty_desire = yes
					}
				}
			}
			else = {
				if = {
					limit = {
						has_dlc = "Leviathan"
					}
					create_subject = {
						subject = FROM
						subject_type = crown_colony
						keep_liberty_desire = yes
					}
				}
				else = {
					create_subject = {
						subject = FROM
						subject_type = colony
						keep_liberty_desire = yes
					}
				}
			}
			FROM = {
				add_liberty_desire = 25
				swap_free_idea_group = yes
			}
		}
	}

	ai_will_do = {
		NOT = { has_country_modifier = established_autonomous_dominion }
		FROM = {
			NOT = { liberty_desire = 33 }
			NOT = { development_of_overlord_fraction = 0.33 }
		}
	}
}

demand_manpower_from_autonomous_dominion = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_autonomous_dominion_or_similar_subject = yes
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_autonomous_dominion_or_similar_subject = yes
			}
		}
		is_at_war = yes
		FROM = { is_at_war = no }
		FROM = {
			manpower = 5
		}
		FROM = {
			NOT = { liberty_desire = 50 }
		}
		FROM = {
			custom_trigger_tooltip = {
				tooltip = DID_NOT_DEMAND_MANPOWER_OF_AUTONOMOUS_DOMINION_WITHIN_LAST_5_YEARS
				NOT = { has_country_modifier = cooldown_demand_manpower_from_autonomous_dominion }
			}
		}
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_autonomous_dominion_or_similar_subject = yes
				}
				is_at_war = yes
				FROM = { is_at_war = no }
				FROM = {
					manpower = 5
				}
				FROM = {
					NOT = { liberty_desire = 50 }
				}
			}
			add_manpower = 5
			FROM = {
				add_manpower = -5
				add_liberty_desire = 10
				country_event = { id = subjects_expanded_dominion_events.2 }
				add_country_modifier = {
					name = cooldown_demand_manpower_from_autonomous_dominion
					duration = 1825
					hidden = yes
				}
			}
		}
	}

	ai_will_do = {
		NOT = { manpower = 1 }
		FROM = {
			manpower = 5
			NOT = { liberty_desire = 40 }
		}
	}
}

seize_provinces_in_other_colonial_regions = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		ai = no
		FROM = {
			is_subject_of = ROOT
			OR = {
				is_colonial_subject_type = yes
				is_subject_of_type = dominion
			}
			any_owned_province = {
				NOT = { colonial_region = CAPITAL }
			}
		}
	}

	is_allowed = {
		hidden_trigger = {
			ai = no
			FROM = {
				is_subject_of = ROOT
				OR = {
					is_colonial_subject_type = yes
					is_subject_of_type = dominion
				}
				any_owned_province = {
					NOT = { colonial_region = CAPITAL }
				}
			}
		}
		num_of_colonists = 1
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = {
			NOT = { liberty_desire = 50 }
		}
		FROM = {
			OR = {
				num_of_owned_provinces_with = {
					value = 5
					custom_trigger_tooltip = {
						tooltip = IS_NOT_IN_THE_CAPITAL_COLONIAL_REGION
						NOT = { colonial_region = CAPITAL }
					}
					custom_trigger_tooltip = {
						tooltip = HAS_NO_OTHER_COLONIAL_NATION_IN_SAME_REGION
						NOT = {
							any_province = {
								colonial_region = PREV
								colonial_region = CAPITAL
								owner = {
									NOT = { tag = FROM }
									is_subject_of = ROOT
									OR = {
										is_colonial_subject_type = yes
										is_any_colonial_region_dominion_subject = yes
									}
								}
							}
						}
					}
				}
				any_owned_province = {
					custom_trigger_tooltip = {
						tooltip = IS_NOT_IN_THE_CAPITAL_COLONIAL_REGION
						NOT = { colonial_region = CAPITAL }
					}
					custom_trigger_tooltip = {
						tooltip = HAS_OTHER_COLONIAL_NATION_IN_SAME_REGION
						any_province = {
							colonial_region = PREV
							colonial_region = CAPITAL
							owner = {
								NOT = { tag = FROM }
								is_subject_of = ROOT
								OR = {
									is_colonial_subject_type = yes
									is_any_colonial_region_dominion_subject = yes
								}
							}
						}
					}
				}
			}
		}
	}

	on_accept = {
		if = {
			limit = {
				ai = no
				num_of_colonists = 1
				FROM = {
					is_subject_of = ROOT
					OR = {
						is_colonial_subject_type = yes
						is_subject_of_type = dominion
					}
					any_owned_province = {
						NOT = { colonial_region = CAPITAL }
					}
				}
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = {
					NOT = { liberty_desire = 50 }
				}
				FROM = {
					OR = {
						num_of_owned_provinces_with = {
							value = 5
							custom_trigger_tooltip = {
								tooltip = IS_NOT_IN_THE_CAPITAL_COLONIAL_REGION
								NOT = { colonial_region = CAPITAL }
							}
							custom_trigger_tooltip = {
								tooltip = HAS_NO_OTHER_COLONIAL_NATION_IN_SAME_REGION
								NOT = {
									any_province = {
										colonial_region = PREV
										colonial_region = CAPITAL
										owner = {
											NOT = { tag = FROM }
											is_subject_of = ROOT
											OR = {
												is_colonial_subject_type = yes
												is_any_colonial_region_dominion_subject = yes
											}
										}
									}
								}
							}
						}
						any_owned_province = {
							custom_trigger_tooltip = {
								tooltip = IS_NOT_IN_THE_CAPITAL_COLONIAL_REGION
								NOT = { colonial_region = CAPITAL }
							}
							custom_trigger_tooltip = {
								tooltip = HAS_OTHER_COLONIAL_NATION_IN_SAME_REGION
								any_province = {
									colonial_region = PREV
									colonial_region = CAPITAL
									owner = {
										NOT = { tag = FROM }
										is_subject_of = ROOT
										OR = {
											is_colonial_subject_type = yes
											is_any_colonial_region_dominion_subject = yes
										}
									}
								}
							}
						}
					}
				}
			}
			FROM = {
				add_liberty_desire = 15
				every_owned_province = {
					limit = {
						NOT = { colonial_region = CAPITAL }
						OR = {
							AND = {
								NOT = {
									any_province = {
										colonial_region = PREV
										colonial_region = CAPITAL
										owner = {
											NOT = { tag = FROM }
											is_subject_of = ROOT
											OR = {
												is_colonial_subject_type = yes
												is_any_colonial_region_dominion_subject = yes
											}
										}
									}
								}
								calc_true_if = {
									all_province = {
										OR = {
											has_province_flag = was_seized_by_colony_overlord_@ROOT
											AND = {
												owned_by = FROM
												colonial_region = PREV
												NOT = { province_id = PREV }
												NOT = { colonial_region = CAPITAL }
												NOT = {
													any_province = {
														colonial_region = PREV
														colonial_region = CAPITAL
														owner = {
															NOT = { tag = FROM }
															is_subject_of = ROOT
															OR = {
																is_colonial_subject_type = yes
																is_any_colonial_region_dominion_subject = yes
															}
														}
													}
												}
											}
										}
									}
									amount = 4
								}
							}
							any_province = {
								colonial_region = PREV
								colonial_region = CAPITAL
								owner = {
									NOT = { tag = FROM }
									is_subject_of = ROOT
									OR = {
										is_colonial_subject_type = yes
										is_any_colonial_region_dominion_subject = yes
									}
								}
							}
						}
					}
					set_province_flag = was_seized_by_colony_overlord_@ROOT
					if = {
						limit = {
							is_core = PREV
						}
						remove_core = PREV
						add_core = ROOT
					}
					cede_province = ROOT
				}
			}
			every_owned_province = {
				clr_province_flag = was_seized_by_colony_overlord_@ROOT
			}
		}
	}

	ai_will_do = {
		always = no
	}
}

combine_colony_with_other_colony_in_same_colonial_region = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		ai = no
		FROM = {
			is_subject_of = ROOT
			is_colonial_subject_type = yes
		}
		any_subject_country = {
			is_colonial_subject_type = yes
			NOT = { tag = FROM }
			ai = yes
			capital_scope = {
				FROM = {
					capital_scope = {
						colonial_region = PREV_PREV
					}
				}
			}
		}
	}

	is_allowed = {
		hidden_trigger = {
			ai = no
			FROM = {
				is_subject_of = ROOT
				is_colonial_subject_type = yes
			}
		}
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = {
			NOT = { liberty_desire = 50 }
		}
		custom_trigger_tooltip = {
			tooltip = COMBINE_COLONY_WITH_OTHER_COLONY_IN_SAME_COLONIAL_REGION_VALID_OTHER_COLONY_TT
			any_subject_country = {
				is_colonial_subject_type = yes
				NOT = { tag = FROM }
				ai = yes
				NOT = { liberty_desire = 50 }
				is_at_war = no
				capital_scope = {
					FROM = {
						capital_scope = {
							colonial_region = PREV_PREV
						}
					}
				}
			}
		}
	}

	on_accept = {
		if = {
			limit = {
				ai = no
				FROM = {
					is_subject_of = ROOT
					is_colonial_subject_type = yes
				}
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = {
					NOT = { liberty_desire = 50 }
				}
				any_subject_country = {
					is_colonial_subject_type = yes
					NOT = { tag = FROM }
					ai = yes
					NOT = { liberty_desire = 50 }
					is_at_war = no
					capital_scope = {
						FROM = {
							capital_scope = {
								colonial_region = PREV_PREV
							}
						}
					}
				}
			}
			FROM = {
				add_liberty_desire = -10
			}
			every_subject_country = {
				limit = {
					is_colonial_subject_type = yes
					NOT = { tag = FROM }
					ai = yes
					NOT = { liberty_desire = 50 }
					is_at_war = no
					capital_scope = {
						FROM = {
							capital_scope = {
								colonial_region = PREV_PREV
							}
						}
					}
				}
				FROM = { inherit = PREV }
			}
		}
	}

	ai_will_do = {
		always = no
	}
}

seize_provinces_in_other_trade_company_regions = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_subject_of_type = dominion_tc
			is_dominion_tag = yes
			tc_dominion_owns_provinces_in_wrong_trade_company_region = yes
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = dominion_tc
				is_dominion_tag = yes
				tc_dominion_owns_provinces_in_wrong_trade_company_region = yes
			}
		}
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = {
			NOT = { liberty_desire = 50 }
		}
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = dominion_tc
					is_dominion_tag = yes
					tc_dominion_owns_provinces_in_wrong_trade_company_region = yes
				}
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = {
					NOT = { liberty_desire = 50 }
				}
			}
			FROM = {
				add_liberty_desire = 10
				every_owned_province = {
					limit = {
						tc_dominion_province_is_in_wrong_trade_company_region = yes
					}
					if = {
						limit = {
							is_core = PREV
						}
						remove_core = PREV
						add_core = ROOT
					}
					cede_province = ROOT
				}
			}
		}
	}

	ai_will_do = {
		FROM = {
			num_of_owned_provinces_with = {
				value = 5
				tc_dominion_province_is_in_wrong_trade_company_region = yes
			}
		}
	}
}