﻿add_death_event_blocker_effect = {
	if = {
		limit = {
			is_alive = yes
		}
		set_variable = {
			name = block_death_event_from
			value = $DEAD$
			days = 3
		}
	}
	#If we get timed variables in list:
#	add_to_variable_list = {
#		name = block_death_event_from
#		target = $DEAD$
#		days = 3
#	}
}

silent_disappearance_effect = {
	hidden_effect = {
		if = {
			limit = { is_alive = yes }

			#if = { #Unop In case we want to investigate more
			#	limit = { unop_can_disappear_trigger = no }
			#	error_log_stack_trace = "Character disappearing who should not"
			#	error_log_scopes = yes
			#}
			death = {
		 		death_reason = death_disappearance
		 	}
		}
	}
}

silent_disappearance_ai_effect = {
	hidden_effect = {
		if = {
			limit = {
				is_alive = yes
				root = { is_ai = yes }
			}

			#if = { #Unop In case we want to investigate more
			#	limit = { unop_can_disappear_trigger = no }
			#	error_log_stack_trace = "Character disappearing who should not"
			#	error_log_scopes = yes
			#}
			death = {
		 		death_reason = death_disappearance
		 	}
		}
	}
}

silent_disappearance_ai_if_created_effect = {
	hidden_effect = {
		if = {
			limit = {
				is_alive = yes
				root = { is_ai = yes }
				has_character_flag = created
			}

			#if = { #Unop In case we want to investigate more
			#	limit = { unop_can_disappear_trigger = no }
			#	error_log_stack_trace = "Character disappearing who should not"
			#	error_log_scopes = yes
			#}
			death = {
		 		death_reason = death_disappearance
		 	}
		}
	}
}

silent_disappear_ai_if_not_hired = {
	hidden_effect = {
		if = {
			limit = {
				is_alive = yes
				root = { is_ai = yes }
				employer != root
			}

			#if = { #Unop In case we want to investigate more
			#	limit = { unop_can_disappear_trigger = no }
			#	error_log_stack_trace = "Character disappearing who should not"
			#	error_log_scopes = yes
			#}
			death = {
		 		death_reason = death_disappearance
		 	}
		}
		else_if = {
			limit = {
				is_alive = yes
				employer != root
			}
			move_to_pool = yes
		}
	}
}

silent_disappear_ai_if_not_hired_with_flag = {
	hidden_effect = {
		if = {
			limit = {
				is_alive = yes
				root = { is_ai = yes }
				employer != root
				has_character_flag = created
			}

			#if = { #Unop In case we want to investigate more
			#	limit = { unop_can_disappear_trigger = no }
			#	error_log_stack_trace = "Character disappearing who should not"
			#	error_log_scopes = yes
			#}
			death = {
		 		death_reason = death_disappearance
		 	}
		}
		else_if = {
			limit = {
				is_alive = yes
				employer != root
				has_character_flag = created
			}
			move_to_pool = yes
		}
	}
}

save_died_in_battle_variables_effect = {
	set_variable = {
		name = battle_death_enemy
		value = $ENEMY$
	}
	set_variable = {
		name = battle_death_leader
		value = $LEADER$
	}
	set_variable = {
		name = battle_death_location
		value = $LOCATION$
	}
}
