# example_class = {
#	name = <name_key>
# 	name_plural = <name_plural_key>
# 	description = <description_key>
#
#	#all the following default to no
#	can_lead_army = yes/no			# Applies skill_<class_id>_army scaled by level to armies
#	can_lead_navy = yes/no			# Applies skill_<class_id>_navy scaled by level to fleets
#	can_govern_planet = yes/no		# Applies skill_<class_id>_planet_governor scaled by level to governed planet
									# Applies skill_<class_id>_sector_governor scaled by level to governed sector, if governing the sector capital
									# Applies skill_<class_id>_background_planet_governor scaled by level togoverned planet, if governing their homeworld
#	can_be_envoy = yes/no
# 	can_research_tech = yes/no
# 	can_research_special_projects = yes/no
# 	can_crew_science_ship = yes/no
# 	can_research_anomalies = yes/no
# 	can_research_archaeology_site = yes/no
# 	can_survey = yes/no
# 	can_boost_cloaking_detection = yes/no
# 	can_explore_rifts = yes/no
# 	can_conduct_active_reconnaissance = yes/no
# 	can_govern_planet = yes/no
# 	can_have_traits = yes/no	# defaults to yes, if no this class will not gain LEADER_ASSIGNED_MONTHLY_EXPERIENCE when assigned
#	can_rule_empire = yes/no	# defaults to yes
#	recruitable = yes/no		# defaults to yes
# 	max_trait_points = <num>
#	leader_capacity = <num>		# maximum number of leader of this type before you get maluses, 0 means no cap
#	replaces_old_class = "old_class"	# used for backwards compatibility. When "old_class" appears in an old save, it is converted to this class at loading
#										# can appear multiple times
#
# 	resources = { #upkeep
# 		category = leader_scientists/etc
# 		cost = {
# 			...
# 		}
# 	}
#
# 	ai_weight = {			# used to determine which type of leader the AI prefers (frex: commanders for warlike leaders, and governor for pacifists)
# 		base = <num>
#		modifier = {}
# 	}
#
#	ai_location_weight = {	# used to evaluate a specific leader for an assignment to a specific location (right now only used for fleet),
#							# scope is the leader, from is the leader location (can be a planet, a fleet, an army etc)
#							# if the score is 0 or less, the leader will not be assigned to that location
#		base = <num>
#		modifier = {}
#	}
#
# 	minimum_ai_target = <num>
#
# 	leader_background_job_weight = {
# 		job_name = <weight>
# 		# etc
# 	}
# }
#
# icon = 1 # 1-based index in the icon file. might be replaced by an icon name later
#
# paragon_background_selector = <name of an asset_selector>, used to display a background behind paragon portraits
#
#
# How the AI assigns leaders now:
#
# Step 1: Sort all possible location using the NDefines::NAI::LOCATION_WEIGHT_* values (all of them are multipliers except the galactic community which is a flat value)
# Step 2: Sort all available leaders by skill
# Step 3: for each leader in order, calculate a location weight based on the ai_location_weight of their class
# Step 4: Assign the highest leader/location pair based on the weight
# Step 5: if no leader was assigned, see if hiring a leader is possible repeating the same steps

@base_leader_cap = 3

official = {
	name = official
	name_plural = official_plural
	description = official_description
	can_govern_planet = yes
	max_trait_points = 1
	can_have_traits = yes
	can_be_assigned_to_federation = yes
	can_be_assigned_to_galactic_community = yes
	leader_capacity = @base_leader_cap
	resources = {
		category = leader_officials
		cost = {
			unity = 1
			mult = value:leader_cost
		}
		inline_script = "paragon/leader_base_upkeep"
		produces = {
			trigger = {
				exists = owner
				owner = {
					has_tradition = tr_politics_adopt
				}
				OR = {
					is_assigned_to_galcom = yes
					is_strengthing_imperial_authority = yes
					is_undermining_imperial_authority = yes
				}
			}
			influence = 0.1
			mult = trigger:has_total_skill
		}
	}

	ai_weight = {
		modifier = {
			factor = 2
			or = {
				is_pacifist = yes
				is_egalitarian = yes
			}
		}
	}

	ai_location_weight = {
		modifier = {
			add = 10
			exists = FROM
			from = {
				is_scope_type = colony
			}
		}
		complex_trigger_modifier = {
			potential = {
				exists = FROM
				from = {
					is_scope_type = colony
				}
			}
			trigger = pop_amount
			trigger_scope = from
			mode = add
			mult = 0.0001
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = colony
			MODIFIER = colony
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = federation
			MODIFIER = federation
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = galactic_community
			MODIFIER = galcom
		}
	}

	replaces_old_class = "governor"

	leader_background_job_weight = {
		high_priest = 100
		politician = 100
		noble = 100
		merchant = 100
		executive = 100
		colonist = 100
		culture_worker = 100
		bureaucrat = 100
		unifier = 100
		manager = 100
		entertainer = 100
		death_chronicler = 100
		artisan = 100
		reassigner = 100
		clerk = 100
		miner = 100
		crystal_miner = 100
		farmer = 100
		preacher = 100
		scrap_miner = 100
		angler = 100
	}
	icon = 4
	paragon_background_selector = "paragon_background_selector"
}

commander = {
	name = commander
	name_plural = commander_plural
	description = commander_description
	can_lead_navy = yes
	can_lead_army = yes
	can_govern_planet = yes
	max_trait_points = 1
	can_have_traits = yes
	leader_capacity = @base_leader_cap
	resources = {
		category = leader_commanders
		cost = {
			unity = 1
			mult = value:leader_cost
		}
		inline_script = "paragon/leader_base_upkeep"
	}
	ai_weight = {
		modifier = {
			factor = 2
			or = {
				is_militarist = yes
				is_authoritarian = yes
			}
		}
	}
	ai_location_weight = {
		modifier = {
			add = 10
			exists = FROM
			from = {
				OR = {
					is_scope_type = fleet
					is_scope_type = ship
				}
				is_civilian = no
			}
		}
		complex_trigger_modifier = {
			potential = {
				exists = FROM
				from = {
					OR = {
						is_scope_type = fleet
						is_scope_type = ship
					}
					is_civilian = no
				}
			}
			trigger = num_ships
			trigger_scope = from
			mode = add
			mult = 1
		}
		modifier = {
			add = 5
			exists = FROM
			from = {
				is_scope_type = colony
				planet_stability <= 10
			}
		}
		modifier = {
			add = 5
			exists = FROM
			from = {
				is_scope_type = colony
				planet_crime >= 25
			}
		}
		complex_trigger_modifier = {
			potential = {
				exists = FROM
				from = {
					is_scope_type = colony
					OR = {
						planet_stability <= 10
						planet_crime >= 25
					}
				}
			}
			trigger = pop_amount
			trigger_scope = from
			mode = add
			mult = 0.0001
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = colony
			MODIFIER = colony
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = fleet
			MODIFIER = fleet
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = army
			MODIFIER = army
		}
	}
	replaces_old_class = "admiral"
	replaces_old_class = "general"
	leader_background_job_weight = {
		noble = 100
		knight_commander = 100
		duelist = 100
		knight = 100
		ranger = 100
		squire = 100
	}
	icon = 1
	paragon_background_selector = "paragon_background_selector"
}

scientist = {
	name = scientist
	name_plural = scientist_plural
	description = scientist_description
	can_research_tech = yes
	can_research_special_projects = yes
	can_crew_science_ship = yes
	can_research_anomalies = yes
	can_survey = yes
	can_boost_cloaking_detection = yes
	can_research_archaeology_site = yes
	can_explore_rifts = yes
	can_conduct_active_reconnaissance = yes
	can_govern_planet = yes
	max_trait_points = 1
	leader_capacity = @base_leader_cap
	resources = {
		category = leader_scientists
		cost = {
			unity = 1
			mult = value:leader_cost
		}
		inline_script = "paragon/leader_base_upkeep"
	}

	ai_weight = {
		base = 50
	}
	ai_location_weight = {
		modifier = {
			add = 10
			exists = FROM
			FROM = {
				is_scope_type = ship
				is_ship_class = shipclass_science_ship
			}
		}
		modifier = {
			add = 1
			exists = FROM
			FROM = {
				is_scope_type = colony
			}
		}
		modifier = {
			mult = 10
			exists = FROM
			FROM = {
				is_scope_type = colony
				exists = owner
				owner = {
					has_valid_civic = civic_technocracy
				}
			}
		}
		complex_trigger_modifier = {
			potential = {
				exists = FROM
				from = {
					is_scope_type = colony
				}
			}
			trigger = pop_amount
			trigger_scope = from
			mode = add
			mult = 0.000025
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = colony
			MODIFIER = colony
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = fleet
			MODIFIER = self
		}
		inline_script = {
			script = paragon/num_traits_with_modifier
			SCOPE = fleet
			MODIFIER = fleet
		}
	}
	minimum_ai_target = 3
	leader_background_job_weight = {
		head_researcher = 100
		noble = 100
		colonist = 100
		researcher = 100
		xeno_zoo_keeper = 100
		telepath = 100
		chemist = 100
		translucer = 100
		gas_refiner = 100
		roboticist = 100
		healthcare = 100
		foundry = 100
		catalytic_technician = 100
		artificer = 100
		technician = 100
		gas_extractor = 100
		mote_harvester = 100
		puddle_technician = 100
	}
	icon = 3
	paragon_background_selector = "paragon_background_selector"
}

envoy = {
	name = envoy
	name_plural = envoy_plural
	description = envoy_description
	can_be_envoy = yes
	default_category = envoy
	assignment_cooldown = 360
	can_have_traits = no
	recruitable = no
	can_rule_empire = no
	can_be_assigned_to_federation = no
	can_be_assigned_to_galactic_community = no
	icon = 5
	paragon_background_selector = "paragon_background_selector"
	resources = {
		category = shroud_envoys
		produces = {
			trigger = {
				is_assigned_to_patron = yes
			}
			sr_zro = 0.5
			mult = value:disciple_of_the_cradle_envoy_zro_mult
		}
	}
}
