############################
#
# Leader Events
#
# Written by Henrik Eklund
#
############################

namespace = leader

# New Admiral
country_event = {
	id = leader.1
	title = "leader.1.name"
	desc = "leader.1.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	is_triggered_only = yes
	
	trigger = {
		is_country_type = default
		free_leader_slots > 0
	}
	
	immediate = {
		FROMFROM = {
			solar_system = { save_event_target_as = system }
		}
		random_owned_ship = { 
			limit = {
				fleet = { is_same_value = FROMFROM }
			}
			save_event_target_as = ship
		}
		random_list = {
			25 = {
				create_leader = {
					type = admiral
					species = owner_main_species
					name = random
					skill = 201
					traits = {
						trait = leader_trait_gale_speed
						trait = leader_trait_aggressive
					}
				}
				last_created_leader = { save_event_target_as = officer }
			}
			25 = {
				create_leader = {
					type = admiral
					species = owner_main_species
					name = random
					skill = 301
					traits = {
						trait = leader_trait_aggressive
						trait = leader_trait_engineer
					}
				}
				last_created_leader = { save_event_target_as = officer }
			}
			25 = {
				create_leader = {
					type = admiral
					species = owner_main_species
					name = random
					skill = 401
					traits = {
						trait = leader_trait_fleet_logistician
						trait = leader_trait_cautious
					}
				}
				last_created_leader = { save_event_target_as = officer }
			}
			25 = {
				create_leader = {
					type = admiral
					species = owner_main_species
					name = random
					skill = 250
					traits = {
						trait = leader_trait_scout
						trait = leader_trait_trickster
					}
				}
				last_created_leader = { save_event_target_as = officer }
			}
		}
	}
	
	option = {
		name = GOOD
		custom_tooltip = new_admiral
	}
}

### ADMIRAL TRAITS

# Trickster gained from Victory
country_event = {
	id = leader.5
	title = "admiral_trait_gain"
	desc = "leader.5.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	is_triggered_only = yes
	
	trigger = {
		is_country_type = default
		FROMFROM = {
			exists = leader
			leader = {
				leader_class = admiral
				num_traits < 3
				NOT = { 
					has_trait = leader_trait_trickster 
					has_trait = leader_trait_unyielding
				}
			}
		}
	}
	
	immediate = {
		FROMFROM = {
			leader = { save_event_target_as = officer }
			solar_system = { save_event_target_as = system }
		}
	}
	
	option = {
		name = GOOD
		FROMFROM = {
			leader = { add_trait = leader_trait_trickster }
		}		
	}
}

# Aggressive gained from Victory
country_event = {
	id = leader.6
	title = "admiral_trait_gain"
	desc = "leader.6.desc"
	picture = GFX_evt_federation_fleet
	location = FROMFROM
	
	is_triggered_only = yes
	
	trigger = {
		is_country_type = default
		FROMFROM = {
			exists = leader
			leader = {
				leader_class = admiral
				num_traits < 3
				NOT = { 
					has_trait = leader_trait_cautious 
					has_trait = leader_trait_aggressive
				}
			}
		}
	}
	
	immediate = {
		FROMFROM = {
			leader = { save_event_target_as = officer }
			solar_system = { save_event_target_as = system }
		}
	}
	
	option = {
		name = GOOD
		FROMFROM = {
			leader = { add_trait = leader_trait_aggressive }
		}		
	}
}

# Unyielding gained from Victory
country_event = {
	id = leader.7
	title = "admiral_trait_gain"
	desc = "leader.7.desc"
	picture = GFX_evt_federation_fleet
	location = FROMFROM
	
	is_triggered_only = yes
	
	trigger = {
		is_country_type = default
		FROMFROM = {
			exists = leader
			leader = {
				leader_class = admiral
				num_traits < 3
				NOT = { 
					has_trait = leader_trait_trickster
					has_trait = leader_trait_unyielding
				}
			}
		}
	}
	
	immediate = {
		FROMFROM = {
			leader = { save_event_target_as = officer }
			solar_system = { save_event_target_as = system }
		}
	}
	
	option = {
		name = GOOD
		FROMFROM = {
			leader = { add_trait = leader_trait_unyielding }
		}		
	}
}

# Gale Speed gained from Victory
country_event = {
	id = leader.8
	title = "admiral_trait_gain"
	desc = "leader.8.desc"
	picture = GFX_evt_federation_fleet
	location = FROMFROM
	
	is_triggered_only = yes
	
	trigger = {
		is_country_type = default
		FROMFROM = {
			exists = leader
			leader = {
				leader_class = admiral
				num_traits < 3
				NOT = { 
					has_trait = leader_trait_lethargic
					has_trait = leader_trait_gale_speed
				}
			}
		}
	}
	
	immediate = {
		FROMFROM = {
			leader = { save_event_target_as = officer }
			solar_system = { save_event_target_as = system }
		}
	}
	
	option = {
		name = GOOD
		FROMFROM = {
			leader = { add_trait = leader_trait_gale_speed }
		}		
	}
}

# Lethargic lost from Victory
country_event = {
	id = leader.9
	title = "admiral_trait_loss"
	desc = "leader.9.desc"
	picture = GFX_evt_federation_fleet
	location = FROMFROM
	
	is_triggered_only = yes
	
	trigger = {
		is_country_type = default
		FROMFROM = {
			exists = leader
			leader = { has_trait = leader_trait_lethargic }
		}
	}
	
	immediate = {
		FROMFROM = {
			leader = { save_event_target_as = officer }
			solar_system = { save_event_target_as = system }
		}
	}
	
	option = {
		name = GOOD
		FROMFROM = {
			leader = { remove_trait = leader_trait_lethargic }
		}		
	}
}

# Cautious gained from Defeat
fleet_event = {
	id = leader.10
	title = "admiral_trait_gain"
	desc = "leader.10.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	is_triggered_only = yes
	
	trigger = {
		owner = { is_country_type = default }
		exists = leader
		leader = {
			leader_class = admiral
			num_traits < 3
			NOT = { 
				has_trait = leader_trait_cautious 
				has_trait = leader_trait_aggressive
			}
		}
	}
	
	immediate = {
		leader = { save_event_target_as = officer }
		solar_system = { save_event_target_as = system }
	}
	
	option = {
		name = GOOD
		leader = { add_trait = leader_trait_cautious }	
	}
}

# Nervous gained from Defeat
#fleet_event = {
#	id = leader.11
#	title = "admiral_trait_gain"
#	desc = "leader.11.desc"
#	picture = GFX_evt_federation_fleet
#	location = ROOT
#	
#	is_triggered_only = yes
#	
#	trigger = {
#		owner = { is_country_type = default }
#		exists = leader
#		owner = { has_technology = tech_doctrine_fleet_size_2 }
#		leader = {
#			num_traits < 3
#			NOT = { 
#				has_trait = leader_trait_fleet_organizer
#				has_trait = leader_trait_unyielding
#				has_trait = leader_trait_nervous
#			}
#		}
#	}
#	
#	immediate = {
#		leader = { save_event_target_as = officer }
#		solar_system = { save_event_target_as = system }
#	}
#	
#	option = {
#		name = GOOD
#		leader = { add_trait = leader_trait_nervous }	
#	}
#}

# Unyielding gained from Defeat
fleet_event = {
	id = leader.12
	title = "admiral_trait_gain"
	desc = "leader.12.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	is_triggered_only = yes
	
	trigger = {
		owner = { is_country_type = default }
		exists = leader
		leader = {
			leader_class = admiral
			num_traits < 3
			NOT = { 
				has_trait = leader_trait_nervous
				has_trait = leader_trait_unyielding
			}
		}
	}
	
	immediate = {
		leader = { save_event_target_as = officer }
		solar_system = { save_event_target_as = system }
	}
	
	option = {
		name = GOOD
		leader = { add_trait = leader_trait_unyielding }	
	}
}

# Gale Speed gained from Defeat
fleet_event = {
	id = leader.13
	title = "admiral_trait_gain"
	desc = "leader.13.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	is_triggered_only = yes
	
	trigger = {
		owner = { is_country_type = default }
		exists = leader
		leader = {
			leader_class = admiral
			num_traits < 3
			NOT = { 
				has_trait = leader_trait_lethargic
				has_trait = leader_trait_gale_speed
			}
		}
	}
	
	immediate = {
		leader = { save_event_target_as = officer }
		solar_system = { save_event_target_as = system }
	}
	
	option = {
		name = GOOD
		leader = { add_trait = leader_trait_gale_speed }	
	}
}

# Lethargic gained from Defeat
fleet_event = {
	id = leader.14
	title = "admiral_trait_gain"
	desc = "leader.14.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	is_triggered_only = yes
	
	trigger = {
		owner = { is_country_type = default }
		exists = leader
		leader = {
			leader_class = admiral
			num_traits < 3
			NOT = { 
				has_trait = leader_trait_gale_speed
				has_trait = leader_trait_lethargic
			}
		}
	}
	
	immediate = {
		leader = { save_event_target_as = officer }
		solar_system = { save_event_target_as = system }
	}
	
	option = {
		name = UNFORTUNATE
		leader = { add_trait = leader_trait_lethargic }	
	}
}

# Engineer gained from Repairing
fleet_event = {
	id = leader.15
	title = "admiral_trait_gain"
	desc = "leader.15.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	trigger = {
		owner = { is_country_type = default }
		is_being_repaired = yes
		exists = leader
		leader = {
			leader_class = admiral
			num_traits < 3
			NOT = { has_trait = leader_trait_engineer }
		}
		owner = { has_technology = tech_doctrine_fleet_size_3 }
	}
	
	mean_time_to_happen = {
		months = 240
	}
	
	immediate = {
		leader = { save_event_target_as = officer }
	}
	
	option = {
		name = GOOD
		leader = { add_trait = leader_trait_engineer }	
	}
}

# Organizer gained from Large Fleet
#fleet_event = {
#	id = leader.16
#	title = "admiral_trait_gain"
#	desc = "leader.16.desc"
#	picture = GFX_evt_federation_fleet
#	location = ROOT
#	
#	trigger = {
#		owner = { is_country_type = default }
#		exists = leader
#		num_ships > 1
#		leader = {
#			num_traits < 3
#			NOT = { 
#				has_trait = leader_trait_fleet_organizer 
#				has_trait = leader_trait_nervous
#			}
#		}
#		owner = { has_technology = tech_doctrine_fleet_size_3 }
#	}
#	
#	mean_time_to_happen = {
#		months = 240
#	}
#	
#	immediate = {
#		leader = { save_event_target_as = officer }
#	}
#	
#	option = {
#		name = GOOD
#		leader = { add_trait = leader_trait_fleet_organizer  }	
#	}
#}

# Nervous lost from Victory
#country_event = {
#	id = leader.17
#	title = "admiral_trait_loss"
#	desc = "leader.17.desc"
#	picture = GFX_evt_federation_fleet
#	location = FROMFROM
#	
#	is_triggered_only = yes
#	
#	trigger = {
#		is_country_type = default
#		FROMFROM = {
#			exists = leader
#			leader = { has_trait = leader_trait_nervous }
#		}
#	}
#	
#	immediate = {
#		FROMFROM = {
#			leader = { save_event_target_as = officer }
#			solar_system = { save_event_target_as = system }
#		}
#	}
#	
#	option = {
#		name = GOOD
#		FROMFROM = {
#			leader = { remove_trait = leader_trait_nervous }
#		}		
#	}
#}

# Logistics gained from Large Fleet
fleet_event = {
	id = leader.18
	title = "admiral_trait_gain"
	desc = "leader.18.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	trigger = {
		owner = { is_country_type = default }
		exists = leader
		num_ships > 1
		leader = {
			leader_class = admiral
			num_traits < 3
			NOT = { has_trait = leader_trait_fleet_logistician }
		}
	}
	
	mean_time_to_happen = {
		months = 240
	}
	
	immediate = {
		leader = { save_event_target_as = officer }
	}
	
	option = {
		name = GOOD
		leader = { add_trait = leader_trait_fleet_logistician  }	
	}
}

# Scout gained from Exploration
ship_event = {
	id = leader.19
	title = "admiral_trait_gain"
	desc = "leader.19.desc"
	picture = GFX_evt_federation_fleet
	location = ROOT
	
	is_triggered_only = yes
	
	trigger = {
		owner = { is_country_type = default }
		fleet = {
			exists = leader
			num_ships > 1
			leader = {
				leader_class = admiral
				num_traits < 3
				NOT = { has_trait = leader_trait_scout }
			}
		}
	}
	
	immediate = {
		fleet = {
			leader = { save_event_target_as = officer }
			solar_system = { save_event_target_as = system }
		}
	}
	
	option = {
		name = GOOD
		fleet = {
			leader = { add_trait = leader_trait_scout  }
		}
	}
}


#### LEADER LEVEL UP EVENTS ####

#Gatekeeper fired from on_action on_leader_level_up
country_event = {
	id = leader.20
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		from = {
			if = {
				limit = {
					leader_class = scientist
					NOT = {
						has_leader_flag = has_gained_level_trait
						is_researching_area = society
						is_researching_area = engineering
						is_researching_area = physics
					}
				}
				random_list = {
					93 = { }
					7 = {
						modifier = {
							factor = 1.5
							OR = {
								has_level = 3
								has_level = 4
							}
						}
						modifier = {
							factor = 5
							has_level = 5
						}
						random_list = {
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_adaptable }
									}
									add_trait = leader_trait_adaptable
									set_leader_flag = gained_leader_trait_adaptable
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_resilient }
									}
									add_trait = leader_trait_resilient
									set_leader_flag = gained_leader_trait_resilient
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_stubborn }
									}
									add_trait = leader_trait_stubborn
									set_leader_flag = gained_leader_trait_stubborn
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_substance_abuser }
									}
									add_trait = leader_trait_substance_abuser
									set_leader_flag = gained_leader_trait_substance_abuser
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_arrested_development }
									}
									add_trait = leader_trait_arrested_development
									set_leader_flag = gained_leader_trait_arrested_development
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_meticulous }
									}
									add_trait = leader_trait_meticulous
									set_leader_flag = gained_leader_trait_meticulous
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_careful }
									}
									add_trait = leader_trait_careful
									set_leader_flag = gained_leader_trait_careful
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_spark_of_genius }
									}
									add_trait = leader_trait_spark_of_genius
									set_leader_flag = gained_leader_trait_spark_of_genius
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_carefree }
									}
									add_trait = leader_trait_carefree
									set_leader_flag = gained_leader_trait_carefree
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_roamer }
									}
									add_trait = leader_trait_roamer
									set_leader_flag = gained_leader_trait_roamer
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_archaeologist }
									}
									add_trait = leader_trait_archaeologist
									set_leader_flag = gained_leader_trait_archaeologist
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_maniacal }
									}
									add_trait = leader_trait_maniacal
									set_leader_flag = gained_leader_trait_maniacal
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_custom_AI_assistant }
									}
									add_trait = leader_trait_custom_AI_assistant
									set_leader_flag = gained_leader_trait_custom_AI_assistant
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_materials }
									}
									add_trait = leader_trait_expertise_materials
									set_leader_flag = gained_leader_trait_expertise_materials
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_rocketry }
									}
									add_trait = leader_trait_expertise_rocketry
									set_leader_flag = gained_leader_trait_expertise_rocketry
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_voidcraft }
									}
									add_trait = leader_trait_expertise_voidcraft
									set_leader_flag = gained_leader_trait_expertise_voidcraft
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_industry }
									}
									add_trait = leader_trait_expertise_industry
									set_leader_flag = gained_leader_trait_expertise_industry
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_field_manipulation }
									}
									add_trait = leader_trait_expertise_field_manipulation
									set_leader_flag = gained_leader_trait_expertise_field_manipulation
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_particles }
									}
									add_trait = leader_trait_expertise_particles
									set_leader_flag = gained_leader_trait_expertise_particles
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_computing }
									}
									add_trait = leader_trait_expertise_computing
									set_leader_flag = gained_leader_trait_expertise_computing
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_psionics }
									}
									add_trait = leader_trait_expertise_psionics
									set_leader_flag = gained_leader_trait_expertise_psionics
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_new_worlds }
									}
									add_trait = leader_trait_expertise_new_worlds
									set_leader_flag = gained_leader_trait_expertise_new_worlds
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_statecraft }
									}
									add_trait = leader_trait_expertise_statecraft
									set_leader_flag = gained_leader_trait_expertise_statecraft
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_biology }
									}
									add_trait = leader_trait_expertise_biology
									set_leader_flag = gained_leader_trait_expertise_biology
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_expertise_military_theory }
									}
									add_trait = leader_trait_expertise_military_theory
									set_leader_flag = gained_leader_trait_expertise_military_theory
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_paranoid }
									}
									add_trait = leader_trait_paranoid
									set_leader_flag = gained_leader_trait_paranoid
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.21} }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					leader_class = admiral
					NOT = { has_leader_flag = has_gained_level_trait }
				}
				random_list = {
					93 = { }
					7 = {
						modifier = {
							factor = 1.5
							OR = {
								has_level = 3
								has_level = 4
							}
						}
						modifier = {
							factor = 5
							has_level = 5
						}
						random_list = {
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_adaptable }
									}
									add_trait = leader_trait_adaptable
									set_leader_flag = gained_leader_trait_adaptable
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_resilient }
									}
									add_trait = leader_trait_resilient
									set_leader_flag = gained_leader_trait_resilient
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_stubborn }
									}
									add_trait = leader_trait_stubborn
									set_leader_flag = gained_leader_trait_stubborn
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_substance_abuser }
									}
									add_trait = leader_trait_substance_abuser
									set_leader_flag = gained_leader_trait_substance_abuser
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_arrested_development }
									}
									add_trait = leader_trait_arrested_development
									set_leader_flag = gained_leader_trait_arrested_development
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_trickster }
									}
									add_trait = leader_trait_trickster
									set_leader_flag = gained_leader_trait_trickster
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_fleet_logistician }
									}
									add_trait = leader_trait_fleet_logistician
									set_leader_flag = gained_leader_trait_fleet_logistician
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_engineer }
									}
									add_trait = leader_trait_engineer
									set_leader_flag = gained_leader_trait_engineer
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_aggressive }
									}
									add_trait = leader_trait_aggressive
									set_leader_flag = gained_leader_trait_aggressive
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_cautious }
									}
									add_trait = leader_trait_cautious
									set_leader_flag = gained_leader_trait_cautious
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_scout }
									}
									add_trait = leader_trait_scout
									set_leader_flag = gained_leader_trait_scout
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_unyielding }
									}
									add_trait = leader_trait_unyielding
									set_leader_flag = gained_leader_trait_unyielding
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_gale_speed }
									}
									add_trait = leader_trait_gale_speed
									set_leader_flag = gained_leader_trait_gale_speed
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_lethargic }
									}
									add_trait = leader_trait_lethargic
									set_leader_flag = gained_leader_trait_lethargic
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.22} }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					leader_class = governor
					NOT = { has_leader_flag = has_gained_level_trait }
				}
				random_list = {
					90 = { }
					10 = {
						modifier = {
							factor = 1.5
							OR = {
								has_level = 3
								has_level = 4
							}
						}
						modifier = {
							factor = 5
							has_level = 5
						}
						random_list = {
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_adaptable }
									}
									add_trait = leader_trait_adaptable
									set_leader_flag = gained_leader_trait_adaptable
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_resilient }
									}
									add_trait = leader_trait_resilient
									set_leader_flag = gained_leader_trait_resilient
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_stubborn }
									}
									add_trait = leader_trait_stubborn
									set_leader_flag = gained_leader_trait_stubborn
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_substance_abuser }
									}
									add_trait = leader_trait_substance_abuser
									set_leader_flag = gained_leader_trait_substance_abuser
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_arrested_development }
									}
									add_trait = leader_trait_arrested_development
									set_leader_flag = gained_leader_trait_arrested_development
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_iron_fist }
									}
									add_trait = leader_trait_iron_fist
									set_leader_flag = gained_leader_trait_iron_fist
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_architectural_interest }
									}
									add_trait = leader_trait_architectural_interest
									set_leader_flag = gained_leader_trait_architectural_interest
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_intellectual }
									}
									add_trait = leader_trait_intellectual
									set_leader_flag = gained_leader_trait_intellectual
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_environmental_engineer }
									}
									add_trait = leader_trait_environmental_engineer
									set_leader_flag = gained_leader_trait_environmental_engineer
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.23} }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					leader_class = general
					NOT = { has_leader_flag = has_gained_level_trait }
				}
				random_list = {
					90 = { }
					10 = {
						modifier = {
							factor = 1.5
							OR = {
								has_level = 3
								has_level = 4
							}
						}
						modifier = {
							factor = 5
							has_level = 5
						}
						random_list = {
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_adaptable }
									}
									add_trait = leader_trait_adaptable
									set_leader_flag = gained_leader_trait_adaptable
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_resilient }
									}
									add_trait = leader_trait_resilient
									set_leader_flag = gained_leader_trait_resilient
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_stubborn }
									}
									add_trait = leader_trait_stubborn
									set_leader_flag = gained_leader_trait_stubborn
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_substance_abuser }
									}
									add_trait = leader_trait_substance_abuser
									set_leader_flag = gained_leader_trait_substance_abuser
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_arrested_development }
									}
									add_trait = leader_trait_arrested_development
									set_leader_flag = gained_leader_trait_arrested_development
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_defender }
									}
									add_trait = leader_trait_defender
									set_leader_flag = gained_leader_trait_defender
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_attacker }
									}
									add_trait = leader_trait_attacker
									set_leader_flag = gained_leader_trait_attacker
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_charismatic }
									}
									add_trait = leader_trait_charismatic
									set_leader_flag = gained_leader_trait_charismatic
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_butcher }
									}
									add_trait = leader_trait_butcher
									set_leader_flag = gained_leader_trait_butcher
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_glory_seeker }
									}
									add_trait = leader_trait_glory_seeker
									set_leader_flag = gained_leader_trait_glory_seeker
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_armchair_commander }
									}
									add_trait = leader_trait_armchair_commander
									set_leader_flag = gained_leader_trait_armchair_commander
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_army_logistician }
									}
									add_trait = leader_trait_army_logistician
									set_leader_flag = gained_leader_trait_army_logistician
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.24} }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					leader_class = ruler
					NOT = { has_leader_flag = has_gained_level_trait }
				}
				random_list = {
					90 = { }
					10 = {
						modifier = {
							factor = 1.5
							OR = {
								has_level = 3
								has_level = 4
							}
						}
						modifier = {
							factor = 5
							has_level = 5
						}
						random_list = {
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_adaptable }
									}
									add_trait = leader_trait_adaptable
									set_leader_flag = gained_leader_trait_adaptable
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_resilient }
									}
									add_trait = leader_trait_resilient
									set_leader_flag = gained_leader_trait_resilient
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_stubborn }
									}
									add_trait = leader_trait_stubborn
									set_leader_flag = gained_leader_trait_stubborn
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_substance_abuser }
									}
									add_trait = leader_trait_substance_abuser
									set_leader_flag = gained_leader_trait_substance_abuser
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_arrested_development }
									}
									add_trait = leader_trait_arrested_development
									set_leader_flag = gained_leader_trait_arrested_development
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_corvette_focus }
									}
									add_trait = trait_ruler_corvette_focus
									set_leader_flag = gained_trait_ruler_corvette_focus
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_destroyer_focus }
									}
									add_trait = trait_ruler_destroyer_focus
									set_leader_flag = gained_trait_ruler_destroyer_focus
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_cruiser_focus }
									}
									add_trait = trait_ruler_cruiser_focus
									set_leader_flag = gained_trait_ruler_cruiser_focus
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_battleship_focus }
									}
									add_trait = trait_ruler_battleship_focus
									set_leader_flag = gained_trait_ruler_battleship_focus
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_recruiter }
									}
									add_trait = trait_ruler_recruiter
									set_leader_flag = gained_trait_ruler_recruiter
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_from_the_ranks }
									}
									add_trait = trait_ruler_from_the_ranks
									set_leader_flag = gained_trait_ruler_from_the_ranks
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_fortifier }
									}
									add_trait = trait_ruler_fortifier
									set_leader_flag = gained_trait_ruler_fortifier
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_logistic_understanding }
									}
									add_trait = trait_ruler_logistic_understanding
									set_leader_flag = gained_trait_ruler_logistic_understanding
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_military_pioneer }
									}
									add_trait = trait_ruler_military_pioneer
									set_leader_flag = gained_trait_ruler_military_pioneer
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_warlike }
									}
									add_trait = trait_ruler_warlike
									set_leader_flag = gained_trait_ruler_warlike
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_architectural_sense }
									}
									add_trait = trait_ruler_architectural_sense
									set_leader_flag = gained_trait_ruler_architectural_sense
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_frontier_spirit }
									}
									add_trait = trait_ruler_frontier_spirit
									set_leader_flag = gained_trait_ruler_frontier_spirit
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_world_shaper }
									}
									add_trait = trait_ruler_world_shaper
									set_leader_flag = gained_trait_ruler_world_shaper
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_home_in_the_sky }
									}
									add_trait = trait_ruler_home_in_the_sky
									set_leader_flag = gained_trait_ruler_home_in_the_sky
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_industrialist }
									}
									add_trait = trait_ruler_industrialist
									set_leader_flag = gained_trait_ruler_industrialist
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							100 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_eye_for_talent }
									}
									add_trait = trait_ruler_eye_for_talent
									set_leader_flag = gained_trait_ruler_eye_for_talent
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_deep_connections }
									}
									add_trait = trait_ruler_deep_connections
									set_leader_flag = gained_trait_ruler_deep_connections
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_champion_of_the_people }
									}
									add_trait = trait_ruler_champion_of_the_people
									set_leader_flag = gained_trait_ruler_champion_of_the_people
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_expansionist }
									}
									add_trait = trait_ruler_expansionist
									set_leader_flag = gained_trait_ruler_expansionist
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_fertility_preacher }
									}
									add_trait = trait_ruler_fertility_preacher
									set_leader_flag = gained_trait_ruler_fertility_preacher
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_investor }
									}
									add_trait = trait_ruler_investor
									set_leader_flag = gained_trait_ruler_investor
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = trait_ruler_explorer }
									}
									add_trait = trait_ruler_explorer
									set_leader_flag = gained_trait_ruler_explorer
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_fleet_organizer }
									}
									add_trait = leader_trait_fleet_organizer
									set_leader_flag = gained_leader_trait_fleet_organizer
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
							5 = {
								if = {
									limit = {
										NOT = { has_trait = leader_trait_nervous }
									}
									add_trait = leader_trait_nervous
									set_leader_flag = gained_leader_trait_nervous
									set_leader_flag = has_gained_level_trait
									owner = { country_event = { id = leader.25} }
								}
							}
						}
					}
				}
			}
		}
	}
}

#Scientist gains new trait
country_event = {
	id = leader.21
	title = leader.21.name
	desc = {
		trigger = {
			hidden:fromfrom = {
				switch = {
					trigger = has_leader_flag
					gained_leader_trait_adaptable = { text = leader.21.desc.adaptable }
					gained_leader_trait_resilient = { text = leader.21.desc.resilient }
					gained_leader_trait_stubborn = { text = leader.21.desc.stubborn }
					gained_leader_trait_substance_abuser = { text = leader.21.desc.substance_abuser }
					gained_leader_trait_arrested_development = { text = leader.21.desc.arrested_development }
					gained_leader_trait_meticulous = { text = leader.21.desc.meticulous }
					gained_leader_trait_careful = { text = leader.21.desc.careful }
					gained_leader_trait_spark_of_genius = { text = leader.21.desc.spark_of_genius }
					gained_leader_trait_carefree = { text = leader.21.desc.carefree }
					gained_leader_trait_roamer = { text = leader.21.desc.roamer }
					gained_leader_trait_archaeologist = { text = leader.21.desc.archaeologist }
					gained_leader_trait_maniacal = { text = leader.21.desc.maniacal }
					gained_leader_trait_custom_AI_assistant = { text = leader.21.desc.custom_AI_assistant }
					gained_leader_trait_expertise_materials = { text = leader.21.desc.expertise_materials }
					gained_leader_trait_expertise_rocketry = { text = leader.21.desc.expertise_rocketry }
					gained_leader_trait_expertise_voidcraft = { text = leader.21.desc.expertise_voidcraft }
					gained_leader_trait_expertise_industry = { text = leader.21.desc.expertise_industry }
					gained_leader_trait_expertise_field_manipulation = { text = leader.21.desc.expertise_field_manipulation }
					gained_leader_trait_expertise_particles = { text = leader.21.desc.expertise_particles }
					gained_leader_trait_expertise_computing = { text = leader.21.desc.expertise_computing }
					gained_leader_trait_expertise_psionics = { text = leader.21.desc.expertise_psionics }
					gained_leader_trait_expertise_new_worlds = { text = leader.21.desc.expertise_new_worlds }
					gained_leader_trait_expertise_statecraft = { text = leader.21.desc.expertise_statecraft }
					gained_leader_trait_expertise_biology = { text = leader.21.desc.expertise_biology }
					gained_leader_trait_expertise_military_theory = { text = leader.21.desc.expertise_military_theory }
					gained_leader_trait_paranoid = { text = leader.21.desc.paranoid }
					default = { text = "ERROR" }
				}
			}
		}
	}
	location = event_target:current_location
	picture = GFX_evt_archaeological_dig
	is_triggered_only = yes

	immediate = {
		fromfrom = {
			if = {
				limit = {
					exists = planet
				}
				planet = {
					save_event_target_as = current_location
				}
			}
			if = {
				limit = {
					exists = fleet
				}
				fleet = {
					random_owned_ship = {
						save_event_target_as = current_location
					}
				}
			}
		}
	}

	option = {
		name = leader.21.a.positive
		trigger = {
			fromfrom = {
				NOT = {
					has_leader_flag = gained_leader_trait_paranoid
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
	option = {
		name = leader.21.a.negative
		trigger = {
			fromfrom = {
				OR = {
					has_leader_flag = gained_leader_trait_paranoid
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
}

#Admiral gains new trait
country_event = {
	id = leader.22
	title = leader.22.name
	desc = {
		trigger = {
			hidden:fromfrom = {
				switch = {
					trigger = has_leader_flag
					gained_leader_trait_adaptable = { text = leader.22.desc.adaptable }
					gained_leader_trait_resilient = { text = leader.22.desc.resilient }
					gained_leader_trait_stubborn = { text = leader.22.desc.stubborn }
					gained_leader_trait_substance_abuser = { text = leader.22.desc.substance_abuser }
					gained_leader_trait_arrested_development = { text = leader.22.desc.arrested_development }
					gained_leader_trait_trickster = { text = leader.22.desc.trickster }
					gained_leader_trait_fleet_logistician = { text = leader.22.desc.fleet_logistician }
					gained_leader_trait_engineer = { text = leader.22.desc.engineer }
					gained_leader_trait_aggressive = { text = leader.22.desc.aggressive }
					gained_leader_trait_cautious = { text = leader.22.desc.cautious }
					gained_leader_trait_scout = { text = leader.22.desc.scout }
					gained_leader_trait_unyielding = { text = leader.22.desc.unyielding }
					gained_leader_trait_gale_speed = { text = leader.22.desc.gale_speed }
					gained_leader_trait_lethargic = { text = leader.22.desc.lethargic }
					default = { text = "ERROR" }
				}
			}
		}
	}
	location = event_target:current_location
	picture = GFX_evt_archaeological_dig
	is_triggered_only = yes

	immediate = {
		fromfrom = {
			if = {
				limit = {
					exists = planet
				}
				planet = {
					save_event_target_as = current_location
				}
			}
			if = {
				limit = {
					exists = fleet
				}
				fleet = {
					random_owned_ship = {
						save_event_target_as = current_location
					}
				}
			}
		}
	}

	option = {
		name = leader.21.a.positive
		trigger = {
			fromfrom = {
				NOT = {
					has_leader_flag = gained_leader_trait_lethargic
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
	option = {
		name = leader.21.a.negative
		trigger = {
			fromfrom = {
				OR = {
					has_leader_flag = gained_leader_trait_lethargic
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
}

#Governor gains new trait
country_event = {
	id = leader.23
	title = leader.23.name
	desc = {
		trigger = {
			hidden:fromfrom = {
				switch = {
					trigger = has_leader_flag
					gained_leader_trait_adaptable = { text = leader.23.desc.adaptable }
					gained_leader_trait_resilient = { text = leader.23.desc.resilient }
					gained_leader_trait_stubborn = { text = leader.23.desc.stubborn }
					gained_leader_trait_substance_abuser = { text = leader.23.desc.substance_abuser }
					gained_leader_trait_arrested_development = { text = leader.23.desc.arrested_development }
					gained_leader_trait_iron_fist = { text = leader.23.desc.iron_fist }
					gained_leader_trait_architectural_interest = { text = leader.23.desc.architectural_interest }
					gained_leader_trait_intellectual = { text = leader.23.desc.intellectual }
					gained_leader_trait_environmental_engineer = { text = leader.23.desc.environmental_engineer }
					default = { text = "ERROR" }
				}
			}
		}
	}
	location = event_target:current_planet
	picture = GFX_evt_archaeological_dig
	is_triggered_only = yes

	immediate = {
		fromfrom = {
			planet = {
				save_event_target_as = current_planet
			}
		}
	}

	option = {
		name = leader.21.a.positive
		trigger = {
			fromfrom = {
				NOT = {
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
	option = {
		name = leader.21.a.negative
		trigger = {
			fromfrom = {
				OR = {
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
}

#General gains new trait
country_event = {
	id = leader.24
	title = leader.24.name
	desc = {
		trigger = {
			hidden:fromfrom = {
				switch = {
					trigger = has_leader_flag
					gained_leader_trait_adaptable = { text = leader.24.desc.adaptable }
					gained_leader_trait_resilient = { text = leader.24.desc.resilient }
					gained_leader_trait_stubborn = { text = leader.24.desc.stubborn }
					gained_leader_trait_substance_abuser = { text = leader.24.desc.substance_abuser }
					gained_leader_trait_arrested_development = { text = leader.24.desc.arrested_development }
					gained_leader_trait_defender = { text = leader.24.desc.defender }
					gained_leader_trait_attacker = { text = leader.24.desc.attacker }
					gained_leader_trait_charismatic = { text = leader.24.desc.charismatic }
					gained_leader_trait_butcher = { text = leader.24.desc.butcher }
					gained_leader_trait_glory_seeker = { text = leader.24.desc.glory_seeker }
					gained_leader_trait_army_logistician = { text = leader.24.desc.army_logistician }
					gained_leader_trait_armchair_commander = { text = leader.24.desc.armchair_commander }
					default = { text = "ERROR" }
				}
			}
		}
	}
	location = event_target:current_location
	picture = GFX_evt_archaeological_dig
	is_triggered_only = yes

	immediate = {
		fromfrom = {
			if = {
				limit = {
					exists = planet
				}
				planet = {
					save_event_target_as = current_location
				}
			}
			if = {
				limit = {
					exists = fleet
				}
				fleet = {
					random_owned_ship = {
						save_event_target_as = current_location
					}
				}
			}
		}
	}

	option = {
		name = leader.21.a.positive
		trigger = {
			fromfrom = {
				NOT = {
					has_leader_flag = gained_leader_trait_armchair_commander
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
	option = {
		name = leader.21.a.negative
		trigger = {
			fromfrom = {
				OR = {
					has_leader_flag = gained_leader_trait_armchair_commander
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
}

#Ruler gains new trait
country_event = {
	id = leader.25
	title = leader.25.name
	desc = {
		trigger = {
			hidden:fromfrom = {
				switch = {
					trigger = has_leader_flag
					gained_leader_trait_adaptable = { text = leader.25.desc.adaptable }
					gained_leader_trait_resilient = { text = leader.25.desc.resilient }
					gained_leader_trait_stubborn = { text = leader.25.desc.stubborn }
					gained_leader_trait_substance_abuser = { text = leader.25.desc.substance_abuser }
					gained_leader_trait_arrested_development = { text = leader.25.desc.arrested_development }
					gained_trait_ruler_corvette_focus = { text = leader.25.desc.corvette_focus }
					gained_trait_ruler_destroyer_focus = { text = leader.25.desc.destroyer_focus }
					gained_trait_ruler_cruiser_focus = { text = leader.25.desc.cruiser_focus }
					gained_trait_ruler_battleship_focus = { text = leader.25.desc.battleship_focus }
					gained_trait_ruler_recruiter = { text = leader.25.desc.recruiter }
					gained_trait_ruler_from_the_ranks = { text = leader.25.desc.from_the_ranks }
					gained_trait_ruler_fortifier = { text = leader.25.desc.fortifier }
					gained_trait_ruler_logistic_understanding = { text = leader.25.desc.logistic_understanding }
					gained_trait_ruler_military_pioneer = { text = leader.25.desc.military_pioneer }
					gained_trait_ruler_warlike = { text = leader.25.desc.warlike }
					gained_trait_ruler_architectural_sense = { text = leader.25.desc.architectural_sense }
					gained_trait_ruler_frontier_spirit = { text = leader.25.desc.frontier_spirit }
					gained_trait_ruler_world_shaper = { text = leader.25.desc.world_shaper }
					gained_trait_ruler_home_in_the_sky = { text = leader.25.desc.home_in_the_sky }
					gained_trait_ruler_industrialist = { text = leader.25.desc.industrialist }
					gained_trait_ruler_eye_for_talent = { text = leader.25.desc.eye_for_talent }
					gained_trait_ruler_deep_connections = { text = leader.25.desc.deep_connections }
					gained_trait_ruler_charismatic = { text = leader.25.desc.charismatic }
					gained_trait_ruler_champion_of_the_people = { text = leader.25.desc.champion_of_the_people }
					gained_trait_ruler_expansionist = { text = leader.25.desc.expansionist }
					gained_trait_ruler_fertility_preacher = { text = leader.25.desc.fertility_preacher }
					gained_trait_ruler_investor = { text = leader.25.desc.investor }
					gained_trait_ruler_explorer = { text = leader.25.desc.explorer }
					gained_leader_trait_fleet_organizer = { text = leader.25.desc.fleet_organizer }
					gained_leader_trait_nervous = { text = leader.25.desc.nervous }
					default = { text = "ERROR" }
				}
			}
		}
	}
	location = event_target:current_planet
	picture = GFX_evt_archaeological_dig
	is_triggered_only = yes

	immediate = {
		fromfrom = {
			planet = {
				save_event_target_as = current_planet
			}
		}
	}

	option = {
		name = leader.21.a.positive
		trigger = {
			fromfrom = {
				NOT = {
					has_leader_flag = gained_leader_trait_nervous
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
	option = {
		name = leader.21.a.negative
		trigger = {
			fromfrom = {
				OR = {
					has_leader_flag = gained_leader_trait_nervous
					has_leader_flag = gained_leader_trait_stubborn
					has_leader_flag = gained_leader_trait_substance_abuser
					has_leader_flag = gained_leader_trait_arrested_development
				}
			}
		}
	}
}