#############
# COMMANDER #
#############

@ai_selection_high = 5
@ai_selection_low = 0.1

subclass_commander_admiral = {
	custom_subtitle = commander_subclass
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = commander_admiral
		COUNCIL = no
	}
	custom_tooltip_with_modifiers = admiral_subclass_tt
	modifier = {
		ship_weapon_damage = 0.05
		ship_fire_rate_mult = 0.05
		ship_disengage_chance_mult = 0.15
	}
	triggered_modifier = {
		potential = {
			leader_class = commander
			owner? = {
				is_nomadic = yes
			}
		}
		science_ship_survey_speed = 0.15
	}
	leader_potential_add = {
		NAND = {
			owner = { has_civic = civic_distinguished_admiralty }
			is_heir = yes
		}
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_low
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_high
		}
		modifier = {
			exists = fleet
			NOT = {
				fleet = {
					is_ship_class = shipclass_transport
				}
			}
			factor = @ai_selection_high
		}
		modifier = {
			NOT = {
				exists = fleet
			}
			factor = @ai_selection_low
		}
	}
	leader_class = { commander }
	background_icon = "GFX_leader_subclass_commander_admiral_background"
}

subclass_commander_general = {
	custom_subtitle = commander_subclass
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = commander_general
		COUNCIL = no
	}
	custom_tooltip_with_modifiers = general_subclass_tt

	fleet_modifier = {
		ship_damage_against_starbases_mult = 0.1
		ship_orbital_bombardment_mult = 0.1
	}

	army_modifier = {
		army_damage_mult = 0.1
	}

	triggered_background_planet_modifier = {
		potential = {
			exists = FROM
			FROM = {
				exists = owner
				owner = {
					is_same_value = root.owner
					NOT = { has_origin = origin_toxic_knights }
				}
			}
			trait_is_wilderness_check = no
		}
		planet_soldiers_produces_mult = 0.05
	}

	leader_potential_add = {
		trait_is_crisis_faction_check = no
		NAND = {
			owner = { has_civic = civic_distinguished_admiralty }
			is_heir = yes
		}
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_low
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_high
		}
		modifier = {
			OR = {
				AND = {
					exists = fleet
					fleet = {
						is_ship_class = shipclass_transport
					}
				}
				owner = {
					any_owned_army = {
						exists = leader
						leader = {
							is_same_value = root
						}
					}
				}
			}
			factor = @ai_selection_high
		}
		modifier = {
			NOT = {
				owner = {
					any_owned_army = {
						exists = leader
						leader = {
							is_same_value = root
						}
					}
				}
			}
			factor = @ai_selection_low
		}
	}
	leader_class = { commander }
	background_icon = "GFX_leader_subclass_commander_general_background"
}

subclass_commander_governor = {
	custom_subtitle = commander_subclass
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = commander_governor
		COUNCIL = no
	}
	custom_tooltip_with_modifiers = governor_subclass_tt
	planet_modifier = {
		job_soldier_stability_add = 0.5
		specialist_and_complex_drone_cat_bonus_workforce_mult = 0.05
	}
	sector_modifier = {
		job_soldier_stability_add = 0.25
		specialist_and_complex_drone_cat_bonus_workforce_mult = 0.025
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_low
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_high
		}
		modifier = {
			exists =  planet
			factor = @ai_selection_high
		}
		modifier = {
			NOT = { exists =  planet }
			factor = @ai_selection_low
		}
	}
	leader_potential_add = {
		trait_is_crisis_faction_check = no
	}
	leader_class = { commander }
	background_icon = "GFX_leader_subclass_commander_governor_background"
}

subclass_commander_councilor = {
	custom_subtitle = councilor_subclass_commander
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = commander_councilor
		COUNCIL = yes
	}
	custom_tooltip_with_modifiers = councilor_subclass_tt
	triggered_councilor_modifier = {
		potential = {
			exists = owner
			owner = { is_gestalt = no }
		}
		shipclass_military_build_speed_mult = 0.1
		starbase_shipyard_build_cost_mult = -0.01
	}
	leader_potential_add = {
		trait_is_crisis_faction_check = no
		NAND = {
			exists = owner
			owner = { is_gestalt = yes }
		}
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_high
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_low
		}
	}
	leader_class = { commander }
	background_icon = "GFX_leader_subclass_commander_councilor_background"
}

#############
# OFFICIAL #
#############

subclass_official_delegate = {
	custom_subtitle = governor_subclass
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = official_delegate
		COUNCIL = no
	}
	leader_class = { official }
	custom_tooltip_with_modifiers = delegate_subclass_tt
	
	self_modifier = {
		leader_trait_selection_options_add = 1
	}

	federation_modifier = {
		cohesion_add = 0.5
	}

	galcom_modifier = {
		diplo_weight_mult = 0.05
	}

	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_low
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_high
		}
		modifier = {
			OR = {
				is_assigned_to_federation = yes
				is_assigned_to_galcom = yes
			}
			factor = @ai_selection_high
		}
		modifier = {
			OR = {
				is_assigned_to_federation = no
				is_assigned_to_galcom = no
			}
			factor = @ai_selection_low
		}
	}
	background_icon = "GFX_leader_subclass_official_delegate_background"
}

subclass_official_governor = {
	custom_subtitle = governor_subclass
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = official_governor
		COUNCIL = no
	}
	custom_tooltip_with_modifiers = governor_subclass_tt

	planet_modifier = {
		planet_jobs_specialist_produces_mult = 0.05
		pop_amenities_usage_mult = -0.1
	}
	sector_modifier = {
		planet_jobs_specialist_produces_mult = 0.025
		pop_amenities_usage_mult = -0.05
	}

	leader_class = { official }

	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_low
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_high
		}
		modifier = {
			exists =  planet
			factor = @ai_selection_high
		}
		modifier = {
			NOT = { exists =  planet }
			factor = @ai_selection_low
		}
	}

	background_icon = "GFX_leader_subclass_official_governor_background"
}

subclass_official_diplomacy_councilor = {
	custom_subtitle = councilor_subclass_governor
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = official_diplomacy_councilor
		COUNCIL = yes
	}
	custom_tooltip_with_modifiers = councilor_subclass_tt

	triggered_councilor_modifier = {
		potential = {
			exists = owner
			owner = { is_gestalt = no }
		}
		country_trust_growth = 0.15
		country_councilor_influence_produces_add = 0.15
	}

	leader_potential_add = {
		NAND = {
			exists = owner
			owner = { is_gestalt = yes }
		}
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_high
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_low
		}
	}
	leader_class = { official }
	background_icon = "GFX_leader_subclass_official_diplomacy_councilor_background"
}

subclass_official_economy_councilor = {
	custom_subtitle = councilor_subclass_governor
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = official_economy_councilor
		COUNCIL = yes
	}
	custom_tooltip_with_modifiers = councilor_subclass_tt

	triggered_councilor_modifier = {
		potential = {
			exists = owner
			owner = { is_gestalt = no }
		}
		planet_pops_upkeep_mult = -0.05
		country_trade_produces_mult = 0.05
	}

	leader_potential_add = {
		NAND = {
			exists = owner
			owner = { is_gestalt = yes }
		}
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_high
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_low
		}
	}
	leader_class = { official }
	background_icon = "GFX_leader_subclass_official_economy_councilor_background"
}

#############
# SCIENTIST #
#############

subclass_scientist_explorer = {
	custom_subtitle = scientist_subclass
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = scientist_explorer
		COUNCIL = no
	}
	custom_tooltip_with_modifiers = explorer_subclass_tt
	modifier = {
		ship_sensor_range_add = 1
		science_ship_survey_speed = 0.1
		ship_anomaly_generation_chance_mult = 0.1
	}
	triggered_background_planet_modifier = {
		potential = {
			exists = FROM
			FROM = {
				exists = owner
				owner = {
					is_same_value = root.owner
				}
			}
		}
		planet_jobs_physics_research_produces_mult = 0.05
	}


	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_low
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_high
		}
		modifier = {
			exists = fleet
			NOT = {
				fleet = {
					is_ship_class = shipclass_transport
				}
			}
			factor = @ai_selection_high
		}
		modifier = {
			NOT = {
				exists = fleet
			}
			factor = @ai_selection_low
		}
	}

	leader_class = { scientist }
	background_icon = "GFX_leader_subclass_scientist_explorer_background"
}

subclass_scientist_scholar = {
	custom_subtitle = scientist_subclass
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = scientist_scholar
		COUNCIL = no
	}
	custom_tooltip_with_modifiers = scholar_subclass_tt

	modifier = {
		ship_anomaly_research_speed_mult = 0.1
		ship_archaeological_site_excavation_speed_mult = 0.1
		country_astral_rift_speed_mult = 0.1
	}
	triggered_background_planet_modifier = {
		potential = {
			exists = FROM
			FROM = {
				exists = owner
				owner = {
					is_same_value = root.owner
				}
			}
		}
		planet_jobs_society_research_produces_mult = 0.05
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_low
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_high
		}
		modifier = {
			exists = fleet
			NOT = {
				fleet = {
					is_ship_class = shipclass_transport
				}
			}
			factor = @ai_selection_high
		}
		modifier = {
			NOT = {
				exists = fleet
			}
			factor = @ai_selection_low
		}
	}

	leader_class = { scientist }
	background_icon = "GFX_leader_subclass_scientist_scholar_background"
}

subclass_scientist_governor = {
	custom_subtitle = scientist_subclass
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = scientist_governor
		COUNCIL = no
	}
	custom_tooltip_with_modifiers = governor_subclass_tt
	planet_modifier = {
		planet_jobs_physics_research_produces_mult = 0.10
		planet_jobs_society_research_produces_mult = 0.10
		planet_jobs_engineering_research_produces_mult = 0.10
	}
	sector_modifier = {
		planet_jobs_physics_research_produces_mult = 0.05
		planet_jobs_society_research_produces_mult = 0.05
		planet_jobs_engineering_research_produces_mult = 0.05
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_low
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_high
		}
		modifier = {
			exists =  planet
			factor = @ai_selection_high
		}
		modifier = {
			NOT = { exists =  planet }
			factor = @ai_selection_low
		}
	}
	leader_class = { scientist }
	background_icon = "GFX_leader_subclass_scientist_governor_background"
}

subclass_scientist_councilor = {
	custom_subtitle = councilor_subclass_scientist
	leader_trait_type = subclass
	inline_script = {
		script = trait/icon_subclass
		SUBCLASS = scientist_councilor
		COUNCIL = yes
	}
	custom_tooltip_with_modifiers = councilor_subclass_tt

	triggered_councilor_modifier = {
		potential = {
			exists = owner
			owner = { is_gestalt = no }
		}
		all_technology_research_speed = 0.05
	}
	leader_potential_add = {
		NAND = {
			exists = owner
			owner = { is_gestalt = yes }
		}
	}
	ai_weight = {
		modifier = {
			is_councilor = yes
			factor = @ai_selection_high
		}
		modifier = {
			is_councilor = no
			factor = @ai_selection_low
		}
	}
	leader_class = { scientist }
	background_icon = "GFX_leader_subclass_scientist_councilor_background"
}
