################################
#
# First Contact Events
#
# Written by Pierre du Plessis
#
################################

namespace = first_contact

# First Contact Stage 1
first_contact_event = {
	id = first_contact.1
	title = first_contact_start_title
	desc = {
		trigger = {
			owner = {
				NOR = {
					is_gestalt = yes
					AND = {
						OR = {
							is_xenophobe = yes
							is_militarist = yes
						}
						is_xenophile = no
					}
				}
			}
		}
		text = first_contact.1.desc.default
	}
	desc = {
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_militarist = yes
				}
				is_xenophile = no
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		text = first_contact.1.desc.xenophobe
	}
	desc = {
		trigger = {
			owner = { has_valid_civic = civic_machine_terminator }
		}
		text = first_contact.1.desc.terminator
	}
	desc = {
		trigger = {
			owner = { has_valid_civic = civic_hive_devouring_swarm }
		}
		text = first_contact.1.desc.devourer
	}
	desc = {
		trigger = {
			owner = { has_valid_civic = civic_fanatic_purifiers }
		}
		text = first_contact.1.desc.purifier
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
				NOR = {
					is_wilderness_empire = yes
					has_valid_civic = civic_hive_devouring_swarm
				}
			}
		}
		text = first_contact.1.desc.hive
	}
	desc = {
		trigger = {
			owner = { is_wilderness_empire = yes }
		}
		text = first_contact.1.desc.wilderness
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
				NOT = { has_valid_civic = civic_machine_terminator }
			}
		}
		text = first_contact.1.desc.machine
	}
	picture = GFX_evt_star_chart
	is_triggered_only = yes
	first_contact = yes
	location = solar_system

	show_sound = event_mysterious_signal

	abort_trigger = {
		OR = {
			NOT = { exists = owner }
			NOT = { exists = contact_country }
			contact_country = { is_country_type = primitive }
			owner = { has_communications = root.contact_country }
		}
	}

	immediate = {
		set_first_contact_starting_stage = yes
		hidden_effect = {
			fire_on_action = {
				on_action = on_first_contact_started
			}
		}
	}

	option = {
		name = INTERESTING
	}

}

# First contact with default empire, no planets
first_contact_event = {
	id = first_contact.5
	title = first_contact.5.name
	desc = {
		trigger = { first_contact_default_desc = yes }
		text = first_contact.5.desc
	}
	desc = {
		trigger = { first_contact_militarist_desc = yes }
		text = first_contact.5.militarist.desc
	}
	desc = {
		trigger = { first_contact_pacifist_desc = yes }
		text = first_contact.5.pacifist.desc
	}
	desc = {
		trigger = { first_contact_spiritualist_desc = yes }
		text = first_contact.5.spiritualist.desc
	}
	desc = {
		trigger = { first_contact_materialist_desc = yes }
		text = first_contact.5.materialist.desc
	}
	desc = {
		trigger = { first_contact_xenophobe_desc = yes }
		text = first_contact.5.xenophobe.desc
	}
	desc = {
		trigger = { first_contact_xenophile_desc = yes }
		text = first_contact.5.xenophile.desc
	}
	desc = {
		trigger = { first_contact_authoritarian_desc = yes }
		text = first_contact.5.authoritarian.desc
	}
	desc = {
		trigger = { first_contact_egalitarian_desc = yes }
		text = first_contact.5.egalitarian.desc
	}
	picture = GFX_evt_unknown_ships

	is_triggered_only = yes
	first_contact = yes

	inline_script = first_contact_event_sounds

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	#you can see their ship, so attempt to capture it
	option = {
		name = first_contact.15.B
		custom_tooltip = first_contact.10.B.tooltip
		icon = {
			icon = GFX_option_icon_hostile
			text = hostile_first_contact_tt
		}
		trigger = {
			owner = { has_policy_flag = first_contact_attack_allowed }
		}
		allow = {
			custom_tooltip = {
				text = any_civilian_ship_in_sensor_range
				first_contact_can_capture_ship = yes
			}
		}
		if = {
			limit = {
				contact_country = {
					is_synthetic_empire = no
					is_same_species = root.owner
				}
			}
			set_first_contact_stage = default_end_stage_hostile_same_species
		}
		else = {
			set_first_contact_stage = default_hostile_ship_stage
		}
		set_first_contact_flag = hostile_first_contact_attempted


		ai_chance = {
			factor = 3
			modifier = {
				factor = 2
				owner = { is_xenophobe = yes }
			}
			modifier = {
				factor = 2
				owner = { is_militarist = yes }
			}
			modifier = {
				factor = 15
				owner = { is_homicidal = yes }
			}
		}
	}

	option = {
		name = first_contact.5.A
		if = {
			limit = {
				owner = {
					OR = {
						is_synthetic_empire = no
						has_country_flag = lost_colony_parent_of@prev
					}
					is_same_species = prev.contact_country
				}
			}
			set_first_contact_stage = default_end_stage_same_species
		}
		else_if = {
			limit = {
				#synths will still need to work it out
				owner = { is_machine_empire = yes }
				contact_country = { is_machine_empire = yes }
			}
			set_first_contact_stage = default_end_stage_both_machines
		}
		else_if = {
			limit = {
				owner = {
					is_hive_empire = yes
					is_wilderness_empire = no
				}
				contact_country = {
					is_hive_empire = yes
					is_wilderness_empire = no
				}
			}
			set_first_contact_stage = default_end_stage_both_hive_minds
		}
		else = {
			set_first_contact_stage = default_stage_2
		}
	}
}

# First contact with default empire, no planets, THEY ARE SCANNING US
first_contact_event = {
	id = first_contact.10
	title = first_contact.10.name

	# Default
	desc = {
		text = first_contact.10.desc.proactive
		trigger = {
			first_contact_default_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.desc.cautious
		trigger = {
			first_contact_default_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.desc.attack_allowed
		trigger = {
			first_contact_default_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	# Militarist
	desc = {
		text = first_contact.10.militarist.desc.proactive
		trigger = {
			first_contact_militarist_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.militarist.desc.cautious
		trigger = {
			first_contact_militarist_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.militarist.desc.attack_allowed
		trigger = {
			first_contact_militarist_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	# Pacifist
	desc = {
		text = first_contact.10.pacifist.desc.proactive
		trigger = {
			first_contact_pacifist_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.pacifist.desc.cautious
		trigger = {
			first_contact_pacifist_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.pacifist.desc.attack_allowed
		trigger = {
			first_contact_pacifist_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	# Spiritualist
	desc = {
		text = first_contact.10.spiritualist.desc.proactive
		trigger = {
			first_contact_spiritualist_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.spiritualist.desc.cautious
		trigger = {
			first_contact_spiritualist_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.spiritualist.desc.attack_allowed
		trigger = {
			first_contact_spiritualist_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	# Materialist
	desc = {
		text = first_contact.10.materialist.desc.proactive
		trigger = {
			first_contact_materialist_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.materialist.desc.cautious
		trigger = {
			first_contact_materialist_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.materialist.desc.attack_allowed
		trigger = {
			first_contact_materialist_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	# Xenophobe
	desc = {
		text = first_contact.10.xenophobe.desc.proactive
		trigger = {
			first_contact_xenophobe_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.xenophobe.desc.cautious
		trigger = {
			first_contact_xenophobe_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.xenophobe.desc.attack_allowed
		trigger = {
			first_contact_xenophobe_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	# Xenophile
	desc = {
		text = first_contact.10.xenophile.desc.proactive
		trigger = {
			first_contact_xenophile_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.xenophile.desc.cautious
		trigger = {
			first_contact_xenophile_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.xenophile.desc.attack_allowed
		trigger = {
			first_contact_xenophile_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	# Authoritarian
	desc = {
		text = first_contact.10.authoritarian.desc.proactive
		trigger = {
			first_contact_authoritarian_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.authoritarian.desc.cautious
		trigger = {
			first_contact_authoritarian_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.authoritarian.desc.attack_allowed
		trigger = {
			first_contact_authoritarian_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	# Egalitarian
	desc = {
		text = first_contact.10.egalitarian.desc.proactive
		trigger = {
			first_contact_egalitarian_desc = yes
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.10.egalitarian.desc.cautious
		trigger = {
			first_contact_egalitarian_desc = yes
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.10.egalitarian.desc.attack_allowed
		trigger = {
			first_contact_egalitarian_desc = yes
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}

	desc = {
		text = first_contact.10.desc.attack_allowed.gestalt
		trigger = {
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = yes
			}
		}
	}
	picture = GFX_evt_unknown_ships

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.10.B #deliberate, sorry
		custom_tooltip = first_contact.10.B.tooltip
		icon = {
			icon = GFX_option_icon_hostile
			text = hostile_first_contact_tt
		}

		if = {
			limit = {
				contact_country = {
					is_synthetic_empire = no
					is_same_species = root.owner
				}
			}
			set_first_contact_stage = default_end_stage_hostile_same_species
		}
		else = {
			set_first_contact_stage = default_hostile_ship_stage
		}
		set_first_contact_flag = hostile_first_contact_attempted

		trigger = {
			owner = { has_policy_flag = first_contact_attack_allowed }
		}

		ai_chance = {
			factor = 3
			modifier = {
				factor = 2
				owner = { is_xenophobe = yes }
			}
			modifier = {
				factor = 2
				owner = { is_militarist = yes }
			}
			modifier = {
				factor = 15
				owner = { is_homicidal = yes }
			}
		}
	}
	option = {
		name = first_contact.10.A

		if = {
			limit = {
				owner = {
					OR = {
						is_synthetic_empire = no
						has_country_flag = lost_colony_parent_of@prev
					}
					is_same_species = prev.contact_country
				}
			}
			set_first_contact_stage = default_end_stage_same_species
		}
		else_if = {
			limit = {
				#synths will still need to work it out
				owner = { is_machine_empire = yes }
				contact_country = { is_machine_empire = yes }
			}
			set_first_contact_stage = default_end_stage_both_machines
		}
		else_if = {
			limit = {
				owner = {
					is_hive_empire = yes
					is_wilderness_empire = no
				}
				contact_country = {
					is_hive_empire = yes
					is_wilderness_empire = no
				}
			}
			set_first_contact_stage = default_end_stage_both_hive_minds
		}
		else = {
			set_first_contact_stage = default_stage_2
		}
	}
}

# First contact with default empire, planets found.
first_contact_event = {
	id = first_contact.15
	title = first_contact.15.name

	# Default
	desc = {
		text = first_contact.15.desc
		trigger = {
			first_contact_default_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.desc.no_planets
		trigger = {
			first_contact_default_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	# Militarist
	desc = {
		text = first_contact.15.militarist.desc
		trigger = {
			first_contact_militarist_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.militarist.desc.no_planets
		trigger = {
			first_contact_militarist_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	# Pacifist
	desc = {
		text = first_contact.15.pacifist.desc
		trigger = {
			first_contact_pacifist_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.pacifist.desc.no_planets
		trigger = {
			first_contact_pacifist_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	# Spiritualist
	desc = {
		text = first_contact.15.spiritualist.desc
		trigger = {
			first_contact_spiritualist_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.spiritualist.desc.no_planets
		trigger = {
			first_contact_spiritualist_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	# Materialist
	desc = {
		text = first_contact.15.materialist.desc
		trigger = {
			first_contact_materialist_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.materialist.desc.no_planets
		trigger = {
			first_contact_materialist_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	# Xenophobe
	desc = {
		text = first_contact.15.xenophobe.desc
		trigger = {
			first_contact_xenophobe_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.xenophobe.desc.no_planets
		trigger = {
			first_contact_xenophobe_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	# Xenophile
	desc = {
		text = first_contact.15.xenophile.desc
		trigger = {
			first_contact_xenophile_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.xenophile.desc.no_planets
		trigger = {
			first_contact_xenophile_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	# Authoritarian
	desc = {
		text = first_contact.15.authoritarian.desc
		trigger = {
			first_contact_authoritarian_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.authoritarian.desc.no_planets
		trigger = {
			first_contact_authoritarian_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	# Egalitarian
	desc = {
		text = first_contact.15.egalitarian.desc
		trigger = {
			first_contact_egalitarian_desc = yes
			exists = event_target:known_planet
		}
	}
	desc = {
		text = first_contact.15.egalitarian.desc.no_planets
		trigger = {
			first_contact_egalitarian_desc = yes
			NOT = { exists = event_target:known_planet }
		}
	}

	inline_script = first_contact_event_sounds

	picture = GFX_evt_inhabited_solar_system

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		contact_country = {
			random_owned_planet = {
				limit = {
					root.owner = {
						intel_level = {
							level > low
							system = prev.solar_system
						}
					}
				}
				save_event_target_as = known_planet
				solar_system = {
					set_star_flag = first_contact_known_system@root.owner
				}

				if = {
					limit = {
						is_moon = yes
					}
					orbit = {
						generate_number_planet_in_system_flags = yes
					}
				}
				else = {
					generate_number_planet_in_system_flags = yes
				}
			}
			if = {
				limit = { NOT = { exists = event_target:known_planet } }
				random_system_within_border = {
					limit = {
						root.owner = {
							intel_level = {
								level > low
								system = prev
							}
						}
					}
					save_event_target_as = known_system
					set_star_flag = first_contact_known_system@root.owner
				}
			}
		}
	}

	after = {
		set_site_progress_locked = no
	}

	#you can see their system, so start alternative hostile chain
	option = {
		name = first_contact.15.B
		custom_tooltip = first_contact.280.B.tooltip
		icon = {
			icon = GFX_option_icon_hostile
			text = hostile_first_contact_tt
		}
		if = {
			limit = {
				contact_country = {
					is_synthetic_empire = no
					is_same_species = root.owner
				}
			}
			set_first_contact_stage = default_end_stage_hostile_same_species
		}
		else = {
			set_first_contact_stage = default_hostile_systems_stage
		}
		set_first_contact_flag = hostile_first_contact_attempted

		trigger = {
			owner = { has_policy_flag = first_contact_attack_allowed }
		}

		ai_chance = {
			factor = 3
			modifier = {
				factor = 2
				owner = { is_xenophobe = yes }
			}
			modifier = {
				factor = 2
				owner = { is_militarist = yes }
			}
			modifier = {
				factor = 15
				owner = { is_homicidal = yes }
			}
		}
	}

	option = {
		name = {
			trigger = {
				owner = { is_xenophile = yes }
			}
			text = FASCINATING
		}
		name = {
			trigger = {
				owner = { is_xenophobe = yes }
			}
			text = WORRYING
		}
		name = {
			trigger = {
				owner = {
					is_xenophile = no
					is_xenophobe = no
				}
			}
			text = first_contact.15.A
		}
		if = {
			limit = {
				owner = {
					OR = {
						is_synthetic_empire = no
						has_country_flag = lost_colony_parent_of@prev
					}
					is_same_species = prev.contact_country
				}
			}
			set_first_contact_stage = default_end_stage_same_species
		}
		else_if = {
			limit = {
				#synths will still need to work it out
				owner = { is_machine_empire = yes }
				contact_country = { is_machine_empire = yes }
			}
			set_first_contact_stage = default_end_stage_both_machines
		}
		else_if = {
			limit = {
				owner = {
					is_hive_empire = yes
					is_wilderness_empire = no
				}
				contact_country = {
					is_hive_empire = yes
					is_wilderness_empire = no
				}
			}
			set_first_contact_stage = default_end_stage_both_hive_minds
		}
		else = {
			set_first_contact_stage = default_stage_2
		}
	}
}

# First contact with nomadic empire, both nomadic, arkship within sensor range
first_contact_event = {
	id = first_contact.20
	title = first_contact.20.name

	desc = {
		text = first_contact.20.desc.proactive
		trigger = {
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.20.desc.cautious
		trigger = {
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.20.desc.attack_allowed
		trigger = {
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.20.desc.attack_allowed.gestalt
		trigger = {
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = yes
			}
		}
	}

	picture = GFX_evt_arkship_in_orbit

	is_triggered_only = yes
	first_contact = yes

	inline_script = first_contact_event_sounds

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.10.B
		custom_tooltip = first_contact.10.B.tooltip
		icon = {
			icon = GFX_option_icon_hostile
			text = hostile_first_contact_tt
		}
		trigger = {
			owner = { has_policy_flag = first_contact_attack_allowed }
		}
		if = {
			limit = {
				contact_country = {
					is_synthetic_empire = no
					is_same_species = root.owner
				}
			}
			set_first_contact_stage = default_end_stage_hostile_same_species
		}
		else = {
			set_first_contact_stage = default_hostile_ship_stage
		}
		set_first_contact_flag = hostile_first_contact_attempted

		ai_chance = {
			factor = 3
			modifier = {
				factor = 2
				owner = { is_xenophobe = yes }
			}
			modifier = {
				factor = 2
				owner = { is_militarist = yes }
			}
			modifier = {
				factor = 15
				owner = { is_homicidal = yes }
			}
		}
	}

	option = {
		name = first_contact.20.A
		if = {
			limit = {
				owner = {
					OR = {
						is_synthetic_empire = no
						has_country_flag = lost_colony_parent_of@prev
					}
					is_same_species = prev.contact_country
				}
			}
			set_first_contact_stage = default_end_stage_same_species
		}
		else_if = {
			limit = {
				owner = { is_machine_empire = yes }
				contact_country = { is_machine_empire = yes }
			}
			set_first_contact_stage = default_end_stage_both_machines
		}
		else_if = {
			limit = {
				owner = {
					is_hive_empire = yes
				}
				contact_country = {
					is_hive_empire = yes
				}
			}
			set_first_contact_stage = default_end_stage_both_hive_minds
		}
		else = {
			set_first_contact_stage = default_stage_2
		}
	}
}

# First contact with nomadic empire, non-nomadic observer, arkship within sensor range
first_contact_event = {
	id = first_contact.25
	title = first_contact.25.name

	desc = {
		text = first_contact.25.desc.proactive
		trigger = {
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.25.desc.cautious
		trigger = {
			owner = { has_policy_flag = first_contact_cautious }
		}
	}
	desc = {
		text = first_contact.25.desc.attack_allowed
		trigger = {
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.25.desc.attack_allowed.gestalt
		trigger = {
			owner = {
				has_policy_flag = first_contact_attack_allowed
				is_gestalt = yes
			}
		}
	}

	picture = GFX_evt_arkship_in_orbit

	is_triggered_only = yes
	first_contact = yes

	inline_script = first_contact_event_sounds

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.10.B
		custom_tooltip = first_contact.10.B.tooltip
		icon = {
			icon = GFX_option_icon_hostile
			text = hostile_first_contact_tt
		}
		trigger = {
			owner = { has_policy_flag = first_contact_attack_allowed }
		}
		if = {
			limit = {
				contact_country = {
					is_synthetic_empire = no
					is_same_species = root.owner
				}
			}
			set_first_contact_stage = default_end_stage_hostile_same_species
		}
		else = {
			set_first_contact_stage = default_hostile_ship_stage
		}
		set_first_contact_flag = hostile_first_contact_attempted

		ai_chance = {
			factor = 3
			modifier = {
				factor = 2
				owner = { is_xenophobe = yes }
			}
			modifier = {
				factor = 2
				owner = { is_militarist = yes }
			}
			modifier = {
				factor = 15
				owner = { is_homicidal = yes }
			}
		}
	}

	option = {
		name = first_contact.25.A
		if = {
			limit = {
				owner = {
					OR = {
						is_synthetic_empire = no
						has_country_flag = lost_colony_parent_of@prev
					}
					is_same_species = prev.contact_country
				}
			}
			set_first_contact_stage = default_end_stage_same_species
		}
		else_if = {
			limit = {
				owner = { is_machine_empire = yes }
				contact_country = { is_machine_empire = yes }
			}
			set_first_contact_stage = default_end_stage_both_machines
		}
		else_if = {
			limit = {
				owner = {
					is_hive_empire = yes
					is_wilderness_empire = no
				}
				contact_country = {
					is_hive_empire = yes
				}
			}
			set_first_contact_stage = default_end_stage_both_hive_minds
		}
		else = {
			set_first_contact_stage = default_stage_2
		}
	}
}

##### Stage 2 - Stories start here

# Default version where the other side is cautious
first_contact_event = {
	id = first_contact.50
	title = first_contact.50.name
	desc = {
		text = first_contact.50.desc
		trigger = {
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	desc = {
		text = first_contact.50.desc.aggressive
		trigger = {
			owner = { NOT = { has_policy_flag = first_contact_proactive } }
		}
	}
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		fire_on_action = { on_action = on_first_contact_generic_stage_2 }
		set_first_contact_flag = seen_aliens
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			trigger = {
				owner = { has_policy_flag = first_contact_cautious }
			}
			text = first_contact.50.A.cautious
		}
		name = {
			trigger = {
				owner = { has_policy_flag = first_contact_proactive }
			}
			text = first_contact.50.A.proactive
		}
		trigger = {
			owner = { has_policy_flag = first_contact_proactive }
		}

		set_first_contact_stage = default_end_stage_cautious
	}

	option = {
		name = {
			trigger = {
				owner = {
					is_machine_empire = no
					has_policy_flag = first_contact_cautious
				}
			}
			text = first_contact.50.A.cautious
		}
		name = {
			trigger = {
				owner = {
					is_machine_empire = no
					has_policy_flag = first_contact_attack_allowed
				}
			}
			text = first_contact.50.B
		}
		name = {
			trigger = {
				owner = { is_machine_empire = yes }
			}
			text = first_contact.50.B.machine
		}
		trigger = {
			owner = { NOT = { has_policy_flag = first_contact_proactive } }
		}

		set_first_contact_stage = default_end_stage_cautious
	}

	option = {
		name = {
			trigger = {
				owner = {
					is_machine_empire = no
					has_policy_flag = first_contact_cautious
				}
			}
			text = first_contact.50.C1
		}
		name = {
			trigger = {
				owner = {
					is_machine_empire = no
					has_policy_flag = first_contact_attack_allowed
				}
			}
			text = first_contact.50.C
		}
		name = {
			trigger = {
				owner = { is_machine_empire = yes }
			}
			text = first_contact.50.C.machine
		}
		trigger = {
			owner = { NOT = { has_policy_flag = first_contact_proactive } }
		}

		custom_tooltip = first_contact.50.C.tooltip
		set_first_contact_stage = default_hacking_stage_main

		ai_chance = {
			factor = 2
		}
	}
}


# Default version where the other side is proactive
first_contact_event = {
	id = first_contact.60
	title = first_contact.60.name
	desc = { # default > default
		text = first_contact.60.desc.default.default
		trigger = {
			owner = { is_gestalt = no }
			contact_country = { is_gestalt = no }
		}
	}
	desc = { # hive > default
		text = first_contact.60.desc.default.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			contact_country = { is_gestalt = no }
		}
	}
	desc = { # Wilderness > default
		text = first_contact.60.desc.default.wilderness
		trigger = {
			owner = { is_wilderness_empire = yes }
			contact_country = { is_gestalt = no }
		}
	}
	desc = { # machine > default
		text = first_contact.60.desc.default.machine
		trigger = {
			owner = { is_machine_empire = yes }
			contact_country = { is_gestalt = no }
		}
	}
	desc = { # default > hive
		text = first_contact.60.desc.hive.default
		trigger = {
			owner = { is_gestalt = no }
			contact_country = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
		}
	}
	desc = { # default > Wilderness
		text = first_contact.60.desc.wilderness.default
		trigger = {
			owner = { is_gestalt = no }
			contact_country = { is_wilderness_empire = yes }
		}
	}
	desc = { # machine > hive
		text = first_contact.60.desc.hive.machine
		trigger = {
			owner = { is_machine_empire = yes }
			contact_country = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
		}
	}
	desc = { # machine > Wilderness
		text = first_contact.60.desc.wilderness.machine
		trigger = {
			owner = { is_machine_empire = yes }
			contact_country = { is_wilderness_empire = yes }
		}
	}
	desc = { # default > machine
		text = first_contact.60.desc.machine.default
		trigger = {
			owner = { is_gestalt = no }
			contact_country = { is_machine_empire = yes }
		}
	}
	desc = { # hive > Wilderness
		text = first_contact.60.desc.wilderness.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			contact_country = { is_wilderness_empire = yes }
		}
	}
	desc = { # hive > machine
		text = first_contact.60.desc.machine.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			contact_country = { is_machine_empire = yes }
		}
	}
	desc = { # Wilderness > hive
		text = first_contact.60.desc.hive.wilderness
		trigger = {
			owner = { is_wilderness_empire = yes }
			contact_country = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
		}
	}
	desc = { # Wilderness > machine
		text = first_contact.60.desc.machine.wilderness
		trigger = {
			owner = { is_wilderness_empire = yes }
			contact_country = { is_machine_empire = yes }
		}
	}

	inline_script = first_contact_event_sounds

	picture = GFX_evt_mysterious_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		fire_on_action = { on_action = on_first_contact_generic_stage_2 }
		set_first_contact_flag = seen_aliens
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			trigger = {
				owner = { NOT = { has_policy_flag = first_contact_proactive } }
			}
			text = first_contact.60.A.cautious
		}
		name = {
			trigger = {
				owner = { has_policy_flag = first_contact_proactive }
			}
			text = first_contact.60.A.proactive
		}

		set_first_contact_stage = default_end_stage_proactive
	}
}



### Endings

# Normal first contact is completed
first_contact_event = {
	id = first_contact.100
	title = first_contact.100.name
	desc = {
		trigger = {
			owner = {
				NOR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
		}
		text = first_contact.100.desc
	}
	desc = {
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
		}
		text = first_contact.100.desc.homicidal
	}
	picture = {
		trigger = {
			owner = {
				OR = {
					is_militarist = yes
					is_xenophobe = yes
				}
			}
			contact_country = {
				is_machine_empire = no
			}
		}
		picture = GFX_evt_signing
	}
	picture = {
		trigger = {
			owner = {
				is_xenophobe = no
				is_militarist = no
				is_machine_empire = no
			}
			contact_country = {
				is_machine_empire = no
			}
		}
		picture = GFX_evt_hand_shake
	}
	picture = {
		trigger = {
			owner = { is_machine_empire = yes }
			contact_country = {
				is_machine_empire = no
			}
		}
		picture = GFX_evt_synth_organic_relations
	}
	picture = {
		trigger = {
			contact_country = {
				is_machine_empire = yes
			}
		}
		picture = GFX_evt_robot_encounter
	}
	show_sound = event_robot_encounter

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = ON_SCREEN
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# First contact with same species empire is completed
first_contact_event = {
	id = first_contact.101
	title = first_contact.101.name
	desc = {
		text = first_contact.101.desc
		trigger = {
			NOT = { has_first_contact_flag = hostile_first_contact_attempted }
		}
	}
	desc = {
		text = first_contact.101.desc.2
		trigger = {
			has_first_contact_flag = hostile_first_contact_attempted
		}
	}
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = first_contact.101.A
		trigger = {
			owner = { has_policy_flag = first_contact_proactive }
		}
	}
	option = {
		name = first_contact.101.B
		trigger = {
			NOT = { owner = { has_policy_flag = first_contact_proactive } }
		}
	}
	option = {
		name = first_contact.101.C
		trigger = {
			has_first_contact_flag = hostile_first_contact_attempted
		}
	}
	option = {
		name = first_contact.101.D
		trigger = {
			owner = {
				is_homicidal = yes
			}
		}
	}
}

# First contact between machines
first_contact_event = {
	id = first_contact.102
	title = first_contact.102.name
	desc = first_contact.102.desc

	picture = GFX_evt_robot_encounter
	show_sound = event_robot_encounter

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = {
			text = first_contact.102.A
			trigger = {
				owner = {
					NOT = { has_origin = origin_lost_colony }
				}
			}
		}
		name = {
			text = first_contact.102.B
			trigger = {
				owner = {
					has_origin = origin_lost_colony
				}
			}
		}
	}
}

first_contact_event = {
	id = first_contact.1020
	title = first_contact.102.name
	desc = first_contact.102.lostcolony.desc

	picture = GFX_evt_robot_encounter
	show_sound = event_robot_encounter

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = {
			text = first_contact.102.A
			trigger = {
				owner = {
					NOT = { has_origin = origin_lost_colony }
				}
			}
		}
		name = {
			text = first_contact.102.B
			trigger = {
				owner = {
					has_origin = origin_lost_colony
				}
			}
		}
	}
}

# First contact: default meets hive
first_contact_event = {
	id = first_contact.103
	title = first_contact.103.name
	desc = first_contact.103.desc
	picture = GFX_evt_hive_mind
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		owner = { set_country_flag = met_hive_mind }
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = first_contact.103.A
		trigger = {
			owner = {
				is_xenophobe = no
				NOT = { has_country_flag = met_hive_mind }
			}
		}
		allow = {
			owner = {
				is_egalitarian = no
			}
		}
		owner = {
			add_modifier = {
				modifier = first_contact_hive_drones_study
				days = 5400
			}
		}
	}
	option = {
		name = first_contact.103.B
		trigger = {
			owner = {
				is_xenophobe = no
				NOT = { has_country_flag = met_hive_mind }
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}
	option = {
		name = {
			text = first_contact.103.C1
			trigger = {
				owner = { is_homicidal = yes }
			}
		}
		name = {
			text = DISGUSTING
			trigger = {
				owner = { is_homicidal = no }
			}
		}
		trigger = {
			owner = { is_xenophobe = yes }
		}
	}
	option = {
		name = ON_SCREEN
		trigger = {
			owner = { has_country_flag = met_hive_mind }
		}
	}
}

# First contact: default/hive meet machines
# owner = player country | contact_country = other party
first_contact_event = {
	id = first_contact.104
	title = first_contact.104.name
	# Generic Machines & Driven Assimilators
	desc = {
		trigger = {
			NOT = { exists = event_target:secondary_species }
			owner = { is_wilderness_empire = no }
		}
		text = first_contact.104.desc.terminator_or_default
	}
	desc = {
		trigger = {
			NOT = { exists = event_target:secondary_species }
			owner = { is_wilderness_empire = yes }
		}
		text = first_contact.104.desc.terminator_or_default.wilderness
	}
	# Rogue Servitors
	desc = {
		trigger = {
			exists = event_target:secondary_species
			owner = { is_wilderness_empire = no }
			contact_country = {
				has_valid_civic = civic_machine_servitor
			}
		}
		text = first_contact.104.desc.servitor
	}
	desc = {
		trigger = {
			exists = event_target:secondary_species
			owner = { is_wilderness_empire = yes }
			contact_country = {
				has_valid_civic = civic_machine_servitor
			}
		}
		text = first_contact.104.desc.servitor.wilderness
	}
	# Driven Assimilators
	desc = {
		trigger = {
			exists = event_target:secondary_species
			owner = { is_hive_empire = no } # includes Wilderness
			contact_country = {
				has_valid_civic = civic_machine_assimilator
			}
		}
		text = first_contact.104.desc.assimilator.regular
	}
	desc = {
		trigger = {
			exists = event_target:secondary_species
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			contact_country = {
				has_valid_civic = civic_machine_assimilator
			}
		}
		text = first_contact.104.desc.assimilator.hive
	}
	desc = {
		trigger = {
			exists = event_target:secondary_species
			owner = { is_wilderness_empire = yes }
			contact_country = {
				has_valid_civic = civic_machine_assimilator
			}
		}
		text = first_contact.104.desc.assimilator.wilderness
	}
	picture = GFX_evt_robot_encounter
	show_sound = event_robot_encounter

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		contact_country = {
			random_owned_species = {
				limit = {
					OR = {
						has_citizenship_type = {
							type = citizenship_organic_trophy
							country = prev
						}
						has_trait = trait_cybernetic
					}
				}
				save_event_target_as = secondary_species
			}
		}
	}

	after = {
		set_site_progress_locked = no
		owner = { set_country_flag = met_machine_empire }
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = first_contact.104.A
		trigger = {
			owner = {
				is_gestalt = no
				is_homicidal = no
				NOT = { has_country_flag = met_machine_empire }
			}
		}
		allow = {
			owner = {
				is_spiritualist = no
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}
	option = {
		name = {
			text = first_contact.104.B1
			trigger = {
				owner = { is_spiritualist = yes }
			}
		}
		name = {
			text = first_contact.104.B2
			trigger = {
				owner = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		name = {
			text = first_contact.104.B3
			trigger = {
				owner = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
		trigger = {
			owner = {
				is_gestalt = no
				OR = {
					is_homicidal = yes
					is_spiritualist = yes
				}
			}
		}
	}
	option = {
		name = ON_SCREEN
		trigger = {
			owner = {
				OR = {
					is_gestalt = yes
					has_country_flag = met_machine_empire
				}
			}
		}
	}
}

# First contact between hives
first_contact_event = {
	id = first_contact.105
	title = first_contact.105.name
	desc = first_contact.105.desc
	picture = GFX_evt_hive_mind
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.105.A
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}


# Hacking Chain

#success, undetected
first_contact_event = {
	id = first_contact.200
	title = first_contact.200.name
	desc = first_contact.200.desc
	show_sound = event_spymaster

	picture = GFX_evt_spymaster

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = EXCELLENT

		set_first_contact_stage = default_end_stage_hacking
	}
}

#success, detected
first_contact_event = {
	id = first_contact.205
	title = first_contact.205.name
	desc = first_contact.205.desc
	show_sound = event_spymaster

	picture = GFX_evt_spymaster

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		contact_country = {
			country_event = { id = first_contact.206 }
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_caught_hacking
			}
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.205.A
		custom_tooltip = first_contact.215.A.tooltip #deliberate

		set_first_contact_stage = default_end_stage_hacking
	}
}

#other empire notified: success, detected
country_event = {
	id = first_contact.206
	title = first_contact.206.name
	desc = {
		trigger = { owner = { is_gestalt = no } }
		text = first_contact.206.desc.normal
	}
	desc = {
		trigger = { owner = { is_hive_empire = yes } }
		text = first_contact.206.desc.hive
	}
	desc = {
		trigger = { owner = { is_machine_empire = yes } }
		text = first_contact.206.desc.machine
	}

	show_sound = event_spymaster
	picture = GFX_evt_synth_sabotage

	is_triggered_only = yes

	option = {
		name = first_contact.206.A
	}
}

#failure, undetected
first_contact_event = {
	id = first_contact.210
	title = first_contact.210.name
	desc = first_contact.210.desc
	picture = GFX_evt_glitchy_matrix

	show_sound = event_comms_cutoff
	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.210.A

		if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_end_stage_cautious
		}
	}
}


#failure, detected
first_contact_event = {
	id = first_contact.215
	title = first_contact.215.name
	desc = first_contact.215.desc
	picture = GFX_evt_glitchy_matrix

	show_sound = event_comms_cutoff
	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		contact_country = {
			country_event = { id = first_contact.216 }
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_caught_hacking
			}
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.215.A
		custom_tooltip = first_contact.215.A.tooltip

		set_first_contact_stage = default_end_stage_cautious
	}
}

#other empire notified: failure, detected
country_event = {
	id = first_contact.216
	title = first_contact.216.name
	desc = {
		trigger = { owner = { is_gestalt = no } }
		text = first_contact.216.desc.normal
	}
	desc = {
		trigger = { owner = { is_hive_empire = yes } }
		text = first_contact.216.desc.hive
	}
	desc = {
		trigger = { owner = { is_machine_empire = yes } }
		text = first_contact.216.desc.machine
	}
	picture = GFX_evt_synth_sabotage

	show_sound = event_spymaster
	is_triggered_only = yes

	option = {
		name = first_contact.216.A
	}
}

# Hacking first contact is completed
first_contact_event = {
	id = first_contact.220
	title = first_contact.220.name
	desc = {
		text = first_contact.220.desc.physics
		trigger = {
			owner = {
				NOR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
			has_first_contact_flag = steal_physics
		}
	}
	desc = {
		text = first_contact.220.desc.society
		trigger = {
			owner = {
				NOR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
			has_first_contact_flag = steal_society
		}
	}
	desc = {
		text = first_contact.220.desc.engineering
		trigger = {
			owner = {
				NOR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
			has_first_contact_flag = steal_engineering
		}
	}
	desc = {
		text = first_contact.220.desc.nothing
		trigger = {
			owner = {
				NOR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
			has_first_contact_flag = steal_nothing_possible
		}
	}
	desc = {
		text = first_contact.220.desc.homicidal.physics
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
			has_first_contact_flag = steal_physics
		}
	}
	desc = {
		text = first_contact.220.desc.homicidal.society
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
			has_first_contact_flag = steal_society
		}
	}
	desc = {
		text = first_contact.220.desc.homicidal.engineering
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
			has_first_contact_flag = steal_engineering
		}
	}
	desc = {
		text = first_contact.220.desc.homicidal.nothing
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_homicidal = yes
				}
			}
			has_first_contact_flag = steal_nothing_possible
		}
	}
	picture = GFX_evt_spymaster
	show_sound = event_spymaster

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		if = {
			limit = {
				owner = {
					can_copy_random_tech_from = {
						who = root.contact_country
						area = physics
					}
				}
			}
			set_first_contact_flag = steal_physics
		}
		else_if = {
			limit = {
				owner = {
					can_copy_random_tech_from = {
						who = root.contact_country
						area = society
					}
				}
			}
			set_first_contact_flag = steal_society
		}
		else_if = {
			limit = {
				owner = {
					can_copy_random_tech_from = {
						who = root.contact_country
						area = engineering
					}
				}
			}
			set_first_contact_flag = steal_engineering
		}
		else = {
			set_first_contact_flag = steal_nothing_possible
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = ON_SCREEN

		switch = {
			trigger = has_first_contact_flag
			steal_physics = {
				owner = {
					copy_random_tech_from = {
						who = root.contact_country
						area = physics
						progress = 0.1
					}
				}
			}
			steal_society = {
				owner = {
					copy_random_tech_from = {
						who = root.contact_country
						area = society
						progress = 0.1
					}
				}
			}
			steal_engineering = {
				owner = {
					copy_random_tech_from = {
						who = root.contact_country
						area = engineering
						progress = 0.1
					}
				}
			}
			steal_nothing_possible = {
				owner = {
					add_monthly_resource_mult = {
						resource = unity
						value = @tier1unityreward
						min = @tier1unitymin
						max = @tier1unitymax
					}
				}
			}
		}

		finish_first_contact_effect = yes

		owner = {
			first_contact_add_intel = {
				INTEL = 5
			}
		}
	}
}



### Fully hostile chain 1: Capture their ship

# You capture them and their ship alive (best)
first_contact_event = {
	id = first_contact.250
	title = first_contact.250.name
	desc = {
		text = first_contact.250.desc
		trigger = {
			contact_country = {
				is_gestalt = no
				NOR = {
					has_origin = origin_syncretic_evolution
					AND = {
						has_origin = origin_necrophage
						NOT = { has_valid_civic = civic_fanatic_purifiers }
					}
					pop_amount_percentage = {
						percentage > 0.25
						limit = {
							is_organic_species = yes
							NOT = { is_same_species = owner_species }
						}
					}
				}
			}
		}
	}
	desc = {
		text = first_contact.250.desc.multispecies
		trigger = {
			contact_country = {
				is_gestalt = no
				OR = {
					has_origin = origin_syncretic_evolution
					AND = {
						has_origin = origin_necrophage
						NOT = { has_valid_civic = civic_fanatic_purifiers }
					}
					pop_amount_percentage = {
						percentage > 0.25
						limit = {
							is_organic_species = yes
							NOT = { is_same_species = owner_species }
						}
					}
				}
			}
		}
	}
	desc = {
		text = first_contact.250.desc.machine_victim
		trigger = {
			contact_country = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.250.desc.hive_victim
		trigger = {
			contact_country = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
		}
	}
	desc = {
		text = first_contact.250.desc.wilderness_victim
		trigger = {
			contact_country = { is_wilderness_empire = yes }
		}
	}
	picture = GFX_evt_face_off_in_space
	show_sound = event_faceoff_in_space

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		first_contact_get_ship_to_capture = yes #generates event_target:fleet_to_seize
		set_first_contact_flag = succeeded_capture_attempt
		set_first_contact_flag = seen_aliens
		reverse_first_contact = { set_first_contact_flag = seen_aliens }
		owner = {
			set_timed_relation_flag = {
				who = root.contact_country
				flag = vivisectors
				years = 25
			}
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.250.A
		hidden_effect = {
			event_target:fleet_to_seize = {
				destroy_fleet = this
			}
			contact_country = {
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact
				}
				first_contact_send_fleets_mia = yes
				country_event = { id = first_contact.252 }
			}
		}
		if = {
			limit = {
				contact_country = {
					is_gestalt = yes
				}
			}
			set_first_contact_stage = default_end_stage_hostile_with_crew_hard
		}
		else_if = {
			limit = {
				contact_country = {
					OR = {
						has_trait = trait_weak
						has_trait = trait_docile
					}
				}
			}
			hidden_effect = { set_first_contact_flag = weak_interrogees }
			set_first_contact_stage = default_end_stage_hostile_with_crew_easy
		}
		else_if = {
			limit = {
				contact_country = {
					OR = {
						has_trait = trait_strong
						has_trait = trait_very_strong
					}
				}
			}
			hidden_effect = { set_first_contact_flag = strong_interrogees }
			set_first_contact_stage = default_end_stage_hostile_with_crew_hard
		}
		else = {
			set_first_contact_stage = default_end_stage_hostile_with_crew
		}

		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				owner = {
					OR = {
						is_homicidal = yes
						is_fanatic_xenophobe = yes
					}
				}
			}
		}
	}
	option = {
		name = {
			text = first_contact.250.B
			trigger = {
				contact_country = {
					is_machine_empire = no
				}
			}
		}
		name = {
			text = first_contact.250.B.machine
			trigger = {
				contact_country = {
					is_machine_empire = yes
				}
			}
		}
		hidden_effect = {
			event_target:fleet_to_seize = {
				destroy_fleet = this
			}
			contact_country = {
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact_vivisection
				}
				first_contact_send_fleets_mia = yes
				country_event = { id = first_contact.253 }
			}
		}
		if = {
			limit = {
				contact_country = {
					is_machine_empire = no
				}
				owner = { has_origin = origin_evolutionary_predators }
			}
			owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = medium } }
		}
		custom_tooltip = first_contact.250.B.tooltip
		set_first_contact_stage = default_end_stage_hostile_with_vivisection
		ai_chance = {
			factor = 1
			modifier = {
				factor = 5
				owner = { is_xenophobe = yes }
			}
		}
	}
	option = {
		name = first_contact.250.C
		trigger = {
			owner = {
				is_homicidal = yes
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
		hidden_effect = {
			event_target:fleet_to_seize = {
				destroy_fleet = this
			}
			contact_country = {
				add_opinion_modifier = { #it accumulates
					who = root.owner
					modifier = opinion_hostile_first_contact
				}
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact
				}
				first_contact_send_fleets_mia = yes
				country_event = { id = first_contact.254 }
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
			}
		}
		custom_tooltip = first_contact.250.C.homicidal_tooltip
		set_first_contact_stage = default_end_stage_hostile_no_crew
		ai_chance = {
			factor = 1
			modifier = {
				factor = 100
				owner = { has_civic = civic_machine_terminator }
			}
		}
	}
	option = {
		name = first_contact.250.C.devourers
		trigger = {
			owner = { has_valid_civic = civic_hive_devouring_swarm }
		}
		if = {
			limit = {
				contact_country = {
					OR = {
						is_synthetic_empire = yes
						is_individual_machine = yes
					}
				}
			}
			owner = {
				add_resource = {
					influence = 50
				}
				add_monthly_resource_mult = {
					resource = alloys
					value = @tier1materialreward
					min = @tier1materialmin
				}
			}
		}
		else_if = {
			limit = { contact_country = { is_lithoid = yes } }
			owner = {
				add_resource = {
					influence = 50
				}
				add_monthly_resource_mult = {
					resource = minerals
					value = @tier1materialreward
					min = @tier1materialmin
				}
			}
		}
		else = {
			owner = {
				add_resource = {
					influence = 50
				}
				add_monthly_resource_mult = {
					resource = food
					value = @tier1materialreward
					min = @tier1materialmin
				}
			}
		}
		if = {
			limit = {
				contact_country = {
					is_machine_empire = no
				}
				owner = { has_origin = origin_evolutionary_predators }
			}
			owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small } }
		}
		hidden_effect = {
			event_target:fleet_to_seize = {
				destroy_fleet = this
			}
			contact_country = {
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact_hungry
				}
				first_contact_send_fleets_mia = yes
				country_event = { id = first_contact.254 }
			}
		}
		custom_tooltip = first_contact.250.C.homicidal_tooltip
		set_first_contact_stage = default_end_stage_hostile_no_crew

		ai_chance = {
			factor = 100
		}
	}
}

# Notification for other side: interrogation
# this = victim | from = first contact site | from.owner = aggressor
country_event = {
	id = first_contact.252
	title = first_contact.252.name
	desc = {
		text = first_contact.252.desc.normal
		trigger = {
			owner = { is_gestalt = no }
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.252.desc.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.252.desc.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.252.desc.machine_enemy.normal
		trigger = {
			owner = { is_hive_empire = no }
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.252.desc.machine_enemy.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.252.desc.machine_enemy.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.252.desc.hive_enemy.normal
		trigger = {
			owner = { is_machine_empire = no }
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.252.desc.hive_enemy.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.252.desc.hive_enemy.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.252.desc.wilderness
		trigger = {
			owner = { is_wilderness_empire = yes }
			# Valid for all aggressor types
		}
	}
	picture = GFX_evt_face_off_in_space
	show_sound = event_faceoff_in_space

	is_triggered_only = yes

	immediate = {
		set_hostile = from.owner
	}

	option = {
		name = first_contact.252.A
		if = {
			limit = { from = { has_first_contact_flag = fleets_sent_mia } }
			custom_tooltip = first_contact_fleets_mia_tooltip
		}
	}
}

# Notification for other side: vivisection
# this = victim | from = first contact site | from.owner = aggressor
country_event = {
	id = first_contact.253
	title = first_contact.253.name
	desc = {
		text = first_contact.253.desc.normal
		trigger = {
			owner = { is_gestalt = no }
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.253.desc.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.253.desc.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.253.desc.machine_enemy.normal
		trigger = {
			owner = { is_hive_empire = no }
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.253.desc.machine_enemy.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.253.desc.machine_enemy.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.253.desc.hive_enemy.normal
		trigger = {
			owner = { is_machine_empire = no }
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.253.desc.hive_enemy.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.253.desc.hive_enemy.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.253.desc.wilderness
		trigger = {
			owner = { is_wilderness_empire = yes }
			# Valid for all aggressor types
		}
	}
	picture = GFX_evt_vivisection
	show_sound = event_vivisection

	is_triggered_only = yes

	immediate = {
		set_hostile = from.owner
	}

	option = {
		name = {
			text = first_contact.254.A
			trigger = {
				owner = {
					is_homicidal = no
					is_militarist = no
					is_spiritualist = no
				}
				from.owner = {
					NOT = { has_valid_civic = civic_hive_devouring_swarm }
				}
			}
		}
		name = {
			text = first_contact.254.A2
			trigger = {
				owner = {
					is_homicidal = no
					is_spiritualist = yes
				}
			}
		}
		name = {
			text = first_contact.254.A3
			trigger = {
				owner = {
					is_homicidal = no
					OR = {
						is_militarist = yes
						is_xenophobe = yes
					}
					is_pacifist = no
				}
			}
		}
		name = {
			text = first_contact.254.A.devourer
			trigger = {
				owner = { is_homicidal = yes }
				OR = {
					owner = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
					from.owner = {
						NOT = { has_valid_civic = civic_hive_devouring_swarm }
					}
				}
			}
		}
		name = {
			text = first_contact.254.B
			trigger = {
				owner = {
					is_homicidal = no
					is_spiritualist = no
				}
				from.owner = {
					has_valid_civic = civic_hive_devouring_swarm
				}
			}
		}
		name = {
			text = first_contact.253.B.devourer
			trigger = {
				owner = { has_valid_civic = civic_hive_devouring_swarm }
				from.owner = {
					has_valid_civic = civic_hive_devouring_swarm
				}
			}
		}
		if = {
			limit = { from = { has_first_contact_flag = fleets_sent_mia } }
			custom_tooltip = first_contact_fleets_mia_tooltip
		}
	}
}

# Notification for other side: death
# this = victim | from = first contact site | from.owner = aggressor
country_event = {
	id = first_contact.254
	title = first_contact.254.name
	desc = {
		text = first_contact.254.desc.normal
		trigger = {
			owner = { is_gestalt = no }
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.254.desc.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.254.desc.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.254.desc.machine_enemy.normal
		trigger = {
			owner = { is_hive_empire = no }
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.254.desc.machine_enemy.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.254.desc.machine_enemy.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.254.desc.hive_enemy.normal
		trigger = {
			owner = { is_machine_empire = no }
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.254.desc.hive_enemy.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.254.desc.hive_enemy.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.254.desc.wilderness
		trigger = {
			owner = { is_wilderness_empire = yes }
			# Valid for all aggressor types
		}
	}
	picture = GFX_evt_face_off_in_space
	show_sound = event_vivisection

	is_triggered_only = yes

	immediate = {
		set_hostile = from.owner
	}

	option = {
		name = {
			text = first_contact.254.A
			trigger = {
				owner = {
					is_homicidal = no
					is_militarist = no
					is_spiritualist = no
				}
				from.owner = {
					NOT = { has_valid_civic = civic_hive_devouring_swarm }
				}
			}
		}
		name = {
			text = first_contact.254.A2
			trigger = {
				owner = {
					is_homicidal = no
					is_spiritualist = yes
				}
			}
		}
		name = {
			text = first_contact.254.A3
			trigger = {
				owner = {
					is_homicidal = no
					OR = {
						is_militarist = yes
						is_xenophobe = yes
					}
					is_pacifist = no
				}
			}
		}
		name = {
			text = first_contact.254.A.devourer
			trigger = {
				owner = { is_homicidal = yes }
				OR = {
					owner = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
					from.owner = {
						NOT = { has_valid_civic = civic_hive_devouring_swarm }
					}
				}
			}
		}
		name = {
			text = first_contact.254.B
			trigger = {
				owner = {
					is_homicidal = no
					is_spiritualist = no
				}
				from.owner = {
					has_valid_civic = civic_hive_devouring_swarm
				}
			}
		}
		name = {
			text = first_contact.254.B.devourer
			trigger = {
				owner = { has_valid_civic = civic_hive_devouring_swarm }
				from.owner = {
					has_valid_civic = civic_hive_devouring_swarm
				}
			}
		}
		if = {
			limit = { from = { has_first_contact_flag = fleets_sent_mia } }
			custom_tooltip = first_contact_fleets_mia_tooltip
		}
	}
}

# You capture the ship intact but no living hostages, computer systems intact
first_contact_event = {
	id = first_contact.260
	title = first_contact.260.name
	desc = {
		text = first_contact.260.desc
		trigger = {
			contact_country = {
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.260.desc.machine_victim
		trigger = {
			contact_country = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.260.desc.hive_victim
		trigger = {
			contact_country = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
		}
	}
	desc = {
		text = first_contact.260.desc.wilderness_victim
		trigger = {
			contact_country = { is_wilderness_empire = yes }
		}
	}
	picture = GFX_evt_interior_battle
	show_sound = event_faceoff_in_space

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		first_contact_get_ship_to_capture = yes #generates event_target:fleet_to_seize
		set_first_contact_flag = succeeded_capture_attempt
		set_first_contact_flag = seen_aliens
		reverse_first_contact = { set_first_contact_flag = seen_aliens }

		event_target:fleet_to_seize = {
			destroy_fleet = this
		}

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_hostile_first_contact
			}
			first_contact_send_fleets_mia = yes
		}
		contact_country = { country_event = { id = first_contact.262 } }
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.260.A
		set_first_contact_stage = default_end_stage_hostile_no_crew
	}
}

# Notification for other side
# this = victim | from = first contact site | from.owner = aggressor
country_event = {
	id = first_contact.262
	title = first_contact.262.name
	desc = {
		text = first_contact.262.desc.normal
		trigger = {
			owner = { is_gestalt = no }
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.262.desc.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.262.desc.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_machine_empire = no
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
	}
	desc = {
		text = first_contact.262.desc.machine_enemy.normal
		trigger = {
			owner = { is_hive_empire = no }
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.262.desc.machine_enemy.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.262.desc.machine_enemy.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.262.desc.hive_enemy.normal
		trigger = {
			owner = { is_machine_empire = no }
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.262.desc.hive_enemy.machine
		trigger = {
			owner = { is_machine_empire = yes }
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.262.desc.hive_enemy.hive
		trigger = {
			owner = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
			from.owner = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.262.desc.wilderness
		trigger = {
			owner = { is_wilderness_empire = yes }
			# Valid for all aggressor types
		}
	}
	picture = GFX_evt_face_off_in_space
	show_sound = event_faceoff_in_space

	is_triggered_only = yes

	immediate = {
		set_hostile = from.owner
	}

	option = {
		name = {
			text = WORRYING
			trigger = {
				is_militarist = no
				OR = {
					is_pacifist = yes
					is_xenophobe = no
				}
			}
		}
		name = {
			text = first_contact.272.B #deliberate
			trigger = {
				OR = {
					is_militarist = yes
					is_xenophobe = yes
				}
				is_pacifist = no
			}
		}
		if = {
			limit = { from = { has_first_contact_flag = fleets_sent_mia } }
			custom_tooltip = first_contact_fleets_mia_tooltip
		}
	}
}

# You accidentally destroy the ship
first_contact_event = {
	id = first_contact.270
	title = first_contact.270.name
	desc = first_contact.270.desc
	desc = first_contact.270.desc2
	picture = GFX_evt_exploding_ship
	show_sound = event_ship_explosion

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		first_contact_get_ship_to_capture = yes #generates event_target:fleet_to_seize
		set_first_contact_flag = failed_capture_attempt

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_hostile_first_contact
			}
		}
	}

	after = {
		set_site_progress_locked = no

		event_target:fleet_to_seize = {
			destroy_and_spawn_debris_for = root.owner
		}
		hidden_effect = {
			contact_country = {
				every_controlled_fleet = {
					limit = {
						NOT = { is_same_value = event_target:fleet_to_seize }
						is_within_borders_of = root.owner
						is_mobile = yes
						if = {
							limit = { prev = { is_hostile = root.owner } }
							is_civilian = yes
						}
					}
					set_mia = mia_return_home
					root = {
						set_first_contact_flag = fleets_sent_mia
					}
				}
			}
			contact_country = { country_event = { id = first_contact.272 } }
		}
	}

	option = {
		name = first_contact.270.A
		set_first_contact_stage = default_end_stage_cautious
	}

	#you can see their system, so start alternative hostile chain (with a malus if you were caught before)
	option = {
		name = first_contact.270.B
		custom_tooltip = first_contact.270.B.tooltip
		trigger = { first_contact_can_see_their_system = yes }
		hidden_effect = {
			contact_country = {
				random_system_within_border = {
					limit = {
						root.owner = {
							intel_level = {
								level > low
								system = prev
							}
						}
					}
					set_star_flag = first_contact_known_system@root.owner
				}
			}
		}
		set_first_contact_stage = default_hostile_systems_stage
	}
}

# Notification for other side
country_event = {
	id = first_contact.272
	title = first_contact.272.name
	desc = first_contact.272.desc
	picture = GFX_evt_exploding_ship
	show_sound = event_ship_explosion

	is_triggered_only = yes

	immediate = {
		set_hostile = from.owner
	}

	option = {
		name = {
			text = WORRYING
			trigger = {
				is_militarist = no
				OR = {
					is_pacifist = yes
					is_xenophobe = no
				}
			}
		}
		name = {
			text = first_contact.272.B
			trigger = {
				OR = {
					is_militarist = yes
					is_xenophobe = yes
				}
				is_pacifist = no
			}
		}
		if = {
			limit = { from = { has_first_contact_flag = fleets_sent_mia } }
			custom_tooltip = first_contact_fleets_mia_tooltip
		}
	}
}

# failure, they escaped
first_contact_event = {
	id = first_contact.280
	title = first_contact.280.name
	desc = {
		trigger = { NOT = { exists = event_target:fleet_to_seize } }
		text = first_contact.280.desc.just_left
	}
	desc = {
		trigger = { exists = event_target:fleet_to_seize }
		text = first_contact.280.desc.failed
	}
	picture = {
		trigger = { NOT = { exists = event_target:fleet_to_seize } }
		picture = GFX_evt_wormhole
	}
	picture = {
		trigger = { exists = event_target:fleet_to_seize }
		picture = GFX_evt_face_off_in_space
	}
	show_sound = event_mysterious_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		if = {
			limit = {
				first_contact_can_capture_ship = yes
			}
			first_contact_get_ship_to_capture = yes #generates event_target:fleet_to_seize
			set_first_contact_flag = failed_capture_attempt

			event_target:fleet_to_seize = {
				set_mia = mia_return_home
			}
			contact_country = {
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact
				}
				every_controlled_fleet = {
					limit = {
						NOT = { is_same_value = event_target:fleet_to_seize }
						is_within_borders_of = root.owner
						is_mobile = yes
						if = {
							limit = { prev = { is_hostile = root.owner } }
							is_civilian = yes
						}
					}
					set_mia = mia_return_home
					root = {
						set_first_contact_flag = fleets_sent_mia
					}
				}
				country_event = { id = first_contact.282 }
			}
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.280.A
		if = {
			limit = {
				has_first_contact_flag = failed_capture_attempt
			}
			set_first_contact_stage = default_end_stage_cautious
		}
		else_if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_end_stage_cautious
		}
	}

	#you can see their system, so start alternative hostile chain (with a malus if you were caught before)
	option = {
		name = first_contact.280.B
		icon = {
			icon = GFX_option_icon_hostile
			text = hostile_first_contact_tt
		}
		if = {
			limit = { has_first_contact_flag = failed_capture_attempt }
			custom_tooltip = first_contact.270.B.tooltip
		}
		else = { custom_tooltip = first_contact.280.B.tooltip }
		trigger = { first_contact_can_see_their_system = yes }
		hidden_effect = {
			contact_country = {
				random_system_within_border = {
					limit = {
						root.owner = {
							intel_level = {
								level > low
								system = prev
							}
						}
					}
					set_star_flag = first_contact_known_system@root.owner
				}
			}
		}
		set_first_contact_stage = default_hostile_systems_stage
	}
}

# Notification for other side
country_event = {
	id = first_contact.282
	title = first_contact.282.name
	desc = {
		text = first_contact.282.desc
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.282.desc.gestalt
		trigger = {
			owner = {
				is_gestalt = yes
			}
		}
	}
	picture = GFX_evt_face_off_in_space
	show_sound = event_faceoff_in_space

	is_triggered_only = yes

	immediate = {
		set_hostile = from.owner
	}

	option = {
		name = WORRYING
		if = {
			limit = { from = { has_first_contact_flag = fleets_sent_mia } }
			custom_tooltip = first_contact_fleets_mia_tooltip
		}
	}
}


# Hostile interrogations end
first_contact_event = {
	id = first_contact.285
	title = first_contact.285.name
	desc = {
		trigger = {
			contact_country = { is_gestalt = no }
			NOR = {
				has_first_contact_flag = weak_interrogees
				has_first_contact_flag = strong_interrogees
			}
		}
		text = first_contact.285.desc
	}
	desc = {
		trigger = {
			contact_country = { is_gestalt = no }
			has_first_contact_flag = weak_interrogees
		}
		text = first_contact.285.desc.weak
	}
	desc = {
		trigger = {
			contact_country = { is_gestalt = no }
			has_first_contact_flag = strong_interrogees
		}
		text = first_contact.285.desc.strong
	}
	desc = {
		trigger = {
			contact_country = { is_machine_empire = yes }
		}
		text = first_contact.285.desc.machine_victim
	}
	desc = {
		trigger = {
			contact_country = {
				is_hive_empire = yes
				is_wilderness_empire = no
			}
		}
		text = first_contact.285.desc.hive_victim
	}
	desc = {
		trigger = {
			contact_country = { is_wilderness_empire = yes }
		}
		text = first_contact.285.desc.wilderness_victim
	}
	picture = GFX_evt_face_off_in_space
	show_sound = event_vivisection

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = EXCELLENT
		trigger = {
			contact_country = {
				is_gestalt = no
			}
		}
		finish_first_contact_effect = yes
		owner = {
			if = {
				limit = {
					root = { has_first_contact_flag = weak_interrogees }
				}
				first_contact_add_intel = {
					INTEL = 15
				}
				first_contact_grant_random_tech_option = { PROGRESS = 0.3 }
			}
			else_if = {
				limit = {
					root = { has_first_contact_flag = strong_interrogees }
				}
				first_contact_add_intel = {
					INTEL = 5
				}
				first_contact_grant_random_tech_option = { PROGRESS = 0.1 }
			}
			else = {
				first_contact_add_intel = {
					INTEL = 10
				}
				first_contact_grant_random_tech_option = { PROGRESS = 0.2 }
			}
		}
	}
	option = {
		name = EXCELLENT
		trigger = {
			contact_country = {
				is_gestalt = yes
			}
		}
		finish_first_contact_effect = yes
		owner = {
			first_contact_add_intel = {
				INTEL = 5
			}
			first_contact_grant_random_tech_option = { PROGRESS = 0.2 }
		}
	}
}

# Hostile vivisections end
first_contact_event = {
	id = first_contact.290
	title = first_contact.290.name
	desc = {
		text = first_contact.290.desc
		trigger = {
			contact_country = {
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.290.desc.wilderness_victim # suitable regardless how many vessels remain
		exclusive_trigger = {
			contact_country = { is_wilderness_empire = yes }
		}
	}
	desc = {
		text = first_contact.290.desc.hive_victim
		trigger = {
			NOT = { has_first_contact_flag = no_vessel }
			contact_country = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.290.desc.hive_victim.no_vessel
		trigger = {
			has_first_contact_flag = no_vessel
			contact_country = {
				is_hive_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.290.desc.machine_victim
		trigger = {
			contact_country = {
				is_machine_empire = yes
			}
		}
	}
	picture = GFX_evt_vivisection
	show_sound = event_vivisection

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		finish_first_contact_effect = yes

		owner = {
			hidden_effect = {
				set_country_flag = they_come_in_pieces_achievement
			}
			if = {
				limit = {
					root.contact_country = {
						is_machine_empire = yes
					}
				}
				if = {
					limit = {
						can_copy_random_tech_from = {
							who = root.contact_country
							category = computing
						}
					}
					copy_random_tech_from = {
						who = root.contact_country
						category = computing
						progress = 0.5
					}
				}
				else = {
					add_monthly_resource_mult = {
						resource = engineering_research
						value = @tier3researchreward
						min = @tier3researchmin
					}
				}
			}
			else = {
				if = {
					limit = {
						can_copy_random_tech_from = {
							who = root.contact_country
							category = biology
						}
					}
					copy_random_tech_from = {
						who = root.contact_country
						category = biology
						progress = 0.5
					}
				}
				else = {
					add_monthly_resource_mult = {
						resource = society_research
						value = @tier3researchreward
						min = @tier3researchmin
					}
				}
				if = {
					limit = { has_nemesis = yes }
					custom_tooltip = gain_asset_internal_organs
					hidden_effect = {
						random_spynetwork = {
							limit = { target = { is_same_value = root.contact_country } }
							create_espionage_asset = { type = asset_internal_organs }
						}
					}
				}
			}
			first_contact_add_intel = {
				INTEL = 15
			}
		}
		set_site_progress_locked = no
	}

	option = {
		trigger = {
			owner = {
				NOT = { has_origin = origin_evolutionary_predators }
			}
		}
		name = first_contact.290.A
	}

	option = { #Separate option just to get the little icon on the left
		exclusive_trigger = {
			contact_country = {
				is_machine_empire = no
			}
			owner = {
				has_origin = origin_evolutionary_predators
			}
		}
		name = first_contact.290.A

		owner = {
			root.contact_country.species = {
				switch = {
					trigger = is_species_class
					HUM = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = humanoid } }
					}
					MAM = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = mammalian } }
					}
					REP = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = reptilian } }
					}
					AVI = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = avian } }
					}
					ART = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = arthropoid } }
					}
					MOL = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = molluscoid } }
					}
					FUN = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = fungoid } }
					}
					PLANT = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = plantoid } }
					}
					LITHOID = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = lithoid } }
					}
					NECROID = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = necroid } }
					}
					AQUATIC = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = aquatic } }
					}
					TOX = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = toxoid } }
					}
					MINDWARDEN = {
						root.owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = small TYPE = reptilian } }
					}
				}
			}
		}
	}
}

# Hostile no crew end
first_contact_event = {
	id = first_contact.295
	title = first_contact.295.name
	desc = {
		text = first_contact.295.desc
		trigger = {
			NOT = { has_first_contact_flag = no_vessel }
		}
	}
	desc = {
		text = first_contact.295.desc.no_ship
		trigger = {
			has_first_contact_flag = no_vessel
		}
	}
	picture = GFX_evt_ancient_databank
	show_sound = event_spymaster

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = EXCELLENT
		finish_first_contact_effect = yes
		owner = {
			first_contact_add_intel = {
				INTEL = 5
			}
			first_contact_grant_random_tech_option = { PROGRESS = 0.1 }
		}
	}
}


# Hostile systems chain

#You capture something
first_contact_event = {
	id = first_contact.320
	title = first_contact.320.name
	desc = {
		text = first_contact.320.desc.planet.normal.normal
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_gestalt = no }
			contact_country = {
				OR = {
					is_regular_empire = yes
					is_hive_empire = yes
				}
			}
		}
	}
	desc = {
		text = first_contact.320.desc.planet.normal.machine
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_gestalt = no }
			contact_country = { is_machine_empire = yes }
		}
	}
	desc = {
		text = first_contact.320.desc.planet.gestalt.normal
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_gestalt = yes }
			contact_country = {
				OR = {
					is_regular_empire = yes
					is_hive_empire = yes
				}
			}
		}
	}
	desc = {
		text = first_contact.320.desc.planet.hive.machine
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_hive_empire = yes }
			contact_country = { is_machine_empire = yes }
		}
	}
	desc = {
		text = first_contact.320.desc.planet.machine.machine
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_machine_empire = yes }
			contact_country = { is_machine_empire = yes }
		}
	}
	desc = {
		text = first_contact.320.desc.no_planet.normal.normal
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = { is_gestalt = no }
			contact_country = {
				OR = {
					is_regular_empire = yes
					is_hive_empire = yes
				}
			}
		}
	}
	desc = {
		text = first_contact.320.desc.no_planet.normal.machine
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = { is_gestalt = no }
			contact_country = { is_machine_empire = yes }
		}
	}
	desc = {
		text = first_contact.320.desc.no_planet.gestalt.normal
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = { is_gestalt = yes }
			contact_country = {
				OR = {
					is_regular_empire = yes
					is_hive_empire = yes
				}
			}
		}
	}
	desc = {
		text = first_contact.320.desc.no_planet.hive.machine
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = { is_hive_empire = yes }
			contact_country = { is_machine_empire = yes }
		}
	}
	desc = {
		text = first_contact.320.desc.no_planet.machine.machine
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = { is_machine_empire = yes }
			contact_country = { is_machine_empire = yes }
		}
	}
	picture = {
		picture = GFX_evt_alien_abduction
		trigger = {
			exists = event_target:abduction_planet
		}
	}
	picture = {
		picture = GFX_evt_unidentified_ship
		trigger = {
			NOT = { exists = event_target:abduction_planet }
		}
	}
	show_sound = event_alien_abduction

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		set_first_contact_flag = seen_aliens
		reverse_first_contact = { set_first_contact_flag = seen_aliens }

		contact_country = {
			random_owned_planet = {
				limit = {
					OR = {
						is_surveyed = {
							who = root.owner
							status = yes
						}
						solar_system = {
							root.owner = {
								intel_level = {
									level > low
									system = prev
								}
							}
						}
					}
				}
				save_event_target_as = abduction_planet
				root = { set_first_contact_flag = no_vessel }
			}
		}
		if = {
			limit = { NOT = { exists = event_target:abduction_planet } }
			contact_country = {
				random_system_within_border = {
					limit = {
						OR = {
							is_surveyed = {
								who = root.owner
								status = yes
							}
							root.owner = {
								intel_level = {
									level > low
									system = prev
								}
							}
						}
					}
					save_event_target_as = abduction_system
				}
			}
		}
		if = {
			limit = { NOT = { exists = event_target:abduction_system } }
			random_system = {
				limit = {
					has_star_flag = first_contact_known_system@root.owner
				}
				save_event_target_as = abduction_system
			}
		}
		owner = {
			set_timed_relation_flag = {
				who = root.contact_country
				flag = vivisectors
				years = 25
			}
		}
	}

	after = {
		set_site_progress_locked = no
		hidden_effect = {
			contact_country = { country_event = { id = first_contact.322 } }
		}
	}

	option = {
		name = {
			text = first_contact.320.A
			trigger = {
				contact_country = {
					is_machine_empire = no
				}
				owner = { is_gestalt = no }
			}
		}
		name = {
			text = first_contact.320.A2
			trigger = {
				OR = {
					contact_country = {
						is_machine_empire = yes
					}
					owner = { is_gestalt = yes }
				}
			}
		}
		custom_tooltip = first_contact.320.A.tooltip
		hidden_effect = {
			owner = {
				every_controlled_fleet = {
					limit = {
						is_within_borders_of = root.contact_country
						is_mobile = yes
						if = {
							limit = { prev = { is_hostile = root.contact_country } }
							is_civilian = yes
						}
					}
					set_mia = mia_return_home
				}
			}
			contact_country = {
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact
				}
			}
		}
		if = {
			limit = {
				contact_country = {
					is_gestalt = yes
				}
			}
			set_first_contact_stage = default_end_stage_hostile_with_crew_hard
		}
		else_if = {
			limit = {
				contact_country = {
					OR = {
						has_trait = trait_weak
						has_trait = trait_docile
					}
				}
			}
			hidden_effect = { set_first_contact_flag = weak_interrogees }
			set_first_contact_stage = default_end_stage_hostile_with_crew_easy
		}
		else_if = {
			limit = {
				contact_country = {
					OR = {
						has_trait = trait_strong
						has_trait = trait_very_strong
					}
				}
			}
			hidden_effect = { set_first_contact_flag = strong_interrogees }
			set_first_contact_stage = default_end_stage_hostile_with_crew_hard
		}
		else = {
			set_first_contact_stage = default_end_stage_hostile_with_crew
		}

		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				owner = {
					OR = {
						is_homicidal = yes
						is_fanatic_xenophobe = yes
					}
				}
			}
		}
	}
	option = {
		name = {
			text = first_contact.250.B
			trigger = {
				contact_country = {
					is_machine_empire = no
				}
			}
		}
		name = {
			text = first_contact.250.B.machine
			trigger = {
				contact_country = {
					is_machine_empire = yes
				}
			}
		}
		hidden_effect = {
			contact_country = {
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact_vivisection
				}
			}
		}
		custom_tooltip = first_contact.250.B.tooltip
		set_first_contact_stage = default_end_stage_hostile_with_vivisection

		ai_chance = {
			factor = 1
			modifier = {
				factor = 5
				owner = { is_xenophobe = yes }
			}
		}
	}

	option = {
		name = first_contact.250.C
		trigger = {
			owner = {
				is_homicidal = yes
				NOT = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
			}
		}
		if = {
			limit = { has_first_contact_flag = no_vessel }
			custom_tooltip = first_contact.320.C.homicidal_tooltip
		}
		else = {
			custom_tooltip = first_contact.250.C.homicidal_tooltip
		}
		set_first_contact_stage = default_end_stage_hostile_no_crew

		ai_chance = {
			factor = 1
			modifier = {
				factor = 100
				owner = { has_civic = civic_machine_terminator }
			}
		}
	}
	option = {
		name = first_contact.250.C.devourers
		trigger = {
			owner = { has_valid_civic = civic_hive_devouring_swarm }
		}
		if = {
			limit = {
				contact_country = {
					OR = {
						is_synthetic_empire = yes
						is_individual_machine = yes
					}
				}
			}
			owner = {
				add_resource = {
					influence = 50
				}
				add_monthly_resource_mult = {
					resource = alloys
					value = @tier1materialreward
					min = @tier1materialmin
				}
			}
		}
		else_if = {
			limit = { contact_country = { is_lithoid = yes } }
			owner = {
				add_resource = {
					influence = 50
				}
				add_monthly_resource_mult = {
					resource = minerals
					value = @tier1materialreward
					min = @tier1materialmin
				}
			}
		}
		else = {
			owner = {
				add_resource = {
					influence = 50
				}
				add_monthly_resource_mult = {
					resource = food
					value = @tier1materialreward
					min = @tier1materialmin
				}
			}
		}
		if = {
			limit = { has_first_contact_flag = no_vessel }
			custom_tooltip = first_contact.320.C.homicidal_tooltip
		}
		else = {
			custom_tooltip = first_contact.250.C.homicidal_tooltip
		}
		set_first_contact_stage = default_end_stage_hostile_no_crew

		ai_chance = {
			factor = 100
		}
	}
}

# Notification for other side (they don't know what you're doing, so only one needed)
country_event = {
	id = first_contact.322
	title = first_contact.322.name
	desc = {
		text = first_contact.322.desc.planet
		trigger = {
			exists = event_target:abduction_planet
			owner = {
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.322.desc.no_planet
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = {
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.322.desc.planet.gestalt
		trigger = {
			exists = event_target:abduction_planet
			owner = {
				is_gestalt = yes
				is_wilderness_empire = no
			}
		}
	}
	desc = {
		text = first_contact.322.desc.planet.wilderness
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_wilderness_empire = yes }
		}
	}
	desc = {
		text = first_contact.322.desc.no_planet.gestalt
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = {
				is_gestalt = yes # includes Wilderness
			}
		}
	}
	picture = {
		picture = GFX_evt_alien_abduction
		trigger = {
			exists = event_target:abduction_planet
		}
	}
	picture = {
		picture = GFX_evt_unidentified_ship
		trigger = {
			NOT = { exists = event_target:abduction_planet }
		}
	}
	show_sound = event_alien_abduction

	immediate = {
		set_hostile = from.owner
	}

	is_triggered_only = yes

	option = {
		name = WORRYING
	}
}


#You fail spectacularly
first_contact_event = {
	id = first_contact.321
	title = first_contact.321.name
	desc = first_contact.321.desc.mega_oops
	picture = GFX_evt_alien_abduction
	show_sound = event_alien_abduction

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		owner = { set_country_flag = abducted_cows }

		contact_country = {
			random_owned_planet = {
				limit = {
					OR = {
						is_surveyed = {
							who = root.owner
							status = yes
						}
						solar_system = {
							root.owner = {
								intel_level = {
									level > low
									system = prev
								}
							}
						}
					}
				}
				save_event_target_as = abduction_planet
			}
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.321.A
		custom_tooltip = first_contact.320.A.tooltip
		hidden_effect = {
			owner = {
				every_controlled_fleet = {
					limit = {
						is_within_borders_of = root.contact_country
						is_mobile = yes
						if = {
							limit = { prev = { is_hostile = root.contact_country } }
							is_civilian = yes
						}
					}
					set_mia = mia_return_home
				}
			}
			contact_country = {
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact
				}
			}
		}
		set_first_contact_stage = default_end_stage_cautious
	}
}


#You fail
first_contact_event = {
	id = first_contact.330
	title = first_contact.330.name
	desc = {
		text = first_contact.330.desc.planet
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_gestalt = no }
		}
	}
	desc = {
		text = first_contact.330.desc.planet.gestalt
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_gestalt = yes }
		}
	}
	desc = {
		text = first_contact.330.desc.no_planet
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = { is_gestalt = no }
		}
	}
	desc = {
		text = first_contact.330.desc.no_planet.gestalt
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = { is_gestalt = yes }
		}
	}
	picture = {
		picture = GFX_evt_alien_abduction
		trigger = {
			exists = event_target:abduction_planet
		}
	}
	picture = {
		picture = GFX_evt_unidentified_ship
		trigger = {
			NOT = { exists = event_target:abduction_planet }
		}
	}
	show_sound = event_alien_abduction

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		contact_country = {
			random_owned_planet = {
				limit = {
					OR = {
						is_surveyed = {
							who = root.owner
							status = yes
						}
						solar_system = {
							root.owner = {
								intel_level = {
									level > low
									system = prev
								}
							}
						}
					}
				}
				save_event_target_as = abduction_planet
			}
		}
		if = {
			limit = { NOT = { exists = event_target:abduction_planet } }
			contact_country = {
				random_system_within_border = {
					limit = {
						OR = {
							is_surveyed = {
								who = root.owner
								status = yes
							}
							root.owner = {
								intel_level = {
									level > low
									system = prev
								}
							}
						}
					}
					save_event_target_as = abduction_system
				}
			}
		}
		if = {
			limit = { NOT = { exists = event_target:abduction_system } }
			random_system = {
				limit = {
					has_star_flag = first_contact_known_system@root.owner
				}
				save_event_target_as = abduction_system
			}
		}
	}

	after = {
		set_site_progress_locked = no
		hidden_effect = {
			contact_country = { country_event = { id = first_contact.332 } }
		}
	}

	option = {
		name = first_contact.330.A
		custom_tooltip = first_contact.320.A.tooltip
		if = {
			limit = {
				exists = leader
			}
			leader = {
				kill_leader = {
					show_notification = no
				}
			}
		}
		hidden_effect = {
			owner = {
				every_controlled_fleet = {
					limit = {
						is_within_borders_of = root.contact_country
						is_mobile = yes
						if = {
							limit = { prev = { is_hostile = root.contact_country } }
							is_civilian = yes
						}
					}
					set_mia = mia_return_home
				}
			}
			contact_country = {
				add_opinion_modifier = {
					who = root.owner
					modifier = opinion_hostile_first_contact
				}
			}
		}
		set_first_contact_stage = default_end_stage_cautious
	}
}

# Notification for other side
country_event = {
	id = first_contact.332
	title = first_contact.332.name
	desc = {
		text = first_contact.332.desc.planet
		trigger = {
			exists = event_target:abduction_planet
			owner = {
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.332.desc.planet.machine_enemy
		trigger = {
			exists = event_target:abduction_planet
			owner = {
				is_gestalt = no
			}
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.332.desc.no_planet
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = {
				is_gestalt = no
			}
		}
	}
	desc = {
		text = first_contact.332.desc.planet.gestalt
		trigger = {
			exists = event_target:abduction_planet
			owner = {
				is_gestalt = yes
				is_wilderness_empire = no
			}
		}
	}
	desc = {
		text = first_contact.332.desc.planet.wilderness
		trigger = {
			exists = event_target:abduction_planet
			owner = { is_wilderness_empire = yes }
		}
	}
	desc = {
		text = first_contact.332.desc.planet.gestalt.machine_enemy
		trigger = {
			exists = event_target:abduction_planet
			owner = {
				is_hive_empire = yes
			}
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.332.desc.planet.gestalt.machine_enemy.machine
		trigger = {
			exists = event_target:abduction_planet
			owner = {
				is_machine_empire = yes
			}
			from.owner = {
				is_machine_empire = yes
			}
		}
	}
	desc = {
		text = first_contact.332.desc.no_planet.gestalt
		trigger = {
			NOT = { exists = event_target:abduction_planet }
			owner = {
				is_gestalt = yes # includes Wilderness
			}
		}
	}
	picture = {
		picture = GFX_evt_alien_abduction
		trigger = {
			exists = event_target:abduction_planet
		}
	}
	picture = {
		picture = GFX_evt_unidentified_ship
		trigger = {
			NOT = { exists = event_target:abduction_planet }
		}
	}
	show_sound = event_alien_abduction

	is_triggered_only = yes

	immediate = {
		set_hostile = from.owner
	}

	option = {
		name = first_contact.332.A

		random_active_first_contact = {
			limit = {
				contact_country = {
					is_same_value = from.owner
				}
			}
			if = {
				limit = {
					exists = event_target:abduction_planet
				}
				add_stage_clues = 4
			}
			else = {
				add_stage_clues = 2
			}
		}
	}
}

### Speaking in Riddles

first_contact_event = {
	id = first_contact.350
	title = first_contact.350.name
	desc = first_contact.350.desc
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_speaking_in_riddles_chain }
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.350.A
		if = {
			limit = {
				contact_country = {
					has_policy_flag = first_contact_proactive
				}
			}
			set_first_contact_stage = default_end_stage_riddles_proactive
		}
		else = {
			set_first_contact_stage = default_end_stage_riddles_cautious
		}
	}
}

first_contact_event = {
	id = first_contact.355
	title = first_contact.355.name
	desc = {
		text = first_contact.355.desc
		trigger = {
			owner = { is_gestalt = no }
		}
	}
	desc = {
		text = first_contact.355.desc.gestalt
		trigger = {
			owner = { is_gestalt = yes }
		}
	}
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = first_contact.355.A
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_not_very_intelligent
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		set_site_progress_locked = no
	}
	option = {
		name = first_contact.355.B
		hidden_effect = {
			first_contact_event = { id = first_contact.356 }
		}
	}
}


first_contact_event = {
	id = first_contact.356
	title = first_contact.356.name
	desc = first_contact.356.desc
	picture = GFX_evt_mysterious_signal
	show_sound = event_default

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		contact_country = {
			create_leader = {
				name = random
				class = scientist
				species = this
				effect = {
					save_event_target_as = riddles_leader_1
					exile_leader_as = riddles_leader_1
				}
			}
			create_leader = {
				name = random
				class = scientist
				species = this
				effect = {
					save_event_target_as = riddles_leader_2
					exile_leader_as = riddles_leader_2
				}
			}
		}
		random_list = {
			1 = { set_first_contact_flag = option_A_correct }
			1 = { set_first_contact_flag = option_B_correct }
		}
	}

	option = {
		name = first_contact.356.A1
		name = first_contact.356.A2
		name = first_contact.356.A3
		custom_tooltip = first_contact.356.option.tooltip
		hidden_effect = {
			if = {
				limit = { has_first_contact_flag = option_A_correct }
				first_contact_event = { id = first_contact.357 }
			}
			else = {
				first_contact_event = { id = first_contact.358 }
			}
		}
	}
	option = {
		name = first_contact.356.B1
		name = first_contact.356.B2
		name = first_contact.356.B3
		custom_tooltip = first_contact.356.option.tooltip
		hidden_effect = {
			if = {
				limit = { has_first_contact_flag = option_B_correct }
				first_contact_event = { id = first_contact.357 }
			}
			else = {
				first_contact_event = { id = first_contact.358 }
			}
		}
	}
	option = {
		name = first_contact.356.C
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_not_very_intelligent
			}
		}
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		set_site_progress_locked = no
	}
}

first_contact_event = {
	id = first_contact.357
	title = first_contact.357.name
	desc = first_contact.357.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	option = {
		name = {
			trigger = {
				owner = { is_xenophobe = no }
			}
			text = first_contact.357.A
		}
		name = {
			trigger = {
				owner = { is_xenophobe = yes }
			}
			text = first_contact.357.B
		}
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_speak_like_us
			}
		}
		owner = {
			add_modifier = {
				modifier = first_contact_speak_like_us_country
				years = 25
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		set_site_progress_locked = no

		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				owner = { is_xenophobe = yes }
			}
		}
	}
	option = {
		name = first_contact.357.C
		custom_tooltip = first_contact.357.C.tooltip
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_speak_like_us
			}
		}
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		hidden_effect = {
			owner = {
				random_spynetwork = {
					limit = { target = { is_same_value = root.contact_country } }
					add_modifier = {
						modifier = first_contact_speak_like_us_spynetwork
						years = 25
					}
				}
			}
		}
		set_site_progress_locked = no

		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				owner = { is_xenophile = yes }
			}
		}
	}
}

first_contact_event = {
	id = first_contact.358
	title = first_contact.358.name
	desc = first_contact.358.desc
	picture = GFX_evt_worrying_signal
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	option = {
		name = first_contact.358.A
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_very_insulting
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		set_site_progress_locked = no
	}
}

### Monstrous Noises

first_contact_event = {
	id = first_contact.365
	title = first_contact.365.name
	desc = first_contact.365.desc
	picture = GFX_evt_worrying_signal
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_monstrous_noises_chain }
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.365.A

		owner = {
			add_modifier = {
				modifier = first_contact_challenge_not_returned
				days = 5400
			}
		}

		if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_monstrous_noises_no_action_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_monstrous_noises_no_action_end_stage_cautious
		}
	}
	option = {
		name = first_contact.365.B
		custom_tooltip = first_contact.365.B.tooltip

		tooltip = { set_first_contact_stage = default_monstrous_noises_notification_stage }
		hidden_effect = {
			random_list = {
				9 = { set_first_contact_stage = default_monstrous_noises_notification_stage }
				1 = {
					modifier = {
						factor = 0
						contact_country = { is_pacifist = yes }
					}
					first_contact_event = { id = first_contact.500 }
					set_first_contact_stage = default_end_stage_cautious
				}
			}
		}
	}
	option = {
		name = {
			text = first_contact.365.C
			trigger = {
				owner = {
					is_pacifist = no
					OR = {
						is_xenophile = no
						is_militarist = yes
					}
				}
			}
		}
		name = {
			text = first_contact.365.C.pacifist
			trigger = {
				owner = {
					Or = {
						is_pacifist = yes
						AND = {
							is_xenophile = yes
							is_militarist = no
						}
					}
				}
			}
		}
		custom_tooltip = first_contact.365.C.tooltip

		owner = {
			add_modifier = {
				modifier = first_contact_war_preparations
				days = 5400
			}
		}
		if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_end_stage_cautious
		}
	}
}

first_contact_event = {
	id = first_contact.370
	title = first_contact.370.name
	desc = first_contact.370.desc1
	desc = first_contact.370.desc2
	picture = GFX_evt_worrying_signal
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = INTRIGUING
		set_first_contact_stage = default_monstrous_noises_end_stage
	}
	option = {
		name = WORRYING
		set_first_contact_stage = default_monstrous_noises_end_stage
	}
}

# Ending: They are purifiers
first_contact_event = {
	id = first_contact.375
	title = first_contact.375.name
	desc = first_contact.375.desc
	picture = GFX_evt_worrying_signal
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			text = first_contact.375.A.militarist
			trigger = {
				owner = {
					is_militarist = yes
				}
			}
		}
		name = {
			text = first_contact.375.A.xenophobe
			trigger = {
				owner = {
					is_xenophobe = yes
				}
			}
		}
		name = {
			text = first_contact.375.A.materialist
			trigger = {
				owner = {
					is_materialist = yes
				}
			}
		}
		name = {
			text = first_contact.375.A.others
			trigger = {
				owner = {
					is_militarist = no
					is_xenophobe = no
				}
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# Ending: You showed yourself worthy to the challenge
first_contact_event = {
	id = first_contact.376
	title = first_contact.376.name
	desc = first_contact.376.desc
	picture = GFX_evt_victorious_army
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			trigger = {
				owner = { is_militarist = yes }
			}
			text = first_contact.376.A.mil
		}
		name = {
			trigger = {
				owner = { is_pacifist = yes }
			}
			text = first_contact.376.A.pac
		}
		name = {
			trigger = {
				owner = {
					is_militarist = no
					is_pacifist = no
				}
			}
			text = first_contact.376.A.other
		}

		owner = {
			if = {
				limit = {
					is_militarist = yes
				}
				add_modifier = {
					modifier = first_contact_warlike_warriors_recognised
					years = 10
				}
			}
			else = {
				add_modifier = {
					modifier = first_contact_warlike_warriors_presumed
					years = 10
				}
			}
		}

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_respect_earned
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# Ending: You've just insulted their mother
first_contact_event = {
	id = first_contact.377
	title = first_contact.377.name
	desc = first_contact.377.desc
	picture = GFX_evt_partition
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.377.A
		trigger = {
			owner = { is_xenophobe = no }
		}

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_quite_insulting
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes

		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = first_contact.377.B
		trigger = {
			owner = { is_xenophile = no }
		}

		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
			}
		}

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_very_insulting
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes

		ai_chance = {
			factor = 100
		}
	}
}

# Ending: Warriors; you are cowardly
first_contact_event = {
	id = first_contact.378
	title = first_contact.378.name
	desc = first_contact.378.desc
	picture = GFX_evt_alien_segregation
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			trigger = {
				owner = { is_militarist = yes }
			}
			text = first_contact.378.A.mil
		}
		name = {
			trigger = {
				owner = {
					is_militarist = no
				}
			}
			text = first_contact.378.A.other
		}

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_cowardly
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# Ending: Standard empire
first_contact_event = {
	id = first_contact.379
	title = first_contact.379.name
	desc = first_contact.379.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			trigger = { owner = { is_materialist = yes } }
			text = first_contact.379.A.mat
		}
		name = {
			trigger = { owner = { is_materialist = no } }
			text = first_contact.379.A
		}

		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes

		ai_chance = {
			factor = 1
		}
	}
}

#Hive minds have just discovered the individual

first_contact_event = {
	id = first_contact.380
	title = first_contact.380.name
	desc = {
		trigger = {
			owner = { is_wilderness_empire = no }
			contact_country = {
				has_policy_flag = first_contact_proactive
			}
		}
		text = first_contact.380.desc.proactive
	}
	desc = {
		trigger = {
			owner = { is_wilderness_empire = no }
			contact_country = {
				NOT = { has_policy_flag = first_contact_proactive }
			}
		}
		text = first_contact.380.desc.cautious
	}
	desc = {
		trigger = {
			owner = { is_wilderness_empire = yes }
			contact_country = {
				has_policy_flag = first_contact_proactive
			}
		}
		text = first_contact.380.desc.proactive.wilderness
	}
	desc = {
		trigger = {
			owner = { is_wilderness_empire = yes }
			contact_country = {
				NOT = { has_policy_flag = first_contact_proactive }
			}
		}
		text = first_contact.380.desc.cautious.wilderness
	}
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		set_first_contact_flag = seen_aliens
		owner = {
			set_country_flag = hive_encountered_default
		}
		set_first_contact_flag = seen_aliens
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			text = first_contact.380.A
			trigger = {
				owner = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
			}
		}
		name = {
			text = first_contact.380.A.devourer
			trigger = {
				owner = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}

		if = {
			limit = {
				contact_country = {
					has_policy_flag = first_contact_proactive
				}
			}
			set_first_contact_stage = hive_meets_default_end_stage_proactive
		}
		else = {
			set_first_contact_stage = hive_meets_default_end_stage_cautious
		}
	}
}

first_contact_event = {
	id = first_contact.385
	title = first_contact.385.name
	desc = {
		trigger = {
			owner = {
				NOR = {
					has_valid_civic = civic_hive_devouring_swarm
					is_wilderness_empire = yes
				}
			}
		}
		text = first_contact.385.desc.non_devourer
	}
	desc = {
		trigger = {
			owner = { has_valid_civic = civic_hive_devouring_swarm }
		}
		text = first_contact.385.desc.devourer
	}
	desc = {
		trigger = {
			owner = { is_wilderness_empire = yes }
		}
		text = first_contact.385.desc.wilderness
	}
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			text = first_contact.385.A
			trigger = {
				owner = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
			}
		}
		name = {
			text = first_contact.385.A.devourer
			trigger = {
				owner = { has_valid_civic = civic_hive_devouring_swarm }
			}
		}

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

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

#Machines have just discovered the non-machine

first_contact_event = {
	id = first_contact.390
	title = first_contact.390.name
	desc = {
		trigger = {
			contact_country = {
				has_policy_flag = first_contact_proactive
				is_wilderness_empire = no
			}
		}
		text = first_contact.390.desc.proactive
	}
	desc = {
		trigger = {
			contact_country = {
				NOT = { has_policy_flag = first_contact_proactive }
				is_wilderness_empire = no
			}
		}
		text = first_contact.390.desc.cautious
	}
	desc = {
		trigger = {
			contact_country = {
				has_policy_flag = first_contact_proactive
				is_wilderness_empire = yes
			}
		}
		text = first_contact.390.desc.wilderness.proactive
	}
	desc = {
		trigger = {
			contact_country = {
				NOT = { has_policy_flag = first_contact_proactive }
				is_wilderness_empire = yes
			}
		}
		text = first_contact.390.desc.wilderness.cautious
	}
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		if = {
			limit = {
				contact_country = {
					is_hive_empire = yes
				}
			}
			owner = {
				set_country_flag = machine_encountered_hive
			}
		}
		else = {
			owner = {
				set_country_flag = machine_encountered_default
			}
		}
		set_first_contact_flag = seen_aliens
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			text = INTERESTING
			trigger = {
				owner = {
					NOR = {
						has_valid_civic = civic_machine_terminator
						has_valid_civic = civic_machine_assimilator
						has_valid_civic = civic_machine_servitor
					}
				}
			}
		}
		name = {
			text = first_contact.390.A.terminator
			trigger = {
				owner = { has_valid_civic = civic_machine_terminator }
			}
		}
		name = {
			text = first_contact.390.A.assimilator
			trigger = {
				owner = { has_valid_civic = civic_machine_assimilator }
			}
		}
		name = {
			text = first_contact.390.A.servitor
			trigger = {
				owner = { has_valid_civic = civic_machine_servitor }
			}
		}

		if = {
			limit = {
				contact_country = {
					has_policy_flag = first_contact_proactive
				}
			}
			if = {
				limit = {
					contact_country = {
						is_hive_empire = yes
					}
				}
				set_first_contact_stage = machine_meets_hive_end_stage_proactive
			}
			else = {
				set_first_contact_stage = machine_meets_default_end_stage_proactive
			}
		}
		else_if = {
			limit = {
				contact_country = {
					is_hive_empire = yes
				}
			}
			set_first_contact_stage = machine_meets_hive_end_stage_cautious
		}
		else = {
			set_first_contact_stage = machine_meets_default_end_stage_cautious
		}
	}
}

# machine->hive
first_contact_event = {
	id = first_contact.395
	title = first_contact.395.name
	desc = {
		exclusive_trigger = {
			contact_country = { is_wilderness_empire = yes }
		}
		text = first_contact.395.desc.they_wilderness # suitable for all Machine types
	}
	desc = {
		trigger = {
			owner = {
				NOR = {
					has_valid_civic = civic_machine_terminator
					has_valid_civic = civic_machine_assimilator
					has_valid_civic = civic_machine_servitor
				}
			}
		}
		text = first_contact.395.desc.standard
	}
	desc = {
		trigger = {
			owner = { has_valid_civic = civic_machine_terminator }
		}
		text = first_contact.395.desc.terminator
	}
	desc = {
		trigger = {
			owner = { has_valid_civic = civic_machine_assimilator }
		}
		text = first_contact.395.desc.assimilator
	}
	desc = {
		trigger = {
			owner = { has_valid_civic = civic_machine_servitor }
		}
		text = first_contact.395.desc.servitor
	}
	picture = GFX_evt_mysterious_signal
	show_sound = event_mysterious_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			text = first_contact.395.A
			trigger = {
				owner = {
					NOR = {
						has_valid_civic = civic_machine_terminator
						has_valid_civic = civic_machine_assimilator
						has_valid_civic = civic_machine_servitor
					}
				}
			}
		}
		name = {
			trigger = {
				owner = { has_valid_civic = civic_machine_terminator }
			}
			text = first_contact.395.A.terminator
		}
		name = {
			trigger = {
				owner = { has_valid_civic = civic_machine_assimilator }
				contact_country = { is_wilderness_empire = no }
			}
			text = first_contact.395.A.assimilator
		}
		name = {
			trigger = {
				owner = { has_valid_civic = civic_machine_assimilator }
				contact_country = { is_wilderness_empire = yes }
			}
			text = first_contact.395.A.assimilator_wilderness
		}
		name = {
			trigger = {
				owner = { has_valid_civic = civic_machine_servitor }
			}
			text = first_contact.395.A.servitor
		}

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

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# machine->default
first_contact_event = {
	id = first_contact.397
	title = first_contact.397.name
	desc = {
		trigger = {
			owner = {
				NOR = {
					has_valid_civic = civic_machine_terminator
					has_valid_civic = civic_machine_assimilator
					has_valid_civic = civic_machine_servitor
				}
			}
		}
		text = first_contact.397.desc.standard
	}
	desc = {
		trigger = {
			owner = { has_valid_civic = civic_machine_terminator }
		}
		text = first_contact.397.desc.terminator
	}
	desc = {
		trigger = {
			owner = {
				has_valid_civic = civic_machine_assimilator
				exists = event_target:secondary_species
			}
		}
		text = first_contact.397.desc.assimilator
	}
	desc = {
		trigger = {
			owner = {
				has_valid_civic = civic_machine_servitor
				exists = event_target:secondary_species
			}
		}
		text = first_contact.397.desc.servitor
	}
	picture = GFX_evt_synth_organic_relations
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = {
			if = {
				limit = {
					OR = {
						has_valid_civic = civic_machine_assimilator
						has_valid_civic = civic_machine_servitor
					}
				}
				random_owned_species = {
					limit = {
						OR = {
							has_citizenship_type = {
								type = citizenship_organic_trophy
								country = root.owner
							}
							has_trait = trait_cybernetic
						}
					}
					save_event_target_as = secondary_species
				}
			}
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			text = first_contact.397.A
			trigger = {
				owner = {
					NOR = {
						has_valid_civic = civic_machine_terminator
						has_valid_civic = civic_machine_assimilator
						has_valid_civic = civic_machine_servitor
					}
				}
			}
		}
		name = {
			trigger = {
				owner = { has_valid_civic = civic_machine_terminator }
			}
			text = first_contact.397.A.terminator
		}
		name = {
			trigger = {
				owner = { has_valid_civic = civic_machine_assimilator }
			}
			text = first_contact.397.A.assimilator
		}
		name = {
			trigger = {
				owner = { has_valid_civic = civic_machine_servitor }
			}
			text = first_contact.397.A.servitor
		}

		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier3unityreward
				min = @tier3unitymin
				max = @tier3unitymax
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

## Apparent Hostility

first_contact_event = {
	id = first_contact.400
	title = first_contact.400.name
	desc = {
		trigger = { owner = { is_gestalt = no } }
		text = first_contact.400.desc
	}
	desc = {
		trigger = { owner = { is_gestalt = yes } }
		text = first_contact.400.desc.gestalt
	}
	picture = GFX_evt_worrying_signal
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_apparent_hostility_chain }
		set_first_contact_flag = seen_aliens
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.400.A
		custom_tooltip = first_contact.400.A.tooltip
		tooltip = { set_first_contact_stage = default_apparent_hostility_end_stage }
		hidden_effect = {
			random_list = {
				9 = { set_first_contact_stage = default_apparent_hostility_end_stage }
				1 = {
					modifier = {
						factor = 0
						contact_country = { is_pacifist = yes }
					}
					first_contact_event = { id = first_contact.500 }
					set_first_contact_stage = default_end_stage_cautious
				}
			}
		}
	}
	option = {
		name = first_contact.400.B
		custom_tooltip = first_contact.400.B.tooltip
		if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_apparent_hostility_no_action_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_apparent_hostility_no_action_end_stage_cautious
		}
	}
}

# Ending: You contacted them, it went averagely
first_contact_event = {
	id = first_contact.405
	title = first_contact.405.name
	desc = first_contact.405.desc
	picture = GFX_evt_signing
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			trigger = {
				owner = {
					is_pacifist = no
				}
			}
			text = first_contact.405.A
		}
		name = {
			trigger = {
				owner = {
					is_pacifist = yes
				}
			}
			text = first_contact.405.A.pacifist
		}

		owner = {
			if = {
				limit = {
					is_militarist = yes
				}
				add_modifier = {
					modifier = first_contact_warlike_warriors_recognised_2
					years = 10
				}
			}
			else = {
				add_modifier = {
					modifier = first_contact_warlike_warriors_presumed_2
					years = 10
				}
			}
		}

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_rivalry_earned
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# Ending: You contacted them, it went well
first_contact_event = {
	id = first_contact.406
	title = first_contact.406.name
	desc = first_contact.406.desc
	picture = GFX_evt_victorious_army
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			trigger = {
				owner = {
					NOR = {
						is_pacifist = yes
						is_homicidal = yes
					}
					is_xenophobe = no
				}
			}
			text = first_contact.406.A
		}
		name = {
			trigger = {
				owner = {
					is_xenophobe = yes
				}
			}
			text = first_contact.406.A.xenophobe
		}
		name = {
			trigger = {
				owner = {
					OR = {
						is_pacifist = yes
						is_homicidal = yes
					}
				}
			}
			text = first_contact.406.A.homicidal_or_peaceful #seriously
		}

		owner = {
			if = {
				limit = {
					is_militarist = yes
				}
				add_modifier = {
					modifier = first_contact_warlike_warriors_recognised
					years = 10
				}
			}
			else = {
				add_modifier = {
					modifier = first_contact_warlike_warriors_presumed
					years = 10
				}
			}
		}

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_respect_earned
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# Ending: You didn't contact them, it went poorly
first_contact_event = {
	id = first_contact.410
	title = first_contact.410.name
	desc = first_contact.410.desc
	picture = GFX_evt_alien_segregation
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			text = first_contact.410.A.mil
			trigger = {
				owner = { is_militarist = yes }
			}
		}
		name = {
			text = first_contact.410.A.other
			trigger = {
				owner = { is_militarist = no }
			}
		}
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_cowardly
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# Ending: You didn't contact them, but it is fine
first_contact_event = {
	id = first_contact.411
	title = first_contact.411.name
	desc = first_contact.411.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = {
			trigger = { owner = { is_homicidal = no } }
			text = first_contact.411.A
		}
		name = {
			trigger = { owner = { is_homicidal = yes } }
			text = first_contact.411.A.homicidal
		}
		owner = {
			add_modifier = {
				modifier = first_contact_level_headedness
				years = 10
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}


## Hummers

first_contact_event = {
	id = first_contact.415
	title = first_contact.415.name
	desc = first_contact.415.desc
	picture = GFX_evt_mysterious_signal
	show_sound = event_encrypted_comms

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_hummers_chain }
		set_first_contact_flag = seen_aliens
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.415.A
		custom_tooltip = first_contact.415.A.tooltip #this will be hard

		if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_hummers_no_action_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_hummers_no_action_end_stage_cautious
		}

		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = first_contact.415.B
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 1000
				}
			}
		}
		owner = {
			add_resource = {
				energy = -1000
			}
		}
		if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_hummers_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_hummers_end_stage_cautious
		}
		ai_chance = {
			factor = 100
		}
	}
}

# Ending: You paid up
first_contact_event = {
	id = first_contact.420
	title = first_contact.420.name
	desc = first_contact.420.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		contact_country = {
			save_event_target_as = contacted_hummers
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.420.A

		owner = {
			enable_special_project = {
				name = UNIVERSAL_TRANSLATOR_PROJECT
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# Follow-up from special project
country_event = {
	id = first_contact.422
	title = first_contact.422.name
	desc = first_contact.422.desc
	picture = GFX_evt_intelligence_report
	show_sound = event_mysterious_signal

	is_triggered_only = yes

	option = {
		name = first_contact.422.A

		add_modifier = {
			modifier = universal_translator
		}
	}
}


# Ending: You didn't pay, end of chain
first_contact_event = {
	id = first_contact.425
	title = first_contact.425.name
	desc = first_contact.425.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = ON_SCREEN
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		#Just flavour here
	}
}


## Octopodes

first_contact_event = {
	id = first_contact.430
	title = first_contact.430.name
	desc = first_contact.430.desc
	picture = GFX_evt_mysterious_signal
	show_sound = event_encrypted_comms

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_octopodes_chain }
		set_first_contact_flag = seen_aliens
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.430.A
		custom_tooltip = first_contact.415.A.tooltip #this will be hard

		if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_octopodes_no_action_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_octopodes_no_action_end_stage_cautious
		}

		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = first_contact.430.B
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 1000
				}
			}
		}
		owner = {
			add_resource = {
				energy = -1000
			}
		}
		if = {
			limit = {
				contact_country = { has_policy_flag = first_contact_proactive }
			}
			set_first_contact_stage = default_octopodes_end_stage_proactive
		}
		else = {
			set_first_contact_stage = default_octopodes_end_stage_cautious
		}
		ai_chance = {
			factor = 100
		}
	}
}

# Ending: You paid up
first_contact_event = {
	id = first_contact.435
	title = first_contact.435.name
	desc = first_contact.435.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		contact_country = {
			save_event_target_as = encountered_country
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = FASCINATING

		owner = {
			enable_special_project = {
				name = OCTOPODES_LIGHT_PATTERNS_PROJECT
			}
		}

		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

# Follow-up from special project
country_event = {
	id = first_contact.437
	title = first_contact.437.name
	desc = first_contact.437.desc
	picture = GFX_evt_clocks
	show_sound = event_mystic_reveal

	is_triggered_only = yes

	option = {
		name = first_contact.437.A

		add_modifier = {
			modifier = space_lights_insights
		}
	}
}


# Ending: You didn't pay, end of chain
first_contact_event = {
	id = first_contact.440
	title = first_contact.440.name
	desc = first_contact.440.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.440.A
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		#Just flavour here
	}
}

## Poetry
# Mid stage
first_contact_event = {
	id = first_contact.450
	title = first_contact.450.name
	desc = first_contact.450.desc
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_poetry_chain }
	}

	after = {
		set_site_progress_locked = no
	}

	option = { #Warlike
		name = first_contact.450.A
		custom_tooltip = first_contact.450.A.tooltip
		hidden_effect = {
			random_list = {
				1 = {
					modifier = {
						factor = 0.5
						contact_country = { is_militarist = yes }
					}
					first_contact_event = { id = first_contact.455 }
				}
				1 = {
					modifier = {
						factor = 0
						contact_country = { is_pacifist = yes }
					}
					first_contact_event = { id = first_contact.460 }
				}
				1 = {
					modifier = {
						factor = 0
						NOT = {
							contact_country = { has_ethic = ethic_fanatic_militarist }
						}
					}
					first_contact_event = { id = first_contact.462 }
					set_first_contact_stage = default_poetry_end_stage_hostile
				}
			}
		}
		trigger = {
			owner = { is_pacifist = no }
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 5
				owner = { is_pacifist = yes }
			}
		}
	}
	option = { #Exploration
		name = first_contact.450.B
		custom_tooltip = first_contact.450.B.tooltip
		hidden_effect = {
			first_contact_event = { id = first_contact.465 }
		}

		ai_chance = {
			factor = 2
		}
	}
	option = { #Love story
		name = first_contact.450.C
		custom_tooltip = first_contact.450.C.tooltip
		hidden_effect = {
			if = {
				limit = {
					contact_country = { is_xenophile = yes }
				}
				first_contact_event = { id = first_contact.470 }
			}
			else = {
				first_contact_event = { id = first_contact.472 }
			}
		}

		trigger = {
			owner = { is_xenophobe = no }
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 5
				owner = { is_xenophile = yes }
			}
		}
	}
	option = { #Dadaism
		name = first_contact.450.D
		custom_tooltip = first_contact.450.D.tooltip
		hidden_effect = {
			first_contact_event = { id = first_contact.474 }
		}

		ai_chance = {
			factor = 1
		}
	}
	option = { #No time for this
		name = first_contact.450.E
		set_first_contact_stage = default_end_stage_proactive
		ai_chance = {
			factor = 1
		}
	}
}

first_contact_event = {
	id = first_contact.455
	title = first_contact.455.name
	desc = first_contact.455.desc
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = UNFORTUNATE
		set_first_contact_stage = default_end_stage_cautious
	}

	after = {
		set_site_progress_locked = no
	}
}

first_contact_event = {
	id = first_contact.460
	title = first_contact.460.name
	desc = first_contact.460.desc
	picture = GFX_evt_face_off_in_space

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = first_contact.460.A
		set_first_contact_stage = default_poetry_end_stage
	}

	after = {
		set_site_progress_locked = no
	}
}

first_contact_event = {
	id = first_contact.465
	title = first_contact.465.name
	desc = first_contact.465.desc
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = first_contact.465.A
		set_first_contact_stage = default_poetry_end_stage
	}

	after = {
		set_site_progress_locked = no
	}
}

first_contact_event = {
	id = first_contact.470
	title = first_contact.470.name
	desc = first_contact.470.desc
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = first_contact.470.A
		set_first_contact_stage = default_poetry_end_stage_flowery
	}

	option = {
		name = first_contact.470.B
		set_first_contact_stage = default_poetry_end_stage_flowery
	}

	after = {
		set_site_progress_locked = no
	}
}

first_contact_event = {
	id = first_contact.472
	title = first_contact.472.name
	desc = first_contact.472.desc
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = UNFORTUNATE
		set_first_contact_stage = default_end_stage_cautious
	}

	after = {
		set_site_progress_locked = no
	}
}

first_contact_event = {
	id = first_contact.474
	title = first_contact.474.name
	desc = first_contact.474.desc
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = first_contact.474.A
		set_first_contact_stage = default_poetry_end_stage_dada
	}

	after = {
		set_site_progress_locked = no
	}
}

# Ending after war
first_contact_event = {
	id = first_contact.475
	title = first_contact.475.name
	desc = first_contact.475.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.475.A
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes

		owner = {
			if = {
				limit = { is_militarist = yes }
				add_monthly_resource_mult = {
					resource = unity
					value = @tier2unityreward
					min = @tier2unitymin
					max = @tier2unitymax
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = unity
					value = @tier1unityreward
					min = @tier1unitymin
					max = @tier1unitymax
				}
			}
		}
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_poetic_warrior
			}
		}
	}
}

# Ending after nice poems
first_contact_event = {
	id = first_contact.480
	title = first_contact.480.name
	desc = first_contact.480.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = EXCELLENT
		finish_first_contact_effect = yes

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_admirer_of_poetry
			}
		}
		owner = {
			first_contact_add_intel = {
				INTEL = 10
			}
		}
	}
}

# Ending after Dadaism
first_contact_event = {
	id = first_contact.485
	title = first_contact.485.name
	desc = first_contact.485.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.485.A
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes

		owner = {
			add_modifier = {
				modifier = first_contact_defeated_dadaism
			}
		}
	}
}

# Ending after love poem
first_contact_event = {
	id = first_contact.490
	title = first_contact.490.name
	desc = first_contact.490.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.490.A
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes

		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_poetic_flatterer
			}
		}
	}
}


### Colorful Linguistics

first_contact_event = {
	id = first_contact.5070
	title = first_contact.5070.name
	desc = first_contact.5070.desc
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_colorful_linguistics_chain }
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact.5070.A
		if = {
			limit = {
				contact_country = {
					has_policy_flag = first_contact_proactive
				}
			}
			set_first_contact_stage = default_end_stage_colorful_linguistics_proactive
		}
		else = {
			set_first_contact_stage = default_end_stage_colorful_linguistics_cautious
		}
	}
}

first_contact_event = {
	id = first_contact.5071
	title = first_contact.5071.name
	desc = {
		text = first_contact.5071.desc
		trigger = {
			owner = { is_gestalt = no }
		}
	}
	desc = {
		text = first_contact.5071.desc.gestalt
		trigger = {
			owner = { is_gestalt = yes }
		}
	}
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = first_contact.5071.A
		hidden_effect = {
			random_list = {
				66 = {
					modifier = {
						factor = 2
						OR = {
							owner = { has_ethic = ethic_xenophile }
							contact_country = { has_ethic = ethic_xenophile }
						}
					}
					modifier = {
						factor = 4
						OR = {
							owner = { has_ethic = ethic_fanatic_xenophile }
							contact_country = { has_ethic = ethic_fanatic_xenophile }
						}
					}
					first_contact_event = { id = first_contact.5072 days = 30 }
				}
				33 = {
					modifier = {
						factor = 2
						OR = {
							owner = { has_ethic = ethic_xenophobe }
							contact_country = { has_ethic = ethic_xenophobe }
						}
					}
					modifier = {
						factor = 4
						OR = {
							owner = { has_ethic = ethic_fanatic_xenophobe }
							contact_country = { has_ethic = ethic_fanatic_xenophobe }
						}
					}
					first_contact_event = { id = first_contact.5073 days = 30 }
				}
			}
		}
		custom_tooltip = first_contact.5071.A.tooltip
	}
	option = {
		name = first_contact.5071.B
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_not_very_intelligent
			}
		}
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		set_site_progress_locked = no
	}
}

first_contact_event = {
	id = first_contact.5072
	title = first_contact.5072.name
	desc = {
		text = first_contact.5072.desc
		trigger = {
			owner = { is_gestalt = no }
		}
	}
	desc = {
		text = first_contact.5072.desc.gestalt
		trigger = {
			owner = { is_gestalt = yes }
		}
	}
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = EXCELLENT
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_delightful_aliens
			}
		}
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		set_site_progress_locked = no
	}
}

first_contact_event = {
	id = first_contact.5073
	title = first_contact.5073.name
	desc = {
		text = first_contact.5073.desc
		trigger = {
			owner = { is_gestalt = no }
		}
	}
	desc = {
		text = first_contact.5073.desc.gestalt
		trigger = {
			owner = { is_gestalt = yes }
		}
	}
	picture = GFX_evt_mysterious_signal

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = UNFORTUNATE
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_first_contact_very_insulting
			}
		}
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
		set_site_progress_locked = no
	}
}

# The Trial
first_contact_event = { # The Shuttle
	id = first_contact.5080
	title = first_contact.5080.name
	desc = {
		trigger = {
			text = first_contact.5080.desc.start
			text = newline
			success_text = {
				text = first_contact.5080.desc.weapon
				has_first_contact_flag = shuttle_weapon
			}
			success_text = {
				text = first_contact.5080.desc.functional
				has_first_contact_flag = shuttle_functional
			}
			success_text = {
				text = first_contact.5080.desc.bling
				has_first_contact_flag = shuttle_bling
			}
			success_text = {
				text = first_contact.5080.desc.standard
				NOR = {
					has_first_contact_flag = shuttle_weapon
					has_first_contact_flag = shuttle_functional
					has_first_contact_flag = shuttle_bling
				}
			}
		}
	}
	picture = GFX_evt_face_off_in_space

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_trial_chain }

		# SHUTTLE APPEARANCE
		# WEAPON
		#  Like: ethic_militarist
		#  Hate: ethic_pacifist
		# FUNCTIONAL
		#  Like: ethic_egalitarian
		#  Hate: ethic_spiritualist
		# BLING
		#  Like: ethic_materialist
		#  Hate: ethic_authoritarian
		random_list = {
			1 = {
				modifier = {
					factor = 0
					contact_country = { is_pacifist = yes }
				}
				modifier = {
					factor = 6
					contact_country = {	has_ethic = ethic_militarist }
				}
				modifier = {
					factor = 24
					contact_country = {	has_ethic = ethic_fanatic_militarist }
				}
				set_first_contact_flag = shuttle_weapon
			}
			1 = {
				modifier = {
					factor = 0
					contact_country = { is_spiritualist = yes }
				}
				modifier = {
					factor = 6
					contact_country = {	has_ethic = ethic_egalitarian }
				}
				modifier = {
					factor = 24
					contact_country = {	has_ethic = ethic_fanatic_egalitarian }
				}
				set_first_contact_flag = shuttle_functional
			}
			1 = {
				modifier = {
					factor = 0
					contact_country = { is_authoritarian = yes }
				}
				modifier = {
					factor = 6
					contact_country = {	has_ethic = ethic_materialist }
				}
				modifier = {
					factor = 24
					contact_country = {	has_ethic = ethic_fanatic_materialist }
				}
				set_first_contact_flag = shuttle_bling
			}
			1 = {
				# shuttle_standard, no flag set
			}
		}
	}
	after = {
		set_site_progress_locked = no
	}

	option = {
		name = PECULIAR
		if = {
			limit = {
				contact_country = {
					has_policy_flag = first_contact_proactive
				}
			}
			set_first_contact_stage = default_trial_wait_proactive
		}
		else = {
			set_first_contact_stage = default_trial_wait_cautious
		}
	}
}

first_contact_event = { # The Wait
	id = first_contact.5085
	title = first_contact.5085.name
	desc = {
		trigger = {
			text = first_contact.5085.desc.start
			text = newline
			success_text = {
				text = first_contact.5085.desc.meditation
				has_first_contact_flag = room_meditation
			}
			success_text = {
				text = first_contact.5085.desc.pool
				has_first_contact_flag = room_pool
			}
			success_text = {
				text = first_contact.5085.desc.imposing
				has_first_contact_flag = room_imposing
			}
			success_text = {
				text = first_contact.5085.desc.standard
				NOR = {
					has_first_contact_flag = room_meditation
					has_first_contact_flag = room_pool
					has_first_contact_flag = room_imposing
				}
			}
			text = newline
			text = first_contact.5085.desc.end
		}
	}
	picture = GFX_evt_spymaster

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		# ROOM APPEARANCE
		# MEDITATION
		#  Like: ethic_pacifist
		#  Hate: ethic_militarist
		# POOL
		#  Like: ethic_spiritualist
		#  Hate: ethic_egalitarian
		# IMPOSING
		#  Like: ethic_authoritarian
		#  Hate: ethic_materialist
		random_list = {
			1 = {
				modifier = {
					factor = 0
					contact_country = { is_militarist = yes }
				}
				modifier = {
					factor = 6
					contact_country = {	has_ethic = ethic_pacifist }
				}
				modifier = {
					factor = 24
					contact_country = {	has_ethic = ethic_fanatic_pacifist }
				}
				set_first_contact_flag = room_meditation
			}
			1 = {
				modifier = {
					factor = 0
					contact_country = { is_egalitarian = yes }
				}
				modifier = {
					factor = 6
					contact_country = {	has_ethic = ethic_spiritualist }
				}
				modifier = {
					factor = 24
					contact_country = {	has_ethic = ethic_fanatic_spiritualist }
				}
				set_first_contact_flag = room_pool
			}
			1 = {
				modifier = {
					factor = 0
					contact_country = { is_materialist = yes }
				}
				modifier = {
					factor = 6
					contact_country = {	has_ethic = ethic_authoritarian }
				}
				modifier = {
					factor = 24
					contact_country = {	has_ethic = ethic_fanatic_authoritarian }
				}
				set_first_contact_flag = room_imposing
			}
			1 = {
				# room_standard, no flag set
			}
		}
	}
	after = {
		set_site_progress_locked = no
	}
	option = {
		name = first_contact.5085.a
		if = {
			limit = {
				contact_country = {
					has_policy_flag = first_contact_proactive
				}
			}
			set_first_contact_stage = default_trial_method_proactive
		}
		else = {
			set_first_contact_stage = default_trial_method_cautious
		}
	}
}

first_contact_event = { # The Method
	id = first_contact.5090
	title = first_contact.5090.name
	desc = {
		trigger = {
			success_text = {
				text = first_contact.5090.desc.proactive
				owner = {
					has_policy_flag = first_contact_proactive
				}
			}
			success_text = {
				text = first_contact.5090.desc.cautious
				owner = {
					has_policy_flag = first_contact_cautious
				}
			}
			success_text = {
				text = first_contact.5090.desc.aggressive
				owner = {
					has_policy_flag = first_contact_attack_allowed
				}
			}
			text = newline
			text = first_contact.5090.desc.end
		}
	}
	picture = GFX_evt_face_off_in_space

	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}
	after = {
		set_site_progress_locked = no
	}

	# TRIAL METHOD
	# COMBAT
	#   Like: ethic_militarist
	#   Hate: ethic_pacifist
	# SPEECH
	#   Like: ethic_egalitarian
	#   Hate: ethic_spiritualist
	# SONG
	#   Like: ethic_materialist
	#   Hate: ethic_authoritarian
	option = { # COMBAT
		name = first_contact.5090.a
		custom_tooltip = first_contact.5090.a.tt

		hidden_effect = {
			random_list = {
				3 = { # Good
					modifier = {
						factor = 0
						contact_country = { is_pacifist = yes }
					}
					contact_country = {
						switch = {
							trigger = has_ethic
							ethic_fanatic_militarist = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_fanatic_good
								}
							}
							ethic_militarist = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_very_good
								}
							}
							default = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_good
								}
							}
						}
					}
					set_first_contact_flag = fc_event_trial_combat_good
				}
				1 = { # Bad
					modifier = {
						factor = 0
						contact_country = { is_militarist = yes }
					}
					contact_country = {
						switch = {
							trigger = has_ethic
							ethic_fanatic_pacifist = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_fanatic_bad
								}
							}
							ethic_pacifist = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_very_bad
								}
							}
							default = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_bad
								}
							}
						}
					}
					set_first_contact_flag = fc_event_trial_combat_bad
				}
			}
			if = {
				limit = {
					contact_country = {
						has_policy_flag = first_contact_proactive
					}
				}
				set_first_contact_stage = default_trial_verdict_proactive
			}
			else = {
				set_first_contact_stage = default_trial_verdict_cautious
			}
		}
	}
	option = { # SPEECH
		name = first_contact.5090.b
		custom_tooltip = first_contact.5090.b.tt

		hidden_effect = {
			random_list = {
				3 = { # Good
					modifier = {
						factor = 0
						contact_country = { is_spiritualist = yes }
					}
					contact_country = {
						switch = {
							trigger = has_ethic
							ethic_fanatic_egalitarian = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_fanatic_good
								}
							}
							ethic_egalitarian = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_very_good
								}
							}
							default = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_good
								}
							}
						}
					}
					set_first_contact_flag = fc_event_trial_speech_good
				}
				1 = { # Bad
					modifier = {
						factor = 0
						contact_country = { is_egalitarian = yes }
					}
					contact_country = {
						switch = {
							trigger = has_ethic
							ethic_fanatic_spiritualist = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_fanatic_bad
								}
							}
							ethic_spiritualist = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_very_bad
								}
							}
							default = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_bad
								}
							}
						}
					}
					set_first_contact_flag = fc_event_trial_speech_bad
				}
			}
			if = {
				limit = {
					contact_country = {
						has_policy_flag = first_contact_proactive
					}
				}
				set_first_contact_stage = default_trial_verdict_proactive
			}
			else = {
				set_first_contact_stage = default_trial_verdict_cautious
			}
		}
	}
	option = { # SONG
		name = first_contact.5090.c
		custom_tooltip = first_contact.5090.c.tt

		hidden_effect = {
			random_list = {
				3 = { # Good
					modifier = {
						factor = 0
						contact_country = { is_authoritarian = yes }
					}
					contact_country = {
						switch = {
							trigger = has_ethic
							ethic_fanatic_materialist = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_fanatic_good
								}
							}
							ethic_materialist = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_very_good
								}
							}
							default = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_good
								}
							}
						}
					}
					set_first_contact_flag = fc_event_trial_song_good
				}
				1 = { # Bad
					modifier = {
						factor = 0
						contact_country = { is_materialist = yes }
					}
					contact_country = {
						switch = {
							trigger = has_ethic
							ethic_fanatic_authoritarian = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_fanatic_bad
								}
							}
							ethic_authoritarian = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_very_bad
								}
							}
							default = {
								add_opinion_modifier = {
									who = root.owner
									modifier = opinion_first_contact_trial_bad
								}
							}
						}
					}
					set_first_contact_flag = fc_event_trial_song_bad
				}
			}
			if = {
				limit = {
					contact_country = {
						has_policy_flag = first_contact_proactive
					}
				}
				set_first_contact_stage = default_trial_verdict_proactive
			}
			else = {
				set_first_contact_stage = default_trial_verdict_cautious
			}
		}
	}
}

first_contact_event = { # The Verdict
	id = first_contact.5095
	title = first_contact.5095.name
	desc = {
		trigger = {
			has_first_contact_flag = fc_event_trial_combat_good
		}
		text = first_contact.5095.desc.combat_good
	}
	desc = {
		trigger = {
			has_first_contact_flag = fc_event_trial_combat_bad
		}
		text = first_contact.5095.desc.combat_bad
	}
	desc = {
		trigger = {
			has_first_contact_flag = fc_event_trial_speech_good
		}
		text = first_contact.5095.desc.speech_good
	}
	desc = {
		trigger = {
			has_first_contact_flag = fc_event_trial_speech_bad
		}
		text = first_contact.5095.desc.speech_bad
	}
	desc = {
		trigger = {
			has_first_contact_flag = fc_event_trial_song_good
		}
		text = first_contact.5095.desc.song_good
	}
	desc = {
		trigger = {
			has_first_contact_flag = fc_event_trial_song_bad
		}
		text = first_contact.5095.desc.song_bad
	}
	picture = {
		trigger = {
			OR = {
				has_first_contact_flag = fc_event_trial_combat_good
				has_first_contact_flag = fc_event_trial_combat_bad
			}
		}
		picture = GFX_evt_assembly_fight
	}
	picture = {
		trigger = {
			OR = {
				has_first_contact_flag = fc_event_trial_speech_good
				has_first_contact_flag = fc_event_trial_speech_bad
			}
		}
		picture = GFX_evt_acquire_asset
	}
	picture = {
		trigger = {
			OR = {
				has_first_contact_flag = fc_event_trial_song_good
				has_first_contact_flag = fc_event_trial_song_bad
			}
		}
		picture = GFX_evt_friendly_infiltration
	}
	inline_script = first_contact_event_sounds

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}
	after = {
		set_site_progress_locked = no
	}
	option = {
		name = first_contact.5095.a
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}
}

### Misc

# War breaks out
first_contact_event = {
	id = first_contact.500
	title = first_contact.500.name
	desc = first_contact.500.desc
	picture = GFX_evt_face_off_in_space
	show_sound = event_faceoff_in_space
	is_triggered_only = yes

	immediate = {
		owner = { set_hostile = root.contact_country }
		contact_country = {
			set_hostile = root.owner
		}
		reverse_first_contact = {
			first_contact_event = { id = first_contact.505 }
		}
	}

	option = {
		name = first_contact.500.A
		custom_tooltip = first_contact.500.A.tooltip
	}
}

#Variation of .500. Needs to be after it in the events file
first_contact_event = {
	id = first_contact.462
	base = first_contact.500
	title = first_contact.462.name
	desc_clear = yes
	desc = first_contact.462.desc
}

#Notification of previous
first_contact_event = {
	id = first_contact.505
	title = first_contact.500.name
	desc = first_contact.505.desc
	picture = GFX_evt_face_off_in_space
	show_sound = event_faceoff_in_space
	is_triggered_only = yes

	option = {
		name = first_contact.500.A
		custom_tooltip = first_contact.500.A.tooltip
	}
}

# General stuff

# Executed right after country has established communications with another country
# This = Country which established the communications
# From = Country which communications were established with
# Communication Established - hidden event replacing action.11
country_event = {
	id = first_contact.1050
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		from = {
			is_country_type = default
		}
		has_country_flag = first_contact_completed@from
	}

	immediate = {
		from = {
			country_event = { id = action.13 }
			save_event_target_as = contact_empire
		}
		country_event = { id = distar.238 days = 1 }
		country_event = { id = action.1 }
	}
}

#They established comms first; hostile no crew
#see first_contact.295
country_event = {
	id = first_contact.1100
	title = first_contact.295.name
	desc = first_contact.1100.desc
	picture = GFX_evt_ancient_databank
	show_sound = event_spymaster

	is_triggered_only = yes

	immediate = {
		from.owner = { save_event_target_as = contact_country }
	}

	option = {
		name = EXCELLENT

		first_contact_grant_random_tech_option = { PROGRESS = 0.1 }
		add_intel = {
			who = event_target:contact_country
			amount = 25
		}
	}
}

#They established comms first; hostile vivisection
#see first_contact.300
country_event = {
	id = first_contact.1105
	title = first_contact.290.name
	desc = {
		trigger = { event_target:contact_country = { is_regular_empire = yes } }
		text = first_contact.1105.desc
	}
	desc = {
		trigger = { event_target:contact_country = { is_hive_empire = yes } }
		text = first_contact.1105.desc.hive_victim
	}
	desc = {
		trigger = { event_target:contact_country = { is_machine_empire = yes } }
		text = first_contact.1105.desc.machine_victim
	}
	picture = GFX_evt_vivisection
	show_sound = event_vivisection

	is_triggered_only = yes

	immediate = {
		from.owner = { save_event_target_as = contact_country }
	}

	option = {
		name = first_contact.290.A

		hidden_effect = {
			set_country_flag = they_come_in_pieces_achievement
		}
		if = {
			limit = {
				event_target:contact_country = {
					is_machine_empire = yes
				}
			}
			if = {
				limit = {
					can_copy_random_tech_from = {
						who = event_target:contact_country
						category = computing
					}
				}
				copy_random_tech_from = {
					who = event_target:contact_country
					category = computing
					progress = 0.5
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier3researchreward
					min = @tier3researchmin
				}
			}
		}
		else = {
			if = {
				limit = {
					can_copy_random_tech_from = {
						who = event_target:contact_country
						category = biology
					}
				}
				copy_random_tech_from = {
					who = event_target:contact_country
					category = biology
					progress = 0.5
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier3researchreward
					min = @tier3researchmin
				}
			}
			if = {
				limit = { has_nemesis = yes }
				custom_tooltip = gain_asset_internal_organs
				hidden_effect = {
					random_spynetwork = {
						limit = { target = { is_same_value = event_target:contact_country } }
						create_espionage_asset = { type = asset_internal_organs }
					}
				}
			}
		}
		add_intel = {
			who = event_target:contact_country
			amount = 35
		}
	}
}

#They established comms first; hostile interrogation
#see first_contact.285
country_event = {
	id = first_contact.1110
	title = first_contact.285.name
	desc = {
		trigger = {
			event_target:contact_country = { is_gestalt = no }
			event_target:our_first_contact_site = {
				NOR = {
					has_first_contact_flag = weak_interrogees
					has_first_contact_flag = strong_interrogees
				}
			}
		}
		text = first_contact.285.desc
	}
	desc = {
		trigger = {
			event_target:contact_country = { is_gestalt = no }
			event_target:our_first_contact_site = { has_first_contact_flag = weak_interrogees }
		}
		text = first_contact.1110.desc.weak
	}
	desc = {
		trigger = {
			event_target:contact_country = { is_gestalt = no }
			event_target:our_first_contact_site = { has_first_contact_flag = strong_interrogees }
		}
		text = first_contact.1110.desc.strong
	}
	desc = {
		trigger = {
			event_target:contact_country = { is_machine_empire = yes }
		}
		text = first_contact.1110.desc.machine_victim
	}
	desc = {
		trigger = {
			event_target:contact_country = { is_hive_empire = yes }
		}
		text = first_contact.285.desc.hive_victim
	}
	picture = GFX_evt_face_off_in_space
	show_sound = event_vivisection

	is_triggered_only = yes

	immediate = {
		from.reverse_first_contact = { save_event_target_as = our_first_contact_site }
		from.owner = { save_event_target_as = contact_country }
	}

	option = {
		name = EXCELLENT
		if = {
			limit = {
				event_target:contact_country = { is_gestalt = yes }
			}
			add_intel = {
				who = event_target:contact_country
				amount = 25
			}
		}
		else_if = {
			limit = {
				event_target:our_first_contact_site = { has_first_contact_flag = weak_interrogees }
			}
			add_intel = {
				who = event_target:contact_country
				amount = 35
			}
			first_contact_grant_random_tech_option = { PROGRESS = 0.3 }
		}
		else_if = {
			limit = {
				event_target:our_first_contact_site = { has_first_contact_flag = strong_interrogees }
			}
			add_intel = {
				who = event_target:contact_country
				amount = 25
			}
			first_contact_grant_random_tech_option = { PROGRESS = 0.1 }
		}
		else = {
			add_intel = {
				who = event_target:contact_country
				amount = 30
			}
			first_contact_grant_random_tech_option = { PROGRESS = 0.2 }
		}
	}
}

### Xeno Dinner Party
first_contact_event = {
	id = first_contact.1120
	title = first_contact.1120.name
	desc = {
		trigger = { owner = { is_nomadic = yes } }
		text = first_contact.1120.desc.nomadic
	}
	desc = {
		trigger = { owner = { is_nomadic = no } }
		text = first_contact.1120.desc
	}
	picture = GFX_evt_mysterious_signal
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
		owner = { set_country_flag = first_contact_xeno_dinner_party_chain }
	}

	after = {
		set_site_progress_locked = no
	}

	#Yes - Two text options depend on first contact stance
	option = {
		name = {
			trigger = { owner = { has_policy_flag = first_contact_proactive } }
			text = first_contact.1120.a.proactive
		}
		name = {
			trigger = { owner = { has_policy_flag = first_contact_cautious } }
			text = first_contact.1120.a.cautious
		}
		custom_tooltip = first_contact.1120.a.tooltip
		hidden_effect = {
			set_first_contact_stage = default_xeno_dinner_party_we_said_yes_stage
		}
	}
	#No
	option = {
		name = first_contact.1120.b
		custom_tooltip = first_contact.1120.b.tooltip
		hidden_effect = {
			set_first_contact_stage = default_xeno_dinner_party_we_said_no_stage
		}
	}
}
#Mise En Place
first_contact_event = {
	id = first_contact.1125
	title = first_contact.1125.name
	desc = first_contact.1125.desc
	picture = GFX_evt_tradedeal
	show_sound = event_ship_bridge

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	#This could be good!
	option = {
		name = first_contact.1125.a
		custom_tooltip = first_contact.1125.a.tooltip
		hidden_effect = {
			set_first_contact_stage = default_xeno_dinner_party_pre_game_stage
		}
	}
	#Lets Spy on them.
	option = {
		name = first_contact.1125.b
		custom_tooltip = first_contact.1125.b.tooltip
		hidden_effect = {
			set_first_contact_stage = default_xeno_dinner_party_pre_game_stage
			set_first_contact_flag = xeno_dinner_party_spy_attempted
		}
	}
}
#Pre-Game
first_contact_event = {
	id = first_contact.1130
	title = first_contact.1130.name
	desc = first_contact.1130.desc
	picture = GFX_evt_diplomatic_visit
	show_sound = event_announcement

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	#Have fun
	option = {
		name = first_contact.1130.a
		trigger = {
			NOT = { has_first_contact_flag = xeno_dinner_party_spy_attempted }
		}
		custom_tooltip = first_contact.1130.a.tooltip
		hidden_effect = {
			if = {
				limit = {
					OR = {
						AND = {
							owner = {
								has_trait = trait_lithoid
							}
							contact_country = {
								NOT = {
									has_trait = trait_lithoid
								}
							}
						}
						AND = {
							owner = {
								NOT = {
									has_trait = trait_lithoid
								}
							}
							contact_country = {
								has_trait = trait_lithoid
							}
						}
					}
				}
				set_first_contact_stage = default_xeno_dinner_party_hungry_for_connection_end_stage
			}
			else_if = {
				limit = {
					NOR = {
						AND = {
							owner = {
								has_trait = trait_lithoid
							}
							contact_country = {
								NOT = {
									has_trait = trait_lithoid
								}
							}
						}
						AND = {
							owner = {
								NOT = {
									has_trait = trait_lithoid
								}
							}
							contact_country = {
								has_trait = trait_lithoid
							}
						}
					}
				}
				random_list = {
					60 = {
						set_first_contact_stage = default_xeno_dinner_party_life_of_the_party_end_stage
						modifier = {
							add = 25
							owner = {
								has_trait = trait_charismatic
							}
						}
						modifier = {
							add = -25
							owner = {
								has_trait = trait_repugnant
							}
						}
						modifier = {
							add = -50
							owner = {
								has_trait = trait_noxious
							}
						}
					}
					40 = {
						set_first_contact_stage = default_xeno_dinner_party_wet_towel_end_stage
						modifier = {
							add = -25
							owner = {
								has_trait = trait_charismatic
							}
						}
						modifier = {
							add = 25
							owner = {
								has_trait = trait_repugnant
							}
						}
						modifier = {
							add = 50
							owner = {
								has_trait = trait_noxious
							}
						}
					}
				}
			}
		}
	}
	#Don't have fun
	option = {
		name = first_contact.1130.b
		trigger = {
			NOT = { has_first_contact_flag = xeno_dinner_party_spy_attempted }
		}
		custom_tooltip = first_contact.1130.b.tooltip
		hidden_effect = {
			if = {
				limit = {
					OR = {
						AND = {
							owner = {
								has_trait = trait_lithoid
							}
							contact_country = {
								NOT = {
									has_trait = trait_lithoid
								}
							}
						}
						AND = {
							owner = {
								NOT = {
									has_trait = trait_lithoid
								}
							}
							contact_country = {
								has_trait = trait_lithoid
							}
						}
					}
				}
				set_first_contact_stage = default_xeno_dinner_party_hungry_for_connection_end_stage
			}
			else_if = {
				limit = {
					NOR = {
						AND = {
							owner = {
								has_trait = trait_lithoid
							}
							contact_country = {
								NOT = {
									has_trait = trait_lithoid
								}
							}
						}
						AND = {
							owner = {
								NOT = {
									has_trait = trait_lithoid
								}
							}
							contact_country = {
								has_trait = trait_lithoid
							}
						}
					}
				}
				random_list = {
					60 = {
						set_first_contact_stage = default_xeno_dinner_party_wet_towel_end_stage
						modifier = {
							add = -25
							owner = {
								has_trait = trait_charismatic
							}
						}
						modifier = {
							add = 25
							owner = {
								has_trait = trait_repugnant
							}
						}
						modifier = {
							add = 50
							owner = {
								has_trait = trait_noxious
							}
						}
					}
					40 = {
						set_first_contact_stage = default_xeno_dinner_party_life_of_the_party_end_stage
						modifier = {
							add = 25
							owner = {
								has_trait = trait_charismatic
							}
						}
						modifier = {
							add = -25
							owner = {
								has_trait = trait_repugnant
							}
						}
						modifier = {
							add = -50
							owner = {
								has_trait = trait_noxious
							}
						}
					}
				}
			}
		}
	}
	#Spy option
	option = {
		name = first_contact.1130.c
		trigger = {
			has_first_contact_flag = xeno_dinner_party_spy_attempted
		}
		custom_tooltip = first_contact.1130.c.tooltip
		hidden_effect = {
			random_list = {
				50 = {
					modifier = {
						add = 100
						root.owner = {
							relative_encryption_decryption = {
								target = root.contact_country
								value < 1.0 #At > 1.0 root's encryption is superior to target's decryption
							}
						}
					}
					set_first_contact_stage = default_xeno_dinner_party_we_got_caught_spying_end_stage
				}
				50 = {
					modifier = {
						add = 100
						root.owner = {
							relative_encryption_decryption = {
								target = root.contact_country
								value > 1.0 #At > root's encryption is superior to target's decryption
							}
						}
					}
					set_first_contact_stage = default_xeno_dinner_party_we_spying_end_stage
				}
			}
		}
	}
}
#Second Chances
first_contact_event = {
	id = first_contact.1135
	title = first_contact.1135.name
	desc = first_contact.1135.desc
	picture = GFX_evt_worrying_signal
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	#Ok fine
	option = {
		name = first_contact.1135.a
		custom_tooltip = first_contact.1135.a.tooltip
		hidden_effect = {
			set_first_contact_stage = default_xeno_dinner_party_pre_game_stage
		}
	}
	#No means no
	option = {
		name = first_contact.1135.b
		custom_tooltip = first_contact.1135.b.tooltip
		hidden_effect = {
			set_first_contact_stage = default_xeno_dinner_party_no_means_no_end_stage
		}
	}
}
#Caught Spying
first_contact_event = {
	id = first_contact.1140
	title = first_contact.1140.name
	desc = first_contact.1140.desc
	picture = GFX_evt_alien_segregation
	show_sound = event_administrative_work

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = UNFORTUNATE
		root.contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_caught_spying
			}
		}
		root.owner = {
			add_intel = {
				who = root.contact_country
				amount = 25
			}
		}
	}
}
#Not Caught Spying
first_contact_event = {
	id = first_contact.1145
	title = first_contact.1145.name
	desc = first_contact.1145.desc
	picture = GFX_evt_spymaster
	show_sound = event_spymaster

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = EXCELLENT
		root.owner = {
			add_intel = {
				who = root.contact_country
				amount = 50
			}
		}
	}
}
#Life of the Party
first_contact_event = {
	id = first_contact.1150
	title = first_contact.1150.name
	desc = first_contact.1150.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = first_contact.1150.a
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_life_of_the_party
			}
		}
	}
}
#Wet Towel
first_contact_event = {
	id = first_contact.1155
	title = first_contact.1155.name
	desc = first_contact.1155.desc
	picture = GFX_evt_smear_campaign
	show_sound = event_default

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = first_contact.1155.a
		root.contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_wet_towel_party
			}
		}
	}
}
#Lithoid/Bio Mismatch
first_contact_event = {
	id = first_contact.1160
	title = first_contact.1160.name
	desc = first_contact.1160.desc
	picture = GFX_evt_hand_shake
	show_sound = event_hand_shake

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = first_contact.1160.a
		root.contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_could_not_eat_the_food_party
			}
		}
	}
}
#No means no
first_contact_event = {
	id = first_contact.1165
	title = first_contact.1165.name
	desc = first_contact.1165.desc
	picture = GFX_evt_worrying_signal
	show_sound = event_worrying_signal

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
		first_contact_inform_intel = yes
	}

	option = {
		name = first_contact.1165.a
		contact_country = {
			add_opinion_modifier = {
				who = root.owner
				modifier = opinion_double_rejection_party
			}
		}
	}
}




### Unique Stories

## Here Be Dragons
# First Contact Stage 1 - Here Be Dragons
first_contact_event = {
	id = first_contact.2000
	title = aquatic_events.250.name
	desc = {
		trigger = {
			owner = { is_gestalt = no }
		}
		text = aquatic_events.250.desc
	}
	desc = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		text = aquatic_events.250.desc.hive
	}
	desc = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		text = aquatic_events.250.desc.machine
	}
	picture = GFX_evt_star_chart
	is_triggered_only = yes
	first_contact = yes
	location = solar_system

	show_sound = event_mysterious_signal

	abort_trigger = {
		OR = {
			NOT = { exists = owner }
			NOT = { exists = contact_country }
			owner = { has_communications = root.contact_country }
		}
	}

	immediate = {
		# set_site_progress_locked = yes #deliberately commented out to stop the notification from showing; site is locked anyway by dint of having no envoy
		set_name = aquatic_events.250.name
		owner = {
			create_leader = { #just for locs
				class = scientist
				species = this
				effect = {
					save_event_target_as = needed_name
					exile_leader_as = needed_name
				}
			}
		}
	}

	after = {
		# set_site_progress_locked = no
		hidden_effect = {
			fire_on_action = {
				on_action = on_first_contact_started
			}
		}
	}

	#something here?
	option = {
		name = INTERESTING
		set_first_contact_starting_stage = yes
	}
}

# First Contact Stage 1 - Jaunting Traveler
first_contact_event = {
	id = first_contact.3000
	title = first_contact.3000.name
	desc = {
		trigger = {
			owner = { is_gestalt = yes }
		}
		text = first_contact.3000.desc.gestalt
	}
	desc = {
		trigger = {
			owner = { is_gestalt = no }
		}
		text = first_contact.3000.desc
	}
	picture = GFX_evt_news_room
	show_sound = event_alien_nature
	location = fromfromfrom
	is_triggered_only = yes
	first_contact = yes

	immediate = {
		# set_site_progress_locked = yes #deliberately commented out to stop the notification from showing; site is locked anyway by dint of having no envoy
		set_name = first_contact.3000.name
	}

	# Attempt to communicate (only non-genocidal empires)
	option = {
		name = {
			text = first_contact.3000.a.friendly
			trigger = {
				owner = {
					is_unfriendly = no
					is_xenophobe = no
				}
			}
		}
		name = {
			text = first_contact.3000.a.unfriendly
			trigger = {
				owner = {
					OR = {
						is_unfriendly = yes
						is_xenophobe = yes
						is_pacifist = no
					}
				}
			}
		}
		trigger = {
			owner = {
				is_homicidal = no
				NOT = { has_valid_civic = civic_machine_assimilator }
			}
		}
		set_first_contact_starting_stage = yes
	}

	# Kill/sacrifice (xenophobes, purifiers and death cults)
	option = {
		name = {
			text = first_contact.3000.b.execution
			trigger = {
				owner = {
					OR = {
						has_valid_civic = civic_machine_terminator
						has_valid_civic = civic_fanatic_purifiers
						is_xenophobe = yes
					}
				}
			}
		}
		name = {
			text = first_contact.3000.b.sacrifice
			trigger = {
				owner = {
					is_death_cult_empire = yes
				}
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
		hidden_effect = {
			root.contact_country = {
				destroy_country = yes
			}
		}
	}

	# Eat (hiveminds and necrophages)
	option = {
		name = first_contact.3000.c.hive
		trigger = {
			owner = {
				OR = {
					is_hive_empire = yes
					has_origin = origin_necrophage
				}
			}
		}

		owner = {
			add_monthly_resource_mult = {
				resource = food
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmin
			}
		}
		hidden_effect = {
			root.contact_country = {
				destroy_country = yes
			}
		}
	}

	# Assimilate (Driven Assimilators only)
	option = {
		name = first_contact.3000.d.assimilator
		custom_tooltip = first_contact.3000.d.assimilator.tooltip
		trigger = {
			owner = {
				has_valid_civic = civic_machine_assimilator
			}
		}

		owner = {
			create_leader = {
				class = scientist
				name = "NAME_Guest"
				species = root.contact_country.species
				gender = female
				skill = 5
				traits = {
					trait = leader_trait_psionic
					trait = leader_trait_cyborg
				}
				event_leader = yes
			}
			hidden_effect = {
				root.contact_country = {
					destroy_country = yes
				}
			}
		}
	}

	after = {
		# set_site_progress_locked = no
		hidden_effect = {
			fire_on_action = {
				on_action = on_first_contact_started
			}
		}
	}
}

# First Contact Stage 1 - Slavers Empire (Broken Shackles/Payback origin)
first_contact_event = {
	id = first_contact.4000
	title = first_contact.4000.name
	desc = {
		trigger = {
			owner = {
				has_origin = origin_broken_shackles
			}
		}
		text = first_contact.4000.desc.broken_shackles
	}
	desc = {
		trigger = {
			owner = {
				has_origin = origin_payback
			}
		}
		text = first_contact.4000.desc.payback
	}
	picture = GFX_evt_worrying_signal
	show_sound = event_mysterious_signal
	location = fromfromfrom

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		#set_site_progress_locked = yes
		set_name = first_contact.4000.name
	}

	after = {
		#set_site_progress_locked = no
		hidden_effect = {
			fire_on_action = {
				on_action = on_first_contact_started
			}
		}
	}

	option = {
		name = {
			trigger = {
				owner = {
					has_origin = origin_broken_shackles
				}
			}
			text = first_contact.4000.a.bs
		}
		name = {
			trigger = {
				owner = {
					has_origin = origin_payback
				}
			}
			text = first_contact.4000.a.payback
		}
		set_first_contact_starting_stage = yes
	}
}

# Reveal your presence to pre-FTL civilization
# Fired by action_reveal_presence
# This = Country which revealed its presence
# From = Pre-ftl country
country_event = {
	id = first_contact.6000
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			is_country_type = default
			is_country_type = fallen_empire
			is_country_type = awakened_fallen_empire
		}
		from = {
			is_country_type = primitive
		}
	}

	immediate = {
		set_country_flag = first_contact_completed@from
		set_timed_country_flag = { # 'New Contact' Pop Faction Demand (see factions.11)
			flag = recent_comms_timed
			days = 3600
		}
		from = {
			save_event_target_as = contact_empire
			set_country_flag = first_contact_completed@root
		}
		country_event = { id = action.2 }
	}
}
