namespace = NE

# Notification event for invited character
character_event = {
	id = NE.1
	picture = GFX_evt_emissary

	is_triggered_only = yes

	desc = {
		text = EVTDESC_NE_1_debutant
		trigger = { event_target:invited_character = { has_character_flag = debutante } }
	}
	desc = {
		text = EVTDESC_NE_1 #Not debutantes
		trigger = { event_target:invited_character = { NOT = { has_character_flag = debutante } } }
	}

	
	option = {
		name = EVTOPTA_NE_1
		
		trigger = {
			OR = { 
				NOT = { ROOT = { has_law = succ_byzantine_elective } }  #Either not Imperial...
				NOT = { #...Or there are no valid vassal candidates that can be commanders.
					any_vassal = { 
						higher_real_tier_than = BARON
						NOT = { 
							primary_title = { temporary = yes } 
						}
						OR = {
							AND = {
								OR = {
									male_can_hold_minor_title_trigger = yes
									female_can_hold_minor_commander_title_trigger = yes
								}
								OR = {
									NOT = { religion = hindu }
									trait = kshatriya
								}
								is_adult = yes
							}
							has_character_flag = special_marshal
						}
				
						prisoner = no
						NOT = { trait = incapable }
						NOT = { is_inaccessible_trigger = yes }
						NOT = { has_character_flag = guru }
						NOT = { has_character_modifier = refusing_to_lead }
						NOR = {
							has_job_title = job_chancellor
							has_job_title = job_marshal
							has_job_title = job_treasurer
							has_job_title = job_spymaster
							has_job_title = job_spiritual
							has_minor_title = title_commander
						}
					} 
				}
			}
			event_target:invited_character = { has_character_flag = invited_soldier }
			OR = {
				AND = {
					tier = COUNT
					NOT = {
						any_realm_character = {
							count = 2
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = DUKE
					NOT = {
						any_realm_character = {
							count = 4
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = KING
					is_nomadic = no
					NOT = {
						any_realm_character = {
							count = 6
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = EMPEROR
					is_nomadic = no
					NOT = {
						any_realm_character = {
							count = 8
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = KING
					is_nomadic = yes
					NOT = {
						any_realm_character = {
							count = 2
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = EMPEROR
					is_nomadic = yes
					NOT = {
						any_realm_character = {
							count = 4
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
			}
		}
		
		event_target:invited_character = {
			give_minor_title = title_commander
		}
	}
	
	option = {
		name = EXCELLENT
	}
	
	option = {
		name = EVTOPTB_NE_1
		
		hidden_tooltip = {
			event_target:invited_character = { 
				any_artifact = { destroy_artifact = yes }
				death = {
					death_reason = death_missing
				}
			}
		}
	}
}