############################
#
# Progress Events
#
# Written by Henrik Thyrwall
#
############################

namespace = progress

## Home System Surveyed
#country_event = {
#	id = progress.1
#	title = "progress.1.name"
#	desc = "progress.1.desc"
#	picture = GFX_evt_satellite_in_orbit
#
#	trigger = {
#		is_ai = no
#		NOT = { has_country_flag = surveyed_home_system }
#		NOT = {
#			capital_scope = {
#				solar_system = {
#					any_system_planet = {
#						is_surveyed = {
#							who = ROOT
#							status = no
#						}
#					}
#				}
#			}
#		}
#	}
#
#	mean_time_to_happen = {
#		days = 1
#	}
#
#	immediate = {
#		set_country_flag = surveyed_home_system
#		capital_scope = {
#			solar_system = { save_event_target_as = home_system }
#		}
#	}
#
#	option = {
#		name = "progress.1.a"
#		end_event_chain = "survey_home_system"
#		add_resource = { physics_research = 200 }
#		hidden_effect = {
#			country_event = { id = progress.8 days = 20 random = 5 }
#		}
#	}
#}

# Discovery of Alien Life
ship_event = {
	id = progress.2
	title = "progress.2.name"
	desc = {
		trigger = {
			owner = {
				NOR = {
					is_machine_empire = yes
					has_origin = origin_storm_chasers
					is_individual_machine = yes
					is_wilderness_empire = yes
				}
			}
		}
		text = "progress.2.desc"
	}
	desc = {
		trigger = {
			owner = { is_wilderness_empire = yes }
		}
		text = "progress.2.desc.wilderness"
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
				NOR = {
					has_civic = civic_machine_terminator
					has_civic = civic_machine_servitor
					has_civic = civic_machine_assimilator
					has_origin = origin_storm_chasers
				}
			}
		}
		text = "progress.2.desc.mach"
	}
	desc = {
		trigger = { owner = { has_civic = civic_machine_terminator } }
		text = "progress.2.desc.term"
	}
	desc = {
		trigger = { owner = { has_civic = civic_machine_servitor } }
		text = "progress.2.desc.serv"
	}
	desc = {
		trigger = { owner = { has_civic = civic_machine_assimilator } }
		text = "progress.2.desc.assim"
	}
	desc = {
		trigger = {
			owner = {
				has_origin = origin_storm_chasers
				is_gestalt = no
			}
		}
		text = "progress.2.desc.storm.normal"
	}
	desc = {
		trigger = {
			owner = {
				has_origin = origin_storm_chasers
				is_gestalt = yes
			}
		}
		text = "progress.2.desc.storm.gestalt"
	}
	desc = {
		trigger = {
			owner = {
				is_individual_machine = yes
			}
		}
		text = "progress.2.desc.droid"
	}

	desc = {
		trigger = {
			owner = {
				has_origin = origin_evolutionary_predators
			}
		}
		text = "progress.2.desc.evopred"
	}

	picture = GFX_evt_alien_planet

	location = from
	show_sound = event_alien_nature

	is_triggered_only = yes

	trigger = {
		owner = {
			is_ai = no
			NOR = {
				has_country_flag = first_alien_life
				has_country_flag = Story1
				has_country_flag = Story2
				has_country_flag = Story3
				has_country_flag = Story4
				has_country_flag = Story5
				has_country_flag = Story6
				has_country_flag = Story7
				has_country_flag = Story8
			}
		}
		FROM = {
			has_owner = no
			OR = {
				is_planet_class = pc_desert
				is_planet_class = pc_tropical
				is_planet_class = pc_arid
				is_planet_class = pc_continental
				is_planet_class = pc_ocean
				is_planet_class = pc_tundra
				is_planet_class = pc_arctic
				is_planet_class = pc_alpine
				is_planet_class = pc_savannah
				is_planet_class = pc_gaia
			}
		}
	}

	immediate = {
		owner = { set_country_flag = first_alien_life }
	}

	option = {
		trigger = {
			owner = {
				NOR = {
					is_machine_empire = yes
					has_origin = origin_storm_chasers
				}
			}
		}
		name = "progress.2.a"
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		hidden_effect = {
			owner = {
				if = {
					limit = {
						from = {
							has_deposit = d_dangerous_wildlife_blocker
						}
					}
					country_event = { id = story.3 days = 30 }
				}
				if = {
					limit = {
						from = {
							NOT = {
								has_deposit = d_dangerous_wildlife_blocker
							}
						}
					}
					country_event = { id = story.1 days = 30 }
				}
			}
		}
	}
	option = {
		trigger = {
			owner = {
				AND = {
					is_machine_empire = yes
					NOR = {
						has_civic = civic_machine_terminator
						has_civic = civic_machine_servitor
						has_civic = civic_machine_assimilator
						has_origin = origin_storm_chasers
					}
				}
			}
		}
		name = "progress.2.a.mech"
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		hidden_effect = {
			owner = {
				if = {
					limit = {
						from = {
							has_deposit = d_dangerous_wildlife_blocker
						}
					}
					country_event = { id = story.3 days = 30 }
				}
				if = {
					limit = {
						from = {
							NOT = {
								has_deposit = d_dangerous_wildlife_blocker
							}
						}
					}
					country_event = { id = story.1 days = 30 }
				}
			}
		}
	}
	option = {
		trigger = { owner = { has_civic = civic_machine_terminator } }
		name = "progress.2.a.term"
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		hidden_effect = {
			owner = {
				if = {
					limit = {
						from = {
							has_deposit = d_dangerous_wildlife_blocker
						}
					}
					country_event = { id = story.3 days = 30 }
				}
				if = {
					limit = {
						from = {
							NOT = {
								has_deposit = d_dangerous_wildlife_blocker
							}
						}
					}
					country_event = { id = story.1 days = 30 }
				}
			}
		}
	}
	option = {
		trigger = { owner = { has_civic = civic_machine_servitor } }
		name = "progress.2.a.serv"
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		hidden_effect = {
			owner = {
				if = {
					limit = {
						from = {
							has_deposit = d_dangerous_wildlife_blocker
						}
					}
					country_event = { id = story.3 days = 30 }
				}
				if = {
					limit = {
						from = {
							NOT = {
								has_deposit = d_dangerous_wildlife_blocker
							}
						}
					}
					country_event = { id = story.1 days = 30 }
				}
			}
		}
	}
	option = {
		trigger = { owner = { has_civic = civic_machine_assimilator } }
		name = "progress.2.a.assim"
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		hidden_effect = {
			owner = {
				if = {
					limit = {
						from = {
							has_deposit = d_dangerous_wildlife_blocker
						}
					}
					country_event = { id = story.3 days = 30 }
				}
				if = {
					limit = {
						from = {
							NOT = {
								has_deposit = d_dangerous_wildlife_blocker
							}
						}
					}
					country_event = { id = story.1 days = 30 }
				}
			}
		}
	}
	option = {
		trigger = { owner = { has_origin = origin_storm_chasers } }
		name = EXCELLENT
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = progress.2.a.evopred
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# First Colony
# See nomads.4705 for the nomadic settlement equivalent.
carrier_event = {
	id = progress.3
	title = "progress.3.name"
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_big_landing_ship
		BIOSHIP_PICTURE = GFX_evt_bioship_landing
	}

	desc = { # Lithoid origin
		text = progress.3.desc_lith
		trigger = {
			exists = FROM
			FROM = { is_ship_size = lithoid_colonizer }
		}
	}
	desc = { # Continental
		text = progress.3.desc_01
		trigger = {
			is_planet_class = pc_continental
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Ocean
		text = progress.3.desc_02
		trigger = {
			is_planet_class = pc_ocean
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Desert
		text = progress.3.desc_03
		trigger = {
			is_planet_class = pc_desert
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Tropical
		text = progress.3.desc_04
		trigger = {
			is_planet_class = pc_tropical
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Arid
		text = progress.3.desc_05
		trigger = {
			is_planet_class = pc_arid
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Tundra
		text = progress.3.desc_06
		trigger = {
			is_planet_class = pc_tundra
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Arctic
		text = progress.3.desc_07
		trigger = {
			is_planet_class = pc_arctic
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Savanna
		text = progress.3.desc_08
		trigger = {
			is_planet_class = pc_savannah
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Alpine
		text = progress.3.desc_09
		trigger = {
			is_planet_class = pc_alpine
			NOR = {
				owner = {
					OR = {
						is_hive_empire = yes
						is_machine_empire = yes
						is_individual_machine = yes
						has_origin = origin_storm_chasers
					}
				}
				AND = {
					exists = FROM
					FROM = { is_ship_size = lithoid_colonizer }
				}
			}
		}
	}
	desc = { # Machine Empires
		text = progress.3.desc_10
		trigger = {
			owner = {
				is_machine_empire = yes
				NOT = { has_origin = origin_storm_chasers }
			}
		}
	}
	desc = { # Storm Chasers Regular
		text = progress.3.desc.storm.normal
		trigger = {
			owner = {
				has_origin = origin_storm_chasers
				is_gestalt = no
			}
		}
	}
	desc = { # Storm Chasers Gestalt
		text = progress.3.desc.storm.gestalt
		trigger = {
			owner = {
				has_origin = origin_storm_chasers
				is_gestalt = yes
			}
		}
	}

	# Individual Machines
	desc = {
		text = progress.3.desc_11_droids
		trigger = {
			owner = {
				is_individual_machine = yes
			}
		}
	}

	# Biological Hives
	desc = {
		text = progress.3.desc_11_hive
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
	}

	location = root
	is_triggered_only = yes

	trigger = {
		NOR = {
			is_planet_class = pc_gaia
			is_planet_class = pc_habitat
			is_planet_class = pc_ringworld_habitable
			is_planet_class = pc_relic
			is_planet_class = pc_nuked
			FROM = {
				is_ship_size = guided_sapience_colonizer
			}
		}
		owner = {
			NOR = {
				has_origin = origin_remnants
				has_origin = origin_broken_shackles
				has_origin = origin_legendary_leader_dictatorial
				has_origin = origin_legendary_leader_imperial
				has_origin = origin_wilderness
				has_country_flag = first_colony
			}
			num_owned_planets < 3
		}
	}

	immediate = {
		owner = {
			set_country_flag = first_colony
		}
	}

	option = {
		trigger = {
			owner = { is_materialist = yes }
		}
		name = "progress.3.materialist"
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		root = {
			add_modifier = {
				modifier = planet_new_colony_materialist_attraction
				years = 20
			}
		}
	}
	option = {
		trigger = {
			owner = { is_spiritualist = yes }
		}
		name = "progress.3.spiritualist"
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		root = {
			add_modifier = {
				modifier = planet_new_colony_spiritualist_attraction
				years = 20
			}
		}
	}
	option = {
		trigger = {
			owner = { is_militarist = yes }
		}
		name = "progress.3.militarist"
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		root = {
			add_modifier = {
				modifier = planet_new_colony_militarist_attraction
				years = 20
			}
		}
	}
	option = {
		trigger = {
			owner = { is_pacifist = yes }
		}
		name = "progress.3.pacifist"
		owner = {
			add_monthly_resource_mult = {
				resource = consumer_goods
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		root = {
			add_modifier = {
				modifier = planet_new_colony_pacifist_attraction
				years = 20
			}
		}
	}
	option = {
		trigger = {
			owner = { is_authoritarian = yes }
		}
		name = "progress.3.authoritarian"
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		root = {
			add_modifier = {
				modifier = planet_new_colony_authoritarian_attraction
				years = 20
			}
		}
	}
	option = {
		trigger = {
			owner = { is_xenophile = yes }
		}
		name = "progress.3.xenophile"
		owner = {
			add_monthly_resource_mult = {
				resource = energy
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		root = {
			add_modifier = {
				modifier = planet_new_colony_xenophile_attraction
				years = 20
			}
		}
	}
	option = {
		trigger = {
			owner = { is_xenophobe = yes }
		}
		name = "progress.3.xenophobe"
		owner = {
			add_monthly_resource_mult = {
				resource = minerals
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		root = {
			add_modifier = {
				modifier = planet_new_colony_xenophobe_attraction
				years = 20
			}
		}
	}
	option = {
		trigger = {
			owner = { is_egalitarian = yes }
		}
		name = "progress.3.egalitarian"
		owner = {
			if = {
				limit = {
					is_lithoid_empire = yes
				}
				add_monthly_resource_mult = {
					resource = minerals
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
			else_if = {
				limit = {
					is_infernal_empire = yes
				}
				add_monthly_resource_mult = {
					resource = alloys
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = food
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
		}
		root = {
			add_modifier = {
				modifier = planet_new_colony_egalitarian_attraction
				years = 20
			}
		}
	}
	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = "progress.3.gestalt_consciousness_hive"
		owner = {
			if = {
				limit = {
					is_lithoid_empire = yes
				}
				add_monthly_resource_mult = {
					resource = minerals
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
			else_if = {
				limit = {
					is_infernal_empire = yes
				}
				add_monthly_resource_mult = {
					resource = alloys
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = food
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
		}
	}
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = "progress.3.gestalt_consciousness_machine"
		owner = {
			add_monthly_resource_mult = {
				resource = energy
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
	}
	option = {
		exclusive_trigger = { owner = { has_origin = origin_storm_chasers } }
		name = "progress.3.a.storm"
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
	option = {
		exclusive_trigger = { owner = { has_origin = origin_evolutionary_predators } }
		name = "progress.3.b.evopred"
		owner = {
			#end_event_chain = "establish_colony"
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
	after = {
		# This is done to inform the player that they get the research options.
		if = {
			limit = {
				owner = {
					is_environmental_architects_empire = yes
				}
			}
			tooltip = {
				add_research_options_for_natural_blockers = yes
			}
		}
	}
}

# First Contact (Normal Empire)
country_event = {
	id = progress.4
	title = "progress.4.name"
	picture = GFX_evt_news_room

	desc = {
		text = progress.4.desc_01
		trigger = {
			NOT = {
				OR = {
					is_xenophobe = yes
					is_xenophile = yes
					has_ethic = ethic_gestalt_consciousness
					has_origin = origin_storm_chasers
				}
			}
		}
	}
	desc = { # Xenophile
		text = progress.4.desc_02
		trigger = {
			is_xenophile = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	desc = { # Xenophobe
		text = progress.4.desc_03
		trigger = {
			is_xenophobe = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	desc = { # Gestalt Consciousness
		text = progress.4.desc_04
		trigger = {
			has_ethic = ethic_gestalt_consciousness
			NOT = { has_origin = origin_storm_chasers }
		}
	}

	desc = { # Storm Chasers
		text = progress.4.desc.storm
		trigger = { has_origin = origin_storm_chasers }
	}

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_country_flag = first_contact_event }
		NOR = {
			has_origin = origin_payback
			has_origin = origin_broken_shackles
			has_origin = origin_sacred_path
		}
		event_target:contact_empire = {
			NOR = {
				is_country_type = fallen_empire
				is_country_type = awakened_fallen_empire
				#is_country_type = tiyanki
				is_amoeba_country_type = yes
				is_country_type = cloud
				is_drone_country_type = yes
				is_crystal_country_type = yes
			}
			is_primitive = no
		}
	}

	immediate = {
		set_country_flag = first_contact_event
	}

	option = {
		name = "progress.4.a"
		trigger = {
			NOT = {
				OR = {
					has_ethic = ethic_gestalt_consciousness
					is_xenophobe = yes
					is_xenophile = yes
					has_origin = origin_storm_chasers
				}
			}
		}
	}
	option = {
		name = "progress.4.b"
		trigger = {
			is_xenophile = yes
			NOT = { owner = { has_origin = origin_storm_chasers } }
		}
	}
	option = {
		name = "progress.4.c"
		trigger = {
			is_xenophobe = yes
			NOT = { owner = { has_origin = origin_storm_chasers } }
		}
	}
	option = {
		name = "progress.4.d"
		trigger = {
			is_hive_empire = yes
			has_devouring_swarm_government = no
			NOT = { owner = { has_origin = origin_storm_chasers } }
		}
	}
	option = {
		name = "progress.4.e"
		trigger = {
			is_machine_empire = yes
			NOR = {
				has_government = "gov_machine_terminator"
				has_origin = origin_storm_chasers
			}
		}
	}
	option = {
		name = "progress.4.f"
		trigger = {
			has_devouring_swarm_government = yes
			NOT = { owner = { has_origin = origin_storm_chasers } }
		}
	}
	option = {
		name = "progress.4.g"
		trigger = {
			has_government = "gov_machine_terminator"
			NOT = { owner = { has_origin = origin_storm_chasers } }
		}
	}
	option = {
		name = progress.4.h.storm
		trigger = { has_origin = origin_storm_chasers }
	}

	after = {
		if = {
			limit = {
				has_paragon_dlc = yes
				is_gestalt = no
				is_homicidal = no
			}
			add_research_option = tech_xeno_linguistics
		}
	}
}

# First Contact (Primitive)
country_event = {
	id = progress.5
	title = "progress.5.name"
	picture = GFX_evt_news_room

	desc = {
		text = progress.5.desc_01
		trigger = {
			NOT = {
				OR = {
					has_ethic = ethic_gestalt_consciousness
					is_xenophobe = yes
					is_xenophile = yes
					has_origin = origin_storm_chasers
				}
			}
		}
	}
	desc = { # Xenophile
		text = progress.5.desc_02
		trigger = {
			is_xenophile = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	desc = { # Xenophobe
		text = progress.5.desc_03
		trigger = {
			is_xenophobe = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	desc = { # Gestalt Consciousness
		text = progress.5.desc_04
		trigger = {
			has_ethic = ethic_gestalt_consciousness
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	desc = { # Storm Chasers Normal
		text = progress.5.desc.storm.normal
		trigger = {
			has_origin = origin_storm_chasers
			is_gestalt = no
		}
	}
	desc = { # Storm Chasers Gestalt
		text = progress.5.desc.storm.gestalt
		trigger = {
			has_origin = origin_storm_chasers
			is_gestalt = yes
		}
	}

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_country_flag = first_contact_preFTL_established }
		NOR = {
			has_origin = origin_payback
			has_origin = origin_broken_shackles
			has_origin = origin_unplugged
		}
		event_target:contact_empire = { is_primitive = yes }
	}

	immediate = {
		set_country_flag = first_contact_preFTL_established
	}

	option = {
		name = "progress.4.a"
		trigger = {
			NOT = {
				OR = {
					has_ethic = ethic_gestalt_consciousness
					is_xenophobe = yes
					is_xenophile = yes
					has_origin = origin_storm_chasers
				}
			}
		}
	}
	option = {
		name = "progress.5.b"
		trigger = {
			is_xenophile = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	option = {
		name = "progress.5.c"
		trigger = {
			is_xenophobe = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	option = {
		name = "progress.4.d"
		trigger = {
			is_hive_empire = yes
			NOR = {
				has_devouring_swarm_government = yes
				has_origin = origin_storm_chasers
			}
		}
	}
	option = {
		name = "progress.4.e"
		trigger = {
			is_machine_empire = yes
			NOR = {
				has_government = "gov_machine_terminator"
				has_origin = origin_storm_chasers
			}
		}
	}
	option = {
		name = "progress.4.f"
		trigger = {
			has_devouring_swarm_government = yes
		}
	}
	option = {
		name = "progress.4.g"
		trigger = {
			has_government = "gov_machine_terminator"
		}
	}
	option = {
		name = progress.5.h.storm
		trigger = { has_origin = origin_storm_chasers }
	}
}

# First Contact (Fallen Empire)
country_event = {
	id = progress.6
	title = "progress.4.name"
	picture = GFX_evt_news_room

	desc = {
		text = progress.6.desc_01
		trigger = {
			NOT = {
				OR = {
					has_ethic = ethic_gestalt_consciousness
					is_xenophobe = yes
					is_xenophile = yes
					has_origin = origin_storm_chasers
				}
			}
		}
	}
	desc = { # Xenophile
		text = progress.6.desc_02
		trigger = {
			is_xenophile = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	desc = { # Xenophobe
		text = progress.6.desc_03
		trigger = {
			is_xenophobe = yes

		}
	}
	desc = { # Gestalt Consciousness
		text = progress.6.desc_04
		trigger = {
			has_ethic = ethic_gestalt_consciousness
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	desc = { # Storm Chasers
		text = progress.6.desc.storm
		trigger = { has_origin = origin_storm_chasers }
	}

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_country_flag = first_contact_event }
		NOT = { has_origin = origin_payback }
		event_target:contact_empire = { is_country_type = fallen_empire }
	}

	immediate = {
		set_country_flag = first_contact_event
	}

	option = {
		name = "progress.4.a"
		trigger = {
			NOT = {
				OR = {
					has_ethic = ethic_gestalt_consciousness
					is_xenophobe = yes
					is_xenophile = yes
					has_origin = origin_storm_chasers
				}
			}
		}
	}
	option = {
		name = "progress.6.b"
		trigger = {
			is_xenophile = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	option = {
		name = "progress.6.c"
		trigger = {
			is_xenophobe = yes
			NOT = { has_origin = origin_storm_chasers }
		}
	}
	option = {
		name = "progress.4.d"
		trigger = {
			is_hive_empire = yes
			NOR = {
				has_devouring_swarm_government = yes
				has_origin = origin_storm_chasers
			}
		}
	}
	option = {
		name = "progress.4.e"
		trigger = {
			is_machine_empire = yes
			NOR = {
				has_government = "gov_machine_terminator"
				has_origin = origin_storm_chasers
			}
		}
	}
	option = {
		name = "progress.4.f"
		trigger = {
			has_devouring_swarm_government = yes
		}
	}
	option = {
		name = "progress.4.g"
		trigger = {
			has_government = "gov_machine_terminator"
		}
	}
	option = {
		name = progress.6.h.storm
		trigger = { has_origin = origin_storm_chasers }
	}
}

carrier_event = {
	id = progress.7

	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = { has_country_flag = first_colony }
			num_owned_planets > 2
		}
	}

	immediate = {
		owner = {
			set_country_flag = first_colony
		}
	}
}

# First Contact (special event for Payback Origin)
country_event = {
	id = progress.9
	title = "progress.9.name"
	picture = GFX_evt_news_room

	desc = {
		trigger = {
			text = "progress.9.desc.start"
			success_text = {
				text = "progress.9.desc.default"
				event_target:contact_empire = {
					is_country_type = default
					NOT = { has_origin = origin_slavers }
				}
			}
			success_text = {
				text = "progress.9.desc.preftl"
				event_target:contact_empire = { is_primitive = yes }
			}
			success_text = {
				text = "progress.9.desc.fallen"
				event_target:contact_empire = { is_country_type = fallen_empire }
			}
			success_text = {
				text = "progress.9.desc.msi"
				event_target:contact_empire = { has_origin = origin_slavers }
			}
			text = newline
			success_text = {
				text = "progress.9.desc.friendly_friendly"
				has_country_flag = first_contact_event_friendly_friendly
			}
			success_text = {
				text = "progress.9.desc.friendly_mean"
				has_country_flag = first_contact_event_friendly_mean
			}
			success_text = {
				text = "progress.9.desc.mean_friendly"
				has_country_flag = first_contact_event_mean_friendly
			}
			success_text = {
				text = "progress.9.desc.mean_mean"
				has_country_flag = first_contact_event_mean_mean
			}
			success_text = {
				text = "progress.9.desc.msi2"
				event_target:contact_empire = { has_origin = origin_slavers }
			}
		}
	}

	is_triggered_only = yes

	trigger = {
		is_ai = no
		has_origin = origin_payback
		NOT = { has_country_flag = first_contact_event_payback }
	}

	immediate = {
		set_country_flag = first_contact_event_payback
		if = {
			limit = {
				# friendly aliens meeting friendly aliens
					is_unfriendly = no
					is_xenophobe = no

				event_target:contact_empire = {
					is_unfriendly = no
					is_xenophobe = no
				}
			}
			set_country_flag = first_contact_event_friendly_friendly
		}
		else_if = {
			# friendly aliens meeting mean aliens
			limit = {
					is_unfriendly = no
					is_xenophobe = no

				event_target:contact_empire = {
					OR = {
						is_unfriendly = yes
						is_xenophobe = yes
					}
				}
			}
			set_country_flag = first_contact_event_friendly_mean
			# xenophobic faction created
			hidden_effect = {
				while = {
					count = 5
					pop_group_add_ethic_effect = {
						ETHOS = ethic_xenophobe
						AMOUNT = 100
						RANDOM = 25
					}
				}
			}
			# If militarist, they now want to defeat the mean aliens
			# if not, they just want to be left alone
			if = {
				limit = { is_militarist = yes }
				enable_faction_of_type = supremacist
			}
			else = {
				enable_faction_of_type = isolationist
			}
		}
		else_if = {
			# mean aliens meeting nice aliens
			limit = {
				OR = {
					is_unfriendly = yes
					is_xenophobe = yes
				}
				event_target:contact_empire = {
					is_unfriendly = no
					is_xenophobe = no
				}
			}
			set_country_flag = first_contact_event_mean_friendly
			# xenophilic faction created
			enable_faction_of_type = xenoist
			hidden_effect = {
				while = {
					count = 5
					weighted_random_owned_pop_group = {
						limit = {
							is_same_species = owner.species
							has_any_ethic = yes
						}
						pop_group_add_ethic_effect = {
							POP_GROUP = this
							ETHOS = ethic_xenophile
							PERCENTAGE = 100
							RANDOM = 25
						}
					}
				}
			}
		}
		else_if = {
			# mean aliens meeting mean aliens
			limit = {
				OR = {
					is_unfriendly = yes
					is_xenophobe = yes
				}
				event_target:contact_empire = {
					OR = {
						is_unfriendly = yes
						is_xenophobe = yes
					}
				}
			}
			set_country_flag = first_contact_event_mean_mean
		}
		else = {
			# generic fallback option
			set_country_flag = first_contact_event_neutral
		}
	}

	option = {
		name = ACKNOWLEDGED
	}

	after = {
		every_owned_planet = {
			every_owned_pop_group = {
				force_faction_evaluation = yes
			}
		}
	}
}
