####################################
# Grand Archive - Special Projects #
####################################

special_project = {
	key = "VOIDWORMS_PROJECT"
	cost = 1500
	tech_department = society_technology
	timelimit = -1
	picture = GFX_evt_unidentified_voidworms
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"
	location = no

	event_scope = planet_event

	on_success = {
		prev = { country_event = { id = grand_archive.2015 } }
	}
}

#######################
# Cutholoids Projects #
#######################

# Scope = Eaten fleet
special_project = {
	key = "HIDDEN_CUTHOLOID_ATTACK_PROJECT"
	event_chain = "cutholoid_discovered_chain"
	days_to_research = 10
	timelimit = 3600
	picture = GFX_evt_asteroid_field
	icon = "gfx/interface/icons/situation_log/situation_log_ship.dds"

	same_option_group_as = { HIDDEN_CUTHOLOID_CAPTURE_PROJECT }

	event_scope = ship_event

	triggered_requirement = {
		text = HIDDEN_CUTHOLOID_ATTACK_PROJECT_REQUIREMENT
		count = 1
		trigger = {
			OR = {
				is_ship_class = shipclass_military
				is_ship_class = shipclass_starbase
			}
			fleet_power >= 600
		}
	}

	on_success = {
		from = {
			set_fleet_flag = revealed_hiding_cutholoid
		}
		spawn_cutholoid_from_asteroid = {
			LOCATION = event_target:cutholoid_under_radar
			EVENT_NAME = ambushing_cutholoid
		}
		event_target:ambushing_cutholoid = {
			set_ship_flag = ambushing_cutholoid
			set_ship_flag = spawned_for@prev.controller
			fleet = { set_fleet_stance = aggressive }
		}
		controller = {
			end_event_chain = "cutholoid_discovered_chain"
		}
	}
	on_fail = {
		country_event = {
			id = grand_archive.3020
			scopes = {
				from = fromfrom
				fromfrom = event_target:cutholoid_under_radar
			}
		}
		end_event_chain = "cutholoid_discovered_chain"
	}

	abort_trigger = {
		NOR = {
			fromfrom = { has_fleet_flag = revealed_hiding_cutholoid }
			exists = event_target:cutholoid_under_radar
		}
	}
	on_cancel = {
		if = {
			limit = {
				NOT = { exists = event_target:cutholoid_under_radar }
			}
			end_event_chain = "cutholoid_discovered_chain"
			fromfrom = {
				set_leader = leader_eaten_by_cutholoid@prev
				set_mia_return_delay = 0
				fleet_event = { id = grand_archive.3017 }
			}
		}
	}
}

# Scope = Eaten fleet
special_project = {
	key = "HIDDEN_CUTHOLOID_CAPTURE_PROJECT"
	event_chain = "cutholoid_discovered_chain"
	days_to_research = 180
	timelimit = 3600
	picture = GFX_evt_asteroid_field
	icon = "gfx/interface/icons/situation_log/situation_log_gravity_snare.dds"

	same_option_group_as = { HIDDEN_CUTHOLOID_ATTACK_PROJECT }

	event_scope = ship_event

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
		has_technology = tech_gravity_wells
	}

	on_success = {
		from.fleet = {
			set_fleet_flag = revealed_hiding_cutholoid
		}
		event_target:cutholoid_under_radar = {
			solar_system = {
				save_event_target_as = cutholoid_system
			}
			remove_planet = yes
		}
		from.fleet = {
			controller = {
				add_to_vivarium = {
					design = NAME_Cutholoids
				}
				set_country_flag = captured_hiding_cutholoid
				set_country_flag = has_ever_captured_a_cutholoid
				end_event_chain = "cutholoid_discovered_chain"
			}
			fleet_event = {
				id = grand_archive.3015
				scopes = { from = event_target:cutholoid_system }
			}
		}
		event_target:cutholoids_country = {
			change_variable = {
				which = alive_cutholoids
				value = -1
			}
		}
	}

	# Fail and cancel triggers are handled in HIDDEN_CUTHOLOID_ATTACK_PROJECT
}

special_project = {
	key = "CUTHOLOID_DEBRIS_PROJECT"
	days_to_research = 90
	timelimit = 1800
	tech_department = engineering_technology
	picture = GFX_evt_cutholoids_attack
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"

	event_scope = ship_event

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
	}

	on_success = {
		controller = {
			country_event = {
				id = grand_archive.3026
				scopes = {
					from = root.from
					fromfrom = root.solar_system
				}
			}
		}
	}

	on_fail = {
		fromfrom = {
			destroy_ambient_object = this
		}
	}
}

special_project = {
	key = "RESEARCH_CUTHOLOIDS_PROJECT"
	cost = 2000
	tech_department = engineering_technology
	timelimit = -1
	picture = GFX_evt_cutholoids_first_contact
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"
	location = no

	event_scope = ship_event

	on_success = {
		prev = { country_event = { id = grand_archive.2905 } }
	}
}

###########################
# Primal Calling Projects #
###########################

special_project = {
	key = "CARRION_DEBRIS_PROJECT"
	days_to_research = 90
	timelimit = 1800
	tech_department = engineering_technology
	picture = GFX_evt_fauna_debris
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"

	event_scope = ship_event

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
	}

	on_success = {
		destroy_ambient_object = from
		controller = {
			country_event = {
				id = grand_archive.1065
			}
		}
	}

	on_fail = {
		destroy_ambient_object = fromfrom
	}
}

############################
# Treasure Troves Projects #
############################

special_project = {
	key = "TREASURE_TROVE"
	event_chain = "treasure_troves_chain"
	days_to_research = 60
	picture = GFX_evt_treasure_trove
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"

	event_scope = ship_event

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
	}

	on_success = {
		ship_event = { id = grand_archive.6015 }
	}
}

special_project = {
	key = "TREASURE_TROVE_PIRATES"
	event_chain = "treasure_troves_chain"
	timelimit = 1800
	picture = GFX_evt_treasure_trove_pirate_fleet
	icon = "gfx/interface/icons/situation_log/situation_log_ship.dds"

	event_scope = planet_event

	requirements = {
		handled_by_event_tooltip = TREASURE_TROVE_EVENT_TOOLTIP
	}

	on_success = {
	}

	on_fail = {
		country_event = {
			id = grand_archive.6035
			scopes = {
				from = from
				fromfrom = from.solar_system
			}
		}
	}
}

#############################
# Treasure Hunters Projects #
#############################

special_project = {
	key = "TREASURE_HUNTERS_ANCIENT_CAPSULE_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	cost = 500
	tech_department = physics_technology
	timelimit = -1
	picture = GFX_evt_astral_rift_psionic_stranger_2
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"
	location = no
	remove_when_completed = yes

	event_scope = planet_event

	on_success = {
		prev = { country_event = { id = grand_archive.8005 } }
	}
}

special_project = {
	key = "TREASURE_HUNTERS_CHART_PIECE_2_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 180
	picture = GFX_evt_treasure_hunt_1
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"
	remove_when_completed = yes

	event_scope = ship_event

	triggered_requirement = {
		text = CONSTRUCTOR_PROJECT_REQUIREMENTS
		count = 1
		trigger = {
			OR = {
				is_ship_class = shipclass_constructor
				is_arkship_fleet = yes
			}
		}
	}

	on_success = {
		prev = { country_event = { id = grand_archive.8055 } }
	}
}

special_project = {
	key = "TREASURE_HUNTERS_ANCIENT_CAPSULE_2_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	cost = 1000
	tech_department = physics_technology
	timelimit = -1
	picture = GFX_evt_treasure_hunt_2
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"
	location = no
	remove_when_completed = yes

	event_scope = planet_event

	on_success = {
		prev = { country_event = { id = grand_archive.8060 } }
	}
}

special_project = {
	key = "TREASURE_HUNTERS_EXHIBITION_PROJECT"
	cost = 3000
	tech_department = engineering_technology
	timelimit = -1
	picture = GFX_evt_ancient_artifact
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"
	location = no

	event_scope = planet_event

	on_success = {
		prev = { country_event = { id = grand_archive.8080 } }
	}
}

special_project = {
	key = "TREASURE_HUNTERS_BUILD_GRAND_ARCHIVE"
	timelimit = -1
	picture = GFX_evt_grand_archive
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"

	event_scope = planet_event

	requirements = {
		handled_by_event_tooltip = TREASURE_HUNTERS_EXHIBITION_PROJECT_TOOLTIP
		has_technology = tech_galactic_archivism
	}

	abort_trigger = {
		OR = {
			NOT = { exists = from.owner }
			has_grand_archive = yes
		}
	}
}

special_project = {
	key = "BLACK_NEEDLE_BASE_BOMBARD"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 90
	timelimit = -1
	picture = GFX_evt_black_needle_base
	icon = "gfx/interface/icons/situation_log/situation_log_projectile.dds"
	location = yes
	remove_when_completed = yes
	project_type = project_type_bombardment

	event_scope = ship_event

	triggered_requirement = {
		text = BLACK_NEEDLE_BASE_BOMBARD_PROJECT_REQUIREMENT
		count = 1
		trigger = {
			OR = {
				is_ship_class = shipclass_military
				is_ship_class = shipclass_starbase
			}
			fleet_power >= 2000
		}
	}

	on_progress_25 = {
		ship_event = {
			id = grand_archive.8103
			scopes = { from = fromfrom }
		}
	}

	on_success = {
		ship_event = { id = grand_archive.8105 }
	}
}

special_project = {
	key = "BLACK_NEEDLE_BASE_BOMBARD_REINFORCEMENTS_KILLED"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 90
	timelimit = -1
	picture = GFX_evt_black_needle_base
	icon = "gfx/interface/icons/situation_log/situation_log_projectile.dds"
	location = yes
	project_type = project_type_bombardment
	remove_when_completed = yes

	event_scope = ship_event
	same_option_group_as = { BLACK_NEEDLE_BASE_BOMBARD }

	triggered_requirement = {
		text = BLACK_NEEDLE_BASE_BOMBARD_2_PROJECT_REQUIREMENT
		count = 1
		trigger = {
			OR = {
				is_ship_class = shipclass_military
				is_ship_class = shipclass_starbase
			}
			fleet_power >= 1000
		}
	}

	on_success = {
		ship_event = { id = grand_archive.8105 }
	}
}

special_project = {
	key = "BLACK_NEEDLE_BASE_DEPLOY_ARMIES"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 135
	timelimit = -1
	picture = GFX_evt_black_needle_base
	icon = "gfx/interface/icons/situation_log/situation_log_combat.dds"
	location = yes
	remove_when_completed = yes

	event_scope = ship_event
	same_option_group_as = { BLACK_NEEDLE_BASE_BOMBARD }

	requirements = {
		shipclass_transport = 4
	}

	on_success = {
		ship_event = { id = grand_archive.8110 }
	}
}

special_project = {
	key = "BLACK_NEEDLE_BASE_HACK"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 540
	timelimit = -1
	picture = GFX_evt_black_needle_base
	icon = "gfx/interface/icons/situation_log/situation_log_scanning_beam.dds"
	location = yes

	event_scope = ship_event
	same_option_group_as = { BLACK_NEEDLE_BASE_BOMBARD }
	remove_when_completed = yes

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
	}

	on_success = {
		random_list = {
			50 = {
				inline_script = {
					script = grand_archive/black_needle_base_hack_modifiers
					MODE = add
				}
				ship_event = { id = grand_archive.8115 }
			}
			50 = {
				inline_script = {
					script = grand_archive/black_needle_base_hack_modifiers
					MODE = subtract
				}
				ship_event = { id = grand_archive.8120 }
			}
		}
	}
}

special_project = {
	key = "DECODE_THIRD_MAP_PIECE"
	cost = 2000
	tech_department = physics_technology
	event_chain = "treasure_hunters_origin_story_chain"
	timelimit = -1
	picture = GFX_evt_treasure_hunt_2
	icon = "gfx/interface/icons/situation_log/situation_log_scanning_beam.dds"
	remove_when_completed = yes

	event_scope = country_event

	on_success = {
		country_event = {
			id = grand_archive.8135
		}
	}
}

special_project = {
	key = "TREASURE_HUNTERS_CHART_PIECE_3_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 60
	picture = GFX_evt_treasure_hunt_savannah
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"
	location = yes
	remove_when_completed = yes

	event_scope = ship_event

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
	}

	on_success = {
		prev = {
			country_event = {
				id = grand_archive.8270
				scopes = { from = root.from }
			}
		}
	}
}

special_project = {
	key = "TREASURE_HUNTERS_ANCIENT_CAPSULE_4_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	cost = 2000
	tech_department = physics_technology
	timelimit = -1
	picture = GFX_evt_treasure_hunt_4
	icon = "gfx/interface/icons/situation_log/situation_log_tick.dds"
	location = no
	remove_when_completed = yes

	event_scope = planet_event

	on_success = {
		prev = { country_event = { id = grand_archive.8280 } }
	}
}

special_project = {
	key = "GATEWAY_VOIDWORMS_KILL_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	picture = GFX_evt_voidworm_flock
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"
	location = yes
	remove_when_completed = yes

	event_scope = country_event

	requirements = {
		handled_by_event_tooltip = GATEWAY_VOIDWORMS_KILL_PROJECT_TT
	}
}

special_project = {
	key = "GATEWAY_VOIDWORMS_DEBRIS_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 30
	picture = GFX_evt_voidworm_flock
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"
	location = yes
	remove_when_completed = yes

	event_scope = ship_event

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
	}

	on_success = {
		destroy_ambient_object = from
		ship_event = {
			id = grand_archive.8310
		}
	}
}

special_project = {
	key = "RESEARCH_GATEWAY_ACTIVATION_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	picture = GFX_evt_drifting_gateway
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"
	location = yes
	remove_when_completed = yes

	event_scope = country_event

	requirements = {
		handled_by_event_tooltip = RESEARCH_GATEWAY_ACTIVATION_PROJECT_TT
	}
}

special_project = {
	key = "ACTIVATE_GATEWAY_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	picture = GFX_evt_drifting_gateway
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"
	location = yes
	remove_when_completed = yes

	event_scope = country_event

	requirements = {
		handled_by_event_tooltip = ACTIVATE_GATEWAY_PROJECT_TT
	}
}

special_project = {
	key = "ACTIVATE_GATEWAY_PROJECT_NOMADS"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 30
	tech_department = engineering_technology
	picture = GFX_evt_drifting_gateway
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"
	location = yes
	remove_when_completed = yes

	event_scope = country_event

	on_success = {
		set_country_flag = activating_ness_gate
		random_megastructure = {
			limit = {
				is_megastructure_type = gateway_ness_ruined
			}
			upgrade_megastructure_to = gateway_ness_restored
		}
	}
}

special_project = {
	key = "TREASURE_HUNTERS_BLACK_NEEDLE_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	timelimit = -1
	picture = GFX_evt_treasure_trove_pirate_fleet
	icon = "gfx/interface/icons/situation_log/situation_log_combat.dds"
	location = yes
	remove_when_completed = yes

	event_scope = country_event

	requirements = {
		handled_by_event_tooltip = TREASURE_HUNTERS_BLACK_NEEDLE_PROJECT_TOOLTIP
	}

	on_success = {
		root = {
			country_event = {
				id = grand_archive.8560
				days = 1
			}
		}
	}
}

special_project = {
	key = "CAPTAIN_NESS_HOARD_PROJECT"
	event_chain = "treasure_hunters_origin_story_chain"
	days_to_research = 30
	tech_department = engineering_technology
	picture = GFX_evt_treasure_hunt_4
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"
	location = yes
	remove_when_completed = yes

	event_scope = ship_event

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
	}

	on_success = {
		controller = {
			country_event = { id = grand_archive.8565 }
		}
	}
}

#############################
# Voidworms Crisis Projects #
#############################

special_project = {
	key = "VOIDWORM_GLANDS_PROJECT"
	timelimit = 1800
	picture = GFX_evt_voidworms
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"
	location = no

	event_scope = country_event

	requirements = {
		handled_by_event_tooltip = VOIDWORM_GLANDS_PROJECT_TOOLTIP
	}
}

special_project = {
	key = "VOIDWORM_TITAN_DEBRIS_PROJECT"
	days_to_research = 40
	tech_department = engineering_technology
	picture = GFX_evt_fauna_debris
	icon = "gfx/interface/icons/situation_log/situation_log_quest.dds"
	location = yes

	event_scope = ship_event

	requirements = {
		shipclass_science_ship = 1
		leader = scientist
	}

	on_success = {
		controller = {
			country_event = { id = grand_archive.2455 }
		}
	}
}

#############################
# Unique Mutations Projects #
#############################

special_project = {
	inline_script = {
		script = grand_archive/mutations/unique_mutation_special_project
		SHIP_CATEGORY = space_amoeba
		PICTURE = GFX_evt_friendly_amoeba
		EVENT_ID = grand_archive.10010
	}
}

special_project = {
	inline_script = {
		script = grand_archive/mutations/unique_mutation_special_project
		SHIP_CATEGORY = tiyanki
		PICTURE = GFX_evt_tiyanki_family
		EVENT_ID = grand_archive.10015
	}
}

special_project = {
	inline_script = {
		script = grand_archive/mutations/unique_mutation_special_project
		SHIP_CATEGORY = voidworm
		PICTURE = GFX_evt_voidworm_flock
		EVENT_ID = grand_archive.10020
	}
}

special_project = {
	inline_script = {
		script = grand_archive/mutations/unique_mutation_special_project
		SHIP_CATEGORY = cutholoid
		PICTURE = GFX_evt_cutholoids_attack
		EVENT_ID = grand_archive.10025
	}
}

special_project = {
	inline_script = {
		script = grand_archive/mutations/unique_mutation_special_project
		SHIP_CATEGORY = crystalline_entity
		PICTURE = GFX_evt_space_crystals
		EVENT_ID = grand_archive.10030
	}
}

special_project = {
	key = "tiyanki_matriarch_UNIQUE_MUTATION_PROJECT"
	cost = @tier4cost1
	tech_department = society_technology
	picture = GFX_evt_ancient_tiyanki
	icon = "gfx/interface/icons/situation_log/situation_log_society.dds"
	location = no

	event_scope = country_event

	on_success = {
		country_event = { id = grand_archive.10060 }
	}
}

special_project = {
	key = "voidspawn_UNIQUE_MUTATION_PROJECT"
	cost = @tier4cost1
	tech_department = society_technology
	picture = GFX_evt_voidspawn
	icon = "gfx/interface/icons/situation_log/situation_log_society.dds"
	location = no

	event_scope = country_event

	on_success = {
		country_event = { id = grand_archive.10080 }
	}
}
