tr_synthetics_adopt = {
	possible = {
		if = {
			limit = { has_origin = origin_synthetic_fertility }
			has_technology = tech_synthetic_workers
		}
		else_if = {
			limit = {
				has_machine_age_dlc = yes
				is_machine_empire = no
				is_individual_machine = no
			}
			has_ascension_perk = ap_synthetic_evolution
			has_technology = tech_synthetic_workers
		}
		else = { # No Machine Age DLC
			if = {
				limit = {
					is_machine_empire = no
				}
				has_ascension_perk = ap_synthetic_evolution
				has_technology = tech_synthetic_workers
			}
			else = {
				has_ascension_perk = ap_synthetic_age
				has_technology = tech_robomodding_m
			}
		}
	}

	unlocks_agenda = agenda_synthetic_yield
	custom_tooltip_with_modifiers = tr_synthetics_adopt_desc

	on_enabled = { # has_machine_age_dlc = yes
		if = {
			limit = {
				NOT = {
					has_technology = tech_synthetic_leaders
				}
			}
			add_tech_progress = {
				tech = tech_synthetic_leaders
				progress = 0.1
			}
		}
		hidden_effect = {
			if = {
				limit = {
					has_origin = origin_synthetic_fertility
				}
				country_event = { id = machine_age.3125 }
			}
			else = {
				country_event = { id = synth.1 }
			}
			if = {
				limit = {
					any_planet_within_border = {
						has_planet_flag = fotd_seperatist_planet@root
						owner = {
							has_country_flag = fotd_seperatist_country@root
						}
					}
				}
				country_event = { id = origin.6099 days = 5 random = 2 }
			}
		}
	}

	tradition_swap = { # has_machine_age_dlc = no
		inherit_name = yes
		inherit_icon = yes
		trigger = {
			has_machine_age_dlc = no
			is_machine_empire = no
		}

		custom_tooltip = tr_synthetics_adopt_utopia_desc

		on_enabled = {
			if = {
				limit = {
					NOT = {
						has_technology = tech_synthetic_leaders
					}
				}
				add_tech_progress = {
					tech = tech_synthetic_leaders
					progress = 0.1
				}
			}
			hidden_effect = {
				country_event = { id = utopia.2550 }
				if = {
					limit = {
						any_planet_within_border = {
							has_planet_flag = fotd_seperatist_planet@root
							owner = {
								has_country_flag = fotd_seperatist_country@root
							}
						}
					}
					country_event = { id = origin.6099 days = 5 random = 2 }
				}
			}
		}
		weight = {
			factor = 1
		}
	}

	tradition_swap = {
		name = tr_synthetics_adopt_machine
		inherit_name = yes
		inherit_icon = yes
		trigger = {
			OR = {
				has_machine_age_dlc = no
				is_machine_empire = yes
			}
		}
		modifier = {
			pop_environment_tolerance = 0.25
		}
		weight = {
			factor = 1
		}
	}
}

tr_synthetics_finish = {
	on_enabled = {
		hidden_effect = {
			refresh_portraits = character
			if = {
				limit = {
					has_machine_age_dlc = yes
					has_country_flag = synthetics_traditions_unlocked
				}
				country_event = { id = synth.500 days = 180 }
			}
			else = {
				country_event = { id = timeline.79 }
			}
		}
	}
	modifier = {
		ROBOT_species_trait_picks_add = 2
		ROBOT_species_trait_points_add = 2
		modify_species_cost_mult = -0.5
		ascension_perks_add = 1
	}

	tradition_swap = {
		name = tr_synthetics_finish_machine
		inherit_name = no
		inherit_icon = yes
		inherit_effects = no
		custom_tooltip_with_modifiers = tr_synthetics_finish_machine_desc
		trigger = {
			is_machine_empire = yes
		}
		on_enabled = {
			hidden_effect = {
				machine_synthetic_leader_effect = yes
			}
		}
		modifier = {
			MACHINE_species_trait_picks_add = 2
			MACHINE_species_trait_points_add = 2
			modify_species_cost_mult = -0.5
			ascension_perks_add = 1
		}
		weight = {
			factor = 1
		}
	}

	tradition_swap = {
		name = tr_synthetics_finish_situation
		inherit_name = yes
		inherit_icon = yes
		trigger = {
			has_machine_age_dlc = yes
			NOR = {
				has_country_flag = synthetics_traditions_unlocked
				has_origin = origin_synthetic_fertility
			}
		}
		custom_tooltip = tr_synthetics_finish_situation_effects
	}
}

tr_synthetics_maintenance_protocols = {
	possible = {
		if = {
			limit = { has_machine_age_dlc = no }
			if = {
				limit = { is_synthetic_empire = yes }
			}
			else = {
				custom_tooltip = {
					fail_text = REQUIRES_SYNTHETIC_EMPIRE_UTOPIA
					is_synthetic_empire = yes
				}
			}
		}
	}

	modifier = {
		pop_amenities_usage_robotic_mult = -0.1
	}

	tradition_swap = {
		name = tr_synthetics_maintenance_protocols_situation
		inherit_name = yes
		inherit_icon = yes
		trigger = {
			has_machine_age_dlc = yes
			NOR = {
				has_country_flag = synthetics_traditions_unlocked
				has_origin = origin_synthetic_fertility
			}
		}
		custom_tooltip = tr_synthetics_maintenance_protocols_situation_effects
	}
}

tr_synthetics_optimization_algorithms = {
	possible = {
		has_tradition = tr_synthetics_maintenance_protocols
	}
	custom_tooltip_with_modifiers = BLANK_STRING
	modifier = {
		robotic_pop_bonus_workforce_mult = 0.10
	}

	tradition_swap = {
		name = tr_synthetics_optimization_algorithms_situation
		inherit_name = yes
		inherit_icon = yes
		trigger = {
			has_machine_age_dlc = yes
			NOR = {
				has_country_flag = synthetics_traditions_unlocked
				has_origin = origin_synthetic_fertility
			}
		}
		custom_tooltip = tr_synthetics_optimization_algorithms_situation_effects
	}
}

tr_synthetics_transubstatiation_synthesis = {
	possible = {
		if = {
			limit = { has_machine_age_dlc = no }
			if = {
				limit = { is_synthetic_empire = yes }
			}
			else = {
				custom_tooltip = {
					fail_text = REQUIRES_SYNTHETIC_EMPIRE_UTOPIA
					is_synthetic_empire = yes
				}
			}
		}
	}

	on_enabled = {
		set_country_flag = synth_assimilation
	}

	custom_tooltip = tr_synthetics_transubstatiation_synthesis_desc

	tradition_swap = {
		name = tr_synthetics_solid_state_actuators
		inherit_effects = no
		inherit_icon = no
		trigger = {
			OR = {
				AND = {
					has_machine_age_dlc = yes
					has_valid_civic = civic_fanatic_purifiers
					has_country_flag = synthetics_traditions_unlocked
				}
				AND = {
					has_machine_age_dlc = no
					has_valid_civic = civic_fanatic_purifiers
				}
				AND = {
					has_machine_age_dlc = no
					is_machine_empire = yes
				}
			}
		}
		modifier = {
			leader_lifespan_mult = 0.2
		}

		weight = {
			factor = 1
		}
	}

	tradition_swap = {
		name = tr_synthetics_solid_state_actuators_virtual
		inherit_effects = no
		inherit_icon = yes
		trigger = {
			AND = {
				has_valid_civic = civic_fanatic_purifiers
				has_country_flag = synth_virtual
			}
		}
		modifier = {
			leaders_cost_mult = -0.15
			leaders_upkeep_mult = -0.15
		}

		weight = {
			factor = 1
		}
	}

	tradition_swap = {
		name = tr_synthetics_transubstatiation_synthesis_situation
		inherit_name = yes
		inherit_icon = yes
		trigger = {
			has_machine_age_dlc = yes
			NOR = {
				has_country_flag = synthetics_traditions_unlocked
				has_origin = origin_synthetic_fertility
				has_valid_civic = civic_fanatic_purifiers
			}
		}
		custom_tooltip = tr_synthetics_transubstatiation_synthesis_situation_effects
	}

	tradition_swap = {
		name = tr_synthetics_solid_state_actuators_situation
		inherit_name = no
		inherit_icon = no
		trigger = {
			has_machine_age_dlc = yes
			has_valid_civic = civic_fanatic_purifiers
			NOR = {
				has_country_flag = synthetics_traditions_unlocked
				has_origin = origin_synthetic_fertility
			}
		}
		custom_tooltip = tr_synthetics_solid_state_actuators_situation_effects
	}
}

tr_synthetics_power_systems = {
	possible = {
		has_tradition = tr_synthetics_transubstatiation_synthesis
	}

	modifier = {
		planet_pops_robotics_upkeep_mult = -0.25
		planet_pop_assemblers_upkeep_mult = -0.25
	}

	tradition_swap = {
		name = tr_synthetics_power_systems_situation
		inherit_name = yes
		inherit_icon = yes
		trigger = {
			has_machine_age_dlc = yes
			NOR = {
				has_country_flag = synthetics_traditions_unlocked
				has_origin = origin_synthetic_fertility
			}
			is_machine_empire = no
		}
		custom_tooltip = tr_synthetics_power_systems_situation_effects
	}
}

tr_synthetics_prefabricated_components = {
	possible = {
		has_tradition = tr_synthetics_transubstatiation_synthesis
	}
	modifier = {}

	custom_tooltip = tr_synthetics_prefabricated_components_effects

	tradition_swap = {
		name = tr_synthetics_prefabricated_components_situation
		inherit_name = yes
		inherit_icon = yes
		trigger = {
			has_machine_age_dlc = yes
			NOR = {
				has_country_flag = synthetics_traditions_unlocked
				has_origin = origin_synthetic_fertility
			}
			is_machine_empire = no
		}
		weight = {
			factor = 1
		}
		custom_tooltip = tr_synthetics_prefabricated_components_situation_effects
	}

	tradition_swap = {
		name = tr_synthetics_prefabricated_components_machine
		inherit_name = no
		inherit_effects = no
		inherit_icon = yes
		trigger = {
			has_machine_age_dlc = no
			is_machine_empire = yes
		}

		weight = {
			factor = 1
		}
		custom_tooltip = tr_synthetics_prefabricated_components_machine_effects
	}
}
