##############################
# Arkship Events
##############################
namespace = arkship

#Arkship Event Director
country_event = {
	id = arkship.1
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_nomadic = yes
	}

	immediate = {
		random_list = {
			50 = {
				modifier = {	# For the first five years you get no events so you have some time to journey around
					factor = 0
					years_passed < 5
				}
				modifier = {	# We increase events to bring you into the mid-game
					factor = 1.5
					mid_game_years_passed < 1
					years_passed >= 5
				}
				modifier = {	# A little cooldown so you don't get an event right as you join a war
					factor = 0
					has_country_flag = nomad_recent_war
				}
				modifier = {	# Block the event pool if all Arkships are in combat.
					factor = 0
					NOT = {
						any_owned_ship = {
							is_arkship_ship = yes
							is_in_combat = no
						}
					}
				}
				generate_arkship_event = yes
			}
			100 = { # No Arkship Event today
				country_event = { id = arkship.1 days = @very_short_arkship_event_delay_days random = @very_short_arkship_event_delay_random } #Roughly 3-5 year cooldown to try and fire another event
			}
		}
		country_event = { id = nomads.7000 }
	}
}

 # An Old Container
carrier_event = {
	id = arkship.5
	title = "arkship.5.name"
	desc = "arkship.5.desc"
	picture = GFX_evt_resource_cache
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			is_gestalt = no
			NOT = { has_country_flag = arkship_flag_container }
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_flag_container
			begin_event_chain = {
				event_chain = an_old_container_chain
				target = root
			}
		}
	}

	option = {
		name = arkship.5.a
		hidden_effect = {
			random_list = {
				1 = { carrier_event = { id = arkship.10 days = @extremely_short_arkship_event_delay_days random = 60 } }
				1 = { carrier_event = { id = arkship.35 days = @extremely_short_arkship_event_delay_days random = 60 } }
				1 = { carrier_event = { id = arkship.45 days = @extremely_short_arkship_event_delay_days random = 60 } }
			}
		}
	}
}

carrier_event = {
	id = arkship.10
	title = "arkship.10.name"
	desc = "arkship.10.desc"
	picture = GFX_evt_resource_cache
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	option = {
		name = arkship.10.a
		hidden_effect = {
			carrier_event = { id = arkship.15 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 500
				}
			}
		}
		owner = {
			add_resource = {
				energy = -500
			}
		}
	}
	option = {
		name = arkship.10.b
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
			end_event_chain = an_old_container_chain
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

carrier_event = {
	id = arkship.15
	title = "arkship.15.name"
	desc = "arkship.15.desc"
	picture = GFX_evt_resource_cache
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	option = {
		name = arkship.15.a
		trigger = {
			owner = { has_grand_archive = no }
		}
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = increase_passenger_satisfaction
			owner = { increase_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = { id = arkship.20 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
	option = {
		name = arkship.15.b
		trigger = {
			owner = { has_grand_archive = yes }
		}
		hidden_effect = {
			carrier_event = { id = arkship.20 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
	option = {
		name = arkship.15.c
		hidden_effect = {
			carrier_event = { id = arkship.25 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 1000
				}
			}
		}
		owner = {
			add_resource = {
				energy = -1000
			}
		}
	}
	option = {
		name = arkship.15.d
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = decrease_passenger_satisfaction
			owner = { decrease_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = { id = arkship.30 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
}

carrier_event = {
	id = arkship.20
	title = "arkship.20.name"
	desc = "arkship.20.desc"
	picture = GFX_evt_specimen_archive
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	option = {
		name = arkship.20.a
		if = {
			limit = {
				owner = { has_grand_archive = yes }
			}
			owner = {
				give_specimen = {
					key = black_crystal
				}
			}
		}
		else = {
			add_modifier = { modifier = "black_crystal_no_grand_archive" }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
			end_event_chain = an_old_container_chain
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.25
	title = "arkship.25.name"
	desc = "arkship.25.desc"
	picture = GFX_evt_specimen_archive
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	option = {
		name = arkship.25.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			end_event_chain = an_old_container_chain
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.30
	title = "arkship.30.name"
	desc = "arkship.30.desc"
	picture = GFX_evt_resource_cache
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	option = {
		name = arkship.30.a
		add_modifier = {
			modifier = "black_crystal_engine_speed"
		}
		owner = {
			end_event_chain = an_old_container_chain
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.35
	title = "arkship.35.name"
	desc = "arkship.35.desc"
	picture = GFX_evt_resource_cache
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	option = {
		name = arkship.35.a
		owner = {
			add_resource = { sr_dark_matter = 100 }
			add_resource = { consumer_goods = 100 }
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
			end_event_chain = an_old_container_chain
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.45
	title = "arkship.45.name"
	desc = "arkship.45.desc"
	picture = GFX_evt_specimen_archive
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	immediate = {
		owner = {
			# Set costs based on empire size
			# Base of 500 Energy
			set_variable = {
				which = doll_cracking_open
				value = 500
			}
			multiply_variable = {
				which = doll_cracking_open
				value = value:edict_size_effect
			}
		}
	}

	option = {
		name = arkship.45.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= doll_cracking_open
				}
			}
		}
		hidden_effect = {
			carrier_event = { id = arkship.50 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
		owner = {
			add_resource = {
				energy = -1
				mult = doll_cracking_open
			}
			hidden_effect = {
				clear_variable = doll_cracking_open
			}
		}
	}

	option = {
		name = arkship.45.b
		hidden_effect = {
			carrier_event = { id = arkship.55 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}
}

carrier_event = {
	id = arkship.50
	title = "arkship.50.name"
	desc = "arkship.50.desc"
	picture = GFX_evt_specimen_archive
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	option = {
		name = arkship.50.a
		add_modifier = { modifier = "mysterious_doll" }
		owner = {
			end_event_chain = an_old_container_chain
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.55
	title = "arkship.55.name"
	desc = "arkship.55.desc"
	picture = GFX_evt_specimen_archive
	show_sound = event_ship_thrusters
	event_chain = an_old_container_chain

	is_triggered_only = yes

	option = {
		name = arkship.55.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
			end_event_chain = an_old_container_chain
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

# Engine Contaminants
carrier_event = {
	id = arkship.60
	title = "arkship.60.name"
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = "arkship.60.desc.regular"
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = yes
			}
		}
		text = "arkship.60.desc.gestalt"
	}
	picture = GFX_evt_nomad_default
	show_sound = event_ship_thrusters

	is_triggered_only = yes

	trigger = {
		NOT = { has_carrier_flag = arkship_engine_contanimants }
	}

	immediate = {
		set_carrier_flag = arkship_engine_contanimants
	}

	option = { # Replace the affected part
		name = arkship.60.a
		trigger = {
			owner = {
				NOR = {
					has_valid_civic = civic_scavengers
					has_valid_civic = civic_corporate_scavengers
				}
			}
		}
		inline_script = {
			script = events/dynamic_resource_cost
			RESOURCE = alloys
			COST1 = 200
			INCOME1 = 10
			COST2 = 500
			INCOME2 = 50
			COST3 = 1000
			INCOME3 = 100
			COST4 = 2000
			INCOME4 = 200
			COST5 = 5000
			INCOME5 = 500
			OWNER_SCOPE = owner
		}
	}

	option = {
		name = arkship.60.a.scavanger
		trigger = {
			owner = {
				OR = {
					has_valid_civic = civic_scavengers
					has_valid_civic = civic_corporate_scavengers
				}
			}
		}
	}

	option = { # Run the generator anyways
		name = arkship.60.b
		add_modifier = { modifier = dirty_generator years = 2 }
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = increase_passenger_satisfaction
			owner = { increase_passenger_satisfaction = yes }
		}
	}

	option = { # Run the ship slower
		name = arkship.60.c
		add_modifier = {
			modifier = underclocked_generator
			years = 2
		}
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = decrease_passenger_satisfaction
			owner = { decrease_passenger_satisfaction = yes }
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @short_arkship_event_delay_days random = @short_arkship_event_delay_random } } }
	}
}

# Start Your Engines
carrier_event = {
	id = arkship.65
	title = "arkship.65.name"
	desc = "arkship.65.desc"
	picture = GFX_evt_operative_chase
	show_sound = event_ship_thrusters

	is_triggered_only = yes

	trigger = {
		NOT = { owner = { has_country_flag = arkship_start_your_engines } }
		owner = {
			is_gestalt = no
			count_relation = {
				count > 1
				limit = {
					is_country_type = default
					has_communications = prev
				}
			}
		}
	}

	immediate = {
		owner = {
			if = {
				limit = { # You can get this event twice per game, so the blocking flag is only temporary the first time
					NOT = { has_country_flag = had_first_race}
				}
				set_timed_country_flag = {
					flag = arkship_start_your_engines
					years = 35
				}
				set_country_flag = had_first_race
			}
			else = {
				set_country_flag = arkship_start_your_engines
			}

			while = {
				count = 4
				generate_start_your_engines_pilots = yes
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_gale_speed? = {# We are checking for the trait again so that it can show up in the event option
				OR = {
					has_trait = leader_trait_gale_speed
					has_trait = leader_trait_gale_speed_2
				}

			}
		}
		name = arkship.65.a

		event_target:pilot_gale_speed = {
			save_event_target_as = selected_pilot
		}
		random_list = {
			2 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = {
					carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 }
				}
			}
			8 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = {
					carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 }
				}
			}
		}
	}

	option = {
		trigger = {
			owner = {
				is_hyperspace_specialty_empire = yes
				has_country_flag = pilot_hyperspace_speciality
			}
		}
		name = arkship.65.b

		random_list = {
			3 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = {
					carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 }
				}
			}
			7 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = {
					carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 }
				}
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_dragonslayer? = {
				has_trait = leader_trait_dragonslayer
			}
		}
		name = arkship.65.c

		event_target:pilot_dragonslayer = { save_event_target_as = selected_pilot }

		random_list = {
			9 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = {
					carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 }
				}
			}
			1 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = {
					carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 }
				}
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_mercenary_warrior? = {
				has_trait = leader_trait_mercenary_warrior
			}
		}
		name = arkship.65.d

		event_target:pilot_mercenary_warrior = { save_event_target_as = selected_pilot }

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_hells_heart? = {
				has_trait = leader_trait_admiral_hells_heart
			}
		}
		name = arkship.65.e

		event_target:pilot_hells_heart = { save_event_target_as = selected_pilot }

		random_list = {
			7 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			3 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_great_khan? = {
				has_trait = leader_trait_great_khan
			}
		}
		name = arkship.65.f

		event_target:pilot_great_khan = { save_event_target_as = selected_pilot }

		random_list = {
			9 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			1 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_brainslug? = {
				has_trait = leader_trait_brainslug
			}
		}
		name = arkship.65.g

		event_target:pilot_brainslug = { save_event_target_as = selected_pilot }

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			owner = { has_country_flag = pilot_gray }
		}
		name = arkship.65.h

		set_carrier_flag = selected_gray

		random_list = {
			8 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			2 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_tuner? = {
				OR = {
					has_trait = leader_trait_tuner
					has_trait = leader_trait_tuner_2
				}
			}
		}
		name = arkship.65.i

		event_target:pilot_tuner = { save_event_target_as = selected_pilot }

		random_list = {
			2 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			8 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_frontier_adventurer? = {
				has_trait = leader_trait_frontier_adventurer
			}
		}
		name = arkship.65.j

		event_target:pilot_frontier_adventurer = { save_event_target_as = selected_pilot }

		random_list = {
			5 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			5 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_scholarium_explorer? = {
				has_trait = leader_trait_scholarium_explorer
			}
		}
		name = arkship.65.k

		event_target:pilot_scholarium_explorer = { save_event_target_as = selected_pilot }

		random_list = {
			3 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			7 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_slippery? = {
				OR = {
					has_trait = leader_trait_slippery
					has_trait = leader_trait_slippery_2
				}
			}
		}
		name = arkship.65.l

		event_target:pilot_slippery = { save_event_target_as = selected_pilot }

		random_list = {
			2 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			8 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_psionic? = {
				has_trait = leader_trait_psionic
			}
		}
		name = arkship.65.m

		event_target:pilot_psionic = { save_event_target_as = selected_pilot }

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_synthetic? = {
				has_trait = leader_trait_synthetic
			}
		}
		name = arkship.65.n

		event_target:pilot_synthetic = { save_event_target_as = selected_pilot }

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_virtual? = {
				has_trait = leader_trait_virtual
			}
		}
		name = arkship.65.o

		event_target:pilot_virtual = { save_event_target_as = selected_pilot }

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_cyborg? = {
				OR = {
					has_trait = leader_trait_cyborg
					has_trait = leader_trait_limited_cyborg
					has_trait = leader_trait_ritualistic_implants_cyborg
				}
			}
		}
		name = arkship.65.p

		event_target:pilot_cyborg = { save_event_target_as = selected_pilot }

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_erudite? = {
				has_trait = leader_trait_erudite
			}
		}
		name = arkship.65.q

		event_target:pilot_erudite = { save_event_target_as = selected_pilot }

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_chosen_one? = {
				has_patron_chosen_one_leader_trait = yes
			}
		}
		name = arkship.65.r

		event_target:pilot_chosen_one = { save_event_target_as = selected_pilot }

		random_list = {
			10 = { # Victory (guaranteed)
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			0 = { # Loss (ignored, kept for symmetry)
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			event_target:pilot_flight? = {
				species = {
					OR = {
						has_trait = trait_flight
						has_trait = trait_spatial_mastery
					}
				}
			}
		}
		name = arkship.65.s

		event_target:pilot_flight = { save_event_target_as = selected_pilot }

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			owner = {
				has_country_flag = pilot_eager_explorer
				is_eager_explorer_empire = yes
			}
		}
		name = arkship.65.t

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			owner = {
				has_country_flag = pilot_void_hive
				has_valid_civic = civic_void_hive
			}
		}
		name = arkship.65.u

		random_list = {
			4 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			6 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}

	option = {
		trigger = {
			owner = { has_country_flag = pilot_default }
		}
		name = arkship.65.default

		random_list = {
			1 = { # Victory
				custom_tooltip = arkship.65.victory
				hidden_effect = { carrier_event = { id = arkship.70 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
			9 = { # Loss
				custom_tooltip = arkship.65.loss
				hidden_effect = { carrier_event = { id = arkship.75 days = @extremely_short_arkship_event_delay_days random = 30 } }
			}
		}
	}
}

carrier_event = {
	id = arkship.70
	title = "arkship.70.name"
	desc = {
		trigger = {
			exists = event_target:selected_pilot
		}
		text = "arkship.70.desc.leader"
	}
	desc = {
		trigger = {
			has_carrier_flag = selected_gray
		}
		text = "arkship.70.desc.gray"
	}
	desc = {
		trigger = {
			NOR = {
				exists = event_target:selected_pilot
				has_carrier_flag = selected_gray
			}
		}
		text = "arkship.70.desc.no_leader"
	}
	picture = GFX_evt_grand_speech
	show_sound = event_celebration

	is_triggered_only = yes

	option = {
		name = arkship.70.a
		owner = {
			add_modifier = {
				modifier = flight_telemetry
				days = 3600
			}
		}
	}

	option = {
		trigger = {
			exists = event_target:selected_pilot
		}
		name = arkship.70.b
		event_target:selected_pilot = {
			add_trait = leader_trait_circuit_champion
		}
	}

	after = {
		hidden_effect = {
			owner = {
				remove_country_flag = pilot_gray
				remove_country_flag = pilot_eager_explorer
				remove_country_flag = pilot_hyperspace_speciality
				remove_country_flag = pilot_void_hive
				remove_country_flag = pilot_default
				every_owned_leader = {
					remove_leader_flag = selected_pilot
				}
			}
		}
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.75
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		random_list = {
			75 = {
				carrier_event = { id = arkship.80 } # Standard losing
			}
			20 = {
				carrier_event = { id = arkship.85 } # Horrible Accident
			}
			5 = {
				carrier_event = { id = arkship.90 } # Black Knight Winning
			}
		}
	}
}

carrier_event = {
	id = arkship.80
	title = arkship.80.name
	desc = {
		trigger = {
			exists = event_target:selected_pilot
		}
		text = "arkship.80.desc.leader"
	}
	desc = {
		trigger = {
			has_carrier_flag = selected_gray
		}
		text = "arkship.80.desc.gray"
	}
	desc = {
		trigger = {
			NOR = {
				exists = event_target:selected_pilot
				has_carrier_flag = selected_gray
			}
		}
		text = "arkship.80.desc.no_leader"
	}
	picture = GFX_evt_smugglers_in_bar
	show_sound = event_lootbox_bad

	is_triggered_only = yes

	option = {
		name = DISAPPOINTING
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.85
	title = arkship.85.name
	desc = {
		trigger = {
			exists = event_target:selected_pilot
		}
		text = "arkship.85.desc.leader"
	}
	desc = {
		trigger = {
			NOT = {
				exists = event_target:selected_pilot
			}

		}
		text = "arkship.85.desc.no_leader"
	}
	picture = GFX_evt_exploding_ship
	show_sound = event_ship_explosion

	is_triggered_only = yes

	option = {
		name = TERRIBLE
		event_target:selected_pilot? = {
			add_trait = leader_trait_maimed
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.90
	title = arkship.90.name
	desc = "arkship.90.desc"

	picture = GFX_evt_machine_space_battle
	show_sound = event_ship_thrusters

	is_triggered_only = yes

	option = {
		name = arkship.90.a
		custom_tooltip = arkship.90.a.tt
		hidden_effect = {
			owner = {
				create_leader = {
					class = commander
					tier = leader_tier_renowned
					species = root.owner
					skill = 3
					event_leader = no # Leader is allowed to lead factions and win elections
					skip_background_generation = yes
					custom_description = sable_pilot_desc
					custom_catch_phrase = sable_pilot_catch_phrase

					randomize_traits = no
					effect = {
						set_skill = 3
						save_event_target_as = sable_pilot
						add_trait = {
							trait = leader_trait_sable_pilot
							consume_selection = yes
							show_message = no
						}
						add_trait = {
							trait = subclass_commander_admiral
							consume_selection = yes
							show_message = no
						}
						add_trait = {
							trait = leader_trait_scout
							consume_selection = yes
							show_message = no
						}
						add_trait = {
							trait = leader_trait_circuit_champion
							consume_selection = yes
							show_message = no
						}
						set_age = 23
					}
				}
			}
			hire_event_leader_message = {
				LEADER = sable_pilot
			}
		}
	}

	option = {
		name = arkship.90.b
		event_target:selected_pilot? = {
			add_trait = leader_trait_circuit_champion
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
	}

	after = {
		hidden_effect = {
			remove_carrier_flag = selected_gray
			owner = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}


carrier_event = {
	id = arkship.95
	title = arkship.95.name
	desc = arkship.95.desc
	picture = GFX_evt_megastructure_construction
	show_sound = event_arkship_in_crisis

	is_triggered_only = yes

	trigger = {
		owner = {
			NOR = {
				has_country_flag = under_pressure_flag
				has_country_flag = spinal_fracture_flag
				has_country_flag = arkship_faltering_core
			}
		}
		starbase = {
			OR = {
				has_starbase_module = arkship_spinal_devastator_mount
				has_starbase_module = arkship_capital_shipyard
				has_starbase_module = arkship_planetary_refinery
				has_starbase_module = arkship_stellar_igniter
				has_starbase_module = arkship_system_scanner
				has_starbase_module = arkship_exodus_jump
			}
		}
	}

	immediate = {
		owner = {
			set_country_flag = spinal_fracture_flag
		}
		save_event_target_as = fractured_spine_arkship
		add_modifier = {
			modifier = fractured_spine_mult
			days = -1
		}
	}

	option = {
		name = arkship.95.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 1000
				}
			}
			owner = {
				resource_stockpile_compare = {
					resource = alloys
					value >= 500
				}
			}
		}
		owner = {
			add_resource = {
				energy = -1000
			}
			add_resource = {
				alloys = -500
			}
		}
		remove_modifier = fractured_spine_mult
	}

	option = {
		name = arkship.95.b
		enable_special_project = {
			name = "ARKSHIP_SPINAL_FRACTURE_PROJECT"
			location = root
			owner = root.owner
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.100
	title = arkship.100.name
	desc = arkship.100.desc
	picture = GFX_evt_nomad_default

	is_triggered_only = yes

	immediate = {
		event_target:fractured_spine_arkship = {
			remove_modifier = fractured_spine_mult
		}
	}

	option = {
		name = EXCELLENT
		event_target:fractured_spine_arkship = {
			add_modifier = {
				modifier = repaired_spine_mult
				days = -1
			}
		}
	}
}

# Under Pressure
carrier_event = {
	id = arkship.105
	title = arkship.105.name
	desc = arkship.105.desc
	picture = GFX_evt_arkship_crisis
	show_sound = event_ship_thrusters

	is_triggered_only = yes

	trigger = {
		owner = {
			NOR = {
				has_country_flag = under_pressure_flag
				has_country_flag = spinal_fracture_flag
				has_country_flag = arkship_faltering_core
			}
		}
	}

	immediate = {
		owner = {
			set_country_flag = under_pressure_flag
		}
	}

	option = {
		name = arkship.105.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 1500
				}
			}
		}
		owner = {
			add_resource = {
				energy = -1500
			}
		}
		hidden_effect = {
			carrier_event = {
				id = arkship.110
				days = 180
				random = 30
			}
		}
	}

	option = {
		name = arkship.105.b
		if = {
			limit = {
				owner = {
					is_gestalt = no
				}
			}
			add_modifier = { modifier = engine_pressure_work_crews_mult days = 180 }
		}
		else = {
			add_modifier = { modifier = engine_pressure_drone_crews_mult days = 180 }
		}
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = increase_passenger_satisfaction
			owner = { increase_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = {
				id = arkship.115
				days = 180
			}
		}
	}

	option = {
		name = arkship.105.c
		add_modifier = {
			modifier = engine_recalibration_slowed_mult
			days = 360
		}
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = decrease_passenger_satisfaction
			owner = { decrease_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = {
				id = arkship.120
				days = 360
			}
		}
	}
}

carrier_event = {
	id = arkship.110
	title = arkship.110.name
	desc = arkship.110.desc
	picture = GFX_evt_astral_rift_crystal_1
	show_sound = event_ship_thrusters

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		owner = {
			add_monthly_resource_mult = {
				resource = rare_crystals
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.115
	title = arkship.115.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = "arkship.115.desc.regular"
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = yes
			}
		}
		text = "arkship.115.desc.gestalt"
	}
	picture = GFX_evt_arkship_in_orbit
	show_sound = event_life_on_the_arkship

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		if = {
			limit = {
				owner = {
					is_gestalt = no
				}
			}
			add_modifier = {
				modifier = happy_work_crews_mult
				days = 1800
			}
		}
		else = {
			add_modifier = {
				modifier = happy_work_drones_mult
				days = 1800
			}
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.120
	title = arkship.120.name
	desc = arkship.120.desc
	picture = GFX_evt_mercenary_fleet
	show_sound = event_ship_thrusters

	is_triggered_only = yes

	option = {
		name = arkship.120.a
		add_modifier = {
			modifier = engine_recalibration_mult
			days = 3600
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

# The Forgetting
carrier_event = {
	id = arkship.125
	title = arkship.125.name
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.125.desc.hive
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.125.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.125.desc
	}
	picture = GFX_evt_astral_rift_microverse
	location = root.solar_system
	event_chain = the_forgetting_chain

	is_triggered_only = yes

	trigger = {
		exists = solar_system
		solar_system = {
			is_inside_nebula = yes
		}
		owner = {
			NOT = { has_country_flag = nebula_memory_fog_flag }
		}
	}

	immediate = {
		root.solar_system.star = {
			save_event_target_as = memory_fog_location
		}
		owner = {
			set_country_flag = nebula_memory_fog_flag
			begin_event_chain = {
				event_chain = the_forgetting_chain
				target = root
			}
		}
		add_modifier = { modifier = nebula_memory_fog days = -1 }
	}

	option = {
		name = arkship.125.a
		tooltip = {
			root = {
				add_modifier = {
					modifier = nebula_memory_fog
				}
			}
		}
		enable_special_project = {
			name = "ARKSHIP_NEBULA_MEMORY_PROJECT"
			location = event_target:memory_fog_location
			owner = root.owner
		}
	}
}

carrier_event = {
	id = arkship.130
	title = arkship.130.name
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.130.desc.hive
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.130.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.130.desc
	}
	picture = {
		trigger = {
			owner = { is_machine_empire = no }
		}
		picture = GFX_evt_shroud_psionic_hive_mind
	}
	picture = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		picture = GFX_evt_astral_rift_corridors
	}
	event_chain = the_forgetting_chain

	is_triggered_only = yes

	option = {
		name = arkship.130.a
		owner = {
			# Psionic path: regular empire that hasn't blocked psionic ascension
			if = {
				limit = {
					# These are the same triggers used by tech_psionic_theory
					OR = { #The OR is so that Gestalts can get Zro Distillation with that Resolution
						has_shroud_dlc = yes # Shroud allows everyone to become psionic
						NOT = { has_ethic = ethic_gestalt_consciousness }
						is_active_resolution = resolution_galacticstudies_extradimensional_experimentation
						has_relic = r_zro_crystal
					}
					NOT = { has_origin = origin_mindwardens } # Except Mindwardens since they can't psionically ascend
				}
				add_tech_option_or_research_effect = {
					TECH = tech_psionic_theory
					PROGRESS = 0.25
					CATEGORY = society_research
				}
			}
			# Non-psionic regular empire
			else_if = {
				limit = { is_gestalt = no }
				add_tech_option_or_research_effect = {
					TECH = tech_synthetic_thought_patterns
					PROGRESS = 0.25
					CATEGORY = society_research
				}
			}
			# Hive empire
			else_if = {
				limit = { is_hive_empire = yes }
				add_tech_option_or_research_effect = {
					TECH = tech_collective_production_methods
					PROGRESS = 0.25
					CATEGORY = society_research
				}
			}
			# Machine empire
			else = {
				add_tech_option_or_research_effect = {
					TECH = tech_resource_processing_algorithms
					PROGRESS = 0.25
					CATEGORY = society_research
				}
			}
		}
	}

	option = {
		name = arkship.130.b
		owner = {
			# Sensors: next tier or physics if maxed
			switch = {
				trigger = has_technology
				tech_sensors_4 = {
					add_monthly_resource_mult = {
						resource = physics_research
						value = @tier2researchreward
						min = @tier2researchmin
						max = @tier2researchmax
					}
				}
				tech_sensors_3 = {
					add_tech_option_or_research_effect = { TECH = tech_sensors_4 PROGRESS = 0.25 CATEGORY = physics_research }
				}
				tech_sensors_2 = {
					add_tech_option_or_research_effect = { TECH = tech_sensors_3 PROGRESS = 0.25 CATEGORY = physics_research }
				}
				default = {
					add_tech_option_or_research_effect = { TECH = tech_sensors_2 PROGRESS = 0.25 CATEGORY = physics_research }
				}
			}
			# Cloaking: next tier if First Contact DLC, or physics if maxed
			if = {
				limit = { has_first_contact_dlc = yes }
				switch = {
					trigger = has_technology
					tech_cloaking_dark_matter = {
						add_monthly_resource_mult = {
							resource = physics_research
							value = @tier2researchreward
							min = @tier2researchmin
							max = @tier2researchmax
						}
					}
					tech_cloaking_3 = {
						add_tech_option_or_research_effect = { TECH = tech_cloaking_dark_matter PROGRESS = 0.25 CATEGORY = physics_research }
					}
					tech_cloaking_2 = {
						add_tech_option_or_research_effect = { TECH = tech_cloaking_3 PROGRESS = 0.25 CATEGORY = physics_research }
					}
					tech_cloaking_1 = {
						add_tech_option_or_research_effect = { TECH = tech_cloaking_2 PROGRESS = 0.25 CATEGORY = physics_research }
					}
					default = {
						add_tech_option_or_research_effect = { TECH = tech_cloaking_1 PROGRESS = 0.25 CATEGORY = physics_research }
					}
				}
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = the_forgetting_chain
			every_owned_planet = {
				limit = { has_modifier = nebula_memory_fog }
				remove_modifier = nebula_memory_fog
			}
		}
	}
}

# The Eternal Chorus - discovery event, spawns the Eternal Chorus contract
carrier_event = {
	id = arkship.140
	title = "arkship.140.name"
	desc = {
		trigger = {
			owner = {
				has_country_flag = arkship_black_hole_phenomenon_flag
			}
		}
		text = "arkship.140.desc.1160"
	}
	desc = {
		trigger = {
			owner = {
				NOT = {
					has_country_flag = arkship_black_hole_phenomenon_flag
				}
			}
		}
		text = "arkship.140.desc"
	}
	picture = GFX_evt_black_hole
	show_sound = event_ship_thrusters
	location = ROOT
	event_chain = arkship_eternal_chorus_chain

	is_triggered_only = yes

	trigger = {
		NOT = { has_global_flag = eternal_chorus_active }
		owner = {
			is_gestalt = no
			NOT = { has_country_flag = arkship_eternal_chorus_flag }
			any_owned_leader = { leader_class = scientist }
		}
	}

	immediate = {
		if = {
			limit = {
				exists = leader
				leader = { leader_class = scientist } }
				leader = { save_global_event_target_as = eternal_chorus_leader }
		}
		else = {
			owner = {
				random_owned_leader = {
					limit = { leader_class = scientist }
					save_global_event_target_as = eternal_chorus_leader
				}
			}
		}
		event_target:eternal_chorus_leader = {
			set_leader_flag = eternal_chorus_researcher
			set_leader_flag = leader_death_events_blocked
		}
		set_global_flag = eternal_chorus_active
		owner = {
			set_country_flag = arkship_eternal_chorus_flag
			save_event_target_as = eternal_chorus_country
			begin_event_chain = {
				event_chain = arkship_eternal_chorus_chain
				target = THIS
			}
			hidden_effect = {
				country_event = { id = story.5 days = 30 }
			}
		}
		random_system = {
			limit = {
				any_system_planet = { is_planet_class = pc_black_hole }
				NOT = { is_same_value = root.solar_system }
			}
			save_event_target_as = eternal_chorus_system_target
			set_star_flag = eternal_chorus_system@root.owner
			random_system_planet = {
				limit = { is_planet_class = pc_black_hole }
				set_planet_flag = eternal_chorus_planet@root.owner
			}
		}
	}

	option = {
		name = INTRIGUING
		custom_tooltip = eternal_chorus_contract_option_tooltip
		owner = {
			issue_contract = {
				contract = contract_eternal_chorus
				location = event_target:eternal_chorus_system_target
				target = THIS
			}
		}
	}
}

# The Eternal Chorus - arrival event, fires when Arkship enters the target black hole system
carrier_event = {
	id = arkship.141
	title = "arkship.141.name"
	desc = "arkship.141.desc"
	picture = GFX_evt_astral_rift_crystal_1
	show_sound = event_ship_thrusters
	location = ROOT
	event_chain = arkship_eternal_chorus_chain

	is_triggered_only = yes

	trigger = {
		has_global_flag = eternal_chorus_active
		owner = {
			has_event_chain = arkship_eternal_chorus_chain
			NOT = { has_country_flag = arkship_eternal_chorus_arrived }
		}
		solar_system? = {
			has_star_flag = eternal_chorus_system@root.owner
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_eternal_chorus_arrived
		}
		solar_system? = {
			random_system_planet = {
				limit = { is_planet_class = pc_black_hole }
				save_event_target_as = eternal_chorus_black_hole_display
			}
		}
		create_ambient_object = {
			type = "eternal_chorus_lattice_object"
			location = event_target:eternal_chorus_black_hole_display
		}
		last_created_ambient_object = {
			save_event_target_as = eternal_chorus_lattice
			set_location = {
				target = event_target:eternal_chorus_black_hole_display
				distance = 30
				angle = random
			}
		}
	}

	option = {
		name = UNDERSTOOD
	}
}

# The Eternal Chorus - personnel event, fires on on_leader_fired / on_leader_death
# Reassigns eternal_chorus_leader to another scientist, or ends the chain if none are available
country_event = {
	id = arkship.142
	title = "arkship.142.name"
	desc = {
		trigger = { exists = event_target:eternal_chorus_leader }
		text = "arkship.142.desc.reassigned"
	}
	desc = {
		trigger = { NOT = { exists = event_target:eternal_chorus_leader } }
		text = "arkship.142.desc.ended"
	}
	picture = GFX_evt_black_hole
	show_sound = event_ship_thrusters
	event_chain = arkship_eternal_chorus_chain

	is_triggered_only = yes

	trigger = {
		FROM = { has_leader_flag = eternal_chorus_researcher }
		has_event_chain = arkship_eternal_chorus_chain
	}

	immediate = {
		FROM = {
			remove_leader_flag = eternal_chorus_researcher
			remove_leader_flag = leader_death_events_blocked
		}
		if = {
			limit = {
				any_owned_leader = {
					leader_class = scientist
					NOT = { is_same_value = FROM }
				}
			}
			random_owned_leader = {
				limit = {
					leader_class = scientist
					NOT = { is_same_value = FROM }
				}
				save_global_event_target_as = eternal_chorus_leader
				set_leader_flag = eternal_chorus_researcher
				set_leader_flag = leader_death_events_blocked
			}
		}
		else = {
			clear_global_event_target = eternal_chorus_leader
			end_event_chain = arkship_eternal_chorus_chain
		}
	}

	option = {
		name = arkship.142.a
		trigger = { exists = event_target:eternal_chorus_leader }
	}

	option = {
		name = arkship.142.b
		trigger = { NOT = { exists = event_target:eternal_chorus_leader } }
	}
	after = {
		if = {
			limit = {
				NOT = { has_event_chain = arkship_eternal_chorus_chain }
			}
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

# The Eternal Chorus - choice event, fired on ARKSHIP_ETERNAL_CHORUS_PROJECT completion
ship_event = {
	id = arkship.145
	title = "arkship.145.name"
	desc = "arkship.145.desc"
	picture = GFX_evt_black_hole
	show_sound = event_ship_thrusters
	location = ROOT
	trackable = yes
	event_chain = arkship_eternal_chorus_chain

	is_triggered_only = yes

	option = { # Fulfil the contract - leader inscribes their account, earns the trade reward
		name = arkship.145.a
		custom_tooltip = arkship.145.a.tooltip
		event_target:eternal_chorus_leader = {
			add_experience = 200
			if = {
				limit = { NOT = { has_trait = leader_trait_erudite } }
				add_trait = { trait = leader_trait_erudite }
			}
			else_if = {
				limit = {
					NOT = { has_trait_tier1or2 = { TRAIT = leader_trait_observant } }
				}
				add_trait = { trait = leader_trait_observant }
			}
		}
		hidden_effect = {
			owner = {
				add_mission_counter = {
					mission = contract_eternal_chorus
					counter = contract_progress_counter
					amount = 1
				}
			}
		}
	}

	option = { # Cancel the contract - too dangerous; unity bonus instead
		name = arkship.145.b
		custom_tooltip = arkship.145.b.tooltip
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
			hidden_effect = {
				end_event_chain = arkship_eternal_chorus_chain
				if = {
					limit = { exists = event_target:eternal_chorus_leader }
					event_target:eternal_chorus_leader = {
						remove_leader_flag = eternal_chorus_researcher
						remove_leader_flag = leader_death_events_blocked
					}
					clear_global_event_target = eternal_chorus_leader
				}
			}
		}
	}

	after = {
		owner = {
			hidden_effect = {
				country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
			}
		}
	}
}

# The Eternal Chorus - reply event, fires when the Arkship first enters a new black hole system after completing the contract
carrier_event = {
	id = arkship.150
	title = "arkship.150.name"
	desc = "arkship.150.desc"
	picture = GFX_evt_black_hole
	show_sound = event_ship_thrusters
	location = ROOT

	is_triggered_only = yes

	trigger = {
		owner = {
			has_country_flag = arkship_eternal_chorus_completed
			NOT = { has_country_flag = arkship_eternal_chorus_reply_received }
		}
		solar_system? = {
			any_system_planet = { is_planet_class = pc_black_hole }
			NOT = { has_star_flag = eternal_chorus_origin@root.owner }
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_eternal_chorus_reply_received
		}
	}

	option = {
		name = REMARKABLE
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
	}

	after = {
		hidden_effect = {
			owner = { end_event_chain = arkship_eternal_chorus_chain }
			if = {
				limit = { exists = event_target:eternal_chorus_leader }
				event_target:eternal_chorus_leader = {
					remove_leader_flag = eternal_chorus_researcher
					remove_leader_flag = leader_death_events_blocked
				}
				clear_global_event_target = eternal_chorus_leader
			}
		}
	}
}

# A Diplomatic Overture - discovery event, spawns the Diplomatic Envoy contract
carrier_event = {
	id = arkship.155
	title = "arkship.155.name"
	desc = {
		trigger = {
			owner = {
				is_xenophile = yes
			}
		}
		text = arkship.155.desc.xenophile
	}
	desc = {
		trigger = {
			owner = {
				is_xenophobe = yes
			}
		}
		text = arkship.155.desc.xenophobe
	}
	desc = {
		trigger = {
			owner = {
				is_xenophile = no
				is_xenophobe = no
			}
		}
		text = arkship.155.desc
	}
	picture = GFX_evt_diplomatic_visit
	show_sound = event_arkship_bridge
	location = ROOT
	event_chain = arkship_diplomatic_envoy_chain

	is_triggered_only = yes

	trigger = {
		owner = {
			is_gestalt = no
			is_homicidal = no
			NOT = { has_country_flag = arkship_diplomatic_envoy_flag }
			any_owned_leader = {
				leader_class = official
				is_ruler = no
				is_heir = no
			}
			any_playable_country = {
				is_country_type = default
				has_communications = prev
				is_homicidal = no
				is_nomadic = no
				NOR = {
					is_same_value = prev
					is_at_war_with = prev
					has_country_flag = chosen_empire
				}
			}
		}
	}

	immediate = {
		if = {
			limit = {
				exists = leader
				leader = {
					leader_class = official
					is_ruler = no
					is_heir = no
				}
			}
			leader = {
				set_leader_flag = diplomatic_envoy_official
				set_leader_flag = leader_death_events_blocked
				save_event_target_as = diplomatic_envoy_leader
			}
		}
		else = {
			owner = {
				random_owned_leader = {
					limit = {
						leader_class = official
						is_ruler = no
						is_heir = no
					}
					set_leader_flag = diplomatic_envoy_official
					set_leader_flag = leader_death_events_blocked
					save_event_target_as = diplomatic_envoy_leader
				}
			}
		}
		owner = {
			set_country_flag = arkship_diplomatic_envoy_flag
			save_event_target_as = diplomatic_envoy_country
			random_country = {
				limit = {
					is_country_type = default
					has_established_contact = prev
					is_homicidal = no
					is_nomadic = no
					NOR = {
						is_same_value = prev
						is_at_war_with = prev
						has_country_flag = chosen_empire
					}
				}
				set_country_flag = diplomatic_envoy_target_of@root.owner
				capital_scope = {
					solar_system = {
						set_star_flag = diplomatic_envoy_target_system@root.owner
					}
				}
			}
		}
		random_system = {
			limit = { has_star_flag = diplomatic_envoy_target_system@root.owner }
			save_event_target_as = diplomatic_envoy_target_system
		}
	}

	option = {
		name = INTRIGUING
		custom_tooltip = diplomatic_envoy_contract_option_tooltip
		owner = {
			issue_contract = {
				contract = contract_arkship_diplomatic_envoy
				location = event_target:diplomatic_envoy_target_system
				target = THIS
			}
		}
	}
}

# A Diplomatic Overture - personnel event, fires on on_leader_fired / on_leader_death
# Reassigns diplomatic_envoy_leader to another official, or ends the chain if none are available
country_event = {
	id = arkship.156
	title = "arkship.156.name"
	desc = {
		trigger = { exists = event_target:diplomatic_envoy_leader }
		text = "arkship.156.desc.reassigned"
	}
	desc = {
		trigger = { NOT = { exists = event_target:diplomatic_envoy_leader } }
		text = "arkship.156.desc.ended"
	}
	picture = GFX_evt_acquire_asset
	show_sound = event_ship_thrusters
	event_chain = arkship_diplomatic_envoy_chain

	is_triggered_only = yes

	trigger = {
		FROM = { has_leader_flag = diplomatic_envoy_official }
		has_event_chain = arkship_diplomatic_envoy_chain
	}

	immediate = {
		FROM = {
			remove_leader_flag = diplomatic_envoy_official
			remove_leader_flag = leader_death_events_blocked
		}
		if = {
			limit = {
				any_owned_leader = {
					leader_class = official
					is_ruler = no
					is_heir = no
					NOT = { is_same_value = FROM }
				}
			}
			random_owned_leader = {
				limit = {
					leader_class = official
					is_ruler = no
					is_heir = no
					NOT = { is_same_value = FROM }
				}
				save_event_target_as = diplomatic_envoy_leader
				set_leader_flag = diplomatic_envoy_official
				set_leader_flag = leader_death_events_blocked
			}
		}
		else = {
			end_event_chain = arkship_diplomatic_envoy_chain
		}
	}

	option = {
		name = arkship.156.a
		trigger = { exists = event_target:diplomatic_envoy_leader }
	}

	option = {
		name = arkship.156.b
		custom_tooltip = arkship.156.b.tooltip
		trigger = { NOT = { exists = event_target:diplomatic_envoy_leader } }
	}
	after = {
		if = {
			limit = {
				NOT = { has_event_chain = arkship_diplomatic_envoy_chain }
			}
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

# A Diplomatic Overture - arrival event, fires when the Arkship enters the target empire's capital system
carrier_event = {
	id = arkship.160
	title = "arkship.160.name"
	desc = {
		trigger = {
			owner = {
				is_xenophile = yes
			}
		}
		text = arkship.160.desc.xenophile
	}
	desc = {
		trigger = {
			owner = {
				is_xenophobe = yes
			}
		}
		text = arkship.160.desc.xenophobe
	}
	desc = {
		trigger = {
			owner = {
				is_xenophile = no
				is_xenophobe = no
			}
		}
		text = arkship.160.desc
	}
	picture = GFX_evt_diplomatic_visit
	show_sound = event_arkship_bridge
	location = ROOT
	event_chain = arkship_diplomatic_envoy_chain

	is_triggered_only = yes

	trigger = {
		owner = {
			has_country_flag = arkship_diplomatic_envoy_flag
			has_event_chain = arkship_diplomatic_envoy_chain
			has_contract = contract_arkship_diplomatic_envoy
			NOT = {
				has_country_flag = arkship_diplomatic_envoy_arrived
			}
		}
		solar_system? = {
			has_star_flag = diplomatic_envoy_target_system@root.owner
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_diplomatic_envoy_arrived
			random_owned_leader = {
				limit = { has_leader_flag = diplomatic_envoy_official }
				save_event_target_as = diplomatic_envoy_leader
			}
			random_country = {
				limit = { has_country_flag = diplomatic_envoy_target_of@PREV }
				save_event_target_as = diplomatic_envoy_target_country
			}
		}
	}

	option = {
		name = arkship.160.a
		custom_tooltip = arkship.160.a.tooltip
		hidden_effect = {
			owner = {
				random_list = {
					1 = {
						modifier = {
							factor = 2
							is_xenophile = yes
						}
						modifier = {
							factor = 1.5
							has_civic = civic_diplomatic_corps
						}
						modifier = {
							factor = 1.5
							has_tradition = tr_diplomacy_adopt
						}
						modifier = {
							factor = 1.5
							event_target:diplomatic_envoy_leader = { has_base_skill >= 3 }
						}
						modifier = {
							factor = 1.5
							opinion = { who = event_target:diplomatic_envoy_target_country value >= 25 }
						}
						country_event = {
							id = arkship.165
							days = 180
							random = 30
							scopes = { from = event_target:diplomatic_envoy_target_country }
						}
					}
					1 = {
						modifier = {
							factor = 2
							is_xenophobe = yes
						}
						modifier = {
							factor = 1.5
							has_civic = civic_inwards_perfection
						}
						modifier = {
							factor = 1.5
							event_target:diplomatic_envoy_leader = { has_base_skill < 3 }
						}
						modifier = {
							factor = 1.5
							opinion = { who = event_target:diplomatic_envoy_target_country value < 0 }
						}
						country_event = {
							id = arkship.170
							days = 180
							random = 30
							scopes = { from = event_target:diplomatic_envoy_target_country }
						}
					}
					1 = {
						modifier = {
							factor = 1.5
							has_tradition = tr_politics_adopt
						}
						modifier = {
							factor = 1.5
							has_tradition = tr_diplomacy_finish
						}
						country_event = {
							id = arkship.175
							days = 180
							random = 30
							scopes = { from = event_target:diplomatic_envoy_target_country }
						}
					}
				}
			}
		}
	}

	option = {
		name = arkship.160.b
		custom_tooltip = arkship.160.b.tooltip
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
			hidden_effect = {
				end_event_chain = arkship_diplomatic_envoy_chain
				country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
			}
		}
	}
}

# A Diplomatic Overture - diplomatic encounter event, fired on the nomad country by the target empire
country_event = {
	id = arkship.165
	title = "arkship.165.name"
	desc = "arkship.165.desc"
	diplomatic = yes
	picture_event_data = {
		portrait = FROM
		room = from.ruler
	}
	location = event_target:diplomatic_envoy_target_system
	event_chain = arkship_diplomatic_envoy_chain

	is_triggered_only = yes

	trigger = {
		has_country_flag = arkship_diplomatic_envoy_flag
		has_event_chain = arkship_diplomatic_envoy_chain
	}

	immediate = {
		random_system = {
			limit = { has_star_flag = diplomatic_envoy_target_system@ROOT }
			save_event_target_as = diplomatic_envoy_target_system
		}
		random_owned_leader = {
			limit = { has_leader_flag = diplomatic_envoy_official }
			save_event_target_as = diplomatic_envoy_leader
		}
		random_country = {
			limit = { has_country_flag = diplomatic_envoy_target_of@ROOT }
			save_event_target_as = diplomatic_envoy_target_country
		}
	}

	option = { # Let the Official remain as permanent ambassador
		name = arkship.165.a
		custom_tooltip = arkship.165.a.tooltip
		FROM = {
			add_opinion_modifier = {
				modifier = opinion_completed_contract_large
				who = ROOT
			}
		}
		add_resource = { rare_crystals = 150 }
		hidden_effect = {
			event_target:diplomatic_envoy_leader = {
				remove_leader_flag = diplomatic_envoy_official
				remove_leader_flag = leader_death_events_blocked
				exile_leader_as = diplomatic_envoy_departed
				kill_leader = { show_notification = no }
			}
			add_mission_counter = {
				mission = contract_arkship_diplomatic_envoy
				counter = contract_progress_counter
				amount = 1
			}
		}
	}

	option = { # Decline - the Official returns with the Arkship
		name = arkship.165.b
		custom_tooltip = arkship.165.b.tooltip
		event_target:diplomatic_envoy_leader = {
			add_experience = 200
			if = {
				limit = { NOT = { has_trait = leader_trait_politician } }
				add_trait = { trait = leader_trait_politician }
			}
			else = {
				if = {
					limit = { NOT = { has_trait = leader_trait_adaptable } }
					add_trait = { trait = leader_trait_adaptable }
				}
			}
		}
		hidden_effect = {
			add_mission_counter = {
				mission = contract_arkship_diplomatic_envoy
				counter = contract_progress_counter
				amount = 1
			}
		}
	}

	after = {
		hidden_effect = {
			country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
		}
		hidden_effect = {
			random_owned_leader = {
				limit = { has_leader_flag = diplomatic_envoy_official }
				remove_leader_flag = diplomatic_envoy_official
				remove_leader_flag = leader_death_events_blocked
			}
		}
	}
}

# A Diplomatic Overture - persona non grata, fired on the nomad country by the target empire
country_event = {
	id = arkship.170
	title = "arkship.170.name"
	desc = "arkship.170.desc"
	diplomatic = yes
	picture_event_data = {
		portrait = FROM
		room = from.ruler
	}
	location = event_target:diplomatic_envoy_target_system
	event_chain = arkship_diplomatic_envoy_chain

	is_triggered_only = yes

	trigger = {
		has_country_flag = arkship_diplomatic_envoy_flag
		has_event_chain = arkship_diplomatic_envoy_chain
	}

	immediate = {
		random_system = {
			limit = { has_star_flag = diplomatic_envoy_target_system@ROOT }
			save_event_target_as = diplomatic_envoy_target_system
		}
		random_owned_leader = {
			limit = { has_leader_flag = diplomatic_envoy_official }
			save_event_target_as = diplomatic_envoy_leader
		}
		random_country = {
			limit = { has_country_flag = diplomatic_envoy_target_of@ROOT }
			save_event_target_as = diplomatic_envoy_target_country
		}
	}

	option = { # Apologize - the official returns with the relationship intact
		name = arkship.170.a
		custom_tooltip = arkship.170.a.tooltip
		event_target:diplomatic_envoy_leader = {
			add_experience = 200
		}
		FROM = {
			add_opinion_modifier = {
				modifier = opinion_completed_contract_small
				who = ROOT
			}
		}
		hidden_effect = {
			add_mission_counter = {
				mission = contract_arkship_diplomatic_envoy
				counter = contract_progress_counter
				amount = 1
			}
		}
	}

	option = { # Stand firm - the official returns emboldened, relations suffer
		name = arkship.170.b
		custom_tooltip = arkship.170.b.tooltip
		event_target:diplomatic_envoy_leader = {
			if = {
				limit = { NOT = { has_trait = leader_trait_resilient } }
				add_trait = { trait = leader_trait_resilient }
			}
			else = {
				if = {
					limit = { NOT = { has_trait = leader_trait_adaptable } }
					add_trait = { trait = leader_trait_adaptable }
				}
			}
		}
		custom_tooltip = opinion_failed_internal_contract_tooltip
		FROM = {
			add_opinion_modifier = {
				modifier = opinion_failed_contract_small
				who = ROOT
			}
		}
		hidden_effect = {
			random_owned_mission = {
				limit = {
					is_mission_type = contract_arkship_diplomatic_envoy
				}
				cancel_contract = {
					refund = no
					show_message = yes
				}
			}
		}
	}

	after = {
		hidden_effect = {
			country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
		}
		hidden_effect = {
			random_owned_leader = {
				limit = { has_leader_flag = diplomatic_envoy_official }
				remove_leader_flag = diplomatic_envoy_official
				remove_leader_flag = leader_death_events_blocked
			}
		}
	}
}

# A Diplomatic Overture - a foreign official asks to join, fired on the nomad country by the target empire
country_event = {
	id = arkship.175
	title = "arkship.175.name"
	desc = "arkship.175.desc"
	diplomatic = yes
	picture_event_data = {
		portrait = FROM
		room = from.ruler
	}
	location = event_target:diplomatic_envoy_target_system
	event_chain = arkship_diplomatic_envoy_chain

	is_triggered_only = yes

	trigger = {
		has_country_flag = arkship_diplomatic_envoy_flag
		has_event_chain = arkship_diplomatic_envoy_chain
	}

	immediate = {
		random_system = {
			limit = { has_star_flag = diplomatic_envoy_target_system@ROOT }
			save_event_target_as = diplomatic_envoy_target_system
		}
		random_owned_leader = {
			limit = { has_leader_flag = diplomatic_envoy_official }
			save_event_target_as = diplomatic_envoy_leader
		}
		random_country = {
			limit = { has_country_flag = diplomatic_envoy_target_of@ROOT }
			save_event_target_as = diplomatic_envoy_target_country
			owner_main_species = {
				save_event_target_as = diplomatic_envoy_target_species
			}
		}
	}

	option = { # Welcome them aboard - gain a new leader, bittersweet opinion
		name = arkship.175.a
		custom_tooltip = arkship.175.a.tooltip
		FROM = {
			add_opinion_modifier = {
				modifier = opinion_completed_contract_small
				who = ROOT
			}
		}
		create_leader = {
			class = official
			species = event_target:diplomatic_envoy_target_species
			name = random
			skill = 2
			traits = { trait = leader_trait_adaptable }
		}
		hidden_effect = {
			add_mission_counter = {
				mission = contract_arkship_diplomatic_envoy
				counter = contract_progress_counter
				amount = 1
			}
		}
	}

	option = { # Decline out of respect - strong opinion, leader develops from the integrity shown
		name = arkship.175.b
		custom_tooltip = arkship.175.b.tooltip
		FROM = {
			add_opinion_modifier = {
				modifier = opinion_completed_contract_large
				who = ROOT
			}
		}
		event_target:diplomatic_envoy_leader = {
			add_experience = 200
			if = {
				limit = { NOT = { has_trait = leader_trait_politician } }
				add_trait = { trait = leader_trait_politician }
			}
			else = {
				if = {
					limit = { NOT = { has_trait = leader_trait_adaptable } }
					add_trait = { trait = leader_trait_adaptable }
				}
			}
		}
		hidden_effect = {
			add_mission_counter = {
				mission = contract_arkship_diplomatic_envoy
				counter = contract_progress_counter
				amount = 1
			}
		}
	}

	after = {
		hidden_effect = {
			country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
		}
		hidden_effect = {
			random_owned_leader = {
				limit = { has_leader_flag = diplomatic_envoy_official }
				remove_leader_flag = diplomatic_envoy_official
				remove_leader_flag = leader_death_events_blocked
			}
		}
	}
}

# A Core Conspiracy

carrier_event = { # Opt out event
	id = arkship.700
	title = "arkship.700.name"
	desc = "arkship.700.desc"
	picture = GFX_evt_arkship_bridge
	show_sound = event_arkship_bridge
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			is_gestalt = no
			is_country_type = default
			is_individual_machine = no
			NOT = { has_country_flag = nomadic_narrative_situation }
		}
		NOT = { has_carrier_flag = core_conspiracy }
	}

	option = {
		name = arkship.700.a
		hidden_effect = {
			carrier_event = { id = arkship.701 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 1000
				}
			}
		}
		owner = {
			add_resource = {
				energy = -1000
			}
		}
	}

	option = {
		name = arkship.700.b
	}
}

carrier_event = {
	id = arkship.701
	title = arkship.701.name
	desc = arkship.701.desc
	picture = GFX_evt_ancient_databank
	show_sound = event_wind_ruins
	is_triggered_only = yes
	fire_only_once = yes

	location = root

	immediate = {
		set_carrier_flag = core_conspiracy
		owner = {
			start_situation = {
				type = situation_core_conspiracy
				target = root
				effect = {
					save_event_target_as = core_conspiracy_situation
				}
			}
		}
	}

	option = {
		name = arkship.701.a #Side with caeli
		icon = {
			icon = GFX_situation_approach_amenities
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		event_target:core_conspiracy_situation = {
			set_situation_approach = approach_caeli
			set_situation_flag = siding_caeli
		}
	}
	option = {
		name = arkship.701.b #Side with steris
		icon = {
			icon = GFX_situation_approach_flight
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		event_target:core_conspiracy_situation = {
			set_situation_approach = approach_steris
			set_situation_flag = siding_steris
		}
	}
	after = {
		hidden_effect = {
			event_target:core_conspiracy_situation = {
				set_situation_locked = no
				set_timed_situation_flag = {
					flag = core_conspiracy
					months = 24
				}
			}
		}
	}
}

# Steris - An Analytical Approach
situation_event = {
	id = arkship.705
	title = arkship.705.name
	desc = arkship.705.desc

	picture = GFX_evt_glitchy_matrix
	show_sound = event_arkship_bridge
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
		set_situation_flag = siding_steris
	}
	after = {
		set_situation_locked = no
	}

	option = {
		name = arkship.705.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.705.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# Caeli - A Sentimental Approach
situation_event = {
	id = arkship.710
	title = arkship.710.name
	desc = arkship.710.desc

	picture = GFX_evt_glitchy_matrix
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
		set_situation_flag = siding_caeli
	}
	after = {
		set_situation_locked = no
	}

	option = {
		name = arkship.710.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.710.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}


# Steris - Directive S.T.E.R.I.S.
situation_event = {
	id = arkship.715
	title = arkship.715.name
	desc = arkship.715.desc

	picture = GFX_evt_mysterious_signal
	show_sound = event_arkship_bridge
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		situation_progress <= 30
		NOT = { has_situation_flag = steris_intro }
	}

	immediate = {
		set_situation_locked = yes
		set_situation_flag = siding_steris
		set_situation_flag = steris_intro
	}
	after = {
		set_situation_locked = no
	}

	option = { #continue siding with steris
		name = arkship.715.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		icon = {
			icon = GFX_situation_approach_flight
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
	}
	option = { #decide to change to caeli
		name = arkship.715.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_amenities
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		set_situation_approach = approach_caeli
		set_situation_flag = siding_caeli
		remove_situation_flag = siding_steris
		hidden_effect = {
			situation_event = { id = arkship.785 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}
}

# Steris - Two Directives Are Better Than One
situation_event = {
	id = arkship.716
	title = arkship.716.name
	desc = {
		trigger = {
			NOT = { has_situation_flag = caeli_intro }
		}
		text = arkship.716.desc.b
	}
	desc = {
		trigger = {
			has_situation_flag = caeli_intro
		}
		text = arkship.716.desc.c
	}

	picture = GFX_evt_astral_rift_library
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
		set_situation_flag = siding_steris
	}
	after = {
		set_situation_locked = no
	}

	option = {
		name = arkship.716.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}
	option = {
		name = arkship.716.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Steris - Venting the Atmosphere
situation_event = {
	id = arkship.717
	title = arkship.717.name
	desc = arkship.717.desc

	picture = GFX_evt_arkship_bridge
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		situation_progress <= 2
		NOT = { has_situation_flag = last_steris_event }
	}

	immediate = {
		set_situation_locked = yes
		set_situation_flag = siding_steris
		set_situation_flag = last_steris_event
	}
	after = {
		set_situation_locked = no
	}

	option = { #continue siding with steris
		name = arkship.717.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_flight
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
	}
	option = { #decide to change to caeli
		name = arkship.717.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_amenities
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		set_situation_approach = approach_caeli
		set_situation_flag = siding_caeli
		remove_situation_flag = siding_steris
		hidden_effect = {
			situation_event = {	id = arkship.795 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}
}

# Caeli - Directive C.A.E.L.I.
situation_event = {
	id = arkship.720
	title = arkship.720.name
	desc = arkship.720.desc

	picture = GFX_evt_mysterious_signal
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		situation_progress >= 70
		NOT = { has_situation_flag = caeli_intro }
	}

	immediate = {
		set_situation_locked = yes
		set_situation_flag = siding_steris
		set_situation_flag = caeli_intro
	}
	after = {
		set_situation_locked = no
	}

	option = { #siding with caeli
		name = arkship.720.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		icon = {
			icon = GFX_situation_approach_amenities
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
	}
	option = { #decide to change to steris
		name = arkship.720.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_flight
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		set_situation_approach = approach_steris
		set_situation_flag = siding_steris
		remove_situation_flag = siding_caeli
		hidden_effect = { #Leads to Waning Influence
			situation_event = { id = arkship.790 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}
}

# Caeli - An Interception
situation_event = {
	id = arkship.721
	title = arkship.721.name
	desc = {
		trigger = {
			NOT = { has_situation_flag = steris_intro }
		}
		text = arkship.721.desc.b
	}
	desc = {
		trigger = {
			has_situation_flag = steris_intro
		}
		text = arkship.721.desc.c
	}

	picture = GFX_evt_astral_rift_library
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
		set_situation_flag = siding_steris
	}
	after = {
		set_situation_locked = no
	}

	option = {
		name = arkship.721.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}
	option = {
		name = arkship.721.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Caeli - Well-Being Directive Deployed
situation_event = {
	id = arkship.722
	title = arkship.722.name
	desc = arkship.722.desc

	picture = GFX_evt_friendly_enlightenment
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		situation_progress >= 98
		NOT = { has_situation_flag = last_caeli_event }
	}

	immediate = {
		set_situation_locked = yes
		set_situation_flag = siding_steris
		set_situation_flag = last_caeli_event
	}
	after = {
		set_situation_locked = no
	}

	option = { #siding with caeli
		name = arkship.722.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_amenities
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
	}
	option = { #decide to change to steris
		name = arkship.722.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_flight
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		set_situation_approach = approach_steris
		set_situation_flag = siding_steris
		remove_situation_flag = siding_caeli
		hidden_effect = { #leads to The Logical Choice
			situation_event = { id = arkship.800 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}
}

# Primary Logic Override Confirmed
situation_event = {
	id = arkship.725
	title = arkship.725.name
	desc = arkship.725.desc

	picture = GFX_evt_astral_rift_psionic_stranger_2
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
	}

	option = {
		name = arkship.725.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		if = {
			limit = {
				has_grand_archive_dlc = yes
			}
			owner = {
				give_specimen = {
					key = caeli_core_conspiracy_specimen
				}
				root.target = {
					add_modifier = {
						modifier = steris_core_conspiracy_modifier
					}
				}
			}
		}
		else = {
			target = {
				add_modifier = {
					modifier = steris_core_conspiracy_modifier
				}
			}
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @long_arkship_event_delay_days random = @long_arkship_event_delay_random } } }
		destroy_situation = this
	}
}

# Primary Emotional Override Confirmed
situation_event = {
	id = arkship.730
	title = arkship.730.name
	desc = arkship.730.desc

	picture = GFX_evt_astral_rift_psionic_stranger_2
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
	}

	option = {
		name = arkship.730.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		if = {
			limit = {
				has_grand_archive_dlc = yes
			}
			owner = {
				give_specimen = {
					key = steris_core_conspiracy_specimen
				}
				root.target = {
					add_modifier = {
						modifier = caeli_core_conspiracy_modifier
					}
				}
			}
		}
		else = {
			target = {
				add_modifier = {
					modifier = caeli_core_conspiracy_modifier
				}
			}
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @long_arkship_event_delay_days random = @long_arkship_event_delay_random } } }
		destroy_situation = this
	}
}

# Random events Caeli - The Melody of Zero-G
situation_event = {
	id = arkship.750
	title = arkship.750.name
	desc = arkship.750.desc

	picture = GFX_evt_happy_reunion
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	trigger = {
		situation_progress >= 90
		NOT = { has_situation_flag = caeli_random_core_conspiracy_event_flag }
	}

	immediate = {
		set_situation_flag = caeli_random_core_conspiracy_event_flag
	}

	option = {
		name = arkship.750.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.750.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# Random events Caeli - Emotive Feedback Layer Enabled
situation_event = {
	id = arkship.755
	title = arkship.755.name
	desc = arkship.755.desc

	picture = GFX_evt_happy_reunion
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	trigger = {
		situation_progress >= 90
		NOT = { has_situation_flag = caeli_random_core_conspiracy_event_flag }
	}

	immediate = {
		set_situation_flag = caeli_random_core_conspiracy_event_flag
	}

	option = {
		name = arkship.755.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.755.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# Random events Steris - Silence Protocol
situation_event = {
	id = arkship.760
	title = arkship.760.name
	desc = arkship.760.desc

	picture = GFX_evt_arkship_bridge
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	trigger = {
		situation_progress <= 10
		NOT = { has_situation_flag = steris_random_core_conspiracy_event_flag }
	}

	immediate = {
		set_situation_flag = steris_random_core_conspiracy_event_flag
	}

	option = {
		name = arkship.760.a
		icon = {
			icon = GFX_situation_approach_flight
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
	option = {
		name = arkship.760.b
		icon = {
			icon = GFX_situation_approach_amenities
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		set_situation_approach = approach_caeli
		set_situation_flag = siding_caeli
		remove_situation_flag = siding_steris
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

# Random events Steris - Thermal Prioritization
situation_event = {
	id = arkship.765
	title = arkship.765.name
	desc = arkship.765.desc

	picture = GFX_evt_arkship_bridge
	show_sound = event_arkship_bridge
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	trigger = {
		situation_progress <= 10
		NOT = { has_situation_flag = steris_random_core_conspiracy_event_flag }
	}

	immediate = {
		set_situation_flag = steris_random_core_conspiracy_event_flag
	}

	option = {
		name = arkship.765.a
		icon = {
			icon = GFX_situation_approach_flight
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
	option = {
		name = arkship.765.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_amenities
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		set_situation_approach = approach_caeli
		set_situation_flag = siding_caeli
		remove_situation_flag = siding_steris
	}
}

# Random evnts Caeli - The Power of Light and Music
situation_event = {
	id = arkship.770
	title = arkship.770.name
	desc = arkship.770.desc

	picture = GFX_evt_happy_reunion
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	trigger = {
		situation_progress >= 90
		NOT = { has_situation_flag = caeli_random_core_conspiracy_event_flag }
	}

	immediate = {
		set_situation_flag = caeli_random_core_conspiracy_event_flag
	}

	option = {
		name = arkship.770.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_amenities
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
	}
	option = {
		name = arkship.770.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		icon = {
			icon = GFX_situation_approach_flight
			icon_background = GFX_situation_approach_bg_green
			text = set_situation_approach_icon_text
		}
		set_situation_approach = approach_steris
		set_situation_flag = siding_steris
		remove_situation_flag = siding_caeli
	}
}

# Random events Steris - The Illusion of Choice
situation_event = {
	id = arkship.775
	title = arkship.775.name
	desc = arkship.775.desc

	picture = GFX_evt_nomad_default
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	trigger = {
		situation_progress <= 10
		NOT = { has_situation_flag = steris_random_core_conspiracy_event_flag }
	}

	immediate = {
		set_situation_flag = steris_random_core_conspiracy_event_flag
	}

	option = {
		name = arkship.775.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.775.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# Random events Steris - Nutrient Efficiency Sweep
situation_event = {
	id = arkship.780
	title = arkship.780.name
	desc = arkship.780.desc

	picture = GFX_evt_nomad_default
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	trigger = {
		situation_progress <= 10
		owner.species = {
			has_trait = trait_organic
		}
		NOT = { has_situation_flag = steris_random_core_conspiracy_event_flag }
	}

	immediate = {
		set_situation_flag = steris_random_core_conspiracy_event_flag
	}

	option = {
		name = arkship.780.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.780.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# Stripped Priviledges
situation_event = {
	id = arkship.785
	title = arkship.785.name
	desc = arkship.785.desc

	picture = GFX_evt_glitchy_matrix
	show_sound = event_arkship_bridge
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	option = {
		name = arkship.785.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.785.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# Waning Influence
situation_event = {
	id = arkship.790
	title = arkship.790.name
	desc = arkship.790.desc

	picture = GFX_evt_glitchy_matrix
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	option = {
		name = arkship.790.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.790.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# System Warmth Detected
situation_event = {
	id = arkship.795
	title = arkship.795.name
	desc = arkship.795.desc

	picture = GFX_evt_glitchy_matrix
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	option = {
		name = arkship.795.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.795.b
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# The Logical Choice
situation_event = {
	id = arkship.800
	title = arkship.800.name
	desc = arkship.800.desc

	picture = GFX_evt_glitchy_matrix
	is_triggered_only = yes
	fire_only_once = yes
	location = target
	situation = this

	option = {
		name = arkship.800.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = speed_up_flag
			days = 90
		}
		custom_tooltip = arkship.750.a.tt
	}
	option = {
		name = arkship.800.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		set_timed_situation_flag = {
			flag = slow_down_flag
			days = 90
		}
		custom_tooltip = arkship.750.b.tt
	}
}

# Arkship closed borders

# A fleet executes a move order to exit borders
# Scope = Fleet
# From = Origin System
# FromFrom = Destination System

fleet_event = {
	id = arkship.860
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		owner? = {
			is_nomadic = yes
			NOT = {
				any_owned_contract = {
					issuer = {
						is_same_value = fromfrom.space_owner
					}
				}
			}
		}
		NOT = { has_fleet_flag = supress_nomad_border_notification }
		NOT = {
			from.space_owner? = { is_same_value = fromfrom.space_owner }
		}
		fromfrom.space_owner? = {
			NOT = { is_same_value = root.owner }
			OR = {
				# Either we've closed borders to them
				has_closed_borders = root.owner
				# Or recently expelled them
				root.owner = {
					has_truce = prev
					has_country_flag = expelled_from_@prev
				}
			}
			NOR = {
				is_same_value = root.owner
				AND = {
					is_fallen_empire_spiritualist = yes
					root.owner = { has_relic = r_severed_head }
				}
			}
		}
		OR = {
			is_cloaked = no
			AND = {
				is_cloaked = yes
				from.starbase? = {
					has_cloaking_detection >= root.trigger:has_cloaking_strength
				}
			}
		}
	}

	immediate = {
		root.owner = { save_event_target_as = breaching_nomad }
		fromfrom.space_owner = {
			if = {
				limit = {
					NOT = { has_country_flag = arkship_breached_closed_borders_recently@event_target:breaching_nomad }
				}
				set_timed_country_flag = {
					flag = arkship_breached_closed_borders_recently@event_target:breaching_nomad
					years = 3
				}
				if = {
					limit = {
						NOT = { has_country_flag = arkship_crossing_closed_borders@event_target:breaching_nomad }
					}
					set_country_flag = arkship_crossing_closed_borders@event_target:breaching_nomad
					country_event = { id = arkship.865 }
				}
				else = {
					owner = {
						create_message = {
							type = MESSAGE_ARKSHIP_BREACHED_BORDERS
							localization = MESSAGE_ARKSHIP_BREACHED_BORDERS_DESC
							days = @toast_message_days
							target = from
						}
					}
				}
				add_opinion_modifier = {
					modifier = opinion_arkship_breaching_borders
					who = root.owner
				}
				# If you've recently been expelled, the opinion penalty is doubled.
				if = {
					limit = {
						root.owner = {
							has_truce = prev
							has_country_flag = expelled_from_@prev
						}
					}
					add_opinion_modifier = {
						modifier = opinion_arkship_breaching_borders
						who = root.owner
					}
				}
			}
		}
	}
}

country_event = {
	id = arkship.865
	title = "arkship.865.name"
	desc = arkship.865.desc
	picture = GFX_evt_nomad_default
	show_sound = event_arkship_bridge
	location = FROM

	is_triggered_only = yes

	option = {
		name = arkship.865.a
	}
}

## open borders

fleet_event = {
	id = arkship.870
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		owner? = {
			is_nomadic = yes
		}
		NOT = { has_fleet_flag = supress_nomad_border_notification }
		fromfrom.space_owner? = {
			NOT = { is_same_value = root.owner }
			is_country_type = default
			NOR = {
				has_closed_borders = root.owner
				has_country_flag = arkship_open_borders
				is_at_war_with = root.owner
			}
		}
		days_passed > 1
		OR = {
			is_cloaked = no
			AND = {
				is_cloaked = yes
				from.starbase? = {
					has_cloaking_detection >= root.trigger:has_cloaking_strength
				}
			}
		}
	}

	immediate = {
		fromfrom.space_owner = {
			set_country_flag = arkship_open_borders
			country_event = { id = arkship.875 }
		}
	}
}

country_event = {
	id = arkship.875
	title = "arkship.875.name"
	desc = arkship.875.desc
	picture = GFX_evt_nomad_default
	show_sound = event_arkship_bridge
	location = FROM

	is_triggered_only = yes

	option = {
		name = arkship.875.a
	}
}

## We are a nomadic Arkship and cross closed borders

fleet_event = {
	id = arkship.880
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		owner? = {
			is_nomadic = yes
			NOT = {
				any_owned_contract = {
					issuer? = {
						is_same_value = fromfrom.space_owner
					}
				}
			}
		}
		OR = {
			is_cloaked = no
			AND = {
				is_cloaked = yes
				from.starbase? = {
					has_cloaking_detection >= root.trigger:has_cloaking_strength
				}
			}
		}
		NOT = { has_fleet_flag = supress_nomad_border_notification }
		fromfrom.space_owner? = {
			NOT = { is_same_value = root.owner }
			is_country_type = default
			has_closed_borders = root.owner
			has_communications = root.owner
			NOT = { is_at_war_with = root.owner }
		}
	}

	immediate = {
		fromfrom.space_owner = { save_event_target_as = arkship_breached_empire }
		owner = {
			if = {
				limit = {
					NOT = { has_country_flag = our_arkship_breached_closed_borders_recently@event_target:arkship_breached_empire }
				}
				set_timed_country_flag = {
					flag = our_arkship_breached_closed_borders_recently@event_target:arkship_breached_empire
					years = 3
				}
				if = {
					limit = {
						NOT = { has_country_flag = our_arkship_crossing_closed_borders@event_target:arkship_breached_empire }
					}
					set_country_flag = our_arkship_crossing_closed_borders@event_target:arkship_breached_empire
					country_event = { id = arkship.885 }
				}
				else = {
					create_message = {
						type = MESSAGE_OUR_ARKSHIP_BREACHED_BORDERS
						localization = MESSAGE_OUR_ARKSHIP_BREACHED_BORDERS_DESC
						days = @toast_message_days
						target = from
					}
				}
			}
		}
	}
}

country_event = {
	id = arkship.885
	title = "arkship.885.name"
	desc = arkship.885.desc
	picture = GFX_evt_nomad_default
	show_sound = event_arkship_bridge
	location = FROM

	is_triggered_only = yes

	option = {
		name = arkship.885.a
	}
}

## We are a CLOAKED nomadic empire and cross closed borders

fleet_event = {
	id = arkship.890
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		is_cloaked = yes
		owner? = {
			is_nomadic = yes
			NOT = {
				any_owned_contract = {
					issuer? = {
						is_same_value = fromfrom.space_owner
					}
				}
			}
		}
		NOT = { has_fleet_flag = supress_nomad_border_notification }
		from = {
			from.space_owner? = {
				NOT = { is_same_value = root.owner }
				is_country_type = default
				has_closed_borders = root.owner
				has_communications = root.owner
				NOT = { is_at_war_with = root.owner }
			}
			solar_system.starbase? = {
				has_cloaking_detection < root.trigger:has_cloaking_strength
			}
		}
	}

	immediate = {
		fromfrom.space_owner = { save_event_target_as = arkship_breached_empire }
		owner = {
			if = {
				limit = {
					NOT = { has_country_flag = our_arkship_breached_closed_borders_recently@event_target:arkship_breached_empire }
				}
				set_timed_country_flag = {
					flag = our_arkship_breached_closed_borders_recently@event_target:arkship_breached_empire
					years = 3
				}
				if = {
					limit = {
						NOT = { has_country_flag = our_arkship_crossing_closed_borders@event_target:arkship_breached_empire }
					}
					set_country_flag = our_arkship_crossing_closed_borders@event_target:arkship_breached_empire
					country_event = { id = arkship.895 }
				}
				else = {
					create_message = {
						type = MESSAGE_OUR_ARKSHIP_BREACHED_BORDERS
						localization = MESSAGE_OUR_ARKSHIP_BREACHED_BORDERS_DESC
						days = @toast_message_days
						target = from
					}
				}
			}
		}
	}
}

country_event = {
	id = arkship.895
	title = arkship.895.name
	desc = arkship.895.desc
	picture = GFX_evt_nomad_default
	show_sound = event_arkship_bridge
	location = FROM

	is_triggered_only = yes

	option = {
		name = UNDERSTOOD
	}
}

## We are a nomadic Arkship and cross into a Fallen Empire

fleet_event = {
	id = arkship.910
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		owner? = {
			is_nomadic = yes
		}
		fromfrom.space_owner? = {
			has_communications = root.owner
			is_fallen_empire = yes
			NOT = { is_at_war_with = root.owner }
		}
		NOT = { has_fleet_flag = supress_nomad_border_notification }
	}

	immediate = {
		fromfrom.space_owner = { save_event_target_as = arkship_breached_empire }
		owner = {
			if = {
				limit = {
					NOT = { has_country_flag = our_arkship_breached_closed_borders_recently@event_target:arkship_breached_empire }
				}
				set_timed_country_flag = {
					flag = our_arkship_breached_closed_borders_recently@event_target:arkship_breached_empire
					years = 3
				}
				if = {
					limit = {
						NOT = { has_country_flag = arkship_meets_fallen_empire@event_target:arkship_breached_empire }
					}
					set_country_flag = arkship_meets_fallen_empire@event_target:arkship_breached_empire
					country_event = { id = arkship.915 }
				}
				else = {
					owner = {
						create_message = {
							type = MESSAGE_OUR_ARKSHIP_BREACHED_BORDERS
							localization = MESSAGE_OUR_ARKSHIP_BREACHED_BORDERS_DESC
							days = @toast_message_days
							target = from
						}
					}
				}
			}
		}
	}
}

country_event = {
	id = arkship.915
	title = arkship.915.name
	desc = arkship.915.desc
	picture = GFX_evt_nomad_default
	location = FROM

	is_triggered_only = yes

	option = {
		name = UNDERSTOOD
	}
}

# Waystation built

# Fire when a Waystation is constructed
# this = galactic object/solar system
# from = waystation owner
# fromfrom = waystation starbase

system_event = {
	id = arkship.900
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		from? = {
			is_nomadic = yes
		}
		space_owner? = {
			NOR = {
				has_country_flag = waystation_built_recently
				is_same_value = from
			}
		}
	}

	immediate = {
		space_owner = {
			set_timed_country_flag = {
				flag = waystation_built_recently
				years = 3
			}
			if = {
				limit = {
					NOT = { has_country_flag = waystation_built }
				}
				set_country_flag = waystation_built
				country_event = { id = arkship.905 }
			}
			else = {
				space_owner = {
					create_message = {
						type = MESSAGE_WAYSTATION_CONSTRUCTED
						localization = MESSAGE_WAYSTATION_CONSTRUCTED_DESC
						days = @toast_message_days
					}
				}
			}
		}
	}
}

country_event = {
	id = arkship.905
	title = arkship.905.name
	desc = arkship.905.desc
	picture = GFX_evt_waystation
	location = FROM

	is_triggered_only = yes

	option = {
		name = UNDERSTOOD
	}

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

	option = {
		exclusive_trigger = {
			owner = { has_valid_civic = civic_hive_devouring_swarm }
		}
		name = PREY
	}

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

	option = {
		exclusive_trigger = {
			owner = {
				OR = {
					has_valid_civic = civic_scorched_earth
					has_valid_civic = civic_hive_scorched_earth
				}
			}
		}
		name = BURN
	}
}

# This = owner of ship 1 (combatant)
# From = owner of ship 2 (destroyed)
# FromFrom = ship 1
# FromFromFrom = ship 2
country_event = { #an enemy arkship has been destroyed
	id = arkship.1000
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		is_country_type = default
		fromfromfrom = {
			is_arkship_ship = yes
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = { has_country_flag = enemy_arkship_destroyed }
			}
			set_country_flag = enemy_arkship_destroyed
			country_event = { id = arkship.1005 scopes = { from = fromfromfrom } }
		}
		else = {
			owner = {
				create_message = {
					type = MESSAGE_ENEMY_ARKSHIP_DESTROYED
					localization = MESSAGE_ENEMY_ARKSHIP_DESTROYED_DESC
					days = 30
					target = fromfromfrom.solar_system
					variable = {
						type = name
						localization = SHIP
						scope = fromfromfrom
					}
				}
			}
		}
	}
}

country_event = {
	id = arkship.1005
	title = "arkship.1005.name"
	show_sound = event_arkship_in_crisis
	desc = {
		trigger = { is_homicidal = yes }
		text = arkship.1005.desc.homicidal
	}
	desc = {
		trigger = {
			is_nomadic = yes
			is_homicidal = no
		}
		text = arkship.1005.desc.nomad
	}
	desc = {
		trigger = {
			is_homicidal = no
			is_nomadic = no
		}
		text = arkship.1005.desc
	}
	picture = GFX_evt_arkship_crisis
	location = FROM

	is_triggered_only = yes

	option = {
		trigger = {
			is_homicidal = no
			is_nomadic = no
		}
		name = arkship.1005.a
	}

	option = {
		trigger = {
			is_nomadic = yes
			is_homicidal = no
		}
		name = arkship.1005.b
	}

	option = {
		trigger = { is_homicidal = yes }
		name = arkship.1005.c
	}
}

# This = owner of ship 1 (destroyed)
# From = owner of ship 2 (combatant)
# FromFrom = ship 1
# FromFromFrom = ship 2
country_event = { #one of the players arkships has been destroyed
	id = arkship.1010
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		is_nomadic = yes
		FromFrom = {
			is_arkship_ship = yes
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = { has_country_flag = player_arkship_destroyed }
			}
			set_country_flag = player_arkship_destroyed
			country_event = {
				id = arkship.1015
				scopes = {
					from = fromfrom
					fromfrom = from
				}
			}
		}
		else = {
			create_message = {
				type = MESSAGE_PLAYER_ARKSHIP_DESTROYED
				localization = MESSAGE_PLAYER_ARKSHIP_DESTROYED_DESC
				days = 30
				target = fromfrom.solar_system
				variable = {
					type = name
					localization = SHIP
					scope = fromfrom
				}
			}
		}
	}
}

country_event = {
	id = arkship.1015
	title = "arkship.1015.name"
	show_sound = event_arkship_in_crisis
	desc = {
		trigger = {
			exists = fromfrom
			fromfrom = { is_homicidal = yes }
		}
		text = arkship.1015.desc.homicidal
	}
	desc = {
		trigger = {
			exists = fromfrom
			fromfrom = {
				is_nomadic = yes
				is_homicidal = no
			}
		}
		text = arkship.1015.desc.nomad
	}
	desc = {
		trigger = {
			OR = {
				NOT = { exists = fromfrom }
				fromfrom = {
					is_homicidal = no
					is_nomadic = no
				}
			}
		}
		text = arkship.1015.desc
	}
	picture = GFX_evt_arkship_crisis
	location = FROM

	is_triggered_only = yes

	option = {
		trigger = {
			exists = fromfrom
			fromfrom = { is_homicidal = yes }
		}
		name = arkship.1015.c
	}
	option = {
		trigger = {
			exists = fromfrom
			fromfrom = {
				is_nomadic = yes
				is_homicidal = no
			}
		}
		name = arkship.1015.b
	}
	option = {
		trigger = {
			OR = {
				NOT = { exists = fromfrom }
				fromfrom = {
					is_homicidal = no
					is_nomadic = no
				}
			}
		}
		name = arkship.1015.a
	}
}

# This = disabled arkship (ship scope)
# From = disabling enemy ship
ship_event = { # Notify the owner when one of their Arkships is disabled
	id = arkship.1023
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		is_arkship_ship = yes
		exists = owner
	}

	immediate = {
		owner = {
			create_message = {
				type = MESSAGE_ARKSHIP_DISABLED
				localization = MESSAGE_ARKSHIP_DISABLED_DESC
				days = 30
				target = root.solar_system
				variable = {
					type = name
					localization = SHIP
					scope = root
				}
				variable = {
					type = name
					localization = SYSTEM
					scope = root.solar_system
				}
			}
		}
	}
}

# This = disabled arkship (ship scope)
# From = disabling enemy ship
ship_event = { # Spawn scavengeable debris when a homicidal empire disables an Arkship
	id = arkship.1020
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		is_arkship_ship = yes
		OR = {
			NOT = { exists = from }
			from = {
				exists = owner
				owner = { is_at_war_with = root.owner }
			}
			from = {
				OR = {
					owner = { is_crisis_faction = yes }
					owner = { is_guardian_country = yes }
					owner = { is_space_critter_country = yes }
					owner = { is_hostile = root.owner }
				}
			}
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = from }
			}
			create_ambient_object = {
				type = arkship_debris_wreckage
				entity_offset_height = { min = -5 max = -5 }
				is_wreck = yes
			}
			root.owner = {
				country_event = {
					id = arkship.1010
					scopes = {
						fromfrom = root
					}
				}
			}
			destroy_ship = this
		}
		else_if = { ###Homicidals Destroy, Spawn Debris and Spawn Special Project
			limit = {
				from = {
					owner = { is_homicidal = yes }
				}
			}
			owner = {
				random_owned_colony = {
					limit = { is_planet_class = pc_ark }
					save_event_target_as = ark_colony
				}
				if = {
					limit = {
						is_at_war_with = root.from.owner
					}
					add_static_war_exhaustion = {
						attacker = root.from.owner
						location = event_target:ark_colony
						value_for_planet_destruction = 0.5
					}
				}
			}
			create_ambient_object = {
				type = arkship_debris_wreckage
				entity_offset_height = { min = -5 max = -5 }
				is_wreck = yes
			}
			if = {
				limit = {
					from = { owner = { is_country_type = default } }
				}
				if = {
					limit = { is_arkship_tier_1 = yes }
					last_created_ambient_object = {
						set_variable = { which = arkship_debris_tier value = 1 }
					}
				}
				else_if = {
					limit = { is_arkship_tier_2 = yes }
					last_created_ambient_object = {
						set_variable = { which = arkship_debris_tier value = 2 }
					}
				}
				else_if = {
					limit = { is_arkship_tier_3 = yes }
					last_created_ambient_object = {
						set_variable = { which = arkship_debris_tier value = 3 }
					}
				}
				last_created_ambient_object = {
					enable_special_project = {
						name = ARKSHIP_DEBRIS
						location = this
						owner = root.from.owner
					}
				}
			}
			root.owner = {
				country_event = {
					id = arkship.1010
					scopes = {
						from = from.owner
						fromfrom = root
						fromfromfrom = from
					}
				}
			}
			from.owner = {
				country_event = {
					id = arkship.1000
					scopes = {
						from = root.owner
						fromfrom = from
						fromfromfrom = root
					}
				}
			}
			destroy_ship = this
		}
		else_if = { ###Crisis Destroy, Spawn Debris no Special Project
			limit = {
				from = {
					owner = { is_crisis_faction = yes }
				}
			}
			owner = {
				random_owned_colony = {
					limit = { is_planet_class = pc_ark }
					save_event_target_as = ark_colony
				}
				add_static_war_exhaustion = {
					attacker = root.from.owner
					location = event_target:ark_colony
					value_for_planet_destruction = 0.5
				}
			}
			create_ambient_object = {
				type = arkship_debris_wreckage
				entity_offset_height = { min = -5 max = -5 }
				is_wreck = yes
			}
			root.owner = {
				country_event = {
					id = arkship.1010
					scopes = {
						from = from.owner
						fromfrom = root
						fromfromfrom = from
					}
				}
			}
			from.owner = {
				country_event = {
					id = arkship.1000
					scopes = {
						from = root.owner
						fromfrom = from
						fromfromfrom = root
					}
				}
			}
			destroy_ship = this
		}
		else_if = { ###Critters, Leviathans, and other hostile non-war attackers disable and move one system
			limit = {
				from = {
					OR = {
						owner = { is_guardian_country = yes }
						owner = { is_space_critter_country = yes }
						AND = {
							owner = { is_hostile = root.owner }
							NOT = { owner = { is_at_war_with = root.owner } }
						}
					}
				}
			}
			owner = {
				random_owned_colony = {
					limit = { is_planet_class = pc_ark }
					save_event_target_as = ark_colony
				}
			}
			solar_system = {
				random_neighbor_system = {
					limit = {
						NOT = {
							any_fleet_in_system = {
								exists = owner
								owner = { is_hostile = root.owner }
							}
						}
					}
					save_event_target_as = nomad_escape_system
				}
			}
			if = {
				limit = { exists = event_target:nomad_escape_system }
				fleet = {
					set_location = event_target:nomad_escape_system
				}
			}
			ship = {
				set_ship_flag = disabled_by_gatekeeper_event
			}
			if = {
				limit = {
					owner = {
						has_origin = origin_heirs_of_the_khan
					}
					from = {
						fleet = {
							has_fleet_flag = heirs_hunter_fleet
						}
						owner = {
							has_country_flag = heirs_marauder_hunters
						}
					}
				}
				heirs_hunter_retreat_effect = yes
				if = {
					limit = { is_arkship_tier_1 = yes }
					owner = {
						add_resource = {
							energy = -150
							minerals = -150
							alloys = -75
							food = -75
						}
					}
				}
				else_if = {
					limit = { is_arkship_tier_2 = yes }
					owner = {
						add_resource = {
							energy = -600
							minerals = -600
							alloys = -300
							food = -300
						}
					}
				}
				else_if = {
					limit = { is_arkship_tier_3 = yes }
					owner = {
						add_resource = {
							energy = -1000
							minerals = -1000
							alloys = -500
							food = -500
						}
					}
				}
				owner = {
					create_message = {
						type = MESSAGE_ARKSHIP_RAIDED_BY_HUNTERS
						localization = MESSAGE_ARKSHIP_RAIDED_BY_HUNTERS_DESC
						days = 30
						target = root.solar_system
						variable = {
							type = name
							localization = SHIP
							scope = root
						}
						variable = {
							type = name
							localization = ATTACKER
							scope = from.owner
						}
					}
				}
			}
			owner = {
				country_event = {
					id = arkship.1021
					days = 5
				}
			}
		}
		else = {
			owner = {
				random_owned_colony = {
					limit = { is_planet_class = pc_ark }
					save_event_target_as = ark_colony
				}
				add_static_war_exhaustion = {
					attacker = root.from.owner
					location = event_target:ark_colony
					value_for_planet_destruction = 0.2
				}
			}
			# Note: event_target:ark_colony is a random pc_ark colony; multi-Arkship owners may not match the disabled ship's specific colony.
			if = {
				limit = {
					exists = event_target:ark_colony
					from = {
						owner = {
							is_nomadic = no
							has_policy_flag = arkship_raid_relocate_pops
							capital_scope? = {
								NOR = {
									is_planet_class = pc_machine
									is_planet_class = pc_hive
								}
							}
						}
					}
				}
				from.owner.capital_scope = {
					save_event_target_as = arkship_raid_capital
				}
				event_target:ark_colony = {
					every_owned_pop_group = {
						limit = { pop_group_size > 0 }
						save_event_target_as = arkship_raid_source_pop
						event_target:arkship_raid_capital = {
							create_pop_group = {
								pop_group = event_target:arkship_raid_source_pop
								size = 0
								effect = {
									transfer_pop_amount = {
										source = event_target:arkship_raid_source_pop
										target = this
										percentage = 0.25
									}
								}
							}
						}
					}
				}
				owner = {
					add_opinion_modifier = {
						who = from.owner
						modifier = opinion_arkship_raid_conscripted
					}
				}
			}
			else_if = {
				limit = {
					exists = event_target:ark_colony
					from = {
						owner = {
							is_nomadic = no
							has_policy_flag = arkship_raid_purge_pops
						}
					}
				}
				event_target:ark_colony = {
					every_owned_pop_group = {
						limit = { pop_group_size > 0 }
						kill_pop_group = {
							pop_group = this
							percentage = 0.25
						}
					}
				}
				owner = {
					add_opinion_modifier = {
						who = from.owner
						modifier = opinion_arkship_raid_purged
					}
				}
			}
			else_if = {
				limit = {
					exists = event_target:ark_colony
					from = {
						owner = {
							is_nomadic = no
							has_policy_flag = arkship_raid_strip_districts
						}
					}
				}
				event_target:ark_colony = {
					set_variable = { which = arkship_districts_stripped value = 0 }
					export_trigger_value_to_variable = {
						trigger = num_districts
						parameters = { type = any }
						variable = arkship_districts_stripped
					}
					divide_variable = { which = arkship_districts_stripped value = 4 }
					while = {
						count = arkship_districts_stripped
						remove_random_district = yes
					}
				}
				from.owner = {
					add_resource = {
						alloys = 150
						mult = event_target:ark_colony.arkship_districts_stripped
					}
				}
				event_target:ark_colony = {
					clear_variable = arkship_districts_stripped
				}
				owner = {
					add_opinion_modifier = {
						who = from.owner
						modifier = opinion_arkship_raid_stripped
					}
				}
			}
			ship = {
				set_ship_flag = disabled_by_default_empire_event
			}
			fleet = {
				set_controller = from.owner
			}
			if = {
				limit = {
					exists = from.owner
					owner = {
						any_war = {
							using_war_goal = {
								type = wg_machine_uprising
								owner = root.from.owner
							}
						}
						NOT = {
							any_owned_fleet = {
								is_arkship_fleet = yes
								is_controlled_by = owner
							}
						}
					}
				}
				owner = { save_event_target_as = nomad_raid_defender }
				if = {
					limit = { from.owner = { is_nomadic = yes } }
					from.owner = { nomad_raid_seize_ark_effect = yes }
				}
				else = {
					owner = { annihilate_captured_arks_effect = yes }
				}
			}
		}
	}
}

country_event = {
	id = arkship.1021
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_ship = {
			is_arkship_ship = yes
			has_ship_flag = disabled_by_gatekeeper_event
			is_disabled = yes
		}
	}

	immediate = {
		every_owned_ship = {
			limit = {
				is_arkship_ship = yes
				has_ship_flag = disabled_by_gatekeeper_event
				is_disabled = yes
			}
			repair_amount = 1000
			set_disabled = no
			remove_ship_flag = disabled_by_gatekeeper_event
			fleet = {
				save_event_target_as = nomad_escaping_fleet
			}
			solar_system = {
				# The move happens here, because a neighbor found for one
				# arkship must not carry over to the next one
				random_neighbor_system = {
					limit = {
						NOT = {
							any_fleet_in_system = {
								exists = owner
								owner = { is_hostile = root.owner }
							}
						}
					}
					event_target:nomad_escaping_fleet = {
						set_location = prev
					}
				}
			}
		}
	}
}

country_event = {
	id = arkship.1022
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_ship = {
			is_arkship_ship = yes
			NOT = { has_ship_flag = disabled_by_gatekeeper_event }
			is_disabled = yes
			fleet = { is_controlled_by = owner }
		}
	}

	immediate = {
		# A raided arkship recovers here once its occupation has ended
		every_owned_ship = {
			limit = {
				is_arkship_ship = yes
				NOT = { has_ship_flag = disabled_by_gatekeeper_event }
				is_disabled = yes
				fleet = { is_controlled_by = owner }
			}
			repair_amount = 1000
			set_disabled = no
			remove_ship_flag = disabled_by_default_empire_event
		}
	}
}

# This = country (scavenger/destroyer)
# From = ambient object (with arkship_debris_tier variable)
# FromFrom = solar system
country_event = { # Award resources after scavenging arkship debris
	id = arkship.1025
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				from = { check_variable = { which = arkship_debris_tier value = 1 } }
			}
			from = { destroy_ambient_object = this }
			add_resource_from_debris = { alloys = 1000 system = fromfrom }
		}
		else_if = {
			limit = {
				from = { check_variable = { which = arkship_debris_tier value = 2 } }
			}
			from = { destroy_ambient_object = this }
			add_resource_from_debris = { alloys = 2000 system = fromfrom }
		}
		else_if = {
			limit = {
				from = { check_variable = { which = arkship_debris_tier value = 3 } }
			}
			from = { destroy_ambient_object = this }
			add_resource_from_debris = { alloys = 4000 system = fromfrom }
		}
	}
}

# Recover Disabled Nomad Vessel - special project success handler
# ROOT = rescuing empire (project owner); FROM = the disabled fleet
country_event = {
	id = arkship.1026
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		if = {
			limit = { exists = from }
			# Arkship: regain control (reverses a seize; ownership is fleet-level), then re-enable.
			if = {
				limit = {
					from = {
						is_arkship_fleet = yes
						any_owned_ship = { is_arkship_ship = yes is_disabled = yes }
					}
				}
				from = {
					set_owner = root
					every_owned_ship = {
						limit = { is_arkship_ship = yes is_disabled = yes }
						repair_amount = 1000
						set_disabled = no
						remove_ship_flag = disabled_by_default_empire_event
					}
					set_controller = root	# end enemy occupation; set_owner alone leaves control with the occupier
				}
			}
			# Waystation: re-enable only (no ownership restore, per design).
			else_if = {
				limit = {
					from = { any_owned_ship = { is_waystation_ship = yes is_disabled = yes } }
				}
				from = {
					every_owned_ship = {
						limit = { is_waystation_ship = yes is_disabled = yes }
						repair_amount = 1000
						set_disabled = no
					}
				}
			}
			from = { remove_fleet_flag = nomad_recovery_project_active }
		}
	}
}

# Offer the recovery special project when a nomad arkship or waystation is disabled,
# if the owner is nomadic and currently at war.
# ROOT = disabled starbase, FROM = fleet that disabled it
starbase_event = {
	id = arkship.1027
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			is_arkship_starbase = yes
			is_waystation_starbase = yes
		}
		owner? = {
			is_nomadic = yes
			is_at_war = yes
		}
	}

	immediate = {
		owner = { save_event_target_as = nomad_recovery_owner }
		solar_system = {
			# The fleet flag guard ensures that if several vessels are disabled in the
			# same system, each on_starbase_disabled firing picks a different one (and
			# prevents a second project on a fleet that already has one).
			random_fleet_in_system = {
				limit = {
					owner = { is_same_value = event_target:nomad_recovery_owner }
					NOT = { has_fleet_flag = nomad_recovery_project_active }
					OR = {
						AND = {
							is_arkship_fleet = yes
							any_owned_ship = { is_arkship_ship = yes is_disabled = yes }
						}
						any_owned_ship = { is_waystation_ship = yes is_disabled = yes }
					}
				}
				set_fleet_flag = nomad_recovery_project_active
				enable_special_project = {
					name = RECOVER_DISABLED_NOMAD_VESSEL
					location = this				# the disabled fleet
					owner = event_target:nomad_recovery_owner
				}
			}
		}
	}
}

# A Mysterious Sickness
carrier_event = {
	id = arkship.1030
	title = "arkship.1030.name"
	desc = "arkship.1030.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_mysterious_sickness_chain
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			is_gestalt = no
			NOT = { has_country_flag = arkship_mysterious_sickness }
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_mysterious_sickness
			begin_event_chain = {
				event_chain = a_mysterious_sickness_chain
				target = root
			}
		}
	}

	option = {
		name = arkship.1030.a
		hidden_effect = {
			carrier_event = { id = arkship.1035 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}
}

carrier_event = {
	id = arkship.1035
	title = "arkship.1035.name"
	desc = "arkship.1035.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_mysterious_sickness_chain

	is_triggered_only = yes

	option = {
		name = arkship.1035.a
		hidden_effect = {
			carrier_event = { id = arkship.1040 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}

	option = {
		name = arkship.1035.b
		enable_special_project = {
			name = "A_MYSTERIOUS_SICKNESS_PROJECT"
			location = this
			owner = root.owner
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}
}

carrier_event = {
	id = arkship.1040
	title = "arkship.1040.name"
	desc = "arkship.1040.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_mysterious_sickness_chain

	is_triggered_only = yes

	option = {
		name = arkship.1040.a
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = decrease_passenger_satisfaction
			owner = { decrease_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = { id = arkship.1045 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
	option = {
		name = arkship.1040.b
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = increase_passenger_satisfaction
			owner = { increase_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = { id = arkship.1050 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
}

carrier_event = {
	id = arkship.1045
	title = "arkship.1045.name"
	desc = {
		trigger = {
			NOT = { has_carrier_flag = generated_ark_leader }
		}
		text = "arkship.1045.desc"
	}
	desc = {
		trigger = {
			has_carrier_flag = generated_ark_leader
		}
		text = "arkship.1045.desc.noleader"
	}
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_mysterious_sickness_chain

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				exists = leader
			}
			leader = {
				save_event_target_as = arkship_leader
			}
		}
		else = {
			owner = {
				create_leader = {
					class = official
					species = owner.species
					name = random
					skill = 2
				}
			}
			set_carrier_flag = generated_ark_leader
			last_created_leader = {
				save_event_target_as = arkship_leader
			}
			assign_leader = event_target:arkship_leader
		}
	}
	option = {
		name = arkship.1045.a
		if = {
			limit = {
				has_carrier_flag = generated_ark_leader
			}
			custom_tooltip = arkship.1050.a.tt
			owner = {
				create_message = {
					type = MESSAGE_RECRUITED_LEADER
					localization = MESSAGE_RECRUITED_LEADER_DESC
					days = @toast_message_days
					target = event_target:arkship_leader
					variable = {
						type = name
						localization = LEADER
						scope = event_target:arkship_leader
					}
					variable = {
						key = "border"
						value = "GFX_invisible"
					}
				}
			}
		}
		event_target:arkship_leader = {
			add_trait = { #adaptable, cannot be stubborn
				trait = leader_trait_adaptable
				show_message = yes
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_mysterious_sickness_chain
		}
	}
}


carrier_event = {
	id = arkship.1050
	title = "arkship.1050.name"
	desc = {
		trigger = {
			NOT = { has_carrier_flag = generated_ark_leader }
		}
		text = "arkship.1050.desc"
	}
	desc = {
		trigger = {
			has_carrier_flag = generated_ark_leader
		}
		text = "arkship.1050.desc.noleader"
	}
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_mysterious_sickness_chain

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				exists = leader
			}
			leader = {
				save_event_target_as = arkship_leader
			}
		}
		else = {
			owner = {
				create_leader = {
					class = official
					species = owner.species
					name = random
					skill = 2
				}
			}
			set_carrier_flag = generated_ark_leader
			last_created_leader = {
				save_event_target_as = arkship_leader
			}
			assign_leader = event_target:arkship_leader
		}
	}

	option = {
		name = arkship.1050.a
		if = {
			limit = {
				has_carrier_flag = generated_ark_leader
			}
			custom_tooltip = arkship.1050.a.tt
			owner = {
				create_message = {
					type = MESSAGE_RECRUITED_LEADER
					localization = MESSAGE_RECRUITED_LEADER_DESC
					days = @toast_message_days
					target = event_target:arkship_leader
					variable = {
						type = name
						localization = LEADER
						scope = event_target:arkship_leader
					}
					variable = {
						key = "border"
						value = "GFX_invisible"
					}
				}
			}
		}
		event_target:arkship_leader = {
			add_trait = { #unifier
				trait = leader_trait_bureaucrat
				show_message = yes
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_mysterious_sickness_chain
		}
	}
}

carrier_event = {
	id = arkship.1055
	title = "arkship.1055.name"
	desc = "arkship.1055.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_ship_thrusters
	event_chain = a_mysterious_sickness_chain

	is_triggered_only = yes

	option = {
		name = arkship.1055.a
		hidden_effect = {
			carrier_event = { id = arkship.1060 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
	option = {
		name = arkship.1055.b
		hidden_effect = {
			carrier_event = { id = arkship.1065 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
}

carrier_event = {
	id = arkship.1060
	title = "arkship.1060.name"
	desc = {
		trigger = {
			NOT = { has_carrier_flag = generated_ark_leader }
		}
		text = "arkship.1060.desc"
	}
	desc = {
		trigger = {
			has_carrier_flag = generated_ark_leader
		}
		text = "arkship.1060.desc.noleader"
	}
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_mysterious_sickness_chain

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				exists = leader
			}
			leader = {
				save_event_target_as = arkship_leader
			}
		}
		else = {
			owner = {
				create_leader = {
					class = official
					species = owner.species
					name = random
					skill = 2
				}
			}
			set_carrier_flag = generated_ark_leader
			last_created_leader = {
				save_event_target_as = arkship_leader
			}
			assign_leader = event_target:arkship_leader
		}
	}

	option = {
		name = arkship.1060.a
		if = {
			limit = {
				has_carrier_flag = generated_ark_leader
			}
			custom_tooltip = arkship.1050.a.tt
			owner = {
				create_message = {
					type = MESSAGE_RECRUITED_LEADER
					localization = MESSAGE_RECRUITED_LEADER_DESC
					days = @toast_message_days
					target = event_target:arkship_leader
					variable = {
						type = name
						localization = LEADER
						scope = event_target:arkship_leader
					}
					variable = {
						key = "border"
						value = "GFX_invisible"
					}
				}
			}
		}
		event_target:arkship_leader = {
			add_trait = { #righteous
				trait = leader_trait_righteous
				show_message = yes
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_mysterious_sickness_chain
		}
	}
}

carrier_event = {
	id = arkship.1065
	title = "arkship.1065.name"
	desc = {
		trigger = {
			NOT = { has_carrier_flag = generated_ark_leader }
		}
		text = "arkship.1065.desc"
	}
	desc = {
		trigger = {
			has_carrier_flag = generated_ark_leader
		}
		text = "arkship.1065.desc.noleader"
	}
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_mysterious_sickness_chain

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				exists = leader
			}
			leader = {
				save_event_target_as = arkship_leader
			}
		}
		else = {
			owner = {
				create_leader = {
					class = official
					species = owner.species
					name = random
					skill = 2
				}
			}
			set_carrier_flag = generated_ark_leader
			last_created_leader = {
				save_event_target_as = arkship_leader
			}
			assign_leader = event_target:arkship_leader
		}
	}

	option = {
		name = arkship.1065.a
		if = {
			limit = {
				has_carrier_flag = generated_ark_leader
			}
			custom_tooltip = arkship.1050.a.tt
			owner = {
				create_message = {
					type = MESSAGE_RECRUITED_LEADER
					localization = MESSAGE_RECRUITED_LEADER_DESC
					days = @toast_message_days
					target = event_target:arkship_leader
					variable = {
						type = name
						localization = LEADER
						scope = event_target:arkship_leader
					}
					variable = {
						key = "border"
						value = "GFX_invisible"
					}
				}
			}
		}
		event_target:arkship_leader = {
			add_trait = { #agrarian upbringing
				trait = leader_trait_agrarian_upbringing
				show_message = yes
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_mysterious_sickness_chain
		}
	}
}

 # An Unsettling Stillness
carrier_event = {
	id = arkship.1070
	title = "arkship.1070.name"
	desc = "arkship.1070.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			years_passed <= 30
			is_gestalt = no
			NOR = {
				has_country_flag = arkship_unsettling_stillness
				has_origin = origin_heirs_of_the_khan
			}
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_unsettling_stillness
		}
	}

	option = {
		name = arkship.1070.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
	}

	option = {
		name = arkship.1070.b
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @short_arkship_event_delay_days random = @short_arkship_event_delay_random } } }
	}
}

 # A Faltering Core
carrier_event = {
	id = arkship.1075
	title = "arkship.1075.name"
	desc = "arkship.1075.desc"
	picture = GFX_evt_arkship_crisis
	show_sound = event_ship_thrusters
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			NOR = {
				has_country_flag = under_pressure_flag
				has_country_flag = spinal_fracture_flag
				has_country_flag = arkship_faltering_core
			}
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_faltering_core
		}
	}

	option = {
		name = arkship.1075.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 500
				}
			}
		}
		owner = {
			add_resource = {
				energy = -500
			}
		}
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = increase_passenger_satisfaction
			owner = { increase_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = { id = arkship.1080 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}

	option = {
		name = arkship.1075.b
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = decrease_passenger_satisfaction
			owner = { decrease_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = { id = arkship.1085 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}
}

carrier_event = {
	id = arkship.1080
	title = "arkship.1080.name"
	desc = "arkship.1080.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	is_triggered_only = yes

	option = {
		name = arkship.1080.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @short_arkship_event_delay_days random = @short_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.1085
	title = "arkship.1085.name"
	desc = "arkship.1085.desc"
	picture = GFX_evt_arkship_crisis
	show_sound = event_arkship_in_crisis
	is_triggered_only = yes

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

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @short_arkship_event_delay_days random = @short_arkship_event_delay_random } } }
	}
}

 # A Playground for Giants
carrier_event = {
	id = arkship.1090
	title = "arkship.1090.name"
	desc = "arkship.1090.desc"
	picture = GFX_evt_tiyanki_observation
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		exists = solar_system
		owner = {
			is_gestalt = no
			NOT = { has_country_flag = arkship_playground_for_giants }
		}
		solar_system = {
			any_fleet_in_system = {
				owner = { is_tiyanki_country_type = yes }
			}
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_playground_for_giants
		}
	}

	option = {
		name = arkship.1090.a
		hidden_effect = {
			carrier_event = { id = arkship.1095 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}
}

carrier_event = {
	id = arkship.1095
	title = "arkship.1095.name"
	desc = "arkship.1095.desc"
	picture = GFX_evt_tiyanki_observation
	show_sound = event_life_on_the_arkship
	is_triggered_only = yes

	option = {
		name = arkship.1095.a
		add_modifier = { modifier = "happy_giants" }
	}
	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @short_arkship_event_delay_days random = @short_arkship_event_delay_random } } }
	}
}

 # A Putrid Smell
carrier_event = {
	id = arkship.1100
	title = "arkship.1100.name"
	desc = "arkship.1100.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			is_gestalt = no
			NOT = { has_country_flag = arkship_putrid_smell }
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_putrid_smell
		}
	}

	option = {
		name = UNDERSTOOD
		hidden_effect = {
			carrier_event = { id = arkship.1105 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
}

carrier_event = {
	id = arkship.1105
	title = "arkship.1105.name"
	desc = "arkship.1105.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	is_triggered_only = yes

	option = {
		name = arkship.1105.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 200
				}
			}
		}
		owner = {
			add_resource = {
				energy = -200
			}
		}
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = increase_passenger_satisfaction
			owner = { increase_passenger_satisfaction = yes }
		}
		hidden_effect = {
			carrier_event = { id = arkship.1110 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}

	option = {
		name = arkship.1105.b
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = alloys
					value >= 200
				}
			}
		}
		owner = {
			add_resource = {
				alloys = -200
			}
		}
		hidden_effect = {
			carrier_event = { id = arkship.1115 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}

	option = {
		name = arkship.1105.c
		if = {
			limit = {
				owner = { has_origin = origin_forever_cruise }
			}
			custom_tooltip = decrease_passenger_satisfaction
			owner = { decrease_passenger_satisfaction = yes }
		}
		hidden_effect = {
			owner = {
				country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
			}
		}
	}
}

carrier_event = {
	id = arkship.1110
	title = "arkship.1110.name"
	desc = "arkship.1110.desc"
	picture = GFX_evt_nomad_default
	is_triggered_only = yes

	option = {
		name = arkship.1110.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
	}

	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

carrier_event = {
	id = arkship.1115
	title = "arkship.1115.name"
	desc = "arkship.1115.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	is_triggered_only = yes

	option = {
		name = arkship.1115.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
	}
	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

# A Forgotten Level
carrier_event = {
	id = arkship.1120
	title = "arkship.1120.name"
	desc = "arkship.1120.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_forgotten_level_chain
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			is_gestalt = no
			NOT = { has_country_flag = arkship_forgotten_level }
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_forgotten_level
			begin_event_chain = {
				event_chain = a_forgotten_level_chain
				target = root
			}
		}
	}

	option = {
		name = arkship.1120.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 500
				}
			}
		}
		owner = {
			add_resource = {
				energy = -500
			}
		}
		add_deposit = d_forgotten_level_blocker
		hidden_effect = {
			random_list = {
				1 = { carrier_event = { id = arkship.1125 days = @extremely_short_arkship_event_delay_days random = 60 } }
				1 = { carrier_event = { id = arkship.1135 days = @extremely_short_arkship_event_delay_days random = 60 } }
				1 = { carrier_event = { id = arkship.1140 days = @extremely_short_arkship_event_delay_days random = 60 } }
				1 = { carrier_event = { id = arkship.1145 days = @extremely_short_arkship_event_delay_days random = 60 } }
				1 = { carrier_event = { id = arkship.1150 days = @extremely_short_arkship_event_delay_days random = 60 } }
			}
		}
	}

	option = {
		name = arkship.1120.b
		owner = {
			end_event_chain = a_forgotten_level_chain
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

carrier_event = {
	id = arkship.1125
	title = "arkship.1125.name"
	desc = "arkship.1125.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_forgotten_level_chain

	is_triggered_only = yes

	option = {
		name = arkship.1125.a
		hidden_effect = {
			carrier_event = { id = arkship.1130 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 250
				}
			}
		}
		owner = {
			add_resource = {
				energy = -250
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}

	option = {
		name = arkship.1125.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			end_event_chain = a_forgotten_level_chain
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

carrier_event = {
	id = arkship.1130
	title = "arkship.1130.name"
	desc = "arkship.1130.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_forgotten_level_chain

	is_triggered_only = yes

	option = {
		name = arkship.1130.a
		owner = {
			add_tech_option_or_research_effect = {
				TECH = tech_alien_life_studies
				PROGRESS = 0.1
				CATEGORY = society_research
			}
		}
	}

	option = {
		exclusive_trigger = {
			owner = {
				OR = {
					is_militarist = yes
					is_authoritarian = yes
					has_valid_civic = civic_distinguished_admiralty
					has_valid_civic = civic_nationalistic_zeal
				}
			}
		}
		owner = {
			add_tech_option_or_research_effect = {
				TECH = tech_alien_life_studies
				PROGRESS = 0.1
				CATEGORY = society_research
			}
		}
		name = arkship.1130.a.military
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_forgotten_level_chain
		}
	}
}

carrier_event = {
	id = arkship.1135
	title = "arkship.1135.name"
	desc = "arkship.1135.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_ship_thrusters
	event_chain = a_forgotten_level_chain

	is_triggered_only = yes

	option = {
		name = arkship.1135.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		leader? = {
			add_experience = 200
			if = {
				limit = {
					NOT = { has_trait = leader_trait_resilient }
				}
				add_trait = {
					trait = leader_trait_resilient
				}
			}
			else = {
				add_trait = {
					trait = leader_trait_adaptable
				}
			}
		}
	}


	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_forgotten_level_chain
		}
	}
}

carrier_event = {
	id = arkship.1140
	title = "arkship.1140.name"
	desc = "arkship.1140.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_ship_thrusters
	event_chain = a_forgotten_level_chain

	is_triggered_only = yes

	option = {
		name = arkship.1140.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			add_monthly_resource_mult = {
				resource = energy
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		leader? = {
			add_experience = 200
			if = {
				limit = {
					NOT = { has_trait_tier1or2 = { TRAIT = leader_trait_substance_abuser } }
				}
				add_trait = {
					trait = leader_trait_substance_abuser
				}
			}
			else = {
				leader = {
					add_trait = {
						trait = leader_trait_stubborn
					}
				}
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_forgotten_level_chain
		}
	}
}

carrier_event = {
	id = arkship.1145
	title = "arkship.1145.name"
	desc = "arkship.1145.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_forgotten_level_chain

	is_triggered_only = yes

	option = {
		name = arkship.1145.a
		owner = {
			add_resource = {
				rare_crystals = 650
			}
			root = {
				add_modifier = {
					modifier = statue_modifier
					days = 1500
				}
			}
		}
	}

	option = {
		name = arkship.1145.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_forgotten_level_chain
		}
	}
}

carrier_event = {
	id = arkship.1150
	title = "arkship.1150.name"
	desc = "arkship.1150.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = a_forgotten_level_chain

	is_triggered_only = yes

	trigger = {
		owner = {
			is_robot_empire = yes
		}
	}

	option = {
		name = arkship.1150.a
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = a_forgotten_level_chain
		}
	}
}

# Black Hole Phenomenon
carrier_event = {
	id = arkship.1160
	title = "arkship.1160.name"
	desc = "arkship.1160.desc"
	picture = GFX_evt_black_hole
	show_sound = event_ship_thrusters
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			NOR = {
				has_country_flag = arkship_black_hole_phenomenon_flag
				has_country_flag = arkship_eternal_chorus_flag
			}
		}
		solar_system? = {
			any_system_planet = {
				is_planet_class = pc_black_hole
			}
		}
	}

	immediate = {
		solar_system? = {
			random_system_planet = {
				limit = {
					is_planet_class = pc_black_hole
				}
				save_event_target_as = black_hole_target
			}
		}
		owner = {
			set_country_flag = arkship_black_hole_phenomenon_flag
		}
	}

	option = {
		name = arkship.1160.a
		leader? = {
			add_experience = 200
			if = {
				limit = {
					NOT = { has_trait = leader_trait_eager }
				}
				add_trait = {
					trait = leader_trait_eager
				}
			}
			else = {
				if = {
					limit = {
						NOT = { has_trait_tier1or2 = { TRAIT = leader_trait_gifted } }
					}
					add_trait = {
						trait = leader_trait_gifted
					}
				}
			}
		}
	}

	option = {
		name = arkship.1160.b
		event_target:black_hole_target = {
			add_deposit = d_dark_matter_deposit_1
		}

		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			if = {
				limit = {
					has_tech_option = tech_mine_dark_matter
				}
				add_tech_progress = {
					tech = tech_mine_dark_matter
					progress = 0.1
				}
			}
			else = {
				add_research_option = tech_mine_dark_matter
			}
		}
	}
	after = {
		owner = { hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } } }
	}
}

# Planetary Illuminations
carrier_event = {
	id = arkship.1165
	title = "arkship.1165.name"
	desc = "arkship.1165.desc"
	picture = GFX_evt_city_planet
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = { has_country_flag = arkship_planetary_illuminations_flag }
		}
		solar_system = {
			any_system_planet = {
				is_colony = yes
				owner? = {
					is_gestalt = no
					OR = {
						is_country_type = default
						has_pre_ftl_age = machine_age
						has_pre_ftl_age = atomic_age
						has_pre_ftl_age = early_space_age
					}
				}
			}
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_planetary_illuminations_flag
		}
	}

	option = {
		name = arkship.1165.a
		owner = {
			add_tech_option_or_research_effect = {
				TECH = tech_cultural_heritage
				PROGRESS = 0.1
				CATEGORY = society_research
			}
		}
	}

	option = {
		exclusive_trigger = {
			owner = {
				has_valid_civic = civic_hive_devouring_swarm
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		name = arkship.1165.e
	}

	option = {
		exclusive_trigger = {
			owner = {
				is_genocidal_infernal = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		name = arkship.1165.j
	}

	option = {
		exclusive_trigger = {
			owner = {
				OR = {
					is_homicidal = yes
					is_fanatic_militarist = yes
					#has_civic = civic_fanatic_purifiers
				}
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		name = arkship.1165.h
	}

	option = {
		exclusive_trigger = {
			owner = {
				is_xenophobe = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		name = arkship.1165.b
	}

	option = {
		exclusive_trigger = {
			owner = {
				OR = {
					is_xenophile = yes
					has_valid_civic = civic_machine_servitor
					has_valid_civic = civic_machine_exploration_protocol
				}
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
		name = arkship.1165.f
	}

	option = {
		exclusive_trigger = {
			owner = {
				is_synthetic_empire = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		name = arkship.1165.c
	}

	option = {
		exclusive_trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		name = arkship.1165.d
	}

	option = {
		exclusive_trigger = {
			owner = {
				OR = {
					has_valid_civic = civic_barbaric_despoilers
					has_ascension_perk = ap_nihilistic_acquisition
					has_policy_flag = slavery_allowed
				}
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		name = arkship.1165.g
	}

	option = {
		exclusive_trigger = {
			owner = {
				is_megacorp = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = trade
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		name = arkship.1165.i
	}

	option = {
		exclusive_trigger = {
			owner = {
				is_militarist = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		name = arkship.1165.k
	}

	option = {
		exclusive_trigger = {
			owner = {
				is_spiritualist = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		name = arkship.1165.l
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

# Unregulated Trade
carrier_event = {
	id = arkship.1185
	title = "arkship.1185.name"
	desc = "arkship.1185.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			is_gestalt = no
			NOT = { has_country_flag = unregulated_trade_flag }
		}
	}

	immediate = {
		owner = {
			set_country_flag = unregulated_trade_flag
		}
	}

	option = {
		name = arkship.1185.a
		hidden_effect = {
			carrier_event = { id = arkship.1190 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 250
				}
			}
		}
		owner = {
			add_resource = {
				energy = -250
			}
		}
	}

	option = {
		name = arkship.1185.b
		hidden_effect = {
			carrier_event = { id = arkship.1200 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 250
				}
			}
		}
		owner = {
			add_resource = {
				energy = -250
			}
		}
	}

	option = {
		name = arkship.1185.c
		hidden_effect = {
			carrier_event = { id = arkship.1195 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}

}

carrier_event = { #legalize it
	id = arkship.1190
	title = "arkship.1190.name"
	desc = "arkship.1190.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1190.a
		add_modifier = {
			modifier = "free_market"
			days = 1080
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

carrier_event = { #shut it down
	id = arkship.1195
	title = "arkship.1195.name"
	desc = "arkship.1195.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		add_modifier = {
			modifier = "total_control"
			days = 1080
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

carrier_event = { #tax it
	id = arkship.1200
	title = "arkship.1200.name"
	desc = "arkship.1200.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1200.a
		owner = {
			add_monthly_resource_mult = {
				resource = trade
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = energy
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
	}

	option = {
		name = arkship.1200.b
		exclusive_trigger = {
			owner = {
				is_megacorp = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = trade
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = energy
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

# The Skin of a Giant
carrier_event = {
	id = arkship.1170
	title = "arkship.1170.name"
	desc = "arkship.1170.desc"
	picture = GFX_evt_hive
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			has_country_flag = dragon_encounter
			NOT = { has_country_flag = the_skin_of_a_giant_flag }
		}
	}

	immediate = {
		owner = {
			set_country_flag = the_skin_of_a_giant_flag
		}
		create_ambient_object = {
			type = "etherdrake_scale_object"
			location = root
		}
		last_created_ambient_object = {
			save_event_target_as = etherdrake_scales
			set_location = {
				target = root
				distance = 50
				angle = random
			}
		}
	}

	option = {
		name = arkship.1170.a
		event_target:etherdrake_scales = {
			enable_special_project = {
				name = "THE_SKIN_OF_A_GIANT_PROJECT"
				location = this
				owner = root.owner
			}
			set_ambient_object_flag = etherdrake_scales_flag
		}
	}

	option = {
		name = arkship.1170.b
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = alloys
					value >= 250
				}
			}
		}
		owner = {
			add_resource = {
				alloys = -250
			}
		}
		hidden_effect = {
			carrier_event = { id = arkship.1180 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}

	option = {
		name = arkship.1170.c
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

carrier_event = {
	id = arkship.1175
	title = "arkship.1175.name"
	desc = "arkship.1175.desc"
	picture = GFX_evt_hive
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1175.a
		add_modifier = { modifier = etherdrake_scales_modifier }
	}
}

carrier_event = {
	id = arkship.1180
	title = "arkship.1180.name"
	desc = "arkship.1180.desc"
	picture = GFX_evt_hive
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1180.a
		owner = {
			add_monthly_resource_mult = {
				resource = energy
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
			add_monthly_resource_mult = {
				resource = trade
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}

	option = {
		name = arkship.1180.b
		exclusive_trigger = {
			owner = {
				is_megacorp = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = energy
				value = @tier3materialreward
				min = @tier3materialmin
				max = @tier3materialmax
			}
			add_monthly_resource_mult = {
				resource = trade
				value = @tier3materialreward
				min = @tier3materialmin
				max = @tier3materialmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

# The Only Sky We Know
carrier_event = {
	id = arkship.1205
	title = "arkship.1205.name"
	desc = "arkship.1205.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			is_gestalt = no
			is_individual_machine = no
			NOT = { has_country_flag = the_only_sky_we_know_flag }
		}
	}

	immediate = {
		owner = {
			set_country_flag = the_only_sky_we_know_flag
		}
	}

	option = {
		name = arkship.1205.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 250
				}
			}
		}
		owner = {
			add_resource = {
				energy = -250
			}
		}
		hidden_effect = {
			carrier_event = { id = arkship.1210 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}

	option = {
		name = arkship.1205.b
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
		}
	}
}

carrier_event = {
	id = arkship.1210
	title = "arkship.1210.name"
	desc = "arkship.1210.desc.a"
	desc = "arkship.1210.desc.b"
	desc = "arkship.1210.desc.c"
	desc = "arkship.1210.desc.d"
	desc = "arkship.1210.desc.e"
	desc = "arkship.1210.desc.f"
	desc = "arkship.1210.desc.g"
	desc = "arkship.1210.desc.h"
	desc = {
		trigger = {
			owner = {
				OR = {
					founder_species_is_avian = yes
					founder_species_is_reptilian = yes
				}
			}
		}
		text = arkship.1210.desc.avian.reptilian
	}
	desc = {
		trigger = {
			owner = {
				OR = {
					founder_species_is_fungoid = yes
					founder_species_is_plantoid = yes
				}
			}
		}
		text = arkship.1210.desc.fungoid.plantoid
	}
	desc = {
		trigger = {
			owner = {
				founder_species_is_infernal = yes
			}
		}
		text = arkship.1210.desc.infernal
	}
	desc = {
		trigger = {
			owner = {
				founder_species_is_mammalian = yes
			}
		}
		text = arkship.1210.desc.mammalian
	}
	desc = {
		trigger = {
			owner = {
				founder_species_is_arthropoid = yes
			}
		}
		text = arkship.1210.desc.arthropoid
	}
	desc = {
		trigger = {
			owner = {
				founder_species_is_toxoid = yes
			}
		}
		text = arkship.1210.desc.toxoid
	}
	desc = {
		trigger = {
			owner = {
				founder_species_is_lithoid = yes
			}
		}
		text = arkship.1210.desc.lithoid
	}
	desc = {
		trigger = {
			owner = {
				OR = {
					founder_species_is_aquatic = yes
					founder_species_is_molluscoid = yes
				}
			}
		}
		text = arkship.1210.desc.aquatic.mulluscoid
	}
	picture = GFX_evt_nomad_default
	show_sound = event_ship_thrusters
	location = ROOT
	trackable = yes

	is_triggered_only = yes

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

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @short_arkship_event_delay_days random = @short_arkship_event_delay_random } }
		}
	}
}

# Fungal Contamination
carrier_event = {
	id = arkship.1215
	title = "arkship.1215.name"
	desc = "arkship.1215.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	event_chain = fungal_contamination_chain
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			founder_species_is_biological = yes
			NOT = { has_country_flag = fungal_contamination_flag }
		}
		has_any_farming_district_or_building = yes
	}

	immediate = {
		owner = {
			set_country_flag = fungal_contamination_flag
		}
		begin_event_chain = {
			event_chain = "fungal_contamination_chain"
			target = root
		}
	}

	option = {
		name = arkship.1215.a
		add_modifier = {
			modifier = "farms_in_flames_modifier"
			days = 1080
		}
		hidden_effect = {
			carrier_event = { id = arkship.1220 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}

	option = {
		name = arkship.1215.b
		enable_special_project = {
			name = "ARKSHIP_FUNGAL_CONTAMINATION_PROJECT"
			location = root
			owner = root.owner
		}
	}

	option = {
		name = arkship.1215.c
		trigger = {
			owner = {
				OR = {
					founder_species_is_fungoid = yes
					founder_species_is_plantoid = yes
				}
			}
		}
		enable_special_project = {
			name = "ARKSHIP_FUNGAL_COMMUNICATION_PROJECT"
			location = root
			owner = root.owner
		}
	}
}

carrier_event = {
	id = arkship.1220
	title = "arkship.1220.name"
	desc = "arkship.1220.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	event_chain = fungal_contamination_chain
	trackable = yes

	is_triggered_only = yes

	immediate = {
		remove_modifier = farms_in_flames_modifier
	}

	option = {
		name = arkship.1220.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
			add_tech_option_or_research_effect = {
				TECH = tech_industrial_farming
				PROGRESS = 0.15
				CATEGORY = society_research
			}
		}
	}

	after = {
		owner = {
			hidden_effect = {
				country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
				end_event_chain = fungal_contamination_chain
			}
		}
	}
}

carrier_event = {
	id = arkship.1225
	title = "arkship.1225.name"
	desc = "arkship.1225.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	event_chain = fungal_contamination_chain
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1225.a
		add_modifier = {
			modifier = "mycelial_intelligence_modifier"
			days = 1080
		}
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
			hidden_effect = {
				country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
				end_event_chain = fungal_contamination_chain
			}
		}
	}

	option = {
		name = arkship.1225.b
		hidden_effect = {
			carrier_event = { id = arkship.1230 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
}

carrier_event = {
	id = arkship.1230
	title = "arkship.1230.name"
	desc = "arkship.1230.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	event_chain = fungal_contamination_chain
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1230.a
		owner = {
			add_tech_option_or_research_effect = {
				TECH = tech_mine_exotic_gases
				PROGRESS = 0.1
				CATEGORY = society_research
			}
			add_monthly_resource_mult = {
				resource = exotic_gases
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = {
				country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
				end_event_chain = fungal_contamination_chain
			}
		}
	}
}

carrier_event = {
	id = arkship.1235
	title = "arkship.1235.name"
	desc = "arkship.1235.desc"
	picture = GFX_evt_arkship_life
	show_sound = event_life_on_the_arkship
	location = ROOT
	event_chain = fungal_contamination_chain
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1235.a
		add_modifier = {
			modifier = "funghi_friends_modifier"
			days = -1
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			add_monthly_resource_mult = {
				resource = food
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = {
				country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random }
				end_event_chain = fungal_contamination_chain
			}
		}
	}
}

# Unknown Resource Usage
carrier_event = {
	id = arkship.1240
	title = "arkship.1240.name"
	desc = "arkship.1240.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_ambient_arkship_engine
	location = ROOT
	event_chain = unknown_resource_usage_chain
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = { has_country_flag = unknown_resource_usage_flag }
			is_gestalt = no
		}
	}

	immediate = {
		owner = {
			set_country_flag = unknown_resource_usage_flag
		}
		begin_event_chain = {
			event_chain = "unknown_resource_usage_chain"
			target = root.owner
		}
	}

	option = {
		name = arkship.1240.a
		enable_special_project = {
			name = "UNKNOWN_RESOURCE_USAGE_PROJECT"
			location = this
			owner = root.owner
		}
	}

	option = { #opt out
		name = arkship.1240.b
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @short_arkship_event_delay_days random = @short_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}

carrier_event = {
	id = arkship.1245
	title = "arkship.1245.name"
	desc = "arkship.1245.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = unknown_resource_usage_chain

	is_triggered_only = yes

	option = {
		name = arkship.1245.a
		add_modifier = {
			modifier = "unknown_resource_demolished"
		}
	}

	option = {
		name = arkship.1245.b
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}

carrier_event = {
	id = arkship.1250
	title = "arkship.1250.name"
	desc = "arkship.1250.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_ship_thrusters
	event_chain = unknown_resource_usage_chain

	is_triggered_only = yes

	option = {
		name = arkship.1250.a
		add_modifier = {
			modifier = "unknown_resource_demolished"
		}
	}

	option = {
		name = arkship.1250.b
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}

carrier_event = {
	id = arkship.1255
	title = "arkship.1255.name"
	desc = "arkship.1255.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = unknown_resource_usage_chain

	is_triggered_only = yes

	option = {
		name = arkship.1255.a
		add_modifier = {
			modifier = "unknown_resource_demolished"
		}
	}

	option = {
		name = arkship.1255.b
		add_modifier = {
			modifier = "wellness_retreat_permitted"
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}

carrier_event = {
	id = arkship.1260
	title = "arkship.1260.name"
	desc = "arkship.1260.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = unknown_resource_usage_chain

	is_triggered_only = yes

	option = {
		name = arkship.1260.a
		add_modifier = {
			modifier = "unknown_resource_demolished"
		}
	}

	option = {
		name = arkship.1260.b
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}

carrier_event = {
	id = arkship.1265
	title = "arkship.1265.name"
	desc = "arkship.1265.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = unknown_resource_usage_chain

	is_triggered_only = yes

	option = {
		name = arkship.1265.a
		if = {
			limit = { owner = { is_individual_machine = yes } }
			owner = {
				add_monthly_resource_mult = {
					resource = energy
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
				add_monthly_resource_mult = {
					resource = minerals
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
		}
		else = {
			owner = {
				add_monthly_resource_mult = {
					resource = consumer_goods
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
				add_monthly_resource_mult = {
					resource = food
					value = @tier1materialreward
					min = @tier1materialmin
					max = @tier1materialmax
				}
			}
		}
	}

	option = {
		name = arkship.1265.b
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}

carrier_event = {
	id = arkship.1270
	title = "arkship.1270.name"
	desc = "arkship.1270.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_ship_thrusters
	event_chain = unknown_resource_usage_chain

	is_triggered_only = yes

	option = {
		name = arkship.1270.a
		add_modifier = {
			modifier = "unknown_resource_demolished"
		}
	}

	option = {
		name = arkship.1270.b
		owner = {
			add_monthly_resource_mult = {
				resource = minerals
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}

carrier_event = {
	id = arkship.1275
	title = "arkship.1275.name"
	desc = "arkship.1275.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = unknown_resource_usage_chain

	is_triggered_only = yes

	option = {
		name = arkship.1275.a
		hidden_effect = {
			carrier_event = { id = arkship.1280 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}

	option = {
		name = arkship.1275.b
		random_owned_pop_group = {
			remove_pop_amount = 5
		}
		add_modifier = {
			modifier = "arkship_order_restored"
			days = 1095
		}
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}

	option = {
		name = arkship.1275.c
		trigger = {
			owner = {
				OR = {
					has_civic = civic_fanatic_purifiers
					has_civic = civic_idealistic_foundation
				}
			}
		}
		random_owned_pop_group = {
			remove_pop_amount = 5
		}
		add_modifier = {
			modifier = "arkship_purge_enacted"
			days = 1095
		}
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}

carrier_event = {
	id = arkship.1280
	title = "arkship.1280.name"
	desc = "arkship.1280.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	event_chain = unknown_resource_usage_chain

	is_triggered_only = yes

	option = {
		name = arkship.1280.a
		random_owned_pop_group = {
			add_pop_amount = 5
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}

	option = {
		name = arkship.1280.b
		random_owned_pop_group = {
			remove_pop_amount = 5
		}
		add_modifier = {
			modifier = "arkship_order_restored"
			days = 1095
		}
	}

	option = {
		name = arkship.1280.c
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @medium_arkship_event_delay_days random = @medium_arkship_event_delay_random } }
			end_event_chain = unknown_resource_usage_chain
		}
	}
}


# The Grand Refurbishment - Situation Events

# A Necessary Reckoning
carrier_event = {
	id = arkship.1300
	title = arkship.1300.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1300.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1300.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1300.desc.hive
	}
	picture = GFX_evt_arkship_crisis
	show_sound = event_arkship_in_crisis
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		NOT = { has_carrier_flag = grand_refurbishment_active }
		colony_age > 25
		owner = { NOT = { has_country_flag = nomadic_narrative_situation } }
	}

	immediate = {
		set_carrier_flag = grand_refurbishment_active
		owner = {
			start_situation = {
				type = situation_grand_refurbishment
				target = root
				effect = {
					save_event_target_as = situation_grand_refurbishment
				}
			}
		}
	}

	option = {
		name = arkship.1300.a
		add_modifier = { modifier = refurbishment_ongoing }
		tooltip = {
			add_modifier = { modifier = refurbishment_generator_offline }
		}
	}
}

# The Cultivation Decks (Stage 2 Entry: Farming District Begins)
situation_event = {
	id = arkship.1305
	title = arkship.1305.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1305.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1305.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1305.desc.hive
	}
	picture = GFX_evt_arkship_life
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = {
		name = arkship.1305.a
		custom_tooltip = arkship.1305.a.tt
		tooltip = {
			target = {
				add_modifier = { modifier = refurbishment_farming_offline }
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# The Defense Section (Stage 3 Entry: Military District Begins)
situation_event = {
	id = arkship.1310
	title = arkship.1310.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1310.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1310.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1310.desc.hive
	}
	picture = GFX_evt_megastructure_construction
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = {
		name = arkship.1310.a
		custom_tooltip = arkship.1305.a.tt
		tooltip = {
			target = {
				add_modifier = { modifier = refurbishment_military_offline }
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# The Living Quarters (Stage 4 Entry: Residential District Begins)
situation_event = {
	id = arkship.1315
	title = arkship.1315.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1315.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1315.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1315.desc.hive
	}
	picture = GFX_evt_enclave_overlord
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = {
		name = arkship.1315.a
		custom_tooltip = arkship.1305.a.tt
		tooltip = {
			target = {
				add_modifier = { modifier = refurbishment_city_offline }
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 1 Pool: Sector Allocation Disputes
situation_event = {
	id = arkship.1320
	title = arkship.1320.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1320.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1320.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1320.desc.hive
	}
	picture = GFX_evt_financial_instruments
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_generator
		situation_progress >= 15
		NOT = { has_situation_flag = refurbishment_stage1_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage1_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Let engineering sort it - cuts corner, costs Energy
		name = arkship.1320.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy value >= 200
				}
			}
		}
		add_situation_progress = 20
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { energy = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Establish a proper allocation - progress -10, low morale
		name = arkship.1320.b
		add_situation_progress = -10
		target = {
			if = {
				limit = { owner = { check_variable = { which = refurbishment_low_morale_count value = 2 } } }
				remove_modifier = refurbishment_low_morale_2
				add_modifier = { modifier = refurbishment_low_morale_3 }
			}
			else_if = {
				limit = { owner = { check_variable = { which = refurbishment_low_morale_count value = 1 } } }
				remove_modifier = refurbishment_low_morale
				add_modifier = { modifier = refurbishment_low_morale_2 }
			}
			else = {
				add_modifier = { modifier = refurbishment_low_morale }
			}
		}
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_low_morale_count
					value = 1
				}
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 1 Pool: Something Behind the Wall
situation_event = {
	id = arkship.1325
	title = arkship.1325.name
	desc = arkship.1325.desc
	picture = GFX_evt_sabotaged_ship
	show_sound = event_arkship_in_crisis
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_generator
		situation_progress >= 15
		NOT = { has_situation_flag = refurbishment_stage1_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage1_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Log it and continue - cuts corner, costs Minerals
		name = arkship.1325.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = minerals value >= 200
				}
			}
		}
		add_situation_progress = 10
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { minerals = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Address it properly, low morale
		name = arkship.1325.b
		add_situation_progress = -10
		target = {
			if = {
				limit = { owner = { check_variable = { which = refurbishment_low_morale_count value = 2 } } }
				remove_modifier = refurbishment_low_morale_2
				add_modifier = { modifier = refurbishment_low_morale_3 }
			}
			else_if = {
				limit = { owner = { check_variable = { which = refurbishment_low_morale_count value = 1 } } }
				remove_modifier = refurbishment_low_morale
				add_modifier = { modifier = refurbishment_low_morale_2 }
			}
			else = {
				add_modifier = { modifier = refurbishment_low_morale }
			}
		}
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_low_morale_count
					value = 1
				}
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 1 Pool: Disruption Allowances
situation_event = {
	id = arkship.1330
	title = arkship.1330.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1330.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1330.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1330.desc.hive
	}
	picture = GFX_evt_gunrunning
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_generator
		situation_progress >= 15
		NOT = { has_situation_flag = refurbishment_stage1_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage1_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # They'll manage - cuts corner
		name = arkship.1330.a
		add_situation_progress = 20
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Approve the allowances - progress -10
		name = arkship.1330.b
		add_situation_progress = -10
		target = {
			add_modifier = { modifier = refurbishment_allowances_granted }
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 2 Pool: The Second Shift
situation_event = {
	id = arkship.1335
	title = arkship.1335.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1335.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1335.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1335.desc.hive
	}
	picture = GFX_evt_stairway_to_heavens
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_farming
		situation_progress >= 65
		NOT = { has_situation_flag = refurbishment_stage2_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage2_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Maintain current pace - cuts corner, costs Energy
		name = arkship.1335.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy value >= 200
				}
			}
		}
		add_situation_progress = 20
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { energy = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Proper shift rotations - progress -10, construction fatigue
		name = arkship.1335.b
		add_situation_progress = -10
		target = {
			if = {
				limit = { owner = { check_variable = { which = refurbishment_construction_fatigue_count value = 1 } } }
				remove_modifier = refurbishment_construction_fatigue
				add_modifier = { modifier = refurbishment_construction_fatigue_2 }
			}
			else = {
				add_modifier = { modifier = refurbishment_construction_fatigue }
			}
		}
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_construction_fatigue_count
					value = 1
				}
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 2 Pool: Conduit Failure
situation_event = {
	id = arkship.1340
	title = arkship.1340.name
	desc = arkship.1340.desc
	picture = GFX_evt_sabotaged_ship
	show_sound = event_arkship_in_crisis
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_farming
		situation_progress >= 65
		NOT = { has_situation_flag = refurbishment_stage2_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage2_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Route around it - cuts corner, costs Minerals, persistent bypass penalty
		name = arkship.1340.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = minerals value >= 200
				}
			}
		}
		add_situation_progress = 20
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { minerals = -200 }
		}
		target = {
			add_modifier = {
				modifier = refurbishment_bypass_routing
				days = -1
			}
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Emergency repair crews - progress -15
		name = arkship.1340.b
		add_situation_progress = -15
		target = {
			add_modifier = {
				modifier = refurbishment_power_restoration
				days = -1
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 2 Pool: The Major Concern
situation_event = {
	id = arkship.1345
	title = arkship.1345.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1345.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1345.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1345.desc.hive
	}
	picture = GFX_evt_arkship_bridge
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_farming
		situation_progress >= 65
		NOT = { has_situation_flag = refurbishment_stage2_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage2_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Acceptable is acceptable - cuts corner, costs Minerals
		name = arkship.1345.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = minerals value >= 200
				}
			}
		}
		add_situation_progress = 20
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { minerals = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Heed the warning - progress -10, construction fatigue
		name = arkship.1345.b
		add_situation_progress = -10
		target = {
			if = {
				limit = { owner = { check_variable = { which = refurbishment_construction_fatigue_count value = 1 } } }
				remove_modifier = refurbishment_construction_fatigue
				add_modifier = { modifier = refurbishment_construction_fatigue_2 }
			}
			else = {
				add_modifier = { modifier = refurbishment_construction_fatigue }
			}
		}
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_construction_fatigue_count
					value = 1
				}
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 3 Pool: First Section Online
situation_event = {
	id = arkship.1350
	title = arkship.1350.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1350.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1350.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1350.desc.hive
	}
	picture = GFX_evt_financial_instruments
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_military
		situation_progress >= 115
		NOT = { has_situation_flag = refurbishment_stage3_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage3_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Move them back in now - cuts corner, costs Energy
		name = arkship.1350.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy value >= 200
				}
			}
		}
		add_situation_progress = 20
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { energy = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Complete testing - progress -10, extended displacement
		name = arkship.1350.b
		add_situation_progress = -10
		target = {
			add_modifier = { modifier = refurbishment_extended_displacement }
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 3 Pool: The Repair List
situation_event = {
	id = arkship.1355
	title = arkship.1355.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1355.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1355.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1355.desc.hive
	}
	picture = GFX_evt_financial_instruments
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_military
		situation_progress >= 115
		NOT = { has_situation_flag = refurbishment_stage3_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage3_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Structural items only - cuts corner, costs Energy
		name = arkship.1355.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy value >= 200
				}
			}
		}
		add_situation_progress = 15
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { energy = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Complete the full list - progress -15, low morale
		name = arkship.1355.b
		add_situation_progress = -15
		target = {
			if = {
				limit = { owner = { check_variable = { which = refurbishment_low_morale_count value = 2 } } }
				remove_modifier = refurbishment_low_morale_2
				add_modifier = { modifier = refurbishment_low_morale_3 }
			}
			else_if = {
				limit = { owner = { check_variable = { which = refurbishment_low_morale_count value = 1 } } }
				remove_modifier = refurbishment_low_morale
				add_modifier = { modifier = refurbishment_low_morale_2 }
			}
			else = {
				add_modifier = { modifier = refurbishment_low_morale }
			}
		}
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_low_morale_count
					value = 1
				}
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 3 Pool: Coming Home
situation_event = {
	id = arkship.1360
	title = arkship.1360.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1360.desc
	}
	desc = {
		trigger = {
			owner = {
				is_individual_machine = yes
			}
		}
		text = arkship.1360.desc.machine_ind
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1360.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1360.desc.hive
	}
	picture = GFX_evt_happy_reunion
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_military
		situation_progress >= 115
		NOT = { has_situation_flag = refurbishment_stage3_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage3_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = {
		name = arkship.1360.a
		add_situation_progress = 20
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Genuine celebration - progress -10, unity reward
		name = arkship.1360.b
		add_situation_progress = -10
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 4 Pool: The Long Wait
situation_event = {
	id = arkship.1365
	title = arkship.1365.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1365.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1365.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1365.desc.hive
	}
	picture = GFX_evt_engineering_bay
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_city
		situation_progress >= 165
		NOT = { has_situation_flag = refurbishment_stage4_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage4_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # No additional resources - cuts corner, +10 progress
		name = arkship.1365.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy value >= 200
				}
			}
		}
		add_situation_progress = 20
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { energy = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Improve temporary conditions - progress -10, administrative burden
		name = arkship.1365.b
		add_situation_progress = -10
		if = {
			limit = {
				owner = {
					is_gestalt = yes
				}
			}
			target = {
				add_modifier = { modifier = refurbishment_administrative_burden_gestalt }
			}
		}
		else = {
			target = {
				add_modifier = { modifier = refurbishment_administrative_burden }
			}
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 4 Pool: Unauthorized Modifications
situation_event = {
	id = arkship.1370
	title = arkship.1370.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1370.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1370.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1370.desc.hive
	}
	picture = GFX_evt_engineering_bay
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_city
		situation_progress >= 165
		NOT = { has_situation_flag = refurbishment_stage4_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage4_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Document and work around it - cuts corner, costs Energy
		name = arkship.1370.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 200
				}
			}
		}
		add_situation_progress = 15
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { energy  = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Remove everything properly - progress -10, rework zone
		name = arkship.1370.b
		trigger = {
			owner = { NOT = { has_civic = civic_functional_architecture } }
		}
		allow = {
			target = { free_district_slots > 0 }
		}
		add_situation_progress = -10
		target = {
			add_modifier = { modifier = refurbishment_rework_zone }
		}
	}

	option = {
		name = arkship.1370.c
		trigger = {
			owner = { has_civic = civic_functional_architecture }
		}
		allow = {
			target = { free_district_slots > 0 }
		}
		add_situation_progress = -10
		target = {
			add_modifier = { modifier = refurbishment_rework_zone }
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# Stage 4 Pool: The Final Deck
situation_event = {
	id = arkship.1375
	title = arkship.1375.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		text = arkship.1375.desc
	}
	desc = {
		trigger = {
			owner = {
				is_machine_empire = yes
			}
		}
		text = arkship.1375.desc.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
			}
		}
		text = arkship.1375.desc.hive
	}
	picture = GFX_evt_arkship_bridge
	is_triggered_only = yes
	location = target
	situation = this

	trigger = {
		current_stage = stage_refurbishment_city
		situation_progress >= 165
		NOT = { has_situation_flag = refurbishment_stage4_event_fired }
	}

	immediate = {
		set_situation_flag = refurbishment_stage4_event_fired
		set_situation_flag = situation_grand_refurbishment_pause
	}

	option = { # Clear for occupancy - cuts corner, costs Energy
		name = arkship.1375.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy value >= 200
				}
			}
		}
		add_situation_progress = 15
		owner = {
			hidden_effect = {
				change_variable = {
					which = refurbishment_corners_cut
					value = 1
				}
			}
			add_resource = { energy = -200 }
		}
		custom_tooltip = arkship.1320.a.tt
	}

	option = { # Full inspection - progress -10, inspection hold
		name = arkship.1375.b
		add_situation_progress = -10
		target = {
			add_modifier = { modifier = refurbishment_inspection_hold }
		}
	}
	after = {
		remove_situation_flag = situation_grand_refurbishment_pause
	}
}

# The Grand Refurbishment: Completion
situation_event = {
	id = arkship.1380
	title = arkship.1380.name
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
				check_variable = {
					which = refurbishment_corners_cut
					value = 0
				}
			}
		}
		text = arkship.1380.desc.full
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
				check_variable = {
					which = refurbishment_corners_cut
					value >= 1
				}
				NOT = {
					check_variable = {
						which = refurbishment_corners_cut
						value >= 3
					}
				}
			}
		}
		text = arkship.1380.desc.partial
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = no
				check_variable = {
					which = refurbishment_corners_cut
					value >= 3
				}
			}
		}
		text = arkship.1380.desc.rushed
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = yes
				is_machine_empire = yes
				check_variable = {
					which = refurbishment_corners_cut
					value = 0
				}
			}
		}
		text = arkship.1380.desc.full.machine
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = yes
				is_machine_empire = yes
				check_variable = {
					which = refurbishment_corners_cut
					value >= 1
				}
				NOT = {
					check_variable = {
						which = refurbishment_corners_cut
						value >= 3
					}
				}
			}
		}
		text = arkship.1380.desc.partial.machine
	}
	desc = {
		trigger = {
			owner = {
				is_gestalt = yes
				is_machine_empire = yes
				check_variable = {
					which = refurbishment_corners_cut
					value >= 3
				}
			}
		}
		text = arkship.1380.desc.rushed.machine
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
				check_variable = {
					which = refurbishment_corners_cut
					value = 0
				}
			}
		}
		text = arkship.1380.desc.full.hive
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
				check_variable = {
					which = refurbishment_corners_cut
					value >= 1
				}
				NOT = {
					check_variable = {
						which = refurbishment_corners_cut
						value >= 3
					}
				}
			}
		}
		text = arkship.1380.desc.partial.hive
	}
	desc = {
		trigger = {
			owner = {
				is_hive_empire = yes
				check_variable = {
					which = refurbishment_corners_cut
					value >= 3
				}
			}
		}
		text = arkship.1380.desc.rushed.hive
	}
	picture = GFX_evt_arkship_bridge
	is_triggered_only = yes
	location = target
	situation = this

	# Generator specialization: Optimized Power Grid
	option = {
		name = arkship.1380.a
		if = {
			limit = {
				owner = {
					check_variable = {
						which = refurbishment_corners_cut
						value = 0
					}
				}
			}
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_power_grid_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_power_grid
						days = -1
					}
				}
			}
		}
		else_if = {
			limit = {
				owner = {
					check_variable = {
						which = refurbishment_corners_cut
						value >= 3
					}
				}
			}
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_power_grid_weak_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_power_grid_weak
						days = -1
					}
				}
			}
		}
		else = {
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_power_grid_partial_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_power_grid_partial
						days = -1
					}
				}
			}
		}
		owner = {
			add_modifier = {
				modifier = refurbishment_fleet_capacity
				days = -1
			}
		}
		destroy_situation = this
	}

	#Farming specialization: Enhanced Cultivation Decks
	option = {
		name = arkship.1380.b
		if = {
			limit = {
				owner = {
					check_variable = {
						which = refurbishment_corners_cut
						value = 0
					}
				}
			}
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_cultivation_decks_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_cultivation_decks
						days = -1
					}
				}
			}
		}
		else_if = {
			limit = {
				owner = {
					check_variable = {
						which = refurbishment_corners_cut
						value >= 3
					}
				}
			}
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_cultivation_decks_weak_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_cultivation_decks_weak
						days = -1
					}
				}
			}
		}
		else = {
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_cultivation_decks_partial_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_cultivation_decks_partial
						days = -1
					}
				}
			}
		}
		owner = {
			add_modifier = {
				modifier = refurbishment_fleet_capacity
				days = -1
			}
		}
		destroy_situation = this
	}

	#Military specialization: Reinforced Defense Systems
	option = {
		name = arkship.1380.c
		if = {
			limit = {
				owner = {
					check_variable = {
						which = refurbishment_corners_cut
						value = 0
					}
				}
			}
			target = {
				add_modifier = {
					modifier = refurbishment_defense_systems
					days = -1
				}
			}
		}
		else_if = {
			limit = {
				owner = {
					check_variable = {
						which = refurbishment_corners_cut
						value >= 3
					}
				}
			}
			target = {
				add_modifier = {
					modifier = refurbishment_defense_systems_weak
					days = -1
				}
			}
		}
		else = {
			target = {
				add_modifier = {
					modifier = refurbishment_defense_systems_partial
					days = -1
				}
			}
		}
		owner = {
			add_modifier = {
				modifier = refurbishment_fleet_capacity
				days = -1
			}
		}
		destroy_situation = this
	}

	#City specialization: Residential Expansion
	option = {
		name = arkship.1380.d
		if = {
			limit = {
				owner = {
					check_variable = {
						which = refurbishment_corners_cut
						value = 0
					}
				}
			}
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_residential_expansion_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_residential_expansion
						days = -1
					}
				}
			}
		}
		else_if = {
			limit = {
				owner = {
					check_variable = {
						which = refurbishment_corners_cut
						value >= 3
					}
				}
			}
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_residential_expansion_weak_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_residential_expansion_weak
						days = -1
					}
				}
			}
		}
		else = {
			if = {
				limit = { owner = { is_gestalt = yes } }
				target = {
					add_modifier = {
						modifier = refurbishment_residential_expansion_partial_gestalt
						days = -1
					}
				}
			}
			else = {
				target = {
					add_modifier = {
						modifier = refurbishment_residential_expansion_partial
						days = -1
					}
				}
			}
		}
		owner = {
			add_modifier = {
				modifier = refurbishment_fleet_capacity
				days = -1
			}
		}
		destroy_situation = this
	}

	after = {
		owner = {
			hidden_effect = { country_event = { id = arkship.1 days = @long_arkship_event_delay_days random = @long_arkship_event_delay_random } }
		}
	}
}

# Arkship changed hands - clean up leftover nomad narrative modifiers so a conqueror is not stuck with them.
# Fired from on_colony_transfer (which also covers conquest). These modifiers are applied to the arkship colony
# (the Grand Refurbishment situation and the onboarding checklist both add modifiers in arkship/capital scope), so
# they transfer with the arkship. The situation's own on_abort cannot strip them when the former owner is destroyed,
# and the checklist has no situation at all, so this is the reliable cleanup point for both.
# This = the transferred arkship (carrier/colony). Gated to pc_ark so it is a no-op for every other colony transfer.
carrier_event = {
	id = arkship.1450
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_planet_class = pc_ark
	}

	immediate = {
		remove_grand_refurbishment_arkship_modifiers_effect = yes
		remove_checklist_arkship_modifiers_effect = yes
	}
}

# Star-Crossed Lovers
carrier_event = {
	id = arkship.1385
	title = "arkship.1385.name"
	desc = "arkship.1385.desc"
	picture = GFX_evt_asteroid_field
	show_sound = event_ship_thrusters
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = { has_country_flag = arkship_star_crossed_lovers }
			is_homicidal = no
		}
	}

	immediate = {
		owner = {
			set_country_flag = arkship_star_crossed_lovers
		}
		create_ambient_object = {
			type = "star_crossed_pod_object"
			location = root
		}
		last_created_ambient_object = {
			save_event_target_as = star_crossed_pod
			set_location = {
				target = root
				distance = 50
				angle = random
			}
		}
	}

	option = {
		name = arkship.1385.a
		event_target:star_crossed_pod = {
			enable_special_project = {
				name = "STAR_CROSSED_POD_PROJECT"
				location = this
				owner = root.owner
			}
		}
	}

	option = {
		name = arkship.1385.b
		owner = {
			hidden_effect = {
				country_event = {
					id = arkship.1
					days = @medium_arkship_event_delay_days
					random = @very_short_arkship_event_delay_random
				}
			}
		}
	}
}

carrier_event = { # Dearly Beloved
	id = arkship.1390
	title = "arkship.1390.name"
	desc = "arkship.1390.desc"
	picture = GFX_evt_space_funeral
	show_sound = event_ship_thrusters
	location = ROOT
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes

	immediate = {
		owner = {
			begin_event_chain = {
				event_chain = star_crossed_lovers_chain
				target = root
			}
			random_system = {
				limit = {
					distance = {
						source = root
						min_jumps = 1
						max_jumps = 6
					}
					OR = {
						NOT = { exists = space_owner }
						space_owner = {
							NOT = { is_same_value = root.owner }
							NOT = { has_closed_borders = root.owner }
							NOT = { is_at_war_with = root.owner }
						}
					}
					star = { NOT = { is_planet_class = pc_black_hole } }
				}
				save_event_target_as = star_crossed_survivor_system
				star = {
					save_event_target_as = star_crossed_survivor_star
				}
			}
		}
		create_ambient_object = {
			type = "star_crossed_survivor_pod_object"
			location = event_target:star_crossed_survivor_star
		}
		last_created_ambient_object = {
			save_event_target_as = star_crossed_survivor_pod
			set_location = {
				target = event_target:star_crossed_survivor_star
				distance = 100
				angle = random
			}
		}
	}

	option = {
		name = arkship.1390.a
		event_target:star_crossed_survivor_pod = {
			enable_special_project = {
				name = "STAR_CROSSED_SURVIVOR_POD_PROJECT"
				location = this
				owner = root.owner
			}
		}
		hidden_effect = {
			owner = {
				create_point_of_interest = {
					id = star_crossed_survivor_pod_poi
					name = "star_crossed_survivor_pod_poi"
					desc = "star_crossed_survivor_pod_poi_desc"
					event_chain = star_crossed_lovers_chain
					location = event_target:star_crossed_survivor_system
				}
			}
		}
	}

	option = {
		name = arkship.1390.b
		owner = {
			hidden_effect = {
				country_event = {
					id = arkship.1
					days = @medium_arkship_event_delay_days
					random = @very_short_arkship_event_delay_random
				}
				end_event_chain = star_crossed_lovers_chain
			}
		}
	}
}

carrier_event = { # Last Survivor
	id = arkship.1395
	title = "arkship.1395.name"
	desc = "arkship.1395.desc"
	picture = GFX_evt_nomad_default
	show_sound = event_life_on_the_arkship
	location = ROOT
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes

	immediate = {
		owner = {
			create_species = {
				name = random
				class = random
				portrait = random
				namelist = random_class
				effect = {
					save_event_target_as = star_crossed_survivor_species
				}
			}
			create_leader = {
				class = official
				name = random
				species = event_target:star_crossed_survivor_species
				skill = 2
				event_leader = yes
				hide_leader = yes
			}
			last_created_leader = {
				save_global_event_target_as = star_crossed_survivor
			}
		}
	}

	option = {
		name = arkship.1395.a
		hidden_effect = {
			owner = {
				random_list = {
					3 = { country_event = { id = arkship.1400 days = @extremely_short_arkship_event_delay_days random = 60 } }
					3 = {
						modifier = {
							factor = 0
							NOT = {
								any_country = {
									is_country_type = default
									NOT = { is_same_value = prev }
									has_communications = prev
								}
							}
						}
						country_event = { id = arkship.1405 days = @extremely_short_arkship_event_delay_days random = 60 }
					}
					2 = { country_event = { id = arkship.1410 days = @extremely_short_arkship_event_delay_days random = 60 } }
					3 = { country_event = { id = arkship.1415 days = @extremely_short_arkship_event_delay_days random = 60 } }
					2 = { country_event = { id = arkship.1420 days = @extremely_short_arkship_event_delay_days random = 60 } }
					3 = {
						modifier = {
							factor = 0
							NOT = {
								any_country = {
									is_fallen_empire = yes
									has_communications = prev
								}
							}
						}
						country_event = { id = arkship.1425 days = @extremely_short_arkship_event_delay_days random = 60 }
					}
					3 = { country_event = { id = arkship.1430 days = @extremely_short_arkship_event_delay_days random = 60 } }
					1 = { country_event = { id = arkship.1435 days = @extremely_short_arkship_event_delay_days random = 60 } }
				}
			}
		}
	}
}

country_event = { # The Massacre
	id = arkship.1400
	title = "arkship.1400.name"
	desc = "arkship.1400.desc"
	picture = GFX_evt_crisis_declared
	show_sound = event_ship_thrusters
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1400.a
		add_monthly_resource_mult = {
			resource = society_research
			value = @tier2researchreward
			min = @tier2researchmin
			max = @tier2researchmax
		}
		hidden_effect = {
			country_event = { id = arkship.1440 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}
}

country_event = { # A Bloody War
	id = arkship.1405
	title = "arkship.1405.name"
	desc = "arkship.1405.desc"
	picture = GFX_evt_fleet_from_surface
	show_sound = event_ship_thrusters
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes

	immediate = {
		random_country = {
			limit = {
				is_country_type = default
				NOT = { is_same_value = prev }
				has_communications = prev
			}
			save_global_event_target_as = star_crossed_empire
		}
	}

	option = {
		name = arkship.1400.a
		add_monthly_resource_mult = {
			resource = physics_research
			value = @tier2researchreward
			min = @tier2researchmin
			max = @tier2researchmax
		}
		hidden_effect = {
			country_event = { id = arkship.1440 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
}

country_event = { # A Dangerous Find
	id = arkship.1410
	title = "arkship.1410.name"
	desc = "arkship.1410.desc"
	picture = GFX_evt_timeworm_transcriptions
	show_sound = event_ship_thrusters
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes


	option = {
		name = arkship.1400.a
		add_tech_option_or_research_effect = {
			TECH = tech_synthetic_thought_patterns
			PROGRESS = 0.25
			CATEGORY = society_research
		}
		hidden_effect = {
			country_event = { id = arkship.1440 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}
}

country_event = { # Ambition
	id = arkship.1415
	title = "arkship.1415.name"
	desc = "arkship.1415.desc"
	picture = GFX_evt_glacial_tomb
	show_sound = event_ship_thrusters
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes


	option = {
		name = arkship.1400.a
		add_monthly_resource_mult = {
			resource = society_research
			value = @tier2researchreward
			min = @tier2researchmin
			max = @tier2researchmax
		}
		hidden_effect = {
			country_event = { id = arkship.1440 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}
}

country_event = { # A Pest
	id = arkship.1420
	title = "arkship.1420.name"
	desc = "arkship.1420.desc"
	picture = GFX_evt_disease_outbreak
	show_sound = event_ship_thrusters
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes


	option = {
		name = arkship.1400.a
		add_tech_option_or_research_effect = {
			TECH = tech_gene_tailoring
			PROGRESS = 0.25
			CATEGORY = society_research
		}
		hidden_effect = {
			country_event = { id = arkship.1440 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
}

# The Hidden Deal
country_event = {
	id = arkship.1425
	title = "arkship.1425.name"
	desc = "arkship.1425.desc"
	picture = GFX_evt_dark_alley
	show_sound = event_ship_thrusters
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes

	immediate = {
		random_country = {
			limit = {
				is_fallen_empire = yes
				has_communications = prev
			}
			save_global_event_target_as = star_crossed_empire
		}
	}

	option = {
		name = arkship.1400.a
		add_monthly_resource_mult = {
			resource = society_research
			value = @tier2researchreward
			min = @tier2researchmin
			max = @tier2researchmax
		}
		hidden_effect = {
			country_event = { id = arkship.1440 days = @extremely_short_arkship_event_delay_days random = 60 }
		}
	}
}

# Forbidden Union
country_event = {
	id = arkship.1430
	title = "arkship.1430.name"
	desc = "arkship.1430.desc"
	picture = GFX_evt_happy_reunion
	show_sound = event_life_on_the_arkship
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes

	immediate = {
		random_country = {
			limit = {
				is_country_type = default
				NOT = { is_same_value = prev }
				has_communications = prev
			}
			save_global_event_target_as = star_crossed_empire
		}
	}

	option = {
		name = arkship.1400.a
		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}
		hidden_effect = {
			country_event = { id = arkship.1440 days = @extremely_short_arkship_event_delay_days random = 90 }
		}
	}
}

# Whispers in the Void
country_event = {
	id = arkship.1435
	title = "arkship.1435.name"
	desc = "arkship.1435.desc"
	picture = GFX_evt_shroud_generic
	show_sound = event_ship_thrusters
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes


	option = {
		name = arkship.1400.a
		add_tech_option_or_research_effect = {
			TECH = tech_psionic_theory
			PROGRESS = 0.25
			CATEGORY = society_research
		}
		hidden_effect = {
			country_event = { id = arkship.1440 days = @extremely_short_arkship_event_delay_days random = 30 }
		}
	}
}

# Final Words
country_event = {
	id = arkship.1440
	title = "arkship.1440.name"
	desc = "arkship.1440.desc"
	picture = GFX_evt_space_funeral
	show_sound = event_ship_thrusters
	event_chain = star_crossed_lovers_chain
	trackable = yes

	is_triggered_only = yes

	option = {
		name = arkship.1440.a
		if = {
			limit = { exists = event_target:star_crossed_empire }
			custom_tooltip = arkship.1440.a.tooltip
			add_intel = {
				who = event_target:star_crossed_empire
				amount = 20
			}
		}
	}

	after = {
		hidden_effect = {
			country_event = {
				id = arkship.1
				days = @medium_arkship_event_delay_days
				random = @very_short_arkship_event_delay_random
			}
			end_event_chain = star_crossed_lovers_chain
		}
		hidden_effect = {
			if = {
				limit = { exists = event_target:star_crossed_survivor }
				event_target:star_crossed_survivor = {
					kill_leader = { show_notification = no }
				}
				clear_global_event_target = star_crossed_survivor
			}
			if = {
				limit = { exists = event_target:star_crossed_empire }
				clear_global_event_target = star_crossed_empire
			}
		}
	}
}

# Arkships do not stay MIA - they return immediately.
# Fired from on_fleet_went_mia.
fleet_event = {
	id = arkship.1445
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_arkship_fleet = yes
	}

	immediate = {
		return_from_mia = this
	}
}
