##############################################################
#
# Tutorial Events
# Written by Henrik Thyrwall, Niclas Karlsson, Gemma Thomson & Victor Haeggman
#
##############################################################

namespace = tutorial

### TUTORIAL 1: ZOOM OUT MAP

# Start
country_event = {
	id = tutorial.1
	title = tutorial.1.name
	desc = tutorial.1.desc
	#show_sound = tut_survey_intro - Commented out for 4.0 until new VIR recordings are in place -> AUG-51943

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_survey_system_chain
			has_country_flag = waiting_tutorial_4
			has_country_flag = tutorial_survey_system_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		capital_scope = {
			solar_system = { save_event_target_as = home_system }
		}
		set_country_flag = tutorial_survey_system_chain
		begin_event_chain = {
			event_chain = "tutorial_survey_system_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_survey_system_tooltip
		if = {
			limit = {
				NOT = { has_country_flag = hyperspace_tutorial_triggered }
			}
			hidden_effect = {
				set_country_flag = hyperspace_tutorial_triggered
				country_event = { id = tutorial.71 days = 10 }
			}
		}
	}
}

# Cleared when tutorial is off
ship_event = {
	id = tutorial.299
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_ai = no
			NOR = {
				has_country_flag = waiting_tutorial_4
				has_country_flag = tutorial_1
				has_country_flag = tutorial_2
			}
			FROM = {
				solar_system = {
					any_system_planet = {
						is_capital = yes
						is_owned_by = PREVPREVPREV
					}
				}
			}
		}
	}

	immediate = {
		owner = {
			country_event = { id = tutorial.17 days = 20 }
			set_country_flag = waiting_tutorial_4 #Moved here due to construction ship tutorial removed
		}
	}
}

# Finished Survey System
ship_event = {
	id = tutorial.2
	title = tutorial.2.name
	desc = tutorial.2.desc
	show_sound = tut_survey_success

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			is_ai = no
			has_country_flag = tutorial_1
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 010_surveyed_system
			remove_country_flag = tutorial_1
			end_event_chain = "tutorial_1_chain"
			set_country_flag = waiting_tutorial_4 #Moved here due to construction ship tutorial removed
		}
	}

	option = {
		name = UNDERSTOOD
		hidden_effect = {
			owner = {
				country_event = { id = tutorial.17 days = 20 }
			}
		}
	}
}

### TUTORIAL 2: RESEARCH TECHNOLOGIES

# Triggering Event (HIDDEN)
country_event = {
	id = tutorial.501
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		any_controlled_ship = {
			has_fleet_order = survey_planet_order
		}
		is_tutorial_level = 2
		has_country_flag = tutorial_1
		NOR = {
			has_country_flag = tutorial_2
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		set_country_flag = tutorial_2
		country_event = { id = tutorial.3 days = 25 }
		country_event = { id = tutorial.300 days = 25 }
		country_event = { id = tutorial.13 days = 150 }
	}
}

# Triggering Event from on-action (HIDDEN)
ship_event = {
	id = tutorial.500
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		has_fleet_order = survey_planet_order
		owner = {
			is_tutorial_level = 2
			has_country_flag = tutorial_1
			NOT = { has_country_flag = tutorial_2 }
		}
	}

	immediate = {
		owner = {
			set_country_flag = tutorial_2
			country_event = { id = tutorial.5 }
			country_event = { id = tutorial.3 days = 25 }
			country_event = { id = tutorial.300 days = 25 }
			country_event = { id = tutorial.13 days = 150 }
		}
	}
}

# Start
country_event = {
	id = tutorial.3
	title = tutorial.3.name
	desc = tutorial.3.desc
	show_sound = tut_technologies_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_2_chain
			has_technology = tech_colonization_1
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_2_chain"
			target = ROOT
		}
		country_event = { id = tutorial.7 days = 21 }
		country_event = { id = tutorial.700 days = 21 } #Backup to set flags if finished early
	}

	option = {
		name = SITLOG
		custom_tooltip = tutorial_2_tooltip
		hidden_effect = {
			if = {
				limit = {
					has_technology = tech_colonization_1
				}
				country_event = { id = tutorial.6 }
			}
		}
	}
}

# Clear Early
country_event = {
	id = tutorial.300
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_technology = tech_colonization_1
		is_tutorial_level = 2
		not = {
			has_country_flag = tutorial_2
		}
	}

	immediate = {
		#country_event = { id = tutorial.7 days = 21 } #Moved to earlier due to research taking so long
		#country_event = { id = tutorial.700 days = 21 } #Backup to set flags if finished early
	}
}

# Select Science Ship
country_event = {
	id = tutorial.4
	title = tutorial.4.name
	desc = tutorial.4.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_science_ship_symbol

	trigger = {
		is_nomadic = no
		is_tutorial_level = 2
		NOT = {
			has_country_flag = tutorial_1
		}
	}

	immediate = {
		capital_scope = {
			solar_system = { save_event_target_as = home_system }
		}
		remove_country_flag = tutorial_survey_system_chain
		end_event_chain = "tutorial_survey_system_chain"
		set_country_flag = tutorial_1
		begin_event_chain = {
			event_chain = "tutorial_1_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_1_tooltip
		if = {
			limit = {
				NOT = { has_country_flag = hyperspace_tutorial_triggered }
			}
			hidden_effect = {
				set_country_flag = hyperspace_tutorial_triggered
				country_event = { id = tutorial.71 days = 10 }
			}
		}
	}
}

# A ship has started a new order
# Root = Ship
# From = Country
# Science Ship Queued - Unpause Game
country_event = {
	id = tutorial.5
	title = tutorial.5.name
	desc = tutorial.5.desc
	is_advisor_event = yes
	show_sound = tut_msg_unpause_galaxy_map

	is_triggered_only = yes

	trigger = {
		is_paused = yes
		is_tutorial_level = 2
		NOT = {
			has_country_flag = tutorial_unpause
		}
	}

	immediate = {
		set_country_flag = tutorial_unpause
		begin_event_chain = {
			event_chain = "tutorial_unpause_chain"
			target = ROOT
		}
		hidden_effect = {
			country_event = { id = tutorial.503 days = 1 }
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_unpause_chain_tooltip
	}
}

# Fired a day after the unpause tutorial so it can only happen if the player has unpaused
country_event = {
	id = tutorial.503
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		end_event_chain = "tutorial_unpause_chain"
	}
}

# Finished
country_event = {
	id = tutorial.6
	title = tutorial.6.name
	desc = tutorial.6.desc
	show_sound = tut_technologies_success

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		has_technology = tech_colonization_1
		has_event_chain = "tutorial_2_chain"
	}


	immediate = {
		complete_tutorial_step = 030_researched_tech
		end_event_chain = "tutorial_2_chain"
		remove_country_flag = tech_1_researched
		remove_country_flag = tech_2_researched
		remove_country_flag = tutorial_2
	}

	option = {
		name = "OK"
		hidden_effect = {
			#country_event = { id = tutorial.7 days = 10 } #Moved to earlier due to research taking so long
			#country_event = { id = tutorial.700 days = 10 } #Backup to set flags if finished early
		}
	}
}

### TUTORIAL: BUILD CONSTRUCTION SHIP

# Start
country_event = {
	id = tutorial.7
	title = tutorial.7.name
	desc = tutorial.7.desc
	show_sound = tut_construction_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		count_controlled_ship = {
			limit = { is_ship_class = shipclass_constructor }
			count < 1
		}
		NOR = {
			has_event_chain = tutorial_3_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_3_chain"
			target = ROOT
		}
	}

	option = {
		name = SITLOG
		custom_tooltip = tutorial_3_tooltip
	}
}

# Cleared early
country_event = {
	id = tutorial.700
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		count_controlled_ship = {
			limit = { is_ship_class = shipclass_constructor }
			count > 0
		}
	}

	immediate = {
		complete_tutorial_step = 040_built_construction_ship
		set_country_flag = waiting_tutorial_4
	}
}

# Finished
ship_event = {
	id = tutorial.8
	title = tutorial.8.name
	desc = tutorial.8.desc
	show_sound = tut_construction_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_ship_size = constructor
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_3_chain"
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 040_built_construction_ship
			end_event_chain = "tutorial_3_chain"
		}
	}

	option = {
		name = "OK"
		hidden_effect = {
			owner = { set_country_flag = waiting_tutorial_4 }
		}
	}
}

### TUTORIAL: BUILD MINING STATION

# Start
country_event = {
	id = tutorial.9
	title = tutorial.9.name
	desc = tutorial.9.desc
	show_sound = tut_construction_intro

	is_advisor_event = yes

	trigger = {
		is_ai = no
		is_tutorial_level = 2
		OR = {
			has_country_flag = waiting_tutorial_4
			has_country_flag = tutorial_76_completed
		}

		NOR = {
			has_country_flag = waiting_tutorial_5
			#any_controlled_ship = { is_ship_size = mining_station }
			has_event_chain = tutorial_4_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
		capital_scope = {
			solar_system = {
				closest_system = {
					max_steps = 10
					limit = {
						owner = {
							is_same_value = root
						}
						any_system_planet = {
							is_capital = no
							is_surveyed = { who = ROOT status = yes }
							OR = {
								has_resource = {
									type = minerals
									amount > 0
								}
								has_resource = {
									type = energy
									amount > 0
								}
							}
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 10
	}

	immediate = {
		remove_country_flag = waiting_tutorial_4
		set_country_flag = waiting_tutorial_5
		begin_event_chain = {
			event_chain = "tutorial_4_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_4_tooltip
	}
}

# Cleared early
ship_event = {
	id = tutorial.1000
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			NOT = {
				has_event_chain = "tutorial_4_chain"
				#has_country_flag = "waiting_tutorial_4"
				#has_country_flag = "waiting_tutorial_5"
			}
		}
	}

	immediate = {
		owner = {
			remove_country_flag = waiting_tutorial_4
			set_country_flag = waiting_tutorial_5
		}
	}
}

# Finished
ship_event = {
	id = tutorial.10
	title = tutorial.10.name
	desc = tutorial.10.desc
	show_sound = tut_mining_station_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_4_chain"
			#any_controlled_ship = { is_ship_size = mining_station }
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 050_built_mining_station
			end_event_chain = "tutorial_4_chain"
		}
	}

	option = {
		name = UNDERSTOOD
	}
}


### TUTORIAL: BUILD RESEARCH STATION

# Start
country_event = {
	id = tutorial.11
	title = tutorial.11.name
	desc = tutorial.11.desc
	show_sound = tut_research_station_intro

	is_advisor_event = yes

	trigger = {
		is_ai = no
		is_tutorial_level = 2
		has_country_flag = waiting_tutorial_5
		NOR = {
			any_controlled_ship = {is_ship_size = research_station }
			has_event_chain = tutorial_5_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
		capital_scope = {
			solar_system = {
				closest_system = {
					max_steps = 10
					limit = {
						any_system_planet = {
							is_capital = no
							is_surveyed = { who = ROOT status = yes }
							OR = {
								has_resource = {
									type = society_research
									amount > 0
								}
								has_resource = {
									type = physics_research
									amount > 0
								}
								has_resource = {
									type = engineering_research
									amount > 0
								}
							}
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 10
	}

	immediate = {
		remove_country_flag = waiting_tutorial_5
		begin_event_chain = {
			event_chain = "tutorial_5_chain"
			target = ROOT
		}
	}

	option = {
		name = SITLOG
		custom_tooltip = tutorial_5_tooltip
	}
}

# Cleared early
ship_event = {
	id = tutorial.1200
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			NOR = {
				has_event_chain = "tutorial_5_chain"
				has_country_flag = "waiting_tutorial_5"
			}
		}
	}

	immediate = {
		owner = {
			remove_country_flag = waiting_tutorial_5
			country_event = { id = tutorial.39 days = 25 }
		}
	}
}

# Finished
ship_event = {
	id = tutorial.12
	title = tutorial.12.name
	desc = tutorial.12.desc
	show_sound = tut_research_station_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_5_chain"
			#any_controlled_ship = { is_ship_size = research_station } #removed cause otherwise you need to build 2 before this is triggered
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 060_built_research_station
			end_event_chain = "tutorial_5_chain"
		}
	}

	option = {
		name = "OK"
		hidden_effect = {
			owner = { country_event = { id = tutorial.39 days = 25 } }
		}
	}
}

### TUTORIAL: CONSTRUCT PLANETARY BUILDING

# Start
country_event = {
	id = tutorial.13
	title = tutorial.13.name
	desc = tutorial.13.desc
	#show_sound = tut_planetary_buildings_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_6_chain
			has_country_flag = tutorial_cleared_early_14
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_6_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_6_tooltip
	}
}

# Cleared Early
carrier_event = {
	id = tutorial.140
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			NOT = { has_country_flag = tutorial_cleared_early_14 }
		}
	}

	immediate = {
		owner = {
			set_country_flag = tutorial_cleared_early_14
			country_event = { id = tutorial.15 days = 10 }
		}
	}
}

# Planetary Building Constructed
carrier_event = {
	id = tutorial.14
	title = tutorial.14.name
	desc = tutorial.14.desc
	show_sound = tut_planetary_buildings_success

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_6_chain"
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 070_built_planet_building
			end_event_chain = "tutorial_6_chain"
		}
	}

	option = {
		name = UNDERSTOOD
		hidden_effect = {
			owner = {
				country_event = { id = tutorial.15 days = 10 }
			}
		}
	}
}

### TUTORIAL: CLEAR TILE BLOCKER

# Start
country_event = {
	id = tutorial.15
	title = tutorial.15.name
	desc = tutorial.15.desc
	#show_sound = tut_tile_blockers_intro - Commented out for 4.0 until new VIR recordings are in place -> AUG-51943

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_country_flag = tutorial_cleared_early_16
			has_event_chain = tutorial_7_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_7_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_7_tooltip
	}
}

# Finished
carrier_event = {
	id = tutorial.160
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			NOT = { has_country_flag = tutorial_cleared_early_16 }
		}
	}

	immediate = {
		owner = { set_country_flag = tutorial_cleared_early_16 }
	}
}

# Finished
carrier_event = {
	id = tutorial.16
	title = tutorial.16.name
	desc = tutorial.16.desc
	#show_sound = tut_tile_blockers_success - Commented out for 4.0 until new VIR recordings are in place -> AUG-51943

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_7_chain"
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 080_cleared_planetary_blocker
			end_event_chain = "tutorial_7_chain"
		}
	}

	option = {
		name = UNDERSTOOD
	}
}

### TUTORIAL: SURVEY NEIGHBORING SYSTEMS

# Start
country_event = {
	id = tutorial.17
	title = tutorial.17.name
	desc = tutorial.17.desc
	show_sound = tut_suvey_systems_intro
	# should fix typos in asset

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_8_chain
			has_country_flag = tutorial_cleared_early_17
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_8_chain"
			target = ROOT
		}
		capital_scope = {
			solar_system = {
				set_star_flag = home_system
				closest_system = {
					limit = {
						NOT = { has_star_flag = home_system }
					}
					set_star_flag = survey_target_1
					save_event_target_as = survey_target_1
				}
				closest_system = {
					limit = {
						NOR = {
							has_star_flag = home_system
							has_star_flag = survey_target_1
						}
					}
					set_star_flag = survey_target_2
					save_event_target_as = survey_target_2
				}
				closest_system = {
					limit = {
						NOR = {
							has_star_flag = home_system
							has_star_flag = survey_target_1
							has_star_flag = survey_target_2
						}
					}
					set_star_flag = survey_target_3
					save_event_target_as = survey_target_3
				}
			}
		}
		create_point_of_interest = {
			id = tutorial_8_poi.1
			name = "tutorial_8_poi"
			desc = tutorial_8_poi_desc
			event_chain = tutorial_8_chain
			category = tutorial_8_cat
			location = event_target:survey_target_1
		}
		create_point_of_interest = {
			id = tutorial_8_poi.2
			name = "tutorial_8_poi"
			desc = tutorial_8_poi_desc
			event_chain = "tutorial_8_chain"
			category = tutorial_8_cat
			location = event_target:survey_target_2
		}
		create_point_of_interest = {
			id = tutorial_8_poi.3
			name = "tutorial_8_poi"
			desc = tutorial_8_poi_desc
			event_chain = "tutorial_8_chain"
			category = tutorial_8_cat
			location = event_target:survey_target_3
		}
	}

	option = {
		name = SITLOG
		custom_tooltip = tutorial_8_tooltip
		hidden_effect = {
			set_country_flag = waiting_tutorial_11
			country_event = { id = tutorial.20 days = 75 }
			country_event = { id = tutorial.200 days = 10 } #Backup for flags if you finish the quest early
			country_event = { id = tutorial.33 days = 120 }
			country_event = { id = tutorial.330 days = 120 }
		}
	}
}

# Cleared Early
ship_event = {
	id = tutorial.170
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			NOR = {
				has_country_flag = tutorial_cleared_early_17
				has_event_chain = tutorial_8_chain
				has_ethic = ethic_gestalt_consciousness
				is_nomadic = yes
			}
			FROM = {
				solar_system = {
					NOT = {
						any_system_planet = {
							is_capital = yes
							is_owned_by = PREVPREVPREV
						}
					}
				}
			}
		}
	}

	immediate = {
		owner = {
			save_event_target_as = ShipOwner
			capital_scope = {
				solar_system = {
					random_system_planet = {
						limit = {
							is_homeworld = yes
						}
						save_event_target_as = HomeSystem
					}
				}
			}
		}
		if = {
			limit = {
				any_system = {
					NOT = { is_same_value = event_target:HomeSystem }
					is_surveyed = {
						who = event_target:ShipOwner
						status = yes
					}
				}
			}
			owner = {
				set_country_flag = tutorial_cleared_early_17
				country_event = { id = tutorial.20 days = 75 }
				country_event = { id = tutorial.200 days = 10 } #Backup for flags
				country_event = { id = tutorial.33 days = 120 }
				country_event = { id = tutorial.330 days = 120 }
				#country_event = { id = tutorial.24 days = 20 }
				country_event = { id = tutorial.240 days = 20 } #Backup to set flags if finished early
				country_event = { id = tutorial.75 days = 40 }
			}
		}
	}
}

# System Surveyed
country_event = {
	id = tutorial.18
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_8_chain"
		FROM = {
			OR = {
				has_star_flag = survey_target_1
				has_star_flag = survey_target_2
				has_star_flag = survey_target_3
			}
		}
	}

	immediate = {
		if = {
			limit = {
				FROM = { has_star_flag = survey_target_1 }
			}
			FROM = { remove_star_flag = survey_target_1 }
			remove_point_of_interest = tutorial_8_poi.1
		}
		if = {
			limit = {
				FROM = { has_star_flag = survey_target_2 }
			}
			FROM = { remove_star_flag = survey_target_2 }
			remove_point_of_interest = tutorial_8_poi.2
		}
		if = {
			limit = {
				FROM = { has_star_flag = survey_target_3 }
			}
			FROM = { remove_star_flag = survey_target_3 }
			remove_point_of_interest = tutorial_8_poi.3
		}
		add_event_chain_counter = {
			event_chain = "tutorial_8_chain"
			counter = "systems_surveyed"
			amount = 1
		}
		country_event = { id = tutorial.19 }
	}
}

# Finished
country_event = {
	id = tutorial.19
	title = tutorial.19.name
	desc = tutorial.19.desc
	show_sound = tut_survey_system_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_8_chain"
		has_completed_event_chain_counter = {
			event_chain = "tutorial_8_chain"
			counter = "systems_surveyed"
		}
	}

	immediate = {
		capital_scope = {
			solar_system = {
				remove_star_flag = home_system
			}
		}
		end_event_chain = "tutorial_8_chain"
		complete_tutorial_step = 090_surveyed_more_systems
	}

	option = {
		name = "OK"
		hidden_effect = {
			#country_event = { id = tutorial.24 days = 20 }
			country_event = { id = tutorial.240 days = 20 } #Backup to set flags if finished early
			country_event = { id = tutorial.75 days = 40 }
		}
	}
}

### TUTORIAL: BUILD SECOND SCIENCE SHIP

# Start
country_event = {
	id = tutorial.20
	title = tutorial.20.name
	desc = tutorial.20.desc
	show_sound = tut_science_ship_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_9_chain
			count_controlled_ship = {
				limit = { is_ship_class = shipclass_science_ship }
				count > 1
			}
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_9_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_9_tooltip
	}
}

# Finished before triggered
country_event = {
	id = tutorial.200
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		count_controlled_ship = {
			limit = { is_ship_class = shipclass_science_ship }
			count > 1
		}
	}

	immediate = {
		country_event = { id = tutorial.22 }
	}
}

# Finished. Survey Automation
ship_event = {
	id = tutorial.21
	title = tutorial.21.name
	desc = tutorial.21.desc
	show_sound = tut_science_ship_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_ship_class = shipclass_science_ship
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_9_chain"
			count_controlled_ship = {
				limit = { is_ship_class = shipclass_science_ship }
				count > 1
			}
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 100_built_science_ship
			end_event_chain = "tutorial_9_chain"
		}
	}

	option = {
		name = UNDERSTOOD
		hidden_effect = {
			owner = { country_event = { id = tutorial.22 } }
		}
	}
}

### TUTORIAL: RECRUIT SCIENTIST

# Start
country_event = {
	id = tutorial.22
	title = tutorial.22.name
	desc = tutorial.22.desc
	show_sound = tut_recruit_scientist_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		any_controlled_ship = {
			is_ship_class = shipclass_science_ship
			NOT = { exists = leader }
		}
		NOR = {
			has_event_chain = tutorial_10_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_10_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_10_tooltip
		hidden_effect = {
			country_event = { id = tutorial.48 days = 250 }
		}
	}
}

# Finished
country_event = {
	id = tutorial.23
	title = tutorial.23.name
	desc = tutorial.23.desc
	show_sound = tut_recruit_scientist_success

	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_10_chain"
		count_controlled_ship = {
			limit = {
				is_ship_class = shipclass_science_ship
				exists = leader
			}
			count > 1
		}
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		complete_tutorial_step = 110_recruited_scientist
		end_event_chain = "tutorial_10_chain"
	}

	option = {
		name = UNDERSTOOD
	}
}

### TUTORIAL: BUILD COLONY SHIP

# Start
country_event = {
	id = tutorial.24
	title = tutorial.24.name
	desc = tutorial.24.desc
	show_sound = tut_build_colony_ship_intro

	is_advisor_event = yes
	#is_triggered_only = yes

	trigger = {
		is_ai = no
		is_tutorial_level = 2
		has_technology = tech_colonization_1
		count_controlled_ship = {
			limit = { is_ship_class = shipclass_colonizer }
			count < 1
		}
		NOR = {
			has_event_chain = tutorial_11_chain
			any_owned_planet = {
				is_capital = no
			}
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
		any_planet_within_border = {
			is_ideal_planet_class = {
				who = root
				status = yes
			}
			is_colony = no
		}
	}

	mean_time_to_happen = {
		months = 1
	}

	immediate = {
		remove_country_flag = waiting_tutorial_11
		begin_event_chain = {
			event_chain = "tutorial_11_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_11_tooltip
	}
}

# Cleared early
country_event = {
	id = tutorial.240
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		OR = {
			count_controlled_ship = {
				limit = { is_ship_class = shipclass_colonizer }
				count > 0
			}
			any_owned_planet = {
				is_capital = no
			}
		}
	}

	immediate = {
		country_event = { id = tutorial.26 days = 10 }
		country_event = { id = tutorial.260 days = 10 } #Backup to set flags if cleared early
	}
}

# Finished
ship_event = {
	id = tutorial.25
	title = tutorial.25.name
	desc = tutorial.25.desc
	show_sound = tut_colony_ship_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_ship_class = shipclass_colonizer
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_11_chain"
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 120_built_colony_ship
			end_event_chain = "tutorial_11_chain"
		}
	}

	option = {
		name = UNDERSTOOD
		hidden_effect = {
			owner = {
				country_event = { id = tutorial.260 days = 10 } #Backup to set flags if cleared early}
			}
		}
	}
}

### TUTORIAL: ESTABLISH COLONY

# Start
country_event = {
	id = tutorial.26
	title = tutorial.26.name
	desc = tutorial.26.desc
	show_sound = tut_establish_colony_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		has_technology = tech_colonization_1
		NOR = {
			has_event_chain = tutorial_12_chain
			any_owned_planet = {
				is_capital = no
			}
			count_controlled_ship = {
				limit = { is_ship_class = shipclass_colonizer }
				count < 1
			}
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_12_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_12_tooltip
	}
}

# cleared early
country_event = {
	id = tutorial.260
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		any_owned_planet = {
			is_capital = no
		}
	}

	immediate = {
		#country_event = { id = tutorial.28 days = 10 }
	}
}

# Finished
carrier_event = {
	id = tutorial.27
	title = tutorial.27.name
	desc = tutorial.27.desc
	show_sound = tut_establish_colony_success

	is_advisor_event = yes
	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
	}

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_12_chain"
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 130_established_colony
			end_event_chain = "tutorial_12_chain"
		}
	}

	option = {
		name = "OK"
		hidden_effect = {
			owner = {
				#country_event = { id = tutorial.28 days = 10 }
			}
		}
	}
}

### TUTORIAL: RECRUIT GOVERNOR

# Start
#country_event = {
#	id = tutorial.28
#	title = tutorial.28.name
#	desc = tutorial.28.desc
#	show_sound = tut_recruit_governor_intro
#
#	is_advisor_event = yes
#	is_triggered_only = yes
#
#	trigger = {
#		is_tutorial_level = 2
#		any_owned_planet = {
#			is_capital = no
#			NOT = { exists = leader }
#		}
#		NOR = {
#			has_event_chain = tutorial_13_chain
#			has_ethic = ethic_gestalt_consciousness
#		}
#	}
#
#	immediate = {
#		begin_event_chain = {
#			event_chain = "tutorial_13_chain"
#			target = ROOT
#		}
#	}
#
#	option = {
#		name = SITLOG
#		custom_tooltip = tutorial_13_tooltip
#	}
#}
#
## Finished
#country_event = {
#	id = tutorial.29
#	title = tutorial.29.name
#	desc = tutorial.29.desc
#	show_sound = tut_recruit_governor_success
#
#	is_advisor_event = yes
#
#	trigger = {
#		is_tutorial_level = 2
#		has_event_chain = "tutorial_13_chain"
#		any_owned_planet = {
#			is_capital = no
#			exists = leader
#		}
#	}
#
#	mean_time_to_happen = {
#		days = 1
#	}
#
#	immediate = {
#		end_event_chain = "tutorial_13_chain"
#	}
#
#	option = {
#		name = "OK"
#		hidden_effect = {
#			#country_event = { id = tutorial.30 days = 30 }
#		}
#	}
#}

#### TUTORIAL: ESTABLISH FOUR COLONIES
#
## Start
#country_event = {
#	id = tutorial.30
#	title = tutorial.30.name
#	desc = tutorial.30.desc
#	show_sound = tut_more_colonies_intro
#
#	is_advisor_event = yes
#	is_triggered_only = yes
#
#	immediate = {
#		begin_event_chain = {
#			event_chain = "tutorial_14_chain"
#			target = ROOT
#		}
#		add_event_chain_counter = {
#			event_chain = "tutorial_14_chain"
#			counter = "colonies_established"
#			amount = 1
#		}
#	}
#
#	option = {
#		name = SITLOG
#		custom_tooltip = tutorial_14_tooltip
#	}
#}
#
## Planet Colonized (HIDDEN)
#carrier_event = {
#	id = tutorial.31
#	hide_window = yes
#
#	is_triggered_only = yes
#
#	trigger = {
#		owner = {
#			has_event_chain = "tutorial_14_chain"
#		}
#	}
#
#	immediate = {
#		owner = {
#			add_event_chain_counter = {
#				event_chain = "tutorial_14_chain"
#				counter = "colonies_established"
#				amount = 1
#			}
#			country_event = { id = tutorial.32 }
#		}
#	}
#}
#
## Finished
#country_event = {
#	id = tutorial.32
#	title = tutorial.32.name
#	desc = tutorial.32.desc
#	show_sound = tut_more_colonies_success
#
#	is_triggered_only = yes
#	is_advisor_event = yes
#
#	trigger = {
#		has_event_chain = "tutorial_14_chain"
#		has_completed_event_chain_counter = {
#			event_chain = "tutorial_14_chain"
#			counter = "colonies_established"
#		}
#	}
#
#	immediate = {
#		end_event_chain = "tutorial_14_chain"
#	}
#
#	option = {
#		name = "OK"
#		hidden_effect = {
#			country_event = { id = tutorial.44 days = 5 }
#		}
#	}
#}

### TUTORIAL: RESOURCE PRODUCTION

# Start
country_event = {
	id = tutorial.33
	title = tutorial.33.name
	desc = tutorial.33.desc
	show_sound = tut_resources_production_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_15_chain
			has_monthly_income = { resource = energy value > 9 }
			has_monthly_income = { resource = minerals value > 29 }
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_15_chain"
			target = ROOT
		}
	}

	option = {
		name = SITLOG
		custom_tooltip = tutorial_15_tooltip
	}
}
# Cleared Early
country_event = {
	id = tutorial.330
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		has_monthly_income = { resource = energy value > 9 }
		has_monthly_income = { resource = minerals value > 29 }
	}

	#immediate = {
	#	country_event = { id = tutorial.39 days = 25 }
	#}
}

# Mineral Production Achieved (HIDDEN)
country_event = {
	id = tutorial.34
	hide_window = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_15_chain"
		NOT = { has_country_flag = tutorial_15_minerals_achieved }
		OR = {
			has_monthly_income = { resource = minerals value = 30 }
			has_monthly_income = { resource = minerals value > 30 }
		}
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		set_country_flag = tutorial_15_minerals_achieved
		add_event_chain_counter = {
			event_chain = "tutorial_15_chain"
			counter = "mineral_income"
			amount = 1
		}
		country_event = { id = tutorial.38 }
	}
}

# Mineral Production Lost (HIDDEN)
country_event = {
	id = tutorial.35
	hide_window = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_15_chain"
		has_country_flag = tutorial_15_minerals_achieved
		has_monthly_income = { resource = minerals value < 30 }
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		remove_country_flag = tutorial_15_minerals_achieved
		add_event_chain_counter = {
			event_chain = "tutorial_15_chain"
			counter = "mineral_income"
			amount = -1
		}
	}
}

# Credit Production Achieved (HIDDEN)
country_event = {
	id = tutorial.36
	hide_window = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_15_chain"
		NOT = { has_country_flag = tutorial_15_credits_achieved }
		OR = {
			has_monthly_income = { resource = energy value = 10 }
			has_monthly_income = { resource = energy value > 10 }
		}
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		set_country_flag = tutorial_15_credits_achieved
		add_event_chain_counter = {
			event_chain = "tutorial_15_chain"
			counter = "credit_income"
			amount = 1
		}
		country_event = { id = tutorial.38 }
	}
}

# Credit Production Lost (HIDDEN)
country_event = {
	id = tutorial.37
	hide_window = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_15_chain"
		has_country_flag = tutorial_15_credits_achieved
		has_monthly_income = { resource = energy value < 10 }
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		remove_country_flag = tutorial_15_credits_achieved
		add_event_chain_counter = {
			event_chain = "tutorial_15_chain"
			counter = "credit_income"
			amount = -1
		}
	}
}

# Finished
country_event = {
	id = tutorial.38
	title = tutorial.38.name
	desc = tutorial.38.desc
	show_sound = tut_resources_production_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_15_chain"
		has_completed_event_chain_counter = {
			event_chain = "tutorial_15_chain"
			counter = "mineral_income"
		}
		has_completed_event_chain_counter = {
			event_chain = "tutorial_15_chain"
			counter = "credit_income"
		}
	}

	immediate = {
		complete_tutorial_step = 140_producing_resources
		end_event_chain = "tutorial_15_chain"
	}

	option = {
		name = "OK"
		#hidden_effect = {
		#	country_event = { id = tutorial.39 days = 25 }
		#}
	}
}

### TUTORIAL: INCREASING THE FLEET

# Start
country_event = {
	id = tutorial.39
	title = tutorial.39.name
	desc = tutorial.39.desc
	show_sound = tut_increase_fleet_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		count_controlled_ship = {
			limit = { is_ship_size = corvette }
			count < 4
		}
		count_controlled_ship = {
			limit = { is_ship_size = destroyer }
			count < 1
		}
		NOR = {
			has_event_chain = tutorial_16_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_16_chain"
			target = ROOT
		}
	}

	option = {
		name = SITLOG
		custom_tooltip = tutorial_16_tooltip
	}
}

# Corvette Built (HIDDEN)
ship_event = {
	id = tutorial.40
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_16_chain"
			NOT = { has_country_flag = tutorial_16_corvettes_built }
		}
		is_ship_size = corvette
	}

	immediate = {
		owner = {
			add_event_chain_counter = {
				event_chain = "tutorial_16_chain"
				counter = "corvettes_built"
				amount = 1
			}
			country_event = { id = tutorial.41 }
		}
	}
}

# All Corvettes Built (HIDDEN)
country_event = {
	id = tutorial.41
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_16_chain"
		NOT = { has_country_flag = tutorial_16_corvettes_built }
		has_completed_event_chain_counter = {
			event_chain = "tutorial_16_chain"
			counter = "corvettes_built"
		}
	}

	immediate = {
		set_country_flag = tutorial_16_corvettes_built
	}
}

# Admiral Assigned (HIDDEN)
country_event = {
	id = tutorial.42
	hide_window = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_16_chain"
		NOT = { has_country_flag = tutorial_16_admiral_assigned }
		any_controlled_ship = {
			fleet = {
				exists = leader
				leader = {
					leader_class = commander
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		set_country_flag = tutorial_16_admiral_assigned
		add_event_chain_counter = {
			event_chain = "tutorial_16_chain"
			counter = "admiral_assigned"
			amount = 1
		}
	}
}

# Finished
country_event = {
	id = tutorial.43
	title = tutorial.43.name
	desc = tutorial.43.desc
	show_sound = tut_increase_fleet_success

	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_16_chain"
		has_completed_event_chain_counter = {
			event_chain = "tutorial_16_chain"
			counter = "corvettes_built"
		}
		has_completed_event_chain_counter = {
			event_chain = "tutorial_16_chain"
			counter = "admiral_assigned"
		}
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		complete_tutorial_step = 150_increased_navy
		end_event_chain = "tutorial_16_chain"
		remove_country_flag = tutorial_16_admiral_assigned
		remove_country_flag = tutorial_16_corvettes_built
	}

	option = {
		name = "OK"
	}
}

### TUTORIAL: ESTABLISH SECTOR

# Planet Colonized Counter (HIDDEN)
#carrier_event = {
#	id = tutorial.444
#	hide_window = yes
#	is_triggered_only = yes
#
#	pre_trigger = {
#		has_owner = yes
#	}
#
#	trigger = {
#		owner = {
#			is_tutorial_level = 2
#			check_variable = {
#				which = "num_colonies"
#				value < 3
#			}
#		}
#	}
#
#	immediate = {
#		owner = {
#			if = {
#				limit = {
#					check_variable = {
#						which = "num_colonies"
#						value > 0
#					}
#				}
#				change_variable = {
#					which = "num_colonies"
#					value = 1
#				}
#			}
#			else = {
#				set_variable = {
#					which = "num_colonies"
#					value = 1
#				}
#			}
#			if = {
#				limit = {
#					check_variable = {
#						which = "num_colonies"
#						value > 2
#					}
#				}
#				country_event = { id = tutorial.44 days = 5 }
#			}
#		}
#	}
#}
#
## Start
carrier_event = {
	id = tutorial.9000
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			num_sectors < 2
			NOR = {
				has_ethic = ethic_gestalt_consciousness
				is_nomadic = yes
			}
		}
		is_in_frontier_space = yes
	}

	immediate = {
		owner = { country_event = { id = tutorial.44 } }
	}


}
country_event = {
	id = tutorial.44
	title = tutorial.44.name
	desc = tutorial.44.desc

	# Disable sound for now until there is a new voice over
	#show_sound = tut_msg_CREATESECTOR

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		num_sectors < 2
		NOR = {
			#has_event_chain = tutorial_17_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
		any_owned_planet = {
			is_in_frontier_space = yes
		}
	}

	immediate = {
		set_country_flag = tut44_triggered
	}

	option = {
		name = OK
		#custom_tooltip = tutorial_17_tooltip
	}
}
#
## Finished
country_event = {
	id = tutorial.45
	title = tutorial.45.name
	desc = tutorial.45.desc
	show_sound = tut_establish_sector_success

	is_advisor_event = yes

	trigger = {
		is_nomadic = no
		is_tutorial_level = 2
		NOT = { has_country_flag = tut45_triggered }
		#has_event_chain = "tutorial_17_chain"
		num_sectors > 1
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		complete_tutorial_step = 160_established_sector
	#	end_event_chain = "tutorial_17_chain"
		set_country_flag = tut45_triggered
	}

	option = {
		name = "OK"
		hidden_effect = {
			country_event = { id = tutorial.46 days = 5 }
		}
	}
}
### TUTORIAL: SECTOR GOVERNOR

# Start

country_event = {
	id = tutorial.46
	title = tutorial.46.name
	desc = tutorial.46.desc
	show_sound = tut_sector_governor_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		always = no
		#is_tutorial_level = 2
		#any_owned_sector = {
		#	has_sector_type = normal_sector
		#	NOT = { exists = leader }
		#}
		#NOR = {
		#	has_event_chain = tutorial_18_chain
		#	has_ethic = ethic_gestalt_consciousness
		#}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_18_chain"
			target = ROOT
		}
	}

	option = {
		name = SITLOG
		custom_tooltip = tutorial_18_tooltip
	}
}

# Finished
country_event = {
	id = tutorial.47
	title = tutorial.47.name
	desc = tutorial.47.desc
	show_sound = tut_sector_governor_success

	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_18_chain"
		#any_owned_sector = {
		#	has_sector_type = normal_sector
		#	exists = leader
		#}
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		complete_tutorial_step = 170_assigned_governor
		end_event_chain = "tutorial_18_chain"
	}

	option = {
		name = "OK"
	}
}

### TUTORIAL: SHIP DESIGN

# Start
country_event = {
	id = tutorial.48
	title = tutorial.48.name
	desc = tutorial.48.desc
	show_sound = tut_ship_design_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_19_chain
			has_country_flag = tutorial_cleared_early_48
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_19_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_19_tooltip
	}
}

# Cleared Early
country_event = {
	id = tutorial.480
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = "tutorial_19_chain"
			has_country_flag = tutorial_cleared_early_48
		}
	}

	immediate = {
		set_country_flag = tutorial_cleared_early_48
	}
}

# Finished
country_event = {
	id = tutorial.49
	title = tutorial.49.name
	desc = tutorial.49.desc
	show_sound = tut_ship_design_success

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = "tutorial_19_chain"
	}

	immediate = {
		complete_tutorial_step = 180_designed_ship
		end_event_chain = "tutorial_19_chain"
	}

	option = {
		name = UNDERSTOOD
	}
}

### TUTORIAL: RESEARCH ANOMALY

ship_event = {
	id = tutorial.52
	title = tutorial.52.name
	desc = {
		trigger = {
			hidden:owner = {
				switch = {
					trigger = has_ethic
					ethic_spiritualist = { text = tutorial.52.spirit.desc }
					ethic_fanatic_spiritualist = { text = tutorial.52.spirit.desc }
					default = { text = tutorial.52.desc }
				}
			}
		}
	}
	picture = GFX_evt_star_chart
	show_sound = event_default
	location = from
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			NOR = {
				has_ethic = ethic_gestalt_consciousness
				is_nomadic = yes
			}
		}
	}

	immediate = {
		owner = { complete_tutorial_step = 200_researched_anomaly }
	}

	option = {
		name = tutorial.52.a
		trigger = {
			owner = {
				is_spiritualist = no
			}
		}
	}
	option = {
		name = tutorial.52.spirit.a
		trigger = {
			owner = {
				is_spiritualist = yes
			}
		}
	}
}
ship_event = {
#Story5
	id = tutorial.53
	title = tutorial.52.name
	desc = {
		trigger = {
			hidden:owner = {
				switch = {
					trigger = has_ethic
					ethic_xenophobe = { text = tutorial.53.xenophobe.desc }
					ethic_fanatic_xenophobe = { text = tutorial.53.xenophobe.desc }
					ethic_xenophile = { text = tutorial.53.xenophile.desc }
					ethic_fanatic_xenophile = { text = tutorial.53.xenophile.desc }
					default = { text = tutorial.53.desc }
				}
			}
		}
	}
	picture = GFX_evt_star_chart
	show_sound = event_default
	location = from
	is_triggered_only = yes

	trigger = {
		owner = { is_tutorial_level = 2 }
	}

	immediate = {
		owner = {
			complete_tutorial_step = 200_researched_anomaly
			country_event = {
				id = story.5 days = 30
			}
		}
	}

	option = {
		name = tutorial.53.a
		trigger = {
			owner = {
				NOR = {
					is_xenophobe = yes
					is_xenophile = yes
				}
			}
		}
	}
	option = {
		name = tutorial.53.xenophobe.a
		trigger = {
			owner = {
				is_xenophobe = yes
			}
		}
	}
	option = {
		name = tutorial.53.xenophile.a
		trigger = {
			owner = {
				is_xenophile = yes
			}
		}
	}
}
ship_event = {
	id = tutorial.54
	title = tutorial.52.name
	desc = tutorial.54.desc
	picture = GFX_evt_star_chart
	show_sound = event_default
	location = from
	is_triggered_only = yes

	trigger = {
		owner = { is_tutorial_level = 2 }
	}

	immediate = {
		owner = {
			complete_tutorial_step = 200_researched_anomaly
		}
	}

	option = {
		name = tutorial.54.a
		trigger = {
			owner = {
				is_spiritualist = no
				is_materialist = no
			}
		}
	}
	option = {
		name = tutorial.54.spiritualist.a
		trigger = {
			owner = {
				is_spiritualist = yes
			}
		}
	}
	option = {
		name = tutorial.54.materialist.a
		trigger = {
			owner = {
				is_materialist = yes
			}
		}
	}
}

### TUTORIAL: STRATEGIC RESOURCES
# Start
ship_event = {
	id = tutorial.55
	title = tutorial.55.name
	desc = tutorial.55.desc
	show_sound = tut_strategic_resources_intro

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			NOR = {
				has_event_chain = tutorial_21_chain
				has_country_flag = finished_tutorial_21
				has_ethic = ethic_gestalt_consciousness
				is_nomadic = yes
			}
		}
		from = {
			NOT = { has_orbital_station = yes }
		}
		OR = {
			# Strategic resource on this planet
			AND = {
				owner = { has_technology = tech_rare_crystals }
				from = { has_resource = { type = rare_crystals amount > 0 } }
			}
			AND = {
				owner = { has_technology = tech_exotic_gases }
				from = { has_resource = { type = exotic_gases amount > 0 } }
			}
			AND = {
				owner = { has_technology = tech_volatile_motes }
				from = { has_resource = { type = volatile_motes amount > 0 } }
			}
			AND = {
				owner = { has_technology = tech_mine_dark_matter }
				from = { has_resource = { type = sr_dark_matter amount > 0 } }
			}
			AND = {
				owner = { has_technology = tech_mine_living_metal }
				from = { has_deposit = d_living_metal_deposit }
			}
			AND = {
				owner = { has_technology = tech_mine_zro }
				from = { has_resource = { type = sr_zro amount > 0 } }
			}
			# Local resources
			AND = {
				owner = { has_technology = tech_alien_life_studies }
				from = { has_deposit = d_alien_pets_deposit }
			}
			AND = {
				owner = { has_technology = tech_mine_betharian }
				from = { has_deposit = d_betharian_deposit }
			}
		}
	}

	immediate = {
		owner = {
			begin_event_chain = {
				event_chain = "tutorial_21_chain"
				target = ROOT
			}
		}
		create_point_of_interest = {
			id = tutorial.55.poi
			name = "tutorial.55.poi.name"
			desc = "tutorial.55.poi.desc"
			event_chain = tutorial_21_chain
			location = from
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_21_tooltip
	}
}
# Start with meantime
country_event = {
	id = tutorial.555
	title = tutorial.55.name
	desc = tutorial.55.desc
	show_sound = tut_strategic_resources_intro

	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_21_chain
			has_country_flag = finished_tutorial_21
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
		capital_scope = {
			solar_system = {
				closest_system = {
					max_steps = 15
					limit = {
						any_system_planet = {
							is_capital = no
							is_surveyed = { who = ROOT status = yes }
							NOT = { has_orbital_station = yes }
							OR ={
								AND = {
									has_resource = { type = exotic_gases amount > 0 }
									root = { has_technology = tech_exotic_gases }
								}
								AND = {
									has_resource = { type = volatile_motes amount > 0 }
									root = { has_technology = tech_volatile_motes }
								}
								AND = {
									has_resource = { type = rare_crystals amount > 0 }
									root = { has_technology = tech_rare_crystals }
								}
								AND = {
									has_resource = { type = sr_dark_matter amount > 0 }
									root = { has_technology = tech_mine_dark_matter }
								}
								AND = {
									has_deposit = d_living_metal_deposit
									root = { has_technology = tech_mine_living_metal }
								}
								#Local resources
								AND = {
									has_deposit = d_alien_pets_deposit
									root = { has_technology = tech_alien_life_studies }
								}
								AND = {
									has_deposit = d_betharian_deposit
									root = { has_technology = tech_mine_betharian }
								}
							}
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 30
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_21_chain"
			target = ROOT
		}
	}

	option = {
		name = SITLOG
		custom_tooltip = tutorial_21_tooltip
	}
}

# Finished
ship_event = {
	id = tutorial.56
	title = tutorial.56.name
	desc = tutorial.56.desc
	show_sound = tut_strategic_resources_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_21_chain"
			NOT = { has_country_flag = finished_tutorial_21 }
		}
		from = {
			OR = {
				has_resource = { type = exotic_gases amount > 0 }
				has_resource = { type = volatile_motes amount > 0 }
				has_resource = { type = rare_crystals amount > 0 }
				has_resource = { type = sr_dark_matter amount > 0 }
				has_resource = { type = sr_zro amount > 0 }
				has_deposit = d_living_metal_deposit
				has_deposit = d_alien_pets_deposit
				has_deposit = d_betharian_deposit
			}
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 210_producing_strategic_resources
			end_event_chain = "tutorial_21_chain"
			set_country_flag = finished_tutorial_21
		}
	}

	option = {
		name = OK
	}
}
# Finished by having a mining station on a resource before researching the required tech
country_event = {
	id = tutorial.560
	title = tutorial.55.name
	desc = tutorial.560.desc
	show_sound = tut_strategic_resources_early

	is_advisor_event = yes

	trigger = {
		is_nomadic = no
		is_tutorial_level = 2
		NOT = { has_country_flag = finished_tutorial_21 }
		any_planet_within_border = {
			is_capital = no
			has_orbital_station = yes
			OR ={
				AND = {
					has_resource = { type = exotic_gases amount > 0 }
					root = { has_technology = tech_exotic_gases }
				}
				AND = {
					has_resource = { type = volatile_motes amount > 0 }
					root = { has_technology = tech_volatile_motes }
				}
				AND = {
					has_resource = { type = rare_crystals amount > 0 }
					root = { has_technology = tech_rare_crystals }
				}
				AND = {
					has_resource = { type = sr_dark_matter amount > 0 }
					root = { has_technology = tech_mine_dark_matter }
				}
				AND = {
					has_deposit = d_living_metal_deposit
					root = { has_technology = tech_mine_living_metal }
				}
				AND = {
					has_deposit = d_alien_pets_deposit
					root = { has_technology = tech_alien_life_studies }
				}
				AND = {
					has_deposit = d_betharian_deposit
					root = { has_technology = tech_mine_betharian }
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 30
	}

	immediate = {
		random_planet_within_border = {
			limit = {
				is_capital = no
				is_surveyed = { who = ROOT status = yes }
				has_orbital_station = yes
				if = {
					limit = { exists = owner }
					owner = { is_same_value = ROOT }
				}
				OR ={
					AND = {
						has_resource = { type = exotic_gases amount > 0 }
						root = { has_technology = tech_exotic_gases }
					}
					AND = {
						has_resource = { type = volatile_motes amount > 0 }
						root = { has_technology = tech_volatile_motes }
					}
					AND = {
						has_resource = { type = rare_crystals amount > 0 }
						root = { has_technology = tech_rare_crystals }
					}
					AND = {
						has_resource = { type = sr_dark_matter amount > 0 }
						root = { has_technology = tech_mine_dark_matter }
					}
					AND = {
						has_deposit = d_living_metal_deposit
						root = { has_technology = tech_mine_living_metal }
					}
					AND = {
						has_deposit = d_alien_pets_deposit
						root = { has_technology = tech_alien_life_studies }
					}
					AND = {
						has_deposit = d_betharian_deposit
						root = { has_technology = tech_mine_betharian }
					}
				}
			}
			save_event_target_as = StrategicResourcePlanet
		}
		end_event_chain = "tutorial_21_chain"
		set_country_flag = finished_tutorial_21
		begin_event_chain = {
			event_chain = "tutorial_21b_chain"
			target = ROOT
		}
		create_point_of_interest = {
			id = tutorial.55.poi
			name = "tutorial.55.poi.name"
			desc = "tutorial.56.poi.desc"
			event_chain = tutorial_21b_chain
			location = event_target:StrategicResourcePlanet
		}
		country_event = { id = tutorial.561 days = 90 }
	}

	option = {
		name = OK
	}
}

country_event = {
	id = tutorial.561
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		end_event_chain = "tutorial_21b_chain"
	}
}

### TUTORIAL: UPLIFTING
# Start
country_event = {
	id = tutorial.57
	title = tutorial.57.name
	desc = {
		trigger = { has_technology = tech_epigenetic_triggers }
		text = tutorial.57.desc.yestech
		show_sound = tut_pre_sapients_intro
	}
	desc = {
		trigger = { NOT = { has_technology = tech_epigenetic_triggers } }
		text = tutorial.57.desc.notech
		show_sound = tut_pre_sapients_intro
	}

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_22_chain
			has_country_flag = finished_tutorial_22
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_22_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_22_tooltip
	}
}

# Finish
country_event = {
	id = tutorial.58
	title = tutorial.58.name
	desc = tutorial.58.desc
	show_sound = tut_pre_sapients_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = tutorial_22_chain
	}

	immediate = {
		complete_tutorial_step = 220_uplifted_primitives
		end_event_chain = tutorial_22_chain
		set_country_flag = finished_tutorial_22
	}

	option = {
		name = OK
	}
}

### TUTORIAL: FIRST CONTACT PROJECT
country_event = {
	id = tutorial.59
	title = tutorial.59.name
	desc = tutorial.59.desc
	show_sound = tut_new_first_contact_intro

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_ai = no
		is_gestalt = no
		NOR = {
			is_nomadic = yes
			has_event_chain = tutorial_23_chain
			has_country_flag = firstcontact_tutorial
			has_country_flag = firstcontact_tutorial_completed
		}
		is_tutorial_level > 1 #Full tutorial only
		NOT = {
			from = { is_country_type = primitive }
		}
	}

	immediate = {
		owner = { set_country_flag = firstcontact_tutorial }
		begin_event_chain = {
			event_chain = tutorial_23_chain
			target = root
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_23_tooltip
	}
}

# Finish
# country_event = {
#	id = tutorial.60
#	title = tutorial.60.name
#	desc = tutorial.60.desc
#	show_sound = tut_new_first_contact_success

#	is_triggered_only = yes
#	is_advisor_event = yes

#	trigger = {
#		is_tutorial_level = 2
#		has_event_chain = tutorial_23_chain
#	}

#	immediate = {
#		complete_tutorial_step = 015_researched_contact
#		end_event_chain = tutorial_23_chain
#		set_country_flag = finished_tutorial_23
#	}

#	option = {
#		name = OK
#	}
# }

# Uchuu Kaijuu / Space Monsters
country_event = {
	id = tutorial.61
	title = tutorial.61.name
	desc = tutorial.61.desc
	show_sound = tut_new_first_contact_monster_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = tutorial_23_chain
	}

	immediate = {
		complete_tutorial_step = 015_researched_contact
	}

	option = {
		name = UNDERSTOOD
	}
}

# Other party completed project
country_event = {
	id = tutorial.63
	title = tutorial.63.name
	desc = tutorial.63.desc
	show_sound = tut_new_first_contact_other_party
	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_nomadic = no
		is_tutorial_level = 2
		is_country_type = default
		NOT = { has_country_flag = tutorial_63 }
	}

	immediate = {
		complete_tutorial_step = 014_researched_contacted
	}

	option = {
		name = UNDERSTOOD
		hidden_effect = {
			set_country_flag = tutorial_63
		}
	}
}

### TUTORIAL: MODIFY SPECIES
# Necessary tech researched
country_event = {
	id = tutorial.64
	title = tutorial.64.name
	desc = tutorial.64.desc
	show_sound = tut_modify_species_intro

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		OR = {
			last_increased_tech = "tech_gene_tailoring"
			last_increased_tech = "tech_gene_expressions"
			has_origin = origin_overtuned
		}
		NOR = {
			has_country_flag = tutorial_24
			has_event_chain = tutorial_24_chain
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		set_country_flag = tutorial_24
		begin_event_chain = {
			event_chain = tutorial_24_chain
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_24_tooltip
	}
}

# Modification project completed
country_event = {
	id = tutorial.65
	title = tutorial.65.name
	desc = tutorial.65.desc
	show_sound = tut_modify_species_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_event_chain = tutorial_24_chain
	}

	immediate = {
		complete_tutorial_step = 240_modified_species
		end_event_chain = tutorial_24_chain
	}

	option = {
		name = OK
	}
}

### TUTORIAL: FTL DESCRIPTION

# Warp Travel
#country_event = {
#	id = tutorial.70
#	title = tutorial.70.name
#	desc = tutorial.70.desc
#	show_sound = tut_ftl_warp_travel
#
#	is_triggered_only = yes
#	is_advisor_event = yes
#
#	trigger = {
#		is_tutorial_level > 0
#	}
#
#	option = {
#		name = OK
#	}
#}

# Hyperspace Travel
country_event = {
	id = tutorial.71
	title = tutorial.71.name
	desc = tutorial.71.desc
	show_sound = tut_ftl_hyperlane_travel

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level > 0
	}

	immediate = {
		owner = {
			complete_tutorial_step = 005_travelled_hyperdrive
		}
	}

	option = {
		name = UNDERSTOOD
	}
}

# Wormhole Travel
#country_event = {
#	id = tutorial.72
#	title = tutorial.72.name
#	desc = tutorial.72.desc
#	show_sound = tut_ftl_wormhole_travel
#
#	is_triggered_only = yes
#	is_advisor_event = yes
#
#	trigger = {
#		is_tutorial_level > 0
#	}
#
#	option = {
#		name = OK
#	}
#}

### TUTORIAL REMINDER: Obtained Uplift tech
country_event = {
	id = tutorial.73
	title = tutorial.73.name
	desc = tutorial.73.desc
	show_sound = tut_uplift_reminder

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		OR = {
			last_increased_tech = tech_epigenetic_triggers
			#has_event_chain = tutorial_22_chain
		}
		NOR = {
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	option = {
		name = UNDERSTOOD
	}
}

# HIDDEN - Set flag for Homesystem surveyed
ship_event = {
	id = tutorial.74
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_ai = no
			NOT = { has_country_flag = homesystem_surveyed }
			FROM = {
				solar_system = {
					any_system_planet = {
						is_capital = yes
						is_owned_by = PREVPREVPREV
					}
				}
			}
		}
	}

	immediate = {
		owner = {
			set_country_flag = homesystem_surveyed
		}
	}
}

### TUTORIAL: STARBASE

# Start
country_event = {
	id = tutorial.75
	title = tutorial.75.name
	desc = tutorial.75.desc
	show_sound = tut_frontier_station_intro

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level = 2
		NOR = {
			has_event_chain = tutorial_25_chain
			has_country_flag = tutorial_cleared_early_75
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_25_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_25_tooltip
	}
}

# Cleared early
ship_event = {
	id = tutorial.750
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			NOT = { has_country_flag = tutorial_cleared_early_75 }
		}
	}

	immediate = {
		owner = { set_country_flag = tutorial_cleared_early_75 }
	}
}

# Finished
ship_event = {
	id = tutorial.76
	title = tutorial.76.name
	desc = tutorial.76.desc
	show_sound = tut_frontier_station_success

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_25_chain"
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 020_built_starbase
			end_event_chain = "tutorial_25_chain"
		}
	}

	option = {
		name = UNDERSTOOD
		owner = {
			set_country_flag = tutorial_76_completed
		}
	}
}

# Tutorial level set to 0
country_event = {
	id = tutorial.100
	title = tutorial.100.name
	desc = tutorial.100.desc
	show_sound = tut_no_tutorial_settings

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 0
		has_country_flag = tutorial_level_picked
	}

	option = {
		name = OK
		hidden_effect = {
			remove_country_flag = advisor_tips
			set_advisor_active = no
		}
	}
}

# Tutorial level set to 1
country_event = {
	id = tutorial.101
	title = tutorial.101.name
	desc = tutorial.101.desc
	show_sound = tut_limited_tutorial_settings

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 1
		has_country_flag = tutorial_level_picked
		NOR = {
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	option = {
		name = OK
		hidden_effect = {
			set_country_flag = advisor_tips
			set_advisor_active = yes
		}
	}
}

# Tutorial level set to 2
country_event = {
	id = tutorial.102
	title = tutorial.102.name
	desc = tutorial.102.desc
	show_sound = tut_full_tutorial_settings

	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		is_tutorial_level = 2
		has_country_flag = tutorial_level_picked
		NOR = {
			has_ethic = ethic_gestalt_consciousness
			is_nomadic = yes
		}
	}

	option = {
		name = OK
		hidden_effect = {
			set_country_flag = advisor_tips
			set_advisor_active = yes
			if = {
				limit = {
					has_country_flag = waiting_tutorial_4
				}
				country_event = { id = tutorial.501 days = 10 }
			}
			else = {
				country_event = { id = tutorial.1 }
			}
		}
	}
}

# Remove Event chains set from tutorial levels
country_event = {
	id = tutorial.103
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			is_tutorial_level = 0
			is_tutorial_level = 1
		}
	}

	immediate = {
		remove_country_flag = advisor_tips #Removed to reset the tips whenever you change tutorial level
		#remove_country_flag = tutorial_1 #Might need to add these to make sure stuff doesn't break later
		#remove_country_flag = tutorial_2
		#remove_country_flag = waiting_tutorial_5
		#remove_country_flag = waiting_tutorial_11
		#remove_country_flag = tutorial_cleared_early_14
		#remove_country_flag = tutorial_cleared_early_16
		#remove_country_flag = tutorial_cleared_early_17
		#remove_country_flag = tutorial_cleared_early_48
		#remove_country_flag = tutorial_15_minerals_achieved
		#remove_country_flag = tutorial_15_credits_achieved
		#remove_country_flag = tutorial_16_corvettes_built
		#remove_country_flag = tutorial_16_admiral_assigned
		#remove_country_flag = finished_tutorial_20

		if = {
			limit = {
				has_event_chain = tutorial_survey_system_chain
			}
			end_event_chain = tutorial_survey_system_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_1_chain
			}
			end_event_chain = tutorial_1_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_2_chain
			}
			end_event_chain = tutorial_2_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_3_chain
			}
			end_event_chain = tutorial_3_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_4_chain
			}
			end_event_chain = tutorial_4_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_5_chain
			}
			end_event_chain = tutorial_5_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_6_chain
			}
			end_event_chain = tutorial_6_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_7_chain
			}
			end_event_chain = tutorial_7_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_8_chain
			}
			end_event_chain = tutorial_8_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_9_chain
			}
			end_event_chain = tutorial_9_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_10_chain
			}
			end_event_chain = tutorial_10_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_11_chain
			}
			end_event_chain = tutorial_11_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_12_chain
			}
			end_event_chain = tutorial_12_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_13_chain
			}
			end_event_chain = tutorial_13_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_14_chain
			}
			end_event_chain = tutorial_14_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_15_chain
			}
			end_event_chain = tutorial_15_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_16_chain
			}
			end_event_chain = tutorial_16_chain
		}
#		if = {
#			limit = {
#				has_event_chain = tutorial_17_chain # currently inactive
#			}
#			end_event_chain = tutorial_17_chain
#		}
#		if = {
#			limit = {
#				has_event_chain = tutorial_18_chain # currently inactive
#			}
#			end_event_chain = tutorial_18_chain
#		}
		if = {
			limit = {
				has_event_chain = tutorial_19_chain
			}
			end_event_chain = tutorial_19_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_20_chain
			}
			end_event_chain = tutorial_20_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_21_chain
			}
			end_event_chain = tutorial_21_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_22_chain
			}
			end_event_chain = tutorial_22_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_23_chain
			}
			end_event_chain = tutorial_23_chain
		}
		if = {
			limit = {
				has_event_chain = tutorial_24_chain
			}
			end_event_chain = tutorial_24_chain
		}
	}
}

# Tutorial stuff reset at startup in case disabled from start
country_event = {
	id = tutorial.104
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_tutorial_level < 1
		NOT = { has_country_flag = tutorial_level_picked }
	}

	immediate = {
		set_country_flag = tutorial_level_picked
	}
}

# Minor Artifacts
country_event = {
	id = tutorial.1337
	title = tutorial.1337.name
	desc = tutorial.1337.desc
	is_advisor_event = yes
	is_triggered_only = yes
	# show_sound = tut_minor_artifacts # Commented out for 4.0 until new VIR recordings are in place -> AUG-51943

	pre_triggers = {
		is_ai = no
	}

	trigger = {
		is_tutorial_level > 0
		has_resource = { type = minor_artifacts amount > 0 }
		NOR = {
			has_country_flag = artifact_tutorial
			is_nomadic = yes
		}
	}

	immediate = {
		set_country_flag = artifact_tutorial
	}

	option = {
		name = UNDERSTOOD
	}
}

country_event = {
	id = tutorial.1340
	title = tutorial.1340.name
	desc = tutorial.1340.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_astral_thread_discovered

	pre_triggers = {
		is_ai = no
	}

	trigger = {
		is_tutorial_level > 0
		has_resource = { type = astral_threads amount > 0 }
		NOR = {
			has_country_flag = astral_threads_tutorial
			is_nomadic = yes
		}
	}

	immediate = {
		set_country_flag = astral_threads_tutorial
	}

	option = {
		name = UNDERSTOOD
	}
}

###########################################
# "NEMESIS" / 2.9 TUTORIALS & ADVISOR TIPS
###########################################

#Conducting First Contact
first_contact_event = {
	id = tutorial.2000
	title = tutorial.2000.name
	desc = tutorial.2000.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_first_contact_mission

	trigger = {
		owner = {
			is_nomadic = no
			NOT = {
				has_country_flag = firstcontact_tutorial_completed
			}
			is_tutorial_level > 0 #Tips & full tutorial
		}
	}

	immediate = { }

	option = {
		name = ACKNOWLEDGED
		custom_tooltip = tutorial_23_tooltip
	}
}

#First Contact Established (setup)
first_contact_event = {
	id = tutorial.2004
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		owner = {
			country_event = {
				id = tutorial.2005
				scopes = { from = from }
			}
		}
	}
}

#First Contact Established
#this = Empire 1; from = Empire 2; fromfromfrom = system where contact occurred
country_event = {
	id = tutorial.2005
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_tutorial_level > 1 #Full tutorial
		has_event_chain = tutorial_23_chain
	}

	immediate = {
		if = {
			limit = {
				from = { is_country_type = default }
			}
			country_event = { id = tutorial.2006 }
		}
		else_if = {
			limit = {
				from = {
					OR = {
						is_country_type = fallen_empire
						is_country_type = marauder_raiders
						is_country_type = debt_collectors
						is_country_type = enclave
						is_country_type = enclave_mercenary
						is_country_type = mindwarden_enclave
					}
				}
			}
			country_event = { id = tutorial.2007 }
		}
		else = {
			country_event = { id = tutorial.61 }
		}
		from = {
			country_event = { id = tutorial.2005 }
		}
	}
}
#First Contact Established (regular empire version)
country_event = {
	id = tutorial.2006
	title = tutorial.2006.name
	desc = tutorial.2006.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_communications_protocol

	trigger = {
		has_event_chain = tutorial_23_chain
		NOT = { has_country_flag = firstcontact_tutorial_established_regular }
	}

	immediate = {
		set_country_flag = firstcontact_tutorial_established_regular
		set_country_flag = firstcontact_tutorial_completed #Only considered complete once done with a regular empire
		add_event_chain_counter = {
			event_chain = tutorial_23_chain
			counter = contact_made
			amount = 1
		}
		complete_tutorial_step = 015_researched_contact
	}

	option = {
		name = UNDERSTOOD
		end_event_chain = tutorial_23_chain #Only considered complete once done with a regular empire
	}
}
#First Contact Established (Fallen Empire/Marauder version)
country_event = {
	id = tutorial.2007
	title = tutorial.2007.name
	desc = tutorial.2007.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_communications_unwilling

	trigger = {
		has_event_chain = tutorial_23_chain
		NOT = { has_country_flag = firstcontact_tutorial_established_fe_marauder }
	}

	immediate = {
		set_country_flag = firstcontact_tutorial_established_fe_marauder
		complete_tutorial_step = 015_researched_contact
	}

	option = {
		name = OK
	}
}

#Assigning Assets (fallback in case an Asset is received before the Operations Asset panel tutorial kicks in)
country_event = {
	id = tutorial.2010
	title = tutorial.2010.name
	desc = tutorial.2010.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_ESPIONAGE_VIEW_ASSIGN_ASSET

	trigger = {
		is_nomadic = no
		is_tutorial_level > 1 #Full tutorial
		NOT = { has_country_flag = espionage_tutorial_assigning_assets }
	}

	immediate = {
		set_country_flag = espionage_tutorial_assigning_assets
	}

	option = {
		name = OK
	}
}

###########################################
# "OVERLORD" TUTORIALS & ADVISOR TIPS
###########################################

# Tutorial: Enclave Diplomacy (not Mercs) | from = contacted country
country_event = {
	id = tutorial.2100
	title = tutorial.2100.name
	desc = {
		trigger = { is_tutorial_level = 1 }
		text = tutorial.2100.abbr.desc
	}
	desc = {
		trigger = { is_tutorial_level = 2 }
		text = tutorial.2100.full.desc
	}
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_first_contact_enclave

	trigger = {
		is_tutorial_level > 0 #Tips & full tutorial
		from = {
			OR = {
				has_country_flag = artist_enclave_country
				has_country_flag = curator_enclave_country
				has_country_flag = salvager_enclave_country
				has_country_flag = shroudwalker_enclave_country
				has_country_flag = mindwarden_enclave_country
				has_country_flag = trader_enclave_country
				has_country_flag = champions_forge_enclave_country
			}
		}
		NOR = {
			has_country_flag = tutorial_met_enclave
			is_nomadic = yes
		}
	}

	immediate = {
		set_country_flag = tutorial_met_enclave
	}

	option = {
		name = OK
	}
}

# Tutorial: Enclave Diplomacy (Mercs) | from = contacted country
country_event = {
	id = tutorial.2105
	title = tutorial.2105.name
	desc = {
		trigger = { is_tutorial_level = 1 }
		text = tutorial.2105.abbr.desc
	}
	desc = {
		trigger = { is_tutorial_level = 2 }
		text = tutorial.2105.full.desc
	}
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_encounter_mercenary_enclave_info

	trigger = {
		has_overlord_dlc = yes
		is_tutorial_level > 0 #Tips & full tutorial
		from = {
			has_country_flag = mercenary_enclave_country
		}
		NOR = {
			has_country_flag = tutorial_met_mercenary_enclave
			is_nomadic = yes
		}
	}

	immediate = {
		set_country_flag = tutorial_met_mercenary_enclave
	}

	option = {
		name = OK
	}
}

# Tutorial: Creating a Mercenary Enclave | via on_monthly_pulse_country | from = contacted country
country_event = {
	id = tutorial.2110
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_overlord_dlc = yes
		is_gestalt = no
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		any_owned_fleet = {
			fleet_size > 45
		}
	}

	immediate = {
		random_owned_fleet = {
			limit = { fleet_size > 45 }
			save_event_target_as = tutorial_mercenary_fleet
		}
		country_event = { id = tutorial.2111 }
	}
}
country_event = {
	id = tutorial.2111
	title = tutorial.2111.name
	desc = {
		trigger = { is_tutorial_level = 1 }
		text = tutorial.2111.abbr.desc
	}
	desc = {
		trigger = { is_tutorial_level = 2 }
		text = tutorial.2111.full.desc
	}
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_fleet_conversion

	fire_only_once = yes

	immediate = {
		set_country_flag = tutorial_met_mercenary_enclave
	}

	option = {
		name = OK
	}
}

# Tutorial: Megastructures | via on_tech_increased
country_event = {
	id = tutorial.2115
	title = tutorial.2115.name
	desc = tutorial.2115.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_megastructures_info

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		has_technology = tech_mega_engineering
		NOT = { has_country_flag = tutorial_megastructures }
	}

	immediate = {
		set_country_flag = tutorial_megastructures
	}

	option = {
		name = UNDERSTOOD
	}
}

# Orbital Ring (technology) | via on_tech_increased
country_event = {
	id = tutorial.2120
	title = tutorial.2120.name
	desc = tutorial.2120.desc
	is_advisor_event = yes
	is_triggered_only = yes
	#Non-voiced

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		has_technology = tech_orbital_ring_tier_1
		NOT = { has_country_flag = tutorial_orbital_ring_tech }
	}

	immediate = {
		set_country_flag = tutorial_orbital_ring_tech
	}

	option = {
		name = UNDERSTOOD
	}
}
# Orbital Ring | via Restored Orbital Ring on_build_complete
country_event = {
	id = tutorial.2121
	title = TUTORIAL_ORBITAL_RING_TITLE
	desc = TUTORIAL_ORBITAL_RING_DESC
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_ORBITAL_RING

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		NOT = { has_country_flag = tutorial_built_orbital_ring }
	}

	immediate = {
		set_country_flag = tutorial_built_orbital_ring
	}

	option = {
		name = UNDERSTOOD
	}
}

# Quantum Catapult (technology) | via on_tech_increased
country_event = {
	id = tutorial.2125
	title = tutorial.2125.name
	desc = tutorial.2125.desc
	is_advisor_event = yes
	is_triggered_only = yes
	#Non-voiced

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		has_technology = tech_quantum_catapult
		NOT = { has_country_flag = tutorial_quantum_catapult_tech }
	}

	immediate = {
		set_country_flag = tutorial_quantum_catapult_tech
	}

	option = {
		name = UNDERSTOOD
	}
}
# Quantum Catapult | via Restored/"Slingshot" Restored/Quantum Catapult on_build_complete
country_event = {
	id = tutorial.2126
	title = tutorial.2126.name
	desc = tutorial.2126.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_quantum_catapults

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		NOT = { has_country_flag = tutorial_built_quantum_catapult }
	}

	immediate = {
		set_country_flag = tutorial_built_quantum_catapult
	}

	option = {
		name = OK
	}
}

# Hyper Relay (technology) | via on_tech_increased
country_event = {
	id = tutorial.2130
	title = tutorial.2130.name
	desc = tutorial.2130.desc
	is_advisor_event = yes
	is_triggered_only = yes
	#Non-voiced

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		has_technology = tech_quantum_catapult
		NOT = { has_country_flag = tutorial_hyper_relay_tech }
	}

	immediate = {
		set_country_flag = tutorial_hyper_relay_tech
	}

	option = {
		name = UNDERSTOOD
	}
}
# Hyper Relay | via Restored/Hyper Relay on_build_complete
country_event = {
	id = tutorial.2131
	title = tutorial.2131.name
	desc = tutorial.2131.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_hyper_relays

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		NOT = { has_country_flag = tutorial_built_hyper_relay }
	}

	immediate = {
		set_country_flag = tutorial_built_hyper_relay
	}

	option = {
		name = OK
	}
}

############################################
# "First Contact" TUTORIALS & ADVISOR TIPS #
############################################


### TUTORIAL: OBSERVATION POSTS
# Will not trigger unless player has Observation Station tech
# Add researched_tech on-action event to check for discovered
# primitives and re-trigger this?

# Start
ship_event = {
	id = tutorial.2140
	title = tutorial.2140.name
	desc = tutorial.2140.desc
	show_sound = tut_msg_preftl_society_discovered

	is_advisor_event = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			is_nomadic = no
			is_tutorial_level = 2
			NOR = {
				has_event_chain = tutorial_20_chain
				has_country_flag = finished_tutorial_20
			}
			has_technology = tech_space_construction
		}
		FROM = {
			has_owner = yes
			owner = { is_country_type = primitive }
		}
	}

	immediate = {
		begin_event_chain = {
			event_chain = "tutorial_20_chain"
			target = ROOT
		}
	}

	option = {
		name = UNDERSTOOD
		custom_tooltip = tutorial_20_tooltip
	}
}

# Built Observation Outpost
ship_event = {
	id = tutorial.2145
	title = tutorial.2145.name
	desc = {
		trigger = {
			has_first_contact_dlc = no
		}
		text = tutorial.2145.desc.nodlc
	}
	desc = {
		trigger = {
			has_first_contact_dlc = yes
		}
		text = tutorial.2145.desc.dlc
	}
	show_sound = tut_msg_observation_post
	is_triggered_only = yes
	is_advisor_event = yes

	trigger = {
		owner = {
			is_tutorial_level = 2
			has_event_chain = "tutorial_20_chain"
		}
	}

	immediate = {
		owner = {
			complete_tutorial_step = 190_built_observation_post
			end_event_chain = "tutorial_20_chain"
			set_country_flag = finished_tutorial_20
		}
	}

	option = {
		name = "OK"
	}
}

#First Contact Established (pre-FTL version)
country_event = {
	id = tutorial.2150
	title = tutorial.2150.name
	desc = tutorial.2150.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_preftl_diplomacy

	trigger = {
		is_nomadic = no
		is_tutorial_level = 2
		NOT = { has_country_flag = firstcontact_tutorial_established_pre_ftl }
	}

	immediate = {
		set_country_flag = firstcontact_tutorial_established_pre_ftl
	}

	option = {
		name = OK
	}
}

# Cloaking Fields (technology) | via on_tech_increased
country_event = {
	id = tutorial.2500
	title = tutorial.2500.name
	desc = tutorial.2500.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_cloaking_generators

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		has_technology = tech_cloaking_1
		NOT = { has_country_flag = tutorial_cloaking_tech }
	}

	immediate = {
		set_country_flag = tutorial_cloaking_tech
	}

	option = {
		name = UNDERSTOOD
	}
}

# Cloaking Detection (technology) | via on_tech_increased
country_event = {
	id = tutorial.2550
	title = tutorial.2550.name
	desc = tutorial.2550.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_detection_arrays

	trigger = {
		is_nomadic = no
		is_tutorial_level > 0 #Tips & full tutorial
		has_technology = tech_detection_array
		NOT = { has_country_flag = tutorial_tech_detection_array }
	}

	immediate = {
		set_country_flag = tutorial_tech_detection_array
	}

	option = {
		name = UNDERSTOOD
	}
}

###########################################
# "SHROUD" TUTORIALS & ADVISOR TIPS
###########################################

# Psionic Aura (technology) | via on_tech_increased
country_event = {
	id = tutorial.2600
	title = tutorial.2600.name
	desc = tutorial.2600.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_SHROUD_PSIONIC_AURA

	trigger = {
		is_nomadic = no
		is_tutorial_level = 2
		has_technology = tech_psionic_aura
		NOT = { has_country_flag = tutorial_psionic_aura }
	}

	immediate = {
		set_country_flag = tutorial_psionic_aura
	}

	option = {
		name = UNDERSTOOD
	}
}

# Aura Intensification (technology) | via on_tech_increased
country_event = {
	id = tutorial.2610
	title = tutorial.2610.name
	desc = tutorial.2610.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_SHROUD_AURA_INTENSIFICATION

	trigger = {
		is_nomadic = no
		is_tutorial_level = 2
		has_technology = tech_aura_intensification
		NOT = { has_country_flag = tutorial_aura_intensification }
	}

	immediate = {
		set_country_flag = tutorial_aura_intensification
	}

	option = {
		name = UNDERSTOOD
	}
}

# First Aura Clashing
country_event = {
	id = tutorial.2620
	title = tutorial.2620.name
	desc = tutorial.2620.desc
	is_advisor_event = yes
	is_triggered_only = yes
	show_sound = tut_msg_SHROUD_AURA_CLASHING

	trigger = {
		is_nomadic = no
		is_tutorial_level = 2
		NOT = { has_country_flag = tutorial_aura_clashing }
	}

	immediate = {
		set_country_flag = tutorial_aura_clashing
	}

	option = {
		name = UNDERSTOOD
	}
}
