###########################
# Ascension-path versions of APB's genetic perks (added for 4.6)
#
# Archetypes: Synthetic Evolution turns pops into ROBOT; machine intelligences and individual
# machines are MACHINE; cyborgs and lithoids use the BIOLOGICAL trait pools (Fountain of Youth
# and Engineered Excellency are open to the Cybernetic path in apb_ascension_perks.txt).
# Synthetic and machine leaders are already immortal (vanilla trait_robot_immortality), so the
# synthetic Fountain equivalent gives the machine version of the youth bonuses instead.
###########################

###########################
# Perfected Architecture - ROBOT version of Engineered Excellency
###########################
ap_perfected_architecture = {
	possible = {
		custom_tooltip = {
			fail_text = "requires_synthetic_ascension_robot"
			has_synthetic_ascension = yes
		}
	}
	modifier = {
		ROBOT_species_trait_points_add = 5
		ROBOT_species_trait_picks_add = 2
		modify_species_cost_mult = -0.5
	}
	potential = {
		is_machine_empire = no
		is_individual_machine = no
		NOT = { has_ascension_perk = ap_perfected_architecture }
	}
	ai_weight = { factor = 3 }
}

ap_perfected_architecture_tier_2 = {
	modifier = {
		ROBOT_species_trait_points_add = 10
		ROBOT_species_trait_picks_add = 3
		modify_species_cost_mult = -0.5
	}
	potential = {
		has_ascension_perk = ap_perfected_architecture
		NOT = {
			has_ascension_perk = ap_perfected_architecture_tier_2
			has_global_flag = apb_tier_locked
		}
	}
	ai_weight = { factor = 0 }
}

ap_perfected_architecture_tier_3 = {
	modifier = {
		ROBOT_species_trait_points_add = 15
		ROBOT_species_trait_picks_add = 4
	}
	potential = {
		has_ascension_perk = ap_perfected_architecture_tier_2
		NOT = {
			has_ascension_perk = ap_perfected_architecture_tier_3
			has_global_flag = apb_tier_locked
		}
	}
	ai_weight = { factor = 0 }
}

ap_perfected_architecture_tier_4 = {
	modifier = {
		ROBOT_species_trait_points_add = 20
		ROBOT_species_trait_picks_add = 5
	}
	potential = {
		has_ascension_perk = ap_perfected_architecture_tier_3
		NOT = {
			has_ascension_perk = ap_perfected_architecture_tier_4
			has_global_flag = apb_tier_locked
		}
	}
	ai_weight = { factor = 0 }
}

ap_perfected_architecture_tier_5 = {
	modifier = {
		ROBOT_species_trait_points_add = 25
		ROBOT_species_trait_picks_add = 6
	}
	potential = {
		has_ascension_perk = ap_perfected_architecture_tier_4
		NOT = {
			has_ascension_perk = ap_perfected_architecture_tier_5
			has_global_flag = apb_tier_locked
		}
	}
	ai_weight = { factor = 0 }
}

###########################
# Optimised Schematics - MACHINE version of Engineered Excellency
# (machine intelligences and individual machines, Synthetic Age path)
###########################
ap_optimised_schematics = {
	possible = {
		custom_tooltip = {
			fail_text = "requires_ap_synthetic_age"
			has_ascension_perk = ap_synthetic_age
		}
	}
	modifier = {
		MACHINE_species_trait_points_add = 5
		MACHINE_species_trait_picks_add = 2
		modify_species_cost_mult = -0.5
	}
	potential = {
		OR = {
			is_machine_empire = yes
			is_individual_machine = yes
		}
		NOT = { has_ascension_perk = ap_optimised_schematics }
	}
	ai_weight = { factor = 3 }
}

ap_optimised_schematics_tier_2 = {
	modifier = {
		MACHINE_species_trait_points_add = 10
		MACHINE_species_trait_picks_add = 3
		modify_species_cost_mult = -0.5
	}
	potential = {
		has_ascension_perk = ap_optimised_schematics
		NOT = {
			has_ascension_perk = ap_optimised_schematics_tier_2
			has_global_flag = apb_tier_locked
		}
	}
	ai_weight = { factor = 0 }
}

ap_optimised_schematics_tier_3 = {
	modifier = {
		MACHINE_species_trait_points_add = 15
		MACHINE_species_trait_picks_add = 4
	}
	potential = {
		has_ascension_perk = ap_optimised_schematics_tier_2
		NOT = {
			has_ascension_perk = ap_optimised_schematics_tier_3
			has_global_flag = apb_tier_locked
		}
	}
	ai_weight = { factor = 0 }
}

ap_optimised_schematics_tier_4 = {
	modifier = {
		MACHINE_species_trait_points_add = 20
		MACHINE_species_trait_picks_add = 5
	}
	potential = {
		has_ascension_perk = ap_optimised_schematics_tier_3
		NOT = {
			has_ascension_perk = ap_optimised_schematics_tier_4
			has_global_flag = apb_tier_locked
		}
	}
	ai_weight = { factor = 0 }
}

ap_optimised_schematics_tier_5 = {
	modifier = {
		MACHINE_species_trait_points_add = 25
		MACHINE_species_trait_picks_add = 6
	}
	potential = {
		has_ascension_perk = ap_optimised_schematics_tier_4
		NOT = {
			has_ascension_perk = ap_optimised_schematics_tier_5
			has_global_flag = apb_tier_locked
		}
	}
	ai_weight = { factor = 0 }
}

###########################
# Perpetual Maintenance - Fountain of Youth for synthetics and machines
# perk -> apb_maintenance.100 -> special project -> apb_maintenance.101 -> tech
# -> species trait (added by species modification) -> per-class leader traits
###########################
ap_perpetual_maintenance = {
	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
		custom_tooltip = {
			fail_text = "requires_technology_robomodding"
			OR = {
				has_technology = tech_robomodding
				has_technology = tech_robomodding_m
			}
		}
	}
	on_enabled = {
		custom_tooltip = enable_perpetual_maintenance_project
		custom_tooltip = describe_perpetual_maintenance_project
		hidden_effect = {
			country_event = { id = apb_maintenance.100 }
		}
	}
	modifier = {
		ROBOT_species_trait_picks_add = 1
		MACHINE_species_trait_picks_add = 1
	}
	potential = {
		has_synthetic_ascension = yes
		NOT = { has_ascension_perk = ap_perpetual_maintenance }
	}
	ai_weight = { factor = 3 }
}

###########################
# Shroud-Touched Longevity - psionic counterpart of Fountain of Youth
# A very long life rather than immortality, so it stays distinct from the genetic perk.
###########################
ap_shroud_touched_longevity = {
	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
		custom_tooltip = {
			fail_text = "requires_psionic_ascension"
			has_psionic_ascension = yes
		}
	}
	modifier = {
		leader_lifespan_add = 50
		species_leader_exp_gain = 0.1
		BIOLOGICAL_species_trait_picks_add = 1
	}
	potential = {
		is_machine_empire = no
		NOT = { has_ascension_perk = ap_shroud_touched_longevity }
	}
	ai_weight = { factor = 3 }
}
