﻿agot_hf_new_house_effect = {
	if = {
		limit = {
			NOT = { exists = mother.dynasty }
			NOT = { exists = father.dynasty }
			exists = house
		}
		trigger_event = agot_hf_new_house_name_generation_events.0001
	}
}

agot_hf_random_name_flag = {
	random_list = {
		1 = { add_character_flag = { flag = name_flag_1 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_2 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_3 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_4 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_5 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_6 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_7 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_8 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_9 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_10 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_11 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_12 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_13 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_14 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_15 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_16 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_17 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_18 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_19 days = 40 } }
		1 = { add_character_flag = { flag = name_flag_20 days = 40 } }
	}
}

agot_hf_converting_to_local_culture_effect = {
	save_scope_as = new_ruler
	if = {
		limit = {
			exists = scope:new_ruler.house
			exists = scope:new_ruler.capital_county
			OR = {
				NOT = { scope:new_ruler.culture = scope:new_ruler.capital_county.culture }
				NOT = { scope:new_ruler.faith = scope:new_ruler.capital_county.faith }
			}
			NOT = { scope:new_ruler.culture = culture:high_valyrian }
			NOT = { scope:new_ruler.culture = culture:westerosi_valyrian }
			NOT = { scope:new_ruler = scope:new_ruler.dynasty.dynast }
			NOT = { scope:new_ruler = scope:new_ruler.house.house_head }
			scope:new_ruler = {
				is_landed = yes
				agot_can_be_ruler = yes
				highest_held_title_tier < tier_hegemony
				capital_province = { NOT = { geographical_region = world_stepstones } }
				capital_province = { NOT = { geographical_region = world_westeros_the_crownlands } }
				capital_province = { NOT = { geographical_region = world_westeros_the_wall } }
			}
			scope:new_ruler.capital_county = {
				any_past_holder = {
					dynasty = scope:new_ruler.dynasty
					is_grandparent_of = scope:new_ruler
				}
			}
		}
		scope:new_ruler = {
			trigger_event = {
				id = agot_hf_new_house_name_generation_events.0003
				days = { 30 90 }
			}
		}
	}
	else_if = {
		limit = {
			scope:new_ruler = { agot_is_independent_ruler = yes }
			OR = {
				scope:new_ruler.culture = culture:high_valyrian
				scope:new_ruler.culture = culture:westerosi_valyrian
			}
			scope:new_ruler = {
				is_landed = yes
				agot_can_be_ruler = yes
				highest_held_title_tier > tier_barony
				capital_province = { NOT = { geographical_region = world_stepstones } }
				capital_province = { NOT = { geographical_region = world_westeros_the_crownlands } }
				capital_province = { NOT = { geographical_region = world_westeros_the_wall } }
			}
			NOT = { scope:new_ruler = scope:new_ruler.dynasty.dynast }
			NOT = { scope:new_ruler = scope:new_ruler.house.house_head }
			scope:new_ruler.capital_county = {
				any_past_holder = {
					dynasty = scope:new_ruler.dynasty
					is_grandparent_of = scope:new_ruler
				}
			}
		}
		add_character_flag = {
			flag = valyrian_cadet
			days = 40
		}
		scope:new_ruler = {
			trigger_event = {
				id = agot_hf_new_house_name_generation_events.0003
				days = { 30 90 }
			}
		}
	}
}