###############################
# Narrative Progression Events
# by Maximilian Olbers
###############################

namespace = story

# KEY TO FLAGS:
	# Story1	microbial life
	# Story2	(remnants of) complex space-dwelling life, e.g. 'Gigantic Skeleton'
	# Story3	non-sapient, animal life
	# Story4	pre-sapient life
	# Story5	(remnants of) sapient life, i.e. arc site remains
	# Story6	pre-FTL society
	# Story7	FTL civilization
	# Story8	Leviathan

### 1 - Microbial, simple plant life
country_event = {
	id = story.1
	title = story.1.name
	desc = {
		trigger = {
			switch = {
				trigger = has_ethic
				ethic_fanatic_spiritualist = { text = story.1.desc.spiri }
				ethic_fanatic_xenophobe = { text = story.1.desc.phobe }
				ethic_fanatic_xenophile = { text = story.1.desc.phile }
				ethic_spiritualist = { text = story.1.desc.spiri }
				ethic_xenophobe = { text = story.1.desc.phobe }
				ethic_xenophile = { text = story.1.desc.phile }
				ethic_gestalt_consciousness = {
					if = {
						limit = { has_civic = civic_machine_terminator }
						text = story.1.desc.term
					}
					else = { text = story.1.desc.gesta }
				}
				default = { text = story.1.desc }
			}
		}
	}
	desc = {
		exclusive_trigger = { has_origin = origin_evolutionary_predators }
		text = story.1.desc.evopred
	}

	picture = GFX_evt_news_room
	show_sound = event_scanner

	is_triggered_only = yes

	trigger = {
		is_country_type = default
		NOR = {
			has_country_flag = Story1
			has_country_flag = Story2
			has_country_flag = Story3
			has_country_flag = Story4
			has_country_flag = Story5
			has_country_flag = Story6
			has_country_flag = Story7
			has_country_flag = StoryFirstRewardGiven
		}
	}

	immediate = {
		if = {
			limit = { NOT = { has_country_flag = first_alien_life } }
			set_country_flag = first_alien_life
		}
		set_country_flag = StoryFirst
		set_country_flag = Story1
	}

	option = {
		exclusive_trigger = { has_valid_civic = civic_machine_exploration_protocol }
		name = fircon.machine_exploration_protocol
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_sensors_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Materialist
	option = {
		trigger = {
			owner = { is_materialist = yes }
		}
		name = "story.contact_report.materialist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_science_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Spiritualist
	option = {
		trigger = {
			owner = { is_spiritualist = yes }
		}
		name = "story.contact_report.spiritualist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_cryostasis_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Militarist
	option = {
		trigger = {
			owner = { is_militarist = yes }
		}
		name = "story.contact_report.militarist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_doctrine_fleet_size_1
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Pacifist
	option = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		name = "story.contact_report.pacifist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_bio_reactor
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Authoritarian
	option = {
		trigger = {
			owner = { is_authoritarian = yes }
		}
		name = "story.contact_report.authoritarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_administrative_ai
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Xenophile
	option = {
		trigger = {
			owner = { is_xenophile = yes }
		}
		name = "story.contact_report.xenophile"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_xeno_diplomacy
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Xenophobe
	option = {
		trigger = {
			owner = { is_xenophobe = yes }
		}
		name = "story.contact_report.xenophobe"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_ground_defense_planning
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Egalitarian
	option = {
		trigger = {
			owner = { is_egalitarian = yes }
		}
		name = "story.contact_report.egalitarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_hyper_drive_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Hive
	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_hive"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_mining_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}
	# Machine
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_machine"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_alloys_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}

	after = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirstRewardGiven } }
			set_country_flag = StoryFirstRewardGiven
		}
		hidden_effect = {
			if = {
				limit = {
					very_first_contact_paragon = yes
				}
				set_country_flag = first_contact_protocol_event_happened
			}
			if = {
				limit = {
					has_origin = origin_fear_of_the_dark
				}
				country_event = { id = origin.6030 }
			}
		}
	}
}

### 2 - Spacers
country_event = {
	id = story.2
	title = story.2.name
	# First / Fallback
	desc = {
		trigger = {
			OR = {
				#fallback
				AND = {
					has_country_flag = StoryFirst
					NOR = {
						is_xenophile = yes
						has_ethic = ethic_gestalt_consciousness
					}
				}
				#first
				NOR = {
					has_country_flag = StoryFirst
					has_ethic = ethic_gestalt_consciousness
				}
			}
		}
		text = story.2.desc
	}
	# Gestalt Consciousness
	desc = {
		trigger = { has_ethic = ethic_gestalt_consciousness }
		text = story.2.desc.gesta
	}
	# Xenophile regardless of status
	desc = {
		trigger = {
			is_xenophile = yes
		}
		text = story.2.desc.phile
	}
	# Followup
	desc = {
		trigger = {
			has_country_flag = Story1
			NOT = { has_ethic = ethic_gestalt_consciousness }
		}
		text = story.2.desc.followup
	}
	desc = {
		exclusive_trigger = { has_origin = origin_evolutionary_predators }
		text = story.2.desc.evopred
	}
	picture = GFX_evt_news_room
	show_sound = event_scanner
	# location = from

	is_triggered_only = yes

	trigger = {
		is_country_type = default
		NOR = {
			has_country_flag = Story2
			has_country_flag = Story3
			has_country_flag = Story4
			has_country_flag = Story5
			has_country_flag = Story6
			has_country_flag = Story7
			#has_country_flag = Story8
			has_country_flag = StoryFirstRewardGiven
		}
	}

	immediate = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirst } }
			set_country_flag = StoryFirst
		}
		if = {
			limit = { NOT = { has_country_flag = first_alien_life } }
			set_country_flag = first_alien_life
		}
		set_country_flag = Story2
	}

	option = {
		exclusive_trigger = { has_valid_civic = civic_machine_exploration_protocol }
		name = fircon.machine_exploration_protocol
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_sensors_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Materialist
	option = {
		trigger = {
			owner = { is_materialist = yes }
		}
		name = "story.contact_report.materialist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_science_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Spiritualist
	option = {
		trigger = {
			owner = { is_spiritualist = yes }
		}
		name = "story.contact_report.spiritualist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_cryostasis_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Militarist
	option = {
		trigger = {
			owner = { is_militarist = yes }
		}
		name = "story.contact_report.militarist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_doctrine_fleet_size_1
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Pacifist
	option = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		name = "story.contact_report.pacifist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_bio_reactor
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Authoritarian
	option = {
		trigger = {
			owner = { is_authoritarian = yes }
		}
		name = "story.contact_report.authoritarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_administrative_ai
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Xenophile
	option = {
		trigger = {
			owner = { is_xenophile = yes }
		}
		name = "story.contact_report.xenophile"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_xeno_diplomacy
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Xenophobe
	option = {
		trigger = {
			owner = { is_xenophobe = yes }
		}
		name = "story.contact_report.xenophobe"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_ground_defense_planning
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Egalitarian
	option = {
		trigger = {
			owner = { is_egalitarian = yes }
		}
		name = "story.contact_report.egalitarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_hyper_drive_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Hive
	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_hive"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_mining_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}
	# Machine
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_machine"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_alloys_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}

	after = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirstRewardGiven } }
			set_country_flag = StoryFirstRewardGiven
		}
		hidden_effect = {
			if = {
				limit = {
					very_first_contact_paragon = yes
				}
				set_country_flag = first_contact_protocol_event_happened
			}
			if = {
				limit = {
					has_origin = origin_fear_of_the_dark
				}
				country_event = { id = origin.6030 }
			}
		}
	}
}

### 3 - Animalia
country_event = {
	id = story.3
	title = story.3.name
	# First
	desc = {
		text = story.3.desc
		trigger = {
			NOT = {
				has_country_flag = StoryFirst
			}
		}
	}
	# Gestalt Consciousness
	desc = {
		text = story.3.desc.gesta
		trigger = { has_ethic = ethic_gestalt_consciousness }
	}
	# Spiritualist regardless of status
	desc = {
		text = story.3.desc.spiri
		trigger = {
			is_spiritualist = yes
		}
	}
	# Followup
	desc = {
		trigger = { OR = { has_country_flag = Story1 has_country_flag = Story2 } }
		text = story.3.desc.followup
	}
	desc = {
		exclusive_trigger = { has_origin = origin_evolutionary_predators }
		text = story.3.desc.evopred
	}
	picture = GFX_evt_news_room
	show_sound = event_scanner

	is_triggered_only = yes

	trigger = {
		is_country_type = default
		NOR = {
			has_country_flag = Story3
			has_country_flag = Story4
			has_country_flag = Story5
			has_country_flag = Story6
			has_country_flag = Story7
			has_country_flag = StoryFirstRewardGiven
		}
	}

	immediate = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirst } }
			set_country_flag = StoryFirst
		}
		if = {
			limit = { NOT = { has_country_flag = first_alien_life } }
			set_country_flag = first_alien_life
		}
		#set_country_flag = Story3
		set_country_flag = root
	}

	option = {
		exclusive_trigger = { has_valid_civic = civic_machine_exploration_protocol }
		name = fircon.machine_exploration_protocol
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_sensors_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Materialist
	option = {
		trigger = {
			owner = { is_materialist = yes }
		}
		name = "story.contact_report.materialist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_science_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Spiritualist
	option = {
		trigger = {
			owner = { is_spiritualist = yes }
		}
		name = "story.contact_report.spiritualist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_cryostasis_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Militarist
	option = {
		trigger = {
			owner = { is_militarist = yes }
		}
		name = "story.contact_report.militarist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_doctrine_fleet_size_1
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Pacifist
	option = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		name = "story.contact_report.pacifist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_bio_reactor
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Authoritarian
	option = {
		trigger = {
			owner = { is_authoritarian = yes }
		}
		name = "story.contact_report.authoritarian"

		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_administrative_ai
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Xenophile
	option = {
		trigger = {
			owner = { is_xenophile = yes }
		}
		name = "story.contact_report.xenophile"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_xeno_diplomacy
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Xenophobe
	option = {
		trigger = {
			owner = { is_xenophobe = yes }
		}
		name = "story.contact_report.xenophobe"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_ground_defense_planning
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Egalitarian
	option = {
		trigger = {
			owner = { is_egalitarian = yes }
		}
		name = "story.contact_report.egalitarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_hyper_drive_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Hive
	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_hive"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_mining_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}
	# Machine
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_machine"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_alloys_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}

	after = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirstRewardGiven } }
			set_country_flag = StoryFirstRewardGiven
		}
		hidden_effect = {
			if = {
				limit = {
					has_origin = origin_fear_of_the_dark
				}
				country_event = { id = origin.6030 }
			}
		}
	}
}

### 4 - Pre-Sapients
country_event = {
	id = story.4
	title = story.4.name
	# First
	desc = {
		trigger = { NOT = { has_country_flag = StoryFirst } }
		text = story.4.desc
	}
	# Gestalt Consciousness
	desc = {
		trigger = { has_ethic = ethic_gestalt_consciousness }
		text = story.4.desc.gesta
	}
	# Fanatic Spiritualist regardless of status
	desc = {
		trigger = { is_spiritualist = yes }
		text = story.4.desc.spiri
	}
	# Xenophobe
	desc = {
		trigger = {
			is_xenophobe = yes
		}
		text = story.4.desc.phobe
	}
	# Xenophile
	desc = {
		trigger = {
			is_xenophile = yes
		}
		text = story.4.desc.phile
	}
	# Followup
	desc = {
		trigger = {
			OR = {
				has_country_flag = Story1
				has_country_flag = Story2
				has_country_flag = Story3
			}
		}
		text = story.4.desc.followup
	}
	desc = {
		exclusive_trigger = { has_origin = origin_evolutionary_predators }
		text = story.4.desc.evopred
	}

	picture = GFX_evt_news_room
	show_sound = event_scanner

	is_triggered_only = yes

	trigger = {
		is_country_type = default
		NOR = {
			has_country_flag = has_uplifted_species
			has_country_flag = Story4
			has_country_flag = Story41
			has_country_flag = Story5
			has_country_flag = Story6
			has_country_flag = Story7
			has_country_flag = StoryFirstRewardGiven
		}
	}

	immediate = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirst } }
			set_country_flag = StoryFirst
		}
		if = {
			limit = { NOT = { has_country_flag = first_alien_life } }
			set_country_flag = first_alien_life
		}
		set_country_flag = Story4
	}

	option = {
		exclusive_trigger = { has_valid_civic = civic_machine_exploration_protocol }
		name = fircon.machine_exploration_protocol
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_sensors_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Materialist
	option = {
		trigger = {
			owner = { is_materialist = yes }
		}
		name = "story.contact_report.materialist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_science_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Spiritualist
	option = {
		trigger = {
			owner = { is_spiritualist = yes }
		}
		name = "story.contact_report.spiritualist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_cryostasis_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Militarist
	option = {
		trigger = {
			owner = { is_militarist = yes }
		}
		name = "story.contact_report.militarist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_doctrine_fleet_size_1
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Pacifist
	option = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		name = "story.contact_report.pacifist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_bio_reactor
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Authoritarian
	option = {
		trigger = {
			owner = { is_authoritarian = yes }
		}
		name = "story.contact_report.authoritarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_administrative_ai
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Xenophile
	option = {
		trigger = {
			owner = { is_xenophile = yes }
		}
		name = "story.contact_report.xenophile"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_xeno_diplomacy
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Xenophobe
	option = {
		trigger = {
			owner = { is_xenophobe = yes }
		}
		name = "story.contact_report.xenophobe"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_ground_defense_planning
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Egalitarian
	option = {
		trigger = {
			owner = { is_egalitarian = yes }
		}
		name = "story.contact_report.egalitarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_hyper_drive_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Hive
	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_hive"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_mining_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}
	# Machine
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_machine"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_alloys_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}

	after = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirstRewardGiven } }
			set_country_flag = StoryFirstRewardGiven
		}
		hidden_effect = {
			if = {
				limit = {
					very_first_contact_paragon = yes
				}
				set_country_flag = first_contact_protocol_event_happened
			}
			if = {
				limit = {
					has_origin = origin_fear_of_the_dark
				}
				country_event = { id = origin.6030 }
			}
		}
	}
}

### 5 - Remnants
country_event = {
	id = story.5
	title = story.5.name
	# First
	desc = {
		trigger = { NOT = { has_country_flag = StoryFirst } }
		text = story.5.desc
	}
	# Gestalt Consciousness
	desc = {
		trigger = { has_ethic = ethic_gestalt_consciousness }
		text = story.5.desc.gesta
	}
	# Xenophobe
	desc = {
		trigger = { is_xenophobe = yes }
		text = story.5.desc.phobe
	}
	# Xenophile
	desc = {
		trigger = { is_xenophile = yes }
		text = story.5.desc.phile
	}
	# Followup
	desc = {
		trigger = {
			OR = {
				has_country_flag = Story1
				has_country_flag = Story2
				has_country_flag = Story3
				has_country_flag = Story4
			}
		}
		text = story.5.desc.followup
	}
	picture = GFX_evt_news_room
	show_sound = event_scanner

	is_triggered_only = yes

	trigger = {
		is_country_type = default
		NOR = {
			has_country_flag = Story5
			has_country_flag = Story6
			has_country_flag = Story7
			has_country_flag = StoryFirstRewardGiven
		}
	}

	immediate = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirst } }
			set_country_flag = StoryFirst
		}
		if = {
			limit = { NOT = { has_country_flag = first_alien_life } }
			set_country_flag = first_alien_life
		}
		set_country_flag = Story5
	}

	option = {
		exclusive_trigger = { has_valid_civic = civic_machine_exploration_protocol }
		name = fircon.machine_exploration_protocol
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_sensors_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Materialist
	option = {
		trigger = {
			owner = { is_materialist = yes }
		}
		name = "story.contact_report.materialist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_science_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Spiritualist
	option = {
		trigger = {
			owner = { is_spiritualist = yes }
		}
		name = "story.contact_report.spiritualist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_cryostasis_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Militarist
	option = {
		trigger = {
			owner = { is_militarist = yes }
		}
		name = "story.contact_report.militarist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_doctrine_fleet_size_1
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Pacifist
	option = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		name = "story.contact_report.pacifist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_bio_reactor
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Authoritarian
	option = {
		trigger = {
			owner = { is_authoritarian = yes }
		}
		name = "story.contact_report.authoritarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_administrative_ai
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Xenophile
	option = {
		trigger = {
			owner = { is_xenophile = yes }
		}
		name = "story.contact_report.xenophile"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_xeno_diplomacy
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Xenophobe
	option = {
		trigger = {
			owner = { is_xenophobe = yes }
		}
		name = "story.contact_report.xenophobe"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_ground_defense_planning
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Egalitarian
	option = {
		trigger = {
			owner = { is_egalitarian = yes }
		}
		name = "story.contact_report.egalitarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_hyper_drive_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Hive
	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_hive"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_mining_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}
	# Machine
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_machine"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_alloys_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}

	after = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirstRewardGiven } }
			set_country_flag = StoryFirstRewardGiven
		}
		hidden_effect = {
			if = {
				limit = {
					very_first_contact_paragon = yes
				}
				set_country_flag = first_contact_protocol_event_happened
			}
		}
		if = {
			limit = {
				has_origin = origin_fear_of_the_dark
			}
			country_event = { id = origin.6030 }
		}
	}
}

### 6 - Pre-FTLs
country_event = {
	id = story.6
	title = story.6.name
	# First
	desc = {
		trigger = { NOT = { has_country_flag = StoryFirst } }
		text = story.6.desc
	}
	# Gestalt Consciousness
	desc = {
		trigger = { has_ethic = ethic_gestalt_consciousness }
		text = story.6.desc.gesta
	}
	# Xenophobe
	desc = {
		trigger = { is_xenophobe = yes }
		text = story.6.desc.phobe
	}
	# Xenophile
	desc = {
		trigger = { is_xenophile = yes }
		text = story.6.desc.phile
	}
	# Followup 5
	desc = {
		trigger = { has_country_flag = Story5 }
		text = story.6.desc.followup5
	}
	# Followup 4
	desc = {
		trigger = { has_country_flag = Story4 }
		text = story.6.desc.followup4
	}
	# Followup 1-2-3
	desc = {
		text = story.6.desc.followup123
		trigger = {
			OR = {
				has_country_flag = Story1
				has_country_flag = Story2
				has_country_flag = Story3
				has_country_flag = StoryFirstRewardGiven
			}
		}
	}
	desc = {
		exclusive_trigger = { has_origin = origin_evolutionary_predators }
		text = story.6.desc.evopred
	}

	picture = GFX_evt_news_room
	show_sound = event_scanner

	is_triggered_only = yes

	trigger = {
		is_country_type = default
		NOR = {
			has_country_flag = Story6
			has_country_flag = Story7
		}
	}

	immediate = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirst } }
			set_country_flag = StoryFirst
		}
		if = {
			limit = { NOT = { has_country_flag = first_alien_life } }
			set_country_flag = first_alien_life
		}
		set_country_flag = Story6
	}

	option = {
		exclusive_trigger = { has_valid_civic = civic_machine_exploration_protocol }
		name = fircon.machine_exploration_protocol
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_sensors_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Materialist
	option = {
		trigger = {
			owner = { is_materialist = yes }
		}
		name = "story.contact_report.materialist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_science_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Spiritualist
	option = {
		trigger = {
			owner = { is_spiritualist = yes }
		}
		name = "story.contact_report.spiritualist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_cryostasis_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Militarist
	option = {
		trigger = {
			owner = { is_militarist = yes }
		}
		name = "story.contact_report.militarist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_doctrine_fleet_size_1
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Pacifist
	option = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		name = "story.contact_report.pacifist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_bio_reactor
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Authoritarian
	option = {
		trigger = {
			owner = { is_authoritarian = yes }
		}
		name = "story.contact_report.authoritarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_administrative_ai
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Xenophile
	option = {
		trigger = {
			owner = { is_xenophile = yes }
		}
		name = "story.contact_report.xenophile"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_xeno_diplomacy
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Xenophobe
	option = {
		trigger = {
			owner = { is_xenophobe = yes }
		}
		name = "story.contact_report.xenophobe"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_ground_defense_planning
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Egalitarian
	option = {
		trigger = {
			owner = { is_egalitarian = yes }
		}
		name = "story.contact_report.egalitarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_hyper_drive_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Hive
	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_hive"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_mining_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}
	# Machine
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_machine"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_alloys_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}

	after = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirstRewardGiven } }
			set_country_flag = StoryFirstRewardGiven
		}
		hidden_effect = {
			if = {
				limit = {
					very_first_contact_paragon = yes
				}
				set_country_flag = first_contact_protocol_event_happened
			}
			if = {
				limit = {
					has_origin = origin_fear_of_the_dark
				}
				country_event = { id = origin.6040 }
			}
		}
	}
}

### 7 - Unknown Empire
country_event = {
	id = story.7
	title = story.7.name
	# First
	desc = {
		trigger = { NOT = { has_country_flag = StoryFirst } }
		text = story.7.desc
	}
	# Gestalt Consciousness
	desc = {
		trigger = { has_ethic = ethic_gestalt_consciousness }
		text = story.7.desc.gesta
	}
	# Xenophobe
	desc = {
		trigger = { is_xenophobe = yes }
		text = story.7.desc.phobe
	}
	# Xenophile
	desc = {
		trigger = { is_xenophile = yes }
		text = story.7.desc.phile
	}
	# Followup 6
	desc = {
		trigger = { has_country_flag = Story6 }
		text = story.7.desc.followup6
	}
	# Followup 1-2-3-4-5
	desc = {
		trigger = {
			is_machine_empire = no
			OR = {
				has_country_flag = Story1
				has_country_flag = Story2
				has_country_flag = Story3
				has_country_flag = Story4
				has_country_flag = Story5
			}
		}
		text = story.7.desc.followup12345
	}
	# Followup 1-2-3-4-5 Machine Intelligences
	desc = {
		trigger = {
			is_machine_empire = yes
			OR = {
				has_country_flag = Story1
				has_country_flag = Story2
				has_country_flag = Story3
				has_country_flag = Story4
				has_country_flag = Story5
			}
		}
		text = story.7.desc.mach.followup12345
	}
	desc = {
		exclusive_trigger = { has_origin = origin_evolutionary_predators }
		text = story.7.desc.evopred
	}

	picture = {
		picture = GFX_evt_news_room
		trigger = { NOT = { has_ethic = ethic_gestalt_consciousness } }
	}
	picture = {
		picture = GFX_evt_unknown_ships
		trigger = { has_ethic = ethic_gestalt_consciousness }
	}
	show_sound = event_scanner

	is_triggered_only = yes

	trigger = {
		NOT = {
			has_country_flag = Story7
			has_country_flag = StoryFirstRewardGiven
		}
		FROM = {
			NOR = {
				has_country_flag = radical_cult
				is_country_type = fallen_empire
				is_country_type = awakened_fallen_empire
				is_country_type = primitive
				is_guardian_country = yes
				has_relation_flag = { flag = no_coms who = root }
				has_relation_flag = { flag = AbandonedRefugees who = root }
				has_relation_flag = { flag = pirate_relation who = root }
				has_country_flag = day_0
			}
		}
	}

	immediate = {
		set_country_flag = Story7
		set_country_flag = has_encountered_other_empire
		if = {
			limit = { NOT = { has_country_flag = StoryFirst } }
			set_country_flag = StoryFirst
		}
		if = {
			limit = { NOT = { has_country_flag = first_alien_life } }
			set_country_flag = first_alien_life
		}
	}

	option = {
		exclusive_trigger = { has_valid_civic = civic_machine_exploration_protocol }
		name = fircon.machine_exploration_protocol
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_sensors_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Materialist
	option = {
		trigger = {
			owner = { is_materialist = yes }
		}
		name = "story.contact_report.materialist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_science_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Spiritualist
	option = {
		trigger = {
			owner = { is_spiritualist = yes }
		}
		name = "story.contact_report.spiritualist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_cryostasis_1
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Militarist
	option = {
		trigger = {
			owner = { is_militarist = yes }
		}
		name = "story.contact_report.militarist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_doctrine_fleet_size_1
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Pacifist
	option = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		name = "story.contact_report.pacifist"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_bio_reactor
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Authoritarian
	option = {
		trigger = {
			owner = { is_authoritarian = yes }
		}
		name = "story.contact_report.authoritarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_administrative_ai
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Xenophile
	option = {
		trigger = {
			owner = { is_xenophile = yes }
		}
		name = "story.contact_report.xenophile"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_xeno_diplomacy
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Xenophobe
	option = {
		trigger = {
			owner = { is_xenophobe = yes }
		}
		name = "story.contact_report.xenophobe"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_ground_defense_planning
					PROGRESS = 0.1
					CATEGORY = society_research
				}
			}
		}
	}
	# Egalitarian
	option = {
		trigger = {
			owner = { is_egalitarian = yes }
		}
		name = "story.contact_report.egalitarian"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_hyper_drive_2
					PROGRESS = 0.1
					CATEGORY = physics_research
				}
			}
		}
	}
	# Hive
	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_hive"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_space_mining_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}
	# Machine
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = "story.contact_report.gestalt_consciousness_machine"
		if = {
			limit = {
				NOT = { owner = { has_country_flag = StoryFirstRewardGiven } }
			}
			owner = {
				add_tech_option_or_research_effect = {
					TECH = tech_alloys_1
					PROGRESS = 0.1
					CATEGORY = engineering_research
				}
			}
		}
	}

	option = {
		exclusive_trigger = { has_valid_civic = civic_hive_devouring_swarm }
		name = story.7.a.swarm
	}

	after = {
		if = {
			limit = { NOT = { has_country_flag = StoryFirstRewardGiven } }
			set_country_flag = StoryFirstRewardGiven
		}
		hidden_effect = {
			if = {
				limit = {
					very_first_contact_paragon = yes
				}
				set_country_flag = first_contact_protocol_event_happened
			}
			if = {
				limit = {
					has_origin = origin_fear_of_the_dark
				}
				country_event = { id = origin.6040 }
			}
		}
	}
}

### 8 - Leviathan
country_event = {
	id = story.8
	title = story.8.name
	desc = {
		exclusive_trigger = {
			OR = {
				has_country_flag = encountered_dreadnought
				has_country_flag = encountered_scavenger_bot
				has_country_flag = guardian_scavenger_bot
				has_country_flag = guardians_technosphere_encountered
			}
			is_machine_empire = no
		}
		text = story.8.desc.mechanical
	}
	# First
	desc = {
		trigger = { NOT = { has_country_flag = StoryFirst } }
		text = story.8.desc
	}
	desc = {
		exclusive_trigger = { is_machine_empire = yes }
		text = story.8.desc.mach
	}
	# Spiritualist
	desc = {
		trigger = { is_spiritualist = yes }
		text = story.8.desc.spirit
	}
	# Xenophile
	desc = {
		trigger = { is_xenophile = yes }
		text = story.8.desc.phile
	}
	# Hive Minds and Followup 7
	desc = {
		trigger = {
			OR = {
				is_hive_empire = yes
				has_country_flag = Story7
			}
		}
		text = story.8.desc.followup7
	}
	# Followup 1-2-3-4-5-6
	desc = {
		trigger = {
			OR = {
				has_country_flag = Story1
				has_country_flag = Story2
				has_country_flag = Story3
				has_country_flag = Story4
				has_country_flag = Story5
				has_country_flag = Story6
			}
		}
		text = story.8.desc.followup123456
	}
	picture = GFX_evt_unspeakable_horror
	show_sound = event_mystic_reveal

	is_triggered_only = yes

	trigger = {
		NOT = { has_country_flag = Story8 }
	}

	immediate = {
		set_country_flag = Story8
		if = {
			limit = { NOT = { has_country_flag = StoryFirst } }
			set_country_flag = StoryFirst
		}
		if = {
			limit = { NOT = { has_country_flag = first_alien_life } }
			set_country_flag = first_alien_life
		}
		if = {
			limit = { NOT = { has_country_flag = first_contact_event } }
			set_country_flag = first_contact_event
		}
		if = {
			limit = { NOT = { has_country_flag = encountered_leviathan } }
			set_country_flag = encountered_leviathan
		}
	}

	option = {
		name = story.8.a
		trigger = {
			NOR = {
				has_country_flag = StoryFirst
				is_fanatic_spiritualist = yes
				is_fanatic_materialist = yes
				AND = {
					is_fanatic = no
					OR = {
						has_ethic = ethic_spiritualist
						has_ethic = ethic_materialist
					}
				}
			}
		}
	}
	option = {
		name = story.8.b
		trigger = {
			has_country_flag = StoryFirst
			NOR = {
				is_xenophile = yes
				is_machine_empire = yes
				is_fanatic_spiritualist = yes
				is_fanatic_materialist = yes
				AND = {
					is_fanatic = no
					OR = {
						has_ethic = ethic_spiritualist
						has_ethic = ethic_materialist
					}
				}
			}
		}
	}
	option = {
		name = story.8.c
		trigger = {
			has_country_flag = StoryFirst
			is_xenophile = yes
			NOR = {
				is_fanatic_spiritualist = yes
				is_fanatic_materialist = yes
				AND = {
					is_fanatic = no
					OR = {
						has_ethic = ethic_spiritualist
						has_ethic = ethic_materialist
					}
				}
			}
		}
	}
	option = {
		name = story.8.d
		trigger = {
			has_country_flag = StoryFirst
			is_machine_empire = yes
		}
	}
	option = {
		name = story.8.e
		set_country_flag = spiritualist_reject
		trigger = {
			OR = {
				is_fanatic_spiritualist = yes
				AND = {
					is_fanatic = no
					has_ethic = ethic_spiritualist
				}
			}
		}
	}
	option = {
		name = story.8.f
		set_country_flag = spiritualist_accept
		trigger = {
			OR = {
				is_fanatic_spiritualist = yes
				AND = {
					is_fanatic = no
					has_ethic = ethic_spiritualist
				}
			}
		}
	}
	option = {
		name = story.8.g
		set_country_flag = materialist_science
		trigger = {
			OR = {
				is_fanatic_materialist = yes
				AND = {
					is_fanatic = no
					has_ethic = ethic_materialist
				}
			}
		}
	}
	option = {
		name = story.8.h
		set_country_flag = materialist_trophy
		trigger = {
			OR = {
				is_fanatic_materialist = yes
				AND = {
					is_fanatic = no
					has_ethic = ethic_materialist
				}
			}
		}
	}
	after = {
		hidden_effect = {
			if = {
				limit = {
					has_country_flag = encountered_dreadnought
				}
				remove_country_flag = encountered_dreadnought
			}
			if = {
				limit = {
					very_first_contact_paragon = yes
				}
				set_country_flag = first_contact_protocol_event_happened
			}
			if = {
				limit = {
					has_origin = origin_fear_of_the_dark
				}
				country_event = { id = origin.6060 days = 5 scopes = { fromfrom = fromfromfrom } }
			}
		}
	}
}

##############################
# Uchuukaijuu
##############################

# Project complete
country_event = {
	id = story.105
	title = story.105.name
	desc = {
		trigger = {
			switch = {
				trigger = has_ethic
				ethic_fanatic_xenophile = { text = story.105.desc.phile }
				ethic_xenophile = { text = story.105.desc.phile }
				ethic_fanatic_pacifist = { text = story.105.desc.pacif }
				ethic_pacifist = { text = story.105.desc.pacif }
				ethic_gestalt_consciousness = { text = story.105.desc.gesta }
				default = { text = story.105.desc }
			}
		}
	}
	picture = GFX_evt_friendly_amoeba
	show_sound = event_space_amoeba
	location = from

	is_triggered_only = yes

	option = {
		name = story.105.bb
		add_modifier = {
			modifier = flagellating_movement # +5% evasion
			days = -1
		}
	}

	option = {
		trigger = {
			NOT = { has_technology = tech_regenerative_hull_tissue }
		}
		name = story.105.aa
		add_research_option = tech_regenerative_hull_tissue
		add_tech_progress = {
			tech = tech_regenerative_hull_tissue
			progress = 0.5
		}
	}
}

# Pacification project complete
country_event = {
	id = story.107
	title = story.107.name
	desc = {
		trigger = {
			text = story.107.desc
			text = newline
			success_text = {
				text = story.107.fruitful.desc
				hidden:root = { has_origin = origin_fruitful }
			}
		}
	}
	picture = GFX_evt_fleet_neutral
	show_sound = event_space_amoeba
	location = from

	is_triggered_only = yes

	immediate = {
		every_country = {
			limit = {
				is_amoeba_country_type = yes
			}
			set_faction_hostility = {
				set_hostile = no
				set_neutral = yes
				target = root
			}
		}
	}

	option = {
		name = story.107.a
		custom_tooltip = story.107.a.tooltip
		if = {
			limit = {
				has_origin = origin_fruitful
			}
			set_country_flag = pacified_amoebas
			custom_tooltip = story.107.a.fruitful.tooltip
		}
		hidden_effect = {
			add_modifier = {
				modifier = pacified_amoebas # friendly amoebas
				days = -1
			}
		}
		add_research_option = tech_amoeba_strike_craft_1
		IF = {
			limit = {
				NOR = {
					has_tech_option = tech_regenerative_hull_tissue
					has_technology = tech_regenerative_hull_tissue
				}
			}
			add_research_option = tech_regenerative_hull_tissue
		}
	}
}

# Amoeba kill-check for hunting buff
# This = owner of fleet 1 (combatant)
# From = owner of fleet 2 (destroyed)
# FromFrom = fleet 1
# FromFromFrom = fleet 2
country_event = {
	id = story.109
	trigger = {
		#is_ai = no
		exists = from
		from = {
			is_amoeba_country_type = yes
		}
		has_modifier = amoeba_hunting_buff
	}
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		add_resource = { energy = 1000 }
	}
}

# Project complete
country_event = {
	id = story.205
	title = story.205.name
	desc = {
		trigger = {
			has_ethic = ethic_gestalt_consciousness
		}
		text = story.205.desc.gesta
	}
	# Phile
	desc = {
		trigger = {
			is_xenophile = yes
		}
		text = story.205.desc.phile
	}
	# Pacifist
	desc = {
		trigger = {
			is_pacifist = yes
		}
		text = story.205.desc.pacif
	}
	desc = {
		trigger = {
			is_pacifist = no
			is_xenophile = no
			is_spiritualist = no
		}
		text = story.205.desc
	}
	picture = GFX_evt_fleet_evil
	show_sound = event_crystal_ship
	location = from

	is_triggered_only = yes

	option = {
		name = story.205.bb
		add_modifier = {
			modifier = crystal_focus # +5% energy
			days = -1
		}
	}

	option = {
		trigger = {
			owner = {
				NOR = {
					has_technology = tech_crystal_armor_1
					has_technology = tech_crystal_armor_2
				}
			}
		}
		name = story.205.aa
		add_research_option = tech_crystal_armor_1
		add_tech_progress = {
			tech = tech_crystal_armor_1
			progress = 0.5
		}
	}
}

# Pacification Project complete
country_event = {
	id = story.207
	title = story.207.name
	desc = {
		trigger = {
			text = story.207.desc
			text = newline
			success_text = {
				text = story.207.fruitful.desc
				hidden:root = { has_origin = origin_fruitful }
			}
		}
	}
	picture = GFX_evt_fleet_evil
	show_sound = event_crystal_ship
	location = from

	is_triggered_only = yes

	immediate = {
		set_country_flag = crystal_nonhostile_approach
		every_country = {
			limit = {
				is_crystal_country_type = yes
			}
			set_faction_hostility = {
				set_hostile = no
				set_neutral = yes
				target = root
			}
		}
	}

	option = {
		name = story.207.a
		custom_tooltip = story.207.a.tooltip
		if = {
			limit = {
				has_origin = origin_fruitful
			}
			set_country_flag = pacified_crystals
			custom_tooltip = story.207.a.fruitful.tooltip
		}
		hidden_effect = {
			add_modifier = {
				modifier = pacified_crystals # friendly crystals
				days = -1
			}
		}
		add_research_option = tech_crystal_armor_1
	}
}

# On-action check for destroyed crystal fleet
country_event = {
	id = story.216
	hide_window = yes
	is_triggered_only = yes
	trigger = {
		exists = from
		from = {
			is_crystal_country_type = yes
		}
		has_modifier = crystal_hunting_buff
		is_ai = no
	}

	immediate = {
		add_resource = { minerals = 500 }
	}
}

# Crystal boss
fleet_event = {
	id = story.220
	title = story.220.name
	desc = {
		text = story.220.desc.gesta
		trigger = {
			owner = {
				has_ethic = ethic_gestalt_consciousness
			}
		}
	}
	desc = {
		text = story.220.desc.hostile
		trigger = {
			owner = {
				has_modifier = crystal_hunting_buff
				NOT = { has_ethic = ethic_gestalt_consciousness }
			}
		}
	}
	desc = {
		text = story.220.desc.nonhostile
		trigger = {
			owner = {
				NOR = {
					has_modifier = crystal_hunting_buff
					has_ethic = ethic_gestalt_consciousness
				}
			}
		}
	}
	picture = GFX_evt_fleet_evil
	show_sound = event_crystal_ship
	location = root

	is_triggered_only = yes

	trigger = {
		from = {
			has_star_flag = crystal_home_system
			any_fleet_in_system = {
				is_ship_size = crystal_station_large
			}
		}
		owner = {
			is_country_type = default
			has_country_flag = crystals_encountered
			NOT = { has_country_flag = found_crystal_construct }
		}
	}

	immediate = {
		owner = {
			set_country_flag = found_crystal_construct
		}
	}

	option = {
		name = OK
		trigger = {
			owner = { NOT = { has_modifier = crystal_hunting_buff } }
		}
	}

	option = {
		name = BATTLESTATIONS
		trigger = {
			owner = { has_modifier = crystal_hunting_buff }
		}
	}
}

country_event = {
	id = story.222
	title = story.222.name
	desc = story.222.desc
	picture = GFX_evt_fleet_evil
	show_sound = event_crystal_ship
	location = fromfrom

	is_triggered_only = yes

	trigger = {
		is_country_type = default
		from = {
			is_country_type = crystal
		}
		fromfromfrom = {
			is_ship_size = crystal_station_large
		}
	}

	option = {
		name = OK
		add_research_option = tech_crystal_armor_2
	}
}


# Project complete
country_event = {
	id = story.305
	title = story.305.name
	desc = {
		trigger = { has_ethic = ethic_gestalt_consciousness }
		text = story.305.desc.gesta
	}
	# Phile
	desc = {
		trigger = { is_pacifist = yes }

		text = story.305.desc.pacif
	}
	# Pacifist
	desc = {
		trigger = { is_materialist = yes }
		text = story.305.desc.mater
	}
	desc = {
		trigger = {
			is_materialist = no
			is_pacifist = no
		}
		text = story.305.desc
	}
	picture = GFX_evt_mining_station
	show_sound = event_ancient_drone
	location = from

	is_triggered_only = yes

	option = {
		name = story.305.aa
		add_modifier = {
			modifier = drone_hunting_buff
			days = -1
		}
	}

	option = {
		name = story.305.bb
		if = {
			limit = { is_nomadic = yes }
			add_modifier = {
				modifier = drone_mining_techniques_nomad
				days = -1
			}
		}
		else = {
			add_modifier = {
				modifier = drone_mining_techniques #+5% minerals
				days = -1
			}
		}
	}
}

# Entering drone home system
fleet_event = {
	id = story.330
	title = story.330.name
	desc = {
		text = story.330.desc.gesta
		trigger = {
			owner = {
				has_ethic = ethic_gestalt_consciousness
			}
		}
	}
	desc = {
		text = story.330.desc
		trigger = {
			owner = {
				NOT = { has_ethic = ethic_gestalt_consciousness }
			}
		}
	}
	picture = GFX_evt_mining_station
	show_sound = event_ancient_drone
	location = root

	is_triggered_only = yes

	trigger = {
		exists = event_target:drone_country
		owner = {
			has_communications = event_target:drone_country
			NOT = { has_country_flag = seen_drone_home }
		}
		from = {
			has_star_flag = drone_home_system
		}
	}

	immediate = {
		owner = {
			set_country_flag = seen_drone_home
		}
	}

	option = {
		name = story.330.a
	}
}

# station destroyed
country_event = {
	id = story.332
	title = story.332.name
	desc = story.332.desc
	picture = GFX_evt_exploding_ship
	location = fromfrom

	is_triggered_only = yes

	trigger = {
		exists = event_target:drone_country
		from = {
			is_same_value = event_target:drone_country
		}
		fromfromfrom = { has_fleet_flag = ore_grinder }
	}

	option = {
		name = story.332.a
		trigger = { has_ancrel = no }
		add_resource = { minerals = 4000 alloys = 500 }
	}

	option = {
		name = story.332.b
		trigger = { has_ancrel = yes }
		add_resource = { minerals = 4000 alloys = 500 }
		add_relic = r_surveyor
	}
}

# Surveyor Activated
country_event = {
	id = story.335
	title = story.335.name
	desc = story.335.desc
	picture = GFX_evt_mining_operations
	location = event_target:chosen_planet

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				is_nomadic = yes
			}
			capital_scope.solar_system = {
				random_system_planet = {
					limit = {
						habitable_planet = no
						is_artificial = no
						NOR = {
							is_planet_class = pc_ringworld_habitable_damaged
							is_planet_class = pc_ringworld_tech_damaged
							is_planet_class = pc_ringworld_tech
							is_planet_class = pc_ringworld_seam
							is_planet_class = pc_ringworld_seam_damaged
							is_planet_class = pc_astral_scar
						}
						# check that the random list won't come up empty
						OR = {
							energy_candidate = yes
							mineral_candidate = yes
							physics_candidate = yes
							society_candidate = yes
							engineering_candidate = yes
							alloy_candidate = yes
							exotic_gas_candidate = yes
							rare_crystal_candidate = yes
							volatile_motes_candidate = yes
							ROOT = { is_gestalt = no }
						}
					}
					save_event_target_as = chosen_planet
				}
			}
		}
		else = {
			random_planet_within_border = {
				limit = {
					habitable_planet = no
					is_artificial = no
					NOR = {
						is_planet_class = pc_ringworld_habitable_damaged
						is_planet_class = pc_ringworld_tech_damaged
						is_planet_class = pc_ringworld_tech
						is_planet_class = pc_ringworld_seam
						is_planet_class = pc_ringworld_seam_damaged
						is_planet_class = pc_astral_scar
					}
					# check that the random list won't come up empty
					OR = {
						energy_candidate = yes
						mineral_candidate = yes
						physics_candidate = yes
						society_candidate = yes
						engineering_candidate = yes
						alloy_candidate = yes
						exotic_gas_candidate = yes
						rare_crystal_candidate = yes
						volatile_motes_candidate = yes
						trade_candidate = yes
					}
				}
				save_event_target_as = chosen_planet
			}
		}
	}

	option = {
		name = EXCELLENT

		locked_random_list = {

			# Energy
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { energy_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_energy_5 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { energy_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_energy_7 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { energy_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_energy_9 }
			}

			# Minerals
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { mineral_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_minerals_5 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { mineral_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_minerals_7 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { mineral_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_minerals_9 }
			}

			# Physics
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { physics_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_physics_5 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { physics_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_physics_7 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { physics_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_physics_9 }
			}

			# Society
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { society_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_society_5 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { society_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_society_7 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { society_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_society_9 }
			}

			# Engineering
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { engineering_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_engineering_5 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { engineering_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_engineering_7 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { engineering_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_engineering_9 }
			}

			# Trade
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { trade_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_trade_value_5 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { trade_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_trade_value_7 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { trade_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_trade_value_9 }
			}

			# Alloys
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { alloy_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_alloys_3 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { alloy_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_alloys_4 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { alloy_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_alloys_5 }
			}

			# Exotic Gas
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { exotic_gas_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_exotic_gases_1 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { exotic_gas_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_exotic_gases_2 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { exotic_gas_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_exotic_gases_3 }
			}

			# Rare Crystals
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { rare_crystal_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_rare_crystals_1 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { rare_crystal_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_rare_crystals_2 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { rare_crystal_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_rare_crystals_3 }
			}

			# Volatile Motes
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { volatile_motes_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_volatile_motes_1 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { volatile_motes_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_volatile_motes_2 }
			}
			10 = {
				modifier = {
					factor = 0
					event_target:chosen_planet = { volatile_motes_candidate = no }
				}
				event_target:chosen_planet = { add_deposit = d_volatile_motes_3 }
			}
		}
	}
}


# project complete
country_event = {
	id = story.405
	title = story.405.name
	desc = {
		trigger = {
			has_ethic = ethic_gestalt_consciousness
		}
		text = story.405.desc.gesta
	}
	# Spiri
	desc = {
		trigger = {
			is_spiritualist = yes
		}
		text = story.405.desc.spiri
	}
	desc = {
		trigger = {
			NOR = {
				is_spiritualist = yes
				has_ethic = ethic_gestalt_consciousness
			}
		}
		text = story.405.desc
	}
	picture = GFX_evt_fleet_evil
	show_sound = event_space_cloud
	location = from

	is_triggered_only = yes

	option = {
		name = story.405.b
		add_modifier = {
			modifier = cloud_hunting_buff
			days = -1
		}
	}

	option = {
		name = story.405.a.spiri
		add_modifier = {
			modifier = void_loops
			days = -1
		}
	}
}
