﻿on_death = {
	on_actions = {
		non_dynastic_inheritance_on_action
	}
}

non_dynastic_inheritance_on_action = {
	trigger = {
		has_game_rule = non_dynastic_inheritance_enabled
	}

	effect = {
		if = {
			limit = {
				is_ai = no
				primary_heir = { NOT = { dynasty = root.dynasty } }
			}
				
			play_music_cue = "mx_cue_death"
			
			root = {
				primary_heir = { save_scope_as = ndi_heir }
				set_designated_heir = scope:ndi_heir
			}
		}
	}
}