# Called from a CB's on_accept where FROM = the losing country.
# Shows the might/will Khan death warning and rolls death (guaranteed at 3+ losses).

if = {
	limit = {
		from = {
			has_country_flag = heir_of_the_khan_khan
			ruler = { has_trait = leader_trait_ruler_great_khan }
		}
	}
	if = {
		limit = {
			from = { check_variable = { which = khan_war_losses value >= 2 } }
		}
		custom_tooltip = will_kill_khan_tt
	}
	else = {
		custom_tooltip = might_kill_khan_tt
	}
	hidden_effect = {
		from = {
			if = {
				limit = { NOT = { is_variable_set = khan_war_losses } }
				set_variable = { which = khan_war_losses value = 0 }
			}
			change_variable = { which = khan_war_losses value = 1 }
			if = {
				limit = { check_variable = { which = khan_war_losses value >= 3 } }
				ruler = { kill_leader = {} }
			}
			else = {
				random_list = {
					25 = { ruler = { kill_leader = {} } }
					75 = {}
				}
			}
		}
	}
}
