################################
#
# Ancient Relics Events
# Written by Henrik Thyrwall et al
#
################################

namespace = ancrel

# Omnicodex Activation
country_event = {
	id = ancrel.6000
	title = "ancrel.6000.name"
	desc = "ancrel.6000.desc"
	picture = GFX_evt_genetic_modification
	show_sound = event_laboratory_sound

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				count_owned_colony = { count >= 1 }
			}
			random_owned_colony = { save_event_target_as = planet_option_1 }
		}
		if = {
			limit = {
				count_owned_colony = { count >= 2 }
			}
			random_owned_colony = {
				limit = {
					NOT = { is_same_value = event_target:planet_option_1 }
				}
				save_event_target_as = planet_option_2
			}
		}
		if = {
			limit = {
				count_owned_colony = { count >= 3 }
			}
			random_owned_colony = {
				limit = {
					NOR = {
						is_same_value = event_target:planet_option_1
						is_same_value = event_target:planet_option_2
					}
				}
				save_event_target_as = planet_option_3
			}
		}
		if = {
			limit = {
				count_owned_colony = { count >= 4 }
			}
			random_owned_colony = {
				limit = {
					NOR = {
						is_same_value = event_target:planet_option_1
						is_same_value = event_target:planet_option_2
						is_same_value = event_target:planet_option_3
					}
				}
				save_event_target_as = planet_option_4
			}
		}
		if = {
			limit = {
				count_owned_colony = { count >= 5 }
			}
			random_owned_colony = {
				limit = {
					NOR = {
						is_same_value = event_target:planet_option_1
						is_same_value = event_target:planet_option_2
						is_same_value = event_target:planet_option_3
						is_same_value = event_target:planet_option_4
					}
				}
				save_event_target_as = planet_option_5
			}
		}
	}

	option = {
		name = ancrel.6000.a
		trigger = {
			exists = event_target:planet_option_1
		}
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = random
				homeworld = event_target:planet_option_1
				effect = {
					save_event_target_as = omnicodex_species
				}
			}
			event_target:planet_option_1 = {
				while = {
					count = 3
					create_pop_group = {
						species = event_target:omnicodex_species
					}
				}
			}
			if = {
				limit = {
					is_hive_empire = yes
				}
				modify_species = {
					species = event_target:omnicodex_species
					add_trait = trait_hive_mind
				}
			}
		}
		custom_tooltip = ancrel.6000.a.tooltip
	}
	option = {
		name = ancrel.6000.f
		trigger = {
			NOT = { exists = event_target:planet_option_1 }
		}
		custom_tooltip = ancrel.6000.f.tooltip
	}
	option = {
		name = ancrel.6000.b
		trigger = {
			exists = event_target:planet_option_2
		}
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = random
				homeworld = event_target:planet_option_2
				effect = {
					save_event_target_as = omnicodex_species
				}
			}
			event_target:planet_option_2 = {
				while = {
					count = 3
					create_pop_group = {
						species = event_target:omnicodex_species
					}
				}
			}
			if = {
				limit = {
					is_hive_empire = yes
				}
				modify_species = {
					species = event_target:omnicodex_species
					add_trait = trait_hive_mind
				}
			}
		}
		custom_tooltip = ancrel.6000.b.tooltip
	}
	option = {
		name = ancrel.6000.c
		trigger = {
			exists = event_target:planet_option_3
		}
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = random
				homeworld = event_target:planet_option_3
				effect = {
					save_event_target_as = omnicodex_species
				}
			}
			event_target:planet_option_3 = {
				while = {
					count = 3
					create_pop_group = {
						species = event_target:omnicodex_species
					}
				}
			}
			if = {
				limit = {
					is_hive_empire = yes
				}
				modify_species = {
					species = event_target:omnicodex_species
					add_trait = trait_hive_mind
				}
			}
		}
		custom_tooltip = ancrel.6000.c.tooltip
	}
	option = {
		name = ancrel.6000.d
		trigger = {
			exists = event_target:planet_option_4
		}
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = random
				homeworld = event_target:planet_option_4
				effect = {
					save_event_target_as = omnicodex_species
				}
			}
			event_target:planet_option_4 = {
				while = {
					count = 3
					create_pop_group = {
						species = event_target:omnicodex_species
					}
				}
			}
			if = {
				limit = {
					is_hive_empire = yes
				}
				modify_species = {
					species = event_target:omnicodex_species
					add_trait = trait_hive_mind
				}
			}
		}
		custom_tooltip = ancrel.6000.d.tooltip
	}
	option = {
		name = ancrel.6000.e
		trigger = {
			exists = event_target:planet_option_5
		}
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = random
				homeworld = event_target:planet_option_5
				effect = {
					save_event_target_as = omnicodex_species
				}
			}
			event_target:planet_option_5 = {
				while = {
					count = 3
					create_pop_group = {
						species = event_target:omnicodex_species
					}
				}
			}
			if = {
				limit = {
					is_hive_empire = yes
				}
				modify_species = {
					species = event_target:omnicodex_species
					add_trait = trait_hive_mind
				}
			}
		}
		custom_tooltip = ancrel.6000.e.tooltip
	}
}


### Archaeology: Command Center

# Stage 1 - Drilling a Hole
fleet_event = {
	id = ancrel.6005
	title = "ancrel.6005.name"
	desc = "ancrel.6005.desc"
	picture = GFX_evt_mining_operations
	show_sound = event_drilling

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 2 - Entrance
fleet_event = {
	id = ancrel.6010
	title = "ancrel.6010.name"
	desc = "ancrel.6010.desc"
	picture = GFX_evt_derelict_interior
	show_sound = event_machinery

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = FASCINATING
		small_artifact_reward = yes
	}
}

# Stage 3 - Command Center
fleet_event = {
	id = ancrel.6015
	title = "ancrel.6015.name"
	desc = "ancrel.6015.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_door_opening

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = REMARKABLE
		small_artifact_reward = yes
	}
}

# Stage 4 - The Final Days
fleet_event = {
	id = ancrel.6020
	title = "ancrel.6020.name"
	desc = "ancrel.6020.desc"
	picture = GFX_evt_excavation_team
	show_sound = event_screams

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTERESTING
		great_artifact_reward = yes
		owner = {
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_detection_scrambler
						has_tech_option = tech_archaeo_detection_scrambler
					}
				}
				add_research_option = tech_archaeo_detection_scrambler
				add_tech_progress = {
					tech = tech_archaeo_detection_scrambler
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

### Archaeology: Hunting Grounds

# Spawn Site
carrier_event = {
	id = ancrel.6049
	title = "ancrel.6049.name"
	desc = "ancrel.6049.desc"
	picture = GFX_evt_archaeology_camp
	show_sound = event_dig_site

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		has_ancrel = yes
		pop_amount > 0
		OR = {
			is_planet_class = pc_desert
			is_planet_class = pc_tropical
			is_planet_class = pc_arid
			is_planet_class = pc_continental
			is_planet_class = pc_ocean
			is_planet_class = pc_tundra
			is_planet_class = pc_arctic
			is_planet_class = pc_alpine
			is_planet_class = pc_savannah
		}
		NOT = { exists = archaeological_site }
		NOR = {
			has_global_flag = arc_hunting_grounds
			has_carrier_flag = colony_event
			has_planet_flag = suppress_archaeological_sites
		}
	}

	is_triggered_only = yes

	immediate = {
		set_global_flag = arc_hunting_grounds
		set_carrier_flag = colony_event
	}

	option = {
		name = CURIOUS
		create_archaeological_site = site_hunting_ground
	}
}

# Stage 1 - More Remains
fleet_event = {
	id = ancrel.6050
	title = "ancrel.6050.name"
	desc = "ancrel.6050.desc"
	picture = GFX_evt_habitable_dig_site
	show_sound = event_wind_ruins

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 2 - The Lodge
fleet_event = {
	id = ancrel.6055
	title = "ancrel.6055.name"
	desc = "ancrel.6055.desc"
	picture = GFX_evt_ancient_records
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 3 - The Retarax Domain
fleet_event = {
	id = ancrel.6060
	title = "ancrel.6060.name"
	desc = "ancrel.6060.desc"
	picture = GFX_evt_alien_cavemen
	show_sound = event_screams

	archaeology = yes

	is_triggered_only = yes

	specimen = retarax_hunting_trophies

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 4 - The Huntress
fleet_event = {
	id = ancrel.6065
	title = "ancrel.6065.name"
	desc = "ancrel.6065.desc"
	picture = GFX_evt_alien_wildlife
	show_sound = event_trap_spikes

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 5 - Blade of the Huntress
fleet_event = {
	id = ancrel.6070
	title = "ancrel.6070.name"
	desc = "ancrel.6070.desc"
	picture = GFX_evt_analyzing_artifacts
	show_sound = event_finding_loot

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = EXCELLENT
		owner = { add_relic = r_ancient_sword }
		large_artifact_reward = yes
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.6070.b.evopred
		owner = {
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = large TYPE = arthropoid }
			add_relic = r_ancient_sword
		}
		large_artifact_reward = yes
	}
}

### Archaeology: Zarqlan the Prophet

# Spawning Event (HIDDEN)
event = {
	id = ancrel.6098
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		mid_game_years_passed >= 20
		has_ancrel = yes
		NOT = { has_global_flag = zarqlan_spawned }
		any_country = {
			OR = {
				is_country_type = fallen_empire
				is_country_type = awakened_fallen_empire
			}
			has_country_flag = fallen_empire_2
			any_playable_country = {
				is_ai = no
				has_communications = prev
			}
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = {
					has_global_flag = player_gets_zarqlan
					has_global_flag = ai_gets_zarqlan
				}
			}
			random_list = {
				75 = {
					set_global_flag = player_gets_zarqlan
				}
				25 = {
					set_global_flag = ai_gets_zarqlan
				}
			}
		}

		random_list = {
			100 = {}
			5 = {
				set_global_flag = zarqlan_spawned
				random_country = {
					limit = {
						OR = {
							is_country_type = fallen_empire
							is_country_type = awakened_fallen_empire
						}
						has_country_flag = fallen_empire_2
					}
					save_event_target_as = spiritualist_fallen_empire
				}
				if = {
					limit = {
						has_global_flag = player_gets_zarqlan
					}
					random_playable_country = {
						limit = {
							is_ai = no
							has_communications = event_target:spiritualist_fallen_empire
						}
						country_event = { id = ancrel.6099 days = 1 random = 350 }
					}
				}
				else = {
					random_playable_country = {
						limit = {
							is_ai = yes
							has_communications = event_target:spiritualist_fallen_empire
						}
						country_event = { id = ancrel.6099 days = 1 random = 350 }
					}
				}
			}
		}
	}
}

# Spawning Event
country_event = {
	id = ancrel.6099
	title = "ancrel.6099.name"
	desc = "ancrel.6099.desc"
	picture = GFX_evt_cargoship_caravan
	show_sound = event_power_down
	location = event_target:tomb_planet

	is_triggered_only = yes

	immediate = {
		if = {
			limit = { is_nomadic = yes }
			random_owned_nonprimary_starbase = {
				limit = {
					is_waystation_starbase = yes
					solar_system = {
						any_system_planet = {
							OR = {
								is_planet_class = pc_molten
								is_planet_class = pc_barren
								is_planet_class = pc_barren_cold
								is_planet_class = pc_frozen
							}
							NOT = { exists = archaeological_site }
							NOT = { has_planet_flag = suppress_archaeological_sites }
						}
					}
				}
				solar_system = {
					random_system_planet = {
						limit = {
							OR = {
								is_planet_class = pc_molten
								is_planet_class = pc_barren
								is_planet_class = pc_barren_cold
								is_planet_class = pc_frozen
							}
							NOT = { exists = archaeological_site }
							NOT = { has_planet_flag = suppress_archaeological_sites }
						}
						save_event_target_as = tomb_planet
					}
				}
			}
		}
		else = {
			random_planet_within_border = {
				limit = {
					OR = {
						is_planet_class = pc_molten
						is_planet_class = pc_barren
						is_planet_class = pc_barren_cold
						is_planet_class = pc_frozen
					}
					NOT = { exists = archaeological_site }
					NOT = { has_planet_flag = suppress_archaeological_sites }
				}
				save_event_target_as = tomb_planet
			}
		}
	}

	option = {
		name = ancrel.6099.a
		event_target:tomb_planet = {
			create_archaeological_site = site_zarqlan
		}
	}
}


# Stage 1 - The Mausoleum
fleet_event = {
	id = ancrel.6100
	title = "ancrel.6100.name"
	desc = "ancrel.6100.desc"
	picture = GFX_evt_discovered_hidden_door
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = FASCINATING
		small_artifact_reward = yes
	}
}

# Stage 2 - The First Chamber
fleet_event = {
	id = ancrel.6105
	title = "ancrel.6105.name"
	desc = "ancrel.6105.desc"
	picture = GFX_evt_discovered_hidden_door
	show_sound = event_big_door_opening

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
		owner = { set_country_flag = zarqlan_language_translated }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		small_artifact_reward = yes
	}
}

# Stage 3 - The Second Chamber
fleet_event = {
	id = ancrel.6110
	title = "ancrel.6110.name"
	desc = "ancrel.6110.desc"
	picture = GFX_evt_discovered_hidden_door
	show_sound = event_big_door_opening

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 4 - The Third Chamber
fleet_event = {
	id = ancrel.6115
	title = "ancrel.6115.name"
	desc = "ancrel.6115.desc"
	picture = GFX_evt_discovered_hidden_door
	show_sound = event_big_door_opening

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = REMARKABLE
		small_artifact_reward = yes
	}
}

# Stage 5 - The Fourth Chamber
fleet_event = {
	id = ancrel.6120
	title = "ancrel.6120.name"
	desc = "ancrel.6120.desc"
	picture = GFX_evt_discovered_hidden_door
	show_sound = event_big_door_opening

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ASTOUNDING
		small_artifact_reward = yes
	}
}

# Stage 6 - The Final Chamber
fleet_event = {
	id = ancrel.6125
	title = "ancrel.6125.name"
	desc = "ancrel.6125.desc"
	picture = GFX_evt_excavation_team
	show_sound = event_bad_omen

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		owner = { add_relic = r_severed_head }
		large_artifact_reward = yes
		hidden_effect = {
			owner = {
				country_event = { id = ancrel.6130 }
			}
		}
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.6125.desc.b.evopred
		owner = {
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = large TYPE = humanoid }
			add_relic = r_severed_head
		}
		large_artifact_reward = yes
		hidden_effect = {
			owner = {
				country_event = { id = ancrel.6130 }
			}
		}
	}
}

# Fallen Empire Transmission
country_event = {
	id = ancrel.6130
	title = TRANSMISSION
	desc = {
		trigger = {
			owner = {
				NOR = {
					is_individual_machine = yes
					is_machine_empire = yes
					is_synthetic_empire = yes
				}
			}
		}
		text = ancrel.6130.desc
	}
	desc = {
		trigger = {
			owner = {
				OR = {
					is_individual_machine = yes
					is_machine_empire = yes
					is_synthetic_empire = yes
				}
			}
		}
		text = ancrel.6130.machine.desc
	}

	diplomatic = yes

	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:spiritualist_fallen_empire
		planet_background = event_target:spiritualist_fallen_empire
		graphical_culture = event_target:spiritualist_fallen_empire
		city_level = event_target:spiritualist_fallen_empire
		room = event_target:spiritualist_fallen_empire.ruler
	}

	trigger = {
		any_country = {
			OR = {
				is_country_type = fallen_empire
				is_country_type = awakened_fallen_empire
			}
			has_country_flag = fallen_empire_2
			has_communications = root
		}
	}

	immediate = {
		random_country = {
			limit = {
				OR = {
					is_country_type = fallen_empire
					is_country_type = awakened_fallen_empire
				}
				has_country_flag = fallen_empire_2
			}
			save_event_target_as = spiritualist_fallen_empire
			add_opinion_modifier = {
				who = root
				modifier = opinion_zarqlans_chosen
			}
		}
	}

	option = {
		name = ancrel.6130.a
		add_modifier = {
			modifier = chosen_of_zarqlan
		}
	}
}

# Severed Head Relic Activation
country_event = {
	id = ancrel.6131
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				NOT = { is_variable_set = zarqlan_fervor }
			}
			set_variable = {
				which = zarqlan_fervor
				value = 1
			}
		}
		if = {
			limit = {
				any_country = {
					OR = {
						is_country_type = fallen_empire
						is_country_type = awakened_fallen_empire
					}
					has_country_flag = fallen_empire_2
				}
			}
			random_country = {
				limit = {
					OR = {
						is_country_type = fallen_empire
						is_country_type = awakened_fallen_empire
					}
					has_country_flag = fallen_empire_2
				}
				save_event_target_as = spiritualist_fallen_empire
			}
			country_event = { id = ancrel.6132 }
		}
		else = {
			country_event = { id = ancrel.6133 }
		}
	}
}

# Pilgrim Fleet
country_event = {
	id = ancrel.6132
	title = TRANSMISSION
	desc = "ancrel.6132.a.desc"
	desc = "ancrel.6132.b.desc"
	desc = "ancrel.6132.c.desc"
	desc = "ancrel.6132.d.desc"

	diplomatic = yes

	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:spiritualist_fallen_empire
		room = "ethic_spaceship_room"
	}

	option = {
		name = ancrel.6132.a
		hidden_effect = {
			capital_scope = {
				create_fleet = {
					name = "NAME_Zarqlans_Pilgrims"
					effect = {
						set_owner = event_target:spiritualist_fallen_empire # For ship names
						while = {
							count = root.zarqlan_fervor
							create_fallen_empire_large_ship = yes
						}
						while = {
							count = root.value:zarqlan_fervor_three
							create_fallen_empire_small_ship = yes
						}
						set_location = {
							target = prev
							distance = 45
							angle = random
						}
						set_owner = root
					}
				}
			}
			if = {
				limit = {
					check_variable = {
						which = zarqlan_fervor
						value <= 4
					}
				}
				change_variable = {
					which = zarqlan_fervor
					value = 1
				}
			}
		}
	}
}

# Pilgrim Fleet (Fallen Empire Gone)
country_event = {
	id = ancrel.6133
	title = "ancrel.6133.name"
	desc = "ancrel.6133.desc"
	picture = GFX_evt_fleet_from_surface
	show_sound = event_bad_omen

	is_triggered_only = yes

	option = {
		name = ancrel.6132.a
		hidden_effect = {
			capital_scope = {
				create_fleet = {
					name = "NAME_Zarqlans_Pilgrims"
					effect = {
						set_owner = root
						while = {
							count = root.value:zarqlan_fervor_three
							create_ship = {
								name = random
								design = "NAME_Zealot"
								graphical_culture = fallen_empire_01
							}
						}
						set_location = {
							target = prev
							distance = 45
							angle = random
						}
					}
				}
			}
			if = {
				limit = {
					check_variable = {
						which = zarqlan_fervor
						value <= 4
					}
				}
				change_variable = {
					which = zarqlan_fervor
					value = 1
				}
			}
		}
	}
}

### Archaeology: Barrier Moon

# On Survey (Planet First)
ship_event = {
	id = ancrel.6150
	title = "ancrel.6150.name"
	desc = "ancrel.6150.desc"
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_ship_in_orbit_2
		BIOSHIP_PICTURE = GFX_evt_bio_ships_orbiting
	}
	show_sound = event_energy_field
	location = from

	is_triggered_only = yes

	trigger = {
		from = { has_planet_flag = minigalaxy_planet }
		NOT = {
			has_global_flag = minigalaxy_site_spawned
		}
	}

	immediate = {
		set_global_flag = minigalaxy_site_spawned
		from = {
			solar_system = {
				random_system_planet = {
					limit = { has_planet_flag = minigalaxy_moon }
					save_event_target_as = minigalaxy_moon
				}
			}
		}
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
		event_target:minigalaxy_moon = {
			set_surveyed = {
				surveyed = yes
				surveyor = root.owner
			}
			create_archaeological_site = site_minigalaxy_1
		}
	}
}

# On Survey (Moon First)
ship_event = {
	id = ancrel.6151
	title = "ancrel.6150.name"
	desc = "ancrel.6151.desc"
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_ship_in_orbit_2
		BIOSHIP_PICTURE = GFX_evt_bio_ships_orbiting
	}
	show_sound = event_energy_field
	location = from

	is_triggered_only = yes

	trigger = {
		from = { has_planet_flag = minigalaxy_moon }
		NOT = { has_global_flag = minigalaxy_site_spawned }
	}

	immediate = {
		set_global_flag = minigalaxy_site_spawned
	}

	option = {
		name = CURIOUS
		from = {
			create_archaeological_site = site_minigalaxy_1
		}
	}
}

### Moon Site

# Stage 1 - The Armistice Initiative
fleet_event = {
	id = ancrel.6155
	title = "ancrel.6155.name"
	desc = "ancrel.6155.desc"
	picture = GFX_evt_ancient_alien_temple
	show_sound = event_drilling

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 2 - Belligerent Party C
fleet_event = {
	id = ancrel.6160
	title = "ancrel.6160.name"
	desc = "ancrel.6160.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_door_opening

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 3 - The Shield Generator
fleet_event = {
	id = ancrel.6165
	title = "ancrel.6165.name"
	desc = "ancrel.6165.desc"
	picture = GFX_evt_generator_powerup
	show_sound = event_power_down

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = {
			solar_system = {
				random_system_planet = {
					limit = { has_planet_flag = minigalaxy_planet }
					save_event_target_as = minigalaxy_planet
				}
			}
			set_site_progress_locked = yes
		}
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
		event_target:minigalaxy_planet = {
			change_pc = pc_relic
			hidden_effect = {
				relic_world_deposits = yes
				create_archaeological_site = site_minigalaxy_2
				set_surveyed = {
					surveyed = yes
					surveyor = root.owner
				}
			}
		}
		owner = {
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_overcharger
						has_tech_option = tech_archaeo_overcharger
					}
				}
				add_research_option = tech_archaeo_overcharger
				add_tech_progress = {
					tech = tech_archaeo_overcharger
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

### Planet Site

# Stage 1 - Mysterious Disappearance
fleet_event = {
	id = ancrel.6170
	title = "ancrel.6170.name"
	desc = "ancrel.6170.desc"
	picture = GFX_evt_relic_world_street
	show_sound = event_wind_ruins

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 2 - Evacuation Day
fleet_event = {
	id = ancrel.6175
	title = "ancrel.6175.name"
	desc = "ancrel.6175.desc"
	picture = GFX_evt_relic_world_street
	show_sound = event_wind_ruins

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 3 - The Project
fleet_event = {
	id = ancrel.6180
	title = "ancrel.6180.name"
	desc = "ancrel.6180.desc"
	picture = GFX_evt_relic_world_building
	show_sound = event_whispering

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 4 - Miniaturized Galaxy
fleet_event = {
	id = ancrel.6185
	title = "ancrel.6185.name"
	desc = "ancrel.6185.desc"
	picture = GFX_evt_relic_world_building
	show_sound = event_finding_loot

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		large_artifact_reward = yes
		owner = { add_relic = "r_galaxy" }
	}
}

### Archaeology: Star Petal

# Stage 1 - Pleasure Planet
fleet_event = {
	id = ancrel.6200
	title = "ancrel.6200.name"
	desc = "ancrel.6200.desc"
	picture = GFX_evt_gas_giant_station
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 2 - The Star Petal
fleet_event = {
	id = ancrel.6205
	title = "ancrel.6205.name"
	desc = "ancrel.6205.desc"
	picture = GFX_evt_derelict_interior
	show_sound = event_whispering

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 3 - The Final Days
fleet_event = {
	id = ancrel.6210
	title = "ancrel.6210.name"
	desc = "ancrel.6210.desc"
	picture = GFX_evt_gas_giant_station
	show_sound = event_screams

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 4 - Heart of the Pulsar
fleet_event = {
	id = ancrel.6215
	title = "ancrel.6215.name"
	desc = "ancrel.6215.desc"
	picture = GFX_evt_analyzing_artifacts
	show_sound = event_finding_loot

	archaeology = yes

	is_triggered_only = yes

	specimen = heart_of_the_pulsar

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		medium_artifact_reward = yes
		owner = {
			add_resource = { energy = 4000 }
			if = {
				limit = {
					is_nomadic = no
					NOR = {
						has_technology = tech_archaeo_rampart
						has_tech_option = tech_archaeo_rampart
					}
				}
				add_research_option = tech_archaeo_rampart
				add_tech_progress = {
					tech = tech_archaeo_rampart
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

### Archaeology: Robot Debris

# Stage 1 - Two Sides
fleet_event = {
	id = ancrel.6250
	title = "ancrel.6250.name"
	desc = "ancrel.6250.desc"
	picture = GFX_evt_space_walk
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 2 - The Battle
fleet_event = {
	id = ancrel.6255
	title = "ancrel.6255.name"
	desc = "ancrel.6255.desc"
	picture = GFX_evt_ground_combat
	show_sound = event_ground_battle

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 3 - The Treaty
fleet_event = {
	id = ancrel.6260
	title = "ancrel.6260.name"
	desc = "ancrel.6260.desc"
	picture = GFX_evt_barren_dig_site
	show_sound = event_finding_loot

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		medium_artifact_reward = yes
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_mass_drivers
						has_tech_option = tech_archaeo_mass_drivers
					}
				}
				add_research_option = tech_archaeo_mass_drivers
				add_tech_progress = {
					tech = tech_archaeo_mass_drivers
					progress = 0.25
				}
			}
		}
	}
}

### Archaeology: Freighter Crash

# Stage 1 - Captain's Chronicle
fleet_event = {
	id = ancrel.6300
	title = "ancrel.6300.name"
	desc = "ancrel.6300.desc"
	picture = GFX_evt_crashed_station
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 2 - First Mate's Report
fleet_event = {
	id = ancrel.6310
	title = "ancrel.6310.name"
	desc = "ancrel.6310.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 3 - Food Situation
fleet_event = {
	id = ancrel.6320
	title = "ancrel.6320.name"
	desc = "ancrel.6320.desc"
	picture = GFX_evt_derelict_interior
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 4 - Zarbla is a Fraud
fleet_event = {
	id = ancrel.6330
	title = "ancrel.6330.name"
	desc = "ancrel.6330.desc"
	picture = GFX_evt_generator_powerup
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 5 - Third Mate's Report
fleet_event = {
	id = ancrel.6340
	title = "ancrel.6340.name"
	desc = "ancrel.6340.desc"
	picture = GFX_evt_excavation_team
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		small_artifact_reward = yes
	}
}

# Stage 6 - Patrol Log
fleet_event = {
	id = ancrel.6350
	title = "ancrel.6350.name"
	desc = "ancrel.6350.desc"
	picture = GFX_evt_unidentified_ship
	show_sound = event_finding_loot

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		large_artifact_reward = yes
		owner = {
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeoarmor
						has_tech_option = tech_archaeoarmor
					}
				}
				add_research_option = tech_archaeoarmor
				add_tech_progress = {
					tech = tech_archaeoarmor
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

### RELIC THEFT

# Relic Acquired (HIDDEN)
country_event = {
	id = ancrel.6499
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		From = {
			is_country_type = default
			num_owned_relics > 0
		}
		FromFrom = { is_capital = yes }
		any_war = {
			any_attacker = { is_same_value = root }
			any_defender = { is_same_value = from }
			NOT = {
				using_war_goal = {
					type = wg_take_galatron
					owner = attacker
				}
			}
		}
	}

	immediate = {
		FromFrom = { save_event_target_as = planet }
		From = { save_event_target_as = victim }
		random_list = {
			100 = {}
			10 = {
				modifier = {
					factor = 15
					has_valid_civic = civic_barbaric_despoilers
				}
				modifier = {
					factor = 6.67 # 50% chance of success
					any_war = {
						any_attacker = { is_same_value = root }
						any_defender = { is_same_value = from }
						using_war_goal = {
							type = wg_plunder
							owner = attacker
						}
					}
				}
				country_event = { id = ancrel.6500 }
			}
		}
	}
}

# Relic Acquired
country_event = {
	id = ancrel.6500
	title = "ancrel.6500.name"
	desc = "ancrel.6500.desc"
	picture = GFX_evt_victorious_army
	show_sound = event_ground_battle
	location = event_target:planet

	is_triggered_only = yes

	immediate = {
		steal_relic = {
			target = event_target:victim
			relic = random
		}
		if = {
			limit = {
				has_relic = r_war_forge
			}
			hidden_effect = {
				if = {
					limit = {
						NOT = {
							is_variable_set = cybrex_count
						}
					}
					set_variable = {
						which = cybrex_count
						value = 1
					}
				}
			}
		}
	}

	option = {
		name = ancrel.6500.a
		custom_tooltip = stole_relic
		hidden_effect = {
			event_target:victim = {
				country_event = { id = ancrel.6505 }
			}
		}
	}
}

# Relic Lost
country_event = {
	id = ancrel.6505
	title = "ancrel.6505.name"
	desc = "ancrel.6505.desc"
	picture = GFX_evt_ground_combat
	show_sound = event_ground_battle
	location = event_target:planet

	is_triggered_only = yes

	option = {
		name = ancrel.6505.a
		custom_tooltip = relic_lost
	}
}



### Archaeology: Moon Bump

# Stage 1 - City Center
fleet_event = {
	id = ancrel.9000
	title = "ancrel.9000.name"
	desc = "ancrel.9000.desc"
	picture = GFX_evt_ancient_alien_temple
	show_sound = event_collapsing_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Random Outcome
fleet_event = {
	id = ancrel.9005
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9010 }
			}
			33 = {
				fleet_event = { id = ancrel.9015 }
			}
			33 = {
				fleet_event = { id = ancrel.9020 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9005 }
	}
}

# Stage 2 - Alt. 1 - Just Got Reel
fleet_event = {
	id = ancrel.9010
	title = "ancrel.9010.name"
	desc = "ancrel.9010.desc"
	picture = GFX_evt_asteroid_approaching_planet
	show_sound = event_screams

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = FASCINATING
		owner = {
			if = {
				limit = {
					has_tech_option = tech_housing_2
				}
				add_tech_progress = {
					tech = tech_housing_2
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_housing_2 }
				}
				add_research_option = tech_housing_2
				add_tech_progress = {
					tech = tech_housing_2
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

# Stage 2 - Alt. 2 - Cosmic Nudge
fleet_event = {
	id = ancrel.9015
	title = "ancrel.9015.name"
	desc = "ancrel.9015.desc"
	picture = GFX_evt_nuclear_explosion
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = UNFORTUNATE
		owner = {
			give_next_habitability_tech_option_effect = yes
		}
	}
}

# Stage 2 - Alt. 3 - Grand Scale Attraction
fleet_event = {
	id = ancrel.9020
	title = "ancrel.9020.name"
	desc = "ancrel.9020.desc"
	picture = GFX_evt_atmospheric_entry
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = primitive_mega_electromagnet
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = OOPS
		owner = {
			add_resource = { alloys = 500 }
		}
	}
}

### Archaeology: The Echoes Inside

# Stage 1 - Dead Lands
fleet_event = {
	id = ancrel.9025
	title = "ancrel.9025.name"
	desc = "ancrel.9025.desc"
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_ship_in_orbit
		BIOSHIP_PICTURE = GFX_evt_bio_ships_orbiting
	}
	show_sound = event_bad_omen
	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Tunnel Vision
fleet_event = {
	id = ancrel.9030
	title = "ancrel.9030.name"
	desc = "ancrel.9030.desc"
	picture = GFX_evt_tomb_world
	show_sound = event_drilling

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Tremors
fleet_event = {
	id = ancrel.9035
	title = "ancrel.9035.name"
	desc = "ancrel.9035.desc"
	picture = GFX_evt_warm_barren
	show_sound = event_collapsing_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 4 - Abandoned Outpost
fleet_event = {
	id = ancrel.9040
	title = "ancrel.9040.name"
	desc = "ancrel.9040.desc"
	picture = GFX_evt_mining_operations
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = WORRYING
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
		}
	}
}

### Archaeology: Target From Orbit

# Stage 1 - Down We Go
fleet_event = {
	id = ancrel.9045
	title = "ancrel.9045.name"
	desc = "ancrel.9045.desc"
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_landing_ship
		BIOSHIP_PICTURE = GFX_evt_bioship_landing
	}
	show_sound = event_dig_site

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - The Amber Puzzle Box
fleet_event = {
	id = ancrel.9050
	title = "ancrel.9050.name"
	desc = "ancrel.9050.desc"
	picture = GFX_evt_clocks
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9051
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9055 }
			}
			33 = {
				fleet_event = { id = ancrel.9060 }
			}
			33 = {
				fleet_event = { id = ancrel.9065 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9051 }
	}
}

# Stage 3 - Alt. 1 - Treasure of the Wise
fleet_event = {
	id = ancrel.9055
	title = "ancrel.9055.name"
	desc = "ancrel.9055.desc"
	picture = GFX_evt_sapient_AI
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	specimen = programmable_puzzle_cube

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = MARVELOUS
		owner = {
			if = {
				limit = {
					has_tech_option = tech_power_plant_3
				}
				add_tech_progress = {
					tech = tech_power_plant_3
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_power_plant_3 }
				}
				add_research_option = tech_power_plant_3
				add_tech_progress = {
					tech = tech_power_plant_3
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			owner = {
				if = {
					limit = {
						NOR = {
							has_technology = tech_archaeoshield
							has_tech_option = tech_archaeoshield
						}
					}
					add_research_option = tech_archaeoshield
					add_tech_progress = {
						tech = tech_archaeoshield
						progress = 0.25
					}
				}
				else = {
					add_monthly_resource_mult = {
						resource = engineering_research
						value = @tier3researchreward
						min = @tier3researchmin
						max = @tier3researchmax
					}
				}
			}
		}
	}
}

# Stage 3 - Alt. 2 - Map to the Dust
fleet_event = {
	id = ancrel.9060
	title = "ancrel.9060.name"
	desc = "ancrel.9060.desc"
	picture = GFX_evt_asteroid_field
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	specimen = programmable_puzzle_cube

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = UNFORTUNATE
		owner = {
			add_resource = { minerals = 1000 }
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeoshield
						has_tech_option = tech_archaeoshield
					}
				}
				add_research_option = tech_archaeoshield
				add_tech_progress = {
					tech = tech_archaeoshield
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

# Stage 3 - Alt. 3 - Ancient Approval
fleet_event = {
	id = ancrel.9065
	title = "ancrel.9065.name"
	desc = "ancrel.9065.desc"
	picture = GFX_evt_unity_symbol
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	specimen = programmable_puzzle_cube

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = PECULIAR
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeoshield
						has_tech_option = tech_archaeoshield
					}
				}
				add_research_option = tech_archaeoshield
				add_tech_progress = {
					tech = tech_archaeoshield
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

### Archaeology: Shot into the Ground

# Stage 1 - Digging It
fleet_event = {
	id = ancrel.9070
	title = "ancrel.9070.name"
	desc = "ancrel.9070.desc"
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_big_landing_ship
		BIOSHIP_PICTURE = GFX_evt_bioship_landing
	}
	show_sound = event_drilling

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Toxicity Risk
fleet_event = {
	id = ancrel.9075
	title = "ancrel.9075.name"
	desc = "ancrel.9075.desc"
	picture = GFX_evt_gray_goo
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9076
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9080 }
			}
			33 = {
				fleet_event = { id = ancrel.9085}
			}
			33 = {
				fleet_event = { id = ancrel.9090 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9076 }
	}
}

# Stage 3 - Alt. 1 - Six (Thousand) Feet Under
fleet_event = {
	id = ancrel.9080
	title = "ancrel.9080.name"
	desc = "ancrel.9080.desc"
	picture = GFX_evt_nuclear_explosion
	show_sound = event_metal_fatigue

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = FASCINATING
		owner = {
			if = {
				limit = {
					has_tech_option = tech_shields_4
				}
				add_tech_progress = {
					tech = tech_shields_4
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_shields_4 }
				}
				add_research_option = tech_shields_4
				add_tech_progress = {
					tech = tech_shields_4
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

# Stage 3 - Alt. 2 - Just A Drill
fleet_event = {
	id = ancrel.9085
	title = "ancrel.9085.name"
	desc = "ancrel.9085.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_metal_fatigue

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		owner = {
			if = {
				limit = {
					has_tech_option = tech_mining_2
				}
				add_tech_progress = {
					tech = tech_mining_2
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_mining_2 }
				}
				add_research_option = tech_mining_2
				add_tech_progress = {
					tech = tech_mining_2
					progress = 0.1
				}
			}
			else = {
				add_resource = { volatile_motes = 100 }
			}
		}
	}
}

# Stage 3 - Alt. 3 - Surface-Burster
fleet_event = {
	id = ancrel.9090
	title = "ancrel.9090.name"
	desc = "ancrel.9090.desc"
	picture = GFX_evt_space_monster
	show_sound = event_dangerous_animals

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = giant_egg_shell
				targets = { root.from.planet }
			}
		}
	}

	option = {
		name = INTRIGUING
		owner = {
			if = {
				limit = {
					has_tech_option = tech_alien_life_studies
				}
				add_tech_progress = {
					tech = tech_alien_life_studies
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_alien_life_studies }
					can_research_technology = tech_alien_life_studies
				}
				add_research_option = tech_alien_life_studies
				add_tech_progress = {
					tech = tech_alien_life_studies
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.9090.b.evopred
		owner = {
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = medium }
			if = {
				limit = {
					has_tech_option = tech_alien_life_studies
				}
				add_tech_progress = {
					tech = tech_alien_life_studies
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_alien_life_studies }
					can_research_technology = tech_alien_life_studies
				}
				add_research_option = tech_alien_life_studies
				add_tech_progress = {
					tech = tech_alien_life_studies
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

### Archaeology: Cut to Fit

# Stage 1 - Shapes of Perfection
fleet_event = {
	id = ancrel.9095
	title = "ancrel.9095.name"
	desc = "ancrel.9095.desc"
	picture = GFX_evt_cold_barren
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Signs of Sentience
fleet_event = {
	id = ancrel.9100
	title = "ancrel.9100.name"
	desc = "ancrel.9100.desc"
	picture = GFX_evt_ruined_system
	show_sound = event_metal_fatigue

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9101
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			10 = {
				fleet_event = { id = ancrel.9105 }
			}
			40 = {
				fleet_event = { id = ancrel.9110}
			}
			40 = {
				fleet_event = { id = ancrel.9115 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9101 }
	}
}

# Stage 3 - Alt. 1 - Limitless Art
fleet_event = {
	id = ancrel.9105
	title = "ancrel.9105.name"
	desc = "ancrel.9105.desc"
	picture = GFX_evt_strategic_resources
	show_sound = event_metal_fatigue

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = planetary_sculpture
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = FASCINATING
		owner = {
			if = {
				limit = {
					has_tech_option = tech_mega_art
				}
				add_tech_progress = {
					tech = tech_mega_art
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_mega_art }
					has_megacorp = yes
					is_nomadic = no				}
				add_research_option = tech_mega_art
				add_tech_progress = {
					tech = tech_mega_art
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_lasers
						has_tech_option = tech_archaeo_lasers
					}
				}
				add_research_option = tech_archaeo_lasers
				add_tech_progress = {
					tech = tech_archaeo_lasers
					progress = 0.25
				}
			}
		}
	}
}

# Stage 3 - Alt. 2 - A Custom Job
fleet_event = {
	id = ancrel.9110
	title = "ancrel.9110.name"
	desc = "ancrel.9110.desc"
	picture = GFX_evt_surreal_visions
	show_sound = event_machinery

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		owner = {
			if = {
				limit = {
					has_tech_option = tech_terrestrial_sculpting
				}
				add_tech_progress = {
					tech = tech_terrestrial_sculpting
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					is_nomadic = no
					NOT = { has_technology = tech_terrestrial_sculpting }
				}
				add_research_option = tech_terrestrial_sculpting
				add_tech_progress = {
					tech = tech_terrestrial_sculpting
					progress = 0.1
				}
			}
			else = {
				add_resource = { minerals = 2000 }
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_lasers
						has_tech_option = tech_archaeo_lasers
					}
				}
				add_research_option = tech_archaeo_lasers
				add_tech_progress = {
					tech = tech_archaeo_lasers
					progress = 0.25
				}
			}
		}
	}
}

# Stage 3 - Alt. 3 - Celestial Dismantling
fleet_event = {
	id = ancrel.9115
	title = "ancrel.9115.name"
	desc = "ancrel.9115.desc"
	picture = GFX_evt_gray_goo
	show_sound = event_drilling

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		owner = {
			if = {
				limit = {
					has_tech_option = tech_space_mining_3
				}
				add_tech_progress = {
					tech = tech_space_mining_3
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_space_mining_3 }
				}
				add_research_option = tech_space_mining_3
				add_tech_progress = {
					tech = tech_space_mining_3
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_lasers
						has_tech_option = tech_archaeo_lasers
					}
				}
				add_research_option = tech_archaeo_lasers
				add_tech_progress = {
					tech = tech_archaeo_lasers
					progress = 0.25
				}
			}
		}
	}
}

### Archaeology: Déjà Vu Dig

# Stage 1 - Tumbled Down
fleet_event = {
	id = ancrel.9120
	title = "ancrel.9120.name"
	desc = "ancrel.9120.desc"
	picture = GFX_evt_underground_civilization
	show_sound = event_collapsing_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Meta-Archaeology
fleet_event = {
	id = ancrel.9125
	title = "ancrel.9125.name"
	desc = "ancrel.9125.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_dig_site

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9126
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9130 }
			}
			33 = {
				fleet_event = { id = ancrel.9135}
			}
			33 = {
				fleet_event = { id = ancrel.9140 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9126 }
	}
}

# Stage 3 - Alt. 1 - Archaeological Loop
fleet_event = {
	id = ancrel.9130
	title = "ancrel.9130.name"
	desc = "ancrel.9130.desc"
	picture = GFX_evt_unity_symbol
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = INTENSIFIES
		leader = {
			add_trait = {
				trait = leader_trait_traumatized
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}
}

# Stage 3 - Alt. 2 - Cover It Up
fleet_event = {
	id = ancrel.9135
	title = "ancrel.9135.name"
	desc = "ancrel.9135.desc"
	picture = GFX_evt_exploding_ship
	show_sound = event_metal_fatigue

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = UNFORTUNATE
		owner = {
			if = {
				limit = {
					NOT = { has_technology = tech_deep_sinkhole }
				}
				give_technology = { tech = tech_deep_sinkhole }
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier5researchreward
					min = @tier5researchmin
					max = @tier5researchmax
				}
			}
		}
	}
}

# Stage 3 - Alt. 3 - Defended Tomb
fleet_event = {
	id = ancrel.9140
	title = "ancrel.9140.name"
	desc = "ancrel.9140.desc"
	picture = GFX_evt_warm_barren
	show_sound = event_collapsing_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = NOTIME
		owner = {
			if = {
				limit = {
					has_tech_option = tech_tomb_world_adaption
				}
				add_tech_progress = {
					tech = tech_tomb_world_adaption
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_tomb_world_adaption }
					can_research_technology = tech_tomb_world_adaption
				}
				add_research_option = tech_tomb_world_adaption
				add_tech_progress = {
					tech = tech_tomb_world_adaption
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier5researchreward
					min = @tier5researchmin
					max = @tier5researchmax
				}
			}
		}
	}
}

### Archaeology: Trench World

# Stage 1 - Dug with Intention
fleet_event = {
	id = ancrel.9145
	title = "ancrel.9145.name"
	desc = "ancrel.9145.desc"
	picture = GFX_evt_arid
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Random Outcome
fleet_event = {
	id = ancrel.9146
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9150 }
			}
			33 = {
				fleet_event = { id = ancrel.9155}
			}
			33 = {
				fleet_event = { id = ancrel.9160 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9146 }
	}
}

# Stage 2 - Alt. 1 - Trench War
fleet_event = {
	id = ancrel.9150
	title = "ancrel.9150.name"
	desc = "ancrel.9150.desc"
	picture = GFX_evt_unspeakable_horror
	show_sound = event_dangerous_animals

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = REMARKABLE
		owner = {
			if = {
				limit = {
					has_tech_option = tech_combat_training
				}
				add_tech_progress = {
					tech = tech_combat_training
					progress = 0.25
				}
				add_modifier = {
					modifier = modern_trench_war
					days = -1
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_combat_training }
				}
				add_research_option = tech_combat_training
				add_modifier = {
					modifier = modern_trench_war
					days = -1
				}
			}
			else = {
				add_modifier = {
					modifier = modern_trench_war
					days = -1
				}
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

# Stage 2 - Alt. 2 - Irrigation Prep
fleet_event = {
	id = ancrel.9155
	title = "ancrel.9155.name"
	desc = "ancrel.9155.desc"
	picture = GFX_evt_desert
	show_sound = event_drilling

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = SCRAPIT
		owner = {
			if = {
				limit = {
					has_tech_option = tech_robotic_workers
				}
				add_tech_progress = {
					tech = tech_robotic_workers
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_robotic_workers }
					can_research_technology = tech_robotic_workers
				}
				add_research_option = tech_robotic_workers
				add_tech_progress = {
					tech = tech_robotic_workers
					progress = 0.25
				}
			}
			else = {
				add_resource = { alloys = 500 }
			}
		}
	}
}

# Stage 2 - Alt. 3 - Ice Blanket
fleet_event = {
	id = ancrel.9160
	title = "ancrel.9160.name"
	desc = "ancrel.9160.desc"
	picture = GFX_evt_frozen
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = AMAZING
		owner = {
			if = {
				limit = {
					has_tech_option = tech_massive_glacier
				}
				add_tech_progress = {
					tech = tech_massive_glacier
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					is_nomadic = no
					NOT = { has_technology = tech_massive_glacier }
				}
				add_research_option = tech_massive_glacier
				add_tech_progress = {
					tech = tech_massive_glacier
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

### Archaeology: Ebb & Flow

# Stage 1 - Certainly Gone Now
fleet_event = {
	id = ancrel.9165
	title = "ancrel.9165.name"
	desc = "ancrel.9165.desc"
	picture = GFX_evt_alien_city
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Labyrinth of Death
fleet_event = {
	id = ancrel.9170
	title = "ancrel.9170.name"
	desc = "ancrel.9170.desc"
	picture = GFX_evt_derelict_interior
	show_sound = event_big_door_opening

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - The Floor is Lava
fleet_event = {
	id = ancrel.9175
	title = "ancrel.9175.name"
	desc = "ancrel.9175.desc"
	picture = GFX_evt_molten
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 4 - Random Outcome
fleet_event = {
	id = ancrel.9176
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9177 }
			}
			33 = {
				fleet_event = { id = ancrel.9180}
			}
			33 = {
				fleet_event = { id = ancrel.9185 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9176 }
	}
}

# Stage 4 - Alt. 1 - Sacred Texts
fleet_event = {
	id = ancrel.9177
	title = "ancrel.9177.name"
	desc = "ancrel.9177.desc"
	picture = GFX_evt_star_chart
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	specimen = doomsday_scrolls

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		owner = {
			if = {
				limit = {
					is_machine_empire = yes
				}
				add_modifier = {
					modifier = debug_subroutine
					days = -1
				}
			}
			else_if = {
				limit = {
					is_hive_empire = yes
				}
				add_modifier = {
					modifier = glory_to_the_many
					days = -1
				}
			}
			else = {
				add_modifier = {
					modifier = forced_mindfulness
					days = -1
				}
			}
		}
	}
}

# Stage 4 - Alt. 2 - Treasure Trove
fleet_event = {
	id = ancrel.9180
	title = "ancrel.9180.name"
	desc = "ancrel.9180.desc"
	picture = GFX_evt_ship_offloading_cargo
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = EXCELLENT
		owner = {
			add_resource = { rare_crystals = 200 }
			add_resource = { exotic_gases = 200 }
			add_resource = { volatile_motes = 200 }
		}
	}
}

# Stage 4 - Alt. 3 - Serentiy in Isolation
fleet_event = {
	id = ancrel.9185
	title = "ancrel.9185.name"
	desc = "ancrel.9185.desc"
	picture = GFX_evt_psionics
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		owner = {
			if = {
				limit = {
					is_machine_empire = yes
				}
				add_modifier = {
					modifier = debug_subroutine
					days = -1
				}
			}
			else_if = {
				limit = {
					is_hive_empire = yes
				}
				add_modifier = {
					modifier = glory_to_the_many
					days = -1
				}
			}
			else = {
				add_modifier = {
					modifier = forced_mindfulness
					days = -1
				}
			}
		}
	}
}

### Archaeology: Sky Glow Hymn

# Stage 1 - Barren Grounds & Vibrant Skies
fleet_event = {
	id = ancrel.9190
	title = "ancrel.9190.name"
	desc = "ancrel.9190.desc"
	picture = GFX_evt_alien_city
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Fire in the Sky
fleet_event = {
	id = ancrel.9195
	title = "ancrel.9195.name"
	desc = "ancrel.9195.desc"
	picture = GFX_evt_cold_barren
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9196
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9200 }
			}
			33 = {
				fleet_event = { id = ancrel.9205}
			}
			33 = {
				fleet_event = { id = ancrel.9210 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9196 }
	}
}

# Stage 3 - Alt. 1 - Hidden in Plain Sight
fleet_event = {
	id = ancrel.9200
	title = "ancrel.9200.name"
	desc = "ancrel.9200.desc"
	picture = GFX_evt_dead_city
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = localised_aurora_borealis
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = INCREDIBLE
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
		}
	}
}

# Stage 3 - Alt. 2 - Look to the Heavens for Answers
fleet_event = {
	id = ancrel.9205
	title = "ancrel.9205.name"
	desc = "ancrel.9205.desc"
	picture = GFX_evt_shrouded_planet
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = localised_aurora_borealis
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = OOPS
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
		}
	}
}

# Stage 3 - Alt. 3 - Song of the Solitaire
fleet_event = {
	id = ancrel.9210
	title = "ancrel.9210.name"
	desc = "ancrel.9210.desc"
	picture = GFX_evt_animal_wildlife
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = localised_aurora_borealis
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = GOODBYE
		owner = {
			add_modifier = {
					modifier = anthem_of_aurora
					days = -1
			}
		}
	}
}

### Archaeology: Warmer Climates

# Stage 1 - Nobody Home
fleet_event = {
	id = ancrel.9215
	title = "ancrel.9215.name"
	desc = "ancrel.9215.desc"
	picture = GFX_evt_dead_city
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Down We Go
fleet_event = {
	id = ancrel.9220
	title = "ancrel.9220.name"
	desc = "ancrel.9220.desc"
	picture = GFX_evt_derelict_interior
	show_sound = event_big_door_opening

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9221
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9225 }
			}
			33 = {
				fleet_event = { id = ancrel.9230}
			}
			33 = {
				fleet_event = { id = ancrel.9235 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9221 }
	}
}

# Stage 3 - Alt. 1 - The Deep Sleep
fleet_event = {
	id = ancrel.9225
	title = "ancrel.9225.name"
	desc = "ancrel.9225.desc"
	picture = GFX_evt_clones
	show_sound = event_screams

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = UNFORTUNATE
		owner = {
			if = {
				limit = {
					has_tech_option = tech_colonization_3
				}
				add_tech_progress = {
					tech = tech_colonization_3
					progress = 0.50
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_colonization_3 }
					can_research_technology = tech_colonization_3
				}
				add_research_option = tech_colonization_3
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

# Stage 3 - Alt. 2 - Fatal Heat Wave
fleet_event = {
	id = ancrel.9230
	title = "ancrel.9230.name"
	desc = "ancrel.9230.desc"
	picture = GFX_evt_molten
	show_sound = event_screams

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = OOPS
		owner = {
			if = {
				limit = {
					has_tech_option = tech_volcano
				}
				add_tech_progress = {
					tech = tech_volcano
					progress = 0.50
				}
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			else_if = {
				limit = {
					is_nomadic = no
					NOT = { has_technology = tech_volcano }
				}
				add_research_option = tech_volcano
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			else_if = {
				limit = {
					is_nomadic = yes
				}
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

# Stage 3 - Alt. 3 - Cold and Alone
fleet_event = {
	id = ancrel.9235
	title = "ancrel.9235.name"
	desc = "ancrel.9235.desc"
	picture = GFX_evt_cold_barren
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			if = {
				limit = {
					is_machine_empire = yes
				}
				if = {
					limit = {
						has_tech_option = tech_unity_of_purpose
					}
					add_tech_progress = {
						tech = tech_unity_of_purpose
						progress = 0.25
					}
				}
				else_if = {
					limit = {
						NOT = { has_technology = tech_unity_of_purpose }
					}
					add_research_option = tech_unity_of_purpose
					add_tech_progress = {
						tech = tech_unity_of_purpose
						progress = 0.1
					}
				}
				else = {
					add_monthly_resource_mult = {
						resource = society_research
						value = @tier4researchreward
						min = @tier4researchmin
						max = @tier4researchmax
					}
				}
			}
			else_if = {
				limit = {
					is_hive_empire = yes
				}
				if = {
					limit = {
						has_tech_option = tech_unity_of_purpose
					}
					add_tech_progress = {
						tech = tech_unity_of_purpose
						progress = 0.25
					}
				}
				else_if = {
					limit = {
						NOT = { has_technology = tech_unity_of_purpose }
					}
					add_research_option = tech_unity_of_purpose
					add_tech_progress = {
						tech = tech_unity_of_purpose
						progress = 0.1
					}
				}
				else = {
					add_monthly_resource_mult = {
						resource = society_research
						value = @tier4researchreward
						min = @tier4researchmin
						max = @tier4researchmax
					}
				}
			}
			else = {
				if = {
					limit = {
						has_tech_option = tech_artificial_moral_codes
					}
					add_tech_progress = {
						tech = tech_artificial_moral_codes
						progress = 0.25
					}
				}
				else_if = {
					limit = {
						NOT = { has_technology = tech_artificial_moral_codes }
					}
					add_research_option = tech_artificial_moral_codes
					add_tech_progress = {
						tech = tech_artificial_moral_codes
						progress = 0.1
					}
				}
				else = {
					add_monthly_resource_mult = {
						resource = society_research
						value = @tier4researchreward
						min = @tier4researchmin
						max = @tier4researchmax
					}
				}
			}
		}
	}

	option = {
		name = GOODBYE
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.9235.b.evopred
	}
}

### Archaeology: The Phoenix Collective

# Stage 1 - Defined Steps
fleet_event = {
	id = ancrel.9240
	title = "ancrel.9240.name"
	desc = "ancrel.9240.desc"
	picture = GFX_evt_dead_city
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Same Old, Same Old
fleet_event = {
	id = ancrel.9245
	title = "ancrel.9245.name"
	desc = "ancrel.9245.desc"
	picture = GFX_evt_alien_ruins
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Death/Rebirth
fleet_event = {
	id = ancrel.9250
	title = "ancrel.9250.name"
	desc = "ancrel.9250.desc"
	picture = GFX_evt_unity_symbol
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 4 - Random Outcome
fleet_event = {
	id = ancrel.9251
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9255 }
			}
			33 = {
				fleet_event = { id = ancrel.9260}
			}
			33 = {
				fleet_event = { id = ancrel.9265 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9251 }
	}
}

# Stage 4 - Alt. 1 - A Cycle Disturbed
fleet_event = {
	id = ancrel.9255
	title = "ancrel.9255.name"
	desc = "ancrel.9255.desc"
	picture = GFX_evt_atmospheric_entry
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = UNFORTUNATE
		owner = {
			if = {
				limit = {
					has_tech_option = tech_colonization_3
				}
				add_tech_progress = {
					tech = tech_colonization_3
					progress = 0.50
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_colonization_3 }
					can_research_technology = tech_colonization_3
				}
				add_research_option = tech_colonization_3
				add_tech_progress = {
					tech = tech_colonization_3
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_refinery
						has_tech_option = tech_archaeo_refinery
					}
					can_research_technology = tech_archaeo_refinery
				}
				add_research_option = tech_archaeo_refinery
				add_tech_progress = {
					tech = tech_archaeo_refinery
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

# Stage 4 - Alt. 2 - Rise Above
fleet_event = {
	id = ancrel.9260
	title = "ancrel.9260.name"
	desc = "ancrel.9260.desc"
	picture = GFX_evt_burning_settlement
	show_sound = event_screams

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = ASTOUNDING
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_resource = { rare_crystals = 150 }
			add_resource = { exotic_gases = 150 }
			add_resource = { volatile_motes = 150 }
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_refinery
						has_tech_option = tech_archaeo_refinery
					}
					can_research_technology = tech_archaeo_refinery
				}
				add_research_option = tech_archaeo_refinery
				add_tech_progress = {
					tech = tech_archaeo_refinery
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

# Stage 4 - Alt. 3 - Will Rise Once More
fleet_event = {
	id = ancrel.9265
	title = "ancrel.9265.name"
	desc = "ancrel.9265.desc"
	picture = GFX_evt_animal_wildlife
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_refinery
						has_tech_option = tech_archaeo_refinery
					}
					can_research_technology = tech_archaeo_refinery
				}
				add_research_option = tech_archaeo_refinery
				add_tech_progress = {
					tech = tech_archaeo_refinery
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

### Archaeology: The Grand Herald

# Stage 1 - In High Spirits
fleet_event = {
	id = ancrel.9270
	title = "ancrel.9270.name"
	desc = "ancrel.9270.desc"
	picture = GFX_evt_dead_city
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - The Testament of Omen
fleet_event = {
	id = ancrel.9275
	title = "ancrel.9275.name"
	desc = "ancrel.9275.desc"
	picture = GFX_evt_unspeakable_horror
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - The Creed of Servitude
fleet_event = {
	id = ancrel.9280
	title = "ancrel.9280.name"
	desc = "ancrel.9280.desc"
	picture = GFX_evt_alien_ruins
	show_sound = event_machinery

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 4 - The Hymn of Following
fleet_event = {
	id = ancrel.9285
	title = "ancrel.9285.name"
	desc = "ancrel.9285.desc"
	picture = GFX_evt_alien_propaganda
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 5 - The Pilgrimage of Last Days
fleet_event = {
	id = ancrel.9290
	title = "ancrel.9290.name"
	desc = "ancrel.9290.desc"
	picture = GFX_evt_alien_cavemen
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = pilgrimage_last_days
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 6 - Random Outcome
fleet_event = {
	id = ancrel.9291
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9295 }
			}
			33 = {
				fleet_event = { id = ancrel.9300}
			}
			33 = {
				fleet_event = { id = ancrel.9305 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9291 }
	}
}

# Stage 6 - Alt. 1 - The Ark of Legacy
fleet_event = {
	id = ancrel.9295
	title = "ancrel.9295.name"
	desc = "ancrel.9295.desc"
	picture = GFX_evt_relic_shipyard
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = SPLENDID
		small_artifact_reward = yes
		create_grand_herald = yes
	}
}

# Stage 6 - Alt. 2 - The Guardian of Entirety
fleet_event = {
	id = ancrel.9300
	title = "ancrel.9300.name"
	desc = "ancrel.9300.desc"
	picture = GFX_evt_relic_shipyard
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = SPLENDID
		small_artifact_reward = yes
		create_grand_herald = yes
	}
}

# Stage 6 - Alt. 3 - The Promise of Deliverance
fleet_event = {
	id = ancrel.9305
	title = "ancrel.9305.name"
	desc = "ancrel.9305.desc"
	picture = GFX_evt_relic_shipyard
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = SPLENDID
		small_artifact_reward = yes
		create_grand_herald = yes
	}
}

### Archaeology: Hive Coral

# Stage 1 - Surface Piercers
fleet_event = {
	id = ancrel.9310
	title = "ancrel.9310.name"
	desc = "ancrel.9310.desc"
	picture = GFX_evt_ocean
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Current Makers
fleet_event = {
	id = ancrel.9315
	title = "ancrel.9315.name"
	desc = "ancrel.9315.desc"
	picture = GFX_evt_continental
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9316
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9320 }
			}
			33 = {
				fleet_event = { id = ancrel.9325}
			}
			33 = {
				fleet_event = { id = ancrel.9330 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9316 }
	}
}

# Stage 3 - Alt. 1 - The Hive Coral
fleet_event = {
	id = ancrel.9320
	title = "ancrel.9320.name"
	desc = "ancrel.9320.desc"
	picture = GFX_evt_ocean
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			if = {
				limit = {
					has_tech_option = tech_colonization_2
				}
				add_tech_progress = {
					tech = tech_colonization_2
					progress = 0.25
				}
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_colonization_2 }
				}
				add_research_option = tech_colonization_2
				add_tech_progress = {
					tech = tech_colonization_2
					progress = 0.1
				}
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}

	option = {
		name = INTERESTING
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.9320.b.evopred
	}
}

# Stage 3 - Alt. 2 - Bio-Savior
fleet_event = {
	id = ancrel.9325
	title = "ancrel.9325.name"
	desc = "ancrel.9325.desc"
	picture = GFX_evt_ocean
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			if = {
				limit = {
					has_tech_option = tech_colonization_2
				}
				add_tech_progress = {
					tech = tech_colonization_2
					progress = 0.25
				}
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_colonization_2 }
				}
				add_research_option = tech_colonization_2
				add_tech_progress = {
					tech = tech_colonization_2
					progress = 0.1
				}
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}

	option = {
		name = FASCINATING
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.9320.b.evopred
		owner = {
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = molluscoid }
		}
	}
}

# Stage 3 - Alt. 3 - Welcoming Committee
fleet_event = {
	id = ancrel.9330
	title = "ancrel.9330.name"
	desc = "ancrel.9330.desc"
	picture = GFX_evt_ocean
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			if = {
				limit = {
					has_tech_option = tech_ecological_adaptation
				}
				add_tech_progress = {
					tech = tech_ecological_adaptation
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_ecological_adaptation }
				}
				add_research_option = tech_ecological_adaptation
				add_tech_progress = {
					tech = tech_ecological_adaptation
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}

	option = {
		name = UNFORTUNATE
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.9320.b.evopred
		owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small } }
	}
}

### Archaeology: Orbital Rain

# Stage 1 - Wounds on the Ocean Floor
fleet_event = {
	id = ancrel.9335
	title = "ancrel.9335.name"
	desc = "ancrel.9335.desc"
	picture = GFX_evt_ocean
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Otherworldly Waters
fleet_event = {
	id = ancrel.9340
	title = "ancrel.9340.name"
	desc = "ancrel.9340.desc"
	picture = GFX_evt_continental
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9341
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9345 }
			}
			33 = {
				fleet_event = { id = ancrel.9350 }
			}
			33 = {
				fleet_event = { id = ancrel.9355 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9341 }
	}
}

# Stage 3 - Alt. 1 - Current Events
fleet_event = {
	id = ancrel.9345
	title = "ancrel.9345.name"
	desc = "ancrel.9345.desc"
	picture = GFX_evt_ocean
	show_sound = event_metal_fatigue

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = UNFORTUNATE
		owner = {
			if = {
				limit = {
					has_tech_option = tech_toxic_kelp
				}
				add_tech_progress = {
					tech = tech_toxic_kelp
					progress = 0.8
				}
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			else_if = {
				limit = {
					is_nomadic = no
					NOT = { has_technology = tech_toxic_kelp }
				}
				add_research_option = tech_toxic_kelp
				add_tech_progress = {
					tech = tech_toxic_kelp
					progress = 0.5
				}
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

# Stage 3 - Alt. 2 - Submerged Storage
fleet_event = {
	id = ancrel.9350
	title = "ancrel.9350.name"
	desc = "ancrel.9350.desc"
	picture = GFX_evt_ocean
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = PECULIAR
		owner = {
			if = {
				limit = {
					has_tech_option = tech_ecological_adaptation
				}
				add_tech_progress = {
					tech = tech_ecological_adaptation
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_ecological_adaptation }
				}
				add_research_option = tech_ecological_adaptation
				add_tech_progress = {
					tech = tech_ecological_adaptation
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

# Stage 3 - Alt. 3 - Climate Control
fleet_event = {
	id = ancrel.9355
	title = "ancrel.9355.name"
	desc = "ancrel.9355.desc"
	picture = GFX_evt_glitchy_matrix
	show_sound = event_power_down

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = INCREDIBLE
		owner = {
			if = {
				limit = {
					has_tech_option = tech_terrestrial_sculpting
				}
				add_tech_progress = {
					tech = tech_terrestrial_sculpting
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					is_nomadic = no
					NOT = { has_technology = tech_terrestrial_sculpting }
				}
				add_research_option = tech_terrestrial_sculpting
				add_tech_progress = {
					tech = tech_terrestrial_sculpting
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

### Archaeology: Fossilized Jellyfish

# Stage 1 - Island Tunnels
fleet_event = {
	id = ancrel.9360
	title = "ancrel.9360.name"
	desc = "ancrel.9360.desc"
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_landing_ship
		BIOSHIP_PICTURE = GFX_evt_bioship_landing
	}
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Tunnels Everywhere
fleet_event = {
	id = ancrel.9365
	title = "ancrel.9365.name"
	desc = "ancrel.9365.desc"
	picture = GFX_evt_continental
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9366
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9370 }
			}
			33 = {
				fleet_event = { id = ancrel.9375 }
			}
			33 = {
				fleet_event = { id = ancrel.9380 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9366 }
	}
}

# Stage 3 - Alt. 1 - Frozen Jelly
fleet_event = {
	id = ancrel.9370
	title = "ancrel.9370.name"
	desc = "ancrel.9370.desc"
	picture = GFX_evt_arctic
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = rock_jellies
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = UNFORTUNATE
		owner = {
			add_resource = { exotic_gases = 250 }
		}
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.9370.b.evopred
		owner = {
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = aquatic }
			add_resource = { exotic_gases = 250 }
		}
	}
}

# Stage 3 - Alt. 2 - Preposterous Snooze
fleet_event = {
	id = ancrel.9375
	title = "ancrel.9375.name"
	desc = "ancrel.9375.desc"
	picture = GFX_evt_microscopic_life
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			if = {
				limit = {
					has_tech_option = tech_vitality_boosters
				}
				add_tech_progress = {
					tech = tech_vitality_boosters
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_vitality_boosters }
				}
				add_research_option = tech_vitality_boosters
				add_tech_progress = {
					tech = tech_vitality_boosters
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			give_specimen = {
				key = rock_jellies
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = PECULIAR
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.9370.b.evopred
	}
}

# Stage 3 - Alt. 3 - Big Ones Couldn't Cope
fleet_event = {
	id = ancrel.9380
	title = "ancrel.9380.name"
	desc = "ancrel.9380.desc"
	picture = GFX_evt_ocean
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = rock_jellies
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = INTERESTING
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.9370.b.evopred
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}
}

### Archaeology: Popular Rock

# Stage 1 - Hello / Goodbye
fleet_event = {
	id = ancrel.9385
	title = "ancrel.9385.name"
	desc = "ancrel.9385.desc"
	picture = GFX_evt_asteroid_field
	show_sound = event_big_door_opening

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Random Outcome
fleet_event = {
	id = ancrel.9386
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9390 }
			}
			33 = {
				fleet_event = { id = ancrel.9395 }
			}
			33 = {
				fleet_event = { id = ancrel.9400 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9386 }
	}
}

# Stage 2 - Alt. 1 - Stepping Stone
fleet_event = {
	id = ancrel.9390
	title = "ancrel.9390.name"
	desc = "ancrel.9390.desc"
	picture = GFX_evt_ancient_records
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = FASCINATING
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}
}

# Stage 2 - Alt. 2 - Deep Space Depot
fleet_event = {
	id = ancrel.9395
	title = "ancrel.9395.name"
	desc = "ancrel.9395.desc"
	picture = GFX_evt_resource_cache
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = EXCELLENT
		owner = {
			add_resource = { alloys = 500 }
			add_resource = { exotic_gases = 150 }
			add_resource = { volatile_motes = 150 }
		}
	}
}

# Stage 2 - Alt. 3 - Rise and Shine
fleet_event = {
	id = ancrel.9400
	title = "ancrel.9400.name"
	desc = "ancrel.9400.desc"
	picture = GFX_evt_asteroid_approaching_planet
	show_sound = event_power_down

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = PECULIAR
		owner = {
			if = {
				limit = {
					has_tech_option = tech_cryostasis_2
				}
				add_tech_progress = {
					tech = tech_cryostasis_2
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					is_nomadic = no
					NOT = { has_technology = tech_cryostasis_2 }
				}
				add_research_option = tech_cryostasis_2
				add_tech_progress = {
					tech = tech_cryostasis_2
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
		}
	}
}

### Archaeology: Strange Flows

# Stage 1 - Signs of Resistance
fleet_event = {
	id = ancrel.9405
	title = "ancrel.9405.name"
	desc = "ancrel.9405.desc"
	picture = GFX_evt_molten
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - That's So Metal
fleet_event = {
	id = ancrel.9410
	title = "ancrel.9410.name"
	desc = "ancrel.9410.desc"
	picture = GFX_evt_star_yellow
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Random Outcome
fleet_event = {
	id = ancrel.9411
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = ancrel.9415 }
			}
			33 = {
				fleet_event = { id = ancrel.9420 }
			}
			33 = {
				fleet_event = { id = ancrel.9425 }
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.9411 }
	}
}

# Stage 3 - Alt. 1 - Wake of the Neutron Star
fleet_event = {
	id = ancrel.9415
	title = "ancrel.9415.name"
	desc = "ancrel.9415.desc"
	picture = GFX_evt_star_neutron
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = ASTOUNDING
		owner = {
			if = {
				limit = {
					has_tech_option = tech_volcano
				}
				add_tech_progress = {
					tech = tech_volcano
					progress = 0.8
				}
			}
			else_if = {
				limit = {
					is_nomadic = no
					NOT = { has_technology = tech_volcano }
				}
				add_research_option = tech_volcano
				add_tech_progress = {
					tech = tech_volcano
					progress = 0.25
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_titan_beam
						has_tech_option = tech_archaeo_titan_beam
					}
				}
				add_research_option = tech_archaeo_titan_beam
				add_tech_progress = {
					tech = tech_archaeo_titan_beam
					progress = 0.25
				}
			}
		}
	}
}

# Stage 3 - Alt. 2 - Zapped!
fleet_event = {
	id = ancrel.9420
	title = "ancrel.9420.name"
	desc = "ancrel.9420.desc"
	picture = GFX_evt_planet_beam
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = INCREDIBLE
		owner = {
			if = {
				limit = {
					has_tech_option = tech_disruptors_2
				}
				add_tech_progress = {
					tech = tech_disruptors_2
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_disruptors_2 }
				}
				add_research_option = tech_disruptors_2
				add_tech_progress = {
					tech = tech_disruptors_2
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_titan_beam
						has_tech_option = tech_archaeo_titan_beam
					}
				}
				add_research_option = tech_archaeo_titan_beam
				add_tech_progress = {
					tech = tech_archaeo_titan_beam
					progress = 0.25
				}
			}
		}
	}
}

# Stage 3 - Alt. 3 - For Science!
fleet_event = {
	id = ancrel.9425
	title = "ancrel.9425.name"
	desc = "ancrel.9425.desc"
	picture = GFX_evt_gray_gooed_planet
	show_sound = event_power_down

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = INTERESTING
		owner = {
			if = {
				limit = {
					has_tech_option = tech_alloys_2
				}
				add_tech_progress = {
					tech = tech_alloys_2
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					NOT = { has_technology = tech_alloys_2 }
				}
				add_research_option = tech_alloys_2
				add_tech_progress = {
					tech = tech_alloys_2
					progress = 0.1
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			if = {
				limit = {
					NOR = {
						has_technology = tech_archaeo_titan_beam
						has_tech_option = tech_archaeo_titan_beam
					}
				}
				add_research_option = tech_archaeo_titan_beam
				add_tech_progress = {
					tech = tech_archaeo_titan_beam
					progress = 0.25
				}
			}
		}
	}
}


# Arcane Deciphering Events
country_event = {
	id = ancrel.10000
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		random_list = {
			30 = { country_event = { id = ancrel.10001 } }
			25 = { country_event = { id = ancrel.10002 } }
			25 = { country_event = { id = ancrel.10003 } }
			20 = {
				modifier = {
					factor = 2
					has_ascension_perk = ap_archaeoengineers
				}
				grant_random_fe_building = yes
			}
		}
	}
}

country_event = {
	id = ancrel.10001
	title = "ancrel.10001.name"
	desc = "ancrel.10001.desc"
	picture = GFX_evt_ancient_records

	is_triggered_only = yes

	option = {
		name = "FASCINATING"
		locked_random_list = {
			10 = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			10 = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
			10 = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
	}
}

country_event = {
	id = ancrel.10002
	title = "ancrel.10002.name"
	desc = "ancrel.10002.desc"
	picture = GFX_evt_ancient_records

	is_triggered_only = yes

	option = {
		name = "FASCINATING"
		add_modifier = {
			modifier = "arcane_insight"
			days = 1800
		}
	}
}

country_event = {
	id = ancrel.10003
	title = "ancrel.10003.name"
	desc = "ancrel.10003.desc"
	picture = GFX_evt_ancient_records

	is_triggered_only = yes

	option = {
		name = "FASCINATING"
		locked_random_list = {
			10 = {
				add_random_research_option = {
					add_progress = 0.20
					area = engineering
					ignore_prereqs = no
					fail_effects = {
						add_monthly_resource_mult = {
							resource = engineering_research
							value = @tier3researchreward
							min = @tier3researchmin
							max = @tier3researchmax
						}
					}
				}
			}
			10 = {
				add_random_research_option = {
					add_progress = 0.20
					area = physics
					ignore_prereqs = no
					fail_effects = {
						add_monthly_resource_mult = {
							resource = physics_research
							value = @tier3researchreward
							min = @tier3researchmin
							max = @tier3researchmax
						}
					}
				}
			}
			10 = {
				add_random_research_option = {
					add_progress = 0.20
					area = society
					ignore_prereqs = no
					fail_effects = {
						add_monthly_resource_mult = {
							resource = society_research
							value = @tier3researchreward
							min = @tier3researchmin
							max = @tier3researchmax
						}
					}
				}
			}
		}
	}
}

#country_event = {
#	id = ancrel.10004
#	title = "ancrel.10004.name"
#	desc = "ancrel.10004.nanoforge"
#	picture = GFX_evt_ancient_records
#
#	is_triggered_only = yes
#
#	option = {
#		name = "EXCELLENT"
#
#		hidden_effect = {
#			owner = {
#				change_variable = { which = nano_forge_build_count value = 1 }
#				change_variable = { which = nano_forge_upgrade_count value = 1 }
#				set_country_flag = nano_forge_can_build
#			}
#		}
#	}
#}
#
#country_event = {
#	id = ancrel.10005
#	title = "ancrel.10004.name"
#	desc = "ancrel.10004.skydome"
#	picture = GFX_evt_ancient_records
#
#	is_triggered_only = yes
#
#	option = {
#		name = "EXCELLENT"
#
#		hidden_effect = {
#			owner = {
#				change_variable = { which = skydome_build_count value = 1 }
#				change_variable = { which = skydome_upgrade_count value = 1 }
#				set_country_flag = skydome_can_build
#			}
#		}
#	}
#}
#
#country_event = {
#	id = ancrel.10006
#	title = "ancrel.10004.name"
#	desc = "ancrel.10004.dimensional_fabricator"
#	picture = GFX_evt_ancient_records
#
#	is_triggered_only = yes
#
#	option = {
#		name = "EXCELLENT"
#
#		hidden_effect = {
#			owner = {
#				change_variable = { which = dimensional_fabricator_build_count value = 1 }
#				change_variable = { which = dimensional_fabricator_upgrade_count value = 1 }
#				set_country_flag = dimensional_fabricator_can_build
#			}
#		}
#	}
#}
#
#country_event = {
#	id = ancrel.10007
#	title = "ancrel.10004.name"
#	desc = "ancrel.10004.affluence_center"
#	picture = GFX_evt_ancient_records
#
#	is_triggered_only = yes
#
#	option = {
#		name = "EXCELLENT"
#
#		hidden_effect = {
#			owner = {
#				change_variable = { which = affluence_center_build_count value = 1 }
#				change_variable = { which = affluence_center_upgrade_count value = 1 }
#				set_country_flag = affluence_center_can_build
#			}
#		}
#	}
#}
#
#country_event = {
#	id = ancrel.10008
#	title = "ancrel.10004.name"
#	desc = "ancrel.10004.nourishment_center"
#	picture = GFX_evt_ancient_records
#
#	is_triggered_only = yes
#
#	option = {
#		name = "EXCELLENT"
#
#		hidden_effect = {
#			owner = {
#				change_variable = { which = nourishment_center_build_count value = 1 }
#				change_variable = { which = nourishment_center_upgrade_count value = 1 }
#				set_country_flag = nourishment_center_can_build
#			}
#		}
#	}
#}
#
#country_event = {
#	id = ancrel.10009
#	title = "ancrel.10004.name"
#	desc = "ancrel.10004.class_4_singularity"
#	picture = GFX_evt_ancient_records
#
#	is_triggered_only = yes
#
#	option = {
#		name = "EXCELLENT"
#
#		hidden_effect = {
#			owner = {
#				change_variable = { which = class_4_singularity_build_count value = 1 }
#				change_variable = { which = class_4_singularity_upgrade_count value = 1 }
#				set_country_flag = class_4_singularity_can_build
#			}
#		}
#	}
#}

# Find military applications
country_event = {
	id = ancrel.10010
	title = "ancrel.10010.name"
	desc = "ancrel.10010.desc"
	picture = GFX_evt_engineering_research

	is_triggered_only = yes

	option = {
		name = "artifact_find_military_application_army"
		custom_tooltip = "artifact_find_military_application_army_desc"
		trigger = {	is_machine_empire = no }
		add_modifier = {
			modifier = "artifact_find_military_application_army"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_military_application_army_machine"
		custom_tooltip = "artifact_find_military_application_army_machine_desc"
		trigger = {	is_machine_empire = yes }
		add_modifier = {
			modifier = "artifact_find_military_application_army_machine"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_military_application_shield_damage"
		custom_tooltip = "artifact_find_military_application_shield_damage_desc"
		add_modifier = {
			modifier = "artifact_find_military_application_shield_damage"
			days = 1800
		}
		ai_chance = {
			factor = 5
			modifier = {
				factor = 2
				is_preferred_weapons = weapon_type_energy
			}
			modifier = {
				factor = 10
				has_global_flag = extradimensional_invasion_happened
				NOT = { has_global_flag = extradimensional_invasion_defeated }
			}
		}
	}
	option = {
		name = "artifact_find_military_application_armor_damage"
		custom_tooltip = "artifact_find_military_application_armor_damage_desc"
		add_modifier = {
			modifier = "artifact_find_military_application_armor_damage"
			days = 1800
		}
		ai_chance = {
			factor = 5
			modifier = {
				factor = 2
				NOT = { is_preferred_weapons = weapon_type_energy }
			}
			modifier = {
				factor = 10
				has_global_flag = prethoryn_invasion_happened
				NOT = { has_global_flag = prethoryn_invasion_defeated }
			}
		}
	}
	option = {
		name = "marauder.30.e"

		hidden_effect = {
			add_resource = { minor_artifacts = 50 }
			remove_modifier = "artifact_find_applications_cooldown"
		}
	}
}

# Find peaceful applications
country_event = {
	id = ancrel.10020
	title = "ancrel.10020.name"
	desc = "ancrel.10020.desc"
	picture = GFX_evt_society_research

	is_triggered_only = yes

	option = {
		name = "artifact_find_peaceful_application_happy_bios"
		custom_tooltip = "artifact_find_peaceful_application_happy_bios_desc"
		trigger = {
			OR = {
				is_gestalt = no
				has_civic = civic_machine_servitor
			}
		}
		add_modifier = {
			modifier = "artifact_find_peaceful_application_happy_bios"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_peaceful_application_consumer_goods"
		custom_tooltip = "artifact_find_peaceful_application_consumer_goods_desc"
		trigger = {
			OR = {
				is_gestalt = no
				has_civic = civic_machine_servitor
			}
		}
		add_modifier = {
			modifier = "artifact_find_peaceful_application_consumer_goods"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_peaceful_application_amenities"
		custom_tooltip = "artifact_find_peaceful_application_amenities_desc"
		trigger = {	is_regular_empire = yes }
		add_modifier = {
			modifier = "artifact_find_peaceful_application_amenities"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_peaceful_application_amenities_hivemind"
		custom_tooltip = "artifact_find_peaceful_application_amenities_hivemind_desc"
		trigger = {
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		add_modifier = {
			modifier = "artifact_find_peaceful_application_amenities_hivemind"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_peaceful_application_amenities_machine"
		custom_tooltip = "artifact_find_peaceful_application_amenities_machine_desc"
		trigger = {	is_machine_empire = yes }
		add_modifier = {
			modifier = "artifact_find_peaceful_application_amenities_machine"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_peaceful_application_leader_improvement"
		custom_tooltip = "artifact_find_peaceful_application_leader_improvement_desc"
		trigger = {	is_regular_empire = yes }
		add_modifier = {
			modifier = "artifact_find_peaceful_application_leader_improvement"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_peaceful_application_leader_improvement_hivemind"
		custom_tooltip = "artifact_find_peaceful_application_leader_improvement_hivemind_desc"
		trigger = {	is_hive_empire = yes }
		add_modifier = {
			modifier = "artifact_find_peaceful_application_leader_improvement_hivemind"
			days = 1800
		}
	}
	option = {
		name = "artifact_find_peaceful_application_leader_improvement_machine"
		custom_tooltip = "artifact_find_peaceful_application_leader_improvement_machine_desc"
		trigger = {	is_machine_empire = yes }
		add_modifier = {
			modifier = "artifact_find_peaceful_application_leader_improvement_machine"
			days = 1800
		}
	}
	option = {
		name = "marauder.30.e"

		hidden_effect = {
			add_resource = { minor_artifacts = 50 }
			remove_modifier = "artifact_find_applications_cooldown"
		}
	}
}

# Extra tier on Mega Art Installation
country_event = {
	id = "ancrel.10030"
	title = "ancrel.10030.name"
	desc = {
		trigger = {
			OR = {
				is_xenophobe = yes
				is_homicidal = yes
			}
		}
		text = ancrel.10030.phobe.desc
	}
	desc = {
		trigger = {
			NOR = {
				is_xenophobe = yes
				is_homicidal = yes
			}
		}
		text = ancrel.10030.desc
	}
	show_sound = event_mystic_reveal
	picture = GFX_evt_mega_art_installation
	is_triggered_only = yes
	location = FROM

	option = {
		name = EXCELLENT
	}
}

# Irassian Artifact Research Complete
country_event = {
	id = ancrel.9001
	title = ancrel.9001.name

	# Phobe
	desc = {
		trigger = {
			is_xenophobe = yes
		}
		text = ancrel.9001.desc.phobe
	}
	desc = {
		trigger = {
			is_xenophobe = no
		}
		text = ancrel.9001.desc
	}

	picture = GFX_evt_circuitry_modification
	location = from

	is_triggered_only = yes

	option = {
		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_biology
			}
		}

		owner = {
			if = {
				limit = {
					OR = {
						is_machine_empire = no
						has_civic = civic_machine_assimilator
						has_civic = civic_machine_servitor
					}
					NOT = { has_technology = tech_genome_mapping }
				}
				give_technology = { tech = tech_genome_mapping }
			}
			else_if = {
				limit = {
					is_gestalt = no
					NOT = { has_technology = tech_frontier_health }
				}
				give_technology = { tech = tech_frontier_health }
			}
			else_if = {
				limit = {
					is_gestalt = no
					NOT = { has_technology = tech_frontier_hospital }
				}
				give_technology = { tech = tech_frontier_hospital }
			}
			else_if = {
				limit = {
					OR = {
						is_machine_empire = no
						has_civic = civic_machine_assimilator
						has_civic = civic_machine_servitor
					}
					NOT = { has_technology = tech_gene_tailoring }
				}
				add_research_option = tech_gene_tailoring
				add_tech_progress = {
					tech = tech_gene_tailoring
					progress = 0.5
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			add_tech_progress = {
				tech = tech_secrets_irassian
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_irassian_research_completed # biology research and growth speed bonus
			days = -1
		}
	}
}

country_event = {
	id = ancrel.10040
	title = ancrel.10040.name
	desc = ancrel.10040.desc

	picture = GFX_evt_analyzing_artifacts
	location = from

	is_triggered_only = yes

	option = {
		name = progress.2.a.mech # Acknowledged.
	}
}

# Yuht Artifact Research Complete
country_event = {
	id = ancrel.10050
	title = ancrel.10050.name

	# Phobe
	desc = {
		trigger = {
			is_xenophobe = yes
		}
		text = ancrel.10050.desc.1.phobe
	}
	desc = {
		trigger = {
			is_xenophobe = no
		}
		text = ancrel.10050.desc.1
	}

	picture = GFX_evt_animal_wildlife
	location = from

	is_triggered_only = yes

	option = {
		trigger = {
			owner = {
				can_research_technology = tech_colonization_3
				NOT = { has_technology = tech_colonization_3 }
			}
		}

		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_new_worlds
			}
		}

		custom_tooltip = "ancrel.10050.unlock"
		owner = {
			if = {
				limit = {
					NOT = { has_technology = tech_colonization_2 } # Atmospheric Filtering
				}
				give_technology = { tech = tech_colonization_2 }
			}
			else = {
				add_research_option = tech_colonization_3
				add_tech_progress = {
					tech = tech_colonization_3
					progress = 0.5
				}
			}
			add_tech_progress = {
				tech = tech_secrets_yuht
				progress = 0.1
			}
		}
		hidden_effect = {
			set_country_flag = artifact_yuht_research_completed
		}
	}

	option = {
		trigger = {
			owner = {
				OR = {
					has_technology = tech_colonization_3
					NOT = { can_research_technology = tech_colonization_3 }
				}
			}
		}

		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_new_worlds
			}
		}

		custom_tooltip = "ancrel.10050.unlock"
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_yuht
				progress = 0.1
			}
		}
		hidden_effect = {
			set_country_flag = artifact_yuht_research_completed
		}
	}
}

# First League Research Complete
country_event = {
	id = ancrel.10200
	title = ancrel.10200.name

	# Phobe
	desc = {
		trigger = {
			is_xenophobe = yes
		}
		text = ancrel.10200.desc.phobe
	}
	desc = {
		trigger = {
			is_xenophobe = no
		}
		text = ancrel.10200.desc
	}

	picture = GFX_evt_city_planet
	location = from

	is_triggered_only = yes

	option = {
		exclusive_trigger = {
			has_technology = tech_housing_2
		}

		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_industry
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_league
				progress = 0.1
			}
		}
		add_modifier = {
			modifier = artifact_league_research_completed # industry research and building build speed
			days = -1
		}
	}

	option = {
		exclusive_trigger = {
			has_technology = tech_housing_1
			NOT = {
				has_technology = tech_housing_2
			}
		}

		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_industry
			}
		}

		owner = {
			add_research_option = tech_housing_2
			add_tech_progress = {
				tech = tech_housing_2
				progress = 0.5
			}
			add_tech_progress = {
				tech = tech_secrets_league
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_league_research_completed # industry research and building build speed
			days = -1
		}
	}

	option = {
		exclusive_trigger = {
			NOR = {
				has_technology = tech_housing_1
				is_wilderness_empire = yes
			}
		}

		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_industry
			}
		}

		if = {
			limit = {
				is_wilderness_empire = no
			}
			give_technology = { tech = tech_housing_1 }
			add_research_option = tech_housing_2
			add_tech_progress = {
				tech = tech_secrets_league
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_league_research_completed # industry research and building build speed
			days = -1
		}
	}
}

# Cybrex Artifact Research Complete
country_event = {
	id = ancrel.10250
	title = ancrel.10250.name

	desc = {
		trigger = {
			is_individual_machine = no
			OR = {
				has_policy_flag = ai_outlawed
				is_spiritualist = yes
			}
		}
		text = ancrel.10250.desc.antimachine
	}
	desc = {
		trigger = {
			NOR = {
				AND = {
					is_individual_machine = no
					has_policy_flag = ai_outlawed
				}
				AND = {
					is_individual_machine = no
					is_spiritualist = yes
				}
			}
		}
		text = ancrel.10250.desc
	}

	picture = GFX_evt_ringworld
	location = from

	is_triggered_only = yes

	option = {
		exclusive_trigger = {
			has_technology = tech_mega_engineering
		}
		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_voidcraft
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_cybrex
				progress = 0.1
			}
		}
		add_modifier = {
			modifier = artifact_cybrex_research_completed # megastructure build speed
			days = -1
		}
	}

	option = {
		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_voidcraft
			}
		}

		owner = {
			add_research_option = tech_mega_engineering
			add_tech_progress = {
				tech = tech_secrets_cybrex
				progress = 0.1
			}
		}
		add_modifier = {
			modifier = artifact_cybrex_research_completed # megastructure build speed
			days = -1
		}
	}
}

# Vultaum Artifact Research Complete
country_event = {
	id = ancrel.10100
	title = ancrel.10100.name

	desc = {
		trigger = { is_machine_empire = yes	}
		text = ancrel.10100.desc_machine
	}
	desc = {
		trigger = { is_hive_empire = yes }
		text = ancrel.10100.desc_hive
	}
	desc = {
		trigger = {
			is_regular_empire = yes
			is_fanatic_materialist = yes
		}
		text = ancrel.10100.desc_fm
	}
	desc = {
		trigger = {
			is_regular_empire = yes
			is_fanatic_materialist = no
		}
		text = ancrel.10100.desc
	}

	picture = GFX_evt_ancient_databank
	location = from

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			complete_crisis_objective = crisobj_research_thesis
		}
	}

	option = {
		exclusive_trigger = { is_machine_empire = yes }

		name = progress.2.a.mech # Acknowledged.

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_computing
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_vultaum
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_vultaum_research_completed_machine # computer research and assembly speed
			days = -1
		}

		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			custom_tooltip = add_crisis_currency_tt
		}
	}

	option = {
		exclusive_trigger = { is_hive_empire = yes }

		name = story.210.a # Noted.

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_computing
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_vultaum
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_vultaum_research_completed_hive # computer research
			days = -1
		}

		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			custom_tooltip = add_crisis_currency_tt
		}
	}

	option = {
		trigger = {
			owner = {
				is_regular_empire = yes
				is_fanatic_materialist = no
			}
		}

		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_computing
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_vultaum
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_vultaum_research_completed_suppressed # computer research and amenities bonus
			days = -1
		}

		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			custom_tooltip = add_crisis_currency_tt
		}
	}

	option = {
		trigger = {
			owner = { is_fanatic_materialist = yes }
		}

		name = ancrel.10100.option.fm_enough

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_computing
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_vultaum
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_vultaum_research_completed_suppressed # computer research and amenities bonus
			days = -1
		}

		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			custom_tooltip = add_crisis_currency_tt
		}
	}

	option = {
		trigger = {
			owner = {
				is_fanatic_materialist = yes
			}
		}

		name = ancrel.10100.option.fm_delve_deeper

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_computing
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_vultaum
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_vultaum_research_completed_suppressed # computer research and amenities bonus
			days = -1
		}

		enable_special_project = {
			name = "VULTAUM_SECRETS_2"
			location = capital_scope
			owner = ROOT
		}

		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			custom_tooltip = add_crisis_currency_tt
		}
	}
}

country_event = {
	id = ancrel.10110
	title = ancrel.10110.name

	desc = ancrel.10110.desc

	picture = GFX_evt_glitchy_matrix
	location = from

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			complete_crisis_objective = crisobj_research_thesis
		}
	}

	option = {
		name = ancrel.10110.option.fm_suppress # Suppress the findings.
		owner = {
			add_monthly_resource_mult = {
				resource = influence
				value = @tier4influencereward
				min = @tier4influencemin
				max = @tier4influencemax
			}
		}

		random_owned_leader = {
			limit = {
				is_head_of_research = yes
			}
			add_experience = 200

			save_global_event_target_as = leading_vultaum_research_scientist
		}

		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			custom_tooltip = add_crisis_currency_tt
		}

		hidden_effect = {
			random_list = {
				50 = {
					# physicist commits suicide
					country_event = { id = ancrel.10111 days = 5 }
				}
				35 = {
					# physicist gains maniacal and substance abuser
					country_event = { id = ancrel.10112 days = 5 }
				}
				15 = {
					# physicist gains maniacal
					country_event = { id = ancrel.10113 days = 5 }
				}
			}
		}
	}

	option = {
		name = ancrel.10110.option.fm_public # The public deserves to know.
		owner = {
			add_monthly_resource_mult = {
				resource = influence
				value = @tier4influencereward
				min = @tier4influencemin
				max = @tier4influencemax
			}
			add_monthly_resource_mult = {
				resource = unity
				value = @tier5unityreward
				min = @tier5unitymin
				max = @tier5unitymax
			}
		}

		if = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
			}
			custom_tooltip = add_crisis_currency_tt
		}

		random_owned_leader = {
			limit = {
				is_head_of_research = yes
			}
			add_experience = 300

			save_global_event_target_as = leading_vultaum_research_scientist
		}

		custom_tooltip = "artifact_vultaum_research_completed_public_tooltip"
		add_modifier = {
			modifier = artifact_vultaum_research_completed_public # all research, computer research, amenities bonus, unhappiness
			days = -1
		}

		hidden_effect = {
			remove_modifier = artifact_vultaum_research_completed_suppressed

			random_list = {
				35 = {
					# physicist gains maniacal and substance abuser
					country_event = { id = ancrel.10112 days = 5 }
				}
				65 = {
					# physicist gains maniacal
					country_event = { id = ancrel.10113 days = 5 }
				}
			}
		}
	}
}

country_event = {
	id = ancrel.10111
	title = ancrel.10111.name

	desc = ancrel.10111.desc

	picture = GFX_evt_space_funeral
	location = from

	is_triggered_only = yes
	trigger = {
		exists = event_target:leading_vultaum_research_scientist
	}

	option = {
		name = UNFORTUNATE
		event_target:leading_vultaum_research_scientist = {
			kill_leader = { show_notification = no }
		}
	}
}

country_event = {
	id = ancrel.10112
	title = ancrel.10112.name

	desc = ancrel.10112.desc

	picture = GFX_evt_smugglers_in_bar
	location = from

	is_triggered_only = yes
	trigger = {
		exists = event_target:leading_vultaum_research_scientist
	}

	option = {
		name = INTERESTING
		event_target:leading_vultaum_research_scientist = {
			add_or_level_up_veteran_trait_effect = {
				TRAIT = leader_trait_maniacal
			}
			add_trait = {
				trait = leader_trait_substance_abuser
			}
			add_experience = 200
		}
	}
}

country_event = {
	id = ancrel.10113
	title = ancrel.10113.name

	desc = ancrel.10113.desc

	picture = GFX_evt_physics_research
	location = from

	is_triggered_only = yes
	trigger = {
		exists = event_target:leading_vultaum_research_scientist
	}

	option = {
		name = INTERESTING
		event_target:leading_vultaum_research_scientist = {
			add_or_level_up_veteran_trait_effect = {
				TRAIT = leader_trait_maniacal
			}
			add_experience = 200
		}
	}
}

# Baol Artifact Research Complete
country_event = {
	id = ancrel.10300
	title = ancrel.10300.name
	desc = {
		trigger = { has_technology = tech_epigenetic_triggers }
		text = ancrel.10300.desc.terraform
	}
	desc = {
		trigger = {
			NOT = { has_technology = tech_epigenetic_triggers }
		}
		text = ancrel.10300.desc.uplift
	}

	picture = GFX_evt_baol_grunur
	location = from

	is_triggered_only = yes

	option = {
		exclusive_trigger = {
			NOT = { has_technology = tech_epigenetic_triggers }
		}

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_biology
			}
		}

		name = INTERESTING
		owner = {
			give_technology = { tech = tech_epigenetic_triggers }
			add_tech_progress = {
				tech = tech_secrets_baol
				progress = 0.1
			}
		}
		add_modifier = {
			modifier = artifact_baol_research_completed # terraforming speed
			days = -1
		}
	}

	option = {
		exclusive_trigger = {
			owner = {
				has_technology = tech_epigenetic_triggers
				NOT = { has_technology = tech_terrestrial_sculpting }
			}
		}

		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_biology
			}
		}

		owner = {
			give_technology = { tech = tech_terrestrial_sculpting }
			add_tech_progress = {
				tech = tech_secrets_baol
				progress = 0.1
			}
		}
		add_modifier = {
			modifier = artifact_baol_research_completed # terraforming speed bonus
			days = -1
		}
	}

	option = {
		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_biology
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
			add_tech_progress = {
				tech = tech_secrets_baol
				progress = 0.1
			}
		}
		add_modifier = {
			modifier = artifact_baol_research_completed # terraforming speed bonus
			days = -1
		}
	}
}

# Zroni Artifact Research Complete
country_event = {
	id = ancrel.10350
	title = ancrel.10350.name
	desc = ancrel.10350.desc

	picture = GFX_evt_surreal_visions
	location = from

	is_triggered_only = yes

	option = {
		name = INTERESTING

		random_owned_leader = {
			limit = {
				OR = {
					is_councilor_type = councilor_research
					is_councilor_type = councilor_gestalt_cognitive
				}
			}
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_psionics
			}
		}

		owner = {
			if = {
				limit = {
					NOT = { has_technology = tech_psionic_theory } # Psionic Theory
					can_research_technology = tech_psionic_theory
				}
				if = {
					limit = { NOT = { has_tech_option = tech_psionic_theory } }
					add_research_option = tech_psionic_theory
				}
				add_tech_progress = {
					tech = tech_psionic_theory
					progress = 0.2
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier4researchreward
					min = @tier4researchmin
					max = @tier4researchmax
				}
			}
			add_tech_progress = {
				tech = tech_secrets_zroni
				progress = 0.1
			}
		}

		add_modifier = {
			modifier = artifact_zroni_research_completed # psionic research bonus
			days = -1
		}
	}
}

# Broken World
fleet_event = {
	id = ancrel.11000
	title = ancrel.11000.name
	desc = ancrel.11000.desc
	picture = GFX_evt_archaeology_camp
	show_sound = event_mystic_reveal
	location = from

	is_triggered_only = yes

	archaeology = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.11000.a
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.11005
	title = ancrel.11005.name
	desc = ancrel.11005.desc
	picture = GFX_evt_city_ruins
	show_sound = event_mystic_reveal
	location = from

	is_triggered_only = yes

	archaeology = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.11005.a
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.11010
	title = ancrel.11010.name
	desc = ancrel.11010.desc
	picture = GFX_evt_collapsing_roof
	show_sound = event_mystic_reveal
	location = from

	is_triggered_only = yes

	archaeology = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.11010.a
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.11015
	title = ancrel.11015.name
	desc = ancrel.11015.desc
	picture = GFX_evt_ancient_records
	show_sound = event_mystic_reveal
	location = from

	is_triggered_only = yes

	archaeology = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.11015.a
		hidden_effect = {
			from.solar_system = {
				save_event_target_as = eldritch_location
			}
			owner = {
				country_event = {
					id = ancrel.11020
				}
			}
		}
	}
}

# To explode the system, or to not explode the system
country_event = {
	id = ancrel.11020
	title = ancrel.11020.name
	desc = ancrel.11020.desc
	picture = GFX_evt_black_hole

	is_triggered_only = yes

	immediate = {
		event_target:eldritch_location = {
			if = {
				limit = {
					any_system_planet = {
						is_star_class = sc_black_hole
					}
				}
				random_system_planet = {
					limit = { is_planet_class = pc_black_hole }
					save_event_target_as = cosmic_horror_location
				}
			}
			else = {
				save_event_target_as = cosmic_horror_location
			}
		}
	}

	option = {
		name = ancrel.11020.a
		add_monthly_resource_mult = {
			resource = engineering_research
			value = @tier2researchreward
			min = @tier2researchmin
			max = @tier2researchmax
		}
		give_specimen = { key = altar_to_the_elder_one targets = { event_target:cosmic_horror_location } }
		ai_chance = {
			factor = 3
		}
	}

	option = {
		name = ancrel.11020.b
		custom_tooltip = ancrel.11020.tt
		hidden_effect = {
			event_target:eldritch_location = {
				if = {
					limit = {
						NOT = {
							any_system_planet = {
								is_star_class = sc_black_hole
							}
						}
					}
					if = {
						limit = {
							any_fleet_in_system = {
								exists = owner
								is_mobile = yes
								NOT = { is_owned_by = root }
							}
						}
						every_fleet_in_system = {
							limit = {
								exists = owner
								is_mobile = yes
								NOT = { is_owned_by = root }
							}
							owner = {
								if = {
									limit = {
										is_country_type = default
									}
									country_event = {
										id = ancrel.11035
									}
								}
							}
						}
					}
					destroy_star_system = yes
				}
				random_system_planet = {
					limit = { is_planet_class = pc_black_hole }
					set_carrier_flag = black_hole_horror
					create_country = {
						name = "NAME_Eldritch_Horror"
						type = guardian_horror
						flag = {
							icon = {
								category = "zoological"
								file = "flag_zoological_18.dds"
							}
							background = {
								category = "backgrounds"
								file = "00_solid.dds"
							}
							colors={
								"black"
								"black"
								"null"
								"null"
							}
						}
					}
					last_created_country = {
						save_global_event_target_as = eldritch_horror_country
						set_country_flag = eldritch_horror_country
					}
					create_fleet = {
						name = "NAME_Eldritch_Horror"
						settings = {
							spawn_debris = no
							is_boss = yes
						}
						effect = {
							set_owner = event_target:eldritch_horror_country
							create_ship = {
								name = "NAME_Eldritch_Horror"
								design = "NAME_Dimensional_Horror"
								effect = { set_disabled = yes }
							}
							set_location = {
								target = PREV
								distance = 5
								angle = 270
							}
						}
					}
					last_created_fleet = {
						create_ambient_object = {
							type = "horror_spawn_object"
							location = THIS
							use_3d_location = yes
							duration = 10
						}
						fleet_event = { id = leviathans.3220 days = 8 }
					}
				}
			}
		}
		country_event = {
			id = ancrel.11025
			days = 10
		}
		event_target:eldritch_horror_country = {
			set_faction_hostility = {
				target = root
				set_hostile = no
				set_neutral = yes
			}
		}
		ai_chance = {
			factor = 1
		}
	}
}

# Transmissions from the horror
country_event = {
	id = ancrel.11025
	title = "TRANSMISSION"
	desc = ancrel.11025.desc

	diplomatic = yes

	picture_event_data = {
		room = no_video_feed_room
	}

	is_triggered_only = yes

	option = {
		name = ancrel.11025.a
		if = {
			limit = {
				NOT = { exists = event_target:eldritch_location.starbase }
				is_nomadic = no
			}
			custom_tooltip = ancrel.11025.a.tt
			hidden_effect = {
				event_target:eldritch_location = {
					create_starbase = {
						size = starbase_outpost
						owner = root
					}
				}
			}
		}
		country_event = {
			id = ancrel.11027
		}
		add_modifier = {
			modifier = eldritch_horror_mod
			days = -1
		}
	}

	option = {
		name = ancrel.11025.b
		custom_tooltip = ancrel.11025.b.tt
		add_monthly_resource_mult = {
			resource = influence
			value = @tier4influencereward
			min = @tier4influencemin
			max = @tier4influencemax
		}
		hidden_effect = {
			event_target:eldritch_horror_country = {
				set_faction_hostility = {
					target = root
					set_hostile = yes
					set_neutral = no
				}
			}
			country_event = {
				id = ancrel.11030
			}
		}
	}
}

country_event = {
	id = ancrel.11027
	title = "TRANSMISSION"
	desc = ancrel.11027.desc

	diplomatic = yes

	picture_event_data = {
		room = no_video_feed_room
	}

	is_triggered_only = yes

	option = {
		name = ancrel.11027.a
	}
}

country_event = {
	id = ancrel.11030
	title = "TRANSMISSION"
	desc = ancrel.11030.desc

	diplomatic = yes

	picture_event_data = {
		room = no_video_feed_room
	}

	is_triggered_only = yes

	option = {
		name = ancrel.11030.a
	}
}

# Ping Event for other countries
country_event = {
	id = ancrel.11035
	title = ancrel.11035.name
	desc = ancrel.11035.desc
	picture = GFX_evt_black_hole

	is_triggered_only = yes

	fire_only_once = yes

	option = {
		name = ancrel.11035.a
	}
}

# Remove the modifier if the Eldritch Horror disappears
country_event = {
	id = ancrel.11040
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		is_country_type = guardian_horror
		has_country_flag = eldritch_horror_country
		FROMFROM = { is_ship_size = dimensional_horror }
	}

	immediate = {
		every_playable_country = {
			if = {
				limit = {
					has_modifier = eldritch_horror_mod
				}
				remove_modifier = eldritch_horror_mod
			}
		}
	}
	after = {
		from = {
			if = {
				limit = {
					num_owned_planets > 0
					NOT = { has_country_flag = horrific_celebration }
				}
				set_country_flag = horrific_celebration
				generate_parade_city = yes
				start_situation = {
					type = leviathan_celebration_opportunity
					target = event_target:parade_city
					effect = {
						set_situation_flag = celebration_elder_one
						set_situation_flag = standard_unity_reward
					}
				}
			}
		}
	}
}

# Percussive Maintenance / Abandoned Station event 1
fleet_event = {
	id = ancrel.12000
	title = ancrel.12000.name
	desc = ancrel.12000.desc
	picture = GFX_evt_satellite_in_orbit
	show_sound = event_laboratory_sound
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTERESTING
		small_artifact_reward = yes
	}
}

# Percussive Maintenance / Abandoned Station event 2
fleet_event = {
	id = ancrel.12005
	title = ancrel.12005.name
	desc = {
		trigger = { owner = { is_gestalt = no } }
		text = ancrel.12005.desc
	}
	desc = {
		trigger = { owner = { is_gestalt = yes } }
		text = ancrel.12005.desc.gestalt
	}
	picture = GFX_evt_ancient_databank
	show_sound = event_power_down
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.12005.A
		leader = {
			if = {
				limit = {
					NOR = {
						has_trait = leader_trait_meticulous
						has_trait = leader_trait_meticulous_2
					}
				}
				add_trait = {
					trait = leader_trait_meticulous
				}
			}
		}
		allow = {
			leader = {
				NOR = {
					has_trait = leader_trait_maniacal
					has_trait = leader_trait_carefree
					has_trait = leader_trait_maniacal_2
					has_trait = leader_trait_carefree_2
				}
			}
		}
	}
	option = {
		name = ancrel.12005.B
		leader = {
			if = {
				limit = { NOT = { has_trait = leader_trait_percussive_maintainer } }
				add_trait = {
					trait = leader_trait_percussive_maintainer
				}
			}
		}
		custom_tooltip = percussive_maintainer_tooltip
		ai_chance = {
			factor = 5
		}
	}
}

# Percussive Maintenance / Abandoned Station event 3
fleet_event = {
	id = ancrel.12010
	title = ancrel.12010.name
	desc = ancrel.12010.desc
	picture = GFX_evt_physics_research
	show_sound = event_bad_omen
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.12010.A
		small_artifact_reward = yes
	}
}

# Percussive Maintenance / Abandoned Station event 4
fleet_event = {
	id = ancrel.12015
	title = ancrel.12015.name
	desc = ancrel.12015.desc
	picture = GFX_evt_interstellar_assembly
	show_sound = event_screams
	location = from

	archaeology = yes
	is_triggered_only = yes
	specimen = rudari_death_laser_prototype

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.12015.A
		owner = {
			add_modifier = {
				modifier = rudari_death_laser
			}
		}
		large_artifact_reward = yes
	}
}

# The Library event 1
fleet_event = {
	id = ancrel.12020
	title = ancrel.12020.name
	desc = ancrel.12020.desc
	picture = GFX_evt_archaeological_dig
	show_sound = event_wind_ruins
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTERESTING
		small_artifact_reward = yes
	}
}

# The Library event 2
fleet_event = {
	id = ancrel.12025
	title = ancrel.12025.name
	desc = ancrel.12025.desc
	picture = GFX_evt_underground_city
	show_sound = event_ghost_town
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = first_contact.5.A
		small_artifact_reward = yes
	}
}

# The Library event 3
fleet_event = {
	id = ancrel.12030
	title = ancrel.12030.name
	desc = {
		trigger = {
			owner = {
				is_lithoid = no
				is_robotic_species = no
			}
		}
		text = ancrel.12030.desc.normal
	}
	desc = {
		trigger = {
			owner = {
				is_robotic_species = yes
			}
		}
		text = ancrel.12030.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_lithoid = yes
			}
		}
		text = ancrel.12030.desc.lithoid
	}
	picture = GFX_evt_disease_outbreak
	show_sound = event_screams
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.2047.a
		small_artifact_reward = yes
	}
}

# The Library event 4
fleet_event = {
	id = ancrel.12035
	title = ancrel.12035.name
	desc = ancrel.12035.desc
	picture = GFX_evt_city_planet
	show_sound = event_door_opening
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		small_artifact_reward = yes
	}
}

# The Library event 5
fleet_event = {
	id = ancrel.12040
	title = ancrel.12040.name
	desc = {
		trigger = {
			has_leviathans = yes
			exists = event_target:curator_enclave_country
			owner = { has_communications = event_target:curator_enclave_country }
		}
		text = ancrel.12040.desc.curators
	}
	desc = {
		trigger = {
			has_leviathans = yes
			exists = event_target:curator_enclave_country
			NOT = { owner = { has_communications = event_target:curator_enclave_country } }
		}
		text = ancrel.12040.desc.meet_curators
	}
	desc = {
		trigger = {
			OR = {
				has_leviathans = no
				NOT = { exists = event_target:curator_enclave_country }
			}
		}
		text = ancrel.12040.desc.no_curators
	}
	picture = GFX_evt_death_from_above
	show_sound = event_mystic_reveal
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
		if = {
			limit = {
				has_leviathans = yes
				exists = event_target:curator_enclave_country
				NOT = { owner = { has_communications = event_target:curator_enclave_country } }
			}
			closest_system = {
				limit = { has_star_flag = guardians_curators_system }
				save_event_target_as = curator_poi
			}
		}
	}

	after = {
		from = { set_site_progress_locked = no }

		if = {
			limit = {
				has_leviathans = yes
				exists = event_target:curator_enclave_country
				NOT = { owner = { has_communications = event_target:curator_enclave_country } }
				NOT = { owner = { has_event_chain = find_the_curators } }
			}
			owner = {
				begin_event_chain = {
					event_chain = find_the_curators
					target = this
				}
				hidden_effect = {
					create_point_of_interest = {
						id = poi_curator_location
						name = poi_curator_location
						desc = poi_curator_location_desc
						event_chain = find_the_curators
						location = event_target:curator_poi
					}
				}
			}
		}
		owner = {
			give_specimen = {
				key = illanii_archives
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = ancrel.12040.A
		allow = {
			owner = { is_pacifist = no }
		}
		owner = {
			add_modifier = {
				modifier = killer_librarian_organism
			}
		}
		large_artifact_reward = yes
	}

	option = {
		trigger = {
			owner = { has_origin = origin_evolutionary_predators }
		}
		name = ancrel.12040.c.evopred
		owner = {
			add_modifier = {
				modifier = killer_librarian_organism
			}
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = large }
		}
		large_artifact_reward = yes
	}
	option = {
		name = ancrel.12040.B

		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}

		from.planet = {
			hidden_effect = { clear_deposits = yes }
			add_deposit = d_society_8
			add_deposit = d_engineering_8
			add_deposit = d_physics_8
		}
		large_artifact_reward = yes
	}
}

### Surveillance Supercomputer
#Spawn event
event = {
	id = ancrel.12050
	is_triggered_only = yes
	hide_window = yes

	immediate = {
		random_list = {
			2 = { } # nothing
			1 = {
				random_rim_system = {
					limit = { is_mindwardens_story_system = no }
					system_event = { id = ancrel.12055 }
				}
			}
			1 = {
				modifier = {
					factor = 0
					has_first_contact_dlc = no
				}
				modifier = { #Chosen don't spawn on lowest difficulty
					factor = 0
					is_difficulty = 0
				}
				modifier = { #Chosen don't spawn if you have turned off all other AI
					factor = 0
					num_ai_empires_setting = 0
				}
				random_rim_system = {
					limit = { is_mindwardens_story_system = no }
					system_event = { id = fircon.3500 }
				}
			}
		}
	}
}

system_event = {
	id = ancrel.12055
	is_triggered_only = yes
	hide_window = yes

	immediate = {
		spawn_system = {
			min_distance >= 50
			max_distance <= 100
			direction = rimwards
			initializer = surveillance_supercomputer_system
			hyperlane = no
		}
	}
}

# First enter system (on_entering_system_first_time)
# Scope = Ship
# From = System
# FromFrom = Country
ship_event = {
	id = ancrel.12060
	title = ancrel.12060.name
	desc = ancrel.12060.desc
	picture = GFX_evt_machine_space_battle
	show_sound = event_red_alert
	location = from
	is_triggered_only = yes

	trigger = {
		from = {
			has_star_flag = surveillance_supercomputer_system
			any_fleet_in_system = {
				owner = { has_country_flag = surveillance_bots }
			}
		}
	}

	option = {
		name = BATTLESTATIONS
	}
}

# Defeat them (on_fleet_destroyed_perp)
# This = owner of fleet 1 (combatant)
# From = owner of fleet 2 (destroyed)
# FromFrom = fleet 1
# FromFromFrom = fleet 2
country_event = {
	id = ancrel.12065
	title = ancrel.12065.name
	desc = ancrel.12065.desc
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_ship_in_orbit_3
		BIOSHIP_PICTURE = GFX_evt_bio_ships_orbiting
	}
	show_sound = event_space_battle
	location = fromfrom
	is_triggered_only = yes

	trigger = {
		from = {
			has_country_flag = surveillance_bots
			count_owned_fleet = {
				limit = {
					NOT = { is_same_value = root.fromfromfrom }
				}
				count = 0
			}
		}
	}

	option = { name = SPLENDID }
}

# Surveillance Supercomputer event 1
fleet_event = {
	id = ancrel.12070
	title = ancrel.12070.name
	desc = ancrel.12070.desc
	picture = GFX_evt_busy_spaceport
	show_sound = event_ghost_town
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTERESTING
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.12075
	title = ancrel.12075.name
	desc = ancrel.12075.desc
	picture = GFX_evt_satellite_in_orbit
	show_sound = event_laboratory_sound
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = PECULIAR
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.12080
	title = ancrel.12080.name
	desc = ancrel.12080.desc
	picture = GFX_evt_robot_assembly_plant
	show_sound = event_scanner
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DISTURBING
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.12085
	title = ancrel.12085.name
	desc = ancrel.12085.desc
	picture = GFX_evt_spy_orb
	show_sound = event_activating_unknown_technology
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = KEEP_SEARCHING
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.12090
	title = ancrel.12090.name
	desc = ancrel.12090.desc
	picture = GFX_evt_ai_planet
	show_sound = event_mystic_reveal
	location = from

	archaeology = yes
	is_triggered_only = yes
	specimen = galactic_megadrive

	immediate = {
		from = { set_site_progress_locked = yes }

		owner = {
			create_species = { # Machine Intelligence or Individualist Machine
				class = MACHINE
				name = NAME_Surveillance_Bots
				namelist = "MACHINE1"
				portrait = random
				traits = {
					ideal_planet_class = pc_machine
					trait = trait_machine_unit
					trait = trait_robot_logic_engines
					trait = trait_robot_double_jointed
					trait = trait_robot_enhanced_memory
					trait = trait_robot_durable
					trait = trait_robot_custom_made
					trait = trait_robot_repurposed_hardware
				}
				effect = {
					set_species_homeworld = from.planet
					save_event_target_as = new_machines
				}
			}

			create_species = { # Regular empires
				class = ROBOT
				name = NAME_Surveillance_Bots
				namelist = "MACHINE1"
				portrait = random
				traits = {
					ideal_planet_class = pc_machine
					trait = trait_mechanical
					trait = trait_robot_logic_engines
					trait = trait_robot_double_jointed
					trait = trait_robot_enhanced_memory
					trait = trait_robot_durable
					trait = trait_robot_custom_made
					trait = trait_robot_repurposed_hardware
				}
				effect = {
					set_species_homeworld = from.planet
					save_event_target_as = new_robots
				}
			}
		}
	}

	after = {
		from = { set_site_progress_locked = no }
		large_artifact_reward = yes
	}

	option = {
		name = ancrel.12090.A
		trigger = {
			owner = { is_machine_empire = yes }
		}
		from.planet = {
			change_pc = pc_machine
			hidden_effect = {
				set_timed_carrier_flag = {
					flag = ignore_ai_building_limitations
					days = 1
				}
				colony = {
					set_owner = root.owner
					add_building = building_machine_major_capital
					add_building = building_machine_assembly_complex
					while = {
						count = 10
						add_district = district_nexus
					}
					while = {
						count = 5
						add_district = district_nexus_1
						add_district = district_nexus_2
					}
					add_zone = {
						district = district_nexus_1
						zone = zone_energy_nexus
					}
					add_zone = {
						district = district_nexus_2
						zone = zone_minerals_nexus
					}
					while = {
						count = 80
						create_pop_group = {
							species = event_target:new_machines
						}
					}
				}
			}
		}

		hidden_effect = {
			owner = {
				random = {
					chance = 50
					country_event = { id = ancrel.12095 days = 30 }
				}
			}
		}
	}
	option = {
		name = ancrel.12090.B
		solar_system = {
			spawn_megastructure = {
				type = spy_orb_restored
				planet = from.planet
				graphical_culture = root.owner
			}
		}
	}
	option = { # Machine Intelligence or Individualist Machine
		name = ancrel.12090.C
		trigger = {
			owner = {
				OR = {
					is_machine_empire = yes
					is_individual_machine = yes
				}
			}
		}
		custom_tooltip = ancrel.12090.C.machine.tooltip
		hidden_effect = {
			owner = {
				while = {
					count = 80
					random_owned_planet = {
						create_pop_group = {
							species = event_target:new_machines
						}
						weights = {
							base = 10
							modifier = {
								factor = 0.5
								free_housing <= 0
								num_free_districts = {
									type = any
									value <= 1
								}
							}
						}
					}
				}
			}
		}

		hidden_effect = {
			owner = {
				random = {
					chance = 50
					country_event = { id = ancrel.12095 days = 30 }
				}
			}
		}
	}
	option = { # Regular empires
		name = ancrel.12090.C
		trigger = {
			owner = {
				is_machine_empire = no
				is_individual_machine = no
			}
		}
		allow = {
			owner = { has_policy_flag = robots_allowed }
		}
		custom_tooltip = ancrel.12090.C.mechanical.tooltip
		hidden_effect = {
			owner = {
				while = {
					count = 80
					random_owned_planet = {
						create_pop_group = {
							species = event_target:new_robots
						}
						weights = {
							base = 10
							modifier = {
								factor = 0.5
								free_housing <= 0
								num_free_districts = {
									type = any
									value <= 1
								}
							}
						}
					}
				}
			}
		}

		hidden_effect = {
			owner = {
				random = {
					chance = 50
					country_event = { id = ancrel.12095 days = 30 }
				}
			}
		}
	}
	option = {
		name = ancrel.12090.D
		trigger = {
			owner = { is_spiritualist = yes }
		}
		from.planet = {
			add_deposit = d_alloys_25
		}
		hidden_effect = {
			owner = {
				random = {
					chance = 50
					country_event = { id = ancrel.12095 days = 30 }
				}
			}
		}
	}
	option = {
		name = ancrel.12090.E
		custom_tooltip = ancrel.12090.E.tooltip
		allow = {
			owner = { is_spiritualist = no }
		}
		hidden_effect = {
			from.planet = {
				create_country = {
					type = default
					name = "NAME_Repurposed_Surveillance_Network"
					species = event_target:new_machines
					ethos = {
						ethic = ethic_gestalt_consciousness
					}
					authority = auth_machine_intelligence
					civics = {
						civic = civic_machine_built_to_last
						civic = civic_machine_builder
					}

					effect = {
						prev.solar_system.starbase = {
							set_owner = prev
						}
						give_starting_resources_effect = yes
						add_resource = {
							unity = 1000000
						}
						copy_techs_from = { target = root.owner }
						set_subject_of = {
							who = root.owner
						}
					}
				}
			}
			from.colony = {
				change_pc = pc_machine
				set_timed_carrier_flag = {
					flag = ignore_ai_building_limitations
					days = 1
				}
				while = {
					count = 80
					create_pop_group = {
						species = event_target:new_machines
					}
				}
				while = {
					count = 10
					add_district = district_nexus
				}
				while = {
					count = 2
					add_district = district_nexus_1
					add_district = district_nexus_2
				}
				add_zone = {
					district = district_nexus_1
					zone = zone_energy_nexus
				}
				add_zone = {
					district = district_nexus_2
					zone = zone_minerals_nexus
				}
				add_building = building_machine_major_capital
				add_building = building_machine_assembly_complex
				solar_system = {
					if = {
						limit = {
							NOR = {
								has_megastructure = gateway_0
								has_megastructure = gateway_final
							}
						}
						spawn_megastructure = { #a bit weird, but otherwise they will probably be trapped here forever
							type = gateway_ruined
							random_pos = yes
							orbit_angle = 360
						}
					}
				}
			}
			owner = {
				random = {
					chance = 50
					country_event = { id = ancrel.12095 days = 30 }
				}
			}
		}
	}
}

# Follow-up, sometimes
country_event = {
	id = ancrel.12095
	diplomatic_title = BLANK_STRING
	title = TRANSMISSION
	desc = ancrel.12095.desc
	is_triggered_only = yes
	diplomatic = yes
	picture_event_data = {
		room = no_video_feed_room
	}

	option = {
		name = ancrel.12095.A
	}
	option = {
		name = ancrel.12095.B
	}
	after = {
		custom_tooltip = ancrel.12095.tooltip
		hidden_effect = {
			set_global_flag = endgame_crisis_early_start
			every_playable_country = {
				limit = {
					NOT = { is_same_value = root }
				}
				country_event = { id = ancrel.12100 }
			}
		}
	}
}

country_event = {
	id = ancrel.12100
	diplomatic_title = BLANK_STRING
	title = TRANSMISSION
	desc = ancrel.12095.desc
	is_triggered_only = yes
	diplomatic = yes
	picture_event_data = {
		room = no_video_feed_room
	}

	option = {
		name = ancrel.12100.A
		custom_tooltip = ancrel.12095.tooltip
	}
}

#Cool Reception
country_event = {
	id = ancrel.13000
	title = ancrel.13000.name
	desc = ancrel.13000.desc
	is_triggered_only = yes
	show_sound = event_ship_explosion
	picture = GFX_evt_exploding_ship
	auto_opens = yes
	trackable = yes
	location = fromfrom


	trigger = {
		from = { has_country_flag = polaris_country }
	}
	immediate = {
		set_global_flag = polaris_seen
	}

	option = {
		name = CURIOUS
	}
}
# Stage 1
fleet_event = {
	id = ancrel.13005
	title = ancrel.13005.name
	desc = ancrel.13005.desc
	picture = GFX_evt_outpost
	show_sound = event_dig_site
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = acnrel.13005.a
		small_artifact_reward = yes
	}
}
# Stage 2
fleet_event = {
	id = ancrel.13010
	title = ancrel.13010.name
	desc = ancrel.13010.desc
	picture = GFX_evt_discovered_hidden_door
	show_sound = event_dig_site
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTERESTING
		small_artifact_reward = yes
	}
}

# Stage 3
fleet_event = {
	id = ancrel.13015
	title = ancrel.13015.name
	desc = ancrel.13015.desc
	picture = GFX_evt_in_the_dark
	show_sound = event_dig_site
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = EXCELLENT
		small_artifact_reward = yes
	}
}

#Tombola
fleet_event = {
	id = ancrel.13006
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
   		random_list = {
			50 = { fleet_event = { id = ancrel.13020 } }
			50 = { fleet_event = { id = ancrel.13025 } }
		}
	}

	after = {
		from = { expire_site_event = ancrel.13006 }
	}
}

# Stage 4
fleet_event = {
	id = ancrel.13020
	title = ancrel.13020.name
	desc = ancrel.13020.desc
	picture = GFX_evt_circuitry_modification
	show_sound = event_dig_site
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	option = {
		name = ancrel.13020.a
		medium_artifact_reward = yes
		owner = {
			add_modifier = {
				modifier = polaris_biology_modifier
			}
		}
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.13020.b.evopred
		medium_artifact_reward = yes
		owner = {
			add_modifier = {
				modifier = polaris_biology_modifier
			}
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = medium TYPE = plantoid }
		}
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}
}

# Stage 4 alternate
fleet_event = {
	id = ancrel.13025
	title = ancrel.13020.name
	desc = {
		trigger = {
			owner = {
				is_machine_empire = no
			}
		}
		text = ancrel.13025.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = ancrel.13025.desc.machine
	}
	picture = GFX_evt_microscopic_life
	show_sound = event_dig_site
	location = from

	archaeology = yes

	is_triggered_only = yes

	specimen = vault_of_polaris

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	option = {
		name = ancrel.13020.a
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.13020.b.evopred
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		medium_artifact_reward = yes
		owner = {
			if = {
				limit = { is_machine_empire = no }
				owner = {
					switch = {
						trigger = has_technology
						tech_colonization_4 = {
							add_tech_option_or_research_effect = {
   								TECH = tech_colonization_5
   								PROGRESS = 0.6
   								CATEGORY = society_research
							}
						}
						tech_colonization_3 = {
							add_tech_option_or_research_effect = {
   								TECH = tech_colonization_4
   								PROGRESS = 0.7
   								CATEGORY = society_research
							}
						}
						tech_colonization_2 = {
							add_tech_option_or_research_effect = {
   								TECH = tech_colonization_3
   								PROGRESS = 0.80
   								CATEGORY = society_research
							}
						}
						tech_colonization_1 = {
							add_tech_option_or_research_effect = {
   								TECH = tech_colonization_2
   								PROGRESS = 0.99
   								CATEGORY = society_research
							}
						}
						default = {
							add_tech_option_or_research_effect = {
   								TECH = tech_colonization_1
   								PROGRESS = 0.6
   								CATEGORY = society_research
							}
						}
					}
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier5researchreward
					min = @tier5researchmin
					max = @tier5researchmax
				}
			}
		}
	}
}

### Archaeology: Fumongus

# Stage 1 - Where the Water Went
fleet_event = {
	id = ancrel.13100
	title = "ancrel.13100.name"
	desc = "ancrel.13100.desc"
	picture = GFX_evt_warm_barren
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = CURIOUS
		if = {
			limit = { has_ancrel = yes }
			small_artifact_reward = yes
		}
		else = {
			owner = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
		}
	}
}

# Stage 2 - Bunker
fleet_event = {
	id = ancrel.13105
	title = "ancrel.13105.name"
	desc = "ancrel.13105.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		if = {
			limit = { has_ancrel = yes }
			small_artifact_reward = yes
		}
		else = {
			owner = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
		}
	}
}

# Stage 3 - Bunker - Reactivating Terminals
fleet_event = {
	id = ancrel.13110
	title = "ancrel.13110.name"
	desc = "ancrel.13110.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTERESTING
		if = {
			limit = { has_ancrel = yes }
			small_artifact_reward = yes
		}
		else = {
			owner = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
		}
	}
}

# Stage 4 - Exploring Databanks
fleet_event = {
	id = ancrel.13115
	title = "ancrel.13115.name"
	desc = "ancrel.13115.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = REMARKABLE
		if = {
			limit = { has_ancrel = yes }
			small_artifact_reward = yes
		}
		else = {
			owner = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
		}
	}
}

# Stage 5 - Dry no More
fleet_event = {
	id = ancrel.13120
	title = "ancrel.13120.name"
	desc = "ancrel.13120.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = FASCINATING
		hidden_effect = {
			owner = {
				country_event = {
					id = ancrel.13125
					days = 60
				}
			}
		}
	}
}

#Ending Picker
country_event = {
	id = ancrel.13125
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				owner = { has_country_flag = fumongus_colony_complete }
			}
			country_event = { id = ancrel.13130 }
		}
		else = {
			country_event = { id = ancrel.13135 }
		}
	}
}

# Stage 6a - Fumongus Forever
country_event = {
	id = ancrel.13135
	title = "ancrel.13135.name"
	desc = "ancrel.13135.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_dig_site

	is_triggered_only = yes

	option = {
		name = ancrel.13135.a
		trigger = {
			NOT = { has_origin = origin_evolutionary_predators }
		}
		owner = {
			add_modifier = {
				modifier = mycelial_network_modifier
				days = -1
			}
			add_modifier = {
				modifier = fumongus_authoritarian
				years = 20
			}
		}
		#flag for anomaly hookup
		hidden_effect = {
			owner = {
				set_global_flag = fumongus_active
				set_global_flag = fumongus_resolved
				set_country_flag = fumongus_ours
			}
		}
	}

	option = {
		name = ancrel.13135.a.evopred
		trigger = {
			has_origin = origin_evolutionary_predators
		}
		owner = {
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = large TYPE = fungoid }
			add_modifier = {
				modifier = mycelial_network_modifier
				days = -1
			}
			add_modifier = {
				modifier = fumongus_authoritarian
				years = 20
			}
		}
		#flag for anomaly hookup
		hidden_effect = {
			owner = {
				set_global_flag = fumongus_active
				set_global_flag = fumongus_resolved
				set_country_flag = fumongus_ours
			}
		}
	}

	option = {
		name = ancrel.13135.b
		add_monthly_resource_mult = {
			resource = unity
			value = @tier5unityreward
		}
		#flag for anomaly hookup
		owner = {
			set_global_flag = fumongus_dismantled
			set_global_flag = fumongus_resolved
			set_country_flag = fumongus_ours
		}
	}
}

# Stage 6b - Fear the Old Shroom
country_event = {
	id = ancrel.13130
	title = "ancrel.13130.name"
	desc = "ancrel.13130.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_dig_site

	is_triggered_only = yes

	option = {
		name = ancrel.13130.a
		trigger = {
			NOT = { has_origin = origin_evolutionary_predators }
		}
		owner = {
			add_modifier = {
				modifier = mycelial_network_modifier
				days = -1
			}
			add_modifier = {
				modifier = fumongus_authoritarian
				years = 20
			}
		}
		#flag for anomaly hookup
		owner = {
			set_global_flag = fumongus_active
			set_global_flag = fumongus_resolved
			set_country_flag = fumongus_ours
		}
	}

	option = {
		name = ancrel.13135.a.evopred
		trigger = {
			has_origin = origin_evolutionary_predators
		}
		owner = {
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = large TYPE = fungoid }
			add_modifier = {
				modifier = mycelial_network_modifier
				days = -1
			}
			add_modifier = {
				modifier = fumongus_authoritarian
				years = 20
			}
		}
		#flag for anomaly hookup
		owner = {
			set_global_flag = fumongus_active
			set_global_flag = fumongus_resolved
			set_country_flag = fumongus_ours
		}
	}

	option = {
		name = ancrel.13130.b
			add_monthly_resource_mult = {
				resource = unity
				value = @tier3unityreward
				min = @tier3unitymin
				max = @tier3unitymax
			}
		#flag for anomaly hookup
		owner = {
			set_global_flag = fumongus_dismantled
			set_global_flag = fumongus_resolved
			set_country_flag = fumongus_ours
		}
	}
}

# Rage Sage

fleet_event = {
	id = ancrel.14001
	title = "ancrel.14001.name"
	desc = "ancrel.14001.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.14002
	title = "ancrel.14002.name"
	desc = "ancrel.14002.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.14003
	title = "ancrel.14003.name"
	desc = "ancrel.14003.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.14003.a
		small_artifact_reward = yes
		hidden_effect = {
			random_list = {
				10 = { fleet_event = { id = ancrel.14004 } }
				10 = { fleet_event = { id = ancrel.14005 } }
			}
		}
	}

	option = {
		name = ancrel.14003.b
		small_artifact_reward = yes
		hidden_effect = {
			random_list = {
				10 = { fleet_event = { id = ancrel.14004 } }
				10 = { fleet_event = { id = ancrel.14005 } }
			}
		}
	}
}

fleet_event = {
	id = ancrel.14004
	title = "ancrel.14004.name"
	desc = "ancrel.14004.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	option = {
		name = ancrel.14004.a
		small_artifact_reward = no
		# small_influence_reward = yes
	}
}

fleet_event = {
	id = ancrel.14005
	title = "ancrel.14005.name"
	desc = "ancrel.14005.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	option = {
		name = ancrel.14005.a
		small_artifact_reward = no
		# small_influence_reward = yes
	}
}

fleet_event = {
	id = ancrel.14006
	title = "ancrel.14006.name"
	desc = "ancrel.14006.desc"
	picture = GFX_evt_derelict_interior
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = yes }
	}

	option = {
		name = ancrel.14006.a
		custom_tooltip = ancrel.14006.a.tooltip
		small_artifact_reward = yes
		owner = {
			add_modifier = {
				modifier = rage_sage_soldiers
				days = -1
			}
		}
	}

	option = {
		name = ancrel.14006.b
		custom_tooltip = ancrel.14006.b.tooltip
		owner = {
			small_artifact_reward = yes
			add_resource = { influence = 100 }
		}
	}
}

### Tiyanki Space Graveyard ###

# Stage 1
fleet_event = {
	id = ancrel.14100
	title = "ancrel.14100.name"
	desc = {
		trigger = {
			owner = {
				NOT = { has_civic = civic_reanimated_armies }
			}
		}
		text = "ancrel.14100.desc"
	}
	desc = {
		trigger = {
			owner = {
				has_civic = civic_reanimated_armies
			}
		}
		text = "ancrel.14100.necro.desc"
	}
	picture = GFX_evt_gray_goo
	show_sound = event_whispering
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Stage 2
fleet_event = {
	id = ancrel.14200
	title = "ancrel.14200.name"
	desc = "ancrel.14200.desc"
	picture = GFX_evt_genetic_modification
	show_sound = event_laboratory_sound
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Stage 3
fleet_event = {
	id = ancrel.14300
	title = "ancrel.14300.name"
	desc = "ancrel.14300.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_dig_site
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Stage 4
fleet_event = {
	id = ancrel.14400
	title = "ancrel.14400.name"
	desc = {
		trigger = {
			owner = {
				NOT = { has_country_flag = encountered_elderly_tiyanki }
			}
		}
		text = "ancrel.14400.desc"
	}
	desc = {
		trigger = {
			owner = {
				has_country_flag = encountered_elderly_tiyanki
			}
		}
		text = "ancrel.14400.matriarch.desc"
	}
	picture = GFX_evt_unspeakable_horror
	show_sound = event_dig_site
	location = from

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = FASCINATING
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Stage 4: the Core - alternate endings
fleet_event = {
	id = ancrel.14500
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			5 = { fleet_event = { id = ancrel.14510 } } #core intact
			2 = {
				modifier = {
					factor = 2
					owner = {
						OR = { # higher chances of having smashed the core by accident if owner is aggressive
							is_militarist = yes
							is_homicidal = yes
							is_xenophobe = yes
						}
					}
				}
				fleet_event = { id = ancrel.14520 } #core destroyed
			}
		}
	}

	after = {
		from = { expire_site_event = ancrel.14500 }
	}
}

# Stage 4a: intact core
fleet_event = {
	id = ancrel.14510
	title = "ancrel.14510.name"
	desc = {
		trigger = {
			owner = {
				NOT = { has_country_flag = encountered_elderly_tiyanki }
			}
		}
		text = "ancrel.14510.desc"
	}
	desc = {
		trigger = {
			owner = {
				has_country_flag = encountered_elderly_tiyanki
			}
		}
		text = "ancrel.14510.matriarch.desc"
	}
	picture = GFX_evt_ancient_tiyanki
	show_sound = event_space_whale

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = { # Dissect
		name = ancrel.14510.a
		trigger = {
			owner = {
				is_xenophile = no
				NOT = { has_origin = origin_evolutionary_predators }
			}
		}
		owner = {
			add_modifier = {
				modifier = tiyanki_butcher
				days = -1
			}
		}
	}

	option = { # Study
		name = ancrel.14510.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier5researchreward
				min = @tier5researchmin
				max = @tier5researchmax
			}
		}
	}

	option = { # Leave
		name = ancrel.14510.c
		trigger = {
			owner = {
				is_spiritualist = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier4unityreward
				min = @tier4unitymin
				max = @tier4unitymax
			}
		}
	}

	option = { # Sell
		name = ancrel.14510.d
		trigger = {
			owner = {
				has_country_flag = curator_intro
			}
		}
		owner = {
			add_resource = { energy = 5000 }
		}
	}

	option = { # Evolutionary Predator Interaction
		name = ancrel.14510.e
		trigger = {
			owner = {
				has_origin = origin_evolutionary_predators
			}
		}
		owner = {
			add_modifier = {
				modifier = tiyanki_butcher
				days = -1
			}
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = large }
		}
	}
}

# Stage 4b: ruined core
fleet_event = {
	id = ancrel.14520
	title = "ancrel.14520.name"
	desc = "ancrel.14520.desc"
	picture = GFX_evt_ancient_tiyanki
	show_sound = event_whispering

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = UNFORTUNATE
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}
}

# Random event: Environmental Contamination
fleet_event = {
	id = ancrel.14910
	title = "ancrel.14910.name"
	desc = "ancrel.14910.desc"
	picture = GFX_evt_zro_5
	show_sound = event_screams

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = site_setback
		fromfrom = { add_stage_clues = -1 }
		leader = {
			add_trait = {
				trait = leader_trait_paranoid
			}
		}
	}

	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = ancrel.14910.b.evopred
		fromfrom = { add_stage_clues = -1 }
		owner = {
			give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small }
		}
		leader = {
			add_trait = {
				trait = leader_trait_paranoid
			}
		}
	}
}

# The Mask of Transformation

# Spawn Site
carrier_event = {
	id = ancrel.15010
	title = "ancrel.15010.name"
	desc = "ancrel.15010.desc"
	picture = GFX_evt_archaeology_camp
	show_sound = event_dig_site

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		pop_amount > 0
		OR = {
			is_planet_class = pc_tropical
			is_planet_class = pc_gaia
			is_planet_class = pc_continental
		}
		NOT = { exists = archaeological_site }
		NOR = {
			has_global_flag = arc_transformation
			has_carrier_flag = colony_event
			has_planet_flag = suppress_archaeological_sites
		}
	}

	is_triggered_only = yes

	immediate = {
		set_global_flag = arc_transformation
		set_carrier_flag = colony_event
	}

	option = {
		name = CURIOUS
		create_archaeological_site = site_transformation_dig
	}
}

# Stage 1 - Welcome to the Jungle

fleet_event = {
	id = ancrel.15000
	title = "ancrel.15000.name"
	desc = "ancrel.15000.desc"
	picture = GFX_evt_tropical
	show_sound = event_alien_nature

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.15000.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Stage 2 - Psionic Metamorphosis

fleet_event = {
	id = ancrel.15001
	title = "ancrel.15001.name"
	desc = "ancrel.15001.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.15001.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Stage 3 - The Cave

fleet_event = {
	id = ancrel.15002
	title = "ancrel.15002.name"
	desc = "ancrel.15002.desc"
	picture = GFX_evt_hidden_door
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.15002.a
		owner = {
			if = {
				limit = { has_ancrel = yes }
				custom_tooltip = minor_artifacts_found
				add_resource = { minor_artifacts = 10 }
			}
			else = {
				add_resource = { minerals = 200 }
			}
		}
	}
}

# Stage 4 - The Pillar

fleet_event = {
	id = ancrel.15003
	title = "ancrel.15003.name"
	desc = "ancrel.15003.desc"
	picture = GFX_evt_ancient_records
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.15003.a
		owner = {
			if = {
				limit = { has_ancrel = yes }
				custom_tooltip = minor_artifacts_found
				add_resource = { minor_artifacts = 20 }
			}
			else = {
				add_resource = { alloys = 200 }
			}
		}
		hidden_effect = {
			fleet_event = {
				id = ancrel.15005
				days = 30
				random = 20
			}
		}
	}

	option = {
		name = ancrel.15003.b
		owner = {
			if = {
				limit = { has_ancrel = yes }
				custom_tooltip = minor_artifacts_found
				add_resource = { minor_artifacts = 10 }
			}
			else = {
				add_resource = { alloys = 400 }
			}
		}
		hidden_effect = {
			fleet_event = {
				id = ancrel.15004
				days = 30
				random = 20
			}
		}
	}
}

# Epilogue A - Shattered!

fleet_event = {
	id = ancrel.15004
	title = "ancrel.15005.name"
	desc = "ancrel.15005.desc"
	picture = GFX_evt_ice_asteroids
	show_sound = event_dig_site

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.15005.a
		owner = {
			add_resource = { minerals = 1000 }
			add_resource = { rare_crystals = 200 }
		}
	}
}

# Epilogue B - The Mask of Transformation

fleet_event = {
	id = ancrel.15005
	title = "ancrel.15004.name"
	desc = "ancrel.15004.desc"
	picture = GFX_evt_ancient_artifact
	show_sound = event_mystic_reveal

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
		owner = {
			give_specimen = {
				key = the_mask_of_transformation
				targets = { root.fromfrom.planet }
			}
		}
	}

	option = {
		name = ancrel.15004.a
		owner = {
			add_modifier = {
				modifier = mask_of_transformation
			}
		}
	}
}

# Space Shanty

fleet_event = {
	id = ancrel.15021
	title = "ancrel.15021.name"
	desc = "ancrel.15021.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = INTRIGUING
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.15022
	title = "ancrel.15022.name"
	desc = "ancrel.15022.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.15022.a
		small_artifact_reward = yes
	}
}

fleet_event = {
	id = ancrel.15023
	title = "ancrel.15023.name"
	desc = "ancrel.15023.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.15023.a
		small_artifact_reward = no
	}
}

fleet_event = {
	id = ancrel.15024
	title = "ancrel.15024.name"
	desc = "ancrel.15024.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = ancrel.15024.a
		small_artifact_reward = no
	}
}

fleet_event = {
	id = ancrel.15025
	title = "ancrel.15025.name"
	desc = "ancrel.15025.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_metal_fatigue

	archaeology = yes

	is_triggered_only = yes

	specimen = fish_in_the_sea_sheet_music

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = yes }
	}

	option = {
		name = ancrel.15025.a
		small_artifact_reward = no
		owner = {
			add_modifier = {
				modifier = harmonious_crew
				days = -1
			}
		}
	}
}
