﻿rule_title_creation_imperial_power_projection_title_creation_trigger = {
	trigger_if = {
		limit = {
			has_game_rule = title_creation_imperial_power_projection_any_power_advantage
			rule_title_creation_imperial_power_projection_title_creation_targeting_trigger = yes
			highest_held_title_tier <= tier_kingdom
		}
		custom_tooltip = {
			text = rule_title_creation_imperial_power_projection_title_creation_trigger.tt.any_power_advantage
			any_neighboring_top_liege_realm_owner = {
				count = all
				trigger_if = {
					limit = { highest_held_title_tier >= tier_empire }
					save_temporary_scope_as = char_temp
					OR = {
						any_close_family_member = { is_spouse_of = root }
						root = { has_strong_hook = scope:char_temp }
						root.current_military_strength >= scope:char_temp.fifty_percent_more_of_current_military_strength
					}
				}
				trigger_else = { always = yes }
			}
		}
	}
	trigger_else_if = {
		limit = {
			has_game_rule = title_creation_imperial_power_projection_hard_power_only
			rule_title_creation_imperial_power_projection_title_creation_targeting_trigger = yes
			highest_held_title_tier <= tier_kingdom
		}
		custom_tooltip = {
			text = rule_title_creation_imperial_power_projection_title_creation_trigger.tt.hard_power_only
			any_neighboring_top_liege_realm_owner = {
				count = all
				trigger_if = {
					limit = { highest_held_title_tier >= tier_empire }
					save_temporary_scope_as = char_temp
					root.current_military_strength >= scope:char_temp.fifty_percent_more_of_current_military_strength
				}
				trigger_else = { always = yes }
			}
		}
	}
	trigger_else_if = {
		limit = {
			has_game_rule = title_creation_imperial_power_projection_soft_power_only
			rule_title_creation_imperial_power_projection_title_creation_targeting_trigger = yes
			highest_held_title_tier <= tier_kingdom
		}
		custom_tooltip = {
			text = rule_title_creation_imperial_power_projection_title_creation_trigger.tt.soft_power_only
			any_neighboring_top_liege_realm_owner = {
				count = all
				trigger_if = {
					limit = { highest_held_title_tier >= tier_empire }
					save_temporary_scope_as = char_temp
					OR = {
						any_close_family_member = { is_spouse_of = root }
						root = { has_strong_hook = scope:char_temp }
					}
				}
				trigger_else = { always = yes }
			}
		}
	}
	trigger_else_if = {
		limit = {
			has_game_rule = title_creation_imperial_power_projection_hard_power_only_strict
			rule_title_creation_imperial_power_projection_title_creation_targeting_trigger = yes
			highest_held_title_tier <= tier_kingdom
		}
		custom_tooltip = {
			text = rule_title_creation_imperial_power_projection_title_creation_trigger.tt.hard_power_only_strict.neighbours
			any_neighboring_top_liege_realm_owner = {
				count = all
				trigger_if = {
					limit = { highest_held_title_tier >= tier_empire }
					save_temporary_scope_as = char_temp
					root.current_military_strength >= scope:char_temp.fifty_percent_more_of_current_military_strength
				}
				trigger_else = { always = yes }
			}
		}
		custom_tooltip = {
			text = rule_title_creation_imperial_power_projection_title_creation_trigger.tt.hard_power_only_strict.de_jure_sharers
			any_sub_realm_county = {
				count = all
				empire = {
					OR = {
						is_title_created = no
						holder = {
							save_temporary_scope_as = char_temp
							root.current_military_strength >= scope:char_temp.fifty_percent_more_of_current_military_strength
						}
					}
				}
			}
		}
	}
	trigger_else_if = {
		limit = {
			has_game_rule = title_creation_imperial_power_projection_any_power_strict
			rule_title_creation_imperial_power_projection_title_creation_targeting_trigger = yes
			highest_held_title_tier <= tier_kingdom
		}
		custom_tooltip = {
			text = rule_title_creation_imperial_power_projection_title_creation_trigger.tt.any_power_strict.neighbours
			any_neighboring_top_liege_realm_owner = {
				count = all
				trigger_if = {
					limit = { highest_held_title_tier >= tier_empire }
					save_temporary_scope_as = char_temp
					OR = {
						any_close_family_member = { is_spouse_of = root }
						root = { has_strong_hook = scope:char_temp }
						root.current_military_strength >= scope:char_temp.fifty_percent_more_of_current_military_strength
					}
				}
				trigger_else = { always = yes }
			}
		}
		custom_tooltip = {
			text = rule_title_creation_imperial_power_projection_title_creation_trigger.tt.any_power_strict.de_jure_sharers
			any_sub_realm_county = {
				count = all
				empire = {
					OR = {
						is_title_created = no
						holder = {
							save_temporary_scope_as = char_temp
							OR = {
								any_close_family_member = { is_spouse_of = root }
								root = { has_strong_hook = scope:char_temp }
								root.current_military_strength >= scope:char_temp.fifty_percent_more_of_current_military_strength
							}
						}
					}
				}
			}
		}
	}
	trigger_else = { always = yes }
	
	# AI can't create empire title if they can do HRE
	trigger_if = {
		# this checks if the decisions COULD be taken
		limit = {
			is_ai = yes
			is_landed_or_landless_administrative = yes
			exists = dynasty
			NOR = {
				has_global_variable = flag_restored_roman_empire
				exists = title:e_hre.holder
				exists = title:e_france.holder
				highest_held_title_tier = tier_empire
			}
			exists = faith.religious_head
			NOT = { this = faith.religious_head }
			faith = {
				religion_tag = christianity_religion
				has_doctrine_parameter = spiritual_head_of_faith
			}
			NAND = {
				exists = title:e_byzantium.holder
				faith = title:e_byzantium.holder.faith
			}
			OR = {
				government_has_flag = government_is_feudal
				government_has_flag = government_is_clan
				government_allows = administrative
			}
		}
		# these title holders should be working towards HRE
		NOR = {
			has_title = title:k_east_francia
			has_title = title:k_bavaria
			has_title = title:k_france
			has_title = title:k_lotharingia
			has_title = title:k_italy
			any_held_title = {
				title_tier = kingdom
				is_titular = no
				title_capital_county.title_province = {
					OR = {
						geographical_region = world_europe_west_germania
						geographical_region = custom_northern_italy
					}
				}
			}
		}
	}
}

