#######################
# CLOAKING Technology #
#######################

######################
# Physics Technology #
######################

# Basic Cloaking Devices
tech_cloaking_1 = {
	cost = @tier2cost3
	area = physics
	tier = 2
	category = { field_manipulation }
	is_rare = yes
	prerequisites = { "tech_shields_2" }
	weight = @tier2weight3

	potential = {
		has_first_contact_dlc = yes
	}

	# Unlocks Active Reconnaissance
	feature_flags = {
		active_reconnaissance_unlocked
	}

	prereqfor_desc = {
		hide_prereq_for_desc = component
		custom = {
			title = "TECH_UNLOCK_CLOAKING_1_TITLE"
			desc = "TECH_UNLOCK_CLOAKING_1_DESC"
		}
	}

	gateway = cloaking

	weight_modifier = {
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_curator }
		}
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_fotd_scientist }
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_cloaking_1
		}
		modifier = {
			factor = 5
			has_tradition = tr_subterfuge_adopt
		}
		modifier = {
			factor = 2
			has_cloaking_civic_or_origin = yes
		}
	}

	ai_weight = {
		modifier = {
			factor = 2.0
			has_ai_personality_behaviour = sneak_attacker
		}
	}
}

# Advanced Cloaking Devices
tech_cloaking_2 = {
	cost = @tier3cost3
	area = physics
	tier = 3
	category = { field_manipulation }
	is_rare = yes
	prerequisites = { "tech_cloaking_1" "tech_shields_3" }
	weight = @tier3weight3

	potential = {
		has_first_contact_dlc = yes
	}

	prereqfor_desc = {
		hide_prereq_for_desc = component
		custom = {
			title = "TECH_UNLOCK_CLOAKING_2_TITLE"
			desc = "TECH_UNLOCK_CLOAKING_2_DESC"
		}
	}

	weight_modifier = {
		modifier = {
			factor = 0
			NOR = {
				has_technology = tech_mine_exotic_gases
				has_technology = tech_exotic_gases
				has_country_flag = has_market_access
			}
		}
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_curator }
		}
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_fotd_scientist }
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_cloaking_2
		}
		modifier = {
			factor = 5
			has_tradition = tr_subterfuge_adopt
		}
		modifier = {
			factor = 2
			has_cloaking_civic_or_origin = yes
		}
	}

	ai_weight = {
		modifier = {
			factor = 2.0
			has_ai_personality_behaviour = sneak_attacker
		}
	}
}

# Elite Cloaking Devices
tech_cloaking_3 = {
	cost = @tier4cost3
	area = physics
	tier = 4
	category = { field_manipulation }
	is_rare = yes
	prerequisites = { "tech_cloaking_2" "tech_shields_4" }
	weight = @tier4weight3

	potential = {
		has_first_contact_dlc = yes
	}

	prereqfor_desc = {
		hide_prereq_for_desc = component
		custom = {
			title = "TECH_UNLOCK_CLOAKING_3_TITLE"
			desc = "TECH_UNLOCK_CLOAKING_3_DESC"
		}
	}

	weight_modifier = {
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_curator }
		}
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_fotd_scientist }
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_cloaking_3
		}
		modifier = {
			factor = 5
			has_tradition = tr_subterfuge_adopt
		}
		modifier = {
			factor = 2
			has_cloaking_civic_or_origin = yes
		}
	}

	ai_weight = {
		modifier = {
			factor = 2.0
			has_ai_personality_behaviour = sneak_attacker
		}
	}
}

# Dark Matter Cloaks
tech_cloaking_dark_matter = {
	cost = @fallentechcost
	area = physics
	tier = @fallentechtier
	category = { field_manipulation }
	weight = @tier5weight2
	is_rare = yes
	is_dangerous = yes

	prerequisites = { "tech_dark_matter_deflector" "tech_cloaking_3" }

	prereqfor_desc = {
		hide_prereq_for_desc = component
		custom = {
			title = "TECH_UNLOCK_CLOAKING_DARK_MATTER_TITLE"
			desc = "TECH_UNLOCK_CLOAKING_DARK_MATTER_DESC"
		}
	}

	weight_modifier = {
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_curator }
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_cloaking_dark_matter
		}
		modifier = {
			factor = 5
			has_tradition = tr_subterfuge_adopt
		}
		modifier = {
			factor = 2
			has_cloaking_civic_or_origin = yes
		}
	}

	ai_weight = {
		modifier = {
			factor = 2.0
			has_ai_personality_behaviour = sneak_attacker
		}
	}
}

######################
# Society Technology #
######################

# Psionic Cloaks

tech_cloaking_psi = {
	cost = @tier5cost3
	area = society
	tier = 5
	category = { psionics }
	is_rare = yes
	prerequisites = { "tech_psi_jump_drive_1" }
	weight = @tier5weight2
	is_reverse_engineerable = no

	potential = {
		OR = {
			has_shroud_dlc = yes
			NOT = { has_ethic = ethic_gestalt_consciousness }
		}
		has_first_contact_dlc = yes
	}

	prereqfor_desc = {
		hide_prereq_for_desc = component
		custom = {
			title = "TECH_UNLOCK_CLOAKING_PSI_TITLE"
			desc = "TECH_UNLOCK_CLOAKING_PSI_DESC"
		}
	}

	weight_modifier = {
		modifier = {
			factor = 0.1
			NOR = {
				has_trait_in_council = { TRAIT = leader_trait_expertise_psionics }
				has_trait_in_council = { TRAIT = leader_trait_curator }
				has_trait_in_council = { TRAIT = leader_trait_spark_of_genius }
				has_trait_in_council = { TRAIT = leader_trait_spark_of_genius_2 }
				has_trait_in_council = { TRAIT = leader_trait_maniacal }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_2 }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_3 }
			}
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_cloaking_psi
		}
		modifier = {
			factor = 5
			has_tradition = tr_subterfuge_adopt
		}
		modifier = {
			factor = 2
			has_cloaking_civic_or_origin = yes
		}
	}

	ai_weight = {
		modifier = {
			factor = 2.0
			has_ai_personality_behaviour = sneak_attacker
		}
	}
}

########################
# DETECTION Technology #
########################

# Basic Cloak Detection Platform
tech_detection_array = {
	cost = @tier2cost3
	area = physics
	tier = 2
	category = { computing }
	is_rare = yes
	prerequisites = { "tech_sensors_2" }
	weight = @tier2weight3

	potential = {
		has_first_contact_dlc = yes
	}

	# unlocks starbase module - detection array

	gateway = detection

	weight_modifier = {
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_curator }
		}
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_fotd_scientist }
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_detection_array
		}
		modifier = {
			factor = 5
			has_tradition = tr_subterfuge_adopt
		}
	}
}

# Dark Matter Detection Booster
tech_dark_matter_detection = {
	cost = @tier5cost3
	area = physics
	tier = 5
	category = { particles }
	is_rare = yes
	prerequisites = { "tech_detection_array" "tech_mine_dark_matter" }
	weight = @tier5weight3

	potential = {
		has_first_contact_dlc = yes
	}

	# unlocks starbase building - dark matter resonance chamber

	weight_modifier = {
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_curator }
		}
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_fotd_scientist }
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_dark_matter_detection
		}
		modifier = {
			factor = 5
			has_tradition = tr_subterfuge_adopt
		}
	}
}

# Assisted Detection Algorithms
tech_assisted_detection = {
	cost = @tier2cost3
	area = physics
	tier = 2
	category = { computing }
	is_rare = yes
	prerequisites = { "tech_detection_array" }
	weight = @tier2weight3

	potential = {
		has_first_contact_dlc = yes
	}

	# Unlocks Assist Cloaking Detection
	feature_flags = {
		assist_cloaking_detection_unlocked
	}

	weight_modifier = {
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_curator }
		}
		modifier = {
			factor = value:tech_weight_likelihood
			has_trait_in_council = { TRAIT = leader_trait_fotd_scientist }
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_assisted_detection
		}
		modifier = {
			factor = 5
			has_tradition = tr_subterfuge_adopt
		}
	}
}

########################################
# Basic Jump Drive for Eager Explorers #
########################################

tech_subspace_drive = {
	cost = @tier0cost1
	area = physics
	tier = 0
	category = { particles }
	is_reverse_engineerable = no
	is_rare = yes
	weight = 0
	start_tech = yes

	potential = {
		has_first_contact_dlc = yes
	}

	feature_flags = {
		jump_method
	}

	weight_modifier = {
		factor = 0
	}

	prereqfor_desc = {
		component = {
			title = "TECH_UNLOCK_SUBSPACE_DRIVE_TITLE"
			desc = "TECH_UNLOCK_SUBSPACE_DRIVE_DESC"
		}
	}

	starting_potential = {
		is_eager_explorer_empire = yes
	}
}

#######################
#   Pre-FTL Insights  #
#######################

######################
# Physics Technology #
######################

tech_unusual_senses = {
	cost = @tier2cost3
	area = physics
	tier = 2
	category = { particles }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	prereqfor_desc = {
		custom = {
			title = tech_unusual_senses_effect
		}
	}

	modifier = {
		envoys_add = @insight_envoy_gain
	}
}

tech_new_numbers = {
	cost = @tier2cost3
	area = physics
	tier = 2
	category = { computing }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @insight_envoy_gain
		all_technology_research_speed = 0.05
	}
}

tech_trinary_computing = {
	cost = @tier2cost3
	area = physics
	tier = 2
	category = { computing }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @insight_envoy_gain
		espionage_operation_speed_mult = 0.1
		espionage_operation_difficulty_add = -1
	}
}

tech_atmospheric_orbital_mechanics = {
	cost = @tier2cost3
	area = physics
	tier = 2
	category = { computing }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @insight_envoy_gain
		station_gatherers_produces_mult = 0.05
		station_researchers_produces_mult = 0.05
		stations_upkeep_mult = -0.5
	}

	technology_swap = {
		name = tech_atmospheric_orbital_mechanics
		inherit_icon = yes
		trigger = {
			is_nomadic = yes
		}
		modifier = {
			envoys_add = @insight_envoy_gain
			starbase_waystations_upkeep_mult = -0.2
			ship_starbase_stockpile_collection_rate_add = @arkship_collection_rate_add_125
		}
	}
}

######################
# Society Technology #
######################

# Predatory Tactics
tech_predatory_tactics = {
	cost = @tier2cost3
	area = society
	tier = 2
	category = { military_theory }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	prereqfor_desc = {
		custom = {
			title = tech_predatory_tactics_effect
		}
	}

	modifier = {
		envoys_add = @major_insight_envoy_gain
	}

	ai_weight = {
		modifier = {
			factor = 2
			has_technology = tech_cloaking_1
		}
		modifier = {
			factor = 4
			has_technology = tech_cloaking_2
		}
		modifier = {
			factor = 4
			has_technology = tech_cloaking_3
		}
	}
}

# Satisfying Insult
tech_satisfying_insults = {
	cost = @tier2cost3
	area = society
	tier = 2
	category = { statecraft }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	prereqfor_desc = {
		custom = {
			title = tech_satisfying_insults_effect
		}
	}

	modifier = {
		envoys_add = @major_insight_envoy_gain
		country_insult_efficiency = 0.5
	}

	ai_weight = {
		modifier = {
			factor = 2
			values_others = no
		}
	}
}

# Compact Living
tech_compact_living = {
	cost = @tier2cost3
	area = society
	tier = 2
	category = { statecraft }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @major_insight_envoy_gain
		empire_size_penalty_mult = -0.05
	}

	ai_weight = {
		modifier = {#This is just a good tech
			factor = 2
		}
	}
}

# Alien Topography
tech_alien_topography = {
	cost = @tier2cost3
	area = society
	tier = 2
	category = { new_worlds }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @major_insight_envoy_gain
		planet_non_artificial_max_districts_add = 1
	}

	technology_swap = {
		name = tech_alien_topography
		inherit_icon = yes
		trigger = {
			OR = {
				is_nomadic = yes
				has_void_dweller_origin = yes
			}
		}
		modifier = {
			envoys_add = @major_insight_envoy_gain
			planet_artificial_max_districts_add = 1
		}
	}

	ai_weight = {
		modifier = {#This is just a good tech
			factor = 2
		}
	}
}

# Xeno Astethics
tech_xeno_aesthetics = {
	cost = @tier2cost3
	area = society
	tier = 2
	category = { statecraft }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @major_insight_envoy_gain
		damage_vs_rival_mult = 0.1
	}

	ai_weight = {
		modifier = {
			factor = 2
			num_rivals > 0
		}
	}
}

##########################
# Engineering Technology #
##########################

# Lost Building Methods
tech_lost_building_methods = {
	cost = @tier2cost3
	area = engineering
	tier = 2
	category = { industry }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @insight_envoy_gain
		empire_size_districts_mult = -0.3
		planet_districts_cost_mult = -0.3
	}
}

# Supreme Alloy
tech_supreme_alloy = {
	cost = @tier2cost3
	area = engineering
	tier = 2
	category = { materials }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @insight_envoy_gain
		planet_metallurgists_alloys_produces_add = 0.25
	}
}

# Ordered Retreat
tech_ordered_retreat = {
	cost = @tier2cost3
	area = engineering
	tier = 2
	category = { voidcraft }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @insight_envoy_gain
		fleet_mia_time_mult = -0.15
	}
}

# Temple of Transportation
tech_temple_of_transportation = {
	cost = @tier2cost3
	area = engineering
	tier = 2
	category = { voidcraft }
	is_insight = yes
	weight = 0

	potential = {
		has_first_contact_dlc = yes
	}

	modifier = {
		envoys_add = @insight_envoy_gain
		megastructures_hyper_relay_unity_produces_add = 1
	}
}
