establish_roman_client_kingdom = {
	category = influence

	require_acceptance = no

	is_visible = {
		can_create_subject_type = {
			subject = FROM
			subject_type = roman_client_kingdom
		}
		FROM = {
			is_subject_of = PREV
		}
	}

	is_allowed = {
		can_create_subject_type = {
			subject = FROM
			subject_type = roman_client_kingdom
		}
		FROM = {
			is_subject_of = PREV
		}
		NOT = { truce_with = FROM }
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = { NOT = { liberty_desire = 50 } }
	}

	on_accept = {
		if = {
			limit = {
				can_create_subject_type = {
					subject = FROM
					subject_type = roman_client_kingdom
				}
				FROM = {
					is_subject_of = PREV
				}
				NOT = { truce_with = FROM }
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = { NOT = { liberty_desire = 50 } }
			}
			create_subject = {
				subject = FROM
				subject_type = roman_client_kingdom
				keep_liberty_desire = yes
			}
		}
	}

	ai_will_do = {
		OR = {
			num_of_free_diplomatic_relations = 1
			FROM = {
				any_neighbor_country = {
					OR = {
						is_rival = FROM
						is_enemy = FROM
					}
				}
			}
		}
		FROM = {
			NOT = { is_subject_of_type = exarchate_subject }
			NOT = {
				years_in_vassalage_under = {
					who = ROOT
					years = 10
					all_subject_country = yes
				}
			}
		}
	}
}

cancel_roman_client_kingdom = {
	category = influence

	require_acceptance = no

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

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

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = roman_client_kingdom
				}
				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 = 30
				all_subject_country = yes
			}
		}
	}
}

place_roman_ruler_on_subject_throne = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_subject_of_type = roman_client_kingdom
			government = monarchy
			has_regency = no
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = roman_client_kingdom
				government = monarchy
				has_regency = no
			}
		}
		NOT = { truce_with = FROM }
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = { NOT = { liberty_desire = 50 } }
		FROM = {
			custom_trigger_tooltip = {
				tooltip = DID_NOT_REPLACE_CURRENT_RULER
				NOT = { has_ruler_flag = placed_on_throne_by_@ROOT }
			}
		}
		custom_trigger_tooltip = {
			tooltip = DID_NOT_REPLACE_RULER_WITHIN_LAST_50_YEARS
			NOT = { has_country_modifier = cooldown_placed_roman_ruler_on_subject_throne }
		}
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = roman_client_kingdom
					government = monarchy
					has_regency = no
				}
				NOT = { truce_with = FROM }
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = { NOT = { liberty_desire = 50 } }
				FROM = {
					NOT = { has_ruler_flag = placed_on_throne_by_@ROOT }
				}
				NOT = { has_country_modifier = cooldown_placed_roman_ruler_on_subject_throne }
			}
			FROM = {
				define_ruler = {
					culture = ROOT
					religion = ROOT
					male = yes
				}
				if = {
					limit = {
						has_heir = yes
					}
					kill_heir = {}
				}
				add_liberty_desire = 10
				set_ruler_flag = placed_on_throne_by_@ROOT
				add_opinion = {
					who = ROOT
					modifier = roman_client_kingdom_replaced_ruler
				}
			}
			add_country_modifier = {
				name = cooldown_placed_roman_ruler_on_subject_throne
				duration = 18250
				hidden = yes
			}
		}
	}

	ai_will_do = {
		FROM = {
			months_of_ruling = 60
			NOT = { marriage_with = ROOT }
			NOT = { dynasty = ROOT }
			NOT = { ruler_culture = ROOT }
			OR = {
				AND = {
					has_heir = no
					NOT = { legitimacy = 50 }
				}
				AND = {
					is_female = yes
					ROOT = { is_female = no }
				}
			}
		}
	}
}

demand_additional_tribute_from_roman_client_kingdom = {
	category = subject_interactions

	require_acceptance = no

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

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = roman_client_kingdom
			}
		}
		FROM = { NOT = { liberty_desire = 50 } }
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = roman_client_kingdom
				}
				FROM = { NOT = { liberty_desire = 50 } }
			}
			FROM = {
				country_event = { id = subjects_expanded_roman_client_kingdom_events.3 }
			}
		}
	}

	ai_will_do = {
		always = no
	}
}