# Telepath jobs (Default Gestalt)
telepath_drone = {
	category = complex_drone
	can_be_automated = no

	swappable_data = {
		default = {
			condition_string = DRONE_JOB_TRIGGER
			building_icon = building_psi_corps
		}
	}

	tags = { crime enforcer unity telepath psionic_aura }

	possible_pre_triggers = {
		has_owner = yes
		is_enslaved = no
		is_being_purged = no
		is_being_assimilated = no
		is_sapient = yes
	}

	possible_precalc = can_fill_drone_job
	possible = {
		can_think = yes
		has_psionic_species_trait = yes
	}

	inline_script = "jobs/job_telepath_resources"

	inline_script = "jobs/job_enforcer_additional_modifiers"
	inline_script = "jobs/job_telepath_additional_modifiers"

	inline_script = "jobs/automodding_priority_unity"

	weight = {
		weight = @complex_drone_job_weight
	}
}

# Shroud Forged jobs
physician_drone = {
	category = complex_drone

	swappable_data = {
		default = {
			condition_string = DRONE_JOB_TRIGGER
			building_icon = building_machine_capital
			icon = aid_worker
		}
	}

	possible_pre_triggers = {
		has_owner = yes
		is_enslaved = no
		is_being_purged = no
		is_being_assimilated = no
		is_sapient = yes
	}

	tags = { unity }

	possible_precalc = can_fill_drone_job

	possible = { can_think = yes }

	resources = {
		category = planet_doctors
		produces = {
			unity = 3
		}
		upkeep = {
			energy = 4
		}
	}

	triggered_planet_modifier = {
		planet_amenities_no_happiness_add = 500
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	weight = {
		weight = @complex_drone_job_weight
		mult = value:scripted_job_weight_shroud_forged_mult
	}
}

observator_drone = {
	category = complex_drone

	swappable_data = {
		default = {
			condition_string = DRONE_JOB_TRIGGER
			building_icon = building_shroud_observatory_1
		}
	}

	possible = {
		always = no
	}
}

#=======================
# Energy Thralls

energy_thrall = {
	category = worker

	swappable_data = {
		default = {
			condition_string = WORKER_JOB_TRIGGER
			building_icon = building_lifecrypt_1
		}
	}

	tags = { unity energy_thrall }

	possible_pre_triggers = {
		has_owner = yes
		is_being_purged = no
		is_being_assimilated = no
		is_sapient = yes
	}

	possible_precalc = can_fill_worker_job

	resources = {
		category = planet_energy_thralls
		produces = {
			unity = 1
		}
	}

	triggered_country_modifier = {
		potential = {
			exists = owner
		}
		species_leader_exp_gain = 0.05
	}

	weight = {
		weight = @worker_job_weight
		modifier = {
			factor = 0.2
			has_citizenship_rights = no
			NOT = { has_trait = trait_mechanical }
		}
		modifier = {
			factor = 0.1
			can_take_servant_job = yes
		}
	}

	inline_script = "jobs/automodding_priority_unity"
}

drone_energy_thrall = {
	category = simple_drone

	swappable_data = {
		default = {
			condition_string = DRONE_JOB_TRIGGER
			building_icon = building_lifecrypt_1
			icon = energy_thrall
		}
	}

	tags = { unity energy_thrall }

	possible_pre_triggers = {
		has_owner = yes
		is_enslaved = no
		is_being_purged = no
		is_being_assimilated = no
		is_sapient = yes
	}

	possible_precalc = can_fill_drone_job

	possible = { can_think = yes }

	resources = {
		category = planet_energy_thralls
		produces = {
			unity = 1
		}
	}

	triggered_country_modifier = {
		potential = {
			exists = owner
		}
		species_leader_exp_gain = 0.05
	}

	triggered_planet_modifier = {
		potential = {
			owner? = { has_active_tradition = tr_synchronicity_integrated_preservation }
		}
		modifier = {
			planet_crime_no_happiness_add = -3
		}
	}

	triggered_planet_modifier = {
		planet_amenities_no_happiness_add = 300
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	weight = {
		weight = @synapse_drone_job_weight
		mult = value:scripted_modifier_job_weight_mult|MODIFIER|pop_job_amenities_mult|
	}

	inline_script = "jobs/automodding_priority_unity"
}

#=======================
# Test Subjects

test_subject = {
	category = criminal
	is_capped_by_modifier = yes
	contributes_to_diplo_weight = no
	can_be_automated = no

	swappable_data = {
		default = {
			building_icon = building_experimentation_chambers_1
		}
	}

	tags = { research test_subject }

	possible_pre_triggers = {
		has_owner = yes
		is_sapient = yes
	}

	possible = {
		# check that this is not a robot in servitude
		NOT = {
			has_citizenship_type = {
				country = owner
				type = citizenship_robot_servitude
			}
		}
		owner = {
			is_gestalt = no
		}
	}

	resources = {
		category = planet_test_subjects
		produces = {
			engineering_research = 0.5
			physics_research = 0.5
			society_research = 1
		}
		upkeep = {
			consumer_goods = 1
		}
	}

	planet_modifier = {
		branch_office_criminal_syndicate_value_add = 7.5
	}

	triggered_planet_modifier = {
		potential = {
			owner? = { NOT = { has_valid_civic = civic_dystopian_society } }
		}
		planet_amenities_add = 300
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	triggered_planet_modifier = {
		potential = {
			colony? = {
				has_branch_office = yes
				branch_office_owner = {
					has_councilor = { COUNCILOR = "councilor_criminal_heritage" }
				}
			}
		}

		branch_office_criminal_syndicate_value_add = 0.25
		mult = value:pop_branch_office_councilor_level|TYPE|councilor_criminal_heritage|
	}

	weight = {
		weight = @criminal_job_weight
	}

	can_set_priority = no
}

test_subject_drone = {
	category = deviant_drone
	is_capped_by_modifier = yes
	contributes_to_diplo_weight = no

	swappable_data = {
		default = {
			building_icon = building_experimentation_chambers_1
			icon = test_subject
		}
	}

	tags = { research test_subject }

	possible_pre_triggers = {
		has_planet = yes
		is_sapient = yes
	}

	resources = {
		category = planet_test_subjects
		produces = {
			engineering_research = 0.5
			physics_research = 0.5
			society_research = 1
		}
		upkeep = {
			energy = 1
		}
	}

	triggered_planet_modifier = {
		potential = {
			owner? = { NOT = { has_valid_civic = civic_dystopian_society } }
		}
		planet_amenities_add = 300
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	weight = {
		weight = @criminal_job_weight
	}

	can_set_priority = no
}

#=======================
# Experiment Engineers

experiment_engineer = {
	category = specialist

	swappable_data = {
		default = {
			condition_string = SPECIALIST_JOB_TRIGGER
			building_icon = building_experimentation_chambers_1
		}
	}

	tags = { research experiment_engineer }

	possible_pre_triggers = {
		has_owner = yes
		is_being_purged = no
		is_being_assimilated = no
		is_sapient = yes
	}

	possible_precalc = can_fill_specialist_job
	possible = {
		complex_specialist_job_check_trigger = yes
	}

	triggered_country_modifier = {
		potential = {
			exists = colony
		}
		modifier = {
			country_naval_cap_add = 1
		}
		mult = colony.modifier:job_researcher_naval_cap_add
	}

	inline_script = "jobs/inf_navalcap_jobs"

	resources = {
		category = planet_experiment_engineer
		produces = {
			physics_research = @experiment_engineer_research_output
			engineering_research = @experiment_engineer_research_output
			society_research = @experiment_engineer_research_output
		}
		upkeep = {
			consumer_goods = 1
		}
		upkeep = {
			trigger = {
				has_carrier_flag = has_science_ministry
			}
			consumer_goods = 0.5
		}
	}

	overlord_resources = {
		category = planet_requisitioned_research
		produces = {
			trigger = {
				colony? = {
					has_carrier_flag = has_science_ministry
				}
			}
			physics_research = 0.5
			engineering_research = 0.5
			society_research = 0.5
		}
	}

	weight = {
		weight = @specialist_job_weight
		modifier = {
			factor = 0.2
			has_citizenship_rights = no
			NOT = { has_trait = trait_mechanical }
		}
		modifier = {
			factor = 2
			has_living_standard = { type = living_standard_academic_privilege }
		}
		modifier = {
			factor = 0.1
			can_take_servant_job = yes
		}
		modifier = {
			factor = 0.8
			is_enslaved = yes
			has_slavery_type = { type = slavery_indentured }
		}
		modifier = {
			factor = 5
			has_trait = trait_cyborg_creed_of_research
		}
	}

	inline_script = "jobs/automodding_priority_research"
}

experiment_engineer_drone = {
	category = complex_drone

	swappable_data = {
		default = {
			condition_string = DRONE_JOB_TRIGGER
			building_icon = building_experimentation_chambers_1
			icon = experiment_engineer
		}
	}

	tags = { minerals research experiment_engineer }

	possible_pre_triggers = {
		has_owner = yes
		is_enslaved = no
		is_being_purged = no
		is_being_assimilated = no
		is_sapient = yes
	}

	possible_precalc = can_fill_drone_job

	possible = { can_think = yes }

	resources = {
		category = planet_experiment_engineer
		produces = {
			physics_research = @experiment_engineer_research_output
			engineering_research = @experiment_engineer_research_output
			society_research = @experiment_engineer_research_output
		}
		upkeep = {
			minerals = 3
		}
		upkeep = {
			trigger = {
				has_carrier_flag = has_science_ministry
			}
			minerals = 1.5
		}
	}

	overlord_resources = {
		category = planet_requisitioned_research
		produces = {
			trigger = {
				colony? = {
					has_carrier_flag = has_science_ministry
				}
			}
			physics_research = 0.5
			engineering_research = 0.5
			society_research = 0.5
		}
	}

	triggered_country_modifier = {
		potential = {
			exists = colony
		}
		modifier = {
			country_naval_cap_add = 1
		}
		mult = colony.modifier:job_researcher_naval_cap_add
	}

	inline_script = "jobs/inf_navalcap_jobs"

	weight = {
		weight = @complex_drone_job_weight
		modifier = {
			factor = 0.9
			exists = owner
			years_passed < 1
			owner = { has_valid_civic = civic_machine_assimilator }
			has_trait = trait_cybernetic
		}
	}

	inline_script = "jobs/automodding_priority_research"
}

#=======================
# Slave Orderly

slave_orderly = {
	category = worker
	is_capped_by_modifier = no

	swappable_data = {
		default = {
			building_icon = building_experimentation_chambers_1
		}
	}

	possible_pre_triggers = {
		is_enslaved = yes
		has_planet = yes
		is_sapient = yes
		is_robotic = no
	}

	possible = {
		owner? = { is_twisted_experimenters_empire = yes }
		has_slavery_type = {
			type = slavery_orderly
		}
	}

	resources = {}

	planet_modifier = {
		pop_experiment_engineer_bonus_workforce_mult = 0.025
		pop_test_subject_bonus_workforce_mult = 0.025
	}

	triggered_planet_modifier = {
		potential = {
			owner? = { NOT = { has_valid_civic = civic_dystopian_society } }
		}
		planet_amenities_add = 500
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	weight = {
		weight = @special_job_weight
	}
}

#=======================
# Production Overseer

production_overseer = {
	category = specialist
	can_be_automated = no
	swappable_data = {
		default = {
			condition_string = SPECIALIST_JOB_TRIGGER
			building_icon = building_automation_1
		}
	}

	tags = { unity }

	possible_pre_triggers = {
		has_owner = yes
		is_being_purged = no
		is_being_assimilated = no
		is_sapient = yes
	}

	possible_precalc = can_fill_specialist_job
	possible = {
		complex_specialist_job_check_trigger = yes
	}

	resources = {
		category = planet_production_overseers
		produces = {
			engineering_research = 2
		}
		upkeep = {
			consumer_goods = 1
		}
	}

	triggered_planet_modifier = {
		potential = {
			owner? = { NOT = { has_valid_civic = civic_dystopian_society } }
		}
		planet_amenities_add = 200
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	planet_modifier = {
		bonus_automated_workforce_mult = 0.02
	}

	weight = {
		weight = @specialist_job_weight
		mult = value:scripted_modifier_job_weight_mult|MODIFIER|pop_job_amenities_mult|
		modifier = {
			factor = 0.2
			has_citizenship_rights = no
			NOT = { has_trait = trait_mechanical }
		}
		modifier = {
			factor = 0.1
			can_take_servant_job = yes
		}
		modifier = {
			factor = 2
			owner? = { is_tankbound_empire = yes }
		}
	}

	inline_script = "jobs/automodding_priority_unity"
}

#=======================
# Specialist Colonist
#=======================

spe_colonist = {
	inline_script = {
		script = shroud/jobs/colonist_job
		CATEGORY = specialist
		CONDITION_STRING = SPECIALIST_JOB_TRIGGER
		POSSIBLE_PRECALC = can_fill_specialist_job
	}

	possible = {
		hidden_trigger = { exists = owner }
		owner = { is_tankbound_empire = yes }
	}
}

#=======================
# Extra-dimensional Research Unit
#=======================

extradimensional_research_unit = {
	category = complex_drone

	swappable_data = {
		default = {
			condition_string = DRONE_JOB_TRIGGER
			building_icon = building_materiality_engine
		}
	}

	possible = {
		always = no
	}
}

#=======================
# Psionic Traders
#=======================

shroud_trader = {
	category = specialist

	swappable_data = {
		default = {
			condition_string = SPECIALIST_JOB_TRIGGER
			building_icon = building_psi_corps
			icon = telepath
		}
	}

	tags = { trade amenities }

	possible_pre_triggers = {
		has_owner = yes
		is_being_purged = no
		is_being_assimilated = no
		is_sapient = yes
	}

	possible_precalc = can_fill_specialist_job

	resources = {
		category = planet_traders
		produces = {
			trade = 6
		}
		produces = {
			trigger = {
				owner? = { has_breached_shroud = yes }
			}
			unity = 2
		}
		upkeep = {
			consumer_goods = 1
		}
		upkeep = {
			trigger = {
				owner? = { has_breached_shroud = yes }
			}
			consumer_goods = 1
		}
	}

	triggered_planet_modifier = {
		potential = {
			owner? = {
				has_tradition = tr_mercantile_commercial_enterprise
				NOT = {
					has_valid_civic = civic_dystopian_society
				}
			}
		}
		planet_amenities_add = 200
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	triggered_planet_modifier = {
		potential = {
			colony.orbital_defence.starbase? = {
				has_starbase_building = ring_trade_hub
			}
			owner? = { NOT = { has_valid_civic = civic_dystopian_society } }
		}
		planet_amenities_add = 100
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	triggered_planet_modifier = {
		potential = {
			starbase? = {
				has_starbase_building = arkship_trade_hub
			}
			owner? = { NOT = { has_valid_civic = civic_dystopian_society } }
		}
		planet_amenities_add = 100
		mult = value:scripted_modifier_mult|MODIFIER|pop_job_amenities_mult|
	}

	country_modifier = {
		category_psionics_draw_chance_mult = 0.01
	}

	weight = {
		weight = @specialist_job_weight
		mult = value:scripted_modifier_job_weight_mult|MODIFIER|pop_job_amenities_mult|
		# crisis purge
		modifier = {
			factor = 0.01
			colony.controller? = {
				OR = {
					is_country_type = swarm
					is_country_type = ai_empire
				}
			}
			OR = { # contingency won't purge itself
				NOT = { exists = event_target:custodian_bot }
				AND = {
					exists = event_target:custodian_bot
					NOT = { species = { is_same_value = event_target:custodian_bot } }
				}
			}
		}
	}

	inline_script = "jobs/automodding_priority_trade"

}
