#######################################################
#
# Events that trigger for characters when they die
#
#######################################################
# Written by Johan Andersson

#Death of a loved wife...
character_event = {
	id = 24500
	desc = EVTDESC24500
	picture = GFX_evt_death

	only_women = yes
	is_married = yes

	is_triggered_only = yes

	trigger = {
		immortal = no
		spouse = {
			is_alive = yes
			is_abroad_trigger = no
			is_ruler = yes
			opinion = { who = ROOT value = 50 }
			OR = {
				trait = kind
				trait = charitable
			}
			NOR = {
				is_kinslayer_trigger = yes
				trait = celibate
				trait = depressed
				trait = eunuch
			}
		}
	}

	option = {
		name = EVTOPTA24500
		spouse = { character_event = { id = 24501 days = 64 tooltip = EVTTOOLTIP24501 } }
	}
}

# and what happens...
character_event = {
	id = 24501
	desc = EVTDESC24501
	picture = GFX_evt_death

	is_triggered_only = yes
	trigger = {
		spouse_even_if_dead = {
			is_alive = no
			is_female = yes
		}
	}

	option = {
		name = EVTOPTA24501
		random_list = {
			90 = {
				add_trait = lustful
				hidden_tooltip = { character_event = { id = 38272 } } #notify lustful
			}
			10 = {
				add_trait = incapable
				# regency will be enough notification.
			}
		}
	}

	option = {
		name = EVTOPTB24501
		add_trait = depressed
		if = {
			limit = {
				religion_group = christian
			}
			add_trait = celibate
		}
	}
}


#Death of a good son
character_event = {
	id = 24502
	desc = EVTDESC24502
	picture = GFX_evt_death

	is_triggered_only = yes

	only_men = yes
	min_age = 15

	trigger = {
		is_primary_heir = yes
		martial = 8
		stewardship = 8

		father = {
			is_alive = yes
			is_ruler = yes
			NOT = { trait = stressed }
		}
		any_sibling = {
			is_adult = yes
			is_female = no
			is_alive = yes
			NOT = { martial = 8 }
		}
	}

	option = {
		name = EVTOPTA24502
		father = { character_event = { id = 24503 days = 128 tooltip = EVTTOOLTIP24503 } }
	}
}

# and what happens first...
character_event = {
	id = 24503
	desc = EVTDESC24503
	picture = GFX_evt_death

	is_triggered_only = yes

	option = {
		name = EVTOPTA24503
		trigger = {
			is_married = yes
			spouse = {
				NOT = { age = 30 }
				is_pregnant = no
			}
		}
		character_event = { id = 24504 days = 2 tooltip = EVTTOOLTIP24504 }
	}

	option = {
		name = EVTOPTB24503
		random_child = {
			limit = {
				is_adult = yes
				is_female = no
				is_alive = yes
				NOT = { martial = 8 }
			}
			random_list = {
				90 = {
					if = {
						limit = { NOT = { trait = berserker } }
						add_trait = craven
						hidden_tooltip = { character_event = { id = 38257} } # notify craven
					}
				}
				10 = {
					add_trait = brave
					hidden_tooltip = { character_event = { id = 38270} } # notify brave
				}
			}
		}
	}
}

#and the final part...
character_event = {
	id = 24504
	desc = EVTDESC24504
	picture = GFX_evt_death

	is_triggered_only = yes

	option = {
		name = EVTOPTA24504
		spouse = {
			impregnate_cuckoo = PREV
			if = {
				limit = {
					NOT = { trait = depressed }
				}
				add_trait = stressed
			}
		}
	}
}

#Suspicious death: Start
character_event = {
	id = 24505
	desc = EVTDESC24505
	picture = GFX_evt_death

	is_triggered_only = yes

	trigger = {
		death_murder_unknown_trigger = yes
		NOT = { has_character_flag = was_murdered_by_plot }
		OR = {
			AND = {
				age = 15
				NOT = {
					age = 35
				}
				any_courtier = {
					is_abroad_trigger = no
					in_command_trigger = no
					prisoner = no
					age = 14
					NOT = { trait = incapable }
					NOT = { character = ROOT }
					opinion = { who = ROOT value = 50 }
					NOT = {
						is_liege_of = ROOT
					}
				}
				NOT = {
					has_character_flag = murdered_by_guardian
				}
			}
			has_character_flag = murdered_by_guardian
		}
	}

	weight_multiplier = {
		days = 1
	}

	option = {
		name = EVTOPTA24505
		trigger = {
			NOT = {
				has_character_flag = murdered_by_guardian
			}
		}
		random_courtier = {
			limit = {
				is_abroad_trigger = no
				in_command_trigger = no
				prisoner = no
				age = 14
				NOT = { trait = incapable }
				NOT = { character = ROOT }
				NOT = {
					is_liege_of = ROOT
				}
				opinion = { who = ROOT value = 50 }
			}
			character_event = {
				id = 24506
				tooltip = EVTTOOLTIP24506
			}
		}
	}

	option = {
		name = EVTOPTA24505
		trigger = {
			has_character_flag = murdered_by_guardian
		}
		if = {
			limit = {
				father = {
					is_alive = yes
				}
			}
			father = {
				set_character_flag = guardian_murdered_child
				character_event = {
					id = 24506
					tooltip = EVTTOOLTIP24506
				}
			}
		}
		if = {
			limit = {
				mother = {
					is_alive = yes
				}
				father_even_if_dead = {
					is_alive = no
				}
			}
			mother = {
				set_character_flag = guardian_murdered_child
				character_event = {
					id = 24506
					tooltip = EVTTOOLTIP24506
				}
			}
		}
		clr_character_flag = murdered_by_guardian
	}
}

#Suspicious death: Courtier
character_event = {
	id = 24506
	desc = EVTDESC24506
	picture = GFX_evt_death

	is_triggered_only = yes

	option = {
		name = EVTOPTA24506 #Keep my grudge
		trigger = {
			NOT = {
				has_character_flag = guardian_murdered_child
			}
		}
		random_courtier = {
			limit = {
				intrigue = 8
				NOT = { character = ROOT }
				NOT = { character = FROM }
				prisoner = no
				age = 16
				NOT = { trait = incapable }
			}
			reverse_opinion = {
				modifier = suspect_of_murder
				who = ROOT
				years = 10
			}
		}
		any_courtier = {
			limit = {
				has_character_flag = murder_suspect
			}
			clr_character_flag = murder_suspect
		}
	}

	option = {
		name = EVTOPTB24506
		trigger = {
			is_ruler = yes
			NOT = {
				has_character_flag = guardian_murdered_child
			}
		}
		random_courtier = {
			limit = {
				intrigue = 8
				NOT = { character = ROOT }
				NOT = { character = FROM }
				prisoner = no
				age = 16
				NOT = { trait = incapable }
			}
			opinion = {
				who = ROOT
				modifier = opinion_arrest_attempt
				months = 240
			}
			imprison = ROOT
		}
		any_courtier = {
			limit = {
				has_character_flag = murder_suspect
			}
			clr_character_flag = murder_suspect
		}
	}
	option = {
		name = EVTOPTC24506
		trigger = {
			is_ruler = no
			NOT = {
				has_character_flag = guardian_murdered_child
			}
		}
		random_courtier = {
			limit = {
				intrigue = 8
				NOT = { character = ROOT }
				NOT = { character = FROM }
				prisoner = no
				age = 16
				NOT = { trait = incapable }
			}
			opinion = {
				who = ROOT
				modifier = opinion_arrest_attempt
				months = 240
			}
			imprison = ROOT
			set_character_flag = murder_suspect
		}
		liege = {
			character_event = {
				id = 24507
				tooltip = EVTTOOLTIP24507
			}
		}
	}
	option = {
		name = EVTOPTA24506 #Keep my grudge
		trigger = {
			has_character_flag = guardian_murdered_child
		}
		FROM = {
			any_courtier = {
				limit = {
					has_character_flag = murdered_fosterling
				}
				reverse_opinion = {
					modifier = suspect_of_murder
					who = ROOT
					years = 10
				}
			}
		}
	}

	option = {
		name = EVTOPTB24506
		trigger = {
			is_ruler = yes
			has_character_flag = guardian_murdered_child
		}
		FROM = {
			any_courtier = {
				limit = {
					has_character_flag = murdered_fosterling
				}
				reverse_opinion = {
					modifier = suspect_of_murder
					who = ROOT
					years = 10
				}
			}
		}
	}
	option = {
		name = EVTOPTC24506
		trigger = {
			is_ruler = no
			has_character_flag = guardian_murdered_child
		}
		FROM = {
			any_courtier = {
				limit = {
					has_character_flag = murdered_fosterling
				}
				reverse_opinion = {
					modifier = suspect_of_murder
					who = ROOT
					years = 10
				}
				set_character_flag = murder_suspect
			}
		}
		liege = {
			character_event = {
				id = 24507
				tooltip = EVTTOOLTIP24507
			}
		}
	}
}

#Suspicious death: Liege
character_event = {
	id = 24507
	desc = EVTDESC24507
	picture = GFX_evt_death

	is_triggered_only = yes

	option = {
		name = EVTOPTA24507 #Ignore
		random_courtier = {
			limit = {
				has_character_flag = murder_suspect
			}
			clr_character_flag = murder_suspect
		}
		any_courtier = {
			limit = {
				has_character_flag = murder_suspect
			}
			clr_character_flag = murder_suspect
		}
		FROM = {
			opinion = {
				modifier = opinion_betrayed
				who = ROOT
				years = 10
			}
		}
	}
	option = {
		name = EVTOPTB24507 #Imprison
		random_courtier = {
			limit = {
				has_character_flag = murder_suspect
			}
			opinion = {
				who = ROOT
				modifier = opinion_arrest_attempt
				months = 240
			}
			imprison = ROOT

			clr_character_flag = murder_suspect
		}
		any_courtier = {
			limit = {
				has_character_flag = murder_suspect
			}
			clr_character_flag = murder_suspect
		}
		FROM = {
			opinion = {
				modifier = opinion_satisfied
				who = ROOT
				years = 5
			}
		}
	}
}

#Death of a Councillor
character_event = {
	id = 24510
	desc = EVTDESC24510
	picture = GFX_evt_death

	is_triggered_only = yes

	trigger = {
		is_councillor = yes
		independent = no
		NOT = {
			age = 50
		}
		OR = {
			diplomacy = 15
			martial = 15
			intrigue = 15
			learning = 15
			stewardship = 15
		}
		liege = {
			NOT = {
				character = ROOT
			}
			OR = {
				tier = duke
				tier = count
			}
			NOT = {
				spouse = {
					character = ROOT
				}
			}
			NOT = { is_inaccessible_trigger = yes }
		}
	}

	weight_multiplier = {
		days = 1
	}

	option = {
		name = EVTOPTA24510
		liege = {
			character_event = {
				id = 4140
				tooltip = EVTTOOLTIP4140
			}
		}
	}
}

#Funeral Procession
character_event = {
	id = 4140
	desc = EVTDESC4140
	picture = GFX_evt_death
	
	is_triggered_only = yes
	
	trigger ={
		FROM = {
			NOR = {
				death_no_trace_trigger = yes
				death_in_china_trigger = yes
			}
		}
	}

	option = {
		name = EVTOPTA4140
		trigger = {
			religion_group = christian
		}
		add_character_modifier = {
			name = the_sincere
			years = 5
		}
	}
	option = {
		name = EVTOPTD4140
		trigger = {
			religion_group = muslim
		}
		add_character_modifier = {
			name = the_sincere
			years = 5
		}
	}
	option = {
		name = EVTOPTE4140
		trigger = {
			NOR = {
				religion_group = muslim
				religion_group = christian
			}
		}
		add_character_modifier = {
			name = the_sincere
			years = 5
		}
	}
	
	option = {
		name = EVTOPTB4140
		add_character_modifier = {
			name = the_cynical
			years = 5
		}
	}
	
	option = {
		name = EVTOPTC4140
		trigger = {
			FROM = {
				spouse = {
					is_alive = yes
				}
			}
			wealth = -10
		}
		FROM = {
			spouse = {
				opinion = {
					modifier = charitable_pos
					who = ROOT
					years = 10
				}
			}
		}
	}
}