################################
#
# First Contact Events - meeting non-default countries
#
# Written by Pierre du Plessis
#
################################

namespace = first_contact_critters

### Enclaves

first_contact_event = {
	id = first_contact_critters.1
	title = first_contact_critters.1.name
	desc = {
		trigger = {
			contact_country = { NOT = { has_country_flag = champions_forge_enclave_country } }
		}
		text = first_contact_critters.1.desc
	}
	desc = {
		trigger = {
			contact_country = { has_country_flag = champions_forge_enclave_country }
		}
		text = first_contact_critters.1.desc.cfl
	}
	picture = {
		trigger = {
			contact_country = { NOT = { has_country_flag = champions_forge_enclave_country } }
		}
		picture = GFX_evt_satellite_in_orbit
	}
	picture = {
		trigger = {
			contact_country = { has_country_flag = champions_forge_enclave_country }
		}
		picture = GFX_evt_nomad_default
	}
	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_critters.1.A
		set_first_contact_stage = enclave_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.5
	title = first_contact_critters.5.name
	desc = first_contact_critters.5.desc
	picture = GFX_evt_space_station

	inline_script = first_contact_event_sounds
	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = {
		name = SCUM
		trigger = {
			owner = { has_valid_civic = civic_fanatic_purifiers }
		}
	}

	option = {
		name = TASTY
		trigger = {
			owner = { has_valid_civic = civic_hive_devouring_swarm }
		}
	}

	option = {
		name = EXTERMINATE
		trigger = {
			owner = { has_valid_civic = civic_machine_terminator }
		}
	}

	option = {
		name = first_contact_critters.5.A
		trigger = {
			owner = {
				NOR = {
					has_valid_civic = civic_fanatic_purifiers
					has_valid_civic = civic_hive_devouring_swarm
					has_valid_civic = civic_machine_terminator
				}
			}
		}
	}
	after = {
		set_site_progress_locked = no
		finish_first_contact_effect = yes
	}
}

### Tiyanki

first_contact_event = {
	id = first_contact_critters.10
	title = first_contact_critters.10.name
	desc = first_contact_critters.10.desc
	picture = GFX_evt_unidentified_monster
	show_sound = event_space_whale

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact_critters.10.A
		set_first_contact_stage = tiyanki_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.15
	title = first_contact_critters.15.name
	picture = GFX_evt_tiyanki_family
	show_sound = evn_ove_tiyanki_family

	is_triggered_only = yes
	first_contact = yes

	desc = {
		trigger = {
			if = {
				limit = {
					owner = { is_gestalt = yes }
				}
				text = story.501.desc.gesta
			}
			else_if = {
				limit = {
					owner = { is_spiritualist = yes }
				}
				text = story.501.desc.spiri
			}
			else = {
				text = first_contact_critters.15.desc
			}
			text = newline
			success_text = {
				text = first_contact_critters.15.desc.primal_calling
				owner = { has_origin = origin_primal_calling }
			}
		}
	}

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		finish_first_contact_effect = yes
		set_site_progress_locked = no
		# if = {
		# 	limit = {
		# 		owner = {
		# 			has_country_flag = tiyanki_graveyard_survey
		# 		}
		# 	}
		# 	owner = { country_event = galactic_features.387 } #Tiyanki graveyard follow-up
		# }
		hidden_effect = {
			owner = {
				country_event = {
					id = grand_archive.200
					scopes = {
						from = event_target:tiyanki_country
						fromfrom = root.solar_system
					}
				}
			}
		}
	}

	option = {
		name = story.501.a.spiri
		trigger = {
			owner = {
				is_spiritualist = yes
			}
		}
		owner = {
			if = {
				limit = {
					has_tech_option = tech_space_whale_weapon_1
				}
				add_tech_progress = {
					tech = tech_space_whale_weapon_1
					progress = 0.6
				}
			}
			else = {
				add_research_option = tech_space_whale_weapon_1
				add_tech_progress = {
					tech = tech_space_whale_weapon_1
					progress = 0.2
				}
			}
		}
	}

	option = {
		name = story.501.a.mater
		trigger = {
			owner = {
				OR = {
					is_materialist = yes
					has_ethic = ethic_gestalt_consciousness
				}
				NOT = {
					has_civic = civic_machine_exploration_protocol
				}
			}
		}
		owner = {
			if = {
				limit = {
					has_tech_option = tech_space_whale_weapon_1
				}
				add_tech_progress = {
					tech = tech_space_whale_weapon_1
					progress = 0.3
				}
			}
			else = {
				add_research_option = tech_space_whale_weapon_1
				add_tech_progress = {
					tech = tech_space_whale_weapon_1
					progress = 0.1
				}
			}
		}
	}

	option = {
		name = story.501.a.exploratobot
		trigger = {
			owner = {
				has_civic = civic_machine_exploration_protocol
			}
		}
		owner = {
			if = {
				limit = {
					has_tech_option = tech_space_whale_weapon_1
				}
				add_tech_progress = {
					tech = tech_space_whale_weapon_1
					progress = 0.3
				}
			}
			else = {
				add_research_option = tech_space_whale_weapon_1
				add_tech_progress = {
					tech = tech_space_whale_weapon_1
					progress = 0.1
				}
			}
		}
	}

	option = {
		name = {
			text = first_contact_critters.15.A
			trigger = {
				owner = { is_homicidal = no }
			}
		}
		name = {
			text = story.110.b.milit
			trigger = {
				owner = { is_homicidal = yes }
			}
		}
		trigger = {
			owner = {
				NOR = {
					is_materialist = yes
					is_spiritualist = yes
					has_ethic = ethic_gestalt_consciousness
				}
			}
		}
		owner = {
			if = {
				limit = {
					has_tech_option = tech_space_whale_weapon_1
				}
				add_tech_progress = {
					tech = tech_space_whale_weapon_1
					progress = 0.3
				}
			}
			else = {
				add_research_option = tech_space_whale_weapon_1
				add_tech_progress = {
					tech = tech_space_whale_weapon_1
					progress = 0.1
				}
			}
			if = {
				limit = {
					OR = {
						is_xenophobe = yes
						is_militarist = yes
						is_homicidal = yes
					}
				}
				increase_hunted_fauna_count = yes
			}
		}
	}
}


### Amoebas

first_contact_event = {
	id = first_contact_critters.20
	title = first_contact_critters.20.name
	desc = first_contact_critters.20.desc
	picture = GFX_evt_unidentified_monster
	show_sound = event_space_amoeba

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact_critters.20.A
		set_first_contact_stage = amoeba_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.25
	title = first_contact_critters.25.name
	desc = {
		trigger = {
			hidden:owner = {
				switch = {
					trigger = has_ethic
					ethic_fanatic_xenophile = { text = story.101.desc.phile }
					ethic_fanatic_xenophobe = { text = story.101.desc.phobe }
					ethic_fanatic_militarist = { text = story.101.desc.milit }
					ethic_fanatic_pacifist = { text = story.101.desc.pacif }
					ethic_fanatic_materialist = { text = story.101.desc.mater }
					ethic_xenophile = { text = story.101.desc.phile }
					ethic_xenophobe = { text = story.101.desc.phobe}
					ethic_militarist = { text = story.101.desc.milit }
					ethic_pacifist = { text = story.101.desc.pacif }
					ethic_materialist = { text = story.101.desc.mater }
					ethic_gestalt_consciousness = { text = story.101.desc.gesta }
					default = { text = first_contact_critters.25.desc }
				}
			}
			text = newline
			success_text = {
				text = story.101.desc.fruitful
				hidden:owner = { has_origin = origin_fruitful }
			}
			success_text = {
				text = first_contact_critters.25.desc.primal_calling
				hidden:owner = { has_origin = origin_primal_calling }
			}
		}
	}

	picture = GFX_evt_friendly_amoeba
	show_sound = event_space_amoeba

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
		hidden_effect = {
			owner = {
				country_event = {
					id = grand_archive.200
					scopes = {
						from = event_target:amoeba_country
						fromfrom = root.solar_system
					}
				}
			}
		}
	}

	option = {
		name = story.101.aa
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_militarist = yes
					is_homicidal = yes
				}
			}
		}
		owner = {
			add_modifier = {
				modifier = amoeba_hunting_buff
				days = -1
			}
			increase_hunted_fauna_count = yes
		}
		custom_tooltip = story.101.aa.amoebahunt
		finish_first_contact_effect = yes
	}

	option = {
		name = story.101.bb
		trigger = {
			owner = {
				NOT = { has_civic = civic_machine_terminator }
			}
		}
		owner = {
			capital_scope = {
				enable_special_project = {
					name = "AMOEBAS_PROJECT"
					location = this
					owner = root.owner
				}
			}
		}
		finish_first_contact_effect = yes
	}

	option = {
		name = story.101.bb.exter
		trigger = {
			owner = {
				has_civic = civic_machine_terminator
			}
		}
		owner = {
			capital_scope = {
				enable_special_project = {
					name = "AMOEBAS_PROJECT"
					location = this
					owner = root.owner
				}
			}
		}
		finish_first_contact_effect = yes
	}

	option = {
		name = story.101.cc
		trigger = {
			owner = {
				OR = {
					values_others = yes
					is_pacifist = yes
			   }
			}
		}
		owner = {
			capital_scope = {
				enable_special_project = {
					name = "AMOEBAS_PACIFICATION_PROJECT"
					location = this
					owner = root.owner
				}
			}
		}
		ai_chance = {
			factor = 10
		}
		finish_first_contact_effect = yes
	}
}


### Crystals

first_contact_event = {
	id = first_contact_critters.30
	title = first_contact_critters.30.name
	desc = first_contact_critters.30.desc
	picture = GFX_evt_unidentified_monster
	show_sound = event_space_crystals

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact_critters.30.A
		set_first_contact_stage = crystals_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.35
	title = story.201.name
	desc = {
		trigger = {
			hidden:owner = {
				switch = {
					trigger = has_ethic
					ethic_fanatic_xenophile = { text = story.201.desc.phile }
					ethic_fanatic_xenophobe = { text = story.201.desc.phobe }
					ethic_fanatic_militarist = { text = story.201.desc.milit }
					ethic_fanatic_pacifist = { text = story.201.desc.pacif }
					ethic_xenophile = { text = story.201.desc.phile }
					ethic_xenophobe = { text = story.201.desc.phobe }
					ethic_militarist = { text = story.201.desc.milit }
					ethic_pacifist = { text = story.201.desc.pacif }
					default = { text = story.201.desc }
				}
			}
			text = newline
			success_text = {
				text = story.201.desc.fruitful
				hidden:owner = { has_origin = origin_fruitful }
			}
			success_text = {
				text = first_contact_critters.35.desc.primal_calling
				hidden:owner = { has_origin = origin_primal_calling }
			}
		}
	}
	picture = GFX_evt_fleet_evil
	show_sound = event_space_crystals

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	option = { # Hunting Buff
		name = story.201.aa
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_militarist = yes
					is_homicidal = yes
				}
			}
		}
		owner = {
			add_modifier = {
				modifier = crystal_hunting_buff
				days = -1
			}
			increase_hunted_fauna_count = yes
		}
		custom_tooltip = story.201.aa.crystalhunt
	}

	option = { # Special Project
		name = story.201.bb
		owner = {
			capital_scope = {
				enable_special_project = {
					name = "CRYSTALS_PROJECT"
					location = this
					owner = root.owner
				}
			}
		}
	}

	option = {
		name = story.201.cc
		trigger = {
			owner = {
				OR = {
					values_others = yes
					is_pacifist = yes
					is_beastmasters_empire = yes
			   }
			}
		}
		owner = {
			capital_scope = {
				enable_special_project = {
					name = "CRYSTALS_PACIFICATION_PROJECT"
					location = this
					owner = root.owner
				}
			}
		}
	}

	after = {
		finish_first_contact_effect = yes
		set_site_progress_locked = no
		hidden_effect = {
			owner = {
				country_event = {
					id = grand_archive.200
					scopes = {
						from = event_target:crystal_country
						fromfrom = root.solar_system
					}
				}
			}
		}
	}
}

### Drones

first_contact_event = {
	id = first_contact_critters.40
	title = first_contact_critters.40.name
	desc = first_contact_critters.40.desc
	picture = GFX_evt_ship_in_orbit
	show_sound = event_ancient_drone

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact_critters.40.A
		set_first_contact_stage = drones_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.45
	title = first_contact_critters.45.name
	picture = GFX_evt_mining_station

	desc = {
		trigger = { owner = { has_ethic = ethic_gestalt_consciousness } }
		text = story.301.desc.gesta
	}
	# Materialist
	desc = {
		trigger = {
			owner = { is_materialist = yes }
		}
		text = story.301.desc.mater
	}
	# Pacifist
	desc = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		text = story.301.desc.pacif
	}
	# Generic
	desc = {
		trigger = {
			owner = {
				is_materialist = no
				is_pacifist = no
			}
		}
		text = first_contact_critters.45.desc
	}
	show_sound = event_ancient_drone

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact_critters.45.A
		owner = {
			capital_scope = {
				enable_special_project = {
					name = "DRONES_PROJECT"
					location = this
					owner = root.owner
				}
			}
		}
		finish_first_contact_effect = yes
	}
}


### Marauders

first_contact_event = {
	id = first_contact_critters.50
	title = first_contact_critters.50.name
	desc = first_contact_critters.50.desc
	picture = GFX_evt_pirates_attacking_cargo
	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_critters.50.A
		set_first_contact_stage = marauders_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.55
	title = marauder.1.name
	desc = marauder.1.desc
	picture = GFX_evt_pirate_armada
	inline_script = first_contact_event_sounds

	location = event_target:marauder_system

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes

		contact_country = {
			save_event_target_as = encountered_marauder
			switch = {
				trigger = has_country_flag
				marauder_1 = {
					random_system = {
						limit = { has_star_flag = marauder_capital_1 }
						save_event_target_as = marauder_system
					}
				}
				marauder_2 = {
					random_system = {
						limit = { has_star_flag = marauder_capital_2 }
						save_event_target_as = marauder_system
					}
				}
				marauder_3 = {
					random_system = {
						limit = { has_star_flag = marauder_capital_3 }
						save_event_target_as = marauder_system
					}
				}
			}
		}
		if = {
			limit = {
				owner = {
					intel_level = {
						level = none
						system = event_target:marauder_system
					}
				}
				solar_system? = {
					any_fleet_in_system = {
						is_ship_class = shipclass_military_station
						is_owned_by = event_target:encountered_marauder
					}
				}
			}
			solar_system = {
				save_event_target_as = marauder_system
			}
		}
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = marauder.1.a
		finish_first_contact_effect = yes
	}
}


### Pirates

first_contact_event = {
	id = first_contact_critters.60
	title = first_contact_critters.60.name
	desc = first_contact_critters.60.desc
	picture = GFX_evt_unknown_ships
	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 = WORRYING
		set_first_contact_stage = pirates_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.65
	title = action.6.name
	desc = first_contact_critters.65.desc
	picture = GFX_evt_pirate_armada
	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 = pirate.5.a
		finish_first_contact_effect = yes
	}
}

### Caravaneers

first_contact_event = {
	id = first_contact_critters.70
	title = first_contact_critters.70.name
	desc = {
		trigger = {
			owner = {
				is_nomadic = yes
				NOT = { is_unfriendly = yes }
			}
			contact_country = {
				NOT = { is_same_value = event_target:caravaneer_home_country }
			}
		}
		text = first_contact_critters.70.desc.nomadic
	}
	desc = {
		trigger = {
			owner = {
				is_nomadic = yes
				is_unfriendly = yes
			}
			contact_country = {
				NOT = { is_same_value = event_target:caravaneer_home_country }
			}
		}
		text = first_contact_critters.70.desc.nomadic.unfriendly
	}
	desc = {
		trigger = {
			owner = {
				is_nomadic = no
			}
			contact_country = {
				NOT = { is_same_value = event_target:caravaneer_home_country }
			}
		}
		text = first_contact_critters.70.desc
	}
	desc = {
		trigger = {
			contact_country = {
				is_same_value = event_target:caravaneer_home_country
			}
		}
		text = first_contact_critters.70.desc.home
	}
	picture = GFX_evt_cargoship_caravan
	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 = {
		trigger = {
			owner = {
				is_nomadic = no
			}
		}
		name = {
			text = first_contact_critters.70.A
			trigger = {
				owner = {
					NOR = {
						is_xenophobe = yes
						is_militarist = yes
						is_gestalt = yes
					}
				}
			}
		}
		name = {
			text = first_contact_critters.70.B
			trigger = {
				owner = {
					OR = {
						is_xenophobe = yes
						is_militarist = yes
					}
				}
			}
		}
		name = {
			text = first_contact_critters.70.C
			trigger = {
				owner = {
					is_hive_empire = yes
				}
			}
		}
		name = {
			text = first_contact_critters.70.D
			trigger = {
				owner = {
					is_machine_empire = yes
				}
			}
		}
		set_first_contact_stage = caravaneers_stage_2
	}
	option = {
		name = first_contact_critters.70.E
		trigger = {
			owner = { is_nomadic = yes }
		}
		set_first_contact_stage = caravaneers_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.75
	title = first_contact_critters.75.name
	desc = {
		trigger = {
			contact_country = {
				NOT = { is_same_value = event_target:caravaneer_home_country }
			}
		}
		text = first_contact_critters.75.desc
	}
	desc = {
		trigger = {
			contact_country = {
				is_same_value = event_target:caravaneer_home_country
			}
		}
		text = first_contact_critters.75.desc.home
	}
	picture = GFX_evt_caravaneers
	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 = ON_SCREEN
		trigger = {
			contact_country = {
				NOT = { is_same_value = event_target:caravaneer_home_country }
			}
		}
		finish_first_contact_effect = yes
	}
	option = {
		name = first_contact_critters.75.B
		trigger = {
			contact_country = {
				is_same_value = event_target:caravaneer_home_country
			}
		}
		if = {
			limit = {
				owner = {
					is_homicidal = no
				}
			}
			custom_tooltip = first_contact_critters.75.B.tooltip
		}
		finish_first_contact_effect = yes
	}
}


### Void Clouds

first_contact_event = {
	id = first_contact_critters.80
	title = first_contact_critters.80.name
	desc = first_contact_critters.80.desc
	picture = GFX_evt_unidentified_monster
	show_sound = event_space_cloud

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = first_contact_critters.80.A
		set_first_contact_stage = void_clouds_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.85
	title = story.401.name
	desc = { # Gestalt
		trigger = {
			owner = { has_ethic = ethic_gestalt_consciousness }
		}
		text = story.401.desc.gesta
	}
	desc = { # Spiri
		trigger = { owner = { is_spiritualist = yes } }
		text = story.401.desc.spiri
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
				is_spiritualist = no
			}
		}
		text = story.401.desc
	}
	picture = GFX_evt_binary_stars
	show_sound = event_space_cloud

	is_triggered_only = yes
	first_contact = yes

	immediate = {
		set_site_progress_locked = yes
	}

	after = {
		set_site_progress_locked = no
	}

	option = {
		name = story.401.a.spiri
		trigger = { owner = { is_spiritualist = yes } }
		owner = {
			capital_scope = {
				enable_special_project = {
					name = "CLOUDS_PROJECT"
					location = this
					owner = root.owner
				}
			}
		}
		finish_first_contact_effect = yes
	}

	option = {
		name = story.401.c
		trigger = { owner = { NOT = { is_spiritualist = yes } } }
		owner = {
			capital_scope = {
				enable_special_project = {
					name = "CLOUDS_PROJECT"
					location = this
					owner = root.owner
				}
			}
		}
		finish_first_contact_effect = yes
	}
}


### Nomads

first_contact_event = {
	id = first_contact_critters.90
	title = first_contact_critters.90.name
	desc = first_contact_critters.90.desc
	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 = {
			text = first_contact_critters.70.A
			trigger = {
				owner = {
					NOR = {
						is_xenophobe = yes
						is_militarist = yes
						is_gestalt = yes
					}
				}
			}
		}
		name = {
			text = first_contact_critters.70.B
			trigger = {
				owner = {
					OR = {
						is_xenophobe = yes
						is_militarist = yes
					}
				}
			}
		}
		name = {
			text = first_contact_critters.70.C
			trigger = {
				owner = {
					is_hive_empire = yes
				}
			}
		}
		name = {
			text = first_contact_critters.70.D
			trigger = {
				owner = {
					is_machine_empire = yes
				}
			}
		}
		set_first_contact_stage = nomad_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.95
	title = first_contact_critters.95.name
	desc = first_contact_critters.95.desc
	picture = GFX_evt_cargoship_caravan
	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 = ON_SCREEN
		finish_first_contact_effect = yes
	}
}

### Neutral Factions

first_contact_event = {
	id = first_contact_critters.100
	title = first_contact_critters.70.name
	desc = first_contact_critters.100.desc
	picture = GFX_evt_unknown_ships
	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_critters.100.a
		set_first_contact_stage = neutrals_stage_2
	}
}

first_contact_event = {
	id = first_contact_critters.105
	title = first_contact_critters.105.name
	desc = first_contact_critters.105.desc
	picture = GFX_evt_fleet_neutral
	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 = CURIOUS
		finish_first_contact_effect = yes
	}
}

###################
# MUTUAL DISCOVERY
###################

# Triggered when two empires discover each other
# This = Empire 1
# From = Empire 2
# Fromfromfrom = System where contact occurred
country_event = {
	id = first_contact_critters.1000
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		first_contact_handled = no
		NOT = { has_communications = from }
	}

	immediate = {
		if = {
			limit = {
				from = {
					OR = {
						is_country_type = fallen_empire
						is_country_type = awakened_fallen_empire
					}
					OR = {
						has_origin = origin_fallen_empire
						AND = {
							has_country_flag = first_hive_fe_fragment
							has_origin = origin_fallen_empire_hive
						}
					}
				}
			}
			establish_communications_no_message = from
			from = { save_event_target_as = contact_empire }
			country_event = { id = action.1 }
		}
		else_if = {
			limit = { from = { is_country_type = awakened_marauders } }
			establish_communications_no_message = from
			if = {
				limit = {
					NOT = { has_global_flag = horde_triggered }
				}
				country_event = { id = marauder.501 }
			}
			else = {
				country_event = { id = marauder.526 }
			}
		}
		set_timed_relation_flag = {
			flag = just_encountered
			who = from
			days = 5
		}

		if = {
			limit = {
				NOT = {
					is_country_type = primitive
					from = {
						is_country_type = primitive
					}
				}
			}

			#establish communications with a delay of a few days, in case there's any other relevant events pending
			country_event = { id = first_contact_critters.1001 days = 5 }
		}

	}
}

country_event = {
	id = first_contact_critters.1001
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		exists = fromfrom
		NOT = { has_communications = fromfrom }
	}

	immediate = {
		if = {
			limit = {
				fromfrom = { has_country_flag = use_on_action_when_establishing_comms } #just in case someone wants that
			}
			establish_communications = fromfrom
		}
		else = { establish_communications_no_message = fromfrom }
	}
}
