# These have to be duplicated for each of the 4 Kurultai. In other words, if you make a change in one of them, reflect it across all of them
# Kurultai 1
task_kurultai_default_1 = {
	default_task = yes
	position = councillor_kurultai_1

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_default.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	council_owner_modifier = {
		name = task_kurultai_default_modifier
		herd_gain_mult = 0.01
		herd_capacity_mult = 0.01
		scale = kurultai_manage_herd_final_value
	}

	task_type = task_type_general
	task_progress = task_progress_infinite

	effect_desc = { 
		desc = task_kurultai_default_effect_desc 
		desc = task_kurultai_default_herd_gain_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Herd
			triggered_desc = {
				trigger = {
					scope:councillor = {
						diplomacy >= low_skill_rating
					}
				}
				desc = task_kurultai_default_gain_herd
			}
			# Bonus Army
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						diplomacy >= high_skill_rating
					}
				}
				desc = task_kurultai_default_bonus_army
			}
			## Negative
			# Lose Herd
			triggered_desc = {
				trigger = {
					scope:councillor = {
						diplomacy <= very_high_skill_rating
					}
				}
				desc = task_kurultai_default_lose_herd
			}
			# Lose Control
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						diplomacy <= decent_skill_rating
					}
				}
				desc = task_kurultai_default_lose_control
			}
		}
	}

	monthly_on_action = task_help_herders_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 500
		if = { # 
			limit = {
				scope:councillor = { highest_skill = diplomacy }
			}
			add = 500
		}
	}
}

task_kurultai_fertility_1 = {
	position = councillor_kurultai_1

	task_type = task_type_county
	county_target = realm
	ai_county_target = domain

	task_progress = task_progress_value
	task_current_value = scope:county.county_fertility
	task_max_value = 100 # Highest possible county fertility

	highlight_own_realm = yes

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_fertility.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	county_modifier = {
		name = task_kurultai_fertility_modifier
		county_fertility_growth_mult = 0.01
		scale = kurultai_increased_fertility_scale_value
	}

	potential_county = {
		exists = scope:county.holder
		scope:county = { is_landless_type_title = no }
		custom_tooltip = {
			text = task_kurultai_use_fertility
			scope:county.holder = { 
				OR = {
					government_has_flag = government_is_nomadic 
					government_has_flag = government_is_herder
				}
			}
		}
		custom_tooltip = {
			text = task_kurultai_fertility_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_fertility_2
					is_target_of_council_task = task_kurultai_fertility_3
					is_target_of_council_task = task_kurultai_fertility_4
				}
			}	
		}
		custom_tooltip = {
			text = task_kurultai_exploited_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_exploit_area_2
					is_target_of_council_task = task_kurultai_exploit_area_3
					is_target_of_council_task = task_kurultai_exploit_area_4
				}
			}	
		}
	}

	effect_desc = { 
		desc = task_kurultai_fertility_effect_desc 
		desc = task_kurultai_fertility_gain_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Increase Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship >= low_skill_rating
					}
				}
				desc = task_kurultai_fertility_increase_fertility
			}
			# Increase Popular Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						stewardship >= high_skill_rating
					}
				}
				desc = task_kurultai_fertility_county_opinion
			}
			## Negative
			# Lose Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= very_high_skill_rating
					}
				}
				desc = task_kurultai_fertility_reduce_fertility
			}
			# Prestige Loss
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= decent_skill_rating
					}
				}
				desc = task_kurultai_fertility_lose_prestige
			}
		}
	}

	monthly_on_action = task_manage_fertility_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 500
		if = { # 
			limit = {
				scope:councillor = { highest_skill = stewardship }
			}
			add = 500
		}
		if = {
			limit = {
				capital_county ?= { 
					uses_county_fertility = yes
					county_fertility <= 50 
				}
			}
			add = 1000
		}
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_manage_fertility
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 10000
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_fertility_2
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_fertility_3
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_fertility_4
					}
				}
				divide = 4
			}
		}
	}
}

task_kurultai_control_1 = {
	position = councillor_kurultai_1
	task_type = task_type_county
	county_target = realm
	ai_county_target = domain
	task_progress = task_progress_value
	task_current_value = scope:councillor_liege.marshal_increase_control_current_progress
	task_max_value = 100 # Highest possible county control
	highlight_own_realm = yes
	restart_on_finish = yes # If it "finishes" by removing a corruption modifier, there'll still be control to regain
	
	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_control.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	effect_desc = {
		desc = task_kurultai_control_effect_desc
		desc = task_kurultai_increase_control_effect_desc
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					scope:councillor_liege = {
						any_active_accolade = {
							has_accolade_parameter = accolade_increase_control_bonus
						}
					}
				}
				desc = task_increase_control_acclaimed_knight_subdues_peasantry
			}
			triggered_desc = {
				trigger = {
					martial > mediocre_skill_rating
				}
				desc = task_increase_control_increase_opinion
			}
			triggered_desc = {
				trigger = {
					martial > mediocre_skill_rating
				}
				desc = task_increase_control_baron_opinion_increase
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_lose_opinion
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_lose_control
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_baron_opinion_loss
			}
		}
	}
	
	# TOTAL PROGRESS MUST MATCH THE TOTAL OF THE COUNTY MODIFIERS BELOW
		# Add all new progress values to the script value marshal_increase_control_total
		# Note that for Increase Control, the County Modifiers apply the actual values, while progress is for player info only
	progress = {
		value = 0
		add = {
			value = marshal_increase_control_base
			desc = INCREASE_CONTROL_BASE
		}
		add = {
			value = scope:councillor.marshal_increase_county_control_monthly_change
			desc = SCALED_COUNCILLOR_MARTIAL_VALUE
		}
		# Relation Bonuses/Penalties
		if = { # Friend
			limit = {
				scope:councillor_liege = {
					has_relation_friend = scope:councillor
					NOT = { has_relation_best_friend = scope:councillor }
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_friend_bonus
				desc = COUNCILLOR_IS_YOUR_FRIEND
			}
		}
		if = { # Best Friend
			limit = {
				scope:councillor_liege = {
					has_relation_best_friend = scope:councillor
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_best_friend_bonus
				desc = COUNCILLOR_IS_YOUR_BEST_FRIEND
			}
		}
		if = { # Rival
			limit = {
				scope:councillor_liege = {
					has_relation_rival = scope:councillor
					NOT = { has_relation_nemesis = scope:councillor }
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_rival_bonus
				desc = COUNCILLOR_IS_YOUR_RIVAL
			}
		}
		if = { # Nemesis
			limit = {
				scope:councillor_liege = {
					has_relation_nemesis = scope:councillor
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_nemesis_bonus
				desc = COUNCILLOR_IS_YOUR_NEMESIS
			}
		}
		if = {
			limit = {
				scope:councillor_liege = { has_perk = strict_organization_perk }
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_perk_bonus_monthly_change
				desc = INCREASE_CONTROL_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_erudition_bonus_monthly_change
				desc = ERUDITION_DYNASTY_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_family_business_bonus = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_family_business_bonus_monthly_change
				desc = FAMILY_BUSINESS_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_consulted_house_bonus_monthly_change
				desc = CONSULTED_HOUSE_BONUS_VALUE
			}
		}
		if = {
			limit = {
				scope:councillor = { has_character_modifier = event_bonus_to_county_control }
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_experience_bonus_monthly_change
				desc = INCREASE_COUNTY_CONTROL_EXPERIENCE_BONUS_VALUE
			}
		}
		if = {
			limit = { exists = scope:county }
			multiply = {
				value = scope:county.monthly_county_control_growth_factor
				desc = MARSHAL_COUNTY_SPEED_MODIFIERS
			}
		}
		if = {
			limit = {
				exists = scope:county
				scope:county = { has_county_modifier = petition_liege_county_control_modifier }
			}
			add = {
				value = scope:councillor.petition_liege_county_control_modifier_value
				desc = MARSHAL_INCREASE_CONTROL_LOCAL_COUNTY_MODIFIERS
			}
		}
		#EP3
		if = {
			limit = {
				scope:councillor_liege = {
					employs_court_position = court_jester_court_position
					court_position:court_jester_court_position = {
						has_character_flag = famous_mime_control
					}
				}
			}
			add = {
				value = scope:councillor_liege.court_position:court_jester_court_position.marshal_court_jester_contribution_value
				desc = MARSHAL_INCREASE_CONTROL_MIME_MODIFIER
			}
		}
	}

	full_progress = marshal_increase_control_full_progress
	custom_other_loc = MARSHAL_COUNTY_SPEED_OTHER

	potential_county = {
		scope:county = {
			is_landless_type_title = no
			custom_description = {
				text = potential_county_control_task_trigger
				OR = {
					has_county_corruption_trigger = yes
					county_control < full_county_control
				}
			}
			# If the growth factor is 0, no amount of trying to control helps
			# (happens when the county is under siege/occupied most likely)
			monthly_county_control_growth_factor > 0
			custom_tooltip = {
				text = potential_county_control_task_only_one_target
				scope:county = {
					NOR = {
						is_target_of_council_task = task_kurultai_control_2
						is_target_of_council_task = task_kurultai_control_3
						is_target_of_council_task = task_kurultai_control_4
					}
				}
			}
		}
	}

	county_modifier = {
		name = marshal_increase_control_modifier
		monthly_county_control_growth_add = 1
		scale = marshal_increase_control_total
	}

	on_start_task_county = {
		#spawn a task contract
		if = {
			limit = {
				scope:councillor_liege = {
					is_independent_ruler = yes					
				}
				any_player = {
					is_landless_adventurer = yes
					is_within_diplo_range = { CHARACTER = scope:councillor }
					any_character_task_contract = {
						has_task_contract_type = laamp_help_increase_control_contract
						count <= council_task_contracts_limit_value
					}
					can_create_task_contract = {
						type_name = laamp_help_increase_control_contract
						employer = scope:councillor
					}
					save_temporary_scope_as = player_laamp
				}
			}
			scope:player_laamp = {
				create_task_contract = {
					task_contract_type = laamp_help_increase_control_contract
					task_contract_tier = scope:councillor.task_contract_tier_value
					location = scope:county.title_province
					task_contract_employer = scope:councillor
					target = scope:councillor.liege
					destination = scope:county.title_province
					save_scope_as = task_contract					
				}
			}
		}
	}
	on_finish_task_county = {
		if = {
			limit = {
				scope:county = {
					has_county_corruption_trigger = yes
				}
			}
			scope:county = {
				marshal_remove_random_county_corruption_modifier_effect = yes
				change_county_control = -25
			}
		}
	}

	monthly_on_action = increase_control_monthly_on_action

	on_monthly_county = {
		random = {
			chance = scope:councillor.marshal_remove_county_corruption_chance
			scope:county = {
				marshal_remove_random_county_corruption_modifier_effect = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 1000 # Highest prio
		if = { # Keep doing Organize levies if you're at war
			limit = {
				scope:councillor_liege = {
					is_at_war = no
				}
			}
			add = 19000
		}
		if = { # Keep doing Organize levies if you're at war
			limit = {
				is_performing_council_task = task_organize_levies
				scope:councillor_liege = {
					is_at_war = yes
				}
			}
			add = -1000
		}
		if = { # Stop doing this if Organize levies could help you lose less gold during a war
			limit = {
				NOT = {
					is_performing_council_task = task_organize_levies
				}
				scope:councillor_liege = {
					is_at_war = yes
					monthly_character_income < monthly_character_expenses
				}
			}
			add = -1000
		}
	}
}

task_kurultai_court_astrologer_1 = {
	position = councillor_kurultai_1

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_court_astrologer.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		liege_or_court_owner ?= {
			employs_court_position = court_astrologer_court_position
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	council_owner_modifier = {
		name = task_kurultai_court_astrologer_modifier
		monthly_piety_gain_mult = 0.01
		scale = kurultai_court_astrologer_piety_final_value
	}

	effect_desc = { 
		desc = task_kurultai_court_astrologer_effect_desc 
		desc = task_kurultai_court_astrologer_piety_desc
		desc = task_kurultai_court_astrologer_aptitude_desc
		# You have the Zealous Proselytizer perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = zealous_proselytizer_perk }
			}
			desc = task_kurultai_court_astrologer_zealous_proselytizer_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Piety 
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning >= low_skill_rating
					}
				}
				desc = task_kurultai_astrologer_increase_piety
			}
			# Gain Astrologer Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						learning >= high_skill_rating
					}
				}
				desc = task_kurultai_astrologer_increase_opinion
			}
			## Negative
			# Lose Piety
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning <= very_high_skill_rating
					}
				}
				desc = task_kurultai_astrologer_reduce_piety
			}
			# Lose Astrologer Opinion
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						learning <= decent_skill_rating
					}
				}
				desc = task_kurultai_astrologer_reduce_opinion
			}
		}
	}

	monthly_on_action = task_manage_astrologer_on_action

	ai_will_do = {
		value = 250
		if = { # 
			limit = {
				scope:councillor = { highest_skill = learning }
			}
			add = 500
		}
		if = {
			limit = {
				piety < 50
			}
			add = 1000
		}
	}
}

task_kurultai_domestic_affairs_1 = {
	position = councillor_kurultai_1

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_domestic_affairs.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_domestic_affairs_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_2
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_3
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	effect_desc = {
		desc = task_kurultai_domestic_affairs_effect_desc
		# Direct Vassal Opinion
		desc = task_domestic_affairs_direct_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			desc = chancellor_domestic_affairs_opinion_pandidakterion_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_opinion_food_bonus_desc
		}
		# Parochial Vassal Opinion
		desc = task_domestic_affairs_parochial_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			desc = chancellor_domestic_affairs_opinion_pandidakterion_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_opinion_food_bonus_desc
		}
		# Tyranny Loss
		desc = task_domestic_affairs_tyranny_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_tyranny_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_tyranny_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_tyranny_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_tyranny_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_tyranny_food_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_improved_vassal_opinion
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
					liege = {
						any_vassal = {
							government_has_flag = government_is_feudal
							primary_title.tier > tier_barony
						}
					}
				}
				desc = task_increase_control_improve_vassal_contract
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_end_internal_war
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_force_vassal_partition
			}
			triggered_desc = {
				trigger = {
					diplomacy < high_skill_rating
				}
				desc = task_increase_control_lose_vassal_opinion
			}
			triggered_desc = {
				trigger = {
					diplomacy < high_skill_rating
					liege = {
						any_vassal = {
							government_has_flag = government_is_feudal
							primary_title.tier > tier_barony
						}
					}
				}
				desc = task_increase_control_worsen_contract
			}
		}
	}

	on_start_task = {
		liege = {
			set_variable = {
				name = chancellor_domestic_affairs_opinion_value
				value = 0
			}
		}
	}

	on_cancel_task = {
		if = {
			limit = {
				is_alive = yes
				has_variable = chancellor_domestic_affairs_opinion_value
			}
			remove_variable = chancellor_domestic_affairs_opinion_value
		}
	}

	council_owner_modifier = {
		name = task_domestic_affairs_opinion_modifier
		direct_vassal_opinion = 1
		scale = chancellor_domestic_affairs_opinion_scale
	}

	council_owner_modifier = {
		name = task_domestic_affairs_parochial_opinion_modifier
		parochial_opinion = 1
		scale = chancellor_domestic_affairs_opinion_scale
	}

	council_owner_modifier = {
		name = task_domestic_affairs_opinion_modifier
		tyranny_loss_mult = 0.01
		scale = chancellor_domestic_affairs_tyranny_total
	}

	monthly_on_action = task_domestic_affairs_side_effects

	on_monthly = {
		if = {
			limit = {
				liege = { is_ai = no }
			}
			if = {
				limit = {
					liege = { 
						has_variable = chancellor_domestic_affairs_opinion_value 
					}
				}
				liege = {
					if = {
						limit = {
							var:chancellor_domestic_affairs_opinion_value < root.chancellor_domestic_affairs_opinion_max
						}
						change_variable = {
							name = chancellor_domestic_affairs_opinion_value
							add = root.chancellor_domestic_affairs_monthly_increase
						}
					}
					if = {
						limit = {
							var:chancellor_domestic_affairs_opinion_value > root.chancellor_domestic_affairs_opinion_max
						}
						set_variable = {
							name = chancellor_domestic_affairs_opinion_value
							value = root.chancellor_domestic_affairs_opinion_max
						}
					}
				}	
			}
			else = {
				liege = {
					set_variable = {
						name = chancellor_domestic_affairs_opinion_value
						value = 0
					}
				}
			}
		}
	}

	ai_will_do = {
		value = 0
		if = { # Do this if you have a faction against you, every little bit helps
			limit = {
				scope:councillor_liege = {
					any_targeting_faction = {
						OR = {
							faction_is_type = independence_faction
							faction_is_type = nation_fracturing_faction
							faction_is_type = liberty_faction
							faction_is_type = claimant_faction
						}
					}
				}
			}
			add = 1000
		}
		if = { # Get rid of tyranny
			limit = {
				scope:councillor_liege = {
					OR = {
						AND = { # Somewhat rational characters prefer this over the prestige of foreign affairs
							ai_rationality > -25
							NOT = { has_trait = arrogant }
							tyranny >= 5
						}
						AND = { # If you're arrogant or deeply irrational, it'll take a long time for you to realize
							OR = {
								ai_rationality <= -25
								has_trait = arrogant
							}
							tyranny >= 15
						}
					}
				}
			}
			add = 500
		}
	}
}

task_kurultai_exploit_area_1 = {
	position = councillor_kurultai_1

	task_type = task_type_county
	county_target = domain
	ai_county_target = domain
	highlight_own_realm = yes

	task_progress = task_progress_value
	task_current_value = scope:county.county_fertility
	task_max_value = 100.0001 # Highest possible county fertility

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_exploit_area.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	potential_county = {
		exists = scope:county.holder
		scope:county = {
			is_landless_type_title = no
			county_fertility > 0
		}
		trigger_if = {
			limit = {
				scope:county.holder = { is_ai = yes }
			}
			NOT = { scope:county = scope:county.holder.capital_county }
		}
		custom_tooltip = {
			text = task_kurultai_use_fertility
			scope:county.holder = { 
				OR = {
					government_has_flag = government_is_nomadic 
					government_has_flag = government_is_herder
				}
			}
		}
		custom_tooltip = {
			text = task_kurultai_fertility_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_fertility_2
					is_target_of_council_task = task_kurultai_fertility_3
					is_target_of_council_task = task_kurultai_fertility_4
				}
			}	
		}
		custom_tooltip = {
			text = task_kurultai_exploited_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_exploit_area_2
					is_target_of_council_task = task_kurultai_exploit_area_3
					is_target_of_council_task = task_kurultai_exploit_area_4
				}
			}	
		}
	}

	county_modifier = {
		name = task_kurultai_exploit_modifier
		county_fertility_decline_add = -1
		scale = kurultai_exploit_area_fertility_final_value
	}

	council_owner_modifier = {
		name = task_kurultai_exploit_modifier
		monthly_income_from_herd_mult = 0.01
		scale = kurultai_exploit_area_income_final_value
	}

	effect_desc = {
		desc = task_kurultai_exploit_effect_desc
		desc = task_kurultai_exploit_fertility_desc
		desc = task_kurultai_exploit_income_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Gold
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship >= low_skill_rating
					}
				}
				desc = task_kurultai_exploit_gain_gold
			}
			# Gain Dread
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						stewardship >= high_skill_rating
					}
				}
				desc = task_kurultai_exploit_gain_dread
			}
			## Negative
			# Reduce Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= very_high_skill_rating
					}
				}
				desc = task_kurultai_exploit_reduce_fertility
			}
			# Reduce County Opinion
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= decent_skill_rating
					}
				}
				desc = task_kurultai_exploit_lose_county_opinion
			}
		}
	}

	monthly_on_action = task_exploit_area_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 0
		# Only do this if they are running out of money
		if = {
			limit = {
				gold < 15
			}
			add = 2500
		}
	}
}

task_kurultai_raider_1 = {
	position = councillor_kurultai_1

	task_type = task_type_general
	task_progress = task_progress_infinite
	
	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_raider.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	council_owner_modifier = {
		name = task_kurultai_raider_modifier
		hostile_county_attrition_raiding = -0.01
		max_loot_mult = 0.01
		scale = kurultai_organize_raiders_loot_final_value
	}

	council_owner_modifier = {
		name = task_kurultai_raider_modifier
		raid_speed = 0.01
		movement_speed_land_raiding = 0.01
		scale = kurultai_organize_raiders_raid_final_value
	}

	effect_desc = {
		desc = task_kurultai_control_effect_desc
		desc = task_kurultai_raider_loot_desc
		desc = task_kurultai_raider_attrition_desc
		desc = task_kurultai_raider_raiding_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Prestige
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial >= low_skill_rating
					}
				}
				desc = task_kurultai_raiders_gain_prestige
			}
			# Gain Dread
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						martial >= high_skill_rating
					}
				}
				desc = task_kurultai_raiders_gain_dread
			}
			## Negative
			# Lose Prestige
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial <= very_high_skill_rating
					}
				}
				desc = task_kurultai_raiders_lose_prestige
			}
			# Lose Dread
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial <= decent_skill_rating
					}
				}
				desc = task_kurultai_raiders_lose_dread
			}
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_raiders_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_raider_2
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_raider_3
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_raider_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	monthly_on_action = task_organize_raiders_on_action

	ai_will_do = {
		value = 100
		if = { # 
			limit = {
				scope:councillor = { highest_skill = martial }
			}
			add = 500
		}
		if = {
			limit = {
				any_army = {
					is_raid_army = yes
				}
			}
			add = 1000
		}
	}
}

task_kurultai_culture_1 = {
	position = councillor_kurultai_1
	
	task_type = task_type_general
	task_progress = task_progress_infinite
	
	is_shown = {
		trigger_if = {
			limit = {
				scope:councillor_liege = { tgp_has_access_to_ministry_trigger = yes }
			}
			has_council_position = councillor_court_chaplain
		}
		trigger_else = {
			has_council_position = councillor_kurultai_1
		}
	}
	
	asset = {
		trigger = { tgp_has_access_to_ministry_trigger = no }
		icon = "gfx/interface/icons/council_task_types/task_kurultai_culture.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}
	
	asset = {
		trigger = { tgp_has_access_to_ministry_trigger = yes }
		icon = "gfx/interface/icons/council_task_types/task_culture_minister.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_culture_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_culture_2
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_culture_3
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_culture_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	on_start_task = {
		liege = {
			set_variable = {
				name = kurultai_culture_variable_value
				value = 0
			}
		}
	}

	on_cancel_task = {
		if = {
			limit = {
				is_alive = yes
				has_variable = kurultai_culture_variable_value
			}
			remove_variable = kurultai_culture_variable_value
		}
	}

	on_monthly = {
		if = {
			limit = {
				liege = { is_ai = no }
			}
			if = {
				limit = {
					liege = { 
						has_variable = kurultai_culture_variable_value 
					}
				}
				liege = {
					if = {
						limit = {
							var:kurultai_culture_variable_value < root.kurultai_culture_max_value
						}
						change_variable = {
							name = kurultai_culture_variable_value
							add = root.kurultai_culture_monthly_increase
						}
					}
					if = {
						limit = {
							var:kurultai_culture_variable_value > root.kurultai_culture_max_value
						}
						set_variable = {
							name = kurultai_culture_variable_value
							value = root.kurultai_culture_max_value
						}
					}
				}	
			}
			else = {
				liege = {
					set_variable = {
						name = kurultai_culture_variable_value
						value = 0
					}
				}
			}
		}
	}

	effect_desc = { 
		desc = task_kurultai_court_astrologer_effect_desc 
		desc = task_kurultai_culture_cooldown_effect_desc
		# You have the Of the People perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = of_the_people_perk }
			}
			desc = task_kurultai_culture_1_of_the_people_bonus_desc
		}
		desc = task_kurultai_culture_hybridization_effect_desc
		# You have the Of the People perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = of_the_people_perk }
			}
			desc = task_kurultai_culture_1_of_the_people_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Cultural Acceptance 
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning >= low_skill_rating
					}
				}
				desc = task_kurultai_cultures_increase_acceptance
			}
			# Gain Different Culture Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						learning >= high_skill_rating
					}
				}
				desc = task_kurultai_cultures_increase_opinion
			}
			## Negative
			# Lose Cultural Acceptance
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning <= very_high_skill_rating
					}
				}
				desc = task_kurultai_cultures_decrease_acceptance
			}
			# Lose Different Opinion
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						learning <= decent_skill_rating
					}
				}
				desc = task_kurultai_cultures_decrease_opinion
			}
		}
	}

	monthly_on_action = task_explore_cultures_on_action

	ai_will_do = {
		value = 0 # They will never do this
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_explore_cultures
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 10000
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_culture_2
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_culture_3
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_culture_4
					}
				}
				divide = 4
			}
		}
	}
}

# Kurultai 2
task_kurultai_default_2 = {
	default_task = yes
	position = councillor_kurultai_2
	
	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_default.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	council_owner_modifier = {
		name = task_kurultai_default_modifier
		herd_gain_mult = 0.01
		herd_capacity_mult = 0.01
		scale = kurultai_manage_herd_final_value
	}

	task_type = task_type_general
	task_progress = task_progress_infinite

	effect_desc = { 
		desc = task_kurultai_default_effect_desc 
		desc = task_kurultai_default_herd_gain_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Herd
			triggered_desc = {
				trigger = {
					scope:councillor = {
						diplomacy >= low_skill_rating
					}
				}
				desc = task_kurultai_default_gain_herd
			}
			# Bonus Army
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						diplomacy >= high_skill_rating
					}
				}
				desc = task_kurultai_default_bonus_army
			}
			## Negative
			# Lose Herd
			triggered_desc = {
				trigger = {
					scope:councillor = {
						diplomacy <= very_high_skill_rating
					}
				}
				desc = task_kurultai_default_lose_herd
			}
			# Lose Control
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						diplomacy <= decent_skill_rating
					}
				}
				desc = task_kurultai_default_lose_control
			}
		}
	}

	monthly_on_action = task_help_herders_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 500
		if = { # 
			limit = {
				scope:councillor = { highest_skill = diplomacy }
			}
			add = 500
		}
	}
}

task_kurultai_fertility_2 = {
	position = councillor_kurultai_2

	task_type = task_type_county
	county_target = realm
	ai_county_target = domain
	highlight_own_realm = yes

	task_progress = task_progress_value
	task_current_value = scope:county.county_fertility
	task_max_value = 100 # Highest possible county fertility

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_fertility.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	county_modifier = {
		name = task_kurultai_fertility_modifier
		county_fertility_growth_mult = 0.01
		scale = kurultai_increased_fertility_scale_value
	}

	potential_county = {
		exists = scope:county.holder
		scope:county = { is_landless_type_title = no }
		custom_tooltip = {
			text = task_kurultai_use_fertility
			scope:county.holder = { 
				OR = {
					government_has_flag = government_is_nomadic 
					government_has_flag = government_is_herder
				}
			}
		}
		custom_tooltip = {
			text = task_kurultai_fertility_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_fertility_1
					is_target_of_council_task = task_kurultai_fertility_3
					is_target_of_council_task = task_kurultai_fertility_4
				}
			}	
		}
		custom_tooltip = {
			text = task_kurultai_exploited_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_exploit_area_1
					is_target_of_council_task = task_kurultai_exploit_area_3
					is_target_of_council_task = task_kurultai_exploit_area_4
				}
			}	
		}
	}

	effect_desc = { 
		desc = task_kurultai_fertility_effect_desc 
		desc = task_kurultai_fertility_gain_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Increase Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship >= low_skill_rating
					}
				}
				desc = task_kurultai_fertility_increase_fertility
			}
			# Increase Popular Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						stewardship >= high_skill_rating
					}
				}
				desc = task_kurultai_fertility_county_opinion
			}
			## Negative
			# Lose Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= very_high_skill_rating
					}
				}
				desc = task_kurultai_fertility_reduce_fertility
			}
			# Prestige Loss
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= decent_skill_rating
					}
				}
				desc = task_kurultai_fertility_lose_prestige
			}
		}
	}

	monthly_on_action = task_manage_fertility_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 500
		if = { # 
			limit = {
				scope:councillor = { highest_skill = stewardship }
			}
			add = 500
		}
		if = {
			limit = {
				capital_county ?= { 
					uses_county_fertility = yes
					county_fertility <= 50 
				}
			}
			add = 1000
		}
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_manage_fertility
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 10000
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_fertility_1
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_fertility_3
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_fertility_4
					}
				}
				divide = 4
			}
		}
	}
}

task_kurultai_control_2 = {
	position = councillor_kurultai_2

	task_type = task_type_county
	county_target = realm
	ai_county_target = domain

	task_progress = task_progress_value
	task_current_value = scope:councillor_liege.marshal_increase_control_current_progress
	task_max_value = 100 # Highest possible county control

	highlight_own_realm = yes
	restart_on_finish = yes # If it "finishes" by removing a corruption modifier, there'll still be control to regain

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_control.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	effect_desc = {
		desc = task_kurultai_control_effect_desc
		desc = task_kurultai_increase_control_effect_desc
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					scope:councillor_liege = {
						any_active_accolade = {
							has_accolade_parameter = accolade_increase_control_bonus
						}
					}
				}
				desc = task_increase_control_acclaimed_knight_subdues_peasantry
			}
			triggered_desc = {
				trigger = {
					martial > mediocre_skill_rating
				}
				desc = task_increase_control_increase_opinion
			}
			triggered_desc = {
				trigger = {
					martial > mediocre_skill_rating
				}
				desc = task_increase_control_baron_opinion_increase
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_lose_opinion
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_lose_control
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_baron_opinion_loss
			}
		}
	}
	
	# TOTAL PROGRESS MUST MATCH THE TOTAL OF THE COUNTY MODIFIERS BELOW
		# Add all new progress values to the script value marshal_increase_control_total
		# Note that for Increase Control, the County Modifiers apply the actual values, while progress is for player info only
	progress = {
		value = 0
		add = {
			value = marshal_increase_control_base
			desc = INCREASE_CONTROL_BASE
		}
		add = {
			value = scope:councillor.marshal_increase_county_control_monthly_change
			desc = SCALED_COUNCILLOR_MARTIAL_VALUE
		}
		# Relation Bonuses/Penalties
		if = { # Friend
			limit = {
				scope:councillor_liege = {
					has_relation_friend = scope:councillor
					NOT = { has_relation_best_friend = scope:councillor }
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_friend_bonus
				desc = COUNCILLOR_IS_YOUR_FRIEND
			}
		}
		if = { # Best Friend
			limit = {
				scope:councillor_liege = {
					has_relation_best_friend = scope:councillor
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_best_friend_bonus
				desc = COUNCILLOR_IS_YOUR_BEST_FRIEND
			}
		}
		if = { # Rival
			limit = {
				scope:councillor_liege = {
					has_relation_rival = scope:councillor
					NOT = { has_relation_nemesis = scope:councillor }
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_rival_bonus
				desc = COUNCILLOR_IS_YOUR_RIVAL
			}
		}
		if = { # Nemesis
			limit = {
				scope:councillor_liege = {
					has_relation_nemesis = scope:councillor
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_nemesis_bonus
				desc = COUNCILLOR_IS_YOUR_NEMESIS
			}
		}
		if = {
			limit = {
				scope:councillor_liege = { has_perk = strict_organization_perk }
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_perk_bonus_monthly_change
				desc = INCREASE_CONTROL_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_erudition_bonus_monthly_change
				desc = ERUDITION_DYNASTY_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_family_business_bonus = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_family_business_bonus_monthly_change
				desc = FAMILY_BUSINESS_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_consulted_house_bonus_monthly_change
				desc = CONSULTED_HOUSE_BONUS_VALUE
			}
		}
		if = {
			limit = {
				scope:councillor = { has_character_modifier = event_bonus_to_county_control }
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_experience_bonus_monthly_change
				desc = INCREASE_COUNTY_CONTROL_EXPERIENCE_BONUS_VALUE
			}
		}
		if = {
			limit = { exists = scope:county }
			multiply = {
				value = scope:county.monthly_county_control_growth_factor
				desc = MARSHAL_COUNTY_SPEED_MODIFIERS
			}
		}
		if = {
			limit = {
				exists = scope:county
				scope:county = { has_county_modifier = petition_liege_county_control_modifier }
			}
			add = {
				value = scope:councillor.petition_liege_county_control_modifier_value
				desc = MARSHAL_INCREASE_CONTROL_LOCAL_COUNTY_MODIFIERS
			}
		}
		#EP3
		if = {
			limit = {
				scope:councillor_liege = {
					employs_court_position = court_jester_court_position
					court_position:court_jester_court_position = {
						has_character_flag = famous_mime_control
					}
				}
			}
			add = {
				value = scope:councillor_liege.court_position:court_jester_court_position.marshal_court_jester_contribution_value
				desc = MARSHAL_INCREASE_CONTROL_MIME_MODIFIER
			}
		}
	}

	full_progress = marshal_increase_control_full_progress
	custom_other_loc = MARSHAL_COUNTY_SPEED_OTHER

	potential_county = {
		scope:county = {
			is_landless_type_title = no
			custom_description = {
				text = potential_county_control_task_trigger
				OR = {
					has_county_corruption_trigger = yes
					county_control < full_county_control
				}
			}
			# If the growth factor is 0, no amount of trying to control helps
			# (happens when the county is under siege/occupied most likely)
			monthly_county_control_growth_factor > 0
			custom_tooltip = {
				text = potential_county_control_task_only_one_target
				scope:county = {
					NOR = {
						is_target_of_council_task = task_kurultai_control_1
						is_target_of_council_task = task_kurultai_control_3
						is_target_of_council_task = task_kurultai_control_4
					}
				}
			}
		}
	}

	county_modifier = {
		name = marshal_increase_control_modifier
		monthly_county_control_growth_add = 1
		scale = marshal_increase_control_total
	}

	on_start_task_county = {
		#spawn a task contract
		if = {
			limit = {
				scope:councillor_liege = {
					is_independent_ruler = yes					
				}
				any_player = {
					is_landless_adventurer = yes
					is_within_diplo_range = { CHARACTER = scope:councillor }
					any_character_task_contract = {
						has_task_contract_type = laamp_help_increase_control_contract
						count <= council_task_contracts_limit_value
					}
					can_create_task_contract = {
						type_name = laamp_help_increase_control_contract
						employer = scope:councillor
					}
					save_temporary_scope_as = player_laamp
				}
			}
			scope:player_laamp = {
				create_task_contract = {
					task_contract_type = laamp_help_increase_control_contract
					task_contract_tier = scope:councillor.task_contract_tier_value
					location = scope:county.title_province
					task_contract_employer = scope:councillor
					target = scope:councillor.liege
					destination = scope:county.title_province
					save_scope_as = task_contract					
				}
			}
		}
	}
	on_finish_task_county = {
		if = {
			limit = {
				scope:county = {
					has_county_corruption_trigger = yes
				}
			}
			scope:county = {
				marshal_remove_random_county_corruption_modifier_effect = yes
				change_county_control = -25
			}
		}
	}

	monthly_on_action = increase_control_monthly_on_action

	on_monthly_county = {
		random = {
			chance = scope:councillor.marshal_remove_county_corruption_chance
			scope:county = {
				marshal_remove_random_county_corruption_modifier_effect = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 1000 # Highest prio
		if = { # Keep doing Organize levies if you're at war
			limit = {
				scope:councillor_liege = {
					is_at_war = no
				}
			}
			add = 19000
		}
		if = { # Keep doing Organize levies if you're at war
			limit = {
				is_performing_council_task = task_organize_levies
				scope:councillor_liege = {
					is_at_war = yes
				}
			}
			add = -1000
		}
		if = { # Stop doing this if Organize levies could help you lose less gold during a war
			limit = {
				NOT = {
					is_performing_council_task = task_organize_levies
				}
				scope:councillor_liege = {
					is_at_war = yes
					monthly_character_income < monthly_character_expenses
				}
			}
			add = -1000
		}
	}
}

task_kurultai_court_astrologer_2 = {
	position = councillor_kurultai_2

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_court_astrologer.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		liege_or_court_owner ?= {
			employs_court_position = court_astrologer_court_position
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	council_owner_modifier = {
		name = task_kurultai_court_astrologer_modifier
		monthly_piety_gain_mult = 0.01
		scale = kurultai_court_astrologer_piety_final_value
	}

	effect_desc = { 
		desc = task_kurultai_court_astrologer_effect_desc 
		desc = task_kurultai_court_astrologer_piety_desc
		desc = task_kurultai_court_astrologer_aptitude_desc
		# You have the Zealous Proselytizer perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = zealous_proselytizer_perk }
			}
			desc = task_kurultai_court_astrologer_zealous_proselytizer_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Piety 
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning >= low_skill_rating
					}
				}
				desc = task_kurultai_astrologer_increase_piety
			}
			# Gain Astrologer Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						learning >= high_skill_rating
					}
				}
				desc = task_kurultai_astrologer_increase_opinion
			}
			## Negative
			# Lose Piety
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning <= very_high_skill_rating
					}
				}
				desc = task_kurultai_astrologer_reduce_piety
			}
			# Lose Astrologer Opinion
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						learning <= decent_skill_rating
					}
				}
				desc = task_kurultai_astrologer_reduce_opinion
			}
		}
	}

	monthly_on_action = task_manage_astrologer_on_action

	ai_will_do = {
		value = 250
		if = { # 
			limit = {
				scope:councillor = { highest_skill = learning }
			}
			add = 500
		}
		if = {
			limit = {
				piety < 50
			}
			add = 1000
		}
	}
}

task_kurultai_domestic_affairs_2 = {
	position = councillor_kurultai_2

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_domestic_affairs.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_domestic_affairs_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_1
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_3
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	effect_desc = {
		desc = task_kurultai_domestic_affairs_effect_desc
		# Direct Vassal Opinion
		desc = task_domestic_affairs_direct_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			desc = chancellor_domestic_affairs_opinion_pandidakterion_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_opinion_food_bonus_desc
		}
		# Parochial Vassal Opinion
		desc = task_domestic_affairs_parochial_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			desc = chancellor_domestic_affairs_opinion_pandidakterion_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_opinion_food_bonus_desc
		}
		# Tyranny Loss
		desc = task_domestic_affairs_tyranny_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_tyranny_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_tyranny_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_tyranny_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_tyranny_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_tyranny_food_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_improved_vassal_opinion
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
					liege = {
						any_vassal = {
							government_has_flag = government_is_feudal
							primary_title.tier > tier_barony
						}
					}
				}
				desc = task_increase_control_improve_vassal_contract
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_end_internal_war
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_force_vassal_partition
			}
			triggered_desc = {
				trigger = {
					diplomacy < high_skill_rating
				}
				desc = task_increase_control_lose_vassal_opinion
			}
			triggered_desc = {
				trigger = {
					diplomacy < high_skill_rating
					liege = {
						any_vassal = {
							government_has_flag = government_is_feudal
							primary_title.tier > tier_barony
						}
					}
				}
				desc = task_increase_control_worsen_contract
			}
		}
	}

	on_start_task = {
		liege = {
			set_variable = {
				name = chancellor_domestic_affairs_opinion_value
				value = 0
			}
		}
	}

	on_cancel_task = {
		if = {
			limit = {
				is_alive = yes
				has_variable = chancellor_domestic_affairs_opinion_value
			}
			remove_variable = chancellor_domestic_affairs_opinion_value
		}
	}

	council_owner_modifier = {
		name = task_domestic_affairs_opinion_modifier
		direct_vassal_opinion = 1
		scale = chancellor_domestic_affairs_opinion_scale
	}

	council_owner_modifier = {
		name = task_domestic_affairs_parochial_opinion_modifier
		parochial_opinion = 1
		scale = chancellor_domestic_affairs_opinion_scale
	}

	council_owner_modifier = {
		name = task_domestic_affairs_opinion_modifier
		tyranny_loss_mult = 0.01
		scale = chancellor_domestic_affairs_tyranny_total
	}

	monthly_on_action = task_domestic_affairs_side_effects

	on_monthly = {
		if = {
			limit = {
				liege = { is_ai = no }
			}
			if = {
				limit = {
					liege = { 
						has_variable = chancellor_domestic_affairs_opinion_value 
					}
				}
				liege = {
					if = {
						limit = {
							var:chancellor_domestic_affairs_opinion_value < root.chancellor_domestic_affairs_opinion_max
						}
						change_variable = {
							name = chancellor_domestic_affairs_opinion_value
							add = root.chancellor_domestic_affairs_monthly_increase
						}
					}
					if = {
						limit = {
							var:chancellor_domestic_affairs_opinion_value > root.chancellor_domestic_affairs_opinion_max
						}
						set_variable = {
							name = chancellor_domestic_affairs_opinion_value
							value = root.chancellor_domestic_affairs_opinion_max
						}
					}
				}	
			}
			else = {
				liege = {
					set_variable = {
						name = chancellor_domestic_affairs_opinion_value
						value = 0
					}
				}
			}
		}
	}

	ai_will_do = {
		value = 0
		if = { # Do this if you have a faction against you, every little bit helps
			limit = {
				scope:councillor_liege = {
					any_targeting_faction = {
						OR = {
							faction_is_type = independence_faction
							faction_is_type = nation_fracturing_faction
							faction_is_type = liberty_faction
							faction_is_type = claimant_faction
						}
					}
				}
			}
			add = 1000
		}
		if = { # Get rid of tyranny
			limit = {
				scope:councillor_liege = {
					OR = {
						AND = { # Somewhat rational characters prefer this over the prestige of foreign affairs
							ai_rationality > -25
							NOT = { has_trait = arrogant }
							tyranny >= 5
						}
						AND = { # If you're arrogant or deeply irrational, it'll take a long time for you to realize
							OR = {
								ai_rationality <= -25
								has_trait = arrogant
							}
							tyranny >= 15
						}
					}
				}
			}
			add = 500
		}
	}
}

task_kurultai_exploit_area_2 = {
	position = councillor_kurultai_2

	task_type = task_type_county
	county_target = domain
	ai_county_target = domain
	highlight_own_realm = yes

	task_progress = task_progress_value
	task_current_value = scope:county.county_fertility
	task_max_value = 100.0001 # Highest possible county fertility
	
	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_exploit_area.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	potential_county = {
		exists = scope:county.holder
		scope:county = {
			county_fertility > 0
			is_landless_type_title = no
		}
		trigger_if = {
			limit = {
				scope:county.holder = { is_ai = yes }
			}
			NOT = { scope:county = scope:county.holder.capital_county }
		}
		custom_tooltip = {
			text = task_kurultai_use_fertility
			scope:county.holder = { 
				OR = {
					government_has_flag = government_is_nomadic 
					government_has_flag = government_is_herder
				}
			}
		}
		custom_tooltip = {
			text = task_kurultai_fertility_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_fertility_1
					is_target_of_council_task = task_kurultai_fertility_3
					is_target_of_council_task = task_kurultai_fertility_4
				}
			}	
		}
		custom_tooltip = {
			text = task_kurultai_exploited_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_exploit_area_1
					is_target_of_council_task = task_kurultai_exploit_area_3
					is_target_of_council_task = task_kurultai_exploit_area_4
				}
			}	
		}
	}

	county_modifier = {
		name = task_kurultai_exploit_modifier
		county_fertility_decline_add = -1
		scale = kurultai_exploit_area_fertility_final_value
	}

	council_owner_modifier = {
		name = task_kurultai_exploit_modifier
		monthly_income_from_herd_mult = 0.01
		scale = kurultai_exploit_area_income_final_value
	}

	effect_desc = {
		desc = task_kurultai_exploit_effect_desc
		desc = task_kurultai_exploit_fertility_desc
		desc = task_kurultai_exploit_income_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Gold
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship >= low_skill_rating
					}
				}
				desc = task_kurultai_exploit_gain_gold
			}
			# Gain Dread
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						stewardship >= high_skill_rating
					}
				}
				desc = task_kurultai_exploit_gain_dread
			}
			## Negative
			# Reduce Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= very_high_skill_rating
					}
				}
				desc = task_kurultai_exploit_reduce_fertility
			}
			# Reduce County Opinion
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= decent_skill_rating
					}
				}
				desc = task_kurultai_exploit_lose_county_opinion
			}
		}
	}

	monthly_on_action = task_exploit_area_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 0
		# Only do this if they are running out of money
		if = {
			limit = {
				gold < 15
			}
			add = 2500
		}
	}
}

task_kurultai_raider_2 = {
	position = councillor_kurultai_2

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_raider.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	council_owner_modifier = {
		name = task_kurultai_raider_modifier
		hostile_county_attrition_raiding = -0.01
		max_loot_mult = 0.01
		scale = kurultai_organize_raiders_loot_final_value
	}

	council_owner_modifier = {
		name = task_kurultai_raider_modifier
		raid_speed = 0.01
		movement_speed_land_raiding = 0.01
		scale = kurultai_organize_raiders_raid_final_value
	}

	effect_desc = {
		desc = task_kurultai_control_effect_desc
		desc = task_kurultai_raider_loot_desc
		desc = task_kurultai_raider_attrition_desc
		desc = task_kurultai_raider_raiding_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Prestige
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial >= low_skill_rating
					}
				}
				desc = task_kurultai_raiders_gain_prestige
			}
			# Gain Dread
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						martial >= high_skill_rating
					}
				}
				desc = task_kurultai_raiders_gain_dread
			}
			## Negative
			# Lose Prestige
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial <= very_high_skill_rating
					}
				}
				desc = task_kurultai_raiders_lose_prestige
			}
			# Lose Dread
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial <= decent_skill_rating
					}
				}
				desc = task_kurultai_raiders_lose_dread
			}
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_raiders_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_raider_1
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_raider_3
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_raider_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	monthly_on_action = task_organize_raiders_on_action

	ai_will_do = {
		value = 100
		if = { # 
			limit = {
				scope:councillor = { highest_skill = martial }
			}
			add = 500
		}
		if = {
			limit = {
				any_army = {
					is_raid_army = yes
				}
			}
			add = 1000
		}
	}
}

task_kurultai_culture_2 = {
	position = councillor_kurultai_2

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_culture.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_culture_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_culture_1
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_culture_3
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_culture_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	on_start_task = {
		liege = {
			set_variable = {
				name = kurultai_culture_variable_value
				value = 0
			}
		}
	}

	on_cancel_task = {
		if = {
			limit = {
				is_alive = yes
				has_variable = kurultai_culture_variable_value
			}
			remove_variable = kurultai_culture_variable_value
		}
	}

	on_monthly = {
		if = {
			limit = {
				liege = { is_ai = no }
			}
			if = {
				limit = {
					liege = { 
						has_variable = kurultai_culture_variable_value 
					}
				}
				liege = {
					if = {
						limit = {
							var:kurultai_culture_variable_value < root.kurultai_culture_max_value
						}
						change_variable = {
							name = kurultai_culture_variable_value
							add = root.kurultai_culture_monthly_increase
						}
					}
					if = {
						limit = {
							var:kurultai_culture_variable_value > root.kurultai_culture_max_value
						}
						set_variable = {
							name = kurultai_culture_variable_value
							value = root.kurultai_culture_max_value
						}
					}
				}	
			}
			else = {
				liege = {
					set_variable = {
						name = kurultai_culture_variable_value
						value = 0
					}
				}
			}
		}
	}

	effect_desc = { 
		desc = task_kurultai_court_astrologer_effect_desc 
		desc = task_kurultai_culture_cooldown_effect_desc
		# You have the Of the People perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = of_the_people_perk }
			}
			desc = task_kurultai_culture_1_of_the_people_bonus_desc
		}
		desc = task_kurultai_culture_hybridization_effect_desc
		# You have the Of the People perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = of_the_people_perk }
			}
			desc = task_kurultai_culture_1_of_the_people_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Cultural Acceptance 
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning >= low_skill_rating
					}
				}
				desc = task_kurultai_cultures_increase_acceptance
			}
			# Gain Different Culture Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						learning >= high_skill_rating
					}
				}
				desc = task_kurultai_cultures_increase_opinion
			}
			## Negative
			# Lose Cultural Acceptance
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning <= very_high_skill_rating
					}
				}
				desc = task_kurultai_cultures_decrease_acceptance
			}
			# Lose Different Opinion
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						learning <= decent_skill_rating
					}
				}
				desc = task_kurultai_cultures_decrease_opinion
			}
		}
	}

	monthly_on_action = task_explore_cultures_on_action

	ai_will_do = {
		value = 0 # They will never do this
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_explore_cultures
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 10000
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_culture_1
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_culture_3
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_culture_4
					}
				}
				divide = 4
			}
		}
	}
}

# Kurultai 3
task_kurultai_default_3 = {
	default_task = yes
	position = councillor_kurultai_3
	
	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_default.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	council_owner_modifier = {
		name = task_kurultai_default_modifier
		herd_gain_mult = 0.01
		herd_capacity_mult = 0.01
		scale = kurultai_manage_herd_final_value
	}

	task_type = task_type_general
	task_progress = task_progress_infinite

	effect_desc = { 
		desc = task_kurultai_default_effect_desc 
		desc = task_kurultai_default_herd_gain_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Herd
			triggered_desc = {
				trigger = {
					scope:councillor = {
						diplomacy >= low_skill_rating
					}
				}
				desc = task_kurultai_default_gain_herd
			}
			# Bonus Army
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						diplomacy >= high_skill_rating
					}
				}
				desc = task_kurultai_default_bonus_army
			}
			## Negative
			# Lose Herd
			triggered_desc = {
				trigger = {
					scope:councillor = {
						diplomacy <= very_high_skill_rating
					}
				}
				desc = task_kurultai_default_lose_herd
			}
			# Lose Control
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						diplomacy <= decent_skill_rating
					}
				}
				desc = task_kurultai_default_lose_control
			}
		}
	}

	monthly_on_action = task_help_herders_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 500
		if = { # 
			limit = {
				scope:councillor = { highest_skill = diplomacy }
			}
			add = 500
		}
	}
}

task_kurultai_fertility_3 = {
	position = councillor_kurultai_3

	task_type = task_type_county
	county_target = realm
	ai_county_target = domain
	highlight_own_realm = yes

	task_progress = task_progress_value
	task_current_value = scope:county.county_fertility
	task_max_value = 100 # Highest possible county fertility

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_fertility.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	county_modifier = {
		name = task_kurultai_fertility_modifier
		county_fertility_growth_mult = 0.01
		scale = kurultai_increased_fertility_scale_value
	} 

	potential_county = {
		exists = scope:county.holder
		scope:county = { is_landless_type_title = no }
		custom_tooltip = {
			text = task_kurultai_use_fertility
			scope:county.holder = { 
				OR = {
					government_has_flag = government_is_nomadic 
					government_has_flag = government_is_herder
				}
			}
		}
		custom_tooltip = {
			text = task_kurultai_fertility_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_fertility_1
					is_target_of_council_task = task_kurultai_fertility_2
					is_target_of_council_task = task_kurultai_fertility_4
				}
			}	
		}
		custom_tooltip = {
			text = task_kurultai_exploited_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_exploit_area_1
					is_target_of_council_task = task_kurultai_exploit_area_2
					is_target_of_council_task = task_kurultai_exploit_area_4
				}
			}	
		}
	}

	effect_desc = { 
		desc = task_kurultai_fertility_effect_desc 
		desc = task_kurultai_fertility_gain_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Increase Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship >= low_skill_rating
					}
				}
				desc = task_kurultai_fertility_increase_fertility
			}
			# Increase Popular Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						stewardship >= high_skill_rating
					}
				}
				desc = task_kurultai_fertility_county_opinion
			}
			## Negative
			# Lose Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= very_high_skill_rating
					}
				}
				desc = task_kurultai_fertility_reduce_fertility
			}
			# Prestige Loss
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= decent_skill_rating
					}
				}
				desc = task_kurultai_fertility_lose_prestige
			}
		}
	}

	monthly_on_action = task_manage_fertility_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 500
		if = { # 
			limit = {
				scope:councillor = { highest_skill = stewardship }
			}
			add = 500
		}
		if = {
			limit = {
				capital_county ?= { 
					uses_county_fertility = yes
					county_fertility <= 50 
				}
			}
			add = 1000
		}
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_manage_fertility
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 10000
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_fertility_1
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_fertility_2
					}
				}
				divide = 4
			}
			
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_fertility_4
					}
				}
				divide = 4
			}
		}
	}
}

task_kurultai_control_3 = {
	position = councillor_kurultai_3

	task_type = task_type_county
	county_target = realm
	ai_county_target = domain

	task_progress = task_progress_value
	task_current_value = scope:councillor_liege.marshal_increase_control_current_progress
	task_max_value = 100 # Highest possible county control

	highlight_own_realm = yes
	restart_on_finish = yes # If it "finishes" by removing a corruption modifier, there'll still be control to regain

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_control.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	effect_desc = {
		desc = task_kurultai_control_effect_desc
		desc = task_kurultai_increase_control_effect_desc
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					scope:councillor_liege = {
						any_active_accolade = {
							has_accolade_parameter = accolade_increase_control_bonus
						}
					}
				}
				desc = task_increase_control_acclaimed_knight_subdues_peasantry
			}
			triggered_desc = {
				trigger = {
					martial > mediocre_skill_rating
				}
				desc = task_increase_control_increase_opinion
			}
			triggered_desc = {
				trigger = {
					martial > mediocre_skill_rating
				}
				desc = task_increase_control_baron_opinion_increase
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_lose_opinion
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_lose_control
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_baron_opinion_loss
			}
		}
	}
	
	# TOTAL PROGRESS MUST MATCH THE TOTAL OF THE COUNTY MODIFIERS BELOW
		# Add all new progress values to the script value marshal_increase_control_total
		# Note that for Increase Control, the County Modifiers apply the actual values, while progress is for player info only
	progress = {
		value = 0
		add = {
			value = marshal_increase_control_base
			desc = INCREASE_CONTROL_BASE
		}
		add = {
			value = scope:councillor.marshal_increase_county_control_monthly_change
			desc = SCALED_COUNCILLOR_MARTIAL_VALUE
		}
		# Relation Bonuses/Penalties
		if = { # Friend
			limit = {
				scope:councillor_liege = {
					has_relation_friend = scope:councillor
					NOT = { has_relation_best_friend = scope:councillor }
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_friend_bonus
				desc = COUNCILLOR_IS_YOUR_FRIEND
			}
		}
		if = { # Best Friend
			limit = {
				scope:councillor_liege = {
					has_relation_best_friend = scope:councillor
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_best_friend_bonus
				desc = COUNCILLOR_IS_YOUR_BEST_FRIEND
			}
		}
		if = { # Rival
			limit = {
				scope:councillor_liege = {
					has_relation_rival = scope:councillor
					NOT = { has_relation_nemesis = scope:councillor }
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_rival_bonus
				desc = COUNCILLOR_IS_YOUR_RIVAL
			}
		}
		if = { # Nemesis
			limit = {
				scope:councillor_liege = {
					has_relation_nemesis = scope:councillor
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_nemesis_bonus
				desc = COUNCILLOR_IS_YOUR_NEMESIS
			}
		}
		if = {
			limit = {
				scope:councillor_liege = { has_perk = strict_organization_perk }
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_perk_bonus_monthly_change
				desc = INCREASE_CONTROL_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_erudition_bonus_monthly_change
				desc = ERUDITION_DYNASTY_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_family_business_bonus = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_family_business_bonus_monthly_change
				desc = FAMILY_BUSINESS_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_consulted_house_bonus_monthly_change
				desc = CONSULTED_HOUSE_BONUS_VALUE
			}
		}
		if = {
			limit = {
				scope:councillor = { has_character_modifier = event_bonus_to_county_control }
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_experience_bonus_monthly_change
				desc = INCREASE_COUNTY_CONTROL_EXPERIENCE_BONUS_VALUE
			}
		}
		if = {
			limit = { exists = scope:county }
			multiply = {
				value = scope:county.monthly_county_control_growth_factor
				desc = MARSHAL_COUNTY_SPEED_MODIFIERS
			}
		}
		if = {
			limit = {
				exists = scope:county
				scope:county = { has_county_modifier = petition_liege_county_control_modifier }
			}
			add = {
				value = scope:councillor.petition_liege_county_control_modifier_value
				desc = MARSHAL_INCREASE_CONTROL_LOCAL_COUNTY_MODIFIERS
			}
		}
		#EP3
		if = {
			limit = {
				scope:councillor_liege = {
					employs_court_position = court_jester_court_position
					court_position:court_jester_court_position = {
						has_character_flag = famous_mime_control
					}
				}
			}
			add = {
				value = scope:councillor_liege.court_position:court_jester_court_position.marshal_court_jester_contribution_value
				desc = MARSHAL_INCREASE_CONTROL_MIME_MODIFIER
			}
		}
	}

	full_progress = marshal_increase_control_full_progress
	custom_other_loc = MARSHAL_COUNTY_SPEED_OTHER

	potential_county = {
		scope:county = {
			is_landless_type_title = no
			custom_description = {
				text = potential_county_control_task_trigger
				OR = {
					has_county_corruption_trigger = yes
					county_control < full_county_control
				}
			}
			# If the growth factor is 0, no amount of trying to control helps
			# (happens when the county is under siege/occupied most likely)
			monthly_county_control_growth_factor > 0
			custom_tooltip = {
				text = potential_county_control_task_only_one_target
				scope:county = {
					NOR = {
						is_target_of_council_task = task_kurultai_control_1
						is_target_of_council_task = task_kurultai_control_2
						is_target_of_council_task = task_kurultai_control_4
					}
				}
			}
		}
	}

	county_modifier = {
		name = marshal_increase_control_modifier
		monthly_county_control_growth_add = 1
		scale = marshal_increase_control_total
	}

	on_start_task_county = {
		#spawn a task contract
		if = {
			limit = {
				scope:councillor_liege = {
					is_independent_ruler = yes					
				}
				any_player = {
					is_landless_adventurer = yes
					is_within_diplo_range = { CHARACTER = scope:councillor }
					any_character_task_contract = {
						has_task_contract_type = laamp_help_increase_control_contract
						count <= council_task_contracts_limit_value
					}
					can_create_task_contract = {
						type_name = laamp_help_increase_control_contract
						employer = scope:councillor
					}
					save_temporary_scope_as = player_laamp
				}
			}
			scope:player_laamp = {
				create_task_contract = {
					task_contract_type = laamp_help_increase_control_contract
					task_contract_tier = scope:councillor.task_contract_tier_value
					location = scope:county.title_province
					task_contract_employer = scope:councillor
					target = scope:councillor.liege
					destination = scope:county.title_province
					save_scope_as = task_contract					
				}
			}
		}
	}
	on_finish_task_county = {
		if = {
			limit = {
				scope:county = {
					has_county_corruption_trigger = yes
				}
			}
			scope:county = {
				marshal_remove_random_county_corruption_modifier_effect = yes
				change_county_control = -25
			}
		}
	}

	monthly_on_action = increase_control_monthly_on_action

	on_monthly_county = {
		random = {
			chance = scope:councillor.marshal_remove_county_corruption_chance
			scope:county = {
				marshal_remove_random_county_corruption_modifier_effect = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 1000 # Highest prio
		if = { # Keep doing Organize levies if you're at war
			limit = {
				scope:councillor_liege = {
					is_at_war = no
				}
			}
			add = 19000
		}
		if = { # Keep doing Organize levies if you're at war
			limit = {
				is_performing_council_task = task_organize_levies
				scope:councillor_liege = {
					is_at_war = yes
				}
			}
			add = -1000
		}
		if = { # Stop doing this if Organize levies could help you lose less gold during a war
			limit = {
				NOT = {
					is_performing_council_task = task_organize_levies
				}
				scope:councillor_liege = {
					is_at_war = yes
					monthly_character_income < monthly_character_expenses
				}
			}
			add = -1000
		}
	}
}

task_kurultai_court_astrologer_3 = {
	position = councillor_kurultai_3

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_court_astrologer.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		liege_or_court_owner ?= {
			employs_court_position = court_astrologer_court_position
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	council_owner_modifier = {
		name = task_kurultai_court_astrologer_modifier
		monthly_piety_gain_mult = 0.01
		scale = kurultai_court_astrologer_piety_final_value
	}

	effect_desc = { 
		desc = task_kurultai_court_astrologer_effect_desc 
		desc = task_kurultai_court_astrologer_piety_desc
		desc = task_kurultai_court_astrologer_aptitude_desc
		# You have the Zealous Proselytizer perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = zealous_proselytizer_perk }
			}
			desc = task_kurultai_court_astrologer_zealous_proselytizer_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Piety 
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning >= low_skill_rating
					}
				}
				desc = task_kurultai_astrologer_increase_piety
			}
			# Gain Astrologer Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						learning >= high_skill_rating
					}
				}
				desc = task_kurultai_astrologer_increase_opinion
			}
			## Negative
			# Lose Piety
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning <= very_high_skill_rating
					}
				}
				desc = task_kurultai_astrologer_reduce_piety
			}
			# Lose Astrologer Opinion
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						learning <= decent_skill_rating
					}
				}
				desc = task_kurultai_astrologer_reduce_opinion
			}
		}
	}

	monthly_on_action = task_manage_astrologer_on_action

	ai_will_do = {
		value = 250
		if = { # 
			limit = {
				scope:councillor = { highest_skill = learning }
			}
			add = 500
		}
		if = {
			limit = {
				piety < 50
			}
			add = 1000
		}
	}
}

task_kurultai_domestic_affairs_3 = {
	position = councillor_kurultai_3

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_domestic_affairs.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_domestic_affairs_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_1
					}
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_2
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	effect_desc = {
		desc = task_kurultai_domestic_affairs_effect_desc
		# Direct Vassal Opinion
		desc = task_domestic_affairs_direct_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			desc = chancellor_domestic_affairs_opinion_pandidakterion_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_opinion_food_bonus_desc
		}
		# Parochial Vassal Opinion
		desc = task_domestic_affairs_parochial_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			desc = chancellor_domestic_affairs_opinion_pandidakterion_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_opinion_food_bonus_desc
		}
		# Tyranny Loss
		desc = task_domestic_affairs_tyranny_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_tyranny_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_tyranny_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_tyranny_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_tyranny_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_tyranny_food_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_improved_vassal_opinion
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
					liege = {
						any_vassal = {
							government_has_flag = government_is_feudal
							primary_title.tier > tier_barony
						}
					}
				}
				desc = task_increase_control_improve_vassal_contract
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_end_internal_war
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_force_vassal_partition
			}
			triggered_desc = {
				trigger = {
					diplomacy < high_skill_rating
				}
				desc = task_increase_control_lose_vassal_opinion
			}
			triggered_desc = {
				trigger = {
					diplomacy < high_skill_rating
					liege = {
						any_vassal = {
							government_has_flag = government_is_feudal
							primary_title.tier > tier_barony
						}
					}
				}
				desc = task_increase_control_worsen_contract
			}
		}
	}

	on_start_task = {
		liege = {
			set_variable = {
				name = chancellor_domestic_affairs_opinion_value
				value = 0
			}
		}
	}

	on_cancel_task = {
		if = {
			limit = {
				is_alive = yes
				has_variable = chancellor_domestic_affairs_opinion_value
			}
			remove_variable = chancellor_domestic_affairs_opinion_value
		}
	}

	council_owner_modifier = {
		name = task_domestic_affairs_opinion_modifier
		direct_vassal_opinion = 1
		scale = chancellor_domestic_affairs_opinion_scale
	}

	council_owner_modifier = {
		name = task_domestic_affairs_parochial_opinion_modifier
		parochial_opinion = 1
		scale = chancellor_domestic_affairs_opinion_scale
	}

	council_owner_modifier = {
		name = task_domestic_affairs_opinion_modifier
		tyranny_loss_mult = 0.01
		scale = chancellor_domestic_affairs_tyranny_total
	}

	monthly_on_action = task_domestic_affairs_side_effects

	on_monthly = {
		if = {
			limit = {
				liege = { is_ai = no }
			}
			if = {
				limit = {
					liege = { 
						has_variable = chancellor_domestic_affairs_opinion_value 
					}
				}
				liege = {
					if = {
						limit = {
							var:chancellor_domestic_affairs_opinion_value < root.chancellor_domestic_affairs_opinion_max
						}
						change_variable = {
							name = chancellor_domestic_affairs_opinion_value
							add = root.chancellor_domestic_affairs_monthly_increase
						}
					}
					if = {
						limit = {
							var:chancellor_domestic_affairs_opinion_value > root.chancellor_domestic_affairs_opinion_max
						}
						set_variable = {
							name = chancellor_domestic_affairs_opinion_value
							value = root.chancellor_domestic_affairs_opinion_max
						}
					}
				}	
			}
			else = {
				liege = {
					set_variable = {
						name = chancellor_domestic_affairs_opinion_value
						value = 0
					}
				}
			}
		}
	}

	ai_will_do = {
		value = 0
		if = { # Do this if you have a faction against you, every little bit helps
			limit = {
				scope:councillor_liege = {
					any_targeting_faction = {
						OR = {
							faction_is_type = independence_faction
							faction_is_type = nation_fracturing_faction
							faction_is_type = liberty_faction
							faction_is_type = claimant_faction
						}
					}
				}
			}
			add = 1000
		}
		if = { # Get rid of tyranny
			limit = {
				scope:councillor_liege = {
					OR = {
						AND = { # Somewhat rational characters prefer this over the prestige of foreign affairs
							ai_rationality > -25
							NOT = { has_trait = arrogant }
							tyranny >= 5
						}
						AND = { # If you're arrogant or deeply irrational, it'll take a long time for you to realize
							OR = {
								ai_rationality <= -25
								has_trait = arrogant
							}
							tyranny >= 15
						}
					}
				}
			}
			add = 500
		}
	}
}

task_kurultai_exploit_area_3 = {
	position = councillor_kurultai_3

	task_type = task_type_county
	county_target = domain
	ai_county_target = domain
	highlight_own_realm = yes

	task_progress = task_progress_value
	task_current_value = scope:county.county_fertility
	task_max_value = 100.0001 # Highest possible county fertility

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_exploit_area.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	potential_county = {
		exists = scope:county.holder
		scope:county = {
			is_landless_type_title = no
			county_fertility > 0
		}
		trigger_if = {
			limit = {
				scope:county.holder = { is_ai = yes }
			}
			NOT = { scope:county = scope:county.holder.capital_county }
		}
		custom_tooltip = {
			text = task_kurultai_use_fertility
			scope:county.holder = { 
				OR = {
					government_has_flag = government_is_nomadic 
					government_has_flag = government_is_herder
				}
			}
		}
		custom_tooltip = {
			text = task_kurultai_fertility_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_fertility_1
					is_target_of_council_task = task_kurultai_fertility_2
					is_target_of_council_task = task_kurultai_fertility_4
				}
			}	
		}
		custom_tooltip = {
			text = task_kurultai_exploited_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_exploit_area_1
					is_target_of_council_task = task_kurultai_exploit_area_2
					is_target_of_council_task = task_kurultai_exploit_area_4
				}
			}	
		}
	}

	county_modifier = {
		name = task_kurultai_exploit_modifier
		county_fertility_decline_add = -1
		scale = kurultai_exploit_area_fertility_final_value
	}

	council_owner_modifier = {
		name = task_kurultai_exploit_modifier
		monthly_income_from_herd_mult = 0.01
		scale = kurultai_exploit_area_income_final_value
	}

	effect_desc = {
		desc = task_kurultai_exploit_effect_desc
		desc = task_kurultai_exploit_fertility_desc
		desc = task_kurultai_exploit_income_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Gold
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship >= low_skill_rating
					}
				}
				desc = task_kurultai_exploit_gain_gold
			}
			# Gain Dread
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						stewardship >= high_skill_rating
					}
				}
				desc = task_kurultai_exploit_gain_dread
			}
			## Negative
			# Reduce Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= very_high_skill_rating
					}
				}
				desc = task_kurultai_exploit_reduce_fertility
			}
			# Reduce County Opinion
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= decent_skill_rating
					}
				}
				desc = task_kurultai_exploit_lose_county_opinion
			}
		}
	}

	monthly_on_action = task_exploit_area_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 0
		# Only do this if they are running out of money
		if = {
			limit = {
				gold < 15
			}
			add = 2500
		}
	}
}

task_kurultai_raider_3 = {
	position = councillor_kurultai_3

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_raider.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	council_owner_modifier = {
		name = task_kurultai_raider_modifier
		hostile_county_attrition_raiding = -0.01
		max_loot_mult = 0.01
		scale = kurultai_organize_raiders_loot_final_value
	}

	council_owner_modifier = {
		name = task_kurultai_raider_modifier
		raid_speed = 0.01
		movement_speed_land_raiding = 0.01
		scale = kurultai_organize_raiders_raid_final_value
	}

	effect_desc = {
		desc = task_kurultai_control_effect_desc
		desc = task_kurultai_raider_loot_desc
		desc = task_kurultai_raider_attrition_desc
		desc = task_kurultai_raider_raiding_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Prestige
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial >= low_skill_rating
					}
				}
				desc = task_kurultai_raiders_gain_prestige
			}
			# Gain Dread
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						martial >= high_skill_rating
					}
				}
				desc = task_kurultai_raiders_gain_dread
			}
			## Negative
			# Lose Prestige
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial <= very_high_skill_rating
					}
				}
				desc = task_kurultai_raiders_lose_prestige
			}
			# Lose Dread
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial <= decent_skill_rating
					}
				}
				desc = task_kurultai_raiders_lose_dread
			}
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_raiders_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_raider_1
					}
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_raider_2
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_raider_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	monthly_on_action = task_organize_raiders_on_action

	ai_will_do = {
		value = 100
		if = { # 
			limit = {
				scope:councillor = { highest_skill = martial }
			}
			add = 500
		}
		if = {
			limit = {
				any_army = {
					is_raid_army = yes
				}
			}
			add = 1000
		}
	}
}

task_kurultai_culture_3 = {
	position = councillor_kurultai_3
	
	task_type = task_type_general
	task_progress = task_progress_infinite
	
	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_culture.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_culture_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_culture_1
					}
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_culture_2
					}
					cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_culture_4
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	on_start_task = {
		liege = {
			set_variable = {
				name = kurultai_culture_variable_value
				value = 0
			}
		}
	}

	on_cancel_task = {
		if = {
			limit = {
				is_alive = yes
				has_variable = kurultai_culture_variable_value
			}
			remove_variable = kurultai_culture_variable_value
		}
	}

	on_monthly = {
		if = {
			limit = {
				liege = { is_ai = no }
			}
			if = {
				limit = {
					liege = { 
						has_variable = kurultai_culture_variable_value 
					}
				}
				liege = {
					if = {
						limit = {
							var:kurultai_culture_variable_value < root.kurultai_culture_max_value
						}
						change_variable = {
							name = kurultai_culture_variable_value
							add = root.kurultai_culture_monthly_increase
						}
					}
					if = {
						limit = {
							var:kurultai_culture_variable_value > root.kurultai_culture_max_value
						}
						set_variable = {
							name = kurultai_culture_variable_value
							value = root.kurultai_culture_max_value
						}
					}
				}	
			}
			else = {
				liege = {
					set_variable = {
						name = kurultai_culture_variable_value
						value = 0
					}
				}
			}
		}
	}

	effect_desc = { 
		desc = task_kurultai_court_astrologer_effect_desc 
		desc = task_kurultai_culture_cooldown_effect_desc
		# You have the Of the People perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = of_the_people_perk }
			}
			desc = task_kurultai_culture_1_of_the_people_bonus_desc
		}
		desc = task_kurultai_culture_hybridization_effect_desc
		# You have the Of the People perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = of_the_people_perk }
			}
			desc = task_kurultai_culture_1_of_the_people_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Cultural Acceptance 
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning >= low_skill_rating
					}
				}
				desc = task_kurultai_cultures_increase_acceptance
			}
			# Gain Different Culture Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						learning >= high_skill_rating
					}
				}
				desc = task_kurultai_cultures_increase_opinion
			}
			## Negative
			# Lose Cultural Acceptance
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning <= very_high_skill_rating
					}
				}
				desc = task_kurultai_cultures_decrease_acceptance
			}
			# Lose Different Opinion
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						learning <= decent_skill_rating
					}
				}
				desc = task_kurultai_cultures_decrease_opinion
			}
		}
	}

	monthly_on_action = task_explore_cultures_on_action

	ai_will_do = {
		value = 0 # They will never do this
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_explore_cultures
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 10000
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_culture_1
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_culture_2
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_4 ?= {
						is_performing_council_task = task_kurultai_culture_4
					}
				}
				divide = 4
			}
		}
	}
}

# Kurultai 4
task_kurultai_default_4 = {
	default_task = yes
	position = councillor_kurultai_4

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_default.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	council_owner_modifier = {
		name = task_kurultai_default_modifier
		herd_gain_mult = 0.01
		herd_capacity_mult = 0.01
		scale = kurultai_manage_herd_final_value
	}

	task_type = task_type_general
	task_progress = task_progress_infinite

	effect_desc = { 
		desc = task_kurultai_default_effect_desc 
		desc = task_kurultai_default_herd_gain_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Herd
			triggered_desc = {
				trigger = {
					scope:councillor = {
						diplomacy >= low_skill_rating
					}
				}
				desc = task_kurultai_default_gain_herd
			}
			# Bonus Army
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						diplomacy >= high_skill_rating
					}
				}
				desc = task_kurultai_default_bonus_army
			}
			## Negative
			# Lose Herd
			triggered_desc = {
				trigger = {
					scope:councillor = {
						diplomacy <= very_high_skill_rating
					}
				}
				desc = task_kurultai_default_lose_herd
			}
			# Lose Control
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						diplomacy <= decent_skill_rating
					}
				}
				desc = task_kurultai_default_lose_control
			}
		}
	}

	monthly_on_action = task_help_herders_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 500
		if = { # 
			limit = {
				scope:councillor = { highest_skill = diplomacy }
			}
			add = 500
		}
	}
}

task_kurultai_fertility_4 = {
	position = councillor_kurultai_4

	task_type = task_type_county
	county_target = realm
	ai_county_target = domain
	highlight_own_realm = yes

	task_progress = task_progress_value
	task_current_value = scope:county.county_fertility
	task_max_value = 100 # Highest possible county fertility

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_fertility.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	county_modifier = {
		name = task_kurultai_fertility_modifier
		county_fertility_growth_mult = 0.01
		scale = kurultai_increased_fertility_scale_value
	}

	potential_county = {
		exists = scope:county.holder
		scope:county = { is_landless_type_title = no }
		custom_tooltip = {
			text = task_kurultai_use_fertility
			scope:county.holder = { 
				OR = {
					government_has_flag = government_is_nomadic 
					government_has_flag = government_is_herder
				}
			}
		}
		custom_tooltip = {
			text = task_kurultai_fertility_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_fertility_1
					is_target_of_council_task = task_kurultai_fertility_2
					is_target_of_council_task = task_kurultai_fertility_3
				}
			}	
		}
		custom_tooltip = {
			text = task_kurultai_exploited_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_exploit_area_1
					is_target_of_council_task = task_kurultai_exploit_area_2
					is_target_of_council_task = task_kurultai_exploit_area_3
				}
			}	
		}
	}

	effect_desc = { 
		desc = task_kurultai_fertility_effect_desc 
		desc = task_kurultai_fertility_gain_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Increase Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship >= low_skill_rating
					}
				}
				desc = task_kurultai_fertility_increase_fertility
			}
			# Increase Popular Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						stewardship >= high_skill_rating
					}
				}
				desc = task_kurultai_fertility_county_opinion
			}
			## Negative
			# Lose Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= very_high_skill_rating
					}
				}
				desc = task_kurultai_fertility_reduce_fertility
			}
			# Prestige Loss
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= decent_skill_rating
					}
				}
				desc = task_kurultai_fertility_lose_prestige
			}
		}
	}

	monthly_on_action = task_manage_fertility_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 500
		if = { # 
			limit = {
				scope:councillor = { highest_skill = stewardship }
			}
			add = 500
		}
		if = {
			limit = {
				capital_county ?= { 
					uses_county_fertility = yes
					county_fertility <= 50 
				}
			}
			add = 1000
		}
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_manage_fertility
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 10000
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_fertility_1
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_fertility_2
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_fertility_3
					}
				}
				divide = 4
			}
		}
	}
}

task_kurultai_control_4 = {
	position = councillor_kurultai_4

	task_type = task_type_county
	county_target = realm
	ai_county_target = domain

	task_progress = task_progress_value
	task_current_value = scope:councillor_liege.marshal_increase_control_current_progress
	task_max_value = 100 # Highest possible county control

	highlight_own_realm = yes
	restart_on_finish = yes # If it "finishes" by removing a corruption modifier, there'll still be control to regain

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_control.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	effect_desc = {
		desc = task_kurultai_control_effect_desc
		desc = task_kurultai_increase_control_effect_desc
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					scope:councillor_liege = {
						any_active_accolade = {
							has_accolade_parameter = accolade_increase_control_bonus
						}
					}
				}
				desc = task_increase_control_acclaimed_knight_subdues_peasantry
			}
			triggered_desc = {
				trigger = {
					martial > mediocre_skill_rating
				}
				desc = task_increase_control_increase_opinion
			}
			triggered_desc = {
				trigger = {
					martial > mediocre_skill_rating
				}
				desc = task_increase_control_baron_opinion_increase
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_lose_opinion
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_lose_control
			}
			triggered_desc = {
				trigger = {
					martial < high_skill_rating
				}
				desc = task_increase_control_baron_opinion_loss
			}
		}
	}
	
	# TOTAL PROGRESS MUST MATCH THE TOTAL OF THE COUNTY MODIFIERS BELOW
		# Add all new progress values to the script value marshal_increase_control_total
		# Note that for Increase Control, the County Modifiers apply the actual values, while progress is for player info only
	progress = {
		value = 0
		add = {
			value = marshal_increase_control_base
			desc = INCREASE_CONTROL_BASE
		}
		add = {
			value = scope:councillor.marshal_increase_county_control_monthly_change
			desc = SCALED_COUNCILLOR_MARTIAL_VALUE
		}
		# Relation Bonuses/Penalties
		if = { # Friend
			limit = {
				scope:councillor_liege = {
					has_relation_friend = scope:councillor
					NOT = { has_relation_best_friend = scope:councillor }
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_friend_bonus
				desc = COUNCILLOR_IS_YOUR_FRIEND
			}
		}
		if = { # Best Friend
			limit = {
				scope:councillor_liege = {
					has_relation_best_friend = scope:councillor
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_best_friend_bonus
				desc = COUNCILLOR_IS_YOUR_BEST_FRIEND
			}
		}
		if = { # Rival
			limit = {
				scope:councillor_liege = {
					has_relation_rival = scope:councillor
					NOT = { has_relation_nemesis = scope:councillor }
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_rival_bonus
				desc = COUNCILLOR_IS_YOUR_RIVAL
			}
		}
		if = { # Nemesis
			limit = {
				scope:councillor_liege = {
					has_relation_nemesis = scope:councillor
				}
			}
			add = {
				value = scope:councillor.marshal_increase_control_monthly_increase_nemesis_bonus
				desc = COUNCILLOR_IS_YOUR_NEMESIS
			}
		}
		if = {
			limit = {
				scope:councillor_liege = { has_perk = strict_organization_perk }
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_perk_bonus_monthly_change
				desc = INCREASE_CONTROL_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_erudition_bonus_monthly_change
				desc = ERUDITION_DYNASTY_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_family_business_bonus = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_family_business_bonus_monthly_change
				desc = FAMILY_BUSINESS_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_consulted_house_bonus_monthly_change
				desc = CONSULTED_HOUSE_BONUS_VALUE
			}
		}
		if = {
			limit = {
				scope:councillor = { has_character_modifier = event_bonus_to_county_control }
			}
			add = {
				value = scope:councillor.marshal_increase_county_control_experience_bonus_monthly_change
				desc = INCREASE_COUNTY_CONTROL_EXPERIENCE_BONUS_VALUE
			}
		}
		if = {
			limit = { exists = scope:county }
			multiply = {
				value = scope:county.monthly_county_control_growth_factor
				desc = MARSHAL_COUNTY_SPEED_MODIFIERS
			}
		}
		if = {
			limit = {
				exists = scope:county
				scope:county = { has_county_modifier = petition_liege_county_control_modifier }
			}
			add = {
				value = scope:councillor.petition_liege_county_control_modifier_value
				desc = MARSHAL_INCREASE_CONTROL_LOCAL_COUNTY_MODIFIERS
			}
		}
		#EP3
		if = {
			limit = {
				scope:councillor_liege = {
					employs_court_position = court_jester_court_position
					court_position:court_jester_court_position = {
						has_character_flag = famous_mime_control
					}
				}
			}
			add = {
				value = scope:councillor_liege.court_position:court_jester_court_position.marshal_court_jester_contribution_value
				desc = MARSHAL_INCREASE_CONTROL_MIME_MODIFIER
			}
		}
	}

	full_progress = marshal_increase_control_full_progress
	custom_other_loc = MARSHAL_COUNTY_SPEED_OTHER

	potential_county = {
		scope:county = {
			is_landless_type_title = no
			custom_description = {
				text = potential_county_control_task_trigger
				OR = {
					has_county_corruption_trigger = yes
					county_control < full_county_control
				}
			}
			# If the growth factor is 0, no amount of trying to control helps
			# (happens when the county is under siege/occupied most likely)
			monthly_county_control_growth_factor > 0
			custom_tooltip = {
				text = potential_county_control_task_only_one_target
				scope:county = {
					NOR = {
						is_target_of_council_task = task_kurultai_control_1
						is_target_of_council_task = task_kurultai_control_2
						is_target_of_council_task = task_kurultai_control_3
					}
				}
			}
		}
	}

	county_modifier = {
		name = marshal_increase_control_modifier
		monthly_county_control_growth_add = 1
		scale = marshal_increase_control_total
	}

	on_start_task_county = {
		#spawn a task contract
		if = {
			limit = {
				scope:councillor_liege = {
					is_independent_ruler = yes					
				}
				any_player = {
					is_landless_adventurer = yes
					is_within_diplo_range = { CHARACTER = scope:councillor }
					any_character_task_contract = {
						has_task_contract_type = laamp_help_increase_control_contract
						count <= council_task_contracts_limit_value
					}
					can_create_task_contract = {
						type_name = laamp_help_increase_control_contract
						employer = scope:councillor
					}
					save_temporary_scope_as = player_laamp
				}
			}
			scope:player_laamp = {
				create_task_contract = {
					task_contract_type = laamp_help_increase_control_contract
					task_contract_tier = scope:councillor.task_contract_tier_value
					location = scope:county.title_province
					task_contract_employer = scope:councillor
					target = scope:councillor.liege
					destination = scope:county.title_province
					save_scope_as = task_contract					
				}
			}
		}
	}
	on_finish_task_county = {
		if = {
			limit = {
				scope:county = {
					has_county_corruption_trigger = yes
				}
			}
			scope:county = {
				marshal_remove_random_county_corruption_modifier_effect = yes
				change_county_control = -25
			}
		}
	}

	monthly_on_action = increase_control_monthly_on_action

	on_monthly_county = {
		random = {
			chance = scope:councillor.marshal_remove_county_corruption_chance
			scope:county = {
				marshal_remove_random_county_corruption_modifier_effect = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 1000 # Highest prio
		if = { # Keep doing Organize levies if you're at war
			limit = {
				scope:councillor_liege = {
					is_at_war = no
				}
			}
			add = 19000
		}
		if = { # Keep doing Organize levies if you're at war
			limit = {
				is_performing_council_task = task_organize_levies
				scope:councillor_liege = {
					is_at_war = yes
				}
			}
			add = -1000
		}
		if = { # Stop doing this if Organize levies could help you lose less gold during a war
			limit = {
				NOT = {
					is_performing_council_task = task_organize_levies
				}
				scope:councillor_liege = {
					is_at_war = yes
					monthly_character_income < monthly_character_expenses
				}
			}
			add = -1000
		}
	}
}

task_kurultai_court_astrologer_4 = {
	position = councillor_kurultai_4

	task_type = task_type_general
	task_progress = task_progress_infinite
	
	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_court_astrologer.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		liege_or_court_owner ?= {
			employs_court_position = court_astrologer_court_position
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	council_owner_modifier = {
		name = task_kurultai_court_astrologer_modifier
		monthly_piety_gain_mult = 0.01
		scale = kurultai_court_astrologer_piety_final_value
	}

	effect_desc = { 
		desc = task_kurultai_court_astrologer_effect_desc 
		desc = task_kurultai_court_astrologer_piety_desc
		desc = task_kurultai_court_astrologer_aptitude_desc
		# You have the Zealous Proselytizer perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = zealous_proselytizer_perk }
			}
			desc = task_kurultai_court_astrologer_zealous_proselytizer_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Piety 
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning >= low_skill_rating
					}
				}
				desc = task_kurultai_astrologer_increase_piety
			}
			# Gain Astrologer Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						learning >= high_skill_rating
					}
				}
				desc = task_kurultai_astrologer_increase_opinion
			}
			## Negative
			# Lose Piety
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning <= very_high_skill_rating
					}
				}
				desc = task_kurultai_astrologer_reduce_piety
			}
			# Lose Astrologer Opinion
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						learning <= decent_skill_rating
					}
				}
				desc = task_kurultai_astrologer_reduce_opinion
			}
		}
	}

	monthly_on_action = task_manage_astrologer_on_action

	ai_will_do = {
		value = 250
		if = { # 
			limit = {
				scope:councillor = { highest_skill = learning }
			}
			add = 500
		}
		if = {
			limit = {
				piety < 50
			}
			add = 1000
		}
	}
}

task_kurultai_domestic_affairs_4 = {
	position = councillor_kurultai_4
	
	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_domestic_affairs.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_domestic_affairs_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_1
					}
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_2
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_domestic_affairs_3
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	effect_desc = {
		desc = task_kurultai_domestic_affairs_effect_desc
		# Direct Vassal Opinion
		desc = task_domestic_affairs_direct_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			desc = chancellor_domestic_affairs_opinion_pandidakterion_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_opinion_food_bonus_desc
		}
		# Parochial Vassal Opinion
		desc = task_domestic_affairs_parochial_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			desc = chancellor_domestic_affairs_opinion_pandidakterion_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_opinion_food_bonus_desc
		}
		# Tyranny Loss
		desc = task_domestic_affairs_tyranny_effect_desc
		triggered_desc = {
			trigger = {
				liege = { has_perk = chains_of_loyalty_perk }
			}
			desc = task_domestic_affairs_tyranny_chains_of_loyalty_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_domestic_affairs_tyranny_bureaucrats_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_domestic_affairs_tyranny_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_domestic_affairs_tyranny_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_character_flag = food_improves_opinion
				}
			}
			desc = chancellor_domestic_affairs_tyranny_food_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_improved_vassal_opinion
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
					liege = {
						any_vassal = {
							government_has_flag = government_is_feudal
							primary_title.tier > tier_barony
						}
					}
				}
				desc = task_increase_control_improve_vassal_contract
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_end_internal_war
			}
			triggered_desc = {
				trigger = {
					diplomacy > mediocre_skill_rating
				}
				desc = task_increase_control_force_vassal_partition
			}
			triggered_desc = {
				trigger = {
					diplomacy < high_skill_rating
				}
				desc = task_increase_control_lose_vassal_opinion
			}
			triggered_desc = {
				trigger = {
					diplomacy < high_skill_rating
					liege = {
						any_vassal = {
							government_has_flag = government_is_feudal
							primary_title.tier > tier_barony
						}
					}
				}
				desc = task_increase_control_worsen_contract
			}
		}
	}

	on_start_task = {
		liege = {
			set_variable = {
				name = chancellor_domestic_affairs_opinion_value
				value = 0
			}
		}
	}

	on_cancel_task = {
		if = {
			limit = {
				is_alive = yes
				has_variable = chancellor_domestic_affairs_opinion_value
			}
			remove_variable = chancellor_domestic_affairs_opinion_value
		}
	}

	council_owner_modifier = {
		name = task_domestic_affairs_opinion_modifier
		direct_vassal_opinion = 1
		scale = chancellor_domestic_affairs_opinion_scale
	}

	council_owner_modifier = {
		name = task_domestic_affairs_parochial_opinion_modifier
		parochial_opinion = 1
		scale = chancellor_domestic_affairs_opinion_scale
	}

	council_owner_modifier = {
		name = task_domestic_affairs_opinion_modifier
		tyranny_loss_mult = 0.01
		scale = chancellor_domestic_affairs_tyranny_total
	}

	monthly_on_action = task_domestic_affairs_side_effects

	on_monthly = {
		if = {
			limit = {
				liege = { is_ai = no }
			}
			if = {
				limit = {
					liege = { 
						has_variable = chancellor_domestic_affairs_opinion_value 
					}
				}
				liege = {
					if = {
						limit = {
							var:chancellor_domestic_affairs_opinion_value < root.chancellor_domestic_affairs_opinion_max
						}
						change_variable = {
							name = chancellor_domestic_affairs_opinion_value
							add = root.chancellor_domestic_affairs_monthly_increase
						}
					}
					if = {
						limit = {
							var:chancellor_domestic_affairs_opinion_value > root.chancellor_domestic_affairs_opinion_max
						}
						set_variable = {
							name = chancellor_domestic_affairs_opinion_value
							value = root.chancellor_domestic_affairs_opinion_max
						}
					}
				}	
			}
			else = {
				liege = {
					set_variable = {
						name = chancellor_domestic_affairs_opinion_value
						value = 0
					}
				}
			}
		}
	}

	ai_will_do = {
		value = 0
		if = { # Do this if you have a faction against you, every little bit helps
			limit = {
				scope:councillor_liege = {
					any_targeting_faction = {
						OR = {
							faction_is_type = independence_faction
							faction_is_type = nation_fracturing_faction
							faction_is_type = liberty_faction
							faction_is_type = claimant_faction
						}
					}
				}
			}
			add = 1000
		}
		if = { # Get rid of tyranny
			limit = {
				scope:councillor_liege = {
					OR = {
						AND = { # Somewhat rational characters prefer this over the prestige of foreign affairs
							ai_rationality > -25
							NOT = { has_trait = arrogant }
							tyranny >= 5
						}
						AND = { # If you're arrogant or deeply irrational, it'll take a long time for you to realize
							OR = {
								ai_rationality <= -25
								has_trait = arrogant
							}
							tyranny >= 15
						}
					}
				}
			}
			add = 500
		}
	}
}

task_kurultai_exploit_area_4 = {
	position = councillor_kurultai_4

	task_type = task_type_county
	county_target = domain
	ai_county_target = domain
	highlight_own_realm = yes

	task_progress = task_progress_value
	task_current_value = scope:county.county_fertility
	task_max_value = 100.0001 # Highest possible county fertility

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_exploit_area.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	potential_county = {
		exists = scope:county.holder
		scope:county = {
			is_landless_type_title = no
			county_fertility > 0
		}
		trigger_if = {
			limit = {
				scope:county.holder = { is_ai = yes }
			}
			NOT = { scope:county = scope:county.holder.capital_county }
		}
		custom_tooltip = {
			text = task_kurultai_use_fertility
			scope:county.holder = { 
				OR = {
					government_has_flag = government_is_nomadic 
					government_has_flag = government_is_herder
				}
			}
		}
		custom_tooltip = {
			text = task_kurultai_fertility_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_fertility_1
					is_target_of_council_task = task_kurultai_fertility_2
					is_target_of_council_task = task_kurultai_fertility_3
				}
			}	
		}
		custom_tooltip = {
			text = task_kurultai_exploited_only_one_target
			scope:county = {
				NOR = {
					is_target_of_council_task = task_kurultai_exploit_area_1
					is_target_of_council_task = task_kurultai_exploit_area_2
					is_target_of_council_task = task_kurultai_exploit_area_3
				}
			}	
		}
	}

	county_modifier = {
		name = task_kurultai_exploit_modifier
		county_fertility_decline_add = -1
		scale = kurultai_exploit_area_fertility_final_value
	}

	council_owner_modifier = {
		name = task_kurultai_exploit_modifier
		monthly_income_from_herd_mult = 0.01
		scale = kurultai_exploit_area_income_final_value
	}

	effect_desc = {
		desc = task_kurultai_exploit_effect_desc
		desc = task_kurultai_exploit_fertility_desc
		desc = task_kurultai_exploit_income_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Gold
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship >= low_skill_rating
					}
				}
				desc = task_kurultai_exploit_gain_gold
			}
			# Gain Dread
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						stewardship >= high_skill_rating
					}
				}
				desc = task_kurultai_exploit_gain_dread
			}
			## Negative
			# Reduce Fertility
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= very_high_skill_rating
					}
				}
				desc = task_kurultai_exploit_reduce_fertility
			}
			# Reduce County Opinion
			triggered_desc = {
				trigger = {
					scope:councillor = {
						stewardship <= decent_skill_rating
					}
				}
				desc = task_kurultai_exploit_lose_county_opinion
			}
		}
	}

	monthly_on_action = task_exploit_area_on_action

	is_valid_showing_failures_only = {
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	ai_will_do = {
		value = 0
		# Only do this if they are running out of money
		if = {
			limit = {
				gold < 15
			}
			add = 2500
		}
	}
}

task_kurultai_raider_4 = {
	position = councillor_kurultai_4

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_raider.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	council_owner_modifier = {
		name = task_kurultai_raider_modifier
		hostile_county_attrition_raiding = -0.01
		max_loot_mult = 0.01
		scale = kurultai_organize_raiders_loot_final_value
	}

	council_owner_modifier = {
		name = task_kurultai_raider_modifier
		raid_speed = 0.01
		movement_speed_land_raiding = 0.01
		scale = kurultai_organize_raiders_raid_final_value
	}

	effect_desc = {
		desc = task_kurultai_control_effect_desc
		desc = task_kurultai_raider_loot_desc
		desc = task_kurultai_raider_attrition_desc
		desc = task_kurultai_raider_raiding_desc
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Prestige
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial >= low_skill_rating
					}
				}
				desc = task_kurultai_raiders_gain_prestige
			}
			# Gain Dread
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						martial >= high_skill_rating
					}
				}
				desc = task_kurultai_raiders_gain_dread
			}
			## Negative
			# Lose Prestige
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial <= very_high_skill_rating
					}
				}
				desc = task_kurultai_raiders_lose_prestige
			}
			# Lose Dread
			triggered_desc = {
				trigger = {
					scope:councillor = {
						martial <= decent_skill_rating
					}
				}
				desc = task_kurultai_raiders_lose_dread
			}
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_raiders_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_raider_1
					}
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_raider_2
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_raider_3
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	monthly_on_action = task_organize_raiders_on_action

	ai_will_do = {
		value = 100
		if = { # 
			limit = {
				scope:councillor = { highest_skill = martial }
			}
			add = 500
		}
		if = {
			limit = {
				any_army = {
					is_raid_army = yes
				}
			}
			add = 1000
		}
	}
}

task_kurultai_culture_4 = {
	position = councillor_kurultai_4
	
	task_type = task_type_general
	task_progress = task_progress_infinite
	
	asset = {
		icon = "gfx/interface/icons/council_task_types/task_kurultai_culture.dds"
		background = "gfx/interface/buttons/task_button_kurultai_bg.dds"
		frame = "gfx/interface/buttons/task_button_kurultai_frame.dds"
		glow = "gfx/interface/buttons/task_button_kurultai_glow.dds"
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = task_kurultai_culture_only_one_target
			liege_or_court_owner = {
				NOR = {
					cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_culture_1
					}
					cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_culture_2
					}
					cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_culture_3
					}
				}	
			}
		}
		
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	on_start_task = {
		liege = {
			set_variable = {
				name = kurultai_culture_variable_value
				value = 0
			}
		}
	}

	on_cancel_task = {
		if = {
			limit = {
				is_alive = yes
				has_variable = kurultai_culture_variable_value
			}
			remove_variable = kurultai_culture_variable_value
		}
	}

	on_monthly = {
		if = {
			limit = {
				liege = { is_ai = no }
			}
			if = {
				limit = {
					liege = { 
						has_variable = kurultai_culture_variable_value 
					}
				}
				liege = {
					if = {
						limit = {
							var:kurultai_culture_variable_value < root.kurultai_culture_max_value
						}
						change_variable = {
							name = kurultai_culture_variable_value
							add = root.kurultai_culture_monthly_increase
						}
					}
					if = {
						limit = {
							var:kurultai_culture_variable_value > root.kurultai_culture_max_value
						}
						set_variable = {
							name = kurultai_culture_variable_value
							value = root.kurultai_culture_max_value
						}
					}
				}	
			}
			else = {
				liege = {
					set_variable = {
						name = kurultai_culture_variable_value
						value = 0
					}
				}
			}
		}
	}

	effect_desc = { 
		desc = task_kurultai_court_astrologer_effect_desc 
		desc = task_kurultai_culture_cooldown_effect_desc
		# You have the Of the People perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = of_the_people_perk }
			}
			desc = task_kurultai_culture_1_of_the_people_bonus_desc
		}
		desc = task_kurultai_culture_hybridization_effect_desc
		# You have the Of the People perk
		triggered_desc = {
			trigger = {
				liege = { has_perk = of_the_people_perk }
			}
			desc = task_kurultai_culture_1_of_the_people_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			## Positive
			# Gain Cultural Acceptance 
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning >= low_skill_rating
					}
				}
				desc = task_kurultai_cultures_increase_acceptance
			}
			# Gain Different Culture Opinion
			triggered_desc = {
				trigger = {
					exists = root.capital_province
					scope:councillor = {
						learning >= high_skill_rating
					}
				}
				desc = task_kurultai_cultures_increase_opinion
			}
			## Negative
			# Lose Cultural Acceptance
			triggered_desc = {
				trigger = {
					scope:councillor = {
						learning <= very_high_skill_rating
					}
				}
				desc = task_kurultai_cultures_decrease_acceptance
			}
			# Lose Different Opinion
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:councillor = {
						learning <= decent_skill_rating
					}
				}
				desc = task_kurultai_cultures_decrease_opinion
			}
		}
	}

	monthly_on_action = task_explore_cultures_on_action

	ai_will_do = {
		value = 0 # They will never do this
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_explore_cultures
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 10000
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_1 ?= {
						is_performing_council_task = task_kurultai_culture_1
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_2 ?= {
						is_performing_council_task = task_kurultai_culture_2
					}
				}
				divide = 4
			}
			if = {
				limit = {
					scope:councillor_liege.cp:councillor_kurultai_3 ?= {
						is_performing_council_task = task_kurultai_culture_3
					}
				}
				divide = 4
			}
		}
	}
}

