namespace = distar
# Technology available upon gaining all insights
country_event = {
	id = distar.10904
	title = "distar.10904.name"
	desc = {
		text = "distar.10904.desc"
		trigger = {
			NOR = {
				has_origin = origin_rg_gray
			}
		}
	}
	desc = {
		text = "distar.10904.desc"
		trigger = {
			OR = {
				has_origin = origin_rg_gray
			}
		}
	}
	picture = GFX_evt_drifting_gateway
	show_sound = event_mystic_reveal
	is_triggered_only = yes
	immediate = {
		observer_event = {
			id = observer.61
		}
	}
	option = {
		name = GOOD
		if = {
			# You can only research to open it if it has not been opened already
			limit = {
				can_research_technology = tech_lgate_activation
			}
			add_research_option = tech_lgate_activation
		}
	}
}

# Project available
country_event = {
	id = distar.10905
	title = "distar.10905.name"
	desc = {
		text = "distar.10905.desc"
		trigger = {
			NOR = {
				has_origin = origin_rg_gray
			}
		}
	}
	desc = {
		text = "distar.10905.desc"
		trigger = {
			OR = {
				has_origin = origin_rg_gray
				has_origin = origin_gray
				has_origin = origin_lclusterplus_gatebuilders
				has_origin = origin_lclusterplus_gatebuilders_advanced
			}
		}
	}
	picture = GFX_evt_drifting_gateway
	show_sound = event_mystic_reveal
	location = event_target:candidate_gateway
	is_triggered_only = yes
	immediate = {
		end_event_chain = "l_cluster_chain"
		event_target:candidate_gateway = {
			solar_system = {
				save_event_target_as = candidate_gateway_system
			}
		}
		set_global_flag = rg_kac_lcluster_project
	}
	option = {
		name = "distar.10905.a"
		event_target:candidate_gateway = {
			enable_special_project = {
				name = RG_LCLUSTER_PROJECT
				location = this
			}
		}
	}
}

# Abandoned Cluster Found
country_event = {
	id = distar.10951
	title = "distar.10951.name"
	desc = "distar.10951.desc"
	picture = GFX_evt_l-gateway
	show_sound = event_activating_unknown_technology
	location = event_target:candidate_gateway
	is_triggered_only = yes
	immediate = {
		country_event = {
			id = distar.11000
		}
		every_playable_country = {
			limit = {
				has_special_project = RG_LCLUSTER_PROJECT
				NOT = {
					is_same_value = root
				}
			}
			country_event = {
				id = distar.10952
			}
		}
		every_playable_country = {
			limit = {
				NOR = {
					has_event_chain = l_cluster_chain
					has_special_project = RG_LCLUSTER_PROJECT
					is_same_value = root
				}
			}
			country_event = {
				id = distar.10954
			}
		}
		every_playable_country = {
			limit = {
				NOR = {
					has_special_project = RG_LCLUSTER_PROJECT
					is_same_value = root
				}
				has_event_chain = l_cluster_chain
			}
			country_event = {
				id = distar.10953
			}
		}
		observer_event = {
			id = observer.62
		}
	}
	option = {
		name = "distar.10951.a"
	}
}

# Research Project Aborted
country_event = {
	id = distar.10952
	title = "distar.10952.name"
	desc = "distar.10952.desc"
	picture = GFX_evt_glitchy_matrix
	show_sound = event_alien_signal
	is_triggered_only = yes
	immediate = {
		abort_special_project = {
			type = RG_LCLUSTER_PROJECT
		}
	}
	option = {
		name = "distar.10952.a"
	}
}

# Informed about AI being close to opening L-Gate (HIDDEN)
event = {
	id = distar.10955
	hide_window = yes
	is_triggered_only = yes
	trigger = {
		any_playable_country = {
			is_ai = no
			OR = {
				has_event_chain = l_cluster_chain
				has_special_project = RG_LCLUSTER_PROJECT
			}
			any_relation = {
				is_country_type = default
				has_communications = prev
				has_event_chain = l_cluster_chain
				NOT = {
					has_country_flag = lgate_warned@prev
				}
				check_variable = {
					which = num_lcluster_clues
					value > 5
				}
				any_owned_megastructure = {
					is_megastructure_type = lgate_base
				}
			}
		}
	}
	immediate = {
		random_playable_country = {
			limit = {
				is_ai = no
				OR = {
					has_event_chain = l_cluster_chain
					has_special_project = RG_LCLUSTER_PROJECT
				}
				any_relation = {
					is_country_type = default
					has_communications = prev
					has_event_chain = l_cluster_chain
					NOT = {
						has_country_flag = lgate_warned@prev
					}
					check_variable = {
						which = num_lcluster_clues
						value > 5
					}
					any_owned_megastructure = {
						is_megastructure_type = lgate_base
					}
				}
			}
			random_relation = {
				limit = {
					is_country_type = default
					has_communications = prev
					has_event_chain = l_cluster_chain
					NOT = {
						has_country_flag = lgate_warned@prev
					}
					check_variable = {
						which = num_lcluster_clues
						value > 5
					}
					any_owned_megastructure = {
						is_megastructure_type = lgate_base
					}
				}
				save_event_target_as = lgate_warning_country
				set_country_flag = lgate_warned@prev
			}
			country_event = {
				id = distar.10956
			}
		}
	}
}
