namespace = leviathans

country_event = {
	id = leviathans.1051
	title = leviathans.1050.name
	desc = leviathans.1051.desc
	picture = GFX_evt_technosphere
	show_sound = event_mystic_reveal
	location = event_target:technosphere_ship
	trackable = yes

	is_triggered_only = yes

	trigger = {
		exists = event_target:technosphere_ship
		NOT = { has_country_flag = worm_events_available }
	}

	immediate = {
		set_country_flag = technosphere_studied
		event_target:guardian_technosphere_country = {
			random_controlled_ship = {
				limit = {
					is_ship_size = sphere
				}
				save_event_target_as = technosphere_location
			}
		}
	}

	option = {
		name = leviathans.1051.a
		hidden_effect = {
			country_event = { id = leviathans.1055 }
		}
	}
	option = {
		name = leviathans.1051.c #praise it as your god
		trigger = {
			OR = {
				has_ethic = ethic_fanatic_spiritualist
				has_ethic = ethic_spiritualist
			}
		}
		add_modifier = {
			modifier = technosphere_praising
			days = -1
		}
	}
	option = {
		name = leviathans.1051.b #hack it
		trigger = {
			OR = {
				has_ethic = ethic_fanatic_materialist
				has_ethic = ethic_materialist
			}
		}
		enable_special_project = {
			name = TECHNOSPHERE_HACKING
			location = event_target:technosphere_ship
			owner = root
		}
	}
	option = {
		name = leviathans.1051.d #sabotage it
		#custom_tooltip = leviathans.1051.d.tooltip
		trigger = {
			OR = {
				has_ethic = ethic_fanatic_militarist
				has_ethic = ethic_militarist
			}
		}
		hidden_effect = {
			set_country_flag = technosphere_sabotaged
		}
		event_target:technosphere_ship = {
			enable_special_project = {
				name = TECHNOSPHERE_DESTRUCTION
				location = this
				owner = root
			}
		}
	}
	option = {
		name = leviathans.1051.e #hack it - Gestalt Consciousness
		trigger = {
			has_ethic = ethic_gestalt_consciousness
		}
		enable_special_project = {
			name = TECHNOSPHERE_HACKING
			location = event_target:technosphere_ship
			owner = root
		}
	}
}

#The technosphere submerges itself into the hole - FAIL
country_event = {
	id = leviathans.1063
	title = sphere
	desc = leviathans.1063.desc
	picture = GFX_evt_technosphere
	show_sound = event_mystic_reveal
	location = event_target:technosphere_ship

	is_triggered_only = yes

	trigger = { exists = event_target:technosphere_ship }

	option = {
		name = PECULIAR
		custom_tooltip = leviathans.1063.a.tooltip
		add_resource = { influence = 150 }
		if = {
			limit = {
				NOR = {
					has_technology = tech_sapient_ai
					has_technology = tech_positronic_implants
				}
			}
			if = {
				limit = {
					has_ethic = ethic_gestalt_consciousness
				}
				give_technology = { tech = tech_positronic_implants }
			}
			else = {
				give_technology = { tech = tech_sapient_ai }
			}
		}
		else_if = {
			limit = {
				NOT = { has_technology = tech_zero_point_power }
			}
			give_technology = { tech = tech_zero_point_power }
		}
		else = {
			add_resource = { influence = 150 }
		}
		hidden_effect = {
			event_target:technosphere_ship = {
				solar_system = {
					random_system_planet = {
						limit = { is_star = yes }
						add_deposit = d_physics_4
						add_deposit = d_engineering_4
						add_deposit = d_society_4
					}
				}
			}
			event_target:technosphere_ship = {
				solar_system = {
					save_event_target_as = slain_guardian_system
				}
				delete_fleet = this
			}
			country_event = { id = leviathans.1039 }
		}
	}
	option = {
		name = leviathans.1063.b
		custom_tooltip = leviathans.1063.a.tooltip
		hidden_effect = {
			event_target:technosphere_ship = {
				solar_system = {
					random_system_planet = {
						limit = { is_star = yes }
						add_deposit = d_physics_4
						add_deposit = d_engineering_4
						add_deposit = d_society_4
					}
				}
			}
			event_target:technosphere_ship = {
				solar_system = {
					save_event_target_as = slain_guardian_system
				}
				delete_fleet = this
			}
			country_event = { id = leviathans.1039 }
		}
	}
}

#The technosphere submerges itself into the hole - secret
country_event = {
	id = leviathans.1065
	title = sphere
	desc = leviathans.1065.desc
	picture = GFX_evt_technosphere
	show_sound = event_mystic_reveal
	location = event_target:technosphere_ship

	is_triggered_only = yes

	trigger = { exists = event_target:technosphere_ship }

	immediate = {
		set_country_flag = pantagruel
	}

	option = {
		name = AMAZING
		custom_tooltip = leviathans.1065.a.tooltip
		add_modifier = {
			modifier = black_hole_pantagruel_research
			days = -1
		}
		if = {
			limit = { is_gestalt = no }
			event_target:sots_infinity_scientist = {
				add_trait = sots_infinity_calculator
			}
		}
		else = {
			random_owned_leader = {
				limit = {
					is_councilor_type = councilor_gestalt_cognitive
				}
				add_trait = sots_infinity_calculator
			}
		}
		hidden_effect = {
			add_resource = { influence = 200 }
			event_target:technosphere_ship.solar_system = {
				random_system_planet = {
					limit = { is_star = yes }
					solar_system = {
						set_name = "NAME_Pantagruel"
						set_star_flag = pantagruel
					}
					set_name = "NAME_Pantagruel"
					change_planet_size = -30
					create_ambient_object = {
						type = explosion_particle_object
						location = this
						duration = 5

						use_3d_location = yes

						entity_offset = { min = 0 max = 0 }
						entity_offset_angle = { min = 0 max = 0 }
						entity_offset_height = { min = 0 max = 0 }

						entity_scale_to_size = yes
						scale = 100
					}
					add_deposit = d_physics_10
					add_deposit = d_engineering_10
					add_deposit = d_society_10
					add_modifier = {
						modifier = black_hole_pantagruel
						days = -1
					}
					if = {
						limit = {
							exists = space_owner
							space_owner = { is_same_value = root }
						}
						space_owner = {
							add_modifier = {
								modifier = black_hole_pantagruel_research
								days = -1
							}
						}
					}
					if = {
						limit = {
							is_surveyed = {
								who = root
								status = no
							}
						}
						set_surveyed = {
							surveyed = yes
							surveyor = root
						}
					}
				}
			}
			event_target:technosphere_ship = {
				solar_system = {
					save_event_target_as = slain_guardian_system
				}
				#fleet = {
					delete_fleet = this
				#}
			}
			country_event = { id = leviathans.1039 }
		}
	}
}
