﻿form_the_hunnic_empire_decision = {

	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_concession.dds"
	}
	decision_group_type = major
	desc = form_the_hunnic_empire_decision_desc

	is_shown = {
		OR = {
			culture = { has_cultural_pillar = heritage_hunnic }
		}
		NOT = { exists = title:e_hunnic_empire.holder }
	}
	
	is_valid = {
		prestige_level >= 5
		culture = { has_cultural_pillar = heritage_hunnic }
		has_trait = viking
		has_trait = education_martial_5
		completely_controls_region = custom_hunnic
		has_title = title:k_hungary
	}

	effect = {
		save_scope_as = founder
		
		culture = {save_scope_as = old_culture }
		
		trigger_event = { id = attila_events.1 }
		
		create_title_and_vassal_change = {
			type = created
			save_scope_as = title_change
			add_claim_on_loss = no
		}
		title:e_hunnic_empire = {
			change_title_holder = {
				holder = root
				change = scope:title_change
			}
			hidden_effect = {
			copy_title_history = title:k_huns
			}
		}
		resolve_title_and_vassal_change = scope:title_change
		
		custom_tooltip = {
			text = ckc_become_de_jure_liege_hunnic_empire
			destroy_title = title:e_carpathia
			title:k_hungary = { set_de_jure_liege_title = title:e_hunnic_empire }
			title:k_pontic_steppe = { set_de_jure_liege_title = title:e_hunnic_empire }
			title:k_moldavia = { set_de_jure_liege_title = title:e_hunnic_empire }
			title:k_dacia = { set_de_jure_liege_title = title:e_hunnic_empire }
			title:k_bohemia = { set_de_jure_liege_title = title:e_hunnic_empire }
			title:k_caucasus = { set_de_jure_liege_title = title:e_hunnic_empire }
			title:k_moravia = { set_de_jure_liege_title = title:e_hunnic_empire }
			title:k_croatia = { set_de_jure_liege_title = title:e_byzantium }
		}
		custom_tooltip = {
			text= become_house_attilid
			if = {
			limit = {
				NOT = {
				house = house:house_Attilid
				}
			}
			attila_convert_house_and_descendants_effect = {
				NEW_HOUSE = house:house_Attilid
				}
			}
		}
		dynasty:dynn_Elmingirid = { add_dynasty_prestige = 2500 }
	
		custom_tooltip = {
			text = ckc_attila_nickname
		}
		copy_title_history = title:k_huns
		culture:hunnic = {
			add_culture_tradition = tradition_apocalypse_horsemen
		}
		add_trait = attila_scion
		
		every_child = {
		even_if_dead = yes
		add_trait = attila_scion

		every_child = {
			even_if_dead = yes
			limit = {
				OR = {
					is_grandchild_of = scope:founder
					is_great_grandchild_of = scope:founder
				}
			}
			add_trait = attila_scion

			every_child = {
				even_if_dead = yes
				limit = {
					OR = {
						is_grandchild_of = scope:founder
						is_great_grandchild_of = scope:founder
					}
				}
				add_trait = attila_scion
				}
			}
		}
		if = {
		limit = {
			culture = { has_cultural_pillar = heritage_hunnic }
		}

		# Convert my culture to Hunnic Culture
		set_culture = culture:hunnic
		culture:hunnic = {
			get_all_innovations_from = scope:old_culture
		}

		# Convert my courtiers to Hunnic
		hidden_effect = {
			every_courtier = {
				limit = {
					culture = { has_cultural_pillar = heritage_hunnic }
				}
				set_culture = culture:hunnic
			}
		}

		# Convert my vassals to Hunnic
		every_vassal_or_below = {
			limit = {
				culture = { has_cultural_pillar = heritage_hunnic }
			}

			custom = promote_hunnic_decision_every_vassal_custom
			set_culture = culture:hunnic

			# Convert their courtiers as well
			hidden_effect = {
				every_courtier = {
					limit = {
						culture = { has_cultural_pillar = heritage_hunnic }
					}
					set_culture = culture:hunnic
					}
				}
			}
		}
		title:e_hunnic_empire = {
		every_in_de_jure_hierarchy = {
			custom = promote_hunnic_settlement_decision_every_province_custom
			limit = {
				tier = tier_county
				culture = scope:old_culture
				title_province = { geographical_region = custom_hunnic }
				holder = {
					OR = {
						this = root
						target_is_liege_or_above = root
					}
				}
			}
			set_county_culture = culture:hunnic
			
			hidden_effect = {
				if = {
					limit = {
						development_level < 5
					}
					change_development_level = 5
					}
				}
			}
		}
	}

	cost = {
		gold = 500
		prestige = {
			value = {
				add = 0
				if = {
					limit = {
						government_has_flag = government_is_tribal
					}
					add = medium_prestige_value
				}
			}
		}
		herd = {
			value = {
				add = 0
				if = {
					limit = {
						government_has_flag = government_is_nomadic
					}
					add = medium_herd_value_static
				}
			}
		}
	}
	
	ai_will_do = {
		base = 0
	}
	ai_potential = {
        always = no
	}
}
